diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 26a5e102322..07d7ecc59fa 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1572,11 +1572,11 @@
+ android:theme="@style/SetupWizardTheme.Light"/>
+ android:theme="@style/SetupWizardTheme.Light"/>
+ android:theme="@style/SetupWizardTheme.Light"/>
+ android:theme="@style/SetupWizardTheme.Light"/>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/res/layout/confirm_lock_password_internal.xml b/res/layout/confirm_lock_password_internal.xml
new file mode 100644
index 00000000000..e22d76415f9
--- /dev/null
+++ b/res/layout/confirm_lock_password_internal.xml
@@ -0,0 +1,98 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/layout/confirm_lock_pattern_internal_base.xml b/res/layout/confirm_lock_pattern_internal_base.xml
new file mode 100644
index 00000000000..359b51b8846
--- /dev/null
+++ b/res/layout/confirm_lock_pattern_internal_base.xml
@@ -0,0 +1,112 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/res/values-sw600dp/aliases.xml b/res/values-sw600dp/aliases.xml
index 163e97a3630..86f2da5ec82 100644
--- a/res/values-sw600dp/aliases.xml
+++ b/res/values-sw600dp/aliases.xml
@@ -20,5 +20,6 @@
- @layout/fingerprint_enroll_enrolling_base
- @layout/fingerprint_enroll_finish_base
- @layout/choose_lock_pattern_common
+ - @layout/confirm_lock_pattern_internal_base
diff --git a/res/values/aliases.xml b/res/values/aliases.xml
index 951b1bbb262..8c4858dfb1b 100644
--- a/res/values/aliases.xml
+++ b/res/values/aliases.xml
@@ -17,6 +17,7 @@
- @*android:layout/preference_category_material
- @layout/confirm_lock_pattern_base
+ - @layout/confirm_lock_pattern_internal_base
- @layout/confirm_lock_password_base
- @layout/fingerprint_enroll_find_sensor_base
- @layout/fingerprint_enroll_enrolling_base
diff --git a/src/com/android/settings/ConfirmDeviceCredentialBaseActivity.java b/src/com/android/settings/ConfirmDeviceCredentialBaseActivity.java
index e8880aeb1a1..489dbbe9ec3 100644
--- a/src/com/android/settings/ConfirmDeviceCredentialBaseActivity.java
+++ b/src/com/android/settings/ConfirmDeviceCredentialBaseActivity.java
@@ -22,16 +22,23 @@ import android.os.Bundle;
import android.os.UserManager;
import android.view.MenuItem;
import android.view.WindowManager;
+import android.widget.LinearLayout;
public abstract class ConfirmDeviceCredentialBaseActivity extends SettingsActivity {
private static final String STATE_IS_KEYGUARD_LOCKED = "STATE_IS_KEYGUARD_LOCKED";
+ enum ConfirmCredentialTheme {
+ INTERNAL,
+ DARK,
+ WORK
+ }
+
private boolean mRestoring;
- private boolean mDark;
private boolean mEnterAnimationPending;
private boolean mFirstTimeVisible = true;
private boolean mIsKeyguardLocked = false;
+ private ConfirmCredentialTheme mConfirmCredentialTheme;
@Override
protected void onCreate(Bundle savedState) {
@@ -39,12 +46,24 @@ public abstract class ConfirmDeviceCredentialBaseActivity extends SettingsActivi
Utils.getUserIdFromBundle(this, getIntent().getExtras()));
if (UserManager.get(this).isManagedProfile(credentialOwnerUserId)) {
setTheme(R.style.Theme_ConfirmDeviceCredentialsWork);
+ mConfirmCredentialTheme = ConfirmCredentialTheme.WORK;
} else if (getIntent().getBooleanExtra(
ConfirmDeviceCredentialBaseFragment.DARK_THEME, false)) {
setTheme(R.style.Theme_ConfirmDeviceCredentialsDark);
- mDark = true;
+ mConfirmCredentialTheme = ConfirmCredentialTheme.DARK;
+ } else {
+ setTheme(R.style.SetupWizardTheme_Light);
+ mConfirmCredentialTheme = ConfirmCredentialTheme.INTERNAL;
}
super.onCreate(savedState);
+
+ if (mConfirmCredentialTheme == ConfirmCredentialTheme.INTERNAL) {
+ // Prevent the content parent from consuming the window insets because GlifLayout uses
+ // it to show the status bar background.
+ LinearLayout layout = (LinearLayout) findViewById(R.id.content_parent);
+ layout.setFitsSystemWindows(false);
+ }
+
mIsKeyguardLocked = savedState == null
? getSystemService(KeyguardManager.class).isKeyguardLocked()
: savedState.getBoolean(STATE_IS_KEYGUARD_LOCKED, false);
@@ -85,7 +104,8 @@ public abstract class ConfirmDeviceCredentialBaseActivity extends SettingsActivi
@Override
public void onResume() {
super.onResume();
- if (!isChangingConfigurations() && !mRestoring && mDark && mFirstTimeVisible) {
+ if (!isChangingConfigurations() && !mRestoring
+ && mConfirmCredentialTheme == ConfirmCredentialTheme.DARK && mFirstTimeVisible) {
mFirstTimeVisible = false;
prepareEnterAnimation();
mEnterAnimationPending = true;
@@ -116,4 +136,8 @@ public abstract class ConfirmDeviceCredentialBaseActivity extends SettingsActivi
public void startEnterAnimation() {
getFragment().startEnterAnimation();
}
+
+ public ConfirmCredentialTheme getConfirmCredentialTheme() {
+ return mConfirmCredentialTheme;
+ }
}
diff --git a/src/com/android/settings/ConfirmLockPassword.java b/src/com/android/settings/ConfirmLockPassword.java
index 6b55add036d..5c86dcd3d23 100644
--- a/src/com/android/settings/ConfirmLockPassword.java
+++ b/src/com/android/settings/ConfirmLockPassword.java
@@ -122,7 +122,14 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
Bundle savedInstanceState) {
final int storedQuality = mLockPatternUtils.getKeyguardStoredPasswordQuality(
mEffectiveUserId);
- View view = inflater.inflate(R.layout.confirm_lock_password, null);
+
+ ConfirmLockPassword activity = (ConfirmLockPassword) getActivity();
+ View view = inflater.inflate(
+ activity.getConfirmCredentialTheme() == ConfirmCredentialTheme.INTERNAL
+ ? R.layout.confirm_lock_password_internal
+ : R.layout.confirm_lock_password,
+ container,
+ false);
mPasswordEntry = (TextView) view.findViewById(R.id.password_entry);
mPasswordEntry.setOnEditorActionListener(this);
@@ -406,25 +413,22 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
}
mDisappearing = true;
- if (getActivity().getThemeResId() == R.style.Theme_ConfirmDeviceCredentialsDark) {
- mDisappearAnimationUtils.startAnimation(getActiveViews(), new Runnable() {
- @Override
- public void run() {
- // Bail if there is no active activity.
- if (getActivity() == null || getActivity().isFinishing()) {
- return;
- }
-
- getActivity().setResult(RESULT_OK, intent);
- getActivity().finish();
- getActivity().overridePendingTransition(
- R.anim.confirm_credential_close_enter,
- R.anim.confirm_credential_close_exit);
- }
+ final ConfirmLockPassword activity = (ConfirmLockPassword) getActivity();
+ // Bail if there is no active activity.
+ if (activity == null || activity.isFinishing()) {
+ return;
+ }
+ if (activity.getConfirmCredentialTheme() == ConfirmCredentialTheme.DARK) {
+ mDisappearAnimationUtils.startAnimation(getActiveViews(), () -> {
+ activity.setResult(RESULT_OK, intent);
+ activity.finish();
+ activity.overridePendingTransition(
+ R.anim.confirm_credential_close_enter,
+ R.anim.confirm_credential_close_exit);
});
} else {
- getActivity().setResult(RESULT_OK, intent);
- getActivity().finish();
+ activity.setResult(RESULT_OK, intent);
+ activity.finish();
}
}
diff --git a/src/com/android/settings/ConfirmLockPattern.java b/src/com/android/settings/ConfirmLockPattern.java
index a224ac86eab..4b65163ce29 100644
--- a/src/com/android/settings/ConfirmLockPattern.java
+++ b/src/com/android/settings/ConfirmLockPattern.java
@@ -114,7 +114,13 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
- View view = inflater.inflate(R.layout.confirm_lock_pattern, null);
+ ConfirmLockPattern activity = (ConfirmLockPattern) getActivity();
+ View view = inflater.inflate(
+ activity.getConfirmCredentialTheme() == ConfirmCredentialTheme.INTERNAL
+ ? R.layout.confirm_lock_pattern_internal
+ : R.layout.confirm_lock_pattern,
+ container,
+ false);
mHeaderTextView = (TextView) view.findViewById(R.id.headerText);
mLockPatternView = (LockPatternView) view.findViewById(R.id.lockPattern);
mDetailsTextView = (TextView) view.findViewById(R.id.detailsText);
@@ -343,27 +349,24 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity {
}
mDisappearing = true;
- if (getActivity().getThemeResId() == R.style.Theme_ConfirmDeviceCredentialsDark) {
+ final ConfirmLockPattern activity = (ConfirmLockPattern) getActivity();
+ // Bail if there is no active activity.
+ if (activity == null || activity.isFinishing()) {
+ return;
+ }
+ if (activity.getConfirmCredentialTheme() == ConfirmCredentialTheme.DARK) {
mLockPatternView.clearPattern();
mDisappearAnimationUtils.startAnimation2d(getActiveViews(),
- new Runnable() {
- @Override
- public void run() {
- // Bail if there is no active activity.
- if (getActivity() == null || getActivity().isFinishing()) {
- return;
- }
-
- getActivity().setResult(RESULT_OK, intent);
- getActivity().finish();
- getActivity().overridePendingTransition(
- R.anim.confirm_credential_close_enter,
- R.anim.confirm_credential_close_exit);
- }
+ () -> {
+ activity.setResult(RESULT_OK, intent);
+ activity.finish();
+ activity.overridePendingTransition(
+ R.anim.confirm_credential_close_enter,
+ R.anim.confirm_credential_close_exit);
}, this);
} else {
- getActivity().setResult(RESULT_OK, intent);
- getActivity().finish();
+ activity.setResult(RESULT_OK, intent);
+ activity.finish();
}
}
diff --git a/tests/app/src/com/android/settings/ConfirmLockPasswordTest.java b/tests/app/src/com/android/settings/ConfirmLockPasswordTest.java
new file mode 100644
index 00000000000..05464ad78ca
--- /dev/null
+++ b/tests/app/src/com/android/settings/ConfirmLockPasswordTest.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * 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;
+
+import static android.support.test.espresso.Espresso.onView;
+import static android.support.test.espresso.action.ViewActions.pressKey;
+import static android.support.test.espresso.action.ViewActions.typeText;
+import static android.support.test.espresso.assertion.ViewAssertions.matches;
+import static android.support.test.espresso.matcher.ViewMatchers.withId;
+import static android.support.test.espresso.matcher.ViewMatchers.withText;
+
+import android.app.Instrumentation;
+import android.content.Context;
+import android.content.Intent;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.runner.AndroidJUnit4;
+import android.view.KeyEvent;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(AndroidJUnit4.class)
+public class ConfirmLockPasswordTest {
+
+ private Instrumentation mInstrumentation;
+ private Context mContext;
+
+ @Before
+ public void setUp() {
+ mInstrumentation = InstrumentationRegistry.getInstrumentation();
+ mContext = mInstrumentation.getTargetContext();
+ }
+
+ @Test
+ public void enterWrongPin_shouldShowErrorMessage() {
+ mInstrumentation.startActivitySync(
+ new Intent(mContext, ConfirmLockPassword.class));
+ onView(withId(R.id.password_entry)).perform(typeText("1234"))
+ .perform(pressKey(KeyEvent.KEYCODE_ENTER));
+ onView(withId(R.id.errorText)).check(matches(withText(R.string.lockpassword_invalid_pin)));
+ }
+
+ @Test
+ public void enterWrongPin_darkTheme_shouldShowErrorMessage() {
+ mInstrumentation.startActivitySync(
+ new Intent(mContext, ConfirmLockPassword.class)
+ .putExtra(ConfirmDeviceCredentialBaseFragment.DARK_THEME, true));
+ onView(withId(R.id.password_entry)).perform(typeText("1234"))
+ .perform(pressKey(KeyEvent.KEYCODE_ENTER));
+ onView(withId(R.id.errorText)).check(matches(withText(R.string.lockpassword_invalid_pin)));
+ }
+}