am a36266dd: am a5be033d: Preserve setup wizard step while orientation change

* commit 'a36266dd5840d645e46b18e41ebcdbea4a21c0e4':
  Preserve setup wizard step while orientation change
main
Tadashi G. Takaoka 2013-05-15 12:35:28 -07:00 committed by Android Git Automerger
commit 4e8fde004f
1 changed files with 23 additions and 34 deletions

View File

@ -59,7 +59,7 @@ public final class SetupActivity extends Activity implements View.OnClickListene
private SetupStepGroup mSetupStepGroup;
private static final String STATE_STEP = "step";
private int mStepNumber;
private static final int STEP_0 = 0;
private static final int STEP_WELCOME = 0;
private static final int STEP_1 = 1;
private static final int STEP_2 = 2;
private static final int STEP_3 = 3;
@ -113,18 +113,20 @@ public final class SetupActivity extends Activity implements View.OnClickListene
if (savedInstanceState == null) {
mStepNumber = determineSetupStepNumber();
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 {
mStepNumber = savedInstanceState.getInt(STATE_STEP);
}
if (mStepNumber == STEP_3) {
// This IME already has been enabled and set as current IME.
// TODO: Implement tutorial.
invokeSettingsOfThisIme();
finish();
return;
}
final String applicationName = getResources().getString(getApplicationInfo().labelRes);
mWelcomeScreen = findViewById(R.id.setup_welcome_screen);
final TextView welcomeTitle = (TextView)findViewById(R.id.setup_welcome_title);
@ -230,13 +232,13 @@ public final class SetupActivity extends Activity implements View.OnClickListene
finish();
return;
}
final int stepState = determineSetupState();
final int currentStep = determineSetupStepNumber();
final int nextStep;
if (v == mActionStart) {
nextStep = STEP_1;
} else if (v == mActionNext) {
nextStep = mStepNumber + 1;
} else if (v == mStep1Bullet && stepState == STEP_2) {
} else if (v == mStep1Bullet && currentStep == STEP_2) {
nextStep = STEP_1;
} else {
nextStep = mStepNumber;
@ -316,7 +318,7 @@ public final class SetupActivity extends Activity implements View.OnClickListene
return myImi.getId().equals(currentImeId);
}
private int determineSetupState() {
private int determineSetupStepNumber() {
mHandler.cancelPollingImeSettings();
if (!isThisImeEnabled(this)) {
return STEP_1;
@ -327,14 +329,6 @@ public final class SetupActivity extends Activity implements View.OnClickListene
return STEP_3;
}
private int determineSetupStepNumber() {
final int stepState = determineSetupState();
if (stepState == STEP_1) {
return mWasLanguageAndInputSettingsInvoked ? STEP_1 : STEP_0;
}
return stepState;
}
@Override
protected void onSaveInstanceState(final Bundle outState) {
super.onSaveInstanceState(outState);
@ -347,16 +341,12 @@ public final class SetupActivity extends Activity implements View.OnClickListene
mStepNumber = savedInstanceState.getInt(STATE_STEP);
}
@Override
protected void onStart() {
super.onStart();
mStepNumber = determineSetupStepNumber();
}
@Override
protected void onRestart() {
super.onRestart();
mStepNumber = determineSetupStepNumber();
if (mStepNumber != STEP_WELCOME) {
mStepNumber = determineSetupStepNumber();
}
}
@Override
@ -368,7 +358,7 @@ public final class SetupActivity extends Activity implements View.OnClickListene
@Override
public void onBackPressed() {
if (mStepNumber == STEP_1) {
mStepNumber = STEP_0;
mStepNumber = STEP_WELCOME;
updateSetupStepView();
return;
}
@ -384,15 +374,14 @@ public final class SetupActivity extends Activity implements View.OnClickListene
@Override
public void onWindowFocusChanged(final boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (!hasFocus) {
return;
if (hasFocus && mStepNumber != STEP_WELCOME) {
mStepNumber = determineSetupStepNumber();
updateSetupStepView();
}
mStepNumber = determineSetupStepNumber();
updateSetupStepView();
}
private void updateSetupStepView() {
final boolean welcomeScreen = (mStepNumber == STEP_0);
final boolean welcomeScreen = (mStepNumber == STEP_WELCOME);
mWelcomeScreen.setVisibility(welcomeScreen ? View.VISIBLE : View.GONE);
mSetupScreen.setVisibility(welcomeScreen ? View.GONE: View.VISIBLE);
if (welcomeScreen) {
@ -401,7 +390,7 @@ public final class SetupActivity extends Activity implements View.OnClickListene
return;
}
mWelcomeVideoView.stopPlayback();
final boolean isStepActionAlreadyDone = mStepNumber < determineSetupState();
final boolean isStepActionAlreadyDone = mStepNumber < determineSetupStepNumber();
mSetupStepGroup.enableStep(mStepNumber, isStepActionAlreadyDone);
mActionNext.setVisibility(isStepActionAlreadyDone ? View.VISIBLE : View.GONE);
mActionFinish.setVisibility((mStepNumber == STEP_3) ? View.VISIBLE : View.GONE);