Merge "Move clipboard overlay above IME" into tm-dev am: 2ddef4d16d

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18093719

Change-Id: If4e152ff0a9b6d3effbb22ffac1bcb8fa1d8e855
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Miranda Kephart
2022-05-02 13:08:14 +00:00
committed by Automerger Merge Worker
2 changed files with 135 additions and 152 deletions

View File

@@ -14,30 +14,21 @@
~ See the License for the specific language governing permissions and ~ See the License for the specific language governing permissions and
~ limitations under the License. ~ limitations under the License.
--> -->
<FrameLayout <com.android.systemui.screenshot.DraggableConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android" xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/clipboard_ui"
android:theme="@style/FloatingOverlay" android:theme="@style/FloatingOverlay"
android:alpha="0" android:alpha="0"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<ImageView
android:id="@+id/background_protection"
android:layout_height="@dimen/overlay_bg_protection_height"
android:layout_width="match_parent"
android:layout_gravity="bottom"
android:src="@drawable/overlay_actions_background_protection"/>
<com.android.systemui.screenshot.DraggableConstraintLayout
android:id="@+id/clipboard_ui"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView <ImageView
android:id="@+id/actions_container_background" android:id="@+id/actions_container_background"
android:visibility="gone" android:visibility="gone"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_width="0dp" android:layout_width="0dp"
android:elevation="1dp" android:elevation="4dp"
android:background="@drawable/action_chip_container_background" android:background="@drawable/action_chip_container_background"
android:layout_marginStart="@dimen/overlay_action_container_margin_horizontal" android:layout_marginStart="@dimen/overlay_action_container_margin_horizontal"
app:layout_constraintBottom_toBottomOf="@+id/actions_container" app:layout_constraintBottom_toBottomOf="@+id/actions_container"
@@ -51,8 +42,9 @@
android:layout_marginEnd="@dimen/overlay_action_container_margin_horizontal" android:layout_marginEnd="@dimen/overlay_action_container_margin_horizontal"
android:paddingEnd="@dimen/overlay_action_container_padding_right" android:paddingEnd="@dimen/overlay_action_container_padding_right"
android:paddingVertical="@dimen/overlay_action_container_padding_vertical" android:paddingVertical="@dimen/overlay_action_container_padding_vertical"
android:elevation="1dp" android:elevation="4dp"
android:scrollbars="none" android:scrollbars="none"
android:layout_marginBottom="4dp"
app:layout_constraintHorizontal_bias="0" app:layout_constraintHorizontal_bias="0"
app:layout_constraintWidth_percent="1.0" app:layout_constraintWidth_percent="1.0"
app:layout_constraintWidth_max="wrap" app:layout_constraintWidth_max="wrap"
@@ -78,7 +70,7 @@
android:layout_marginBottom="@dimen/overlay_offset_y" android:layout_marginBottom="@dimen/overlay_offset_y"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="@id/actions_container_background" app:layout_constraintBottom_toBottomOf="@id/actions_container_background"
android:elevation="@dimen/overlay_preview_elevation" android:elevation="7dp"
app:layout_constraintEnd_toEndOf="@id/clipboard_preview_end" app:layout_constraintEnd_toEndOf="@id/clipboard_preview_end"
app:layout_constraintTop_toTopOf="@id/clipboard_preview_top" app:layout_constraintTop_toTopOf="@id/clipboard_preview_top"
android:background="@drawable/overlay_border"/> android:background="@drawable/overlay_border"/>
@@ -98,7 +90,7 @@
app:constraint_referenced_ids="clipboard_preview"/> app:constraint_referenced_ids="clipboard_preview"/>
<FrameLayout <FrameLayout
android:id="@+id/clipboard_preview" android:id="@+id/clipboard_preview"
android:elevation="@dimen/overlay_preview_elevation" android:elevation="7dp"
android:background="@drawable/overlay_preview_background" android:background="@drawable/overlay_preview_background"
android:clipChildren="true" android:clipChildren="true"
android:clipToOutline="true" android:clipToOutline="true"
@@ -134,7 +126,7 @@
android:id="@+id/dismiss_button" android:id="@+id/dismiss_button"
android:layout_width="@dimen/overlay_dismiss_button_tappable_size" android:layout_width="@dimen/overlay_dismiss_button_tappable_size"
android:layout_height="@dimen/overlay_dismiss_button_tappable_size" android:layout_height="@dimen/overlay_dismiss_button_tappable_size"
android:elevation="@dimen/overlay_dismiss_button_elevation" android:elevation="10dp"
android:visibility="gone" android:visibility="gone"
android:alpha="0" android:alpha="0"
app:layout_constraintStart_toEndOf="@id/clipboard_preview" app:layout_constraintStart_toEndOf="@id/clipboard_preview"
@@ -150,4 +142,3 @@
android:src="@drawable/overlay_cancel"/> android:src="@drawable/overlay_cancel"/>
</FrameLayout> </FrameLayout>
</com.android.systemui.screenshot.DraggableConstraintLayout> </com.android.systemui.screenshot.DraggableConstraintLayout>
</FrameLayout>

