From d51e9c7625e0cf1d72c17e908312b7dd42363622 Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Thu, 15 Apr 2021 21:21:31 +0200 Subject: Use VectorDrawable compat library --- .../de/danoeh/antennapod/adapter/NavListAdapter.java | 16 ++++++---------- .../adapter/actionbutton/ItemActionButton.java | 7 ++----- .../java/de/danoeh/antennapod/view/EmptyViewHandler.java | 9 ++------- app/src/main/res/layout/activity_widget_config.xml | 3 ++- app/src/main/res/layout/audioplayer_fragment.xml | 2 +- app/src/main/res/layout/edit_tags_dialog.xml | 3 ++- app/src/main/res/layout/feeditemlist_item.xml | 2 +- app/src/main/res/layout/gpodnetauth_credentials.xml | 3 ++- app/src/main/res/layout/gpodnetauth_finish.xml | 3 ++- app/src/main/res/layout/nav_list.xml | 4 ++-- 10 files changed, 22 insertions(+), 30 deletions(-) (limited to 'app/src') diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java index 911e20aa5..8d7add297 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java @@ -3,10 +3,9 @@ package de.danoeh.antennapod.adapter; import android.app.Activity; import android.content.Intent; import android.content.SharedPreferences; -import android.content.res.TypedArray; -import android.graphics.drawable.Drawable; import android.view.ContextMenu; import android.view.LayoutInflater; +import androidx.annotation.DrawableRes; import androidx.annotation.NonNull; import androidx.preference.PreferenceManager; import android.util.TypedValue; @@ -109,10 +108,10 @@ public class NavListAdapter extends RecyclerView.Adapter return titles[index]; } - private Drawable getDrawable(String tag) { + private @DrawableRes int getDrawable(String tag) { Activity context = activity.get(); if (context == null) { - return null; + return 0; } int icon; switch (tag) { @@ -135,12 +134,9 @@ public class NavListAdapter extends RecyclerView.Adapter icon = R.attr.content_new; break; default: - return null; + return 0; } - TypedArray ta = context.obtainStyledAttributes(new int[] { icon }); - Drawable result = ta.getDrawable(0); - ta.recycle(); - return result; + return ThemeUtils.getDrawableFromAttr(context, icon); } public List getFragmentTags() { @@ -283,7 +279,7 @@ public class NavListAdapter extends RecyclerView.Adapter } } - holder.image.setImageDrawable(getDrawable(fragmentTags.get(position))); + holder.image.setImageResource(getDrawable(fragmentTags.get(position))); } private void bindSectionDivider(DividerHolder holder) { diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/actionbutton/ItemActionButton.java b/app/src/main/java/de/danoeh/antennapod/adapter/actionbutton/ItemActionButton.java index 5d95d3775..35f0a717f 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/actionbutton/ItemActionButton.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/actionbutton/ItemActionButton.java @@ -1,7 +1,6 @@ package de.danoeh.antennapod.adapter.actionbutton; import android.content.Context; -import android.content.res.TypedArray; import android.widget.ImageView; import androidx.annotation.AttrRes; import androidx.annotation.NonNull; @@ -12,6 +11,7 @@ import de.danoeh.antennapod.core.feed.FeedItem; import de.danoeh.antennapod.core.feed.FeedMedia; import de.danoeh.antennapod.core.preferences.UserPreferences; import de.danoeh.antennapod.core.storage.DownloadRequester; +import de.danoeh.antennapod.ui.common.ThemeUtils; public abstract class ItemActionButton { FeedItem item; @@ -62,9 +62,6 @@ public abstract class ItemActionButton { button.setVisibility(getVisibility()); button.setContentDescription(context.getString(getLabel())); button.setOnClickListener((view) -> onClick(context)); - - TypedArray drawables = context.obtainStyledAttributes(new int[]{getDrawable()}); - icon.setImageDrawable(drawables.getDrawable(0)); - drawables.recycle(); + icon.setImageResource(ThemeUtils.getDrawableFromAttr(context, getDrawable())); } } diff --git a/app/src/main/java/de/danoeh/antennapod/view/EmptyViewHandler.java b/app/src/main/java/de/danoeh/antennapod/view/EmptyViewHandler.java index eaad11d1a..d4bf44aa5 100644 --- a/app/src/main/java/de/danoeh/antennapod/view/EmptyViewHandler.java +++ b/app/src/main/java/de/danoeh/antennapod/view/EmptyViewHandler.java @@ -2,15 +2,12 @@ package de.danoeh.antennapod.view; import android.content.Context; import android.database.DataSetObserver; -import android.graphics.drawable.Drawable; import android.view.Gravity; import android.widget.AbsListView; import android.widget.FrameLayout; import android.widget.ListAdapter; import androidx.annotation.AttrRes; -import androidx.core.content.ContextCompat; import androidx.recyclerview.widget.RecyclerView; -import android.util.TypedValue; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; @@ -18,6 +15,7 @@ import android.widget.RelativeLayout; import android.widget.TextView; import de.danoeh.antennapod.R; +import de.danoeh.antennapod.ui.common.ThemeUtils; public class EmptyViewHandler { private boolean layoutAdded = false; @@ -52,10 +50,7 @@ public class EmptyViewHandler { } public void setIcon(@AttrRes int iconAttr) { - TypedValue typedValue = new TypedValue(); - context.getTheme().resolveAttribute(iconAttr, typedValue, true); - Drawable d = ContextCompat.getDrawable(context, typedValue.resourceId); - ivIcon.setImageDrawable(d); + ivIcon.setImageResource(ThemeUtils.getDrawableFromAttr(context, iconAttr)); ivIcon.setVisibility(View.VISIBLE); } diff --git a/app/src/main/res/layout/activity_widget_config.xml b/app/src/main/res/layout/activity_widget_config.xml index 6e31aec0d..8c540fcc6 100644 --- a/app/src/main/res/layout/activity_widget_config.xml +++ b/app/src/main/res/layout/activity_widget_config.xml @@ -1,6 +1,7 @@ diff --git a/app/src/main/res/layout/edit_tags_dialog.xml b/app/src/main/res/layout/edit_tags_dialog.xml index e83cce9cf..9fb6292b2 100644 --- a/app/src/main/res/layout/edit_tags_dialog.xml +++ b/app/src/main/res/layout/edit_tags_dialog.xml @@ -1,5 +1,6 @@ diff --git a/app/src/main/res/layout/feeditemlist_item.xml b/app/src/main/res/layout/feeditemlist_item.xml index e1f382e46..63092cfb3 100644 --- a/app/src/main/res/layout/feeditemlist_item.xml +++ b/app/src/main/res/layout/feeditemlist_item.xml @@ -35,7 +35,7 @@ android:layout_height="match_parent" android:importantForAccessibility="no" android:scaleType="fitCenter" - android:src="?attr/dragview_background" + app:srcCompat="?attr/dragview_background" android:paddingStart="0dp" android:paddingLeft="0dp" android:paddingEnd="4dp" diff --git a/app/src/main/res/layout/gpodnetauth_credentials.xml b/app/src/main/res/layout/gpodnetauth_credentials.xml index 9fcf67cff..8cf6941c9 100644 --- a/app/src/main/res/layout/gpodnetauth_credentials.xml +++ b/app/src/main/res/layout/gpodnetauth_credentials.xml @@ -2,6 +2,7 @@ @@ -15,7 +16,7 @@ + app:srcCompat="@drawable/gpodder_icon"/> @@ -9,7 +10,7 @@ android:id="@id/icon" android:layout_width="64dp" android:layout_height="64dp" - android:src="@drawable/gpodder_icon" /> + app:srcCompat="@drawable/gpodder_icon" /> -- cgit debian/1.2.3+git2.25.1-1-2-gaceb0