diff options
author | Setup Wizard Team <android-setup-team-eng@google.com> | 2020-05-25 11:03:16 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-05-25 11:03:16 +0000 |
commit | d497370655ea8c6f15169af88cd9c75406e51395 (patch) | |
tree | c7081a988f38a61af7ba4abd31376885de4cc10a | |
parent | 5215c8f2e60ffd02e599046f792549dc89afe7ef (diff) | |
parent | c6d929030275abe2cfd23756cce4e1de8db70713 (diff) | |
download | setupcompat-android11-mainline-permission-release.tar.gz |
Import updated Android SetupCompat Library 312662043 am: c6d9290302android-mainline-11.0.0_r44android-mainline-11.0.0_r43android-mainline-11.0.0_r42android-mainline-11.0.0_r41android-mainline-11.0.0_r40android-mainline-11.0.0_r39android-mainline-11.0.0_r38android-mainline-11.0.0_r37android-mainline-11.0.0_r36android-mainline-11.0.0_r35android-mainline-11.0.0_r34android-mainline-11.0.0_r32android-mainline-11.0.0_r31android-mainline-11.0.0_r30android-mainline-11.0.0_r28android-mainline-11.0.0_r27android-mainline-11.0.0_r26android-mainline-11.0.0_r25android-mainline-11.0.0_r24android-mainline-11.0.0_r23android-mainline-11.0.0_r22android-mainline-11.0.0_r21android-mainline-11.0.0_r20android-mainline-11.0.0_r18android-mainline-11.0.0_r17android-mainline-11.0.0_r16android-mainline-11.0.0_r15android-mainline-11.0.0_r14android-mainline-11.0.0_r13android-mainline-11.0.0_r12android11-mainline-tethering-releaseandroid11-mainline-permission-releaseandroid11-mainline-os-statsd-releaseandroid11-mainline-networkstack-releaseandroid11-mainline-media-swcodec-releaseandroid11-mainline-media-releaseandroid11-mainline-extservices-releaseandroid11-mainline-documentsui-releaseandroid11-mainline-conscrypt-releaseandroid11-mainline-cellbroadcast-releaseandroid11-mainline-captiveportallogin-release
Change-Id: Ia893f3ea5f708296ef52407a6a8276cfeed4633f
4 files changed, 85 insertions, 14 deletions
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 @@ import com.google.android.setupcompat.template.FooterButton; /** 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 @@ public class FooterButtonPartnerConfig { private FooterButtonPartnerConfig( int partnerTheme, PartnerConfig buttonBackgroundConfig, + PartnerConfig buttonDisableAlphaConfig, + PartnerConfig buttonDisableBackgroundConfig, PartnerConfig buttonIconConfig, PartnerConfig buttonTextColorConfig, PartnerConfig buttonTextSizeConfig, @@ -45,6 +49,8 @@ public class FooterButtonPartnerConfig { 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 @@ public class FooterButtonPartnerConfig { return buttonBackgroundConfig; } + public PartnerConfig getButtonDisableAlphaConfig() { + return buttonDisableAlphaConfig; + } + + public PartnerConfig getButtonDisableBackgroundConfig() { + return buttonDisableBackgroundConfig; + } + public PartnerConfig getButtonIconConfig() { return buttonIconConfig; } @@ -86,6 +100,8 @@ public class FooterButtonPartnerConfig { 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 @@ public class FooterButtonPartnerConfig { 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 @@ public class FooterButtonPartnerConfig { 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 @@ public class FooterBarMixin implements Mixin { /* 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 @@ public class FooterBarMixin implements Mixin { /* 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 @@ public class FooterBarMixin implements Mixin { // 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 @@ public class FooterBarMixin implements Mixin { 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 @@ public class FooterBarMixin implements Mixin { @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 @@ public enum PartnerConfig { 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 @@ import java.lang.annotation.RetentionPolicy; 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 @@ public @interface PartnerConfigKey { // 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"; |