Use GLIF theme for screen lock confirmation
Theme the confirm password screen similar to setup wizard and screen lock enrollment flow, so that we can start showing it during setup wizard. The new layouts are called "internal" because it's supposed to be used only when another settings screen starts it. For external intents from CONFIRM_DEVICE_CREDENTIAL, the existing theme and layout are unchanged. Bug: 32373672 Test: Run ConfirmLockPasswordTest with `am instrument` Change-Id: Ib887a763a073e6e4b96264d08846827b2e5cbf52
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user