[FRP] Use setup wizard nav bar buttons
Use setup wizard nav bar buttons instead of custom button bar for lock screen setup. Bug: 18482708 Change-Id: I471f475ebe6bc7ba8cfbd179daddd854c1b6982a
This commit is contained in:
@@ -52,6 +52,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:visibility="gone"
|
||||
style="@style/SecurityPreferenceButtonContainer">
|
||||
|
||||
<!-- left : cancel -->
|
||||
|
@@ -44,11 +44,22 @@
|
||||
android:layout_weight="4"
|
||||
android:background="@color/lock_pattern_background"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<Button android:id="@+id/retryButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/lockpattern_retry_button_text"/>
|
||||
|
||||
<TextView android:id="@+id/footerText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dip"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="50dp"
|
||||
android:textSize="14sp"/>
|
||||
|
||||
@@ -59,6 +70,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:visibility="gone"
|
||||
style="@style/SecurityPreferenceButtonContainer">
|
||||
|
||||
<!-- left : cancel, or re-try -->
|
||||
|
@@ -24,14 +24,12 @@ import com.android.settings.notification.RedactionInterstitial;
|
||||
import android.app.Activity;
|
||||
import android.app.Fragment;
|
||||
import android.app.admin.DevicePolicyManager;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.inputmethodservice.KeyboardView;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.provider.Settings;
|
||||
import android.text.Editable;
|
||||
import android.text.InputType;
|
||||
import android.text.Selection;
|
||||
@@ -416,7 +414,7 @@ public class ChooseLockPassword extends SettingsActivity {
|
||||
return null;
|
||||
}
|
||||
|
||||
private void handleNext() {
|
||||
public void handleNext() {
|
||||
if (mDone) return;
|
||||
|
||||
final String pin = mPasswordEntry.getText().toString();
|
||||
@@ -460,6 +458,14 @@ public class ChooseLockPassword extends SettingsActivity {
|
||||
}
|
||||
}
|
||||
|
||||
protected void setNextEnabled(boolean enabled) {
|
||||
mNextButton.setEnabled(enabled);
|
||||
}
|
||||
|
||||
protected void setNextText(int text) {
|
||||
mNextButton.setText(text);
|
||||
}
|
||||
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.next_button:
|
||||
@@ -502,22 +508,22 @@ public class ChooseLockPassword extends SettingsActivity {
|
||||
String msg = getString(mIsAlphaMode ? R.string.lockpassword_password_too_short
|
||||
: R.string.lockpassword_pin_too_short, mPasswordMinLength);
|
||||
mHeaderText.setText(msg);
|
||||
mNextButton.setEnabled(false);
|
||||
setNextEnabled(false);
|
||||
} else {
|
||||
String error = validatePassword(password);
|
||||
if (error != null) {
|
||||
mHeaderText.setText(error);
|
||||
mNextButton.setEnabled(false);
|
||||
setNextEnabled(false);
|
||||
} else {
|
||||
mHeaderText.setText(R.string.lockpassword_press_continue);
|
||||
mNextButton.setEnabled(true);
|
||||
setNextEnabled(true);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mHeaderText.setText(mIsAlphaMode ? mUiStage.alphaHint : mUiStage.numericHint);
|
||||
mNextButton.setEnabled(length > 0);
|
||||
setNextEnabled(length > 0);
|
||||
}
|
||||
mNextButton.setText(mUiStage.buttonText);
|
||||
setNextText(mUiStage.buttonText);
|
||||
}
|
||||
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
@@ -150,6 +150,14 @@ public class ChooseLockPattern extends SettingsActivity {
|
||||
}
|
||||
}
|
||||
|
||||
protected void setRightButtonEnabled(boolean enabled) {
|
||||
mFooterRightButton.setEnabled(enabled);
|
||||
}
|
||||
|
||||
protected void setRightButtonText(int text) {
|
||||
mFooterRightButton.setText(text);
|
||||
}
|
||||
|
||||
/**
|
||||
* The pattern listener that responds according to a user choosing a new
|
||||
* lock pattern.
|
||||
@@ -390,43 +398,51 @@ public class ChooseLockPattern extends SettingsActivity {
|
||||
return RedactionInterstitial.createStartIntent(context);
|
||||
}
|
||||
|
||||
public void handleLeftButton() {
|
||||
if (mUiStage.leftMode == LeftButtonMode.Retry) {
|
||||
mChosenPattern = null;
|
||||
mLockPatternView.clearPattern();
|
||||
updateStage(Stage.Introduction);
|
||||
} else if (mUiStage.leftMode == LeftButtonMode.Cancel) {
|
||||
// They are canceling the entire wizard
|
||||
getActivity().setResult(RESULT_FINISHED);
|
||||
getActivity().finish();
|
||||
} else {
|
||||
throw new IllegalStateException("left footer button pressed, but stage of " +
|
||||
mUiStage + " doesn't make sense");
|
||||
}
|
||||
}
|
||||
|
||||
public void handleRightButton() {
|
||||
if (mUiStage.rightMode == RightButtonMode.Continue) {
|
||||
if (mUiStage != Stage.FirstChoiceValid) {
|
||||
throw new IllegalStateException("expected ui stage "
|
||||
+ Stage.FirstChoiceValid + " when button is "
|
||||
+ RightButtonMode.Continue);
|
||||
}
|
||||
updateStage(Stage.NeedToConfirm);
|
||||
} else if (mUiStage.rightMode == RightButtonMode.Confirm) {
|
||||
if (mUiStage != Stage.ChoiceConfirmed) {
|
||||
throw new IllegalStateException("expected ui stage " + Stage.ChoiceConfirmed
|
||||
+ " when button is " + RightButtonMode.Confirm);
|
||||
}
|
||||
saveChosenPatternAndFinish();
|
||||
} else if (mUiStage.rightMode == RightButtonMode.Ok) {
|
||||
if (mUiStage != Stage.HelpScreen) {
|
||||
throw new IllegalStateException("Help screen is only mode with ok button, "
|
||||
+ "but stage is " + mUiStage);
|
||||
}
|
||||
mLockPatternView.clearPattern();
|
||||
mLockPatternView.setDisplayMode(DisplayMode.Correct);
|
||||
updateStage(Stage.Introduction);
|
||||
}
|
||||
}
|
||||
|
||||
public void onClick(View v) {
|
||||
if (v == mFooterLeftButton) {
|
||||
if (mUiStage.leftMode == LeftButtonMode.Retry) {
|
||||
mChosenPattern = null;
|
||||
mLockPatternView.clearPattern();
|
||||
updateStage(Stage.Introduction);
|
||||
} else if (mUiStage.leftMode == LeftButtonMode.Cancel) {
|
||||
// They are canceling the entire wizard
|
||||
getActivity().setResult(RESULT_FINISHED);
|
||||
getActivity().finish();
|
||||
} else {
|
||||
throw new IllegalStateException("left footer button pressed, but stage of " +
|
||||
mUiStage + " doesn't make sense");
|
||||
}
|
||||
handleLeftButton();
|
||||
} else if (v == mFooterRightButton) {
|
||||
|
||||
if (mUiStage.rightMode == RightButtonMode.Continue) {
|
||||
if (mUiStage != Stage.FirstChoiceValid) {
|
||||
throw new IllegalStateException("expected ui stage " + Stage.FirstChoiceValid
|
||||
+ " when button is " + RightButtonMode.Continue);
|
||||
}
|
||||
updateStage(Stage.NeedToConfirm);
|
||||
} else if (mUiStage.rightMode == RightButtonMode.Confirm) {
|
||||
if (mUiStage != Stage.ChoiceConfirmed) {
|
||||
throw new IllegalStateException("expected ui stage " + Stage.ChoiceConfirmed
|
||||
+ " when button is " + RightButtonMode.Confirm);
|
||||
}
|
||||
saveChosenPatternAndFinish();
|
||||
} else if (mUiStage.rightMode == RightButtonMode.Ok) {
|
||||
if (mUiStage != Stage.HelpScreen) {
|
||||
throw new IllegalStateException("Help screen is only mode with ok button, but " +
|
||||
"stage is " + mUiStage);
|
||||
}
|
||||
mLockPatternView.clearPattern();
|
||||
mLockPatternView.setDisplayMode(DisplayMode.Correct);
|
||||
updateStage(Stage.Introduction);
|
||||
}
|
||||
handleRightButton();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -489,8 +505,8 @@ public class ChooseLockPattern extends SettingsActivity {
|
||||
mFooterLeftButton.setEnabled(stage.leftMode.enabled);
|
||||
}
|
||||
|
||||
mFooterRightButton.setText(stage.rightMode.text);
|
||||
mFooterRightButton.setEnabled(stage.rightMode.enabled);
|
||||
setRightButtonText(stage.rightMode.text);
|
||||
setRightButtonEnabled(stage.rightMode.enabled);
|
||||
|
||||
// same for whether the patten is enabled
|
||||
if (stage.patternEnabled) {
|
||||
|
@@ -47,6 +47,9 @@ public class SetupChooseLockPassword extends ChooseLockPassword
|
||||
return intent;
|
||||
}
|
||||
|
||||
private SetupWizardNavBar mNavigationBar;
|
||||
private SetupChooseLockPasswordFragment mFragment;
|
||||
|
||||
@Override
|
||||
protected boolean isValidFragment(String fragmentName) {
|
||||
return SetupChooseLockPasswordFragment.class.getName().equals(fragmentName);
|
||||
@@ -65,6 +68,7 @@ public class SetupChooseLockPassword extends ChooseLockPassword
|
||||
|
||||
@Override
|
||||
public void onNavigationBarCreated(SetupWizardNavBar bar) {
|
||||
mNavigationBar = bar;
|
||||
SetupWizardUtils.setImmersiveMode(this, bar);
|
||||
}
|
||||
|
||||
@@ -75,6 +79,17 @@ public class SetupChooseLockPassword extends ChooseLockPassword
|
||||
|
||||
@Override
|
||||
public void onNavigateNext() {
|
||||
if (mFragment != null) {
|
||||
mFragment.handleNext();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttachFragment(Fragment fragment) {
|
||||
super.onAttachFragment(fragment);
|
||||
if (fragment instanceof SetupChooseLockPasswordFragment) {
|
||||
mFragment = (SetupChooseLockPasswordFragment) fragment;
|
||||
}
|
||||
}
|
||||
|
||||
public static class SetupChooseLockPasswordFragment extends ChooseLockPasswordFragment {
|
||||
@@ -100,5 +115,17 @@ public class SetupChooseLockPassword extends ChooseLockPassword
|
||||
SetupWizardUtils.copySetupExtras(getActivity().getIntent(), intent);
|
||||
return intent;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setNextEnabled(boolean enabled) {
|
||||
SetupChooseLockPassword activity = (SetupChooseLockPassword) getActivity();
|
||||
activity.mNavigationBar.getNextButton().setEnabled(enabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setNextText(int text) {
|
||||
SetupChooseLockPassword activity = (SetupChooseLockPassword) getActivity();
|
||||
activity.mNavigationBar.getNextButton().setText(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -26,6 +26,7 @@ import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
|
||||
/**
|
||||
* Setup Wizard's version of ChooseLockPattern screen. It inherits the logic and basic structure
|
||||
@@ -45,6 +46,9 @@ public class SetupChooseLockPattern extends ChooseLockPattern
|
||||
return intent;
|
||||
}
|
||||
|
||||
private SetupWizardNavBar mNavigationBar;
|
||||
private SetupChooseLockPatternFragment mFragment;
|
||||
|
||||
@Override
|
||||
protected boolean isValidFragment(String fragmentName) {
|
||||
return SetupChooseLockPatternFragment.class.getName().equals(fragmentName);
|
||||
@@ -63,6 +67,7 @@ public class SetupChooseLockPattern extends ChooseLockPattern
|
||||
|
||||
@Override
|
||||
public void onNavigationBarCreated(SetupWizardNavBar bar) {
|
||||
mNavigationBar = bar;
|
||||
SetupWizardUtils.setImmersiveMode(this, bar);
|
||||
}
|
||||
|
||||
@@ -73,10 +78,23 @@ public class SetupChooseLockPattern extends ChooseLockPattern
|
||||
|
||||
@Override
|
||||
public void onNavigateNext() {
|
||||
if (mFragment != null) {
|
||||
mFragment.handleRightButton();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttachFragment(Fragment fragment) {
|
||||
super.onAttachFragment(fragment);
|
||||
if (fragment instanceof ChooseLockPatternFragment) {
|
||||
mFragment = (SetupChooseLockPatternFragment) fragment;
|
||||
}
|
||||
}
|
||||
|
||||
public static class SetupChooseLockPatternFragment extends ChooseLockPatternFragment {
|
||||
|
||||
private Button mRetryButton;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
@@ -88,6 +106,8 @@ public class SetupChooseLockPattern extends ChooseLockPattern
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
mRetryButton = (Button) view.findViewById(R.id.retryButton);
|
||||
mRetryButton.setOnClickListener(this);
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
SetupWizardUtils.setHeaderText(getActivity(), getActivity().getTitle());
|
||||
}
|
||||
@@ -98,5 +118,33 @@ public class SetupChooseLockPattern extends ChooseLockPattern
|
||||
SetupWizardUtils.copySetupExtras(getActivity().getIntent(), intent);
|
||||
return intent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (v == mRetryButton) {
|
||||
handleLeftButton();
|
||||
} else {
|
||||
super.onClick(v);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setRightButtonEnabled(boolean enabled) {
|
||||
SetupChooseLockPattern activity = (SetupChooseLockPattern) getActivity();
|
||||
activity.mNavigationBar.getNextButton().setEnabled(enabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setRightButtonText(int text) {
|
||||
SetupChooseLockPattern activity = (SetupChooseLockPattern) getActivity();
|
||||
activity.mNavigationBar.getNextButton().setText(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateStage(Stage stage) {
|
||||
super.updateStage(stage);
|
||||
// Only enable the button for retry
|
||||
mRetryButton.setEnabled(stage == Stage.FirstChoiceValid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user