1 /* 2 * Copyright (C) 2024 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.wallpaper.picker.customization.data.repository 18 19 import android.os.Bundle 20 import com.android.systemui.shared.customization.data.content.CustomizationProviderClient 21 import com.android.systemui.shared.customization.data.content.CustomizationProviderContract 22 import com.android.wallpaper.picker.di.modules.BackgroundDispatcher 23 import javax.inject.Inject 24 import javax.inject.Singleton 25 import kotlinx.coroutines.CoroutineScope 26 import kotlinx.coroutines.flow.Flow 27 import kotlinx.coroutines.flow.SharingStarted 28 import kotlinx.coroutines.flow.map 29 import kotlinx.coroutines.flow.shareIn 30 31 @Singleton 32 class CustomizationRuntimeValuesRepository 33 @Inject 34 constructor( 35 @BackgroundDispatcher private val scope: CoroutineScope, 36 client: CustomizationProviderClient, 37 ) { 38 39 private val runtimeValues: Flow<Bundle> = 40 client 41 .observeRuntimeValues() 42 .shareIn(scope = scope, started = SharingStarted.WhileSubscribed(), replay = 1) 43 44 /** 45 * Whether the shade layout should be wide (true) or narrow (false). 46 * 47 * In a wide layout, notifications and quick settings each take up only half the screen width 48 * (whether they are shown at the same time or not). In a narrow layout, they can each be as 49 * wide as the entire screen. 50 */ 51 val isShadeLayoutWide: Flow<Boolean> = <lambda>null52 runtimeValues.map { 53 it.getBoolean( 54 CustomizationProviderContract.RuntimeValuesTable.KEY_IS_SHADE_LAYOUT_WIDE, 55 false, 56 ) 57 } 58 } 59