diff options
author | Setup Wizard Team <android-setup-team-eng@google.com> | 2019-05-14 15:00:32 +0800 |
---|---|---|
committer | pastychang <pastychang@google.com> | 2019-05-14 15:19:55 +0800 |
commit | 2eb34e37de612f57f2609c8ab78e8e4e929bf313 (patch) | |
tree | b804278a8dd9c90e9cc1eebdb2ffbcb78ca51d84 /main/src | |
parent | d77ef759a65b6621e527ab528a34681df8c7e736 (diff) | |
download | setupdesign-2eb34e37de612f57f2609c8ab78e8e4e929bf313.tar.gz |
Import updated Android Setupdesign Library 248082482
Copied from google3/third_party/java_src/android_libs/setupdesign
Bug: 132366388
Bug: 132366547
Test: mm
Included changes:
- 248082482 Fix icon and header in Pattern security screen doesn't ap...
PiperOrigin-RevId: 248082482
Change-Id: I5fd6065ca6750423b134cb61ebf913ce2f444220
Diffstat (limited to 'main/src')
3 files changed, 78 insertions, 52 deletions
diff --git a/main/src/com/google/android/setupdesign/GlifLayout.java b/main/src/com/google/android/setupdesign/GlifLayout.java index 26e55d3..67be5d5 100644 --- a/main/src/com/google/android/setupdesign/GlifLayout.java +++ b/main/src/com/google/android/setupdesign/GlifLayout.java @@ -161,6 +161,8 @@ public class GlifLayout extends PartnerCustomizationLayout { DescriptionStyler.applyPartnerCustomizationStyle(description); } } + getMixin(IconMixin.class).applyPartnerCustomizationStyle(); + getMixin(HeaderMixin.class).applyPartnerCustomizationStyle(); } @Override diff --git a/main/src/com/google/android/setupdesign/template/HeaderMixin.java b/main/src/com/google/android/setupdesign/template/HeaderMixin.java index c2ad460..8e573b9 100644 --- a/main/src/com/google/android/setupdesign/template/HeaderMixin.java +++ b/main/src/com/google/android/setupdesign/template/HeaderMixin.java @@ -54,7 +54,6 @@ public class HeaderMixin implements Mixin { public HeaderMixin( @NonNull TemplateLayout layout, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) { templateLayout = layout; - final Context context = layout.getContext(); final TypedArray a = layout @@ -74,55 +73,67 @@ public class HeaderMixin implements Mixin { } a.recycle(); - - TextView header = layout.findManagedViewById(R.id.suc_layout_title); - if (header != null - && (layout instanceof GlifLayout) - && ((GlifLayout) layout).shouldApplyPartnerHeavyThemeResource()) { - applyPartnerCustomizationStyle(context, header); - } } - public void applyPartnerCustomizationStyle(Context context, TextView header) { + /** See {@link #applyPartnerCustomizationStyle(Context, TextView)}. */ + public void applyPartnerCustomizationStyle() { + final Context context = templateLayout.getContext(); + TextView header = templateLayout.findManagedViewById(R.id.suc_layout_title); + applyPartnerCustomizationStyle(context, header); + } - int textColor = - PartnerConfigHelper.get(context).getColor(context, PartnerConfig.CONFIG_HEADER_TEXT_COLOR); - if (textColor != 0) { - setTextColor(valueOf(textColor)); - } + /** + * Use the given {@code header} to apply heavy theme. If {@link + * com.google.android.setupdesign.GlifLayout#shouldApplyPartnerHeavyThemeResource()} is true, + * {@code header} can be customized style from partner configuration. + * + * @param context The context of client activity. + * @param header The icon image to use for apply heavy theme. + */ + private void applyPartnerCustomizationStyle(Context context, @Nullable TextView header) { + if (header != null + && (templateLayout instanceof GlifLayout) + && ((GlifLayout) templateLayout).shouldApplyPartnerHeavyThemeResource()) { + int textColor = + PartnerConfigHelper.get(context) + .getColor(context, PartnerConfig.CONFIG_HEADER_TEXT_COLOR); + if (textColor != 0) { + setTextColor(valueOf(textColor)); + } - float textSize = - PartnerConfigHelper.get(context) - .getDimension(context, PartnerConfig.CONFIG_HEADER_TEXT_SIZE); - if (textSize != 0) { - setTextSize(textSize); - } + float textSize = + PartnerConfigHelper.get(context) + .getDimension(context, PartnerConfig.CONFIG_HEADER_TEXT_SIZE); + if (textSize != 0) { + setTextSize(textSize); + } - String fontFamily = - PartnerConfigHelper.get(context) - .getString(context, PartnerConfig.CONFIG_HEADER_FONT_FAMILY); - if (fontFamily != null) { - setFontFamily(Typeface.create(fontFamily, Typeface.NORMAL)); - } + String fontFamily = + PartnerConfigHelper.get(context) + .getString(context, PartnerConfig.CONFIG_HEADER_FONT_FAMILY); + if (fontFamily != null) { + setFontFamily(Typeface.create(fontFamily, Typeface.NORMAL)); + } - String gravity = - PartnerConfigHelper.get(context).getString(context, PartnerConfig.CONFIG_LAYOUT_GRAVITY); - if (gravity != null) { - switch (gravity.toLowerCase(Locale.ROOT)) { - case "center": - setGravity(header, Gravity.CENTER); - break; - case "start": - setGravity(header, Gravity.START); - break; - default: // fall out + String gravity = + PartnerConfigHelper.get(context).getString(context, PartnerConfig.CONFIG_LAYOUT_GRAVITY); + if (gravity != null) { + switch (gravity.toLowerCase(Locale.ROOT)) { + case "center": + setGravity(header, Gravity.CENTER); + break; + case "start": + setGravity(header, Gravity.START); + break; + default: // fall out + } } - } - int color = - PartnerConfigHelper.get(context) - .getColor(context, PartnerConfig.CONFIG_HEADER_AREA_BACKGROUND_COLOR); - setBackgroundColor(color); + int color = + PartnerConfigHelper.get(context) + .getColor(context, PartnerConfig.CONFIG_HEADER_AREA_BACKGROUND_COLOR); + setBackgroundColor(color); + } } /** @return The TextView displaying the header. */ diff --git a/main/src/com/google/android/setupdesign/template/IconMixin.java b/main/src/com/google/android/setupdesign/template/IconMixin.java index 334d473..cfc498d 100644 --- a/main/src/com/google/android/setupdesign/template/IconMixin.java +++ b/main/src/com/google/android/setupdesign/template/IconMixin.java @@ -24,6 +24,7 @@ import android.os.Build.VERSION; import android.os.Build.VERSION_CODES; import androidx.annotation.ColorInt; import androidx.annotation.DrawableRes; +import androidx.annotation.Nullable; import android.util.AttributeSet; import android.view.View; import android.view.ViewGroup.LayoutParams; @@ -83,19 +84,31 @@ public class IconMixin implements Mixin { } a.recycle(); + } - ImageView iconImage = layout.findManagedViewById(R.id.sud_layout_icon); - if (iconImage != null - && (layout instanceof GlifLayout) - && ((GlifLayout) layout).shouldApplyPartnerHeavyThemeResource()) { - applyPartnerCustomizationStyle(context, iconImage); - } + /** See {@link #applyPartnerCustomizationStyle(Context, ImageView)}. */ + public void applyPartnerCustomizationStyle() { + final Context context = templateLayout.getContext(); + final ImageView iconImage = templateLayout.findManagedViewById(R.id.sud_layout_icon); + applyPartnerCustomizationStyle(context, iconImage); } - public void applyPartnerCustomizationStyle(Context context, ImageView iconImage) { - int gravity = PartnerStyleHelper.getLayoutGravity(context); - if (gravity != 0) { - setGravity(iconImage, gravity); + /** + * Use the given {@code iconImage} to apply heavy theme. If {@link + * com.google.android.setupdesign.GlifLayout#shouldApplyPartnerHeavyThemeResource()} is true, + * {@code iconImage} can be customized style from partner configuration. + * + * @param context The context of client activity. + * @param iconImage The icon image to use for apply heavy theme. + */ + private void applyPartnerCustomizationStyle(Context context, @Nullable ImageView iconImage) { + if (iconImage != null + && (templateLayout instanceof GlifLayout) + && ((GlifLayout) templateLayout).shouldApplyPartnerHeavyThemeResource()) { + int gravity = PartnerStyleHelper.getLayoutGravity(context); + if (gravity != 0) { + setGravity(iconImage, gravity); + } } } |