diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java index c56f50e193..59f014e7b1 100644 --- a/src/com/android/launcher3/BubbleTextView.java +++ b/src/com/android/launcher3/BubbleTextView.java @@ -23,7 +23,6 @@ import static android.text.Layout.Alignment.ALIGN_NORMAL; import static com.android.launcher3.BubbleTextView.RunningAppState.RUNNING; import static com.android.launcher3.BubbleTextView.RunningAppState.MINIMIZED; import static com.android.launcher3.Flags.enableContrastTiles; -import static com.android.launcher3.Flags.enableCursorHoverStates; import static com.android.launcher3.Flags.enableScalabilityForDesktopExperience; import static com.android.launcher3.allapps.AlphabeticalAppsList.PRIVATE_SPACE_PACKAGE; import static com.android.launcher3.graphics.PreloadIconDrawable.newPendingIcon; @@ -251,7 +250,6 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, public BubbleTextView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); mActivity = ActivityContext.lookupContext(context); - FastBitmapDrawable.setFlagHoverEnabled(enableCursorHoverStates()); mMinimizedStateDescription = getContext().getString( R.string.app_minimized_state_description); mRunningStateDescription = getContext().getString(R.string.app_running_state_description); @@ -1203,7 +1201,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, if (mIcon instanceof PreloadIconDrawable p) { pid = p; pid.setLevel(progressLevel); - pid.setIsDisabled(isIconDisabled(info)); + pid.setDisabled(isIconDisabled(info)); } else { pid = makePreloadIcon(info); setIcon(pid); @@ -1226,7 +1224,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, final PreloadIconDrawable preloadDrawable = newPendingIcon(getContext(), info); preloadDrawable.setLevel(progressLevel); - preloadDrawable.setIsDisabled(isIconDisabled(info)); + preloadDrawable.setDisabled(isIconDisabled(info)); return preloadDrawable; } @@ -1337,7 +1335,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, /** Sets the icon visual state to disabled or not. */ public void setIconDisabled(boolean isDisabled) { if (mIcon != null) { - mIcon.setIsDisabled(isDisabled); + mIcon.setDisabled(isDisabled); } } diff --git a/src/com/android/launcher3/apppairs/AppPairIconGraphic.kt b/src/com/android/launcher3/apppairs/AppPairIconGraphic.kt index 81a92f689b..88e1d4cc2f 100644 --- a/src/com/android/launcher3/apppairs/AppPairIconGraphic.kt +++ b/src/com/android/launcher3/apppairs/AppPairIconGraphic.kt @@ -56,8 +56,8 @@ constructor(context: Context, attrs: AttributeSet? = null) : // If icons are unlaunchable due to screen size, manually override disabled appearance. // (otherwise, leave disabled state alone; icons will naturally inherit the app's state) val (isApp1Launchable, isApp2Launchable) = appPairInfo.isLaunchable(p.context) - if (!isApp1Launchable) appIcon1.setIsDisabled(true) - if (!isApp2Launchable) appIcon2.setIsDisabled(true) + if (!isApp1Launchable) appIcon1.isDisabled = true + if (!isApp2Launchable) appIcon2.isDisabled = true // Create icon drawable. val fullIconDrawable = AppPairIconDrawable(p, appIcon1, appIcon2) diff --git a/src/com/android/launcher3/graphics/PreloadIconDrawable.java b/src/com/android/launcher3/graphics/PreloadIconDrawable.java index ab390aa3d2..ccf64a7f18 100644 --- a/src/com/android/launcher3/graphics/PreloadIconDrawable.java +++ b/src/com/android/launcher3/graphics/PreloadIconDrawable.java @@ -182,7 +182,7 @@ public class PreloadIconDrawable extends FastBitmapDrawable { setLevel(info.getProgressLevel()); // Set a disabled icon color if the app is suspended or if the app is pending download - setIsDisabled(info.isDisabled() || info.isPendingDownload()); + setDisabled(info.isDisabled() || info.isPendingDownload()); } @Override @@ -440,7 +440,7 @@ public class PreloadIconDrawable extends FastBitmapDrawable { @Override public FastBitmapConstantState newConstantState() { return new PreloadIconConstantState( - mBitmapInfo, + bitmapInfo, mItem, mIndicatorColor, new int[] {mSystemAccentColor, mSystemBackgroundColor}, diff --git a/src/com/android/launcher3/model/data/ItemInfoWithIcon.java b/src/com/android/launcher3/model/data/ItemInfoWithIcon.java index f5e5e16b9e..57c3b367be 100644 --- a/src/com/android/launcher3/model/data/ItemInfoWithIcon.java +++ b/src/com/android/launcher3/model/data/ItemInfoWithIcon.java @@ -332,7 +332,7 @@ public abstract class ItemInfoWithIcon extends ItemInfo { } FastBitmapDrawable drawable = bitmap.newIcon( context, creationFlags, Utilities.getIconShapeOrNull(context)); - drawable.setIsDisabled(isDisabled()); + drawable.setDisabled(isDisabled()); return drawable; } diff --git a/src/com/android/launcher3/views/IconButtonView.java b/src/com/android/launcher3/views/IconButtonView.java index 0ac1919485..ab48524135 100644 --- a/src/com/android/launcher3/views/IconButtonView.java +++ b/src/com/android/launcher3/views/IconButtonView.java @@ -121,7 +121,7 @@ public class IconButtonView extends BubbleTextView { @TargetApi(Build.VERSION_CODES.TIRAMISU) IconDrawable(Bitmap b, int colorBg, Drawable fg) { super(b); - mPaint.setColorFilter(new BlendModeColorFilter(colorBg, BlendMode.SRC_IN)); + paint.setColorFilter(new BlendModeColorFilter(colorBg, BlendMode.SRC_IN)); mFg = fg; } diff --git a/src/com/android/launcher3/widget/PendingAppWidgetHostView.java b/src/com/android/launcher3/widget/PendingAppWidgetHostView.java index 8e9cf6f226..d0ada4062d 100644 --- a/src/com/android/launcher3/widget/PendingAppWidgetHostView.java +++ b/src/com/android/launcher3/widget/PendingAppWidgetHostView.java @@ -306,7 +306,7 @@ public class PendingAppWidgetHostView extends LauncherAppWidgetHostView // 3) App icon in the center with a setup icon on the top left corner. if (mDisabledForSafeMode) { FastBitmapDrawable disabledIcon = info.newIcon(getContext()); - disabledIcon.setIsDisabled(true); + disabledIcon.setDisabled(true); mCenterDrawable = disabledIcon; mSettingIconDrawable = null; } else if (isReadyForClickSetup()) { diff --git a/tests/multivalentTests/src/com/android/launcher3/icons/FastBitmapDrawableTest.java b/tests/multivalentTests/src/com/android/launcher3/icons/FastBitmapDrawableTest.java index 58dce0b3dd..47e2698655 100644 --- a/tests/multivalentTests/src/com/android/launcher3/icons/FastBitmapDrawableTest.java +++ b/tests/multivalentTests/src/com/android/launcher3/icons/FastBitmapDrawableTest.java @@ -65,10 +65,9 @@ public class FastBitmapDrawableTest { @Before public void setUp() { MockitoAnnotations.initMocks(this); - FastBitmapDrawable.setFlagHoverEnabled(true); when(mFastBitmapDrawable.isVisible()).thenReturn(true); - mFastBitmapDrawable.mIsPressed = false; - mFastBitmapDrawable.mIsHovered = false; + mFastBitmapDrawable.isPressed = false; + mFastBitmapDrawable.isHovered = false; mFastBitmapDrawable.resetScale(); } @@ -80,7 +79,7 @@ public class FastBitmapDrawableTest { // No scale changes without state change. assertFalse("State change handled.", isHandled); - assertNull("Scale animation not null.", mFastBitmapDrawable.mScaleAnimation); + assertNull("Scale animation not null.", mFastBitmapDrawable.scaleAnimation); } @Test @@ -91,13 +90,13 @@ public class FastBitmapDrawableTest { // Animate to state pressed. assertTrue("State change not handled.", isHandled); - assertEquals("Duration not correct.", mFastBitmapDrawable.mScaleAnimation.getDuration(), + assertEquals("Duration not correct.", mFastBitmapDrawable.scaleAnimation.getDuration(), CLICK_FEEDBACK_DURATION); - mFastBitmapDrawable.mScaleAnimation.end(); + mFastBitmapDrawable.scaleAnimation.end(); assertEquals("End value not correct.", (float) SCALE.get(mFastBitmapDrawable), PRESSED_SCALE, EPSILON); assertTrue("Wrong interpolator used.", - mFastBitmapDrawable.mScaleAnimation.getInterpolator() + mFastBitmapDrawable.scaleAnimation.getInterpolator() instanceof AccelerateInterpolator); } @@ -109,26 +108,13 @@ public class FastBitmapDrawableTest { // Animate to state hovered. assertTrue("State change not handled.", isHandled); - assertEquals("Duration not correct.", mFastBitmapDrawable.mScaleAnimation.getDuration(), + assertEquals("Duration not correct.", mFastBitmapDrawable.scaleAnimation.getDuration(), HOVER_FEEDBACK_DURATION); - mFastBitmapDrawable.mScaleAnimation.end(); + mFastBitmapDrawable.scaleAnimation.end(); assertEquals("End value not correct.", (float) SCALE.get(mFastBitmapDrawable), HOVERED_SCALE, EPSILON); assertTrue("Wrong interpolator used.", - mFastBitmapDrawable.mScaleAnimation.getInterpolator() instanceof PathInterpolator); - } - - @Test - public void testOnStateChange_stateHoveredFlagDisabled() { - FastBitmapDrawable.setFlagHoverEnabled(false); - int[] state = new int[]{android.R.attr.state_hovered}; - - boolean isHandled = mFastBitmapDrawable.onStateChange(state); - - // No state change with flag disabled. - assertFalse("Hover state change handled with flag disabled.", isHandled); - assertNull("Animation should not run with hover flag disabled.", - mFastBitmapDrawable.mScaleAnimation); + mFastBitmapDrawable.scaleAnimation.getInterpolator() instanceof PathInterpolator); } @Test @@ -139,13 +125,13 @@ public class FastBitmapDrawableTest { // Animate to pressed state only. assertTrue("State change not handled.", isHandled); - assertEquals("Duration not correct.", mFastBitmapDrawable.mScaleAnimation.getDuration(), + assertEquals("Duration not correct.", mFastBitmapDrawable.scaleAnimation.getDuration(), CLICK_FEEDBACK_DURATION); - mFastBitmapDrawable.mScaleAnimation.end(); + mFastBitmapDrawable.scaleAnimation.end(); assertEquals("End value not correct.", (float) SCALE.get(mFastBitmapDrawable), PRESSED_SCALE, EPSILON); assertTrue("Wrong interpolator used.", - mFastBitmapDrawable.mScaleAnimation.getInterpolator() + mFastBitmapDrawable.scaleAnimation.getInterpolator() instanceof AccelerateInterpolator); } @@ -157,20 +143,20 @@ public class FastBitmapDrawableTest { // Animate to pressed state only. assertTrue("State change not handled.", isHandled); - assertEquals("Duration not correct.", mFastBitmapDrawable.mScaleAnimation.getDuration(), + assertEquals("Duration not correct.", mFastBitmapDrawable.scaleAnimation.getDuration(), CLICK_FEEDBACK_DURATION); - mFastBitmapDrawable.mScaleAnimation.end(); + mFastBitmapDrawable.scaleAnimation.end(); assertEquals("End value not correct.", (float) SCALE.get(mFastBitmapDrawable), PRESSED_SCALE, EPSILON); assertTrue("Wrong interpolator used.", - mFastBitmapDrawable.mScaleAnimation.getInterpolator() + mFastBitmapDrawable.scaleAnimation.getInterpolator() instanceof AccelerateInterpolator); } @Test public void testOnStateChange_stateHoveredAndPressedToPressed() { - mFastBitmapDrawable.mIsPressed = true; - mFastBitmapDrawable.mIsHovered = true; + mFastBitmapDrawable.isPressed = true; + mFastBitmapDrawable.isHovered = true; SCALE.setValue(mFastBitmapDrawable, PRESSED_SCALE); int[] state = new int[]{android.R.attr.state_pressed}; @@ -184,8 +170,8 @@ public class FastBitmapDrawableTest { @Test public void testOnStateChange_stateHoveredAndPressedToHovered() { - mFastBitmapDrawable.mIsPressed = true; - mFastBitmapDrawable.mIsHovered = true; + mFastBitmapDrawable.isPressed = true; + mFastBitmapDrawable.isHovered = true; SCALE.setValue(mFastBitmapDrawable, PRESSED_SCALE); int[] state = new int[]{android.R.attr.state_hovered}; @@ -199,7 +185,7 @@ public class FastBitmapDrawableTest { @Test public void testOnStateChange_stateHoveredToPressed() { - mFastBitmapDrawable.mIsHovered = true; + mFastBitmapDrawable.isHovered = true; SCALE.setValue(mFastBitmapDrawable, HOVERED_SCALE); int[] state = new int[]{android.R.attr.state_pressed}; @@ -213,7 +199,7 @@ public class FastBitmapDrawableTest { @Test public void testOnStateChange_statePressedToHovered() { - mFastBitmapDrawable.mIsPressed = true; + mFastBitmapDrawable.isPressed = true; SCALE.setValue(mFastBitmapDrawable, PRESSED_SCALE); int[] state = new int[]{android.R.attr.state_hovered}; @@ -227,7 +213,7 @@ public class FastBitmapDrawableTest { @Test public void testOnStateChange_stateDefaultFromPressed() { - mFastBitmapDrawable.mIsPressed = true; + mFastBitmapDrawable.isPressed = true; SCALE.setValue(mFastBitmapDrawable, PRESSED_SCALE); int[] state = new int[]{}; @@ -235,18 +221,18 @@ public class FastBitmapDrawableTest { // Animate to default state from pressed state. assertTrue("State change not handled.", isHandled); - assertEquals("Duration not correct.", mFastBitmapDrawable.mScaleAnimation.getDuration(), + assertEquals("Duration not correct.", mFastBitmapDrawable.scaleAnimation.getDuration(), CLICK_FEEDBACK_DURATION); - mFastBitmapDrawable.mScaleAnimation.end(); + mFastBitmapDrawable.scaleAnimation.end(); assertEquals("End value not correct.", (float) SCALE.get(mFastBitmapDrawable), 1f, EPSILON); assertTrue("Wrong interpolator used.", - mFastBitmapDrawable.mScaleAnimation.getInterpolator() + mFastBitmapDrawable.scaleAnimation.getInterpolator() instanceof DecelerateInterpolator); } @Test public void testOnStateChange_stateDefaultFromHovered() { - mFastBitmapDrawable.mIsHovered = true; + mFastBitmapDrawable.isHovered = true; SCALE.setValue(mFastBitmapDrawable, HOVERED_SCALE); int[] state = new int[]{}; @@ -254,12 +240,12 @@ public class FastBitmapDrawableTest { // Animate to default state from hovered state. assertTrue("State change not handled.", isHandled); - assertEquals("Duration not correct.", mFastBitmapDrawable.mScaleAnimation.getDuration(), + assertEquals("Duration not correct.", mFastBitmapDrawable.scaleAnimation.getDuration(), HOVER_FEEDBACK_DURATION); - mFastBitmapDrawable.mScaleAnimation.end(); + mFastBitmapDrawable.scaleAnimation.end(); assertEquals("End value not correct.", (float) SCALE.get(mFastBitmapDrawable), 1f, EPSILON); assertTrue("Wrong interpolator used.", - mFastBitmapDrawable.mScaleAnimation.getInterpolator() instanceof PathInterpolator); + mFastBitmapDrawable.scaleAnimation.getInterpolator() instanceof PathInterpolator); } @Test @@ -272,12 +258,12 @@ public class FastBitmapDrawableTest { // Animate to hovered state from midway to pressed state. assertTrue("State change not handled.", isHandled); assertEquals("Duration not correct.", - mFastBitmapDrawable.mScaleAnimation.getDuration(), HOVER_FEEDBACK_DURATION); - mFastBitmapDrawable.mScaleAnimation.end(); + mFastBitmapDrawable.scaleAnimation.getDuration(), HOVER_FEEDBACK_DURATION); + mFastBitmapDrawable.scaleAnimation.end(); assertEquals("End value not correct.", (float) SCALE.get(mFastBitmapDrawable), HOVERED_SCALE, EPSILON); assertTrue("Wrong interpolator used.", - mFastBitmapDrawable.mScaleAnimation.getInterpolator() instanceof PathInterpolator); + mFastBitmapDrawable.scaleAnimation.getInterpolator() instanceof PathInterpolator); } @Test @@ -290,19 +276,19 @@ public class FastBitmapDrawableTest { // Animate to pressed state from midway to hovered state. assertTrue("State change not handled.", isHandled); assertEquals("Duration not correct.", - mFastBitmapDrawable.mScaleAnimation.getDuration(), CLICK_FEEDBACK_DURATION); - mFastBitmapDrawable.mScaleAnimation.end(); + mFastBitmapDrawable.scaleAnimation.getDuration(), CLICK_FEEDBACK_DURATION); + mFastBitmapDrawable.scaleAnimation.end(); assertEquals("End value not correct.", (float) SCALE.get(mFastBitmapDrawable), PRESSED_SCALE, EPSILON); assertTrue("Wrong interpolator used.", - mFastBitmapDrawable.mScaleAnimation.getInterpolator() + mFastBitmapDrawable.scaleAnimation.getInterpolator() instanceof AccelerateInterpolator); } @Test public void testOnStateChange_stateDefaultFromPressedNotVisible() { when(mFastBitmapDrawable.isVisible()).thenReturn(false); - mFastBitmapDrawable.mIsPressed = true; + mFastBitmapDrawable.isPressed = true; SCALE.setValue(mFastBitmapDrawable, PRESSED_SCALE); clearInvocations(mFastBitmapDrawable); int[] state = new int[]{}; @@ -311,7 +297,7 @@ public class FastBitmapDrawableTest { // No animations when state was pressed but drawable no longer visible. Set values directly. assertTrue("State change not handled.", isHandled); - assertNull("Scale animation not null.", mFastBitmapDrawable.mScaleAnimation); + assertNull("Scale animation not null.", mFastBitmapDrawable.scaleAnimation); assertEquals("End value not correct.", (float) SCALE.get(mFastBitmapDrawable), 1f, EPSILON); verify(mFastBitmapDrawable).invalidateSelf(); } @@ -319,7 +305,7 @@ public class FastBitmapDrawableTest { @Test public void testOnStateChange_stateDefaultFromHoveredNotVisible() { when(mFastBitmapDrawable.isVisible()).thenReturn(false); - mFastBitmapDrawable.mIsHovered = true; + mFastBitmapDrawable.isHovered = true; SCALE.setValue(mFastBitmapDrawable, HOVERED_SCALE); clearInvocations(mFastBitmapDrawable); int[] state = new int[]{}; @@ -328,7 +314,7 @@ public class FastBitmapDrawableTest { // No animations when state was hovered but drawable no longer visible. Set values directly. assertTrue("State change not handled.", isHandled); - assertNull("Scale animation not null.", mFastBitmapDrawable.mScaleAnimation); + assertNull("Scale animation not null.", mFastBitmapDrawable.scaleAnimation); assertEquals("End value not correct.", (float) SCALE.get(mFastBitmapDrawable), 1f, EPSILON); verify(mFastBitmapDrawable).invalidateSelf(); } diff --git a/tests/src/com/android/launcher3/folder/PreviewItemManagerTest.kt b/tests/src/com/android/launcher3/folder/PreviewItemManagerTest.kt index a13c325fb2..2eac5c0036 100644 --- a/tests/src/com/android/launcher3/folder/PreviewItemManagerTest.kt +++ b/tests/src/com/android/launcher3/folder/PreviewItemManagerTest.kt @@ -134,7 +134,7 @@ class PreviewItemManagerTest { previewItemManager.setDrawable(drawingParams, folderItems[0]) - assert((drawingParams.drawable as FastBitmapDrawable).isThemed) + assert((drawingParams.drawable as FastBitmapDrawable).isThemed()) } @Test @@ -144,7 +144,7 @@ class PreviewItemManagerTest { previewItemManager.setDrawable(drawingParams, folderItems[0]) - assert(!(drawingParams.drawable as FastBitmapDrawable).isThemed) + assert(!(drawingParams.drawable as FastBitmapDrawable).isThemed()) } @Test @@ -154,7 +154,7 @@ class PreviewItemManagerTest { previewItemManager.setDrawable(drawingParams, folderItems[1]) - assert(!(drawingParams.drawable as FastBitmapDrawable).isThemed) + assert(!(drawingParams.drawable as FastBitmapDrawable).isThemed()) } @Test @@ -164,7 +164,7 @@ class PreviewItemManagerTest { previewItemManager.setDrawable(drawingParams, folderItems[1]) - assert(!(drawingParams.drawable as FastBitmapDrawable).isThemed) + assert(!(drawingParams.drawable as FastBitmapDrawable).isThemed()) } @Test @@ -174,7 +174,7 @@ class PreviewItemManagerTest { previewItemManager.setDrawable(drawingParams, folderItems[2]) - assert((drawingParams.drawable as FastBitmapDrawable).isThemed) + assert((drawingParams.drawable as FastBitmapDrawable).isThemed()) assert( ((drawingParams.drawable as FastBitmapDrawable).badge as UserBadgeDrawable).mIsThemed ) @@ -187,7 +187,7 @@ class PreviewItemManagerTest { previewItemManager.setDrawable(drawingParams, folderItems[3]) - assert(!(drawingParams.drawable as FastBitmapDrawable).isThemed) + assert(!(drawingParams.drawable as FastBitmapDrawable).isThemed()) assert( ((drawingParams.drawable as FastBitmapDrawable).badge as UserBadgeDrawable).mIsThemed ) @@ -200,7 +200,7 @@ class PreviewItemManagerTest { previewItemManager.setDrawable(drawingParams, folderItems[3]) - assert(!(drawingParams.drawable as FastBitmapDrawable).isThemed) + assert(!(drawingParams.drawable as FastBitmapDrawable).isThemed()) assert( !((drawingParams.drawable as FastBitmapDrawable).badge as UserBadgeDrawable).mIsThemed )