diff options
author | Setup Wizard Team <android-setup-team-eng@google.com> | 2021-03-24 16:53:04 +0800 |
---|---|---|
committer | Alex Li <alexylli@google.com> | 2021-03-24 09:30:20 +0000 |
commit | 4a594ac4b3d8a13e91695bc8a4e66db99cb2c7d7 (patch) | |
tree | 4ed1683835d5eb0ab5604a94021cf85e0f08a6db | |
parent | eccac8fab947791d79ca9d4bb09103a9b5bd4b8a (diff) | |
download | setupdesign-4a594ac4b3d8a13e91695bc8a4e66db99cb2c7d7.tar.gz |
Import updated Android Setupdesign Library 364750899
Copied from google3/third_party/java_src/android_libs/setupdesign
Test: mm
Bug: 183584598
Included changes:
- 364750899 [SetupDesign][Transition] Changes the usage ActivityOptio...
- 364739100 Change the margin top for BC landscape layout.
- 364711614 Add id for the content area in landscape glif layout
- 364539233 [SetupDesign][Transition] Adds condition check in startAc...
- 364509033 [GlifLoadingLayout] Integrate subacitivty wrapper with Gl...
- 364270938 Remove the BC flag check for the new partner resource
- 364257121 [BC][Transition] Change the type of return value of Trans...
PiperOrigin-RevId: 364750899
Change-Id: I5f731eb0b0ad19b15b80c68e753586daf8348729
17 files changed, 174 insertions, 132 deletions
diff --git a/lottie_loading_layout/res/layout-land-v31/sud_glif_loading_template_content.xml b/lottie_loading_layout/res/layout-land-v31/sud_glif_loading_template_content.xml index 0e0e945..141b7f5 100644 --- a/lottie_loading_layout/res/layout-land-v31/sud_glif_loading_template_content.xml +++ b/lottie_loading_layout/res/layout-land-v31/sud_glif_loading_template_content.xml @@ -29,10 +29,10 @@ android:orientation="horizontal"> <LinearLayout - android:id="@+id/suc_landscape_header_area" + android:id="@+id/sud_landscape_header_area" android:layout_width="0dp" android:layout_height="match_parent" - android:layout_weight="1" + android:layout_weight="@dimen/sud_glif_land_header_area_weight" android:orientation="vertical"> <ViewStub @@ -54,9 +54,10 @@ </LinearLayout> <LinearLayout + android:id="@+id/sud_landscape_content_area" android:layout_width="0dp" android:layout_height="match_parent" - android:layout_weight="1" + android:layout_weight="@dimen/sud_glif_land_content_area_weight" android:orientation="vertical"> <com.google.android.setupdesign.view.BottomScrollView diff --git a/lottie_loading_layout/src/com/google/android/setupdesign/GlifLoadingLayout.java b/lottie_loading_layout/src/com/google/android/setupdesign/GlifLoadingLayout.java index f3b5b98..3078e7b 100644 --- a/lottie_loading_layout/src/com/google/android/setupdesign/GlifLoadingLayout.java +++ b/lottie_loading_layout/src/com/google/android/setupdesign/GlifLoadingLayout.java @@ -37,6 +37,7 @@ import android.view.View; import android.view.ViewGroup; import android.view.ViewStub; import android.widget.ProgressBar; +import androidx.annotation.IntDef; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.RawRes; @@ -58,6 +59,7 @@ import com.google.android.setupdesign.view.IllustrationVideoView; import java.io.InputStream; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -72,7 +74,8 @@ public class GlifLoadingLayout extends GlifLayout { @VisibleForTesting Map<KeyPath, SimpleColorFilter> customizationMap = new HashMap<>(); - @VisibleForTesting LottieAnimationFinishListener animationFinishListener; + @VisibleForTesting + public List<LottieAnimationFinishListener> animationFinishListeners = new ArrayList<>(); public GlifLoadingLayout(Context context) { this(context, 0, 0); @@ -203,15 +206,7 @@ public class GlifLoadingLayout extends GlifLayout { if (activity == null) { throw new NullPointerException("activity should not be null"); } - animationFinishListener = - new LottieAnimationFinishListener(findLottieAnimationView()) { - - @Override - void onAnimationFinished() { - activity.finish(); - removeListener(); - } - }; + registerAnimationFinishRunnable(activity::finish); } /** @@ -238,23 +233,18 @@ public class GlifLoadingLayout extends GlifLayout { throw new NullPointerException("intent should not be null"); } - animationFinishListener = - new LottieAnimationFinishListener(findLottieAnimationView()) { - @Override - void onAnimationFinished() { - if (options == null || Build.VERSION.SDK_INT < VERSION_CODES.JELLY_BEAN) { - activity.startActivity(intent); - } else { - activity.startActivity(intent, options); - } - - if (finish) { - activity.finish(); - } - - removeListener(); + registerAnimationFinishRunnable( + () -> { + if (options == null || Build.VERSION.SDK_INT < VERSION_CODES.JELLY_BEAN) { + activity.startActivity(intent); + } else { + activity.startActivity(intent, options); } - }; + + if (finish) { + activity.finish(); + } + }); } /** @@ -285,23 +275,19 @@ public class GlifLoadingLayout extends GlifLayout { throw new NullPointerException("intent should not be null"); } - animationFinishListener = - new LottieAnimationFinishListener(findLottieAnimationView()) { + new LottieAnimationFinishListener( + findLottieAnimationView(), + () -> { + if (options == null || Build.VERSION.SDK_INT < VERSION_CODES.JELLY_BEAN) { + activity.startActivityForResult(intent, requestCode); + } else { + activity.startActivityForResult(intent, requestCode, options); + } - @Override - void onAnimationFinished() { - if (options == null || Build.VERSION.SDK_INT < VERSION_CODES.JELLY_BEAN) { - activity.startActivityForResult(intent, requestCode); - } else { - activity.startActivityForResult(intent, requestCode, options); - } - - if (finish) { - activity.finish(); - } - removeListener(); + if (finish) { + activity.finish(); } - }; + }); } private void inflateLottieView() { @@ -333,6 +319,7 @@ public class GlifLoadingLayout extends GlifLayout { return; } if (customLottieResource != 0) { + InputStream inputRaw = getResources().openRawResource(customLottieResource); lottieView.setAnimation(inputRaw, null); lottieView.playAnimation(); @@ -402,6 +389,21 @@ public class GlifLoadingLayout extends GlifLayout { return findViewById(R.id.sud_lottie_view); } + private IllustrationVideoView findIllustrationVideoView() { + return findManagedViewById(R.id.sud_progress_illustration); + } + + @AnimationType + public int getAnimationType() { + if (findLottieAnimationView() != null) { + return AnimationType.LOTTIE; + } else if (findIllustrationVideoView() != null) { + return AnimationType.ILLUSTRATION; + } else { + return AnimationType.PROGRESS_BAR; + } + } + //TODO: Should add testcase with mocked LottieAnimationView. /** Add an animator listener to {@link LottieAnimationView}. */ public void addAnimatorListener(Animator.AnimatorListener listener) { @@ -566,9 +568,14 @@ public class GlifLoadingLayout extends GlifLayout { } } - @VisibleForTesting - abstract class LottieAnimationFinishListener { + public void registerAnimationFinishRunnable(Runnable runnable) { + animationFinishListeners.add( + new LottieAnimationFinishListener(findLottieAnimationView(), runnable)); + } + public static class LottieAnimationFinishListener { + + private final Runnable runnable; private final LottieAnimationView lottieAnimationView; @VisibleForTesting @@ -595,25 +602,29 @@ public class GlifLoadingLayout extends GlifLayout { } }; - private LottieAnimationFinishListener(LottieAnimationView lottieAnimationView) { + private LottieAnimationFinishListener( + LottieAnimationView lottieAnimationView, Runnable runnable) { + if (runnable == null) { + throw new NullPointerException("Runnable can not be null"); + } this.lottieAnimationView = lottieAnimationView; + this.runnable = runnable; - if (lottieAnimationView != null && lottieAnimationView.isAnimating()) { - lottieAnimationView.addAnimatorListener(animatorListener); + if (lottieAnimationView != null) { lottieAnimationView.setRepeatCount(0); + lottieAnimationView.addAnimatorListener(animatorListener); } else { onAnimationFinished(); } } - public void removeListener() { + @VisibleForTesting + public void onAnimationFinished() { + runnable.run(); if (lottieAnimationView != null) { lottieAnimationView.removeAnimatorListener(animatorListener); } - animationFinishListener = null; } - - abstract void onAnimationFinished(); } @Retention(RetentionPolicy.SOURCE) @@ -629,4 +640,12 @@ public class GlifLoadingLayout extends GlifLayout { String CONNECTION = "connection"; String UPDATE = "update"; } + + @Retention(RetentionPolicy.SOURCE) + @IntDef({AnimationType.LOTTIE, AnimationType.ILLUSTRATION, AnimationType.PROGRESS_BAR}) + public @interface AnimationType { + int LOTTIE = 1; + int ILLUSTRATION = 2; + int PROGRESS_BAR = 3; + } } 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 69965a0..9cd846d 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,10 +28,10 @@ android:orientation="horizontal"> <LinearLayout - android:id="@+id/suc_landscape_header_area" + android:id="@+id/sud_landscape_header_area" android:layout_width="0dp" android:layout_height="match_parent" - android:layout_weight="1" + android:layout_weight="@dimen/sud_glif_land_header_area_weight" android:orientation="vertical"> <ViewStub @@ -42,9 +42,10 @@ </LinearLayout> <LinearLayout + android:id="@+id/sud_landscape_content_area" android:layout_width="0dp" android:layout_height="match_parent" - android:layout_weight="1" + android:layout_weight="@dimen/sud_glif_land_content_area_weight" android:orientation="vertical"> <FrameLayout 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 3fb76b8..6f6f20e 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,10 +28,10 @@ android:orientation="horizontal"> <LinearLayout - android:id="@+id/suc_landscape_header_area" + android:id="@+id/sud_landscape_header_area" android:layout_width="0dp" android:layout_height="match_parent" - android:layout_weight="1" + android:layout_weight="@dimen/sud_glif_land_header_area_weight" android:orientation="vertical"> <ViewStub @@ -53,9 +53,10 @@ </LinearLayout> <LinearLayout + android:id="@+id/sud_landscape_content_area" android:layout_width="0dp" android:layout_height="match_parent" - android:layout_weight="1" + android:layout_weight="@dimen/sud_glif_land_content_area_weight" android:orientation="vertical"> <com.google.android.setupdesign.view.StickyHeaderListView 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 2a60352..e3a2ba5 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,10 +28,10 @@ android:orientation="horizontal"> <LinearLayout - android:id="@+id/suc_landscape_header_area" + android:id="@+id/sud_landscape_header_area" android:layout_width="0dp" android:layout_height="match_parent" - android:layout_weight="1" + android:layout_weight="@dimen/sud_glif_land_header_area_weight" android:orientation="vertical"> <ViewStub @@ -53,9 +53,10 @@ </LinearLayout> <LinearLayout + android:id="@+id/sud_landscape_content_area" android:layout_width="0dp" android:layout_height="match_parent" - android:layout_weight="1" + android:layout_weight="@dimen/sud_glif_land_content_area_weight" android:orientation="vertical"> <FrameLayout 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 7b46bc7..d7d0985 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,10 +29,10 @@ android:orientation="horizontal"> <LinearLayout - android:id="@+id/suc_landscape_header_area" + android:id="@+id/sud_landscape_header_area" android:layout_width="0dp" android:layout_height="match_parent" - android:layout_weight="1" + android:layout_weight="@dimen/sud_glif_land_header_area_weight" android:orientation="vertical"> <ViewStub @@ -54,9 +54,10 @@ </LinearLayout> <LinearLayout + android:id="@+id/sud_landscape_content_area" android:layout_width="0dp" android:layout_height="match_parent" - android:layout_weight="1" + android:layout_weight="@dimen/sud_glif_land_content_area_weight" android:orientation="vertical"> <com.google.android.setupdesign.view.HeaderRecyclerView 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 8d24b6a..5407be1 100644 --- a/main/res/layout-land-v31/sud_glif_template_content.xml +++ b/main/res/layout-land-v31/sud_glif_template_content.xml @@ -28,10 +28,10 @@ android:orientation="horizontal"> <LinearLayout - android:id="@+id/suc_landscape_header_area" + android:id="@+id/sud_landscape_header_area" android:layout_width="0dp" android:layout_height="match_parent" - android:layout_weight="1" + android:layout_weight="@dimen/sud_glif_land_header_area_weight" android:orientation="vertical"> <ViewStub @@ -53,9 +53,10 @@ </LinearLayout> <LinearLayout + android:id="@+id/sud_landscape_content_area" android:layout_width="0dp" android:layout_height="match_parent" - android:layout_weight="1" + android:layout_weight="@dimen/sud_glif_land_content_area_weight" android:orientation="vertical"> <com.google.android.setupdesign.view.BottomScrollView diff --git a/main/res/values/dimens.xml b/main/res/values/dimens.xml index 57b37c0..40fcc2a 100644 --- a/main/res/values/dimens.xml +++ b/main/res/values/dimens.xml @@ -40,6 +40,8 @@ <dimen name="sud_glif_alert_dialog_corner_radius">8dp</dimen> <dimen name="sud_glif_v3_button_corner_radius">4dp</dimen> + <dimen name="sud_glif_land_header_area_weight">1</dimen> + <dimen name="sud_glif_land_content_area_weight">1</dimen> <!-- Content styles --> <dimen name="sud_check_box_line_spacing_extra">4sp</dimen> diff --git a/main/src/com/google/android/setupdesign/GlifLayout.java b/main/src/com/google/android/setupdesign/GlifLayout.java index b7d19ac..dc84c71 100644 --- a/main/src/com/google/android/setupdesign/GlifLayout.java +++ b/main/src/com/google/android/setupdesign/GlifLayout.java @@ -151,7 +151,7 @@ public class GlifLayout extends PartnerCustomizationLayout { // the value of partner config. LayoutStyler.applyPartnerCustomizationExtraPaddingStyle(view); - applyPartnerCustomizationContentPaddingStyle(view); + applyPartnerCustomizationContentPaddingTopStyle(view); } } @@ -294,7 +294,7 @@ public class GlifLayout extends PartnerCustomizationLayout { */ @TargetApi(Build.VERSION_CODES.S) public void setLandscapeHeaderAreaVisible(boolean visible) { - View view = this.findManagedViewById(R.id.suc_landscape_header_area); + View view = this.findManagedViewById(R.id.sud_landscape_header_area); if (view == null) { return; } @@ -404,14 +404,13 @@ public class GlifLayout extends PartnerCustomizationLayout { } @TargetApi(VERSION_CODES.JELLY_BEAN_MR1) - private static void applyPartnerCustomizationContentPaddingStyle(View view) { + protected static void applyPartnerCustomizationContentPaddingTopStyle(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) diff --git a/main/src/com/google/android/setupdesign/GlifListLayout.java b/main/src/com/google/android/setupdesign/GlifListLayout.java index fba6433..740b2af 100644 --- a/main/src/com/google/android/setupdesign/GlifListLayout.java +++ b/main/src/com/google/android/setupdesign/GlifListLayout.java @@ -73,6 +73,11 @@ public class GlifListLayout extends GlifLayout { final RequireScrollMixin requireScrollMixin = getMixin(RequireScrollMixin.class); requireScrollMixin.setScrollHandlingDelegate( new ListViewScrollHandlingDelegate(requireScrollMixin, getListView())); + + View view = this.findManagedViewById(R.id.sud_landscape_content_area); + if (view != null) { + applyPartnerCustomizationContentPaddingTopStyle(view); + } } @Override diff --git a/main/src/com/google/android/setupdesign/GlifRecyclerLayout.java b/main/src/com/google/android/setupdesign/GlifRecyclerLayout.java index d96d5af..973f388 100644 --- a/main/src/com/google/android/setupdesign/GlifRecyclerLayout.java +++ b/main/src/com/google/android/setupdesign/GlifRecyclerLayout.java @@ -74,6 +74,11 @@ public class GlifRecyclerLayout extends GlifLayout { final RequireScrollMixin requireScrollMixin = getMixin(RequireScrollMixin.class); requireScrollMixin.setScrollHandlingDelegate( new RecyclerViewScrollHandlingDelegate(requireScrollMixin, getRecyclerView())); + + View view = this.findManagedViewById(R.id.sud_landscape_content_area); + if (view != null) { + applyPartnerCustomizationContentPaddingTopStyle(view); + } } @Override diff --git a/main/src/com/google/android/setupdesign/transition/TransitionHelper.java b/main/src/com/google/android/setupdesign/transition/TransitionHelper.java index ba78a54..0d76110 100644 --- a/main/src/com/google/android/setupdesign/transition/TransitionHelper.java +++ b/main/src/com/google/android/setupdesign/transition/TransitionHelper.java @@ -395,7 +395,7 @@ public class TransitionHelper { if (overrideActivityOptions != null) { bundleActivityOptions = overrideActivityOptions; } else { - bundleActivityOptions = ActivityOptions.makeSceneTransitionAnimation(activity).toBundle(); + bundleActivityOptions = makeActivityOptions(activity, intent); } intent.putExtra(EXTRA_ACTIVITY_OPTIONS, (Parcelable) bundleActivityOptions); activity.startActivity(intent, bundleActivityOptions); @@ -415,7 +415,8 @@ public class TransitionHelper { private static void startActivityWithTransitionInternal( Activity activity, Intent intent, Bundle overrideActivityOptions) { if (Build.VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) { - if (overrideActivityOptions != null) { + if (getConfigTransitionType(activity) == CONFIG_TRANSITION_SHARED_X_AXIS + && overrideActivityOptions != null) { activity.startActivity(intent, overrideActivityOptions); } else { activity.startActivity(intent); @@ -474,7 +475,7 @@ public class TransitionHelper { if (overrideActivityOptions != null) { bundleActivityOptions = overrideActivityOptions; } else { - bundleActivityOptions = ActivityOptions.makeSceneTransitionAnimation(activity).toBundle(); + bundleActivityOptions = makeActivityOptions(activity, intent); } intent.putExtra(EXTRA_ACTIVITY_OPTIONS, (Parcelable) bundleActivityOptions); activity.startActivityForResult(intent, requestCode, bundleActivityOptions); @@ -496,7 +497,8 @@ public class TransitionHelper { private static void startActivityForResultWithTransitionInternal( Activity activity, Intent intent, int requestCode, Bundle overrideActivityOptions) { if (Build.VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) { - if (overrideActivityOptions != null) { + if (getConfigTransitionType(activity) == CONFIG_TRANSITION_SHARED_X_AXIS + && overrideActivityOptions != null) { activity.startActivityForResult(intent, requestCode, overrideActivityOptions); } else { activity.startActivityForResult(intent, requestCode); diff --git a/main/src/com/google/android/setupdesign/transition/support/TransitionHelper.java b/main/src/com/google/android/setupdesign/transition/support/TransitionHelper.java index b382f93..8fd9d6e 100644 --- a/main/src/com/google/android/setupdesign/transition/support/TransitionHelper.java +++ b/main/src/com/google/android/setupdesign/transition/support/TransitionHelper.java @@ -23,7 +23,6 @@ import android.annotation.TargetApi; import android.app.Activity; import android.os.Build; import android.os.Build.VERSION_CODES; -import android.os.Bundle; import androidx.fragment.app.Fragment; import android.util.Log; import android.view.Window; @@ -104,13 +103,13 @@ public class TransitionHelper { /** * A wrapper method, create an {@link ActivityOptionsCompat} to transition between activities as * the {@link ActivityOptionsCompat} parameter of {@link - * androidx.activity.result.ActivityResultLauncher#launch} method. + * androidx.activity.result.ActivityResultLauncher#launch(I, ActivityOptionsCompat)} method. */ @Nullable - public static Bundle makeActivityOptionsCompat(Activity activity) { - Bundle resultBundle = null; + public static ActivityOptionsCompat makeActivityOptionsCompat(Activity activity) { + ActivityOptionsCompat activityOptionsCompat = null; if (activity == null) { - return resultBundle; + return activityOptionsCompat; } if (getConfigTransitionType(activity) == CONFIG_TRANSITION_SHARED_X_AXIS) { @@ -122,10 +121,10 @@ public class TransitionHelper { "The transition won't take effect due to NO FEATURE_ACTIVITY_TRANSITIONS feature"); } - resultBundle = ActivityOptionsCompat.makeSceneTransitionAnimation(activity).toBundle(); + activityOptionsCompat = ActivityOptionsCompat.makeSceneTransitionAnimation(activity); } } - return resultBundle; + return activityOptionsCompat; } } diff --git a/main/src/com/google/android/setupdesign/util/HeaderAreaStyler.java b/main/src/com/google/android/setupdesign/util/HeaderAreaStyler.java index 0ebb13d..33a4d34 100644 --- a/main/src/com/google/android/setupdesign/util/HeaderAreaStyler.java +++ b/main/src/com/google/android/setupdesign/util/HeaderAreaStyler.java @@ -145,7 +145,7 @@ public final class HeaderAreaStyler { /** * 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 + * for the margin bottom of header, it would also be appied when heavy theme parter config is * enabled. * * @param headerArea A ViewGroup would apply the partner style of header area @@ -162,7 +162,8 @@ public final class HeaderAreaStyler { .getColor(context, PartnerConfig.CONFIG_HEADER_AREA_BACKGROUND_COLOR); headerArea.setBackgroundColor(color); - if (PartnerConfigHelper.shouldApplyExtendedPartnerConfig(context)) { + if (PartnerConfigHelper.get(context) + .isPartnerConfigAvailable(PartnerConfig.CONFIG_HEADER_CONTAINER_MARGIN_BOTTOM)) { final ViewGroup.LayoutParams lp = headerArea.getLayoutParams(); if (lp instanceof ViewGroup.MarginLayoutParams) { final ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) lp; @@ -180,8 +181,7 @@ public final class HeaderAreaStyler { /** * 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. + * 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 templateLayout The template containing this mixin @@ -199,8 +199,7 @@ public final class HeaderAreaStyler { setGravity(iconImage, gravity); } - if (PartnerStyleHelper.shouldApplyPartnerHeavyThemeResource(iconImage) - && PartnerConfigHelper.shouldApplyExtendedPartnerConfig(context)) { + if (PartnerStyleHelper.shouldApplyPartnerHeavyThemeResource(iconImage)) { final ViewGroup.LayoutParams lp = iconImage.getLayoutParams(); boolean partnerConfigAvailable = PartnerConfigHelper.get(context) diff --git a/main/src/com/google/android/setupdesign/util/ItemStyler.java b/main/src/com/google/android/setupdesign/util/ItemStyler.java index 7694d38..b58945d 100644 --- a/main/src/com/google/android/setupdesign/util/ItemStyler.java +++ b/main/src/com/google/android/setupdesign/util/ItemStyler.java @@ -38,17 +38,17 @@ import com.google.android.setupdesign.R; public final class ItemStyler { /** - * Applies the extended partner configs to the given view {@code view}. The user needs to check + * Applies the heavy theme partner configs to the given view {@code view}. The user needs to check * before calling this method: * - * <p>1) If the {@code view} should apply extended partner configs by calling {@link - * ThemeHelper#shouldApplyExtendedPartnerConfig}. + * <p>1) If the {@code view} should apply heavy theme resource by calling {@link + * PartnerStyleHelper#shouldApplyPartnerHeavyThemeResource}. * * <p>2) If the layout of the {@code view} contains fixed resource IDs which attempts to apply - * extended partner resources (The resource ID of the title is "sud_items_title" and the resource - * ID of the summary is "sud_items_summary"), refer to {@link R.layout#sud_items_default}. + * heavy theme resources (The resource ID of the title is "sud_items_title" and the resource ID of + * the summary is "sud_items_summary"), refer to {@link R.layout#sud_items_default}. * - * @param view A view would be applied extended partner styles + * @param view A view would be applied heavy theme styles */ @TargetApi(VERSION_CODES.JELLY_BEAN_MR1) public static void applyPartnerCustomizationItemStyle(@Nullable View view) { @@ -58,8 +58,7 @@ public final class ItemStyler { final Context context = view.getContext(); - if (!PartnerStyleHelper.shouldApplyPartnerHeavyThemeResource(view) - || !PartnerConfigHelper.shouldApplyExtendedPartnerConfig(context)) { + if (!PartnerStyleHelper.shouldApplyPartnerHeavyThemeResource(view)) { return; } diff --git a/main/src/com/google/android/setupdesign/util/LayoutStyler.java b/main/src/com/google/android/setupdesign/util/LayoutStyler.java index 10856f7..b707521 100644 --- a/main/src/com/google/android/setupdesign/util/LayoutStyler.java +++ b/main/src/com/google/android/setupdesign/util/LayoutStyler.java @@ -34,8 +34,7 @@ public final class LayoutStyler { /** * 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. + * partner heavy theme config first, and then the partner layout style would be applied. * * @param view A view would be applied partner layout padding style */ @@ -54,7 +53,6 @@ public final class LayoutStyler { .isPartnerConfigAvailable(PartnerConfig.CONFIG_LAYOUT_MARGIN_END); if (PartnerStyleHelper.shouldApplyPartnerHeavyThemeResource(view) - && PartnerConfigHelper.shouldApplyExtendedPartnerConfig(context) && (partnerMarginStartAvailable || partnerMarginEndAvailable)) { int paddingStart; int paddingEnd; @@ -104,7 +102,6 @@ public final class LayoutStyler { .isPartnerConfigAvailable(PartnerConfig.CONFIG_LAYOUT_MARGIN_END); if (PartnerStyleHelper.shouldApplyPartnerHeavyThemeResource(view) - && PartnerConfigHelper.shouldApplyExtendedPartnerConfig(context) && (partnerMarginStartAvailable || partnerMarginEndAvailable)) { int extraPaddingStart; int extraPaddingEnd; diff --git a/main/src/com/google/android/setupdesign/util/TextViewPartnerStyler.java b/main/src/com/google/android/setupdesign/util/TextViewPartnerStyler.java index 8344692..03a1684 100644 --- a/main/src/com/google/android/setupdesign/util/TextViewPartnerStyler.java +++ b/main/src/com/google/android/setupdesign/util/TextViewPartnerStyler.java @@ -39,7 +39,9 @@ final class TextViewPartnerStyler { } Context context = textView.getContext(); - if (textPartnerConfigs.getTextColorConfig() != null) { + if (textPartnerConfigs.getTextColorConfig() != null + && PartnerConfigHelper.get(context) + .isPartnerConfigAvailable(textPartnerConfigs.getTextColorConfig())) { int textColor = PartnerConfigHelper.get(context) .getColor(context, textPartnerConfigs.getTextColorConfig()); @@ -48,7 +50,9 @@ final class TextViewPartnerStyler { } } - if (textPartnerConfigs.getTextLinkedColorConfig() != null) { + if (textPartnerConfigs.getTextLinkedColorConfig() != null + && PartnerConfigHelper.get(context) + .isPartnerConfigAvailable(textPartnerConfigs.getTextLinkedColorConfig())) { int linkTextColor = PartnerConfigHelper.get(context) .getColor(context, textPartnerConfigs.getTextLinkedColorConfig()); @@ -57,7 +61,9 @@ final class TextViewPartnerStyler { } } - if (textPartnerConfigs.getTextSizeConfig() != null) { + if (textPartnerConfigs.getTextSizeConfig() != null + && PartnerConfigHelper.get(context) + .isPartnerConfigAvailable(textPartnerConfigs.getTextSizeConfig())) { float textSize = PartnerConfigHelper.get(context) .getDimension(context, textPartnerConfigs.getTextSizeConfig(), 0); @@ -66,7 +72,9 @@ final class TextViewPartnerStyler { } } - if (textPartnerConfigs.getTextFontFamilyConfig() != null) { + if (textPartnerConfigs.getTextFontFamilyConfig() != null + && PartnerConfigHelper.get(context) + .isPartnerConfigAvailable(textPartnerConfigs.getTextFontFamilyConfig())) { String fontFamilyName = PartnerConfigHelper.get(context) .getString(context, textPartnerConfigs.getTextFontFamilyConfig()); @@ -76,34 +84,36 @@ final class TextViewPartnerStyler { } } - if (PartnerConfigHelper.shouldApplyExtendedPartnerConfig(context)) { - if (textPartnerConfigs.getTextMarginTop() != null - || textPartnerConfigs.getTextMarginBottom() != null) { - int topMargin; - int bottomMargin; - final ViewGroup.LayoutParams lp = textView.getLayoutParams(); - if (lp instanceof LinearLayout.LayoutParams) { - final LinearLayout.LayoutParams mlp = (LinearLayout.LayoutParams) lp; - if (textPartnerConfigs.getTextMarginTop() != null) { - topMargin = - (int) - PartnerConfigHelper.get(context) - .getDimension(context, textPartnerConfigs.getTextMarginTop()); - } else { - topMargin = mlp.topMargin; - } - - if (textPartnerConfigs.getTextMarginBottom() != null) { - bottomMargin = - (int) - PartnerConfigHelper.get(context) - .getDimension(context, textPartnerConfigs.getTextMarginBottom()); - } else { - bottomMargin = mlp.bottomMargin; - } - mlp.setMargins(mlp.leftMargin, topMargin, mlp.rightMargin, bottomMargin); - textView.setLayoutParams(lp); + if (textPartnerConfigs.getTextMarginTop() != null + || textPartnerConfigs.getTextMarginBottom() != null) { + int topMargin; + int bottomMargin; + final ViewGroup.LayoutParams lp = textView.getLayoutParams(); + if (lp instanceof LinearLayout.LayoutParams) { + final LinearLayout.LayoutParams mlp = (LinearLayout.LayoutParams) lp; + if (textPartnerConfigs.getTextMarginTop() != null + && PartnerConfigHelper.get(context) + .isPartnerConfigAvailable(textPartnerConfigs.getTextMarginTop())) { + topMargin = + (int) + PartnerConfigHelper.get(context) + .getDimension(context, textPartnerConfigs.getTextMarginTop()); + } else { + topMargin = mlp.topMargin; } + + if (textPartnerConfigs.getTextMarginBottom() != null + && PartnerConfigHelper.get(context) + .isPartnerConfigAvailable(textPartnerConfigs.getTextMarginBottom())) { + bottomMargin = + (int) + PartnerConfigHelper.get(context) + .getDimension(context, textPartnerConfigs.getTextMarginBottom()); + } else { + bottomMargin = mlp.bottomMargin; + } + mlp.setMargins(mlp.leftMargin, topMargin, mlp.rightMargin, bottomMargin); + textView.setLayoutParams(lp); } } textView.setGravity(textPartnerConfigs.getTextGravity()); |