From 9deaf6f7fbd5c138cb66975631b694788ce03425 Mon Sep 17 00:00:00 2001 From: Tsung-Mao Fang Date: Thu, 16 Feb 2023 14:47:00 +0000 Subject: Revert "Revert "Import updated Android Setupdesign Library 50845..." Revert submission 21414271-revert-21343156-skyeye-metric-api-RVCTNJHZTP Reason for revert: Test for building a good rom Reverted changes: /q/submissionid:21414271-revert-21343156-skyeye-metric-api-RVCTNJHZTP Test: Rebuilt rom Fix: 269530919 Change-Id: I835cab9efd9aefe973ff933a63d96d9ebdbde3d5 --- ...f_fullscreen_loading_embedded_template_card.xml | 49 +++++++++ ...ullscreen_loading_embedded_template_content.xml | 96 +++++++++++++++++ .../sud_glif_loading_embedded_template_card.xml | 49 +++++++++ .../sud_glif_loading_embedded_template_compat.xml | 26 +++++ .../sud_glif_loading_embedded_template_content.xml | 80 ++++++++++++++ .../res/values-sw600dp-v31/layouts.xml | 2 + .../res/values-sw600dp/layouts.xml | 1 + lottie_loading_layout/res/values/layouts.xml | 2 + .../android/setupdesign/GlifLoadingLayout.java | 35 ++++++- .../setupdesign/util/LottieAnimationHelper.java | 9 +- .../shared_x_axis_activity_close_enter.xml | 43 ++++++++ .../shared_x_axis_activity_open_enter.xml | 43 ++++++++ .../shared_x_axis_activity_close_enter.xml | 43 ++++++++ ...d_x_axis_activity_close_enter_dynamic_color.xml | 43 ++++++++ .../anim-v34/shared_x_axis_activity_close_exit.xml | 41 ++++++++ .../anim-v34/shared_x_axis_activity_open_enter.xml | 43 ++++++++ ...ed_x_axis_activity_open_enter_dynamic_color.xml | 43 ++++++++ .../anim-v34/shared_x_axis_activity_open_exit.xml | 41 ++++++++ .../interpolator-v21/fast_out_extra_slow_in.xml | 19 ++++ main/res/interpolator-v21/standard_accelerate.xml | 22 ++++ main/res/interpolator-v21/standard_decelerate.xml | 22 ++++ .../sud_glif_blank_embedded_template_card.xml | 49 +++++++++ .../sud_glif_blank_embedded_template_compact.xml | 26 +++++ .../sud_glif_blank_embedded_template_content.xml | 41 ++++++++ .../res/layout/sud_glif_embedded_template_card.xml | 49 +++++++++ .../layout/sud_glif_embedded_template_compact.xml | 26 +++++ .../layout/sud_glif_embedded_template_content.xml | 71 +++++++++++++ .../sud_glif_list_embedded_template_card.xml | 49 +++++++++ .../sud_glif_list_embedded_template_compact.xml | 26 +++++ .../sud_glif_list_embedded_template_content.xml | 48 +++++++++ .../sud_glif_recycler_embedded_template_card.xml | 49 +++++++++ ...sud_glif_recycler_embedded_template_compact.xml | 26 +++++ ...sud_glif_recycler_embedded_template_content.xml | 49 +++++++++ main/res/values-sw600dp-land-v33/config.xml | 19 ++++ main/res/values-sw600dp/layouts.xml | 4 + main/res/values-v31/styles.xml | 4 + main/res/values-v34/dimens.xml | 2 + main/res/values-v34/styles.xml | 32 ++++++ main/res/values/config.xml | 3 + main/res/values/dimens.xml | 11 +- main/res/values/layouts.xml | 6 ++ main/res/values/styles.xml | 4 + .../com/google/android/setupdesign/GlifLayout.java | 15 ++- .../google/android/setupdesign/GlifListLayout.java | 4 + .../android/setupdesign/GlifPreferenceLayout.java | 4 + .../android/setupdesign/GlifRecyclerLayout.java | 4 + .../setupdesign/transition/TransitionHelper.java | 116 +++++++++++++++++---- .../google/android/setupdesign/util/Partner.java | 13 +++ 48 files changed, 1472 insertions(+), 30 deletions(-) create mode 100644 lottie_loading_layout/res/layout/sud_glif_fullscreen_loading_embedded_template_card.xml create mode 100644 lottie_loading_layout/res/layout/sud_glif_fullscreen_loading_embedded_template_content.xml create mode 100644 lottie_loading_layout/res/layout/sud_glif_loading_embedded_template_card.xml create mode 100644 lottie_loading_layout/res/layout/sud_glif_loading_embedded_template_compat.xml create mode 100644 lottie_loading_layout/res/layout/sud_glif_loading_embedded_template_content.xml create mode 100644 main/res/anim-night-v34/shared_x_axis_activity_close_enter.xml create mode 100644 main/res/anim-night-v34/shared_x_axis_activity_open_enter.xml create mode 100644 main/res/anim-v34/shared_x_axis_activity_close_enter.xml create mode 100644 main/res/anim-v34/shared_x_axis_activity_close_enter_dynamic_color.xml create mode 100644 main/res/anim-v34/shared_x_axis_activity_close_exit.xml create mode 100644 main/res/anim-v34/shared_x_axis_activity_open_enter.xml create mode 100644 main/res/anim-v34/shared_x_axis_activity_open_enter_dynamic_color.xml create mode 100644 main/res/anim-v34/shared_x_axis_activity_open_exit.xml create mode 100644 main/res/interpolator-v21/fast_out_extra_slow_in.xml create mode 100644 main/res/interpolator-v21/standard_accelerate.xml create mode 100644 main/res/interpolator-v21/standard_decelerate.xml create mode 100644 main/res/layout/sud_glif_blank_embedded_template_card.xml create mode 100644 main/res/layout/sud_glif_blank_embedded_template_compact.xml create mode 100644 main/res/layout/sud_glif_blank_embedded_template_content.xml create mode 100644 main/res/layout/sud_glif_embedded_template_card.xml create mode 100644 main/res/layout/sud_glif_embedded_template_compact.xml create mode 100644 main/res/layout/sud_glif_embedded_template_content.xml create mode 100644 main/res/layout/sud_glif_list_embedded_template_card.xml create mode 100644 main/res/layout/sud_glif_list_embedded_template_compact.xml create mode 100644 main/res/layout/sud_glif_list_embedded_template_content.xml create mode 100644 main/res/layout/sud_glif_recycler_embedded_template_card.xml create mode 100644 main/res/layout/sud_glif_recycler_embedded_template_compact.xml create mode 100644 main/res/layout/sud_glif_recycler_embedded_template_content.xml create mode 100644 main/res/values-sw600dp-land-v33/config.xml create mode 100644 main/res/values-v34/styles.xml 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 @@ + + + + + + + + + + + + + + + + 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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 @@ + + + + + + + + + + + + + + + + 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 @@ + + + + + + + + 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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 @@ @layout/sud_glif_loading_template_card + @layout/sud_glif_loading_embedded_template_card @layout/sud_glif_fullscreen_loading_template_card + @layout/sud_glif_fullscreen_loading_embedded_template_card 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 @@ @layout/sud_glif_loading_template_card + @layout/sud_glif_loading_embedded_template_card 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 @@ @layout/sud_glif_loading_template_compat + @layout/sud_glif_loading_embedded_template_compat @layout/sud_glif_loading_template_compat + @layout/sud_glif_loading_embedded_template_compat \ 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 7284f7b..458cb90 100644 --- a/lottie_loading_layout/src/com/google/android/setupdesign/GlifLoadingLayout.java +++ b/lottie_loading_layout/src/com/google/android/setupdesign/GlifLoadingLayout.java @@ -17,10 +17,10 @@ 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; @@ -30,6 +30,7 @@ import android.graphics.ColorFilter; import android.os.Build; 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; @@ -88,6 +89,8 @@ public class GlifLoadingLayout extends GlifLayout { 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 @@ -111,7 +114,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); @@ -447,7 +449,7 @@ public class GlifLoadingLayout extends GlifLayout { paddingBottom = (int) configPaddingBottom - (int) - Math.min( + min( configPaddingBottom, getButtonContainerHeight(footerBarMixin.getButtonContainer())); } @@ -666,17 +668,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); @@ -690,6 +703,18 @@ public class GlifLoadingLayout extends GlifLayout { return super.findContainer(containerId); } + @Override + protected void onDetachedFromWindow() { + if (BuildCompatUtils.isAtLeastU()) { + PersistableBundle bundle = new PersistableBundle(); + bundle.putString(GLIF_LAYOUT_TYPE, LOADING_LAYOUT); + setLayoutTypeMetrics(bundle); + } else { + setLayoutTypeMetrics(null); + } + 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 index c61f0e1..e6cdc11 100644 --- a/lottie_loading_layout/src/com/google/android/setupdesign/util/LottieAnimationHelper.java +++ b/lottie_loading_layout/src/com/google/android/setupdesign/util/LottieAnimationHelper.java @@ -29,6 +29,7 @@ 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; @@ -97,8 +98,12 @@ public class LottieAnimationHelper { String[] splitItem = colorMapping.split(":"); if (splitItem.length == 2) { if (splitItem[1].charAt(0) == '#') { // color code - customizationMap.put( - new KeyPath("**", splitItem[0], "**"), Color.parseColor(splitItem[1])); + 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])) { 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 @@ + + + + + + + + + + \ 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 @@ + + + + + + + + + + \ 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 @@ + + + + + + + + + + \ 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 @@ + + + + + + + + + + \ 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 @@ + + + + + + + + + + \ 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 @@ + + + + + + + + + + \ 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 @@ + + + + + + + + + + \ 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 @@ + + + + + + + + + + \ No newline at end of file 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 @@ + + + + \ 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 @@ + + + + \ 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 @@ + + + + \ 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 @@ + + + + + + + + + + + + + + + + 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 @@ + + + + + + + + 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 @@ + + + + + + + + + + + + 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 @@ + + + + + + + + + + + + + + + + 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 @@ + + + + + + + + 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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + 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 @@ + + + + + + + + + + + + + + + + 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 @@ + + + + + + + + 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 @@ + + + + + + + + + + + + + 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 @@ + + + + + + + + + + + + + + + + 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 @@ + + + + + + + + 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 @@ + + + + + + + + + + + + + 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 @@ + + + + true + \ 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 @@ @layout/sud_no_scroll_template_card @layout/sud_glif_template_card + @layout/sud_glif_embedded_template_card @layout/sud_glif_list_template_card + @layout/sud_glif_list_embedded_template_card @layout/sud_glif_blank_template_card @layout/sud_preference_recycler_view_normal @@ -34,7 +36,9 @@ @layout/sud_recycler_template_card @layout/sud_glif_blank_template_card + @layout/sud_glif_blank_embedded_template_card @layout/sud_glif_recycler_template_card + @layout/sud_glif_recycler_embedded_template_card diff --git a/main/res/values-v31/styles.xml b/main/res/values-v31/styles.xml index 3862741..7216905 100644 --- a/main/res/values-v31/styles.xml +++ b/main/res/values-v31/styles.xml @@ -76,6 +76,8 @@ @style/SudFullDynamicColorAlertDialogTheme true + + @style/Animation.SudWindowAnimation.DynamicColor diff --git a/main/res/values-v34/dimens.xml b/main/res/values-v34/dimens.xml index 6bc38bc..84b245c 100644 --- a/main/res/values-v34/dimens.xml +++ b/main/res/values-v34/dimens.xml @@ -17,4 +17,6 @@ 24dp + 14sp + 14sp \ 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 @@ + + + + + + + + \ No newline at end of file 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 @@ false + + false + google-sans google-sans-text diff --git a/main/res/values/dimens.xml b/main/res/values/dimens.xml index d3f0d02..8626945 100644 --- a/main/res/values/dimens.xml +++ b/main/res/values/dimens.xml @@ -167,7 +167,7 @@ 2.22 - 14dp + 14sp 0dp 0dp @@ -209,7 +209,7 @@ 20dp 48dp - 14dp + 14sp 0dp @@ -310,4 +310,11 @@ 0dp + + 24dp + 24dp + 24dp + 24dp + 24dp + 44sp 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 @@ @layout/sud_glif_template_compact + @layout/sud_glif_embedded_template_compact + @layout/sud_glif_list_template_compact + @layout/sud_glif_list_embedded_template_compact + @layout/sud_glif_blank_template_compact @@ -51,5 +55,7 @@ @layout/sud_glif_blank_template_compact + @layout/sud_glif_blank_embedded_template_compact @layout/sud_glif_recycler_template_compact + @layout/sud_glif_recycler_embedded_template_compact diff --git a/main/res/values/styles.xml b/main/res/values/styles.xml index e3b3489..6fe9550 100644 --- a/main/res/values/styles.xml +++ b/main/res/values/styles.xml @@ -196,6 +196,7 @@ @style/TextAppearance.SudGlifItemSummary ?attr/sudButtonFontFamily ?attr/sudButtonCornerRadius + false ?attr/sudButtonAllCaps ?attr/colorAccent ?attr/sudButtonHighlightAlpha @@ -294,6 +295,7 @@ @style/TextAppearance.SudGlifItemSummary ?attr/sudButtonFontFamily ?attr/sudButtonCornerRadius + false ?attr/sudButtonAllCaps ?attr/colorAccent ?attr/sudButtonHighlightAlpha @@ -402,6 +404,7 @@ @dimen/sud_header_container_margin_bottom_material_you @string/sudFontSecondaryMediumMaterialYou @dimen/sud_glif_icon_margin_top_material_you + @bool/suc_footer_bar_button_align_end @dimen/sud_footer_bar_button_radius_material_you center_horizontal @dimen/sud_glif_icon_max_height_material_you @@ -433,6 +436,7 @@ @dimen/sud_glif_footer_bar_padding_start_material_you @dimen/sud_glif_footer_bar_padding_end_material_you @dimen/sud_glif_footer_bar_min_height_material_you + @bool/suc_footer_bar_button_align_end @dimen/sud_glif_margin_end_material_you @dimen/sud_header_container_margin_bottom_material_you @string/sudFontSecondaryMediumMaterialYou diff --git a/main/src/com/google/android/setupdesign/GlifLayout.java b/main/src/com/google/android/setupdesign/GlifLayout.java index 3f0d243..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; @@ -285,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); } @@ -440,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; } @@ -484,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/transition/TransitionHelper.java b/main/src/com/google/android/setupdesign/transition/TransitionHelper.java index ec2c480..773c4af 100644 --- a/main/src/com/google/android/setupdesign/transition/TransitionHelper.java +++ b/main/src/com/google/android/setupdesign/transition/TransitionHelper.java @@ -154,11 +154,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}. + * + *

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}. + * + *

