1 /* 2 * Copyright (C) 2019 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.google.android.setupdesign.util; 18 19 import android.widget.TextView; 20 import com.google.android.setupcompat.partnerconfig.PartnerConfig; 21 import com.google.android.setupdesign.util.TextViewPartnerStyler.TextPartnerConfigs; 22 23 /** 24 * Applies the partner style of description to the given TextView {@code description}. The user 25 * needs to check if the {@code description} should apply partner heavy theme or light theme before 26 * calling this method, only heavy theme can apply for all configs. 27 */ 28 public final class DescriptionStyler { 29 30 /** 31 * Applies the partner heavy style of description to the given text view. Must check the current 32 * text view applies partner customized configurations to heavy theme before applying. 33 * 34 * @param description A text view description resource 35 */ applyPartnerCustomizationHeavyStyle(TextView description)36 public static void applyPartnerCustomizationHeavyStyle(TextView description) { 37 TextViewPartnerStyler.applyPartnerCustomizationStyle( 38 description, 39 new TextPartnerConfigs( 40 PartnerConfig.CONFIG_DESCRIPTION_TEXT_COLOR, 41 PartnerConfig.CONFIG_DESCRIPTION_LINK_TEXT_COLOR, 42 PartnerConfig.CONFIG_DESCRIPTION_TEXT_SIZE, 43 PartnerConfig.CONFIG_DESCRIPTION_FONT_FAMILY, 44 PartnerConfig.CONFIG_DESCRIPTION_LINK_FONT_FAMILY, 45 null, 46 null, 47 PartnerStyleHelper.getLayoutGravity(description.getContext()))); 48 } 49 50 /** 51 * Applies the partner light style of description to the given text view. Must check the current 52 * text view applies partner customized configurations to light theme before applying. 53 * 54 * @param description A text view description resource 55 */ applyPartnerCustomizationLightStyle(TextView description)56 public static void applyPartnerCustomizationLightStyle(TextView description) { 57 TextViewPartnerStyler.applyPartnerCustomizationLightStyle( 58 description, 59 new TextPartnerConfigs( 60 null, 61 null, 62 null, 63 null, 64 null, 65 null, 66 null, 67 PartnerStyleHelper.getLayoutGravity(description.getContext()))); 68 } 69 DescriptionStyler()70 private DescriptionStyler() {} 71 } 72