View File

@@ -122,7 +122,6 @@ public class ClipboardOverlayController {
private final AccessibilityManager mAccessibilityManager; private final AccessibilityManager mAccessibilityManager;
private final TextClassifier mTextClassifier; private final TextClassifier mTextClassifier;
private final FrameLayout mContainer;
private final DraggableConstraintLayout mView; private final DraggableConstraintLayout mView;
private final View mClipboardPreview; private final View mClipboardPreview;
private final ImageView mImagePreview; private final ImageView mImagePreview;
@@ -177,9 +176,8 @@ public class ClipboardOverlayController {
setWindowFocusable(false); setWindowFocusable(false);
mContainer = (FrameLayout) mView = (DraggableConstraintLayout)
LayoutInflater.from(mContext).inflate(R.layout.clipboard_overlay, null); LayoutInflater.from(mContext).inflate(R.layout.clipboard_overlay, null);
mView = requireNonNull(mContainer.findViewById(R.id.clipboard_ui));
mActionContainerBackground = mActionContainerBackground =
requireNonNull(mView.findViewById(R.id.actions_container_background)); requireNonNull(mView.findViewById(R.id.actions_container_background));
mActionContainer = requireNonNull(mView.findViewById(R.id.actions)); mActionContainer = requireNonNull(mView.findViewById(R.id.actions));
@@ -201,13 +199,6 @@ public class ClipboardOverlayController {
public void onSwipeDismissInitiated(Animator animator) { public void onSwipeDismissInitiated(Animator animator) {
mUiEventLogger.log(CLIPBOARD_OVERLAY_SWIPE_DISMISSED); mUiEventLogger.log(CLIPBOARD_OVERLAY_SWIPE_DISMISSED);
mExitAnimator = animator; mExitAnimator = animator;
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
super.onAnimationStart(animation);
mContainer.animate().alpha(0).setDuration(animation.getDuration()).start();
}
});
} }
@Override @Override
@@ -231,7 +222,7 @@ public class ClipboardOverlayController {
attachWindow(); attachWindow();
withWindowAttached(() -> { withWindowAttached(() -> {
mWindow.setContentView(mContainer); mWindow.setContentView(mView);
updateInsets(mWindowManager.getCurrentWindowMetrics().getWindowInsets()); updateInsets(mWindowManager.getCurrentWindowMetrics().getWindowInsets());
mView.requestLayout(); mView.requestLayout();
}); });
@@ -308,7 +299,7 @@ public class ClipboardOverlayController {
} else { } else {
mRemoteCopyChip.setVisibility(View.GONE); mRemoteCopyChip.setVisibility(View.GONE);
} }
withWindowAttached(() -> mContainer.post(this::animateIn)); withWindowAttached(() -> mView.post(this::animateIn));
mTimeoutHandler.resetTimeout(); mTimeoutHandler.resetTimeout();
} }
@@ -508,7 +499,7 @@ public class ClipboardOverlayController {
rootAnim.setInterpolator(linearInterpolator); rootAnim.setInterpolator(linearInterpolator);
rootAnim.setDuration(66); rootAnim.setDuration(66);
rootAnim.addUpdateListener(animation -> { rootAnim.addUpdateListener(animation -> {
mContainer.setAlpha(animation.getAnimatedFraction()); mView.setAlpha(animation.getAnimatedFraction());
}); });
ValueAnimator scaleAnim = ValueAnimator.ofFloat(0, 1); ValueAnimator scaleAnim = ValueAnimator.ofFloat(0, 1);
@@ -553,7 +544,7 @@ public class ClipboardOverlayController {
@Override @Override
public void onAnimationEnd(Animator animation) { public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation); super.onAnimationEnd(animation);
mContainer.setAlpha(1); mView.setAlpha(1);
mTimeoutHandler.resetTimeout(); mTimeoutHandler.resetTimeout();
} }
}); });
@@ -568,9 +559,7 @@ public class ClipboardOverlayController {
ValueAnimator rootAnim = ValueAnimator.ofFloat(0, 1); ValueAnimator rootAnim = ValueAnimator.ofFloat(0, 1);
rootAnim.setInterpolator(linearInterpolator); rootAnim.setInterpolator(linearInterpolator);
rootAnim.setDuration(100); rootAnim.setDuration(100);
rootAnim.addUpdateListener(animation -> { rootAnim.addUpdateListener(anim -> mView.setAlpha(1 - anim.getAnimatedFraction()));
mContainer.setAlpha(1 - animation.getAnimatedFraction());
});
ValueAnimator scaleAnim = ValueAnimator.ofFloat(0, 1); ValueAnimator scaleAnim = ValueAnimator.ofFloat(0, 1);
scaleAnim.setInterpolator(scaleInterpolator); scaleAnim.setInterpolator(scaleInterpolator);
@@ -647,7 +636,7 @@ public class ClipboardOverlayController {
private void reset() { private void reset() {
mView.setTranslationX(0); mView.setTranslationX(0);
mContainer.setAlpha(0); mView.setAlpha(0);
mActionContainerBackground.setVisibility(View.GONE); mActionContainerBackground.setVisibility(View.GONE);
resetActionChips(); resetActionChips();
mTimeoutHandler.cancelTimeout(); mTimeoutHandler.cancelTimeout();
@@ -706,8 +695,9 @@ public class ClipboardOverlayController {
} }
DisplayCutout cutout = insets.getDisplayCutout(); DisplayCutout cutout = insets.getDisplayCutout();
Insets navBarInsets = insets.getInsets(WindowInsets.Type.navigationBars()); Insets navBarInsets = insets.getInsets(WindowInsets.Type.navigationBars());
Insets imeInsets = insets.getInsets(WindowInsets.Type.ime());
if (cutout == null) { if (cutout == null) {
p.setMargins(0, 0, 0, navBarInsets.bottom); p.setMargins(0, 0, 0, Math.max(imeInsets.bottom, navBarInsets.bottom));
} else { } else {
Insets waterfall = cutout.getWaterfallInsets(); Insets waterfall = cutout.getWaterfallInsets();
if (orientation == ORIENTATION_PORTRAIT) { if (orientation == ORIENTATION_PORTRAIT) {
@@ -715,14 +705,16 @@ public class ClipboardOverlayController {
waterfall.left, waterfall.left,
Math.max(cutout.getSafeInsetTop(), waterfall.top), Math.max(cutout.getSafeInsetTop(), waterfall.top),
waterfall.right, waterfall.right,
Math.max(imeInsets.bottom,
Math.max(cutout.getSafeInsetBottom(), Math.max(cutout.getSafeInsetBottom(),
Math.max(navBarInsets.bottom, waterfall.bottom))); Math.max(navBarInsets.bottom, waterfall.bottom))));
} else { } else {
p.setMargins( p.setMargins(
Math.max(cutout.getSafeInsetLeft(), waterfall.left), waterfall.left,
waterfall.top, waterfall.top,
Math.max(cutout.getSafeInsetRight(), waterfall.right), waterfall.right,
Math.max(navBarInsets.bottom, waterfall.bottom)); Math.max(imeInsets.bottom,
Math.max(navBarInsets.bottom, waterfall.bottom)));
} }
} }
mView.setLayoutParams(p); mView.setLayoutParams(p);