diff options
author | Setup Wizard Team <android-setup-team-eng@google.com> | 2021-11-11 15:04:23 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-11-11 15:04:23 +0000 |
commit | 3a998eb9c54393dfbb4ebc060cc1dcf36fdf43ff (patch) | |
tree | 2108b7eda24ec287d2dfb009be3899039de13230 | |
parent | dc563759678ab1cdd7e6c17e972eb03ef38a2e2c (diff) | |
parent | 53b7642562f0fb5336f922808405b34cbb59aba1 (diff) | |
download | setupcompat-3a998eb9c54393dfbb4ebc060cc1dcf36fdf43ff.tar.gz |
Import updated Android SetupCompat Library 408226794 am: 53b7642562
Original change: https://googleplex-android-review.googlesource.com/c/platform/external/setupcompat/+/16214696
Change-Id: I9ab73696591eed1754fbf6b651b91722c1e84f8a
-rw-r--r-- | main/java/com/google/android/setupcompat/template/FooterBarMixin.java | 8 | ||||
-rw-r--r-- | partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfigHelper.java | 29 |
2 files changed, 34 insertions, 3 deletions
diff --git a/main/java/com/google/android/setupcompat/template/FooterBarMixin.java b/main/java/com/google/android/setupcompat/template/FooterBarMixin.java index 33747d4..6d92c40 100644 --- a/main/java/com/google/android/setupcompat/template/FooterBarMixin.java +++ b/main/java/com/google/android/setupcompat/template/FooterBarMixin.java @@ -241,8 +241,9 @@ public class FooterBarMixin implements Mixin { return false; } // TODO: Support neutral button style in glif layout for phone and tablet + PartnerConfigHelper.get(context); return context.getResources().getConfiguration().smallestScreenWidthDp >= 600 - && PartnerConfigHelper.shouldApplyExtendedPartnerConfig(context); + && PartnerConfigHelper.isNeutralButtonStyleEnabled(context); } private View addSpace() { @@ -513,7 +514,7 @@ public class FooterBarMixin implements Mixin { boolean isLandscape = context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE; - if (isLandscape && isEvenlyWeightedButtons) { + if (isLandscape && isEvenlyWeightedButtons && isFooterButtonAlignedEnd()) { addSpace(); } @@ -530,7 +531,8 @@ public class FooterBarMixin implements Mixin { } buttonContainer.addView(tempSecondaryButton); } - if (!isFooterButtonAlignedEnd() && !isEvenlyWeightedButtons) { + if (!isFooterButtonAlignedEnd() + && (!isEvenlyWeightedButtons || (isEvenlyWeightedButtons && isLandscape))) { addSpace(); } if (tempPrimaryButton != null) { diff --git a/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfigHelper.java b/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfigHelper.java index ef39f9f..3525fa1 100644 --- a/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfigHelper.java +++ b/partnerconfig/java/com/google/android/setupcompat/partnerconfig/PartnerConfigHelper.java @@ -62,12 +62,17 @@ public class PartnerConfigHelper { @VisibleForTesting public static final String IS_DYNAMIC_COLOR_ENABLED_METHOD = "isDynamicColorEnabled"; + @VisibleForTesting + public static final String IS_NEUTRAL_BUTTON_STYLE_ENABLED_METHOD = "isNeutralButtonStyleEnabled"; + @VisibleForTesting static Bundle suwDayNightEnabledBundle = null; @VisibleForTesting public static Bundle applyExtendedPartnerConfigBundle = null; @VisibleForTesting public static Bundle applyDynamicColorBundle = null; + @VisibleForTesting public static Bundle applyNeutralButtonStyleBundle = null; + private static PartnerConfigHelper instance = null; @VisibleForTesting Bundle resultBundle = null; @@ -566,6 +571,7 @@ public class PartnerConfigHelper { suwDayNightEnabledBundle = null; applyExtendedPartnerConfigBundle = null; applyDynamicColorBundle = null; + applyNeutralButtonStyleBundle = null; } /** @@ -645,6 +651,29 @@ public class PartnerConfigHelper { && applyDynamicColorBundle.getBoolean(IS_DYNAMIC_COLOR_ENABLED_METHOD, false)); } + /** Returns true if the SetupWizard supports the neutral button style during setup flow. */ + public static boolean isNeutralButtonStyleEnabled(@NonNull Context context) { + if (applyNeutralButtonStyleBundle == null) { + try { + applyNeutralButtonStyleBundle = + context + .getContentResolver() + .call( + getContentUri(), + IS_NEUTRAL_BUTTON_STYLE_ENABLED_METHOD, + /* arg= */ null, + /* extras= */ null); + } catch (IllegalArgumentException | SecurityException exception) { + Log.w(TAG, "Neutral button style supporting status unknown; return as false."); + applyNeutralButtonStyleBundle = null; + return false; + } + } + + return (applyNeutralButtonStyleBundle != null + && applyNeutralButtonStyleBundle.getBoolean(IS_NEUTRAL_BUTTON_STYLE_ENABLED_METHOD, false)); + } + @VisibleForTesting static Uri getContentUri() { return new Uri.Builder() |