diff options
| author | 2024-10-31 18:19:09 +0000 | |
|---|---|---|
| committer | 2024-10-31 18:19:09 +0000 | |
| commit | 1eda1d0ffc2503e4105e90be37cdf601ddf7535c (patch) | |
| tree | d30421f2e8d7040dd7e3bd2eb4e464236f2ed295 | |
| parent | c6ad9c24360667798f539c86f9012e8dc7eca640 (diff) | |
| parent | 0ba7b64604040f334087163b5bfe5fc196de18bb (diff) | |
Merge "[Divider] Read veil color from DividerAttributes" into main
| -rw-r--r-- | libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/DividerPresenter.java | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/DividerPresenter.java b/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/DividerPresenter.java index ad194f707cf3..6398c7a2f498 100644 --- a/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/DividerPresenter.java +++ b/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/DividerPresenter.java @@ -39,6 +39,7 @@ import static androidx.window.extensions.embedding.SplitPresenter.CONTAINER_POSI import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ValueAnimator; +import android.annotation.ColorInt; import android.annotation.Nullable; import android.app.Activity; import android.app.ActivityThread; @@ -1394,10 +1395,14 @@ class DividerPresenter implements View.OnTouchListener { } private void showVeils(@NonNull SurfaceControl.Transaction t) { - final Color primaryVeilColor = getContainerBackgroundColor( - mProperties.mPrimaryContainer, DEFAULT_PRIMARY_VEIL_COLOR); - final Color secondaryVeilColor = getContainerBackgroundColor( - mProperties.mSecondaryContainer, DEFAULT_SECONDARY_VEIL_COLOR); + final Color primaryVeilColor = getVeilColor( + mProperties.mDividerAttributes.getPrimaryVeilColor(), + mProperties.mPrimaryContainer, + DEFAULT_PRIMARY_VEIL_COLOR); + final Color secondaryVeilColor = getVeilColor( + mProperties.mDividerAttributes.getSecondaryVeilColor(), + mProperties.mSecondaryContainer, + DEFAULT_SECONDARY_VEIL_COLOR); t.setColor(mPrimaryVeil, colorToFloatArray(primaryVeilColor)) .setColor(mSecondaryVeil, colorToFloatArray(secondaryVeilColor)) .setLayer(mDividerSurface, DIVIDER_LAYER) @@ -1444,6 +1449,21 @@ class DividerPresenter implements View.OnTouchListener { } } + /** + * Returns the veil color. + * + * If the configured color is not transparent, we use the configured color, otherwise we use + * the window background color of the top activity. If the background color of the top + * activity is unavailable, the default color is used. + */ + @NonNull + private static Color getVeilColor(@ColorInt int configuredColor, + @NonNull TaskFragmentContainer container, @NonNull Color defaultColor) { + return configuredColor != Color.TRANSPARENT + ? Color.valueOf(configuredColor) + : getContainerBackgroundColor(container, defaultColor); + } + private static float[] colorToFloatArray(@NonNull Color color) { return new float[]{color.red(), color.green(), color.blue()}; } |