diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2017-08-22 07:28:35 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2017-08-22 07:28:35 +0000 |
commit | 66955032be6fdc8993e7753d6f0f552229580fcf (patch) | |
tree | d523b4a77ea4d1c38b8c167efe5e180b5cc1fe7a | |
parent | 225a23f6cfdeb456ff103889099c823d5712846a (diff) | |
parent | 81f18acfdac60f419b90eb31b6e0c6700807ef9a (diff) | |
download | setupwizard-66955032be6fdc8993e7753d6f0f552229580fcf.tar.gz |
release-request-696ef4a1-3459-446f-a322-67e13926d505-for-git_oc-mr1-release-4290956 snap-temp-L88300000095517061
Change-Id: Ie894d0ceabb05f43fe047df6990973b1c1d70c43
-rw-r--r-- | library/main/src/com/android/setupwizardlib/util/Partner.java | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/library/main/src/com/android/setupwizardlib/util/Partner.java b/library/main/src/com/android/setupwizardlib/util/Partner.java index d6e4919..67f5546 100644 --- a/library/main/src/com/android/setupwizardlib/util/Partner.java +++ b/library/main/src/com/android/setupwizardlib/util/Partner.java @@ -26,6 +26,9 @@ import android.content.res.Resources; import android.graphics.drawable.Drawable; import android.os.Build.VERSION; import android.os.Build.VERSION_CODES; +import android.support.annotation.AnyRes; +import android.support.annotation.DrawableRes; +import android.support.annotation.StringRes; import android.support.annotation.VisibleForTesting; import android.util.Log; @@ -56,7 +59,7 @@ public class Partner { * * @see #getResourceEntry(android.content.Context, int) */ - public static Drawable getDrawable(Context context, int id) { + public static Drawable getDrawable(Context context, @DrawableRes int id) { final ResourceEntry entry = getResourceEntry(context, id); return entry.resources.getDrawable(entry.id); } @@ -67,12 +70,21 @@ public class Partner { * * @see #getResourceEntry(android.content.Context, int) */ - public static String getString(Context context, int id) { + public static String getString(Context context, @StringRes int id) { final ResourceEntry entry = getResourceEntry(context, id); return entry.resources.getString(entry.id); } /** + * Convenience method to get a CharSequence from partner overlay, or if not available, the text + * from the original context. + */ + public static CharSequence getText(Context context, @StringRes int id) { + final ResourceEntry entry = getResourceEntry(context, id); + return entry.resources.getText(id); + } + + /** * Find an entry of resource in the overlay package provided by partners. It will first look for * the resource in the overlay package, and if not available, will return the one in the * original context. @@ -82,7 +94,7 @@ public class Partner { * {@code entry.resources.getString(entry.id)}, or other methods available in * {@link android.content.res.Resources}. */ - public static ResourceEntry getResourceEntry(Context context, int id) { + public static ResourceEntry getResourceEntry(Context context, @AnyRes int id) { final Partner partner = Partner.get(context); if (partner != null) { final Resources ourResources = context.getResources(); |