summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jorge Gil <jorgegil@google.com> 2024-01-08 18:45:27 +0000
committer Jorge Gil <jorgegil@google.com> 2024-02-12 21:42:48 +0000
commit18051edb042bd76050cbde37ff3b79de26fa665c (patch)
treeb3acc595a3e3663b36be5207e72b01d0ff05aa75
parent953d3b1ec13bcd2843d8b31f2f5c2976bba87349 (diff)
Add APPEARANCE_TRANSPARENT_CAPTION_BAR_BACKGROUND
To control whether the caption bar background is opaque (default) or fully transparent. Also adds APPEARANCE_LIGHT_CAPTION_BARS to control the foreground color of the caption bars when the background is set to transparent and the app will draw a background themselves. Bug: 316387515 Flag: ACONFIG android.view.flags.customizable_window_headers DEVELOPMENT Test: m Change-Id: I5413ef48b1e89b624ecbbcb10bcd735c55575193
-rw-r--r--core/api/current.txt2
-rw-r--r--core/java/android/view/WindowInsetsController.java19
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/viewholder/DesktopModeAppControlsWindowDecorationViewHolder.kt19
3 files changed, 39 insertions, 1 deletions
diff --git a/core/api/current.txt b/core/api/current.txt
index 4c35b4046d3e..9c270ae7bf1c 100644
--- a/core/api/current.txt
+++ b/core/api/current.txt
@@ -53746,8 +53746,10 @@ package android.view {
method public void setSystemBarsAppearance(int, int);
method public void setSystemBarsBehavior(int);
method public void show(int);
+ field @FlaggedApi("android.view.flags.customizable_window_headers") public static final int APPEARANCE_LIGHT_CAPTION_BARS = 256; // 0x100
field public static final int APPEARANCE_LIGHT_NAVIGATION_BARS = 16; // 0x10
field public static final int APPEARANCE_LIGHT_STATUS_BARS = 8; // 0x8
+ field @FlaggedApi("android.view.flags.customizable_window_headers") public static final int APPEARANCE_TRANSPARENT_CAPTION_BAR_BACKGROUND = 128; // 0x80
field public static final int BEHAVIOR_DEFAULT = 1; // 0x1
field @Deprecated public static final int BEHAVIOR_SHOW_BARS_BY_SWIPE = 1; // 0x1
field @Deprecated public static final int BEHAVIOR_SHOW_BARS_BY_TOUCH = 0; // 0x0
diff --git a/core/java/android/view/WindowInsetsController.java b/core/java/android/view/WindowInsetsController.java
index cc2cd7982841..b7542dcd55e2 100644
--- a/core/java/android/view/WindowInsetsController.java
+++ b/core/java/android/view/WindowInsetsController.java
@@ -16,6 +16,7 @@
package android.view;
+import android.annotation.FlaggedApi;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -26,6 +27,7 @@ import android.os.CancellationSignal;
import android.view.WindowInsets.Type;
import android.view.WindowInsets.Type.InsetsType;
import android.view.animation.Interpolator;
+import android.view.flags.Flags;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -78,6 +80,20 @@ public interface WindowInsetsController {
int APPEARANCE_SEMI_TRANSPARENT_NAVIGATION_BARS = 1 << 6;
/**
+ * Makes the caption bar transparent.
+ */
+ @FlaggedApi(Flags.FLAG_CUSTOMIZABLE_WINDOW_HEADERS)
+ int APPEARANCE_TRANSPARENT_CAPTION_BAR_BACKGROUND = 1 << 7;
+
+ /**
+ * When {@link WindowInsetsController#APPEARANCE_TRANSPARENT_CAPTION_BAR_BACKGROUND} is set,
+ * changes the foreground color of the caption bars so that the items on the bar can be read
+ * clearly on light backgrounds.
+ */
+ @FlaggedApi(Flags.FLAG_CUSTOMIZABLE_WINDOW_HEADERS)
+ int APPEARANCE_LIGHT_CAPTION_BARS = 1 << 8;
+
+ /**
* Determines the appearance of system bars.
* @hide
*/
@@ -85,7 +101,8 @@ public interface WindowInsetsController {
@IntDef(flag = true, value = {APPEARANCE_OPAQUE_STATUS_BARS, APPEARANCE_OPAQUE_NAVIGATION_BARS,
APPEARANCE_LOW_PROFILE_BARS, APPEARANCE_LIGHT_STATUS_BARS,
APPEARANCE_LIGHT_NAVIGATION_BARS, APPEARANCE_SEMI_TRANSPARENT_STATUS_BARS,
- APPEARANCE_SEMI_TRANSPARENT_NAVIGATION_BARS})
+ APPEARANCE_SEMI_TRANSPARENT_NAVIGATION_BARS,
+ APPEARANCE_TRANSPARENT_CAPTION_BAR_BACKGROUND, APPEARANCE_LIGHT_CAPTION_BARS})
@interface Appearance {
}
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/viewholder/DesktopModeAppControlsWindowDecorationViewHolder.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/viewholder/DesktopModeAppControlsWindowDecorationViewHolder.kt
index 144373f3550e..2309c54b6591 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/viewholder/DesktopModeAppControlsWindowDecorationViewHolder.kt
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/viewholder/DesktopModeAppControlsWindowDecorationViewHolder.kt
@@ -8,6 +8,8 @@ import android.graphics.Bitmap
import android.graphics.Color
import android.view.View
import android.view.View.OnLongClickListener
+import android.view.WindowInsetsController.APPEARANCE_LIGHT_CAPTION_BARS
+import android.view.WindowInsetsController.APPEARANCE_TRANSPARENT_CAPTION_BAR_BACKGROUND
import android.widget.ImageButton
import android.widget.ImageView
import android.widget.TextView
@@ -79,6 +81,9 @@ internal class DesktopModeAppControlsWindowDecorationViewHolder(
@ColorInt
private fun getCaptionBackgroundColor(taskInfo: RunningTaskInfo): Int {
+ if (isTransparentBackgroundRequested(taskInfo)) {
+ return Color.TRANSPARENT
+ }
val materialColorAttr: Int =
if (isDarkMode()) {
if (!taskInfo.isFocused) {
@@ -102,6 +107,10 @@ internal class DesktopModeAppControlsWindowDecorationViewHolder(
@ColorInt
private fun getAppNameAndButtonColor(taskInfo: RunningTaskInfo): Int {
val materialColorAttr = when {
+ isTransparentBackgroundRequested(taskInfo) &&
+ isLightCaptionBar(taskInfo) -> materialColorOnSecondaryContainer
+ isTransparentBackgroundRequested(taskInfo) &&
+ !isLightCaptionBar(taskInfo) -> materialColorOnSurface
isDarkMode() -> materialColorOnSurface
else -> materialColorOnSecondaryContainer
}
@@ -132,6 +141,16 @@ internal class DesktopModeAppControlsWindowDecorationViewHolder(
Configuration.UI_MODE_NIGHT_YES
}
+ private fun isTransparentBackgroundRequested(taskInfo: RunningTaskInfo): Boolean {
+ val appearance = taskInfo.taskDescription?.statusBarAppearance ?: 0
+ return (appearance and APPEARANCE_TRANSPARENT_CAPTION_BAR_BACKGROUND) != 0
+ }
+
+ private fun isLightCaptionBar(taskInfo: RunningTaskInfo): Boolean {
+ val appearance = taskInfo.taskDescription?.statusBarAppearance ?: 0
+ return (appearance and APPEARANCE_LIGHT_CAPTION_BARS) != 0
+ }
+
companion object {
private const val TAG = "DesktopModeAppControlsWindowDecorationViewHolder"
private const val DARK_THEME_UNFOCUSED_OPACITY = 140 // 55%