avoid showing some warnings if READ_CONTACTS permission isnt given
This commit is contained in:
parent
fec69ff4c3
commit
8f913867f4
1 changed files with 8 additions and 0 deletions
|
|
@ -433,6 +433,10 @@ fun Context.getNameAndPhotoFromPhoneNumber(number: String): NamePhoto? {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Context.getNameFromPhoneNumber(number: String): String {
|
fun Context.getNameFromPhoneNumber(number: String): String {
|
||||||
|
if (!hasPermission(PERMISSION_READ_CONTACTS)) {
|
||||||
|
return number
|
||||||
|
}
|
||||||
|
|
||||||
val uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number))
|
val uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number))
|
||||||
val projection = arrayOf(
|
val projection = arrayOf(
|
||||||
PhoneLookup.DISPLAY_NAME
|
PhoneLookup.DISPLAY_NAME
|
||||||
|
|
@ -453,6 +457,10 @@ fun Context.getNameFromPhoneNumber(number: String): String {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Context.getPhotoUriFromPhoneNumber(number: String): String {
|
fun Context.getPhotoUriFromPhoneNumber(number: String): String {
|
||||||
|
if (!hasPermission(PERMISSION_READ_CONTACTS)) {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
val uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number))
|
val uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number))
|
||||||
val projection = arrayOf(
|
val projection = arrayOf(
|
||||||
PhoneLookup.PHOTO_URI
|
PhoneLookup.PHOTO_URI
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue