Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(android): menu item icon wrongly ignores theme #13106

Merged
merged 2 commits into from
Oct 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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