[MOD][HOW-TO] AOSP Style Notification Drawer "Clear Notifications" Button

upndwn4par

Inactive Recognized Developer
Jan 22, 2012
3,640
10,375
0
New Jersey
This guide will allow you to move the clear notifications button in a TW ROM to the position common in AOSP ROMS.

This mod also removes the notification text, allowing a little more room for notifications.

Decompile SystemUI.apk and navigate to res/layout/tw_status_bar_expanded.xml then delete the line in red.

Code:
<LinearLayout android:orientation="vertical" android:id="@id/noNotificationsTitle" android:focusable="true" android:layout_width="fill_parent" android:layout_height="wrap_content">
    <TextView android:textSize="@dimen/status_bar_expanded_notification_category_text_size" android:textStyle="bold" android:textColor="@color/notification_category_color" android:gravity="left|center" android:id="@id/noNotificationsText" android:paddingLeft="11.0dip" android:layout_width="fill_parent" android:layout_height="@dimen/status_bar_expanded_notification_category_height" android:text="@string/status_bar_no_notifications_title" />
</LinearLayout>
<LinearLayout android:orientation="vertical" android:id="@id/onGoingCart" android:background="#ff293945" android:focusable="true" android:visibility="gone" android:layout_width="fill_parent" android:layout_height="@dimen/status_bar_expanded_notification_category_height">
    <TextView android:textSize="@dimen/status_bar_expanded_notification_category_text_size" android:textStyle="bold" android:textColor="@color/notification_category_color" android:gravity="left|center" android:id="@id/onGoingNotificationText" android:paddingLeft="11.0dip" android:layout_width="wrap_content" android:layout_height="fill_parent" android:text="@string/status_bar_ongoing_events_title" />
</LinearLayout>
<com.android.systemui.statusbar.policy.NotificationRowLayout android:id="@id/onGoingItems" android:layout_width="fill_parent" android:layout_height="wrap_content" systemui:rowHeight="@dimen/tw_notification_row_min_height" />
<LinearLayout android:orientation="vertical" android:id="@id/notificationCart" android:background="#ff293945" android:visibility="gone" android:layout_width="fill_parent" android:layout_height="@dimen/status_bar_expanded_notification_category_height">
    <RelativeLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content">
        <TextView android:textSize="@dimen/status_bar_expanded_notification_category_text_size" android:textStyle="bold" android:textColor="@color/notification_category_color" android:gravity="left|center" android:id="@id/latestNotificationText" android:paddingLeft="11.0dip" android:layout_width="180.0dip" android:layout_height="fill_parent" android:text="@string/status_bar_latest_events_title" android:layout_alignParentLeft="true" />
        [COLOR="Red"]<TextView android:textSize="@dimen/status_bar_expanded_notification_clear_button_text_size" android:textColor="@color/tw_status_bar_clear_btn_text" android:gravity="center" android:id="@id/clear_all_button" android:background="@drawable/tw_btn_default_small" android:padding="0.100000024dip" android:focusable="true" android:clickable="true" android:layout_width="@dimen/status_bar_expanded_clear_button_width" android:layout_height="fill_parent" android:layout_marginRight="4.0dip" android:text="@string/status_bar_clear_all_button" android:layout_alignParentRight="true" android:contentDescription="@string/accessibility_clear_all" />[/COLOR]
    </RelativeLayout>
</LinearLayout>
<com.android.systemui.statusbar.policy.NotificationRowLayout android:id="@id/notificationItems" android:layout_width="fill_parent" android:layout_height="wrap_content" systemui:rowHeight="@dimen/tw_notification_row_min_height" />
<com.android.systemui.statusbar.policy.NotificationRowLayout android:id="@id/latestItems" android:layout_width="fill_parent" android:layout_height="wrap_content" systemui:rowHeight="@dimen/tw_notification_row_min_height" />

