Merge "Fix discard dialog showing when applying clock font" into main
diff --git a/PREUPLOAD.cfg b/PREUPLOAD.cfg
index 2c4355f..5ddf84c 100644
--- a/PREUPLOAD.cfg
+++ b/PREUPLOAD.cfg
@@ -7,7 +7,5 @@
[Hook Scripts]
checkstyle_hook = ${REPO_ROOT}/prebuilts/checkstyle/checkstyle.py --sha ${PREUPLOAD_COMMIT}
-flag_hook = ${REPO_ROOT}/frameworks/base/packages/SystemUI/flag_check.py --msg=${PREUPLOAD_COMMIT_MESSAGE} --files=${PREUPLOAD_FILES} --project=${REPO_PATH}
-
[Tool Paths]
ktfmt = ${REPO_ROOT}/external/ktfmt/ktfmt.sh
diff --git a/src/com/android/customization/picker/clock/data/repository/ClockRegistryProvider.kt b/src/com/android/customization/picker/clock/data/repository/ClockRegistryProvider.kt
index 15d9088..3c3926f 100644
--- a/src/com/android/customization/picker/clock/data/repository/ClockRegistryProvider.kt
+++ b/src/com/android/customization/picker/clock/data/repository/ClockRegistryProvider.kt
@@ -19,7 +19,6 @@
import android.content.ComponentName
import android.content.Context
import android.view.LayoutInflater
-import com.android.systemui.Flags
import com.android.systemui.plugins.Plugin
import com.android.systemui.plugins.PluginManager
import com.android.systemui.shared.clocks.ClockRegistry
@@ -30,6 +29,7 @@
import com.android.systemui.shared.plugins.PluginManagerImpl
import com.android.systemui.shared.plugins.PluginPrefs
import com.android.systemui.shared.system.UncaughtExceptionPreHandlerManager_Factory
+import com.android.wallpaper.config.BaseFlags
import java.util.concurrent.Executors
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
@@ -45,19 +45,20 @@
private val backgroundDispatcher: CoroutineDispatcher,
) {
private val clockRegistry: ClockRegistry by lazy {
+ val flags = BaseFlags.get()
ClockRegistry(
context,
createPluginManager(context),
coroutineScope,
mainDispatcher,
backgroundDispatcher,
- isEnabled = true,
+ isEnabled = flags.isCustomClocksEnabled(context),
handleAllUsers = false,
DefaultClockProvider(
ctx = context,
layoutInflater = LayoutInflater.from(context),
resources = context.resources,
- isClockReactiveVariantsEnabled = Flags.clockReactiveVariants(),
+ isClockReactiveVariantsEnabled = flags.isClockReactiveVariantsEnabled(),
),
keepAllLoaded = true,
subTag = "Picker",
@@ -93,7 +94,7 @@
override fun setDisabled(
component: ComponentName,
- @PluginEnabler.DisableReason reason: Int
+ @PluginEnabler.DisableReason reason: Int,
) = Unit
override fun isEnabled(component: ComponentName): Boolean {
diff --git a/src/com/android/customization/picker/clock/ui/view/ClockCarouselView.kt b/src/com/android/customization/picker/clock/ui/view/ClockCarouselView.kt
index 0ed0362..27bc42c 100644
--- a/src/com/android/customization/picker/clock/ui/view/ClockCarouselView.kt
+++ b/src/com/android/customization/picker/clock/ui/view/ClockCarouselView.kt
@@ -30,6 +30,7 @@
import androidx.core.view.doOnPreDraw
import androidx.core.view.get
import androidx.core.view.isNotEmpty
+import androidx.core.view.isVisible
import com.android.customization.picker.clock.shared.ClockSize
import com.android.customization.picker.clock.ui.viewmodel.ClockCarouselItemViewModel
import com.android.systemui.plugins.clocks.ClockController
@@ -57,6 +58,7 @@
val clockCarousel = LayoutInflater.from(context).inflate(R.layout.clock_carousel, this)
carousel = clockCarousel.requireViewById(R.id.carousel)
motionLayout = clockCarousel.requireViewById(R.id.motion_container)
+ motionLayout.isVisible = false
motionLayout.contentDescription = context.getString(R.string.custom_clocks_label)
clockViewScale =
TypedValue().let {
@@ -133,6 +135,11 @@
onClockSelected: (clock: ClockCarouselItemViewModel) -> Unit,
isTwoPaneAndSmallWidth: Boolean,
) {
+ if (clocks.isEmpty()) {
+ // Hide the carousel if clock list is empty
+ motionLayout.isVisible = false
+ return
+ }
if (isTwoPaneAndSmallWidth) {
overrideScreenPreviewWidth()
}
@@ -311,6 +318,7 @@
) {}
}
)
+ motionLayout.isVisible = true
}
fun setSelectedClockIndex(index: Int) {