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

Commit c75c0875 authored by Miranda Kephart's avatar Miranda Kephart
Browse files

Only run clipboard shared transition for images

There's no available shared transition for text, so trying to run a
shared transition looks bad. Switch to only running the shared
transition for images, otherwise regular dismiss + share intent.

Bug: 369132381
Fix: 369132381
Test: manual (invoke share for text content)
Flag: com.android.systemui.clipboard_shared_transitions
Change-Id: Iecaa3d86a512cc85d7af845403f352381dd14b0a
parent 20f915ec
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -710,9 +710,16 @@ public class ClipboardOverlayController implements ClipboardListener.ClipboardOv
    @Override
    public void onShareButtonTapped() {
        if (clipboardSharedTransitions()) {
            if (mClipboardModel.getType() != ClipboardModel.Type.OTHER) {
            switch (mClipboardModel.getType()) {
                case TEXT:
                case URI:
                    finish(CLIPBOARD_OVERLAY_SHARE_TAPPED,
                            IntentCreator.getShareIntent(mClipboardModel.getClipData(), mContext));
                    break;
                case IMAGE:
                    finishWithSharedTransition(CLIPBOARD_OVERLAY_SHARE_TAPPED,
                            IntentCreator.getShareIntent(mClipboardModel.getClipData(), mContext));
                    break;
            }
        }
    }
+14 −8
Original line number Diff line number Diff line
@@ -104,6 +104,8 @@ public class ClipboardOverlayControllerTest extends SysuiTestCase {

    @Mock
    private Animator mAnimator;
    @Mock
    private Animator mEndAnimator;
    private ArgumentCaptor<Animator.AnimatorListener> mAnimatorListenerCaptor =
            ArgumentCaptor.forClass(Animator.AnimatorListener.class);

@@ -123,7 +125,7 @@ public class ClipboardOverlayControllerTest extends SysuiTestCase {
        MockitoAnnotations.initMocks(this);

        when(mClipboardOverlayView.getEnterAnimation()).thenReturn(mAnimator);
        when(mClipboardOverlayView.getExitAnimation()).thenReturn(mAnimator);
        when(mClipboardOverlayView.getExitAnimation()).thenReturn(mEndAnimator);
        when(mClipboardOverlayView.getFadeOutAnimation()).thenReturn(mAnimator);
        when(mClipboardOverlayWindow.getWindowInsets()).thenReturn(
                getImeInsets(new Rect(0, 0, 0, 0)));
@@ -318,11 +320,11 @@ public class ClipboardOverlayControllerTest extends SysuiTestCase {
        mOverlayController.setClipData(mSampleClipData, "");

        mCallbacks.onShareButtonTapped();
        verify(mAnimator).addListener(mAnimatorListenerCaptor.capture());
        mAnimatorListenerCaptor.getValue().onAnimationEnd(mAnimator);
        verify(mEndAnimator).addListener(mAnimatorListenerCaptor.capture());
        mAnimatorListenerCaptor.getValue().onAnimationEnd(mEndAnimator);

        verify(mUiEventLogger, times(1)).log(CLIPBOARD_OVERLAY_SHARE_TAPPED, 0, "");
        verify(mClipboardOverlayView, times(1)).getFadeOutAnimation();
        verify(mClipboardOverlayView, times(1)).getExitAnimation();
    }

    @Test
@@ -343,8 +345,8 @@ public class ClipboardOverlayControllerTest extends SysuiTestCase {
        initController();

        mCallbacks.onDismissButtonTapped();
        verify(mAnimator).addListener(mAnimatorListenerCaptor.capture());
        mAnimatorListenerCaptor.getValue().onAnimationEnd(mAnimator);
        verify(mEndAnimator).addListener(mAnimatorListenerCaptor.capture());
        mAnimatorListenerCaptor.getValue().onAnimationEnd(mEndAnimator);

        // package name is null since we haven't actually set a source for this test
        verify(mUiEventLogger, times(1)).log(CLIPBOARD_OVERLAY_DISMISS_TAPPED, 0, null);
@@ -403,14 +405,18 @@ public class ClipboardOverlayControllerTest extends SysuiTestCase {

        mOverlayController.setClipData(mSampleClipData, "first.package");
        mCallbacks.onShareButtonTapped();
        verify(mEndAnimator).addListener(mAnimatorListenerCaptor.capture());
        mAnimatorListenerCaptor.getValue().onAnimationEnd(mEndAnimator);

        mOverlayController.setClipData(mSampleClipData, "second.package");
        mCallbacks.onShareButtonTapped();
        verify(mEndAnimator, times(2)).addListener(mAnimatorListenerCaptor.capture());
        mAnimatorListenerCaptor.getValue().onAnimationEnd(mEndAnimator);

        verify(mUiEventLogger).log(CLIPBOARD_OVERLAY_SHARE_TAPPED, 0, "first.package");
        verify(mUiEventLogger).log(CLIPBOARD_OVERLAY_SHARE_TAPPED, 0, "second.package");
        verify(mUiEventLogger).log(CLIPBOARD_OVERLAY_SHOWN_EXPANDED, 0, "first.package");
        verify(mUiEventLogger).log(CLIPBOARD_OVERLAY_SHARE_TAPPED, 0, "first.package");
        verify(mUiEventLogger).log(CLIPBOARD_OVERLAY_SHOWN_EXPANDED, 0, "second.package");
        verify(mUiEventLogger).log(CLIPBOARD_OVERLAY_SHARE_TAPPED, 0, "second.package");
        verifyNoMoreInteractions(mUiEventLogger);
    }