From 53b7642562f0fb5336f922808405b34cbb59aba1 Mon Sep 17 00:00:00 2001 From: Setup Wizard Team Date: Mon, 8 Nov 2021 10:22:44 +0800 Subject: Import updated Android SetupCompat Library 408226794 Copied from google3/third_party/java_src/android_libs/setupcompat Bug: 205233262 Test: mm Included changes: - 408226794 [Tablet] Add neutral button enable/disable flag - 407746786 [Tablet] Make the gravity of weight buttons control from ... PiperOrigin-RevId: 408226794 Change-Id: Idb9bf711e64956595f044d53cc527c3b7e7abcf5 --- .../setupcompat/template/FooterBarMixin.java | 8 +++--- .../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() -- cgit v1.2.3