Skip to content

Commit 0827e7c

Browse files
StarkDroiddarknius09
authored andcommitted
[1/2] Statusbar Clock background chip
Inspired by looking at few magisk/substratum module :P Signed-off-by: StarkDroid <[email protected]> Signed-off-by: Rahmad Adi Pratama <[email protected]>
1 parent 914450f commit 0827e7c

File tree

4 files changed

+40
-3
lines changed

4 files changed

+40
-3
lines changed

core/java/android/provider/Settings.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5589,7 +5589,15 @@ public static void setShowGTalkServiceStatusForUser(ContentResolver cr, boolean
55895589
* 1 - Right of clock
55905590
* @hide
55915591
*/
5592-
public static final String STATUSBAR_CLOCK_DATE_POSITION = "statusbar_clock_date_position";
5592+
public static final String STATUSBAR_CLOCK_DATE_POSITION = "statusbar_clock_date_position";
5593+
5594+
/**
5595+
* Statusbar clock background
5596+
* 0 - hide accented chip
5597+
* 1 - show accented chip (default)
5598+
* @hide
5599+
*/
5600+
public static final String STATUSBAR_CLOCK_CHIP = "statusbar_clock_chip";
55935601

55945602
/**
55955603
* Whether to show the notification ticker on the status bar
@@ -5960,6 +5968,7 @@ public static void setShowGTalkServiceStatusForUser(ContentResolver cr, boolean
59605968
PRIVATE_SETTINGS.add(STATUSBAR_CLOCK_DATE_STYLE);
59615969
PRIVATE_SETTINGS.add(STATUSBAR_CLOCK_DATE_FORMAT);
59625970
PRIVATE_SETTINGS.add(STATUSBAR_CLOCK_DATE_POSITION);
5971+
PRIVATE_SETTINGS.add(STATUSBAR_CLOCK_CHIP);
59635972
PRIVATE_SETTINGS.add(ACCENT_COLOR);
59645973
PRIVATE_SETTINGS.add(USE_WALL_ACCENT);
59655974
PRIVATE_SETTINGS.add(AUTO_ACCENT_TYPE);
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<shape xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:shape="rectangle">
4+
<solid android:color="?android:attr/colorAccent"/>
5+
<corners android:radius="28dp"/>
6+
</shape>

packages/SystemUI/res/layout/status_bar.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,14 @@
7575
<com.android.systemui.statusbar.policy.Clock
7676
android:id="@+id/clock"
7777
android:layout_width="wrap_content"
78-
android:layout_height="match_parent"
78+
android:layout_height="wrap_content"
7979
android:textAppearance="@style/TextAppearance.StatusBar.Clock"
8080
android:singleLine="true"
8181
android:visibility="gone"
8282
android:paddingStart="@dimen/status_bar_left_clock_starting_padding"
8383
android:paddingEnd="@dimen/status_bar_left_clock_end_padding"
8484
android:gravity="center_vertical|start"
85+
android:layout_gravity="center_vertical"
8586
/>
8687

8788
<com.android.systemui.statusbar.AlphaOptimizedFrameLayout
@@ -127,12 +128,13 @@
127128
android:id="@+id/right_clock"
128129
android:textAppearance="@style/TextAppearance.StatusBar.Clock"
129130
android:layout_width="wrap_content"
130-
android:layout_height="match_parent"
131+
android:layout_height="wrap_content"
131132
android:singleLine="true"
132133
android:visibility="gone"
133134
android:paddingStart="@dimen/status_bar_clock_starting_padding"
134135
android:paddingEnd="@dimen/status_bar_clock_end_padding"
135136
android:gravity="center_vertical|start"
137+
android:layout_gravity="center_vertical"
136138
/>
137139
</LinearLayout>
138140

packages/SystemUI/src/com/android/systemui/statusbar/phone/CollapsedStatusBarFragment.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ public class CollapsedStatusBarFragment extends Fragment implements CommandQueue
8181
private LinearLayout mCenterClockLayout;
8282
private View mRightClock;
8383
private boolean mShowClock = true;
84+
private boolean mShowSBClockBg = true;
8485
private final Handler mHandler = new Handler();
8586
private BatteryMeterView mBatteryMeterView;
8687
private StatusIconContainer mStatusIcons;
@@ -98,6 +99,9 @@ void observe() {
9899
mContentResolver.registerContentObserver(Settings.System.getUriFor(
99100
Settings.System.STATUSBAR_CLOCK_STYLE),
100101
false, this, UserHandle.USER_ALL);
102+
mContentResolver.registerContentObserver(Settings.System.getUriFor(
103+
Settings.System.STATUSBAR_CLOCK_CHIP),
104+
false, this, UserHandle.USER_ALL);
101105
}
102106

103107
@Override
@@ -462,6 +466,22 @@ public void updateSettings(boolean animate) {
462466
Settings.System.STATUSBAR_CLOCK_STYLE, 0,
463467
UserHandle.USER_CURRENT);
464468
}
469+
470+
mShowSBClockBg = Settings.System.getIntForUser(mContentResolver,
471+
Settings.System.STATUSBAR_CLOCK_CHIP, 1,
472+
UserHandle.USER_CURRENT) == 1;
473+
474+
if (mShowSBClockBg) {
475+
mClockView.setBackgroundResource(R.drawable.sb_date_bg);
476+
mClockView.setPadding(10,5,10,5);
477+
mRightClock.setBackgroundResource(R.drawable.sb_date_bg);
478+
mRightClock.setPadding(10,5,10,5);
479+
} else {
480+
mClockView.setBackgroundResource(0);
481+
mClockView.setPadding(0,0,0,0);
482+
mRightClock.setBackgroundResource(0);
483+
mRightClock.setPadding(0,0,0,0);
484+
}
465485
updateClockStyle(animate);
466486
}
467487

0 commit comments

Comments
 (0)