am fd4baafe: am 46913aed: Merge "Add next axction to setup wizard"

* commit 'fd4baafe710dc0fe843c7672a6bd8bee4244fd73':
  Add next axction to setup wizard
main
Tadashi G. Takaoka 2013-05-15 10:58:58 -07:00 committed by Android Git Automerger
commit b713600a52
3 changed files with 54 additions and 23 deletions

View File

@ -55,6 +55,12 @@
android:id="@+id/setup_step3" android:id="@+id/setup_step3"
layout="@layout/setup_step" /> layout="@layout/setup_step" />
</FrameLayout> </FrameLayout>
<TextView
android:id="@+id/setup_next"
android:text="@string/setup_next_action"
android:gravity="end|center_vertical"
style="@style/setupStepActionLabelStyleCommon"
android:layout_marginTop="@dimen/setup_step_horizontal_line_height" />
<TextView <TextView
android:id="@+id/setup_finish" android:id="@+id/setup_finish"
android:text="@string/setup_finish_action" android:text="@string/setup_finish_action"

View File

@ -461,6 +461,8 @@
<string name="setup_step1_title">"Enable <xliff:g id="application_name">%s</xliff:g>"</string> <string name="setup_step1_title">"Enable <xliff:g id="application_name">%s</xliff:g>"</string>
<!-- Detailed instruction of the 1st step in the setup wizard. [CHAR LIMIT=120] --> <!-- Detailed instruction of the 1st step in the setup wizard. [CHAR LIMIT=120] -->
<string name="setup_step1_instruction">"Please check \"<xliff:g id="application_name">%s</xliff:g>\" in your Language &amp; input settings. This will authorize it to run on your device."</string> <string name="setup_step1_instruction">"Please check \"<xliff:g id="application_name">%s</xliff:g>\" in your Language &amp; input settings. This will authorize it to run on your device."</string>
<!-- Detailed instruction of the already finished 1st step in the setup wizard. [CHAR LIMIT=120] -->
<string name="setup_step1_finished_instruction">"<xliff:g id="application_name">%s</xliff:g> is already enabled in your Language &amp; input settings, so this step is done. On to the next one!"</string>
<!-- The label of the button that triggers the Language & input settings in order to enable the keyboard. [CHAR_LIMIT=64] --> <!-- The label of the button that triggers the Language & input settings in order to enable the keyboard. [CHAR_LIMIT=64] -->
<string name="setup_step1_action">Enable in Settings</string> <string name="setup_step1_action">Enable in Settings</string>
<!-- Ordinal number of the 2nd step in the setup wizard. [CHAR LIMIT=5] --> <!-- Ordinal number of the 2nd step in the setup wizard. [CHAR LIMIT=5] -->

View File

