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

Commit 8e0675e7 authored by Mady Mellor's avatar Mady Mellor Committed by Automerger Merge Worker
Browse files

Merge "Fix transitions in the background when launching something in TaskView"...

Merge "Fix transitions in the background when launching something in TaskView" into sc-dev am: 83f4345f

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14551317

Change-Id: I973eed431d2fa4fd7aee3e81af0473ad2dd3f98d
parents 51d3fe02 83f4345f
Loading
Loading
Loading
Loading
+11 −8
Original line number Diff line number Diff line
@@ -118,15 +118,15 @@ public class TaskView extends SurfaceView implements SurfaceHolder.Callback,
     *
     * @param shortcut the shortcut used to launch the activity.
     * @param options options for the activity.
     * @param sourceBounds the rect containing the source bounds of the clicked icon to open
     *                     this shortcut.
     * @param launchBounds the bounds (window size and position) that the activity should be
     *                     launched in, in pixels and in screen coordinates.
     */
    public void startShortcutActivity(@NonNull ShortcutInfo shortcut,
            @NonNull ActivityOptions options, @Nullable Rect sourceBounds) {
        prepareActivityOptions(options);
            @NonNull ActivityOptions options, @Nullable Rect launchBounds) {
        prepareActivityOptions(options, launchBounds);
        LauncherApps service = mContext.getSystemService(LauncherApps.class);
        try {
            service.startShortcut(shortcut, sourceBounds, options.toBundle());
            service.startShortcut(shortcut, null /* sourceBounds */, options.toBundle());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
@@ -138,10 +138,12 @@ public class TaskView extends SurfaceView implements SurfaceHolder.Callback,
     * @param pendingIntent Intent used to launch an activity.
     * @param fillInIntent Additional Intent data, see {@link Intent#fillIn Intent.fillIn()}
     * @param options options for the activity.
     * @param launchBounds the bounds (window size and position) that the activity should be
     *                     launched in, in pixels and in screen coordinates.
     */
    public void startActivity(@NonNull PendingIntent pendingIntent, @Nullable Intent fillInIntent,
            @NonNull ActivityOptions options) {
        prepareActivityOptions(options);
            @NonNull ActivityOptions options, @Nullable Rect launchBounds) {
        prepareActivityOptions(options, launchBounds);
        try {
            pendingIntent.send(mContext, 0 /* code */, fillInIntent,
                    null /* onFinished */, null /* handler */, null /* requiredPermission */,
@@ -151,11 +153,12 @@ public class TaskView extends SurfaceView implements SurfaceHolder.Callback,
        }
    }

    private void prepareActivityOptions(ActivityOptions options) {
    private void prepareActivityOptions(ActivityOptions options, Rect launchBounds) {
        final Binder launchCookie = new Binder();
        mShellExecutor.execute(() -> {
            mTaskOrganizer.setPendingLaunchCookieListener(launchCookie, this);
        });
        options.setLaunchBounds(launchBounds);
        options.setLaunchCookie(launchCookie);
        options.setLaunchWindowingMode(WINDOWING_MODE_MULTI_WINDOW);
        options.setRemoveWithTaskOrganizer(true);
+6 −2
Original line number Diff line number Diff line
@@ -153,6 +153,9 @@ public class BubbleExpandedView extends LinearLayout {
            ActivityOptions options = ActivityOptions.makeCustomAnimation(getContext(),
                    0 /* enterResId */, 0 /* exitResId */);

            Rect launchBounds = new Rect();
            mTaskView.getBoundsOnScreen(launchBounds);

            // TODO: I notice inconsistencies in lifecycle
            // Post to keep the lifecycle normal
            post(() -> {
@@ -166,7 +169,7 @@ public class BubbleExpandedView extends LinearLayout {
                    if (!mIsOverflow && mBubble.hasMetadataShortcutId()) {
                        options.setApplyActivityFlagsForBubbles(true);
                        mTaskView.startShortcutActivity(mBubble.getShortcutInfo(),
                                options, null /* sourceBounds */);
                                options, launchBounds);
                    } else {
                        Intent fillInIntent = new Intent();
                        // Apply flags to make behaviour match documentLaunchMode=always.
@@ -175,7 +178,8 @@ public class BubbleExpandedView extends LinearLayout {
                        if (mBubble != null) {
                            mBubble.setIntentActive();
                        }
                        mTaskView.startActivity(mPendingIntent, fillInIntent, options);
                        mTaskView.startActivity(mPendingIntent, fillInIntent, options,
                                launchBounds);
                    }
                } catch (RuntimeException e) {
                    // If there's a runtime exception here then there's something
+2 −1
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import android.app.ActivityManager;
import android.app.ActivityOptions;
import android.app.PendingIntent;
import android.content.Context;
import android.graphics.Rect;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import android.view.SurfaceControl;
@@ -125,7 +126,7 @@ public class TaskViewTest extends ShellTestCase {
    @Test
    public void testStartActivity() {
        ActivityOptions options = ActivityOptions.makeBasic();
        mTaskView.startActivity(mock(PendingIntent.class), null, options);
        mTaskView.startActivity(mock(PendingIntent.class), null, options, new Rect(0, 0, 100, 100));

        verify(mOrganizer).setPendingLaunchCookieListener(any(), eq(mTaskView));
        assertThat(options.getLaunchWindowingMode()).isEqualTo(WINDOWING_MODE_MULTI_WINDOW);
+1 −0
Original line number Diff line number Diff line
@@ -1333,6 +1333,7 @@
    <dimen name="controls_setup_title">22sp</dimen>
    <dimen name="controls_setup_subtitle">14sp</dimen>
    <dimen name="controls_setup_vertical_padding">52dp</dimen>
    <dimen name="controls_detail_dialog_header_height">52dp</dimen>

    <!-- Home Controls activity view detail panel-->
    <dimen name="controls_activity_view_top_offset">100dp</dimen>
+21 −2
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.app.PendingIntent
import android.content.ComponentName
import android.content.Context
import android.content.Intent
import android.graphics.Rect
import android.view.View
import android.view.ViewGroup
import android.view.WindowInsets
@@ -83,8 +84,9 @@ class DetailDialog(
            taskView.startActivity(
                PendingIntent.getActivity(context, 0, launchIntent,
                        PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE),
                null,
                options
                null /* fillInIntent */,
                options,
                getTaskViewBounds()
            )
        }

@@ -159,6 +161,23 @@ class DetailDialog(
        taskView.setListener(cvh.uiExecutor, stateCallback)
    }

    fun getTaskViewBounds(): Rect {
        val wm = context.getSystemService(WindowManager::class.java)
        val windowMetrics = wm.getCurrentWindowMetrics()
        val rect = windowMetrics.bounds
        val metricInsets = windowMetrics.windowInsets
        val insets = metricInsets.getInsetsIgnoringVisibility(Type.systemBars()
                or Type.displayCutout())
        val headerHeight = context.resources.getDimensionPixelSize(
                R.dimen.controls_detail_dialog_header_height)

        val finalRect = Rect(rect.left - insets.left /* left */,
                rect.top + insets.top + headerHeight /* top */,
                rect.right - insets.right /* right */,
                rect.bottom - insets.bottom /* bottom */)
        return finalRect
    }

    override fun dismiss() {
        if (!isShowing()) return
        taskView.release()
Loading