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

Commit d9d5f465 authored by George Lin's avatar George Lin Committed by Automerger Merge Worker
Browse files

Merge "Support small clock for the lock screen preview" into udc-dev am:...

Merge "Support small clock for the lock screen preview" into udc-dev am: b03c480d am: 40fac141 am: 4086d176

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23301057



Change-Id: Ieb6f35a3c31e7d52aededaa3eb576050af55cf81
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents c6f5804b 4086d176
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -96,6 +96,7 @@

    <!-- additional offset for clock switch area items -->
    <dimen name="small_clock_height">114dp</dimen>
    <dimen name="small_clock_padding_top">28dp</dimen>
    <dimen name="clock_padding_start">28dp</dimen>
    <dimen name="below_clock_padding_start">32dp</dimen>
    <dimen name="below_clock_padding_end">16dp</dimen>
+13 −7
Original line number Diff line number Diff line
@@ -70,6 +70,17 @@ public class KeyguardClockSwitch extends RelativeLayout {
                top + targetHeight);
    }

    /** Returns a region for the small clock to position itself, based on the given parent. */
    public static Rect getSmallClockRegion(ViewGroup parent) {
        int targetHeight = parent.getResources()
                .getDimensionPixelSize(R.dimen.small_clock_text_size);
        return new Rect(
                parent.getLeft(),
                parent.getTop(),
                parent.getRight(),
                parent.getTop() + targetHeight);
    }

    /**
     * Frame for small/large clocks
     */
@@ -176,13 +187,8 @@ public class KeyguardClockSwitch extends RelativeLayout {
    void updateClockTargetRegions() {
        if (mClock != null) {
            if (mSmallClockFrame.isLaidOut()) {
                int targetHeight =  getResources()
                        .getDimensionPixelSize(R.dimen.small_clock_text_size);
                mClock.getSmallClock().getEvents().onTargetRegionChanged(new Rect(
                        mSmallClockFrame.getLeft(),
                        mSmallClockFrame.getTop(),
                        mSmallClockFrame.getRight(),
                        mSmallClockFrame.getTop() + targetHeight));
                Rect targetRegion = getSmallClockRegion(mSmallClockFrame);
                mClock.getSmallClock().getEvents().onTargetRegionChanged(targetRegion);
            }

            if (mLargeClockFrame.isLaidOut()) {
+1 −1
Original line number Diff line number Diff line
@@ -142,7 +142,7 @@ object Flags {
     * the digits when the clock moves.
     */
    @JvmField
    val STEP_CLOCK_ANIMATION = unreleasedFlag(212, "step_clock_animation", teamfood = true)
    val STEP_CLOCK_ANIMATION = releasedFlag(212, "step_clock_animation")

    /**
     * Migration from the legacy isDozing/dozeAmount paths to the new KeyguardTransitionRepository
+65 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 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.keyguard.data.repository

import android.os.UserHandle
import android.provider.Settings
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.keyguard.shared.model.SettingsClockSize
import com.android.systemui.util.settings.SecureSettings
import com.android.systemui.util.settings.SettingsProxyExt.observerFlow
import javax.inject.Inject
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.onStart
import kotlinx.coroutines.withContext

@SysUISingleton
class KeyguardClockRepository
@Inject
constructor(
    private val secureSettings: SecureSettings,
    @Background private val backgroundDispatcher: CoroutineDispatcher,
) {

    val selectedClockSize: Flow<SettingsClockSize> =
        secureSettings
            .observerFlow(
                names = arrayOf(Settings.Secure.LOCKSCREEN_USE_DOUBLE_LINE_CLOCK),
                userId = UserHandle.USER_SYSTEM,
            )
            .onStart { emit(Unit) } // Forces an initial update.
            .map { getClockSize() }

    private suspend fun getClockSize(): SettingsClockSize {
        return withContext(backgroundDispatcher) {
            if (
                secureSettings.getIntForUser(
                    Settings.Secure.LOCKSCREEN_USE_DOUBLE_LINE_CLOCK,
                    1,
                    UserHandle.USER_CURRENT
                ) == 1
            ) {
                SettingsClockSize.DYNAMIC
            } else {
                SettingsClockSize.SMALL
            }
        }
    }
}
+34 −0
Original line number Diff line number Diff line
/*
 *  Copyright (C) 2023 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.keyguard.domain.interactor

import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.keyguard.data.repository.KeyguardClockRepository
import com.android.systemui.keyguard.shared.model.SettingsClockSize
import javax.inject.Inject
import kotlinx.coroutines.flow.Flow

/** Encapsulates business-logic related to the keyguard clock. */
@SysUISingleton
class KeyguardClockInteractor
@Inject
constructor(
    repository: KeyguardClockRepository,
) {
    val selectedClockSize: Flow<SettingsClockSize> = repository.selectedClockSize
}
Loading