1 /* 2 * Copyright (C) 2021 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.settings.accessibility; 17 18 import android.content.Context; 19 import android.graphics.drawable.Drawable; 20 import android.widget.LinearLayout; 21 22 import com.android.settings.R; 23 24 import com.google.android.setupdesign.GlifPreferenceLayout; 25 import com.google.android.setupdesign.util.ThemeHelper; 26 27 /** Provides utility methods to accessibility settings for Setup Wizard only. */ 28 class AccessibilitySetupWizardUtils { 29 AccessibilitySetupWizardUtils()30 private AccessibilitySetupWizardUtils(){} 31 32 /** 33 * Update the {@link GlifPreferenceLayout} attributes if they have previously been initialized. 34 * When the SetupWizard supports the extended partner configs, it means the material layout 35 * would be applied. It should set a different padding/margin in views to align Settings style 36 * for accessibility feature pages. 37 * 38 * @param layout The layout instance 39 * @param title The text to be set as title 40 * @param description The text to be set as description 41 * @param icon The icon to be set 42 */ updateGlifPreferenceLayout(Context context, GlifPreferenceLayout layout, CharSequence title, CharSequence description, Drawable icon)43 public static void updateGlifPreferenceLayout(Context context, GlifPreferenceLayout layout, 44 CharSequence title, CharSequence description, Drawable icon) { 45 layout.setHeaderText(title); 46 layout.setDescriptionText(description); 47 layout.setIcon(icon); 48 layout.setDividerInsets(Integer.MAX_VALUE, 0); 49 50 if (ThemeHelper.shouldApplyExtendedPartnerConfig(context)) { 51 final LinearLayout headerLayout = layout.findManagedViewById(R.id.sud_layout_header); 52 if (headerLayout != null) { 53 headerLayout.setPadding(0, layout.getPaddingTop(), 0, 54 layout.getPaddingBottom()); 55 } 56 } 57 } 58 } 59