Loading res/layout/choose_lock_password_footer.xml +9 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,15 @@ android:layout_height="wrap_content" android:text="@string/lockpassword_cancel_label" /> <!-- left : clear --> <Button android:id="@+id/clear_button" style="@style/SuwGlifButton.Secondary" android:layout_width="wrap_content" android:layout_height="wrap_content" android:visibility="gone" android:text="@string/lockpassword_clear_label" /> <Space android:layout_width="0dp" android:layout_height="0dp" Loading res/values/strings.xml +3 −0 Original line number Diff line number Diff line Loading @@ -1375,6 +1375,9 @@ <!-- Label for ChoosePassword/PIN OK button --> <string name="lockpassword_cancel_label">Cancel</string> <!-- Label for ChoosePassword/PIN OK button --> <string name="lockpassword_clear_label">Clear</string> <!-- Label for LockPatternTutorial Cancel button --> <string name="lockpattern_tutorial_cancel_label">Cancel</string> Loading src/com/android/settings/password/ChooseLockPassword.java +16 −0 Original line number Diff line number Diff line Loading @@ -211,6 +211,7 @@ public class ChooseLockPassword extends SettingsActivity { private RecyclerView mPasswordRestrictionView; protected boolean mIsAlphaMode; protected Button mCancelButton; private Button mClearButton; private Button mNextButton; private TextChangedHandler mTextChangedHandler; Loading Loading @@ -347,6 +348,8 @@ public class ChooseLockPassword extends SettingsActivity { mCancelButton.setOnClickListener(this); mNextButton = (Button) view.findViewById(R.id.next_button); mNextButton.setOnClickListener(this); mClearButton = view.findViewById(R.id.clear_button); mClearButton.setOnClickListener(this); if (mForFingerprint) { TextView fingerprintBackupMessage = Loading Loading @@ -735,6 +738,10 @@ public class ChooseLockPassword extends SettingsActivity { case R.id.cancel_button: getActivity().finish(); break; case R.id.clear_button: mPasswordEntry.setText(""); break; } } Loading Loading @@ -839,11 +846,20 @@ public class ChooseLockPassword extends SettingsActivity { mPasswordRestrictionView.setVisibility(View.GONE); setHeaderText(getString(mUiStage.getHint(mIsAlphaMode, mForFingerprint))); setNextEnabled(canInput && length > 0); mClearButton.setEnabled(canInput && length > 0); } mClearButton.setVisibility(toVisibility(mUiStage != Stage.Introduction)); mCancelButton.setVisibility(toVisibility(mUiStage == Stage.Introduction)); setNextText(mUiStage.buttonText); mPasswordEntryInputDisabler.setInputEnabled(canInput); } private int toVisibility(boolean visibleOrGone) { return visibleOrGone ? View.VISIBLE : View.GONE; } private void setHeaderText(String text) { // Only set the text if it is different than the existing one to avoid announcing again. if (!TextUtils.isEmpty(mLayout.getHeaderText()) Loading src/com/android/settings/password/SetupChooseLockPassword.java +6 −7 Original line number Diff line number Diff line Loading @@ -84,13 +84,6 @@ public class SetupChooseLockPassword extends ChooseLockPassword { @Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); if (mForFingerprint) { mCancelButton.setVisibility(View.GONE); } else { mCancelButton.setText(R.string.skip_label); } final Activity activity = getActivity(); ChooseLockGenericController chooseLockGenericController = new ChooseLockGenericController(activity, mUserId); Loading Loading @@ -190,6 +183,12 @@ public class SetupChooseLockPassword extends ChooseLockPassword { @Override protected void updateUi() { super.updateUi(); if (mForFingerprint) { mCancelButton.setVisibility(View.GONE); } else { mCancelButton.setText(R.string.skip_label); } if (mOptionsButton != null) { mOptionsButton.setVisibility( mUiStage == Stage.Introduction ? View.VISIBLE : View.GONE); Loading tests/app/src/com/android/settings/password/ChooseLockPasswordTest.java 0 → 100644 +81 −0 Original line number Diff line number Diff line /* * Copyright (C) 2017 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.settings.password; import static android.support.test.espresso.Espresso.onView; import static android.support.test.espresso.action.ViewActions.pressKey; import static android.support.test.espresso.assertion.ViewAssertions.matches; import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; import static android.support.test.espresso.matcher.ViewMatchers.isEnabled; import static android.support.test.espresso.matcher.ViewMatchers.withEffectiveVisibility; import static android.support.test.espresso.matcher.ViewMatchers.withId; import static org.hamcrest.CoreMatchers.not; import android.app.Instrumentation; import android.content.Context; import android.content.Intent; import android.os.SystemClock; import android.support.test.InstrumentationRegistry; import android.support.test.espresso.action.ViewActions; import android.support.test.espresso.matcher.ViewMatchers; import android.support.test.runner.AndroidJUnit4; import android.view.KeyEvent; import com.android.settings.R; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) public class ChooseLockPasswordTest { private Instrumentation mInstrumentation; private Context mContext; @Before public void setUp() { mInstrumentation = InstrumentationRegistry.getInstrumentation(); mContext = mInstrumentation.getTargetContext(); } @Test public void clearNotVisible_when_activityLaunchedInitially() { mInstrumentation.startActivitySync(new Intent(mContext, ChooseLockPassword.class)); onView(withId(R.id.clear_button)).check(matches( withEffectiveVisibility(ViewMatchers.Visibility.GONE))); } @Test public void clearNotEnabled_when_nothingEntered() { mInstrumentation.startActivitySync(new Intent(mContext, ChooseLockPassword.class)); onView(withId(R.id.password_entry)).perform(ViewActions.typeText("1234")) .perform(pressKey(KeyEvent.KEYCODE_ENTER)); onView(withId(R.id.clear_button)).check(matches(isDisplayed())) .check(matches(not(isEnabled()))); } @Test public void clearEnabled_when_somethingEnteredToConfirm() { mInstrumentation.startActivitySync(new Intent(mContext, ChooseLockPassword.class)); onView(withId(R.id.password_entry)).perform(ViewActions.typeText("1234")) .perform(pressKey(KeyEvent.KEYCODE_ENTER)) .perform(ViewActions.typeText("1")); // clear should be present if text field contains content onView(withId(R.id.clear_button)).check(matches(isDisplayed())); } } Loading
res/layout/choose_lock_password_footer.xml +9 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,15 @@ android:layout_height="wrap_content" android:text="@string/lockpassword_cancel_label" /> <!-- left : clear --> <Button android:id="@+id/clear_button" style="@style/SuwGlifButton.Secondary" android:layout_width="wrap_content" android:layout_height="wrap_content" android:visibility="gone" android:text="@string/lockpassword_clear_label" /> <Space android:layout_width="0dp" android:layout_height="0dp" Loading
res/values/strings.xml +3 −0 Original line number Diff line number Diff line Loading @@ -1375,6 +1375,9 @@ <!-- Label for ChoosePassword/PIN OK button --> <string name="lockpassword_cancel_label">Cancel</string> <!-- Label for ChoosePassword/PIN OK button --> <string name="lockpassword_clear_label">Clear</string> <!-- Label for LockPatternTutorial Cancel button --> <string name="lockpattern_tutorial_cancel_label">Cancel</string> Loading
src/com/android/settings/password/ChooseLockPassword.java +16 −0 Original line number Diff line number Diff line Loading @@ -211,6 +211,7 @@ public class ChooseLockPassword extends SettingsActivity { private RecyclerView mPasswordRestrictionView; protected boolean mIsAlphaMode; protected Button mCancelButton; private Button mClearButton; private Button mNextButton; private TextChangedHandler mTextChangedHandler; Loading Loading @@ -347,6 +348,8 @@ public class ChooseLockPassword extends SettingsActivity { mCancelButton.setOnClickListener(this); mNextButton = (Button) view.findViewById(R.id.next_button); mNextButton.setOnClickListener(this); mClearButton = view.findViewById(R.id.clear_button); mClearButton.setOnClickListener(this); if (mForFingerprint) { TextView fingerprintBackupMessage = Loading Loading @@ -735,6 +738,10 @@ public class ChooseLockPassword extends SettingsActivity { case R.id.cancel_button: getActivity().finish(); break; case R.id.clear_button: mPasswordEntry.setText(""); break; } } Loading Loading @@ -839,11 +846,20 @@ public class ChooseLockPassword extends SettingsActivity { mPasswordRestrictionView.setVisibility(View.GONE); setHeaderText(getString(mUiStage.getHint(mIsAlphaMode, mForFingerprint))); setNextEnabled(canInput && length > 0); mClearButton.setEnabled(canInput && length > 0); } mClearButton.setVisibility(toVisibility(mUiStage != Stage.Introduction)); mCancelButton.setVisibility(toVisibility(mUiStage == Stage.Introduction)); setNextText(mUiStage.buttonText); mPasswordEntryInputDisabler.setInputEnabled(canInput); } private int toVisibility(boolean visibleOrGone) { return visibleOrGone ? View.VISIBLE : View.GONE; } private void setHeaderText(String text) { // Only set the text if it is different than the existing one to avoid announcing again. if (!TextUtils.isEmpty(mLayout.getHeaderText()) Loading
src/com/android/settings/password/SetupChooseLockPassword.java +6 −7 Original line number Diff line number Diff line Loading @@ -84,13 +84,6 @@ public class SetupChooseLockPassword extends ChooseLockPassword { @Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); if (mForFingerprint) { mCancelButton.setVisibility(View.GONE); } else { mCancelButton.setText(R.string.skip_label); } final Activity activity = getActivity(); ChooseLockGenericController chooseLockGenericController = new ChooseLockGenericController(activity, mUserId); Loading Loading @@ -190,6 +183,12 @@ public class SetupChooseLockPassword extends ChooseLockPassword { @Override protected void updateUi() { super.updateUi(); if (mForFingerprint) { mCancelButton.setVisibility(View.GONE); } else { mCancelButton.setText(R.string.skip_label); } if (mOptionsButton != null) { mOptionsButton.setVisibility( mUiStage == Stage.Introduction ? View.VISIBLE : View.GONE); Loading
tests/app/src/com/android/settings/password/ChooseLockPasswordTest.java 0 → 100644 +81 −0 Original line number Diff line number Diff line /* * Copyright (C) 2017 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.settings.password; import static android.support.test.espresso.Espresso.onView; import static android.support.test.espresso.action.ViewActions.pressKey; import static android.support.test.espresso.assertion.ViewAssertions.matches; import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; import static android.support.test.espresso.matcher.ViewMatchers.isEnabled; import static android.support.test.espresso.matcher.ViewMatchers.withEffectiveVisibility; import static android.support.test.espresso.matcher.ViewMatchers.withId; import static org.hamcrest.CoreMatchers.not; import android.app.Instrumentation; import android.content.Context; import android.content.Intent; import android.os.SystemClock; import android.support.test.InstrumentationRegistry; import android.support.test.espresso.action.ViewActions; import android.support.test.espresso.matcher.ViewMatchers; import android.support.test.runner.AndroidJUnit4; import android.view.KeyEvent; import com.android.settings.R; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) public class ChooseLockPasswordTest { private Instrumentation mInstrumentation; private Context mContext; @Before public void setUp() { mInstrumentation = InstrumentationRegistry.getInstrumentation(); mContext = mInstrumentation.getTargetContext(); } @Test public void clearNotVisible_when_activityLaunchedInitially() { mInstrumentation.startActivitySync(new Intent(mContext, ChooseLockPassword.class)); onView(withId(R.id.clear_button)).check(matches( withEffectiveVisibility(ViewMatchers.Visibility.GONE))); } @Test public void clearNotEnabled_when_nothingEntered() { mInstrumentation.startActivitySync(new Intent(mContext, ChooseLockPassword.class)); onView(withId(R.id.password_entry)).perform(ViewActions.typeText("1234")) .perform(pressKey(KeyEvent.KEYCODE_ENTER)); onView(withId(R.id.clear_button)).check(matches(isDisplayed())) .check(matches(not(isEnabled()))); } @Test public void clearEnabled_when_somethingEnteredToConfirm() { mInstrumentation.startActivitySync(new Intent(mContext, ChooseLockPassword.class)); onView(withId(R.id.password_entry)).perform(ViewActions.typeText("1234")) .perform(pressKey(KeyEvent.KEYCODE_ENTER)) .perform(ViewActions.typeText("1")); // clear should be present if text field contains content onView(withId(R.id.clear_button)).check(matches(isDisplayed())); } }