From d520f469f449f64cab202d160fd3c35d6c8f54f7 Mon Sep 17 00:00:00 2001 From: Setup Wizard Team Date: Tue, 5 May 2020 10:02:57 +0800 Subject: Import updated Android Setupdesign Library 309863724 Copied from google3/third_party/java_src/android_libs/setupdesign Test: mm Bug: 155846468 Included changes: - 309863724 Fine tuning the progress illustration for better ux exper... - 308970672 Add description field for illustration_loading_screen lay... - 306581820 Support PartnerResource to customize packages to recipien... - 306566965 New progress illustration layout and related partner conf... - 305382237 Lower log level to prevent crash PiperOrigin-RevId: 309863724 Change-Id: I1820bd33788ab637f974ba7350d5d389271abcf8 --- .../sud_glif_illustration_loading_screen.xml | 56 ++++++++++++++++++++++ .../android/setupdesign/template/HeaderMixin.java | 8 ++++ .../android/setupdesign/template/IconMixin.java | 8 ++++ .../google/android/setupdesign/util/Partner.java | 18 ++++++- .../setupdesign/view/IllustrationVideoView.java | 4 +- 5 files changed, 90 insertions(+), 4 deletions(-) create mode 100644 main/res/layout/sud_glif_illustration_loading_screen.xml (limited to 'main') diff --git a/main/res/layout/sud_glif_illustration_loading_screen.xml b/main/res/layout/sud_glif_illustration_loading_screen.xml new file mode 100644 index 0000000..581d5c6 --- /dev/null +++ b/main/res/layout/sud_glif_illustration_loading_screen.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + diff --git a/main/src/com/google/android/setupdesign/template/HeaderMixin.java b/main/src/com/google/android/setupdesign/template/HeaderMixin.java index ef14d29..0a6eb9e 100644 --- a/main/src/com/google/android/setupdesign/template/HeaderMixin.java +++ b/main/src/com/google/android/setupdesign/template/HeaderMixin.java @@ -121,6 +121,14 @@ public class HeaderMixin implements Mixin { return titleView != null ? titleView.getText() : null; } + /** Sets the visibility of header text */ + public void setVisibility(int visibility) { + final TextView titleView = getTextView(); + if (titleView != null) { + titleView.setVisibility(visibility); + } + } + /** * Sets the color of the header text. This can also be set via XML using {@code * app:sucHeaderTextColor}. diff --git a/main/src/com/google/android/setupdesign/template/IconMixin.java b/main/src/com/google/android/setupdesign/template/IconMixin.java index f74f87a..dca934f 100644 --- a/main/src/com/google/android/setupdesign/template/IconMixin.java +++ b/main/src/com/google/android/setupdesign/template/IconMixin.java @@ -172,6 +172,14 @@ public class IconMixin implements Mixin { return iconView != null ? iconView.getContentDescription() : null; } + /** Sets the visibiltiy of the icon view */ + public void setVisibility(int visibility) { + final ImageView iconView = getView(); + if (iconView != null) { + iconView.setVisibility(visibility); + } + } + /** @return The ImageView responsible for displaying the icon. */ protected ImageView getView() { return (ImageView) templateLayout.findManagedViewById(R.id.sud_layout_icon); diff --git a/main/src/com/google/android/setupdesign/util/Partner.java b/main/src/com/google/android/setupdesign/util/Partner.java index 6b97bf6..aee5070 100644 --- a/main/src/com/google/android/setupdesign/util/Partner.java +++ b/main/src/com/google/android/setupdesign/util/Partner.java @@ -27,13 +27,17 @@ import android.graphics.drawable.Drawable; import android.os.Build.VERSION; import android.os.Build.VERSION_CODES; import androidx.annotation.AnyRes; +import androidx.annotation.ArrayRes; import androidx.annotation.ColorRes; import androidx.annotation.DrawableRes; import androidx.annotation.Nullable; import androidx.annotation.StringRes; import androidx.annotation.VisibleForTesting; import android.util.Log; +import java.util.Arrays; +import java.util.HashSet; import java.util.List; +import java.util.Set; /** * Utilities to discover and interact with partner customizations. An overlay package is one that @@ -54,11 +58,21 @@ public class Partner { private static boolean searched = false; @Nullable private static Partner partner; + /** + * Gets the string-array from partner overlay. If not available, an empty array will be returned. + * + * @see #getResourceEntry(Context, int) + */ + public static Set getStringArray(Context context, @ArrayRes int res) { + ResourceEntry resourceEntry = Partner.getResourceEntry(context, res); + return new HashSet<>(Arrays.asList(resourceEntry.resources.getStringArray(resourceEntry.id))); + } + /** * Gets a drawable from partner overlay, or if not available, the drawable from the original * context. * - * @see #getResourceEntry(android.content.Context, int) + * @see #getResourceEntry(Context, int) */ public static Drawable getDrawable(Context context, @DrawableRes int id) { final ResourceEntry entry = getResourceEntry(context, id); @@ -68,7 +82,7 @@ public class Partner { /** * Gets a string from partner overlay, or if not available, the string from the original context. * - * @see #getResourceEntry(android.content.Context, int) + * @see #getResourceEntry(Context, int) */ public static String getString(Context context, @StringRes int id) { final ResourceEntry entry = getResourceEntry(context, id); diff --git a/main/src/com/google/android/setupdesign/view/IllustrationVideoView.java b/main/src/com/google/android/setupdesign/view/IllustrationVideoView.java index 939b8de..0654b02 100644 --- a/main/src/com/google/android/setupdesign/view/IllustrationVideoView.java +++ b/main/src/com/google/android/setupdesign/view/IllustrationVideoView.java @@ -188,7 +188,7 @@ public class IllustrationVideoView extends TextureView mediaPlayer.setDataSource(getContext(), uri, null); mediaPlayer.prepareAsync(); } catch (IOException e) { - Log.wtf(TAG, "Unable to set data source", e); + Log.e(TAG, "Unable to set video data source: " + videoRes, e); } } @@ -350,7 +350,7 @@ public class IllustrationVideoView extends TextureView if (isPrepared()) { mp.start(); } else { - Log.wtf(TAG, "Seek complete but media player not prepared"); + Log.e(TAG, "Seek complete but media player not prepared"); } } -- cgit v1.2.3