summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSetup Wizard Team <android-setup-team-eng@google.com>2021-03-04 07:59:06 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2021-03-04 07:59:06 +0000
commit17a83d1d96e80a821c212ffc62005f3cae529e88 (patch)
tree3e593a39e434deeb5a924f5d8c30b1d82a0f2dd0
parent89353c39a97f1c5da74d892840f8e0c657376746 (diff)
parent261f8b488cfafac3fcf328ddead2ed23eaa389e6 (diff)
downloadsetupcompat-17a83d1d96e80a821c212ffc62005f3cae529e88.tar.gz
Import updated Android SetupCompat Library 360792876 am: 261f8b488c
Original change: https://googleplex-android-review.googlesource.com/c/platform/external/setupcompat/+/13764947 MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: Ifc0f51a6060c0e1bd5ad7563c029a5de17606e63
-rw-r--r--main/java/com/google/android/setupcompat/PartnerCustomizationLayout.java3
-rw-r--r--main/java/com/google/android/setupcompat/internal/FooterButtonPartnerConfig.java14
-rw-r--r--main/java/com/google/android/setupcompat/template/FooterBarMixin.java17
-rw-r--r--partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfig.java7
-rw-r--r--partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfigHelper.java29
-rw-r--r--partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfigKey.java8
6 files changed, 73 insertions, 5 deletions
diff --git a/main/java/com/google/android/setupcompat/PartnerCustomizationLayout.java b/main/java/com/google/android/setupcompat/PartnerCustomizationLayout.java
index e3f608b..3f3eb9d 100644
--- a/main/java/com/google/android/setupcompat/PartnerCustomizationLayout.java
+++ b/main/java/com/google/android/setupcompat/PartnerCustomizationLayout.java
@@ -83,6 +83,9 @@ public class PartnerCustomizationLayout extends TemplateLayout {
}
private void init(AttributeSet attrs, int defStyleAttr) {
+ if (isInEditMode()) {
+ return;
+ }
TypedArray a =
getContext()
diff --git a/main/java/com/google/android/setupcompat/internal/FooterButtonPartnerConfig.java b/main/java/com/google/android/setupcompat/internal/FooterButtonPartnerConfig.java
index 94101fb..08d76e9 100644
--- a/main/java/com/google/android/setupcompat/internal/FooterButtonPartnerConfig.java
+++ b/main/java/com/google/android/setupcompat/internal/FooterButtonPartnerConfig.java
@@ -29,6 +29,7 @@ public class FooterButtonPartnerConfig {
private final PartnerConfig buttonTextSizeConfig;
private final PartnerConfig buttonMinHeightConfig;
private final PartnerConfig buttonTextTypeFaceConfig;
+ private final PartnerConfig buttonTextStyleConfig;
private final PartnerConfig buttonRadiusConfig;
private final PartnerConfig buttonRippleColorAlphaConfig;
private final int partnerTheme;
@@ -43,6 +44,7 @@ public class FooterButtonPartnerConfig {
PartnerConfig buttonTextSizeConfig,
PartnerConfig buttonMinHeightConfig,
PartnerConfig buttonTextTypeFaceConfig,
+ PartnerConfig buttonTextStyleConfig,
PartnerConfig buttonRadiusConfig,
PartnerConfig buttonRippleColorAlphaConfig) {
this.partnerTheme = partnerTheme;
@@ -51,6 +53,7 @@ public class FooterButtonPartnerConfig {
this.buttonTextSizeConfig = buttonTextSizeConfig;
this.buttonMinHeightConfig = buttonMinHeightConfig;
this.buttonTextTypeFaceConfig = buttonTextTypeFaceConfig;
+ this.buttonTextStyleConfig = buttonTextStyleConfig;
this.buttonBackgroundConfig = buttonBackgroundConfig;
this.buttonDisableAlphaConfig = buttonDisableAlphaConfig;
this.buttonDisableBackgroundConfig = buttonDisableBackgroundConfig;
@@ -95,6 +98,10 @@ public class FooterButtonPartnerConfig {
return buttonTextTypeFaceConfig;
}
+ public PartnerConfig getButtonTextStyleConfig() {
+ return buttonTextStyleConfig;
+ }
+
public PartnerConfig getButtonRadiusConfig() {
return buttonRadiusConfig;
}
@@ -114,6 +121,7 @@ public class FooterButtonPartnerConfig {
private PartnerConfig buttonTextSizeConfig = null;
private PartnerConfig buttonMinHeight = null;
private PartnerConfig buttonTextTypeFaceConfig = null;
+ private PartnerConfig buttonTextStyleConfig = null;
private PartnerConfig buttonRadiusConfig = null;
private PartnerConfig buttonRippleColorAlphaConfig = null;
private int partnerTheme;
@@ -164,6 +172,11 @@ public class FooterButtonPartnerConfig {
return this;
}
+ public Builder setTextStyleConfig(PartnerConfig buttonTextStyleConfig) {
+ this.buttonTextStyleConfig = buttonTextStyleConfig;
+ return this;
+ }
+
public Builder setButtonRadiusConfig(PartnerConfig buttonRadiusConfig) {
this.buttonRadiusConfig = buttonRadiusConfig;
return this;
@@ -190,6 +203,7 @@ public class FooterButtonPartnerConfig {
buttonTextSizeConfig,
buttonMinHeight,
buttonTextTypeFaceConfig,
+ buttonTextStyleConfig,
buttonRadiusConfig,
buttonRippleColorAlphaConfig);
}
diff --git a/main/java/com/google/android/setupcompat/template/FooterBarMixin.java b/main/java/com/google/android/setupcompat/template/FooterBarMixin.java
index 5852548..83eb360 100644
--- a/main/java/com/google/android/setupcompat/template/FooterBarMixin.java
+++ b/main/java/com/google/android/setupcompat/template/FooterBarMixin.java
@@ -312,6 +312,7 @@ public class FooterBarMixin implements Mixin {
.setTextSizeConfig(PartnerConfig.CONFIG_FOOTER_BUTTON_TEXT_SIZE)
.setButtonMinHeight(PartnerConfig.CONFIG_FOOTER_BUTTON_MIN_HEIGHT)
.setTextTypeFaceConfig(PartnerConfig.CONFIG_FOOTER_BUTTON_FONT_FAMILY)
+ .setTextStyleConfig(PartnerConfig.CONFIG_FOOTER_BUTTON_TEXT_STYLE)
.build();
FooterActionButton button = inflateButton(footerButton, footerButtonPartnerConfig);
@@ -369,6 +370,7 @@ public class FooterBarMixin implements Mixin {
.setTextSizeConfig(PartnerConfig.CONFIG_FOOTER_BUTTON_TEXT_SIZE)
.setButtonMinHeight(PartnerConfig.CONFIG_FOOTER_BUTTON_MIN_HEIGHT)
.setTextTypeFaceConfig(PartnerConfig.CONFIG_FOOTER_BUTTON_FONT_FAMILY)
+ .setTextStyleConfig(PartnerConfig.CONFIG_FOOTER_BUTTON_TEXT_STYLE)
.build();
FooterActionButton button = inflateButton(footerButton, footerButtonPartnerConfig);
@@ -553,7 +555,9 @@ public class FooterBarMixin implements Mixin {
updateButtonMinHeightWithPartnerConfig(
button, footerButtonPartnerConfig.getButtonMinHeightConfig());
updateButtonTypeFaceWithPartnerConfig(
- button, footerButtonPartnerConfig.getButtonTextTypeFaceConfig());
+ button,
+ footerButtonPartnerConfig.getButtonTextTypeFaceConfig(),
+ footerButtonPartnerConfig.getButtonTextStyleConfig());
updateButtonBackgroundWithPartnerConfig(
button,
footerButtonPartnerConfig.getButtonBackgroundConfig(),
@@ -598,10 +602,17 @@ public class FooterBarMixin implements Mixin {
}
private void updateButtonTypeFaceWithPartnerConfig(
- Button button, PartnerConfig buttonTextTypeFaceConfig) {
+ Button button, PartnerConfig buttonTextTypeFaceConfig, PartnerConfig buttonTextStyleConfig) {
String fontFamilyName =
PartnerConfigHelper.get(context).getString(context, buttonTextTypeFaceConfig);
- Typeface font = Typeface.create(fontFamilyName, Typeface.NORMAL);
+
+ int textStyleValue = Typeface.NORMAL;
+ if (PartnerConfigHelper.get(context).isPartnerConfigAvailable(buttonTextStyleConfig)) {
+ textStyleValue =
+ PartnerConfigHelper.get(context)
+ .getInteger(context, buttonTextStyleConfig, Typeface.NORMAL);
+ }
+ Typeface font = Typeface.create(fontFamilyName, textStyleValue);
if (font != null) {
button.setTypeface(font);
}
diff --git a/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfig.java b/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfig.java
index 77c4149..b00c278 100644
--- a/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfig.java
+++ b/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfig.java
@@ -97,6 +97,10 @@ public enum PartnerConfig {
CONFIG_FOOTER_BUTTON_TEXT_SIZE(
PartnerConfigKey.KEY_FOOTER_BUTTON_TEXT_SIZE, ResourceType.DIMENSION),
+ // The text style of footer buttons {0 = NORMAL}, {1 = BOLD}, {2 = ITALIC}, {3 = BOLD_ITALIC}
+ CONFIG_FOOTER_BUTTON_TEXT_STYLE(
+ PartnerConfigKey.KEY_FOOTER_BUTTON_TEXT_STYLE, ResourceType.INTEGER),
+
// The min height of the footer buttons
CONFIG_FOOTER_BUTTON_MIN_HEIGHT(
PartnerConfigKey.KEY_FOOTER_BUTTON_MIN_HEIGHT, ResourceType.DIMENSION),
@@ -249,6 +253,9 @@ public enum PartnerConfig {
// The minimum height of list items.
CONFIG_ITEMS_MIN_HEIGHT(PartnerConfigKey.KEY_ITEMS_MIN_HEIGHT, ResourceType.DIMENSION),
+ // The divider of list items are showing on the pages.
+ CONFIG_ITEMS_DIVIDER_SHOWN(PartnerConfigKey.KEY_ITEMS_DIVIDER_SHOWN, ResourceType.BOOL),
+
// The animation of loading screen used in those activities which is non of below type.
CONFIG_PROGRESS_ILLUSTRATION_DEFAULT(
PartnerConfigKey.KEY_PROGRESS_ILLUSTRATION_DEFAULT, ResourceType.ILLUSTRATION),
diff --git a/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfigHelper.java b/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfigHelper.java
index b5152f3..39a105e 100644
--- a/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfigHelper.java
+++ b/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfigHelper.java
@@ -62,7 +62,7 @@ public class PartnerConfigHelper {
@VisibleForTesting static Bundle suwDayNightEnabledBundle = null;
- @VisibleForTesting static Bundle applyExtendedPartnerConfigBundle = null;
+ @VisibleForTesting public static Bundle applyExtendedPartnerConfigBundle = null;
private static PartnerConfigHelper instance = null;
@@ -73,13 +73,38 @@ public class PartnerConfigHelper {
private static ContentObserver contentObserver;
+ private static int savedConfigUiMode;
+
+ private static int savedOrientation = Configuration.ORIENTATION_PORTRAIT;
+
public static synchronized PartnerConfigHelper get(@NonNull Context context) {
- if (instance == null) {
+ if (!isValidInstance(context)) {
instance = new PartnerConfigHelper(context);
}
return instance;
}
+ private static boolean isValidInstance(@NonNull Context context) {
+ Configuration currentConfig = context.getResources().getConfiguration();
+ if (instance == null) {
+ savedConfigUiMode = currentConfig.uiMode & Configuration.UI_MODE_NIGHT_MASK;
+ savedOrientation = currentConfig.orientation;
+ return false;
+ } else {
+ if (isSetupWizardDayNightEnabled(context)
+ && (currentConfig.uiMode & Configuration.UI_MODE_NIGHT_MASK) != savedConfigUiMode) {
+ savedConfigUiMode = currentConfig.uiMode & Configuration.UI_MODE_NIGHT_MASK;
+ resetInstance();
+ return false;
+ } else if (currentConfig.orientation != savedOrientation) {
+ savedOrientation = currentConfig.orientation;
+ resetInstance();
+ return false;
+ }
+ }
+ return true;
+ }
+
private PartnerConfigHelper(Context context) {
getPartnerConfigBundle(context);
diff --git a/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfigKey.java b/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfigKey.java
index 0fe2f7c..eb24acf 100644
--- a/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfigKey.java
+++ b/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfigKey.java
@@ -44,6 +44,7 @@ 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_TEXT_STYLE,
PartnerConfigKey.KEY_FOOTER_BUTTON_MIN_HEIGHT,
PartnerConfigKey.KEY_FOOTER_BUTTON_DISABLED_ALPHA,
PartnerConfigKey.KEY_FOOTER_BUTTON_DISABLED_BG_COLOR,
@@ -88,6 +89,7 @@ import java.lang.annotation.RetentionPolicy;
PartnerConfigKey.KEY_ITEMS_PADDING_TOP,
PartnerConfigKey.KEY_ITEMS_PADDING_BOTTOM,
PartnerConfigKey.KEY_ITEMS_MIN_HEIGHT,
+ PartnerConfigKey.KEY_ITEMS_DIVIDER_SHOWN,
PartnerConfigKey.KEY_PROGRESS_ILLUSTRATION_DEFAULT,
PartnerConfigKey.KEY_PROGRESS_ILLUSTRATION_ACCOUNT,
PartnerConfigKey.KEY_PROGRESS_ILLUSTRATION_CONNECTION,
@@ -169,6 +171,9 @@ public @interface PartnerConfigKey {
// Text size of the footer buttons
String KEY_FOOTER_BUTTON_TEXT_SIZE = "setup_compat_footer_button_text_size";
+ // The font face used in footer buttons {0 = NORMAL}, {1 = BOLD}, {2 = ITALIC}, {3 = BOLD_ITALIC}
+ String KEY_FOOTER_BUTTON_TEXT_STYLE = "setup_compat_footer_button_text_style";
+
// The min height of the footer buttons
String KEY_FOOTER_BUTTON_MIN_HEIGHT = "setup_compat_footer_button_min_height";
@@ -303,6 +308,9 @@ public @interface PartnerConfigKey {
// The minimum height of list items.
String KEY_ITEMS_MIN_HEIGHT = "setup_design_items_min_height";
+ // The divider of list items are showing.
+ String KEY_ITEMS_DIVIDER_SHOWN = "setup_design_items_divider_shown";
+
// The animation of loading screen used in those activities which is non of below type.
String KEY_PROGRESS_ILLUSTRATION_DEFAULT = "progress_illustration_custom_default";