Skip to content

Commit

Permalink
fix(android): menu item icon wrongly ignores theme (#13106)
Browse files Browse the repository at this point in the history
Fixes TIMOB-28547
  • Loading branch information
jquick-axway committed Oct 20, 2021
1 parent 09e9044 commit f3c4057
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
Expand Up @@ -1032,7 +1032,11 @@ public static Drawable getResourceDrawable(String url)

public static Drawable getResourceDrawable(int res_id)
{
return TiApplication.getInstance().getResources().getDrawable(res_id);
Context context = TiApplication.getAppCurrentActivity();
if (context == null) {
context = TiApplication.getInstance();
}
return context.getResources().getDrawable(res_id, context.getTheme());
}

public static Drawable getResourceDrawable(Object path)
Expand Down
Expand Up @@ -36,6 +36,7 @@
import org.appcelerator.titanium.util.TiUrl;

import android.app.Activity;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.res.Resources;
import android.graphics.Bitmap;
Expand Down Expand Up @@ -443,21 +444,21 @@ public Bitmap getBitmap(boolean needRetry, boolean densityScaled)
return bitmap;
}

private Resources getResources()
{
return TiApplication.getInstance().getResources();
}

private Drawable getResourceDrawable()
{
if (!isTypeResourceId()) {
return null;
}

Drawable drawable = null;
Resources resources = getResources();
Context context = TiApplication.getAppCurrentActivity();
if (context == null) {
context = TiApplication.getInstance();
}
Resources resources = context.getResources();
if (resources != null && resourceId > 0) {
try {
drawable = resources.getDrawable(resourceId);
drawable = resources.getDrawable(resourceId, context.getTheme());
} catch (Resources.NotFoundException e) {
drawable = null;
}
Expand Down

0 comments on commit f3c4057

Please sign in to comment.