Use VectorDrawable compat library
This commit is contained in:
parent
5c81631843
commit
d51e9c7625
|
@ -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<NavListAdapter.Holder>
|
|||
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<NavListAdapter.Holder>
|
|||
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<String> getFragmentTags() {
|
||||
|
@ -283,7 +279,7 @@ public class NavListAdapter extends RecyclerView.Adapter<NavListAdapter.Holder>
|
|||
}
|
||||
}
|
||||
|
||||
holder.image.setImageDrawable(getDrawable(fragmentTags.get(position)));
|
||||
holder.image.setImageResource(getDrawable(fragmentTags.get(position)));
|
||||
}
|
||||
|
||||
private void bindSectionDivider(DividerHolder holder) {
|
||||
|
|
|
@ -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()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
|
@ -15,7 +16,7 @@
|
|||
android:id="@+id/widget_config_background"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:src="@drawable/teaser"
|
||||
app:srcCompat="@drawable/teaser"
|
||||
android:scaleType="centerCrop" />
|
||||
|
||||
<include
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="8dp"
|
||||
android:layout_alignBottom="@id/pager"
|
||||
android:src="@drawable/bg_gradient"
|
||||
app:srcCompat="@drawable/bg_gradient"
|
||||
app:tint="?android:attr/windowBackground"
|
||||
android:importantForAccessibility="no"/>
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
|
@ -32,7 +33,7 @@
|
|||
<ImageButton
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="?attr/content_new"
|
||||
app:srcCompat="?attr/content_new"
|
||||
android:contentDescription="@string/new_label"
|
||||
android:id="@+id/newTagButton"/>
|
||||
</LinearLayout>
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
@ -15,7 +16,7 @@
|
|||
<ImageView
|
||||
android:layout_width="64dp"
|
||||
android:layout_height="64dp"
|
||||
android:src="@drawable/gpodder_icon"/>
|
||||
app:srcCompat="@drawable/gpodder_icon"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/createAccountButton"
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
@ -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" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtvDescription"
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/nav_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
@ -18,7 +19,6 @@
|
|||
android:focusable="true">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imgvCover"
|
||||
android:layout_width="@dimen/thumbnail_length_navlist"
|
||||
android:layout_height="@dimen/thumbnail_length_navlist"
|
||||
android:layout_marginBottom="4dp"
|
||||
|
@ -30,7 +30,7 @@
|
|||
android:cropToPadding="true"
|
||||
android:padding="8dp"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="?attr/ic_settings"
|
||||
app:srcCompat="?attr/ic_settings"
|
||||
tools:background="@android:color/holo_orange_dark"
|
||||
tools:src="@android:drawable/sym_def_app_icon" />
|
||||
|
||||
|
|
|
@ -8,6 +8,8 @@ android {
|
|||
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||
|
||||
multiDexEnabled false
|
||||
vectorDrawables.useSupportLibrary true
|
||||
vectorDrawables.generatedDensities = []
|
||||
|
||||
testApplicationId "de.danoeh.antennapod.core.tests"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
@ -23,7 +24,7 @@
|
|||
android:background="?android:attr/selectableItemBackground"
|
||||
android:scaleType="fitCenter"
|
||||
android:padding="8dp"
|
||||
android:src="@drawable/ic_av_play_white_24dp" />
|
||||
app:srcCompat="@drawable/ic_av_play_white_24dp" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/layout_left"
|
||||
|
@ -41,7 +42,7 @@
|
|||
android:id="@+id/imgvCover"
|
||||
android:layout_width="@android:dimen/app_icon_size"
|
||||
android:layout_height="match_parent"
|
||||
android:src="@mipmap/ic_launcher_round"
|
||||
app:srcCompat="@mipmap/ic_launcher_round"
|
||||
android:importantForAccessibility="no"
|
||||
android:layout_margin="12dp" />
|
||||
|
||||
|
@ -98,7 +99,7 @@
|
|||
android:layout_marginRight="2dp"
|
||||
android:layout_marginEnd="2dp"
|
||||
android:scaleType="fitXY"
|
||||
android:src="@drawable/ic_av_fast_rewind_white_48dp"/>
|
||||
app:srcCompat="@drawable/ic_av_fast_rewind_white_48dp"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/butPlayExtended"
|
||||
|
@ -109,7 +110,7 @@
|
|||
android:layout_marginRight="2dp"
|
||||
android:layout_marginEnd="2dp"
|
||||
android:scaleType="fitXY"
|
||||
android:src="@drawable/ic_av_play_white_48dp"/>
|
||||
app:srcCompat="@drawable/ic_av_play_white_48dp"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/butFastForward"
|
||||
|
@ -120,7 +121,7 @@
|
|||
android:layout_marginRight="2dp"
|
||||
android:layout_marginEnd="2dp"
|
||||
android:scaleType="fitXY"
|
||||
android:src="@drawable/ic_av_fast_forward_white_48dp"/>
|
||||
app:srcCompat="@drawable/ic_av_fast_forward_white_48dp"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/butSkip"
|
||||
|
@ -131,7 +132,7 @@
|
|||
android:layout_marginRight="2dp"
|
||||
android:layout_marginEnd="2dp"
|
||||
android:scaleType="fitXY"
|
||||
android:src="@drawable/ic_av_skip_white_24dp"/>
|
||||
app:srcCompat="@drawable/ic_av_skip_white_24dp"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
|
Loading…
Reference in New Issue