Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3316a2e0 authored by Beverly's avatar Beverly Committed by Automerger Merge Worker
Browse files

Animate in a background for kg unlock icon am: 09923d5e am: 07478ee9

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15289155

Change-Id: Ib4bde3f9c304ae706e6efbe4c8fc4940d79830df
parents b10b79c6 07478ee9
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -14,10 +14,11 @@
-->
<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="?android:attr/colorBackground"/>
      android:color="?androidprv:attr/colorSurface"/>

    <size
        android:width="64dp"
+17 −3
Original line number Diff line number Diff line
@@ -55,9 +55,23 @@
        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>

    <com.android.systemui.statusbar.phone.NotificationsQuickSettingsContainer
        android:layout_width="match_parent"
+94 −2
Original line number Diff line number Diff line
@@ -16,16 +16,29 @@

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;
@@ -33,16 +46,96 @@ import java.io.PrintWriter;
/**
 * 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 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;
@@ -70,7 +163,6 @@ public class LockIconView extends ImageView 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 + ")");
+6 −6
Original line number Diff line number Diff line
@@ -40,7 +40,6 @@ 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;
@@ -145,6 +144,7 @@ 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
@@ -224,6 +224,7 @@ 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);
@@ -234,9 +235,11 @@ 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);
        }
@@ -281,11 +284,7 @@ public class LockIconViewController extends ViewController<LockIconView> impleme
    }

    private void updateColors() {
        final int color = Utils.getColorAttrDefaultColor(mView.getContext(),
                R.attr.wallpaperTextColorAccent);
        mFpToUnlockIcon.setTint(color);
        mLockToUnlockIcon.setTint(color);
        mLockIcon.setTint(color);
        mView.updateColor();
    }

    private void updateConfiguration() {
@@ -445,6 +444,7 @@ public class LockIconViewController extends ViewController<LockIconView> impleme
        @Override
        public void onConfigChanged(Configuration newConfig) {
            updateConfiguration();
            updateColors();
        }
    };

+5 −0
Original line number Diff line number Diff line
@@ -162,7 +162,12 @@ public class UdfpsKeyguardView extends UdfpsAnimationView {
    }

    void updateColor() {
        mWallpaperTextColor = Utils.getColorAttrDefaultColor(mContext,
            R.attr.wallpaperTextColorAccent);
        mTextColorPrimary = Utils.getColorAttrDefaultColor(mContext,
            android.R.attr.textColorPrimary);
        mLockScreenFp.invalidate();
        mBgProtection.setBackground(getContext().getDrawable(R.drawable.fingerprint_bg));
    }

    private boolean showingUdfpsBouncer() {