Import updated Android SetupCompat Library 312662043 am: c6d9290302 am: 20bab2f6f4

Change-Id: If9735a4be3eca97d77785a94219f8b006d27b8f1
diff --git a/main/java/com/google/android/setupcompat/internal/FooterButtonPartnerConfig.java b/main/java/com/google/android/setupcompat/internal/FooterButtonPartnerConfig.java
index 6a019fd..39b50cf 100644
--- a/main/java/com/google/android/setupcompat/internal/FooterButtonPartnerConfig.java
+++ b/main/java/com/google/android/setupcompat/internal/FooterButtonPartnerConfig.java
@@ -22,6 +22,8 @@
 /** Keep the partner configuration of a footer button. Used when the button is inflated. */
 public class FooterButtonPartnerConfig {
   private final PartnerConfig buttonBackgroundConfig;
+  private final PartnerConfig buttonDisableAlphaConfig;
+  private final PartnerConfig buttonDisableBackgroundConfig;
   private final PartnerConfig buttonIconConfig;
   private final PartnerConfig buttonTextColorConfig;
   private final PartnerConfig buttonTextSizeConfig;
@@ -33,6 +35,8 @@
   private FooterButtonPartnerConfig(
       int partnerTheme,
       PartnerConfig buttonBackgroundConfig,
+      PartnerConfig buttonDisableAlphaConfig,
+      PartnerConfig buttonDisableBackgroundConfig,
       PartnerConfig buttonIconConfig,
       PartnerConfig buttonTextColorConfig,
       PartnerConfig buttonTextSizeConfig,
@@ -45,6 +49,8 @@
     this.buttonTextSizeConfig = buttonTextSizeConfig;
     this.buttonTextTypeFaceConfig = buttonTextTypeFaceConfig;
     this.buttonBackgroundConfig = buttonBackgroundConfig;
+    this.buttonDisableAlphaConfig = buttonDisableAlphaConfig;
+    this.buttonDisableBackgroundConfig = buttonDisableBackgroundConfig;
     this.buttonRadiusConfig = buttonRadiusConfig;
     this.buttonIconConfig = buttonIconConfig;
     this.buttonRippleColorAlphaConfig = buttonRippleColorAlphaConfig;
@@ -58,6 +64,14 @@
     return buttonBackgroundConfig;
   }
 
+  public PartnerConfig getButtonDisableAlphaConfig() {
+    return buttonDisableAlphaConfig;
+  }
+
+  public PartnerConfig getButtonDisableBackgroundConfig() {
+    return buttonDisableBackgroundConfig;
+  }
+
   public PartnerConfig getButtonIconConfig() {
     return buttonIconConfig;
   }
@@ -86,6 +100,8 @@
   public static class Builder {
     private final FooterButton footerButton;
     private PartnerConfig buttonBackgroundConfig = null;
+    private PartnerConfig buttonDisableAlphaConfig = null;
+    private PartnerConfig buttonDisableBackgroundConfig = null;
     private PartnerConfig buttonIconConfig = null;
     private PartnerConfig buttonTextColorConfig = null;
     private PartnerConfig buttonTextSizeConfig = null;
@@ -105,6 +121,16 @@
       return this;
     }
 
+    public Builder setButtonDisableAlphaConfig(PartnerConfig buttonDisableAlphaConfig) {
+      this.buttonDisableAlphaConfig = buttonDisableAlphaConfig;
+      return this;
+    }
+
+    public Builder setButtonDisableBackgroundConfig(PartnerConfig buttonDisableBackgroundConfig) {
+      this.buttonDisableBackgroundConfig = buttonDisableBackgroundConfig;
+      return this;
+    }
+
     public Builder setButtonIconConfig(PartnerConfig buttonIconConfig) {
       this.buttonIconConfig = buttonIconConfig;
       return this;
@@ -144,6 +170,8 @@
       return new FooterButtonPartnerConfig(
           partnerTheme,
           buttonBackgroundConfig,
+          buttonDisableAlphaConfig,
+          buttonDisableBackgroundConfig,
           buttonIconConfig,
           buttonTextColorConfig,
           buttonTextSizeConfig,
diff --git a/main/java/com/google/android/setupcompat/template/FooterBarMixin.java b/main/java/com/google/android/setupcompat/template/FooterBarMixin.java
index 3c88791..bc9e5c1 100644
--- a/main/java/com/google/android/setupcompat/template/FooterBarMixin.java
+++ b/main/java/com/google/android/setupcompat/template/FooterBarMixin.java
@@ -303,6 +303,8 @@
                     /* buttonBackgroundColorConfig= */ PartnerConfig
                         .CONFIG_FOOTER_PRIMARY_BUTTON_BG_COLOR))
             .setButtonBackgroundConfig(PartnerConfig.CONFIG_FOOTER_PRIMARY_BUTTON_BG_COLOR)
+            .setButtonDisableAlphaConfig(PartnerConfig.CONFIG_FOOTER_BUTTON_DISABLED_ALPHA)
+            .setButtonDisableBackgroundConfig(PartnerConfig.CONFIG_FOOTER_BUTTON_DISABLED_BG_COLOR)
             .setButtonIconConfig(getDrawablePartnerConfig(footerButton.getButtonType()))
             .setButtonRadiusConfig(PartnerConfig.CONFIG_FOOTER_BUTTON_RADIUS)
             .setButtonRippleColorAlphaConfig(PartnerConfig.CONFIG_FOOTER_BUTTON_RIPPLE_COLOR_ALPHA)
@@ -357,6 +359,8 @@
                     /* buttonBackgroundColorConfig= */ PartnerConfig
                         .CONFIG_FOOTER_SECONDARY_BUTTON_BG_COLOR))
             .setButtonBackgroundConfig(PartnerConfig.CONFIG_FOOTER_SECONDARY_BUTTON_BG_COLOR)