@ -49,6 +49,8 @@ public final class SetupActivity extends Activity implements View.OnClickListene
private Uri mWelcomeVideoUri; private Uri mWelcomeVideoUri;
private VideoView mWelcomeVideoView; private VideoView mWelcomeVideoView;
private View mActionStart; private View mActionStart;
private View mActionNext;
private TextView mStep1Bullet;
private TextView mActionFinish; private TextView mActionFinish;
private SetupStepGroup mSetupStepGroup; private SetupStepGroup mSetupStepGroup;
private static final String STATE_STEP = "step"; private static final String STATE_STEP = "step";
@ -132,10 +134,13 @@ public final class SetupActivity extends Activity implements View.OnClickListene
(SetupStepIndicatorView)findViewById(R.id.setup_step_indicator); (SetupStepIndicatorView)findViewById(R.id.setup_step_indicator);
mSetupStepGroup = new SetupStepGroup(indicatorView); mSetupStepGroup = new SetupStepGroup(indicatorView);
mStep1Bullet = (TextView)findViewById(R.id.setup_step1_bullet);
mStep1Bullet.setOnClickListener(this);
final SetupStep step1 = new SetupStep(STEP_1, applicationName, final SetupStep step1 = new SetupStep(STEP_1, applicationName,
(TextView)findViewById(R.id.setup_step1_bullet), findViewById(R.id.setup_step1), mStep1Bullet, findViewById(R.id.setup_step1),
R.string.setup_step1_title, R.string.setup_step1_instruction, R.string.setup_step1_title, R.string.setup_step1_instruction,
R.drawable.ic_setup_step1, R.string.setup_step1_action); R.string.setup_step1_finished_instruction, R.drawable.ic_setup_step1,
R.string.setup_step1_action);
step1.setAction(new Runnable() { step1.setAction(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -148,7 +153,8 @@ public final class SetupActivity extends Activity implements View.OnClickListene
final SetupStep step2 = new SetupStep(STEP_2, applicationName, final SetupStep step2 = new SetupStep(STEP_2, applicationName,
(TextView)findViewById(R.id.setup_step2_bullet), findViewById(R.id.setup_step2), (TextView)findViewById(R.id.setup_step2_bullet), findViewById(R.id.setup_step2),
R.string.setup_step2_title, R.string.setup_step2_instruction, R.string.setup_step2_title, R.string.setup_step2_instruction,
R.drawable.ic_setup_step2, R.string.setup_step2_action); 0 /* finishedInstruction */, R.drawable.ic_setup_step2,
R.string.setup_step2_action);
step2.setAction(new Runnable() { step2.setAction(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -162,7 +168,8 @@ public final class SetupActivity extends Activity implements View.OnClickListene
final SetupStep step3 = new SetupStep(STEP_3, applicationName, final SetupStep step3 = new SetupStep(STEP_3, applicationName,
(TextView)findViewById(R.id.setup_step3_bullet), findViewById(R.id.setup_step3), (TextView)findViewById(R.id.setup_step3_bullet), findViewById(R.id.setup_step3),
R.string.setup_step3_title, R.string.setup_step3_instruction, R.string.setup_step3_title, R.string.setup_step3_instruction,
R.drawable.ic_setup_step3, R.string.setup_step3_action); 0 /* finishedInstruction */, R.drawable.ic_setup_step3,
R.string.setup_step3_action);
step3.setAction(new Runnable() { step3.setAction(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -186,6 +193,8 @@ public final class SetupActivity extends Activity implements View.OnClickListene
mActionStart = findViewById(R.id.setup_start_label); mActionStart = findViewById(R.id.setup_start_label);
mActionStart.setOnClickListener(this); mActionStart.setOnClickListener(this);
mActionNext = findViewById(R.id.setup_next);
mActionNext.setOnClickListener(this);
mActionFinish = (TextView)findViewById(R.id.setup_finish); mActionFinish = (TextView)findViewById(R.id.setup_finish);
TextViewCompatUtils.setCompoundDrawablesRelativeWithIntrinsicBounds(mActionFinish, TextViewCompatUtils.setCompoundDrawablesRelativeWithIntrinsicBounds(mActionFinish,
getResources().getDrawable(R.drawable.ic_setup_finish), null, null, null); getResources().getDrawable(R.drawable.ic_setup_finish), null, null, null);
@ -194,15 +203,25 @@ public final class SetupActivity extends Activity implements View.OnClickListene
@Override @Override
public void onClick(final View v) { public void onClick(final View v) {
if (v == mActionStart) {
mStepNumber = STEP_1;
updateSetupStepView();
return;
}
if (v == mActionFinish) { if (v == mActionFinish) {
finish(); finish();
return; return;
} }
final int stepState = determineSetupState();
final int nextStep;
if (v == mActionStart) {
nextStep = STEP_1;
} else if (v == mActionNext) {
nextStep = mStepNumber + 1;
} else if (v == mStep1Bullet && stepState == STEP_2) {
nextStep = STEP_1;
} else {
nextStep = mStepNumber;
}
if (mStepNumber != nextStep) {
mStepNumber = nextStep;
updateSetupStepView();
}
} }
private void invokeSetupWizardOfThisIme() { private void invokeSetupWizardOfThisIme() {
@ -360,7 +379,9 @@ public final class SetupActivity extends Activity implements View.OnClickListene
return; return;
} }
mWelcomeVideoView.stopPlayback(); mWelcomeVideoView.stopPlayback();
mSetupStepGroup.enableStep(mStepNumber); final boolean isStepActionAlreadyDone = mStepNumber < determineSetupState();
mSetupStepGroup.enableStep(mStepNumber, isStepActionAlreadyDone);
mActionNext.setVisibility(isStepActionAlreadyDone ? View.VISIBLE : View.GONE);
mActionFinish.setVisibility((mStepNumber == STEP_3) ? View.VISIBLE : View.GONE); mActionFinish.setVisibility((mStepNumber == STEP_3) ? View.VISIBLE : View.GONE);
} }
@ -370,12 +391,14 @@ public final class SetupActivity extends Activity implements View.OnClickListene
private final TextView mBulletView; private final TextView mBulletView;
private final int mActivatedColor; private final int mActivatedColor;
private final int mDeactivatedColor; private final int mDeactivatedColor;
private final String mInstruction;
private final String mFinishedInstruction;
private final TextView mActionLabel; private final TextView mActionLabel;
private Runnable mAction; private Runnable mAction;
public SetupStep(final int stepNo, final String applicationName, final TextView bulletView, public SetupStep(final int stepNo, final String applicationName, final TextView bulletView,
final View stepView, final int title, final int instruction, final int actionIcon, final View stepView, final int title, final int instruction,
final int actionLabel) { final int finishedInstruction,final int actionIcon, final int actionLabel) {
mStepNo = stepNo; mStepNo = stepNo;
mStepView = stepView; mStepView = stepView;
mBulletView = bulletView; mBulletView = bulletView;
@ -385,14 +408,10 @@ public final class SetupActivity extends Activity implements View.OnClickListene
final TextView titleView = (TextView)mStepView.findViewById(R.id.setup_step_title); final TextView titleView = (TextView)mStepView.findViewById(R.id.setup_step_title);
titleView.setText(res.getString(title, applicationName)); titleView.setText(res.getString(title, applicationName));
mInstruction = (instruction == 0) ? null
final TextView instructionView = (TextView)mStepView.findViewById( : res.getString(instruction, applicationName);
R.id.setup_step_instruction); mFinishedInstruction = (finishedInstruction == 0) ? null
if (instruction == 0) { : res.getString(finishedInstruction, applicationName);
instructionView.setVisibility(View.GONE);
} else {
instructionView.setText(res.getString(instruction, applicationName));
}
mActionLabel = (TextView)mStepView.findViewById(R.id.setup_step_action_label); mActionLabel = (TextView)mStepView.findViewById(R.id.setup_step_action_label);
mActionLabel.setText(res.getString(actionLabel)); mActionLabel.setText(res.getString(actionLabel));
@ -405,9 +424,13 @@ public final class SetupActivity extends Activity implements View.OnClickListene
} }
} }
public void setEnabled(final boolean enabled) { public void setEnabled(final boolean enabled, final boolean isStepActionAlreadyDone) {
mStepView.setVisibility(enabled ? View.VISIBLE : View.GONE); mStepView.setVisibility(enabled ? View.VISIBLE : View.GONE);
mBulletView.setTextColor(enabled ? mActivatedColor : mDeactivatedColor); mBulletView.setTextColor(enabled ? mActivatedColor : mDeactivatedColor);
final TextView instructionView = (TextView)mStepView.findViewById(
R.id.setup_step_instruction);
instructionView.setText(isStepActionAlreadyDone ? mFinishedInstruction : mInstruction);
mActionLabel.setVisibility(isStepActionAlreadyDone ? View.GONE : View.VISIBLE);
} }
public void setAction(final Runnable action) { public void setAction(final Runnable action) {
@ -436,9 +459,9 @@ public final class SetupActivity extends Activity implements View.OnClickListene
mGroup.add(step); mGroup.add(step);
} }
public void enableStep(final int enableStepNo) { public void enableStep(final int enableStepNo, final boolean isStepActionAlreadyDone) {
for (final SetupStep step : mGroup) { for (final SetupStep step : mGroup) {
step.setEnabled(step.mStepNo == enableStepNo); step.setEnabled(step.mStepNo == enableStepNo, isStepActionAlreadyDone);
} }
mIndicatorView.setIndicatorPosition(enableStepNo - STEP_1, mGroup.size()); mIndicatorView.setIndicatorPosition(enableStepNo - STEP_1, mGroup.size());
} }