From 5d27a28dc90546cf8c6695a3044d8794aac928a1 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 22 May 2018 20:02:38 +0200 Subject: [PATCH] SW eula --- .../nightscout/androidaps/MainActivity.java | 19 +++++++------ .../androidaps/setupwizard/SWDefinition.java | 27 ++++++++++++++++--- .../setupwizard/SetupWizardActivity.java | 3 +++ 3 files changed, 38 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.java b/app/src/main/java/info/nightscout/androidaps/MainActivity.java index c3231814db..555eef8267 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.java @@ -65,6 +65,10 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + + if (Config.logFunctionCalls) + log.debug("onCreate"); + Iconify.with(new FontAwesomeModule()); LocaleHelper.onCreate(this, "en"); setContentView(R.layout.activity_main); @@ -74,16 +78,9 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe if (!SP.getBoolean(R.string.key_setupwizard_processed, false)) { Intent intent = new Intent(this, SetupWizardActivity.class); startActivity(intent); + finish(); } - checkEula(); - AndroidPermission.askForStoragePermission(this); - AndroidPermission.askForBatteryOptimizationPermission(this); - doMigrations(); - - if (Config.logFunctionCalls) - log.debug("onCreate"); - onStatusEvent(new EventSetWakeLock(SP.getBoolean("lockscreen", false))); registerBus(); @@ -214,6 +211,12 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe @Override protected void onResume() { super.onResume(); + + checkEula(); + AndroidPermission.askForStoragePermission(this); + AndroidPermission.askForBatteryOptimizationPermission(this); + doMigrations(); + AndroidPermission.askForSMSPermissions(this); AndroidPermission.askForLocationPermissions(this); MainApp.bus().post(new EventFeatureRunning(EventFeatureRunning.Feature.MAIN)); diff --git a/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.java b/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.java index fbff517c32..54be2153f1 100644 --- a/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.java +++ b/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.java @@ -111,35 +111,56 @@ public class SWDefinition { return SP.contains(R.string.key_language); }) ) + .add(new SWScreen(R.string.end_user_license_agreement) + .skippable(false) + .add(new SWInfotext() + .label(R.string.end_user_license_agreement_text)) + .add(new SWBreak()) + .add(new SWButton() + .text(R.string.end_user_license_agreement_i_understand) + .visibility(() -> !SP.getBoolean(R.string.key_i_understand, false)) + .action(() -> { + SP.putBoolean(R.string.key_i_understand, true); + MainApp.bus().post(new EventSWUpdate(false)); + })) + .visibility(() -> !SP.getBoolean(R.string.key_i_understand, false)) + .validator(() -> SP.getBoolean(R.string.key_i_understand, false)) + ) .add(new SWScreen(R.string.permission) - .skippable(true) + .skippable(false) .add(new SWInfotext() .label(String.format(MainApp.gs(R.string.needwhitelisting), MainApp.gs(R.string.app_name)))) .add(new SWBreak()) .add(new SWButton() .text(R.string.askforpermission) + .visibility(() -> Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !AndroidPermission.checkForPermission(getActivity(), Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS)) .action(() -> AndroidPermission.askForPermission(getActivity(), Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS, AndroidPermission.CASE_BATTERY))) .visibility(() -> Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !AndroidPermission.checkForPermission(getActivity(), Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS)) + .validator(() -> !(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !AndroidPermission.checkForPermission(getActivity(), Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS))) ) .add(new SWScreen(R.string.permission) - .skippable(true) + .skippable(false) .add(new SWInfotext() .label(MainApp.gs(R.string.needlocationpermission))) .add(new SWBreak()) .add(new SWButton() .text(R.string.askforpermission) + .visibility(() -> Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !AndroidPermission.checkForPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION)) .action(() -> AndroidPermission.askForPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION, AndroidPermission.CASE_LOCATION))) .visibility(() -> Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !AndroidPermission.checkForPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION)) + .validator(() -> !(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !AndroidPermission.checkForPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION))) ) .add(new SWScreen(R.string.permission) - .skippable(true) + .skippable(false) .add(new SWInfotext() .label(MainApp.gs(R.string.needstoragepermission))) .add(new SWBreak()) .add(new SWButton() .text(R.string.askforpermission) + .visibility(() -> Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !AndroidPermission.checkForPermission(getActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE)) .action(() -> AndroidPermission.askForPermission(getActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE, AndroidPermission.CASE_STORAGE))) .visibility(() -> Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !AndroidPermission.checkForPermission(getActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE)) + .validator(() -> !(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !AndroidPermission.checkForPermission(getActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE))) ) .add(new SWScreen(R.string.nsclientinternal_title) .skippable(true) diff --git a/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.java b/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.java index fde19eafaa..3212a8c10f 100644 --- a/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.java @@ -70,6 +70,7 @@ public class SetupWizardActivity extends AppCompatActivity { } public void exitPressed(View view) { + SP.putBoolean(R.string.key_setupwizard_processed, true); OKDialog.showConfirmation(this, MainApp.gs(R.string.exitwizard), this::finish); } @@ -170,6 +171,7 @@ public class SetupWizardActivity extends AppCompatActivity { Intent intent = new Intent(this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); + finish(); } private int nextPage() { @@ -212,6 +214,7 @@ public class SetupWizardActivity extends AppCompatActivity { } } } + updateButtons(); } }