1 /* 2 * Copyright (C) 2023 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 package com.android.wallpaper.widget.floatingsheetcontent 17 18 import android.content.Context 19 import android.util.AttributeSet 20 import android.widget.LinearLayout 21 import android.widget.TextView 22 import com.android.internal.widget.LinearLayoutManager 23 import com.android.internal.widget.RecyclerView 24 import com.android.wallpaper.R 25 26 /** This class is the view which displays the bottom sheet for wallpaper effects */ 27 class WallpaperActionSelectionBottomSheet(context: Context?, attrs: AttributeSet?) : 28 LinearLayout(context, attrs) { 29 private lateinit var wallpaperActionsTitle: TextView 30 private lateinit var wallpaperActionsSubtitle: TextView 31 private lateinit var wallpaperActionsToggles: RecyclerView 32 onFinishInflatenull33 override fun onFinishInflate() { 34 super.onFinishInflate() 35 wallpaperActionsTitle = requireViewById(R.id.wallpaper_effects_title) 36 wallpaperActionsSubtitle = requireViewById(R.id.wallpaper_effects_subtitle) 37 wallpaperActionsToggles = requireViewById(R.id.wallpaper_action_toggles) 38 } 39 40 // This function takes in a WallpaperToggleSwitchAdapter and completes the initialization of the 41 // recycler view to present the list of toggle options. setUpActionToggleOptionsnull42 fun setUpActionToggleOptions(adapter: WallpaperActionsToggleAdapter) { 43 // Set CustomAdapter as the adapter for RecyclerView. 44 wallpaperActionsToggles.setAdapter(adapter) 45 wallpaperActionsToggles.setLayoutManager( 46 LinearLayoutManager(context, LinearLayoutManager.VERTICAL, /* reverseLayout= */ false) 47 ) 48 } 49 setBottomSheetTitlenull50 fun setBottomSheetTitle(title: String) { 51 wallpaperActionsTitle.text = title 52 } 53 setBottomSheetSubtitlenull54 fun setBottomSheetSubtitle(subtitle: String) { 55 wallpaperActionsSubtitle.text = subtitle 56 } 57 } 58