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

Commit a57aace3 authored by Alejandro Nijamkin's avatar Alejandro Nijamkin
Browse files

[flexiglass] Separates smartspace view from view-model

This is a necessary step for integrating the views within
keyguard/ui/view/layout/sections/SmartspaceSection.kt into the new
keyguard/ui/composable/section/SmartSpaceSection.kt: namely, the removal
of the incorrectly referenced views from KeyguardSmartspaceViewModel (in
MVVM, view-models mustn't refer to views anyway).

Bug: 316211368
Test: manually verified that the lockscreen smartspace looks correct in
the old KeyguardRootView implementation outside of Flexiglass
Flag: ACONFIG com.android.systemui.scene_container DEVELOPMENT

Change-Id: I9408397c1418b07498a42abfc722bab3d72be964
parent f3d540c9
Loading
Loading
Loading
Loading
+24 −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>
    <!-- ID of the smartspace card view. -->
    <item type="id" name="bc_smartspace_view" />
    <!-- ID of the smartspace date view. -->
    <item type="id" name="date_smartspace_view" />
    <!-- ID of the smartspace weather view. -->
    <item type="id" name="weather_smartspace_view" />
</resources>
+8 −4
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import com.android.systemui.keyguard.ui.viewmodel.KeyguardClockViewModel
import com.android.systemui.keyguard.ui.viewmodel.KeyguardSmartspaceViewModel
import com.android.systemui.lifecycle.repeatWhenAttached
import com.android.systemui.res.R
import com.android.systemui.shared.R as sharedR
import kotlinx.coroutines.launch

object KeyguardSmartspaceViewBinder {
@@ -69,9 +70,10 @@ object KeyguardSmartspaceViewBinder {
                smartspaceViewModel.isSmartspaceEnabled &&
                    smartspaceViewModel.isDateWeatherDecoupled
            ) {
                val dateView = constraintLayout.requireViewById<View>(smartspaceViewModel.dateId)
                val dateView =
                    constraintLayout.requireViewById<View>(sharedR.id.date_smartspace_view)
                val weatherView =
                    constraintLayout.requireViewById<View>(smartspaceViewModel.weatherId)
                    constraintLayout.requireViewById<View>(sharedR.id.weather_smartspace_view)
                addView(weatherView)
                addView(dateView)
            }
@@ -88,8 +90,10 @@ object KeyguardSmartspaceViewBinder {
                smartspaceViewModel.isSmartspaceEnabled &&
                    smartspaceViewModel.isDateWeatherDecoupled
            ) {
                val dateView = smartspaceViewModel.dateView
                val weatherView = smartspaceViewModel.weatherView
                val dateView =
                    constraintLayout.requireViewById<View>(sharedR.id.date_smartspace_view)
                val weatherView =
                    constraintLayout.requireViewById<View>(sharedR.id.weather_smartspace_view)
                removeView(weatherView)
                removeView(dateView)
            }
+2 −1
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import com.android.systemui.keyguard.shared.model.KeyguardSection
import com.android.systemui.keyguard.ui.viewmodel.KeyguardClockViewModel
import com.android.systemui.keyguard.ui.viewmodel.KeyguardSmartspaceViewModel
import com.android.systemui.res.R
import com.android.systemui.shared.R as sharedR
import javax.inject.Inject

/** Adds a layer to group elements for translation for burn-in preventation */
@@ -87,7 +88,7 @@ constructor(
        burnInLayer.apply {
            if (smartspaceViewModel.isSmartspaceEnabled) {
                val smartspaceView =
                    constraintLayout.requireViewById<View>(smartspaceViewModel.smartspaceViewId)
                    constraintLayout.requireViewById<View>(sharedR.id.bc_smartspace_view)
                addView(smartspaceView)
            }
        }
+2 −1
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import com.android.systemui.keyguard.shared.KeyguardShadeMigrationNssl
import com.android.systemui.keyguard.shared.model.KeyguardSection
import com.android.systemui.keyguard.ui.viewmodel.KeyguardSmartspaceViewModel
import com.android.systemui.res.R
import com.android.systemui.shared.R as sharedR
import com.android.systemui.statusbar.notification.icon.ui.viewbinder.AlwaysOnDisplayNotificationIconViewStore
import com.android.systemui.statusbar.notification.icon.ui.viewbinder.NotificationIconContainerViewBinder
import com.android.systemui.statusbar.notification.icon.ui.viewbinder.StatusBarIconViewBindingFailureTracker
@@ -117,7 +118,7 @@ constructor(
            }
        constraintSet.apply {
            if (migrateClocksToBlueprint()) {
                connect(nicId, TOP, smartspaceViewModel.smartspaceViewId, BOTTOM, bottomMargin)
                connect(nicId, TOP, sharedR.id.bc_smartspace_view, BOTTOM, bottomMargin)
                setGoneMargin(nicId, BOTTOM, bottomMargin)
            } else {
                connect(nicId, TOP, R.id.keyguard_status_view, topAlignment, bottomMargin)
+8 −4
Original line number Diff line number Diff line
@@ -32,7 +32,6 @@ import com.android.systemui.keyguard.domain.interactor.KeyguardClockInteractor
import com.android.systemui.keyguard.shared.model.KeyguardSection
import com.android.systemui.keyguard.ui.binder.KeyguardClockViewBinder
import com.android.systemui.keyguard.ui.viewmodel.KeyguardClockViewModel
import com.android.systemui.keyguard.ui.viewmodel.KeyguardSmartspaceViewModel
import com.android.systemui.plugins.clocks.ClockController
import com.android.systemui.plugins.clocks.ClockFaceLayout
import com.android.systemui.res.R
@@ -55,7 +54,6 @@ open class ClockSection
constructor(
    private val clockInteractor: KeyguardClockInteractor,
    protected val keyguardClockViewModel: KeyguardClockViewModel,
    private val smartspaceViewModel: KeyguardSmartspaceViewModel,
    private val context: Context,
    private val splitShadeStateController: SplitShadeStateController,
) : KeyguardSection() {
@@ -119,8 +117,8 @@ constructor(
                        com.android.systemui.customization.R.dimen.small_clock_padding_top
                    ) +
                    context.resources.getDimensionPixelSize(R.dimen.keyguard_smartspace_top_offset)
            largeClockTopMargin += smartspaceViewModel.getDimen(DATE_WEATHER_VIEW_HEIGHT)
            largeClockTopMargin += smartspaceViewModel.getDimen(ENHANCED_SMARTSPACE_HEIGHT)
            largeClockTopMargin += getDimen(DATE_WEATHER_VIEW_HEIGHT)
            largeClockTopMargin += getDimen(ENHANCED_SMARTSPACE_HEIGHT)
            if (!keyguardClockViewModel.useLargeClock) {
                largeClockTopMargin -=
                    context.resources.getDimensionPixelSize(
@@ -163,6 +161,12 @@ constructor(
        }
    }

    private fun getDimen(name: String): Int {
        val res = context.packageManager.getResourcesForApplication(context.packageName)
        val id = res.getIdentifier(name, "dimen", context.packageName)
        return res.getDimensionPixelSize(id)
    }

    companion object {
        private const val DATE_WEATHER_VIEW_HEIGHT = "date_weather_view_height"
        private const val ENHANCED_SMARTSPACE_HEIGHT = "enhanced_smartspace_height"
Loading