Android 6+ Permissions #3
This commit is contained in:
parent
dd02fcaa85
commit
1967602c70
2 changed files with 10 additions and 7 deletions
|
@ -41,8 +41,8 @@ public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
private static KeepAliveReceiver keepAliveReceiver;
|
private static KeepAliveReceiver keepAliveReceiver;
|
||||||
|
|
||||||
static final Integer STORAGE = 0x1;
|
static final Integer CASE_STORAGE = 0x1;
|
||||||
static final Integer SMS = 0x2;
|
static final Integer CASE_SMS = 0x2;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -52,7 +52,7 @@ public class MainActivity extends AppCompatActivity {
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
checkEula();
|
checkEula();
|
||||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1) {
|
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)
|
if (Config.logFunctionCalls)
|
||||||
log.debug("onCreate");
|
log.debug("onCreate");
|
||||||
|
@ -191,12 +191,13 @@ public class MainActivity extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//check for sms permission if enable in prefernces
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventPreferenceChange ev) {
|
public void onStatusEvent(final EventPreferenceChange ev) {
|
||||||
SharedPreferences smssettings = PreferenceManager.getDefaultSharedPreferences(this);
|
SharedPreferences smssettings = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
if (smssettings.getBoolean("smscommunicator_remotecommandsallowed", false)) {
|
if (smssettings.getBoolean("smscommunicator_remotecommandsallowed", false)) {
|
||||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1) {
|
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){
|
if(ActivityCompat.checkSelfPermission(this, permissions[0]) == PackageManager.PERMISSION_GRANTED){
|
||||||
switch (requestCode) {
|
switch (requestCode) {
|
||||||
case 1:
|
case 1:
|
||||||
|
//show dialog after permission is granted
|
||||||
AlertDialog.Builder alert = new AlertDialog.Builder(this);
|
AlertDialog.Builder alert = new AlertDialog.Builder(this);
|
||||||
alert.setTitle("Restart");
|
alert.setMessage(R.string.alert_dialog_storage_permission_text);
|
||||||
alert.setMessage("Please Restart Android APS \notherwise Android APS will not work proper!");
|
alert.setPositiveButton(R.string.alert_dialog_positive_button,null);
|
||||||
alert.setPositiveButton("OK",null);
|
|
||||||
alert.show();
|
alert.show();
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
|
|
|
@ -14,6 +14,8 @@
|
||||||
<string name="danar_useextended_title">Use extended boluses for >200%</string>
|
<string name="danar_useextended_title">Use extended boluses for >200%</string>
|
||||||
<string name="danar_bt_name_title">DanaR Bluetooth device</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="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_objective_label_string">Objective:</string>
|
||||||
<string name="objectives_gate_label_string">Gate:</string>
|
<string name="objectives_gate_label_string">Gate:</string>
|
||||||
|
|
Loading…
Reference in a new issue