Update OMS patches
[GitHub/Stricted/android_vendor_extra.git] / patches / frameworks / base / 0020-Allow-custom-alpha-for-notification-shade-bg-color.patch
1 From 00722b38ae2b5f0d92d671143298c22d2d30a09b Mon Sep 17 00:00:00 2001
2 From: Simao Gomes Viana <xdevs23@outlook.com>
3 Date: Fri, 25 Nov 2016 20:50:29 +0100
4 Subject: [PATCH 20/51] Allow custom alpha for notification shade bg color
5
6 Change-Id: If621df83d994feae0448a734408ba85ac8329325
7 ---
8 .../stack/NotificationStackScrollLayout.java | 40 +++++++++++++++-------
9 1 file changed, 27 insertions(+), 13 deletions(-)
10
11 diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
12 index 9c969900015..84a9715cd45 100644
13 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
14 +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
15 @@ -431,19 +431,33 @@ public class NotificationStackScrollLayout extends ViewGroup
16 }
17
18 private void updateBackgroundDimming() {
19 - float alpha = BACKGROUND_ALPHA_DIMMED + (1 - BACKGROUND_ALPHA_DIMMED) * (1.0f - mDimAmount);
20 - alpha *= mBackgroundFadeAmount;
21 - // We need to manually blend in the background color
22 - int scrimColor = mScrimController.getScrimBehindColor();
23 - // SRC_OVER blending Sa + (1 - Sa)*Da, Rc = Sc + (1 - Sa)*Dc
24 - float alphaInv = 1 - alpha;
25 - int color = Color.argb((int) (alpha * 255 + alphaInv * Color.alpha(scrimColor)),
26 - (int) (mBackgroundFadeAmount * Color.red(mBgColor)
27 - + alphaInv * Color.red(scrimColor)),
28 - (int) (mBackgroundFadeAmount * Color.green(mBgColor)
29 - + alphaInv * Color.green(scrimColor)),
30 - (int) (mBackgroundFadeAmount * Color.blue(mBgColor)
31 - + alphaInv * Color.blue(scrimColor)));
32 + int color;
33 + if(Color.alpha(mBgColor) == 255) {
34 + float alpha = BACKGROUND_ALPHA_DIMMED +
35 + (1 - BACKGROUND_ALPHA_DIMMED) * (1.0f - mDimAmount);
36 + alpha *= mBackgroundFadeAmount;
37 + // We need to manually blend in the background color
38 + int scrimColor = mScrimController.getScrimBehindColor();
39 + // SRC_OVER blending Sa + (1 - Sa)*Da, Rc = Sc + (1 - Sa)*Dc
40 + float alphaInv = 1 - alpha;
41 + color = Color.argb(
42 + (int) (alpha * 255 + alphaInv * Color.alpha(scrimColor)),
43 + (int) (mBackgroundFadeAmount * Color.red(mBgColor)
44 + + alphaInv * Color.red(scrimColor)),
45 + (int) (mBackgroundFadeAmount * Color.green(mBgColor)
46 + + alphaInv * Color.green(scrimColor)),
47 + (int) (mBackgroundFadeAmount * Color.blue(mBgColor)
48 + + alphaInv * Color.blue(scrimColor)));
49 + } else {
50 + int a = Color.alpha(mBgColor) +
51 + Color.alpha(mScrimController.getScrimBehindColor());
52 + if(a > 255) a = 255;
53 + else if(a < 0) /* shouldn't happen */ a = 0;
54 + color = Color.argb(
55 + a,
56 + Color.red(mBgColor), Color.green(mBgColor), Color.blue(mBgColor)
57 + );
58 + }
59 mBackgroundPaint.setColor(color);
60 invalidate();
61 }
62 --
63 2.11.1
64