summaryrefslogtreecommitdiff
path: root/main/src/com/google/android/setupdesign
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/com/google/android/setupdesign')
-rw-r--r--main/src/com/google/android/setupdesign/GlifLayout.java44
-rw-r--r--main/src/com/google/android/setupdesign/GlifListLayout.java8
-rw-r--r--main/src/com/google/android/setupdesign/GlifPreferenceLayout.java22
-rw-r--r--main/src/com/google/android/setupdesign/GlifRecyclerLayout.java8
-rw-r--r--main/src/com/google/android/setupdesign/items/DescriptionItem.java3
-rw-r--r--main/src/com/google/android/setupdesign/items/ExpandableSwitchItem.java5
-rw-r--r--main/src/com/google/android/setupdesign/items/Item.java19
-rw-r--r--main/src/com/google/android/setupdesign/template/DescriptionMixin.java29
-rw-r--r--main/src/com/google/android/setupdesign/transition/TransitionHelper.java14
-rw-r--r--main/src/com/google/android/setupdesign/util/ContentStyler.java9
-rw-r--r--main/src/com/google/android/setupdesign/util/HeaderAreaStyler.java99
-rw-r--r--main/src/com/google/android/setupdesign/util/LayoutStyler.java10
-rw-r--r--main/src/com/google/android/setupdesign/util/MessageWarning.java2
13 files changed, 192 insertions, 80 deletions
diff --git a/main/src/com/google/android/setupdesign/GlifLayout.java b/main/src/com/google/android/setupdesign/GlifLayout.java
index 19eb50a..a5aeea8 100644
--- a/main/src/com/google/android/setupdesign/GlifLayout.java
+++ b/main/src/com/google/android/setupdesign/GlifLayout.java
@@ -48,6 +48,8 @@ import com.google.android.setupdesign.template.RequireScrollMixin;
import com.google.android.setupdesign.template.ScrollViewScrollHandlingDelegate;
import com.google.android.setupdesign.util.DescriptionStyler;
import com.google.android.setupdesign.util.LayoutStyler;
+import com.google.android.setupdesign.util.MessageWarning;
+import com.google.android.setupdesign.util.PartnerStyleHelper;
/**
* Layout for the GLIF theme used in Setup Wizard for N.
@@ -138,13 +140,14 @@ public class GlifLayout extends PartnerCustomizationLayout {
View view = findManagedViewById(R.id.sud_layout_content);
if (view != null) {
// The margin of content is defined by @style/SudContentFrame. The Setupdesign library
- // cannot
- // obtain the content resource ID of the client, so the value of the content margin cannot
- // be adjusted through GlifLayout. If the margin sides are changed through the partner
- // config, it can only be based on the increased or decreased value to adjust the value of
- // pading. In this way, the value of content margin plus padding will be equal to the value
- // of partner config.
+ // cannot obtain the content resource ID of the client, so the value of the content margin
+ // cannot be adjusted through GlifLayout. If the margin sides are changed through the
+ // partner config, it can only be based on the increased or decreased value to adjust the
+ // value of pading. In this way, the value of content margin plus padding will be equal to
+ // the value of partner config.
LayoutStyler.applyPartnerCustomizationExtraPaddingStyle(view);
+
+ applyPartnerCustomizationContentPaddingStyle(view);
}
}
@@ -188,7 +191,12 @@ public class GlifLayout extends PartnerCustomizationLayout {
@Override
protected View onInflateTemplate(LayoutInflater inflater, @LayoutRes int template) {
if (template == 0) {
- template = R.layout.sud_glif_template;
+ // TODO : use "values-land-v31" folder for sud_glif_template_s directly.
+ if (MessageWarning.isAtLeastS()) {
+ template = R.layout.sud_glif_template_s;
+ } else {
+ template = R.layout.sud_glif_template;
+ }
}
return inflateTemplate(inflater, R.style.SudThemeGlif_Light, template);
}
@@ -365,4 +373,26 @@ public class GlifLayout extends PartnerCustomizationLayout {
.getColor(getContext(), PartnerConfig.CONFIG_LAYOUT_BACKGROUND_COLOR);
this.getRootView().setBackgroundColor(color);
}
+
+ @TargetApi(VERSION_CODES.JELLY_BEAN_MR1)
+ private static void applyPartnerCustomizationContentPaddingStyle(View view) {
+ Context context = view.getContext();
+ boolean partnerPaddingTopAvailable =
+ PartnerConfigHelper.get(context)
+ .isPartnerConfigAvailable(PartnerConfig.CONFIG_CONTENT_PADDING_TOP);
+
+ if (PartnerStyleHelper.shouldApplyPartnerHeavyThemeResource(view)
+ && PartnerConfigHelper.shouldApplyExtendedPartnerConfig(context)
+ && partnerPaddingTopAvailable) {
+ int paddingTop =
+ (int)
+ PartnerConfigHelper.get(context)
+ .getDimension(context, PartnerConfig.CONFIG_CONTENT_PADDING_TOP);
+
+ if (paddingTop != view.getPaddingTop()) {
+ view.setPadding(
+ view.getPaddingStart(), paddingTop, view.getPaddingEnd(), view.getPaddingBottom());
+ }
+ }
+ }
}
diff --git a/main/src/com/google/android/setupdesign/GlifListLayout.java b/main/src/com/google/android/setupdesign/GlifListLayout.java
index 31335cc..15aa14b 100644
--- a/main/src/com/google/android/setupdesign/GlifListLayout.java
+++ b/main/src/com/google/android/setupdesign/GlifListLayout.java
@@ -29,6 +29,7 @@ import android.widget.ListView;
import com.google.android.setupdesign.template.ListMixin;
import com.google.android.setupdesign.template.ListViewScrollHandlingDelegate;
import com.google.android.setupdesign.template.RequireScrollMixin;
+import com.google.android.setupdesign.util.MessageWarning;
/**
* A GLIF themed layout with a ListView. {@code android:entries} can also be used to specify an
@@ -80,7 +81,12 @@ public class GlifListLayout extends GlifLayout {
@Override
protected View onInflateTemplate(LayoutInflater inflater, int template) {
if (template == 0) {
- template = R.layout.sud_glif_list_template;
+ // TODO : use "values-land-v31" folder for sud_glif_list_template_s directly.
+ if (MessageWarning.isAtLeastS()) {
+ template = R.layout.sud_glif_list_template_s;
+ } else {
+ template = R.layout.sud_glif_list_template;
+ }
}
return super.onInflateTemplate(inflater, template);
}
diff --git a/main/src/com/google/android/setupdesign/GlifPreferenceLayout.java b/main/src/com/google/android/setupdesign/GlifPreferenceLayout.java
index f235442..166254c 100644
--- a/main/src/com/google/android/setupdesign/GlifPreferenceLayout.java
+++ b/main/src/com/google/android/setupdesign/GlifPreferenceLayout.java
@@ -24,6 +24,7 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.google.android.setupdesign.template.RecyclerMixin;
+import com.google.android.setupdesign.util.MessageWarning;
/**
* A layout to be used with {@code PreferenceFragment} in v14 support library. This can be specified
@@ -98,7 +99,13 @@ public class GlifPreferenceLayout extends GlifRecyclerLayout {
@Override
protected View onInflateTemplate(LayoutInflater inflater, int template) {
if (template == 0) {
- template = R.layout.sud_glif_preference_template;
+ // TODO : use "values-land-v31" folder for sud_glif_preference_template_s
+ // directly.
+ if (MessageWarning.isAtLeastS()) {
+ template = R.layout.sud_glif_preference_template_s;
+ } else {
+ template = R.layout.sud_glif_preference_template;
+ }
}
return super.onInflateTemplate(inflater, template);
}
@@ -108,8 +115,17 @@ public class GlifPreferenceLayout extends GlifRecyclerLayout {
// Inflate the recycler view here, so attributes on the decoration views can be applied
// immediately.
final LayoutInflater inflater = LayoutInflater.from(getContext());
- RecyclerView recyclerView =
- (RecyclerView) inflater.inflate(R.layout.sud_glif_preference_recycler_view, this, false);
+ RecyclerView recyclerView;
+ // TODO : use "layout-land-v31" folder for sud_glif_preference_recycler_view
+ // directly.
+ if (MessageWarning.isAtLeastS()) {
+ recyclerView =
+ (RecyclerView)
+ inflater.inflate(R.layout.sud_glif_preference_recycler_view_s, this, false);
+ } else {
+ recyclerView =
+ (RecyclerView) inflater.inflate(R.layout.sud_glif_preference_recycler_view, this, false);
+ }
recyclerMixin = new RecyclerMixin(this, recyclerView);
}
}
diff --git a/main/src/com/google/android/setupdesign/GlifRecyclerLayout.java b/main/src/com/google/android/setupdesign/GlifRecyclerLayout.java
index c74cff0..06c34bb 100644
--- a/main/src/com/google/android/setupdesign/GlifRecyclerLayout.java
+++ b/main/src/com/google/android/setupdesign/GlifRecyclerLayout.java
@@ -30,6 +30,7 @@ import android.view.ViewGroup;
import com.google.android.setupdesign.template.RecyclerMixin;
import com.google.android.setupdesign.template.RecyclerViewScrollHandlingDelegate;
import com.google.android.setupdesign.template.RequireScrollMixin;
+import com.google.android.setupdesign.util.MessageWarning;
/**
* A GLIF themed layout with a RecyclerView. {@code android:entries} can also be used to specify an
@@ -81,7 +82,12 @@ public class GlifRecyclerLayout extends GlifLayout {
@Override
protected View onInflateTemplate(LayoutInflater inflater, int template) {
if (template == 0) {
- template = R.layout.sud_glif_recycler_template;
+ // TODO : use "values-land-v31" folder for sud_glif_recycler_template_s directly.
+ if (MessageWarning.isAtLeastS()) {
+ template = R.layout.sud_glif_recycler_template_s;
+ } else {
+ template = R.layout.sud_glif_recycler_template;
+ }
}
return super.onInflateTemplate(inflater, template);
}
diff --git a/main/src/com/google/android/setupdesign/items/DescriptionItem.java b/main/src/com/google/android/setupdesign/items/DescriptionItem.java
index 509ddcb..36ccfb9 100644
--- a/main/src/com/google/android/setupdesign/items/DescriptionItem.java
+++ b/main/src/com/google/android/setupdesign/items/DescriptionItem.java
@@ -29,7 +29,10 @@ import com.google.android.setupdesign.util.DescriptionStyler;
/**
* Definition of an item in an {@link ItemHierarchy}. An item is usually defined in XML and inflated
* using {@link ItemInflater}.
+ *
+ * @deprecated Use {@link com.google.android.setupdesign.template.DescriptionMixin} instead.
*/
+@Deprecated
public class DescriptionItem extends Item {
private boolean partnerDescriptionHeavyStyle = false;
diff --git a/main/src/com/google/android/setupdesign/items/ExpandableSwitchItem.java b/main/src/com/google/android/setupdesign/items/ExpandableSwitchItem.java
index 78cf0a9..29eaf23 100644
--- a/main/src/com/google/android/setupdesign/items/ExpandableSwitchItem.java
+++ b/main/src/com/google/android/setupdesign/items/ExpandableSwitchItem.java
@@ -36,7 +36,6 @@ import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.TextView;
import com.google.android.setupdesign.R;
import com.google.android.setupdesign.util.LayoutStyler;
-import com.google.android.setupdesign.util.PartnerStyleHelper;
import com.google.android.setupdesign.view.CheckableLinearLayout;
/**
@@ -182,9 +181,7 @@ public class ExpandableSwitchItem extends SwitchItem
// switch on the right, but not the item itself.
view.setFocusable(false);
- if (PartnerStyleHelper.shouldApplyPartnerHeavyThemeResource(view)) {
- LayoutStyler.applyPartnerCustomizationLayoutPaddingStyle(content);
- }
+ LayoutStyler.applyPartnerCustomizationLayoutPaddingStyle(content);
}
@Override
diff --git a/main/src/com/google/android/setupdesign/items/Item.java b/main/src/com/google/android/setupdesign/items/Item.java
index d3e6a8c..fd3f2eb 100644
--- a/main/src/com/google/android/setupdesign/items/Item.java
+++ b/main/src/com/google/android/setupdesign/items/Item.java
@@ -32,7 +32,6 @@ import androidx.annotation.Nullable;
import com.google.android.setupdesign.R;
import com.google.android.setupdesign.util.ItemStyler;
import com.google.android.setupdesign.util.LayoutStyler;
-import com.google.android.setupdesign.util.PartnerStyleHelper;
/**
* Definition of an item in an {@link ItemHierarchy}. An item is usually defined in XML and inflated
@@ -204,17 +203,15 @@ public class Item extends AbstractItem {
view.setId(getViewId());
- if (PartnerStyleHelper.shouldApplyPartnerHeavyThemeResource(view)) {
- // ExpandableSwitchItem uses its child view to apply the style SudItemContainer. It is not
- // possible to directly adjust the padding start/end of the item's layout here. It needs to
- // get its child view to adjust it first, so skip the Layout padding adjustment.
- // If the item view is a header layout, it doesn't need to adjust the layout padding start/end
- // here. It will be adjusted by HeaderMixin.
- if (!(this instanceof ExpandableSwitchItem) && view.getId() != R.id.sud_layout_header) {
- LayoutStyler.applyPartnerCustomizationLayoutPaddingStyle(view);
- }
- ItemStyler.applyPartnerCustomizationItemStyle(view);
+ // ExpandableSwitchItem uses its child view to apply the style SudItemContainer. It is not
+ // possible to directly adjust the padding start/end of the item's layout here. It needs to
+ // get its child view to adjust it first, so skip the Layout padding adjustment.
+ // If the item view is a header layout, it doesn't need to adjust the layout padding start/end
+ // here. It will be adjusted by HeaderMixin.
+ if (!(this instanceof ExpandableSwitchItem) && view.getId() != R.id.sud_layout_header) {
+ LayoutStyler.applyPartnerCustomizationLayoutPaddingStyle(view);
}
+ ItemStyler.applyPartnerCustomizationItemStyle(view);
}
/**
diff --git a/main/src/com/google/android/setupdesign/template/DescriptionMixin.java b/main/src/com/google/android/setupdesign/template/DescriptionMixin.java
index b78ee1f..983274f 100644
--- a/main/src/com/google/android/setupdesign/template/DescriptionMixin.java
+++ b/main/src/com/google/android/setupdesign/template/DescriptionMixin.java
@@ -16,10 +16,12 @@
package com.google.android.setupdesign.template;
+import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.View;
+import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.AttrRes;
import androidx.annotation.NonNull;
@@ -157,4 +159,31 @@ public class DescriptionMixin implements Mixin {
final TextView titleView = getTextView();
return titleView != null ? titleView.getTextColors() : null;
}
+
+ /**
+ * Call this method ONLY when a layout migrates from {@link
+ * com.google.android.setupdesign.items.DescriptionItem} to {@link DescriptionMixin}.
+ *
+ * <p>If a screen is migrated from {@link com.google.android.setupdesign.items.DescriptionItem} it
+ * will looks slightly different from the original UI. This method helps keeping the UI consistent
+ * with the original UI.
+ */
+ public void adjustLegacyDescriptionItem() {
+ final TextView titleView = getTextView();
+ final Context context = titleView.getContext();
+
+ final ViewGroup.LayoutParams lp = titleView.getLayoutParams();
+ if (lp instanceof ViewGroup.MarginLayoutParams) {
+ final ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) lp;
+ int extraBottomMargin =
+ (int) context.getResources().getDimension(R.dimen.sud_description_margin_bottom_extra);
+ int extraTopMargin =
+ (int) context.getResources().getDimension(R.dimen.sud_description_margin_top_extra);
+ mlp.setMargins(
+ mlp.leftMargin,
+ mlp.topMargin + extraTopMargin,
+ mlp.rightMargin,
+ mlp.bottomMargin + extraBottomMargin);
+ }
+ }
}
diff --git a/main/src/com/google/android/setupdesign/transition/TransitionHelper.java b/main/src/com/google/android/setupdesign/transition/TransitionHelper.java
index 1836a11..8ce4306 100644
--- a/main/src/com/google/android/setupdesign/transition/TransitionHelper.java
+++ b/main/src/com/google/android/setupdesign/transition/TransitionHelper.java
@@ -352,6 +352,13 @@ public class TransitionHelper {
throw new IllegalArgumentException("Invalid intent=" + intent);
}
+ if ((intent.getFlags() & Intent.FLAG_ACTIVITY_NEW_TASK) == Intent.FLAG_ACTIVITY_NEW_TASK) {
+ Log.e(
+ TAG,
+ "The transition won't take effect since the WindowManager does not allow override new"
+ + " task transitions");
+ }
+
int configTransitionType =
PartnerConfigHelper.get(activity)
.getInteger(activity, PartnerConfig.CONFIG_TRANSITION_TYPE, TRANSITION_SLIDE);
@@ -389,6 +396,13 @@ public class TransitionHelper {
throw new IllegalArgumentException("Invalid intent=" + intent);
}
+ if ((intent.getFlags() & Intent.FLAG_ACTIVITY_NEW_TASK) == Intent.FLAG_ACTIVITY_NEW_TASK) {
+ Log.e(
+ TAG,
+ "The transition won't take effect since the WindowManager does not allow override new"
+ + " task transitions");
+ }
+
int configTransitionType =
PartnerConfigHelper.get(activity)
.getInteger(activity, PartnerConfig.CONFIG_TRANSITION_TYPE, TRANSITION_SLIDE);
diff --git a/main/src/com/google/android/setupdesign/util/ContentStyler.java b/main/src/com/google/android/setupdesign/util/ContentStyler.java
index 3b64fd6..185b53b 100644
--- a/main/src/com/google/android/setupdesign/util/ContentStyler.java
+++ b/main/src/com/google/android/setupdesign/util/ContentStyler.java
@@ -25,11 +25,16 @@ import com.google.android.setupdesign.util.TextViewPartnerStyler.TextPartnerConf
import java.util.Locale;
/**
- * Applies the partner style of content to the given TextView {@code contentText}. The user needs to
- * check if the {@code contentText} should apply partner heavy theme before calling this method.
+ * Applies the partner style of content to the given TextView {@code contentText}. The theme should
+ * set partner heavy theme first, and then the partner style of content would be applied. The user
+ * can also check if the {@code contentText} should apply partner heavy theme before calling this
+ * method.
*/
public final class ContentStyler {
public static void applyPartnerCustomizationStyle(TextView contentText) {
+ if (!PartnerStyleHelper.shouldApplyPartnerHeavyThemeResource(contentText)) {
+ return;
+ }
TextViewPartnerStyler.applyPartnerCustomizationStyle(
contentText,
diff --git a/main/src/com/google/android/setupdesign/util/HeaderAreaStyler.java b/main/src/com/google/android/setupdesign/util/HeaderAreaStyler.java
index efeff97..6407b5c 100644
--- a/main/src/com/google/android/setupdesign/util/HeaderAreaStyler.java
+++ b/main/src/com/google/android/setupdesign/util/HeaderAreaStyler.java
@@ -137,38 +137,45 @@ public final class HeaderAreaStyler {
}
/**
- * Applies the partner style of header area to the given layout {@code headerArea}.
+ * Applies the partner style of header area to the given layout {@code headerArea}. The theme
+ * should set partner heavy theme first, and then the partner style of header would be applied. As
+ * for the margin bottom of header, it would aslo be appied when extended parter config is
+ * enabled.
*
* @param headerArea A ViewGroup would apply the partner style of header area
*/
public static void applyPartnerCustomizationHeaderAreaStyle(ViewGroup headerArea) {
-
if (headerArea == null) {
return;
}
- Context context = headerArea.getContext();
- int color =
- PartnerConfigHelper.get(context)
- .getColor(context, PartnerConfig.CONFIG_HEADER_AREA_BACKGROUND_COLOR);
- headerArea.setBackgroundColor(color);
-
- if (PartnerConfigHelper.shouldApplyExtendedPartnerConfig(context)) {
- final ViewGroup.LayoutParams lp = headerArea.getLayoutParams();
- if (lp instanceof ViewGroup.MarginLayoutParams) {
- final ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) lp;
-
- int bottomMargin =
- (int)
- PartnerConfigHelper.get(context)
- .getDimension(context, PartnerConfig.CONFIG_HEADER_CONTAINER_MARGIN_BOTTOM);
- mlp.setMargins(mlp.leftMargin, mlp.topMargin, mlp.rightMargin, bottomMargin);
- headerArea.setLayoutParams(lp);
+ if (PartnerStyleHelper.shouldApplyPartnerHeavyThemeResource(headerArea)) {
+ Context context = headerArea.getContext();
+
+ int color =
+ PartnerConfigHelper.get(context)
+ .getColor(context, PartnerConfig.CONFIG_HEADER_AREA_BACKGROUND_COLOR);
+ headerArea.setBackgroundColor(color);
+
+ if (PartnerConfigHelper.shouldApplyExtendedPartnerConfig(context)) {
+ final ViewGroup.LayoutParams lp = headerArea.getLayoutParams();
+ if (lp instanceof ViewGroup.MarginLayoutParams) {
+ final ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) lp;
+
+ int bottomMargin =
+ (int)
+ PartnerConfigHelper.get(context)
+ .getDimension(context, PartnerConfig.CONFIG_HEADER_CONTAINER_MARGIN_BOTTOM);
+ mlp.setMargins(mlp.leftMargin, mlp.topMargin, mlp.rightMargin, bottomMargin);
+ headerArea.setLayoutParams(lp);
+ }
}
}
}
/**
- * Applies the partner style of header icon to the given {@code iconImage}.
+ * Applies the partner style of header icon to the given {@code iconImage}. The theme should set
+ * partner heavy theme and enable extended parter config first, and then the partner icon size
+ * would be applied.
*
* @param iconImage A ImageView would apply the partner style of header icon
* @param templateLayout The template containing this mixin
@@ -179,42 +186,40 @@ public final class HeaderAreaStyler {
return;
}
- if (PartnerStyleHelper.isPartnerLightThemeLayout(templateLayout)) {
+ if (PartnerStyleHelper.shouldApplyPartnerResource(templateLayout)) {
Context context = iconImage.getContext();
int gravity = PartnerStyleHelper.getLayoutGravity(context);
if (gravity != 0) {
setGravity(iconImage, gravity);
}
- if (!PartnerStyleHelper.isPartnerHeavyThemeLayout(templateLayout)
- || !PartnerConfigHelper.shouldApplyExtendedPartnerConfig(context)) {
- return;
- }
-
- final ViewGroup.LayoutParams lp = iconImage.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 (PartnerStyleHelper.shouldApplyPartnerHeavyThemeResource(iconImage)
+ && PartnerConfigHelper.shouldApplyExtendedPartnerConfig(context)) {
+ final ViewGroup.LayoutParams lp = iconImage.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);
- lp.height =
- (int)
- PartnerConfigHelper.get(context)
- .getDimension(context, PartnerConfig.CONFIG_ICON_SIZE);
- lp.width = LayoutParams.WRAP_CONTENT;
- iconImage.setScaleType(ScaleType.FIT_CENTER);
+ lp.height =
+ (int)
+ PartnerConfigHelper.get(context)
+ .getDimension(context, PartnerConfig.CONFIG_ICON_SIZE);
+ lp.width = LayoutParams.WRAP_CONTENT;
+ iconImage.setScaleType(ScaleType.FIT_CENTER);
+ }
}
}
}
diff --git a/main/src/com/google/android/setupdesign/util/LayoutStyler.java b/main/src/com/google/android/setupdesign/util/LayoutStyler.java
index 97596e1..c18e0d1 100644
--- a/main/src/com/google/android/setupdesign/util/LayoutStyler.java
+++ b/main/src/com/google/android/setupdesign/util/LayoutStyler.java
@@ -33,7 +33,9 @@ import com.google.android.setupdesign.R;
public final class LayoutStyler {
/**
- * Applies the partner layout padding style to the given view {@code view}.
+ * Applies the partner layout padding style to the given view {@code view}. The theme should set
+ * partner heavy theme and enable extended parter config first, and then the partner layout style
+ * would be applied.
*
* @param view A view would be applied partner layout padding style
*/
@@ -51,7 +53,8 @@ public final class LayoutStyler {
PartnerConfigHelper.get(context)
.isPartnerConfigAvailable(PartnerConfig.CONFIG_LAYOUT_MARGIN_END);
- if (PartnerConfigHelper.shouldApplyExtendedPartnerConfig(context)
+ if (PartnerStyleHelper.shouldApplyPartnerHeavyThemeResource(view)
+ && PartnerConfigHelper.shouldApplyExtendedPartnerConfig(context)
&& (partnerMarginStartAvailable || partnerMarginEndAvailable)) {
int paddingStart;
int paddingEnd;
@@ -100,7 +103,8 @@ public final class LayoutStyler {
PartnerConfigHelper.get(context)
.isPartnerConfigAvailable(PartnerConfig.CONFIG_LAYOUT_MARGIN_END);
- if (PartnerConfigHelper.shouldApplyExtendedPartnerConfig(context)
+ if (PartnerStyleHelper.shouldApplyPartnerHeavyThemeResource(view)
+ && PartnerConfigHelper.shouldApplyExtendedPartnerConfig(context)
&& (partnerMarginStartAvailable || partnerMarginEndAvailable)) {
int extraPaddingStart;
int extraPaddingEnd;
diff --git a/main/src/com/google/android/setupdesign/util/MessageWarning.java b/main/src/com/google/android/setupdesign/util/MessageWarning.java
index e98eb52..ca9a93b 100644
--- a/main/src/com/google/android/setupdesign/util/MessageWarning.java
+++ b/main/src/com/google/android/setupdesign/util/MessageWarning.java
@@ -35,7 +35,7 @@ public final class MessageWarning {
}
}
- private static boolean isAtLeastS() {
+ public static boolean isAtLeastS() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
return false;
}