Skip to content

Commit 671688f

Browse files
maxwentemasek
authored andcommitted
[Framework] Add config to apply custom shadow on header images
To make text and status icons better visible with bright images if required. - Fix headershadow derp, thanks to @xyyx Change-Id: I393d7eb55425e72a953947f0ce0a2b33f5ed3ef8
1 parent fd66d77 commit 671688f

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

core/java/android/provider/Settings.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3818,6 +3818,14 @@ public boolean validate(String value) {
38183818
*/
38193819
public static final String STATUS_BAR_CUSTOM_HEADER = "status_bar_custom_header";
38203820

3821+
/**
3822+
*
3823+
* Whether to apply a shadow on top of the header image
3824+
* value is the alpha value of the shadow image is 0 -> no shadow -> 255 black
3825+
* @hide
3826+
*/
3827+
public static final String STATUS_BAR_CUSTOM_HEADER_SHADOW = "status_bar_custom_header_shadow";
3828+
38213829
/**
38223830
* Current active provider
38233831
* @hide

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,10 @@ protected void observe() {
607607
resolver.registerContentObserver(Settings.System.getUriFor(
608608
Settings.System.QS_NUM_TILE_ROWS), false, this,
609609
UserHandle.USER_ALL);
610+
resolver.registerContentObserver(Settings.System.getUriFor(
611+
Settings.System.STATUS_BAR_CUSTOM_HEADER_SHADOW), false, this,
612+
UserHandle.USER_ALL);
613+
610614
update();
611615
}
612616

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import android.graphics.Outline;
3131
import android.graphics.Rect;
3232
import android.graphics.drawable.Animatable;
33+
import android.graphics.drawable.ColorDrawable;
3334
import android.graphics.drawable.Drawable;
3435
import android.graphics.drawable.RippleDrawable;
3536
import android.graphics.drawable.TransitionDrawable;
@@ -516,6 +517,7 @@ private void updateVisibilities() {
516517
mDockBatteryLevel.setForceShown(mExpanded && mShowBatteryTextExpanded);
517518
mDockBatteryLevel.setVisibility(View.VISIBLE);
518519
}
520+
applyHeaderBackgroundShadow();
519521
}
520522

521523
private void updateSignalClusterDetachment() {
@@ -1294,6 +1296,19 @@ private void setNotificationPanelHeaderBackground(final Drawable dw, final boole
12941296
} else {
12951297
mBackgroundImage.setImageDrawable(dw);
12961298
}
1299+
applyHeaderBackgroundShadow();
1300+
}
1301+
1302+
private void applyHeaderBackgroundShadow() {
1303+
final int headerShadow = Settings.System.getIntForUser(mContext.getContentResolver(),
1304+
Settings.System.STATUS_BAR_CUSTOM_HEADER_SHADOW, 0,
1305+
UserHandle.USER_CURRENT);
1306+
1307+
if (mBackgroundImage != null) {
1308+
ColorDrawable shadow = new ColorDrawable(Color.BLACK);
1309+
shadow.setAlpha(headerShadow);
1310+
mBackgroundImage.setForeground(shadow);
1311+
}
12971312
}
12981313

12991314
@Override

0 commit comments

Comments
 (0)