Android 6+ Permissions #3

This commit is contained in:
LadyViktoria 2016-11-25 10:13:27 +01:00 committed by AdrianLxM
parent dd02fcaa85
commit 1967602c70
2 changed files with 10 additions and 7 deletions

View file

@ -41,8 +41,8 @@ public class MainActivity extends AppCompatActivity {
private static KeepAliveReceiver keepAliveReceiver;
static final Integer STORAGE = 0x1;
static final Integer SMS = 0x2;
static final Integer CASE_STORAGE = 0x1;
static final Integer CASE_SMS = 0x2;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -52,7 +52,7 @@ public class MainActivity extends AppCompatActivity {
setContentView(R.layout.activity_main);
checkEula();
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1) {
askForPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, STORAGE);
askForPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, CASE_STORAGE);
}
if (Config.logFunctionCalls)
log.debug("onCreate");
@ -191,12 +191,13 @@ public class MainActivity extends AppCompatActivity {
}
}
//check for sms permission if enable in prefernces
@Subscribe
public void onStatusEvent(final EventPreferenceChange ev) {
SharedPreferences smssettings = PreferenceManager.getDefaultSharedPreferences(this);
if (smssettings.getBoolean("smscommunicator_remotecommandsallowed", false)) {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1) {
askForPermission(Manifest.permission.RECEIVE_SMS, SMS);
askForPermission(Manifest.permission.RECEIVE_SMS, CASE_SMS);
}
}
}
@ -213,10 +214,10 @@ public class MainActivity extends AppCompatActivity {
if(ActivityCompat.checkSelfPermission(this, permissions[0]) == PackageManager.PERMISSION_GRANTED){
switch (requestCode) {
case 1:
//show dialog after permission is granted
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle("Restart");
alert.setMessage("Please Restart Android APS \notherwise Android APS will not work proper!");
alert.setPositiveButton("OK",null);
alert.setMessage(R.string.alert_dialog_storage_permission_text);
alert.setPositiveButton(R.string.alert_dialog_positive_button,null);
alert.show();
break;
case 2:

View file

@ -14,6 +14,8 @@
<string name="danar_useextended_title">Use extended boluses for >200%</string>
<string name="danar_bt_name_title">DanaR Bluetooth device</string>
<string name="ns_sync_use_absolute_title">Always use basal absolute values</string>
<string name="alert_dialog_positive_button">OK</string>
<string name="alert_dialog_storage_permission_text">Please Restart Android APS \notherwise Android APS will not work proper!</string>
<string name="objectives_objective_label_string">Objective:</string>
<string name="objectives_gate_label_string">Gate:</string>