diff options
Diffstat (limited to 'main/src/com')
7 files changed, 160 insertions, 276 deletions
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); * }</pre> + * + * @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); * }</pre> + * + * @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/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), 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 * * <ol> * <li><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" * <li><annotation textAppearance="TextAppearance.FooBar"> will create a {@link * android.text.style.TextAppearanceSpan} with @style/TextAppearance.FooBar * </ol> */ @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) |