Merge "Move clipboard overlay above IME" into tm-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
2ddef4d16d
@@ -14,140 +14,131 @@
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
<FrameLayout
|
||||
<com.android.systemui.screenshot.DraggableConstraintLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/clipboard_ui"
|
||||
android:theme="@style/FloatingOverlay"
|
||||
android:alpha="0"
|
||||
android:layout_width="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">
|
||||
android:id="@+id/actions_container_background"
|
||||
android:visibility="gone"
|
||||
android:layout_height="0dp"
|
||||
android:layout_width="0dp"
|
||||
android:elevation="4dp"
|
||||
android:background="@drawable/action_chip_container_background"
|
||||
android:layout_marginStart="@dimen/overlay_action_container_margin_horizontal"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/actions_container"
|
||||
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
|
||||
android:id="@+id/actions_container_background"
|
||||
android:visibility="gone"
|
||||
android:layout_height="0dp"
|
||||
android:layout_width="0dp"
|
||||
android:elevation="1dp"
|
||||
android:background="@drawable/action_chip_container_background"
|
||||
android:layout_marginStart="@dimen/overlay_action_container_margin_horizontal"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/actions_container"
|
||||
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="1dp"
|
||||
android:scrollbars="none"
|
||||
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="@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>
|
||||
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="10dp"
|
||||
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>
|
||||
|
||||
@@ -122,7 +122,6 @@ public class ClipboardOverlayController {
|
||||
private final AccessibilityManager mAccessibilityManager;
|
||||
private final TextClassifier mTextClassifier;
|
||||
|
||||
private final FrameLayout mContainer;
|
||||
private final DraggableConstraintLayout mView;
|
||||
private final View mClipboardPreview;
|
||||
private final ImageView mImagePreview;
|
||||
@@ -177,9 +176,8 @@ public class ClipboardOverlayController {
|
||||
|
||||
setWindowFocusable(false);
|
||||
|
||||
mContainer = (FrameLayout)
|
||||
mView = (DraggableConstraintLayout)
|
||||
LayoutInflater.from(mContext).inflate(R.layout.clipboard_overlay, null);
|
||||
mView = requireNonNull(mContainer.findViewById(R.id.clipboard_ui));
|
||||
mActionContainerBackground =
|
||||
requireNonNull(mView.findViewById(R.id.actions_container_background));
|
||||
mActionContainer = requireNonNull(mView.findViewById(R.id.actions));
|
||||
@@ -201,13 +199,6 @@ public class ClipboardOverlayController {
|
||||
public void onSwipeDismissInitiated(Animator animator) {
|
||||
mUiEventLogger.log(CLIPBOARD_OVERLAY_SWIPE_DISMISSED);
|
||||
mExitAnimator = animator;
|
||||
animator.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationStart(Animator animation) {
|
||||
super.onAnimationStart(animation);
|
||||
mContainer.animate().alpha(0).setDuration(animation.getDuration()).start();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -231,7 +222,7 @@ public class ClipboardOverlayController {
|
||||
|
||||
attachWindow();
|
||||
withWindowAttached(() -> {
|
||||
mWindow.setContentView(mContainer);
|
||||
mWindow.setContentView(mView);
|
||||
updateInsets(mWindowManager.getCurrentWindowMetrics().getWindowInsets());
|
||||
mView.requestLayout();
|
||||
});
|
||||
@@ -308,7 +299,7 @@ public class ClipboardOverlayController {
|
||||
} else {
|
||||
mRemoteCopyChip.setVisibility(View.GONE);
|
||||
}
|
||||
withWindowAttached(() -> mContainer.post(this::animateIn));
|
||||
withWindowAttached(() -> mView.post(this::animateIn));
|
||||
mTimeoutHandler.resetTimeout();
|
||||
}
|
||||
|
||||
@@ -508,7 +499,7 @@ public class ClipboardOverlayController {
|
||||
rootAnim.setInterpolator(linearInterpolator);
|
||||
rootAnim.setDuration(66);
|
||||
rootAnim.addUpdateListener(animation -> {
|
||||
mContainer.setAlpha(animation.getAnimatedFraction());
|
||||
mView.setAlpha(animation.getAnimatedFraction());
|
||||
});
|
||||
|
||||
ValueAnimator scaleAnim = ValueAnimator.ofFloat(0, 1);
|
||||
@@ -553,7 +544,7 @@ public class ClipboardOverlayController {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
super.onAnimationEnd(animation);
|
||||
mContainer.setAlpha(1);
|
||||
mView.setAlpha(1);
|
||||
mTimeoutHandler.resetTimeout();
|
||||
}
|
||||
});
|
||||
@@ -568,9 +559,7 @@ public class ClipboardOverlayController {
|
||||
ValueAnimator rootAnim = ValueAnimator.ofFloat(0, 1);
|
||||
rootAnim.setInterpolator(linearInterpolator);
|
||||
rootAnim.setDuration(100);
|
||||
rootAnim.addUpdateListener(animation -> {
|
||||
mContainer.setAlpha(1 - animation.getAnimatedFraction());
|
||||
});
|
||||
rootAnim.addUpdateListener(anim -> mView.setAlpha(1 - anim.getAnimatedFraction()));
|
||||
|
||||
ValueAnimator scaleAnim = ValueAnimator.ofFloat(0, 1);
|
||||
scaleAnim.setInterpolator(scaleInterpolator);
|
||||
@@ -647,7 +636,7 @@ public class ClipboardOverlayController {
|
||||
|
||||
private void reset() {
|
||||
mView.setTranslationX(0);
|
||||
mContainer.setAlpha(0);
|
||||
mView.setAlpha(0);
|
||||
mActionContainerBackground.setVisibility(View.GONE);
|
||||
resetActionChips();
|
||||
mTimeoutHandler.cancelTimeout();
|
||||
@@ -706,8 +695,9 @@ public class ClipboardOverlayController {
|
||||
}
|
||||
DisplayCutout cutout = insets.getDisplayCutout();
|
||||
Insets navBarInsets = insets.getInsets(WindowInsets.Type.navigationBars());
|
||||
Insets imeInsets = insets.getInsets(WindowInsets.Type.ime());
|
||||
if (cutout == null) {
|
||||
p.setMargins(0, 0, 0, navBarInsets.bottom);
|
||||
p.setMargins(0, 0, 0, Math.max(imeInsets.bottom, navBarInsets.bottom));
|
||||
} else {
|
||||
Insets waterfall = cutout.getWaterfallInsets();
|
||||
if (orientation == ORIENTATION_PORTRAIT) {
|
||||
@@ -715,14 +705,16 @@ public class ClipboardOverlayController {
|
||||
waterfall.left,
|
||||
Math.max(cutout.getSafeInsetTop(), waterfall.top),
|
||||
waterfall.right,
|
||||
Math.max(cutout.getSafeInsetBottom(),
|
||||
Math.max(navBarInsets.bottom, waterfall.bottom)));
|
||||
Math.max(imeInsets.bottom,
|
||||
Math.max(cutout.getSafeInsetBottom(),
|
||||
Math.max(navBarInsets.bottom, waterfall.bottom))));
|
||||
} else {
|
||||
p.setMargins(
|
||||
Math.max(cutout.getSafeInsetLeft(), waterfall.left),
|
||||
waterfall.left,
|
||||
waterfall.top,
|
||||
Math.max(cutout.getSafeInsetRight(), waterfall.right),
|
||||
Math.max(navBarInsets.bottom, waterfall.bottom));
|
||||
waterfall.right,
|
||||
Math.max(imeInsets.bottom,
|
||||
Math.max(navBarInsets.bottom, waterfall.bottom)));
|
||||
}
|
||||
}
|
||||
mView.setLayoutParams(p);
|
||||
|
||||
Reference in New Issue
Block a user