diff options
author | Setup Wizard Team <android-setup-team-eng@google.com> | 2021-03-17 15:09:32 +0800 |
---|---|---|
committer | Pasty Chang <pastychang@google.com> | 2021-03-17 07:16:47 +0000 |
commit | 6b505d9b7717dc5afd442df1b5665b6dd47df9fb (patch) | |
tree | 6ec3ca9240494f890d45de3ea8009a1441168f0b /main | |
parent | 99993f10df91c854e746d6bc7b08ffb94e991037 (diff) | |
download | setupdesign-6b505d9b7717dc5afd442df1b5665b6dd47df9fb.tar.gz |
Import updated Android Setupdesign Library 363357645
Copied from google3/third_party/java_src/android_libs/setupdesign
Test: mm
Bug: 182136477
Included changes:
- 363357645 [SetupDesign] ThemeHelper.applyTheme need to consider if ...
- 363128601 Fix exception when setDescriptionText with a invalid reso...
- 362493931 Add API to hide Header area in landscape screen
- 362449370 [GlifLoadingLayout] Fix content name incorrect, Foward AP...
- 362400099 [GlifLoadingLayout] Should check is animation still playi...
- 362261179 Update the height of footer bar and footer button in land...
- 361952275 Automated g4 rollback of changelist 361035807.
- 361499610 [GlifLoadingLayout] Add light theme customization, we sho...
- 361490731 [GlifLoadingLayout] Extract FillContentLayout maxWidth/ma...
- 361470484 Judge ui mode is night from activity resource instead of ...
- 361049392 [SetupDesign] update the command for glifv4; not removed ...
- 361035807 Use different weight values for two columns landscape lay...
PiperOrigin-RevId: 363357645
Change-Id: Ia94d4f1e7d16b20d3232ccec05b3367c38c37774
Diffstat (limited to 'main')
13 files changed, 86 insertions, 16 deletions
diff --git a/main/res/layout-land-v31/sud_glif_blank_template_content.xml b/main/res/layout-land-v31/sud_glif_blank_template_content.xml index c8e49d6..69965a0 100644 --- a/main/res/layout-land-v31/sud_glif_blank_template_content.xml +++ b/main/res/layout-land-v31/sud_glif_blank_template_content.xml @@ -28,6 +28,7 @@ android:orientation="horizontal"> <LinearLayout + android:id="@+id/suc_landscape_header_area" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" diff --git a/main/res/layout-land-v31/sud_glif_list_template_content.xml b/main/res/layout-land-v31/sud_glif_list_template_content.xml index 8352a2d..3fb76b8 100644 --- a/main/res/layout-land-v31/sud_glif_list_template_content.xml +++ b/main/res/layout-land-v31/sud_glif_list_template_content.xml @@ -28,6 +28,7 @@ android:orientation="horizontal"> <LinearLayout + android:id="@+id/suc_landscape_header_area" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" diff --git a/main/res/layout-land-v31/sud_glif_preference_template_content.xml b/main/res/layout-land-v31/sud_glif_preference_template_content.xml index 9f41222..2a60352 100644 --- a/main/res/layout-land-v31/sud_glif_preference_template_content.xml +++ b/main/res/layout-land-v31/sud_glif_preference_template_content.xml @@ -28,6 +28,7 @@ android:orientation="horizontal"> <LinearLayout + android:id="@+id/suc_landscape_header_area" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" diff --git a/main/res/layout-land-v31/sud_glif_recycler_template_content.xml b/main/res/layout-land-v31/sud_glif_recycler_template_content.xml index d89d693..7b46bc7 100644 --- a/main/res/layout-land-v31/sud_glif_recycler_template_content.xml +++ b/main/res/layout-land-v31/sud_glif_recycler_template_content.xml @@ -29,6 +29,7 @@ android:orientation="horizontal"> <LinearLayout + android:id="@+id/suc_landscape_header_area" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" diff --git a/main/res/layout-land-v31/sud_glif_template_content.xml b/main/res/layout-land-v31/sud_glif_template_content.xml index 0fab9ca..8d24b6a 100644 --- a/main/res/layout-land-v31/sud_glif_template_content.xml +++ b/main/res/layout-land-v31/sud_glif_template_content.xml @@ -28,6 +28,7 @@ android:orientation="horizontal"> <LinearLayout + android:id="@+id/suc_landscape_header_area" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" diff --git a/main/res/values-land/dimens.xml b/main/res/values-land/dimens.xml index 88a97be..1867d3b 100644 --- a/main/res/values-land/dimens.xml +++ b/main/res/values-land/dimens.xml @@ -17,6 +17,11 @@ <resources> + <!-- General --> + <dimen name="sud_glif_button_min_height">36dp</dimen> + <dimen name="sud_glif_footer_min_height">52dp</dimen> + <dimen name="sud_glif_footer_padding_vertical">0dp</dimen> + <!-- Card layout (for tablets) --> <dimen name="sud_card_title_padding_end">32dp</dimen> <dimen name="sud_card_title_padding_start">56dp</dimen> diff --git a/main/res/values/attrs.xml b/main/res/values/attrs.xml index 63125ee..bd2902c 100644 --- a/main/res/values/attrs.xml +++ b/main/res/values/attrs.xml @@ -152,6 +152,10 @@ <attr name="android:width" /> </declare-styleable> + <attr name="sudContentIllustrationMaxWidth" format="dimension" /> + <attr name="sudContentIllustrationMaxHeight" format="dimension" /> + <attr name="sudContentIllustrationPaddingTop" format="dimension" /> + <attr name="sudContentIllustrationPaddingBottom" format="dimension" /> <declare-styleable name="SudFillContentLayout"> <attr name="android:maxHeight" /> <attr name="android:maxWidth" /> diff --git a/main/res/values/dimens.xml b/main/res/values/dimens.xml index aa2c16c..57b37c0 100644 --- a/main/res/values/dimens.xml +++ b/main/res/values/dimens.xml @@ -26,6 +26,7 @@ <!-- Calculated by (sud_glif_margin_start - sud_glif_button_padding) --> <dimen name="sud_glif_button_margin_start">8dp</dimen> <dimen name="sud_glif_button_padding">16dp</dimen> + <dimen name="sud_glif_button_min_height">48dp</dimen> <!-- Negative of sud_glif_button_padding --> <dimen name="sud_glif_negative_button_padding">-16dp</dimen> <dimen name="sud_glif_footer_padding_vertical">8dp</dimen> diff --git a/main/res/values/styles.xml b/main/res/values/styles.xml index 17e31d2..70a81a8 100644 --- a/main/res/values/styles.xml +++ b/main/res/values/styles.xml @@ -55,6 +55,10 @@ <item name="sudMarginEnd">@dimen/sud_layout_margin_sides</item> <item name="sudNavBarTheme">@style/SudNavBarThemeDark</item> <item name="textAppearanceListItemSmall">@style/TextAppearance.SudItemSummary</item> + <item name="sudContentIllustrationMaxWidth">@dimen/sud_content_illustration_max_width</item> + <item name="sudContentIllustrationMaxHeight">@dimen/sud_content_illustration_max_height</item> + <item name="sudContentIllustrationPaddingTop">@dimen/sud_content_illustration_padding_vertical</item> + <item name="sudContentIllustrationPaddingBottom">@dimen/sud_content_illustration_padding_vertical</item> </style> <style name="SudThemeMaterial.Light" parent="Theme.AppCompat.Light.NoActionBar"> @@ -93,6 +97,10 @@ <item name="sudMarginEnd">@dimen/sud_layout_margin_sides</item> <item name="sudNavBarTheme">@style/SudNavBarThemeLight</item> <item name="textAppearanceListItemSmall">@style/TextAppearance.SudItemSummary</item> + <item name="sudContentIllustrationMaxWidth">@dimen/sud_content_illustration_max_width</item> + <item name="sudContentIllustrationMaxHeight">@dimen/sud_content_illustration_max_height</item> + <item name="sudContentIllustrationPaddingTop">@dimen/sud_content_illustration_padding_vertical</item> + <item name="sudContentIllustrationPaddingBottom">@dimen/sud_content_illustration_padding_vertical</item> </style> <style name="SudBaseThemeGlif" parent="Theme.AppCompat.NoActionBar"> @@ -160,6 +168,10 @@ <item name="sucFooterBarMinHeight">@dimen/sud_glif_footer_min_height</item> <item name="sucFooterButtonPaddingStart">@dimen/sud_glif_button_padding</item> <item name="sucFooterButtonPaddingEnd">@dimen/sud_glif_button_padding</item> + <item name="sudContentIllustrationMaxWidth">@dimen/sud_content_illustration_max_width</item> + <item name="sudContentIllustrationMaxHeight">@dimen/sud_content_illustration_max_height</item> + <item name="sudContentIllustrationPaddingTop">@dimen/sud_content_illustration_padding_vertical</item> + <item name="sudContentIllustrationPaddingBottom">@dimen/sud_content_illustration_padding_vertical</item> </style> <style name="SudThemeGlif" parent="SudBaseThemeGlif"/> @@ -228,6 +240,10 @@ <item name="sucFooterBarMinHeight">@dimen/sud_glif_footer_min_height</item> <item name="sucFooterButtonPaddingStart">@dimen/sud_glif_button_padding</item> <item name="sucFooterButtonPaddingEnd">@dimen/sud_glif_button_padding</item> + <item name="sudContentIllustrationMaxWidth">@dimen/sud_content_illustration_max_width</item> + <item name="sudContentIllustrationMaxHeight">@dimen/sud_content_illustration_max_height</item> + <item name="sudContentIllustrationPaddingTop">@dimen/sud_content_illustration_padding_vertical</item> + <item name="sudContentIllustrationPaddingBottom">@dimen/sud_content_illustration_padding_vertical</item> </style> <style name="SudThemeGlif.Light" parent="SudBaseThemeGlif.Light"/> @@ -385,10 +401,10 @@ <style name="SudFillContentLayout"> <item name="android:minWidth">@dimen/sud_content_illustration_min_width</item> <item name="android:minHeight">@dimen/sud_content_illustration_min_height</item> - <item name="android:maxWidth">@dimen/sud_content_illustration_max_width</item> - <item name="android:maxHeight">@dimen/sud_content_illustration_max_height</item> - <item name="android:paddingTop">@dimen/sud_content_illustration_padding_vertical</item> - <item name="android:paddingBottom">@dimen/sud_content_illustration_padding_vertical</item> + <item name="android:maxWidth">?attr/sudContentIllustrationMaxWidth</item> + <item name="android:maxHeight">?attr/sudContentIllustrationMaxHeight</item> + <item name="android:paddingTop">?attr/sudContentIllustrationPaddingTop</item> + <item name="android:paddingBottom">?attr/sudContentIllustrationPaddingBottom</item> </style> <!-- Ignore UnusedResources: used by clients --> diff --git a/main/src/com/google/android/setupdesign/GlifLayout.java b/main/src/com/google/android/setupdesign/GlifLayout.java index ac778b4..b7d19ac 100644 --- a/main/src/com/google/android/setupdesign/GlifLayout.java +++ b/main/src/com/google/android/setupdesign/GlifLayout.java @@ -22,6 +22,7 @@ import android.content.res.ColorStateList; import android.content.res.TypedArray; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; +import android.os.Build; import android.os.Build.VERSION_CODES; import android.util.AttributeSet; import android.view.LayoutInflater; @@ -35,6 +36,7 @@ import androidx.annotation.ColorInt; import androidx.annotation.LayoutRes; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.annotation.StringRes; import com.google.android.setupcompat.PartnerCustomizationLayout; import com.google.android.setupcompat.partnerconfig.PartnerConfig; import com.google.android.setupcompat.partnerconfig.PartnerConfigHelper; @@ -245,14 +247,27 @@ public class GlifLayout extends PartnerCustomizationLayout { return getMixin(DescriptionMixin.class).getTextView(); } - public void setDescriptionText(int title) { + /** + * Sets the description text and also sets the text visibility to visible. This can also be set + * via the XML attribute {@code app:sudDescriptionText}. + * + * @param title The resource ID of the text to be set as description + */ + public void setDescriptionText(@StringRes int title) { getMixin(DescriptionMixin.class).setText(title); } + /** + * Sets the description text and also sets the text visibility to visible. This can also be set + * via the XML attribute {@code app:sudDescriptionText}. + * + * @param title The text to be set as description + */ public void setDescriptionText(CharSequence title) { getMixin(DescriptionMixin.class).setText(title); } + /** Returns the current description text. */ public CharSequence getDescriptionText() { return getMixin(DescriptionMixin.class).getText(); } @@ -274,6 +289,23 @@ public class GlifLayout extends PartnerCustomizationLayout { } /** + * Sets the visibility of header area in landscape mode. These views inlcudes icon, header title + * and subtitle. It can make the content view become full screen when set false. + */ + @TargetApi(Build.VERSION_CODES.S) + public void setLandscapeHeaderAreaVisible(boolean visible) { + View view = this.findManagedViewById(R.id.suc_landscape_header_area); + if (view == null) { + return; + } + if (visible) { + view.setVisibility(View.VISIBLE); + } else { + view.setVisibility(View.GONE); + } + } + + /** * Sets the primary color of this layout, which will be used to determine the color of the * progress bar and the background pattern. */ diff --git a/main/src/com/google/android/setupdesign/template/DescriptionMixin.java b/main/src/com/google/android/setupdesign/template/DescriptionMixin.java index 983274f..bbccf82 100644 --- a/main/src/com/google/android/setupdesign/template/DescriptionMixin.java +++ b/main/src/com/google/android/setupdesign/template/DescriptionMixin.java @@ -20,12 +20,14 @@ import android.content.Context; import android.content.res.ColorStateList; import android.content.res.TypedArray; import android.util.AttributeSet; +import android.util.Log; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import androidx.annotation.AttrRes; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.annotation.StringRes; import com.google.android.setupcompat.PartnerCustomizationLayout; import com.google.android.setupcompat.internal.TemplateLayout; import com.google.android.setupcompat.template.Mixin; @@ -39,6 +41,7 @@ import com.google.android.setupdesign.util.PartnerStyleHelper; */ public class DescriptionMixin implements Mixin { + private static final String TAG = "DescriptionMixin"; private final TemplateLayout templateLayout; /** @@ -100,22 +103,24 @@ public class DescriptionMixin implements Mixin { } /** - * Sets the description text and also sets the text visibility to visble. This can also be set via - * the XML attribute {@code app:sudDescriptionText}. + * Sets the description text and also sets the text visibility to visible. This can also be set + * via the XML attribute {@code app:sudDescriptionText}. * * @param title The resource ID of the text to be set as description */ - public void setText(int title) { + public void setText(@StringRes int title) { final TextView titleView = getTextView(); - if (titleView != null) { + if (titleView != null && title != 0) { titleView.setText(title); setVisibility(View.VISIBLE); + } else { + Log.w(TAG, "Fail to set text due to either invalid resource id or text view not found."); } } /** - * Sets the description text and also sets the text visibility to visble. This can also be set via - * the XML attribute {@code app:sudDescriptionText}. + * Sets the description text and also sets the text visibility to visible. This can also be set + * via the XML attribute {@code app:sudDescriptionText}. * * @param title The text to be set as description */ diff --git a/main/src/com/google/android/setupdesign/util/ThemeHelper.java b/main/src/com/google/android/setupdesign/util/ThemeHelper.java index c45b64f..7f29c5d 100644 --- a/main/src/com/google/android/setupdesign/util/ThemeHelper.java +++ b/main/src/com/google/android/setupdesign/util/ThemeHelper.java @@ -63,14 +63,12 @@ public final class ThemeHelper { public static final String THEME_GLIF_V3_LIGHT = "glif_v3_light"; /** - * Passed in a setup wizard intent as {@link WizardManagerHelper#EXTRA_THEME}. This is the dark - * variant of the theme used in setup wizard for S. + * Placeholder, not avirailed yet. */ public static final String THEME_GLIF_V4 = "glif_v4"; /** - * Passed in a setup wizard intent as {@link WizardManagerHelper#EXTRA_THEME}. This is the default - * theme used in setup wizard for S. + * Placeholder, not avirailed yet. */ public static final String THEME_GLIF_V4_LIGHT = "glif_v4_light"; diff --git a/main/src/com/google/android/setupdesign/util/ThemeResolver.java b/main/src/com/google/android/setupdesign/util/ThemeResolver.java index e6d3967..c7a28b1 100644 --- a/main/src/com/google/android/setupdesign/util/ThemeResolver.java +++ b/main/src/com/google/android/setupdesign/util/ThemeResolver.java @@ -139,7 +139,11 @@ public class ThemeResolver { /** Reads the theme from the intent, and applies the resolved theme to the activity. */ public void applyTheme(Activity activity) { - activity.setTheme(resolve(activity.getIntent())); + activity.setTheme( + resolve( + activity.getIntent(), + /* suppressDayNight= */ WizardManagerHelper.isAnySetupWizard(activity.getIntent()) + && !ThemeHelper.isSetupWizardDayNightEnabled(activity))); } /** |