Fix contacts permission not being asked anymore after fresh install

This commit is contained in:
Sylvain Berfini 2016-08-09 15:49:50 +02:00
parent 225cb8e1a5
commit 4b08094a4a
3 changed files with 12 additions and 5 deletions

View file

@ -17,7 +17,6 @@ size=qvga
tunnel=disabled tunnel=disabled
push_notification=1 push_notification=1
auto_start=1 auto_start=1
debug=0
[tunnel] [tunnel]
host= host=
@ -25,4 +24,4 @@ port=443
[misc] [misc]
log_collection_upload_server_url=https://www.linphone.org:444/lft.php log_collection_upload_server_url=https://www.linphone.org:444/lft.php
file_transfer_server_url=https://www.linphone.org:444/lft.php file_transfer_server_url=https://www.linphone.org:444/lft.php

View file

@ -1167,7 +1167,7 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
} }
private boolean willContactsPermissionBeAsked() { private boolean willContactsPermissionBeAsked() {
return LinphonePreferences.instance().firstTimeAskingForPermission(Manifest.permission.READ_CONTACTS) || ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.READ_CONTACTS); return LinphonePreferences.instance().firstTimeAskingForPermission(Manifest.permission.READ_CONTACTS, false) || ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.READ_CONTACTS);
} }
public void checkAndRequestWriteContactsPermission() { public void checkAndRequestWriteContactsPermission() {

View file

@ -1326,13 +1326,21 @@ public class LinphonePreferences {
} }
public boolean firstTimeAskingForPermission(String permission) { public boolean firstTimeAskingForPermission(String permission) {
return firstTimeAskingForPermission(permission, true);
}
public boolean firstTimeAskingForPermission(String permission, boolean toggle) {
boolean firstTime = getConfig().getBool("app", permission, true); boolean firstTime = getConfig().getBool("app", permission, true);
if (firstTime) { if (toggle) {
getConfig().setBool("app", permission, false); permissionHasBeenAsked(permission);
} }
return firstTime; return firstTime;
} }
public void permissionHasBeenAsked(String permission) {
getConfig().setBool("app", permission, false);
}
public boolean isDeviceRingtoneEnabled() { public boolean isDeviceRingtoneEnabled() {
int readExternalStorage = mContext.getPackageManager().checkPermission(Manifest.permission.READ_EXTERNAL_STORAGE, mContext.getPackageName()); int readExternalStorage = mContext.getPackageManager().checkPermission(Manifest.permission.READ_EXTERNAL_STORAGE, mContext.getPackageName());
return getConfig().getBool("app", "device_ringtone", true) && readExternalStorage == PackageManager.PERMISSION_GRANTED; return getConfig().getBool("app", "device_ringtone", true) && readExternalStorage == PackageManager.PERMISSION_GRANTED;