Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9ccbfedc authored by Hawkwood's avatar Hawkwood
Browse files

Move SimpleDigitalClockTextView to shared lib

This also updates our naming convention for some of these classes to
better match their current intention. The updated names will also help
avoid confusion with overlapping names as we migrate the existing clocks
to use this common code instead of the duplicated versions.

Bug: 364680879
Flag: NONE Library Refactor
Test: Checked functions of existing clocks
Change-Id: Iccf6264ac416a78f457414960281eda7e2b99c9a
parent a0a17434
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -107,7 +107,7 @@ filegroup {
        "tests/src/**/systemui/media/dialog/MediaOutputBroadcastDialogTest.java",
        "tests/src/**/systemui/media/dialog/MediaOutputDialogTest.java",
        "tests/src/**/systemui/settings/brightness/BrightnessDialogTest.kt",
        "tests/src/**/systemui/shared/clocks/view/SimpleDigitalClockTextViewTest.kt",
        "tests/src/**/systemui/shared/clocks/view/DigitalClockTextViewTest.kt",
        "tests/src/**/systemui/statusbar/policy/SecurityControllerTest.java",
        "tests/src/**/systemui/lifecycle/SysUiViewModelTest.kt",
        "tests/src/**/systemui/keyguard/ui/viewmodel/KeyguardQuickAffordancesCombinedViewModelTest.kt",
+30 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 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.customization.clocks

import android.content.Context
import android.content.res.Resources
import android.os.Vibrator
import com.android.systemui.log.core.MessageBuffer
import com.android.systemui.plugins.clocks.ClockSettings

data class ClockContext(
    val context: Context,
    val resources: Resources,
    val settings: ClockSettings,
    val typefaceCache: TypefaceCache,
    val messageBuffer: MessageBuffer,
    val vibrator: Vibrator?,
    val timeKeeper: TimeKeeper,
)
+3 −3
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@
 * limitations under the License.
 */

package com.android.systemui.shared.clocks
package com.android.systemui.customization.clocks

import android.animation.Animator
import android.animation.AnimatorListenerAdapter
@@ -59,7 +59,7 @@ class DigitTranslateAnimator(private val updateCallback: (VPointF) -> Unit) {
            bounceAnimator.duration = duration
            interpolator?.let { bounceAnimator.interpolator = it }
            if (onAnimationEnd != null) {
                val listener =
                bounceAnimator.addListener(
                    object : AnimatorListenerAdapter() {
                        override fun onAnimationEnd(animation: Animator) {
                            onAnimationEnd.run()
@@ -70,7 +70,7 @@ class DigitTranslateAnimator(private val updateCallback: (VPointF) -> Unit) {
                            bounceAnimator.removeListener(this)
                        }
                    }
                bounceAnimator.addListener(listener)
                )
            }
            bounceAnimator.start()
        } else {
+28 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 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.customization.clocks

import com.android.systemui.plugins.clocks.ClockViewIds

enum class DigitalTimespec(private val hourViewId: Int, private val minuteViewId: Int) {
    TIME_FULL_FORMAT(ClockViewIds.TIME_FULL_FORMAT, ClockViewIds.TIME_FULL_FORMAT),
    DIGIT_PAIR(ClockViewIds.HOUR_DIGIT_PAIR, ClockViewIds.MINUTE_DIGIT_PAIR),
    FIRST_DIGIT(ClockViewIds.HOUR_FIRST_DIGIT, ClockViewIds.MINUTE_FIRST_DIGIT),
    SECOND_DIGIT(ClockViewIds.HOUR_SECOND_DIGIT, ClockViewIds.MINUTE_SECOND_DIGIT);

    fun getViewId(isHour: Boolean): Int = if (isHour) hourViewId else minuteViewId
}
+27 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 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.customization.clocks

import android.view.animation.Interpolator
import com.android.systemui.animation.TextAnimator

data class FontTextStyle(
    val lineHeight: Float? = null,
    val fontSizeScale: Float? = null,
    val transitionDuration: Long = TextAnimator.DEFAULT_ANIMATION_DURATION,
    val transitionInterpolator: Interpolator? = null,
)
Loading