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

Commit c803422b authored by Daniel Sandler's avatar Daniel Sandler Committed by Android (Google) Code Review
Browse files

Merge "Clear all notifications on tablet actually works now."

parents 69ecb0a0 06a0d4b5
Loading
Loading
Loading
Loading
+0 −12
Original line number Diff line number Diff line
@@ -35,18 +35,6 @@
            android:clipChildren="false"
            >

            <ImageView android:id="@+id/clear_all_button"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_alignParentRight="true"
                android:layout_marginTop="1dp"
                android:layout_marginRight="20dp"
                android:paddingLeft="15dp"
                android:paddingRight="15dp"
                android:src="@drawable/ic_notify_clear"
                android:visibility="invisible"
                />

            <!-- notification icons & panel access -->
            <include layout="@layout/status_bar_notification_area" 
                android:layout_width="wrap_content"
+12 −0
Original line number Diff line number Diff line
@@ -24,6 +24,18 @@
    android:gravity="right"
    >

    <ImageView android:id="@+id/clear_all_button"
        android:layout_width="wrap_content"
        android:layout_height="@*android:dimen/status_bar_height"
        android:layout_alignParentRight="true"
        android:layout_alignParentBottom="true"
        android:layout_marginRight="20dp"
        android:paddingLeft="15dp"
        android:paddingRight="15dp"
        android:src="@drawable/ic_notify_clear"
        android:visibility="invisible"
        />

    <RelativeLayout
        android:id="@+id/content_parent"
        android:layout_height="wrap_content"
+24 −5
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ public class NotificationPanel extends RelativeLayout implements StatusBarPanel,
    final static int PANEL_FADE_DURATION = 150;

    boolean mShowing;
    boolean mHasClearableNotifications = false;
    int mNotificationCount = 0;
    NotificationPanelTitle mTitleArea;
    View mSettingsButton;
@@ -50,6 +51,7 @@ public class NotificationPanel extends RelativeLayout implements StatusBarPanel,
    View mSettingsView;
    ViewGroup mContentParent;
    TabletStatusBar mBar;
    View mClearButton;

    // amount to slide mContentParent down by when mContentFrame is missing
    float mContentFrameMissingTranslation;
@@ -84,14 +86,27 @@ public class NotificationPanel extends RelativeLayout implements StatusBarPanel,

        mNotificationScroller = findViewById(R.id.notification_scroller);
        mContentFrame = (ViewGroup)findViewById(R.id.content_frame);
        mContentFrameMissingTranslation =
            mContentFrame.getBackground().getMinimumHeight() + 10;
        mContentFrameMissingTranslation = 0; // not needed with current assets

        // the "X" that appears in place of the clock when the panel is showing notifications
        mClearButton = findViewById(R.id.clear_all_button);
        mClearButton.setOnClickListener(mClearButtonListener);

        mShowing = false;

        setContentFrameVisible(mNotificationCount > 0, false);
    }

    private View.OnClickListener mClearButtonListener = new View.OnClickListener() {
        public void onClick(View v) {
            mBar.clearAll();
        }
    };

    public View getClearButton() {
        return mClearButton;
    }

    public void show(boolean show, boolean animate) {
        if (show && !mShowing) {
            setContentFrameVisible(mSettingsView != null || mNotificationCount > 0, false);
@@ -264,12 +279,16 @@ public class NotificationPanel extends RelativeLayout implements StatusBarPanel,
        if (mBar != null) {
            final boolean showX 
                = (isShowing()
                        && mNotificationScroller.getVisibility() == View.VISIBLE 
                        && mNotificationCount > 0);
            mBar.getClearButton().setVisibility(showX ? View.VISIBLE : View.INVISIBLE);
                        && mHasClearableNotifications
                        && mNotificationScroller.getVisibility() == View.VISIBLE);
            getClearButton().setVisibility(showX ? View.VISIBLE : View.INVISIBLE);
        }
    }

    public void setClearable(boolean clearable) {
        mHasClearableNotifications = clearable;
    }

    public void updatePanelModeButtons() {
        final boolean settingsVisible = (mSettingsView != null);
        mSettingsButton.setVisibility(!settingsVisible ? View.VISIBLE : View.INVISIBLE);
+12 −20
Original line number Diff line number Diff line
@@ -122,7 +122,6 @@ public class TabletStatusBar extends StatusBar implements
    View mNotificationTrigger;
    NotificationIconArea mNotificationIconArea;
    ViewGroup mNavigationArea;
    View mClearButton;

    boolean mNotificationDNDMode;
    NotificationData.Entry mNotificationDNDDummyEntry;
@@ -453,10 +452,6 @@ public class TabletStatusBar extends StatusBar implements
        // the more notifications icon
        mNotificationIconArea = (NotificationIconArea)sb.findViewById(R.id.notificationIcons);

        // the "X" that appears in place of the clock when the panel is showing notifications
        mClearButton = sb.findViewById(R.id.clear_all_button);
        mClearButton.setOnClickListener(mClearButtonListener);

        // where the icons go
        mIconLayout = (NotificationIconArea.IconLayout) sb.findViewById(R.id.icons);
        mIconLayout.setOnTouchListener(new NotificationIconTouchListener());
@@ -587,21 +582,6 @@ public class TabletStatusBar extends StatusBar implements
        return sb;
    }

    private View.OnClickListener mClearButtonListener = new View.OnClickListener() {
        public void onClick(View v) {
            try {
                mBarService.onClearAllNotifications();
            } catch (RemoteException ex) {
                // system process is dead if we're here.
            }
            animateCollapse();
        }
    };

    public View getClearButton() {
        return mClearButton;
    }

    public int getStatusBarHeight() {
        return mHeightReceiver.getHeight();
    }
@@ -1204,6 +1184,9 @@ public class TabletStatusBar extends StatusBar implements
    }

    private void setAreThereNotifications() {
        if (mNotificationPanel != null) {
            mNotificationPanel.setClearable(mNotificationData.hasClearableItems());
        }
    }

    /**
@@ -1779,6 +1762,15 @@ public class TabletStatusBar extends StatusBar implements
        return true;
    }

    public void clearAll() {
        try {
            mBarService.onClearAllNotifications();
        } catch (RemoteException ex) {
            // system process is dead if we're here.
        }
        animateCollapse();
    }

    public void userActivity() {
    }

+5 −0
Original line number Diff line number Diff line
@@ -94,6 +94,11 @@ public class TabletStatusBarView extends FrameLayout {
        mHandler = h;
    }

    /**
     * Let the status bar know that if you tap on ignore while panel is showing, don't do anything.
     * 
     * Debounces taps on, say, a popup's trigger when the popup is already showing.
     */
    public void setIgnoreChildren(int index, View ignore, View panel) {
        mIgnoreChildren[index] = ignore;
        mPanels[index] = panel;