summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSetup Wizard Team <android-setup-team-eng@google.com>2021-05-12 02:47:51 +0000
committerCyril Lee <cyrillee@google.com>2021-05-12 07:59:30 +0000
commit55c0d53a5db43d763c2b133002fb6d0971f4013b (patch)
treeba5b2cb235899a6877b3bd2d8690e1374d0b96dc
parente530e8b9c6d953bf281696a83dca37b03d212e8e (diff)
downloadsetupdesign-55c0d53a5db43d763c2b133002fb6d0971f4013b.tar.gz
Import updated Android Setupdesign Library 373282927
Copied from google3/third_party/java_src/android_libs/setupdesign Bug: 187652105 Test: mm Included changes: - 373282927 Avoid mixin's color override by partner config - 373118233 Adjust the padding of GlifLoadingLayout in landscape mode... - 373090601 [GlifLoadingLayout] Adds calculate padding to fix the pos... - 373072806 Fix recycler mixin - 372913214 Automated g4 rollback of changelist 371836628. - 372886006 [GlifLoadingLayout] Adds LoadingFooterBarMixin that exten... - 372879016 Add color support for portal - 372854559 Fix disrupt flow issue, the SubActivityWrapper will start... - 372518884 [SetupDesign] Support SwitchBar style - 372507661 [Portal] Set round corner for progress items - 372295415 [SetupDesign] listItemStyler - provide 2 more helper for ... - 372106188 [GlifLoadingLayout] Add header height partner resources f... - 372065512 [GlifLoadingLayout] adjust the layout to follow spec to m... - 371872512 [ColorExtration] Fixes typo in comment for color.xml PiperOrigin-RevId: 373282927 Change-Id: Ia7bf4c03fa1df6efa3611b14fa371126651bd0ad
-rw-r--r--lottie_loading_layout/res/layout-land-v31/sud_glif_loading_template_content.xml53
-rw-r--r--lottie_loading_layout/res/layout-v31/sud_glif_loading_template_content.xml92
-rw-r--r--lottie_loading_layout/res/layout-v31/sud_loading_illustration_layout.xml39
-rw-r--r--lottie_loading_layout/res/layout-v31/sud_loading_lottie_layout.xml34
-rw-r--r--lottie_loading_layout/res/values/attrs.xml9
-rw-r--r--lottie_loading_layout/src/com/google/android/setupdesign/GlifLoadingLayout.java78
-rw-r--r--lottie_loading_layout/src/com/google/android/setupdesign/LoadingFooterBarMixin.java44
-rw-r--r--main/res/values-night/colors.xml3
-rw-r--r--main/res/values-v31/colors.xml36
-rw-r--r--main/res/values/colors.xml43
-rw-r--r--main/src/com/google/android/setupdesign/GlifLayout.java6
-rw-r--r--main/src/com/google/android/setupdesign/items/ItemViewHolder.java6
-rw-r--r--main/src/com/google/android/setupdesign/items/RecyclerItemAdapter.java13
-rw-r--r--main/src/com/google/android/setupdesign/template/RecyclerMixin.java4
-rw-r--r--main/src/com/google/android/setupdesign/util/ItemStyler.java159
15 files changed, 453 insertions, 166 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 a11b719..65e20a9 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
@@ -61,43 +61,32 @@
android:layout_weight="@dimen/sud_glif_land_content_area_weight"
android:orientation="vertical">
- <com.google.android.setupdesign.view.BottomScrollView
- android:id="@+id/sud_scroll_view"
+ <FrameLayout
+ android:id="@+id/sud_layout_loading_content"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:fillViewport="true"
- android:scrollIndicators="?attr/sudScrollIndicators">
+ android:layout_height="match_parent">
- <LinearLayout
+ <ViewStub
+ android:id="@+id/sud_loading_layout_lottie_stub"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:inflatedId="@+id/sud_layout_lottie_illustration"
+ android:layout="@layout/sud_loading_lottie_layout" />
+
+ <ViewStub
+ android:id="@+id/sud_loading_layout_illustration_stub"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:inflatedId="@+id/sud_layout_progress_illustration"
+ android:layout="@layout/sud_loading_illustration_layout" />
+
+ <FrameLayout
+ android:id="@+id/sud_layout_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:orientation="vertical">
-
- <ViewStub
- android:id="@+id/sud_loading_layout_lottie_stub"
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1"
- android:inflatedId="@+id/sud_layout_lottie_illustration"
- android:layout="@layout/sud_loading_lottie_layout" />
-
- <ViewStub
- android:id="@+id/sud_loading_layout_illustration_stub"
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1"
- android:inflatedId="@+id/sud_layout_progress_illustration"
- android:layout="@layout/sud_loading_illustration_layout" />
-
- <FrameLayout
- android:id="@+id/sud_layout_content"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:visibility="gone" />
-
- </LinearLayout>
+ android:visibility="gone" />
- </com.google.android.setupdesign.view.BottomScrollView>
+ </FrameLayout>
</LinearLayout>
diff --git a/lottie_loading_layout/res/layout-v31/sud_glif_loading_template_content.xml b/lottie_loading_layout/res/layout-v31/sud_glif_loading_template_content.xml
new file mode 100644
index 0000000..8415324
--- /dev/null
+++ b/lottie_loading_layout/res/layout-v31/sud_glif_loading_template_content.xml
@@ -0,0 +1,92 @@
+<?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.
+-->
+
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:id="@+id/sud_layout_template_content"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <ViewStub
+ android:id="@+id/sud_layout_sticky_header"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" />
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="1"
+ android:orientation="vertical">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <!-- Ignore UnusedAttribute: scrollIndicators is new in M. Default to no indicators in older
+ versions. -->
+ <com.google.android.setupdesign.view.BottomScrollView
+ android:id="@+id/sud_header_scroll_view"
+ android:layout_width="match_parent"
+ android:layout_height="?attr/sudLoadingHeaderHeight"
+ android:fillViewport="true"
+ android:scrollIndicators="?attr/sudScrollIndicators"
+ tools:ignore="UnusedAttribute">
+
+ <include layout="@layout/sud_glif_header" />
+
+ </com.google.android.setupdesign.view.BottomScrollView>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <ViewStub
+ android:id="@+id/sud_loading_layout_lottie_stub"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:inflatedId="@+id/sud_layout_lottie_illustration"
+ android:layout="@layout/sud_loading_lottie_layout" />
+
+ <ViewStub
+ android:id="@+id/sud_loading_layout_illustration_stub"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:inflatedId="@+id/sud_layout_progress_illustration"
+ android:layout="@layout/sud_loading_illustration_layout" />
+
+ <FrameLayout
+ android:id="@+id/sud_layout_content"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:visibility="gone" />
+
+ </LinearLayout>
+
+ </LinearLayout>
+
+ </LinearLayout>
+
+ <ViewStub
+ android:id="@+id/suc_layout_footer"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" />
+
+</LinearLayout> \ No newline at end of file
diff --git a/lottie_loading_layout/res/layout-v31/sud_loading_illustration_layout.xml b/lottie_loading_layout/res/layout-v31/sud_loading_illustration_layout.xml
new file mode 100644
index 0000000..0f60d02
--- /dev/null
+++ b/lottie_loading_layout/res/layout-v31/sud_loading_illustration_layout.xml
@@ -0,0 +1,39 @@
+<?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.
+-->
+
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ style="@style/SudLoadingContentFrame"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <ProgressBar
+ android:id="@+id/sud_progress_bar"
+ android:visibility="gone"
+ style="@style/SudFourColorIndeterminateProgressBar"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+
+ <com.google.android.setupdesign.view.IllustrationVideoView
+ android:id="@+id/sud_progress_illustration"
+ android:visibility="gone"
+ style="@style/SudContentIllustration"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" />
+
+</LinearLayout> \ No newline at end of file
diff --git a/lottie_loading_layout/res/layout-v31/sud_loading_lottie_layout.xml b/lottie_loading_layout/res/layout-v31/sud_loading_lottie_layout.xml
new file mode 100644
index 0000000..a38b791
--- /dev/null
+++ b/lottie_loading_layout/res/layout-v31/sud_loading_lottie_layout.xml
@@ -0,0 +1,34 @@
+<?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.
+-->
+
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ style="@style/SudLoadingContentFrame"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <com.airbnb.lottie.LottieAnimationView
+ android:id="@+id/sud_lottie_view"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:importantForAccessibility="no"
+ style="@style/SudContentIllustration"
+ app:lottie_autoPlay="false"
+ app:lottie_loop="true" />
+
+</LinearLayout>
diff --git a/lottie_loading_layout/res/values/attrs.xml b/lottie_loading_layout/res/values/attrs.xml
index a011ac1..57fcac7 100644
--- a/lottie_loading_layout/res/values/attrs.xml
+++ b/lottie_loading_layout/res/values/attrs.xml
@@ -16,8 +16,9 @@
-->
<resources>
- <declare-styleable name="SudGlifLoadingLayout">
- <attr name="sudIllustrationType" format="string" />
- <attr name="sudLottieRes" format="reference" />
- </declare-styleable>
+ <declare-styleable name="SudGlifLoadingLayout">
+ <attr name="sudIllustrationType" format="string" />
+ <attr name="sudLottieRes" format="reference" />
+ <attr name="sudUsePartnerHeavyTheme" />
+ </declare-styleable>
</resources> \ No newline at end of file
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 86700f6..4299c41 100644
--- a/lottie_loading_layout/src/com/google/android/setupdesign/GlifLoadingLayout.java
+++ b/lottie_loading_layout/src/com/google/android/setupdesign/GlifLoadingLayout.java
@@ -57,6 +57,7 @@ import com.google.android.setupcompat.partnerconfig.PartnerConfig;
import com.google.android.setupcompat.partnerconfig.PartnerConfig.ResourceType;
import com.google.android.setupcompat.partnerconfig.PartnerConfigHelper;
import com.google.android.setupcompat.partnerconfig.ResourceEntry;
+import com.google.android.setupcompat.template.FooterBarMixin;
import com.google.android.setupcompat.util.BuildCompatUtils;
import com.google.android.setupdesign.lottieloadinglayout.R;
import com.google.android.setupdesign.view.IllustrationVideoView;
@@ -76,7 +77,9 @@ import java.util.Map;
* app:sudLottieRes} can assign the json file of Lottie resource.
*/
public class GlifLoadingLayout extends GlifLayout {
+
private static final String TAG = "GlifLoadingLayout";
+ View inflatedView;
@VisibleForTesting @IllustrationType String illustrationType = IllustrationType.DEFAULT;
@VisibleForTesting LottieAnimationConfig animationConfig = LottieAnimationConfig.CONFIG_DEFAULT;
@@ -113,12 +116,17 @@ public class GlifLoadingLayout extends GlifLayout {
}
private void init(AttributeSet attrs, int defStyleAttr) {
+ registerMixin(FooterBarMixin.class, new LoadingFooterBarMixin(this, attrs, defStyleAttr));
+
TypedArray a =
getContext()
.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) {
inflateLottieView();
ViewGroup container = findContainer(0);
@@ -134,9 +142,28 @@ public class GlifLoadingLayout extends GlifLayout {
inflateIllustrationStub();
}
}
+
+ boolean applyPartnerHeavyThemeResource = shouldApplyPartnerResource() && usePartnerHeavyTheme;
+ if (applyPartnerHeavyThemeResource) {
+ View view = findManagedViewById(R.id.sud_layout_loading_content);
+ if (view != null) {
+ applyPartnerCustomizationContentPaddingTopStyle(view);
+ }
+ }
+
+ updateHeaderHeight();
updateLandscapeMiddleHorizontalSpacing();
}
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+
+ if (inflatedView instanceof LinearLayout) {
+ updateContentPadding((LinearLayout) inflatedView);
+ }
+ }
+
public void setIllustrationType(@IllustrationType String type) {
if (customLottieResource != 0) {
throw new IllegalStateException(
@@ -307,6 +334,18 @@ public class GlifLoadingLayout extends GlifLayout {
/* allowFinishWithMaximumDuration= */ true);
}
+ private void updateHeaderHeight() {
+ View headerView = findManagedViewById(R.id.sud_header_scroll_view);
+ if (headerView != null
+ && PartnerConfigHelper.get(getContext())
+ .isPartnerConfigAvailable(PartnerConfig.CONFIG_LOADING_LAYOUT_HEADER_HEIGHT)) {
+ float configHeaderHeight =
+ PartnerConfigHelper.get(getContext())
+ .getDimension(getContext(), PartnerConfig.CONFIG_LOADING_LAYOUT_HEADER_HEIGHT);
+ headerView.getLayoutParams().height = (int) configHeaderHeight;
+ }
+ }
+
private void updateContentPadding(LinearLayout linearLayout) {
int paddingTop = linearLayout.getPaddingTop();
int paddingLeft = linearLayout.getPaddingLeft();
@@ -349,7 +388,17 @@ public class GlifLoadingLayout extends GlifLayout {
PartnerConfigHelper.get(getContext())
.getDimension(getContext(), PartnerConfig.CONFIG_LOADING_LAYOUT_PADDING_BOTTOM);
if (configPaddingBottom >= 0) {
- paddingBottom = (int) configPaddingBottom;
+ FooterBarMixin footerBarMixin = getMixin(FooterBarMixin.class);
+ if (footerBarMixin == null || footerBarMixin.getButtonContainer() == null) {
+ paddingBottom = (int) configPaddingBottom;
+ } else {
+ paddingBottom =
+ (int) configPaddingBottom
+ - (int)
+ Math.min(
+ configPaddingBottom,
+ getResources().getDimension(R.dimen.sud_glif_footer_min_height));
+ }
}
}
@@ -361,9 +410,9 @@ public class GlifLoadingLayout extends GlifLayout {
if (lottieLayout == null) {
ViewStub viewStub = findManagedViewById(R.id.sud_loading_layout_lottie_stub);
if (viewStub != null) {
- View inflateView = viewStub.inflate();
- if (inflateView instanceof LinearLayout) {
- updateContentPadding((LinearLayout) inflateView);
+ inflatedView = viewStub.inflate();
+ if (inflatedView instanceof LinearLayout) {
+ updateContentPadding((LinearLayout) inflatedView);
}
setLottieResource();
}
@@ -375,9 +424,9 @@ public class GlifLoadingLayout extends GlifLayout {
if (progressLayout == null) {
ViewStub viewStub = findManagedViewById(R.id.sud_loading_layout_illustration_stub);
if (viewStub != null) {
- View inflateView = viewStub.inflate();
- if (inflateView instanceof LinearLayout) {
- updateContentPadding((LinearLayout) inflateView);
+ inflatedView = viewStub.inflate();
+ if (inflatedView instanceof LinearLayout) {
+ updateContentPadding((LinearLayout) inflatedView);
}
setIllustrationResource();
}
@@ -478,6 +527,16 @@ public class GlifLoadingLayout extends GlifLayout {
}
}
+ /** Returns whether the layout is waiting for animation finish or not. */
+ public boolean isFinishing() {
+ LottieAnimationView lottieAnimationView = findLottieAnimationView();
+ if (lottieAnimationView != null) {
+ return !animationFinishListeners.isEmpty() && lottieAnimationView.getRepeatCount() == 0;
+ } else {
+ return false;
+ }
+ }
+
@AnimationType
public int getAnimationType() {
if (findLottieAnimationView() != null && isLottieLayoutVisible()) {
@@ -692,6 +751,7 @@ public class GlifLoadingLayout extends GlifLayout {
private final Handler handler;
private final Runnable runnable;
+ private final GlifLoadingLayout glifLoadingLayout;
private final LottieAnimationView lottieAnimationView;
@VisibleForTesting
@@ -723,6 +783,7 @@ public class GlifLoadingLayout extends GlifLayout {
if (runnable == null) {
throw new NullPointerException("Runnable can not be null");
}
+ this.glifLoadingLayout = glifLoadingLayout;
this.runnable = runnable;
this.handler = new Handler(Looper.getMainLooper());
this.lottieAnimationView = glifLoadingLayout.findLottieAnimationView();
@@ -731,7 +792,7 @@ public class GlifLoadingLayout extends GlifLayout {
lottieAnimationView.setRepeatCount(0);
lottieAnimationView.addAnimatorListener(animatorListener);
if (finishWithMinimumDuration > 0) {
- handler.postDelayed(runnable, finishWithMinimumDuration);
+ handler.postDelayed(this::onAnimationFinished, finishWithMinimumDuration);
}
} else {
onAnimationFinished();
@@ -745,6 +806,7 @@ public class GlifLoadingLayout extends GlifLayout {
if (lottieAnimationView != null) {
lottieAnimationView.removeAnimatorListener(animatorListener);
}
+ glifLoadingLayout.animationFinishListeners.remove(this);
}
}
diff --git a/lottie_loading_layout/src/com/google/android/setupdesign/LoadingFooterBarMixin.java b/lottie_loading_layout/src/com/google/android/setupdesign/LoadingFooterBarMixin.java
new file mode 100644
index 0000000..fcc2fff
--- /dev/null
+++ b/lottie_loading_layout/src/com/google/android/setupdesign/LoadingFooterBarMixin.java
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ */
+
+package com.google.android.setupdesign;
+
+import android.util.AttributeSet;
+import android.widget.LinearLayout;
+import androidx.annotation.Nullable;
+import com.google.android.setupcompat.internal.TemplateLayout;
+import com.google.android.setupcompat.template.FooterBarMixin;
+
+/** A {@link Mixin} to get the container of footer bar for usage. */
+public class LoadingFooterBarMixin extends FooterBarMixin {
+
+ /**
+ * Creates a mixin for managing buttons on the footer.
+ *
+ * @param layout The {@link TemplateLayout} containing this mixin.
+ * @param attrs XML attributes given to the layout.
+ * @param defStyleAttr The default style attribute as given to the constructor of the layout.
+ */
+ public LoadingFooterBarMixin(
+ TemplateLayout layout, @Nullable AttributeSet attrs, int defStyleAttr) {
+ super(layout, attrs, defStyleAttr);
+ }
+
+ @Override
+ public LinearLayout getButtonContainer() {
+ return super.getButtonContainer();
+ }
+}
diff --git a/main/res/values-night/colors.xml b/main/res/values-night/colors.xml
index 9fc8f32..74a583e 100644
--- a/main/res/values-night/colors.xml
+++ b/main/res/values-night/colors.xml
@@ -34,7 +34,6 @@
<color name="sud_system_accent_icon_text_button">@color/accent_icon_text_color_device_default_dark</color>
<color name="sud_system_dividing_line">@color/dividing_line_color_device_default_dark</color>
-
- <color name="sud_system_accent_primary">@color/system_accent2_200</color>
+ <color name="sud_portal_pending_progress">@color/sud_portal_pending_progress_dark</color>
</resources> \ No newline at end of file
diff --git a/main/res/values-v31/colors.xml b/main/res/values-v31/colors.xml
index 7b2ed75..b2067c1 100644
--- a/main/res/values-v31/colors.xml
+++ b/main/res/values-v31/colors.xml
@@ -27,51 +27,39 @@
<color name="sud_dynamic_color_accent_glif_v3_dark">@color/sud_system_accent1_200</color>
<color name="sud_dynamic_color_accent_glif_v3_light">@color/sud_system_accent1_600</color>
- <color name="sud_system_accent1_200">@android:color/system_accent1_200</color>
- <color name="sud_system_accent1_600">@android:color/system_accent1_600</color>
-
-
-
- <color name="sud_system_accent2_0">@android:color/system_accent2_0</color>
- <color name="sud_system_accent2_50">@android:color/system_accent2_50</color>
- <color name="sud_system_accent2_100">@android:color/system_accent2_100</color>
-
- <color name="sud_system_accent2_200">@android:color/system_accent2_200</color>
+ <color name="sud_system_accent1_100">@android:color/system_accent1_100</color>
- <color name="sud_system_accent2_300">@android:color/system_accent2_300</color>
+ <color name="sud_system_accent1_200">@android:color/system_accent1_200</color>
- <color name="sud_system_accent2_400">@android:color/system_accent2_400</color>
+ <color name="sud_system_accent1_600">@android:color/system_accent1_600</color>
- <color name="sud_system_accent2_500">@android:color/system_accent2_500</color>
- <color name="sud_system_accent2_600">@android:color/system_accent2_600</color>
- <color name="sud_system_accent2_700">@android:color/system_accent2_700</color>
+ <color name="sud_system_neutral1_0">@android:color/system_neutral1_0</color>
- <color name="sud_system_accent2_800">@android:color/system_accent2_800</color>
+ <color name="sud_system_neutral1_50">@android:color/system_neutral1_50</color>
- <color name="sud_system_accent2_900">@android:color/system_accent2_900</color>
+ <color name="sud_system_neutral1_800">@android:color/system_neutral1_800</color>
- <color name="sud_system_accent2_1000">@android:color/system_accent2_1000</color>
+ <color name="sud_system_neutral1_900">@android:color/system_neutral1_900</color>
- <color name="sud_system_neutral1_900">@android:color/system_neutral1_900</color>
- <color name="sud_system_neutral1_50">@android:color/system_neutral1_50</color>
+ <color name="sud_system_neutral2_50">@android:color/system_neutral1_50</color>
- <color name="sud_system_neutral2_700">@android:color/system_neutral2_700</color>
+ <color name="sud_system_neutral2_100">@android:color/system_neutral1_100</color>
<color name="sud_system_neutral2_200">@android:color/system_neutral2_200</color>
- <color name="sud_system_neutral2_500">@android:color/system_neutral2_500</color>
+ <color name="sud_system_neutral2_300">@android:color/system_accent2_300</color>
<color name="sud_system_neutral2_400">@android:color/system_neutral2_400</color>
- <color name="sud_system_neutral2_300">@android:color/system_accent2_300</color>
+ <color name="sud_system_neutral2_500">@android:color/system_neutral2_500</color>
- <color name="sud_system_accent1_100">@android:color/system_accent1_100</color>
+ <color name="sud_system_neutral2_700">@android:color/system_neutral2_700</color>
<color name="sud_system_primary_text">@color/sud_system_neutral1_900</color>
diff --git a/main/res/values/colors.xml b/main/res/values/colors.xml
index b8a1497..4ce7602 100644
--- a/main/res/values/colors.xml
+++ b/main/res/values/colors.xml
@@ -69,35 +69,38 @@
<color name="sud_dynamic_color_accent_glif_v3_light">@color/sud_color_accent_glif_v3_light</color>
- <color name="system_accent1_200">#71D8C7</color>
- <!-- Shade of the accent system color at 40% lightness.
- This value can be overlaid at runtime by OverlayManager RROs. -->
- <color name="system_accent1_600">#006C5F</color>
+ <color name="sud_system_accent1_100">#8DF5E3</color>
- <color name="system_accent2_0">#ffffff</color>
+ <color name="sud_system_accent1_200">#71D8C7</color>
- <color name="system_accent2_50">#CDFAF1</color>
+ <color name="sud_system_accent1_600">#006C5F</color>
- <color name="system_accent2_100">#BFEBE3</color>
- <color name="system_accent2_200">#A4CFC7</color>
- <color name="system_accent2_300">#89B4AC</color>
+ <color name="sud_system_neutral1_0">#ffffff</color>
- <color name="system_accent2_400">#6F9991</color>
+ <color name="sud_system_neutral1_50">#f0f0f0</color>
- <color name="system_accent2_500">#537C75</color>
+ <color name="sud_system_neutral1_800">#303030</color>
- <color name="system_accent2_600">#3D665F</color>
+ <color name="sud_system_neutral1_900">#1b1b1b</color>
- <color name="system_accent2_700">#254E47</color>
- <color name="system_accent2_800">#0C3731</color>
- <color name="system_accent2_900">#00211C</color>
+ <color name="sud_system_neutral2_50">#f0f0f0</color>
- <color name="system_accent2_1000">#000000</color>
+ <color name="sud_system_neutral2_100">#e2e2e2</color>
+
+ <color name="sud_system_neutral2_200">#c6c6c6</color>
+
+ <color name="sud_system_neutral2_300">#ababab</color>
+
+ <color name="sud_system_neutral2_400">#909090</color>
+
+ <color name="sud_system_neutral2_500">#757575</color>
+
+ <color name="sud_system_neutral2_700">#464646</color>
<color name="error_color_device_default_dark">#ec928e</color>
@@ -112,6 +115,10 @@
<color name="fallback_color_device_default_light">#1A73E8</color>
+ <color name="sud_portal_pending_progress_light">#fdc69c</color>
+
+ <color name="sud_portal_pending_progress_dark">#b06000</color>
+
<color name="primary_text_color_device_default_dark">#EDF2EB</color>
<color name="primary_text_color_device_default_light">#181C14</color>
@@ -162,7 +169,5 @@
<color name="sud_system_button_text">@color/button_text_color_device_default</color>
<color name="sud_system_dividing_line">@color/dividing_line_color_device_default_light</color>
-
- <color name="sud_system_accent_primary">@color/system_accent2_600</color>
-
+ <color name="sud_portal_pending_progress">@color/sud_portal_pending_progress_light</color>
</resources>
diff --git a/main/src/com/google/android/setupdesign/GlifLayout.java b/main/src/com/google/android/setupdesign/GlifLayout.java
index c9e159e..829e3d7 100644
--- a/main/src/com/google/android/setupdesign/GlifLayout.java
+++ b/main/src/com/google/android/setupdesign/GlifLayout.java
@@ -458,6 +458,12 @@ public class GlifLayout extends PartnerCustomizationLayout {
/** Updates the background color of this layout with the partner-customizable background color. */
private void updateContentBackgroundColorWithPartnerConfig() {
+ // If full dynamic color enabled which means this activity is running outside of setup
+ // flow, the colors should refer to R.style.SudFullDynamicColorThemeGlifV3.
+ if (useFullDynamicColor()) {
+ return;
+ }
+
@ColorInt
int color =
PartnerConfigHelper.get(getContext())
diff --git a/main/src/com/google/android/setupdesign/items/ItemViewHolder.java b/main/src/com/google/android/setupdesign/items/ItemViewHolder.java
index f79b2b6..3cffddd 100644
--- a/main/src/com/google/android/setupdesign/items/ItemViewHolder.java
+++ b/main/src/com/google/android/setupdesign/items/ItemViewHolder.java
@@ -20,7 +20,11 @@ import androidx.recyclerview.widget.RecyclerView;
import android.view.View;
import com.google.android.setupdesign.DividerItemDecoration;
-class ItemViewHolder extends RecyclerView.ViewHolder
+/**
+ * ViewHolder for the RecyclerItemAdapter that describes an item view and metadata about its place
+ * within the RecyclerView.
+ */
+public class ItemViewHolder extends RecyclerView.ViewHolder
implements DividerItemDecoration.DividedViewHolder {
private boolean isEnabled;
diff --git a/main/src/com/google/android/setupdesign/items/RecyclerItemAdapter.java b/main/src/com/google/android/setupdesign/items/RecyclerItemAdapter.java
index 2492a9b..dbbda29 100644
--- a/main/src/com/google/android/setupdesign/items/RecyclerItemAdapter.java
+++ b/main/src/com/google/android/setupdesign/items/RecyclerItemAdapter.java
@@ -61,6 +61,7 @@ public class RecyclerItemAdapter extends RecyclerView.Adapter<ItemViewHolder>
private final ItemHierarchy itemHierarchy;
@VisibleForTesting public final boolean applyPartnerHeavyThemeResource;
+ @VisibleForTesting public final boolean useFullDynamicColor;
private OnItemSelectedListener listener;
public RecyclerItemAdapter(ItemHierarchy hierarchy) {
@@ -68,7 +69,15 @@ public class RecyclerItemAdapter extends RecyclerView.Adapter<ItemViewHolder>
}
public RecyclerItemAdapter(ItemHierarchy hierarchy, boolean applyPartnerHeavyThemeResource) {
+ this(hierarchy, applyPartnerHeavyThemeResource, /* useFullDynamicColor= */ false);
+ }
+
+ public RecyclerItemAdapter(
+ ItemHierarchy hierarchy,
+ boolean applyPartnerHeavyThemeResource,
+ boolean useFullDynamicColor) {
this.applyPartnerHeavyThemeResource = applyPartnerHeavyThemeResource;
+ this.useFullDynamicColor = useFullDynamicColor;
itemHierarchy = hierarchy;
itemHierarchy.registerObserver(this);
}
@@ -118,7 +127,9 @@ public class RecyclerItemAdapter extends RecyclerView.Adapter<ItemViewHolder>
} else {
background = view.getBackground();
if (background == null) {
- if (applyPartnerHeavyThemeResource) {
+ // If full dynamic color enabled which means this activity is running outside of setup
+ // flow, the colors should refer to R.style.SudFullDynamicColorThemeGlifV3.
+ if (applyPartnerHeavyThemeResource && !useFullDynamicColor) {
int color =
PartnerConfigHelper.get(view.getContext())
.getColor(view.getContext(), PartnerConfig.CONFIG_LAYOUT_BACKGROUND_COLOR);
diff --git a/main/src/com/google/android/setupdesign/template/RecyclerMixin.java b/main/src/com/google/android/setupdesign/template/RecyclerMixin.java
index 169e995..b327060 100644
--- a/main/src/com/google/android/setupdesign/template/RecyclerMixin.java
+++ b/main/src/com/google/android/setupdesign/template/RecyclerMixin.java
@@ -127,13 +127,15 @@ public class RecyclerMixin implements Mixin {
final ItemHierarchy inflated = new ItemInflater(context).inflate(entries);
boolean applyPartnerHeavyThemeResource = false;
+ boolean useFullDynamicColor = false;
if (templateLayout instanceof GlifLayout) {
applyPartnerHeavyThemeResource =
((GlifLayout) templateLayout).shouldApplyPartnerHeavyThemeResource();
+ useFullDynamicColor = ((GlifLayout) templateLayout).useFullDynamicColor();
}
final RecyclerItemAdapter adapter =
- new RecyclerItemAdapter(inflated, applyPartnerHeavyThemeResource);
+ new RecyclerItemAdapter(inflated, applyPartnerHeavyThemeResource, useFullDynamicColor);
adapter.setHasStableIds(a.getBoolean(R.styleable.SudRecyclerMixin_sudHasStableIds, false));
setAdapter(adapter);
}
diff --git a/main/src/com/google/android/setupdesign/util/ItemStyler.java b/main/src/com/google/android/setupdesign/util/ItemStyler.java
index b58945d..ecddfd4 100644
--- a/main/src/com/google/android/setupdesign/util/ItemStyler.java
+++ b/main/src/com/google/android/setupdesign/util/ItemStyler.java
@@ -18,18 +18,17 @@ package com.google.android.setupdesign.util;
import android.annotation.TargetApi;
import android.content.Context;
-import android.graphics.Typeface;
+import android.os.Build;
import android.os.Build.VERSION_CODES;
-import android.util.TypedValue;
import android.view.Gravity;
import android.view.View;
-import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.Nullable;
import com.google.android.setupcompat.partnerconfig.PartnerConfig;
import com.google.android.setupcompat.partnerconfig.PartnerConfigHelper;
import com.google.android.setupdesign.R;
+import com.google.android.setupdesign.util.TextViewPartnerStyler.TextPartnerConfigs;
/**
* Applies the partner style of layout to the given View {@code view}. The user needs to check if
@@ -38,92 +37,92 @@ import com.google.android.setupdesign.R;
public final class ItemStyler {
/**
- * Applies the heavy theme partner configs to the given view {@code view}. The user needs to check
- * before calling this method:
+ * Applies the heavy theme partner configs to the given listItemView {@code listItemView}. The
+ * user needs to check before calling this method:
*
- * <p>1) If the {@code view} should apply heavy theme resource by calling {@link
+ * <p>1) If the {@code listItemView} 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
- * 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}.
+ * <p>2) If the layout of the {@code listItemView} contains fixed resource IDs which attempts to
+ * apply 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 heavy theme styles
+ * @param listItemView A view would be applied heavy theme styles
*/
@TargetApi(VERSION_CODES.JELLY_BEAN_MR1)
- public static void applyPartnerCustomizationItemStyle(@Nullable View view) {
- if (view == null) {
+ public static void applyPartnerCustomizationItemStyle(@Nullable View listItemView) {
+ if (listItemView == null) {
return;
}
-
- final Context context = view.getContext();
-
- if (!PartnerStyleHelper.shouldApplyPartnerHeavyThemeResource(view)) {
+ if (!PartnerStyleHelper.shouldApplyPartnerHeavyThemeResource(listItemView)) {
return;
}
- // TODO: Move to TextViewPartnerStyler in ItemStyler
- final TextView titleView = view.findViewById(R.id.sud_items_title);
+ final TextView titleTextView = listItemView.findViewById(R.id.sud_items_title);
+ // apply title text style
+ applyPartnerCustomizationItemTitleStyle(titleTextView);
- if (PartnerConfigHelper.get(context)
- .isPartnerConfigAvailable(PartnerConfig.CONFIG_ITEMS_TITLE_TEXT_SIZE)) {
- final float titleSize =
- PartnerConfigHelper.get(context)
- .getDimension(context, PartnerConfig.CONFIG_ITEMS_TITLE_TEXT_SIZE);
- titleView.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleSize);
+ // adjust list item view gravity
+ TextView summaryTextView = listItemView.findViewById(R.id.sud_items_summary);
+ if (summaryTextView.getVisibility() == View.GONE && listItemView instanceof LinearLayout) {
+ // Set list items to vertical center when there is no summary.
+ ((LinearLayout) listItemView).setGravity(Gravity.CENTER_VERTICAL);
}
- if (PartnerConfigHelper.get(context)
- .isPartnerConfigAvailable(PartnerConfig.CONFIG_ITEMS_TITLE_FONT_FAMILY)) {
+ // apply summary text style
+ applyPartnerCustomizationItemSummaryStyle(summaryTextView);
- final String textFont =
- PartnerConfigHelper.get(context)
- .getString(context, PartnerConfig.CONFIG_ITEMS_TITLE_FONT_FAMILY);
-
- final Typeface typeface = Typeface.create(textFont, Typeface.NORMAL);
-
- titleView.setTypeface(typeface);
- }
-
- TextView summaryView = view.findViewById(R.id.sud_items_summary);
- if (summaryView.getVisibility() == View.GONE && view instanceof LinearLayout) {
- // Set list items to vertical center when no summary.
- ((LinearLayout) view).setGravity(Gravity.CENTER_VERTICAL);
- }
+ // apply list item view style
+ applyPartnerCustomizationItemViewLayoutStyle(listItemView);
+ }
- if (PartnerConfigHelper.get(context)
- .isPartnerConfigAvailable(PartnerConfig.CONFIG_ITEMS_SUMMARY_TEXT_SIZE)) {
- final float summarySize =
- PartnerConfigHelper.get(context)
- .getDimension(context, PartnerConfig.CONFIG_ITEMS_SUMMARY_TEXT_SIZE);
- summaryView.setTextSize(TypedValue.COMPLEX_UNIT_PX, summarySize);
+ /**
+ * Applies the partner heavy style to the given list item title text view. Will check the current
+ * text view enabled the partner customized heavy theme configurations before applying.
+ *
+ * @param titleTextView A textView of a list item title text.
+ */
+ public static void applyPartnerCustomizationItemTitleStyle(TextView titleTextView) {
+ if (!PartnerStyleHelper.shouldApplyPartnerHeavyThemeResource(titleTextView)) {
+ return;
}
+ TextViewPartnerStyler.applyPartnerCustomizationStyle(
+ titleTextView,
+ new TextPartnerConfigs(
+ null,
+ null,
+ PartnerConfig.CONFIG_ITEMS_TITLE_TEXT_SIZE,
+ PartnerConfig.CONFIG_ITEMS_TITLE_FONT_FAMILY,
+ null,
+ null,
+ PartnerStyleHelper.getLayoutGravity(titleTextView.getContext())));
+ }
- if (PartnerConfigHelper.get(context)
- .isPartnerConfigAvailable(PartnerConfig.CONFIG_ITEMS_SUMMARY_FONT_FAMILY)) {
-
- final String textFont =
- PartnerConfigHelper.get(context)
- .getString(context, PartnerConfig.CONFIG_ITEMS_SUMMARY_FONT_FAMILY);
-
- final Typeface typeface = Typeface.create(textFont, Typeface.NORMAL);
-
- summaryView.setTypeface(typeface);
+ /**
+ * Applies the partner heavy style to the given summary text view. Will check the current text
+ * view enabled the partner customized heavy theme configurations before applying.
+ *
+ * @param summaryTextView A textView of a list item summary text.
+ */
+ public static void applyPartnerCustomizationItemSummaryStyle(TextView summaryTextView) {
+ if (!PartnerStyleHelper.shouldApplyPartnerHeavyThemeResource(summaryTextView)) {
+ return;
}
- if (PartnerConfigHelper.get(context)
- .isPartnerConfigAvailable(PartnerConfig.CONFIG_ITEMS_SUMMARY_MARGIN_TOP)) {
- float summaryMarginTop =
- PartnerConfigHelper.get(context)
- .getDimension(context, PartnerConfig.CONFIG_ITEMS_SUMMARY_MARGIN_TOP);
- final ViewGroup.LayoutParams lp = summaryView.getLayoutParams();
- if (lp instanceof LinearLayout.LayoutParams) {
- final LinearLayout.LayoutParams mlp = (LinearLayout.LayoutParams) lp;
- mlp.setMargins(mlp.leftMargin, (int) summaryMarginTop, mlp.rightMargin, mlp.bottomMargin);
- summaryView.setLayoutParams(lp);
- }
- }
+ TextViewPartnerStyler.applyPartnerCustomizationStyle(
+ summaryTextView,
+ new TextPartnerConfigs(
+ null,
+ null,
+ PartnerConfig.CONFIG_ITEMS_SUMMARY_TEXT_SIZE,
+ PartnerConfig.CONFIG_ITEMS_SUMMARY_FONT_FAMILY,
+ PartnerConfig.CONFIG_ITEMS_SUMMARY_MARGIN_TOP,
+ null,
+ PartnerStyleHelper.getLayoutGravity(summaryTextView.getContext())));
+ }
+ private static void applyPartnerCustomizationItemViewLayoutStyle(@Nullable View listItemView) {
+ Context context = listItemView.getContext();
float paddingTop;
if (PartnerConfigHelper.get(context)
.isPartnerConfigAvailable(PartnerConfig.CONFIG_ITEMS_PADDING_TOP)) {
@@ -131,7 +130,7 @@ public final class ItemStyler {
PartnerConfigHelper.get(context)
.getDimension(context, PartnerConfig.CONFIG_ITEMS_PADDING_TOP);
} else {
- paddingTop = view.getPaddingTop();
+ paddingTop = listItemView.getPaddingTop();
}
float paddingBottom;
@@ -141,12 +140,24 @@ public final class ItemStyler {
PartnerConfigHelper.get(context)
.getDimension(context, PartnerConfig.CONFIG_ITEMS_PADDING_BOTTOM);
} else {
- paddingBottom = view.getPaddingBottom();
+ paddingBottom = listItemView.getPaddingBottom();
}
- if (paddingTop != view.getPaddingTop() || paddingBottom != view.getPaddingBottom()) {
- view.setPadding(
- view.getPaddingStart(), (int) paddingTop, view.getPaddingEnd(), (int) paddingBottom);
+ if (paddingTop != listItemView.getPaddingTop()
+ || paddingBottom != listItemView.getPaddingBottom()) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
+ listItemView.setPadding(
+ listItemView.getPaddingStart(),
+ (int) paddingTop,
+ listItemView.getPaddingEnd(),
+ (int) paddingBottom);
+ } else {
+ listItemView.setPadding(
+ listItemView.getPaddingLeft(),
+ (int) paddingTop,
+ listItemView.getPaddingRight(),
+ (int) paddingBottom);
+ }
}
if (PartnerConfigHelper.get(context)
@@ -154,7 +165,7 @@ public final class ItemStyler {
float minHeight =
PartnerConfigHelper.get(context)
.getDimension(context, PartnerConfig.CONFIG_ITEMS_MIN_HEIGHT);
- view.setMinimumHeight((int) minHeight);
+ listItemView.setMinimumHeight((int) minHeight);
}
}