Merge "Make unlock dialog exit if the person taps outside of the dialog" into qt-qpr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
7ca7382a6e
@@ -16,12 +16,13 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@+id/layout"
|
android:id="@+id/unlock_dialog_parent"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:gravity="center">
|
android:gravity="center">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:id="@+id/unlock_dialog"
|
||||||
android:layout_width="@dimen/unlock_dialog_width"
|
android:layout_width="@dimen/unlock_dialog_width"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ class CarTrustAgentUnlockDialogHelper extends BroadcastReceiver{
|
|||||||
* Not using Dialog because context passed from {@link FullscreenUserSwitcher} is not an
|
* Not using Dialog because context passed from {@link FullscreenUserSwitcher} is not an
|
||||||
* activity.
|
* activity.
|
||||||
*/
|
*/
|
||||||
private final View mUnlockDialog;
|
private final View mUnlockDialogLayout;
|
||||||
private final TextView mUnlockingText;
|
private final TextView mUnlockingText;
|
||||||
private final Button mButton;
|
private final Button mButton;
|
||||||
private final IntentFilter mFilter;
|
private final IntentFilter mFilter;
|
||||||
@@ -70,14 +70,25 @@ class CarTrustAgentUnlockDialogHelper extends BroadcastReceiver{
|
|||||||
mParams.packageName = mContext.getPackageName();
|
mParams.packageName = mContext.getPackageName();
|
||||||
mParams.setTitle(mContext.getString(R.string.unlock_dialog_title));
|
mParams.setTitle(mContext.getString(R.string.unlock_dialog_title));
|
||||||
|
|
||||||
mUnlockDialog = LayoutInflater.from(mContext).inflate(
|
mUnlockDialogLayout = LayoutInflater.from(mContext).inflate(
|
||||||
R.layout.trust_agent_unlock_dialog, null);
|
R.layout.trust_agent_unlock_dialog, null);
|
||||||
mUnlockDialog.setLayoutParams(mParams);
|
mUnlockDialogLayout.setLayoutParams(mParams);
|
||||||
|
|
||||||
mUnlockingText = mUnlockDialog.findViewById(R.id.unlocking_text);
|
View dialogParent = mUnlockDialogLayout.findViewById(R.id.unlock_dialog_parent);
|
||||||
mButton = mUnlockDialog.findViewById(R.id.enter_pin_button);
|
dialogParent.setOnTouchListener((v, event)-> {
|
||||||
|
hideUnlockDialog(/* dismissUserSwitcher= */ false);
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
View unlockDialog = mUnlockDialogLayout.findViewById(R.id.unlock_dialog);
|
||||||
|
unlockDialog.setOnTouchListener((v, event) -> {
|
||||||
|
// If the person taps inside the unlock dialog, the touch event will be intercepted here
|
||||||
|
// and the dialog will not exit
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
mUnlockingText = mUnlockDialogLayout.findViewById(R.id.unlocking_text);
|
||||||
|
mButton = mUnlockDialogLayout.findViewById(R.id.enter_pin_button);
|
||||||
mButton.setOnClickListener(v -> {
|
mButton.setOnClickListener(v -> {
|
||||||
hideUnlockDialog(/* notifyOnHideListener= */true);
|
hideUnlockDialog(/* dismissUserSwitcher= */true);
|
||||||
// TODO(b/138250105) Stop unlock advertising
|
// TODO(b/138250105) Stop unlock advertising
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -133,7 +144,7 @@ class CarTrustAgentUnlockDialogHelper extends BroadcastReceiver{
|
|||||||
if (!mUserManager.isUserUnlocked(uid)) {
|
if (!mUserManager.isUserUnlocked(uid)) {
|
||||||
logd("Showed unlock dialog for user: " + uid + " after " + delayMillis
|
logd("Showed unlock dialog for user: " + uid + " after " + delayMillis
|
||||||
+ " delay.");
|
+ " delay.");
|
||||||
mWindowManager.addView(mUnlockDialog, mParams);
|
mWindowManager.addView(mUnlockDialogLayout, mParams);
|
||||||
}
|
}
|
||||||
}, delayMillis);
|
}, delayMillis);
|
||||||
}
|
}
|
||||||
@@ -142,22 +153,22 @@ class CarTrustAgentUnlockDialogHelper extends BroadcastReceiver{
|
|||||||
|
|
||||||
private void setUid(int uid) {
|
private void setUid(int uid) {
|
||||||
mUid = uid;
|
mUid = uid;
|
||||||
TextView userName = mUnlockDialog.findViewById(R.id.user_name);
|
TextView userName = mUnlockDialogLayout.findViewById(R.id.user_name);
|
||||||
userName.setText(mUserManager.getUserInfo(mUid).name);
|
userName.setText(mUserManager.getUserInfo(mUid).name);
|
||||||
ImageView avatar = mUnlockDialog.findViewById(R.id.avatar);
|
ImageView avatar = mUnlockDialogLayout.findViewById(R.id.avatar);
|
||||||
avatar.setImageBitmap(mUserManager.getUserIcon(mUid));
|
avatar.setImageBitmap(mUserManager.getUserIcon(mUid));
|
||||||
setButtonText();
|
setButtonText();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void hideUnlockDialog(boolean notifyOnHideListener) {
|
private void hideUnlockDialog(boolean dismissUserSwitcher) {
|
||||||
if (!mIsDialogShowing) {
|
if (!mIsDialogShowing) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mWindowManager.removeView(mUnlockDialog);
|
mWindowManager.removeView(mUnlockDialogLayout);
|
||||||
logd("Receiver unregistered");
|
logd("Receiver unregistered");
|
||||||
mContext.unregisterReceiver(this);
|
mContext.unregisterReceiver(this);
|
||||||
if (notifyOnHideListener && mOnHideListener != null) {
|
if (mOnHideListener != null) {
|
||||||
mOnHideListener.onHide();
|
mOnHideListener.onHide(dismissUserSwitcher);
|
||||||
}
|
}
|
||||||
mIsDialogShowing = false;
|
mIsDialogShowing = false;
|
||||||
}
|
}
|
||||||
@@ -240,6 +251,6 @@ class CarTrustAgentUnlockDialogHelper extends BroadcastReceiver{
|
|||||||
* Listener used to notify when the dialog is hidden
|
* Listener used to notify when the dialog is hidden
|
||||||
*/
|
*/
|
||||||
interface OnHideListener {
|
interface OnHideListener {
|
||||||
void onHide();
|
void onHide(boolean dismissUserSwitcher);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import android.view.ViewStub;
|
|||||||
import androidx.recyclerview.widget.GridLayoutManager;
|
import androidx.recyclerview.widget.GridLayoutManager;
|
||||||
|
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
|
import com.android.systemui.statusbar.car.CarTrustAgentUnlockDialogHelper.OnHideListener;
|
||||||
import com.android.systemui.statusbar.car.UserGridRecyclerView.UserRecord;
|
import com.android.systemui.statusbar.car.UserGridRecyclerView.UserRecord;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -116,7 +117,7 @@ public class FullscreenUserSwitcher {
|
|||||||
// Show unlock dialog for initial user
|
// Show unlock dialog for initial user
|
||||||
if (hasTrustedDevice(initialUser)) {
|
if (hasTrustedDevice(initialUser)) {
|
||||||
mUnlockDialogHelper.showUnlockDialogAfterDelay(initialUser,
|
mUnlockDialogHelper.showUnlockDialogAfterDelay(initialUser,
|
||||||
() -> dismissUserSwitcher());
|
mOnHideListener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,7 +163,7 @@ public class FullscreenUserSwitcher {
|
|||||||
private void onUserSelected(UserGridRecyclerView.UserRecord record) {
|
private void onUserSelected(UserGridRecyclerView.UserRecord record) {
|
||||||
mSelectedUser = record;
|
mSelectedUser = record;
|
||||||
if (hasTrustedDevice(record.mInfo.id)) {
|
if (hasTrustedDevice(record.mInfo.id)) {
|
||||||
mUnlockDialogHelper.showUnlockDialog(record.mInfo.id, () -> dismissUserSwitcher());
|
mUnlockDialogHelper.showUnlockDialog(record.mInfo.id, mOnHideListener);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Log.isLoggable(TAG, Log.DEBUG)) {
|
if (Log.isLoggable(TAG, Log.DEBUG)) {
|
||||||
@@ -202,4 +203,18 @@ public class FullscreenUserSwitcher {
|
|||||||
private boolean hasTrustedDevice(int uid) {
|
private boolean hasTrustedDevice(int uid) {
|
||||||
return !mEnrollmentManager.getEnrolledDeviceInfoForUser(uid).isEmpty();
|
return !mEnrollmentManager.getEnrolledDeviceInfoForUser(uid).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private OnHideListener mOnHideListener = new OnHideListener() {
|
||||||
|
@Override
|
||||||
|
public void onHide(boolean dismissUserSwitcher) {
|
||||||
|
if (dismissUserSwitcher) {
|
||||||
|
dismissUserSwitcher();
|
||||||
|
} else {
|
||||||
|
// Re-draw the parent view, otherwise the unlock dialog will not be removed from
|
||||||
|
// the screen immediately.
|
||||||
|
mParent.invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user