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 buttonDisableAlphaConfig; 26 private final PartnerConfig buttonDisableBackgroundConfig; 27 private final PartnerConfig buttonIconConfig; 28 private final PartnerConfig buttonTextColorConfig; 29 private final PartnerConfig buttonTextSizeConfig; 30 private final PartnerConfig buttonMinHeightConfig; 31 private final PartnerConfig buttonTextTypeFaceConfig; 32 private final PartnerConfig buttonTextStyleConfig; 33 private final PartnerConfig buttonRadiusConfig; 34 private final PartnerConfig buttonRippleColorAlphaConfig; 35 private final int partnerTheme; 36 FooterButtonPartnerConfig( int partnerTheme, PartnerConfig buttonBackgroundConfig, PartnerConfig buttonDisableAlphaConfig, PartnerConfig buttonDisableBackgroundConfig, PartnerConfig buttonIconConfig, PartnerConfig buttonTextColorConfig, PartnerConfig buttonTextSizeConfig, PartnerConfig buttonMinHeightConfig, PartnerConfig buttonTextTypeFaceConfig, PartnerConfig buttonTextStyleConfig, PartnerConfig buttonRadiusConfig, PartnerConfig buttonRippleColorAlphaConfig)37 private FooterButtonPartnerConfig( 38 int partnerTheme, 39 PartnerConfig buttonBackgroundConfig, 40 PartnerConfig buttonDisableAlphaConfig, 41 PartnerConfig buttonDisableBackgroundConfig, 42 PartnerConfig buttonIconConfig, 43 PartnerConfig buttonTextColorConfig, 44 PartnerConfig buttonTextSizeConfig, 45 PartnerConfig buttonMinHeightConfig, 46 PartnerConfig buttonTextTypeFaceConfig, 47 PartnerConfig buttonTextStyleConfig, 48 PartnerConfig buttonRadiusConfig, 49 PartnerConfig buttonRippleColorAlphaConfig) { 50 this.partnerTheme = partnerTheme; 51 52 this.buttonTextColorConfig = buttonTextColorConfig; 53 this.buttonTextSizeConfig = buttonTextSizeConfig; 54 this.buttonMinHeightConfig = buttonMinHeightConfig; 55 this.buttonTextTypeFaceConfig = buttonTextTypeFaceConfig; 56 this.buttonTextStyleConfig = buttonTextStyleConfig; 57 this.buttonBackgroundConfig = buttonBackgroundConfig; 58 this.buttonDisableAlphaConfig = buttonDisableAlphaConfig; 59 this.buttonDisableBackgroundConfig = buttonDisableBackgroundConfig; 60 this.buttonRadiusConfig = buttonRadiusConfig; 61 this.buttonIconConfig = buttonIconConfig; 62 this.buttonRippleColorAlphaConfig = buttonRippleColorAlphaConfig; 63 } 64 getPartnerTheme()65 public int getPartnerTheme() { 66 return partnerTheme; 67 } 68 getButtonBackgroundConfig()69 public PartnerConfig getButtonBackgroundConfig() { 70 return buttonBackgroundConfig; 71 } 72 getButtonDisableAlphaConfig()73 public PartnerConfig getButtonDisableAlphaConfig() { 74 return buttonDisableAlphaConfig; 75 } 76 getButtonDisableBackgroundConfig()77 public PartnerConfig getButtonDisableBackgroundConfig() { 78 return buttonDisableBackgroundConfig; 79 } 80 getButtonIconConfig()81 public PartnerConfig getButtonIconConfig() { 82 return buttonIconConfig; 83 } 84 getButtonTextColorConfig()85 public PartnerConfig getButtonTextColorConfig() { 86 return buttonTextColorConfig; 87 } 88 getButtonMinHeightConfig()89 public PartnerConfig getButtonMinHeightConfig() { 90 return buttonMinHeightConfig; 91 } 92 getButtonTextSizeConfig()93 public PartnerConfig getButtonTextSizeConfig() { 94 return buttonTextSizeConfig; 95 } 96 getButtonTextTypeFaceConfig()97 public PartnerConfig getButtonTextTypeFaceConfig() { 98 return buttonTextTypeFaceConfig; 99 } 100 getButtonTextStyleConfig()101 public PartnerConfig getButtonTextStyleConfig() { 102 return buttonTextStyleConfig; 103 } 104 getButtonRadiusConfig()105 public PartnerConfig getButtonRadiusConfig() { 106 return buttonRadiusConfig; 107 } 108 getButtonRippleColorAlphaConfig()109 public PartnerConfig getButtonRippleColorAlphaConfig() { 110 return buttonRippleColorAlphaConfig; 111 } 112 113 /** Builder class for constructing {@code FooterButtonPartnerConfig} objects. */ 114 public static class Builder { 115 private final FooterButton footerButton; 116 private PartnerConfig buttonBackgroundConfig = null; 117 private PartnerConfig buttonDisableAlphaConfig = null; 118 private PartnerConfig buttonDisableBackgroundConfig = null; 119 private PartnerConfig buttonIconConfig = null; 120 private PartnerConfig buttonTextColorConfig = null; 121 private PartnerConfig buttonTextSizeConfig = null; 122 private PartnerConfig buttonMinHeight = null; 123 private PartnerConfig buttonTextTypeFaceConfig = null; 124 private PartnerConfig buttonTextStyleConfig = null; 125 private PartnerConfig buttonRadiusConfig = null; 126 private PartnerConfig buttonRippleColorAlphaConfig = null; 127 private int partnerTheme; 128 Builder(FooterButton footerButton)129 public Builder(FooterButton footerButton) { 130 this.footerButton = footerButton; 131 if (this.footerButton != null) { 132 // default partnerTheme should be the same as footerButton.getTheme(); 133 this.partnerTheme = this.footerButton.getTheme(); 134 } 135 } 136 setButtonBackgroundConfig(PartnerConfig buttonBackgroundConfig)137 public Builder setButtonBackgroundConfig(PartnerConfig buttonBackgroundConfig) { 138 this.buttonBackgroundConfig = buttonBackgroundConfig; 139 return this; 140 } 141 setButtonDisableAlphaConfig(PartnerConfig buttonDisableAlphaConfig)142 public Builder setButtonDisableAlphaConfig(PartnerConfig buttonDisableAlphaConfig) { 143 this.buttonDisableAlphaConfig = buttonDisableAlphaConfig; 144 return this; 145 } 146 setButtonDisableBackgroundConfig(PartnerConfig buttonDisableBackgroundConfig)147 public Builder setButtonDisableBackgroundConfig(PartnerConfig buttonDisableBackgroundConfig) { 148 this.buttonDisableBackgroundConfig = buttonDisableBackgroundConfig; 149 return this; 150 } 151 setButtonIconConfig(PartnerConfig buttonIconConfig)152 public Builder setButtonIconConfig(PartnerConfig buttonIconConfig) { 153 this.buttonIconConfig = buttonIconConfig; 154 return this; 155 } 156 setTextColorConfig(PartnerConfig buttonTextColorConfig)157 public Builder setTextColorConfig(PartnerConfig buttonTextColorConfig) { 158 this.buttonTextColorConfig = buttonTextColorConfig; 159 return this; 160 } 161 setTextSizeConfig(PartnerConfig buttonTextSizeConfig)162 public Builder setTextSizeConfig(PartnerConfig buttonTextSizeConfig) { 163 this.buttonTextSizeConfig = buttonTextSizeConfig; 164 return this; 165 } 166 setButtonMinHeight(PartnerConfig buttonMinHeightConfig)167 public Builder setButtonMinHeight(PartnerConfig buttonMinHeightConfig) { 168 this.buttonMinHeight = buttonMinHeightConfig; 169 return this; 170 } 171 setTextTypeFaceConfig(PartnerConfig buttonTextTypeFaceConfig)172 public Builder setTextTypeFaceConfig(PartnerConfig buttonTextTypeFaceConfig) { 173 this.buttonTextTypeFaceConfig = buttonTextTypeFaceConfig; 174 return this; 175 } 176 setTextStyleConfig(PartnerConfig buttonTextStyleConfig)177 public Builder setTextStyleConfig(PartnerConfig buttonTextStyleConfig) { 178 this.buttonTextStyleConfig = buttonTextStyleConfig; 179 return this; 180 } 181 setButtonRadiusConfig(PartnerConfig buttonRadiusConfig)182 public Builder setButtonRadiusConfig(PartnerConfig buttonRadiusConfig) { 183 this.buttonRadiusConfig = buttonRadiusConfig; 184 return this; 185 } 186 setButtonRippleColorAlphaConfig(PartnerConfig buttonRippleColorAlphaConfig)187 public Builder setButtonRippleColorAlphaConfig(PartnerConfig buttonRippleColorAlphaConfig) { 188 this.buttonRippleColorAlphaConfig = buttonRippleColorAlphaConfig; 189 return this; 190 } 191 setPartnerTheme(int partnerTheme)192 public Builder setPartnerTheme(int partnerTheme) { 193 this.partnerTheme = partnerTheme; 194 return this; 195 } 196 build()197 public FooterButtonPartnerConfig build() { 198 return new FooterButtonPartnerConfig( 199 partnerTheme, 200 buttonBackgroundConfig, 201 buttonDisableAlphaConfig, 202 buttonDisableBackgroundConfig, 203 buttonIconConfig, 204 buttonTextColorConfig, 205 buttonTextSizeConfig, 206 buttonMinHeight, 207 buttonTextTypeFaceConfig, 208 buttonTextStyleConfig, 209 buttonRadiusConfig, 210 buttonRippleColorAlphaConfig); 211 } 212 } 213 } 214