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

Commit 8c4a55d6 authored by Yein Jo's avatar Yein Jo
Browse files

Add a flag for rounded box charging ripple.

DockingAnimationCallback passes `rippleShape` in ag/19518997 (separating the CLs because they are in a different module.)

rounded box ripple: https://recall.googleplex.com/projects/5caa6343-713d-48a6-9354-df13859d3244/sessions/eaf63912-b4d2-4590-8af3-9748646e2b4d

Bug: b/237282686
Test: Manual
Change-Id: I074e1459893b31a6ff23c416eb710bc62bc67a87
parent a9aaecab
Loading
Loading
Loading
Loading
+14 −12
Original line number Diff line number Diff line
@@ -16,8 +16,6 @@

package com.android.systemui.charging;

import static com.android.systemui.charging.WirelessChargingLayout.UNKNOWN_BATTERY_LEVEL;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.Context;
@@ -32,13 +30,14 @@ import android.view.WindowManager;

import com.android.internal.logging.UiEvent;
import com.android.internal.logging.UiEventLogger;
import com.android.systemui.ripple.RippleShader.RippleShape;

/**
 * A WirelessChargingAnimation is a view containing view + animation for wireless charging.
 * @hide
 */
public class WirelessChargingAnimation {

    public static final int UNKNOWN_BATTERY_LEVEL = -1;
    public static final long DURATION = 1500;
    private static final String TAG = "WirelessChargingView";
    private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
@@ -58,11 +57,12 @@ public class WirelessChargingAnimation {
     * before calling {@link #show} - can be done through {@link #makeWirelessChargingAnimation}.
     * @hide
     */
    public WirelessChargingAnimation(@NonNull Context context, @Nullable Looper looper,
    private WirelessChargingAnimation(@NonNull Context context, @Nullable Looper looper,
            int transmittingBatteryLevel, int batteryLevel, Callback callback, boolean isDozing,
            UiEventLogger uiEventLogger) {
            RippleShape rippleShape, UiEventLogger uiEventLogger) {
        mCurrentWirelessChargingView = new WirelessChargingView(context, looper,
                transmittingBatteryLevel, batteryLevel, callback, isDozing, uiEventLogger);
                transmittingBatteryLevel, batteryLevel, callback, isDozing,
                rippleShape, uiEventLogger);
    }

    /**
@@ -72,9 +72,10 @@ public class WirelessChargingAnimation {
     */
    public static WirelessChargingAnimation makeWirelessChargingAnimation(@NonNull Context context,
            @Nullable Looper looper, int transmittingBatteryLevel, int batteryLevel,
            Callback callback, boolean isDozing, UiEventLogger uiEventLogger) {
            Callback callback, boolean isDozing, RippleShape rippleShape,
            UiEventLogger uiEventLogger) {
        return new WirelessChargingAnimation(context, looper, transmittingBatteryLevel,
                batteryLevel, callback, isDozing, uiEventLogger);
                batteryLevel, callback, isDozing, rippleShape, uiEventLogger);
    }

    /**
@@ -82,9 +83,10 @@ public class WirelessChargingAnimation {
     * battery level without charging number shown.
     */
    public static WirelessChargingAnimation makeChargingAnimationWithNoBatteryLevel(
            @NonNull Context context, UiEventLogger uiEventLogger) {
            @NonNull Context context, RippleShape rippleShape, UiEventLogger uiEventLogger) {
        return makeWirelessChargingAnimation(context, null,
                UNKNOWN_BATTERY_LEVEL, UNKNOWN_BATTERY_LEVEL, null, false, uiEventLogger);
                UNKNOWN_BATTERY_LEVEL, UNKNOWN_BATTERY_LEVEL, null, false,
                rippleShape, uiEventLogger);
    }

    /**
@@ -121,10 +123,10 @@ public class WirelessChargingAnimation {

        public WirelessChargingView(Context context, @Nullable Looper looper,
                int transmittingBatteryLevel, int batteryLevel, Callback callback,
                boolean isDozing, UiEventLogger uiEventLogger) {
                boolean isDozing, RippleShape rippleShape, UiEventLogger uiEventLogger) {
            mCallback = callback;
            mNextView = new WirelessChargingLayout(context, transmittingBatteryLevel, batteryLevel,
                    isDozing);
                    isDozing, rippleShape);
            mGravity = Gravity.CENTER_HORIZONTAL | Gravity.CENTER;
            mUiEventLogger = uiEventLogger;

+21 −19
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ import android.widget.TextView;
import com.android.settingslib.Utils;
import com.android.systemui.R;
import com.android.systemui.animation.Interpolators;
import com.android.systemui.ripple.RippleShader;
import com.android.systemui.ripple.RippleShader.RippleShape;
import com.android.systemui.ripple.RippleView;

import java.text.NumberFormat;
@@ -41,37 +41,36 @@ import java.text.NumberFormat;
/**
 * @hide
 */
public class WirelessChargingLayout extends FrameLayout {
    public static final int UNKNOWN_BATTERY_LEVEL = -1;
final class WirelessChargingLayout extends FrameLayout {
    private static final long RIPPLE_ANIMATION_DURATION = 1500;
    private static final int SCRIM_COLOR = 0x4C000000;
    private static final int SCRIM_FADE_DURATION = 300;
    private RippleView mRippleView;

