Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2c0c9837 authored by Maurice Lam's avatar Maurice Lam Committed by Android (Google) Code Review
Browse files

Merge "[FRP] Use setup wizard nav bar buttons" into lmp-mr1-dev

parents 03cceb32 af103b4e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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 -->
+16 −4
Original line number Diff line number Diff line
@@ -44,11 +44,22 @@
            android:layout_weight="4"
            android:background="@color/lock_pattern_background"/>

        <TextView android:id="@+id/footerText"
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
            android:layout_height="0dip"
            android:layout_weight="1"
            android:gravity="center"
        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="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 -->
+14 −8
Original line number Diff line number Diff line
@@ -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) {
+52 −36
Original line number Diff line number Diff line
@@ -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,8 +398,7 @@ public class ChooseLockPattern extends SettingsActivity {
            return RedactionInterstitial.createStartIntent(context);
        }

        public void onClick(View v) {
            if (v == mFooterLeftButton) {
        public void handleLeftButton() {
            if (mUiStage.leftMode == LeftButtonMode.Retry) {
                mChosenPattern = null;
                mLockPatternView.clearPattern();
@@ -404,12 +411,14 @@ public class ChooseLockPattern extends SettingsActivity {
                throw new IllegalStateException("left footer button pressed, but stage of " +
                        mUiStage + " doesn't make sense");
            }
            } else if (v == mFooterRightButton) {
        }

        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);
                    throw new IllegalStateException("expected ui stage "
                            + Stage.FirstChoiceValid + " when button is "
                            + RightButtonMode.Continue);
                }
                updateStage(Stage.NeedToConfirm);
            } else if (mUiStage.rightMode == RightButtonMode.Confirm) {
@@ -420,14 +429,21 @@ public class ChooseLockPattern extends SettingsActivity {
                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);
                    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) {
                handleLeftButton();
            } else if (v == mFooterRightButton) {
                handleRightButton();
            }
        }

        public boolean onKeyDown(int keyCode, KeyEvent event) {
@@ -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) {
+27 −0
Original line number Diff line number Diff line
@@ -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 {
@@ -102,5 +117,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);
        }
    }
}
Loading