Use ContextCompat.getDrawable

pull/209/head
M66B 3 years ago
parent 3f45339f9a
commit 4e3c9655af

@ -47,6 +47,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.cardview.widget.CardView; import androidx.cardview.widget.CardView;
import androidx.constraintlayout.widget.Group; import androidx.constraintlayout.widget.Group;
import androidx.core.content.ContextCompat;
import androidx.preference.PreferenceManager; import androidx.preference.PreferenceManager;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
@ -294,9 +295,9 @@ public class ActivityEML extends ActivityBase {
public Drawable getDrawable(Element img) { public Drawable getDrawable(Element img) {
Drawable d; Drawable d;
if (TextUtils.isEmpty(img.attr("x-tracking"))) if (TextUtils.isEmpty(img.attr("x-tracking")))
d = context.getDrawable(R.drawable.twotone_image_24); d = ContextCompat.getDrawable(context, R.drawable.twotone_image_24);
else { else {
d = context.getDrawable(R.drawable.twotone_my_location_24); d = ContextCompat.getDrawable(context, R.drawable.twotone_my_location_24);
d.setTint(Helper.resolveColor(context, R.attr.colorWarning)); d.setTint(Helper.resolveColor(context, R.attr.colorWarning));
} }
d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight()); d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());

@ -56,6 +56,7 @@ import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.PopupMenu; import androidx.appcompat.widget.PopupMenu;
import androidx.constraintlayout.widget.Group; import androidx.constraintlayout.widget.Group;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction; import androidx.fragment.app.FragmentTransaction;
@ -203,7 +204,7 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
ivSync.setImageResource(account.synchronize ? R.drawable.twotone_sync_24 : R.drawable.twotone_sync_disabled_24); ivSync.setImageResource(account.synchronize ? R.drawable.twotone_sync_24 : R.drawable.twotone_sync_disabled_24);
ivSync.setContentDescription(context.getString(account.synchronize ? R.string.title_legend_synchronize_on : R.string.title_legend_synchronize_off)); ivSync.setContentDescription(context.getString(account.synchronize ? R.string.title_legend_synchronize_on : R.string.title_legend_synchronize_off));
ivOAuth.setImageDrawable(context.getDrawable(account.auth_type == AUTH_TYPE_GMAIL ivOAuth.setImageDrawable(ContextCompat.getDrawable(context, account.auth_type == AUTH_TYPE_GMAIL
? R.drawable.twotone_android_24 : R.drawable.twotone_security_24)); ? R.drawable.twotone_android_24 : R.drawable.twotone_security_24));
ivOAuth.setVisibility( ivOAuth.setVisibility(
settings && account.auth_type != AUTH_TYPE_PASSWORD ? View.VISIBLE : View.GONE); settings && account.auth_type != AUTH_TYPE_PASSWORD ? View.VISIBLE : View.GONE);

@ -116,6 +116,7 @@ import androidx.appcompat.widget.PopupMenu;
import androidx.constraintlayout.helper.widget.Flow; import androidx.constraintlayout.helper.widget.Flow;
import androidx.constraintlayout.widget.ConstraintLayout; import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.constraintlayout.widget.Group; import androidx.constraintlayout.widget.Group;
import androidx.core.content.ContextCompat;
import androidx.core.content.FileProvider; import androidx.core.content.FileProvider;
import androidx.core.content.pm.ShortcutInfoCompat; import androidx.core.content.pm.ShortcutInfoCompat;
import androidx.core.graphics.ColorUtils; import androidx.core.graphics.ColorUtils;
@ -2937,7 +2938,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
new DynamicDrawableSpan() { new DynamicDrawableSpan() {
@Override @Override
public Drawable getDrawable() { public Drawable getDrawable() {
Drawable d = context.getDrawable(R.drawable.twotone_format_quote_24); Drawable d = ContextCompat.getDrawable(context, R.drawable.twotone_format_quote_24);
d.setTint(colorAccent); d.setTint(colorAccent);
d.setBounds(0, 0, px, px); d.setBounds(0, 0, px, px);
return d; return d;

@ -47,6 +47,7 @@ import android.view.View;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.widget.AppCompatMultiAutoCompleteTextView; import androidx.appcompat.widget.AppCompatMultiAutoCompleteTextView;
import androidx.core.content.ContextCompat;
import androidx.core.graphics.ColorUtils; import androidx.core.graphics.ColorUtils;
import androidx.preference.PreferenceManager; import androidx.preference.PreferenceManager;
@ -359,7 +360,7 @@ public class EditTextMultiAutoComplete extends AppCompatMultiAutoCompleteTextVie
} }
}); });
} else if (has != 0) { } else if (has != 0) {
cd.setCloseIcon(context.getDrawable(icons[has - 1])); cd.setCloseIcon(ContextCompat.getDrawable(context, icons[has - 1]));
cd.setCloseIconVisible(true); cd.setCloseIconVisible(true);
} }

