From 87d94aef0d498b0b35dfcd84f1f6676d797375b7 Mon Sep 17 00:00:00 2001 From: Andreas Schildbach Date: Sat, 21 Nov 2020 14:11:50 +0100 Subject: [PATCH] PlanActivity: Remove image from toast. It won't work with targetSdkVersion 30. --- .../ic_info_outline_white_24dp.xml | 11 -------- .../schildbach/oeffi/plans/PlanActivity.java | 3 +-- oeffi/src/de/schildbach/oeffi/util/Toast.java | 27 +++++-------------- 3 files changed, 8 insertions(+), 33 deletions(-) delete mode 100644 oeffi/res/drawable-anydpi/ic_info_outline_white_24dp.xml diff --git a/oeffi/res/drawable-anydpi/ic_info_outline_white_24dp.xml b/oeffi/res/drawable-anydpi/ic_info_outline_white_24dp.xml deleted file mode 100644 index e0c3355..0000000 --- a/oeffi/res/drawable-anydpi/ic_info_outline_white_24dp.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - diff --git a/oeffi/src/de/schildbach/oeffi/plans/PlanActivity.java b/oeffi/src/de/schildbach/oeffi/plans/PlanActivity.java index ab82358..900fb72 100644 --- a/oeffi/src/de/schildbach/oeffi/plans/PlanActivity.java +++ b/oeffi/src/de/schildbach/oeffi/plans/PlanActivity.java @@ -367,8 +367,7 @@ public class PlanActivity extends Activity { viewAnimator.setDisplayedChild(1); if (!stations.isEmpty()) { - new Toast(PlanActivity.this).imageToast(R.drawable.ic_info_outline_white_24dp, - R.string.toast_plan_interactive_hint); + new Toast(PlanActivity.this).toast(R.string.toast_plan_interactive_hint); plan.setStationsAware(new StationsAware() { public List getStations() { diff --git a/oeffi/src/de/schildbach/oeffi/util/Toast.java b/oeffi/src/de/schildbach/oeffi/util/Toast.java index 8729eaa..e823108 100644 --- a/oeffi/src/de/schildbach/oeffi/util/Toast.java +++ b/oeffi/src/de/schildbach/oeffi/util/Toast.java @@ -30,41 +30,28 @@ public class Toast { } public final void toast(final int textResId, final Object... formatArgs) { - customToast(0, textResId, android.widget.Toast.LENGTH_SHORT, formatArgs); + customToast(textResId, android.widget.Toast.LENGTH_SHORT, formatArgs); } public final void toast(final CharSequence text) { - customToast(0, text, android.widget.Toast.LENGTH_SHORT); + customToast(text, android.widget.Toast.LENGTH_SHORT); } public final void longToast(final int textResId, final Object... formatArgs) { - customToast(0, textResId, android.widget.Toast.LENGTH_LONG, formatArgs); + customToast(textResId, android.widget.Toast.LENGTH_LONG, formatArgs); } public final void longToast(final CharSequence text) { - customToast(0, text, android.widget.Toast.LENGTH_LONG); + customToast(text, android.widget.Toast.LENGTH_LONG); } - public final void imageToast(final int imageResId, final int textResId, final Object... formatArgs) { - customToast(imageResId, textResId, android.widget.Toast.LENGTH_LONG, formatArgs); - } - - private void customToast(final int imageResId, final int textResId, final int duration, + private void customToast(final int textResId, final int duration, final Object... formatArgs) { - customToast(imageResId, context.getString(textResId, formatArgs), duration); + customToast(context.getString(textResId, formatArgs), duration); } - private void customToast(final int imageResId, final CharSequence text, final int duration) { + private void customToast(final CharSequence text, final int duration) { final android.widget.Toast toast = android.widget.Toast.makeText(context, text, duration); - final TextView toastText = toast.getView().findViewById(android.R.id.message); - if (imageResId != 0 && toastText != null) { - toastText.setCompoundDrawablesWithIntrinsicBounds(imageResId, 0, 0, 0); - toastText.setCompoundDrawablePadding( - context.getResources().getDimensionPixelOffset(R.dimen.list_entry_padding_horizontal_verylax)); - // tint - final int textColor = toastText.getTextColors().getDefaultColor(); - toastText.getCompoundDrawables()[0].setColorFilter(textColor, PorterDuff.Mode.SRC_IN); - } toast.show(); } }