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.ui.util 18 19 import android.view.LayoutInflater 20 import android.view.View 21 import android.widget.FrameLayout 22 import android.widget.LinearLayout 23 import com.android.wallpaper.R 24 import com.android.wallpaper.model.Screen 25 import com.android.wallpaper.model.Screen.HOME_SCREEN 26 import com.android.wallpaper.model.Screen.LOCK_SCREEN 27 import com.android.wallpaper.picker.customization.ui.util.CustomizationOptionUtil.CustomizationOption 28 import dagger.hilt.android.scopes.ActivityScoped 29 import javax.inject.Inject 30 31 @ActivityScoped 32 class DefaultCustomizationOptionUtil @Inject constructor() : CustomizationOptionUtil { 33 34 enum class DefaultLockCustomizationOption : CustomizationOption { 35 WALLPAPER, 36 } 37 38 enum class DefaultHomeCustomizationOption : CustomizationOption { 39 WALLPAPER, 40 } 41 42 private var viewMap: Map<CustomizationOption, View>? = null 43 getOptionEntriesnull44 override fun getOptionEntries( 45 screen: Screen, 46 optionContainer: LinearLayout, 47 layoutInflater: LayoutInflater, 48 ): List<Pair<CustomizationOption, View>> = 49 when (screen) { 50 LOCK_SCREEN -> 51 listOf( 52 DefaultLockCustomizationOption.WALLPAPER to 53 layoutInflater.inflate( 54 R.layout.customization_option_entry_wallpaper, 55 optionContainer, 56 false 57 ) 58 ) 59 HOME_SCREEN -> 60 listOf( 61 DefaultHomeCustomizationOption.WALLPAPER to 62 layoutInflater.inflate( 63 R.layout.customization_option_entry_wallpaper, 64 optionContainer, 65 false 66 ) 67 ) 68 } 69 initBottomSheetContentnull70 override fun initBottomSheetContent( 71 bottomSheetContainer: FrameLayout, 72 layoutInflater: LayoutInflater 73 ) { 74 viewMap = mapOf() 75 } 76 getBottomSheetContentnull77 override fun getBottomSheetContent(option: CustomizationOption): View? { 78 return viewMap?.get(option) 79 } 80 onDestroynull81 override fun onDestroy() { 82 viewMap = null 83 } 84 } 85