Navigate to res/layout/tw_status_bar_expanded_header.xml and add the lines in blue.

Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:gravity="center_vertical" android:orientation="horizontal" android:background="#ff000000" android:layout_width="fill_parent" android:layout_height="39.0dip" android:baselineAligned="false"
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:systemui="http://schemas.android.com/apk/res/com.android.systemui">
    <com.android.systemui.statusbar.policy.ClockStock android:textAppearance="@style/TextAppearance.StatusBar.Expanded.Clock" android:textColor="#ff808080" android:id="@id/clock" [COLOR="Blue"]android:visibility="gone"[/COLOR] android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="8.0dip" android:singleLine="true" />
    <com.android.systemui.statusbar.policy.DateView android:textAppearance="@style/TextAppearance.StatusBar.Expanded.Date" android:textColor="#ff808080" android:ellipsize="none" android:id="@id/date" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="8.0dip" android:layout_marginRight="4.0dip" android:maxLines="2" />
    <com.android.systemui.statusbar.RotationToggle android:id="@id/rotation_lock_button" android:visibility="gone" android:clickable="true" android:layout_width="32.0dip" android:layout_height="32.0dip" android:layout_margin="8.0dip" android:button="@drawable/ic_notify_rotation" android:contentDescription="@string/accessibility_rotation_lock_off" />
    <Space android:layout_width="0.0dip" android:layout_height="0.0dip" android:layout_weight="1.0" />
    [COLOR="Blue"]<LinearLayout android:orientation="vertical" android:id="@id/notificationCart" android:background="#ff000000" android:visibility="gone" android:layout_width="72.0dip" android:layout_height="39.0dip">
        <RelativeLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content">
            <TextView android:textSize="@dimen/status_bar_expanded_notification_clear_button_text_size" android:textColor="#ff808080" android:gravity="center" android:id="@id/clear_all_button" android:background="@drawable/tw_btn_default_small" android:padding="0.100000024dip" android:focusable="true" android:clickable="true" android:layout_width="96.0dip" android:layout_height="fill_parent" android:layout_marginRight="4.0dip" android:text="@string/status_bar_clear_all_button" android:layout_alignParentRight="true" android:contentDescription="@string/accessibility_clear_all" />
        </RelativeLayout>
    </LinearLayout>[/COLOR]
    <ImageView android:layout_width="1.0dip" android:layout_height="25.0dip" android:layout_marginTop="7.0dip" android:layout_marginBottom="7.0dip" android:src="@drawable/tw_quick_panel_plnm_setting_dv" />
    <RelativeLayout android:id="@id/settings_button" android:background="@drawable/tw_quick_panel_setting_button_bg" android:focusable="true" android:visibility="visible" android:layout_width="72.0dip" android:layout_height="39.0dip">
        <ImageView android:id="@id/settings_button_icon" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/tw_quickpanel_icon_settings" android:scaleType="center" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:contentDescription="@string/accessibility_settings_button" />
    </RelativeLayout>
</LinearLayout>
Options:
Change the button text color (android:textColor="#ff808080") to whatever you want.

Add the line "android:visibility="gone"" to the clock line to remove the clock.

Recompile and push to your device.
 
Last edited:

hednik

Senior Member
May 31, 2012
1,529
707
0
Fort Worth
First


and woohoo...going to try this out tomorrow !

That clear button from TW is my most hated feature.

Thanks again for this

Sent from my SAMSUNG-SGH-I747 using xda premium
 
Last edited:
  • Like
Reactions: upndwn4par

The LPT

Member
Jan 25, 2013
33
6
0
Awesome work! Can't wait for this mod to eventually make its way to your S3R ROM.

Now if we could only get the smooth scrolling in notification window like in AOSP ROMs. :)

Sent from my SAMSUNG-SGH-I747
 

The LPT

Member
Jan 25, 2013
33
6
0
I'm not loserskater. ;)
Wow I feel like a tool :eek:

Assumption, small fonts, and hidden avatars in the XDA app are a bad mix when you're half asleep.

My apologies. Looks like I'll be trying out CSROM again very soon. Im assuming(there's that word again!) it will make its way there. Or has it already?

Sent from my SAMSUNG-SGH-I747
 
Last edited:

hednik

Senior Member
May 31, 2012
1,529
707
0
Fort Worth
Success. You made my day !

Now how would I go about changing the button icon ? When looking at the code see its listed at tw_button_small or something like that yet I don't see that PNG. With the CM status bar you change the PNG but TW clear button seems different

When I tried to change the color I kept getting compiling errors so maybe in wasn't doing it correctly but I'll keep at troubleshooting that one.

Sent from my SAMSUNG-SGH-I747 using xda premium
 

enewman17

Senior Member
Sep 20, 2010
3,672
8,717
0
Fort Wayne, IN
Success. You made my day !

Now how would I go about changing the button icon ? When looking at the code see its listed at tw_button_small or something like that yet I don't see that PNG. With the CM status bar you change the PNG but TW clear button seems different

When I tried to change the color I kept getting compiling errors so maybe in wasn't doing it correctly but I'll keep at troubleshooting that one.

Sent from my SAMSUNG-SGH-I747 using xda premium
The drawable/tw_btn_default_small" is actually an xml file in the res/drawable then it points to these.

Code:
<?xml version="1.0" encoding="utf-8"?>
<selector
  xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="true" android:[email protected]/tw_quick_panel_clearbtn_press" />
    <item android:state_focused="true" android:[email protected]/tw_quick_panel_clearbtn_focus" />
    <item android:state_selected="true" android:[email protected]/tw_quick_panel_clearbtn_select" />
    <item android:state_enabled="true" android:[email protected]/tw_quick_panel_clearbtn_normal" />
    <item android:[email protected]/tw_quick_panel_clearbtn_normal" />
</selector>
And there in the res/drawable-xhdpi forlder. Those are the images that would need edited.
 
