mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
Merge pull request #1120 from deltachat/tweak-welcome
simplify routing to welcome-activity
This commit is contained in:
@@ -17,15 +17,16 @@ public abstract class PassphraseRequiredActionBarActivity extends BaseActionBarA
|
||||
|
||||
public static final String LOCALE_EXTRA = "locale_extra";
|
||||
|
||||
private static final int STATE_NORMAL = 0;
|
||||
private static final int STATE_NEEDS_CONFIGURE = 1;
|
||||
|
||||
@Override
|
||||
protected final void onCreate(Bundle savedInstanceState) {
|
||||
Log.w(TAG, "onCreate(" + savedInstanceState + ")");
|
||||
onPreCreate();
|
||||
|
||||
routeApplicationState();
|
||||
if (!DcHelper.isConfigured(getApplicationContext())) {
|
||||
Intent intent = new Intent(this, WelcomeActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
@@ -86,38 +87,4 @@ public abstract class PassphraseRequiredActionBarActivity extends BaseActionBarA
|
||||
.commitAllowingStateLoss();
|
||||
return fragment;
|
||||
}
|
||||
|
||||
private void routeApplicationState() {
|
||||
Intent intent = getIntentForState(getApplicationState());
|
||||
if (intent != null) {
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
private Intent getIntentForState(int state) {
|
||||
switch (state) {
|
||||
case STATE_NEEDS_CONFIGURE: return getWelcomeIntent();
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
|
||||
private int getApplicationState() {
|
||||
boolean isConfigured = DcHelper.isConfigured(getApplicationContext());
|
||||
if (!isConfigured) {
|
||||
return STATE_NEEDS_CONFIGURE;
|
||||
} else {
|
||||
return STATE_NORMAL;
|
||||
}
|
||||
}
|
||||
|
||||
private Intent getWelcomeIntent() {
|
||||
return getRoutedIntent(WelcomeActivity.class, null);
|
||||
}
|
||||
|
||||
private Intent getRoutedIntent(Class<?> destination, @Nullable Intent nextIntent) {
|
||||
final Intent intent = new Intent(this, destination);
|
||||
if (nextIntent != null) intent.putExtra("next_intent", nextIntent);
|
||||
return intent;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user