Move lock icon view.

Fixes: 285154903
Bug: 286552209
Test: Observe lock icon view with flag on. Observe it when security
method is SWIPE/PIN

Change-Id: Id4332f3b551212c2061f30a1699e548b3c39031a
This commit is contained in:
Aaron Liu
2023-06-05 13:20:55 -07:00
parent 988c8309be
commit f7a6be9928
6 changed files with 67 additions and 23 deletions

View File

@@ -132,21 +132,6 @@
android:id="@+id/lock_icon_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<!-- Background protection -->
<ImageView
android:id="@+id/lock_icon_bg"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/fingerprint_bg"
android:visibility="invisible"/>
<ImageView
android:id="@+id/lock_icon"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:scaleType="centerCrop"/>
</com.android.keyguard.LockIconView>
<include

View File

@@ -211,4 +211,6 @@
<item type="id" name="keyguard_indication_area" />
<item type="id" name="keyguard_indication_text" />
<item type="id" name="keyguard_indication_text_bottom" />
<item type="id" name="lock_icon" />
<item type="id" name="lock_icon_bg" />
</resources>

View File

@@ -16,6 +16,8 @@
package com.android.keyguard;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Color;
@@ -23,6 +25,7 @@ import android.graphics.Point;
import android.graphics.RectF;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
@@ -68,13 +71,9 @@ public class LockIconView extends FrameLayout implements Dumpable {
public LockIconView(Context context, AttributeSet attrs) {
super(context, attrs);
mSensorRect = new RectF();
}
@Override
public void onFinishInflate() {
super.onFinishInflate();
mLockIcon = findViewById(R.id.lock_icon);
mBgView = findViewById(R.id.lock_icon_bg);
addBgImageView(context, attrs);
addLockIconImageView(context, attrs);
}
void setDozeAmount(float dozeAmount) {
@@ -184,6 +183,30 @@ public class LockIconView extends FrameLayout implements Dumpable {
mLockIcon.setImageState(getLockIconState(mIconType, mAod), true);
}
private void addLockIconImageView(Context context, AttributeSet attrs) {
mLockIcon = new ImageView(context, attrs);
mLockIcon.setId(R.id.lock_icon);
mLockIcon.setScaleType(ImageView.ScaleType.CENTER_CROP);
addView(mLockIcon);
LayoutParams lp = (LayoutParams) mLockIcon.getLayoutParams();
lp.height = MATCH_PARENT;
lp.width = MATCH_PARENT;
lp.gravity = Gravity.CENTER;
mLockIcon.setLayoutParams(lp);
}
private void addBgImageView(Context context, AttributeSet attrs) {
mBgView = new ImageView(context, attrs);
mBgView.setId(R.id.lock_icon_bg);
mBgView.setImageDrawable(context.getDrawable(R.drawable.fingerprint_bg));
mBgView.setVisibility(View.INVISIBLE);
addView(mBgView);
LayoutParams lp = (LayoutParams) mBgView.getLayoutParams();
lp.height = MATCH_PARENT;
lp.width = MATCH_PARENT;
mBgView.setLayoutParams(lp);
}
private static int[] getLockIconState(@IconType int icon, boolean aod) {
if (icon == ICON_NONE) {
return new int[0];

View File

@@ -249,11 +249,19 @@ object Flags {
@JvmField
val DELAY_BOUNCER = unreleasedFlag(235, "delay_bouncer")
/** Keyguard Migration */
/** Migrate the indication area to the new keyguard root view. */
// TODO(b/280067944): Tracking bug.
@JvmField
val MIGRATE_INDICATION_AREA = unreleasedFlag(236, "migrate_indication_area")
/** Migrate the lock icon view to the new keyguard root view. */
// TODO(b/286552209): Tracking bug.
@JvmField
val MIGRATE_LOCK_ICON = unreleasedFlag(238, "migrate_lock_icon")
/** Whether to listen for fingerprint authentication over keyguard occluding activities. */
// TODO(b/283260512): Tracking bug.
@JvmField

View File

@@ -47,9 +47,10 @@ constructor(
private var indicationAreaHandle: DisposableHandle? = null
override fun start() {
bindIndicationArea(
val notificationPanel =
notificationShadeWindowView.requireViewById(R.id.notification_panel) as ViewGroup
)
bindIndicationArea(notificationPanel)
bindLockIconView(notificationPanel)
}
fun bindIndicationArea(legacyParent: ViewGroup) {
@@ -74,4 +75,16 @@ constructor(
indicationController
)
}
private fun bindLockIconView(legacyParent: ViewGroup) {
if (featureFlags.isEnabled(Flags.MIGRATE_LOCK_ICON)) {
legacyParent.requireViewById<View>(R.id.lock_icon_view).let {
legacyParent.removeView(it)
}
} else {
keyguardRootView.findViewById<View?>(R.id.lock_icon_view)?.let {
keyguardRootView.removeView(it)
}
}
}
}

View File

@@ -23,6 +23,7 @@ import android.view.Gravity
import android.view.ViewGroup.LayoutParams.MATCH_PARENT
import android.view.ViewGroup.LayoutParams.WRAP_CONTENT
import android.widget.FrameLayout
import com.android.keyguard.LockIconView
import com.android.systemui.R
/** Provides a container for all keyguard ui content. */
@@ -37,6 +38,7 @@ class KeyguardRootView(
init {
addIndicationTextArea()
addLockIconView()
}
private fun addIndicationTextArea() {
@@ -54,6 +56,17 @@ class KeyguardRootView(
)
}
private fun addLockIconView() {
val view = LockIconView(context, attrs).apply { id = R.id.lock_icon_view }
addView(
view,
LayoutParams(
WRAP_CONTENT,
WRAP_CONTENT,
)
)
}
private fun Int.dp(): Int {
return context.resources.getDimensionPixelSize(this)
}