Fix clipboard overlay in dark mode and RTL
Uses the correct themed colors in dark mode (including clipboard text preview) and dismisses to the right when in RTL Bug: 195554988 Test: manual Change-Id: I221089d142c35ba74f8ecd9299f9162abe8a0cee
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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">
|
||||
|
||||
@@ -204,5 +204,7 @@
|
||||
<attr name="singleLineVerticalPadding" format="dimension" />
|
||||
<attr name="textViewId" format="reference" />
|
||||
</declare-styleable>
|
||||
|
||||
<attr name="overlayButtonTextColor" format="color" />
|
||||
</resources>
|
||||
|
||||
|
||||
@@ -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">
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 -> {
|
||||
|
||||
@@ -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;
|
||||
@@ -136,11 +137,21 @@ public class SwipeDismissHandler implements View.OnTouchListener {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 -> {
|
||||
|
||||
Reference in New Issue
Block a user