@ -125,6 +125,7 @@ import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.PopupMenu; import androidx.appcompat.widget.PopupMenu;
import androidx.appcompat.widget.SwitchCompat; import androidx.appcompat.widget.SwitchCompat;
import androidx.constraintlayout.widget.Group; import androidx.constraintlayout.widget.Group;
import androidx.core.content.ContextCompat;
import androidx.core.content.FileProvider; import androidx.core.content.FileProvider;
import androidx.core.view.MenuCompat; import androidx.core.view.MenuCompat;
import androidx.core.view.WindowInsetsCompat; import androidx.core.view.WindowInsetsCompat;
@ -3150,7 +3151,7 @@ public class FragmentCompose extends FragmentBase {
if (d == null) { if (d == null) {
int px = Helper.dp2pixels(context, (zoom + 1) * 24); int px = Helper.dp2pixels(context, (zoom + 1) * 24);
d = context.getDrawable(R.drawable.twotone_broken_image_24); d = ContextCompat.getDrawable(context, R.drawable.twotone_broken_image_24);
d.setBounds(0, 0, px, px); d.setBounds(0, 0, px, px);
} }

@ -41,6 +41,7 @@ import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
import androidx.core.content.ContextCompat;
import androidx.lifecycle.Observer; import androidx.lifecycle.Observer;
import androidx.localbroadcastmanager.content.LocalBroadcastManager; import androidx.localbroadcastmanager.content.LocalBroadcastManager;
@ -68,8 +69,8 @@ public class FragmentDialogAccount extends FragmentDialogBase {
final Button btnAccount = dview.findViewById(R.id.btnAccount); final Button btnAccount = dview.findViewById(R.id.btnAccount);
final Button btnGmail = dview.findViewById(R.id.btnGmail); final Button btnGmail = dview.findViewById(R.id.btnGmail);
final Drawable check = context.getDrawable(R.drawable.twotone_check_24); final Drawable check = ContextCompat.getDrawable(context, R.drawable.twotone_check_24);
final Drawable close = context.getDrawable(R.drawable.twotone_close_24); final Drawable close = ContextCompat.getDrawable(context, R.drawable.twotone_close_24);
check.setBounds(0, 0, check.getIntrinsicWidth(), check.getIntrinsicHeight()); check.setBounds(0, 0, check.getIntrinsicWidth(), check.getIntrinsicHeight());
close.setBounds(0, 0, close.getIntrinsicWidth(), close.getIntrinsicHeight()); close.setBounds(0, 0, close.getIntrinsicWidth(), close.getIntrinsicHeight());

@ -37,6 +37,7 @@ import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
import androidx.core.content.ContextCompat;
import androidx.preference.PreferenceManager; import androidx.preference.PreferenceManager;
public class FragmentDialogAsk extends FragmentDialogBase { public class FragmentDialogAsk extends FragmentDialogBase {
@ -72,7 +73,7 @@ public class FragmentDialogAsk extends FragmentDialogBase {
ibInfo.setVisibility(faq == 0 ? View.GONE : View.VISIBLE); ibInfo.setVisibility(faq == 0 ? View.GONE : View.VISIBLE);
if (warning) { if (warning) {
Drawable w = context.getDrawable(R.drawable.twotone_warning_24); Drawable w = ContextCompat.getDrawable(context, R.drawable.twotone_warning_24);
w.setBounds(0, 0, w.getIntrinsicWidth(), w.getIntrinsicHeight()); w.setBounds(0, 0, w.getIntrinsicWidth(), w.getIntrinsicHeight());
w.setTint(colorError); w.setTint(colorError);
tvMessage.setCompoundDrawablesRelative(w, null, null, null); tvMessage.setCompoundDrawablesRelative(w, null, null, null);

@ -69,6 +69,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
import androidx.constraintlayout.widget.Group; import androidx.constraintlayout.widget.Group;
import androidx.core.content.ContextCompat;
import androidx.core.net.MailTo; import androidx.core.net.MailTo;
import androidx.core.util.PatternsCompat; import androidx.core.util.PatternsCompat;
import androidx.lifecycle.Lifecycle; import androidx.lifecycle.Lifecycle;
@ -587,7 +588,7 @@ public class FragmentDialogOpenLink extends FragmentDialogBase {
} }
} }
Drawable android = context.getDrawable(R.drawable.android_robot); Drawable android = ContextCompat.getDrawable(context, R.drawable.android_robot);
android.setBounds(0, 0, dp24, dp24); android.setBounds(0, 0, dp24, dp24);
pkgs.add(new Package( pkgs.add(new Package(
android, android,
@ -782,10 +783,10 @@ public class FragmentDialogOpenLink extends FragmentDialogBase {
super(context, 0, pkgs); super(context, 0, pkgs);
this.context = context; this.context = context;
this.pkgs = pkgs; this.pkgs = pkgs;
this.external = context.getDrawable(R.drawable.twotone_open_in_new_24); this.external = ContextCompat.getDrawable(context, R.drawable.twotone_open_in_new_24);
if (external != null) if (external != null)
external.setBounds(0, 0, external.getIntrinsicWidth(), external.getIntrinsicHeight()); external.setBounds(0, 0, external.getIntrinsicWidth(), external.getIntrinsicHeight());
this.browser = context.getDrawable(R.drawable.twotone_language_24); this.browser = ContextCompat.getDrawable(context, R.drawable.twotone_language_24);
if (browser != null) if (browser != null)
browser.setBounds(0, 0, browser.getIntrinsicWidth(), browser.getIntrinsicHeight()); browser.setBounds(0, 0, browser.getIntrinsicWidth(), browser.getIntrinsicHeight());
} }

@ -52,6 +52,7 @@ import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
import androidx.core.content.ContextCompat;
import androidx.preference.PreferenceManager; import androidx.preference.PreferenceManager;
import org.jsoup.nodes.Document; import org.jsoup.nodes.Document;
@ -156,7 +157,7 @@ public class FragmentDialogTranslate extends FragmentDialogBase {
if (language != null) { if (language != null) {
TextView tv = view.findViewById(android.R.id.text1); TextView tv = view.findViewById(android.R.id.text1);
Drawable icon = context.getDrawable(language.icon); Drawable icon = ContextCompat.getDrawable(context, language.icon);
int iconSize = context.getResources() int iconSize = context.getResources()
.getDimensionPixelSize(R.dimen.menu_item_icon_size); .getDimensionPixelSize(R.dimen.menu_item_icon_size);
icon.setBounds(0, 0, iconSize, iconSize); icon.setBounds(0, 0, iconSize, iconSize);

@ -132,6 +132,7 @@ import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.PopupMenu; import androidx.appcompat.widget.PopupMenu;
import androidx.cardview.widget.CardView; import androidx.cardview.widget.CardView;
import androidx.constraintlayout.widget.Group; import androidx.constraintlayout.widget.Group;
import androidx.core.content.ContextCompat;
import androidx.core.graphics.ColorUtils; import androidx.core.graphics.ColorUtils;
import androidx.core.view.MenuCompat; import androidx.core.view.MenuCompat;
import androidx.core.view.MenuItemCompat; import androidx.core.view.MenuItemCompat;
@ -2683,7 +2684,7 @@ public class FragmentMessages extends FragmentBase
else else
icon = EntityFolder.getIcon(dX > 0 ? swipes.right_type : swipes.left_type); icon = EntityFolder.getIcon(dX > 0 ? swipes.right_type : swipes.left_type);
Drawable d = context.getDrawable(icon).mutate(); Drawable d = ContextCompat.getDrawable(context, icon).mutate();
d.setTint(Helper.resolveColor(context, android.R.attr.textColorSecondary)); d.setTint(Helper.resolveColor(context, android.R.attr.textColorSecondary));
int half = rect.width() / 2; int half = rect.width() / 2;
@ -5999,7 +6000,7 @@ public class FragmentMessages extends FragmentBase
tvSelectedCount.setText(NF.format(count)); tvSelectedCount.setText(NF.format(count));
if (count > (BuildConfig.DEBUG ? 10 : MAX_MORE)) { if (count > (BuildConfig.DEBUG ? 10 : MAX_MORE)) {
int ts = Math.round(tvSelectedCount.getTextSize()); int ts = Math.round(tvSelectedCount.getTextSize());
Drawable w = context.getDrawable(R.drawable.twotone_warning_24); Drawable w = ContextCompat.getDrawable(context, R.drawable.twotone_warning_24);
w.setBounds(0, 0, ts, ts); w.setBounds(0, 0, ts, ts);
w.setTint(tvSelectedCount.getCurrentTextColor()); w.setTint(tvSelectedCount.getCurrentTextColor());
tvSelectedCount.setCompoundDrawablesRelative(null, null, w, null); tvSelectedCount.setCompoundDrawablesRelative(null, null, w, null);
@ -10443,20 +10444,20 @@ public class FragmentMessages extends FragmentBase
Drawable source = null; Drawable source = null;
if (sources.size() == 1) { if (sources.size() == 1) {
source = context.getDrawable(EntityFolder.getIcon(sources.get(0))); source = ContextCompat.getDrawable(context, EntityFolder.getIcon(sources.get(0)));
if (source != null) if (source != null)
source.setBounds(0, 0, source.getIntrinsicWidth(), source.getIntrinsicHeight()); source.setBounds(0, 0, source.getIntrinsicWidth(), source.getIntrinsicHeight());
if (sourceColor == null) if (sourceColor == null)
sourceColor = EntityFolder.getDefaultColor(sources.get(0), context); sourceColor = EntityFolder.getDefaultColor(sources.get(0), context);
} else { } else {
source = context.getDrawable(R.drawable.twotone_folders_24); source = ContextCompat.getDrawable(context, R.drawable.twotone_folders_24);
source.setBounds(0, 0, source.getIntrinsicWidth(), source.getIntrinsicHeight()); source.setBounds(0, 0, source.getIntrinsicWidth(), source.getIntrinsicHeight());
sourceColor = null; sourceColor = null;
} }
Drawable target = null; Drawable target = null;
if (targets.size() == 1) { if (targets.size() == 1) {
target = context.getDrawable(EntityFolder.getIcon(targets.get(0))); target = ContextCompat.getDrawable(context, EntityFolder.getIcon(targets.get(0)));
if (target != null) if (target != null)
target.setBounds(0, 0, target.getIntrinsicWidth(), target.getIntrinsicHeight()); target.setBounds(0, 0, target.getIntrinsicWidth(), target.getIntrinsicHeight());
if (targetColor == null) if (targetColor == null)

@ -53,6 +53,7 @@ import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.Group; import androidx.constraintlayout.widget.Group;
import androidx.core.content.ContextCompat;
import androidx.lifecycle.Lifecycle; import androidx.lifecycle.Lifecycle;
import androidx.preference.PreferenceManager; import androidx.preference.PreferenceManager;
@ -197,7 +198,7 @@ public class FragmentOAuth extends FragmentBase {
final boolean dark = Helper.isDarkTheme(context); final boolean dark = Helper.isDarkTheme(context);
int dp12 = Helper.dp2pixels(context, 12); int dp12 = Helper.dp2pixels(context, 12);
int dp24 = Helper.dp2pixels(context, 24); int dp24 = Helper.dp2pixels(context, 24);
Drawable g = context.getDrawable(R.drawable.google_logo); Drawable g = ContextCompat.getDrawable(context, R.drawable.google_logo);
g.setBounds(0, 0, g.getIntrinsicWidth(), g.getIntrinsicHeight()); g.setBounds(0, 0, g.getIntrinsicWidth(), g.getIntrinsicHeight());
btnOAuth.setCompoundDrawablesRelative(g, null, null, null); btnOAuth.setCompoundDrawablesRelative(g, null, null, null);
btnOAuth.setCompoundDrawablePadding(dp24); btnOAuth.setCompoundDrawablePadding(dp24);
@ -212,7 +213,7 @@ public class FragmentOAuth extends FragmentBase {
Color.LTGRAY // 0xffcccccc Color.LTGRAY // 0xffcccccc
} }
)); ));
btnOAuth.setBackground(context.getDrawable(dark btnOAuth.setBackground(ContextCompat.getDrawable(context, dark
? R.drawable.google_signin_background_dark ? R.drawable.google_signin_background_dark
: R.drawable.google_signin_background_light)); : R.drawable.google_signin_background_light));
btnOAuth.setPaddingRelative(dp12, 0, dp12, 0); btnOAuth.setPaddingRelative(dp12, 0, dp12, 0);

@ -43,6 +43,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.SearchView; import androidx.appcompat.widget.SearchView;
import androidx.core.content.ContextCompat;
import androidx.cursoradapter.widget.CursorAdapter; import androidx.cursoradapter.widget.CursorAdapter;
import androidx.cursoradapter.widget.SimpleCursorAdapter; import androidx.cursoradapter.widget.SimpleCursorAdapter;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
@ -240,7 +241,7 @@ public class FragmentOptions extends FragmentBase {
final Context context = getContext(); final Context context = getContext();
int colorAccent = Helper.resolveColor(context, R.attr.colorAccent); int colorAccent = Helper.resolveColor(context, R.attr.colorAccent);
for (int i = 0; i < tabLayout.getTabCount(); i++) { for (int i = 0; i < tabLayout.getTabCount(); i++) {
Drawable d = context.getDrawable(PAGE_ICONS[i]); Drawable d = ContextCompat.getDrawable(context, PAGE_ICONS[i]);
d.setColorFilter(colorAccent, PorterDuff.Mode.SRC_ATOP); d.setColorFilter(colorAccent, PorterDuff.Mode.SRC_ATOP);
SpannableStringBuilder title = new SpannableStringBuilderEx(getString(PAGE_TITLES[i])); SpannableStringBuilder title = new SpannableStringBuilderEx(getString(PAGE_TITLES[i]));
if (i > 0) if (i > 0)

@ -61,6 +61,7 @@ import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.PopupMenu; import androidx.appcompat.widget.PopupMenu;
import androidx.cardview.widget.CardView; import androidx.cardview.widget.CardView;
import androidx.constraintlayout.widget.Group; import androidx.constraintlayout.widget.Group;
import androidx.core.content.ContextCompat;
import androidx.core.view.MenuCompat; import androidx.core.view.MenuCompat;
import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentActivity;
import androidx.lifecycle.Lifecycle; import androidx.lifecycle.Lifecycle;
@ -1075,7 +1076,7 @@ public class FragmentSetup extends FragmentBase {
final Context context = getContext(); final Context context = getContext();
Drawable d = context.getDrawable(R.drawable.twotone_warning_24); Drawable d = ContextCompat.getDrawable(context, R.drawable.twotone_warning_24);
d.mutate(); d.mutate();
d.setTint(Helper.resolveColor(context, R.attr.colorWarning)); d.setTint(Helper.resolveColor(context, R.attr.colorWarning));

@ -64,6 +64,7 @@ import android.view.View;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.core.content.FileProvider; import androidx.core.content.FileProvider;
import androidx.core.content.res.ResourcesCompat; import androidx.core.content.res.ResourcesCompat;
import androidx.core.graphics.ColorUtils; import androidx.core.graphics.ColorUtils;
@ -2234,7 +2235,7 @@ public class HtmlHelper {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean disconnect_images = (prefs.getBoolean("disconnect_images", false) && BuildConfig.DEBUG); boolean disconnect_images = (prefs.getBoolean("disconnect_images", false) && BuildConfig.DEBUG);
Drawable d = context.getDrawable(R.drawable.twotone_my_location_24); Drawable d = ContextCompat.getDrawable(context, R.drawable.twotone_my_location_24);
d.setTint(Helper.resolveColor(context, R.attr.colorWarning)); d.setTint(Helper.resolveColor(context, R.attr.colorWarning));
Bitmap bm = Bitmap.createBitmap(d.getIntrinsicWidth(), d.getIntrinsicHeight(), Bitmap.Config.ARGB_8888); Bitmap bm = Bitmap.createBitmap(d.getIntrinsicWidth(), d.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
@ -2818,7 +2819,7 @@ public class HtmlHelper {
ssb.setSpan(new StyleSpan(Typeface.BOLD), s, ssb.length(), 0); ssb.setSpan(new StyleSpan(Typeface.BOLD), s, ssb.length(), 0);
if (blocklist && i == received.length - 1) { if (blocklist && i == received.length - 1) {
Drawable d = context.getDrawable(R.drawable.twotone_flag_24); Drawable d = ContextCompat.getDrawable(context, R.drawable.twotone_flag_24);
int iconSize = context.getResources().getDimensionPixelSize(R.dimen.menu_item_icon_size); int iconSize = context.getResources().getDimensionPixelSize(R.dimen.menu_item_icon_size);
d.setBounds(0, 0, iconSize, iconSize); d.setBounds(0, 0, iconSize, iconSize);
@ -3474,7 +3475,7 @@ public class HtmlHelper {
String src = element.attr("src"); String src = element.attr("src");
if (!TextUtils.isEmpty(src)) { if (!TextUtils.isEmpty(src)) {
Drawable d = (imageGetter == null Drawable d = (imageGetter == null
? context.getDrawable(R.drawable.twotone_broken_image_24) ? ContextCompat.getDrawable(context, R.drawable.twotone_broken_image_24)
: imageGetter.getDrawable(element)); : imageGetter.getDrawable(element));
ssb.insert(start, "\uFFFC"); // Object replacement character ssb.insert(start, "\uFFFC"); // Object replacement character
setSpan(ssb, new ImageSpanEx(d, element), start, start + 1); setSpan(ssb, new ImageSpanEx(d, element), start, start + 1);

@ -53,6 +53,7 @@ import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi; import androidx.annotation.RequiresApi;
import androidx.core.content.ContextCompat;
import androidx.core.graphics.ColorUtils; import androidx.core.graphics.ColorUtils;
import androidx.exifinterface.media.ExifInterface; import androidx.exifinterface.media.ExifInterface;
import androidx.preference.PreferenceManager; import androidx.preference.PreferenceManager;
@ -331,7 +332,7 @@ class ImageHelper {
try { try {
if (TextUtils.isEmpty(source)) { if (TextUtils.isEmpty(source)) {
Drawable d = context.getDrawable(R.drawable.twotone_broken_image_24); Drawable d = ContextCompat.getDrawable(context, R.drawable.twotone_broken_image_24);
d.setBounds(0, 0, px, px); d.setBounds(0, 0, px, px);
return d; return d;
} }
@ -349,12 +350,12 @@ class ImageHelper {
EntityAttachment attachment = db.attachment().getAttachment(id, cid); EntityAttachment attachment = db.attachment().getAttachment(id, cid);
if (attachment == null) { if (attachment == null) {
Log.i("Image not found CID=" + cid); Log.i("Image not found CID=" + cid);
Drawable d = context.getDrawable(R.drawable.twotone_broken_image_24); Drawable d = ContextCompat.getDrawable(context, R.drawable.twotone_broken_image_24);
d.setBounds(0, 0, px, px); d.setBounds(0, 0, px, px);
return d; return d;
} else if (!attachment.available) { } else if (!attachment.available) {
Log.i("Image not available CID=" + cid); Log.i("Image not available CID=" + cid);
Drawable d = context.getDrawable(R.drawable.twotone_photo_library_24); Drawable d = ContextCompat.getDrawable(context, R.drawable.twotone_photo_library_24);
d.setBounds(0, 0, px, px); d.setBounds(0, 0, px, px);
return d; return d;
} else { } else {
@ -370,7 +371,7 @@ class ImageHelper {
return d; return d;
} catch (IOException ex) { } catch (IOException ex) {
Log.w(ex); Log.w(ex);
Drawable d = context.getDrawable(R.drawable.twotone_broken_image_24); Drawable d = ContextCompat.getDrawable(context, R.drawable.twotone_broken_image_24);
d.setBounds(0, 0, px, px); d.setBounds(0, 0, px, px);
return d; return d;
} }
@ -381,7 +382,7 @@ class ImageHelper {
scaleToPixels); scaleToPixels);
if (bm == null) { if (bm == null) {
Log.i("Image not decodable CID=" + cid); Log.i("Image not decodable CID=" + cid);
Drawable d = context.getDrawable(R.drawable.twotone_broken_image_24); Drawable d = ContextCompat.getDrawable(context, R.drawable.twotone_broken_image_24);
d.setBounds(0, 0, px, px); d.setBounds(0, 0, px, px);
return d; return d;
} else { } else {
@ -413,7 +414,7 @@ class ImageHelper {
return d; return d;
} catch (IllegalArgumentException ex) { } catch (IllegalArgumentException ex) {
Log.i(ex); Log.i(ex);
Drawable d = context.getDrawable(R.drawable.twotone_broken_image_24); Drawable d = ContextCompat.getDrawable(context, R.drawable.twotone_broken_image_24);
d.setBounds(0, 0, px, px); d.setBounds(0, 0, px, px);
return d; return d;
} }
@ -442,7 +443,7 @@ class ImageHelper {
} catch (Throwable ex) { } catch (Throwable ex) {
// FileNotFound, Security // FileNotFound, Security
Log.w(ex); Log.w(ex);
Drawable d = context.getDrawable(R.drawable.twotone_broken_image_24); Drawable d = ContextCompat.getDrawable(context, R.drawable.twotone_broken_image_24);
d.setBounds(0, 0, px, px); d.setBounds(0, 0, px, px);
return d; return d;
} }
@ -450,7 +451,7 @@ class ImageHelper {
if (!show) { if (!show) {
// Show placeholder icon // Show placeholder icon
int resid = (embedded || data ? R.drawable.twotone_photo_library_24 : R.drawable.twotone_image_24); int resid = (embedded || data ? R.drawable.twotone_photo_library_24 : R.drawable.twotone_image_24);
Drawable d = context.getDrawable(resid); Drawable d = ContextCompat.getDrawable(context, resid);
d.setBounds(0, 0, px, px); d.setBounds(0, 0, px, px);
return d; return d;
} }
@ -460,7 +461,7 @@ class ImageHelper {
if (cached != null || view == null) { if (cached != null || view == null) {
if (view == null) if (view == null)
if (cached == null) { if (cached == null) {
Drawable d = context.getDrawable(R.drawable.twotone_hourglass_top_24); Drawable d = ContextCompat.getDrawable(context, R.drawable.twotone_hourglass_top_24);
d.setBounds(0, 0, px, px); d.setBounds(0, 0, px, px);
return d; return d;
} else } else
@ -471,7 +472,7 @@ class ImageHelper {
} }
final LevelListDrawable lld = new LevelListDrawable(); final LevelListDrawable lld = new LevelListDrawable();
Drawable wait = context.getDrawable(R.drawable.twotone_hourglass_top_24); Drawable wait = ContextCompat.getDrawable(context, R.drawable.twotone_hourglass_top_24);
lld.addLevel(1, 1, wait); lld.addLevel(1, 1, wait);
lld.setBounds(0, 0, px, px); lld.setBounds(0, 0, px, px);
lld.setLevel(1); lld.setLevel(1);
@ -522,7 +523,7 @@ class ImageHelper {
int resid = (ex instanceof IOException && !(ex instanceof FileNotFoundException) int resid = (ex instanceof IOException && !(ex instanceof FileNotFoundException)
? R.drawable.twotone_cloud_off_24 ? R.drawable.twotone_cloud_off_24
: R.drawable.twotone_broken_image_24); : R.drawable.twotone_broken_image_24);
Drawable d = context.getDrawable(resid); Drawable d = ContextCompat.getDrawable(context, resid);
d.setBounds(0, 0, px, px); d.setBounds(0, 0, px, px);
post(d, source); post(d, source);
} }
@ -558,7 +559,7 @@ class ImageHelper {
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(ex); Log.e(ex);
Drawable d = context.getDrawable(R.drawable.twotone_broken_image_24); Drawable d = ContextCompat.getDrawable(context, R.drawable.twotone_broken_image_24);
d.setBounds(0, 0, px, px); d.setBounds(0, 0, px, px);
return d; return d;
} }

@ -41,6 +41,7 @@ import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.core.app.Person; import androidx.core.app.Person;
import androidx.core.content.ContextCompat;
import androidx.core.content.pm.ShortcutInfoCompat; import androidx.core.content.pm.ShortcutInfoCompat;
import androidx.core.content.pm.ShortcutManagerCompat; import androidx.core.content.pm.ShortcutManagerCompat;
import androidx.core.graphics.drawable.IconCompat; import androidx.core.graphics.drawable.IconCompat;
@ -293,7 +294,7 @@ class Shortcuts {
bm = contactInfo[0].getPhotoBitmap(); bm = contactInfo[0].getPhotoBitmap();
else { else {
int resid = R.drawable.baseline_mail_24; int resid = R.drawable.baseline_mail_24;
Drawable d = context.getDrawable(resid); Drawable d = ContextCompat.getDrawable(context, resid);
bm = Bitmap.createBitmap( bm = Bitmap.createBitmap(
d.getIntrinsicWidth(), d.getIntrinsicWidth(),
d.getIntrinsicHeight(), d.getIntrinsicHeight(),
@ -326,7 +327,7 @@ class Shortcuts {
view.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); view.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
int resid = EntityFolder.getIcon(folder.type); int resid = EntityFolder.getIcon(folder.type);
Drawable d = context.getDrawable(resid); Drawable d = ContextCompat.getDrawable(context, resid);
Bitmap bm = Bitmap.createBitmap( Bitmap bm = Bitmap.createBitmap(
d.getIntrinsicWidth(), d.getIntrinsicWidth(),
d.getIntrinsicHeight(), d.getIntrinsicHeight(),

Loading…
Cancel
Save