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

Commit 7e36009d authored by Mady Mellor's avatar Mady Mellor Committed by Android (Google) Code Review
Browse files

Merge "Make lifecycle events for bubble activity views report normally" into qt-dev

parents 07deba3c 60101c9f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -117,6 +117,7 @@ package android.app {
    method public void startActivity(@NonNull android.content.Intent);
    method public void startActivity(@NonNull android.content.Intent, android.os.UserHandle);
    method public void startActivity(@NonNull android.app.PendingIntent);
    method public void startActivity(@NonNull android.app.PendingIntent, @NonNull android.app.ActivityOptions);
  }

  public abstract static class ActivityView.StateCallback {
+28 −0
Original line number Diff line number Diff line
@@ -254,6 +254,34 @@ public class ActivityView extends ViewGroup {
        }
    }

    /**
     * Launch a new activity into this container.
     * <p>Activity resolved by the provided {@link PendingIntent} must have
     * {@link android.R.attr#resizeableActivity} attribute set to {@code true} in order to be
     * launched here. Also, if activity is not owned by the owner of this container, it must allow
     * embedding and the caller must have permission to embed.
     * <p>Note: This class must finish initializing and
     * {@link StateCallback#onActivityViewReady(ActivityView)} callback must be triggered before
     * this method can be called.
     *
     * @param pendingIntent Intent used to launch an activity.
     * @param options options for the activity
     *
     * @see StateCallback
     * @see #startActivity(Intent)
     */
    public void startActivity(@NonNull PendingIntent pendingIntent,
            @NonNull ActivityOptions options) {
        options.setLaunchDisplayId(mVirtualDisplay.getDisplay().getDisplayId());
        try {
            pendingIntent.send(null /* context */, 0 /* code */, null /* intent */,
                    null /* onFinished */, null /* handler */, null /* requiredPermission */,
                    options.toBundle());
        } catch (PendingIntent.CanceledException e) {
            throw new RuntimeException(e);
        }
    }

    /**
     * Check if container is ready to launch and create {@link ActivityOptions} to target the
     * virtual display.
+6 −1
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import static android.view.Display.INVALID_DISPLAY;
import android.animation.LayoutTransition;
import android.animation.ObjectAnimator;
import android.annotation.Nullable;
import android.app.ActivityOptions;
import android.app.ActivityView;
import android.app.INotificationManager;
import android.app.Notification;
@@ -121,7 +122,11 @@ public class BubbleExpandedView extends LinearLayout implements View.OnClickList
        public void onActivityViewReady(ActivityView view) {
            if (!mActivityViewReady) {
                mActivityViewReady = true;
                mActivityView.startActivity(mBubbleIntent);
                // Custom options so there is no activity transition animation
                ActivityOptions options = ActivityOptions.makeCustomAnimation(getContext(),
                        0 /* enterResId */, 0 /* exitResId */);
                // Post to keep the lifecycle normal
                post(() -> mActivityView.startActivity(mBubbleIntent, options));
            }
        }