summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--exempting_lint_checks.txt27
-rw-r--r--lottie_loading_layout/Android.bp2
-rw-r--r--lottie_loading_layout/src/com/google/android/setupdesign/GlifLoadingLayout.java86
-rw-r--r--lottie_loading_layout/src/com/google/android/setupdesign/util/LottieAnimationHelper.java3
-rw-r--r--main/src/com/google/android/setupdesign/span/BoldLinkSpan.java46
-rw-r--r--main/src/com/google/android/setupdesign/template/HeaderMixin.java9
-rw-r--r--main/src/com/google/android/setupdesign/transition/TransitionHelper.java325
-rw-r--r--main/src/com/google/android/setupdesign/util/PartnerStyleHelper.java12
-rw-r--r--main/src/com/google/android/setupdesign/util/ThemeHelper.java17
-rw-r--r--main/src/com/google/android/setupdesign/view/FillContentLayout.java14
-rw-r--r--main/src/com/google/android/setupdesign/view/RichTextView.java13
-rw-r--r--strings/AndroidManifest.xml4
12 files changed, 192 insertions, 366 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: <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="30" />
+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/lottie_loading_layout/Android.bp b/lottie_loading_layout/Android.bp
index 24f2e7e..6d41812 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: "19",
+ min_sdk_version: "16",
sdk_version: "current"
}
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.
- * <p>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);
* }</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>&lt;annotation link="foobar"&gt; 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>&lt;annotation textAppearance="TextAppearance.FooBar"&gt; 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)
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">
<uses-sdk
- android:minSdkVersion="14"
- android:targetSdkVersion="32" />
+ android:minSdkVersion="19"
+ android:targetSdkVersion="34" />
</manifest>