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.systemui.settings.brightness.ui.binder 18 19 import android.content.Context 20 import android.view.LayoutInflater 21 import android.view.View 22 import android.view.ViewGroup 23 import androidx.core.view.isVisible 24 import androidx.core.view.setPadding 25 import com.android.systemui.res.R 26 import com.android.systemui.settings.brightness.BrightnessSliderController 27 28 object BrightnessMirrorInflater { 29 inflatenull30 fun inflate( 31 context: Context, 32 sliderControllerFactory: BrightnessSliderController.Factory, 33 ): Pair<View, BrightnessSliderController> { 34 val frame = 35 (LayoutInflater.from(context).inflate(R.layout.brightness_mirror_container, null) 36 as ViewGroup) 37 .apply { 38 isVisible = true 39 // Match BrightnessMirrorController padding 40 setPadding( 41 context.resources.getDimensionPixelSize( 42 R.dimen.rounded_slider_background_padding 43 ) 44 ) 45 } 46 val sliderController = sliderControllerFactory.create(context, frame) 47 sliderController.init() 48 frame.addView( 49 sliderController.rootView, 50 ViewGroup.LayoutParams.MATCH_PARENT, 51 ViewGroup.LayoutParams.WRAP_CONTENT 52 ) 53 return frame to sliderController 54 } 55 } 56