Migrate navigation drawer to Material3
This commit is contained in:
parent
cbfa0181f4
commit
e5d2d1b6ef
@ -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) -> {
|
||||
|
@ -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" />
|
||||
|
||||
|
20
core/src/main/res/drawable-v21/drawer_item_background.xml
Normal file
20
core/src/main/res/drawable-v21/drawer_item_background.xml
Normal file
@ -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>
|
16
core/src/main/res/drawable/drawer_item_background.xml
Normal file
16
core/src/main/res/drawable/drawer_item_background.xml
Normal file
@ -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>
|
@ -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>
|
||||
|
||||
|
@ -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>
|
||||
|
Loading…
x
Reference in New Issue
Block a user