Animate in a background for kg unlock icon
- to indicate it is tappable - update background drawable on color change to update color Test: manual Fixes: 192403524 Change-Id: I34255e3f7cc7b1dfc246c4e2441822129abdf819
This commit is contained in:
@@ -14,10 +14,11 @@
|
|||||||
-->
|
-->
|
||||||
<shape
|
<shape
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
|
||||||
android:shape="oval">
|
android:shape="oval">
|
||||||
|
|
||||||
<solid
|
<solid
|
||||||
android:color="?android:attr/colorBackground"/>
|
android:color="?androidprv:attr/colorSurface"/>
|
||||||
|
|
||||||
<size
|
<size
|
||||||
android:width="64dp"
|
android:width="64dp"
|
||||||
|
|||||||
@@ -55,9 +55,23 @@
|
|||||||
android:id="@+id/lock_icon_view"
|
android:id="@+id/lock_icon_view"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:padding="48px"
|
android:layout_gravity="center">
|
||||||
android:layout_gravity="center"
|
<!-- Background protection -->
|
||||||
android:scaleType="centerCrop"/>
|
<ImageView
|
||||||
|
android:id="@+id/lock_icon_bg"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="@drawable/fingerprint_bg"
|
||||||
|
android:visibility="invisible"/>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/lock_icon"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:padding="48px"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:scaleType="centerCrop"/>
|
||||||
|
</com.android.keyguard.LockIconView>
|
||||||
|
|
||||||
<com.android.systemui.statusbar.phone.NotificationsQuickSettingsContainer
|
<com.android.systemui.statusbar.phone.NotificationsQuickSettingsContainer
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|||||||
@@ -16,16 +16,29 @@
|
|||||||
|
|
||||||
package com.android.keyguard;
|
package com.android.keyguard;
|
||||||
|
|
||||||
|
import android.animation.Animator;
|
||||||
|
import android.animation.AnimatorListenerAdapter;
|
||||||
|
import android.animation.AnimatorSet;
|
||||||
|
import android.animation.ArgbEvaluator;
|
||||||
|
import android.animation.ObjectAnimator;
|
||||||
|
import android.animation.ValueAnimator;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.res.ColorStateList;
|
||||||
import android.graphics.PointF;
|
import android.graphics.PointF;
|
||||||
import android.graphics.RectF;
|
import android.graphics.RectF;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.animation.Interpolator;
|
||||||
|
import android.view.animation.PathInterpolator;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import com.android.settingslib.Utils;
|
||||||
import com.android.systemui.Dumpable;
|
import com.android.systemui.Dumpable;
|
||||||
|
import com.android.systemui.R;
|
||||||
|
|
||||||
import java.io.FileDescriptor;
|
import java.io.FileDescriptor;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
@@ -33,16 +46,96 @@ import java.io.PrintWriter;
|
|||||||
/**
|
/**
|
||||||
* A view positioned under the notification shade.
|
* A view positioned under the notification shade.
|
||||||
*/
|
*/
|
||||||
public class LockIconView extends ImageView implements Dumpable {
|
public class LockIconView extends FrameLayout implements Dumpable {
|
||||||
@NonNull private final RectF mSensorRect;
|
@NonNull private final RectF mSensorRect;
|
||||||
@NonNull private PointF mLockIconCenter = new PointF(0f, 0f);
|
@NonNull private PointF mLockIconCenter = new PointF(0f, 0f);
|
||||||
private int mRadius;
|
private int mRadius;
|
||||||
|
|
||||||
|
private ImageView mLockIcon;
|
||||||
|
private ImageView mUnlockBgView;
|
||||||
|
|
||||||
|
private AnimatorSet mBgAnimator;
|
||||||
|
private int mLockIconColor;
|
||||||
|
private int mUnlockStartColor;
|
||||||
|
private int mUnlockEndColor;
|
||||||
|
|
||||||
public LockIconView(Context context, AttributeSet attrs) {
|
public LockIconView(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
mSensorRect = new RectF();
|
mSensorRect = new RectF();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFinishInflate() {
|
||||||
|
super.onFinishInflate();
|
||||||
|
mLockIcon = findViewById(R.id.lock_icon);
|
||||||
|
mUnlockBgView = findViewById(R.id.lock_icon_bg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateColor() {
|
||||||
|
mLockIconColor = Utils.getColorAttrDefaultColor(getContext(),
|
||||||
|
R.attr.wallpaperTextColorAccent);
|
||||||
|
mUnlockStartColor = mLockIconColor;
|
||||||
|
mUnlockEndColor = Utils.getColorAttrDefaultColor(getContext(),
|
||||||
|
android.R.attr.textColorPrimary);
|
||||||
|
mUnlockBgView.setBackground(getContext().getDrawable(R.drawable.fingerprint_bg));
|
||||||
|
}
|
||||||
|
|
||||||
|
void setImageDrawable(Drawable drawable) {
|
||||||
|
mLockIcon.setImageDrawable(drawable);
|
||||||
|
}
|
||||||
|
|
||||||
|
void hideBg() {
|
||||||
|
mUnlockBgView.setVisibility(View.INVISIBLE);
|
||||||
|
mLockIcon.setImageTintList(ColorStateList.valueOf(mLockIconColor));
|
||||||
|
}
|
||||||
|
|
||||||
|
void animateBg() {
|
||||||
|
ValueAnimator bgAlphaAnimator = ObjectAnimator.ofFloat(mUnlockBgView, View.ALPHA, 0f, 1f);
|
||||||
|
bgAlphaAnimator.setDuration(133);
|
||||||
|
|
||||||
|
Interpolator interpolator = new PathInterpolator(0f, 0f, 0f, 1f);
|
||||||
|
Animator scaleXAnimator = ObjectAnimator.ofFloat(mUnlockBgView, View.SCALE_X, .9f, 1f);
|
||||||
|
scaleXAnimator.setInterpolator(interpolator);
|
||||||
|
scaleXAnimator.setDuration(300);
|
||||||
|
Animator scaleYAnimator = ObjectAnimator.ofFloat(mUnlockBgView, View.SCALE_Y, .9f, 1f);
|
||||||
|
scaleYAnimator.setDuration(300);
|
||||||
|
scaleYAnimator.setInterpolator(interpolator);
|
||||||
|
|
||||||
|
ValueAnimator lockIconColorAnimator =
|
||||||
|
ValueAnimator.ofObject(new ArgbEvaluator(), mUnlockStartColor, mUnlockEndColor);
|
||||||
|
lockIconColorAnimator.addUpdateListener(
|
||||||
|
animation -> mLockIcon.setImageTintList(
|
||||||
|
ColorStateList.valueOf((int) animation.getAnimatedValue())));
|
||||||
|
lockIconColorAnimator.setDuration(150);
|
||||||
|
|
||||||
|
if (mBgAnimator != null) {
|
||||||
|
if (mBgAnimator.isRunning()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mBgAnimator.cancel();
|
||||||
|
}
|
||||||
|
mBgAnimator = new AnimatorSet();
|
||||||
|
mBgAnimator.addListener(new AnimatorListenerAdapter() {
|
||||||
|
@Override
|
||||||
|
public void onAnimationEnd(Animator animation) {
|
||||||
|
super.onAnimationEnd(animation);
|
||||||
|
mBgAnimator = null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
mBgAnimator.playTogether(
|
||||||
|
bgAlphaAnimator,
|
||||||
|
scaleYAnimator,
|
||||||
|
scaleXAnimator,
|
||||||
|
lockIconColorAnimator);
|
||||||
|
mBgAnimator.setStartDelay(167);
|
||||||
|
mUnlockBgView.setAlpha(0f);
|
||||||
|
mUnlockBgView.setScaleX(0);
|
||||||
|
mUnlockBgView.setScaleY(0);
|
||||||
|
mUnlockBgView.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
mBgAnimator.start();
|
||||||
|
}
|
||||||
|
|
||||||
void setCenterLocation(@NonNull PointF center, int radius) {
|
void setCenterLocation(@NonNull PointF center, int radius) {
|
||||||
mLockIconCenter = center;
|
mLockIconCenter = center;
|
||||||
mRadius = radius;
|
mRadius = radius;
|
||||||
@@ -70,7 +163,6 @@ public class LockIconView extends ImageView implements Dumpable {
|
|||||||
return mLockIconCenter.y - mRadius;
|
return mLockIconCenter.y - mRadius;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dump(@NonNull FileDescriptor fd, @NonNull PrintWriter pw, @NonNull String[] args) {
|
public void dump(@NonNull FileDescriptor fd, @NonNull PrintWriter pw, @NonNull String[] args) {
|
||||||
pw.println("Center in px (x, y)= (" + mLockIconCenter.x + ", " + mLockIconCenter.y + ")");
|
pw.println("Center in px (x, y)= (" + mLockIconCenter.x + ", " + mLockIconCenter.y + ")");
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ import androidx.annotation.NonNull;
|
|||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
|
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
|
||||||
|
|
||||||
import com.android.settingslib.Utils;
|
|
||||||
import com.android.systemui.Dumpable;
|
import com.android.systemui.Dumpable;
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
import com.android.systemui.biometrics.AuthController;
|
import com.android.systemui.biometrics.AuthController;
|
||||||
@@ -145,6 +144,7 @@ public class LockIconViewController extends ViewController<LockIconView> impleme
|
|||||||
mUnlockedLabel = context.getResources().getString(R.string.accessibility_unlock_button);
|
mUnlockedLabel = context.getResources().getString(R.string.accessibility_unlock_button);
|
||||||
mLockedLabel = context.getResources().getString(R.string.accessibility_lock_icon);
|
mLockedLabel = context.getResources().getString(R.string.accessibility_lock_icon);
|
||||||
dumpManager.registerDumpable("LockIconViewController", this);
|
dumpManager.registerDumpable("LockIconViewController", this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -224,6 +224,7 @@ public class LockIconViewController extends ViewController<LockIconView> impleme
|
|||||||
mView.setImageDrawable(mLockIcon);
|
mView.setImageDrawable(mLockIcon);
|
||||||
mView.setVisibility(View.VISIBLE);
|
mView.setVisibility(View.VISIBLE);
|
||||||
mView.setContentDescription(mLockedLabel);
|
mView.setContentDescription(mLockedLabel);
|
||||||
|
mView.hideBg();
|
||||||
} else if (mShowUnlockIcon) {
|
} else if (mShowUnlockIcon) {
|
||||||
if (wasShowingFpIcon) {
|
if (wasShowingFpIcon) {
|
||||||
mView.setImageDrawable(mFpToUnlockIcon);
|
mView.setImageDrawable(mFpToUnlockIcon);
|
||||||
@@ -234,9 +235,11 @@ public class LockIconViewController extends ViewController<LockIconView> impleme
|
|||||||
mLockToUnlockIcon.forceAnimationOnUI();
|
mLockToUnlockIcon.forceAnimationOnUI();
|
||||||
mLockToUnlockIcon.start();
|
mLockToUnlockIcon.start();
|
||||||
}
|
}
|
||||||
|
mView.animateBg();
|
||||||
mView.setVisibility(View.VISIBLE);
|
mView.setVisibility(View.VISIBLE);
|
||||||
mView.setContentDescription(mUnlockedLabel);
|
mView.setContentDescription(mUnlockedLabel);
|
||||||
} else {
|
} else {
|
||||||
|
mView.hideBg();
|
||||||
mView.setVisibility(View.INVISIBLE);
|
mView.setVisibility(View.INVISIBLE);
|
||||||
mView.setContentDescription(null);
|
mView.setContentDescription(null);
|
||||||
}
|
}
|
||||||
@@ -281,11 +284,7 @@ public class LockIconViewController extends ViewController<LockIconView> impleme
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateColors() {
|
private void updateColors() {
|
||||||
final int color = Utils.getColorAttrDefaultColor(mView.getContext(),
|
mView.updateColor();
|
||||||
R.attr.wallpaperTextColorAccent);
|
|
||||||
mFpToUnlockIcon.setTint(color);
|
|
||||||
mLockToUnlockIcon.setTint(color);
|
|
||||||
mLockIcon.setTint(color);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateConfiguration() {
|
private void updateConfiguration() {
|
||||||
@@ -445,6 +444,7 @@ public class LockIconViewController extends ViewController<LockIconView> impleme
|
|||||||
@Override
|
@Override
|
||||||
public void onConfigChanged(Configuration newConfig) {
|
public void onConfigChanged(Configuration newConfig) {
|
||||||
updateConfiguration();
|
updateConfiguration();
|
||||||
|
updateColors();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -162,7 +162,12 @@ public class UdfpsKeyguardView extends UdfpsAnimationView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void updateColor() {
|
void updateColor() {
|
||||||
|
mWallpaperTextColor = Utils.getColorAttrDefaultColor(mContext,
|
||||||
|
R.attr.wallpaperTextColorAccent);
|
||||||
|
mTextColorPrimary = Utils.getColorAttrDefaultColor(mContext,
|
||||||
|
android.R.attr.textColorPrimary);
|
||||||
mLockScreenFp.invalidate();
|
mLockScreenFp.invalidate();
|
||||||
|
mBgProtection.setBackground(getContext().getDrawable(R.drawable.fingerprint_bg));
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean showingUdfpsBouncer() {
|
private boolean showingUdfpsBouncer() {
|
||||||
|
|||||||
Reference in New Issue
Block a user