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

Commit 82296cfe authored by Mark Renouf's avatar Mark Renouf Committed by Android (Google) Code Review
Browse files

Merge "Only call ActivityView.startActivity once per bubble"

parents 22f2b4cc 8eafa224
Loading
Loading
Loading
Loading
+0 −16
Original line number Diff line number Diff line
@@ -478,22 +478,6 @@ public class BubbleStackView extends FrameLayout implements BubbleTouchHandler.F
            final PendingIntent intent = mExpandedBubble.getAppOverlayIntent();
            mExpandedViewContainer.setHeaderText(intent.getIntent().getComponent().toShortString());
            mExpandedViewContainer.setExpandedView(expandedView);
            expandedView.setCallback(new ActivityView.StateCallback() {
                @Override
                public void onActivityViewReady(ActivityView view) {
                    Log.d(TAG, "onActivityViewReady("
                            + mExpandedBubble.getEntry().key + "): " + view);
                    view.startActivity(intent);
                }

                @Override
                public void onActivityViewDestroyed(ActivityView view) {
                    NotificationEntry entry = mExpandedBubble != null
                            ? mExpandedBubble.getEntry() : null;
                    Log.d(TAG, "onActivityViewDestroyed(key="
                            + ((entry != null) ? entry.key : "(none)") + "): " + view);
                }
            });
        } else {
            // Bubble with notification view expanded state
            ExpandableNotificationRow row = mExpandedBubble.getRowView();
+28 −15
Original line number Diff line number Diff line
@@ -60,6 +60,8 @@ public class BubbleView extends FrameLayout implements BubbleTouchHandler.Floati
    private NotificationEntry mEntry;
    private PendingIntent mAppOverlayIntent;
    private ActivityView mActivityView;
    private boolean mActivityViewReady;
    private boolean mActivityViewStarted;

    public BubbleView(Context context) {
        this(context, null);
@@ -232,8 +234,21 @@ public class BubbleView extends FrameLayout implements BubbleTouchHandler.Floati
     */
    public ActivityView getActivityView() {
        if (mActivityView == null) {
            mActivityView = new ActivityView(mContext);
            mActivityView = new ActivityView(mContext, null /* attrs */, 0 /* defStyle */,
                    true /* singleTaskInstance */);
            Log.d(TAG, "[getActivityView] created: " + mActivityView);
            mActivityView.setCallback(new ActivityView.StateCallback() {
                @Override
                public void onActivityViewReady(ActivityView view) {
                    mActivityViewReady = true;
                    mActivityView.startActivity(mAppOverlayIntent);
                }

                @Override
                public void onActivityViewDestroyed(ActivityView view) {
                    mActivityViewReady = false;
                }
            });
        }
        return mActivityView;
    }
@@ -245,22 +260,20 @@ public class BubbleView extends FrameLayout implements BubbleTouchHandler.Floati
        if (mActivityView == null) {
            return;
        }
        // HACK: Only release if initialized. There's no way to know if the ActivityView has
        // been initialized. Calling release() if it hasn't been initialized will crash.

        if (!mActivityView.isAttachedToWindow()) {
        if (!mActivityViewReady) {
            // release not needed, never initialized?
            mActivityView = null;
            return;
        }
        // HACK: release() will crash if the view is not attached.

        if (!mActivityView.isAttachedToWindow()) {
            mActivityView.setVisibility(View.GONE);
            tmpParent.addView(mActivityView, new LinearLayout.LayoutParams(
                    ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.MATCH_PARENT));
        }
        try {

        mActivityView.release();
        } catch (IllegalStateException ex) {
            Log.e(TAG, "ActivityView either already released, or not yet initialized.", ex);
        }

        ((ViewGroup) mActivityView.getParent()).removeView(mActivityView);
        mActivityView = null;