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,140 +14,131 @@
~ 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 <ImageView
android:id="@+id/background_protection" android:id="@+id/actions_container_background"
android:layout_height="@dimen/overlay_bg_protection_height" android:visibility="gone"
android:layout_width="match_parent" android:layout_height="0dp"
android:layout_gravity="bottom" android:layout_width="0dp"
android:src="@drawable/overlay_actions_background_protection"/> android:elevation="4dp"
<com.android.systemui.screenshot.DraggableConstraintLayout android:background="@drawable/action_chip_container_background"
android:id="@+id/clipboard_ui" android:layout_marginStart="@dimen/overlay_action_container_margin_horizontal"
android:layout_width="match_parent" app:layout_constraintBottom_toBottomOf="@+id/actions_container"
android:layout_height="match_parent"> app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/actions_container"
app:layout_constraintEnd_toEndOf="@+id/actions_container"/>
<HorizontalScrollView
android:id="@+id/actions_container"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/overlay_action_container_margin_horizontal"
android:paddingEnd="@dimen/overlay_action_container_padding_right"
android:paddingVertical="@dimen/overlay_action_container_padding_vertical"
android:elevation="4dp"
android:scrollbars="none"
android:layout_marginBottom="4dp"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintWidth_percent="1.0"
app:layout_constraintWidth_max="wrap"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/preview_border"
app:layout_constraintEnd_toEndOf="parent">
<LinearLayout
android:id="@+id/actions"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:animateLayoutChanges="true">
<include layout="@layout/overlay_action_chip"
android:id="@+id/remote_copy_chip"/>
<include layout="@layout/overlay_action_chip"
android:id="@+id/edit_chip"/>
</LinearLayout>
</HorizontalScrollView>
<View
android:id="@+id/preview_border"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="@dimen/overlay_offset_x"
android:layout_marginBottom="@dimen/overlay_offset_y"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="@id/actions_container_background"
android:elevation="7dp"
app:layout_constraintEnd_toEndOf="@id/clipboard_preview_end"
app:layout_constraintTop_toTopOf="@id/clipboard_preview_top"
android:background="@drawable/overlay_border"/>
<androidx.constraintlayout.widget.Barrier
android:id="@+id/clipboard_preview_end"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:barrierMargin="@dimen/overlay_border_width"
app:barrierDirection="end"
app:constraint_referenced_ids="clipboard_preview"/>
<androidx.constraintlayout.widget.Barrier
android:id="@+id/clipboard_preview_top"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:barrierDirection="top"
app:barrierMargin="@dimen/overlay_border_width_neg"
app:constraint_referenced_ids="clipboard_preview"/>
<FrameLayout
android:id="@+id/clipboard_preview"
android:elevation="7dp"
android:background="@drawable/overlay_preview_background"
android:clipChildren="true"
android:clipToOutline="true"
android:clipToPadding="true"
android:layout_width="@dimen/clipboard_preview_size"
android:layout_margin="@dimen/overlay_border_width"
android:layout_height="wrap_content"
android:layout_gravity="center"
app:layout_constraintBottom_toBottomOf="@id/preview_border"
app:layout_constraintStart_toStartOf="@id/preview_border"
app:layout_constraintEnd_toEndOf="@id/preview_border"
app:layout_constraintTop_toTopOf="@id/preview_border">
<TextView android:id="@+id/text_preview"
android:textFontWeight="500"
android:padding="8dp"
android:gravity="center|start"
android:ellipsize="end"
android:autoSizeTextType="uniform"
android:autoSizeMinTextSize="10sp"
android:autoSizeMaxTextSize="200sp"
android:textColor="?attr/overlayButtonTextColor"
android:background="?androidprv:attr/colorAccentSecondary"
android:layout_width="@dimen/clipboard_preview_size"
android:layout_height="@dimen/clipboard_preview_size"/>
<ImageView <ImageView
android:id="@+id/actions_container_background" android:id="@+id/image_preview"
android:visibility="gone" android:scaleType="fitCenter"
android:layout_height="0dp" android:adjustViewBounds="true"
android:layout_width="0dp" android:layout_width="match_parent"
android:elevation="1dp" android:layout_height="wrap_content"/>
android:background="@drawable/action_chip_container_background" </FrameLayout>
android:layout_marginStart="@dimen/overlay_action_container_margin_horizontal" <FrameLayout
app:layout_constraintBottom_toBottomOf="@+id/actions_container" android:id="@+id/dismiss_button"
app:layout_constraintStart_toStartOf="parent" android:layout_width="@dimen/overlay_dismiss_button_tappable_size"
app:layout_constraintTop_toTopOf="@+id/actions_container" android:layout_height="@dimen/overlay_dismiss_button_tappable_size"
app:layout_constraintEnd_toEndOf="@+id/actions_container"/> android:elevation="10dp"
<HorizontalScrollView android:visibility="gone"
android:id="@+id/actions_container" android:alpha="0"
android:layout_width="0dp" app:layout_constraintStart_toEndOf="@id/clipboard_preview"
android:layout_height="wrap_content" app:layout_constraintEnd_toEndOf="@id/clipboard_preview"
android:layout_marginEnd="@dimen/overlay_action_container_margin_horizontal" app:layout_constraintTop_toTopOf="@id/clipboard_preview"
android:paddingEnd="@dimen/overlay_action_container_padding_right" app:layout_constraintBottom_toTopOf="@id/clipboard_preview"
android:paddingVertical="@dimen/overlay_action_container_padding_vertical" android:contentDescription="@string/clipboard_dismiss_description">
android:elevation="1dp" <ImageView
android:scrollbars="none" android:id="@+id/dismiss_image"
app:layout_constraintHorizontal_bias="0" android:layout_width="match_parent"
app:layout_constraintWidth_percent="1.0" android:layout_height="match_parent"
app:layout_constraintWidth_max="wrap" android:layout_margin="@dimen/overlay_dismiss_button_margin"
app:layout_constraintBottom_toBottomOf="parent" android:src="@drawable/overlay_cancel"/>
app:layout_constraintStart_toEndOf="@+id/preview_border" </FrameLayout>
app:layout_constraintEnd_toEndOf="parent"> </com.android.systemui.screenshot.DraggableConstraintLayout>
<LinearLayout
android:id="@+id/actions"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:animateLayoutChanges="true">
<include layout="@layout/overlay_action_chip"
android:id="@+id/remote_copy_chip"/>
<include layout="@layout/overlay_action_chip"
android:id="@+id/edit_chip"/>
</LinearLayout>
</HorizontalScrollView>
<View
android:id="@+id/preview_border"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="@dimen/overlay_offset_x"
android:layout_marginBottom="@dimen/overlay_offset_y"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="@id/actions_container_background"
android:elevation="@dimen/overlay_preview_elevation"
app:layout_constraintEnd_toEndOf="@id/clipboard_preview_end"
app:layout_constraintTop_toTopOf="@id/clipboard_preview_top"
android:background="@drawable/overlay_border"/>
<androidx.constraintlayout.widget.Barrier
android:id="@+id/clipboard_preview_end"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:barrierMargin="@dimen/overlay_border_width"
app:barrierDirection="end"
app:constraint_referenced_ids="clipboard_preview"/>
<androidx.constraintlayout.widget.Barrier
android:id="@+id/clipboard_preview_top"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:barrierDirection="top"
app:barrierMargin="@dimen/overlay_border_width_neg"
app:constraint_referenced_ids="clipboard_preview"/>
<FrameLayout
android:id="@+id/clipboard_preview"
android:elevation="@dimen/overlay_preview_elevation"
android:background="@drawable/overlay_preview_background"
android:clipChildren="true"
android:clipToOutline="true"
android:clipToPadding="true"
android:layout_width="@dimen/clipboard_preview_size"
android:layout_margin="@dimen/overlay_border_width"
android:layout_height="wrap_content"
android:layout_gravity="center"
app:layout_constraintBottom_toBottomOf="@id/preview_border"
app:layout_constraintStart_toStartOf="@id/preview_border"
app:layout_constraintEnd_toEndOf="@id/preview_border"
app:layout_constraintTop_toTopOf="@id/preview_border">
<TextView android:id="@+id/text_preview"
android:textFontWeight="500"
android:padding="8dp"
android:gravity="center|start"
android:ellipsize="end"
android:autoSizeTextType="uniform"
android:autoSizeMinTextSize="10sp"
android:autoSizeMaxTextSize="200sp"
android:textColor="?attr/overlayButtonTextColor"
android:background="?androidprv:attr/colorAccentSecondary"
android:layout_width="@dimen/clipboard_preview_size"
android:layout_height="@dimen/clipboard_preview_size"/>
<ImageView
android:id="@+id/image_preview"
android:scaleType="fitCenter"
android:adjustViewBounds="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</FrameLayout>
<FrameLayout
android:id="@+id/dismiss_button"
android:layout_width="@dimen/overlay_dismiss_button_tappable_size"
android:layout_height="@dimen/overlay_dismiss_button_tappable_size"
android:elevation="@dimen/overlay_dismiss_button_elevation"
android:visibility="gone"
android:alpha="0"
app:layout_constraintStart_toEndOf="@id/clipboard_preview"
app:layout_constraintEnd_toEndOf="@id/clipboard_preview"
app:layout_constraintTop_toTopOf="@id/clipboard_preview"
app:layout_constraintBottom_toTopOf="@id/clipboard_preview"
android:contentDescription="@string/clipboard_dismiss_description">
<ImageView
android:id="@+id/dismiss_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="@dimen/overlay_dismiss_button_margin"
android:src="@drawable/overlay_cancel"/>
</FrameLayout>
</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(cutout.getSafeInsetBottom(), Math.max(imeInsets.bottom,
Math.max(navBarInsets.bottom, waterfall.bottom))); Math.max(cutout.getSafeInsetBottom(),
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);