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

Commit c8b33ca4 authored by Hawkwood Glazier's avatar Hawkwood Glazier
Browse files

Migrate KeyguardClockSwitch to new shared Clock library

This change modifies the KeyguardClockSwitch and Controller
to get clocks from the ClockRegistry. Since the only clock
available from the registry is the default one, this should
have no user-facing changes, and is intended only to update
the relevant codepaths.

Bug: 229771520
Test: Manual and Automated
Change-Id: Ia053aaec6987e00de980388a6c024d8bcf5203a2
parent 3e2c4a8f
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -474,7 +474,13 @@ class TextInterpolator(layout: Layout) {
        val out = mutableListOf<List<PositionedGlyphs>>()
        for (lineNo in 0 until layout.lineCount) { // Shape all lines.
            val lineStart = layout.getLineStart(lineNo)
            val count = layout.getLineEnd(lineNo) - lineStart
            var count = layout.getLineEnd(lineNo) - lineStart
            // Do not render the last character in the line if it's a newline and unprintable
            val last = lineStart + count - 1
            if (last > lineStart && last < layout.text.length && layout.text[last] == '\n') {
                count--
            }

            val runs = mutableListOf<PositionedGlyphs>()
            TextShaper.shapeText(
                layout.text,
+13 −8
Original line number Diff line number Diff line
@@ -13,9 +13,9 @@
 */
package com.android.systemui.plugins

import android.content.res.Resources
import android.graphics.drawable.Drawable
import android.view.View
import com.android.internal.colorextraction.ColorExtractor
import com.android.systemui.plugins.annotations.ProvidesInterface
import java.io.PrintWriter
import java.util.Locale
@@ -57,7 +57,15 @@ interface Clock {
    val events: ClockEvents

    /** Triggers for various animations */
    val animation: ClockAnimation
    val animations: ClockAnimations

    /** Initializes various rendering parameters. If never called, provides reasonable defaults. */
    fun initialize(resources: Resources, dozeFraction: Float, foldFraction: Float) {
        events.onColorPaletteChanged(resources)
        animations.doze(dozeFraction)
        animations.fold(foldFraction)
        events.onTimeTick()
    }

    /** Optional method for dumping debug information */
    fun dump(pw: PrintWriter) { }
@@ -80,15 +88,12 @@ interface ClockEvents {
    /** Call whenever font settings change */
    fun onFontSettingChanged() { }

    /** Call whenever the color pallete should update */
    fun onColorPaletteChanged(palette: ColorExtractor.GradientColors) { }
    /** Call whenever the color palette should update */
    fun onColorPaletteChanged(resources: Resources) { }
}

/** Methods which trigger various clock animations */
interface ClockAnimation {
    /** Initializes the doze & fold animation positions. Defaults to neither folded nor dozing. */
    fun initialize(dozeFraction: Float, foldFraction: Float) { }

interface ClockAnimations {
    /** Runs an enter animation (if any) */
    fun enter() { }

+0 −28
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
**
** Copyright 2020, 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.
*/
-->

<!--
** AOD/LockScreen Clock font.
** Should include all numeric glyphs in all supported locales.
** Recommended: font with variable width to support AOD => LS animations
-->
<!-- TODO: Remove when clock migration complete -->
<font-family xmlns:android="http://schemas.android.com/apk/res/android">
    <font android:typeface="monospace"/>
</font-family>
 No newline at end of file
+2 −30
Original line number Diff line number Diff line
@@ -31,42 +31,14 @@
        android:layout_alignParentStart="true"
        android:layout_alignParentTop="true"
        android:paddingStart="@dimen/clock_padding_start">
        <com.android.systemui.shared.clocks.AnimatableClockView
            android:id="@+id/animatable_clock_view"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="start"
            android:gravity="start"
            android:textSize="@dimen/clock_text_size"
            android:fontFamily="@font/clock"
            android:elegantTextHeight="false"
            android:singleLine="true"
            android:fontFeatureSettings="pnum"
            chargeAnimationDelay="350"
            dozeWeight="200"
            lockScreenWeight="400"
        />
    </FrameLayout>
    <FrameLayout
        android:id="@+id/lockscreen_clock_view_large"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_height="match_parent"
        android:layout_below="@id/keyguard_slice_view"
        android:paddingTop="@dimen/keyguard_large_clock_top_padding"
        android:visibility="gone">
        <com.android.systemui.shared.clocks.AnimatableClockView
            android:id="@+id/animatable_clock_view_large"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:gravity="center_horizontal"
            android:textSize="@dimen/large_clock_text_size"
            android:fontFamily="@font/clock"
            android:typeface="monospace"
            android:elegantTextHeight="false"
            chargeAnimationDelay="200"
            dozeWeight="200"
            lockScreenWeight="400"
        />
    </FrameLayout>

    <!-- Not quite optimal but needed to translate these items as a group. The
+1 −1
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@
    android:id="@+id/time_view"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:fontFamily="@font/clock"
    android:fontFamily="@*android:string/config_clockFontFamily"
    android:includeFontPadding="false"
    android:textColor="@android:color/white"
    android:format12Hour="h:mm"
Loading