The timing to apply the transition is going forward from the previous activity to this, or + * going forward from this activity to the next. * *

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 +205,46 @@ 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}. + * + *

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}. + * + *

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}, or + * argument {@code useClientTransitionSettings} is false, or System property {@code + * suw_apply_glif_theme_controlled_transition} is true. + * + *

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}, + * 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}. + * + *

The timing to apply the transition is going forward from the previous activity to this, or + * going forward from this activity to the next. * *

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)) { + // Do nothing + } 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 +293,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}. + * + *

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}. + * + *

The timing to apply the transition is going backward from the next activity to this, or + * going backward from this activity to the previous. * *

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 +345,47 @@ 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}. + * + *

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}. + * + *

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}, or argument {@code useClientTransitionSettings} is false, or + * System property {@code suw_apply_glif_theme_controlled_transition} is true. + * + *

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}, + * 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}. + * + *

The timing to apply the transition is going backward from the next activity to this, or + * going backward from this activity to the previous. * *

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)) { + // Do nothing + } 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 +428,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/Partner.java b/main/src/com/google/android/setupdesign/util/Partner.java index 2052afb..ce0c0d2 100644 --- a/main/src/com/google/android/setupdesign/util/Partner.java +++ b/main/src/com/google/android/setupdesign/util/Partner.java @@ -36,9 +36,11 @@ 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; @@ -183,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; -- cgit v1.2.3 From a6cf7e06805f78c96e3f1821e5ba69a913276ff2 Mon Sep 17 00:00:00 2001 From: Tsung-Mao Fang Date: Thu, 16 Feb 2023 14:47:00 +0000 Subject: Revert^2 "Added missing lib for setupdesign lib" 7d5f27a195c312d015d174b3db3614b5c53ae56f Test: Rebuilt rom Fix: 269530919 Change-Id: I53032310b65c2c4ed2818cda9562a8d7ab5fef03 --- Android.bp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Android.bp b/Android.bp index 35b6a3c..5f879ef 100644 --- a/Android.bp +++ b/Android.bp @@ -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", -- cgit v1.2.3 From 26bd34d1a35b6edc899645f0daba23a39450a316 Mon Sep 17 00:00:00 2001 From: Setup Wizard Team Date: Fri, 6 Oct 2023 15:15:03 +0800 Subject: Import updated Android Setupdesign Library 571249030 Copied from google3/third_party/java_src/android_libs/setupdesign Bug: 303336953 Test: mm Included changes: - 571249030 Fix external/setupdesign for use_resource_processor: true - 567212193 [Cosmic Ray] Remove StartActivity and StartActivityForRes... - 566521975 Automated g4 rollback of changelist 566362468. - 566362468 Automated g4 rollback of changelist 566242836. - 566242836 Decoupling the activity start and transition - 564894091 [Cosmic Ray] Remove Activity options for Cosmic Ray - 562965479 [DesignLibrary] Bump up the sdk to the latest version. - 561595584 [DesignLibrary] Upgrade the min sdk version to 19 due to ... PiperOrigin-RevId: 571249030 Change-Id: I61cd78999675fdcf62f807fdde0e3ac25d8654b9 --- Android.bp | 4 +- lottie_loading_layout/AndroidManifest.xml | 4 +- .../android/setupdesign/GlifLoadingLayout.java | 86 +----- .../setupdesign/util/LottieAnimationHelper.java | 3 +- .../android/setupdesign/span/BoldLinkSpan.java | 46 +++ .../android/setupdesign/template/HeaderMixin.java | 9 +- .../setupdesign/transition/TransitionHelper.java | 325 +++++---------------- .../setupdesign/util/PartnerStyleHelper.java | 12 +- .../android/setupdesign/util/ThemeHelper.java | 17 +- .../android/setupdesign/view/RichTextView.java | 13 +- strings/AndroidManifest.xml | 4 +- 11 files changed, 156 insertions(+), 367 deletions(-) create mode 100644 main/src/com/google/android/setupdesign/span/BoldLinkSpan.java diff --git a/Android.bp b/Android.bp index 3653d5f..7a42f5f 100644 --- a/Android.bp +++ b/Android.bp @@ -47,7 +47,7 @@ android_library { srcs: [ "main/src/**/*.java", ], - min_sdk_version: "14", + min_sdk_version: "19", optimize: { proguard_flags_files: ["proguard.flags"], } @@ -64,6 +64,6 @@ android_library { resource_dirs: [ "strings/res", ], - min_sdk_version: "14", + min_sdk_version: "19", sdk_version: "current" } diff --git a/lottie_loading_layout/AndroidManifest.xml b/lottie_loading_layout/AndroidManifest.xml index 3053930..1b0b77e 100644 --- a/lottie_loading_layout/AndroidManifest.xml +++ b/lottie_loading_layout/AndroidManifest.xml @@ -19,7 +19,7 @@ package="com.google.android.setupdesign.lottieloadinglayout"> + android:minSdkVersion="23" + android:targetSdkVersion="34" /> 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 00be9ea..8fe2340 100644 --- a/lottie_loading_layout/src/com/google/android/setupdesign/GlifLoadingLayout.java +++ b/lottie_loading_layout/src/com/google/android/setupdesign/GlifLoadingLayout.java @@ -23,14 +23,12 @@ import android.animation.Animator; import android.animation.Animator.AnimatorListener; 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.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; @@ -308,86 +306,6 @@ public class GlifLoadingLayout extends GlifLayout { registerAnimationFinishRunnable(activity::finish); } - /** - * Launch a new activity after the animation finished. - * - * @param activity The activity which is GlifLoadingLayout attached to. - * @param intent The intent to start. - * @param options Additional options for how the Activity should be started. See {@link - * android.content.Context#startActivity(Intent, Bundle)} for more details. - * @param finish Finish the activity after startActivity - * @see Activity#startActivity(Intent) - * @see Activity#startActivityForResult - */ - public void startActivity( - @NonNull Activity activity, - @NonNull Intent intent, - @Nullable Bundle options, - boolean finish) { - if (activity == null) { - throw new NullPointerException("activity should not be null"); - } - - if (intent == null) { - throw new NullPointerException("intent should not be null"); - } - - registerAnimationFinishRunnable( - () -> { - if (options == null || Build.VERSION.SDK_INT < VERSION_CODES.JELLY_BEAN) { - activity.startActivity(intent); - } else { - activity.startActivity(intent, options); - } - - if (finish) { - activity.finish(); - } - }); - } - - /** - * Waiting for the animation finished and launch an activity for which you would like a result - * when it finished. - * - * @param activity The activity which the GlifLoadingLayout attached to. - * @param intent The intent to start. - * @param requestCode If >= 0, this code will be returned in onActivityResult() when the activity - * exits. - * @param options Additional options for how the Activity should be started. - * @param finish Finish the activity after startActivityForResult. The onActivityResult might not - * be called because the activity already finished. - *

See {@link android.content.Context#startActivity(Intent, Bundle)} - * Context.startActivity(Intent, Bundle)} for more details. - */ - public void startActivityForResult( - @NonNull Activity activity, - @NonNull Intent intent, - int requestCode, - @Nullable Bundle options, - boolean finish) { - if (activity == null) { - throw new NullPointerException("activity should not be null"); - } - - if (intent == null) { - throw new NullPointerException("intent should not be null"); - } - - registerAnimationFinishRunnable( - () -> { - if (options == null || Build.VERSION.SDK_INT < VERSION_CODES.JELLY_BEAN) { - activity.startActivityForResult(intent, requestCode); - } else { - activity.startActivityForResult(intent, requestCode, options); - } - - if (finish) { - activity.finish(); - } - }); - } - private void updateHeaderHeight() { View headerView = findManagedViewById(R.id.sud_header_scroll_view); Configuration currentConfig = getResources().getConfiguration(); @@ -695,9 +613,7 @@ public class GlifLoadingLayout extends GlifLayout { } } return inflateTemplate( - inflater, - com.google.android.setupdesign.R.style.SudThemeGlif_Light, - template); + inflater, com.google.android.setupdesign.R.style.SudThemeGlif_Light, template); } @Override 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 index e6cdc11..5a59c40 100644 --- a/lottie_loading_layout/src/com/google/android/setupdesign/util/LottieAnimationHelper.java +++ b/lottie_loading_layout/src/com/google/android/setupdesign/util/LottieAnimationHelper.java @@ -29,7 +29,6 @@ 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; @@ -118,7 +117,7 @@ public class LottieAnimationHelper { try { customizationMap.put( new KeyPath("**", splitItem[0], "**"), - context.getResources().getColor(colorResourceId)); + context.getResources().getColor(colorResourceId, null)); } catch (Resources.NotFoundException exception) { Log.e(TAG, "Resource Not found, resource value=" + colorMapping); } diff --git a/main/src/com/google/android/setupdesign/span/BoldLinkSpan.java b/main/src/com/google/android/setupdesign/span/BoldLinkSpan.java new file mode 100644 index 0000000..9bb9cc6 --- /dev/null +++ b/main/src/com/google/android/setupdesign/span/BoldLinkSpan.java @@ -0,0 +1,46 @@ +/* + * 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. + */ +package com.google.android.setupdesign.span; + +import android.content.Context; +import android.os.Build; +import android.text.TextPaint; +import androidx.annotation.VisibleForTesting; + +/** A clickableSpan extends the {@link LinkSpan} with the configurable bold style. */ +public class BoldLinkSpan extends LinkSpan { + + /* FontStyle.FONT_WEIGHT_BOLD - FontStyle.FONT_WEIGHT_NORMAL */ + @VisibleForTesting static final int BOLD_TEXT_ADJUSTMENT = 300; + + private final Context context; + + public BoldLinkSpan(Context context, String link) { + super(link); + this.context = context; + } + + @Override + public void updateDrawState(TextPaint drawState) { + super.updateDrawState(drawState); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { + int fontWeightAdjustment = context.getResources().getConfiguration().fontWeightAdjustment; + boolean boldText = fontWeightAdjustment == BOLD_TEXT_ADJUSTMENT; + drawState.setFakeBoldText(boldText); + } + drawState.setUnderlineText(true); + } +} diff --git a/main/src/com/google/android/setupdesign/template/HeaderMixin.java b/main/src/com/google/android/setupdesign/template/HeaderMixin.java index 5085bda..3e17f70 100644 --- a/main/src/com/google/android/setupdesign/template/HeaderMixin.java +++ b/main/src/com/google/android/setupdesign/template/HeaderMixin.java @@ -77,13 +77,10 @@ public class HeaderMixin implements Mixin { layout .getContext() .obtainStyledAttributes( - attrs, - com.google.android.setupcompat.R.styleable.SucHeaderMixin, - defStyleAttr, - 0); + attrs, com.google.android.setupcompat.R.styleable.SucHeaderMixin, defStyleAttr, 0); - final CharSequence headerText = a.getText( - com.google.android.setupcompat.R.styleable.SucHeaderMixin_sucHeaderText); + final CharSequence headerText = + a.getText(com.google.android.setupcompat.R.styleable.SucHeaderMixin_sucHeaderText); final ColorStateList headerTextColor = a.getColorStateList( com.google.android.setupcompat.R.styleable.SucHeaderMixin_sucHeaderTextColor); diff --git a/main/src/com/google/android/setupdesign/transition/TransitionHelper.java b/main/src/com/google/android/setupdesign/transition/TransitionHelper.java index 5dd5f3d..25ab984 100644 --- a/main/src/com/google/android/setupdesign/transition/TransitionHelper.java +++ b/main/src/com/google/android/setupdesign/transition/TransitionHelper.java @@ -24,21 +24,18 @@ import android.content.ActivityNotFoundException; import android.content.Context; import android.content.Intent; import android.content.res.TypedArray; -import android.os.Build; import android.os.Build.VERSION_CODES; import android.os.Bundle; -import android.os.Parcelable; import android.util.Log; -import android.view.Window; import androidx.annotation.IntDef; import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; -import com.google.android.material.transition.platform.MaterialSharedAxis; import com.google.android.setupcompat.partnerconfig.PartnerConfig; import com.google.android.setupcompat.partnerconfig.PartnerConfigHelper; import com.google.android.setupcompat.util.BuildCompatUtils; import com.google.android.setupdesign.R; import com.google.android.setupdesign.util.ThemeHelper; +import com.google.errorprone.annotations.InlineMe; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -142,8 +139,11 @@ public class TransitionHelper { /** * Passed in an intent as EXTRA_ACTIVITY_OPTIONS. This is the {@link ActivityOptions} of the * transition used in {@link Activity#startActivity} or {@link Activity#startActivityForResult}. + * + * @deprecated Deprecated to use CONFIG_TRANSITION_SHARED_X_AXIS transition, so it never have + * activity options input. */ - public static final String EXTRA_ACTIVITY_OPTIONS = "sud:activity_options"; + @Deprecated public static final String EXTRA_ACTIVITY_OPTIONS = "sud:activity_options"; /** A flag to avoid the {@link Activity#finish} been called more than once. */ @VisibleForTesting static boolean isFinishCalled = false; @@ -183,28 +183,14 @@ public class TransitionHelper { * The default transition that will be applied is {@link #CONFIG_TRANSITION_NONE}. The timing to * apply the transition is going forward from the previous {@link Fragment} to this, or going * forward from this {@link Fragment} to the next. + * + * @deprecated Deprecated to use CONFIG_TRANSITION_SHARED_X_AXIS transition, so it never have + * activity options input, should start the activity directly. */ @TargetApi(VERSION_CODES.M) + @Deprecated public static void applyForwardTransition(Fragment fragment) { - if (Build.VERSION.SDK_INT >= VERSION_CODES.M) { - if (getConfigTransitionType(fragment.getContext()) == CONFIG_TRANSITION_SHARED_X_AXIS) { - MaterialSharedAxis exitTransition = - new MaterialSharedAxis(MaterialSharedAxis.X, /* forward= */ true); - fragment.setExitTransition(exitTransition); - - MaterialSharedAxis enterTransition = - new MaterialSharedAxis(MaterialSharedAxis.X, /* forward= */ true); - fragment.setEnterTransition(enterTransition); - } else { - Log.w(TAG, "Not apply the forward transition for platform fragment."); - } - } else { - Log.w( - TAG, - "Not apply the forward transition for platform fragment. The API is supported from" - + " Android Sdk " - + VERSION_CODES.M); - } + // Do nothing } /** @@ -254,11 +240,11 @@ public class TransitionHelper { && 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; - } + int openEnterTransition = + ThemeHelper.shouldApplyDynamicColor(activity) + ? R.anim.shared_x_axis_activity_open_enter_dynamic_color + : R.anim.shared_x_axis_activity_open_enter; activity.overridePendingTransition( openEnterTransition, R.anim.shared_x_axis_activity_open_exit); } else { @@ -285,29 +271,6 @@ public class TransitionHelper { } else if (transitionId == TRANSITION_NONE) { // For TRANSITION_NONE, turn off the transition activity.overridePendingTransition(/* enterAnim= */ 0, /* exitAnim= */ 0); - } else if (transitionId == TRANSITION_CAPTIVE) { - if (Build.VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) { - // 1. Do not change the transition behavior by default - // 2. If the flag present, apply the transition from transition type - if (getConfigTransitionType(activity) == CONFIG_TRANSITION_SHARED_X_AXIS) { - Window window = activity.getWindow(); - if (window != null) { - MaterialSharedAxis exitTransition = - new MaterialSharedAxis(MaterialSharedAxis.X, /* forward= */ true); - window.setExitTransition(exitTransition); - - window.setAllowEnterTransitionOverlap(true); - - MaterialSharedAxis enterTransition = - new MaterialSharedAxis(MaterialSharedAxis.X, /* forward= */ true); - window.setEnterTransition(enterTransition); - } else { - Log.w(TAG, "applyForwardTransition: Invalid window=" + window); - } - } - } 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 } @@ -340,28 +303,14 @@ public class TransitionHelper { * The default transition that will be applied is {@link #CONFIG_TRANSITION_NONE}. The timing to * apply the transition is going backward from the next {@link Fragment} to this, or going * backward from this {@link Fragment} to the previous. + * + * @deprecated Deprecated to use CONFIG_TRANSITION_SHARED_X_AXIS transition, so it never have + * activity options input, should start the activity directly. */ @TargetApi(VERSION_CODES.M) + @Deprecated public static void applyBackwardTransition(Fragment fragment) { - if (Build.VERSION.SDK_INT >= VERSION_CODES.M) { - if (getConfigTransitionType(fragment.getContext()) == CONFIG_TRANSITION_SHARED_X_AXIS) { - MaterialSharedAxis returnTransition = - new MaterialSharedAxis(MaterialSharedAxis.X, /* forward= */ false); - fragment.setReturnTransition(returnTransition); - - MaterialSharedAxis reenterTransition = - new MaterialSharedAxis(MaterialSharedAxis.X, /* forward= */ false); - fragment.setReenterTransition(reenterTransition); - } else { - Log.w(TAG, "Not apply the backward transition for platform fragment."); - } - } else { - Log.w( - TAG, - "Not apply the backward transition for platform fragment. The API is supported from" - + " Android Sdk " - + VERSION_CODES.M); - } + // Do nothing } /** @@ -413,10 +362,10 @@ public class TransitionHelper { // 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; - } + int closeEnterTransition = + ThemeHelper.shouldApplyDynamicColor(activity) + ? R.anim.shared_x_axis_activity_close_enter_dynamic_color + : R.anim.shared_x_axis_activity_close_enter; activity.overridePendingTransition( closeEnterTransition, R.anim.shared_x_axis_activity_close_exit); } else { @@ -444,28 +393,6 @@ public class TransitionHelper { } else if (transitionId == TRANSITION_NONE) { // For TRANSITION_NONE, turn off the transition activity.overridePendingTransition(/* enterAnim= */ 0, /* exitAnim= */ 0); - } else if (transitionId == TRANSITION_CAPTIVE) { - if (Build.VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) { - // 1. Do not change the transition behavior by default - // 2. If the flag present, apply the transition from transition type - if (getConfigTransitionType(activity) == CONFIG_TRANSITION_SHARED_X_AXIS) { - Window window = activity.getWindow(); - if (window != null) { - MaterialSharedAxis reenterTransition = - new MaterialSharedAxis(MaterialSharedAxis.X, /* forward= */ false); - window.setReenterTransition(reenterTransition); - - MaterialSharedAxis returnTransition = - new MaterialSharedAxis(MaterialSharedAxis.X, /* forward= */ false); - window.setReturnTransition(returnTransition); - } else { - Log.w(TAG, "applyBackwardTransition: Invalid window=" + window); - } - } - } 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 } } @@ -476,9 +403,13 @@ public class TransitionHelper { * @throws IllegalArgumentException is thrown when {@code activity} or {@code intent} is null. * @throws android.content.ActivityNotFoundException if there was no {@link Activity} found to run * the given Intent. + * @deprecated Deprecated to use CONFIG_TRANSITION_SHARED_X_AXIS transition, so it never have + * activity options input, should start the activity directly. */ + @InlineMe(replacement = "activity.startActivity(intent)") + @Deprecated public static void startActivityWithTransition(Activity activity, Intent intent) { - startActivityWithTransition(activity, intent, /* overrideActivityOptions= */ null); + activity.startActivity(intent); } /** @@ -488,7 +419,10 @@ public class TransitionHelper { * @throws IllegalArgumentException is thrown when {@code activity} or {@code intent} is null. * @throws android.content.ActivityNotFoundException if there was no {@link Activity} found to run * the given Intent. + * @deprecated Deprecated to use CONFIG_TRANSITION_SHARED_X_AXIS transition, so it never have + * activity options input, should start the activity directly. */ + @Deprecated public static void startActivityWithTransition( Activity activity, Intent intent, Bundle overrideActivityOptions) { if (activity == null) { @@ -508,67 +442,26 @@ public class TransitionHelper { if (!isStartActivity) { isStartActivity = true; - if (getConfigTransitionType(activity) == CONFIG_TRANSITION_SHARED_X_AXIS) { - if (Build.VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) { - if (activity.getWindow() != null - && !activity.getWindow().hasFeature(Window.FEATURE_ACTIVITY_TRANSITIONS)) { - Log.w( - TAG, - "The transition won't take effect due to NO FEATURE_ACTIVITY_TRANSITIONS feature"); - } - - Bundle bundleActivityOptions; - if (overrideActivityOptions != null) { - bundleActivityOptions = overrideActivityOptions; - } else { - bundleActivityOptions = makeActivityOptions(activity, intent); - } - intent.putExtra(EXTRA_ACTIVITY_OPTIONS, (Parcelable) bundleActivityOptions); - activity.startActivity(intent, bundleActivityOptions); - } else { - Log.w( - TAG, - "Fallback to using startActivity due to the" - + " ActivityOptions#makeSceneTransitionAnimation is supported from Android Sdk " - + VERSION_CODES.LOLLIPOP); - startActivityWithTransitionInternal(activity, intent, overrideActivityOptions); - } - } else { - startActivityWithTransitionInternal(activity, intent, overrideActivityOptions); - } + activity.startActivity(intent); } isStartActivity = false; } - private static void startActivityWithTransitionInternal( - Activity activity, Intent intent, Bundle overrideActivityOptions) { - try { - if (Build.VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) { - if (getConfigTransitionType(activity) == CONFIG_TRANSITION_SHARED_X_AXIS - && overrideActivityOptions != null) { - activity.startActivity(intent, overrideActivityOptions); - } else { - activity.startActivity(intent); - } - } else { - Log.w( - TAG, - "Fallback to using startActivity(Intent) due to the startActivity(Intent, Bundle) is" - + " supported from Android Sdk " - + VERSION_CODES.JELLY_BEAN); - activity.startActivity(intent); - } - } catch (ActivityNotFoundException e) { - Log.w(TAG, "Activity not found when startActivity with transition."); - isStartActivity = false; - throw e; - } - } - + /** + * A wrapper method, create an {@link android.app.ActivityOptions} to transition between + * activities as the {@code activityOptions} parameter of {@link Activity#startActivityForResult}. + * + * @throws IllegalArgumentException is thrown when {@code activity} or {@code intent} is null. + * @throws android.content.ActivityNotFoundException if there was no {@link Activity} found to run + * the given Intent. + * @deprecated Deprecated to use CONFIG_TRANSITION_SHARED_X_AXIS transition, so it never have + * activity options input, should start the activity directly. + */ + @InlineMe(replacement = "activity.startActivityForResult(intent, requestCode)") + @Deprecated public static void startActivityForResultWithTransition( Activity activity, Intent intent, int requestCode) { - startActivityForResultWithTransition( - activity, intent, requestCode, /* overrideActivityOptions= */ null); + activity.startActivityForResult(intent, requestCode); } /** @@ -578,7 +471,10 @@ public class TransitionHelper { * @throws IllegalArgumentException is thrown when {@code activity} or {@code intent} is null. * @throws android.content.ActivityNotFoundException if there was no {@link Activity} found to run * the given Intent. + * @deprecated Deprecated to use CONFIG_TRANSITION_SHARED_X_AXIS transition, so it never have + * activity options input, should start the activity directly. */ + @Deprecated public static void startActivityForResultWithTransition( Activity activity, Intent intent, int requestCode, Bundle overrideActivityOptions) { if (activity == null) { @@ -597,63 +493,16 @@ public class TransitionHelper { } if (!isStartActivityForResult) { - isStartActivityForResult = true; - if (getConfigTransitionType(activity) == CONFIG_TRANSITION_SHARED_X_AXIS) { - if (Build.VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) { - if (activity.getWindow() != null - && !activity.getWindow().hasFeature(Window.FEATURE_ACTIVITY_TRANSITIONS)) { - Log.w( - TAG, - "The transition won't take effect due to NO FEATURE_ACTIVITY_TRANSITIONS feature"); - } - - Bundle bundleActivityOptions; - if (overrideActivityOptions != null) { - bundleActivityOptions = overrideActivityOptions; - } else { - bundleActivityOptions = makeActivityOptions(activity, intent); - } - intent.putExtra(EXTRA_ACTIVITY_OPTIONS, (Parcelable) bundleActivityOptions); - activity.startActivityForResult(intent, requestCode, bundleActivityOptions); - } else { - Log.w( - TAG, - "Fallback to using startActivityForResult API due to the" - + " ActivityOptions#makeSceneTransitionAnimation is supported from Android Sdk " - + VERSION_CODES.LOLLIPOP); - startActivityForResultWithTransitionInternal( - activity, intent, requestCode, overrideActivityOptions); - } - } else { - startActivityForResultWithTransitionInternal( - activity, intent, requestCode, overrideActivityOptions); - } - isStartActivityForResult = false; - } - } - - private static void startActivityForResultWithTransitionInternal( - Activity activity, Intent intent, int requestCode, Bundle overrideActivityOptions) { - try { - if (Build.VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) { - if (getConfigTransitionType(activity) == CONFIG_TRANSITION_SHARED_X_AXIS - && overrideActivityOptions != null) { - activity.startActivityForResult(intent, requestCode, overrideActivityOptions); - } else { - activity.startActivityForResult(intent, requestCode); - } - } else { - Log.w( - TAG, - "Fallback to using startActivityForResult(Intent) due to the" - + " startActivityForResult(Intent,int) is supported from Android Sdk " - + VERSION_CODES.JELLY_BEAN); + try { + isStartActivityForResult = true; activity.startActivityForResult(intent, requestCode); + } catch (ActivityNotFoundException e) { + Log.w(TAG, "Activity not found when startActivityForResult with transition."); + throw e; + } finally { + // Allow to start next activity. + isStartActivityForResult = false; } - } catch (ActivityNotFoundException e) { - Log.w(TAG, "Activity not found when startActivityForResult with transition."); - isStartActivityForResult = false; - throw e; } } @@ -671,17 +520,12 @@ public class TransitionHelper { // Avoids finish been called more than once. if (!isFinishCalled) { isFinishCalled = true; - if (Build.VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP - && getConfigTransitionType(activity) == CONFIG_TRANSITION_SHARED_X_AXIS) { - activity.finishAfterTransition(); - } else { - Log.w( - TAG, - "Fallback to using Activity#finish() due to the" - + " Activity#finishAfterTransition() is supported from Android Sdk " - + VERSION_CODES.LOLLIPOP); - activity.finish(); - } + Log.w( + TAG, + "Fallback to using Activity#finish() due to the" + + " Activity#finishAfterTransition() is supported from Android Sdk " + + VERSION_CODES.LOLLIPOP); + activity.finish(); } isFinishCalled = false; } @@ -716,10 +560,15 @@ public class TransitionHelper { * Intent intent2 = new Intent("com.example.NEXT_ACTIVITY"); * activity.startActivity(intent, TransitionHelper.makeActivityOptions(activity, intent2, null); * } + * + * @deprecated Deprecated to use CONFIG_TRANSITION_SHARED_X_AXIS transition, so it never have + * activity options input, should start the activity directly. */ + @InlineMe(replacement = "null") @Nullable + @Deprecated public static Bundle makeActivityOptions(Activity activity, Intent intent) { - return makeActivityOptions(activity, intent, false); + return null; } /** @@ -742,41 +591,15 @@ public class TransitionHelper { * Intent intent = new Intent("com.example.NEXT_ACTIVITY"); * activity.startActivity(intent, TransitionHelper.makeActivityOptions(activity, intent, true); * } + * + * @deprecated Deprecated to use CONFIG_TRANSITION_SHARED_X_AXIS transition, so it never have + * activity options input, should start the activity directly. */ + @InlineMe(replacement = "null") @Nullable + @Deprecated public static Bundle makeActivityOptions( Activity activity, Intent intent, boolean overrideActivityOptionsFromIntent) { - Bundle resultBundle = null; - if (activity == null || intent == null) { - return resultBundle; - } - - if ((intent.getFlags() & Intent.FLAG_ACTIVITY_NEW_TASK) == Intent.FLAG_ACTIVITY_NEW_TASK) { - Log.e( - TAG, - "The transition won't take effect since the WindowManager does not allow override new" - + " task transitions"); - } - - if (getConfigTransitionType(activity) == CONFIG_TRANSITION_SHARED_X_AXIS) { - if (Build.VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) { - if (activity.getWindow() != null - && !activity.getWindow().hasFeature(Window.FEATURE_ACTIVITY_TRANSITIONS)) { - Log.w( - TAG, - "The transition won't take effect due to NO FEATURE_ACTIVITY_TRANSITIONS feature"); - } - - if (overrideActivityOptionsFromIntent && activity.getIntent() != null) { - resultBundle = activity.getIntent().getBundleExtra(EXTRA_ACTIVITY_OPTIONS); - } else { - resultBundle = ActivityOptions.makeSceneTransitionAnimation(activity).toBundle(); - } - intent.putExtra(EXTRA_ACTIVITY_OPTIONS, (Parcelable) resultBundle); - return resultBundle; - } - } - - return resultBundle; + return null; } } diff --git a/main/src/com/google/android/setupdesign/util/PartnerStyleHelper.java b/main/src/com/google/android/setupdesign/util/PartnerStyleHelper.java index 2029ddc..fb4466a 100644 --- a/main/src/com/google/android/setupdesign/util/PartnerStyleHelper.java +++ b/main/src/com/google/android/setupdesign/util/PartnerStyleHelper.java @@ -113,9 +113,9 @@ public final class PartnerStyleHelper { if (activity != null) { isSetupFlow = WizardManagerHelper.isAnySetupWizard(activity.getIntent()); } - TypedArray a = context.obtainStyledAttributes(new int[] { - com.google.android.setupcompat.R.attr.sucUsePartnerResource - }); + TypedArray a = + context.obtainStyledAttributes( + new int[] {com.google.android.setupcompat.R.attr.sucUsePartnerResource}); boolean usePartnerResource = a.getBoolean(0, true); a.recycle(); @@ -182,9 +182,9 @@ public final class PartnerStyleHelper { } // try best to get dynamic color settings from attr - TypedArray a = context.obtainStyledAttributes(new int[] { - com.google.android.setupcompat.R.attr.sucFullDynamicColor - }); + TypedArray a = + context.obtainStyledAttributes( + new int[] {com.google.android.setupcompat.R.attr.sucFullDynamicColor}); boolean useDynamicColorTheme = a.hasValue( com.google diff --git a/main/src/com/google/android/setupdesign/util/ThemeHelper.java b/main/src/com/google/android/setupdesign/util/ThemeHelper.java index 4c349e4..cdc6f37 100644 --- a/main/src/com/google/android/setupdesign/util/ThemeHelper.java +++ b/main/src/com/google/android/setupdesign/util/ThemeHelper.java @@ -201,13 +201,10 @@ public final class ThemeHelper { boolean isSetupFlow = WizardManagerHelper.isAnySetupWizard(activity.getIntent()); boolean isDayNightEnabled = isSetupWizardDayNightEnabled(context); - if (isSetupFlow && !BuildCompatUtils.isAtLeastU()) { - // return theme for inside setup flow - resId = - isDayNightEnabled - ? R.style.SudDynamicColorTheme_DayNight - : R.style.SudDynamicColorTheme_Light; - } else { + boolean isSUWFullDynamicColorEnabled = + PartnerConfigHelper.isSetupWizardFullDynamicColorEnabled(context); + + if (!isSetupFlow || (BuildCompatUtils.isAtLeastU() && isSUWFullDynamicColorEnabled)) { // return theme for outside setup flow resId = isDayNightEnabled @@ -218,6 +215,12 @@ public final class ThemeHelper { + (isDayNightEnabled ? "SudFullDynamicColorTheme_DayNight" : "SudFullDynamicColorTheme_Light")); + } else { + // return theme for inside setup flow + resId = + isDayNightEnabled + ? R.style.SudDynamicColorTheme_DayNight + : R.style.SudDynamicColorTheme_Light; } LOG.atDebug( diff --git a/main/src/com/google/android/setupdesign/view/RichTextView.java b/main/src/com/google/android/setupdesign/view/RichTextView.java index 182981f..bbca7b1 100644 --- a/main/src/com/google/android/setupdesign/view/RichTextView.java +++ b/main/src/com/google/android/setupdesign/view/RichTextView.java @@ -16,7 +16,6 @@ package com.google.android.setupdesign.view; -import android.annotation.SuppressLint; import android.annotation.TargetApi; import android.content.Context; import android.graphics.Typeface; @@ -36,7 +35,9 @@ import android.util.Log; import android.view.MotionEvent; import androidx.annotation.VisibleForTesting; import androidx.core.view.ViewCompat; +import com.google.android.setupcompat.util.BuildCompatUtils; import com.google.android.setupdesign.accessibility.LinkAccessibilityHelper; +import com.google.android.setupdesign.span.BoldLinkSpan; import com.google.android.setupdesign.span.LinkSpan; import com.google.android.setupdesign.span.LinkSpan.OnLinkClickListener; import com.google.android.setupdesign.span.SpanHelper; @@ -63,13 +64,12 @@ public class RichTextView extends AppCompatTextView implements OnLinkClickListen * *

    *
  1. <annotation link="foobar"> will create a {@link - * com.google.android.setupdesign.span.LinkSpan} that broadcasts with the key "foobar" + * com.google.android.setupdesign.span.BoldLinkSpan} that broadcasts with the key "foobar" *
  2. <annotation textAppearance="TextAppearance.FooBar"> will create a {@link * android.text.style.TextAppearanceSpan} with @style/TextAppearance.FooBar *
*/ @TargetApi(28) - @SuppressLint("NewApi") public static CharSequence getRichText(Context context, CharSequence text) { if (text instanceof Spanned) { final SpannableString spannable = new SpannableString(text); @@ -88,7 +88,12 @@ public class RichTextView extends AppCompatTextView implements OnLinkClickListen final TextAppearanceSpan textAppearanceSpan = new TextAppearanceSpan(context, style); SpanHelper.replaceSpan(spannable, span, textAppearanceSpan); } else if (ANNOTATION_LINK.equals(key)) { - LinkSpan link = new LinkSpan(span.getValue()); + LinkSpan link; + if (BuildCompatUtils.isAtLeastU()) { + link = new BoldLinkSpan(context, span.getValue()); + } else { + link = new LinkSpan(span.getValue()); + } TypefaceSpan typefaceSpan = (spanTypeface != null) ? new TypefaceSpan(spanTypeface) diff --git a/strings/AndroidManifest.xml b/strings/AndroidManifest.xml index 7461fc6..3bf97d8 100644 --- a/strings/AndroidManifest.xml +++ b/strings/AndroidManifest.xml @@ -19,7 +19,7 @@ package="com.google.android.setupdesign.strings"> + android:minSdkVersion="19" + android:targetSdkVersion="34" /> -- cgit v1.2.3 From aae1b458dbb46927153202ff4a325c00ae95d9eb Mon Sep 17 00:00:00 2001 From: Setup Wizard Team Date: Wed, 1 Nov 2023 06:38:21 +0000 Subject: Import updated Android Setupdesign Library 578413139 Copied from google3/third_party/java_src/android_libs/setupdesign Bug:278492246 Test: mm Included changes: - 578413139 [SetupLibrary] Make if there have partnerConfig override ... - 577767834 Change min sdk to 23 for lottie loading layout - 572013340 Update Android Lint to http://ab/10672018 (version ID 31.... PiperOrigin-RevId: 578413139 Change-Id: Ia6e568f145c63fc5d50cc4eb87a701192122f95d --- exempting_lint_checks.txt | 27 ++++++++++++++++++++++ .../setupdesign/view/FillContentLayout.java | 14 +++++++++-- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/exempting_lint_checks.txt b/exempting_lint_checks.txt index 949488a..fb01c62 100644 --- a/exempting_lint_checks.txt +++ b/exempting_lint_checks.txt @@ -89,3 +89,30 @@ third_party/java_src/android_libs/setupdesign/main/src/com/google/android/setupd third_party/java_src/android_libs/setupdesign/main/src/com/google/android/setupdesign/view/RichTextView.java: NewApi: text = getRichText(getContext(), text); third_party/java_src/android_libs/setupdesign/main/src/com/google/android/setupdesign/view/StickyHeaderListView.java: CustomViewStyleable: .obtainStyledAttributes(attrs, R.styleable.SudStickyHeaderListView, defStyleAttr, 0); third_party/java_src/android_libs/setupdesign/main/src/com/google/android/setupdesign/view/StickyHeaderScrollView.java: ObsoleteSdkInt: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { +third_party/java_src/android_libs/setupdesign/AndroidManifest.xml: ExpiredTargetSdkVersion: +third_party/java_src/android_libs/setupdesign/main/src/com/google/android/setupdesign/GlifLayout.java: CustomViewStyleable: getContext().obtainStyledAttributes(attrs, R.styleable.SudGlifLayout, defStyleAttr, 0); +third_party/java_src/android_libs/setupdesign/main/src/com/google/android/setupdesign/GlifLayout.java: NewApi: LayoutStyler.applyPartnerCustomizationExtraPaddingStyle(view); +third_party/java_src/android_libs/setupdesign/main/src/com/google/android/setupdesign/GlifLayout.java: NewApi: tryApplyPartnerCustomizationContentPaddingTopStyle(view); +third_party/java_src/android_libs/setupdesign/main/src/com/google/android/setupdesign/GlifListLayout.java: NewApi: tryApplyPartnerCustomizationContentPaddingTopStyle(view); +third_party/java_src/android_libs/setupdesign/main/src/com/google/android/setupdesign/GlifRecyclerLayout.java: NewApi: tryApplyPartnerCustomizationContentPaddingTopStyle(view); +third_party/java_src/android_libs/setupdesign/main/src/com/google/android/setupdesign/SetupWizardLayout.java: CustomViewStyleable: .obtainStyledAttributes(attrs, R.styleable.SudSetupWizardLayout, defStyleAttr, 0); +third_party/java_src/android_libs/setupdesign/main/src/com/google/android/setupdesign/items/ExpandableSwitchItem.java: NewApi: LayoutStyler.applyPartnerCustomizationLayoutPaddingStyle(content); +third_party/java_src/android_libs/setupdesign/main/src/com/google/android/setupdesign/items/Item.java: NewApi: ItemStyler.applyPartnerCustomizationItemStyle(view); +third_party/java_src/android_libs/setupdesign/main/src/com/google/android/setupdesign/items/Item.java: NewApi: LayoutStyler.applyPartnerCustomizationLayoutPaddingStyle(view); +third_party/java_src/android_libs/setupdesign/main/src/com/google/android/setupdesign/items/RecyclerItemAdapter.java: NotifyDataSetChanged: notifyDataSetChanged(); +third_party/java_src/android_libs/setupdesign/main/src/com/google/android/setupdesign/template/HeaderMixin.java: NewApi: LayoutStyler.applyPartnerCustomizationExtraPaddingStyle(headerAreaView); +third_party/java_src/android_libs/setupdesign/main/src/com/google/android/setupdesign/util/Partner.java: DiscouragedApi: return resources.getIdentifier(name, defType, packageName); +third_party/java_src/android_libs/setupdesign/main/src/com/google/android/setupdesign/util/TextViewPartnerStyler.java: NewApi: ((RichTextView) textView).setSpanTypeface(linkFont); +third_party/java_src/android_libs/setupdesign/main/src/com/google/android/setupdesign/view/FillContentLayout.java: CustomViewStyleable: context.obtainStyledAttributes(attrs, R.styleable.SudFillContentLayout, defStyleAttr, 0); +third_party/java_src/android_libs/setupdesign/main/src/com/google/android/setupdesign/view/HeaderRecyclerView.java: CustomViewStyleable: .obtainStyledAttributes(attrs, R.styleable.SudHeaderRecyclerView, defStyleAttr, 0); +third_party/java_src/android_libs/setupdesign/main/src/com/google/android/setupdesign/view/HeaderRecyclerView.java: NotifyDataSetChanged: notifyDataSetChanged(); +third_party/java_src/android_libs/setupdesign/main/src/com/google/android/setupdesign/view/IconUniformityAppImageView.java: AnnotateVersionCheck: private static final boolean ON_L_PLUS = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP; +third_party/java_src/android_libs/setupdesign/main/src/com/google/android/setupdesign/view/Illustration.java: CustomViewStyleable: getContext().obtainStyledAttributes(attrs, R.styleable.SudIllustration, defStyleAttr, 0); +third_party/java_src/android_libs/setupdesign/main/src/com/google/android/setupdesign/view/IllustrationVideoView.java: CustomViewStyleable: context.obtainStyledAttributes(attrs, R.styleable.SudIllustrationVideoView); +third_party/java_src/android_libs/setupdesign/main/src/com/google/android/setupdesign/view/IntrinsicSizeFrameLayout.java: CustomViewStyleable: attrs, R.styleable.SudIntrinsicSizeFrameLayout, defStyleAttr, 0); +third_party/java_src/android_libs/setupdesign/main/src/com/google/android/setupdesign/view/NavigationBar.java: ResourceType: @StyleableRes int colorBackground = 2; +third_party/java_src/android_libs/setupdesign/main/src/com/google/android/setupdesign/view/NavigationBar.java: ResourceType: @StyleableRes int colorForeground = 1; +third_party/java_src/android_libs/setupdesign/main/src/com/google/android/setupdesign/view/RichTextView.java: DiscouragedApi: .getIdentifier(textAppearance, "style", context.getPackageName()); +third_party/java_src/android_libs/setupdesign/main/src/com/google/android/setupdesign/view/RichTextView.java: NewApi: text = getRichText(getContext(), text); +third_party/java_src/android_libs/setupdesign/main/src/com/google/android/setupdesign/view/StickyHeaderListView.java: CustomViewStyleable: .obtainStyledAttributes(attrs, R.styleable.SudStickyHeaderListView, defStyleAttr, 0); +third_party/java_src/android_libs/setupdesign/main/src/com/google/android/setupdesign/view/StickyHeaderScrollView.java: ObsoleteSdkInt: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { diff --git a/main/src/com/google/android/setupdesign/view/FillContentLayout.java b/main/src/com/google/android/setupdesign/view/FillContentLayout.java index af49fbb..bdb3ed8 100644 --- a/main/src/com/google/android/setupdesign/view/FillContentLayout.java +++ b/main/src/com/google/android/setupdesign/view/FillContentLayout.java @@ -21,6 +21,8 @@ import android.content.res.TypedArray; import android.util.AttributeSet; import android.view.View; import android.widget.FrameLayout; +import com.google.android.setupcompat.partnerconfig.PartnerConfig; +import com.google.android.setupcompat.partnerconfig.PartnerConfigHelper; import com.google.android.setupdesign.R; /** @@ -66,7 +68,16 @@ public class FillContentLayout extends FrameLayout { context.obtainStyledAttributes(attrs, R.styleable.SudFillContentLayout, defStyleAttr, 0); maxHeight = a.getDimensionPixelSize(R.styleable.SudFillContentLayout_android_maxHeight, -1); - maxWidth = a.getDimensionPixelSize(R.styleable.SudFillContentLayout_android_maxWidth, -1); + + if (PartnerConfigHelper.get(context) + .isPartnerConfigAvailable(PartnerConfig.CONFIG_ILLUSTRATION_MAX_WIDTH)) { + maxWidth = + (int) + PartnerConfigHelper.get(context) + .getDimension(context, PartnerConfig.CONFIG_ILLUSTRATION_MAX_WIDTH); + } else { + maxWidth = a.getDimensionPixelSize(R.styleable.SudFillContentLayout_android_maxWidth, -1); + } a.recycle(); } @@ -91,7 +102,6 @@ public class FillContentLayout extends FrameLayout { final MarginLayoutParams lp = (MarginLayoutParams) child.getLayoutParams(); // Create measure specs that are no bigger than min(parentSize, maxSize) - int childWidthMeasureSpec = getMaxSizeMeasureSpec( Math.min(maxWidth, parentWidth), -- cgit v1.2.3 From bf9ae68c7fbe68a78bb6d9c58b058e99102931d6 Mon Sep 17 00:00:00 2001 From: Anvesh Renikindi Date: Tue, 14 Nov 2023 19:09:00 +0000 Subject: update setup design to min sdk 19 Change-Id: Id5e413b2d1577bd0a59d56d11927091621cd8b48 --- Android.bp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Android.bp b/Android.bp index 3653d5f..7a42f5f 100644 --- a/Android.bp +++ b/Android.bp @@ -47,7 +47,7 @@ android_library { srcs: [ "main/src/**/*.java", ], - min_sdk_version: "14", + min_sdk_version: "19", optimize: { proguard_flags_files: ["proguard.flags"], } @@ -64,6 +64,6 @@ android_library { resource_dirs: [ "strings/res", ], - min_sdk_version: "14", + min_sdk_version: "19", sdk_version: "current" } -- cgit v1.2.3 From f011d28256c1a29a17d0276b5bd0a636b564ed24 Mon Sep 17 00:00:00 2001 From: Anvesh Renikindi Date: Thu, 16 Nov 2023 05:51:49 +0000 Subject: update lottie_loading_layout to minsdk19 Change-Id: Iabd997ede6c6d9fa1d02dc304c4fa5ac794b0dc0 Merged-In: I61cd78999675fdcf62f807fdde0e3ac25d8654b9 Bug: 307291543 --- lottie_loading_layout/Android.bp | 2 +- lottie_loading_layout/AndroidManifest.xml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lottie_loading_layout/Android.bp b/lottie_loading_layout/Android.bp index 6d41812..24f2e7e 100644 --- a/lottie_loading_layout/Android.bp +++ b/lottie_loading_layout/Android.bp @@ -26,6 +26,6 @@ android_library { resource_dirs: [ "res", ], - min_sdk_version: "16", + min_sdk_version: "19", sdk_version: "current" } diff --git a/lottie_loading_layout/AndroidManifest.xml b/lottie_loading_layout/AndroidManifest.xml index 3053930..1b0b77e 100644 --- a/lottie_loading_layout/AndroidManifest.xml +++ b/lottie_loading_layout/AndroidManifest.xml @@ -19,7 +19,7 @@ package="com.google.android.setupdesign.lottieloadinglayout"> + android:minSdkVersion="23" + android:targetSdkVersion="34" /> -- cgit v1.2.3