Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 317cffa8 authored by Miranda Kephart's avatar Miranda Kephart
Browse files

Add background protection to clipboard UI

Bug: 195554988
Test: manual
Change-Id: Ia1de8afbd8a43abb543a478771718ab47c322760
parent 551b26eb
Loading
Loading
Loading
Loading
+126 −115
Original line number Diff line number Diff line
@@ -14,13 +14,23 @@
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->
<com.android.systemui.clipboardoverlay.DraggableConstraintLayout
<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    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.clipboardoverlay.DraggableConstraintLayout
        android:id="@+id/clipboard_ui"
        android:theme="@style/FloatingOverlay"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <ImageView
            android:id="@+id/actions_container_background"
            android:visibility="gone"
@@ -137,3 +147,4 @@
                android:src="@drawable/overlay_cancel"/>
        </FrameLayout>
    </com.android.systemui.clipboardoverlay.DraggableConstraintLayout>
</FrameLayout>
 No newline at end of file
+8 −6
Original line number Diff line number Diff line
@@ -103,6 +103,7 @@ public class ClipboardOverlayController {
    private final AccessibilityManager mAccessibilityManager;
    private final TextClassifier mTextClassifier;

    private final FrameLayout mContainer;
    private final DraggableConstraintLayout mView;
    private final ImageView mImagePreview;
    private final TextView mTextPreview;
@@ -147,8 +148,9 @@ public class ClipboardOverlayController {
        mWindow = FloatingWindowUtil.getFloatingWindow(mContext);
        mWindow.setWindowManager(mWindowManager, null, null);

        mView = (DraggableConstraintLayout)
        mContainer = (FrameLayout)
                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));
@@ -180,7 +182,7 @@ public class ClipboardOverlayController {

        attachWindow();
        withWindowAttached(() -> {
            mWindow.setContentView(mView);
            mWindow.setContentView(mContainer);
            updateInsets(mWindowManager.getCurrentWindowMetrics().getWindowInsets());
            mView.requestLayout();
            mView.post(this::animateIn);
@@ -371,7 +373,7 @@ public class ClipboardOverlayController {
    private ValueAnimator getEnterAnimation() {
        ValueAnimator anim = ValueAnimator.ofFloat(0, 1);

        mView.setAlpha(0);
        mContainer.setAlpha(0);
        mDismissButton.setVisibility(View.GONE);
        final View previewBorder = requireNonNull(mView.findViewById(R.id.preview_border));
        final View actionBackground = requireNonNull(
@@ -383,7 +385,7 @@ public class ClipboardOverlayController {
        }

        anim.addUpdateListener(animation -> {
            mView.setAlpha(animation.getAnimatedFraction());
            mContainer.setAlpha(animation.getAnimatedFraction());
            float scale = 0.6f + 0.4f * animation.getAnimatedFraction();
            mView.setPivotY(mView.getHeight() - previewBorder.getHeight() / 2f);
            mView.setPivotX(actionBackground.getWidth() / 2f);
@@ -394,7 +396,7 @@ public class ClipboardOverlayController {
            @Override
            public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                mView.setAlpha(1);
                mContainer.setAlpha(1);
                mTimeoutHandler.resetTimeout();
            }
        });
@@ -439,7 +441,7 @@ public class ClipboardOverlayController {

    private void reset() {
        mView.setTranslationX(0);
        mView.setAlpha(0);
        mContainer.setAlpha(0);
        resetActionChips();
        mTimeoutHandler.cancelTimeout();
    }