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

Commit 469e96e2 authored by Daniel Sandler's avatar Daniel Sandler
Browse files

Close notification blame popups when the panel disappears.

Also be sure to cancel the longpress listeners when things
change.

Finally, increase the longpress timeout to 1.5x normal
longpress.

Bug: 6441520
Change-Id: Icea4d2a5c98a9a51a15f0762454de9e5cd454c50
parent b4b2223f
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -74,6 +74,7 @@ public class SwipeHelper implements Gefingerpoken {
    private boolean mLongPressSent;
    private View.OnLongClickListener mLongPressListener;
    private Runnable mWatchLongPress;
    private long mLongPressTimeout;

    public SwipeHelper(int swipeDirection, Callback callback, float densityScale,
            float pagingTouchSlop) {
@@ -83,6 +84,8 @@ public class SwipeHelper implements Gefingerpoken {
        mVelocityTracker = VelocityTracker.obtain();
        mDensityScale = densityScale;
        mPagingTouchSlop = pagingTouchSlop;

        mLongPressTimeout = (long) (ViewConfiguration.getLongPressTimeout() * 1.5f); // extra long-press!
    }

    public void setLongPressListener(View.OnLongClickListener listener) {
@@ -180,7 +183,7 @@ public class SwipeHelper implements Gefingerpoken {
        }
    }

    private void removeLongPressCallback() {
    public void removeLongPressCallback() {
        if (mWatchLongPress != null) {
            mHandler.removeCallbacks(mWatchLongPress);
        }
@@ -214,7 +217,7 @@ public class SwipeHelper implements Gefingerpoken {
                                }
                            };
                        }
                        mHandler.postDelayed(mWatchLongPress, ViewConfiguration.getLongPressTimeout());
                        mHandler.postDelayed(mWatchLongPress, mLongPressTimeout);
                    }

                }
+15 −4
Original line number Diff line number Diff line
@@ -91,6 +91,8 @@ public abstract class BaseStatusBar extends SystemUI implements
    protected RecentsPanelView mRecentsPanel;
    protected RecentTasksLoader mRecentTasksLoader;

    protected PopupMenu mNotificationBlamePopup;

    // UI-specific methods

    /**
@@ -238,9 +240,11 @@ public abstract class BaseStatusBar extends SystemUI implements
                final String packageNameF = (String) v.getTag();
                if (packageNameF == null) return false;
                if (v.getWindowToken() == null) return false;
                PopupMenu popup = new PopupMenu(mContext, v);
                popup.getMenuInflater().inflate(R.menu.notification_popup_menu, popup.getMenu());
                popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
                mNotificationBlamePopup = new PopupMenu(mContext, v);
                mNotificationBlamePopup.getMenuInflater().inflate(
                        R.menu.notification_popup_menu,
                        mNotificationBlamePopup.getMenu());
                mNotificationBlamePopup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
                    public boolean onMenuItemClick(MenuItem item) {
                        if (item.getItemId() == R.id.notification_inspect_item) {
                            startApplicationDetailsActivity(packageNameF);
@@ -251,13 +255,20 @@ public abstract class BaseStatusBar extends SystemUI implements
                        return true;
                    }
                });
                popup.show();
                mNotificationBlamePopup.show();

                return true;
            }
        };
    }

    public void dismissPopups() {
        if (mNotificationBlamePopup != null) {
            mNotificationBlamePopup.dismiss();
            mNotificationBlamePopup = null;
        }
    }

    public void dismissIntruder() {
        // pass
    }
+4 −0
Original line number Diff line number Diff line
@@ -1235,6 +1235,10 @@ public class PhoneStatusBar extends BaseStatusBar {
            return;
        }
        mExpanded = false;

        // Close any "App info" popups that might have snuck on-screen
        dismissPopups();

        if (mPostCollapseCleanup != null) {
            mPostCollapseCleanup.run();
            mPostCollapseCleanup = null;
+9 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
import android.widget.LinearLayout;

import com.android.systemui.ExpandHelper;
@@ -108,6 +109,14 @@ public class NotificationRowLayout
        mSwipeHelper.setLongPressListener(listener);
    }

    @Override
    public void onWindowFocusChanged(boolean hasWindowFocus) {
        super.onWindowFocusChanged(hasWindowFocus);
        if (!hasWindowFocus) {
            mSwipeHelper.removeLongPressCallback();
        }
    }

    public void setAnimateBounds(boolean anim) {
        mAnimateBounds = anim;
    }