Loading packages/SystemUI/customization/src/com/android/systemui/shared/clocks/DefaultClockController.kt +12 −4 Original line number Diff line number Diff line Loading @@ -95,7 +95,7 @@ class DefaultClockController( open inner class DefaultClockFaceController( override val view: AnimatableClockView, val seedColor: Int?, var seedColor: Int?, ) : ClockFaceController { // MAGENTA is a placeholder, and will be assigned correctly in initialize Loading @@ -111,9 +111,9 @@ class DefaultClockController( init { if (seedColor != null) { currentColor = seedColor currentColor = seedColor!! } view.setColors(currentColor, currentColor) view.setColors(DOZE_COLOR, currentColor) } override val events = Loading Loading @@ -141,7 +141,7 @@ class DefaultClockController( fun updateColor() { val color = if (seedColor != null) { seedColor seedColor!! } else if (isRegionDark) { resources.getColor(android.R.color.system_accent1_100) } else { Loading Loading @@ -194,6 +194,14 @@ class DefaultClockController( smallClock.updateColor() } override fun onSeedColorChanged(seedColor: Int?) { largeClock.seedColor = seedColor smallClock.seedColor = seedColor largeClock.updateColor() smallClock.updateColor() } override fun onLocaleChanged(locale: Locale) { val nf = NumberFormat.getInstance(locale) if (nf.format(FORMAT_NUMBER.toLong()) == burmeseNumerals) { Loading packages/SystemUI/plugin/src/com/android/systemui/plugins/ClockProviderPlugin.kt +3 −0 Original line number Diff line number Diff line Loading @@ -112,6 +112,9 @@ interface ClockEvents { /** Call whenever the color palette should update */ fun onColorPaletteChanged(resources: Resources) {} /** Call if the seed color has changed and should be updated */ fun onSeedColorChanged(seedColor: Int?) {} /** Call whenever the weather data should update */ fun onWeatherDataChanged(data: WeatherData) {} } Loading packages/SystemUI/tests/src/com/android/systemui/shared/clocks/DefaultClockProviderTest.kt +26 −9 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import android.widget.FrameLayout import androidx.test.filters.SmallTest import com.android.systemui.R import com.android.systemui.SysuiTestCase import com.android.systemui.plugins.ClockSettings import com.android.systemui.shared.clocks.DefaultClockController.Companion.DOZE_COLOR import com.android.systemui.util.mockito.any import com.android.systemui.util.mockito.eq Loading @@ -40,7 +41,6 @@ import org.junit.Test import org.junit.runner.RunWith import org.mockito.ArgumentMatchers.anyBoolean import org.mockito.ArgumentMatchers.anyFloat import org.mockito.ArgumentMatchers.anyInt import org.mockito.ArgumentMatchers.notNull import org.mockito.Mock import org.mockito.Mockito.never Loading Loading @@ -97,13 +97,14 @@ class DefaultClockProviderTest : SysuiTestCase() { @Test fun defaultClock_initialize() { val clock = provider.createClock(DEFAULT_CLOCK_ID) verify(mockSmallClockView).setColors(Color.MAGENTA, Color.MAGENTA) verify(mockLargeClockView).setColors(Color.MAGENTA, Color.MAGENTA) verify(mockSmallClockView).setColors(DOZE_COLOR, Color.MAGENTA) verify(mockLargeClockView).setColors(DOZE_COLOR, Color.MAGENTA) clock.initialize(resources, 0f, 0f) verify(mockSmallClockView).setColors(eq(DOZE_COLOR), anyInt()) verify(mockLargeClockView).setColors(eq(DOZE_COLOR), anyInt()) val expectedColor = 0 verify(mockSmallClockView).setColors(DOZE_COLOR, expectedColor) verify(mockLargeClockView).setColors(DOZE_COLOR, expectedColor) verify(mockSmallClockView).onTimeZoneChanged(notNull()) verify(mockLargeClockView).onTimeZoneChanged(notNull()) verify(mockSmallClockView).refreshTime() Loading Loading @@ -159,15 +160,31 @@ class DefaultClockProviderTest : SysuiTestCase() { @Test fun defaultClock_events_onColorPaletteChanged() { val expectedColor = 0 val clock = provider.createClock(DEFAULT_CLOCK_ID) verify(mockSmallClockView).setColors(Color.MAGENTA, Color.MAGENTA) verify(mockLargeClockView).setColors(Color.MAGENTA, Color.MAGENTA) verify(mockSmallClockView).setColors(DOZE_COLOR, Color.MAGENTA) verify(mockLargeClockView).setColors(DOZE_COLOR, Color.MAGENTA) clock.events.onColorPaletteChanged(resources) verify(mockSmallClockView).setColors(eq(DOZE_COLOR), anyInt()) verify(mockLargeClockView).setColors(eq(DOZE_COLOR), anyInt()) verify(mockSmallClockView).setColors(DOZE_COLOR, expectedColor) verify(mockLargeClockView).setColors(DOZE_COLOR, expectedColor) } @Test fun defaultClock_events_onSeedColorChanged() { val initSeedColor = 10 val newSeedColor = 20 val clock = provider.createClock(ClockSettings(DEFAULT_CLOCK_ID, initSeedColor)) verify(mockSmallClockView).setColors(DOZE_COLOR, initSeedColor) verify(mockLargeClockView).setColors(DOZE_COLOR, initSeedColor) clock.events.onSeedColorChanged(newSeedColor) verify(mockSmallClockView).setColors(DOZE_COLOR, newSeedColor) verify(mockLargeClockView).setColors(DOZE_COLOR, newSeedColor) } @Test Loading Loading
packages/SystemUI/customization/src/com/android/systemui/shared/clocks/DefaultClockController.kt +12 −4 Original line number Diff line number Diff line Loading @@ -95,7 +95,7 @@ class DefaultClockController( open inner class DefaultClockFaceController( override val view: AnimatableClockView, val seedColor: Int?, var seedColor: Int?, ) : ClockFaceController { // MAGENTA is a placeholder, and will be assigned correctly in initialize Loading @@ -111,9 +111,9 @@ class DefaultClockController( init { if (seedColor != null) { currentColor = seedColor currentColor = seedColor!! } view.setColors(currentColor, currentColor) view.setColors(DOZE_COLOR, currentColor) } override val events = Loading Loading @@ -141,7 +141,7 @@ class DefaultClockController( fun updateColor() { val color = if (seedColor != null) { seedColor seedColor!! } else if (isRegionDark) { resources.getColor(android.R.color.system_accent1_100) } else { Loading Loading @@ -194,6 +194,14 @@ class DefaultClockController( smallClock.updateColor() } override fun onSeedColorChanged(seedColor: Int?) { largeClock.seedColor = seedColor smallClock.seedColor = seedColor largeClock.updateColor() smallClock.updateColor() } override fun onLocaleChanged(locale: Locale) { val nf = NumberFormat.getInstance(locale) if (nf.format(FORMAT_NUMBER.toLong()) == burmeseNumerals) { Loading
packages/SystemUI/plugin/src/com/android/systemui/plugins/ClockProviderPlugin.kt +3 −0 Original line number Diff line number Diff line Loading @@ -112,6 +112,9 @@ interface ClockEvents { /** Call whenever the color palette should update */ fun onColorPaletteChanged(resources: Resources) {} /** Call if the seed color has changed and should be updated */ fun onSeedColorChanged(seedColor: Int?) {} /** Call whenever the weather data should update */ fun onWeatherDataChanged(data: WeatherData) {} } Loading
packages/SystemUI/tests/src/com/android/systemui/shared/clocks/DefaultClockProviderTest.kt +26 −9 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import android.widget.FrameLayout import androidx.test.filters.SmallTest import com.android.systemui.R import com.android.systemui.SysuiTestCase import com.android.systemui.plugins.ClockSettings import com.android.systemui.shared.clocks.DefaultClockController.Companion.DOZE_COLOR import com.android.systemui.util.mockito.any import com.android.systemui.util.mockito.eq Loading @@ -40,7 +41,6 @@ import org.junit.Test import org.junit.runner.RunWith import org.mockito.ArgumentMatchers.anyBoolean import org.mockito.ArgumentMatchers.anyFloat import org.mockito.ArgumentMatchers.anyInt import org.mockito.ArgumentMatchers.notNull import org.mockito.Mock import org.mockito.Mockito.never Loading Loading @@ -97,13 +97,14 @@ class DefaultClockProviderTest : SysuiTestCase() { @Test fun defaultClock_initialize() { val clock = provider.createClock(DEFAULT_CLOCK_ID) verify(mockSmallClockView).setColors(Color.MAGENTA, Color.MAGENTA) verify(mockLargeClockView).setColors(Color.MAGENTA, Color.MAGENTA) verify(mockSmallClockView).setColors(DOZE_COLOR, Color.MAGENTA) verify(mockLargeClockView).setColors(DOZE_COLOR, Color.MAGENTA) clock.initialize(resources, 0f, 0f) verify(mockSmallClockView).setColors(eq(DOZE_COLOR), anyInt()) verify(mockLargeClockView).setColors(eq(DOZE_COLOR), anyInt()) val expectedColor = 0 verify(mockSmallClockView).setColors(DOZE_COLOR, expectedColor) verify(mockLargeClockView).setColors(DOZE_COLOR, expectedColor) verify(mockSmallClockView).onTimeZoneChanged(notNull()) verify(mockLargeClockView).onTimeZoneChanged(notNull()) verify(mockSmallClockView).refreshTime() Loading Loading @@ -159,15 +160,31 @@ class DefaultClockProviderTest : SysuiTestCase() { @Test fun defaultClock_events_onColorPaletteChanged() { val expectedColor = 0 val clock = provider.createClock(DEFAULT_CLOCK_ID) verify(mockSmallClockView).setColors(Color.MAGENTA, Color.MAGENTA) verify(mockLargeClockView).setColors(Color.MAGENTA, Color.MAGENTA) verify(mockSmallClockView).setColors(DOZE_COLOR, Color.MAGENTA) verify(mockLargeClockView).setColors(DOZE_COLOR, Color.MAGENTA) clock.events.onColorPaletteChanged(resources) verify(mockSmallClockView).setColors(eq(DOZE_COLOR), anyInt()) verify(mockLargeClockView).setColors(eq(DOZE_COLOR), anyInt()) verify(mockSmallClockView).setColors(DOZE_COLOR, expectedColor) verify(mockLargeClockView).setColors(DOZE_COLOR, expectedColor) } @Test fun defaultClock_events_onSeedColorChanged() { val initSeedColor = 10 val newSeedColor = 20 val clock = provider.createClock(ClockSettings(DEFAULT_CLOCK_ID, initSeedColor)) verify(mockSmallClockView).setColors(DOZE_COLOR, initSeedColor) verify(mockLargeClockView).setColors(DOZE_COLOR, initSeedColor) clock.events.onSeedColorChanged(newSeedColor) verify(mockSmallClockView).setColors(DOZE_COLOR, newSeedColor) verify(mockLargeClockView).setColors(DOZE_COLOR, newSeedColor) } @Test Loading