diff options
| author | 2020-04-22 16:57:03 +0000 | |
|---|---|---|
| committer | 2020-04-22 16:57:03 +0000 | |
| commit | a0397fc671b9d0f7c69a95d6a04cff618f9eceb8 (patch) | |
| tree | 99140d51aa19f4b90c0a170e39cbe5dcfe3cca3e | |
| parent | 8650e9aa11e3ad5c72b11e651170060d9fa19cde (diff) | |
| parent | 9ddbe1311d0e42057013811a57c159a5bbc7d1f3 (diff) | |
Merge "Update screenshot UI for dark theme" into rvc-dev
5 files changed, 54 insertions, 5 deletions
diff --git a/packages/SystemUI/res/drawable/screenshot_cancel.xml b/packages/SystemUI/res/drawable/screenshot_cancel.xml index be3c5983bb2e..f0dfd21a830d 100644 --- a/packages/SystemUI/res/drawable/screenshot_cancel.xml +++ b/packages/SystemUI/res/drawable/screenshot_cancel.xml @@ -20,9 +20,9 @@ android:viewportWidth="48.0" android:viewportHeight="48.0"> <path - android:pathData="M24,24m-16,0a16,16 0,1 1,32 0a16,16 0,1 1,-32 0" - android:fillColor="@android:color/white"/> + android:fillColor="@color/global_screenshot_dismiss_background" + android:pathData="M24,24m-16,0a16,16 0,1 1,32 0a16,16 0,1 1,-32 0"/> <path - android:fillColor="@color/GM2_grey_500" + android:fillColor="@color/global_screenshot_dismiss_foreground" android:pathData="M31,18.41L29.59,17 24,22.59 18.41,17 17,18.41 22.59,24 17,29.59 18.41,31 24,25.41 29.59,31 31,29.59 25.41,24z"/> </vector>
\ No newline at end of file diff --git a/packages/SystemUI/res/layout/global_screenshot.xml b/packages/SystemUI/res/layout/global_screenshot.xml index d506e7e8e700..db109fe8a541 100644 --- a/packages/SystemUI/res/layout/global_screenshot.xml +++ b/packages/SystemUI/res/layout/global_screenshot.xml @@ -68,6 +68,7 @@ android:visibility="gone" android:contentDescription="@string/screenshot_dismiss_ui_description"> <ImageView + android:id="@+id/global_screenshot_dismiss_image" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="@dimen/screenshot_dismiss_button_margin" diff --git a/packages/SystemUI/res/values-night/colors.xml b/packages/SystemUI/res/values-night/colors.xml index 93aa2701ad07..2d5101104237 100644 --- a/packages/SystemUI/res/values-night/colors.xml +++ b/packages/SystemUI/res/values-night/colors.xml @@ -72,9 +72,14 @@ <color name="global_actions_alert_text">@color/GM2_red_300</color> <!-- Global screenshot actions --> - <color name="global_screenshot_button_background">@color/GM2_grey_900</color> + <color name="global_screenshot_button_background">@color/GM2_grey_800</color> <color name="global_screenshot_button_ripple">#42FFFFFF</color> - <color name="global_screenshot_button_text">@color/GM2_blue_300</color> + <color name="global_screenshot_button_text">#FFFFFF</color> + <color name="global_screenshot_button_border">@color/GM2_grey_600</color> + <color name="global_screenshot_button_icon">@color/GM2_blue_300</color> + <color name="global_screenshot_dismiss_background">@color/GM2_grey_800</color> + <color name="global_screenshot_dismiss_foreground">#FFFFFF</color> + <!-- Biometric dialog colors --> <color name="biometric_dialog_gray">#ff888888</color> diff --git a/packages/SystemUI/res/values/colors.xml b/packages/SystemUI/res/values/colors.xml index 4482cdac3327..8b6b5f67d5a7 100644 --- a/packages/SystemUI/res/values/colors.xml +++ b/packages/SystemUI/res/values/colors.xml @@ -198,6 +198,8 @@ <color name="global_screenshot_button_border">@color/GM2_grey_300</color> <color name="global_screenshot_button_ripple">#1f000000</color> <color name="global_screenshot_button_icon">@color/GM2_blue_500</color> + <color name="global_screenshot_dismiss_background">#FFFFFF</color> + <color name="global_screenshot_dismiss_foreground">@color/GM2_grey_500</color> <!-- GM2 colors --> <color name="GM2_grey_50">#F8F9FA</color> diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java index 1efe663ca6ce..7233b72e3115 100644 --- a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java +++ b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java @@ -36,6 +36,7 @@ import android.app.PendingIntent; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; +import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.Insets; @@ -184,9 +185,11 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset private final LinearLayout mActionsView; private final ImageView mBackgroundProtection; private final FrameLayout mDismissButton; + private final ImageView mDismissImage; private Bitmap mScreenBitmap; private Animator mScreenshotAnimation; + private boolean mInDarkMode = false; private float mScreenshotOffsetXPx; private float mScreenshotOffsetYPx; @@ -250,6 +253,7 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset mUiEventLogger.log(ScreenshotEvent.SCREENSHOT_EXPLICIT_DISMISSAL); clearScreenshot("dismiss_button"); }); + mDismissImage = mDismissButton.findViewById(R.id.global_screenshot_dismiss_image); mScreenshotFlash = mScreenshotLayout.findViewById(R.id.global_screenshot_flash); mScreenshotSelectorView = mScreenshotLayout.findViewById(R.id.global_screenshot_selector); @@ -356,6 +360,8 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset mScreenBitmap.setHasAlpha(false); mScreenBitmap.prepareToDraw(); + updateDarkTheme(); + mWindowManager.addView(mScreenshotLayout, mWindowLayoutParams); mScreenshotLayout.getViewTreeObserver().addOnComputeInternalInsetsListener(this); @@ -454,6 +460,41 @@ public class GlobalScreenshot implements ViewTreeObserver.OnComputeInternalInset } /** + * Update assets (called when the dark theme status changes). We only need to update the dismiss + * button and the actions container background, since the buttons are re-inflated on demand. + */ + private void reloadAssets() { + mDismissImage.setImageDrawable(mContext.getDrawable(R.drawable.screenshot_cancel)); + mActionsContainer.setBackground( + mContext.getDrawable(R.drawable.action_chip_container_background)); + + } + + /** + * Checks the current dark theme status and updates if it has changed. + */ + private void updateDarkTheme() { + int currentNightMode = mContext.getResources().getConfiguration().uiMode + & Configuration.UI_MODE_NIGHT_MASK; + switch (currentNightMode) { + case Configuration.UI_MODE_NIGHT_NO: + // Night mode is not active, we're using the light theme + if (mInDarkMode) { + mInDarkMode = false; + reloadAssets(); + } + break; + case Configuration.UI_MODE_NIGHT_YES: + // Night mode is active, we're using dark theme + if (!mInDarkMode) { + mInDarkMode = true; + reloadAssets(); + } + break; + } + } + + /** * Starts the animation after taking the screenshot */ private void startAnimation(final Consumer<Uri> finisher, int w, int h, |