Merge "Updates to color tokens for Bubbles according to new spec." into udc-dev

This commit is contained in:
Liran Binyamin
2023-04-26 19:03:55 +00:00
committed by Android (Google) Code Review
8 changed files with 81 additions and 44 deletions

View File

@@ -16,9 +16,10 @@
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
android:shape="rectangle">
<solid
android:color="@android:color/system_neutral1_800"
android:color="?androidprv:attr/materialColorSurfaceContainerHigh"
/>
<corners android:radius="20dp" />

View File

@@ -17,7 +17,7 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
android:shape="rectangle">
<solid android:color="?androidprv:attr/colorSurface" />
<solid android:color="?androidprv:attr/materialColorSurfaceBright" />
<corners
android:bottomLeftRadius="?android:attr/dialogCornerRadius"
android:topLeftRadius="?android:attr/dialogCornerRadius"

View File

@@ -13,7 +13,8 @@
~ See the License for the specific language governing permissions and
~ limitations under the License
-->
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android">
<LinearLayout
android:id="@+id/bubble_flyout_text_container"
@@ -48,6 +49,7 @@
android:fontFamily="@*android:string/config_bodyFontFamilyMedium"
android:maxLines="1"
android:ellipsize="end"
android:textColor="?androidprv:attr/materialColorOnSurface"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body2"/>
<TextView
@@ -57,6 +59,7 @@
android:fontFamily="@*android:string/config_bodyFontFamily"
android:maxLines="2"
android:ellipsize="end"
android:textColor="?androidprv:attr/materialColorOnSurfaceVariant"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body2"/>
</LinearLayout>

View File

@@ -16,6 +16,7 @@
-->
<com.android.wm.shell.common.AlphaOptimizedButton
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
style="@android:style/Widget.DeviceDefault.Button.Borderless"
android:id="@+id/manage_button"
android:layout_gravity="start"
@@ -27,6 +28,6 @@
android:focusable="true"
android:text="@string/manage_bubbles_text"
android:textSize="@*android:dimen/text_size_body_2_material"
android:textColor="@*android:color/system_neutral1_50"
android:textColor="?androidprv:attr/materialColorOnSurface"
android:background="@drawable/bubble_manage_btn_bg"
/>

View File

@@ -15,6 +15,7 @@
~ limitations under the License
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/bubble_manage_menu_bg"
@@ -41,6 +42,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:textColor="?androidprv:attr/materialColorOnSurface"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault"
android:text="@string/bubble_dismiss_text" />
@@ -66,6 +68,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:textColor="?androidprv:attr/materialColorOnSurface"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault"
android:text="@string/bubbles_dont_bubble_conversation" />
@@ -92,6 +95,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:textColor="?androidprv:attr/materialColorOnSurface"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault" />
</LinearLayout>

View File

