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

Commit d586865e authored by Nicolò Mazzucato's avatar Nicolò Mazzucato Committed by Android (Google) Code Review
Browse files

Merge "Fix resources used for secondary display presentation" into main

parents 429b99da 9cd0bf54
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
 * 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.
*/
-->
<resources>
    <dimen name="presentation_clock_text_size">170dp</dimen>
</resources>
 No newline at end of file
+1 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
-->
<resources>
    <!-- Clock maximum font size (dp is intentional, to prevent any further scaling) -->
    <dimen name="presentation_clock_text_size">50dp</dimen>
    <dimen name="large_clock_text_size">150dp</dimen>
    <dimen name="small_clock_text_size">86dp</dimen>

+14 −6
Original line number Diff line number Diff line
@@ -16,16 +16,24 @@
*/
-->

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/presentation"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <com.android.keyguard.KeyguardStatusView
        android:id="@+id/clock"
        android:layout_width="410dp"
        android:layout_height="wrap_content"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_gravity="center"
        android:orientation="vertical">
        android:orientation="vertical"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintDimensionRatio="1:1"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">


        <include
            android:id="@+id/keyguard_clock_container"
@@ -34,4 +42,4 @@
            android:layout_height="wrap_content"/>
    </com.android.keyguard.KeyguardStatusView>

</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
 No newline at end of file
+24 −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.dagger.qualifiers

import java.lang.annotation.Documented
import java.lang.annotation.Retention
import java.lang.annotation.RetentionPolicy.RUNTIME
import javax.inject.Qualifier

/** Annotates a class that is display specific. */
@Qualifier @Documented @Retention(RUNTIME) annotation class DisplaySpecific
+26 −6
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import androidx.lifecycle.repeatOnLifecycle
import com.android.systemui.customization.R
import com.android.systemui.broadcast.BroadcastDispatcher
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.dagger.qualifiers.DisplaySpecific
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.flags.FeatureFlags
import com.android.systemui.flags.Flags.DOZING_MIGRATION_1
@@ -79,8 +80,8 @@ constructor(
    private val batteryController: BatteryController,
    private val keyguardUpdateMonitor: KeyguardUpdateMonitor,
    private val configurationController: ConfigurationController,
    @Main private val resources: Resources,
    private val context: Context,
    @DisplaySpecific private val resources: Resources,
    @DisplaySpecific private val context: Context,
    @Main private val mainExecutor: DelayableExecutor,
    @Background private val bgExecutor: Executor,
    @KeyguardSmallClockLog private val smallLogBuffer: LogBuffer?,
@@ -205,7 +206,7 @@ constructor(
    private var isRegistered = false
    private var disposableHandle: DisposableHandle? = null
    private val regionSamplingEnabled = featureFlags.isEnabled(REGION_SAMPLING)

    private var largeClockOnSecondaryDisplay = false

    private fun updateColors() {
        if (regionSamplingEnabled) {
@@ -381,6 +382,19 @@ constructor(
                ?.removeOnAttachStateChangeListener(largeClockOnAttachStateChangeListener)
    }

    /**
     * Sets this clock as showing in a secondary display.
     *
     * Not that this is not necessarily needed, as we could get the displayId from [Context]
     * directly and infere [largeClockOnSecondaryDisplay] from the id being different than the
     * default display one. However, if we do so, current screenshot tests would not work, as they
     * pass an activity context always from the default display.
     */
    fun setLargeClockOnSecondaryDisplay(onSecondaryDisplay: Boolean) {
        largeClockOnSecondaryDisplay = onSecondaryDisplay
        updateFontSizes()
    }

    private fun updateTimeListeners() {
        smallTimeListener?.stop()
        largeTimeListener?.stop()
@@ -403,9 +417,15 @@ constructor(
            smallClock.events.onFontSettingChanged(
                resources.getDimensionPixelSize(R.dimen.small_clock_text_size).toFloat()
            )
            largeClock.events.onFontSettingChanged(
            largeClock.events.onFontSettingChanged(getLargeClockSizePx())
        }
    }

    private fun getLargeClockSizePx(): Float {
        return if (largeClockOnSecondaryDisplay) {
            resources.getDimensionPixelSize(R.dimen.presentation_clock_text_size).toFloat()
        } else {
            resources.getDimensionPixelSize(R.dimen.large_clock_text_size).toFloat()
            )
        }
    }

Loading