Last edited:

upndwn4par

Inactive Recognized Developer
Jan 22, 2012
3,640
10,375
0
New Jersey
Success. You made my day !

Now how would I go about changing the button icon ? When looking at the code see its listed at tw_button_small or something like that yet I don't see that PNG. With the CM status bar you change the PNG but TW clear button seems different

When I tried to change the color I kept getting compiling errors so maybe in wasn't doing it correctly but I'll keep at troubleshooting that one.

Sent from my SAMSUNG-SGH-I747 using xda premium
The drawable/tw_btn_default_small" is actually an xml file in the res/drawable then it points to these.

Code:
<?xml version="1.0" encoding="utf-8"?>
<selector
  xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="true" android:[email protected]/tw_quick_panel_clearbtn_press" />
    <item android:state_focused="true" android:[email protected]/tw_quick_panel_clearbtn_focus" />
    <item android:state_selected="true" android:[email protected]/tw_quick_panel_clearbtn_select" />
    <item android:state_enabled="true" android:[email protected]/tw_quick_panel_clearbtn_normal" />
    <item android:[email protected]/tw_quick_panel_clearbtn_normal" />
</selector>
And there in the res/drawable-xhdpi forlder. Those are the images that would need edited.
Correct. And if you want to use an AOSP style clear button (offset horizontal slashes), be sure to set your clear button text to 0dp.
 
  • Like
Reactions: enewman17

hednik

Senior Member
May 31, 2012
1,529
707
0
Fort Worth
The drawable/tw_btn_default_small" is actually an xml file in the res/drawable then it points to these.

Code:
<?xml version="1.0" encoding="utf-8"?>
<selector
  xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="true" android:[email protected]/tw_quick_panel_clearbtn_press" />
    <item android:state_focused="true" android:[email protected]/tw_quick_panel_clearbtn_focus" />
    <item android:state_selected="true" android:[email protected]/tw_quick_panel_clearbtn_select" />
    <item android:state_enabled="true" android:[email protected]/tw_quick_panel_clearbtn_normal" />
    <item android:[email protected]/tw_quick_panel_clearbtn_normal" />
</selector>
And there in the res/drawable-xhdpi forlder. Those are the images that would need edited.
You are the man Enewman17. Thanks !

Sent from my SAMSUNG-SGH-I747 using xda premium
 
  • Like
Reactions: enewman17

enewman17

Senior Member
Sep 20, 2010
3,672
8,717
0
Fort Wayne, IN
use existing stock AOSP icons

If you want to use the existing stock AOSP icons this is how. Follow upndwn4par's op on removing the line in the tw_status_bar_expanded then...

res/layout/tw_status_bar_expanded_header.xml

Add / change whats in blue so it looks similar to this

Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:gravity="center_vertical" android:orientation="horizontal" android:background="#ff000000" android:layout_width="fill_parent" android:layout_height="39.0dip" android:baselineAligned="false"
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:systemui="http://schemas.android.com/apk/res/com.android.systemui">
    <com.android.systemui.statusbar.policy.ClockStock android:textAppearance="@style/TextAppearance.StatusBar.Expanded.Clock" android:textColor="#ffffffff" android:id="@id/clock" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="4.0dip" android:singleLine="true" systemui:ampmSmall="true" />
    <com.android.systemui.statusbar.policy.DateView android:textAppearance="@style/TextAppearance.StatusBar.Expanded.Date" android:textColor="#ffcbcbcb" android:ellipsize="none" android:id="@id/date" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="8.0dip" android:layout_marginRight="4.0dip" android:maxLines="2" />
    <com.android.systemui.statusbar.RotationToggle android:id="@id/rotation_lock_button" android:visibility="gone" android:clickable="true" android:layout_width="32.0dip" android:layout_height="32.0dip" android:layout_margin="8.0dip" android:button="@drawable/ic_notify_rotation" android:contentDescription="@string/accessibility_rotation_lock_off" />
[COLOR="Blue"]    <Space android:layout_width="0.0dip" android:layout_height="0.0dip" android:layout_weight="1.0" />
    <ImageView android:id="@id/clear_all_button" android:layout_width="48.0dip" android:layout_height="48.0dip" android:src="@drawable/ic_notify_clear" android:scaleType="center" android:contentDescription="@string/accessibility_clear_all" />
    <ImageView android:layout_width="1.0dip" android:layout_height="25.0dip" android:layout_marginTop="7.0dip" android:layout_marginBottom="7.0dip" android:src="@drawable/tw_quick_panel_plnm_setting_dv" />
    <ImageView android:id="@id/settings_button" android:layout_width="48.0dip" android:layout_height="48.0dip" android:src="@drawable/ic_notify_quicksettings" android:scaleType="center" android:contentDescription="@string/accessibility_settings_button" />[/COLOR]
</LinearLayout>
 

Attachments

Last edited: