This commit is contained in:
Milos Kozak 2018-05-22 20:02:38 +02:00
parent 250f9f74a0
commit 5d27a28dc9
3 changed files with 38 additions and 11 deletions

View file

@ -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));

View file

@ -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)

View file

@ -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();
}
}