Loading packages/SystemUI/plugin/src/com/android/systemui/plugins/clocks/ClockAnimations.kt 0 → 100644 +61 −0 Original line number Diff line number Diff line /* * 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. */ package com.android.systemui.plugins.clocks import android.view.View import com.android.systemui.plugins.annotations.ProtectedInterface /** Methods which trigger various clock animations */ @ProtectedInterface interface ClockAnimations { /** Runs an enter animation (if any) */ fun enter() /** Sets how far into AOD the device currently is. */ fun doze(fraction: Float) /** Sets how far into the folding animation the device is. */ fun fold(fraction: Float) /** Runs the battery animation (if any). */ fun charge() /** * Runs when the clock's position changed during the move animation. * * @param fromLeft the [View.getLeft] position of the clock, before it started moving. * @param direction the direction in which it is moving. A positive number means right, and * negative means left. * @param fraction fraction of the clock movement. 0 means it is at the beginning, and 1 means * it finished moving. * @deprecated use {@link #onPositionUpdated(float, float)} instead. */ fun onPositionUpdated(fromLeft: Int, direction: Int, fraction: Float) /** * Runs when the clock's position changed during the move animation. * * @param distance is the total distance in pixels to offset the glyphs when animation * completes. Negative distance means we are animating the position towards the center. * @param fraction fraction of the clock movement. 0 means it is at the beginning, and 1 means * it finished moving. */ fun onPositionUpdated(distance: Float, fraction: Float) /** * Runs when swiping clock picker, swipingFraction: 1.0 -> clock is scaled up in the preview, * 0.0 -> clock is scaled down in the shade; previewRatio is previewSize / screenSize */ fun onPickerCarouselSwiping(swipingFraction: Float) } packages/SystemUI/plugin/src/com/android/systemui/plugins/clocks/ClockConfig.kt 0 → 100644 +65 −0 Original line number Diff line number Diff line /* * 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. */ package com.android.systemui.plugins.clocks /** * Exposes the rendering capabilities of this clock to SystemUI so that it can be hosted and render * correctly in SystemUI's process. Ideally all clocks could be rendered identically, but in * practice we different clocks require different behavior from SystemUI. */ data class ClockConfig( val id: ClockId, /** Localized name of the clock */ val name: String, /** Localized accessibility description for the clock */ val description: String, /** Transition to AOD should move smartspace like large clock instead of small clock */ val useAlternateSmartspaceAODTransition: Boolean = false, /** Deprecated version of isReactiveToTone; moved to ClockPickerConfig */ @Deprecated("TODO(b/352049256): Remove in favor of ClockPickerConfig.isReactiveToTone") val isReactiveToTone: Boolean = true, /** True if the clock is large frame clock, which will use weather in compose. */ val useCustomClockScene: Boolean = false, ) /** Render configuration options for a specific clock face. */ data class ClockFaceConfig( /** Expected interval between calls to onTimeTick. Can always reduce to PER_MINUTE in AOD. */ val tickRate: ClockTickRate = ClockTickRate.PER_MINUTE, /** Call to check whether the clock consumes weather data */ val hasCustomWeatherDataDisplay: Boolean = false, /** * Whether this clock has a custom position update animation. If true, the keyguard will call * `onPositionUpdated` to notify the clock of a position update animation. If false, a default * animation will be used (e.g. a simple translation). */ val hasCustomPositionUpdatedAnimation: Boolean = false, /** True if the clock is large frame clock, which will use weatherBlueprint in compose. */ val useCustomClockScene: Boolean = false, ) /** Tick rates for clocks */ enum class ClockTickRate(val value: Int) { PER_MINUTE(2), // Update the clock once per minute. PER_SECOND(1), // Update the clock once per second. PER_FRAME(0), // Update the clock every second. } packages/SystemUI/plugin/src/com/android/systemui/plugins/clocks/ClockController.kt 0 → 100644 +44 −0 Original line number Diff line number Diff line /* * 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. */ package com.android.systemui.plugins.clocks import com.android.systemui.plugins.annotations.ProtectedInterface import com.android.systemui.plugins.annotations.SimpleProperty import java.io.PrintWriter /** Interface for controlling an active clock */ @ProtectedInterface interface ClockController { @get:SimpleProperty /** A small version of the clock, appropriate for smaller viewports */ val smallClock: ClockFaceController @get:SimpleProperty /** A large version of the clock, appropriate when a bigger viewport is available */ val largeClock: ClockFaceController @get:SimpleProperty /** Determines the way the hosting app should behave when rendering either clock face */ val config: ClockConfig @get:SimpleProperty /** Events that clocks may need to respond to */ val events: ClockEvents /** Initializes various rendering parameters. If never called, provides reasonable defaults. */ fun initialize(isDarkTheme: Boolean, dozeFraction: Float, foldFraction: Float) /** Optional method for dumping debug information */ fun dump(pw: PrintWriter) } packages/SystemUI/plugin/src/com/android/systemui/plugins/clocks/ClockEvents.kt 0 → 100644 +48 −0 Original line number Diff line number Diff line /* * 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. */ package com.android.systemui.plugins.clocks import com.android.systemui.plugins.annotations.ProtectedInterface import com.android.systemui.plugins.annotations.ProtectedReturn import java.util.Locale import java.util.TimeZone /** Events that should call when various rendering parameters change */ @ProtectedInterface interface ClockEvents { @get:ProtectedReturn("return false;") /** Set to enable or disable swipe interaction */ var isReactiveTouchInteractionEnabled: Boolean // TODO(b/364664388): Remove/Rename /** Call whenever timezone changes */ fun onTimeZoneChanged(timeZone: TimeZone) /** Call whenever the text time format changes (12hr vs 24hr) */ fun onTimeFormatChanged(is24Hr: Boolean) /** Call whenever the locale changes */ fun onLocaleChanged(locale: Locale) /** Call whenever the weather data should update */ fun onWeatherDataChanged(data: WeatherData) /** Call with alarm information */ fun onAlarmDataChanged(data: AlarmData) /** Call with zen/dnd information */ fun onZenDataChanged(data: ZenData) /** Update reactive axes for this clock */ fun onFontAxesChanged(axes: List<ClockFontAxisSetting>) } packages/SystemUI/plugin/src/com/android/systemui/plugins/clocks/ClockFaceController.kt 0 → 100644 +47 −0 Original line number Diff line number Diff line /* * 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. */ package com.android.systemui.plugins.clocks import android.view.View import com.android.systemui.plugins.annotations.ProtectedInterface import com.android.systemui.plugins.annotations.SimpleProperty /** Interface for a specific clock face version rendered by the clock */ @ProtectedInterface interface ClockFaceController { @get:SimpleProperty @Deprecated("Prefer use of layout") /** View that renders the clock face */ val view: View @get:SimpleProperty /** Layout specification for this clock */ val layout: ClockFaceLayout @get:SimpleProperty /** Determines the way the hosting app should behave when rendering this clock face */ val config: ClockFaceConfig @get:SimpleProperty /** Current theme information the clock is using */ val theme: ThemeConfig @get:SimpleProperty /** Events specific to this clock face */ val events: ClockFaceEvents @get:SimpleProperty /** Triggers for various animations */ val animations: ClockAnimations } Loading
packages/SystemUI/plugin/src/com/android/systemui/plugins/clocks/ClockAnimations.kt 0 → 100644 +61 −0 Original line number Diff line number Diff line /* * 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. */ package com.android.systemui.plugins.clocks import android.view.View import com.android.systemui.plugins.annotations.ProtectedInterface /** Methods which trigger various clock animations */ @ProtectedInterface interface ClockAnimations { /** Runs an enter animation (if any) */ fun enter() /** Sets how far into AOD the device currently is. */ fun doze(fraction: Float) /** Sets how far into the folding animation the device is. */ fun fold(fraction: Float) /** Runs the battery animation (if any). */ fun charge() /** * Runs when the clock's position changed during the move animation. * * @param fromLeft the [View.getLeft] position of the clock, before it started moving. * @param direction the direction in which it is moving. A positive number means right, and * negative means left. * @param fraction fraction of the clock movement. 0 means it is at the beginning, and 1 means * it finished moving. * @deprecated use {@link #onPositionUpdated(float, float)} instead. */ fun onPositionUpdated(fromLeft: Int, direction: Int, fraction: Float) /** * Runs when the clock's position changed during the move animation. * * @param distance is the total distance in pixels to offset the glyphs when animation * completes. Negative distance means we are animating the position towards the center. * @param fraction fraction of the clock movement. 0 means it is at the beginning, and 1 means * it finished moving. */ fun onPositionUpdated(distance: Float, fraction: Float) /** * Runs when swiping clock picker, swipingFraction: 1.0 -> clock is scaled up in the preview, * 0.0 -> clock is scaled down in the shade; previewRatio is previewSize / screenSize */ fun onPickerCarouselSwiping(swipingFraction: Float) }
packages/SystemUI/plugin/src/com/android/systemui/plugins/clocks/ClockConfig.kt 0 → 100644 +65 −0 Original line number Diff line number Diff line /* * 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. */ package com.android.systemui.plugins.clocks /** * Exposes the rendering capabilities of this clock to SystemUI so that it can be hosted and render * correctly in SystemUI's process. Ideally all clocks could be rendered identically, but in * practice we different clocks require different behavior from SystemUI. */ data class ClockConfig( val id: ClockId, /** Localized name of the clock */ val name: String, /** Localized accessibility description for the clock */ val description: String, /** Transition to AOD should move smartspace like large clock instead of small clock */ val useAlternateSmartspaceAODTransition: Boolean = false, /** Deprecated version of isReactiveToTone; moved to ClockPickerConfig */ @Deprecated("TODO(b/352049256): Remove in favor of ClockPickerConfig.isReactiveToTone") val isReactiveToTone: Boolean = true, /** True if the clock is large frame clock, which will use weather in compose. */ val useCustomClockScene: Boolean = false, ) /** Render configuration options for a specific clock face. */ data class ClockFaceConfig( /** Expected interval between calls to onTimeTick. Can always reduce to PER_MINUTE in AOD. */ val tickRate: ClockTickRate = ClockTickRate.PER_MINUTE, /** Call to check whether the clock consumes weather data */ val hasCustomWeatherDataDisplay: Boolean = false, /** * Whether this clock has a custom position update animation. If true, the keyguard will call * `onPositionUpdated` to notify the clock of a position update animation. If false, a default * animation will be used (e.g. a simple translation). */ val hasCustomPositionUpdatedAnimation: Boolean = false, /** True if the clock is large frame clock, which will use weatherBlueprint in compose. */ val useCustomClockScene: Boolean = false, ) /** Tick rates for clocks */ enum class ClockTickRate(val value: Int) { PER_MINUTE(2), // Update the clock once per minute. PER_SECOND(1), // Update the clock once per second. PER_FRAME(0), // Update the clock every second. }
packages/SystemUI/plugin/src/com/android/systemui/plugins/clocks/ClockController.kt 0 → 100644 +44 −0 Original line number Diff line number Diff line /* * 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. */ package com.android.systemui.plugins.clocks import com.android.systemui.plugins.annotations.ProtectedInterface import com.android.systemui.plugins.annotations.SimpleProperty import java.io.PrintWriter /** Interface for controlling an active clock */ @ProtectedInterface interface ClockController { @get:SimpleProperty /** A small version of the clock, appropriate for smaller viewports */ val smallClock: ClockFaceController @get:SimpleProperty /** A large version of the clock, appropriate when a bigger viewport is available */ val largeClock: ClockFaceController @get:SimpleProperty /** Determines the way the hosting app should behave when rendering either clock face */ val config: ClockConfig @get:SimpleProperty /** Events that clocks may need to respond to */ val events: ClockEvents /** Initializes various rendering parameters. If never called, provides reasonable defaults. */ fun initialize(isDarkTheme: Boolean, dozeFraction: Float, foldFraction: Float) /** Optional method for dumping debug information */ fun dump(pw: PrintWriter) }
packages/SystemUI/plugin/src/com/android/systemui/plugins/clocks/ClockEvents.kt 0 → 100644 +48 −0 Original line number Diff line number Diff line /* * 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. */ package com.android.systemui.plugins.clocks import com.android.systemui.plugins.annotations.ProtectedInterface import com.android.systemui.plugins.annotations.ProtectedReturn import java.util.Locale import java.util.TimeZone /** Events that should call when various rendering parameters change */ @ProtectedInterface interface ClockEvents { @get:ProtectedReturn("return false;") /** Set to enable or disable swipe interaction */ var isReactiveTouchInteractionEnabled: Boolean // TODO(b/364664388): Remove/Rename /** Call whenever timezone changes */ fun onTimeZoneChanged(timeZone: TimeZone) /** Call whenever the text time format changes (12hr vs 24hr) */ fun onTimeFormatChanged(is24Hr: Boolean) /** Call whenever the locale changes */ fun onLocaleChanged(locale: Locale) /** Call whenever the weather data should update */ fun onWeatherDataChanged(data: WeatherData) /** Call with alarm information */ fun onAlarmDataChanged(data: AlarmData) /** Call with zen/dnd information */ fun onZenDataChanged(data: ZenData) /** Update reactive axes for this clock */ fun onFontAxesChanged(axes: List<ClockFontAxisSetting>) }
packages/SystemUI/plugin/src/com/android/systemui/plugins/clocks/ClockFaceController.kt 0 → 100644 +47 −0 Original line number Diff line number Diff line /* * 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. */ package com.android.systemui.plugins.clocks import android.view.View import com.android.systemui.plugins.annotations.ProtectedInterface import com.android.systemui.plugins.annotations.SimpleProperty /** Interface for a specific clock face version rendered by the clock */ @ProtectedInterface interface ClockFaceController { @get:SimpleProperty @Deprecated("Prefer use of layout") /** View that renders the clock face */ val view: View @get:SimpleProperty /** Layout specification for this clock */ val layout: ClockFaceLayout @get:SimpleProperty /** Determines the way the hosting app should behave when rendering this clock face */ val config: ClockFaceConfig @get:SimpleProperty /** Current theme information the clock is using */ val theme: ThemeConfig @get:SimpleProperty /** Events specific to this clock face */ val events: ClockFaceEvents @get:SimpleProperty /** Triggers for various animations */ val animations: ClockAnimations }