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

Commit a3c755b2 authored by Chris Wren's avatar Chris Wren Committed by Android Git Automerger
Browse files

am 0425de31: Merge "eliminate notification clicker garbage." into mnc-dev

* commit '0425de31':
  eliminate notification clicker garbage.
parents 7a80f122 0425de31
Loading
Loading
Loading
Loading
+38 −35
Original line number Original line Diff line number Diff line
@@ -238,6 +238,8 @@ public abstract class BaseStatusBar extends SystemUI implements
    protected DismissView mDismissView;
    protected DismissView mDismissView;
    protected EmptyShadeView mEmptyShadeView;
    protected EmptyShadeView mEmptyShadeView;


    private NotificationClicker mNotificationClicker = new NotificationClicker();

    @Override  // NotificationData.Environment
    @Override  // NotificationData.Environment
    public boolean isDeviceProvisioned() {
    public boolean isDeviceProvisioned() {
        return mDeviceProvisioned;
        return mDeviceProvisioned;
@@ -1292,13 +1294,7 @@ public abstract class BaseStatusBar extends SystemUI implements
            row.setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS);
            row.setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS);
        }
        }


        PendingIntent contentIntent = sbn.getNotification().contentIntent;
        mNotificationClicker.register(row, sbn);
        if (contentIntent != null) {
            final View.OnClickListener listener = makeClicker(contentIntent, sbn.getKey());
            row.setOnClickListener(listener);
        } else {
            row.setOnClickListener(null);
        }


        // set up the adaptive layout
        // set up the adaptive layout
        View contentViewLocal = null;
        View contentViewLocal = null;
