Merge "Request focus when pin is visible" into pi-dev
am: a74dd692aa
Change-Id: Ic632255d28d8284e4288add8f895b004d28aeec8
This commit is contained in:
committed by
android-build-merger
commit
9ede3cc3bd
@@ -140,12 +140,6 @@ public class KeyguardPasswordView extends KeyguardAbsKeyInputView
|
||||
mImm.hideSoftInputFromWindow(getWindowToken(), 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
super.reset();
|
||||
mPasswordEntry.requestFocus();
|
||||
}
|
||||
|
||||
private void updateSwitchImeButton() {
|
||||
// If there's more than one IME, enable the IME switcher button
|
||||
final boolean wasVisible = mSwitchImeButton.getVisibility() == View.VISIBLE;
|
||||
@@ -193,8 +187,6 @@ public class KeyguardPasswordView extends KeyguardAbsKeyInputView
|
||||
// Set selected property on so the view can send accessibility events.
|
||||
mPasswordEntry.setSelected(true);
|
||||
|
||||
mPasswordEntry.requestFocus();
|
||||
|
||||
mSwitchImeButton = findViewById(R.id.switch_ime_button);
|
||||
mSwitchImeButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
|
||||
@@ -23,13 +23,16 @@ import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
|
||||
/**
|
||||
* A Pin based Keyguard input view
|
||||
*/
|
||||
public abstract class KeyguardPinBasedInputView extends KeyguardAbsKeyInputView
|
||||
implements View.OnKeyListener, View.OnTouchListener {
|
||||
|
||||
protected PasswordTextView mPasswordEntry;
|
||||
@VisibleForTesting
|
||||
PasswordTextView mPasswordEntry;
|
||||
private View mOkButton;
|
||||
private View mDeleteButton;
|
||||
private View mButton0;
|
||||
@@ -51,12 +54,6 @@ public abstract class KeyguardPinBasedInputView extends KeyguardAbsKeyInputView
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
mPasswordEntry.requestFocus();
|
||||
super.reset();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onRequestFocusInDescendants(int direction, Rect previouslyFocusedRect) {
|
||||
// send focus to the password field
|
||||
@@ -237,6 +234,12 @@ public abstract class KeyguardPinBasedInputView extends KeyguardAbsKeyInputView
|
||||
super.onFinishInflate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume(int reason) {
|
||||
super.onResume(reason);
|
||||
mPasswordEntry.requestFocus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
|
||||
|
||||
@@ -54,6 +54,8 @@ public class KeyguardBouncer {
|
||||
|
||||
private static final String TAG = "KeyguardBouncer";
|
||||
static final float ALPHA_EXPANSION_THRESHOLD = 0.95f;
|
||||
private static final float EXPANSION_HIDDEN = 1f;
|
||||
private static final float EXPANSION_VISIBLE = 0f;
|
||||
|
||||
protected final Context mContext;
|
||||
protected final ViewMediatorCallback mCallback;
|
||||
@@ -71,10 +73,15 @@ public class KeyguardBouncer {
|
||||
}
|
||||
};
|
||||
private final Runnable mRemoveViewRunnable = this::removeView;
|
||||
protected KeyguardHostView mKeyguardView;
|
||||
private final Runnable mResetRunnable = ()-> {
|
||||
if (mKeyguardView != null) {
|
||||
mKeyguardView.reset();
|
||||
}
|
||||
};
|
||||
|
||||
private int mStatusBarHeight;
|
||||
private float mExpansion;
|
||||
protected KeyguardHostView mKeyguardView;
|
||||
private float mExpansion = EXPANSION_HIDDEN;
|
||||
protected ViewGroup mRoot;
|
||||
private boolean mShowingSoon;
|
||||
private int mBouncerPromptReason;
|
||||
@@ -96,7 +103,7 @@ public class KeyguardBouncer {
|
||||
}
|
||||
|
||||
public void show(boolean resetSecuritySelection) {
|
||||
show(resetSecuritySelection, true /* notifyFalsing */);
|
||||
show(resetSecuritySelection, true /* animated */);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -120,8 +127,7 @@ public class KeyguardBouncer {
|
||||
// Later, at the end of the animation, when the bouncer is at the top of the screen,
|
||||
// onFullyShown() will be called and FalsingManager will stop recording touches.
|
||||
if (animated) {
|
||||
mFalsingManager.onBouncerShown();
|
||||
setExpansion(0);
|
||||
setExpansion(EXPANSION_VISIBLE);
|
||||
}
|
||||
|
||||
if (resetSecuritySelection) {
|
||||
@@ -152,6 +158,7 @@ public class KeyguardBouncer {
|
||||
mShowingSoon = true;
|
||||
|
||||
// Split up the work over multiple frames.
|
||||
DejankUtils.removeCallbacks(mResetRunnable);
|
||||
DejankUtils.postAfterTraversal(mShowRunnable);
|
||||
|
||||
mCallback.onBouncerVisiblityChanged(true /* shown */);
|
||||
@@ -181,6 +188,7 @@ public class KeyguardBouncer {
|
||||
mRoot.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
mFalsingManager.onBouncerHidden();
|
||||
DejankUtils.postAfterTraversal(mResetRunnable);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,6 +218,9 @@ public class KeyguardBouncer {
|
||||
mKeyguardView.requestLayout();
|
||||
}
|
||||
mShowingSoon = false;
|
||||
if (mExpansion == EXPANSION_VISIBLE) {
|
||||
mKeyguardView.onResume();
|
||||
}
|
||||
StatsLog.write(StatsLog.KEYGUARD_BOUNCER_STATE_CHANGED,
|
||||
StatsLog.KEYGUARD_BOUNCER_STATE_CHANGED__STATE__SHOWN);
|
||||
}
|
||||
@@ -303,7 +314,7 @@ public class KeyguardBouncer {
|
||||
|
||||
public boolean isShowing() {
|
||||
return (mShowingSoon || (mRoot != null && mRoot.getVisibility() == View.VISIBLE))
|
||||
&& mExpansion == 0 && !isAnimatingAway();
|
||||
&& mExpansion == EXPANSION_VISIBLE && !isAnimatingAway();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -337,10 +348,10 @@ public class KeyguardBouncer {
|
||||
mKeyguardView.setTranslationY(fraction * mKeyguardView.getHeight());
|
||||
}
|
||||
|
||||
if (fraction == 0 && oldExpansion != 0) {
|
||||
if (fraction == EXPANSION_VISIBLE && oldExpansion != EXPANSION_VISIBLE) {
|
||||
onFullyShown();
|
||||
mExpansionCallback.onFullyShown();
|
||||
} else if (fraction == 1 && oldExpansion != 0) {
|
||||
} else if (fraction == EXPANSION_HIDDEN && oldExpansion != EXPANSION_HIDDEN) {
|
||||
onFullyHidden();
|
||||
mExpansionCallback.onFullyHidden();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.keyguard;
|
||||
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import android.support.test.filters.SmallTest;
|
||||
import android.testing.AndroidTestingRunner;
|
||||
import android.testing.TestableLooper.RunWithLooper;
|
||||
import android.view.LayoutInflater;
|
||||
|
||||
import com.android.systemui.SysuiTestCase;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
@SmallTest
|
||||
@RunWith(AndroidTestingRunner.class)
|
||||
@RunWithLooper(setAsMainLooper = true)
|
||||
public class KeyguardPinBasedInputViewTest extends SysuiTestCase {
|
||||
|
||||
@Mock
|
||||
private PasswordTextView mPasswordTextView;
|
||||
private KeyguardPinBasedInputView mKeyguardPinView;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
LayoutInflater inflater = LayoutInflater.from(getContext());
|
||||
mKeyguardPinView =
|
||||
(KeyguardPinBasedInputView) inflater.inflate(R.layout.keyguard_pin_view, null);
|
||||
mKeyguardPinView.mPasswordEntry = mPasswordTextView;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onResume_requestsFocus() {
|
||||
mKeyguardPinView.onResume(KeyguardSecurityView.SCREEN_ON);
|
||||
verify(mPasswordTextView).requestFocus();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user