summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSetup Wizard Team <android-setup-team-eng@google.com>2021-11-04 13:11:13 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2021-11-04 13:11:13 +0000
commit2189580a41a4c2cea7c1e8573607b07ba3645d99 (patch)
tree28f65ae91134367b7a484c50f79b33da4e3b37b4
parentc9623ec76a3625fd6fa54408a362bb26a8cd8102 (diff)
parent341b27d037e36a2408025d97dc2a382955386933 (diff)
downloadsetupdesign-2189580a41a4c2cea7c1e8573607b07ba3645d99.tar.gz
Import updated Android Setupdesign Library 406038565 am: 341b27d037
Original change: https://googleplex-android-review.googlesource.com/c/platform/external/setupdesign/+/16138379 Change-Id: I011d7271f2669b14a04122db26126fddd7992aad
-rw-r--r--exempting_lint_checks.txt16
-rw-r--r--lottie_loading_layout/src/com/google/android/setupdesign/GlifLoadingLayout.java54
-rw-r--r--main/res/values-sw600dp-v31/diments.xml24
-rw-r--r--main/src/com/google/android/setupdesign/GlifLayout.java25
-rw-r--r--main/src/com/google/android/setupdesign/GlifListLayout.java2
-rw-r--r--main/src/com/google/android/setupdesign/GlifRecyclerLayout.java2
-rw-r--r--main/src/com/google/android/setupdesign/items/Item.java1
-rw-r--r--main/src/com/google/android/setupdesign/template/DescriptionMixin.java16
-rw-r--r--main/src/com/google/android/setupdesign/template/HeaderMixin.java23
-rw-r--r--main/src/com/google/android/setupdesign/template/IconMixin.java15
-rw-r--r--main/src/com/google/android/setupdesign/template/ListMixin.java2
-rw-r--r--main/src/com/google/android/setupdesign/template/RecyclerMixin.java2
-rw-r--r--main/src/com/google/android/setupdesign/util/ContentStyler.java14
-rw-r--r--main/src/com/google/android/setupdesign/util/HeaderAreaStyler.java104
-rw-r--r--main/src/com/google/android/setupdesign/util/LayoutStyler.java8
-rw-r--r--main/src/com/google/android/setupdesign/util/TextViewPartnerStyler.java41
-rw-r--r--main/src/com/google/android/setupdesign/util/ThemeHelper.java15
17 files changed, 178 insertions, 186 deletions
diff --git a/exempting_lint_checks.txt b/exempting_lint_checks.txt
index 201fd64..b6d4d30 100644
--- a/exempting_lint_checks.txt
+++ b/exempting_lint_checks.txt
@@ -47,3 +47,19 @@ third_party/java_src/android_libs/setupdesign/main/src/com/google/android/setupd
third_party/java_src/android_libs/setupdesign/main/src/com/google/android/setupdesign/view/NavigationBar.java: ResourceType: @StyleableRes int colorForeground = 1;
third_party/java_src/android_libs/setupdesign/main/src/com/google/android/setupdesign/view/StickyHeaderListView.java: CustomViewStyleable: .obtainStyledAttributes(attrs, R.styleable.SudStickyHeaderListView, defStyleAttr, 0);
third_party/java_src/android_libs/setupdesign/main/src/com/google/android/setupdesign/view/StickyHeaderScrollView.java: ObsoleteSdkInt: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
+third_party/java_src/android_libs/setupdesign/main/src/com/google/android/setupdesign/GlifLayout.java: CustomViewStyleable: getContext().obtainStyledAttributes(attrs, R.styleable.SudGlifLayout, defStyleAttr, 0);
+third_party/java_src/android_libs/setupdesign/main/src/com/google/android/setupdesign/SetupWizardLayout.java: CustomViewStyleable: .obtainStyledAttributes(attrs, R.styleable.SudSetupWizardLayout, defStyleAttr, 0);
+third_party/java_src/android_libs/setupdesign/main/src/com/google/android/setupdesign/items/RecyclerItemAdapter.java: NotifyDataSetChanged: notifyDataSetChanged();
+third_party/java_src/android_libs/setupdesign/main/src/com/google/android/setupdesign/util/Partner.java: DiscouragedApi: return resources.getIdentifier(name, defType, packageName);
+third_party/java_src/android_libs/setupdesign/main/src/com/google/android/setupdesign/view/FillContentLayout.java: CustomViewStyleable: context.obtainStyledAttributes(attrs, R.styleable.SudFillContentLayout, defStyleAttr, 0);
+third_party/java_src/android_libs/setupdesign/main/src/com/google/android/setupdesign/view/HeaderRecyclerView.java: CustomViewStyleable: .obtainStyledAttributes(attrs, R.styleable.SudHeaderRecyclerView, defStyleAttr, 0);
+third_party/java_src/android_libs/setupdesign/main/src/com/google/android/setupdesign/view/HeaderRecyclerView.java: NotifyDataSetChanged: notifyDataSetChanged();
+third_party/java_src/android_libs/setupdesign/main/src/com/google/android/setupdesign/view/IconUniformityAppImageView.java: AnnotateVersionCheck: private static final boolean ON_L_PLUS = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP;
+third_party/java_src/android_libs/setupdesign/main/src/com/google/android/setupdesign/view/Illustration.java: CustomViewStyleable: getContext().obtainStyledAttributes(attrs, R.styleable.SudIllustration, defStyleAttr, 0);
+third_party/java_src/android_libs/setupdesign/main/src/com/google/android/setupdesign/view/IllustrationVideoView.java: CustomViewStyleable: context.obtainStyledAttributes(attrs, R.styleable.SudIllustrationVideoView);
+third_party/java_src/android_libs/setupdesign/main/src/com/google/android/setupdesign/view/IntrinsicSizeFrameLayout.java: CustomViewStyleable: attrs, R.styleable.SudIntrinsicSizeFrameLayout, defStyleAttr, 0);
+third_party/java_src/android_libs/setupdesign/main/src/com/google/android/setupdesign/view/NavigationBar.java: ResourceType: @StyleableRes int colorBackground = 2;
+third_party/java_src/android_libs/setupdesign/main/src/com/google/android/setupdesign/view/NavigationBar.java: ResourceType: @StyleableRes int colorForeground = 1;
+third_party/java_src/android_libs/setupdesign/main/src/com/google/android/setupdesign/view/RichTextView.java: DiscouragedApi: .getIdentifier(textAppearance, "style", context.getPackageName());
+third_party/java_src/android_libs/setupdesign/main/src/com/google/android/setupdesign/view/StickyHeaderListView.java: CustomViewStyleable: .obtainStyledAttributes(attrs, R.styleable.SudStickyHeaderListView, defStyleAttr, 0);
+third_party/java_src/android_libs/setupdesign/main/src/com/google/android/setupdesign/view/StickyHeaderScrollView.java: ObsoleteSdkInt: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
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 19b60b7..8b26e70 100644
--- a/lottie_loading_layout/src/com/google/android/setupdesign/GlifLoadingLayout.java
+++ b/lottie_loading_layout/src/com/google/android/setupdesign/GlifLoadingLayout.java
@@ -88,6 +88,11 @@ public class GlifLoadingLayout extends GlifLayout {
@VisibleForTesting Map<KeyPath, SimpleColorFilter> customizationMap = new HashMap<>();
+ private AnimatorListener animatorListener;
+ private Runnable nextActionRunnable;
+ private boolean workFinished;
+ @VisibleForTesting public boolean runRunnable;
+
@VisibleForTesting
public List<LottieAnimationFinishListener> animationFinishListeners = new ArrayList<>();
@@ -123,8 +128,6 @@ public class GlifLoadingLayout extends GlifLayout {
.obtainStyledAttributes(attrs, R.styleable.SudGlifLoadingLayout, defStyleAttr, 0);
customLottieResource = a.getResourceId(R.styleable.SudGlifLoadingLayout_sudLottieRes, 0);
String illustrationType = a.getString(R.styleable.SudGlifLoadingLayout_sudIllustrationType);
- boolean usePartnerHeavyTheme =
- a.getBoolean(R.styleable.SudGlifLoadingLayout_sudUsePartnerHeavyTheme, false);
a.recycle();
if (customLottieResource != 0) {
@@ -143,21 +146,24 @@ public class GlifLoadingLayout extends GlifLayout {
}
}
- boolean applyPartnerHeavyThemeResource = shouldApplyPartnerResource() && usePartnerHeavyTheme;
- if (applyPartnerHeavyThemeResource) {
- View view = findManagedViewById(R.id.sud_layout_loading_content);
- if (view != null) {
- applyPartnerCustomizationContentPaddingTopStyle(view);
- }
+ View view = findManagedViewById(R.id.sud_layout_loading_content);
+ if (view != null) {
+ tryApplyPartnerCustomizationContentPaddingTopStyle(view);
}
updateHeaderHeight();
updateLandscapeMiddleHorizontalSpacing();
+ workFinished = false;
+ runRunnable = true;
+
LottieAnimationView lottieAnimationView = findLottieAnimationView();
if (lottieAnimationView != null) {
- // add the listener used to log animation end.
- lottieAnimationView.addAnimatorListener(
+ /*
+ * add the listener used to log animation end and check whether the
+ * work in background finish when repeated.
+ */
+ animatorListener =
new AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
@@ -176,9 +182,14 @@ public class GlifLoadingLayout extends GlifLayout {
@Override
public void onAnimationRepeat(Animator animation) {
- // Do nothing.
+ if (workFinished) {
+ Log.i(TAG, "Animation repeat but work finished, run the register runnable.");
+ finishRunnable(nextActionRunnable);
+ workFinished = false;
+ }
}
- });
+ };
+ lottieAnimationView.addAnimatorListener(animatorListener);
}
}
@@ -776,10 +787,25 @@ public class GlifLoadingLayout extends GlifLayout {
}
/**
- * Register the {@link Runnable} as a callback class that will be perform when animation finished.
+ * Register the {@link Runnable} as a callback that will be performed when the animation finished.
*/
public void registerAnimationFinishRunnable(Runnable runnable) {
- animationFinishListeners.add(new LottieAnimationFinishListener(this, runnable));
+ workFinished = true;
+ nextActionRunnable = runnable;
+ synchronized (this) {
+ runRunnable = true;
+ animationFinishListeners.add(
+ new LottieAnimationFinishListener(this, () -> finishRunnable(runnable)));
+ }
+ }
+
+ @VisibleForTesting
+ public synchronized void finishRunnable(Runnable runnable) {
+ // to avoid run the runnable twice.
+ if (runRunnable) {
+ runnable.run();
+ }
+ runRunnable = false;
}
/** The listener that to indicate the playing status for lottie animation. */
diff --git a/main/res/values-sw600dp-v31/diments.xml b/main/res/values-sw600dp-v31/diments.xml
new file mode 100644
index 0000000..899fa39
--- /dev/null
+++ b/main/res/values-sw600dp-v31/diments.xml
@@ -0,0 +1,24 @@
+<?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.
+-->
+
+<resources>
+
+ <!-- GLIF card layout for tablets. Set 0dp to enable fullscreen layout -->
+ <dimen name="sud_glif_card_width">0dp</dimen>
+ <dimen name="sud_glif_card_height">0dp</dimen>
+
+</resources>
diff --git a/main/src/com/google/android/setupdesign/GlifLayout.java b/main/src/com/google/android/setupdesign/GlifLayout.java
index 018e194..dcfc595 100644
--- a/main/src/com/google/android/setupdesign/GlifLayout.java
+++ b/main/src/com/google/android/setupdesign/GlifLayout.java
@@ -50,7 +50,6 @@ 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.PartnerStyleHelper;
/**
* Layout for the GLIF theme used in Setup Wizard for N.
@@ -139,9 +138,11 @@ public class GlifLayout extends PartnerCustomizationLayout {
}
if (shouldApplyPartnerHeavyThemeResource()) {
updateContentBackgroundColorWithPartnerConfig();
+ }
- View view = findManagedViewById(R.id.sud_layout_content);
- if (view != null) {
+ View view = findManagedViewById(R.id.sud_layout_content);
+ if (view != null) {
+ if (shouldApplyPartnerResource()) {
// 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
@@ -149,15 +150,16 @@ public class GlifLayout extends PartnerCustomizationLayout {
// 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);
+ }
- // {@class GlifPreferenceLayout} Inherited from {@class GlifRecyclerLayout}. The API would
- // be called twice from GlifRecyclerLayout and GlifLayout, so it should skip the API here
- // when the instance is GlifPreferenceLayout.
- if (!(this instanceof GlifPreferenceLayout)) {
- applyPartnerCustomizationContentPaddingTopStyle(view);
- }
+ // {@class GlifPreferenceLayout} Inherited from {@class GlifRecyclerLayout}. The API would
+ // be called twice from GlifRecyclerLayout and GlifLayout, so it should skip the API here
+ // when the instance is GlifPreferenceLayout.
+ if (!(this instanceof GlifPreferenceLayout)) {
+ tryApplyPartnerCustomizationContentPaddingTopStyle(view);
}
}
+
updateLandscapeMiddleHorizontalSpacing();
ColorStateList backgroundColor =
@@ -477,14 +479,13 @@ public class GlifLayout extends PartnerCustomizationLayout {
}
@TargetApi(VERSION_CODES.JELLY_BEAN_MR1)
- protected static void applyPartnerCustomizationContentPaddingTopStyle(View view) {
+ protected void tryApplyPartnerCustomizationContentPaddingTopStyle(View view) {
Context context = view.getContext();
boolean partnerPaddingTopAvailable =
PartnerConfigHelper.get(context)
.isPartnerConfigAvailable(PartnerConfig.CONFIG_CONTENT_PADDING_TOP);
- if (PartnerStyleHelper.shouldApplyPartnerHeavyThemeResource(view)
- && partnerPaddingTopAvailable) {
+ if (shouldApplyPartnerResource() && partnerPaddingTopAvailable) {
int paddingTop =
(int)
PartnerConfigHelper.get(context)
diff --git a/main/src/com/google/android/setupdesign/GlifListLayout.java b/main/src/com/google/android/setupdesign/GlifListLayout.java
index 60f0343..89d0888 100644
--- a/main/src/com/google/android/setupdesign/GlifListLayout.java
+++ b/main/src/com/google/android/setupdesign/GlifListLayout.java
@@ -76,7 +76,7 @@ public class GlifListLayout extends GlifLayout {
View view = this.findManagedViewById(R.id.sud_landscape_content_area);
if (view != null) {
- applyPartnerCustomizationContentPaddingTopStyle(view);
+ tryApplyPartnerCustomizationContentPaddingTopStyle(view);
}
updateLandscapeMiddleHorizontalSpacing();
}
diff --git a/main/src/com/google/android/setupdesign/GlifRecyclerLayout.java b/main/src/com/google/android/setupdesign/GlifRecyclerLayout.java
index 5e75436..87f871c 100644
--- a/main/src/com/google/android/setupdesign/GlifRecyclerLayout.java
+++ b/main/src/com/google/android/setupdesign/GlifRecyclerLayout.java
@@ -77,7 +77,7 @@ public class GlifRecyclerLayout extends GlifLayout {
View view = this.findManagedViewById(R.id.sud_landscape_content_area);
if (view != null) {
- applyPartnerCustomizationContentPaddingTopStyle(view);
+ tryApplyPartnerCustomizationContentPaddingTopStyle(view);
}
updateLandscapeMiddleHorizontalSpacing();
}
diff --git a/main/src/com/google/android/setupdesign/items/Item.java b/main/src/com/google/android/setupdesign/items/Item.java
index fd3f2eb..3947c62 100644
--- a/main/src/com/google/android/setupdesign/items/Item.java
+++ b/main/src/com/google/android/setupdesign/items/Item.java
@@ -208,6 +208,7 @@ public class Item extends AbstractItem {
// 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.
+ // TODO: Add partner resource enable check
if (!(this instanceof ExpandableSwitchItem) && view.getId() != R.id.sud_layout_header) {
LayoutStyler.applyPartnerCustomizationLayoutPaddingStyle(view);
}
diff --git a/main/src/com/google/android/setupdesign/template/DescriptionMixin.java b/main/src/com/google/android/setupdesign/template/DescriptionMixin.java
index bbccf82..63e4f41 100644
--- a/main/src/com/google/android/setupdesign/template/DescriptionMixin.java
+++ b/main/src/com/google/android/setupdesign/template/DescriptionMixin.java
@@ -28,7 +28,6 @@ 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;
import com.google.android.setupdesign.R;
@@ -79,21 +78,12 @@ public class DescriptionMixin implements Mixin {
/**
* Applies the partner customizations to the description text (contains text alignment) and
- * background, if apply heavy theme resource, it will apply all partner customizations, otherwise,
- * only apply alignment style.
+ * background. It will apply all partner customizations.
*/
public void tryApplyPartnerCustomizationStyle() {
TextView description = templateLayout.findManagedViewById(R.id.sud_layout_subtitle);
- boolean partnerHeavyThemeLayout = PartnerStyleHelper.isPartnerHeavyThemeLayout(templateLayout);
- if (partnerHeavyThemeLayout) {
- if (description != null) {
- HeaderAreaStyler.applyPartnerCustomizationDescriptionHeavyStyle(description);
- }
- } else if (templateLayout instanceof PartnerCustomizationLayout
- && ((PartnerCustomizationLayout) templateLayout).shouldApplyPartnerResource()) {
- if (description != null) {
- HeaderAreaStyler.applyPartnerCustomizationDescriptionLightStyle(description);
- }
+ if (description != null && PartnerStyleHelper.shouldApplyPartnerResource(templateLayout)) {
+ HeaderAreaStyler.applyPartnerCustomizationDescriptionHeavyStyle(description);
}
}
diff --git a/main/src/com/google/android/setupdesign/template/HeaderMixin.java b/main/src/com/google/android/setupdesign/template/HeaderMixin.java
index d040c94..96f9f67 100644
--- a/main/src/com/google/android/setupdesign/template/HeaderMixin.java
+++ b/main/src/com/google/android/setupdesign/template/HeaderMixin.java
@@ -77,8 +77,8 @@ public class HeaderMixin implements Mixin {
a.recycle();
- // overlay the Auto size config settings
- updateAutoTextSizeWithPartnerConfig();
+ // Try to update the flag of the uto size config settings
+ tryUpdateAutoTextSizeFlagWithPartnerConfig();
// Set the header text
if (headerText != null) {
@@ -90,10 +90,9 @@ public class HeaderMixin implements Mixin {
}
}
- private void updateAutoTextSizeWithPartnerConfig() {
+ private void tryUpdateAutoTextSizeFlagWithPartnerConfig() {
Context context = templateLayout.getContext();
- if (!PartnerStyleHelper.isPartnerHeavyThemeLayout(templateLayout)
- || !PartnerConfigHelper.shouldApplyExtendedPartnerConfig(context)) {
+ if (!PartnerStyleHelper.shouldApplyPartnerResource(templateLayout)) {
autoTextSizeEnabled = false;
return;
}
@@ -149,18 +148,14 @@ public class HeaderMixin implements Mixin {
*/
public void tryApplyPartnerCustomizationStyle() {
TextView header = templateLayout.findManagedViewById(R.id.suc_layout_title);
- boolean partnerLightThemeLayout = PartnerStyleHelper.isPartnerLightThemeLayout(templateLayout);
- boolean partnerHeavyThemeLayout = PartnerStyleHelper.isPartnerHeavyThemeLayout(templateLayout);
- if (partnerHeavyThemeLayout) {
+ if (PartnerStyleHelper.shouldApplyPartnerResource(templateLayout)) {
View headerAreaView = templateLayout.findManagedViewById(R.id.sud_layout_header);
- HeaderAreaStyler.applyPartnerCustomizationHeaderHeavyStyle(header);
- HeaderAreaStyler.applyPartnerCustomizationHeaderAreaStyle((ViewGroup) headerAreaView);
LayoutStyler.applyPartnerCustomizationExtraPaddingStyle(headerAreaView);
- // overlay the Auto size config settings
- updateAutoTextSizeWithPartnerConfig();
- } else if (partnerLightThemeLayout) {
- HeaderAreaStyler.applyPartnerCustomizationHeaderLightStyle(header);
+ HeaderAreaStyler.applyPartnerCustomizationHeaderStyle(header);
+ HeaderAreaStyler.applyPartnerCustomizationHeaderAreaStyle((ViewGroup) headerAreaView);
}
+ // Try to update the flag of the uto size config settings
+ tryUpdateAutoTextSizeFlagWithPartnerConfig();
if (autoTextSizeEnabled) {
// Override the text size setting of the header
autoAdjustTextSize(header);
diff --git a/main/src/com/google/android/setupdesign/template/IconMixin.java b/main/src/com/google/android/setupdesign/template/IconMixin.java
index ef9f441..3c2b6d0 100644
--- a/main/src/com/google/android/setupdesign/template/IconMixin.java
+++ b/main/src/com/google/android/setupdesign/template/IconMixin.java
@@ -71,8 +71,8 @@ public class IconMixin implements Mixin {
context.obtainStyledAttributes(
attrs, R.styleable.SudIconMixin, defStyleAttr, /* defStyleRes= */ 0);
- final @DrawableRes int icon =
- a.getResourceId(R.styleable.SudIconMixin_android_icon, /* defValue= */ 0);
+ @DrawableRes
+ final int icon = a.getResourceId(R.styleable.SudIconMixin_android_icon, /* defValue= */ 0);
if (icon != 0) {
setIcon(icon);
}
@@ -81,8 +81,8 @@ public class IconMixin implements Mixin {
a.getBoolean(R.styleable.SudIconMixin_sudUpscaleIcon, /* defValue= */ false);
setUpscaleIcon(upscaleIcon);
- final @ColorInt int iconTint =
- a.getColor(R.styleable.SudIconMixin_sudIconTint, Color.TRANSPARENT);
+ @ColorInt
+ final int iconTint = a.getColor(R.styleable.SudIconMixin_sudIconTint, Color.TRANSPARENT);
if (iconTint != Color.TRANSPARENT) {
setIconTint(iconTint);
}
@@ -92,12 +92,9 @@ public class IconMixin implements Mixin {
/** Tries to apply the partner customization to the header icon. */
public void tryApplyPartnerCustomizationStyle() {
- if (PartnerStyleHelper.isPartnerHeavyThemeLayout(templateLayout)) {
- // apply partner heavy configs
+ // apply partner configs for icon
+ if (PartnerStyleHelper.shouldApplyPartnerResource(templateLayout)) {
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/template/ListMixin.java b/main/src/com/google/android/setupdesign/template/ListMixin.java
index 5963a79..bfaf640 100644
--- a/main/src/com/google/android/setupdesign/template/ListMixin.java
+++ b/main/src/com/google/android/setupdesign/template/ListMixin.java
@@ -79,7 +79,7 @@ public class ListMixin implements Mixin {
int dividerInsetEnd =
a.getDimensionPixelSize(R.styleable.SudListMixin_sudDividerInsetEnd, 0);
- if (PartnerStyleHelper.shouldApplyPartnerHeavyThemeResource(templateLayout)) {
+ if (PartnerStyleHelper.shouldApplyPartnerResource(templateLayout)) {
if (PartnerConfigHelper.get(context)
.isPartnerConfigAvailable(PartnerConfig.CONFIG_LAYOUT_MARGIN_START)) {
dividerInsetStart =
diff --git a/main/src/com/google/android/setupdesign/template/RecyclerMixin.java b/main/src/com/google/android/setupdesign/template/RecyclerMixin.java
index b327060..fb69a8d 100644
--- a/main/src/com/google/android/setupdesign/template/RecyclerMixin.java
+++ b/main/src/com/google/android/setupdesign/template/RecyclerMixin.java
@@ -154,7 +154,7 @@ public class RecyclerMixin implements Mixin {
int dividerInsetEnd =
a.getDimensionPixelSize(R.styleable.SudRecyclerMixin_sudDividerInsetEnd, 0);
- if (PartnerStyleHelper.shouldApplyPartnerHeavyThemeResource(templateLayout)) {
+ if (PartnerStyleHelper.shouldApplyPartnerResource(templateLayout)) {
if (PartnerConfigHelper.get(context)
.isPartnerConfigAvailable(PartnerConfig.CONFIG_LAYOUT_MARGIN_START)) {
dividerInsetStart =
diff --git a/main/src/com/google/android/setupdesign/util/ContentStyler.java b/main/src/com/google/android/setupdesign/util/ContentStyler.java
index f44ddc6..ef365e3 100644
--- a/main/src/com/google/android/setupdesign/util/ContentStyler.java
+++ b/main/src/com/google/android/setupdesign/util/ContentStyler.java
@@ -41,6 +41,7 @@ import java.util.Locale;
*/
public final class ContentStyler {
public static void applyBodyPartnerCustomizationStyle(TextView contentText) {
+ // TODO: Remove the check of applying the heavy theme.
if (!PartnerStyleHelper.shouldApplyPartnerHeavyThemeResource(contentText)) {
return;
}
@@ -69,6 +70,7 @@ public final class ContentStyler {
*/
public static void applyInfoPartnerCustomizationStyle(
@Nullable View infoContainer, @Nullable ImageView infoIcon, TextView infoText) {
+ // TODO: Remove the check of applying the heavy theme.
if (!PartnerStyleHelper.shouldApplyPartnerHeavyThemeResource(infoText)) {
return;
}
@@ -190,13 +192,11 @@ public final class ContentStyler {
// default value is GlifTheme layout margin start.
// That is the attr sudMarginStart, and the value is sud_layout_margin_sides.
float result = context.getResources().getDimension(R.dimen.sud_layout_margin_sides);
- if (PartnerStyleHelper.shouldApplyPartnerHeavyThemeResource(context)) {
- if (PartnerConfigHelper.get(context)
- .isPartnerConfigAvailable(PartnerConfig.CONFIG_LAYOUT_MARGIN_START)) {
- result =
- PartnerConfigHelper.get(context)
- .getDimension(context, PartnerConfig.CONFIG_LAYOUT_MARGIN_START, result);
- }
+ if (PartnerConfigHelper.get(context)
+ .isPartnerConfigAvailable(PartnerConfig.CONFIG_LAYOUT_MARGIN_START)) {
+ result =
+ PartnerConfigHelper.get(context)
+ .getDimension(context, PartnerConfig.CONFIG_LAYOUT_MARGIN_START, result);
}
return result;
}
diff --git a/main/src/com/google/android/setupdesign/util/HeaderAreaStyler.java b/main/src/com/google/android/setupdesign/util/HeaderAreaStyler.java
index 40313b5..e233219 100644
--- a/main/src/com/google/android/setupdesign/util/HeaderAreaStyler.java
+++ b/main/src/com/google/android/setupdesign/util/HeaderAreaStyler.java
@@ -54,11 +54,11 @@ public final class HeaderAreaStyler {
"To achieve scaling icon in SetupDesign lib, should use vector drawable icon from ";
/**
- * Applies the partner heavy style of header text to the given textView {@code header}.
+ * Applies the partner style of header text to the given textView {@code header}.
*
- * @param header A header text would apply partner heavy style
+ * @param header A header text would apply partner style
*/
- public static void applyPartnerCustomizationHeaderHeavyStyle(@Nullable TextView header) {
+ public static void applyPartnerCustomizationHeaderStyle(@Nullable TextView header) {
if (header == null) {
return;
@@ -101,55 +101,6 @@ public final class HeaderAreaStyler {
}
/**
- * Applies the partner light style of header text to the given textView {@code header}.
- *
- * @param header A header text would apply partner light style
- */
- public static void applyPartnerCustomizationHeaderLightStyle(@Nullable TextView header) {
-
- if (header == null) {
- return;
- }
-
- TextViewPartnerStyler.applyPartnerCustomizationLightStyle(
- header,
- new TextPartnerConfigs(
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- PartnerStyleHelper.getLayoutGravity(header.getContext())));
- }
-
- /**
- * Applies the partner light style of description text to the given textView {@code description}.
- *
- * @param description A description text would apply partner light style
- */
- public static void applyPartnerCustomizationDescriptionLightStyle(
- @Nullable TextView description) {
-
- if (description == null) {
- return;
- }
-
- TextViewPartnerStyler.applyPartnerCustomizationLightStyle(
- description,
- new TextPartnerConfigs(
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- PartnerStyleHelper.getLayoutGravity(description.getContext())));
- }
-
- /**
* 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 also be appied when heavy theme parter config is
@@ -161,27 +112,25 @@ public final class HeaderAreaStyler {
if (headerArea == null) {
return;
}
- if (PartnerStyleHelper.shouldApplyPartnerHeavyThemeResource(headerArea)) {
- Context context = headerArea.getContext();
- int color =
- PartnerConfigHelper.get(context)
- .getColor(context, PartnerConfig.CONFIG_HEADER_AREA_BACKGROUND_COLOR);
- headerArea.setBackgroundColor(color);
+ Context context = headerArea.getContext();
+ int color =
+ PartnerConfigHelper.get(context)
+ .getColor(context, PartnerConfig.CONFIG_HEADER_AREA_BACKGROUND_COLOR);
+ headerArea.setBackgroundColor(color);
- 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;
+ 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;
- 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);
- }
+ 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);
}
}
}
@@ -227,8 +176,8 @@ public final class HeaderAreaStyler {
}
/**
- * 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.
+ * Applies the partner style of header icon to the given {@code iconImage}. It needs to check if
+ * it should apply partner resource 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
@@ -285,17 +234,6 @@ public final class HeaderAreaStyler {
}
}
- /** 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);
- }
- }
-
private static void checkImageType(ImageView imageView) {
ViewTreeObserver vto = imageView.getViewTreeObserver();
vto.addOnPreDrawListener(
diff --git a/main/src/com/google/android/setupdesign/util/LayoutStyler.java b/main/src/com/google/android/setupdesign/util/LayoutStyler.java
index ffe273e..b910601 100644
--- a/main/src/com/google/android/setupdesign/util/LayoutStyler.java
+++ b/main/src/com/google/android/setupdesign/util/LayoutStyler.java
@@ -54,7 +54,9 @@ public final class LayoutStyler {
PartnerConfigHelper.get(context)
.isPartnerConfigAvailable(PartnerConfig.CONFIG_LAYOUT_MARGIN_END);
- if (PartnerStyleHelper.shouldApplyPartnerHeavyThemeResource(view)
+ // TODO: After all users added the check before calling the API, this check can be
+ // deleted.
+ if (PartnerStyleHelper.shouldApplyPartnerResource(view)
&& (partnerMarginStartAvailable || partnerMarginEndAvailable)) {
int paddingStart;
int paddingEnd;
@@ -103,7 +105,9 @@ public final class LayoutStyler {
PartnerConfigHelper.get(context)
.isPartnerConfigAvailable(PartnerConfig.CONFIG_LAYOUT_MARGIN_END);
- if (PartnerStyleHelper.shouldApplyPartnerHeavyThemeResource(view)
+ // TODO: After all users added the check before calling the API, this check can be
+ // deleted.
+ if (PartnerStyleHelper.shouldApplyPartnerResource(view)
&& (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 85b775e..b56d09a 100644
--- a/main/src/com/google/android/setupdesign/util/TextViewPartnerStyler.java
+++ b/main/src/com/google/android/setupdesign/util/TextViewPartnerStyler.java
@@ -98,8 +98,32 @@ final class TextViewPartnerStyler {
}
}
+ applyPartnerCustomizationVerticalMargins(textView, textPartnerConfigs);
+ textView.setGravity(textPartnerConfigs.getTextGravity());
+ }
+
+ /**
+ * Applies given partner configurations {@code textPartnerConfigs} to the {@code textView}.
+ *
+ * @param textView A text view would apply the gravity
+ * @param textPartnerConfigs A partner conflagrations contains text gravity would be set
+ */
+ public static void applyPartnerCustomizationLightStyle(
+ @NonNull TextView textView, @NonNull TextPartnerConfigs textPartnerConfigs) {
+
+ if (textView == null || textPartnerConfigs == null) {
+ return;
+ }
+
+ applyPartnerCustomizationVerticalMargins(textView, textPartnerConfigs);
+ textView.setGravity(textPartnerConfigs.getTextGravity());
+ }
+
+ private static void applyPartnerCustomizationVerticalMargins(
+ @NonNull TextView textView, @NonNull TextPartnerConfigs textPartnerConfigs) {
if (textPartnerConfigs.getTextMarginTop() != null
|| textPartnerConfigs.getTextMarginBottom() != null) {
+ Context context = textView.getContext();
int topMargin;
int bottomMargin;
final ViewGroup.LayoutParams lp = textView.getLayoutParams();
@@ -130,23 +154,6 @@ final class TextViewPartnerStyler {
textView.setLayoutParams(lp);
}
}
- textView.setGravity(textPartnerConfigs.getTextGravity());
- }
-
- /**
- * Applies given partner configurations {@code textPartnerConfigs} to the {@code textView}.
- *
- * @param textView A text view would apply the gravity
- * @param textPartnerConfigs A partner conflagrations contains text gravity would be set
- */
- public static void applyPartnerCustomizationLightStyle(
- @NonNull TextView textView, @NonNull TextPartnerConfigs textPartnerConfigs) {
-
- if (textView == null || textPartnerConfigs == null) {
- return;
- }
-
- textView.setGravity(textPartnerConfigs.getTextGravity());
}
/** Keeps the partner conflagrations for a textView. */
diff --git a/main/src/com/google/android/setupdesign/util/ThemeHelper.java b/main/src/com/google/android/setupdesign/util/ThemeHelper.java
index 0b750c9..3c46be9 100644
--- a/main/src/com/google/android/setupdesign/util/ThemeHelper.java
+++ b/main/src/com/google/android/setupdesign/util/ThemeHelper.java
@@ -166,16 +166,9 @@ public final class ThemeHelper {
return PartnerConfigHelper.shouldApplyExtendedPartnerConfig(context);
}
- /**
- * Returns {@code true} if the partner provider of SetupWizard is ready to support dynamic color.
- */
- public static boolean isSetupWizardDynamicColorEnabled(@NonNull Context context) {
- return PartnerConfigHelper.isSetupWizardDynamicColorEnabled(context);
- }
-
/** Returns {@code true} if this {@code context} should apply dynamic color. */
public static boolean shouldApplyDynamicColor(@NonNull Context context) {
- return shouldApplyExtendedPartnerConfig(context) && isSetupWizardDynamicColorEnabled(context);
+ return PartnerConfigHelper.isSetupWizardDynamicColorEnabled(context);
}
/**
@@ -237,12 +230,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("SetupWizard does not supports the extended partner configs.");
+ if (!BuildCompatUtils.isAtLeastS()) {
+ LOG.w("Dynamic color require platform version at least S.");
return false;
}
- if (!isSetupWizardDynamicColorEnabled(context)) {
+ if (!shouldApplyDynamicColor(context)) {
LOG.w("SetupWizard does not support the dynamic color or supporting status unknown.");
return false;
}