summaryrefslogtreecommitdiff
path: root/main/src
diff options
context:
space:
mode:
authorSetup Wizard Team <android-setup-team-eng@google.com>2021-03-24 16:53:04 +0800
committerAlex Li <alexylli@google.com>2021-03-24 09:30:20 +0000
commit4a594ac4b3d8a13e91695bc8a4e66db99cb2c7d7 (patch)
tree4ed1683835d5eb0ab5604a94021cf85e0f08a6db /main/src
parenteccac8fab947791d79ca9d4bb09103a9b5bd4b8a (diff)
downloadsetupdesign-4a594ac4b3d8a13e91695bc8a4e66db99cb2c7d7.tar.gz
Import updated Android Setupdesign Library 364750899
Copied from google3/third_party/java_src/android_libs/setupdesign Test: mm Bug: 183584598 Included changes: - 364750899 [SetupDesign][Transition] Changes the usage ActivityOptio... - 364739100 Change the margin top for BC landscape layout. - 364711614 Add id for the content area in landscape glif layout - 364539233 [SetupDesign][Transition] Adds condition check in startAc... - 364509033 [GlifLoadingLayout] Integrate subacitivty wrapper with Gl... - 364270938 Remove the BC flag check for the new partner resource - 364257121 [BC][Transition] Change the type of return value of Trans... PiperOrigin-RevId: 364750899 Change-Id: I5f731eb0b0ad19b15b80c68e753586daf8348729
Diffstat (limited to 'main/src')
-rw-r--r--main/src/com/google/android/setupdesign/GlifLayout.java7
-rw-r--r--main/src/com/google/android/setupdesign/GlifListLayout.java5
-rw-r--r--main/src/com/google/android/setupdesign/GlifRecyclerLayout.java5
-rw-r--r--main/src/com/google/android/setupdesign/transition/TransitionHelper.java10
-rw-r--r--main/src/com/google/android/setupdesign/transition/support/TransitionHelper.java13
-rw-r--r--main/src/com/google/android/setupdesign/util/HeaderAreaStyler.java11
-rw-r--r--main/src/com/google/android/setupdesign/util/ItemStyler.java15
-rw-r--r--main/src/com/google/android/setupdesign/util/LayoutStyler.java5
-rw-r--r--main/src/com/google/android/setupdesign/util/TextViewPartnerStyler.java72
9 files changed, 79 insertions, 64 deletions
diff --git a/main/src/com/google/android/setupdesign/GlifLayout.java b/main/src/com/google/android/setupdesign/GlifLayout.java
index b7d19ac..dc84c71 100644
--- a/main/src/com/google/android/setupdesign/GlifLayout.java
+++ b/main/src/com/google/android/setupdesign/GlifLayout.java
@@ -151,7 +151,7 @@ public class GlifLayout extends PartnerCustomizationLayout {
// the value of partner config.
LayoutStyler.applyPartnerCustomizationExtraPaddingStyle(view);
- applyPartnerCustomizationContentPaddingStyle(view);
+ applyPartnerCustomizationContentPaddingTopStyle(view);
}
}
@@ -294,7 +294,7 @@ public class GlifLayout extends PartnerCustomizationLayout {
*/
@TargetApi(Build.VERSION_CODES.S)
public void setLandscapeHeaderAreaVisible(boolean visible) {
- View view = this.findManagedViewById(R.id.suc_landscape_header_area);
+ View view = this.findManagedViewById(R.id.sud_landscape_header_area);
if (view == null) {
return;
}
@@ -404,14 +404,13 @@ public class GlifLayout extends PartnerCustomizationLayout {
}
@TargetApi(VERSION_CODES.JELLY_BEAN_MR1)
- private static void applyPartnerCustomizationContentPaddingStyle(View view) {
+ protected static void applyPartnerCustomizationContentPaddingTopStyle(View view) {
Context context = view.getContext();
boolean partnerPaddingTopAvailable =
PartnerConfigHelper.get(context)
.isPartnerConfigAvailable(PartnerConfig.CONFIG_CONTENT_PADDING_TOP);
if (PartnerStyleHelper.shouldApplyPartnerHeavyThemeResource(view)
- && PartnerConfigHelper.shouldApplyExtendedPartnerConfig(context)
&& partnerPaddingTopAvailable) {
int paddingTop =
(int)
diff --git a/main/src/com/google/android/setupdesign/GlifListLayout.java b/main/src/com/google/android/setupdesign/GlifListLayout.java
index fba6433..740b2af 100644
--- a/main/src/com/google/android/setupdesign/GlifListLayout.java
+++ b/main/src/com/google/android/setupdesign/GlifListLayout.java
@@ -73,6 +73,11 @@ public class GlifListLayout extends GlifLayout {
final RequireScrollMixin requireScrollMixin = getMixin(RequireScrollMixin.class);
requireScrollMixin.setScrollHandlingDelegate(
new ListViewScrollHandlingDelegate(requireScrollMixin, getListView()));
+
+ View view = this.findManagedViewById(R.id.sud_landscape_content_area);
+ if (view != null) {
+ applyPartnerCustomizationContentPaddingTopStyle(view);
+ }
}
@Override
diff --git a/main/src/com/google/android/setupdesign/GlifRecyclerLayout.java b/main/src/com/google/android/setupdesign/GlifRecyclerLayout.java
index d96d5af..973f388 100644
--- a/main/src/com/google/android/setupdesign/GlifRecyclerLayout.java
+++ b/main/src/com/google/android/setupdesign/GlifRecyclerLayout.java
@@ -74,6 +74,11 @@ public class GlifRecyclerLayout extends GlifLayout {
final RequireScrollMixin requireScrollMixin = getMixin(RequireScrollMixin.class);
requireScrollMixin.setScrollHandlingDelegate(
new RecyclerViewScrollHandlingDelegate(requireScrollMixin, getRecyclerView()));
+
+ View view = this.findManagedViewById(R.id.sud_landscape_content_area);
+ if (view != null) {
+ applyPartnerCustomizationContentPaddingTopStyle(view);
+ }
}
@Override
diff --git a/main/src/com/google/android/setupdesign/transition/TransitionHelper.java b/main/src/com/google/android/setupdesign/transition/TransitionHelper.java
index ba78a54..0d76110 100644
--- a/main/src/com/google/android/setupdesign/transition/TransitionHelper.java
+++ b/main/src/com/google/android/setupdesign/transition/TransitionHelper.java
@@ -395,7 +395,7 @@ public class TransitionHelper {
if (overrideActivityOptions != null) {
bundleActivityOptions = overrideActivityOptions;
} else {
- bundleActivityOptions = ActivityOptions.makeSceneTransitionAnimation(activity).toBundle();
+ bundleActivityOptions = makeActivityOptions(activity, intent);
}
intent.putExtra(EXTRA_ACTIVITY_OPTIONS, (Parcelable) bundleActivityOptions);
activity.startActivity(intent, bundleActivityOptions);
@@ -415,7 +415,8 @@ public class TransitionHelper {
private static void startActivityWithTransitionInternal(
Activity activity, Intent intent, Bundle overrideActivityOptions) {
if (Build.VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {
- if (overrideActivityOptions != null) {
+ if (getConfigTransitionType(activity) == CONFIG_TRANSITION_SHARED_X_AXIS
+ && overrideActivityOptions != null) {
activity.startActivity(intent, overrideActivityOptions);
} else {
activity.startActivity(intent);
@@ -474,7 +475,7 @@ public class TransitionHelper {
if (overrideActivityOptions != null) {
bundleActivityOptions = overrideActivityOptions;
} else {
- bundleActivityOptions = ActivityOptions.makeSceneTransitionAnimation(activity).toBundle();
+ bundleActivityOptions = makeActivityOptions(activity, intent);
}
intent.putExtra(EXTRA_ACTIVITY_OPTIONS, (Parcelable) bundleActivityOptions);
activity.startActivityForResult(intent, requestCode, bundleActivityOptions);
@@ -496,7 +497,8 @@ public class TransitionHelper {
private static void startActivityForResultWithTransitionInternal(
Activity activity, Intent intent, int requestCode, Bundle overrideActivityOptions) {
if (Build.VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {
- if (overrideActivityOptions != null) {
+ if (getConfigTransitionType(activity) == CONFIG_TRANSITION_SHARED_X_AXIS
+ && overrideActivityOptions != null) {
activity.startActivityForResult(intent, requestCode, overrideActivityOptions);
} else {
activity.startActivityForResult(intent, requestCode);
diff --git a/main/src/com/google/android/setupdesign/transition/support/TransitionHelper.java b/main/src/com/google/android/setupdesign/transition/support/TransitionHelper.java
index b382f93..8fd9d6e 100644
--- a/main/src/com/google/android/setupdesign/transition/support/TransitionHelper.java
+++ b/main/src/com/google/android/setupdesign/transition/support/TransitionHelper.java
@@ -23,7 +23,6 @@ import android.annotation.TargetApi;
import android.app.Activity;
import android.os.Build;
import android.os.Build.VERSION_CODES;
-import android.os.Bundle;
import androidx.fragment.app.Fragment;
import android.util.Log;
import android.view.Window;
@@ -104,13 +103,13 @@ public class TransitionHelper {
/**
* A wrapper method, create an {@link ActivityOptionsCompat} to transition between activities as
* the {@link ActivityOptionsCompat} parameter of {@link
- * androidx.activity.result.ActivityResultLauncher#launch} method.
+ * androidx.activity.result.ActivityResultLauncher#launch(I, ActivityOptionsCompat)} method.
*/
@Nullable
- public static Bundle makeActivityOptionsCompat(Activity activity) {
- Bundle resultBundle = null;
+ public static ActivityOptionsCompat makeActivityOptionsCompat(Activity activity) {
+ ActivityOptionsCompat activityOptionsCompat = null;
if (activity == null) {
- return resultBundle;
+ return activityOptionsCompat;
}
if (getConfigTransitionType(activity) == CONFIG_TRANSITION_SHARED_X_AXIS) {
@@ -122,10 +121,10 @@ public class TransitionHelper {
"The transition won't take effect due to NO FEATURE_ACTIVITY_TRANSITIONS feature");
}
- resultBundle = ActivityOptionsCompat.makeSceneTransitionAnimation(activity).toBundle();
+ activityOptionsCompat = ActivityOptionsCompat.makeSceneTransitionAnimation(activity);
}
}
- return resultBundle;
+ return activityOptionsCompat;
}
}
diff --git a/main/src/com/google/android/setupdesign/util/HeaderAreaStyler.java b/main/src/com/google/android/setupdesign/util/HeaderAreaStyler.java
index 0ebb13d..33a4d34 100644
--- a/main/src/com/google/android/setupdesign/util/HeaderAreaStyler.java
+++ b/main/src/com/google/android/setupdesign/util/HeaderAreaStyler.java
@@ -145,7 +145,7 @@ public final class HeaderAreaStyler {
/**
* Applies the partner style of header area to the given layout {@code headerArea}. The theme
* should set partner heavy theme first, and then the partner style of header would be applied. As
- * for the margin bottom of header, it would aslo be appied when extended parter config is
+ * for the margin bottom of header, it would also be appied when heavy theme parter config is
* enabled.
*
* @param headerArea A ViewGroup would apply the partner style of header area
@@ -162,7 +162,8 @@ public final class HeaderAreaStyler {
.getColor(context, PartnerConfig.CONFIG_HEADER_AREA_BACKGROUND_COLOR);
headerArea.setBackgroundColor(color);
- if (PartnerConfigHelper.shouldApplyExtendedPartnerConfig(context)) {
+ if (PartnerConfigHelper.get(context)
+ .isPartnerConfigAvailable(PartnerConfig.CONFIG_HEADER_CONTAINER_MARGIN_BOTTOM)) {
final ViewGroup.LayoutParams lp = headerArea.getLayoutParams();
if (lp instanceof ViewGroup.MarginLayoutParams) {
final ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) lp;
@@ -180,8 +181,7 @@ public final class HeaderAreaStyler {
/**
* Applies the partner style of header icon to the given {@code iconImage}. The theme should set
- * partner heavy theme and enable extended parter config first, and then the partner icon size
- * would be applied.
+ * partner heavy theme first, and then the partner icon size would be applied.
*
* @param iconImage A ImageView would apply the partner style of header icon
* @param templateLayout The template containing this mixin
@@ -199,8 +199,7 @@ public final class HeaderAreaStyler {
setGravity(iconImage, gravity);
}
- if (PartnerStyleHelper.shouldApplyPartnerHeavyThemeResource(iconImage)
- && PartnerConfigHelper.shouldApplyExtendedPartnerConfig(context)) {
+ if (PartnerStyleHelper.shouldApplyPartnerHeavyThemeResource(iconImage)) {
final ViewGroup.LayoutParams lp = iconImage.getLayoutParams();
boolean partnerConfigAvailable =
PartnerConfigHelper.get(context)
diff --git a/main/src/com/google/android/setupdesign/util/ItemStyler.java b/main/src/com/google/android/setupdesign/util/ItemStyler.java
index 7694d38..b58945d 100644
--- a/main/src/com/google/android/setupdesign/util/ItemStyler.java
+++ b/main/src/com/google/android/setupdesign/util/ItemStyler.java
@@ -38,17 +38,17 @@ import com.google.android.setupdesign.R;
public final class ItemStyler {
/**
- * Applies the extended partner configs to the given view {@code view}. The user needs to check
+ * Applies the heavy theme partner configs to the given view {@code view}. The user needs to check
* before calling this method:
*
- * <p>1) If the {@code view} should apply extended partner configs by calling {@link
- * ThemeHelper#shouldApplyExtendedPartnerConfig}.
+ * <p>1) If the {@code view} should apply heavy theme resource by calling {@link
+ * PartnerStyleHelper#shouldApplyPartnerHeavyThemeResource}.
*
* <p>2) If the layout of the {@code view} contains fixed resource IDs which attempts to apply
- * extended partner resources (The resource ID of the title is "sud_items_title" and the resource
- * ID of the summary is "sud_items_summary"), refer to {@link R.layout#sud_items_default}.
+ * heavy theme resources (The resource ID of the title is "sud_items_title" and the resource ID of
+ * the summary is "sud_items_summary"), refer to {@link R.layout#sud_items_default}.
*
- * @param view A view would be applied extended partner styles
+ * @param view A view would be applied heavy theme styles
*/
@TargetApi(VERSION_CODES.JELLY_BEAN_MR1)
public static void applyPartnerCustomizationItemStyle(@Nullable View view) {
@@ -58,8 +58,7 @@ public final class ItemStyler {
final Context context = view.getContext();
- if (!PartnerStyleHelper.shouldApplyPartnerHeavyThemeResource(view)
- || !PartnerConfigHelper.shouldApplyExtendedPartnerConfig(context)) {
+ if (!PartnerStyleHelper.shouldApplyPartnerHeavyThemeResource(view)) {
return;
}
diff --git a/main/src/com/google/android/setupdesign/util/LayoutStyler.java b/main/src/com/google/android/setupdesign/util/LayoutStyler.java
index 10856f7..b707521 100644
--- a/main/src/com/google/android/setupdesign/util/LayoutStyler.java
+++ b/main/src/com/google/android/setupdesign/util/LayoutStyler.java
@@ -34,8 +34,7 @@ public final class LayoutStyler {
/**
* Applies the partner layout padding style to the given view {@code view}. The theme should set
- * partner heavy theme and enable extended parter config first, and then the partner layout style
- * would be applied.
+ * partner heavy theme config first, and then the partner layout style would be applied.
*
* @param view A view would be applied partner layout padding style
*/
@@ -54,7 +53,6 @@ public final class LayoutStyler {
.isPartnerConfigAvailable(PartnerConfig.CONFIG_LAYOUT_MARGIN_END);
if (PartnerStyleHelper.shouldApplyPartnerHeavyThemeResource(view)
- && PartnerConfigHelper.shouldApplyExtendedPartnerConfig(context)
&& (partnerMarginStartAvailable || partnerMarginEndAvailable)) {
int paddingStart;
int paddingEnd;
@@ -104,7 +102,6 @@ public final class LayoutStyler {
.isPartnerConfigAvailable(PartnerConfig.CONFIG_LAYOUT_MARGIN_END);
if (PartnerStyleHelper.shouldApplyPartnerHeavyThemeResource(view)
- && PartnerConfigHelper.shouldApplyExtendedPartnerConfig(context)
&& (partnerMarginStartAvailable || partnerMarginEndAvailable)) {
int extraPaddingStart;
int extraPaddingEnd;
diff --git a/main/src/com/google/android/setupdesign/util/TextViewPartnerStyler.java b/main/src/com/google/android/setupdesign/util/TextViewPartnerStyler.java
index 8344692..03a1684 100644
--- a/main/src/com/google/android/setupdesign/util/TextViewPartnerStyler.java
+++ b/main/src/com/google/android/setupdesign/util/TextViewPartnerStyler.java
@@ -39,7 +39,9 @@ final class TextViewPartnerStyler {
}
Context context = textView.getContext();
- if (textPartnerConfigs.getTextColorConfig() != null) {
+ if (textPartnerConfigs.getTextColorConfig() != null
+ && PartnerConfigHelper.get(context)
+ .isPartnerConfigAvailable(textPartnerConfigs.getTextColorConfig())) {
int textColor =
PartnerConfigHelper.get(context)
.getColor(context, textPartnerConfigs.getTextColorConfig());
@@ -48,7 +50,9 @@ final class TextViewPartnerStyler {
}
}
- if (textPartnerConfigs.getTextLinkedColorConfig() != null) {
+ if (textPartnerConfigs.getTextLinkedColorConfig() != null
+ && PartnerConfigHelper.get(context)
+ .isPartnerConfigAvailable(textPartnerConfigs.getTextLinkedColorConfig())) {
int linkTextColor =
PartnerConfigHelper.get(context)
.getColor(context, textPartnerConfigs.getTextLinkedColorConfig());
@@ -57,7 +61,9 @@ final class TextViewPartnerStyler {
}
}
- if (textPartnerConfigs.getTextSizeConfig() != null) {
+ if (textPartnerConfigs.getTextSizeConfig() != null
+ && PartnerConfigHelper.get(context)
+ .isPartnerConfigAvailable(textPartnerConfigs.getTextSizeConfig())) {
float textSize =
PartnerConfigHelper.get(context)
.getDimension(context, textPartnerConfigs.getTextSizeConfig(), 0);
@@ -66,7 +72,9 @@ final class TextViewPartnerStyler {
}
}
- if (textPartnerConfigs.getTextFontFamilyConfig() != null) {
+ if (textPartnerConfigs.getTextFontFamilyConfig() != null
+ && PartnerConfigHelper.get(context)
+ .isPartnerConfigAvailable(textPartnerConfigs.getTextFontFamilyConfig())) {
String fontFamilyName =
PartnerConfigHelper.get(context)
.getString(context, textPartnerConfigs.getTextFontFamilyConfig());
@@ -76,34 +84,36 @@ final class TextViewPartnerStyler {
}
}
- if (PartnerConfigHelper.shouldApplyExtendedPartnerConfig(context)) {
- if (textPartnerConfigs.getTextMarginTop() != null
- || textPartnerConfigs.getTextMarginBottom() != null) {
- int topMargin;
- int bottomMargin;
- final ViewGroup.LayoutParams lp = textView.getLayoutParams();
- if (lp instanceof LinearLayout.LayoutParams) {
- final LinearLayout.LayoutParams mlp = (LinearLayout.LayoutParams) lp;
- if (textPartnerConfigs.getTextMarginTop() != null) {
- topMargin =
- (int)
- PartnerConfigHelper.get(context)
- .getDimension(context, textPartnerConfigs.getTextMarginTop());
- } else {
- topMargin = mlp.topMargin;
- }
-
- if (textPartnerConfigs.getTextMarginBottom() != null) {
- bottomMargin =
- (int)
- PartnerConfigHelper.get(context)
- .getDimension(context, textPartnerConfigs.getTextMarginBottom());
- } else {
- bottomMargin = mlp.bottomMargin;
- }
- mlp.setMargins(mlp.leftMargin, topMargin, mlp.rightMargin, bottomMargin);
- textView.setLayoutParams(lp);
+ if (textPartnerConfigs.getTextMarginTop() != null
+ || textPartnerConfigs.getTextMarginBottom() != null) {
+ int topMargin;
+ int bottomMargin;
+ final ViewGroup.LayoutParams lp = textView.getLayoutParams();
+ if (lp instanceof LinearLayout.LayoutParams) {
+ final LinearLayout.LayoutParams mlp = (LinearLayout.LayoutParams) lp;
+ if (textPartnerConfigs.getTextMarginTop() != null
+ && PartnerConfigHelper.get(context)
+ .isPartnerConfigAvailable(textPartnerConfigs.getTextMarginTop())) {
+ topMargin =
+ (int)
+ PartnerConfigHelper.get(context)
+ .getDimension(context, textPartnerConfigs.getTextMarginTop());
+ } else {
+ topMargin = mlp.topMargin;
}
+
+ if (textPartnerConfigs.getTextMarginBottom() != null
+ && PartnerConfigHelper.get(context)
+ .isPartnerConfigAvailable(textPartnerConfigs.getTextMarginBottom())) {
+ bottomMargin =
+ (int)
+ PartnerConfigHelper.get(context)
+ .getDimension(context, textPartnerConfigs.getTextMarginBottom());
+ } else {
+ bottomMargin = mlp.bottomMargin;
+ }
+ mlp.setMargins(mlp.leftMargin, topMargin, mlp.rightMargin, bottomMargin);
+ textView.setLayoutParams(lp);
}
}
textView.setGravity(textPartnerConfigs.getTextGravity());