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 */ 17 18 package com.android.customization.picker.notifications.ui.section 19 20 import android.annotation.SuppressLint 21 import android.content.Context 22 import android.view.LayoutInflater 23 import androidx.lifecycle.LifecycleOwner 24 import com.android.customization.picker.notifications.ui.binder.NotificationSectionBinder 25 import com.android.customization.picker.notifications.ui.view.NotificationSectionView 26 import com.android.customization.picker.notifications.ui.viewmodel.NotificationSectionViewModel 27 import com.android.themepicker.R 28 import com.android.wallpaper.model.CustomizationSectionController 29 30 /** Controls a section with UI that lets the user toggle notification settings. */ 31 class NotificationSectionController( 32 private val viewModel: NotificationSectionViewModel, 33 private val lifecycleOwner: LifecycleOwner, 34 ) : CustomizationSectionController<NotificationSectionView> { 35 isAvailablenull36 override fun isAvailable(context: Context): Boolean { 37 return true 38 } 39 40 @SuppressLint("InflateParams") // We don't care that the parent is null. createViewnull41 override fun createView(context: Context): NotificationSectionView { 42 val view = 43 LayoutInflater.from(context) 44 .inflate( 45 R.layout.notification_section, 46 /* parent= */ null, 47 ) as NotificationSectionView 48 49 NotificationSectionBinder.bind( 50 view = view, 51 viewModel = viewModel, 52 lifecycleOwner = lifecycleOwner, 53 ) 54 55 return view 56 } 57 } 58