Fix unintentional setup step advance in orientation change

Bug: 8159728
Change-Id: I53e7d7c8fb5cc231ea94474b091e550f77ae8dab
main
Tadashi G. Takaoka 2013-05-15 16:07:56 +09:00
parent 769427cff2
commit 9b4a883e09
1 changed files with 16 additions and 4 deletions

View File

@ -61,6 +61,7 @@ public final class SetupWizardActivity extends Activity implements View.OnClickL
private SetupStepGroup mSetupStepGroup; private SetupStepGroup mSetupStepGroup;
private static final String STATE_STEP = "step"; private static final String STATE_STEP = "step";
private int mStepNumber; private int mStepNumber;
private boolean mNeedsToAdjustStepNumberToSystemState;
private static final int STEP_WELCOME = 0; private static final int STEP_WELCOME = 0;
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;
@ -159,9 +160,7 @@ public final class SetupWizardActivity extends Activity implements View.OnClickL
step2.setAction(new Runnable() { step2.setAction(new Runnable() {
@Override @Override
public void run() { public void run() {
// Invoke input method picker. invokeInputMethodPicker();
RichInputMethodManager.getInstance().getInputMethodManager()
.showInputMethodPicker();
} }
}); });
mSetupStepGroup.addStep(step2); mSetupStepGroup.addStep(step2);
@ -245,6 +244,7 @@ public final class SetupWizardActivity extends Activity implements View.OnClickL
| Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP
| Intent.FLAG_ACTIVITY_CLEAR_TOP); | Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent); startActivity(intent);
mNeedsToAdjustStepNumberToSystemState = true;
} }
private void invokeSettingsOfThisIme() { private void invokeSettingsOfThisIme() {
@ -260,6 +260,14 @@ public final class SetupWizardActivity extends Activity implements View.OnClickL
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);
mNeedsToAdjustStepNumberToSystemState = true;
}
void invokeInputMethodPicker() {
// Invoke input method picker.
RichInputMethodManager.getInstance().getInputMethodManager()
.showInputMethodPicker();
mNeedsToAdjustStepNumberToSystemState = true;
} }
void invokeSubtypeEnablerOfThisIme() { void invokeSubtypeEnablerOfThisIme() {
@ -313,6 +321,9 @@ public final class SetupWizardActivity extends Activity implements View.OnClickL
@Override @Override
protected void onRestart() { protected void onRestart() {
super.onRestart(); super.onRestart();
// Probably the setup wizard has been invoked from "Recent" menu. The setup step number
// needs to be adjusted to system state, because the state (IME is enabled and/or current)
// may have been changed.
if (isInSetupSteps(mStepNumber)) { if (isInSetupSteps(mStepNumber)) {
mStepNumber = determineSetupStepNumber(); mStepNumber = determineSetupStepNumber();
} }
@ -371,7 +382,8 @@ public final class SetupWizardActivity extends Activity implements View.OnClickL
@Override @Override
public void onWindowFocusChanged(final boolean hasFocus) { public void onWindowFocusChanged(final boolean hasFocus) {
super.onWindowFocusChanged(hasFocus); super.onWindowFocusChanged(hasFocus);
if (hasFocus && isInSetupSteps(mStepNumber)) { if (hasFocus && mNeedsToAdjustStepNumberToSystemState) {
mNeedsToAdjustStepNumberToSystemState = false;
mStepNumber = determineSetupStepNumber(); mStepNumber = determineSetupStepNumber();
updateSetupStepView(); updateSetupStepView();
} }