diff options
author | Setup Wizard Team <android-setup-team-eng@google.com> | 2021-06-09 14:15:41 +0800 |
---|---|---|
committer | Alex Li <alexylli@google.com> | 2021-06-10 08:36:19 +0000 |
commit | 26e5d52bfea77f4f74f123f3409d513334ea23c3 (patch) | |
tree | b38e89b258e58949fd24929016ae11ee105c8b84 /main | |
parent | a8dcfe7e54601f6c3e2870db3cbbcb5879fa831c (diff) | |
download | setupdesign-26e5d52bfea77f4f74f123f3409d513334ea23c3.tar.gz |
Import updated Android Setupdesign Library 378330318
Copied from google3/third_party/java_src/android_libs/setupdesign
Test: mm
Bug: 190562325
Included changes:
- 378330318 [DynamicColor] Changes disable text color to google gray ...
- 378131441 [BC] Do not show the "More" button if there is only 1-pag...
- 378117159 [SetupWizard] Fixes the radius was lost for datetime dial...
- 377856359 [SetupDesign] Fix the Icon size did not apply
- 377838411 Consolidate log tag of setupdesign and setupcompat library
- 377507895 [SetupDesign] Fix the icon always apply partner resource ...
- 377435955 Fix DateTime dialog color
PiperOrigin-RevId: 378330318
Change-Id: I0145292dfa064c1f79e867cc16458107c64eecf5
Diffstat (limited to 'main')
-rw-r--r-- | main/res/drawable/sud_dialog_background_dark.xml | 30 | ||||
-rw-r--r-- | main/res/drawable/sud_dialog_background_light.xml | 30 | ||||
-rw-r--r-- | main/res/values-night-v31/colors.xml | 2 | ||||
-rw-r--r-- | main/res/values-v31/colors.xml | 2 | ||||
-rw-r--r-- | main/res/values-v31/styles.xml | 16 | ||||
-rw-r--r-- | main/res/values/colors.xml | 2 | ||||
-rw-r--r-- | main/res/values/styles.xml | 4 | ||||
-rw-r--r-- | main/src/com/google/android/setupdesign/template/IconMixin.java | 9 | ||||
-rw-r--r-- | main/src/com/google/android/setupdesign/util/HeaderAreaStyler.java | 72 | ||||
-rw-r--r-- | main/src/com/google/android/setupdesign/util/PartnerStyleHelper.java | 5 | ||||
-rw-r--r-- | main/src/com/google/android/setupdesign/util/ThemeHelper.java | 46 | ||||
-rw-r--r-- | main/src/com/google/android/setupdesign/view/BottomScrollView.java | 1 |
12 files changed, 151 insertions, 68 deletions
diff --git a/main/res/drawable/sud_dialog_background_dark.xml b/main/res/drawable/sud_dialog_background_dark.xml new file mode 100644 index 0000000..076200d --- /dev/null +++ b/main/res/drawable/sud_dialog_background_dark.xml @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2021 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<!-- The purpose of this file is to set the radius for datetime dialog which is + copy from abc_dialog_material_background.xml of + Base.V7.Theme.AppCompat.Light.Dialog. --> +<inset xmlns:android="http://schemas.android.com/apk/res/android"> + android:insetLeft="16dp" + android:insetTop="16dp" + android:insetRight="16dp" + android:insetBottom="16dp"> + <shape android:shape="rectangle"> + <corners android:radius="@dimen/sud_glif_alert_dialog_corner_radius" /> + <solid android:color="@color/sud_glif_window_bg_dark_color" /> + </shape> +</inset> diff --git a/main/res/drawable/sud_dialog_background_light.xml b/main/res/drawable/sud_dialog_background_light.xml new file mode 100644 index 0000000..14e9418 --- /dev/null +++ b/main/res/drawable/sud_dialog_background_light.xml @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2021 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<!-- The purpose of this file is to set the radius for datetime dialog which is + copy from abc_dialog_material_background.xml of + Base.V7.Theme.AppCompat.Light.Dialog. --> +<inset xmlns:android="http://schemas.android.com/apk/res/android"> + android:insetLeft="16dp" + android:insetTop="16dp" + android:insetRight="16dp" + android:insetBottom="16dp"> + <shape android:shape="rectangle"> + <corners android:radius="@dimen/sud_glif_alert_dialog_corner_radius" /> + <solid android:color="@color/sud_glif_window_bg_light_color" /> + </shape> +</inset> diff --git a/main/res/values-night-v31/colors.xml b/main/res/values-night-v31/colors.xml index 7aee45c..f929595 100644 --- a/main/res/values-night-v31/colors.xml +++ b/main/res/values-night-v31/colors.xml @@ -25,7 +25,7 @@ <color name="sud_system_tertiary_text_inactive">@color/sud_system_neutral2_400</color> <color name="sud_system_error_warning">@color/sud_error_warning_default_dark</color> <color name="sud_system_background_surface">@color/sud_system_neutral1_900</color> - <color name="sud_system_accent_icon_text_button">@color/sud_system_accent1_200</color> + <color name="sud_system_accent_icon_text_button">@color/sud_system_accent1_100</color> <color name="sud_system_button_surface">@color/sud_system_accent1_100</color> <color name="sud_system_button_text">@color/sud_system_neutral1_900</color> <color name="sud_system_dividing_line">@color/sud_system_neutral2_300</color> diff --git a/main/res/values-v31/colors.xml b/main/res/values-v31/colors.xml index c3c6ab5..91587ee 100644 --- a/main/res/values-v31/colors.xml +++ b/main/res/values-v31/colors.xml @@ -24,7 +24,7 @@ <!-- Accent color --> <color name="sud_dynamic_color_accent_glif_v3">@color/sud_dynamic_color_accent_glif_v3_light</color> - <color name="sud_dynamic_color_accent_glif_v3_dark">@color/sud_system_accent1_200</color> + <color name="sud_dynamic_color_accent_glif_v3_dark">@color/sud_system_accent1_100</color> <color name="sud_dynamic_color_accent_glif_v3_light">@color/sud_system_accent1_600</color> diff --git a/main/res/values-v31/styles.xml b/main/res/values-v31/styles.xml index 0b7de5b..b088f78 100644 --- a/main/res/values-v31/styles.xml +++ b/main/res/values-v31/styles.xml @@ -16,10 +16,13 @@ --> <resources> + <!-- Main theme for dynamic color --> <style name="SudDynamicColorThemeGlifV3" parent="SudThemeGlifV3"> <item name="colorAccent">@color/sud_dynamic_color_accent_glif_v3_dark</item> <item name="android:textColorLink">@color/sud_dynamic_color_accent_glif_v3_dark</item> <item name="alertDialogTheme">@style/SudDynamicColorAlertDialogThemeCompat</item> + <item name="android:datePickerDialogTheme">@style/SudDynamicColorDateTimePickerDialogTheme</item> + <item name="android:timePickerDialogTheme">@style/SudDynamicColorDateTimePickerDialogTheme</item> <item name="sucFullDynamicColor">false</item> </style> @@ -27,6 +30,8 @@ <item name="colorAccent">@color/sud_dynamic_color_accent_glif_v3_light</item> <item name="android:textColorLink">@color/sud_dynamic_color_accent_glif_v3_light</item> <item name="alertDialogTheme">@style/SudDynamicColorAlertDialogThemeCompat.Light</item> + <item name="android:datePickerDialogTheme">@style/SudDynamicColorDateTimePickerDialogTheme.Light</item> + <item name="android:timePickerDialogTheme">@style/SudDynamicColorDateTimePickerDialogTheme.Light</item> <item name="sucFullDynamicColor">false</item> </style> @@ -79,7 +84,7 @@ <item name="sucFullDynamicColor">true</item> </style> - + <!-- Dynamic color theme for alert dialog --> <style name="SudDynamicColorAlertDialogThemeCompat" parent="Theme.AppCompat.Dialog.Alert"> <item name="android:textAllCaps">false</item> <item name="android:colorBackground">@color/sud_glif_v3_dialog_background_color_dark</item> @@ -101,4 +106,13 @@ <item name="android:colorBackground">@color/sud_system_neutral1_50</item> </style> + <!-- Dynamic color theme for date time dialog --> + <style name="SudDynamicColorDateTimePickerDialogTheme" parent="SudDateTimePickerDialogTheme"> + <item name="colorAccent">@color/sud_dynamic_color_accent_glif_v3_dark</item> + </style> + + <style name="SudDynamicColorDateTimePickerDialogTheme.Light" parent="SudDateTimePickerDialogTheme.Light"> + <item name="colorAccent">@color/sud_dynamic_color_accent_glif_v3_light</item> + </style> + </resources> diff --git a/main/res/values/colors.xml b/main/res/values/colors.xml index 7c27547..798abc9 100644 --- a/main/res/values/colors.xml +++ b/main/res/values/colors.xml @@ -124,7 +124,7 @@ <color name="sud_inactive_default_dark">#5F6368</color> - <color name="sud_inactive_default_light">#DADCE0</color> + <color name="sud_inactive_default_light">#9AA0A6</color> <color name="sud_error_warning_default_dark">#EE675C</color> diff --git a/main/res/values/styles.xml b/main/res/values/styles.xml index 04555c0..4725735 100644 --- a/main/res/values/styles.xml +++ b/main/res/values/styles.xml @@ -800,14 +800,14 @@ <item name="android:textAllCaps">false</item> <item name="colorAccent">@color/sud_color_accent_glif_v3_dark</item> <item name="dialogCornerRadius">@dimen/sud_glif_alert_dialog_corner_radius</item> - <item name="android:windowBackground">@color/sud_glif_window_bg_dark_color</item> + <item name="android:windowBackground">@drawable/sud_dialog_background_dark</item> </style> <style name="SudDateTimePickerDialogTheme.Light" parent="Theme.AppCompat.Light.Dialog"> <item name="android:textAllCaps">false</item> <item name="colorAccent">@color/sud_color_accent_glif_v3_light</item> <item name="dialogCornerRadius">@dimen/sud_glif_alert_dialog_corner_radius</item> - <item name="android:windowBackground">@color/sud_glif_window_bg_light_color</item> + <item name="android:windowBackground">@drawable/sud_dialog_background_light</item> </style> <style name="SudSwitchBarStyle"> diff --git a/main/src/com/google/android/setupdesign/template/IconMixin.java b/main/src/com/google/android/setupdesign/template/IconMixin.java index 1b2fbbf..75e624a 100644 --- a/main/src/com/google/android/setupdesign/template/IconMixin.java +++ b/main/src/com/google/android/setupdesign/template/IconMixin.java @@ -33,6 +33,7 @@ import com.google.android.setupcompat.internal.TemplateLayout; import com.google.android.setupcompat.template.Mixin; import com.google.android.setupdesign.R; import com.google.android.setupdesign.util.HeaderAreaStyler; +import com.google.android.setupdesign.util.PartnerStyleHelper; /** * A {@link com.google.android.setupcompat.template.Mixin} for setting an icon on the template @@ -91,7 +92,13 @@ public class IconMixin implements Mixin { /** Tries to apply the partner customization to the header icon. */ public void tryApplyPartnerCustomizationStyle() { - HeaderAreaStyler.applyPartnerCustomizationIconStyle(getView(), getContainerView()); + if (PartnerStyleHelper.isPartnerHeavyThemeLayout(templateLayout)) { + // apply partner heavy configs + HeaderAreaStyler.applyPartnerCustomizationIconStyle(getView(), getContainerView()); + } else if (PartnerStyleHelper.isPartnerLightThemeLayout(templateLayout)) { + // apply partner light configs + HeaderAreaStyler.applyPartnerCustomizationIconStyle(getView()); + } } /** diff --git a/main/src/com/google/android/setupdesign/util/HeaderAreaStyler.java b/main/src/com/google/android/setupdesign/util/HeaderAreaStyler.java index 44a7d49..1b3daac 100644 --- a/main/src/com/google/android/setupdesign/util/HeaderAreaStyler.java +++ b/main/src/com/google/android/setupdesign/util/HeaderAreaStyler.java @@ -180,8 +180,8 @@ public final class HeaderAreaStyler { } /** - * Applies the partner style of header icon to the given {@code iconImage}. The theme should set - * partner heavy theme first, and then the partner icon size would be applied. + * Applies the partner heavy style of header icon to the given {@code iconImage}. The theme should + * check partner heavy theme first, and then the partner icon size would be applied. * * @param iconImage A ImageView would apply the partner style of header icon * @param iconContainer The container of the header icon @@ -192,41 +192,47 @@ public final class HeaderAreaStyler { return; } - if (PartnerStyleHelper.shouldApplyPartnerResource(iconImage)) { - Context context = iconImage.getContext(); - int gravity = PartnerStyleHelper.getLayoutGravity(context); - if (gravity != 0) { - setGravity(iconImage, gravity); - } + Context context = iconImage.getContext(); + int gravity = PartnerStyleHelper.getLayoutGravity(context); + if (gravity != 0) { + setGravity(iconImage, gravity); + } - if (PartnerStyleHelper.shouldApplyPartnerHeavyThemeResource(iconContainer)) { - final ViewGroup.LayoutParams lp = iconContainer.getLayoutParams(); - boolean partnerConfigAvailable = - PartnerConfigHelper.get(context) - .isPartnerConfigAvailable(PartnerConfig.CONFIG_ICON_MARGIN_TOP); - if (partnerConfigAvailable && lp instanceof ViewGroup.MarginLayoutParams) { - final ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) lp; - int topMargin = - (int) - PartnerConfigHelper.get(context) - .getDimension(context, PartnerConfig.CONFIG_ICON_MARGIN_TOP); - mlp.setMargins(mlp.leftMargin, topMargin, mlp.rightMargin, mlp.bottomMargin); - } + final ViewGroup.LayoutParams lp = iconContainer.getLayoutParams(); + boolean partnerConfigAvailable = + PartnerConfigHelper.get(context) + .isPartnerConfigAvailable(PartnerConfig.CONFIG_ICON_MARGIN_TOP); + if (partnerConfigAvailable && lp instanceof ViewGroup.MarginLayoutParams) { + final ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) lp; + int topMargin = + (int) + PartnerConfigHelper.get(context) + .getDimension(context, PartnerConfig.CONFIG_ICON_MARGIN_TOP); + mlp.setMargins(mlp.leftMargin, topMargin, mlp.rightMargin, mlp.bottomMargin); + } - if (PartnerConfigHelper.get(context) - .isPartnerConfigAvailable(PartnerConfig.CONFIG_ICON_SIZE)) { + if (PartnerConfigHelper.get(context).isPartnerConfigAvailable(PartnerConfig.CONFIG_ICON_SIZE)) { - checkImageType(iconImage); + checkImageType(iconImage); - final ViewGroup.LayoutParams lpIcon = iconImage.getLayoutParams(); - lpIcon.height = - (int) - PartnerConfigHelper.get(context) - .getDimension(context, PartnerConfig.CONFIG_ICON_SIZE); - lpIcon.width = LayoutParams.WRAP_CONTENT; - iconImage.setScaleType(ScaleType.FIT_CENTER); - } - } + final ViewGroup.LayoutParams lpIcon = iconImage.getLayoutParams(); + lpIcon.height = + (int) + PartnerConfigHelper.get(context) + .getDimension(context, PartnerConfig.CONFIG_ICON_SIZE); + lpIcon.width = LayoutParams.WRAP_CONTENT; + iconImage.setScaleType(ScaleType.FIT_CENTER); + } + } + + /** Applies the partner light style of header icon to the given {@code iconImage}. */ + public static void applyPartnerCustomizationIconStyle(@Nullable ImageView iconImage) { + if (iconImage == null) { + return; + } + int gravity = PartnerStyleHelper.getLayoutGravity(iconImage.getContext()); + if (gravity != 0) { + setGravity(iconImage, gravity); } } diff --git a/main/src/com/google/android/setupdesign/util/PartnerStyleHelper.java b/main/src/com/google/android/setupdesign/util/PartnerStyleHelper.java index d99f724..78900b1 100644 --- a/main/src/com/google/android/setupdesign/util/PartnerStyleHelper.java +++ b/main/src/com/google/android/setupdesign/util/PartnerStyleHelper.java @@ -74,7 +74,7 @@ public final class PartnerStyleHelper { * Returns if the current layout/activity of the given {@code view} applies partner customized * configurations or not. * - * @param view A view would be used to get the activity and context. + * @param view A PartnerCustomizationLayout view, would be used to get the activity and context. */ public static boolean shouldApplyPartnerResource(View view) { if (view == null) { @@ -159,7 +159,7 @@ public final class PartnerStyleHelper { /** * Returns if the current layout/activity applies dynamic color configurations or not. * - * @param view A view would be used to get the activity and context. + * @param view A GlifLayout view would be used to get the activity and context. */ public static boolean useDynamicColor(View view) { if (view == null) { @@ -198,6 +198,7 @@ public final class PartnerStyleHelper { if (activity == null) { return null; } + // This only worked after activity setContentView, otherwise it will return null View rootView = activity.findViewById(R.id.suc_layout_status); return rootView != null ? (TemplateLayout) rootView.getParent() : null; } diff --git a/main/src/com/google/android/setupdesign/util/ThemeHelper.java b/main/src/com/google/android/setupdesign/util/ThemeHelper.java index 91e6e07..ba2ca1d 100644 --- a/main/src/com/google/android/setupdesign/util/ThemeHelper.java +++ b/main/src/com/google/android/setupdesign/util/ThemeHelper.java @@ -20,11 +20,11 @@ import android.app.Activity; import android.content.Context; import android.content.Intent; import androidx.annotation.NonNull; -import android.util.Log; import androidx.annotation.StyleRes; import com.google.android.setupcompat.PartnerCustomizationLayout; import com.google.android.setupcompat.partnerconfig.PartnerConfigHelper; import com.google.android.setupcompat.util.BuildCompatUtils; +import com.google.android.setupcompat.util.Logger; import com.google.android.setupcompat.util.WizardManagerHelper; import com.google.android.setupdesign.R; import java.util.Objects; @@ -32,7 +32,7 @@ import java.util.Objects; /** The helper class holds the constant names of themes and util functions */ public final class ThemeHelper { - private static final String TAG = "ThemeHelper"; + private static final Logger LOG = new Logger("ThemeHelper"); /** * Passed in a setup wizard intent as {@link WizardManagerHelper#EXTRA_THEME}. This is the dark @@ -192,7 +192,7 @@ public final class ThemeHelper { try { activity = PartnerCustomizationLayout.lookupActivityFromContext(context); } catch (IllegalArgumentException ex) { - Log.e(TAG, Objects.requireNonNull(ex.getMessage())); + LOG.e(Objects.requireNonNull(ex.getMessage())); return resId; } @@ -211,30 +211,26 @@ public final class ThemeHelper { isDayNightEnabled ? R.style.SudFullDynamicColorThemeGlifV3_DayNight : R.style.SudFullDynamicColorThemeGlifV3_Light; - Log.i( - TAG, + LOG.atInfo( "Return " + (isDayNightEnabled ? "SudFullDynamicColorThemeGlifV3_DayNight" : "SudFullDynamicColorThemeGlifV3_Light")); } - if(Log.isLoggable(TAG, Log.DEBUG)) { - Log.d( - TAG, - "Gets the dynamic accentColor: [Light] " - + colorIntToHex(context, R.color.sud_dynamic_color_accent_glif_v3_light) - + ", " - + (BuildCompatUtils.isAtLeastS() - ? colorIntToHex(context, android.R.color.system_accent1_600) - : "n/a") - + ", [Dark] " - + colorIntToHex(context, R.color.sud_dynamic_color_accent_glif_v3_dark) - + ", " - + (BuildCompatUtils.isAtLeastS() - ? colorIntToHex(context, android.R.color.system_accent1_200) - : "n/a")); - } + LOG.atDebug( + "Gets the dynamic accentColor: [Light] " + + colorIntToHex(context, R.color.sud_dynamic_color_accent_glif_v3_light) + + ", " + + (BuildCompatUtils.isAtLeastS() + ? colorIntToHex(context, android.R.color.system_accent1_600) + : "n/a") + + ", [Dark] " + + colorIntToHex(context, R.color.sud_dynamic_color_accent_glif_v3_dark) + + ", " + + (BuildCompatUtils.isAtLeastS() + ? colorIntToHex(context, android.R.color.system_accent1_200) + : "n/a")); return resId; } @@ -242,12 +238,12 @@ public final class ThemeHelper { /** Returns {@code true} if the dynamic color is set. */ public static boolean trySetDynamicColor(@NonNull Context context) { if (!shouldApplyExtendedPartnerConfig(context)) { - Log.w(TAG, "SetupWizard does not supports the extended partner configs."); + LOG.w("SetupWizard does not supports the extended partner configs."); return false; } if (!isSetupWizardDynamicColorEnabled(context)) { - Log.w(TAG, "SetupWizard does not support the dynamic color or supporting status unknown."); + LOG.w("SetupWizard does not support the dynamic color or supporting status unknown."); return false; } @@ -255,7 +251,7 @@ public final class ThemeHelper { try { activity = PartnerCustomizationLayout.lookupActivityFromContext(context); } catch (IllegalArgumentException ex) { - Log.e(TAG, Objects.requireNonNull(ex.getMessage())); + LOG.e(Objects.requireNonNull(ex.getMessage())); return false; } @@ -263,7 +259,7 @@ public final class ThemeHelper { if (resId != 0) { activity.setTheme(resId); } else { - Log.w(TAG, "Error occurred on getting dynamic color theme."); + LOG.w("Error occurred on getting dynamic color theme."); return false; } diff --git a/main/src/com/google/android/setupdesign/view/BottomScrollView.java b/main/src/com/google/android/setupdesign/view/BottomScrollView.java index c376c36..a3b250d 100644 --- a/main/src/com/google/android/setupdesign/view/BottomScrollView.java +++ b/main/src/com/google/android/setupdesign/view/BottomScrollView.java @@ -68,7 +68,6 @@ public class BottomScrollView extends ScrollView { return listener; } - @VisibleForTesting public int getScrollThreshold() { return scrollThreshold; } |