move askForStoragePermission

This commit is contained in:
Milos Kozak 2018-05-22 18:59:34 +02:00
parent 2626e5bb63
commit 250f9f74a0
2 changed files with 12 additions and 9 deletions

View file

@ -1,6 +1,5 @@
package info.nightscout.androidaps; package info.nightscout.androidaps;
import android.Manifest;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
@ -72,19 +71,16 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
menuButton = (ImageButton) findViewById(R.id.overview_menuButton); menuButton = (ImageButton) findViewById(R.id.overview_menuButton);
menuButton.setOnClickListener(this); menuButton.setOnClickListener(this);
checkEula();
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1) {
AndroidPermission.askForPermission(this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE}, AndroidPermission.CASE_STORAGE);
}
AndroidPermission.askForBatteryOptimizationPermission(this);
doMigrations();
if (!SP.getBoolean(R.string.key_setupwizard_processed, false)) { if (!SP.getBoolean(R.string.key_setupwizard_processed, false)) {
Intent intent = new Intent(this, SetupWizardActivity.class); Intent intent = new Intent(this, SetupWizardActivity.class);
startActivity(intent); startActivity(intent);
} }
checkEula();
AndroidPermission.askForStoragePermission(this);
AndroidPermission.askForBatteryOptimizationPermission(this);
doMigrations();
if (Config.logFunctionCalls) if (Config.logFunctionCalls)
log.debug("onCreate"); log.debug("onCreate");

View file

@ -60,6 +60,13 @@ public class AndroidPermission {
} }
} }
public static synchronized void askForStoragePermission(Activity activity) {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1) {
AndroidPermission.askForPermission(activity, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE}, AndroidPermission.CASE_STORAGE);
}
}
public static synchronized void askForLocationPermissions(Activity activity) { public static synchronized void askForLocationPermissions(Activity activity) {
if (askForLocation) { //only when settings were changed an MainActivity resumes. if (askForLocation) { //only when settings were changed an MainActivity resumes.
askForLocation = false; askForLocation = false;