• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.customization.picker.settings.ui.section
18 
19 import android.annotation.SuppressLint
20 import android.content.Context
21 import android.content.Intent
22 import android.provider.Settings
23 import android.view.LayoutInflater
24 import androidx.lifecycle.LifecycleOwner
25 import com.android.customization.picker.settings.ui.binder.ColorContrastSectionViewBinder
26 import com.android.customization.picker.settings.ui.view.ColorContrastSectionView
27 import com.android.customization.picker.settings.ui.viewmodel.ColorContrastSectionViewModel
28 import com.android.themepicker.R
29 import com.android.wallpaper.model.CustomizationSectionController
30 
31 class ColorContrastSectionController(
32     private val viewModel: ColorContrastSectionViewModel,
33     private val lifecycleOwner: LifecycleOwner,
34 ) : CustomizationSectionController<ColorContrastSectionView> {
35 
36     // TODO (b/330381229): Check for whether the color contrast activity intent
37     // resolves to something or not before marking the feature as available
isAvailablenull38     override fun isAvailable(context: Context): Boolean {
39         return true
40     }
41 
42     @SuppressLint("InflateParams") // We're okay not providing a parent view.
createViewnull43     override fun createView(context: Context): ColorContrastSectionView {
44         val view =
45             LayoutInflater.from(context)
46                 .inflate(
47                     R.layout.color_contrast_section_view,
48                     null,
49                 ) as ColorContrastSectionView
50         ColorContrastSectionViewBinder.bind(
51             view = view,
52             lifecycleOwner = lifecycleOwner,
53             viewModel = viewModel
54         ) {
55             context.startActivity(Intent(Settings.ACTION_ACCESSIBILITY_COLOR_CONTRAST_SETTINGS))
56         }
57         return view
58     }
59 }
60