+            .setButtonDisableAlphaConfig(PartnerConfig.CONFIG_FOOTER_BUTTON_DISABLED_ALPHA)
+            .setButtonDisableBackgroundConfig(PartnerConfig.CONFIG_FOOTER_BUTTON_DISABLED_BG_COLOR)
             .setButtonIconConfig(getDrawablePartnerConfig(footerButton.getButtonType()))
             .setButtonRadiusConfig(PartnerConfig.CONFIG_FOOTER_BUTTON_RADIUS)
             .setButtonRippleColorAlphaConfig(PartnerConfig.CONFIG_FOOTER_BUTTON_RIPPLE_COLOR_ALPHA)
@@ -428,14 +432,16 @@
     // TODO: Make sure customize attributes in theme can be applied during setup flow.
     // If sets background color to full transparent, the button changes to colored borderless ink
     // button style.
-    int color = PartnerConfigHelper.get(context).getColor(context, buttonBackgroundColorConfig);
-    if (applyPartnerResources && color == Color.TRANSPARENT) {
-      overrideTheme = R.style.SucPartnerCustomizationButton_Secondary;
-    } else if (applyPartnerResources && (color != Color.TRANSPARENT)) {
-      // TODO: remove the constrain (color != Color.WHITE), need to check all pages go
-      // well without customization. It should be fine since the default value of secondary bg color
-      // is set as transparent.
-      overrideTheme = R.style.SucPartnerCustomizationButton_Primary;
+    if (applyPartnerResources) {
+      int color = PartnerConfigHelper.get(context).getColor(context, buttonBackgroundColorConfig);
+      if (color == Color.TRANSPARENT) {
+        overrideTheme = R.style.SucPartnerCustomizationButton_Secondary;
+      } else if (color != Color.TRANSPARENT) {
+        // TODO: remove the constrain (color != Color.WHITE), need to check all pages
+        // go well without customization. It should be fine since the default value of secondary bg
+        // color is set as transparent.
+        overrideTheme = R.style.SucPartnerCustomizationButton_Primary;
+      }
     }
     return overrideTheme;
   }
@@ -545,7 +551,10 @@
     updateButtonTypeFaceWithPartnerConfig(
         button, footerButtonPartnerConfig.getButtonTextTypeFaceConfig());
     updateButtonBackgroundWithPartnerConfig(
-        button, footerButtonPartnerConfig.getButtonBackgroundConfig());
+        button,
+        footerButtonPartnerConfig.getButtonBackgroundConfig(),
+        footerButtonPartnerConfig.getButtonDisableAlphaConfig(),
+        footerButtonPartnerConfig.getButtonDisableBackgroundConfig());
     updateButtonRadiusWithPartnerConfig(button, footerButtonPartnerConfig.getButtonRadiusConfig());
     updateButtonIconWithPartnerConfig(button, footerButtonPartnerConfig.getButtonIconConfig());
     updateButtonRippleColorWithPartnerConfig(button, footerButtonPartnerConfig);
