Add next axction to setup wizard
Bug: 8159728
Change-Id: Ia37ab32b63e4eda29bf1411719d00846525c278f
diff --git a/java/res/layout/setup_steps_cards.xml b/java/res/layout/setup_steps_cards.xml
index 6c46461..2451731 100644
--- a/java/res/layout/setup_steps_cards.xml
+++ b/java/res/layout/setup_steps_cards.xml
@@ -56,6 +56,12 @@
layout="@layout/setup_step" />
</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
android:id="@+id/setup_finish"
android:text="@string/setup_finish_action"
style="@style/setupStepActionLabelStyle"
diff --git a/java/res/values/strings.xml b/java/res/values/strings.xml
index d8a88a8..4a7c70b 100644
--- a/java/res/values/strings.xml
+++ b/java/res/values/strings.xml
@@ -461,6 +461,8 @@
<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] -->
<string name="setup_step1_instruction">"Please check \"<xliff:g id="application_name">%s</xliff:g>\" in your Language & 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 & 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] -->
<string name="setup_step1_action">Enable in Settings</string>
<!-- Ordinal number of the 2nd step in the setup wizard. [CHAR LIMIT=5] -->
diff --git a/java/src/com/android/inputmethod/latin/setup/SetupActivity.java b/java/src/com/android/inputmethod/latin/setup/SetupActivity.java
index 66c0b5f..578787d 100644
--- a/java/src/com/android/inputmethod/latin/setup/SetupActivity.java
+++ b/java/src/com/android/inputmethod/latin/setup/SetupActivity.java
@@ -49,6 +49,8 @@
private Uri mWelcomeVideoUri;
private VideoView mWelcomeVideoView;
private View mActionStart;
+ private View mActionNext;
+ private TextView mStep1Bullet;
private TextView mActionFinish;
private SetupStepGroup mSetupStepGroup;
private static final String STATE_STEP = "step";
@@ -132,10 +134,13 @@
(SetupStepIndicatorView)findViewById(R.id.setup_step_indicator);
mSetupStepGroup = new SetupStepGroup(indicatorView);
+ mStep1Bullet = (TextView)findViewById(R.id.setup_step1_bullet);
+ mStep1Bullet.setOnClickListener(this);
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.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() {
@Override
public void run() {
@@ -148,7 +153,8 @@
final SetupStep step2 = new SetupStep(STEP_2, applicationName,
(TextView)findViewById(R.id.setup_step2_bullet), findViewById(R.id.setup_step2),
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() {
@Override
public void run() {
@@ -162,7 +168,8 @@
final SetupStep step3 = new SetupStep(STEP_3, applicationName,
(TextView)findViewById(R.id.setup_step3_bullet), findViewById(R.id.setup_step3),
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() {
@Override
public void run() {
@@ -186,6 +193,8 @@
mActionStart = findViewById(R.id.setup_start_label);
mActionStart.setOnClickListener(this);
+ mActionNext = findViewById(R.id.setup_next);
+ mActionNext.setOnClickListener(this);
mActionFinish = (TextView)findViewById(R.id.setup_finish);
TextViewCompatUtils.setCompoundDrawablesRelativeWithIntrinsicBounds(mActionFinish,
getResources().getDrawable(R.drawable.ic_setup_finish), null, null, null);
@@ -194,15 +203,25 @@
@Override
public void onClick(final View v) {
- if (v == mActionStart) {
- mStepNumber = STEP_1;
- updateSetupStepView();
- return;
- }
if (v == mActionFinish) {
finish();
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() {
@@ -360,7 +379,9 @@
return;
}
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);
}
@@ -370,12 +391,14 @@
private final TextView mBulletView;
private final int mActivatedColor;
private final int mDeactivatedColor;
+ private final String mInstruction;
+ private final String mFinishedInstruction;
private final TextView mActionLabel;
private Runnable mAction;
public SetupStep(final int stepNo, final String applicationName, final TextView bulletView,
- final View stepView, final int title, final int instruction, final int actionIcon,
- final int actionLabel) {
+ final View stepView, final int title, final int instruction,
+ final int finishedInstruction,final int actionIcon, final int actionLabel) {
mStepNo = stepNo;
mStepView = stepView;
mBulletView = bulletView;
@@ -385,14 +408,10 @@
final TextView titleView = (TextView)mStepView.findViewById(R.id.setup_step_title);
titleView.setText(res.getString(title, applicationName));
-
- final TextView instructionView = (TextView)mStepView.findViewById(
- R.id.setup_step_instruction);
- if (instruction == 0) {
- instructionView.setVisibility(View.GONE);
- } else {
- instructionView.setText(res.getString(instruction, applicationName));
- }
+ mInstruction = (instruction == 0) ? null
+ : res.getString(instruction, applicationName);
+ mFinishedInstruction = (finishedInstruction == 0) ? null
+ : res.getString(finishedInstruction, applicationName);
mActionLabel = (TextView)mStepView.findViewById(R.id.setup_step_action_label);
mActionLabel.setText(res.getString(actionLabel));
@@ -405,9 +424,13 @@
}
}
- public void setEnabled(final boolean enabled) {
+ public void setEnabled(final boolean enabled, final boolean isStepActionAlreadyDone) {
mStepView.setVisibility(enabled ? View.VISIBLE : View.GONE);
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) {
@@ -436,9 +459,9 @@
mGroup.add(step);
}
- public void enableStep(final int enableStepNo) {
+ public void enableStep(final int enableStepNo, final boolean isStepActionAlreadyDone) {
for (final SetupStep step : mGroup) {
- step.setEnabled(step.mStepNo == enableStepNo);
+ step.setEnabled(step.mStepNo == enableStepNo, isStepActionAlreadyDone);
}
mIndicatorView.setIndicatorPosition(enableStepNo - STEP_1, mGroup.size());
}