• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_FONT_WEIGHT,
45             PartnerConfig.CONFIG_DESCRIPTION_LINK_FONT_FAMILY,
46             /* textMarginTopConfig= */ null,
47             /* textMarginBottomConfig= */ null,
48             PartnerStyleHelper.getLayoutGravity(description.getContext())));
49   }
50 
51   /**
52    * Applies the partner light style of description to the given text view. Must check the current
53    * text view applies partner customized configurations to light theme before applying.
54    *
55    * @param description A text view description resource
56    */
applyPartnerCustomizationLightStyle(TextView description)57   public static void applyPartnerCustomizationLightStyle(TextView description) {
58     TextViewPartnerStyler.applyPartnerCustomizationLightStyle(
59         description,
60         new TextPartnerConfigs(
61             /* textColorConfig= */ null,
62             /* textLinkedColorConfig= */ null,
63             /* textSizeConfig= */ null,
64             /* textFontFamilyConfig= */ null,
65             /* textFontWeightConfig= */ null,
66             /* textLinkFontFamilyConfig= */ null,
67             /* textMarginTopConfig= */ null,
68             /* textMarginBottomConfig= */ null,
69             PartnerStyleHelper.getLayoutGravity(description.getContext())));
70   }
71 
DescriptionStyler()72   private DescriptionStyler() {}
73 }
74