    public WirelessChargingLayout(Context context) {
    WirelessChargingLayout(Context context, int transmittingBatteryLevel, int batteryLevel,
            boolean isDozing, RippleShape rippleShape) {
        super(context);
        init(context, null, false);
        init(context, null, transmittingBatteryLevel, batteryLevel, isDozing, rippleShape);
    }

    public WirelessChargingLayout(Context context, int transmittingBatteryLevel, int batteryLevel,
            boolean isDozing) {
    private WirelessChargingLayout(Context context) {
        super(context);
        init(context, null, transmittingBatteryLevel, batteryLevel, isDozing);
        init(context, null, /* isDozing= */ false, RippleShape.CIRCLE);
    }

    public WirelessChargingLayout(Context context, AttributeSet attrs) {
    private WirelessChargingLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context, attrs, false);
        init(context, attrs, /* isDozing= */false, RippleShape.CIRCLE);
    }

    private void init(Context c, AttributeSet attrs, boolean isDozing) {
        init(c, attrs, -1, -1, false);
    private void init(Context c, AttributeSet attrs, boolean isDozing, RippleShape rippleShape) {
        init(c, attrs, -1, -1, isDozing, rippleShape);
    }

    private void init(Context context, AttributeSet attrs, int transmittingBatteryLevel,
            int batteryLevel, boolean isDozing) {
            int batteryLevel, boolean isDozing, RippleShape rippleShape) {
        final boolean showTransmittingBatteryLevel =
                (transmittingBatteryLevel != UNKNOWN_BATTERY_LEVEL);
                (transmittingBatteryLevel != WirelessChargingAnimation.UNKNOWN_BATTERY_LEVEL);

        // set style based on background
        int style = R.style.ChargingAnim_WallpaperBackground;
@@ -84,7 +83,7 @@ public class WirelessChargingLayout extends FrameLayout {
        // amount of battery:
        final TextView percentage = findViewById(R.id.wireless_charging_percentage);

        if (batteryLevel != UNKNOWN_BATTERY_LEVEL) {
        if (batteryLevel != WirelessChargingAnimation.UNKNOWN_BATTERY_LEVEL) {
            percentage.setText(NumberFormat.getPercentInstance().format(batteryLevel / 100f));
            percentage.setAlpha(0);
        }
@@ -138,8 +137,7 @@ public class WirelessChargingLayout extends FrameLayout {
        animatorSetScrim.start();

        mRippleView = findViewById(R.id.wireless_charging_ripple);
        // TODO: Make rounded box shape if the device is tablet.
        mRippleView.setupShader(RippleShader.RippleShape.CIRCLE);
        mRippleView.setupShader(rippleShape);
        OnAttachStateChangeListener listener = new OnAttachStateChangeListener() {
            @Override
            public void onViewAttachedToWindow(View view) {
@@ -233,8 +231,12 @@ public class WirelessChargingLayout extends FrameLayout {
            int width = getMeasuredWidth();
            int height = getMeasuredHeight();
            mRippleView.setCenter(width * 0.5f, height * 0.5f);
            if (mRippleView.getRippleShape() == RippleShape.ROUNDED_BOX) {
                mRippleView.setMaxSize(width * 1.5f, height * 1.5f);
            } else {
                float maxSize = Math.max(width, height);
                mRippleView.setMaxSize(maxSize, maxSize);
            }
            mRippleView.setColor(Utils.getColorAttr(mRippleView.getContext(),
                    android.R.attr.colorAccent).getDefaultColor());
        }
+1 −0
Original line number Diff line number Diff line
@@ -185,6 +185,7 @@ public class Flags {
            new ReleasedFlag(1000);
    public static final ReleasedFlag DOCK_SETUP_ENABLED = new ReleasedFlag(1001);

    public static final UnreleasedFlag ROUNDED_BOX_RIPPLE = new UnreleasedFlag(1002, false);

    // 1100 - windowing
    @Keep
+1 −1
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ class RippleShader internal constructor(rippleShape: RippleShape = RippleShape.C
        ROUNDED_BOX,
        ELLIPSE
    }

    //language=AGSL
    companion object {
        private const val SHADER_UNIFORMS = """uniform vec2 in_center;
                uniform vec2 in_size;
+1 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ package com.android.systemui.ripple

/** A common utility functions that are used for computing [RippleShader]. */
class RippleShaderUtilLibrary {
    //language=AGSL
    companion object {
        const val SHADER_LIB = """
            float triangleNoise(vec2 n) {
Loading