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
This commit is contained in:
Yein Jo
2022-08-01 16:12:30 +00:00
parent a9aaecab10
commit 8c4a55d6a2
8 changed files with 46 additions and 35 deletions

View File

@@ -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;

View File

@@ -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);
float maxSize = Math.max(width, height);
mRippleView.setMaxSize(maxSize, maxSize);
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());
}

View File

@@ -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

View File

@@ -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;

View File

@@ -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) {

View File

@@ -39,7 +39,9 @@ private const val RIPPLE_DEFAULT_COLOR: Int = 0xffffffff.toInt()
open class RippleView(context: Context?, attrs: AttributeSet?) : View(context, attrs) {
private lateinit var rippleShader: RippleShader
private lateinit var rippleShape: RippleShape
lateinit var rippleShape: RippleShape
private set
private val ripplePaint = Paint()
var rippleInProgress: Boolean = false

View File

@@ -17,6 +17,7 @@ package com.android.systemui.ripple
/** Library class that contains 2D signed distance functions. */
class SdfShaderLibrary {
//language=AGSL
companion object {
const val CIRCLE_SDF = """
float sdCircle(vec2 p, float r) {

View File

@@ -31,7 +31,7 @@ import static androidx.core.view.ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_
import static androidx.lifecycle.Lifecycle.State.RESUMED;
import static com.android.systemui.Dependency.TIME_TICK_HANDLER_NAME;
import static com.android.systemui.charging.WirelessChargingLayout.UNKNOWN_BATTERY_LEVEL;
import static com.android.systemui.charging.WirelessChargingAnimation.UNKNOWN_BATTERY_LEVEL;
import static com.android.systemui.keyguard.WakefulnessLifecycle.WAKEFULNESS_ASLEEP;
import static com.android.systemui.statusbar.NotificationLockscreenUserManager.PERMISSION_SELF;
import static com.android.systemui.statusbar.phone.BarTransitions.MODE_LIGHTS_OUT;
@@ -172,6 +172,7 @@ import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.qs.QSFragment;
import com.android.systemui.qs.QSPanelController;
import com.android.systemui.recents.ScreenPinningRequest;
import com.android.systemui.ripple.RippleShader.RippleShape;
import com.android.systemui.scrim.ScrimView;
import com.android.systemui.settings.brightness.BrightnessSliderController;
import com.android.systemui.shade.NotificationPanelViewController;
@@ -2211,7 +2212,8 @@ public class CentralSurfacesImpl extends CoreStartable implements
public void onAnimationEnded() {
mNotificationShadeWindowController.setRequestTopUi(false, TAG);
}
}, false, sUiEventLogger).show(animationDelay);
}, /* isDozing= */ false, RippleShape.CIRCLE,
sUiEventLogger).show(animationDelay);
}
@Override