Add disbled background for the apply button (1/2)
Test: Manully tested that the disabled state of the button shows
Fixes: 376092261
Flag: com.android.systemui.shared.new_customization_picker_ui
Change-Id: I01d324244ca1fb17aebcd6dbea976f08277d354b
diff --git a/src/com/android/wallpaper/customization/ui/binder/ThemePickerToolbarBinder.kt b/src/com/android/wallpaper/customization/ui/binder/ThemePickerToolbarBinder.kt
index 357f131..5ea757e 100644
--- a/src/com/android/wallpaper/customization/ui/binder/ThemePickerToolbarBinder.kt
+++ b/src/com/android/wallpaper/customization/ui/binder/ThemePickerToolbarBinder.kt
@@ -21,11 +21,13 @@
import android.widget.Button
import android.widget.FrameLayout
import android.widget.Toolbar
+import androidx.core.graphics.ColorUtils
import androidx.core.view.isInvisible
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
+import com.android.wallpaper.R
import com.android.wallpaper.customization.ui.viewmodel.ThemePickerCustomizationOptionsViewModel
import com.android.wallpaper.customization.ui.viewmodel.ToolbarHeightsViewModel
import com.android.wallpaper.picker.customization.ui.binder.DefaultToolbarBinder
@@ -109,6 +111,14 @@
}
)
+ val applyButtonTextColorEnabled =
+ applyButton.resources.getColor(R.color.system_on_primary, null)
+ val applyButtonTextColorDisabled =
+ ColorUtils.setAlphaComponent(
+ applyButton.resources.getColor(R.color.system_on_surface, null),
+ 97,
+ ) // 97 for 38% transparent
+
lifecycleOwner.lifecycleScope.launch {
lifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
launch {
@@ -117,9 +127,18 @@
}
}
- launch { viewModel.isOnApplyVisible.collect { applyButton.isInvisible = !it } }
+ launch { viewModel.isApplyButtonVisible.collect { applyButton.isInvisible = !it } }
- launch { viewModel.isOnApplyEnabled.collect { applyButton.isEnabled = it } }
+ launch {
+ viewModel.isApplyButtonEnabled.collect {
+ applyButton.isEnabled = it
+ applyButton.background.alpha =
+ if (it) 255 else 31 // 255 for 100%, 31 for 12% transparent,
+ applyButton.setTextColor(
+ if (it) applyButtonTextColorEnabled else applyButtonTextColorDisabled
+ )
+ }
+ }
launch {
combine(toolbarHeights, viewModel.isToolbarCollapsed, ::Pair).collect {
diff --git a/src/com/android/wallpaper/customization/ui/viewmodel/ThemePickerCustomizationOptionsViewModel.kt b/src/com/android/wallpaper/customization/ui/viewmodel/ThemePickerCustomizationOptionsViewModel.kt
index 0937315..62a96fe 100644
--- a/src/com/android/wallpaper/customization/ui/viewmodel/ThemePickerCustomizationOptionsViewModel.kt
+++ b/src/com/android/wallpaper/customization/ui/viewmodel/ThemePickerCustomizationOptionsViewModel.kt
@@ -178,9 +178,9 @@
}
.stateIn(viewModelScope, SharingStarted.Eagerly, null)
- val isOnApplyEnabled: Flow<Boolean> = onApplyButtonClicked.map { it != null }
+ val isApplyButtonEnabled: Flow<Boolean> = onApplyButtonClicked.map { it != null }
- val isOnApplyVisible: Flow<Boolean> = selectedOption.map { it != null }
+ val isApplyButtonVisible: Flow<Boolean> = selectedOption.map { it != null }
val isToolbarCollapsed: Flow<Boolean> =
combine(selectedOption, clockPickerViewModel.selectedTab) { selectedOption, selectedTab ->