diff options
| author | 2024-07-23 08:53:27 +0000 | |
|---|---|---|
| committer | 2024-07-24 13:14:03 +0000 | |
| commit | df1a57396c9d87f23cd5cbfaa188500f7e6b2fd3 (patch) | |
| tree | 20a8b44b4308138408716473a46fc05847188cdc | |
| parent | 5d5ef73568a1cb0d1597e7e2614c02ab1b1b9b3b (diff) | |
Fixed Bluetooth dialog active device color
Bug: 337067143
Flag: EXEMPT bugfix
Test: manual
Change-Id: I756c3f90ea13f5264174ef94149f9d78764d5833
7 files changed, 94 insertions, 17 deletions
diff --git a/packages/SystemUI/res/color/disconnected_network_primary_color.xml b/packages/SystemUI/res/color/disconnected_network_primary_color.xml new file mode 100644 index 000000000000..536bf78b7b60 --- /dev/null +++ b/packages/SystemUI/res/color/disconnected_network_primary_color.xml @@ -0,0 +1,20 @@ +<!-- + ~ Copyright (C) 2024 The Android Open Source Project + ~ + ~ Licensed under the Apache License, Version 2.0 (the "License"); + ~ you may not use this file except in compliance with the License. + ~ You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License. + --> + +<selector xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"> + <item android:color="?androidprv:attr/materialColorPrimaryContainer" /> +</selector>
\ No newline at end of file diff --git a/packages/SystemUI/res/layout/internet_connectivity_dialog.xml b/packages/SystemUI/res/layout/internet_connectivity_dialog.xml index 22d156da7580..0029180932ee 100644 --- a/packages/SystemUI/res/layout/internet_connectivity_dialog.xml +++ b/packages/SystemUI/res/layout/internet_connectivity_dialog.xml @@ -170,8 +170,7 @@ android:layout_height="28dp" android:layout_marginStart="7dp" android:layout_marginEnd="16dp" - android:layout_gravity="center_vertical" - android:background="?android:attr/textColorSecondary"/> + android:layout_gravity="center_vertical"/> <FrameLayout android:layout_width="@dimen/settingslib_switch_track_width" diff --git a/packages/SystemUI/res/values/styles.xml b/packages/SystemUI/res/values/styles.xml index 36912acbbdb9..c428705dab78 100644 --- a/packages/SystemUI/res/values/styles.xml +++ b/packages/SystemUI/res/values/styles.xml @@ -1386,9 +1386,13 @@ <item name="android:textColor">?androidprv:attr/materialColorOnSurfaceVariant</item> </style> - <style name="TextAppearance.InternetDialog.Active"/> + <style name="TextAppearance.InternetDialog.Active"> + <item name="android:textColor">?androidprv:attr/materialColorOnPrimaryContainer</item> + </style> - <style name="TextAppearance.InternetDialog.Secondary.Active"/> + <style name="TextAppearance.InternetDialog.Secondary.Active"> + <item name="android:textColor">?androidprv:attr/materialColorOnPrimaryContainer</item> + </style> <style name="FgsManagerDialogTitle"> <item name="android:fontFamily">@*android:string/config_bodyFontFamily</item> @@ -1424,17 +1428,32 @@ <item name="android:orientation">horizontal</item> <item name="android:focusable">true</item> <item name="android:clickable">true</item> + <item name="android:textColor">?androidprv:attr/materialColorOnSurface</item> + </style> + + <style name="BluetoothTileDialog.Device.Active"> + <item name="android:textColor">?androidprv:attr/materialColorOnPrimaryContainer</item> </style> <style name="BluetoothTileDialog.DeviceName"> <item name="android:textSize">14sp</item> <item name="android:textAppearance">@style/TextAppearance.Dialog.Title</item> + <item name="android:textColor">?androidprv:attr/materialColorOnSurface</item> </style> <style name="BluetoothTileDialog.DeviceSummary"> <item name="android:ellipsize">end</item> <item name="android:maxLines">2</item> <item name="android:textAppearance">@style/TextAppearance.Dialog.Body.Message</item> + <item name="android:textColor">?androidprv:attr/materialColorOnSurfaceVariant</item> + </style> + + <style name="BluetoothTileDialog.DeviceName.Active"> + <item name="android:textColor">?androidprv:attr/materialColorOnPrimaryContainer</item> + </style> + + <style name="BluetoothTileDialog.DeviceSummary.Active"> + <item name="android:textColor">?androidprv:attr/materialColorOnPrimaryContainer</item> </style> <style name="BroadcastDialog"> diff --git a/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/BluetoothTileDialogDelegate.kt b/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/BluetoothTileDialogDelegate.kt index 911145b62661..f5b9a050f33e 100644 --- a/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/BluetoothTileDialogDelegate.kt +++ b/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/BluetoothTileDialogDelegate.kt @@ -37,6 +37,7 @@ import androidx.recyclerview.widget.AsyncListDiffer import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView +import com.android.internal.R as InternalR import com.android.internal.logging.UiEventLogger import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.res.R @@ -367,6 +368,7 @@ internal constructor( private val nameView = view.requireViewById<TextView>(R.id.bluetooth_device_name) private val summaryView = view.requireViewById<TextView>(R.id.bluetooth_device_summary) private val iconView = view.requireViewById<ImageView>(R.id.bluetooth_device_icon) + private val iconGear = view.requireViewById<ImageView>(R.id.gear_icon_image) private val gearView = view.requireViewById<View>(R.id.gear_icon) internal fun bind( @@ -380,6 +382,36 @@ internal constructor( mutableDeviceItemClick.tryEmit(item) uiEventLogger.log(BluetoothTileDialogUiEvent.DEVICE_CLICKED) } + + // updating icon colors + val tintColor = + com.android.settingslib.Utils.getColorAttr( + context, + if (item.isActive) InternalR.attr.materialColorOnPrimaryContainer + else InternalR.attr.materialColorOnSurface + ) + .defaultColor + + // update icons + iconView.apply { + item.iconWithDescription?.let { + setImageDrawable(it.first.apply { mutate()?.setTint(tintColor) }) + contentDescription = it.second + } + } + + iconGear.apply { drawable?.let { it.mutate()?.setTint(tintColor) } } + + // update text styles + nameView.setTextAppearance( + if (item.isActive) R.style.BluetoothTileDialog_DeviceName_Active + else R.style.BluetoothTileDialog_DeviceName + ) + summaryView.setTextAppearance( + if (item.isActive) R.style.BluetoothTileDialog_DeviceSummary_Active + else R.style.BluetoothTileDialog_DeviceSummary + ) + accessibilityDelegate = object : AccessibilityDelegate() { override fun onInitializeAccessibilityNodeInfo( @@ -398,12 +430,7 @@ internal constructor( } nameView.text = item.deviceName summaryView.text = item.connectionSummary - iconView.apply { - item.iconWithDescription?.let { - setImageDrawable(it.first) - contentDescription = it.second - } - } + gearView.setOnClickListener { deviceItemOnClickCallback.onDeviceItemGearClicked(item, it) } diff --git a/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/DeviceItem.kt b/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/DeviceItem.kt index 0ea98d14bca3..a78130f1b041 100644 --- a/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/DeviceItem.kt +++ b/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/DeviceItem.kt @@ -52,4 +52,5 @@ data class DeviceItem( val background: Int? = null, var isEnabled: Boolean = true, var actionAccessibilityLabel: String = "", + var isActive: Boolean = false ) diff --git a/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/DeviceItemFactory.kt b/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/DeviceItemFactory.kt index 51b228026b03..d7893dbb0f90 100644 --- a/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/DeviceItemFactory.kt +++ b/packages/SystemUI/src/com/android/systemui/bluetooth/qsdialog/DeviceItemFactory.kt @@ -55,7 +55,8 @@ internal abstract class DeviceItemFactory { type: DeviceItemType, connectionSummary: String, background: Int, - actionAccessibilityLabel: String + actionAccessibilityLabel: String, + isActive: Boolean ): DeviceItem { return DeviceItem( type = type, @@ -68,7 +69,8 @@ internal abstract class DeviceItemFactory { }, background = background, isEnabled = !cachedDevice.isBusy, - actionAccessibilityLabel = actionAccessibilityLabel + actionAccessibilityLabel = actionAccessibilityLabel, + isActive = isActive ) } } @@ -91,7 +93,8 @@ internal open class ActiveMediaDeviceItemFactory : DeviceItemFactory() { DeviceItemType.ACTIVE_MEDIA_BLUETOOTH_DEVICE, cachedDevice.connectionSummary ?: "", backgroundOn, - context.getString(actionAccessibilityLabelDisconnect) + context.getString(actionAccessibilityLabelDisconnect), + isActive = true ) } } @@ -116,7 +119,8 @@ internal class AudioSharingMediaDeviceItemFactory( cachedDevice.connectionSummary.takeUnless { it.isNullOrEmpty() } ?: context.getString(audioSharing), if (cachedDevice.isBusy) backgroundOffBusy else backgroundOn, - "" + "", + isActive = !cachedDevice.isBusy ) } } @@ -150,7 +154,8 @@ internal open class AvailableMediaDeviceItemFactory : DeviceItemFactory() { cachedDevice.connectionSummary.takeUnless { it.isNullOrEmpty() } ?: context.getString(connected), if (cachedDevice.isBusy) backgroundOffBusy else backgroundOff, - context.getString(actionAccessibilityLabelActivate) + context.getString(actionAccessibilityLabelActivate), + isActive = false ) } } @@ -188,7 +193,8 @@ internal class ConnectedDeviceItemFactory : DeviceItemFactory() { cachedDevice.connectionSummary.takeUnless { it.isNullOrEmpty() } ?: context.getString(connected), if (cachedDevice.isBusy) backgroundOffBusy else backgroundOff, - context.getString(actionAccessibilityLabelDisconnect) + context.getString(actionAccessibilityLabelDisconnect), + isActive = false ) } } @@ -216,7 +222,8 @@ internal open class SavedDeviceItemFactory : DeviceItemFactory() { cachedDevice.connectionSummary.takeUnless { it.isNullOrEmpty() } ?: context.getString(saved), if (cachedDevice.isBusy) backgroundOffBusy else backgroundOff, - context.getString(actionAccessibilityLabelActivate) + context.getString(actionAccessibilityLabelActivate), + isActive = false ) } } diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialogDelegate.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialogDelegate.java index edc49cac2f92..f0183360bea9 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialogDelegate.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialogDelegate.java @@ -489,6 +489,10 @@ public class InternetDialogDelegate implements mMobileDataToggle.setVisibility(mCanConfigMobileData ? View.VISIBLE : View.INVISIBLE); mMobileToggleDivider.setVisibility( mCanConfigMobileData ? View.VISIBLE : View.INVISIBLE); + int primaryColor = isNetworkConnected + ? R.color.connected_network_primary_color + : R.color.disconnected_network_primary_color; + mMobileToggleDivider.setBackgroundColor(dialog.getContext().getColor(primaryColor)); // Display the info for the non-DDS if it's actively being used int autoSwitchNonDdsSubId = mInternetDialogController.getActiveAutoSwitchNonDdsSubId(); |