diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-07-07 01:05:24 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-07-07 01:05:24 +0000 |
commit | 963f0a4e3d1ed54b517e45031e590bfd69174bff (patch) | |
tree | 3b082b212c713a9325c854beb6ec86e74f7f9323 | |
parent | c9152336e29e3b1a5579ece1404f4480ad6b696e (diff) | |
parent | db39f0a910b99b7247282074e01e09a6895aae77 (diff) | |
download | setupdesign-android14-mainline-resolv-release.tar.gz |
Snap for 10447354 from db39f0a910b99b7247282074e01e09a6895aae77 to mainline-resolv-releaseaml_res_341510000aml_res_341410010aml_res_341311030aml_res_341110000aml_res_340912000android14-mainline-resolv-release
Change-Id: I73d4a35cc06400b2cc9cc2cb41178c77aabc7070
69 files changed, 2418 insertions, 192 deletions
@@ -29,10 +29,11 @@ android_library { name: "setupdesign", static_libs: [ "androidx.annotation_annotation", + "androidx.appcompat_appcompat", "androidx.core_core", "androidx.legacy_legacy-support-core-ui", - "androidx.appcompat_appcompat", "androidx.recyclerview_recyclerview", + "androidx.window_window", "com.google.android.material_material", "error_prone_annotations", "setupcompat", @@ -47,6 +48,9 @@ android_library { "main/src/**/*.java", ], min_sdk_version: "14", + optimize: { + proguard_flags_files: ["proguard.flags"], + } } // @@ -8,4 +8,3 @@ pihuei@google.com prochinwang@google.com cipson@google.com #{LAST_RESORT_SUGGESTION} -luyota@google.com #{LAST_RESORT_SUGGESTION} diff --git a/lint-baseline.xml b/lint-baseline.xml index c369cea..6177906 100644 --- a/lint-baseline.xml +++ b/lint-baseline.xml @@ -3,101 +3,64 @@ <issue id="NewApi" - message="`android:datePickerDialogTheme` requires API level 21 (current min is 14)" - errorLine1=" <item name="android:datePickerDialogTheme">@style/SudDateTimePickerDialogTheme</item>" - errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> + message="`@android:interpolator/linear_out_slow_in` requires API level 21 (current min is 14)" + errorLine1=' android:interpolator="@android:interpolator/linear_out_slow_in"' + errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> <location - file="external/setupdesign/main/res/values/styles.xml" - line="291" - column="15"/> + file="external/setupdesign/main/res/anim/sud_pre_p_activity_close_enter.xml" + line="21" + column="9"/> </issue> <issue id="NewApi" - message="`android:timePickerDialogTheme` requires API level 21 (current min is 14)" - errorLine1=" <item name="android:timePickerDialogTheme">@style/SudDateTimePickerDialogTheme</item>" - errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> + message="`@android:interpolator/fast_out_slow_in` requires API level 21 (current min is 14)" + errorLine1=' android:interpolator="@android:interpolator/fast_out_slow_in"' + errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> <location - file="external/setupdesign/main/res/values/styles.xml" - line="292" - column="15"/> + file="external/setupdesign/main/res/anim/sud_pre_p_activity_open_exit.xml" + line="22" + column="9"/> </issue> <issue id="NewApi" - message="`android:datePickerDialogTheme` requires API level 21 (current min is 14)" - errorLine1=" <item name="android:datePickerDialogTheme">@style/SudDateTimePickerDialogTheme.Light</item>" - errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> + message="`android:datePickerDialogTheme` requires API level 21 (current min is 14)"> <location file="external/setupdesign/main/res/values/styles.xml" - line="302" - column="15"/> + line="371"/> </issue> <issue id="NewApi" - message="`android:timePickerDialogTheme` requires API level 21 (current min is 14)" - errorLine1=" <item name="android:timePickerDialogTheme">@style/SudDateTimePickerDialogTheme.Light</item>" - errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> + message="`android:datePickerDialogTheme` requires API level 21 (current min is 14)"> <location file="external/setupdesign/main/res/values/styles.xml" - line="303" - column="15"/> + line="385"/> </issue> <issue id="NewApi" - message="`android:stateListAnimator` requires API level 21 (current min is 14)" - errorLine1=" <item name="android:stateListAnimator">@null</item>" - errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> + message="`android:stateListAnimator` requires API level 21 (current min is 14)"> <location file="external/setupdesign/main/res/values/styles.xml" - line="523" - column="15"/> + line="718"/> </issue> <issue id="NewApi" - message="`android:fontFamily` requires API level 16 (current min is 14)" - errorLine1=" <item name="android:fontFamily">@string/sudFontSecondaryMedium</item>" - errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~"> + message="`android:timePickerDialogTheme` requires API level 21 (current min is 14)"> <location file="external/setupdesign/main/res/values/styles.xml" - line="619" - column="15"/> - </issue> - - <issue - id="NewApi" - message="Attribute `paddingStart` referenced here can result in a crash on some specific devices older than API 17 (current min is 14)" - errorLine1=" android:paddingStart="?attr/listPreferredItemPaddingLeft">" - errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> - <location - file="external/setupdesign/main/res/layout/sud_items_expandable_switch.xml" - line="38" - column="9"/> + line="372"/> </issue> <issue id="NewApi" - message="`@android:interpolator/linear_out_slow_in` requires API level 21 (current min is 14)" - errorLine1=" android:interpolator="@android:interpolator/linear_out_slow_in"" - errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> + message="`android:timePickerDialogTheme` requires API level 21 (current min is 14)"> <location - file="external/setupdesign/main/res/anim/sud_pre_p_activity_close_enter.xml" - line="21" - column="9"/> - </issue> - - <issue - id="NewApi" - message="`@android:interpolator/fast_out_slow_in` requires API level 21 (current min is 14)" - errorLine1=" android:interpolator="@android:interpolator/fast_out_slow_in"" - errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> - <location - file="external/setupdesign/main/res/anim/sud_pre_p_activity_open_exit.xml" - line="22" - column="9"/> + file="external/setupdesign/main/res/values/styles.xml" + line="386"/> </issue> -</issues> +</issues>
\ No newline at end of file diff --git a/lottie_loading_layout/res/layout/sud_glif_fullscreen_loading_embedded_template_card.xml b/lottie_loading_layout/res/layout/sud_glif_fullscreen_loading_embedded_template_card.xml new file mode 100644 index 0000000..b24fda4 --- /dev/null +++ b/lottie_loading_layout/res/layout/sud_glif_fullscreen_loading_embedded_template_card.xml @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright (C) 2022 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" + android:id="@+id/suc_layout_status" + style="@style/SudGlifCardBackground" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:fitsSystemWindows="true" + android:gravity="center_horizontal" + android:orientation="vertical"> + + <View + android:layout_width="0dp" + android:layout_height="0dp" + android:layout_weight="1" + android:visibility="invisible" /> + + <com.google.android.setupdesign.view.IntrinsicSizeFrameLayout + style="@style/SudGlifCardContainer" + android:layout_width="@dimen/sud_glif_card_width" + android:layout_height="wrap_content" + android:height="@dimen/sud_glif_card_height"> + + <include layout="@layout/sud_glif_fullscreen_loading_embedded_template_content" /> + + </com.google.android.setupdesign.view.IntrinsicSizeFrameLayout> + + <View + android:layout_width="0dp" + android:layout_height="0dp" + android:layout_weight="1" + android:visibility="invisible" /> + +</LinearLayout> diff --git a/lottie_loading_layout/res/layout/sud_glif_fullscreen_loading_embedded_template_content.xml b/lottie_loading_layout/res/layout/sud_glif_fullscreen_loading_embedded_template_content.xml new file mode 100644 index 0000000..e1dc7c4 --- /dev/null +++ b/lottie_loading_layout/res/layout/sud_glif_fullscreen_loading_embedded_template_content.xml @@ -0,0 +1,96 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright (C) 2022 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. +--> +<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="match_parent"> + + <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_fullscreen_lottie_layout" /> + + <LinearLayout + 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_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> + +</FrameLayout> diff --git a/lottie_loading_layout/res/layout/sud_glif_loading_embedded_template_card.xml b/lottie_loading_layout/res/layout/sud_glif_loading_embedded_template_card.xml new file mode 100644 index 0000000..9092e1a --- /dev/null +++ b/lottie_loading_layout/res/layout/sud_glif_loading_embedded_template_card.xml @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright (C) 2022 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" + android:id="@+id/suc_layout_status" + style="@style/SudGlifCardBackground" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:fitsSystemWindows="true" + android:gravity="center_horizontal" + android:orientation="vertical"> + + <View + android:layout_width="0dp" + android:layout_height="0dp" + android:layout_weight="1" + android:visibility="invisible" /> + + <com.google.android.setupdesign.view.IntrinsicSizeFrameLayout + style="@style/SudGlifCardContainer" + android:layout_width="@dimen/sud_glif_card_width" + android:layout_height="wrap_content" + android:height="@dimen/sud_glif_card_height"> + + <include layout="@layout/sud_glif_loading_embedded_template_content" /> + + </com.google.android.setupdesign.view.IntrinsicSizeFrameLayout> + + <View + android:layout_width="0dp" + android:layout_height="0dp" + android:layout_weight="1" + android:visibility="invisible" /> + +</LinearLayout> diff --git a/lottie_loading_layout/res/layout/sud_glif_loading_embedded_template_compat.xml b/lottie_loading_layout/res/layout/sud_glif_loading_embedded_template_compat.xml new file mode 100644 index 0000000..b79851a --- /dev/null +++ b/lottie_loading_layout/res/layout/sud_glif_loading_embedded_template_compat.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright (C) 2022 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. +--> + +<com.google.android.setupcompat.view.StatusBarBackgroundLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/suc_layout_status" + android:layout_width="match_parent" + android:layout_height="match_parent"> + + <include layout="@layout/sud_glif_loading_embedded_template_content" /> + +</com.google.android.setupcompat.view.StatusBarBackgroundLayout> diff --git a/lottie_loading_layout/res/layout/sud_glif_loading_embedded_template_content.xml b/lottie_loading_layout/res/layout/sud_glif_loading_embedded_template_content.xml new file mode 100644 index 0000000..a49aead --- /dev/null +++ b/lottie_loading_layout/res/layout/sud_glif_loading_embedded_template_content.xml @@ -0,0 +1,80 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright (C) 2022 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" /> + + <!-- Ignore UnusedAttribute: scrollIndicators is new in M. Default to no indicators in older + versions. --> + <com.google.android.setupdesign.view.BottomScrollView + android:id="@+id/sud_scroll_view" + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_weight="1" + android:fillViewport="true" + android:scrollIndicators="?attr/sudScrollIndicators" + tools:ignore="UnusedAttribute"> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> + + <include layout="@layout/sud_glif_header" /> + + <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" /> + + <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" /> + + <FrameLayout + android:id="@+id/sud_layout_content" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:visibility="gone" /> + + </LinearLayout> + + </com.google.android.setupdesign.view.BottomScrollView> + + <ViewStub + android:id="@+id/suc_layout_footer" + android:layout_width="match_parent" + android:layout_height="wrap_content" /> + +</LinearLayout> diff --git a/lottie_loading_layout/res/values-sw600dp-v31/layouts.xml b/lottie_loading_layout/res/values-sw600dp-v31/layouts.xml index f627c06..534b956 100644 --- a/lottie_loading_layout/res/values-sw600dp-v31/layouts.xml +++ b/lottie_loading_layout/res/values-sw600dp-v31/layouts.xml @@ -17,5 +17,7 @@ <resources xmlns:tools="http://schemas.android.com/tools"> <item name="sud_glif_loading_template" type="layout" tools:ignore="UnusedResources">@layout/sud_glif_loading_template_card</item> + <item name="sud_glif_loading_embedded_template" type="layout" tools:ignore="UnusedResources">@layout/sud_glif_loading_embedded_template_card</item> <item name="sud_glif_fullscreen_loading_template" type="layout" tools:ignore="UnusedResources">@layout/sud_glif_fullscreen_loading_template_card</item> + <item name="sud_glif_fullscreen_loading_embedded_template" type="layout" tools:ignore="UnusedResources">@layout/sud_glif_fullscreen_loading_embedded_template_card</item> </resources> diff --git a/lottie_loading_layout/res/values-sw600dp/layouts.xml b/lottie_loading_layout/res/values-sw600dp/layouts.xml index 9fe5404..3afbee7 100644 --- a/lottie_loading_layout/res/values-sw600dp/layouts.xml +++ b/lottie_loading_layout/res/values-sw600dp/layouts.xml @@ -17,4 +17,5 @@ <resources xmlns:tools="http://schemas.android.com/tools"> <item name="sud_glif_loading_template" type="layout" tools:ignore="UnusedResources">@layout/sud_glif_loading_template_card</item> + <item name="sud_glif_loading_embedded_template" type="layout" tools:ignore="UnusedResources">@layout/sud_glif_loading_embedded_template_card</item> </resources> diff --git a/lottie_loading_layout/res/values/layouts.xml b/lottie_loading_layout/res/values/layouts.xml index 9ea5e67..8298bb1 100644 --- a/lottie_loading_layout/res/values/layouts.xml +++ b/lottie_loading_layout/res/values/layouts.xml @@ -17,5 +17,7 @@ <resources xmlns:tools="http://schemas.android.com/tools"> <item name="sud_glif_loading_template" type="layout" tools:ignore="UnusedResources">@layout/sud_glif_loading_template_compat</item> + <item name="sud_glif_loading_embedded_template" type="layout" tools:ignore="UnusedResources">@layout/sud_glif_loading_embedded_template_compat</item> <item name="sud_glif_fullscreen_loading_template" type="layout" tools:ignore="UnusedResources">@layout/sud_glif_loading_template_compat</item> + <item name="sud_glif_fullscreen_loading_embedded_template" type="layout" tools:ignore="UnusedResources">@layout/sud_glif_loading_embedded_template_compat</item> </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 db0b1f3..d4e1961 100644 --- a/lottie_loading_layout/src/com/google/android/setupdesign/GlifLoadingLayout.java +++ b/lottie_loading_layout/src/com/google/android/setupdesign/GlifLoadingLayout.java @@ -17,26 +17,28 @@ package com.google.android.setupdesign; import static com.google.android.setupcompat.partnerconfig.Util.isNightMode; +import static java.lang.Math.min; import android.animation.Animator; import android.animation.Animator.AnimatorListener; -import android.annotation.TargetApi; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.content.res.Configuration; import android.content.res.TypedArray; -import android.graphics.Color; import android.graphics.ColorFilter; import android.os.Build; +import android.os.Build.VERSION; import android.os.Build.VERSION_CODES; import android.os.Bundle; +import android.os.PersistableBundle; import android.provider.Settings; import android.provider.Settings.SettingNotFoundException; import android.util.AttributeSet; import android.util.Log; import android.view.LayoutInflater; import android.view.View; +import android.view.View.MeasureSpec; import android.view.ViewGroup; import android.view.ViewStub; import android.widget.LinearLayout; @@ -50,7 +52,6 @@ import androidx.annotation.VisibleForTesting; import com.airbnb.lottie.LottieAnimationView; import com.airbnb.lottie.LottieDrawable; import com.airbnb.lottie.LottieProperty; -import com.airbnb.lottie.SimpleColorFilter; import com.airbnb.lottie.model.KeyPath; import com.airbnb.lottie.value.LottieValueCallback; import com.airbnb.lottie.value.SimpleLottieValueCallback; @@ -62,14 +63,13 @@ 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.util.LayoutStyler; +import com.google.android.setupdesign.util.LottieAnimationHelper; 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; /** * A GLIF themed layout with a {@link com.airbnb.lottie.LottieAnimationView} to showing lottie @@ -88,11 +88,11 @@ public class GlifLoadingLayout extends GlifLayout { @VisibleForTesting @RawRes int customLottieResource = 0; - @VisibleForTesting Map<KeyPath, SimpleColorFilter> customizationMap = new HashMap<>(); - private AnimatorListener animatorListener; private Runnable nextActionRunnable; private boolean workFinished; + protected static final String GLIF_LAYOUT_TYPE = "GlifLayoutType"; + protected static final String LOADING_LAYOUT = "LoadingLayout"; @VisibleForTesting public boolean runRunnable; @VisibleForTesting @@ -116,7 +116,6 @@ public class GlifLoadingLayout extends GlifLayout { init(attrs, R.attr.sudLayoutTheme); } - @TargetApi(VERSION_CODES.HONEYCOMB) public GlifLoadingLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(attrs, defStyleAttr); @@ -230,7 +229,6 @@ public class GlifLoadingLayout extends GlifLayout { if (!illustrationType.equals(type)) { illustrationType = type; - customizationMap.clear(); } switch (type) { @@ -453,7 +451,7 @@ public class GlifLoadingLayout extends GlifLayout { paddingBottom = (int) configPaddingBottom - (int) - Math.min( + min( configPaddingBottom, getButtonContainerHeight(footerBarMixin.getButtonContainer())); } @@ -521,7 +519,13 @@ public class GlifLoadingLayout extends GlifLayout { lottieView.playAnimation(); setLottieLayoutVisibility(View.VISIBLE); setIllustrationLayoutVisibility(View.GONE); - applyThemeCustomization(); + LottieAnimationHelper.get() + .applyColor( + getContext(), + findLottieAnimationView(), + isNightMode(getResources().getConfiguration()) + ? animationConfig.getDarkThemeCustomization() + : animationConfig.getLightThemeCustomization()); } else { setLottieLayoutVisibility(View.GONE); setIllustrationLayoutVisibility(View.VISIBLE); @@ -654,43 +658,6 @@ public class GlifLoadingLayout extends GlifLayout { } } - @VisibleForTesting - protected void loadCustomization() { - if (customizationMap.isEmpty()) { - PartnerConfigHelper helper = PartnerConfigHelper.get(getContext()); - List<String> lists = - helper.getStringArray( - getContext(), - isNightMode(getResources().getConfiguration()) - ? animationConfig.getDarkThemeCustomization() - : animationConfig.getLightThemeCustomization()); - for (String item : lists) { - String[] splitItem = item.split(":"); - if (splitItem.length == 2) { - customizationMap.put( - new KeyPath("**", splitItem[0], "**"), - new SimpleColorFilter(Color.parseColor(splitItem[1]))); - } else { - Log.w(TAG, "incorrect format customization, value=" + item); - } - } - } - } - - @VisibleForTesting - protected void applyThemeCustomization() { - LottieAnimationView animationView = findLottieAnimationView(); - if (animationView != null) { - loadCustomization(); - for (KeyPath keyPath : customizationMap.keySet()) { - animationView.addValueCallback( - keyPath, - LottieProperty.COLOR_FILTER, - new LottieValueCallback<>(customizationMap.get(keyPath))); - } - } - } - @Nullable private View peekLottieLayout() { return findViewById(R.id.sud_layout_lottie_illustration); @@ -703,17 +670,28 @@ public class GlifLoadingLayout extends GlifLayout { @Override protected View onInflateTemplate(LayoutInflater inflater, int template) { + Context context = getContext(); if (template == 0) { boolean useFullScreenIllustration = - PartnerConfigHelper.get(getContext()) + PartnerConfigHelper.get(context) .getBoolean( - getContext(), + context, PartnerConfig.CONFIG_LOADING_LAYOUT_FULL_SCREEN_ILLUSTRATION_ENABLED, false); if (useFullScreenIllustration) { template = R.layout.sud_glif_fullscreen_loading_template; + + // if the activity is embedded should apply an embedded layout. + if (isEmbeddedActivityOnePaneEnabled(context)) { + template = R.layout.sud_glif_fullscreen_loading_embedded_template; + } } else { template = R.layout.sud_glif_loading_template; + + // if the activity is embedded should apply an embedded layout. + if (isEmbeddedActivityOnePaneEnabled(context)) { + template = R.layout.sud_glif_loading_embedded_template; + } } } return inflateTemplate(inflater, R.style.SudThemeGlif_Light, template); @@ -727,6 +705,16 @@ public class GlifLoadingLayout extends GlifLayout { return super.findContainer(containerId); } + @Override + protected void onDetachedFromWindow() { + if (VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + PersistableBundle bundle = new PersistableBundle(); + bundle.putString(GLIF_LAYOUT_TYPE, LOADING_LAYOUT); + setLayoutTypeMetrics(bundle); + super.onDetachedFromWindow(); + } + } + /** The progress config used to maps to different animation */ public enum LottieAnimationConfig { CONFIG_DEFAULT( diff --git a/lottie_loading_layout/src/com/google/android/setupdesign/util/LottieAnimationHelper.java b/lottie_loading_layout/src/com/google/android/setupdesign/util/LottieAnimationHelper.java new file mode 100644 index 0000000..e6cdc11 --- /dev/null +++ b/lottie_loading_layout/src/com/google/android/setupdesign/util/LottieAnimationHelper.java @@ -0,0 +1,134 @@ +/* + * Copyright (C) 2022 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.util; + +import android.content.Context; +import android.content.res.Resources; +import android.graphics.Color; +import android.util.Log; +import androidx.annotation.NonNull; +import androidx.annotation.VisibleForTesting; +import com.airbnb.lottie.LottieAnimationView; +import com.airbnb.lottie.LottieProperty; +import com.airbnb.lottie.SimpleColorFilter; +import com.airbnb.lottie.model.KeyPath; +import com.airbnb.lottie.value.LottieValueCallback; +import com.google.android.setupcompat.partnerconfig.PartnerConfig; +import com.google.android.setupcompat.partnerconfig.PartnerConfigHelper; +import com.google.android.setupcompat.util.BuildCompatUtils; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** A helper to help apply color on lottie animation */ +public class LottieAnimationHelper { + + private static final String TAG = "LottieAnimationHelper"; + + private static LottieAnimationHelper instance = null; + + @VisibleForTesting public final Map<String, Integer> colorResourceMapping; + + public static LottieAnimationHelper get() { + if (instance == null) { + instance = new LottieAnimationHelper(); + } + return instance; + } + + private LottieAnimationHelper() { + colorResourceMapping = new HashMap<>(); + } + + /** + * The color resource is from PartnerConfig, which is a string array and each string will be + * {key_path_name}:@{color_reference} or {key_path_name}:{color code} + */ + public void applyColor( + @NonNull Context context, LottieAnimationView lottieView, PartnerConfig partnerConfig) { + applyColor( + context, + lottieView, + PartnerConfigHelper.get(context).getStringArray(context, partnerConfig)); + } + + /** + * The color resource is from list of string and each string will be + * {key_path_name}:@{color_reference} or {key_path_name}:#{color code} + */ + public void applyColor( + @NonNull Context context, LottieAnimationView lottieView, List<String> colorMappings) { + applyColor(context, lottieView, parseColorMapping(context, colorMappings)); + } + + /** + * The color resource is from a color mapping table and the key is the keypath, and value is color + * Integer. + */ + public void applyColor( + @NonNull Context context, + LottieAnimationView lottieView, + Map<KeyPath, Integer> colorMappings) { + for (KeyPath keyPath : colorMappings.keySet()) { + lottieView.addValueCallback( + keyPath, + LottieProperty.COLOR_FILTER, + new LottieValueCallback<>(new SimpleColorFilter(colorMappings.get(keyPath)))); + } + } + + private Map<KeyPath, Integer> parseColorMapping( + @NonNull Context context, List<String> colorMappings) { + Map<KeyPath, Integer> customizationMap = new HashMap<>(); + for (String colorMapping : colorMappings) { + String[] splitItem = colorMapping.split(":"); + if (splitItem.length == 2) { + if (splitItem[1].charAt(0) == '#') { // color code + try { + customizationMap.put( + new KeyPath("**", splitItem[0], "**"), Color.parseColor(splitItem[1])); + } catch (IllegalArgumentException exception) { + Log.e(TAG, "Unknown color, value=" + colorMapping); + } + } else if (splitItem[1].charAt(0) == '@') { // color resource + int colorResourceId; + if (colorResourceMapping.containsKey(splitItem[1])) { + colorResourceId = colorResourceMapping.get(splitItem[1]); + } else { + colorResourceId = + context + .getResources() + .getIdentifier(splitItem[1].substring(1), "color", context.getPackageName()); + colorResourceMapping.put(splitItem[1], colorResourceId); + } + try { + customizationMap.put( + new KeyPath("**", splitItem[0], "**"), + context.getResources().getColor(colorResourceId)); + } catch (Resources.NotFoundException exception) { + Log.e(TAG, "Resource Not found, resource value=" + colorMapping); + } + } else { + Log.w(TAG, "incorrect format customization, value=" + colorMapping); + } + } else { + Log.w(TAG, "incorrect format customization, value=" + colorMapping); + } + } + return customizationMap; + } +} diff --git a/main/res/anim-night-v34/shared_x_axis_activity_close_enter.xml b/main/res/anim-night-v34/shared_x_axis_activity_close_enter.xml new file mode 100644 index 0000000..2496f2d --- /dev/null +++ b/main/res/anim-night-v34/shared_x_axis_activity_close_enter.xml @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (C) 2022 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. + --> + +<set xmlns:android="http://schemas.android.com/apk/res/android" + android:shareInterpolator="false" + android:showBackdrop="true" + android:backdropColor="@color/sud_glif_background_color_dark"> + + <alpha + android:fromAlpha="0.0" + android:toAlpha="1.0" + android:fillEnabled="true" + android:fillBefore="true" + android:fillAfter="true" + android:interpolator="@interpolator/standard_decelerate" + android:startOffset="100" + android:duration="350" /> + + <translate + android:fromXDelta="-25%" + android:toXDelta="0" + android:fillEnabled="true" + android:fillBefore="true" + android:fillAfter="true" + android:interpolator="@interpolator/fast_out_extra_slow_in" + android:startOffset="0" + android:duration="450" /> + +</set>
\ No newline at end of file diff --git a/main/res/anim-night-v34/shared_x_axis_activity_open_enter.xml b/main/res/anim-night-v34/shared_x_axis_activity_open_enter.xml new file mode 100644 index 0000000..a26b3e9 --- /dev/null +++ b/main/res/anim-night-v34/shared_x_axis_activity_open_enter.xml @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (C) 2022 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. + --> + +<set xmlns:android="http://schemas.android.com/apk/res/android" + android:shareInterpolator="false" + android:showBackdrop="true" + android:backdropColor="@color/sud_glif_background_color_dark"> + + <alpha + android:fromAlpha="0.0" + android:toAlpha="1.0" + android:fillEnabled="true" + android:fillBefore="true" + android:fillAfter="true" + android:interpolator="@interpolator/standard_decelerate" + android:startOffset="100" + android:duration="350" /> + + <translate + android:fromXDelta="25%" + android:toXDelta="0" + android:fillEnabled="true" + android:fillBefore="true" + android:fillAfter="true" + android:interpolator="@interpolator/fast_out_extra_slow_in" + android:startOffset="0" + android:duration="450" /> + +</set>
\ No newline at end of file diff --git a/main/res/anim-v34/shared_x_axis_activity_close_enter.xml b/main/res/anim-v34/shared_x_axis_activity_close_enter.xml new file mode 100644 index 0000000..54cfc89 --- /dev/null +++ b/main/res/anim-v34/shared_x_axis_activity_close_enter.xml @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (C) 2022 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. + --> + +<set xmlns:android="http://schemas.android.com/apk/res/android" + android:shareInterpolator="false" + android:showBackdrop="true" + android:backdropColor="@color/sud_glif_background_color_light"> + + <alpha + android:fromAlpha="0.0" + android:toAlpha="1.0" + android:fillEnabled="true" + android:fillBefore="true" + android:fillAfter="true" + android:interpolator="@interpolator/standard_decelerate" + android:startOffset="100" + android:duration="350" /> + + <translate + android:fromXDelta="-25%" + android:toXDelta="0" + android:fillEnabled="true" + android:fillBefore="true" + android:fillAfter="true" + android:interpolator="@interpolator/fast_out_extra_slow_in" + android:startOffset="0" + android:duration="450" /> + +</set>
\ No newline at end of file diff --git a/main/res/anim-v34/shared_x_axis_activity_close_enter_dynamic_color.xml b/main/res/anim-v34/shared_x_axis_activity_close_enter_dynamic_color.xml new file mode 100644 index 0000000..a9d0a82 --- /dev/null +++ b/main/res/anim-v34/shared_x_axis_activity_close_enter_dynamic_color.xml @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (C) 2022 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. + --> + +<set xmlns:android="http://schemas.android.com/apk/res/android" + android:shareInterpolator="false" + android:showBackdrop="true" + android:backdropColor="@color/sud_system_background_surface"> + + <alpha + android:fromAlpha="0.0" + android:toAlpha="1.0" + android:fillEnabled="true" + android:fillBefore="true" + android:fillAfter="true" + android:interpolator="@interpolator/standard_decelerate" + android:startOffset="100" + android:duration="350" /> + + <translate + android:fromXDelta="-25%" + android:toXDelta="0" + android:fillEnabled="true" + android:fillBefore="true" + android:fillAfter="true" + android:interpolator="@interpolator/fast_out_extra_slow_in" + android:startOffset="0" + android:duration="450" /> + +</set>
\ No newline at end of file diff --git a/main/res/anim-v34/shared_x_axis_activity_close_exit.xml b/main/res/anim-v34/shared_x_axis_activity_close_exit.xml new file mode 100644 index 0000000..e2a79e0 --- /dev/null +++ b/main/res/anim-v34/shared_x_axis_activity_close_exit.xml @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (C) 2022 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. + --> + +<set xmlns:android="http://schemas.android.com/apk/res/android" + android:shareInterpolator="false"> + + <alpha + android:fromAlpha="1.0" + android:toAlpha="0.0" + android:fillEnabled="true" + android:fillBefore="true" + android:fillAfter="true" + android:interpolator="@interpolator/standard_accelerate" + android:startOffset="0" + android:duration="100" /> + + <translate + android:fromXDelta="0" + android:toXDelta="25%" + android:fillEnabled="true" + android:fillBefore="true" + android:fillAfter="true" + android:interpolator="@interpolator/fast_out_extra_slow_in" + android:startOffset="0" + android:duration="450" /> + +</set>
\ No newline at end of file diff --git a/main/res/anim-v34/shared_x_axis_activity_open_enter.xml b/main/res/anim-v34/shared_x_axis_activity_open_enter.xml new file mode 100644 index 0000000..b0a5ca6 --- /dev/null +++ b/main/res/anim-v34/shared_x_axis_activity_open_enter.xml @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (C) 2022 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. + --> + +<set xmlns:android="http://schemas.android.com/apk/res/android" + android:shareInterpolator="false" + android:showBackdrop="true" + android:backdropColor="@color/sud_glif_background_color_light"> + + <alpha + android:fromAlpha="0.0" + android:toAlpha="1.0" + android:fillEnabled="true" + android:fillBefore="true" + android:fillAfter="true" + android:interpolator="@interpolator/standard_decelerate" + android:startOffset="100" + android:duration="350" /> + + <translate + android:fromXDelta="25%" + android:toXDelta="0" + android:fillEnabled="true" + android:fillBefore="true" + android:fillAfter="true" + android:interpolator="@interpolator/fast_out_extra_slow_in" + android:startOffset="0" + android:duration="450" /> + +</set>
\ No newline at end of file diff --git a/main/res/anim-v34/shared_x_axis_activity_open_enter_dynamic_color.xml b/main/res/anim-v34/shared_x_axis_activity_open_enter_dynamic_color.xml new file mode 100644 index 0000000..3d797cf --- /dev/null +++ b/main/res/anim-v34/shared_x_axis_activity_open_enter_dynamic_color.xml @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (C) 2022 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. + --> + +<set xmlns:android="http://schemas.android.com/apk/res/android" + android:shareInterpolator="false" + android:showBackdrop="true" + android:backdropColor="@color/sud_system_background_surface"> + + <alpha + android:fromAlpha="0.0" + android:toAlpha="1.0" + android:fillEnabled="true" + android:fillBefore="true" + android:fillAfter="true" + android:interpolator="@interpolator/standard_decelerate" + android:startOffset="100" + android:duration="350" /> + + <translate + android:fromXDelta="25%" + android:toXDelta="0" + android:fillEnabled="true" + android:fillBefore="true" + android:fillAfter="true" + android:interpolator="@interpolator/fast_out_extra_slow_in" + android:startOffset="0" + android:duration="450" /> + +</set>
\ No newline at end of file diff --git a/main/res/anim-v34/shared_x_axis_activity_open_exit.xml b/main/res/anim-v34/shared_x_axis_activity_open_exit.xml new file mode 100644 index 0000000..f55baeb --- /dev/null +++ b/main/res/anim-v34/shared_x_axis_activity_open_exit.xml @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (C) 2022 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. + --> + +<set xmlns:android="http://schemas.android.com/apk/res/android" + android:shareInterpolator="false"> + + <alpha + android:fromAlpha="1.0" + android:toAlpha="0.0" + android:fillEnabled="true" + android:fillBefore="true" + android:fillAfter="true" + android:interpolator="@interpolator/standard_accelerate" + android:startOffset="0" + android:duration="100" /> + + <translate + android:fromXDelta="0" + android:toXDelta="-25%" + android:fillEnabled="true" + android:fillBefore="true" + android:fillAfter="true" + android:interpolator="@interpolator/fast_out_extra_slow_in" + android:startOffset="0" + android:duration="450" /> + +</set>
\ No newline at end of file diff --git a/main/res/drawable/sud_dialog_background_dark.xml b/main/res/drawable/sud_dialog_background_dark.xml index 914cfec..38f727d 100644 --- a/main/res/drawable/sud_dialog_background_dark.xml +++ b/main/res/drawable/sud_dialog_background_dark.xml @@ -19,10 +19,6 @@ copy from abc_dialog_material_background.xml of Base.V7.Theme.AppCompat.Light.Dialog. --> <inset xmlns:android="http://schemas.android.com/apk/res/android"> - android:insetLeft="16dp" - android:insetTop="16dp" - android:insetRight="16dp" - android:insetBottom="16dp"> <shape android:shape="rectangle"> <corners android:radius="?attr/dialogCornerRadius" /> <solid android:color="@color/sud_glif_window_bg_dark_color" /> diff --git a/main/res/drawable/sud_dialog_background_light.xml b/main/res/drawable/sud_dialog_background_light.xml index 0302783..49280f4 100644 --- a/main/res/drawable/sud_dialog_background_light.xml +++ b/main/res/drawable/sud_dialog_background_light.xml @@ -19,10 +19,6 @@ copy from abc_dialog_material_background.xml of Base.V7.Theme.AppCompat.Light.Dialog. --> <inset xmlns:android="http://schemas.android.com/apk/res/android"> - android:insetLeft="16dp" - android:insetTop="16dp" - android:insetRight="16dp" - android:insetBottom="16dp"> <shape android:shape="rectangle"> <corners android:radius="?attr/dialogCornerRadius" /> <solid android:color="@color/sud_glif_window_bg_light_color" /> diff --git a/main/res/interpolator-v21/fast_out_extra_slow_in.xml b/main/res/interpolator-v21/fast_out_extra_slow_in.xml new file mode 100644 index 0000000..f296a82 --- /dev/null +++ b/main/res/interpolator-v21/fast_out_extra_slow_in.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (C) 2022 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 + --> + +<pathInterpolator xmlns:android="http://schemas.android.com/apk/res/android" + android:pathData="M 0,0 C 0.05, 0, 0.133333, 0.06, 0.166666, 0.4 C 0.208333, 0.82, 0.25, 1, 1, 1"/>
\ No newline at end of file diff --git a/main/res/interpolator-v21/standard_accelerate.xml b/main/res/interpolator-v21/standard_accelerate.xml new file mode 100644 index 0000000..394393d --- /dev/null +++ b/main/res/interpolator-v21/standard_accelerate.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (C) 2022 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. + --> + +<pathInterpolator xmlns:android="http://schemas.android.com/apk/res/android" + android:controlX1="0.3" + android:controlY1="0" + android:controlX2="1" + android:controlY2="1"/>
\ No newline at end of file diff --git a/main/res/interpolator-v21/standard_decelerate.xml b/main/res/interpolator-v21/standard_decelerate.xml new file mode 100644 index 0000000..579f4f5 --- /dev/null +++ b/main/res/interpolator-v21/standard_decelerate.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (C) 2022 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. + --> + +<pathInterpolator xmlns:android="http://schemas.android.com/apk/res/android" + android:controlX1="0" + android:controlY1="0" + android:controlX2="0" + android:controlY2="1"/>
\ No newline at end of file diff --git a/main/res/layout/sud_glif_blank_embedded_template_card.xml b/main/res/layout/sud_glif_blank_embedded_template_card.xml new file mode 100644 index 0000000..89badcd --- /dev/null +++ b/main/res/layout/sud_glif_blank_embedded_template_card.xml @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright (C) 2022 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" + android:id="@+id/suc_layout_status" + style="@style/SudGlifCardBackground" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:fitsSystemWindows="true" + android:gravity="center_horizontal" + android:orientation="vertical"> + + <View + android:layout_width="0dp" + android:layout_height="0dp" + android:layout_weight="1" + android:visibility="invisible" /> + + <com.google.android.setupdesign.view.IntrinsicSizeFrameLayout + style="@style/SudGlifCardContainer" + android:layout_width="@dimen/sud_glif_card_width" + android:layout_height="wrap_content" + android:height="@dimen/sud_glif_card_height"> + + <include layout="@layout/sud_glif_blank_embedded_template_content" /> + + </com.google.android.setupdesign.view.IntrinsicSizeFrameLayout> + + <View + android:layout_width="0dp" + android:layout_height="0dp" + android:layout_weight="1" + android:visibility="invisible" /> + +</LinearLayout> diff --git a/main/res/layout/sud_glif_blank_embedded_template_compact.xml b/main/res/layout/sud_glif_blank_embedded_template_compact.xml new file mode 100644 index 0000000..5b26190 --- /dev/null +++ b/main/res/layout/sud_glif_blank_embedded_template_compact.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright (C) 2022 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. +--> + +<com.google.android.setupcompat.view.StatusBarBackgroundLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/suc_layout_status" + android:layout_width="match_parent" + android:layout_height="match_parent"> + + <include layout="@layout/sud_glif_blank_embedded_template_content" /> + +</com.google.android.setupcompat.view.StatusBarBackgroundLayout> diff --git a/main/res/layout/sud_glif_blank_embedded_template_content.xml b/main/res/layout/sud_glif_blank_embedded_template_content.xml new file mode 100644 index 0000000..359c3a8 --- /dev/null +++ b/main/res/layout/sud_glif_blank_embedded_template_content.xml @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright (C) 2022 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" + 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" /> + + <FrameLayout + android:id="@+id/sud_layout_content" + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_weight="1" /> + + <ViewStub + android:id="@+id/suc_layout_footer" + android:layout_width="match_parent" + android:layout_height="wrap_content" /> + +</LinearLayout> diff --git a/main/res/layout/sud_glif_embedded_template_card.xml b/main/res/layout/sud_glif_embedded_template_card.xml new file mode 100644 index 0000000..381cfcb --- /dev/null +++ b/main/res/layout/sud_glif_embedded_template_card.xml @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright (C) 2022 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" + android:id="@+id/suc_layout_status" + style="@style/SudGlifCardBackground" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:fitsSystemWindows="true" + android:gravity="center_horizontal" + android:orientation="vertical"> + + <View + android:layout_width="0dp" + android:layout_height="0dp" + android:layout_weight="1" + android:visibility="invisible" /> + + <com.google.android.setupdesign.view.IntrinsicSizeFrameLayout + style="@style/SudGlifCardContainer" + android:layout_width="@dimen/sud_glif_card_width" + android:layout_height="wrap_content" + android:height="@dimen/sud_glif_card_height"> + + <include layout="@layout/sud_glif_embedded_template_content" /> + + </com.google.android.setupdesign.view.IntrinsicSizeFrameLayout> + + <View + android:layout_width="0dp" + android:layout_height="0dp" + android:layout_weight="1" + android:visibility="invisible" /> + +</LinearLayout> diff --git a/main/res/layout/sud_glif_embedded_template_compact.xml b/main/res/layout/sud_glif_embedded_template_compact.xml new file mode 100644 index 0000000..952c012 --- /dev/null +++ b/main/res/layout/sud_glif_embedded_template_compact.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright (C) 2022 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. +--> + +<com.google.android.setupcompat.view.StatusBarBackgroundLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/suc_layout_status" + android:layout_width="match_parent" + android:layout_height="match_parent"> + + <include layout="@layout/sud_glif_embedded_template_content" /> + +</com.google.android.setupcompat.view.StatusBarBackgroundLayout> diff --git a/main/res/layout/sud_glif_embedded_template_content.xml b/main/res/layout/sud_glif_embedded_template_content.xml new file mode 100644 index 0000000..c535723 --- /dev/null +++ b/main/res/layout/sud_glif_embedded_template_content.xml @@ -0,0 +1,71 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright (C) 2022 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" /> + + <!-- Ignore UnusedAttribute: scrollIndicators is new in M. Default to no indicators in older + versions. --> + <com.google.android.setupdesign.view.BottomScrollView + android:id="@+id/sud_scroll_view" + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_weight="1" + android:fillViewport="true" + android:scrollIndicators="?attr/sudScrollIndicators" + tools:ignore="UnusedAttribute"> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> + + <include layout="@layout/sud_glif_header" /> + + <ViewStub + android:id="@+id/sud_layout_illustration_progress_stub" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:inflatedId="@+id/sud_layout_progress_illustration" + android:layout="@layout/sud_progress_illustration_layout" /> + + <FrameLayout + android:id="@+id/sud_layout_content" + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_weight="1" /> + + </LinearLayout> + + </com.google.android.setupdesign.view.BottomScrollView> + + <ViewStub + android:id="@+id/suc_layout_footer" + android:layout_width="match_parent" + android:layout_height="wrap_content" /> + +</LinearLayout> diff --git a/main/res/layout/sud_glif_header.xml b/main/res/layout/sud_glif_header.xml index 70b8daa..accb3c0 100644 --- a/main/res/layout/sud_glif_header.xml +++ b/main/res/layout/sud_glif_header.xml @@ -43,6 +43,8 @@ android:layout_width="match_parent" android:layout_height="wrap_content" /> + <include layout="@layout/sud_glif_profile" /> + <ViewStub android:id="@+id/sud_layout_progress_stub" android:layout_width="match_parent" diff --git a/main/res/layout/sud_glif_list_embedded_template_card.xml b/main/res/layout/sud_glif_list_embedded_template_card.xml new file mode 100644 index 0000000..45e35b3 --- /dev/null +++ b/main/res/layout/sud_glif_list_embedded_template_card.xml @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright (C) 2022 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" + android:id="@+id/suc_layout_status" + style="@style/SudGlifCardBackground" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:fitsSystemWindows="true" + android:gravity="center_horizontal" + android:orientation="vertical"> + + <View + android:layout_width="0dp" + android:layout_height="0dp" + android:layout_weight="1" + android:visibility="invisible" /> + + <com.google.android.setupdesign.view.IntrinsicSizeFrameLayout + style="@style/SudGlifCardContainer" + android:layout_width="@dimen/sud_glif_card_width" + android:layout_height="wrap_content" + android:height="@dimen/sud_glif_card_height"> + + <include layout="@layout/sud_glif_list_embedded_template_content" /> + + </com.google.android.setupdesign.view.IntrinsicSizeFrameLayout> + + <View + android:layout_width="0dp" + android:layout_height="0dp" + android:layout_weight="1" + android:visibility="invisible" /> + +</LinearLayout> diff --git a/main/res/layout/sud_glif_list_embedded_template_compact.xml b/main/res/layout/sud_glif_list_embedded_template_compact.xml new file mode 100644 index 0000000..a72a33b --- /dev/null +++ b/main/res/layout/sud_glif_list_embedded_template_compact.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright (C) 2022 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. +--> + +<com.google.android.setupcompat.view.StatusBarBackgroundLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/suc_layout_status" + android:layout_width="match_parent" + android:layout_height="match_parent"> + + <include layout="@layout/sud_glif_list_embedded_template_content" /> + +</com.google.android.setupcompat.view.StatusBarBackgroundLayout> diff --git a/main/res/layout/sud_glif_list_embedded_template_content.xml b/main/res/layout/sud_glif_list_embedded_template_content.xml new file mode 100644 index 0000000..4644c80 --- /dev/null +++ b/main/res/layout/sud_glif_list_embedded_template_content.xml @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright (C) 2022 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" /> + + <!-- Ignore UnusedAttribute: scrollIndicators is new in M. Default to no indicators in older + versions. --> + <com.google.android.setupdesign.view.StickyHeaderListView + xmlns:app="http://schemas.android.com/apk/res-auto" + android:id="@android:id/list" + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_weight="1" + android:scrollIndicators="?attr/sudScrollIndicators" + app:sudHeader="@layout/sud_glif_header" + tools:ignore="UnusedAttribute" /> + + <ViewStub + android:id="@+id/suc_layout_footer" + android:layout_width="match_parent" + android:layout_height="wrap_content" /> + +</LinearLayout> diff --git a/main/res/layout/sud_glif_profile.xml b/main/res/layout/sud_glif_profile.xml new file mode 100644 index 0000000..dbbf813 --- /dev/null +++ b/main/res/layout/sud_glif_profile.xml @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright (C) 2022 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. +--> + +<!-- TODO: Change LinearLayout to a TextView include drawable --> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/sud_layout_profile" + style="?attr/sudGlifAccountContainerStyle" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:visibility="gone" + android:orientation="horizontal"> + + <ImageView + android:id="@+id/sud_account_avatar" + style="?attr/sudGlifAccountAvatarStyle" + android:contentDescription="@null" + android:layout_width="wrap_content" + android:layout_height="wrap_content" /> + + <TextView + android:id="@+id/sud_account_name" + style="?attr/sudGlifAccountNameStyle" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:gravity="left" /> + +</LinearLayout> diff --git a/main/res/layout/sud_glif_recycler_embedded_template_card.xml b/main/res/layout/sud_glif_recycler_embedded_template_card.xml new file mode 100644 index 0000000..316abb2 --- /dev/null +++ b/main/res/layout/sud_glif_recycler_embedded_template_card.xml @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright (C) 2022 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" + android:id="@+id/suc_layout_status" + style="@style/SudGlifCardBackground" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:fitsSystemWindows="true" + android:gravity="center_horizontal" + android:orientation="vertical"> + + <View + android:layout_width="0dp" + android:layout_height="0dp" + android:layout_weight="1" + android:visibility="invisible" /> + + <com.google.android.setupdesign.view.IntrinsicSizeFrameLayout + style="@style/SudGlifCardContainer" + android:layout_width="@dimen/sud_glif_card_width" + android:layout_height="wrap_content" + android:height="@dimen/sud_glif_card_height"> + + <include layout="@layout/sud_glif_recycler_embedded_template_content" /> + + </com.google.android.setupdesign.view.IntrinsicSizeFrameLayout> + + <View + android:layout_width="0dp" + android:layout_height="0dp" + android:layout_weight="1" + android:visibility="invisible" /> + +</LinearLayout> diff --git a/main/res/layout/sud_glif_recycler_embedded_template_compact.xml b/main/res/layout/sud_glif_recycler_embedded_template_compact.xml new file mode 100644 index 0000000..4280d05 --- /dev/null +++ b/main/res/layout/sud_glif_recycler_embedded_template_compact.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright (C) 2022 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. +--> + +<com.google.android.setupcompat.view.StatusBarBackgroundLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/suc_layout_status" + android:layout_width="match_parent" + android:layout_height="match_parent"> + + <include layout="@layout/sud_glif_recycler_embedded_template_content" /> + +</com.google.android.setupcompat.view.StatusBarBackgroundLayout> diff --git a/main/res/layout/sud_glif_recycler_embedded_template_content.xml b/main/res/layout/sud_glif_recycler_embedded_template_content.xml new file mode 100644 index 0000000..dafd3c8 --- /dev/null +++ b/main/res/layout/sud_glif_recycler_embedded_template_content.xml @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright (C) 2022 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" + 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" /> + + <!-- Ignore UnusedAttribute: scrollIndicators is new in M. Default to no indicators in older + versions. --> + <com.google.android.setupdesign.view.HeaderRecyclerView + android:id="@+id/sud_recycler_view" + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_weight="1" + android:scrollbars="vertical" + android:scrollIndicators="?attr/sudScrollIndicators" + app:sudHeader="@layout/sud_glif_header" + tools:ignore="UnusedAttribute" /> + + <ViewStub + android:id="@+id/suc_layout_footer" + android:layout_width="match_parent" + android:layout_height="wrap_content" /> + +</LinearLayout> diff --git a/main/res/values-night-v33/colors.xml b/main/res/values-night-v33/colors.xml index 79ed31a..5bb3d39 100644 --- a/main/res/values-night-v33/colors.xml +++ b/main/res/values-night-v33/colors.xml @@ -17,9 +17,5 @@ <resources> - <color name="sud_system_primary_text">@color/sud_system_neutral1_0</color> - <color name="sud_system_secondary_text">@color/sud_system_neutral1_200</color> - <color name="sud_system_tertiary_text_inactive">@color/sud_system_neutral1_300</color> - <color name="sud_system_background_surface">@color/sud_system_neutral1_1000</color> - <color name="sud_system_dividing_line">@color/sud_system_neutral1_600</color> -</resources>
\ No newline at end of file + <color name="sud_system_dividing_line">@color/sud_system_neutral2_700</color> +</resources> diff --git a/main/res/values-sw600dp-land-v33/config.xml b/main/res/values-sw600dp-land-v33/config.xml new file mode 100644 index 0000000..2d2238c --- /dev/null +++ b/main/res/values-sw600dp-land-v33/config.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2023 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> + <bool name="suc_footer_bar_button_align_end">true</bool> +</resources>
\ No newline at end of file diff --git a/main/res/values-sw600dp-land-v33/dimens.xml b/main/res/values-sw600dp-land-v33/dimens.xml new file mode 100644 index 0000000..d672ce6 --- /dev/null +++ b/main/res/values-sw600dp-land-v33/dimens.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright (C) 2022 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> + + <!-- General --> + <dimen name="sud_glif_land_middle_horizontal_spacing">76dp</dimen> + +</resources>
\ No newline at end of file diff --git a/main/res/values-sw600dp/layouts.xml b/main/res/values-sw600dp/layouts.xml index 3c27d25..41bc74e 100644 --- a/main/res/values-sw600dp/layouts.xml +++ b/main/res/values-sw600dp/layouts.xml @@ -25,7 +25,9 @@ <item name="sud_no_scroll_template_short" type="layout">@layout/sud_no_scroll_template_card</item> <item name="sud_glif_template" type="layout">@layout/sud_glif_template_card</item> + <item name="sud_glif_embedded_template" type="layout">@layout/sud_glif_embedded_template_card</item> <item name="sud_glif_list_template" type="layout">@layout/sud_glif_list_template_card</item> + <item name="sud_glif_list_embedded_template" type="layout">@layout/sud_glif_list_embedded_template_card</item> <item name="sud_glif_blank_template" type="layout">@layout/sud_glif_blank_template_card</item> <item name="sud_preference_recycler_view" type="layout">@layout/sud_preference_recycler_view_normal</item> @@ -34,7 +36,9 @@ <item name="sud_recycler_template_short" type="layout">@layout/sud_recycler_template_card</item> <item name="sud_glif_preference_template" type="layout">@layout/sud_glif_blank_template_card</item> + <item name="sud_glif_preference_embedded_template" type="layout">@layout/sud_glif_blank_embedded_template_card</item> <item name="sud_glif_recycler_template" type="layout">@layout/sud_glif_recycler_template_card</item> + <item name="sud_glif_recycler_embedded_template" type="layout">@layout/sud_glif_recycler_embedded_template_card</item> </resources> diff --git a/main/res/values-v31/colors.xml b/main/res/values-v31/colors.xml index 1ed67df..12b13eb 100644 --- a/main/res/values-v31/colors.xml +++ b/main/res/values-v31/colors.xml @@ -15,7 +15,8 @@ limitations under the License. --> -<resources> +<resources xmlns:tools="http://schemas.android.com/tools" + tools:keep="@color/sud_system_accent*,@color/sud_system_neutral*"> <!-- Default color for BC --> <color name="sud_color_accent_glif_v3_dark">#ff669df6</color> @@ -46,6 +47,19 @@ <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_accent2_600">@android:color/system_accent2_600</color> + + + + <color name="sud_system_accent3_100">@android:color/system_accent3_100</color> + + <color name="sud_system_accent3_200">@android:color/system_accent3_200</color> + + <color name="sud_system_accent3_600">@android:color/system_accent3_600</color> + + <color name="sud_system_neutral1_0">@android:color/system_neutral1_0</color> diff --git a/main/res/values-v31/styles.xml b/main/res/values-v31/styles.xml index df86de7..7216905 100644 --- a/main/res/values-v31/styles.xml +++ b/main/res/values-v31/styles.xml @@ -19,8 +19,10 @@ <!-- Main theme for dynamic color --> <style name="SudDynamicColorBaseTheme"> <item name="colorAccent">@color/sud_dynamic_color_accent_glif_v3_dark</item> + <item name="android:colorAccent">?attr/colorAccent</item> <item name="android:textColorLink">@color/sud_system_hyperlink_text</item> <item name="alertDialogTheme">@style/SudDynamicColorAlertDialogThemeCompat</item> + <item name="android:alertDialogTheme">@style/SudDynamicColorAlertDialogTheme</item> <item name="android:datePickerDialogTheme">@style/SudDynamicColorDateTimePickerDialogTheme</item> <item name="android:timePickerDialogTheme">@style/SudDynamicColorDateTimePickerDialogTheme</item> <item name="sucFullDynamicColor">false</item> @@ -33,8 +35,10 @@ <style name="SudDynamicColorBaseTheme.Light"> <item name="colorAccent">@color/sud_dynamic_color_accent_glif_v3_light</item> + <item name="android:colorAccent">?attr/colorAccent</item> <item name="android:textColorLink">@color/sud_system_hyperlink_text</item> <item name="alertDialogTheme">@style/SudDynamicColorAlertDialogThemeCompat.Light</item> + <item name="android:alertDialogTheme">@style/SudDynamicColorAlertDialogTheme.Light</item> <item name="android:datePickerDialogTheme">@style/SudDynamicColorDateTimePickerDialogTheme.Light</item> <item name="android:timePickerDialogTheme">@style/SudDynamicColorDateTimePickerDialogTheme.Light</item> <item name="sucFullDynamicColor">false</item> @@ -69,8 +73,11 @@ <item name="colorSwitchThumbNormal">@color/switch_thumb_material_dark</item> <item name="alertDialogTheme">@style/SudFullDynamicColorAlertDialogThemeCompat</item> + <item name="android:alertDialogTheme">@style/SudFullDynamicColorAlertDialogTheme</item> <item name="sucFullDynamicColor">true</item> + + <item name="android:windowAnimationStyle">@style/Animation.SudWindowAnimation.DynamicColor</item> </style> <style name="SudFullDynamicColorTheme.Light" parent="SudDynamicColorTheme.Light"> @@ -93,8 +100,11 @@ <item name="colorSwitchThumbNormal">@color/switch_thumb_material_light</item> <item name="alertDialogTheme">@style/SudFullDynamicColorAlertDialogThemeCompat.Light</item> + <item name="android:alertDialogTheme">@style/SudFullDynamicColorAlertDialogTheme.Light</item> <item name="sucFullDynamicColor">true</item> + + <item name="android:windowAnimationStyle">@style/Animation.SudWindowAnimation.DynamicColor</item> </style> <!-- Main theme for dynamic color --> @@ -186,6 +196,15 @@ <item name="android:windowTitleStyle">@style/SudMaterialYouWindowTitleStyle</item> </style> + <style name="SudDynamicColorAlertDialogTheme" parent="android:Theme.DeviceDefault.Dialog.Alert"> + <item name="android:textAllCaps">false</item> + <item name="android:colorBackground">@color/sud_glif_v3_dialog_background_color_dark</item> + <item name="colorAccent">@color/sud_dynamic_color_accent_glif_v3_dark</item> + <item name="dialogCornerRadius">@dimen/sud_glif_device_default_dialog_corner_radius</item> + <item name="buttonBarButtonStyle">@style/SudAppCompatButtonButtonBarAlertDialog</item> + <item name="android:windowTitleStyle">@style/SudMaterialYouWindowTitleStyle</item> + </style> + <style name="SudDynamicColorAlertDialogThemeCompat.Light" parent="Theme.AppCompat.Light.Dialog.Alert"> <item name="android:textAllCaps">false</item> <item name="android:colorBackground">@color/sud_glif_v3_dialog_background_color_light</item> @@ -195,7 +214,19 @@ <item name="android:windowTitleStyle">@style/SudMaterialYouWindowTitleStyle</item> </style> + <style name="SudDynamicColorAlertDialogTheme.Light" parent="android:Theme.DeviceDefault.Light.Dialog.Alert"> + <item name="android:textAllCaps">false</item> + <item name="android:colorBackground">@color/sud_glif_v3_dialog_background_color_light</item> + <item name="colorAccent">@color/sud_dynamic_color_accent_glif_v3_light</item> + <item name="dialogCornerRadius">@dimen/sud_glif_device_default_dialog_corner_radius</item> + <item name="buttonBarButtonStyle">@style/SudAppCompatButtonButtonBarAlertDialog.Light</item> + <item name="android:windowTitleStyle">@style/SudMaterialYouWindowTitleStyle</item> + </style> + + <style name="SudAppCompatButtonButtonBarAlertDialog" parent="Widget.AppCompat.ButtonBar.AlertDialog"> + <item name="android:layout_marginStart">@dimen/sud_glif_alert_dialog_footer_bar_padding_start</item> + <item name="android:layout_marginLeft">@dimen/sud_glif_alert_dialog_footer_bar_padding_start</item> <item name="android:textAppearance">@style/SudTextAppearanceDeviceDefaultMedium</item> <item name="android:minWidth">@dimen/sud_alert_dialog_button_bar_width</item> <item name="android:minHeight">@dimen/sud_alert_dialog_button_bar_height</item> @@ -229,6 +260,14 @@ <item name="android:colorBackground">@color/sud_system_neutral1_50</item> </style> + <style name="SudFullDynamicColorAlertDialogTheme" parent="SudDynamicColorAlertDialogTheme"> + <item name="android:colorBackground">@color/sud_system_neutral1_900</item> + </style> + <style name="SudFullDynamicColorAlertDialogTheme.Light" parent="SudDynamicColorAlertDialogTheme.Light"> + <item name="android:colorBackground">@color/sud_system_neutral1_50</item> + </style> + + <!-- Dynamic color theme for date time dialog --> <style name="SudDynamicColorDateTimePickerDialogTheme" parent="SudDateTimePickerDialogTheme"> <item name="colorAccent">@color/sud_dynamic_color_accent_glif_v3_dark</item> diff --git a/main/res/values-v33/colors.xml b/main/res/values-v33/colors.xml index c46c6fc..37e3b37 100644 --- a/main/res/values-v33/colors.xml +++ b/main/res/values-v33/colors.xml @@ -18,11 +18,10 @@ <resources> - <color name="sud_system_secondary_text">@color/sud_system_neutral1_700</color> - <color name="sud_system_tertiary_text_inactive">@color/sud_system_neutral1_600</color> - <color name="sud_system_background_surface">@color/sud_system_neutral1_0</color> <color name="sud_system_button_surface">@color/sud_system_accent1_600</color> - <color name="sud_system_dividing_line">@color/sud_system_neutral1_500</color> + <color name="sud_system_button_text">@color/sud_system_neutral1_50</color> + <!-- used by other 1p--> + <color name="sud_system_dividing_line">@color/sud_system_neutral2_200</color> <color name="sud_glif_v3_nav_bar_divider_color_light">@android:color/transparent</color> </resources> diff --git a/main/res/values-v34/colors.xml b/main/res/values-v34/colors.xml new file mode 100644 index 0000000..9460e6e --- /dev/null +++ b/main/res/values-v34/colors.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2022 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> + <!-- Accent color --> + <color name="sud_dynamic_color_accent_glif_v3_dark">@color/sud_system_accent1_300</color> +</resources>
\ No newline at end of file diff --git a/main/res/values-v34/dimens.xml b/main/res/values-v34/dimens.xml new file mode 100644 index 0000000..84b245c --- /dev/null +++ b/main/res/values-v34/dimens.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2022 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> + <dimen name="sud_glif_margin_start_material_you">24dp</dimen> + <dimen name="sud_glif_description_text_size_material_you">14sp</dimen> + <dimen name="sud_description_text_size">14sp</dimen> +</resources>
\ No newline at end of file diff --git a/main/res/values-v34/styles.xml b/main/res/values-v34/styles.xml new file mode 100644 index 0000000..24411e2 --- /dev/null +++ b/main/res/values-v34/styles.xml @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright (C) 2022 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 xmlns:tools="http://schemas.android.com/tools"> + <style name="Animation.SudWindowAnimation" parent="@android:style/Animation.Activity"> + <item name="android:activityOpenEnterAnimation">@anim/shared_x_axis_activity_open_enter</item> + <item name="android:activityOpenExitAnimation">@anim/shared_x_axis_activity_open_exit</item> + <item name="android:activityCloseEnterAnimation">@anim/shared_x_axis_activity_close_enter</item> + <item name="android:activityCloseExitAnimation">@anim/shared_x_axis_activity_close_exit</item> + </style> + + <style name="Animation.SudWindowAnimation.DynamicColor" parent="@android:style/Animation.Activity"> + <item name="android:activityOpenEnterAnimation">@anim/shared_x_axis_activity_open_enter_dynamic_color</item> + <item name="android:activityOpenExitAnimation">@anim/shared_x_axis_activity_open_exit</item> + <item name="android:activityCloseEnterAnimation">@anim/shared_x_axis_activity_close_enter_dynamic_color</item> + <item name="android:activityCloseExitAnimation">@anim/shared_x_axis_activity_close_exit</item> + </style> +</resources>
\ No newline at end of file diff --git a/main/res/values/attrs.xml b/main/res/values/attrs.xml index 22aee0d..4600bcc 100644 --- a/main/res/values/attrs.xml +++ b/main/res/values/attrs.xml @@ -61,11 +61,14 @@ <attr name="sudGlifIconSize" format="dimension" /> <attr name="sudGlifDescriptionStyle" format="reference" /> + <attr name="sudGlifAccountNameStyle" format="reference" /> + <attr name="sudGlifAccountAvatarStyle" format="reference" /> + <attr name="sudGlifAccountContainerStyle" format="reference" /> + <attr name="sudGlifAccountAvatarSize" format="dimension" /> <attr name="sudButtonAllCaps" format="boolean" /> <attr name="sudButtonCornerRadius" format="dimension" /> <attr name="sudButtonFontFamily" format="string|reference" /> - <!-- Values copied from frameworks/base/core/res/res/values/attrs.xml --> <attr name="sudButtonTertiaryGravity"> <!-- Push object to the left of its container, not changing its size. --> <flag name="left" value="0x03" /> diff --git a/main/res/values/colors.xml b/main/res/values/colors.xml index 75fd097..5cbcf07 100644 --- a/main/res/values/colors.xml +++ b/main/res/values/colors.xml @@ -15,7 +15,8 @@ limitations under the License. --> -<resources> +<resources xmlns:tools="http://schemas.android.com/tools" + tools:keep="@color/sud_system_accent*,@color/sud_system_neutral*"> <!-- General colors --> <color name="sud_color_accent_dark">#ff448aff</color> @@ -81,6 +82,19 @@ <color name="sud_system_accent2_100">#FFE8DEF8</color> + <color name="sud_system_accent2_200">#A4CFC7</color> + + <color name="sud_system_accent2_600">#3D665F</color> + + + + <color name="sud_system_accent3_100">#ECDBFF</color> + + <color name="sud_system_accent3_200">#CFBFEB</color> + + <color name="sud_system_accent3_600">#64587F</color> + + <color name="sud_system_neutral1_0">#ffffff</color> diff --git a/main/res/values/config.xml b/main/res/values/config.xml index de724a3..79a2779 100644 --- a/main/res/values/config.xml +++ b/main/res/values/config.xml @@ -23,6 +23,9 @@ <!-- Whether to use tablet layout --> <bool name="sudUseTabletLayout">false</bool> + <!-- Whether to make the footer button in footer bar align end --> + <bool name="suc_footer_bar_button_align_end">false</bool> + <!-- Secondary font for use with headings, title, and other non-body text --> <string name="sudFontSecondary" translatable="false">google-sans</string> <string name="sudFontSecondaryText" translatable="false">google-sans-text</string> diff --git a/main/res/values/dimens.xml b/main/res/values/dimens.xml index 4b821a4..8626945 100644 --- a/main/res/values/dimens.xml +++ b/main/res/values/dimens.xml @@ -56,6 +56,7 @@ <dimen name="sud_horizontal_icon_height">32dp</dimen> <dimen name="sud_glif_alert_dialog_corner_radius">8dp</dimen> + <dimen name="sud_glif_alert_dialog_footer_bar_padding_start">8dp</dimen> <dimen name="sud_glif_v3_button_corner_radius">4dp</dimen> <dimen name="sud_glif_device_default_dialog_corner_radius">28dp</dimen> <dimen name="sud_glif_land_header_area_weight">1</dimen> @@ -152,6 +153,11 @@ <dimen name="sud_glif_header_title_margin_bottom">2dp</dimen> <dimen name="sud_header_container_margin_bottom">0dp</dimen> + <!-- Account information --> + <dimen name="sud_account_name_text_size">14sp</dimen> + <dimen name="sud_account_avatar_margin_end">8dp</dimen> + <dimen name="sud_account_avatar_max_height">24dp</dimen> + <!-- This value leverages sud_description_glif_margin_top --> <dimen name="sud_glif_description_margin_top">3dp</dimen> <dimen name="sud_glif_description_margin_bottom">12dp</dimen> @@ -161,7 +167,7 @@ <item name="sud_illustration_aspect_ratio" format="float" type="dimen">2.22</item> <!-- Footer Button--> - <dimen name="sud_glif_footer_button_text_size">14dp</dimen> + <dimen name="sud_glif_footer_button_text_size">14sp</dimen> <dimen name="sud_glif_primary_button_button_margin_start">0dp</dimen> <dimen name="sud_glif_secondary_button_button_margin_start">0dp</dimen> @@ -203,7 +209,7 @@ <!-- Footer Button Material You--> <dimen name="sud_footer_bar_button_radius_material_you">20dp</dimen> <dimen name="sud_glif_button_min_height_material_you">48dp</dimen> - <dimen name="sud_glif_footer_button_text_size_material_you">14dp</dimen> + <dimen name="sud_glif_footer_button_text_size_material_you">14sp</dimen> <dimen name="sud_glif_primary_button_button_margin_start_material_you">0dp</dimen> @@ -304,4 +310,11 @@ <!-- Set 0dp since we don't want shadow. --> <dimen name="sud_icon_uniformity_elevation">0dp</dimen> + <!-- Embedded Activity --> + <dimen name="sud_glif_footer_padding_start_embedded_activity">24dp</dimen> + <dimen name="sud_glif_footer_padding_end_embedded_activity">24dp</dimen> + <dimen name="sud_glif_margin_start_embedded_activity">24dp</dimen> + <dimen name="sud_glif_margin_end_embedded_activity">24dp</dimen> + <dimen name="sud_glif_header_title_margin_top_embedded_activity">24dp</dimen> + <dimen name="sud_header_title_size_embedded_activity">44sp</dimen> </resources> diff --git a/main/res/values/layouts.xml b/main/res/values/layouts.xml index 910965f..56f227d 100644 --- a/main/res/values/layouts.xml +++ b/main/res/values/layouts.xml @@ -35,8 +35,12 @@ <item name="sud_glif_template" type="layout">@layout/sud_glif_template_compact</item> + <item name="sud_glif_embedded_template" type="layout">@layout/sud_glif_embedded_template_compact</item> + <item name="sud_glif_list_template" type="layout">@layout/sud_glif_list_template_compact</item> + <item name="sud_glif_list_embedded_template" type="layout">@layout/sud_glif_list_embedded_template_compact</item> + <!-- Ignore UnusedResources: can be used by clients --> <item name="sud_glif_blank_template" type="layout" tools:ignore="UnusedResources">@layout/sud_glif_blank_template_compact</item> @@ -51,5 +55,7 @@ <!-- Ignore UnusedResources: can be used by clients --> <item name="sud_glif_preference_template" type="layout">@layout/sud_glif_blank_template_compact</item> + <item name="sud_glif_preference_embedded_template" type="layout">@layout/sud_glif_blank_embedded_template_compact</item> <item name="sud_glif_recycler_template" type="layout">@layout/sud_glif_recycler_template_compact</item> + <item name="sud_glif_recycler_embedded_template" type="layout">@layout/sud_glif_recycler_embedded_template_compact</item> </resources> diff --git a/main/res/values/styles.xml b/main/res/values/styles.xml index e33b305..6fe9550 100644 --- a/main/res/values/styles.xml +++ b/main/res/values/styles.xml @@ -168,6 +168,10 @@ <item name="sudDividerInsetStart">@dimen/sud_items_glif_icon_divider_inset</item> <item name="sudDividerInsetStartNoIcon">@dimen/sud_items_glif_text_divider_inset</item> <item name="sudDividerShown">true</item> + <item name="sudGlifAccountContainerStyle">@style/SudGlifAccountContainer</item> + <item name="sudGlifAccountNameStyle">@style/SudGlifAccountName</item> + <item name="sudGlifAccountAvatarSize">@dimen/sud_account_avatar_max_height</item> + <item name="sudGlifAccountAvatarStyle">@style/SudGlifAccountAvatar</item> <item name="sudGlifHeaderTitleStyle">@style/SudGlifHeaderTitle</item> <item name="sudGlifHeaderGravity">start</item> <item name="sudGlifSubtitleGravity">start</item> @@ -192,6 +196,7 @@ <item name="textAppearanceListItemSmall">@style/TextAppearance.SudGlifItemSummary</item> <item name="sucFooterBarButtonFontFamily">?attr/sudButtonFontFamily</item> <item name="sucFooterBarButtonCornerRadius">?attr/sudButtonCornerRadius</item> + <item name="sucFooterBarButtonAlignEnd">false</item> <item name="sucFooterBarButtonAllCaps">?attr/sudButtonAllCaps</item> <item name="sucFooterBarButtonColorControlHighlightRipple">?attr/colorAccent</item> <item name="sucFooterBarButtonHighlightAlpha">?attr/sudButtonHighlightAlpha</item> @@ -262,6 +267,10 @@ <item name="sudDividerInsetStart">@dimen/sud_items_glif_icon_divider_inset</item> <item name="sudDividerInsetStartNoIcon">@dimen/sud_items_glif_text_divider_inset</item> <item name="sudDividerShown">true</item> + <item name="sudGlifAccountContainerStyle">@style/SudGlifAccountContainer</item> + <item name="sudGlifAccountNameStyle">@style/SudGlifAccountName</item> + <item name="sudGlifAccountAvatarSize">@dimen/sud_account_avatar_max_height</item> + <item name="sudGlifAccountAvatarStyle">@style/SudGlifAccountAvatar</item> <item name="sudGlifHeaderTitleStyle">@style/SudGlifHeaderTitle</item> <item name="sudGlifHeaderGravity">start</item> <item name="sudGlifSubtitleGravity">start</item> @@ -286,6 +295,7 @@ <item name="textAppearanceListItemSmall">@style/TextAppearance.SudGlifItemSummary</item> <item name="sucFooterBarButtonFontFamily">?attr/sudButtonFontFamily</item> <item name="sucFooterBarButtonCornerRadius">?attr/sudButtonCornerRadius</item> + <item name="sucFooterBarButtonAlignEnd">false</item> <item name="sucFooterBarButtonAllCaps">?attr/sudButtonAllCaps</item> <item name="sucFooterBarButtonColorControlHighlightRipple">?attr/colorAccent</item> <item name="sucFooterBarButtonHighlightAlpha">?attr/sudButtonHighlightAlpha</item> @@ -394,9 +404,11 @@ <item name="sucHeaderContainerMarginBottom">@dimen/sud_header_container_margin_bottom_material_you</item> <item name="sucFooterBarButtonFontFamily">@string/sudFontSecondaryMediumMaterialYou</item> <item name="sucGlifIconMarginTop">@dimen/sud_glif_icon_margin_top_material_you</item> + <item name="sucFooterBarButtonAlignEnd">@bool/suc_footer_bar_button_align_end</item> <item name="sudButtonCornerRadius">@dimen/sud_footer_bar_button_radius_material_you</item> <item name="sudButtonTertiaryGravity">center_horizontal</item> <item name="sudGlifIconSize">@dimen/sud_glif_icon_max_height_material_you</item> + <item name="sudGlifAccountContainerStyle">@style/SudGlifAccountContainerMaterialYou</item> <item name="sudGlifHeaderTitleStyle">@style/SudGlifHeaderTitleMaterialYou</item> <item name="sudGlifHeaderGravity">start</item> <item name="sucGlifHeaderMarginTop">@dimen/sud_glif_header_title_margin_top_material_you</item> @@ -415,7 +427,7 @@ <item name="sudItemDescriptionStyle">@style/SudItemContainerMaterialYou.Description</item> <item name="sudItemVerboseTitleStyle">@style/SudMaterialYouItemTitle.Verbose</item> <item name="alertDialogTheme">@style/SudMaterialYouAlertDialogThemeCompat</item> - <item name="android:alertDialogTheme" >@style/SudMaterialYouAlertDialogTheme</item> + <item name="android:alertDialogTheme">@style/SudMaterialYouAlertDialogTheme</item> </style> <style name="SudThemeGlifV4.Light" parent="SudThemeGlifV3.Light"> @@ -424,6 +436,7 @@ <item name="sucFooterBarPaddingStart">@dimen/sud_glif_footer_bar_padding_start_material_you</item> <item name="sucFooterBarPaddingEnd">@dimen/sud_glif_footer_bar_padding_end_material_you</item> <item name="sucFooterBarMinHeight">@dimen/sud_glif_footer_bar_min_height_material_you</item> + <item name="sucFooterBarButtonAlignEnd">@bool/suc_footer_bar_button_align_end</item> <item name="sudMarginEnd">@dimen/sud_glif_margin_end_material_you</item> <item name="sucHeaderContainerMarginBottom">@dimen/sud_header_container_margin_bottom_material_you</item> <item name="sucFooterBarButtonFontFamily">@string/sudFontSecondaryMediumMaterialYou</item> @@ -431,6 +444,7 @@ <item name="sudButtonCornerRadius">@dimen/sud_footer_bar_button_radius_material_you</item> <item name="sudButtonTertiaryGravity">center_horizontal</item> <item name="sudGlifIconSize">@dimen/sud_glif_icon_max_height_material_you</item> + <item name="sudGlifAccountContainerStyle">@style/SudGlifAccountContainerMaterialYou</item> <item name="sudGlifHeaderTitleStyle">@style/SudGlifHeaderTitleMaterialYou</item> <item name="sudGlifHeaderGravity">start</item> <item name="sucGlifHeaderMarginTop">@dimen/sud_glif_header_title_margin_top_material_you</item> @@ -449,7 +463,7 @@ <item name="sudItemDescriptionStyle">@style/SudItemContainerMaterialYou.Description</item> <item name="sudItemVerboseTitleStyle">@style/SudMaterialYouItemTitle.Verbose</item> <item name="alertDialogTheme">@style/SudMaterialYouAlertDialogThemeCompat.Light</item> - <item name="android:alertDialogTheme" >@style/SudMaterialYouAlertDialogTheme.Light</item> + <item name="android:alertDialogTheme">@style/SudMaterialYouAlertDialogTheme.Light</item> </style> <style name="SudDynamicColorTheme" /> @@ -877,6 +891,7 @@ <item name="android:textColor">?android:attr/textColorPrimary</item> <item name="android:textDirection" tools:targetApi="jelly_bean_mr1">locale</item> <item name="android:accessibilityHeading" tools:targetApi="p">true</item> + <item name="android:hyphenationFrequency" tools:targetApi="23">full</item> </style> <style name="SudGlifHeaderTitleMaterialYou"> @@ -895,6 +910,7 @@ <item name="android:textDirection" tools:targetApi="jelly_bean_mr1">locale</item> <item name="android:accessibilityHeading" tools:targetApi="p">true</item> <item name="android:textSize">@dimen/sud_glif_header_title_size_material_you</item> + <item name="android:hyphenationFrequency" tools:targetApi="23">full</item> </style> <style name="SudGlifDescription" parent="SudDescription.Glif"> @@ -926,16 +942,51 @@ <item name="android:textSize">@dimen/sud_glif_description_text_size_material_you</item> </style> + <style name="SudGlifAccountContainerMaterialYou"> + <item name="android:layout_marginBottom">@dimen/sud_glif_header_title_margin_bottom_material_you</item> + <item name="android:layout_marginTop">@dimen/sud_glif_header_title_margin_top_material_you</item> + <item name="android:layout_marginLeft">?attr/sudMarginStart</item> + <item name="android:layout_marginStart" tools:ignore="NewApi">?attr/sudMarginStart</item> + <item name="android:layout_marginRight">?attr/sudMarginEnd</item> + <item name="android:layout_marginEnd" tools:ignore="NewApi">?attr/sudMarginEnd</item> + <item name="android:gravity">?attr/sudGlifHeaderGravity</item> + </style> + + <style name="SudGlifAccountAvatar"> + <item name="android:layout_marginRight">@dimen/sud_account_avatar_margin_end</item> + <item name="android:layout_marginEnd">@dimen/sud_account_avatar_margin_end</item> + <item name="android:adjustViewBounds">true</item> + <item name="android:maxHeight">@dimen/sud_account_avatar_max_height</item> + <item name="android:layout_gravity">center_vertical</item> + </style> + + <style name="SudGlifAccountName"> + <item name="android:fontFamily" tools:targetApi="jelly_bean">@string/sudFontSecondary</item> + <item name="android:textColor">?android:attr/textColorPrimary</item> + <item name="android:textSize">@dimen/sud_account_name_text_size</item> + <item name="android:layout_gravity">center_vertical</item> + </style> + <style name="SudGlifHeaderContainer"> <item name="android:gravity">?attr/sudGlifHeaderGravity</item> <item name="android:layout_marginBottom">?attr/sucHeaderContainerMarginBottom</item> </style> + <style name="SudGlifAccountContainer"> + <item name="android:layout_marginBottom">@dimen/sud_glif_header_title_margin_bottom_material_you</item> + <item name="android:layout_marginTop">@dimen/sud_glif_header_title_margin_top_material_you</item> + <item name="android:layout_marginLeft">?attr/sudMarginStart</item> + <item name="android:layout_marginStart" tools:ignore="NewApi">?attr/sudMarginStart</item> + <item name="android:layout_marginRight">?attr/sudMarginEnd</item> + <item name="android:layout_marginEnd" tools:ignore="NewApi">?attr/sudMarginEnd</item> + <item name="android:gravity">?attr/sudGlifHeaderGravity</item> + </style> + <style name="SudGlifIconContainer"> <item name="android:layout_marginLeft">?attr/sudMarginStart</item> - <item name="android:layout_marginStart" tools:ignore="NewApi">?attr/sudMarginStart</item> + <item name="android:layout_marginStart" tools:ignore="NewApi">?attr/sudMarginStart</item> <item name="android:layout_marginRight">?attr/sudMarginEnd</item> - <item name="android:layout_marginEnd" tools:ignore="NewApi">?attr/sudMarginEnd</item> + <item name="android:layout_marginEnd" tools:ignore="NewApi">?attr/sudMarginEnd</item> <item name="android:layout_marginTop">?attr/sucGlifIconMarginTop</item> <item name="android:maxHeight">?attr/sudGlifIconSize</item> </style> diff --git a/main/src/com/google/android/setupdesign/GlifLayout.java b/main/src/com/google/android/setupdesign/GlifLayout.java index 1b8c8f8..61d8329 100644 --- a/main/src/com/google/android/setupdesign/GlifLayout.java +++ b/main/src/com/google/android/setupdesign/GlifLayout.java @@ -37,6 +37,7 @@ import androidx.annotation.LayoutRes; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.StringRes; +import androidx.window.embedding.ActivityEmbeddingController; import com.google.android.setupcompat.PartnerCustomizationLayout; import com.google.android.setupcompat.partnerconfig.PartnerConfig; import com.google.android.setupcompat.partnerconfig.PartnerConfigHelper; @@ -45,6 +46,7 @@ import com.google.android.setupdesign.template.DescriptionMixin; import com.google.android.setupdesign.template.HeaderMixin; import com.google.android.setupdesign.template.IconMixin; import com.google.android.setupdesign.template.IllustrationProgressMixin; +import com.google.android.setupdesign.template.ProfileMixin; import com.google.android.setupdesign.template.ProgressBarMixin; import com.google.android.setupdesign.template.RequireScrollMixin; import com.google.android.setupdesign.template.ScrollViewScrollHandlingDelegate; @@ -121,6 +123,7 @@ public class GlifLayout extends PartnerCustomizationLayout { registerMixin(HeaderMixin.class, new HeaderMixin(this, attrs, defStyleAttr)); registerMixin(DescriptionMixin.class, new DescriptionMixin(this, attrs, defStyleAttr)); registerMixin(IconMixin.class, new IconMixin(this, attrs, defStyleAttr)); + registerMixin(ProfileMixin.class, new ProfileMixin(this, attrs, defStyleAttr)); registerMixin(ProgressBarMixin.class, new ProgressBarMixin(this, attrs, defStyleAttr)); registerMixin(IllustrationProgressMixin.class, new IllustrationProgressMixin(this)); final RequireScrollMixin requireScrollMixin = new RequireScrollMixin(this); @@ -184,6 +187,7 @@ public class GlifLayout extends PartnerCustomizationLayout { getMixin(HeaderMixin.class).tryApplyPartnerCustomizationStyle(); getMixin(DescriptionMixin.class).tryApplyPartnerCustomizationStyle(); getMixin(ProgressBarMixin.class).tryApplyPartnerCustomizationStyle(); + getMixin(ProfileMixin.class).tryApplyPartnerCustomizationStyle(); tryApplyPartnerCustomizationStyleToShortDescription(); } @@ -282,7 +286,12 @@ public class GlifLayout extends PartnerCustomizationLayout { protected View onInflateTemplate(LayoutInflater inflater, @LayoutRes int template) { if (template == 0) { template = R.layout.sud_glif_template; + // if the activity is embedded should apply an embedded layout. + if (isEmbeddedActivityOnePaneEnabled(getContext())) { + template = R.layout.sud_glif_embedded_template; + } } + return inflateTemplate(inflater, R.style.SudThemeGlif_Light, template); } @@ -437,7 +446,7 @@ public class GlifLayout extends PartnerCustomizationLayout { updateBackground(); } - /** @return True if this view uses {@link GlifPatternDrawable} as background. */ + /** Returns true if this view uses {@link GlifPatternDrawable} as background. */ public boolean isBackgroundPatterned() { return backgroundPatterned; } @@ -481,6 +490,13 @@ public class GlifLayout extends PartnerCustomizationLayout { && PartnerConfigHelper.shouldApplyExtendedPartnerConfig(getContext())); } + /** Check if the one pane layout is enabled in embedded activity */ + protected boolean isEmbeddedActivityOnePaneEnabled(Context context) { + return PartnerConfigHelper.isEmbeddedActivityOnePaneEnabled(context) + && ActivityEmbeddingController.getInstance(context) + .isActivityEmbedded(PartnerCustomizationLayout.lookupActivityFromContext(context)); + } + /** 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 diff --git a/main/src/com/google/android/setupdesign/GlifListLayout.java b/main/src/com/google/android/setupdesign/GlifListLayout.java index 89d0888..79b905c 100644 --- a/main/src/com/google/android/setupdesign/GlifListLayout.java +++ b/main/src/com/google/android/setupdesign/GlifListLayout.java @@ -91,6 +91,10 @@ public class GlifListLayout extends GlifLayout { protected View onInflateTemplate(LayoutInflater inflater, int template) { if (template == 0) { template = R.layout.sud_glif_list_template; + // if the activity is embedded should apply an embedded layout. + if (isEmbeddedActivityOnePaneEnabled(getContext())) { + template = R.layout.sud_glif_list_embedded_template; + } } return super.onInflateTemplate(inflater, template); } diff --git a/main/src/com/google/android/setupdesign/GlifPreferenceLayout.java b/main/src/com/google/android/setupdesign/GlifPreferenceLayout.java index f235442..fb10515 100644 --- a/main/src/com/google/android/setupdesign/GlifPreferenceLayout.java +++ b/main/src/com/google/android/setupdesign/GlifPreferenceLayout.java @@ -99,6 +99,10 @@ public class GlifPreferenceLayout extends GlifRecyclerLayout { protected View onInflateTemplate(LayoutInflater inflater, int template) { if (template == 0) { template = R.layout.sud_glif_preference_template; + // if the activity is embedded should apply an embedded layout. + if (isEmbeddedActivityOnePaneEnabled(getContext())) { + template = R.layout.sud_glif_preference_embedded_template; + } } return super.onInflateTemplate(inflater, template); } diff --git a/main/src/com/google/android/setupdesign/GlifRecyclerLayout.java b/main/src/com/google/android/setupdesign/GlifRecyclerLayout.java index 87f871c..484ad50 100644 --- a/main/src/com/google/android/setupdesign/GlifRecyclerLayout.java +++ b/main/src/com/google/android/setupdesign/GlifRecyclerLayout.java @@ -92,6 +92,10 @@ public class GlifRecyclerLayout extends GlifLayout { protected View onInflateTemplate(LayoutInflater inflater, int template) { if (template == 0) { template = R.layout.sud_glif_recycler_template; + // if the activity is embedded should apply an embedded layout. + if (isEmbeddedActivityOnePaneEnabled(getContext())) { + template = R.layout.sud_glif_recycler_embedded_template; + } } return super.onInflateTemplate(inflater, template); } diff --git a/main/src/com/google/android/setupdesign/span/LinkSpan.java b/main/src/com/google/android/setupdesign/span/LinkSpan.java index 7d91012..3bb1617 100644 --- a/main/src/com/google/android/setupdesign/span/LinkSpan.java +++ b/main/src/com/google/android/setupdesign/span/LinkSpan.java @@ -73,10 +73,10 @@ public class LinkSpan extends ClickableSpan { /* non-static section */ - private final String id; + private final String link; - public LinkSpan(String id) { - this.id = id; + public LinkSpan(String link) { + this.link = link; } @Override @@ -137,7 +137,7 @@ public class LinkSpan extends ClickableSpan { drawState.setUnderlineText(false); } - public String getId() { - return id; + public String getLink() { + return link; } } diff --git a/main/src/com/google/android/setupdesign/template/HeaderMixin.java b/main/src/com/google/android/setupdesign/template/HeaderMixin.java index 814f873..2a6114d 100644 --- a/main/src/com/google/android/setupdesign/template/HeaderMixin.java +++ b/main/src/com/google/android/setupdesign/template/HeaderMixin.java @@ -27,6 +27,7 @@ import android.view.View; import android.view.ViewGroup; import android.view.ViewParent; import android.view.ViewTreeObserver; +import android.view.ViewTreeObserver.OnPreDrawListener; import android.widget.LinearLayout; import android.widget.TextView; import androidx.annotation.AttrRes; @@ -42,6 +43,7 @@ import com.google.android.setupdesign.util.HeaderAreaStyler; import com.google.android.setupdesign.util.LayoutStyler; import com.google.android.setupdesign.util.PartnerStyleHelper; import com.google.errorprone.annotations.CanIgnoreReturnValue; +import java.util.ArrayList; /** * A {@link com.google.android.setupcompat.template.Mixin} for setting and getting the header text. @@ -54,7 +56,10 @@ public class HeaderMixin implements Mixin { private float headerAutoSizeMinTextSizeInPx; private float headerAutoSizeLineExtraSpacingInPx; private int headerAutoSizeMaxLineOfMaxSize; + private float defaultTextSize = 0; + private int defaultLineHeight = 0; private static final int AUTO_SIZE_DEFAULT_MAX_LINES = 6; + ArrayList<OnPreDrawListener> titlePreDrawListeners = new ArrayList<>(); /** * A {@link com.google.android.setupcompat.template.Mixin} for setting and getting the Header. @@ -78,8 +83,11 @@ public class HeaderMixin implements Mixin { a.getColorStateList(R.styleable.SucHeaderMixin_sucHeaderTextColor); a.recycle(); - - // Try to update the flag of the uto size config settings + if (getTextView() != null) { + defaultTextSize = getTextView().getTextSize(); + defaultLineHeight = getTextView().getLineHeight(); + } + // Try to update the flag of the auto size config settings tryUpdateAutoTextSizeFlagWithPartnerConfig(); // Set the header text @@ -109,7 +117,11 @@ public class HeaderMixin implements Mixin { if (!autoTextSizeEnabled) { return; } + tryUpdateAutoTextConfigWithPartnerConfig(); + } + private void tryUpdateAutoTextConfigWithPartnerConfig() { + Context context = templateLayout.getContext(); if (PartnerConfigHelper.get(context) .isPartnerConfigAvailable(PartnerConfig.CONFIG_HEADER_AUTO_SIZE_MAX_TEXT_SIZE)) { headerAutoSizeMaxTextSizeInPx = @@ -207,36 +219,66 @@ public class HeaderMixin implements Mixin { } // preset as the max size titleView.setTextSize(TypedValue.COMPLEX_UNIT_PX, headerAutoSizeMaxTextSizeInPx); + defaultTextSize = titleView.getTextSize(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { titleView.setLineHeight( Math.round(headerAutoSizeLineExtraSpacingInPx + headerAutoSizeMaxTextSizeInPx)); + defaultLineHeight = titleView.getLineHeight(); } titleView.setMaxLines(AUTO_SIZE_DEFAULT_MAX_LINES); - // reset text size if the line count for max text size > headerAutoSizeMaxLineOfMaxTextSize - titleView - .getViewTreeObserver() - .addOnPreDrawListener( - new ViewTreeObserver.OnPreDrawListener() { - @Override - public boolean onPreDraw() { - // Remove listener to avoid this called every frame - titleView.getViewTreeObserver().removeOnPreDrawListener(this); - int lineCount = titleView.getLineCount(); - if (lineCount > headerAutoSizeMaxLineOfMaxSize) { - // reset text size - titleView.setTextSize(TypedValue.COMPLEX_UNIT_PX, headerAutoSizeMinTextSizeInPx); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { - titleView.setLineHeight( - Math.round( - headerAutoSizeLineExtraSpacingInPx + headerAutoSizeMinTextSizeInPx)); - } - titleView.invalidate(); - return false; // false to skip this frame - } - return true; + OnPreDrawListener titlePreDrawListener = + new ViewTreeObserver.OnPreDrawListener() { + @Override + public boolean onPreDraw() { + // Remove listener to avoid this called every frame + titleView.getViewTreeObserver().removeOnPreDrawListener(this); + int lineCount = titleView.getLineCount(); + if (lineCount > headerAutoSizeMaxLineOfMaxSize) { + // reset text size + titleView.setTextSize(TypedValue.COMPLEX_UNIT_PX, headerAutoSizeMinTextSizeInPx); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { + titleView.setLineHeight( + Math.round(headerAutoSizeLineExtraSpacingInPx + headerAutoSizeMinTextSizeInPx)); } - }); + titleView.invalidate(); + return false; // false to skip this frame + } + return true; + } + }; + titleView.getViewTreeObserver().addOnPreDrawListener(titlePreDrawListener); + titlePreDrawListeners.add(titlePreDrawListener); + } + + private void resetTextSize(TextView titleView) { + if (titleView == null) { + return; + } + titleView.setTextSize(TypedValue.COMPLEX_UNIT_PX, defaultTextSize); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { + titleView.setLineHeight(defaultLineHeight); + } + for (OnPreDrawListener titlePreDrawListener : titlePreDrawListeners) { + titleView.getViewTreeObserver().removeOnPreDrawListener(titlePreDrawListener); + } + titlePreDrawListeners.clear(); + } + + /** + * Enable or disable the auto size for header string. Which will adjust the font size of header + * string to fit the limitation of headerAutoSizeMaxLineOfMaxSize. + */ + public void setAutoTextSizeEnabled(boolean autoTextSizeEnabled) { + this.autoTextSizeEnabled = autoTextSizeEnabled; + if (autoTextSizeEnabled) { + tryUpdateAutoTextConfigWithPartnerConfig(); + if (autoTextSizeEnabled) { + autoAdjustTextSize(getTextView()); + } + } else { + resetTextSize(getTextView()); + } } /** Returns the current header text. */ diff --git a/main/src/com/google/android/setupdesign/template/ProfileMixin.java b/main/src/com/google/android/setupdesign/template/ProfileMixin.java new file mode 100644 index 0000000..2970d0e --- /dev/null +++ b/main/src/com/google/android/setupdesign/template/ProfileMixin.java @@ -0,0 +1,201 @@ +/* + * Copyright (C) 2022 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.template; + +import android.graphics.drawable.Drawable; +import android.util.AttributeSet; +import android.util.Log; +import android.view.View; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.TextView; +import androidx.annotation.DrawableRes; +import com.google.android.setupcompat.internal.TemplateLayout; +import com.google.android.setupcompat.template.Mixin; +import com.google.android.setupdesign.R; +import com.google.android.setupdesign.util.HeaderAreaStyler; +import com.google.android.setupdesign.util.LayoutStyler; +import com.google.android.setupdesign.util.PartnerStyleHelper; +import com.google.errorprone.annotations.CheckReturnValue; + +/** A {@link Mixin} for setting an account name and account avatar on the template layout. */ +@CheckReturnValue // see go/why-crv +public class ProfileMixin implements Mixin { + + private final TemplateLayout templateLayout; + private static final String TAG = "ProfileMixin"; + public static final int RIGHT = 5; + public static final int CENTER = 17; + public static final int LEFT = 3; + + /** + * A {@link Mixin} for setting and getting the Account. + * + * @param layout The template layout that this Mixin is a part of + * @param attrs XML attributes given to the layout + * @param defStyleAttr The default style attribute as given to the constructor of the layout + */ + public ProfileMixin(TemplateLayout layout, AttributeSet attrs, int defStyleAttr) { + templateLayout = layout; + } + + /** + * Sets the Account name. + * + * @param accountName The text to be set as account name + */ + public void setAccountName(CharSequence accountName) { + final TextView accountView = getAccountNameView(); + final ImageView iconView = getAccountAvatarView(); + final LinearLayout container = getContainerView(); + if (accountView != null && accountName != null) { + accountView.setText(accountName); + container.setVisibility(View.VISIBLE); + if (iconView != null && getAccountAvatar() == null) { + iconView.setVisibility(View.GONE); + } + } else { + Log.w(TAG, "Didn't get the account name"); + } + } + + /** + * Sets the icon on this layout. + * + * @param icon A drawable icon to set, or {@code null} to hide the icon + */ + public void setAccountAvatar(Drawable icon) { + final ImageView iconView = getAccountAvatarView(); + final LinearLayout container = getContainerView(); + if (iconView != null && icon != null) { + iconView.setImageDrawable(icon); + container.setVisibility(View.VISIBLE); + iconView.setVisibility(View.VISIBLE); + } else if (iconView != null) { + iconView.setVisibility(View.GONE); + Log.w(TAG, "Didn't get the account avatar"); + } + } + + /** + * Sets the icon on this layout. + * + * @param icon A drawable icon resource to set, or {@code null} to hide the icon + */ + public void setAccountAvatar(@DrawableRes int icon) { + final ImageView iconView = getAccountAvatarView(); + final LinearLayout container = getContainerView(); + if (iconView != null && icon != 0) { + // Note: setImageResource on the ImageView is overridden in AppCompatImageView for + // support lib users, which enables vector drawable compat to work on versions pre-L. + iconView.setImageResource(icon); + container.setVisibility(View.VISIBLE); + iconView.setVisibility(View.VISIBLE); + } else if (iconView != null) { + iconView.setVisibility(View.GONE); + Log.w(TAG, "Didn't get the account avatar"); + } + } + + /** + * Sets the account name icon on this layout. + * + * @param accountName The text to be set as account name + * @param icon A drawable icon + */ + public void setAccount(CharSequence accountName, Drawable icon) { + setAccountName(accountName); + setAccountAvatar(icon); + } + + /** + * Sets the account name icon on this layout. + * + * @param accountName The text to be set as account name + * @param icon A drawable icon resource + */ + public void setAccount(CharSequence accountName, @DrawableRes int icon) { + setAccountName(accountName); + setAccountAvatar(icon); + } + + /** + * Sets the visibility of the account. gone map to 8 invisible map to 4 visible map to 0 + * + * @param visibility Set it visible or not + */ + public void setVisibility(int visibility) { + getContainerView().setVisibility(visibility); + } + + /** + * Makes account align to left, center or right. + * + * @param gravity the number or the gravity + */ + public void setAccountAlignment(int gravity) { + final LinearLayout container = getContainerView(); + if (gravity == RIGHT || gravity == CENTER || gravity == LEFT) { + container.setGravity(gravity); + } else { + Log.w(TAG, "Unsupported alignment"); + } + } + + /** Tries to apply the partner customization to the account photo. */ + public void tryApplyPartnerCustomizationStyle() { + if (PartnerStyleHelper.shouldApplyPartnerResource(templateLayout)) { + final ImageView iconView = getAccountAvatarView(); + final TextView accountView = getAccountNameView(); + final LinearLayout container = getContainerView(); + View iconAreaView = templateLayout.findManagedViewById(R.id.sud_layout_header); + LayoutStyler.applyPartnerCustomizationExtraPaddingStyle(iconAreaView); + HeaderAreaStyler.applyPartnerCustomizationAccountStyle(iconView, accountView, container); + } + } + + /** Returns the current account name. */ + public CharSequence getAccountName() { + final TextView accountView = getAccountNameView(); + return accountView.getText(); + } + + /** Returns the current account avatar. */ + public Drawable getAccountAvatar() { + final ImageView iconView = getAccountAvatarView(); + return iconView.getDrawable(); + } + + /** Returns the current account name text. */ + private TextView getAccountNameView() { + return (TextView) templateLayout.findManagedViewById(R.id.sud_account_name); + } + + /** Returns the current account icon image. */ + private ImageView getAccountAvatarView() { + return (ImageView) templateLayout.findManagedViewById(R.id.sud_account_avatar); + } + + private LinearLayout getContainerView() { + return (LinearLayout) templateLayout.findManagedViewById(R.id.sud_layout_profile); + } + + /** Returns the current account visibility. */ + public int getVisibility() { + return getContainerView().getVisibility(); + } +} diff --git a/main/src/com/google/android/setupdesign/transition/TransitionHelper.java b/main/src/com/google/android/setupdesign/transition/TransitionHelper.java index ec2c480..5dd5f3d 100644 --- a/main/src/com/google/android/setupdesign/transition/TransitionHelper.java +++ b/main/src/com/google/android/setupdesign/transition/TransitionHelper.java @@ -127,6 +127,9 @@ public class TransitionHelper { // TODO: Add new partner resource to determine which transition type would be apply. public static final int TRANSITION_CAPTIVE = 5; + /** Override the transition to a fade-through-from-right (or from-left for RTL locales). */ + public static final int TRANSITION_FADE_THROUGH = 6; + /** * No override. If this is specified as the transition, the enter/exit transition of the window * will not be set and keep original behavior. @@ -154,11 +157,17 @@ public class TransitionHelper { private TransitionHelper() {} /** - * Apply the transition for going forward which is decided by partner resource {@link - * PartnerConfig#CONFIG_TRANSITION_TYPE} and system property {@code setupwizard.transition_type}. - * The default transition that will be applied is {@link #TRANSITION_SLIDE}. The timing to apply - * the transition is going forward from the previous activity to this, or going forward from this - * activity to the next. + * Apply the transition for going forward which is decided by {@code Animation.SudWindowAnimation} + * theme if the API level is equal or higher than {@link android.os.Build.VERSION_CODES#U}. + * + * <p>Otherwise, apply the transition for going forward which is decided by partner resource + * {@link PartnerConfig#CONFIG_TRANSITION_TYPE} and system property {@code + * setupwizard.transition_type} if the API level is equal or lower than {@link + * android.os.Build.VERSION_CODES#T}. The default transition that will be applied is {@link + * #TRANSITION_SLIDE}. + * + * <p>The timing to apply the transition is going forward from the previous activity to this, or + * going forward from this activity to the next. * * <p>For example, in the flow below, the forward transitions will be applied to all arrows * pointing to the right. Previous screen --> This screen --> Next screen @@ -199,15 +208,63 @@ public class TransitionHelper { } /** - * Apply the transition for going forward. This is applied when going forward from the previous - * activity to this, or going forward from this activity to the next. + * Apply the transition for going forward which is decided by {@code Animation.SudWindowAnimation} + * theme if the API level is equal or higher than {@link android.os.Build.VERSION_CODES#U}. + * + * <p>Otherwise, apply the transition for going forward which is decided by the argument {@code + * transitionId} if the API level is equal or lower than {@link android.os.Build.VERSION_CODES#T}. + * + * <p>The timing to apply the transition is going forward from the previous activity to this, or + * going forward from this activity to the next. + */ + @TargetApi(VERSION_CODES.LOLLIPOP) + public static void applyForwardTransition(Activity activity, @TransitionType int transitionId) { + applyForwardTransition(activity, transitionId, /* useClientTransitionSettings= */ false); + } + + /** + * Apply the transition for going forward which is decided by {@code Animation.SudWindowAnimation} + * theme if the API level is equal or higher than {@link android.os.Build.VERSION_CODES#U}, and + * argument {@code useClientTransitionSettings} is false, and System property {@code + * suw_apply_glif_theme_controlled_transition} is true, and {@code TRANSITION_FADE_THOUGH} + * transition is not specified. + * + * <p>Otherwise, apply the transition for going forward which is decided by the argument {@code + * transitionId}, {@code shared_x_axis_activity} transition is used only when {@code + * TRANSITION_FADE_TROUGH} transition is specified, and System property {@code * + * suw_apply_glif_theme_controlled_transition} is true, and the API level is equal or more than + * {@link android.os.Build.VERSION_CODES#U}, other {@code transitionId} can be specified if the + * API level is equal or lower than {@link android.os.Build.VERSION_CODES#T}, or argument {@code + * useClientTransitionSettings} is true, or System property {@code + * suw_apply_glif_theme_controlled_transition} is false. The default transition that will be + * applied is {@link #TRANSITION_SLIDE}. + * + * <p>The timing to apply the transition is going forward from the previous activity to this, or + * going forward from this activity to the next. * * <p>For example, in the flow below, the forward transitions will be applied to all arrows * pointing to the right. Previous screen --> This screen --> Next screen */ @TargetApi(VERSION_CODES.LOLLIPOP) - public static void applyForwardTransition(Activity activity, @TransitionType int transitionId) { - if (transitionId == TRANSITION_SLIDE) { + public static void applyForwardTransition( + Activity activity, @TransitionType int transitionId, boolean useClientTransitionSettings) { + if (BuildCompatUtils.isAtLeastU() + && !useClientTransitionSettings + && PartnerConfigHelper.isGlifThemeControlledTransitionApplied(activity) + && transitionId != TRANSITION_FADE_THROUGH) { + // Do nothing + } else if (BuildCompatUtils.isAtLeastU() && transitionId == TRANSITION_FADE_THROUGH) { + int openEnterTransition = R.anim.shared_x_axis_activity_open_enter; + if (PartnerConfigHelper.isGlifThemeControlledTransitionApplied(activity)) { + if (ThemeHelper.shouldApplyDynamicColor(activity)) { + openEnterTransition = R.anim.shared_x_axis_activity_open_enter_dynamic_color; + } + activity.overridePendingTransition( + openEnterTransition, R.anim.shared_x_axis_activity_open_exit); + } else { + activity.overridePendingTransition(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out); + } + } else if (transitionId == TRANSITION_SLIDE) { activity.overridePendingTransition(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out); } else if (transitionId == TRANSITION_FADE) { activity.overridePendingTransition(android.R.anim.fade_in, R.anim.sud_stay); @@ -256,14 +313,21 @@ public class TransitionHelper { } /** - * Apply the transition for going backward which is decided by partner resource {@link - * PartnerConfig#CONFIG_TRANSITION_TYPE} and system property {@code setupwizard.transition_type}. - * The default transition that will be applied is {@link #TRANSITION_SLIDE}. The timing to apply - * the transition is going backward from the next activity to this, or going backward from this - * activity to the previous. + * Apply the transition for going backward which is decided by {@code + * Animation.SudWindowAnimation} theme if the API level is equal or higher than {@link + * android.os.Build.VERSION_CODES#U}. + * + * <p>Otherwise, apply the transition for going backward which is decided by partner resource + * {@link PartnerConfig#CONFIG_TRANSITION_TYPE} and system property {@code + * setupwizard.transition_type} if the API level is equal or lower than {@link + * android.os.Build.VERSION_CODES#T}. The default transition that will be applied is {@link + * #TRANSITION_SLIDE}. + * + * <p>The timing to apply the transition is going backward from the next activity to this, or + * going backward from this activity to the previous. * * <p>For example, in the flow below, the backward transitions will be applied to all arrows - * pointing to the left. Previous screen <-- This screen <-- Next screen + * pointing to the left. Previous screen <-- This screen <-- Next screen. */ @TargetApi(VERSION_CODES.LOLLIPOP) public static void applyBackwardTransition(Activity activity) { @@ -301,15 +365,64 @@ public class TransitionHelper { } /** - * Apply the transition for going backward. This is applied when going backward from the next - * activity to this, or going backward from this activity to the previous. + * Apply the transition for going backward which is decided by {@code + * Animation.SudWindowAnimation} theme if the API level is equal or higher than {@link + * android.os.Build.VERSION_CODES#U}. + * + * <p>Otherwise, apply the transition for going backward which is decided by the argument {@code + * transitionId} if the API level is equal or lower than {@link android.os.Build.VERSION_CODES#T}. + * + * <p>The timing to apply the transition is going backward from the next activity to this, or + * going backward from this activity to the previous. + */ + @TargetApi(VERSION_CODES.LOLLIPOP) + public static void applyBackwardTransition(Activity activity, @TransitionType int transitionId) { + applyBackwardTransition(activity, transitionId, /* useClientTransitionSettings= */ false); + } + + /** + * Apply the transition for going backward which is decided by {@code + * Animation.SudWindowAnimation} theme if the API level is equal or higher than {@link + * android.os.Build.VERSION_CODES#U}, and argument {@code useClientTransitionSettings} is false, + * and System property {@code suw_apply_glif_theme_controlled_transition} is true, and {@code + * TRANSITION_FADE_THOUGH} transition is not specified. + * + * <p>Otherwise, apply the transition for going backward which is decided by the argument {@code + * transitionId}, {@code shared_x_axis_activity} transition is used only when {@code + * TRANSITION_FADE_TROUGH} transition is specified, and System property {@code * + * suw_apply_glif_theme_controlled_transition} is true, and the API level is equal or more than + * {@link android.os.Build.VERSION_CODES#U}, other {@code transitionId} can be specified if the + * API level is equal or lower than {@link android.os.Build.VERSION_CODES#T}, or argument {@code + * useClientTransitionSettings} is true, or System property {@code + * suw_apply_glif_theme_controlled_transition} is false. The default transition that will be + * applied is {@link #TRANSITION_SLIDE}. + * + * <p>The timing to apply the transition is going backward from the next activity to this, or + * going backward from this activity to the previous. * * <p>For example, in the flow below, the backward transitions will be applied to all arrows * pointing to the left. Previous screen <-- This screen <-- Next screen */ @TargetApi(VERSION_CODES.LOLLIPOP) - public static void applyBackwardTransition(Activity activity, @TransitionType int transitionId) { - if (transitionId == TRANSITION_SLIDE) { + public static void applyBackwardTransition( + Activity activity, @TransitionType int transitionId, boolean useClientTransitionSettings) { + if (BuildCompatUtils.isAtLeastU() + && !useClientTransitionSettings + && PartnerConfigHelper.isGlifThemeControlledTransitionApplied(activity) + && transitionId != TRANSITION_FADE_THROUGH) { + // Do nothing + } else if (BuildCompatUtils.isAtLeastU() && transitionId == TRANSITION_FADE_THROUGH) { + if (PartnerConfigHelper.isGlifThemeControlledTransitionApplied(activity)) { + int closeEnterTransition = R.anim.shared_x_axis_activity_close_enter; + if (ThemeHelper.shouldApplyDynamicColor(activity)) { + closeEnterTransition = R.anim.shared_x_axis_activity_close_enter_dynamic_color; + } + activity.overridePendingTransition( + closeEnterTransition, R.anim.shared_x_axis_activity_close_exit); + } else { + activity.overridePendingTransition(R.anim.sud_slide_back_in, R.anim.sud_slide_back_out); + } + } else if (transitionId == TRANSITION_SLIDE) { activity.overridePendingTransition(R.anim.sud_slide_back_in, R.anim.sud_slide_back_out); } else if (transitionId == TRANSITION_FADE) { activity.overridePendingTransition(R.anim.sud_stay, android.R.anim.fade_out); @@ -352,8 +465,8 @@ public class TransitionHelper { } else { Log.w(TAG, "This API is supported from Android Sdk " + VERSION_CODES.LOLLIPOP); } + // For TRANSITION_NO_OVERRIDE or other values, do not override the transition } - // For TRANSITION_NO_OVERRIDE or other values, do not override the transition } /** diff --git a/main/src/com/google/android/setupdesign/util/DeviceHelper.java b/main/src/com/google/android/setupdesign/util/DeviceHelper.java new file mode 100644 index 0000000..1a7e0bd --- /dev/null +++ b/main/src/com/google/android/setupdesign/util/DeviceHelper.java @@ -0,0 +1,116 @@ +/* + * Copyright (C) 2022 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.util; + +import android.annotation.SuppressLint; +import android.content.ContentResolver; +import android.content.Context; +import android.content.res.Resources.NotFoundException; +import android.net.Uri; +import android.os.Bundle; +import android.text.TextUtils; +import android.util.Log; +import androidx.annotation.NonNull; +import androidx.annotation.VisibleForTesting; +import com.google.android.setupcompat.util.Logger; +import com.google.android.setupdesign.R; + +/** Helper class to get attributes of the device, like a friendly display name. */ +public final class DeviceHelper { + + private static final Logger LOG = new Logger("DeviceHelper"); + private static final String TAG = DeviceHelper.class.getSimpleName(); + + @VisibleForTesting + public static final String SUW_AUTHORITY = "com.google.android.setupwizard.partner"; + + @VisibleForTesting public static final String DEVICE_NAME = "device_name"; + private static final String STRING = "string"; + @VisibleForTesting public static final String GET_DEVICE_NAME_METHOD = "getDeviceName"; + + @VisibleForTesting public static Bundle deviceName = null; + + /** + * Get the device name text from these resources, if they are unavailable or setupwizard apk is + * older which does not contains {@link DeviceHelper#GET_DEVICE_NAME_METHOD} method, return the + * device name as default value "device". + * + * <p>Priority: partner config ({@link + * com.google.android.setupwizard.util.PartnerResource#DEVICE_NAME}) > {@link + * android.provider.Settings.Global#DEVICE_NAME} > system property ro.product.model) + */ + public static CharSequence getDeviceName(@NonNull Context context) { + return getDeviceName(context, /* enableCache= */ true); + } + + /** + * Get the device name text from these resources, if they are unavailable or setupwizard apk is + * older which does not contains {@link DeviceHelper#GET_DEVICE_NAME_METHOD} method, return the + * device name as default value "device". + * + * <p>Priority: partner config ({@link + * com.google.android.setupwizard.util.PartnerResource#DEVICE_NAME}) > {@link + * android.provider.Settings.Global#DEVICE_NAME} > system property ro.product.model) + * + * @param enableCache Indicates whether the device name is preferentially obtained from the cache. + */ + @NonNull + @SuppressLint("DiscouragedApi") + public static CharSequence getDeviceName(@NonNull Context context, boolean enableCache) { + if (deviceName == null || deviceName.isEmpty() || !enableCache) { + try { + deviceName = + context + .getContentResolver() + .call( + new Uri.Builder() + .scheme(ContentResolver.SCHEME_CONTENT) + .authority(SUW_AUTHORITY) + .build(), + GET_DEVICE_NAME_METHOD, + /* arg= */ null, + /* extras= */ null); + } catch (IllegalArgumentException | SecurityException exception) { + Log.w(TAG, "device name unknown; return the device name as default value"); + } + } + + if (deviceName != null && !deviceName.isEmpty()) { + return deviceName.getCharSequence(GET_DEVICE_NAME_METHOD, null); + } + + Partner partner = Partner.get(context); + if (partner != null) { + try { + int resId = + partner.getResources().getIdentifier(DEVICE_NAME, STRING, partner.getPackageName()); + String overlayDeviceName = partner.getResources().getString(resId); + if (!TextUtils.isEmpty(overlayDeviceName)) { + return overlayDeviceName; + } else { + LOG.w("The overlayDeviceName is null!"); + } + } catch (NotFoundException ex) { + // fall through + } + } + + return context.getString(R.string.sud_default_device_name); + } + + private DeviceHelper() {} +} diff --git a/main/src/com/google/android/setupdesign/util/HeaderAreaStyler.java b/main/src/com/google/android/setupdesign/util/HeaderAreaStyler.java index e233219..bb1c667 100644 --- a/main/src/com/google/android/setupdesign/util/HeaderAreaStyler.java +++ b/main/src/com/google/android/setupdesign/util/HeaderAreaStyler.java @@ -19,18 +19,21 @@ package com.google.android.setupdesign.util; import static com.google.android.setupcompat.util.BuildCompatUtils.isAtLeastS; import android.content.Context; +import android.graphics.Typeface; import android.graphics.drawable.Drawable; import android.graphics.drawable.VectorDrawable; import android.os.Build; import android.os.Build.VERSION; import android.os.Build.VERSION_CODES; import android.util.Log; +import android.util.TypedValue; import android.view.ViewGroup; import android.view.ViewGroup.LayoutParams; import android.view.ViewTreeObserver; import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.ImageView.ScaleType; +import android.widget.LinearLayout; import android.widget.ProgressBar; import android.widget.TextView; import androidx.annotation.Nullable; @@ -100,6 +103,53 @@ public final class HeaderAreaStyler { PartnerStyleHelper.getLayoutGravity(description.getContext()))); } + public static void applyPartnerCustomizationAccountStyle( + ImageView avatar, TextView name, LinearLayout container) { + if (avatar == null || name == null) { + return; + } + + Context context = avatar.getContext(); + + ViewGroup.LayoutParams lpIcon = avatar.getLayoutParams(); + if (lpIcon instanceof ViewGroup.MarginLayoutParams) { + ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) lpIcon; + + int rightMargin = + (int) + PartnerConfigHelper.get(context) + .getDimension(context, PartnerConfig.CONFIG_ACCOUNT_AVATAR_MARGIN_END); + mlp.setMargins(mlp.leftMargin, mlp.topMargin, rightMargin, mlp.bottomMargin); + } + + int maxHeight = + (int) + PartnerConfigHelper.get(context) + .getDimension(context, PartnerConfig.CONFIG_ACCOUNT_AVATAR_SIZE, + context.getResources().getDimension(R.dimen.sud_account_avatar_max_height)); + avatar.setMaxHeight(maxHeight); + + int textSize = + (int) + PartnerConfigHelper.get(context) + .getDimension( + context, + PartnerConfig.CONFIG_ACCOUNT_NAME_TEXT_SIZE, + context.getResources().getDimension(R.dimen.sud_account_name_text_size)); + name.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); + + String textFamily = + PartnerConfigHelper.get(context) + .getString(context, PartnerConfig.CONFIG_ACCOUNT_NAME_FONT_FAMILY); + Typeface font = Typeface.create(textFamily, Typeface.NORMAL); + if (font != null) { + name.setTypeface(font); + } + + int gravity = PartnerStyleHelper.getLayoutGravity(container.getContext()); + container.setGravity(gravity); + } + /** * 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 diff --git a/main/src/com/google/android/setupdesign/util/Partner.java b/main/src/com/google/android/setupdesign/util/Partner.java index cf26f16..ce0c0d2 100644 --- a/main/src/com/google/android/setupdesign/util/Partner.java +++ b/main/src/com/google/android/setupdesign/util/Partner.java @@ -33,11 +33,14 @@ import androidx.annotation.AnyRes; import androidx.annotation.ArrayRes; import androidx.annotation.BoolRes; import androidx.annotation.ColorRes; +import androidx.annotation.DimenRes; import androidx.annotation.DrawableRes; import androidx.annotation.Nullable; +import androidx.annotation.RawRes; import androidx.annotation.RequiresApi; import androidx.annotation.StringRes; import androidx.annotation.VisibleForTesting; +import java.io.InputStream; import java.util.Arrays; import java.util.HashSet; import java.util.List; @@ -84,6 +87,28 @@ public class Partner { } /** + * Gets a dimension value from partner overlay, or if not available, gets the value from the + * original context instead. + * + * @see #getResourceEntry(Context, int) + */ + public static int getDimensionPixelSize(Context context, @DimenRes int id) { + final ResourceEntry entry = getResourceEntry(context, id); + return entry.resources.getDimensionPixelSize(entry.id); + } + + /** + * Gets a dimension value from partner overlay, or if not available, gets the value from the + * original context instead. + * + * @see #getResourceEntry(Context, int) + */ + public static float getDimension(Context context, @DimenRes int id) { + final ResourceEntry entry = getResourceEntry(context, id); + return entry.resources.getDimension(entry.id); + } + + /** * Gets a drawable from partner overlay, or if not available, the drawable from the original * context. * @@ -160,6 +185,17 @@ public class Partner { return new ResourceEntry(context.getPackageName(), context.getResources(), id, false); } + /** + * Returns input stream for raw resources from overlay package provided by partners. + * + * @return an InputStream in the partner overlay's resources, if one is defined. Otherwise the + * InputStream in resources from the original context is returned. + */ + public static InputStream getRawResources(Context context, @RawRes int id) { + final ResourceEntry entry = getResourceEntry(context, id); + return entry.resources.openRawResource(entry.id); + } + public static class ResourceEntry { public String packageName; public Resources resources; diff --git a/main/src/com/google/android/setupdesign/util/ThemeHelper.java b/main/src/com/google/android/setupdesign/util/ThemeHelper.java index eeee7dd..4c349e4 100644 --- a/main/src/com/google/android/setupdesign/util/ThemeHelper.java +++ b/main/src/com/google/android/setupdesign/util/ThemeHelper.java @@ -19,6 +19,8 @@ package com.google.android.setupdesign.util; import android.app.Activity; import android.content.Context; import android.content.Intent; +import android.os.Build.VERSION; +import android.os.Build.VERSION_CODES; import androidx.annotation.NonNull; import androidx.annotation.StyleRes; import com.google.android.setupcompat.PartnerCustomizationLayout; @@ -199,7 +201,7 @@ public final class ThemeHelper { boolean isSetupFlow = WizardManagerHelper.isAnySetupWizard(activity.getIntent()); boolean isDayNightEnabled = isSetupWizardDayNightEnabled(context); - if (isSetupFlow) { + if (isSetupFlow && !BuildCompatUtils.isAtLeastU()) { // return theme for inside setup flow resId = isDayNightEnabled @@ -235,6 +237,39 @@ public final class ThemeHelper { return resId; } + /** Returns a default theme resource id which provides by setup wizard. */ + @StyleRes + public static int getSuwDefaultTheme(@NonNull Context context) { + String themeName = PartnerConfigHelper.getSuwDefaultThemeString(context); + @StyleRes int defaultTheme; + if (VERSION.SDK_INT < VERSION_CODES.O) { + defaultTheme = + ThemeHelper.isSetupWizardDayNightEnabled(context) + ? R.style.SudThemeGlif_DayNight + : R.style.SudThemeGlif_Light; + } else if (VERSION.SDK_INT < VERSION_CODES.P) { + defaultTheme = + ThemeHelper.isSetupWizardDayNightEnabled(context) + ? R.style.SudThemeGlifV2_DayNight + : R.style.SudThemeGlifV2_Light; + } else if (VERSION.SDK_INT < VERSION_CODES.TIRAMISU) { + defaultTheme = + ThemeHelper.isSetupWizardDayNightEnabled(context) + ? R.style.SudThemeGlifV3_DayNight + : R.style.SudThemeGlifV3_Light; + } else { + defaultTheme = + ThemeHelper.isSetupWizardDayNightEnabled(context) + ? R.style.SudThemeGlifV4_DayNight + : R.style.SudThemeGlifV4_Light; + } + return new ThemeResolver.Builder() + .setDefaultTheme(defaultTheme) + .setUseDayNight(isSetupWizardDayNightEnabled(context)) + .build() + .resolve(themeName, /* suppressDayNight= */ !isSetupWizardDayNightEnabled(context)); + } + /** Returns {@code true} if the dynamic color is set. */ public static boolean trySetDynamicColor(@NonNull Context context) { if (!BuildCompatUtils.isAtLeastS()) { diff --git a/strings/res/values/strings.xml b/strings/res/values/strings.xml index 7608716..0b976a5 100644 --- a/strings/res/values/strings.xml +++ b/strings/res/values/strings.xml @@ -22,6 +22,12 @@ <!-- Button for going to the previous screen or step [CHAR LIMIT=20] --> <string name="sud_back_button_label">Back</string> + <!-- Button for skipping the action on the current screen [CHAR LIMIT=20] --> + <string name="sud_skip_button_label">Skip</string> + <!-- Button for scrolling down to reveal more content on the screen [CHAR LIMIT=20] --> <string name="sud_more_button_label">More</string> + + <!-- The default device name when other resources get the device name are not available [CHAR LIMIT=20] --> + <string name="sud_default_device_name">device</string> </resources> |