Skip to content

Commit

Permalink
[TIMOB-19859] Android: Deprecate Ti.Android.R.drawable
Browse files Browse the repository at this point in the history
  • Loading branch information
sriks committed Nov 4, 2015
1 parent 05289ff commit 40a96fe
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ public InputStream openInputStream(String path, boolean report)
if (TI_RESOURCE_PREFIX.equals(section)) {
is = TiFileHelper.class.getResourceAsStream("/org/appcelerator/titanium/res/drawable/" + resid + ".png");
} else if ("Sys".equals(section)) {
Log.e(TAG, "Accessing Android system icons is deprecated. Instead copy to res folder.");
Integer id = systemIcons.get(resid);
if (id != null) {
is = Resources.getSystem().openRawResource(id);
Expand Down Expand Up @@ -407,6 +408,7 @@ public Drawable getTitaniumResource(Context context, String s) {
}
}
} else if ("Sys".equals(section)) {
Log.e(TAG, "Accessing Android system icons is deprecated. Instead copy to res folder.");
Integer id = systemIcons.get(resid);
if (id != null) {
d = Resources.getSystem().getDrawable(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ protected static int getResource(String prefix, String path) throws ResourceNotF
}

protected static int lookupResource(String prefix, String path, String[] classAndFieldNames) throws ResourceNotFoundException {
if (prefix.startsWith("android.R") && path.startsWith("drawable.")) {
Log.w(TAG, "Using android.R.drawable is not recommended since they are changed/removed across Android versions. Instead copy images to res folder.");
}

// Get the clsPrefixApplication if this is the first time
if (clsPrefixApplication == null)
clsPrefixApplication = TiApplication.getInstance().getApplicationInfo().packageName + ".R$";
Expand Down
5 changes: 5 additions & 0 deletions apidoc/Titanium/Android/R.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ description: |
See also: [android.R](http://developer.android.com/reference/android/R.html) in the
Android Developer Reference.
Accessing drawables using Ti.Android.R.drawable is deprecated and not a recommended practice since the system provided drawables can be
removed across Android versions. Prefer to copy the images to application res folder.
extends: Titanium.Proxy
platforms: [android]
createable: false
Expand Down Expand Up @@ -67,6 +70,8 @@ properties:
Drawable resources. See
[R.drawable](http://developer.android.com/reference/android/R.drawable.html)
in the Android Developer Reference.
Accessing drawables using Ti.Android.R.drawable is deprecated and not a recommended practice since the system provided
drawables can be removed across Android versions. Prefer to copy the images to application res folder.
type: Object
accessors: false
permission: read-only
Expand Down

0 comments on commit 40a96fe

Please sign in to comment.