Keep SetupActivity alive to check re-launching from launcher

Bug: 8336068
Change-Id: I183b8e3fd1b3898d5f8dbbb13a0c93c64341fc38
main
Tadashi G. Takaoka 2013-05-09 13:14:18 +09:00
parent b0aabbfbe0
commit 9ed322b40f
1 changed files with 32 additions and 18 deletions

View File

@ -63,7 +63,8 @@ public final class SetupActivity extends Activity implements View.OnClickListene
private static final int STEP_1 = 1; private static final int STEP_1 = 1;
private static final int STEP_2 = 2; private static final int STEP_2 = 2;
private static final int STEP_3 = 3; private static final int STEP_3 = 3;
private boolean mWasLanguageAndInputSettingsInvoked; private static final int STEP_LAUNCHING_IME_SETTINGS = 4;
private static final int STEP_BACK_FROM_IME_SETTINGS = 5;
private final SettingsPoolingHandler mHandler = new SettingsPoolingHandler(this); private final SettingsPoolingHandler mHandler = new SettingsPoolingHandler(this);
@ -83,7 +84,7 @@ public final class SetupActivity extends Activity implements View.OnClickListene
} }
switch (msg.what) { switch (msg.what) {
case MSG_POLLING_IME_SETTINGS: case MSG_POLLING_IME_SETTINGS:
if (SetupActivity.isThisImeEnabled(setupActivity)) { if (isThisImeEnabled(setupActivity)) {
setupActivity.invokeSetupWizardOfThisIme(); setupActivity.invokeSetupWizardOfThisIme();
return; return;
} }
@ -112,17 +113,7 @@ public final class SetupActivity extends Activity implements View.OnClickListene
RichInputMethodManager.init(this); RichInputMethodManager.init(this);
if (savedInstanceState == null) { if (savedInstanceState == null) {
mStepNumber = determineSetupStepNumber(); mStepNumber = determineSetupStepNumberFromLauncher();
if (mStepNumber == STEP_1 && !mWasLanguageAndInputSettingsInvoked) {
mStepNumber = STEP_WELCOME;
}
if (mStepNumber == STEP_3) {
// This IME already has been enabled and set as current IME.
// TODO: Implement tutorial.
invokeSettingsOfThisIme();
finish();
return;
}
} else { } else {
mStepNumber = savedInstanceState.getInt(STATE_STEP); mStepNumber = savedInstanceState.getInt(STATE_STEP);
} }
@ -265,7 +256,6 @@ public final class SetupActivity extends Activity implements View.OnClickListene
intent.setAction(Settings.ACTION_INPUT_METHOD_SETTINGS); intent.setAction(Settings.ACTION_INPUT_METHOD_SETTINGS);
intent.addCategory(Intent.CATEGORY_DEFAULT); intent.addCategory(Intent.CATEGORY_DEFAULT);
startActivity(intent); startActivity(intent);
mWasLanguageAndInputSettingsInvoked = true;
} }
private void invokeSubtypeEnablerOfThisIme() { private void invokeSubtypeEnablerOfThisIme() {
@ -313,6 +303,17 @@ public final class SetupActivity extends Activity implements View.OnClickListene
return myImi.getId().equals(currentImeId); return myImi.getId().equals(currentImeId);
} }
private int determineSetupStepNumberFromLauncher() {
final int stepNumber = determineSetupStepNumber();
if (stepNumber == STEP_1) {
return STEP_WELCOME;
}
if (stepNumber == STEP_3) {
return STEP_LAUNCHING_IME_SETTINGS;
}
return stepNumber;
}
private int determineSetupStepNumber() { private int determineSetupStepNumber() {
mHandler.cancelPollingImeSettings(); mHandler.cancelPollingImeSettings();
if (!isThisImeEnabled(this)) { if (!isThisImeEnabled(this)) {
@ -336,10 +337,14 @@ public final class SetupActivity extends Activity implements View.OnClickListene
mStepNumber = savedInstanceState.getInt(STATE_STEP); mStepNumber = savedInstanceState.getInt(STATE_STEP);
} }
private static boolean isInSetupSteps(final int stepNumber) {
return stepNumber >= STEP_1 && stepNumber <= STEP_3;
}
@Override @Override
protected void onRestart() { protected void onRestart() {
super.onRestart(); super.onRestart();
if (mStepNumber != STEP_WELCOME) { if (isInSetupSteps(mStepNumber)) {
mStepNumber = determineSetupStepNumber(); mStepNumber = determineSetupStepNumber();
} }
} }
@ -347,6 +352,15 @@ public final class SetupActivity extends Activity implements View.OnClickListene
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
if (mStepNumber == STEP_LAUNCHING_IME_SETTINGS) {
invokeSettingsOfThisIme();
mStepNumber = STEP_BACK_FROM_IME_SETTINGS;
return;
}
if (mStepNumber == STEP_BACK_FROM_IME_SETTINGS) {
finish();
return;
}
updateSetupStepView(); updateSetupStepView();
} }
@ -374,7 +388,7 @@ public final class SetupActivity extends Activity implements View.OnClickListene
@Override @Override
public void onWindowFocusChanged(final boolean hasFocus) { public void onWindowFocusChanged(final boolean hasFocus) {
super.onWindowFocusChanged(hasFocus); super.onWindowFocusChanged(hasFocus);
if (hasFocus && mStepNumber != STEP_WELCOME) { if (hasFocus && isInSetupSteps(mStepNumber)) {
mStepNumber = determineSetupStepNumber(); mStepNumber = determineSetupStepNumber();
updateSetupStepView(); updateSetupStepView();
} }