1 /* 2 * Copyright 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.setupcompat.internal; 18 19 import com.google.android.setupcompat.partnerconfig.PartnerConfig; 20 import com.google.android.setupcompat.template.FooterButton; 21 22 /** Keep the partner configuration of a footer button. Used when the button is inflated. */ 23 public class FooterButtonPartnerConfig { 24 private final PartnerConfig buttonBackgroundConfig; 25 private final PartnerConfig buttonIconConfig; 26 private final PartnerConfig buttonTextColorConfig; 27 private final PartnerConfig buttonTextSizeConfig; 28 private final PartnerConfig buttonTextTypeFaceConfig; 29 private final PartnerConfig buttonRadiusConfig; 30 private final PartnerConfig buttonRippleColorAlphaConfig; 31 private final int partnerTheme; 32 FooterButtonPartnerConfig( int partnerTheme, PartnerConfig buttonBackgroundConfig, PartnerConfig buttonIconConfig, PartnerConfig buttonTextColorConfig, PartnerConfig buttonTextSizeConfig, PartnerConfig buttonTextTypeFaceConfig, PartnerConfig buttonRadiusConfig, PartnerConfig buttonRippleColorAlphaConfig)33 private FooterButtonPartnerConfig( 34 int partnerTheme, 35 PartnerConfig buttonBackgroundConfig, 36 PartnerConfig buttonIconConfig, 37 PartnerConfig buttonTextColorConfig, 38 PartnerConfig buttonTextSizeConfig, 39 PartnerConfig buttonTextTypeFaceConfig, 40 PartnerConfig buttonRadiusConfig, 41 PartnerConfig buttonRippleColorAlphaConfig) { 42 this.partnerTheme = partnerTheme; 43 44 this.buttonTextColorConfig = buttonTextColorConfig; 45 this.buttonTextSizeConfig = buttonTextSizeConfig; 46 this.buttonTextTypeFaceConfig = buttonTextTypeFaceConfig; 47 this.buttonBackgroundConfig = buttonBackgroundConfig; 48 this.buttonRadiusConfig = buttonRadiusConfig; 49 this.buttonIconConfig = buttonIconConfig; 50 this.buttonRippleColorAlphaConfig = buttonRippleColorAlphaConfig; 51 } 52 getPartnerTheme()53 public int getPartnerTheme() { 54 return partnerTheme; 55 } 56 getButtonBackgroundConfig()57 public PartnerConfig getButtonBackgroundConfig() { 58 return buttonBackgroundConfig; 59 } 60 getButtonIconConfig()61 public PartnerConfig getButtonIconConfig() { 62 return buttonIconConfig; 63 } 64 getButtonTextColorConfig()65 public PartnerConfig getButtonTextColorConfig() { 66 return buttonTextColorConfig; 67 } 68 getButtonTextSizeConfig()69 public PartnerConfig getButtonTextSizeConfig() { 70 return buttonTextSizeConfig; 71 } 72 getButtonTextTypeFaceConfig()73 public PartnerConfig getButtonTextTypeFaceConfig() { 74 return buttonTextTypeFaceConfig; 75 } 76 getButtonRadiusConfig()77 public PartnerConfig getButtonRadiusConfig() { 78 return buttonRadiusConfig; 79 } 80 getButtonRippleColorAlphaConfig()81 public PartnerConfig getButtonRippleColorAlphaConfig() { 82 return buttonRippleColorAlphaConfig; 83 } 84 85 /** Builder class for constructing {@code FooterButtonPartnerConfig} objects. */ 86 public static class Builder { 87 private final FooterButton footerButton; 88 private PartnerConfig buttonBackgroundConfig = null; 89 private PartnerConfig buttonIconConfig = null; 90 private PartnerConfig buttonTextColorConfig = null; 91 private PartnerConfig buttonTextSizeConfig = null; 92 private PartnerConfig buttonTextTypeFaceConfig = null; 93 private PartnerConfig buttonRadiusConfig = null; 94 private PartnerConfig buttonRippleColorAlphaConfig = null; 95 private int partnerTheme; 96 Builder(FooterButton footerButton)97 public Builder(FooterButton footerButton) { 98 this.footerButton = footerButton; 99 // default partnerTheme should be the same as footerButton.getTheme(); 100 this.partnerTheme = this.footerButton.getTheme(); 101 } 102 setButtonBackgroundConfig(PartnerConfig buttonBackgroundConfig)103 public Builder setButtonBackgroundConfig(PartnerConfig buttonBackgroundConfig) { 104 this.buttonBackgroundConfig = buttonBackgroundConfig; 105 return this; 106 } 107 setButtonIconConfig(PartnerConfig buttonIconConfig)108 public Builder setButtonIconConfig(PartnerConfig buttonIconConfig) { 109 this.buttonIconConfig = buttonIconConfig; 110 return this; 111 } 112 setTextColorConfig(PartnerConfig buttonTextColorConfig)113 public Builder setTextColorConfig(PartnerConfig buttonTextColorConfig) { 114 this.buttonTextColorConfig = buttonTextColorConfig; 115 return this; 116 } 117 setTextSizeConfig(PartnerConfig buttonTextSizeConfig)118 public Builder setTextSizeConfig(PartnerConfig buttonTextSizeConfig) { 119 this.buttonTextSizeConfig = buttonTextSizeConfig; 120 return this; 121 } 122 setTextTypeFaceConfig(PartnerConfig buttonTextTypeFaceConfig)123 public Builder setTextTypeFaceConfig(PartnerConfig buttonTextTypeFaceConfig) { 124 this.buttonTextTypeFaceConfig = buttonTextTypeFaceConfig; 125 return this; 126 } 127 setButtonRadiusConfig(PartnerConfig buttonRadiusConfig)128 public Builder setButtonRadiusConfig(PartnerConfig buttonRadiusConfig) { 129 this.buttonRadiusConfig = buttonRadiusConfig; 130 return this; 131 } 132 setButtonRippleColorAlphaConfig(PartnerConfig buttonRippleColorAlphaConfig)133 public Builder setButtonRippleColorAlphaConfig(PartnerConfig buttonRippleColorAlphaConfig) { 134 this.buttonRippleColorAlphaConfig = buttonRippleColorAlphaConfig; 135 return this; 136 } 137 setPartnerTheme(int partnerTheme)138 public Builder setPartnerTheme(int partnerTheme) { 139 this.partnerTheme = partnerTheme; 140 return this; 141 } 142 build()143 public FooterButtonPartnerConfig build() { 144 return new FooterButtonPartnerConfig( 145 partnerTheme, 146 buttonBackgroundConfig, 147 buttonIconConfig, 148 buttonTextColorConfig, 149 buttonTextSizeConfig, 150 buttonTextTypeFaceConfig, 151 buttonRadiusConfig, 152 buttonRippleColorAlphaConfig); 153 } 154 } 155 } 156