diff options
8 files changed, 42 insertions, 62 deletions
diff --git a/packages/SystemUI/res/layout/overlay_action_chip.xml b/packages/SystemUI/res/layout/overlay_action_chip.xml index 13b16124f419..6d2d93124234 100644 --- a/packages/SystemUI/res/layout/overlay_action_chip.xml +++ b/packages/SystemUI/res/layout/overlay_action_chip.xml @@ -32,7 +32,7 @@ android:gravity="center"> <ImageView android:id="@+id/overlay_action_chip_icon" - android:tint="?android:attr/textColorPrimary" + android:tint="?attr/overlayButtonTextColor" android:layout_width="@dimen/overlay_action_chip_icon_size" android:layout_height="@dimen/overlay_action_chip_icon_size"/> <TextView @@ -41,6 +41,6 @@ android:layout_height="wrap_content" android:fontFamily="@*android:string/config_headlineFontFamilyMedium" android:textSize="@dimen/overlay_action_chip_text_size" - android:textColor="?android:attr/textColorPrimary"/> + android:textColor="?attr/overlayButtonTextColor"/> </LinearLayout> </com.android.systemui.screenshot.OverlayActionChip> diff --git a/packages/SystemUI/res/values-night/styles.xml b/packages/SystemUI/res/values-night/styles.xml index 6cef8035f10b..f7261e70a610 100644 --- a/packages/SystemUI/res/values-night/styles.xml +++ b/packages/SystemUI/res/values-night/styles.xml @@ -48,7 +48,7 @@ </style> <style name="FloatingOverlay" parent="@android:style/Theme.DeviceDefault.DayNight"> - <item name="android:textColorPrimary">?android:attr/textColorPrimaryInverse</item> + <item name="overlayButtonTextColor">?android:attr/textColorPrimaryInverse</item> </style> <style name="Theme.PeopleTileConfigActivity" parent="@style/Theme.SystemUI"> diff --git a/packages/SystemUI/res/values/attrs.xml b/packages/SystemUI/res/values/attrs.xml index de136de9dd5f..e6ab0ff9bd73 100644 --- a/packages/SystemUI/res/values/attrs.xml +++ b/packages/SystemUI/res/values/attrs.xml @@ -204,5 +204,7 @@ <attr name="singleLineVerticalPadding" format="dimension" /> <attr name="textViewId" format="reference" /> </declare-styleable> + + <attr name="overlayButtonTextColor" format="color" /> </resources> diff --git a/packages/SystemUI/res/values/styles.xml b/packages/SystemUI/res/values/styles.xml index 7007baa5d28d..9b238296418f 100644 --- a/packages/SystemUI/res/values/styles.xml +++ b/packages/SystemUI/res/values/styles.xml @@ -664,7 +664,9 @@ <item name="android:windowActivityTransitions">true</item> </style> - <style name="FloatingOverlay" parent="@android:style/Theme.DeviceDefault.DayNight"/> + <style name="FloatingOverlay" parent="@android:style/Theme.DeviceDefault.DayNight"> + <item name="overlayButtonTextColor">?android:attr/textColorPrimary</item> + </style> <!-- Clipboard overlay's edit text activity. --> <style name="EditTextActivity" parent="@android:style/Theme.DeviceDefault.DayNight"> diff --git a/packages/SystemUI/src/com/android/systemui/clipboardoverlay/ClipboardOverlayController.java b/packages/SystemUI/src/com/android/systemui/clipboardoverlay/ClipboardOverlayController.java index b57a13b36ad6..8b549b43019f 100644 --- a/packages/SystemUI/src/com/android/systemui/clipboardoverlay/ClipboardOverlayController.java +++ b/packages/SystemUI/src/com/android/systemui/clipboardoverlay/ClipboardOverlayController.java @@ -365,7 +365,7 @@ public class ClipboardOverlayController { } private void animateOut() { - getExitAnimation().start(); + mView.dismiss(); } private ValueAnimator getEnterAnimation() { @@ -401,28 +401,6 @@ public class ClipboardOverlayController { return anim; } - private ValueAnimator getExitAnimation() { - ValueAnimator anim = ValueAnimator.ofFloat(0, 1); - - anim.addUpdateListener(animation -> { - mView.setAlpha(1 - animation.getAnimatedFraction()); - final View actionBackground = requireNonNull( - mView.findViewById(R.id.actions_container_background)); - mView.setTranslationX( - -animation.getAnimatedFraction() * actionBackground.getWidth() / 2); - }); - - anim.addListener(new AnimatorListenerAdapter() { - @Override - public void onAnimationEnd(Animator animation) { - super.onAnimationEnd(animation); - hideImmediate(); - } - }); - - return anim; - } - private void hideImmediate() { // Note this may be called multiple times if multiple dismissal events happen at the same // time. diff --git a/packages/SystemUI/src/com/android/systemui/clipboardoverlay/DraggableConstraintLayout.java b/packages/SystemUI/src/com/android/systemui/clipboardoverlay/DraggableConstraintLayout.java index 6a4be6ee5eae..8843462413b5 100644 --- a/packages/SystemUI/src/com/android/systemui/clipboardoverlay/DraggableConstraintLayout.java +++ b/packages/SystemUI/src/com/android/systemui/clipboardoverlay/DraggableConstraintLayout.java @@ -98,10 +98,23 @@ public class DraggableConstraintLayout extends ConstraintLayout { return mSwipeDetector.onTouchEvent(ev); } + /** + * Dismiss the view, with animation controlled by SwipeDismissHandler + */ + public void dismiss() { + mSwipeDismissHandler.dismiss(); + } + + /** + * Set the callback to be run after view is dismissed + */ public void setOnDismissCallback(Runnable callback) { mOnDismiss = callback; } + /** + * Set the callback to be run when the view is interacted with (e.g. tapped) + */ public void setOnInteractionCallback(Runnable callback) { mOnInteraction = callback; } diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotView.java b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotView.java index aec63d2b1752..f9827905b69a 100644 --- a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotView.java +++ b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotView.java @@ -158,7 +158,6 @@ public class ScreenshotView extends FrameLayout implements private UiEventLogger mUiEventLogger; private ScreenshotViewCallback mCallbacks; - private Animator mDismissAnimation; private boolean mPendingSharedTransition; private SwipeDismissHandler mSwipeDismissHandler; private InputMonitorCompat mInputMonitor; @@ -940,7 +939,7 @@ public class ScreenshotView extends FrameLayout implements } boolean isDismissing() { - return (mDismissAnimation != null && mDismissAnimation.isRunning()); + return mSwipeDismissHandler.isDismissing(); } boolean isPendingSharedTransition() { @@ -956,12 +955,6 @@ public class ScreenshotView extends FrameLayout implements Log.d(TAG, "reset screenshot view"); } - if (mDismissAnimation != null && mDismissAnimation.isRunning()) { - if (DEBUG_ANIM) { - Log.d(TAG, "cancelling dismiss animation"); - } - mDismissAnimation.cancel(); - } mSwipeDismissHandler.cancel(); if (DEBUG_WINDOW) { Log.d(TAG, "removing OnComputeInternalInsetsListener"); @@ -1014,31 +1007,6 @@ public class ScreenshotView extends FrameLayout implements } } - private AnimatorSet createScreenshotTranslateDismissAnimation() { - ValueAnimator alphaAnim = ValueAnimator.ofFloat(0, 1); - alphaAnim.setStartDelay(SCREENSHOT_DISMISS_ALPHA_OFFSET_MS); - alphaAnim.setDuration(SCREENSHOT_DISMISS_ALPHA_DURATION_MS); - alphaAnim.addUpdateListener(animation -> { - setAlpha(1 - animation.getAnimatedFraction()); - }); - - ValueAnimator xAnim = ValueAnimator.ofFloat(0, 1); - xAnim.setInterpolator(mAccelerateInterpolator); - xAnim.setDuration(SCREENSHOT_DISMISS_X_DURATION_MS); - float deltaX = mDirectionLTR - ? -1 * (mScreenshotPreviewBorder.getX() + mScreenshotPreviewBorder.getWidth()) - : (mDisplayMetrics.widthPixels - mScreenshotPreviewBorder.getX()); - xAnim.addUpdateListener(animation -> { - float currXDelta = MathUtils.lerp(0, deltaX, animation.getAnimatedFraction()); - mScreenshotStatic.setTranslationX(currXDelta); - }); - - AnimatorSet animSet = new AnimatorSet(); - animSet.play(xAnim).with(alphaAnim); - - return animSet; - } - ValueAnimator createScreenshotFadeDismissAnimation() { ValueAnimator alphaAnim = ValueAnimator.ofFloat(0, 1); alphaAnim.addUpdateListener(animation -> { diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/SwipeDismissHandler.java b/packages/SystemUI/src/com/android/systemui/screenshot/SwipeDismissHandler.java index 4e960037bb7b..451fb1311ebb 100644 --- a/packages/SystemUI/src/com/android/systemui/screenshot/SwipeDismissHandler.java +++ b/packages/SystemUI/src/com/android/systemui/screenshot/SwipeDismissHandler.java @@ -16,6 +16,7 @@ package com.android.systemui.screenshot; +import static com.android.systemui.screenshot.LogConfig.DEBUG_ANIM; import static com.android.systemui.screenshot.LogConfig.DEBUG_DISMISS; import android.animation.Animator; @@ -137,10 +138,20 @@ public class SwipeDismissHandler implements View.OnTouchListener { } /** + * Return whether the view is currently being dismissed + */ + public boolean isDismissing() { + return (mDismissAnimation != null && mDismissAnimation.isRunning()); + } + + /** * Cancel the currently-running dismissal animation, if any. */ public void cancel() { - if (mDismissAnimation != null && mDismissAnimation.isRunning()) { + if (isDismissing()) { + if (DEBUG_ANIM) { + Log.d(TAG, "cancelling dismiss animation"); + } mDismissAnimation.cancel(); } } @@ -182,7 +193,13 @@ public class SwipeDismissHandler implements View.OnTouchListener { // make sure the UI gets all the way off the screen in the direction of movement // (the actions container background is guaranteed to be both the leftmost and // rightmost UI element in LTR and RTL) - float finalX = startX <= 0 ? -1 * mView.getRight() : mDisplayMetrics.widthPixels; + float finalX; + int layoutDir = mView.getContext().getResources().getConfiguration().getLayoutDirection(); + if (startX > 0 || (startX == 0 && layoutDir == View.LAYOUT_DIRECTION_RTL)) { + finalX = mDisplayMetrics.widthPixels; + } else { + finalX = -1 * mView.getRight(); + } float distance = Math.abs(finalX - startX); anim.addUpdateListener(animation -> { |