Merge "Add dismiss button to clipboard overlay"
This commit is contained in:
committed by
Android (Google) Code Review
commit
102ba053a3
@@ -1,60 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright (C) 2021 The Android Open Source Project
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/preview_border"
|
||||
android:elevation="9dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/screenshot_offset_x"
|
||||
android:layout_marginBottom="@dimen/screenshot_offset_y"
|
||||
android:layout_gravity="bottom|start"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
android:clipToPadding="false"
|
||||
android:clipChildren="false"
|
||||
android:padding="4dp"
|
||||
android:background="@drawable/screenshot_border"
|
||||
>
|
||||
<FrameLayout
|
||||
android:elevation="0dp"
|
||||
android:background="@drawable/screenshot_preview_background"
|
||||
android:clipChildren="true"
|
||||
android:clipToOutline="true"
|
||||
android:clipToPadding="true"
|
||||
android:layout_width="@dimen/screenshot_x_scale"
|
||||
android:layout_height="wrap_content">
|
||||
<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="?android:attr/textColorPrimary"
|
||||
android:layout_width="@dimen/screenshot_x_scale"
|
||||
android:layout_height="@dimen/screenshot_x_scale"/>
|
||||
<ImageView
|
||||
android:id="@+id/image_preview"
|
||||
android:scaleType="fitCenter"
|
||||
android:adjustViewBounds="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
</FrameLayout>
|
||||
</FrameLayout>
|
||||
@@ -17,9 +17,8 @@
|
||||
<com.android.systemui.clipboardoverlay.DraggableConstraintLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_gravity="bottom"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="match_parent">
|
||||
<ImageView
|
||||
android:id="@+id/actions_container_background"
|
||||
android:visibility="gone"
|
||||
@@ -57,5 +56,81 @@
|
||||
android:id="@+id/edit_chip"/>
|
||||
</LinearLayout>
|
||||
</HorizontalScrollView>
|
||||
<include layout="@layout/clipboard_content_preview" />
|
||||
<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="parent"
|
||||
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="?android:attr/textColorPrimary"
|
||||
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"
|
||||
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.clipboardoverlay.DraggableConstraintLayout>
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="gone"
|
||||
android:elevation="@dimen/screenshot_preview_elevation"
|
||||
android:elevation="@dimen/overlay_preview_elevation"
|
||||
android:src="@android:color/white"/>
|
||||
<com.android.systemui.screenshot.ScreenshotSelectorView
|
||||
android:id="@+id/screenshot_selector"
|
||||
|
||||
@@ -63,20 +63,20 @@
|
||||
android:id="@+id/screenshot_preview_border"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginStart="@dimen/screenshot_offset_x"
|
||||
android:layout_marginBottom="@dimen/screenshot_offset_y"
|
||||
android:elevation="@dimen/screenshot_preview_elevation"
|
||||
android:layout_marginStart="@dimen/overlay_offset_x"
|
||||
android:layout_marginBottom="@dimen/overlay_offset_y"
|
||||
android:elevation="@dimen/overlay_preview_elevation"
|
||||
android:alpha="0"
|
||||
android:background="@drawable/screenshot_border"
|
||||
android:background="@drawable/overlay_border"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="@+id/screenshot_preview_end"
|
||||
app:layout_constraintTop_toTopOf="@+id/screenshot_preview_top"/>
|
||||
app:layout_constraintEnd_toEndOf="@id/screenshot_preview_end"
|
||||
app:layout_constraintTop_toTopOf="@id/screenshot_preview_top"/>
|
||||
<androidx.constraintlayout.widget.Barrier
|
||||
android:id="@+id/screenshot_preview_end"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:barrierMargin="4dp"
|
||||
app:barrierMargin="@dimen/overlay_border_width"
|
||||
app:barrierDirection="end"
|
||||
app:constraint_referenced_ids="screenshot_preview"/>
|
||||
<androidx.constraintlayout.widget.Barrier
|
||||
@@ -84,30 +84,30 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:barrierDirection="top"
|
||||
app:barrierMargin="-4dp"
|
||||
app:barrierMargin="@dimen/overlay_border_width_neg"
|
||||
app:constraint_referenced_ids="screenshot_preview"/>
|
||||
<ImageView
|
||||
android:id="@+id/screenshot_preview"
|
||||
android:visibility="invisible"
|
||||
android:layout_width="@dimen/screenshot_x_scale"
|
||||
android:layout_margin="4dp"
|
||||
android:layout_margin="@dimen/overlay_border_width"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:elevation="@dimen/screenshot_preview_elevation"
|
||||
android:elevation="@dimen/overlay_preview_elevation"
|
||||
android:contentDescription="@string/screenshot_edit_description"
|
||||
android:scaleType="fitEnd"
|
||||
android:background="@drawable/screenshot_preview_background"
|
||||
android:background="@drawable/overlay_preview_background"
|
||||
android:adjustViewBounds="true"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/screenshot_preview_border"
|
||||
app:layout_constraintStart_toStartOf="@+id/screenshot_preview_border"
|
||||
app:layout_constraintEnd_toEndOf="@+id/screenshot_preview_border"
|
||||
app:layout_constraintTop_toTopOf="@+id/screenshot_preview_border">
|
||||
app:layout_constraintBottom_toBottomOf="@id/screenshot_preview_border"
|
||||
app:layout_constraintStart_toStartOf="@id/screenshot_preview_border"
|
||||
app:layout_constraintEnd_toEndOf="@id/screenshot_preview_border"
|
||||
app:layout_constraintTop_toTopOf="@id/screenshot_preview_border">
|
||||
</ImageView>
|
||||
<FrameLayout
|
||||
android:id="@+id/screenshot_dismiss_button"
|
||||
android:layout_width="@dimen/screenshot_dismiss_button_tappable_size"
|
||||
android:layout_height="@dimen/screenshot_dismiss_button_tappable_size"
|
||||
android:elevation="7dp"
|
||||
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"
|
||||
app:layout_constraintStart_toEndOf="@id/screenshot_preview"
|
||||
app:layout_constraintEnd_toEndOf="@id/screenshot_preview"
|
||||
@@ -118,8 +118,8 @@
|
||||
android:id="@+id/screenshot_dismiss_image"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="@dimen/screenshot_dismiss_button_margin"
|
||||
android:src="@drawable/screenshot_cancel"/>
|
||||
android:layout_margin="@dimen/overlay_dismiss_button_margin"
|
||||
android:src="@drawable/overlay_cancel"/>
|
||||
</FrameLayout>
|
||||
<ImageView
|
||||
android:id="@+id/screenshot_scrollable_preview"
|
||||
@@ -129,5 +129,5 @@
|
||||
android:visibility="gone"
|
||||
app:layout_constraintStart_toStartOf="@id/screenshot_preview"
|
||||
app:layout_constraintTop_toTopOf="@id/screenshot_preview"
|
||||
android:elevation="@dimen/screenshot_preview_elevation"/>
|
||||
android:elevation="@dimen/overlay_preview_elevation"/>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
@@ -261,11 +261,6 @@
|
||||
<!-- The padding on the global screenshot background image -->
|
||||
<dimen name="screenshot_x_scale">80dp</dimen>
|
||||
<dimen name="screenshot_bg_protection_height">242dp</dimen>
|
||||
<dimen name="screenshot_preview_elevation">4dp</dimen>
|
||||
<dimen name="screenshot_offset_y">8dp</dimen>
|
||||
<dimen name="screenshot_offset_x">16dp</dimen>
|
||||
<dimen name="screenshot_dismiss_button_tappable_size">48dp</dimen>
|
||||
<dimen name="screenshot_dismiss_button_margin">8dp</dimen>
|
||||
<dimen name="screenshot_action_container_corner_radius">18dp</dimen>
|
||||
<dimen name="screenshot_action_container_padding_vertical">4dp</dimen>
|
||||
<dimen name="screenshot_action_container_margin_horizontal">8dp</dimen>
|
||||
@@ -289,6 +284,19 @@
|
||||
<dimen name="screenshot_crop_handle_thickness">3dp</dimen>
|
||||
<dimen name="long_screenshot_action_bar_top_margin">8dp</dimen>
|
||||
|
||||
<!-- Dimensions shared between "overlays" (clipboard and screenshot preview UIs) -->
|
||||
<dimen name="overlay_offset_y">8dp</dimen>
|
||||
<dimen name="overlay_offset_x">16dp</dimen>
|
||||
<dimen name="overlay_preview_elevation">4dp</dimen>
|
||||
<dimen name="overlay_dismiss_button_elevation">7dp</dimen>
|
||||
<dimen name="overlay_dismiss_button_tappable_size">48dp</dimen>
|
||||
<dimen name="overlay_dismiss_button_margin">8dp</dimen>
|
||||
<dimen name="overlay_border_width">4dp</dimen>
|
||||
<!-- need a negative margin for some of the constraints. should be overlay_border_width * -1 -->
|
||||
<dimen name="overlay_border_width_neg">-4dp</dimen>
|
||||
|
||||
<dimen name="clipboard_preview_size">@dimen/screenshot_x_scale</dimen>
|
||||
|
||||
|
||||
<!-- The width of the view containing navigation buttons -->
|
||||
<dimen name="navigation_key_width">70dp</dimen>
|
||||
|
||||
@@ -2364,4 +2364,6 @@
|
||||
<string name="clipboard_edit_text_copy">Copy</string>
|
||||
<!-- Text informing user that content has been copied to the system clipboard [CHAR LIMIT=NONE] -->
|
||||
<string name="clipboard_overlay_text_copied">Copied</string>
|
||||
<!-- Label for button to dismiss clipboard overlay [CHAR LIMIT=NONE] -->
|
||||
<string name="clipboard_dismiss_description">Dismiss copy UI</string>
|
||||
</resources>
|
||||
|
||||
@@ -59,6 +59,7 @@ import android.view.View;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.WindowInsets;
|
||||
import android.view.WindowManager;
|
||||
import android.view.accessibility.AccessibilityManager;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
@@ -91,6 +92,7 @@ public class ClipboardOverlayController {
|
||||
private final WindowManager.LayoutParams mWindowLayoutParams;
|
||||
private final PhoneWindow mWindow;
|
||||
private final TimeoutHandler mTimeoutHandler;
|
||||
private final AccessibilityManager mAccessibilityManager;
|
||||
|
||||
private final DraggableConstraintLayout mView;
|
||||
private final ImageView mImagePreview;
|
||||
@@ -98,6 +100,7 @@ public class ClipboardOverlayController {
|
||||
private final ScreenshotActionChip mEditChip;
|
||||
private final ScreenshotActionChip mRemoteCopyChip;
|
||||
private final View mActionContainerBackground;
|
||||
private final View mDismissButton;
|
||||
|
||||
private Runnable mOnSessionCompleteListener;
|
||||
|
||||
@@ -113,6 +116,8 @@ public class ClipboardOverlayController {
|
||||
final Context displayContext = context.createDisplayContext(getDefaultDisplay());
|
||||
mContext = displayContext.createWindowContext(TYPE_SCREENSHOT, null);
|
||||
|
||||
mAccessibilityManager = AccessibilityManager.getInstance(mContext);
|
||||
|
||||
mWindowManager = mContext.getSystemService(WindowManager.class);
|
||||
|
||||
mTimeoutHandler = timeoutHandler;
|
||||
@@ -135,10 +140,13 @@ public class ClipboardOverlayController {
|
||||
mTextPreview = requireNonNull(mView.findViewById(R.id.text_preview));
|
||||
mEditChip = requireNonNull(mView.findViewById(R.id.edit_chip));
|
||||
mRemoteCopyChip = requireNonNull(mView.findViewById(R.id.remote_copy_chip));
|
||||
mDismissButton = requireNonNull(mView.findViewById(R.id.dismiss_button));
|
||||
|
||||
mView.setOnDismissCallback(this::hideImmediate);
|
||||
mView.setOnInteractionCallback(() -> mTimeoutHandler.resetTimeout());
|
||||
|
||||
mDismissButton.setOnClickListener(view -> animateOut());
|
||||
|
||||
mEditChip.setIcon(Icon.createWithResource(mContext, R.drawable.ic_screenshot_edit), true);
|
||||
mRemoteCopyChip.setIcon(
|
||||
Icon.createWithResource(mContext, R.drawable.ic_baseline_devices_24), true);
|
||||
@@ -158,10 +166,10 @@ public class ClipboardOverlayController {
|
||||
withWindowAttached(() -> {
|
||||
mWindow.setContentView(mView);
|
||||
updateInsets(mWindowManager.getCurrentWindowMetrics().getWindowInsets());
|
||||
getEnterAnimation().start();
|
||||
mView.post(() -> getEnterAnimation().start());
|
||||
});
|
||||
|
||||
mTimeoutHandler.setOnTimeoutRunnable(() -> animateOut());
|
||||
mTimeoutHandler.setOnTimeoutRunnable(this::animateOut);
|
||||
|
||||
mCloseDialogsReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
@@ -226,8 +234,8 @@ public class ClipboardOverlayController {
|
||||
mView.getLocationOnScreen(pt);
|
||||
Rect rect = new Rect(pt[0], pt[1], pt[0] + mView.getWidth(),
|
||||
pt[1] + mView.getHeight());
|
||||
if (!rect.contains((int) motionEvent.getRawX(),
|
||||
(int) motionEvent.getRawY())) {
|
||||
if (!rect.contains(
|
||||
(int) motionEvent.getRawX(), (int) motionEvent.getRawY())) {
|
||||
animateOut();
|
||||
}
|
||||
}
|
||||
@@ -311,11 +319,15 @@ public class ClipboardOverlayController {
|
||||
ValueAnimator anim = ValueAnimator.ofFloat(0, 1);
|
||||
|
||||
mView.setAlpha(0);
|
||||
mDismissButton.setVisibility(View.GONE);
|
||||
final View previewBorder = requireNonNull(mView.findViewById(R.id.preview_border));
|
||||
final View actionBackground = requireNonNull(
|
||||
mView.findViewById(R.id.actions_container_background));
|
||||
mImagePreview.setVisibility(View.VISIBLE);
|
||||
mActionContainerBackground.setVisibility(View.VISIBLE);
|
||||
if (mAccessibilityManager.isEnabled()) {
|
||||
mDismissButton.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
anim.addUpdateListener(animation -> {
|
||||
mView.setAlpha(animation.getAnimatedFraction());
|
||||
@@ -385,7 +397,7 @@ public class ClipboardOverlayController {
|
||||
|
||||
private void reset() {
|
||||
mView.setTranslationX(0);
|
||||
mView.setAlpha(1);
|
||||
mView.setAlpha(0);
|
||||
mTimeoutHandler.cancelTimeout();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user