diff options
author | ByteHamster <info@bytehamster.com> | 2022-08-06 16:55:29 +0200 |
---|---|---|
committer | ByteHamster <info@bytehamster.com> | 2022-09-18 19:12:41 +0200 |
commit | e5d2d1b6ef6eec995e2ef7e714653567e349e59e (patch) | |
tree | 048d2ac7cbe88b6066281a234c4e4f80f1560abc | |
parent | cbfa0181f48e601a18d87f9f699f48460dd61acd (diff) | |
download | AntennaPod-e5d2d1b6ef6eec995e2ef7e714653567e349e59e.zip |
Migrate navigation drawer to Material3
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java | 8 | ||||
-rw-r--r-- | app/src/main/res/layout/nav_listitem.xml | 9 | ||||
-rw-r--r-- | core/src/main/res/drawable-v21/drawer_item_background.xml | 20 | ||||
-rw-r--r-- | core/src/main/res/drawable/drawer_item_background.xml | 16 | ||||
-rw-r--r-- | core/src/main/res/values/colors.xml | 3 | ||||
-rw-r--r-- | core/src/main/res/values/styles.xml | 4 |
6 files changed, 46 insertions, 14 deletions
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 5b3562997..286da1e20 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java @@ -10,7 +10,6 @@ import android.view.LayoutInflater; import androidx.annotation.DrawableRes; import androidx.annotation.NonNull; import androidx.preference.PreferenceManager; -import android.util.TypedValue; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; @@ -208,12 +207,7 @@ public class NavListAdapter extends RecyclerView.Adapter<NavListAdapter.Holder> holder.itemView.setOnCreateContextMenuListener(itemAccess); } if (viewType != VIEW_TYPE_SECTION_DIVIDER) { - TypedValue typedValue = new TypedValue(); - - activity.get().getTheme().resolveAttribute(itemAccess.isSelected(position) - ? R.attr.drawer_activated_color : android.R.attr.windowBackground, typedValue, true); - holder.itemView.setBackgroundResource(typedValue.resourceId); - + holder.itemView.setSelected(itemAccess.isSelected(position)); holder.itemView.setOnClickListener(v -> itemAccess.onItemClick(position)); holder.itemView.setOnLongClickListener(v -> itemAccess.onItemLongClick(position)); holder.itemView.setOnTouchListener((v, e) -> { diff --git a/app/src/main/res/layout/nav_listitem.xml b/app/src/main/res/layout/nav_listitem.xml index 37b629abb..0aca5eb7d 100644 --- a/app/src/main/res/layout/nav_listitem.xml +++ b/app/src/main/res/layout/nav_listitem.xml @@ -1,17 +1,19 @@ <?xml version="1.0" encoding="utf-8"?> <RelativeLayout 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" + xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="@dimen/listitem_iconwithtext_height" - android:foreground="?attr/selectableItemBackground" - android:orientation="vertical"> + android:orientation="vertical" + android:layout_marginHorizontal="8dp" + android:background="@drawable/drawer_item_background"> <ImageView android:id="@+id/imgvCover" android:layout_width="@dimen/thumbnail_length_navlist" android:layout_height="@dimen/thumbnail_length_navlist" + android:importantForAccessibility="no" android:layout_alignParentStart="true" android:layout_alignParentLeft="true" android:layout_centerVertical="true" @@ -21,7 +23,6 @@ android:layout_marginBottom="4dp" android:adjustViewBounds="true" android:cropToPadding="true" - android:importantForAccessibility="no" android:scaleType="centerInside" tools:src="@drawable/ic_download_black" /> diff --git a/core/src/main/res/drawable-v21/drawer_item_background.xml b/core/src/main/res/drawable-v21/drawer_item_background.xml new file mode 100644 index 000000000..1992158cc --- /dev/null +++ b/core/src/main/res/drawable-v21/drawer_item_background.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8"?> +<ripple xmlns:android="http://schemas.android.com/apk/res/android" android:color="?attr/currently_playing_background"> + <item android:id="@android:id/mask"> + <shape android:shape="rectangle"> + <solid android:color="@color/black"/> + <corners android:radius="32dp"/> + </shape> + </item> + <item> + <selector> + <item android:state_selected="true"> + <shape android:shape="rectangle"> + <solid android:color="?attr/drawer_activated_color"/> + <corners android:radius="32dp"/> + </shape> + </item> + <item android:drawable="@android:color/transparent" /> + </selector> + </item> +</ripple> diff --git a/core/src/main/res/drawable/drawer_item_background.xml b/core/src/main/res/drawable/drawer_item_background.xml new file mode 100644 index 000000000..a0ec893a8 --- /dev/null +++ b/core/src/main/res/drawable/drawer_item_background.xml @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="utf-8"?> +<selector xmlns:android="http://schemas.android.com/apk/res/android"> + <item android:state_pressed="true"> + <shape android:shape="rectangle"> + <solid android:color="?attr/currently_playing_background"/> + <corners android:radius="32dp"/> + </shape> + </item> + <item android:state_selected="true"> + <shape android:shape="rectangle"> + <solid android:color="?attr/drawer_activated_color" /> + <corners android:radius="32dp" /> + </shape> + </item> + <item android:drawable="@android:color/transparent" /> +</selector> diff --git a/core/src/main/res/values/colors.xml b/core/src/main/res/values/colors.xml index 859b64367..d8a860af6 100644 --- a/core/src/main/res/values/colors.xml +++ b/core/src/main/res/values/colors.xml @@ -25,10 +25,11 @@ <color name="non_square_icon_background">#22777777</color> <color name="seek_background_light">#90000000</color> <color name="seek_background_dark">#905B5B5B</color> - <color name="navigation_bar_divider_light">#1F000000</color> <color name="accent_light">#0078C2</color> + <color name="accent_light_alpha">#250078C2</color> <color name="accent_dark">#3D8BFF</color> + <color name="accent_dark_alpha">#253D8BFF</color> <color name="icon_background_gradient_start">#0ba2ff</color> <color name="icon_background_gradient_end">#0878ff</color> diff --git a/core/src/main/res/values/styles.xml b/core/src/main/res/values/styles.xml index e3e23c1d2..a1e93aad3 100644 --- a/core/src/main/res/values/styles.xml +++ b/core/src/main/res/values/styles.xml @@ -21,7 +21,7 @@ <item name="master_switch_background">@color/master_switch_background_light</item> <item name="currently_playing_background">@color/highlight_light</item> <item name="action_icon_color">@color/black</item> - <item name="drawer_activated_color">@color/highlight_light</item> + <item name="drawer_activated_color">@color/accent_light_alpha</item> <item name="android:textAllCaps">false</item> <item name="android:textColorHint">@color/grey600</item> <item name="seek_background">@color/seek_background_light</item> @@ -56,7 +56,7 @@ <item name="background_elevated">@color/background_elevated_darktheme</item> <item name="colorControlNormal">@color/white</item> <item name="progressBarTheme">@style/ProgressBarDark</item> - <item name="drawer_activated_color">@color/highlight_dark</item> + <item name="drawer_activated_color">@color/accent_dark_alpha</item> <item name="master_switch_background">@color/master_switch_background_dark</item> <item name="currently_playing_background">@color/highlight_dark</item> <item name="action_icon_color">@color/white</item> |