diff options
author | Setup Wizard Team <android-setup-team-eng@google.com> | 2021-01-27 15:58:17 +0800 |
---|---|---|
committer | Nicole Huang <nicolehuang@google.com> | 2021-01-27 11:15:03 +0000 |
commit | 13e0225dad0a25f6865f0fab308309c3749ac957 (patch) | |
tree | d9911d5a1c63c16637fef29dc88eb5406cfefbbf /main/src | |
parent | 1566b59c3c4a54877291db2319f3a727b92c881f (diff) | |
download | setupdesign-13e0225dad0a25f6865f0fab308309c3749ac957.tar.gz |
Import updated Android Setupdesign Library 354034477
Copied from google3/third_party/java_src/android_libs/setupdesign
Test: mm
Included changes:
- 354034477 Rename ContentStyler#applyPartnerCustomizationStyle to ap...
- 353821411 Fix the javadoc of @link
- 353804268 [SetupDesign] clean up - use "values-land-v31" folder for...
- 353709689 Update Android Lint to http://ab/7077792
- 353350644 Don't show the toast warning users to use a vector drawab...
- 353027853 [BC][Tranisition] Support transfer ActivityOptions from B...
- 352699802 [SetupDesign] Update the scroll indicator style
- 352689119 Remove unused attributes in SetupDesign library
- 352515869 [SetDesign] Support landscape mode for glif blank template
Bug:176785490
PiperOrigin-RevId: 354034477
Change-Id: If8feb1fa11cef5f2998d01c04f99953208e65a37
Diffstat (limited to 'main/src')
8 files changed, 95 insertions, 79 deletions
diff --git a/main/src/com/google/android/setupdesign/GlifLayout.java b/main/src/com/google/android/setupdesign/GlifLayout.java index a461ee5..126b8a5 100644 --- a/main/src/com/google/android/setupdesign/GlifLayout.java +++ b/main/src/com/google/android/setupdesign/GlifLayout.java @@ -46,7 +46,6 @@ import com.google.android.setupdesign.template.IllustrationProgressMixin; import com.google.android.setupdesign.template.ProgressBarMixin; import com.google.android.setupdesign.template.RequireScrollMixin; import com.google.android.setupdesign.template.ScrollViewScrollHandlingDelegate; -import com.google.android.setupdesign.util.BuildCompatUtils; import com.google.android.setupdesign.util.DescriptionStyler; import com.google.android.setupdesign.util.LayoutStyler; import com.google.android.setupdesign.util.PartnerStyleHelper; @@ -191,12 +190,7 @@ public class GlifLayout extends PartnerCustomizationLayout { @Override protected View onInflateTemplate(LayoutInflater inflater, @LayoutRes int template) { if (template == 0) { - // TODO : use "values-land-v31" folder for sud_glif_template_s directly. - if (BuildCompatUtils.isAtLeastS()) { - template = R.layout.sud_glif_template_s; - } else { - template = R.layout.sud_glif_template; - } + template = R.layout.sud_glif_template; } return inflateTemplate(inflater, R.style.SudThemeGlif_Light, template); } diff --git a/main/src/com/google/android/setupdesign/GlifListLayout.java b/main/src/com/google/android/setupdesign/GlifListLayout.java index b906f41..31335cc 100644 --- a/main/src/com/google/android/setupdesign/GlifListLayout.java +++ b/main/src/com/google/android/setupdesign/GlifListLayout.java @@ -29,7 +29,6 @@ import android.widget.ListView; import com.google.android.setupdesign.template.ListMixin; import com.google.android.setupdesign.template.ListViewScrollHandlingDelegate; import com.google.android.setupdesign.template.RequireScrollMixin; -import com.google.android.setupdesign.util.BuildCompatUtils; /** * A GLIF themed layout with a ListView. {@code android:entries} can also be used to specify an @@ -81,12 +80,7 @@ public class GlifListLayout extends GlifLayout { @Override protected View onInflateTemplate(LayoutInflater inflater, int template) { if (template == 0) { - // TODO : use "values-land-v31" folder for sud_glif_list_template_s directly. - if (BuildCompatUtils.isAtLeastS()) { - template = R.layout.sud_glif_list_template_s; - } else { - template = R.layout.sud_glif_list_template; - } + template = R.layout.sud_glif_list_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 d5c0f69..f235442 100644 --- a/main/src/com/google/android/setupdesign/GlifPreferenceLayout.java +++ b/main/src/com/google/android/setupdesign/GlifPreferenceLayout.java @@ -24,7 +24,6 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import com.google.android.setupdesign.template.RecyclerMixin; -import com.google.android.setupdesign.util.BuildCompatUtils; /** * A layout to be used with {@code PreferenceFragment} in v14 support library. This can be specified @@ -99,13 +98,7 @@ public class GlifPreferenceLayout extends GlifRecyclerLayout { @Override protected View onInflateTemplate(LayoutInflater inflater, int template) { if (template == 0) { - // TODO : use "values-land-v31" folder for sud_glif_preference_template_s - // directly. - if (BuildCompatUtils.isAtLeastS()) { - template = R.layout.sud_glif_preference_template_s; - } else { - template = R.layout.sud_glif_preference_template; - } + template = R.layout.sud_glif_preference_template; } return super.onInflateTemplate(inflater, template); } @@ -115,17 +108,8 @@ public class GlifPreferenceLayout extends GlifRecyclerLayout { // Inflate the recycler view here, so attributes on the decoration views can be applied // immediately. final LayoutInflater inflater = LayoutInflater.from(getContext()); - RecyclerView recyclerView; - // TODO : use "layout-land-v31" folder for sud_glif_preference_recycler_view - // directly. - if (BuildCompatUtils.isAtLeastS()) { - recyclerView = - (RecyclerView) - inflater.inflate(R.layout.sud_glif_preference_recycler_view_s, this, false); - } else { - recyclerView = - (RecyclerView) inflater.inflate(R.layout.sud_glif_preference_recycler_view, this, false); - } + RecyclerView recyclerView = + (RecyclerView) inflater.inflate(R.layout.sud_glif_preference_recycler_view, this, false); recyclerMixin = new RecyclerMixin(this, recyclerView); } } diff --git a/main/src/com/google/android/setupdesign/GlifRecyclerLayout.java b/main/src/com/google/android/setupdesign/GlifRecyclerLayout.java index bb9ebb0..c74cff0 100644 --- a/main/src/com/google/android/setupdesign/GlifRecyclerLayout.java +++ b/main/src/com/google/android/setupdesign/GlifRecyclerLayout.java @@ -30,7 +30,6 @@ import android.view.ViewGroup; import com.google.android.setupdesign.template.RecyclerMixin; import com.google.android.setupdesign.template.RecyclerViewScrollHandlingDelegate; import com.google.android.setupdesign.template.RequireScrollMixin; -import com.google.android.setupdesign.util.BuildCompatUtils; /** * A GLIF themed layout with a RecyclerView. {@code android:entries} can also be used to specify an @@ -82,12 +81,7 @@ public class GlifRecyclerLayout extends GlifLayout { @Override protected View onInflateTemplate(LayoutInflater inflater, int template) { if (template == 0) { - // TODO : use "values-land-v31" folder for sud_glif_recycler_template_s directly. - if (BuildCompatUtils.isAtLeastS()) { - template = R.layout.sud_glif_recycler_template_s; - } else { - template = R.layout.sud_glif_recycler_template; - } + template = R.layout.sud_glif_recycler_template; } return super.onInflateTemplate(inflater, template); } diff --git a/main/src/com/google/android/setupdesign/items/ItemHierarchy.java b/main/src/com/google/android/setupdesign/items/ItemHierarchy.java index b22e9ef..6a5b51f 100644 --- a/main/src/com/google/android/setupdesign/items/ItemHierarchy.java +++ b/main/src/com/google/android/setupdesign/items/ItemHierarchy.java @@ -71,7 +71,7 @@ public interface ItemHierarchy { /** * Get the item at position. * - * @param position An integer from 0 to {@link #getCount()}}, which indicates the position in this + * @param position An integer from 0 to {@link #getCount()}, which indicates the position in this * item hierarchy to get the child item. * @return A representation of the item at {@code position}. Must not be {@code null}. */ diff --git a/main/src/com/google/android/setupdesign/transition/TransitionHelper.java b/main/src/com/google/android/setupdesign/transition/TransitionHelper.java index 8ce4306..005cf9b 100644 --- a/main/src/com/google/android/setupdesign/transition/TransitionHelper.java +++ b/main/src/com/google/android/setupdesign/transition/TransitionHelper.java @@ -16,6 +16,7 @@ package com.google.android.setupdesign.transition; +import android.annotation.TargetApi; import android.app.Activity; import android.app.ActivityOptions; import android.app.Fragment; @@ -24,6 +25,7 @@ import android.content.res.TypedArray; import android.os.Build; import android.os.Build.VERSION; import android.os.Build.VERSION_CODES; +import android.os.Bundle; import android.os.Parcelable; import android.util.Log; import android.view.Window; @@ -43,7 +45,8 @@ public class TransitionHelper { /* * In Setup Wizard, all Just-a-sec style screens (i.e. screens that has an indeterminate * progress bar and automatically finishes itself), should do a cross-fade when entering or - * exiting the screen. For all other screens, the transition should be a slide-in-from-right. + * exiting the screen. For all other screens, the transition should be a slide-in-from-right + * or customized. * * We use two different ways to override the transitions. The first is calling * overridePendingTransition in code, and the second is using windowAnimationStyle in the theme. @@ -120,7 +123,7 @@ public class TransitionHelper { public static final int TRANSITION_CAPTIVE = 5; /** Override the transition to the specific type that will depend on the partner resource. */ - private static final int CONFIG_TRANSITION_SHARED_X_AXIS = 1; + public static final int CONFIG_TRANSITION_SHARED_X_AXIS = 1; /** * Passed in an intent as EXTRA_ACTIVITY_OPTIONS. This is the {@link ActivityOptions} of the @@ -205,7 +208,7 @@ public class TransitionHelper { // For TRANSITION_NONE, turn off the transition activity.overridePendingTransition(/* enterAnim= */ 0, /* exitAnim= */ 0); } else if (transitionId == TRANSITION_CAPTIVE) { - // 1. If the flag not available, apply TRANSITION_SLIDE + // 1. Do not change the transition behavior by default // 2. If the flag present, apply the transition from transition type int configTransitionType = PartnerConfigHelper.get(activity) @@ -226,8 +229,6 @@ public class TransitionHelper { } else { Log.w(TAG, "applyForwardTransition: Invalid window=" + window); } - } else { - activity.overridePendingTransition(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out); } } // For TRANSITION_NO_OVERRIDE or other values, do not override the transition @@ -309,7 +310,7 @@ public class TransitionHelper { // For TRANSITION_NONE, turn off the transition activity.overridePendingTransition(/* enterAnim= */ 0, /* exitAnim= */ 0); } else if (transitionId == TRANSITION_CAPTIVE) { - // 1. If the flag not available, apply TRANSITION_SLIDE + // 1. Do not change the transition behavior by default // 2. If the flag present, apply the transition from transition type int configTransitionType = PartnerConfigHelper.get(activity) @@ -328,8 +329,6 @@ public class TransitionHelper { } else { Log.w(TAG, "applyBackwardTransition: Invalid window=" + window); } - } else { - activity.overridePendingTransition(R.anim.sud_slide_back_in, R.anim.sud_slide_back_out); } } // For TRANSITION_NO_OVERRIDE or other values, do not override the transition @@ -343,7 +342,22 @@ public class TransitionHelper { * @throws android.content.ActivityNotFoundException if there was no {@link Activity} found to run * the given Intent. */ + @TargetApi(VERSION_CODES.JELLY_BEAN) public static void startActivityWithTransition(Activity activity, Intent intent) { + startActivityWithTransition(activity, intent, /* overrideActivityOptions= */ null); + } + + /** + * A wrapper method, create an {@link android.app.ActivityOptions} to transition between + * activities as the {@link ActivityOptions} parameter of {@link Activity#startActivity}. + * + * @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. + */ + @TargetApi(VERSION_CODES.JELLY_BEAN) + public static void startActivityWithTransition( + Activity activity, Intent intent, Bundle overrideActivityOptions) { if (activity == null) { throw new IllegalArgumentException("Invalid activity=" + activity); } @@ -359,25 +373,46 @@ public class TransitionHelper { + " task transitions"); } - int configTransitionType = - PartnerConfigHelper.get(activity) - .getInteger(activity, PartnerConfig.CONFIG_TRANSITION_TYPE, TRANSITION_SLIDE); - if (Build.VERSION.SDK_INT > Build.VERSION_CODES.R - && configTransitionType == CONFIG_TRANSITION_SHARED_X_AXIS) { - 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 (Build.VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) { + int configTransitionType = + PartnerConfigHelper.get(activity) + .getInteger(activity, PartnerConfig.CONFIG_TRANSITION_TYPE, TRANSITION_SLIDE); + if (Build.VERSION.SDK_INT > Build.VERSION_CODES.R + && configTransitionType == CONFIG_TRANSITION_SHARED_X_AXIS) { + 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"); + } - ActivityOptions activityOptions = ActivityOptions.makeSceneTransitionAnimation(activity); - intent.putExtra(EXTRA_ACTIVITY_OPTIONS, (Parcelable) activityOptions.toBundle()); - activity.startActivity(intent, activityOptions.toBundle()); + Bundle bundleActivityOptions; + if (overrideActivityOptions != null) { + bundleActivityOptions = overrideActivityOptions; + } else { + bundleActivityOptions = ActivityOptions.makeSceneTransitionAnimation(activity).toBundle(); + } + intent.putExtra(EXTRA_ACTIVITY_OPTIONS, (Parcelable) bundleActivityOptions); + activity.startActivity(intent, bundleActivityOptions); + } else { + if (overrideActivityOptions != null) { + activity.startActivity(intent, overrideActivityOptions); + } else { + activity.startActivity(intent); + } + } } else { activity.startActivity(intent); } } + @TargetApi(VERSION_CODES.JELLY_BEAN) + public static void startActivityForResultWithTransition( + Activity activity, Intent intent, int requestCode) { + startActivityForResultWithTransition( + activity, intent, requestCode, /* overrideActivityOptions= */ null); + } + /** * A wrapper method, create an {@link android.app.ActivityOptions} to transition between * activities as the {@code activityOptions} parameter of {@link Activity#startActivityForResult}. @@ -386,8 +421,9 @@ public class TransitionHelper { * @throws android.content.ActivityNotFoundException if there was no {@link Activity} found to run * the given Intent. */ + @TargetApi(VERSION_CODES.JELLY_BEAN) public static void startActivityForResultWithTransition( - Activity activity, Intent intent, int requestCode) { + Activity activity, Intent intent, int requestCode, Bundle overrideActivityOptions) { if (activity == null) { throw new IllegalArgumentException("Invalid activity=" + activity); } @@ -403,20 +439,34 @@ public class TransitionHelper { + " task transitions"); } - int configTransitionType = - PartnerConfigHelper.get(activity) - .getInteger(activity, PartnerConfig.CONFIG_TRANSITION_TYPE, TRANSITION_SLIDE); - if (Build.VERSION.SDK_INT > Build.VERSION_CODES.R - && configTransitionType == CONFIG_TRANSITION_SHARED_X_AXIS) { - 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 (Build.VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) { + int configTransitionType = + PartnerConfigHelper.get(activity) + .getInteger(activity, PartnerConfig.CONFIG_TRANSITION_TYPE, TRANSITION_SLIDE); + if (Build.VERSION.SDK_INT > Build.VERSION_CODES.R + && configTransitionType == CONFIG_TRANSITION_SHARED_X_AXIS) { + 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"); + } - ActivityOptions activityOptions = ActivityOptions.makeSceneTransitionAnimation(activity); - intent.putExtra(EXTRA_ACTIVITY_OPTIONS, (Parcelable) activityOptions.toBundle()); - activity.startActivityForResult(intent, requestCode, activityOptions.toBundle()); + Bundle bundleActivityOptions; + if (overrideActivityOptions != null) { + bundleActivityOptions = overrideActivityOptions; + } else { + bundleActivityOptions = ActivityOptions.makeSceneTransitionAnimation(activity).toBundle(); + } + intent.putExtra(EXTRA_ACTIVITY_OPTIONS, (Parcelable) bundleActivityOptions); + activity.startActivityForResult(intent, requestCode, bundleActivityOptions); + } else { + if (overrideActivityOptions != null) { + activity.startActivityForResult(intent, requestCode, overrideActivityOptions); + } else { + activity.startActivityForResult(intent, requestCode); + } + } } else { activity.startActivityForResult(intent, requestCode); } diff --git a/main/src/com/google/android/setupdesign/util/ContentStyler.java b/main/src/com/google/android/setupdesign/util/ContentStyler.java index 185b53b..2ab1658 100644 --- a/main/src/com/google/android/setupdesign/util/ContentStyler.java +++ b/main/src/com/google/android/setupdesign/util/ContentStyler.java @@ -31,7 +31,7 @@ import java.util.Locale; * method. */ public final class ContentStyler { - public static void applyPartnerCustomizationStyle(TextView contentText) { + public static void applyBodyPartnerCustomizationStyle(TextView contentText) { if (!PartnerStyleHelper.shouldApplyPartnerHeavyThemeResource(contentText)) { return; } diff --git a/main/src/com/google/android/setupdesign/util/HeaderAreaStyler.java b/main/src/com/google/android/setupdesign/util/HeaderAreaStyler.java index cdfebc5..0ebb13d 100644 --- a/main/src/com/google/android/setupdesign/util/HeaderAreaStyler.java +++ b/main/src/com/google/android/setupdesign/util/HeaderAreaStyler.java @@ -237,10 +237,10 @@ public final class HeaderAreaStyler { @Override public boolean onPreDraw() { imageView.getViewTreeObserver().removeOnPreDrawListener(this); - // TODO: Remove when Partners all used Drawable icon image and never use if (isAtLeastS() - && !(imageView.getDrawable() instanceof VectorDrawable + && !(imageView.getDrawable() == null + || imageView.getDrawable() instanceof VectorDrawable || imageView.getDrawable() instanceof VectorDrawableCompat)) { if (Build.TYPE.equals("userdebug") || Build.TYPE.equals("eng")) { Toast.makeText(imageView.getContext(), WARN_TO_USE_DRAWABLE, Toast.LENGTH_LONG) |