@@ -586,25 +595,43 @@
 
   @TargetApi(VERSION_CODES.Q)
   private void updateButtonBackgroundWithPartnerConfig(
-      Button button, PartnerConfig buttonBackgroundConfig) {
+      Button button,
+      PartnerConfig buttonBackgroundConfig,
+      PartnerConfig buttonDisableAlphaConfig,
+      PartnerConfig buttonDisableBackgroundConfig) {
     Preconditions.checkArgument(
         Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q,
         "Update button background only support on sdk Q or higher");
     @ColorInt int color;
+    @ColorInt int disabledColor;
+    float disabledAlpha;
     int[] DISABLED_STATE_SET = {-android.R.attr.state_enabled};
     int[] ENABLED_STATE_SET = {};
     color = PartnerConfigHelper.get(context).getColor(context, buttonBackgroundConfig);
+    disabledAlpha =
+        PartnerConfigHelper.get(context).getFraction(context, buttonDisableAlphaConfig, 0f);
+    disabledColor =
+        PartnerConfigHelper.get(context).getColor(context, buttonDisableBackgroundConfig);
 
     if (color != Color.TRANSPARENT) {
-      TypedArray a = context.obtainStyledAttributes(new int[] {android.R.attr.disabledAlpha});
-      float alpha = a.getFloat(0, DEFAULT_DISABLED_ALPHA);
-      a.recycle();
+      if (disabledAlpha <= 0f) {
+        // if no partner resource, fallback to theme disable alpha
+        float alpha;
+        TypedArray a = context.obtainStyledAttributes(new int[] {android.R.attr.disabledAlpha});
+        alpha = a.getFloat(0, DEFAULT_DISABLED_ALPHA);
+        a.recycle();
+        disabledAlpha = alpha;
+      }
+      if (disabledColor == Color.TRANSPARENT) {
+        // if no partner resource, fallback to button background color
+        disabledColor = color;
+      }
 
       // Set text color for ripple.
       ColorStateList colorStateList =
           new ColorStateList(
               new int[][] {DISABLED_STATE_SET, ENABLED_STATE_SET},
-              new int[] {convertRgbToArgb(color, alpha), color});
+              new int[] {convertRgbToArgb(disabledColor, disabledAlpha), color});
 
       // b/129482013: When a LayerDrawable is mutated, a new clone of its children drawables are
       // created, but without copying the state from the parent drawable. So even though the
diff --git a/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfig.java b/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfig.java
index 2844e03..56256c9 100644
--- a/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfig.java
+++ b/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfig.java
@@ -93,6 +93,14 @@
   CONFIG_FOOTER_BUTTON_TEXT_SIZE(
       PartnerConfigKey.KEY_FOOTER_BUTTON_TEXT_SIZE, ResourceType.DIMENSION),
 
+  // Disabled background alpha of the footer buttons
+  CONFIG_FOOTER_BUTTON_DISABLED_ALPHA(
+      PartnerConfigKey.KEY_FOOTER_BUTTON_DISABLED_ALPHA, ResourceType.FRACTION),
+
+  // Disabled background color of the footer buttons
+  CONFIG_FOOTER_BUTTON_DISABLED_BG_COLOR(
+      PartnerConfigKey.KEY_FOOTER_BUTTON_DISABLED_BG_COLOR, ResourceType.COLOR),
+
   // Background color of the primary footer button
   CONFIG_FOOTER_PRIMARY_BUTTON_BG_COLOR(
       PartnerConfigKey.KEY_FOOTER_PRIMARY_BUTTON_BG_COLOR, ResourceType.COLOR),
diff --git a/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfigKey.java b/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfigKey.java
index 49e96b2..e5c5442 100644
--- a/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfigKey.java
+++ b/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfigKey.java
@@ -43,6 +43,8 @@
   PartnerConfigKey.KEY_FOOTER_BUTTON_RADIUS,
   PartnerConfigKey.KEY_FOOTER_BUTTON_RIPPLE_ALPHA,
   PartnerConfigKey.KEY_FOOTER_BUTTON_TEXT_SIZE,
+  PartnerConfigKey.KEY_FOOTER_BUTTON_DISABLED_ALPHA,
+  PartnerConfigKey.KEY_FOOTER_BUTTON_DISABLED_BG_COLOR,
   PartnerConfigKey.KEY_FOOTER_PRIMARY_BUTTON_BG_COLOR,
   PartnerConfigKey.KEY_FOOTER_PRIMARY_BUTTON_TEXT_COLOR,
   PartnerConfigKey.KEY_FOOTER_SECONDARY_BUTTON_BG_COLOR,
@@ -131,6 +133,12 @@
   // Text size of the footer button
   String KEY_FOOTER_BUTTON_TEXT_SIZE = "setup_compat_footer_button_text_size";
 
+  // Disabled background alpha of the footer buttons
+  String KEY_FOOTER_BUTTON_DISABLED_ALPHA = "setup_compat_footer_button_disabled_alpha";
+
+  // Disabled background color of the footer buttons
+  String KEY_FOOTER_BUTTON_DISABLED_BG_COLOR = "setup_compat_footer_button_disabled_bg_color";
+
   // Background color of the primary footer button
   String KEY_FOOTER_PRIMARY_BUTTON_BG_COLOR = "setup_compat_footer_primary_button_bg_color";