@@ -1559,35 +1555,38 @@ public abstract class BaseStatusBar extends SystemUI implements
        }
        }
    }
    }


    public NotificationClicker makeClicker(PendingIntent intent, String notificationKey) {
    private final class NotificationClicker implements View.OnClickListener {
        return new NotificationClicker(intent, notificationKey);
        public void onClick(final View v) {
            if (!(v instanceof ExpandableNotificationRow)) {
                Log.e(TAG, "NotificationClicker called on a view that is not a notification row.");
                return;
            }
            }


    protected class NotificationClicker implements View.OnClickListener {
            final ExpandableNotificationRow row = (ExpandableNotificationRow) v;
        private PendingIntent mIntent;
            final StatusBarNotification sbn = row.getStatusBarNotification();
        private final String mNotificationKey;
            if (sbn == null) {

                Log.e(TAG, "NotificationClicker called on an unclickable notification,");
        public NotificationClicker(PendingIntent intent, String notificationKey) {
                return;
            mIntent = intent;
            mNotificationKey = notificationKey;
            }
            }


        public void onClick(final View v) {
            final PendingIntent intent = sbn.getNotification().contentIntent;
            final String notificationKey = sbn.getKey();

            if (NOTIFICATION_CLICK_DEBUG) {
            if (NOTIFICATION_CLICK_DEBUG) {
                Log.d(TAG, "Clicked on content of " + mNotificationKey);
                Log.d(TAG, "Clicked on content of " + notificationKey);
            }
            }
            final boolean keyguardShowing = mStatusBarKeyguardViewManager.isShowing();
            final boolean keyguardShowing = mStatusBarKeyguardViewManager.isShowing();
            final boolean afterKeyguardGone = mIntent.isActivity()
            final boolean afterKeyguardGone = intent.isActivity()
                    && PreviewInflater.wouldLaunchResolverActivity(mContext, mIntent.getIntent(),
                    && PreviewInflater.wouldLaunchResolverActivity(mContext, intent.getIntent(),
                            mCurrentUserId);
                            mCurrentUserId);
            dismissKeyguardThenExecute(new OnDismissAction() {
            dismissKeyguardThenExecute(new OnDismissAction() {
                public boolean onDismiss() {
                public boolean onDismiss() {
                    if (mHeadsUpManager != null && mHeadsUpManager.isHeadsUp(mNotificationKey)) {
                    if (mHeadsUpManager != null && mHeadsUpManager.isHeadsUp(notificationKey)) {
                        // Release the HUN notification to the shade.
                        // Release the HUN notification to the shade.
                        //
                        //
                        // In most cases, when FLAG_AUTO_CANCEL is set, the notification will
                        // In most cases, when FLAG_AUTO_CANCEL is set, the notification will
                        // become canceled shortly by NoMan, but we can't assume that.
                        // become canceled shortly by NoMan, but we can't assume that.
                        mHeadsUpManager.releaseImmediately(mNotificationKey);
                        mHeadsUpManager.releaseImmediately(notificationKey);
                    }
                    }
                    new Thread() {
                    new Thread() {
                        @Override
                        @Override
@@ -1606,9 +1605,9 @@ public abstract class BaseStatusBar extends SystemUI implements
                            } catch (RemoteException e) {
                            } catch (RemoteException e) {
                            }
                            }


                            if (mIntent != null) {
                            if (intent != null) {
                                try {
                                try {
                                    mIntent.send();
                                    intent.send();
                                } catch (PendingIntent.CanceledException e) {
                                } catch (PendingIntent.CanceledException e) {
                                    // the stack trace isn't very helpful here.
                                    // the stack trace isn't very helpful here.
                                    // Just log the exception message.
                                    // Just log the exception message.
@@ -1616,14 +1615,14 @@ public abstract class BaseStatusBar extends SystemUI implements


                                    // TODO: Dismiss Keyguard.
                                    // TODO: Dismiss Keyguard.
                                }
                                }
                                if (mIntent.isActivity()) {
                                if (intent.isActivity()) {
                                    overrideActivityPendingAppTransition(keyguardShowing
                                    overrideActivityPendingAppTransition(keyguardShowing
                                            && !afterKeyguardGone);
                                            && !afterKeyguardGone);
                                }
                                }
                            }
                            }


                            try {
                            try {
                                mBarService.onNotificationClick(mNotificationKey);
                                mBarService.onNotificationClick(notificationKey);
                            } catch (RemoteException ex) {
                            } catch (RemoteException ex) {
                                // system process is dead if we're here.
                                // system process is dead if we're here.
                            }
                            }
@@ -1635,10 +1634,19 @@ public abstract class BaseStatusBar extends SystemUI implements
                            true /* force */, true /* delayed */);
                            true /* force */, true /* delayed */);
                    visibilityChanged(false);
                    visibilityChanged(false);


                    return mIntent != null && mIntent.isActivity();
                    return intent != null && intent.isActivity();
                }
                }
            }, afterKeyguardGone);
            }, afterKeyguardGone);
        }
        }

        public void register(ExpandableNotificationRow row, StatusBarNotification sbn) {
            final PendingIntent contentIntent = sbn.getNotification().contentIntent;
            if (contentIntent != null) {
                row.setOnClickListener(this);
            } else {
                row.setOnClickListener(null);
            }
        }
    }
    }


    public void animateCollapsePanels(int flags, boolean force) {
    public void animateCollapsePanels(int flags, boolean force) {
@@ -2037,13 +2045,8 @@ public abstract class BaseStatusBar extends SystemUI implements
            publicContentView.reapply(mContext, entry.getPublicContentView(), mOnClickHandler);
            publicContentView.reapply(mContext, entry.getPublicContentView(), mOnClickHandler);
        }
        }
        // update the contentIntent
        // update the contentIntent
        final PendingIntent contentIntent = notification.getNotification().contentIntent;
        mNotificationClicker.register(entry.row, notification);
        if (contentIntent != null) {

            final View.OnClickListener listener = makeClicker(contentIntent, notification.getKey());
            entry.row.setOnClickListener(listener);
        } else {
            entry.row.setOnClickListener(null);
        }
        entry.row.setStatusBarNotification(notification);
        entry.row.setStatusBarNotification(notification);
        entry.row.notifyContentUpdated();
        entry.row.notifyContentUpdated();
        entry.row.resetHeight();
        entry.row.resetHeight();