diff options
author | Maurice Lam <yukl@google.com> | 2017-08-21 17:59:13 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2017-08-21 17:59:13 +0000 |
commit | 81f18acfdac60f419b90eb31b6e0c6700807ef9a (patch) | |
tree | d523b4a77ea4d1c38b8c167efe5e180b5cc1fe7a | |
parent | eacc898778dcb45a71ba463fc954993f55d87666 (diff) | |
parent | cb38f9b86c595ad8010384c331edcecdbae2dcb3 (diff) | |
download | setupwizard-81f18acfdac60f419b90eb31b6e0c6700807ef9a.tar.gz |
Merge "Add getText to Partner.java" into oc-mr1-dev
-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(); |