Merge "Revert "Animate in a background for kg unlock icon"" into sc-dev
This commit is contained in:
@@ -14,11 +14,10 @@
|
||||
-->
|
||||
<shape
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
|
||||
android:shape="oval">
|
||||
|
||||
<solid
|
||||
android:color="?androidprv:attr/colorSurface"/>
|
||||
android:color="?android:attr/colorBackground"/>
|
||||
|
||||
<size
|
||||
android:width="64dp"
|
||||
|
||||
@@ -55,23 +55,9 @@
|
||||
android:id="@+id/lock_icon_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center">
|
||||
<!-- Background protection -->
|
||||
<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>
|
||||
android:padding="48px"
|
||||
android:layout_gravity="center"
|
||||
android:scaleType="centerCrop"/>
|
||||
|
||||
<com.android.systemui.statusbar.phone.NotificationsQuickSettingsContainer
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -16,29 +16,16 @@
|
||||
|
||||
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.res.ColorStateList;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.drawable.Drawable;
|
||||
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.ImageView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.android.settingslib.Utils;
|
||||
import com.android.systemui.Dumpable;
|
||||
import com.android.systemui.R;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.PrintWriter;
|
||||
@@ -46,96 +33,16 @@ import java.io.PrintWriter;
|
||||
/**
|
||||
* A view positioned under the notification shade.
|
||||
*/
|
||||
public class LockIconView extends FrameLayout implements Dumpable {
|
||||
public class LockIconView extends ImageView implements Dumpable {
|
||||
@NonNull private final RectF mSensorRect;
|
||||
@NonNull private PointF mLockIconCenter = new PointF(0f, 0f);
|
||||
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) {
|
||||
super(context, attrs);
|
||||
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) {
|
||||
mLockIconCenter = center;
|
||||
mRadius = radius;
|
||||
@@ -163,6 +70,7 @@ public class LockIconView extends FrameLayout implements Dumpable {
|
||||
return mLockIconCenter.y - mRadius;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void dump(@NonNull FileDescriptor fd, @NonNull PrintWriter pw, @NonNull String[] args) {
|
||||
pw.println("Center in px (x, y)= (" + mLockIconCenter.x + ", " + mLockIconCenter.y + ")");
|
||||
|
||||
@@ -43,6 +43,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
|
||||
|
||||
import com.android.settingslib.Utils;
|
||||
import com.android.systemui.Dumpable;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.biometrics.AuthController;
|
||||
@@ -158,7 +159,6 @@ public class LockIconViewController extends ViewController<LockIconView> impleme
|
||||
mUnlockedLabel = context.getResources().getString(R.string.accessibility_unlock_button);
|
||||
mLockedLabel = context.getResources().getString(R.string.accessibility_lock_icon);
|
||||
dumpManager.registerDumpable("LockIconViewController", this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -238,7 +238,6 @@ public class LockIconViewController extends ViewController<LockIconView> impleme
|
||||
mView.setImageDrawable(mLockIcon);
|
||||
mView.setVisibility(View.VISIBLE);
|
||||
mView.setContentDescription(mLockedLabel);
|
||||
mView.hideBg();
|
||||
} else if (mShowUnlockIcon) {
|
||||
if (wasShowingFpIcon) {
|
||||
mView.setImageDrawable(mFpToUnlockIcon);
|
||||
@@ -249,11 +248,9 @@ public class LockIconViewController extends ViewController<LockIconView> impleme
|
||||
mLockToUnlockIcon.forceAnimationOnUI();
|
||||
mLockToUnlockIcon.start();
|
||||
}
|
||||
mView.animateBg();
|
||||
mView.setVisibility(View.VISIBLE);
|
||||
mView.setContentDescription(mUnlockedLabel);
|
||||
} else {
|
||||
mView.hideBg();
|
||||
mView.setVisibility(View.INVISIBLE);
|
||||
mView.setContentDescription(null);
|
||||
}
|
||||
@@ -298,7 +295,11 @@ public class LockIconViewController extends ViewController<LockIconView> impleme
|
||||
}
|
||||
|
||||
private void updateColors() {
|
||||
mView.updateColor();
|
||||
final int color = Utils.getColorAttrDefaultColor(mView.getContext(),
|
||||
R.attr.wallpaperTextColorAccent);
|
||||
mFpToUnlockIcon.setTint(color);
|
||||
mLockToUnlockIcon.setTint(color);
|
||||
mLockIcon.setTint(color);
|
||||
}
|
||||
|
||||
private void updateConfiguration() {
|
||||
@@ -458,7 +459,6 @@ public class LockIconViewController extends ViewController<LockIconView> impleme
|
||||
@Override
|
||||
public void onConfigChanged(Configuration newConfig) {
|
||||
updateConfiguration();
|
||||
updateColors();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user