diff options
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardPreviewClockViewBinder.kt (renamed from packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardPreviewClockSmartspaceViewBinder.kt) | 20 | ||||
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardPreviewSmartspaceViewBinder.kt | 45 | ||||
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/keyguard/ui/preview/KeyguardPreviewRenderer.kt | 23 | ||||
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardPreviewClockViewModel.kt | 40 | ||||
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardPreviewSmartspaceViewModel.kt (renamed from packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardPreviewClockSmartspaceViewModel.kt) | 10 |
5 files changed, 105 insertions, 33 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardPreviewClockSmartspaceViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardPreviewClockViewBinder.kt index 57c32b3a56d9..1b5b329f3f7e 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardPreviewClockSmartspaceViewBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardPreviewClockViewBinder.kt @@ -21,19 +21,17 @@ import android.view.View import androidx.core.view.isVisible import androidx.lifecycle.Lifecycle import androidx.lifecycle.repeatOnLifecycle -import com.android.systemui.keyguard.ui.viewmodel.KeyguardPreviewClockSmartspaceViewModel +import com.android.systemui.keyguard.ui.viewmodel.KeyguardPreviewClockViewModel import com.android.systemui.lifecycle.repeatWhenAttached -import kotlinx.coroutines.flow.collect -/** Binder for the small clock view, large clock view and smartspace. */ -object KeyguardPreviewClockSmartspaceViewBinder { +/** Binder for the small clock view, large clock view. */ +object KeyguardPreviewClockViewBinder { @JvmStatic fun bind( largeClockHostView: View, smallClockHostView: View, - smartspace: View?, - viewModel: KeyguardPreviewClockSmartspaceViewModel, + viewModel: KeyguardPreviewClockViewModel, ) { largeClockHostView.repeatWhenAttached { repeatOnLifecycle(Lifecycle.State.STARTED) { @@ -46,15 +44,5 @@ object KeyguardPreviewClockSmartspaceViewBinder { viewModel.isSmallClockVisible.collect { smallClockHostView.isVisible = it } } } - - smartspace?.repeatWhenAttached { - repeatOnLifecycle(Lifecycle.State.STARTED) { - viewModel.smartSpaceTopPadding.collect { smartspace.setTopPadding(it) } - } - } - } - - private fun View.setTopPadding(padding: Int) { - setPaddingRelative(paddingStart, padding, paddingEnd, paddingBottom) } } diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardPreviewSmartspaceViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardPreviewSmartspaceViewBinder.kt new file mode 100644 index 000000000000..387e9a6ff74c --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardPreviewSmartspaceViewBinder.kt @@ -0,0 +1,45 @@ +/* + * 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.ui.binder + +import android.view.View +import androidx.lifecycle.Lifecycle +import androidx.lifecycle.repeatOnLifecycle +import com.android.systemui.keyguard.ui.viewmodel.KeyguardPreviewSmartspaceViewModel +import com.android.systemui.lifecycle.repeatWhenAttached + +/** Binder for the small clock view, large clock view and smartspace. */ +object KeyguardPreviewSmartspaceViewBinder { + + @JvmStatic + fun bind( + smartspace: View, + viewModel: KeyguardPreviewSmartspaceViewModel, + ) { + + smartspace.repeatWhenAttached { + repeatOnLifecycle(Lifecycle.State.STARTED) { + viewModel.smartSpaceTopPadding.collect { smartspace.setTopPadding(it) } + } + } + } + + private fun View.setTopPadding(padding: Int) { + setPaddingRelative(paddingStart, padding, paddingEnd, paddingBottom) + } +} diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/preview/KeyguardPreviewRenderer.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/preview/KeyguardPreviewRenderer.kt index 4308d843c27a..f9a8b988a27f 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/preview/KeyguardPreviewRenderer.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/preview/KeyguardPreviewRenderer.kt @@ -42,9 +42,11 @@ import com.android.systemui.biometrics.domain.interactor.UdfpsOverlayInteractor import com.android.systemui.broadcast.BroadcastDispatcher import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.dagger.qualifiers.Main -import com.android.systemui.keyguard.ui.binder.KeyguardPreviewClockSmartspaceViewBinder +import com.android.systemui.keyguard.ui.binder.KeyguardPreviewClockViewBinder +import com.android.systemui.keyguard.ui.binder.KeyguardPreviewSmartspaceViewBinder import com.android.systemui.keyguard.ui.viewmodel.KeyguardBottomAreaViewModel -import com.android.systemui.keyguard.ui.viewmodel.KeyguardPreviewClockSmartspaceViewModel +import com.android.systemui.keyguard.ui.viewmodel.KeyguardPreviewClockViewModel +import com.android.systemui.keyguard.ui.viewmodel.KeyguardPreviewSmartspaceViewModel import com.android.systemui.plugins.ClockController import com.android.systemui.shared.clocks.ClockRegistry import com.android.systemui.shared.clocks.DefaultClockController @@ -65,7 +67,8 @@ constructor( @Application private val context: Context, @Main private val mainDispatcher: CoroutineDispatcher, @Main private val mainHandler: Handler, - private val clockSmartspaceViewModel: KeyguardPreviewClockSmartspaceViewModel, + private val clockViewModel: KeyguardPreviewClockViewModel, + private val smartspaceViewModel: KeyguardPreviewSmartspaceViewModel, private val bottomAreaViewModel: KeyguardBottomAreaViewModel, displayManager: DisplayManager, private val windowManager: WindowManager, @@ -129,16 +132,18 @@ constructor( setUpBottomArea(rootView) setUpSmartspace(rootView) + smartSpaceView?.let { + KeyguardPreviewSmartspaceViewBinder.bind(it, smartspaceViewModel) + } setUpUdfps(rootView) if (!shouldHideClock) { setUpClock(rootView) - KeyguardPreviewClockSmartspaceViewBinder.bind( + KeyguardPreviewClockViewBinder.bind( largeClockHostView, smallClockHostView, - smartSpaceView, - clockSmartspaceViewModel, + clockViewModel, ) } @@ -219,8 +224,8 @@ constructor( smartSpaceView = lockscreenSmartspaceController.buildAndConnectDateView(parentView) val topPadding: Int = - KeyguardPreviewClockSmartspaceViewModel.getLargeClockSmartspaceTopPadding( - context.resources + KeyguardPreviewSmartspaceViewModel.getLargeClockSmartspaceTopPadding( + context.resources, ) val startPadding: Int = @@ -372,7 +377,7 @@ constructor( resources.getDimensionPixelSize(R.dimen.small_clock_height) ) layoutParams.topMargin = - KeyguardPreviewClockSmartspaceViewModel.getStatusBarHeight(resources) + + KeyguardPreviewSmartspaceViewModel.getStatusBarHeight(resources) + resources.getDimensionPixelSize(R.dimen.small_clock_padding_top) hostView.layoutParams = layoutParams diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardPreviewClockViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardPreviewClockViewModel.kt new file mode 100644 index 000000000000..53013026670c --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardPreviewClockViewModel.kt @@ -0,0 +1,40 @@ +/* + * 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.ui.viewmodel + +import android.content.Context +import com.android.systemui.dagger.qualifiers.Application +import com.android.systemui.keyguard.domain.interactor.KeyguardClockInteractor +import com.android.systemui.keyguard.shared.model.SettingsClockSize +import javax.inject.Inject +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.map + +/** View model for the small clock view, large clock view. */ +class KeyguardPreviewClockViewModel +@Inject +constructor( + @Application private val context: Context, + interactor: KeyguardClockInteractor, +) { + + val isLargeClockVisible: Flow<Boolean> = + interactor.selectedClockSize.map { it == SettingsClockSize.DYNAMIC } + + val isSmallClockVisible: Flow<Boolean> = + interactor.selectedClockSize.map { it == SettingsClockSize.SMALL } +} diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardPreviewClockSmartspaceViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardPreviewSmartspaceViewModel.kt index 00c603b04ccf..e60bb3412c31 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardPreviewClockSmartspaceViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardPreviewSmartspaceViewModel.kt @@ -26,20 +26,14 @@ import javax.inject.Inject import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.map -/** View model for the small clock view, large clock view and smartspace. */ -class KeyguardPreviewClockSmartspaceViewModel +/** View model for the smartspace. */ +class KeyguardPreviewSmartspaceViewModel @Inject constructor( @Application private val context: Context, interactor: KeyguardClockInteractor, ) { - val isLargeClockVisible: Flow<Boolean> = - interactor.selectedClockSize.map { it == SettingsClockSize.DYNAMIC } - - val isSmallClockVisible: Flow<Boolean> = - interactor.selectedClockSize.map { it == SettingsClockSize.SMALL } - val smartSpaceTopPadding: Flow<Int> = interactor.selectedClockSize.map { when (it) { |