@@ -177,7 +177,7 @@ public class BubbleFlyoutView extends FrameLayout {
final TypedArray ta = mContext.obtainStyledAttributes(
new int[] {
com.android.internal.R.attr.colorSurface,
com.android.internal.R.attr.materialColorSurfaceContainer,
android.R.attr.dialogCornerRadius});
mFloatingBackgroundColor = ta.getColor(0, Color.WHITE);
mCornerRadius = ta.getDimensionPixelSize(1, 0);

View File

@@ -19,23 +19,21 @@ package com.android.wm.shell.bubbles
import android.app.ActivityTaskManager.INVALID_TASK_ID
import android.content.Context
import android.graphics.Bitmap
import android.graphics.Color
import android.graphics.Matrix
import android.graphics.Path
import android.graphics.drawable.AdaptiveIconDrawable
import android.graphics.drawable.ColorDrawable
import android.graphics.drawable.InsetDrawable
import android.util.PathParser
import android.util.TypedValue
import android.view.LayoutInflater
import android.widget.FrameLayout
import com.android.launcher3.icons.BubbleIconFactory
import com.android.wm.shell.R
import com.android.wm.shell.bubbles.bar.BubbleBarExpandedView
class BubbleOverflow(
private val context: Context,
private val positioner: BubblePositioner
) : BubbleViewProvider {
class BubbleOverflow(private val context: Context, private val positioner: BubblePositioner) :
BubbleViewProvider {
private lateinit var bitmap: Bitmap
private lateinit var dotPath: Path
@@ -54,7 +52,7 @@ class BubbleOverflow(
overflowBtn = null
}
/** Call before use and again if cleanUpExpandedState was called. */
/** Call before use and again if cleanUpExpandedState was called. */
fun initialize(controller: BubbleController) {
createExpandedView()
getExpandedView()?.initialize(controller, controller.stackView, true /* isOverflow */)
@@ -74,10 +72,10 @@ class BubbleOverflow(
}
fun updateResources() {
overflowIconInset = context.resources.getDimensionPixelSize(
R.dimen.bubble_overflow_icon_inset)
overflowBtn?.layoutParams = FrameLayout.LayoutParams(positioner.bubbleSize,
positioner.bubbleSize)
overflowIconInset =
context.resources.getDimensionPixelSize(R.dimen.bubble_overflow_icon_inset)
overflowBtn?.layoutParams =
FrameLayout.LayoutParams(positioner.bubbleSize, positioner.bubbleSize)
expandedView?.updateDimensions()
}
@@ -85,36 +83,58 @@ class BubbleOverflow(
val res = context.resources
// Set overflow button accent color, dot color
val typedValue = TypedValue()
context.theme.resolveAttribute(com.android.internal.R.attr.colorAccentPrimary,
typedValue, true)
val colorAccent = res.getColor(typedValue.resourceId, null)
dotColor = colorAccent
val shapeColor = res.getColor(android.R.color.system_accent1_1000)
val typedArray =
context.obtainStyledAttributes(
intArrayOf(
com.android.internal.R.attr.materialColorPrimaryFixed,
com.android.internal.R.attr.materialColorOnPrimaryFixed
)
)
val colorAccent = typedArray.getColor(0, Color.WHITE)
val shapeColor = typedArray.getColor(1, Color.BLACK)
typedArray.recycle()
dotColor = colorAccent
overflowBtn?.iconDrawable?.setTint(shapeColor)
val iconFactory = BubbleIconFactory(context,
context.getResources().getDimensionPixelSize(R.dimen.bubble_size),
context.getResources().getDimensionPixelSize(R.dimen.bubble_badge_size),
context.getResources().getColor(R.color.important_conversation),
context.getResources().getDimensionPixelSize(
com.android.internal.R.dimen.importance_ring_stroke_width))
val iconFactory =
BubbleIconFactory(
context,
res.getDimensionPixelSize(R.dimen.bubble_size),
res.getDimensionPixelSize(R.dimen.bubble_badge_size),
res.getColor(R.color.important_conversation),
res.getDimensionPixelSize(com.android.internal.R.dimen.importance_ring_stroke_width)
)
// Update bitmap
val fg = InsetDrawable(overflowBtn?.iconDrawable, overflowIconInset)
bitmap = iconFactory.createBadgedIconBitmap(
AdaptiveIconDrawable(ColorDrawable(colorAccent), fg)).icon
bitmap =
iconFactory
.createBadgedIconBitmap(AdaptiveIconDrawable(ColorDrawable(colorAccent), fg))
.icon
// Update dot path
dotPath = PathParser.createPathFromPathData(
res.getString(com.android.internal.R.string.config_icon_mask))
val scale = iconFactory.normalizer.getScale(iconView!!.iconDrawable,
null /* outBounds */, null /* path */, null /* outMaskShape */)
dotPath =
PathParser.createPathFromPathData(
res.getString(com.android.internal.R.string.config_icon_mask)
)
val scale =
iconFactory.normalizer.getScale(
iconView!!.iconDrawable,
null /* outBounds */,
null /* path */,
null /* outMaskShape */
)
val radius = BadgedImageView.DEFAULT_PATH_SIZE / 2f
val matrix = Matrix()
matrix.setScale(scale /* x scale */, scale /* y scale */, radius /* pivot x */,
radius /* pivot y */)
matrix.setScale(
scale /* x scale */,
scale /* y scale */,
radius /* pivot x */,
radius /* pivot y */
)
dotPath.transform(matrix)
// Attach BubbleOverflow to BadgedImageView
@@ -132,8 +152,12 @@ class BubbleOverflow(
}
fun createExpandedView(): BubbleExpandedView? {
expandedView = inflater.inflate(R.layout.bubble_expanded_view,
null /* root */, false /* attachToRoot */) as BubbleExpandedView
expandedView =
inflater.inflate(
R.layout.bubble_expanded_view,
null /* root */,
false /* attachToRoot */
) as BubbleExpandedView
expandedView?.applyThemeAttrs()
updateResources()
return expandedView
@@ -177,11 +201,15 @@ class BubbleOverflow(
override fun getIconView(): BadgedImageView? {
if (overflowBtn == null) {
overflowBtn = inflater.inflate(R.layout.bubble_overflow_button,
null /* root */, false /* attachToRoot */) as BadgedImageView
overflowBtn =
inflater.inflate(
R.layout.bubble_overflow_button,
null /* root */,
false /* attachToRoot */
) as BadgedImageView
overflowBtn?.initialize(positioner)
overflowBtn?.contentDescription = context.resources.getString(
R.string.bubble_overflow_button_content_description)
overflowBtn?.contentDescription =
context.resources.getString(R.string.bubble_overflow_button_content_description)
val bubbleSize = positioner.bubbleSize
overflowBtn?.layoutParams = FrameLayout.LayoutParams(bubbleSize, bubbleSize)
updateBtnTheme()
@@ -200,4 +228,4 @@ class BubbleOverflow(
companion object {
const val KEY = "Overflow"
}
}
}

View File

@@ -220,8 +220,8 @@ public class BubbleOverflowContainerView extends LinearLayout {
: res.getColor(R.color.bubbles_light));
final TypedArray typedArray = getContext().obtainStyledAttributes(new int[] {
android.R.attr.colorBackgroundFloating,
android.R.attr.textColorSecondary});
com.android.internal.R.attr.materialColorSurfaceBright,
com.android.internal.R.attr.materialColorOnSurface});
int bgColor = typedArray.getColor(0, isNightMode ? Color.BLACK : Color.WHITE);
int textColor = typedArray.getColor(1, isNightMode ? Color.WHITE : Color.BLACK);
textColor = ContrastColorUtil.ensureTextContrast(textColor, bgColor, isNightMode);