Added grid layout change option
This commit is contained in:
parent
fc7c3b30f5
commit
6210065221
49 changed files with 1571 additions and 1428 deletions
|
@ -22,7 +22,7 @@ android {
|
|||
vectorDrawables.useSupportLibrary = true
|
||||
|
||||
applicationId "code.name.monkey.retromusic"
|
||||
versionCode 403
|
||||
versionCode 404
|
||||
versionName '3.4.850'
|
||||
|
||||
multiDexEnabled true
|
||||
|
@ -175,6 +175,7 @@ dependencies {
|
|||
implementation 'com.anjlab.android.iab.v3:library:1.1.0'
|
||||
implementation 'com.r0adkll:slidableactivity:2.1.0'
|
||||
implementation 'com.heinrichreimersoftware:material-intro:1.6'
|
||||
implementation 'me.zhanghai.android.fastscroll:library:1.1.0'
|
||||
|
||||
def dagger_version = "2.23.1"
|
||||
implementation "com.google.dagger:dagger:$dagger_version"
|
||||
|
|
|
@ -12,21 +12,15 @@
|
|||
"profile_image": "https://i.imgur.com/Q5Nsx1R.jpg"
|
||||
},
|
||||
{
|
||||
"name": "Gaming Inc.",
|
||||
"name": "GameSpeck",
|
||||
"summary": "Telegram group maintainer",
|
||||
"link": "https://www.gaminginc.tk/",
|
||||
"profile_image": "https://i.imgur.com/pfvN7d9.png"
|
||||
"link": "https://t.me/GameSpeck",
|
||||
"profile_image": "https://imgur.com/B15Kb9a.jpg"
|
||||
},
|
||||
{
|
||||
"name": "Milind Goel",
|
||||
"summary": "Github & Telegram maintainer",
|
||||
"link": "https://t.me/MilindGoel15",
|
||||
"profile_image": "https://i.imgur.com/Bz4De21_d.jpg"
|
||||
},
|
||||
{
|
||||
"name": "Abilas Sathiya",
|
||||
"summary": "Design & Suggestions",
|
||||
"link": "https://t.me/@abs2606",
|
||||
"profile_image": "https://i.imgur.com/MUyEWlx.jpg"
|
||||
}
|
||||
]
|
File diff suppressed because one or more lines are too long
|
@ -187,14 +187,14 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C
|
|||
albumText.text = String.format(
|
||||
"%s • %s",
|
||||
album.artistName,
|
||||
MusicUtil.getReadableDurationString(MusicUtil.getTotalDuration(this, album.songs))
|
||||
MusicUtil.getReadableDurationString(MusicUtil.getTotalDuration(album.songs))
|
||||
)
|
||||
} else {
|
||||
albumText.text = String.format(
|
||||
"%s • %s • %s",
|
||||
album.artistName,
|
||||
MusicUtil.getYearString(album.year),
|
||||
MusicUtil.getReadableDurationString(MusicUtil.getTotalDuration(this, album.songs))
|
||||
MusicUtil.getReadableDurationString(MusicUtil.getTotalDuration(album.songs))
|
||||
)
|
||||
}
|
||||
loadAlbumCover()
|
||||
|
|
|
@ -219,7 +219,7 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailsView,
|
|||
text.text = String.format(
|
||||
"%s • %s",
|
||||
MusicUtil.getArtistInfoString(this, artist),
|
||||
MusicUtil.getReadableDurationString(MusicUtil.getTotalDuration(this, artist.songs))
|
||||
MusicUtil.getReadableDurationString(MusicUtil.getTotalDuration(artist.songs))
|
||||
)
|
||||
|
||||
songAdapter.swapDataSet(artist.songs)
|
||||
|
|
|
@ -116,7 +116,7 @@ class GenreDetailsActivity : AbsSlidingMusicPanelActivity(), CabHolder, GenreDet
|
|||
|
||||
private fun setupRecyclerView() {
|
||||
ViewUtil.setUpFastScrollRecyclerViewColor(this, recyclerView)
|
||||
songAdapter = ShuffleButtonSongAdapter(this, ArrayList(), R.layout.item_list, false, this)
|
||||
songAdapter = ShuffleButtonSongAdapter(this, ArrayList(), R.layout.item_list, this)
|
||||
recyclerView.apply {
|
||||
itemAnimator = DefaultItemAnimator()
|
||||
layoutManager = LinearLayoutManager(this@GenreDetailsActivity)
|
||||
|
|
|
@ -77,7 +77,7 @@ class PlaylistDetailActivity : AbsSlidingMusicPanelActivity(), CabHolder, Playli
|
|||
|
||||
recyclerView.layoutManager = LinearLayoutManager(this)
|
||||
if (playlist is AbsCustomPlaylist) {
|
||||
adapter = PlaylistSongAdapter(this, ArrayList(), R.layout.item_list, false, this)
|
||||
adapter = PlaylistSongAdapter(this, ArrayList(), R.layout.item_list, this)
|
||||
recyclerView.adapter = adapter
|
||||
} else {
|
||||
recyclerViewDragDropManager = RecyclerViewDragDropManager()
|
||||
|
@ -85,7 +85,6 @@ class PlaylistDetailActivity : AbsSlidingMusicPanelActivity(), CabHolder, Playli
|
|||
adapter = OrderablePlaylistSongAdapter(this,
|
||||
ArrayList(),
|
||||
R.layout.item_list,
|
||||
false,
|
||||
this,
|
||||
object : OrderablePlaylistSongAdapter.OnMoveItemListener {
|
||||
override fun onMoveItem(fromPosition: Int, toPosition: Int) {
|
||||
|
|
|
@ -22,22 +22,39 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.ItemTouchHelper;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.google.android.material.checkbox.MaterialCheckBox;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import code.name.monkey.appthemehelper.ThemeStore;
|
||||
import code.name.monkey.retromusic.R;
|
||||
import code.name.monkey.retromusic.model.CategoryInfo;
|
||||
import code.name.monkey.retromusic.util.SwipeAndDragHelper;
|
||||
import com.google.android.material.checkbox.MaterialCheckBox;
|
||||
import java.util.List;
|
||||
|
||||
public class CategoryInfoAdapter extends RecyclerView.Adapter<CategoryInfoAdapter.ViewHolder>
|
||||
implements SwipeAndDragHelper.ActionCompletionContract {
|
||||
|
||||
static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
MaterialCheckBox checkBox;
|
||||
|
||||
View dragView;
|
||||
|
||||
TextView title;
|
||||
|
||||
ViewHolder(View view) {
|
||||
super(view);
|
||||
checkBox = view.findViewById(R.id.checkbox);
|
||||
checkBox.setButtonTintList(
|
||||
ColorStateList.valueOf(ThemeStore.Companion.accentColor(checkBox.getContext())));
|
||||
title = view.findViewById(R.id.title);
|
||||
dragView = view.findViewById(R.id.drag_view);
|
||||
}
|
||||
}
|
||||
|
||||
public class CategoryInfoAdapter extends RecyclerView.Adapter<CategoryInfoAdapter.ViewHolder> implements SwipeAndDragHelper.ActionCompletionContract {
|
||||
private List<CategoryInfo> categoryInfos;
|
||||
|
||||
private ItemTouchHelper touchHelper;
|
||||
|
||||
public CategoryInfoAdapter(@NonNull List<CategoryInfo> categoryInfos) {
|
||||
|
@ -46,52 +63,6 @@ public class CategoryInfoAdapter extends RecyclerView.Adapter<CategoryInfoAdapte
|
|||
touchHelper = new ItemTouchHelper(swipeAndDragHelper);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public CategoryInfoAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.preference_dialog_library_categories_listitem, parent, false);
|
||||
return new ViewHolder(view);
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull CategoryInfoAdapter.ViewHolder holder, int position) {
|
||||
CategoryInfo categoryInfo = categoryInfos.get(position);
|
||||
|
||||
holder.checkBox.setChecked(categoryInfo.visible);
|
||||
holder.title.setText(holder.title.getResources().getString(categoryInfo.category.stringRes));
|
||||
|
||||
holder.itemView.setOnClickListener(v -> {
|
||||
if (!(categoryInfo.visible && isLastCheckedCategory(categoryInfo))) {
|
||||
categoryInfo.visible = !categoryInfo.visible;
|
||||
holder.checkBox.setChecked(categoryInfo.visible);
|
||||
} else {
|
||||
Toast.makeText(holder.itemView.getContext(), R.string.you_have_to_select_at_least_one_category, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
|
||||
holder.dragView.setOnTouchListener((view, event) -> {
|
||||
if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
|
||||
touchHelper.startDrag(holder);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return categoryInfos.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewMoved(int oldPosition, int newPosition) {
|
||||
CategoryInfo categoryInfo = categoryInfos.get(oldPosition);
|
||||
categoryInfos.remove(oldPosition);
|
||||
categoryInfos.add(newPosition, categoryInfo);
|
||||
notifyItemMoved(oldPosition, newPosition);
|
||||
}
|
||||
|
||||
public void attachToRecyclerView(RecyclerView recyclerView) {
|
||||
touchHelper.attachToRecyclerView(recyclerView);
|
||||
}
|
||||
|
@ -106,26 +77,62 @@ public class CategoryInfoAdapter extends RecyclerView.Adapter<CategoryInfoAdapte
|
|||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return categoryInfos.size();
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull CategoryInfoAdapter.ViewHolder holder, int position) {
|
||||
CategoryInfo categoryInfo = categoryInfos.get(position);
|
||||
|
||||
holder.checkBox.setChecked(categoryInfo.visible);
|
||||
holder.title.setText(holder.title.getResources().getString(categoryInfo.category.stringRes));
|
||||
|
||||
holder.itemView.setOnClickListener(v -> {
|
||||
if (!(categoryInfo.visible && isLastCheckedCategory(categoryInfo))) {
|
||||
categoryInfo.visible = !categoryInfo.visible;
|
||||
holder.checkBox.setChecked(categoryInfo.visible);
|
||||
} else {
|
||||
Toast.makeText(holder.itemView.getContext(), R.string.you_have_to_select_at_least_one_category,
|
||||
Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
|
||||
holder.dragView.setOnTouchListener((view, event) -> {
|
||||
if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
|
||||
touchHelper.startDrag(holder);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public CategoryInfoAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.preference_dialog_library_categories_listitem, parent, false);
|
||||
return new ViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewMoved(int oldPosition, int newPosition) {
|
||||
CategoryInfo categoryInfo = categoryInfos.get(oldPosition);
|
||||
categoryInfos.remove(oldPosition);
|
||||
categoryInfos.add(newPosition, categoryInfo);
|
||||
notifyItemMoved(oldPosition, newPosition);
|
||||
}
|
||||
|
||||
private boolean isLastCheckedCategory(CategoryInfo categoryInfo) {
|
||||
if (categoryInfo.visible) {
|
||||
for (CategoryInfo c : categoryInfos) {
|
||||
if (c != categoryInfo && c.visible) return false;
|
||||
if (c != categoryInfo && c.visible) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
MaterialCheckBox checkBox;
|
||||
TextView title;
|
||||
View dragView;
|
||||
|
||||
ViewHolder(View view) {
|
||||
super(view);
|
||||
checkBox = view.findViewById(R.id.checkbox);
|
||||
checkBox.setButtonTintList(ColorStateList.valueOf(ThemeStore.Companion.accentColor(checkBox.getContext())));
|
||||
title = view.findViewById(R.id.title);
|
||||
dragView = view.findViewById(R.id.drag_view);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,7 +1,9 @@
|
|||
package code.name.monkey.retromusic.adapter
|
||||
|
||||
import android.app.Activity
|
||||
import android.view.*
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import code.name.monkey.retromusic.R
|
||||
|
|
|
@ -9,15 +9,19 @@ import code.name.monkey.retromusic.R
|
|||
import code.name.monkey.retromusic.adapter.base.MediaEntryViewHolder
|
||||
import code.name.monkey.retromusic.model.Genre
|
||||
import code.name.monkey.retromusic.util.NavigationUtil
|
||||
import java.util.*
|
||||
import java.util.ArrayList
|
||||
import java.util.Locale
|
||||
|
||||
/**
|
||||
* @author Hemanth S (h4h13).
|
||||
*/
|
||||
|
||||
class GenreAdapter(
|
||||
private val activity: Activity, dataSet: ArrayList<Genre>, private val mItemLayoutRes: Int
|
||||
private val activity: Activity,
|
||||
dataSet: ArrayList<Genre>,
|
||||
private val mItemLayoutRes: Int
|
||||
) : RecyclerView.Adapter<GenreAdapter.ViewHolder>() {
|
||||
|
||||
var dataSet = ArrayList<Genre>()
|
||||
private set
|
||||
|
||||
|
@ -32,7 +36,12 @@ class GenreAdapter(
|
|||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
val genre = dataSet[position]
|
||||
holder.title?.text = genre.name
|
||||
holder.text?.text = String.format(Locale.getDefault(), "%d %s", genre.songCount, if (genre.songCount > 1) activity.getString(R.string.songs) else activity.getString(R.string.song))
|
||||
holder.text?.text = String.format(
|
||||
Locale.getDefault(),
|
||||
"%d %s",
|
||||
genre.songCount,
|
||||
if (genre.songCount > 1) activity.getString(R.string.songs) else activity.getString(R.string.song)
|
||||
)
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
|
|
|
@ -23,7 +23,8 @@ import code.name.monkey.retromusic.model.Playlist
|
|||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
|
||||
class HomeAdapter(
|
||||
private val activity: AppCompatActivity, private val displayMetrics: DisplayMetrics
|
||||
private val activity: AppCompatActivity,
|
||||
private val displayMetrics: DisplayMetrics
|
||||
) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
||||
|
||||
private var list = ArrayList<Home>()
|
||||
|
@ -137,14 +138,9 @@ class HomeAdapter(
|
|||
if (songs.isNotEmpty()) {
|
||||
recyclerView.apply {
|
||||
show()
|
||||
val songAdapter = SongAdapter(
|
||||
activity, songs, R.layout.item_album_card, false, null
|
||||
)
|
||||
layoutManager = GridLayoutManager(
|
||||
activity, 1, GridLayoutManager.HORIZONTAL, false
|
||||
)
|
||||
val songAdapter = SongAdapter(activity, songs, R.layout.item_album_card, null)
|
||||
layoutManager = GridLayoutManager(activity, 1, GridLayoutManager.HORIZONTAL, false)
|
||||
adapter = songAdapter
|
||||
|
||||
}
|
||||
title.text = activity.getString(titleRes)
|
||||
}
|
||||
|
|
|
@ -23,7 +23,8 @@ import com.bumptech.glide.Glide
|
|||
import android.util.Pair as UtilPair
|
||||
|
||||
class SearchAdapter(
|
||||
private val activity: AppCompatActivity, private var dataSet: List<Any>?
|
||||
private val activity: AppCompatActivity,
|
||||
private var dataSet: List<Any>?
|
||||
) : RecyclerView.Adapter<SearchAdapter.ViewHolder>() {
|
||||
|
||||
fun swapDataSet(dataSet: MutableList<Any>) {
|
||||
|
@ -39,7 +40,13 @@ class SearchAdapter(
|
|||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
return if (viewType == HEADER) ViewHolder(LayoutInflater.from(activity).inflate(R.layout.sub_header, parent, false), viewType)
|
||||
return if (viewType == HEADER) ViewHolder(
|
||||
LayoutInflater.from(activity).inflate(
|
||||
R.layout.sub_header,
|
||||
parent,
|
||||
false
|
||||
), viewType
|
||||
)
|
||||
else
|
||||
ViewHolder(LayoutInflater.from(activity).inflate(R.layout.item_list, parent, false), viewType)
|
||||
}
|
||||
|
@ -108,11 +115,17 @@ class SearchAdapter(
|
|||
val item = dataSet!![adapterPosition]
|
||||
when (itemViewType) {
|
||||
ALBUM -> {
|
||||
val options = ActivityOptions.makeSceneTransitionAnimation(activity, UtilPair.create(image, activity.getString(R.string.transition_album_art)))
|
||||
val options = ActivityOptions.makeSceneTransitionAnimation(
|
||||
activity,
|
||||
UtilPair.create(image, activity.getString(R.string.transition_album_art))
|
||||
)
|
||||
NavigationUtil.goToAlbumOptions(activity, (item as Album).id, options)
|
||||
}
|
||||
ARTIST -> {
|
||||
val options = ActivityOptions.makeSceneTransitionAnimation(activity, UtilPair.create(image, activity.getString(R.string.transition_artist_image)))
|
||||
val options = ActivityOptions.makeSceneTransitionAnimation(
|
||||
activity,
|
||||
UtilPair.create(image, activity.getString(R.string.transition_artist_image))
|
||||
)
|
||||
NavigationUtil.goToArtistOptions(activity, (item as Artist).id, options)
|
||||
}
|
||||
GENRE -> {
|
||||
|
|
|
@ -12,37 +12,38 @@ import code.name.monkey.retromusic.adapter.base.AbsMultiSelectAdapter
|
|||
import code.name.monkey.retromusic.adapter.base.MediaEntryViewHolder
|
||||
import code.name.monkey.retromusic.glide.audiocover.AudioFileCover
|
||||
import code.name.monkey.retromusic.interfaces.CabHolder
|
||||
import code.name.monkey.retromusic.util.MusicUtil
|
||||
import code.name.monkey.retromusic.util.RetroUtil
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||
import com.bumptech.glide.signature.MediaStoreSignature
|
||||
import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView
|
||||
import me.zhanghai.android.fastscroll.PopupTextProvider
|
||||
import java.io.File
|
||||
import java.text.DecimalFormat
|
||||
import java.util.*
|
||||
import java.util.ArrayList
|
||||
import kotlin.math.log10
|
||||
import kotlin.math.pow
|
||||
|
||||
class SongFileAdapter(
|
||||
private val activity: AppCompatActivity,
|
||||
private var dataSet: List<File>?,
|
||||
private var dataSet: List<File>,
|
||||
private val itemLayoutRes: Int,
|
||||
private val callbacks: Callbacks?,
|
||||
cabHolder: CabHolder?
|
||||
) : AbsMultiSelectAdapter<SongFileAdapter.ViewHolder, File>(
|
||||
activity, cabHolder, R.menu.menu_media_selection
|
||||
), FastScrollRecyclerView.SectionedAdapter {
|
||||
), PopupTextProvider {
|
||||
|
||||
init {
|
||||
this.setHasStableIds(true)
|
||||
}
|
||||
|
||||
override fun getItemViewType(position: Int): Int {
|
||||
return if (dataSet!![position].isDirectory) FOLDER else FILE
|
||||
return if (dataSet[position].isDirectory) FOLDER else FILE
|
||||
}
|
||||
|
||||
override fun getItemId(position: Int): Long {
|
||||
return dataSet!![position].hashCode().toLong()
|
||||
return dataSet[position].hashCode().toLong()
|
||||
}
|
||||
|
||||
fun swapDataSet(songFiles: List<File>) {
|
||||
|
@ -55,7 +56,7 @@ class SongFileAdapter(
|
|||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, index: Int) {
|
||||
val file = dataSet!![index]
|
||||
val file = dataSet[index]
|
||||
holder.itemView.isActivated = isChecked(file)
|
||||
holder.title?.text = getFileTitle(file)
|
||||
if (holder.text != null) {
|
||||
|
@ -87,7 +88,6 @@ class SongFileAdapter(
|
|||
it.setImageResource(R.drawable.ic_folder_white_24dp)
|
||||
}
|
||||
holder.imageTextContainer?.setCardBackgroundColor(ATHUtil.resolveColor(activity, R.attr.colorSurface))
|
||||
|
||||
} else {
|
||||
val error = RetroUtil.getTintedVectorDrawable(
|
||||
activity, R.drawable.ic_file_music_white_24dp, iconColor
|
||||
|
@ -100,11 +100,11 @@ class SongFileAdapter(
|
|||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
return dataSet!!.size
|
||||
return dataSet.size
|
||||
}
|
||||
|
||||
override fun getIdentifier(position: Int): File? {
|
||||
return dataSet!![position]
|
||||
return dataSet[position]
|
||||
}
|
||||
|
||||
override fun getName(`object`: File): String {
|
||||
|
@ -116,8 +116,12 @@ class SongFileAdapter(
|
|||
callbacks.onMultipleItemAction(menuItem, selection)
|
||||
}
|
||||
|
||||
override fun getSectionName(position: Int): String {
|
||||
return dataSet!![position].name[0].toString().toUpperCase()
|
||||
override fun getPopupText(position: Int): String {
|
||||
return getSectionName(position)
|
||||
}
|
||||
|
||||
private fun getSectionName(position: Int): String {
|
||||
return MusicUtil.getSectionName(dataSet[position].name)
|
||||
}
|
||||
|
||||
interface Callbacks {
|
||||
|
@ -135,7 +139,7 @@ class SongFileAdapter(
|
|||
menu?.setOnClickListener { v ->
|
||||
val position = adapterPosition
|
||||
if (isPositionInRange(position)) {
|
||||
callbacks.onFileMenuClicked(dataSet!![position], v)
|
||||
callbacks.onFileMenuClicked(dataSet[position], v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -150,7 +154,7 @@ class SongFileAdapter(
|
|||
if (isInQuickSelectMode) {
|
||||
toggleChecked(position)
|
||||
} else {
|
||||
callbacks?.onFileSelected(dataSet!![position])
|
||||
callbacks?.onFileSelected(dataSet[position])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -161,7 +165,7 @@ class SongFileAdapter(
|
|||
}
|
||||
|
||||
private fun isPositionInRange(position: Int): Boolean {
|
||||
return position >= 0 && position < dataSet!!.size
|
||||
return position >= 0 && position < dataSet.size
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ import code.name.monkey.retromusic.util.MusicUtil
|
|||
import code.name.monkey.retromusic.util.NavigationUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import com.bumptech.glide.Glide
|
||||
import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView
|
||||
import me.zhanghai.android.fastscroll.PopupTextProvider
|
||||
|
||||
open class AlbumAdapter(
|
||||
protected val activity: AppCompatActivity,
|
||||
|
@ -37,7 +37,7 @@ open class AlbumAdapter(
|
|||
activity,
|
||||
cabHolder,
|
||||
R.menu.menu_media_selection
|
||||
), FastScrollRecyclerView.SectionedAdapter {
|
||||
), PopupTextProvider {
|
||||
|
||||
var dataSet: ArrayList<Album>
|
||||
protected set
|
||||
|
@ -168,7 +168,11 @@ open class AlbumAdapter(
|
|||
return songs
|
||||
}
|
||||
|
||||
override fun getSectionName(position: Int): String {
|
||||
override fun getPopupText(position: Int): String {
|
||||
return getSectionName(position)
|
||||
}
|
||||
|
||||
private fun getSectionName(position: Int): String {
|
||||
var sectionName: String? = null
|
||||
when (PreferenceUtil.getInstance(activity).albumSortOrder) {
|
||||
SortOrder.AlbumSortOrder.ALBUM_A_Z, SortOrder.AlbumSortOrder.ALBUM_Z_A -> sectionName =
|
||||
|
|
|
@ -70,7 +70,7 @@ class AlbumCoverPagerAdapter(
|
|||
|
||||
private val layout: Int
|
||||
get() {
|
||||
return when (PreferenceUtil.getInstance(activity).albumCoverStyle) {
|
||||
return when (PreferenceUtil.getInstance(requireContext()).albumCoverStyle) {
|
||||
AlbumCoverStyle.NORMAL -> R.layout.fragment_album_cover
|
||||
AlbumCoverStyle.FLAT -> R.layout.fragment_album_flat_cover
|
||||
AlbumCoverStyle.CIRCLE -> R.layout.fragment_album_circle_cover
|
||||
|
@ -95,7 +95,7 @@ class AlbumCoverPagerAdapter(
|
|||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
val finalLayout = when {
|
||||
PreferenceUtil.getInstance(activity).carouselEffect() -> R.layout.fragment_album_carousel_cover
|
||||
PreferenceUtil.getInstance(requireContext()).carouselEffect() -> R.layout.fragment_album_carousel_cover
|
||||
else -> layout
|
||||
}
|
||||
val view = inflater.inflate(finalLayout, container, false)
|
||||
|
|
|
@ -13,7 +13,7 @@ import code.name.monkey.retromusic.interfaces.CabHolder
|
|||
import code.name.monkey.retromusic.model.Album
|
||||
import code.name.monkey.retromusic.util.MusicUtil
|
||||
import com.bumptech.glide.Glide
|
||||
import java.util.*
|
||||
import java.util.ArrayList
|
||||
|
||||
class HorizontalAlbumAdapter(
|
||||
activity: AppCompatActivity,
|
||||
|
|
|
@ -23,7 +23,7 @@ import code.name.monkey.retromusic.model.Song
|
|||
import code.name.monkey.retromusic.util.MusicUtil
|
||||
import code.name.monkey.retromusic.util.NavigationUtil
|
||||
import com.bumptech.glide.Glide
|
||||
import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView
|
||||
import me.zhanghai.android.fastscroll.PopupTextProvider
|
||||
import java.util.ArrayList
|
||||
|
||||
class ArtistAdapter(
|
||||
|
@ -34,7 +34,7 @@ class ArtistAdapter(
|
|||
cabHolder: CabHolder?
|
||||
) : AbsMultiSelectAdapter<ArtistAdapter.ViewHolder, Artist>(
|
||||
activity, cabHolder, R.menu.menu_media_selection
|
||||
), FastScrollRecyclerView.SectionedAdapter {
|
||||
), PopupTextProvider {
|
||||
|
||||
fun swapDataSet(dataSet: ArrayList<Artist>) {
|
||||
this.dataSet = dataSet
|
||||
|
@ -70,7 +70,7 @@ class ArtistAdapter(
|
|||
|
||||
fun setColors(color: Int, holder: ViewHolder) {
|
||||
if (holder.paletteColorContainer != null) {
|
||||
holder.paletteColorContainer?.backgroundTintList = ColorStateList.valueOf(color)
|
||||
holder.paletteColorContainer?.setBackgroundColor(color)
|
||||
holder.title?.setTextColor(
|
||||
MaterialValueHelper.getPrimaryTextColor(
|
||||
activity, ColorUtil.isColorLight(
|
||||
|
@ -126,7 +126,11 @@ class ArtistAdapter(
|
|||
return songs
|
||||
}
|
||||
|
||||
override fun getSectionName(position: Int): String {
|
||||
override fun getPopupText(position: Int): String {
|
||||
return getSectionName(position)
|
||||
}
|
||||
|
||||
private fun getSectionName(position: Int): String {
|
||||
return MusicUtil.getSectionName(dataSet[position].name)
|
||||
}
|
||||
|
||||
|
|
|
@ -3,26 +3,28 @@ package code.name.monkey.retromusic.adapter.base;
|
|||
import android.content.Context;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import androidx.annotation.MenuRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.afollestad.materialcab.MaterialCab;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import code.name.monkey.retromusic.R;
|
||||
import code.name.monkey.retromusic.interfaces.CabHolder;
|
||||
import com.afollestad.materialcab.MaterialCab;
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
||||
public abstract class AbsMultiSelectAdapter<VH extends RecyclerView.ViewHolder, I> extends RecyclerView.Adapter<VH> implements MaterialCab.Callback {
|
||||
public abstract class AbsMultiSelectAdapter<VH extends RecyclerView.ViewHolder, I> extends RecyclerView.Adapter<VH>
|
||||
implements MaterialCab.Callback {
|
||||
|
||||
private MaterialCab cab;
|
||||
|
||||
@Nullable
|
||||
private final CabHolder cabHolder;
|
||||
private final Context context;
|
||||
private MaterialCab cab;
|
||||
|
||||
private ArrayList<I> checked;
|
||||
|
||||
private final Context context;
|
||||
|
||||
private int menuRes;
|
||||
|
||||
public AbsMultiSelectAdapter(@NonNull Context context, @Nullable CabHolder cabHolder, @MenuRes int menuRes) {
|
||||
|
@ -32,22 +34,27 @@ public abstract class AbsMultiSelectAdapter<VH extends RecyclerView.ViewHolder,
|
|||
this.context = context;
|
||||
}
|
||||
|
||||
protected void setMultiSelectMenuRes(@MenuRes int menuRes) {
|
||||
this.menuRes = menuRes;
|
||||
}
|
||||
|
||||
protected boolean toggleChecked(final int position) {
|
||||
if (cabHolder != null) {
|
||||
I identifier = getIdentifier(position);
|
||||
if (identifier == null) return false;
|
||||
|
||||
if (!checked.remove(identifier)) checked.add(identifier);
|
||||
|
||||
notifyItemChanged(position);
|
||||
updateCab();
|
||||
@Override
|
||||
public boolean onCabCreated(MaterialCab materialCab, Menu menu) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@Override
|
||||
public boolean onCabFinished(MaterialCab materialCab) {
|
||||
clearChecked();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCabItemClicked(MenuItem menuItem) {
|
||||
if (menuItem.getItemId() == R.id.action_multi_select_adapter_check_all) {
|
||||
checkAll();
|
||||
} else {
|
||||
onMultipleItemAction(menuItem, new ArrayList<>(checked));
|
||||
cab.finish();
|
||||
clearChecked();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void checkAll() {
|
||||
|
@ -64,21 +71,11 @@ public abstract class AbsMultiSelectAdapter<VH extends RecyclerView.ViewHolder,
|
|||
}
|
||||
}
|
||||
|
||||
private void updateCab() {
|
||||
if (cabHolder != null) {
|
||||
if (cab == null || !cab.isActive()) {
|
||||
cab = cabHolder.openCab(menuRes, this);
|
||||
}
|
||||
final int size = checked.size();
|
||||
if (size <= 0) cab.finish();
|
||||
else if (size == 1) cab.setTitle(getName(checked.get(0)));
|
||||
else cab.setTitle(context.getString(R.string.x_selected, size));
|
||||
}
|
||||
}
|
||||
@Nullable
|
||||
protected abstract I getIdentifier(int position);
|
||||
|
||||
private void clearChecked() {
|
||||
checked.clear();
|
||||
notifyDataSetChanged();
|
||||
protected String getName(I object) {
|
||||
return object.toString();
|
||||
}
|
||||
|
||||
protected boolean isChecked(I identifier) {
|
||||
|
@ -89,35 +86,48 @@ public abstract class AbsMultiSelectAdapter<VH extends RecyclerView.ViewHolder,
|
|||
return cab != null && cab.isActive();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCabCreated(MaterialCab materialCab, Menu menu) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCabItemClicked(MenuItem menuItem) {
|
||||
if (menuItem.getItemId() == R.id.action_multi_select_adapter_check_all) {
|
||||
checkAll();
|
||||
} else {
|
||||
onMultipleItemAction(menuItem, new ArrayList<>(checked));
|
||||
cab.finish();
|
||||
clearChecked();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCabFinished(MaterialCab materialCab) {
|
||||
clearChecked();
|
||||
return true;
|
||||
}
|
||||
|
||||
protected String getName(I object) {
|
||||
return object.toString();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected abstract I getIdentifier(int position);
|
||||
|
||||
protected abstract void onMultipleItemAction(MenuItem menuItem, ArrayList<I> selection);
|
||||
|
||||
protected void setMultiSelectMenuRes(@MenuRes int menuRes) {
|
||||
this.menuRes = menuRes;
|
||||
}
|
||||
|
||||
protected boolean toggleChecked(final int position) {
|
||||
if (cabHolder != null) {
|
||||
I identifier = getIdentifier(position);
|
||||
if (identifier == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!checked.remove(identifier)) {
|
||||
checked.add(identifier);
|
||||
}
|
||||
|
||||
notifyItemChanged(position);
|
||||
updateCab();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void clearChecked() {
|
||||
checked.clear();
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
private void updateCab() {
|
||||
if (cabHolder != null) {
|
||||
if (cab == null || !cab.isActive()) {
|
||||
cab = cabHolder.openCab(menuRes, this);
|
||||
}
|
||||
final int size = checked.size();
|
||||
if (size <= 0) {
|
||||
cab.finish();
|
||||
} else if (size == 1) {
|
||||
cab.setTitle(getName(checked.get(0)));
|
||||
} else {
|
||||
cab.setTitle(context.getString(R.string.x_selected, size));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
package code.name.monkey.retromusic.adapter.base;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageButton;
|
||||
|
@ -22,7 +23,6 @@ import android.widget.TextView;
|
|||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil;
|
||||
import code.name.monkey.retromusic.R;
|
||||
import com.google.android.material.card.MaterialCardView;
|
||||
import com.h6ah4i.android.widget.advrecyclerview.utils.AbstractDraggableSwipeableItemViewHolder;
|
||||
|
@ -97,8 +97,7 @@ public class MediaEntryViewHolder extends AbstractDraggableSwipeableItemViewHold
|
|||
dummyContainer = itemView.findViewById(R.id.dummy_view);
|
||||
|
||||
if (imageContainerCard != null) {
|
||||
imageContainerCard.setCardBackgroundColor(
|
||||
ATHUtil.INSTANCE.resolveColor(itemView.getContext(), R.attr.colorSurface));
|
||||
imageContainerCard.setCardBackgroundColor(Color.TRANSPARENT);
|
||||
}
|
||||
itemView.setOnClickListener(this);
|
||||
itemView.setOnLongClickListener(this);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package code.name.monkey.retromusic.adapter.playlist
|
||||
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.view.LayoutInflater
|
||||
import android.view.MenuItem
|
||||
|
@ -15,6 +16,8 @@ import code.name.monkey.retromusic.adapter.base.AbsMultiSelectAdapter
|
|||
import code.name.monkey.retromusic.adapter.base.MediaEntryViewHolder
|
||||
import code.name.monkey.retromusic.dialogs.ClearSmartPlaylistDialog
|
||||
import code.name.monkey.retromusic.dialogs.DeletePlaylistDialog
|
||||
import code.name.monkey.retromusic.extensions.hide
|
||||
import code.name.monkey.retromusic.extensions.show
|
||||
import code.name.monkey.retromusic.helper.menu.PlaylistMenuHelper
|
||||
import code.name.monkey.retromusic.helper.menu.SongsMenuHelper
|
||||
import code.name.monkey.retromusic.interfaces.CabHolder
|
||||
|
@ -26,7 +29,7 @@ import code.name.monkey.retromusic.model.smartplaylist.AbsSmartPlaylist
|
|||
import code.name.monkey.retromusic.model.smartplaylist.LastAddedPlaylist
|
||||
import code.name.monkey.retromusic.util.MusicUtil
|
||||
import code.name.monkey.retromusic.util.NavigationUtil
|
||||
import java.util.*
|
||||
import java.util.ArrayList
|
||||
|
||||
class PlaylistAdapter(
|
||||
private val activity: AppCompatActivity,
|
||||
|
@ -77,12 +80,26 @@ class PlaylistAdapter(
|
|||
holder.title?.text = getPlaylistTitle(playlist)
|
||||
holder.text?.text = getPlaylistText(playlist)
|
||||
holder.image?.setImageDrawable(getIconRes(playlist))
|
||||
val isChecked = isChecked(playlist)
|
||||
if (isChecked) {
|
||||
holder.menu?.hide()
|
||||
} else {
|
||||
holder.menu?.show()
|
||||
}
|
||||
}
|
||||
|
||||
private fun getIconRes(playlist: Playlist): Drawable {
|
||||
return if (MusicUtil.isFavoritePlaylist(activity, playlist))
|
||||
TintHelper.createTintedDrawable(activity, R.drawable.ic_favorite_white_24dp, ThemeStore.accentColor(activity))!!
|
||||
else TintHelper.createTintedDrawable(activity, R.drawable.ic_playlist_play_white_24dp, ATHUtil.resolveColor(activity, R.attr.colorControlNormal))!!
|
||||
TintHelper.createTintedDrawable(
|
||||
activity,
|
||||
R.drawable.ic_favorite_white_24dp,
|
||||
ThemeStore.accentColor(activity)
|
||||
)
|
||||
else TintHelper.createTintedDrawable(
|
||||
activity,
|
||||
R.drawable.ic_playlist_play_white_24dp,
|
||||
ATHUtil.resolveColor(activity, R.attr.colorControlNormal)
|
||||
)
|
||||
}
|
||||
|
||||
override fun getItemViewType(position: Int): Int {
|
||||
|
@ -157,7 +174,6 @@ class PlaylistAdapter(
|
|||
image?.apply {
|
||||
val iconPadding = activity.resources.getDimensionPixelSize(R.dimen.list_item_image_icon_padding)
|
||||
setPadding(iconPadding, iconPadding, iconPadding, iconPadding)
|
||||
//setColorFilter(ATHUtil.resolveColor(activity, R.attr.iconColor), PorterDuff.Mode.SRC_IN)
|
||||
}
|
||||
|
||||
menu?.setOnClickListener { view ->
|
||||
|
@ -189,7 +205,7 @@ class PlaylistAdapter(
|
|||
|
||||
imageTextContainer?.apply {
|
||||
cardElevation = 0f
|
||||
setCardBackgroundColor(ATHUtil.resolveColor(activity, R.attr.colorSurface))
|
||||
setCardBackgroundColor(Color.TRANSPARENT)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,31 +1,22 @@
|
|||
package code.name.monkey.retromusic.adapter.song
|
||||
|
||||
import android.view.*
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.annotation.LayoutRes
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||
import code.name.monkey.retromusic.interfaces.CabHolder
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import java.util.*
|
||||
import java.util.ArrayList
|
||||
|
||||
abstract class AbsOffsetSongAdapter : SongAdapter {
|
||||
|
||||
constructor(
|
||||
abstract class AbsOffsetSongAdapter(
|
||||
activity: AppCompatActivity,
|
||||
dataSet: ArrayList<Song>, @LayoutRes itemLayoutRes: Int,
|
||||
usePalette: Boolean,
|
||||
dataSet: ArrayList<Song>,
|
||||
@LayoutRes itemLayoutRes: Int,
|
||||
cabHolder: CabHolder?
|
||||
) : super(activity, dataSet, itemLayoutRes, usePalette, cabHolder)
|
||||
|
||||
constructor(
|
||||
activity: AppCompatActivity,
|
||||
dataSet: ArrayList<Song>, @LayoutRes itemLayoutRes: Int,
|
||||
usePalette: Boolean,
|
||||
cabHolder: CabHolder?,
|
||||
showSectionName: Boolean
|
||||
) : super(activity, dataSet, itemLayoutRes, usePalette, cabHolder, showSectionName) {
|
||||
}
|
||||
) : SongAdapter(activity, dataSet, itemLayoutRes, cabHolder) {
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SongAdapter.ViewHolder {
|
||||
if (viewType == OFFSET_ITEM) {
|
||||
|
@ -61,12 +52,6 @@ abstract class AbsOffsetSongAdapter : SongAdapter {
|
|||
return if (position == 0) OFFSET_ITEM else SONG
|
||||
}
|
||||
|
||||
override fun getSectionName(position: Int): String {
|
||||
var positionF = position
|
||||
positionF--
|
||||
return if (positionF < 0) "" else super.getSectionName(positionF)
|
||||
}
|
||||
|
||||
open inner class ViewHolder(itemView: View) : SongAdapter.ViewHolder(itemView) {
|
||||
|
||||
override // could also return null, just to be safe return empty song
|
||||
|
|
|
@ -1,28 +1,32 @@
|
|||
package code.name.monkey.retromusic.adapter.song
|
||||
|
||||
import android.view.*
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.R.menu
|
||||
import code.name.monkey.retromusic.dialogs.RemoveFromPlaylistDialog
|
||||
import code.name.monkey.retromusic.interfaces.CabHolder
|
||||
import code.name.monkey.retromusic.model.*
|
||||
import code.name.monkey.retromusic.model.PlaylistSong
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.util.ViewUtil
|
||||
import com.h6ah4i.android.widget.advrecyclerview.draggable.*
|
||||
import com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemAdapter
|
||||
import com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemViewHolder
|
||||
import com.h6ah4i.android.widget.advrecyclerview.draggable.ItemDraggableRange
|
||||
import com.h6ah4i.android.widget.advrecyclerview.draggable.annotation.DraggableItemStateFlags
|
||||
|
||||
class OrderablePlaylistSongAdapter(
|
||||
activity: AppCompatActivity,
|
||||
dataSet: ArrayList<Song>,
|
||||
itemLayoutRes: Int,
|
||||
usePalette: Boolean,
|
||||
cabHolder: CabHolder?,
|
||||
private val onMoveItemListener: OnMoveItemListener?
|
||||
) : PlaylistSongAdapter(
|
||||
activity, dataSet, itemLayoutRes, usePalette, cabHolder
|
||||
activity, dataSet, itemLayoutRes, cabHolder
|
||||
), DraggableItemAdapter<OrderablePlaylistSongAdapter.ViewHolder> {
|
||||
|
||||
init {
|
||||
setMultiSelectMenuRes(code.name.monkey.retromusic.R.menu.menu_playlists_songs_selection)
|
||||
setMultiSelectMenuRes(menu.menu_playlists_songs_selection)
|
||||
}
|
||||
|
||||
override fun createViewHolder(view: View): SongAdapter.ViewHolder {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package code.name.monkey.retromusic.adapter.song
|
||||
|
||||
import android.graphics.Color
|
||||
import android.graphics.PorterDuff.Mode
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
|
@ -31,7 +30,7 @@ class PlayingQueueAdapter(
|
|||
private var current: Int,
|
||||
itemLayoutRes: Int
|
||||
) : SongAdapter(
|
||||
activity, dataSet, itemLayoutRes, false, null
|
||||
activity, dataSet, itemLayoutRes, null
|
||||
), DraggableItemAdapter<PlayingQueueAdapter.ViewHolder>, SwipeableItemAdapter<PlayingQueueAdapter.ViewHolder> {
|
||||
|
||||
private var color = -1
|
||||
|
@ -48,9 +47,6 @@ class PlayingQueueAdapter(
|
|||
if (holder.itemViewType == HISTORY || holder.itemViewType == CURRENT) {
|
||||
setAlpha(holder, 0.5f)
|
||||
}
|
||||
if (usePalette) {
|
||||
setColor(holder, Color.WHITE)
|
||||
}
|
||||
}
|
||||
|
||||
private fun setColor(holder: SongAdapter.ViewHolder, white: Int) {
|
||||
|
@ -70,12 +66,6 @@ class PlayingQueueAdapter(
|
|||
}
|
||||
}
|
||||
|
||||
override fun usePalette(usePalette: Boolean) {
|
||||
super.usePalette(usePalette)
|
||||
this.usePalette = usePalette
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
override fun getItemViewType(position: Int): Int {
|
||||
if (position < current) {
|
||||
return HISTORY
|
||||
|
|
|
@ -16,9 +16,8 @@ open class PlaylistSongAdapter(
|
|||
activity: AppCompatActivity,
|
||||
dataSet: ArrayList<Song>,
|
||||
itemLayoutRes: Int,
|
||||
usePalette: Boolean,
|
||||
cabHolder: CabHolder?
|
||||
) : AbsOffsetSongAdapter(activity, dataSet, itemLayoutRes, usePalette, cabHolder, false) {
|
||||
) : AbsOffsetSongAdapter(activity, dataSet, itemLayoutRes, cabHolder) {
|
||||
|
||||
init {
|
||||
this.setMultiSelectMenuRes(R.menu.menu_cannot_delete_single_songs_playlist_songs_selection)
|
||||
|
|
|
@ -7,15 +7,14 @@ import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
|||
import code.name.monkey.retromusic.interfaces.CabHolder
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import com.google.android.material.button.MaterialButton
|
||||
import java.util.*
|
||||
import java.util.ArrayList
|
||||
|
||||
class ShuffleButtonSongAdapter(
|
||||
activity: AppCompatActivity,
|
||||
dataSet: ArrayList<Song>,
|
||||
itemLayoutRes: Int,
|
||||
usePalette: Boolean,
|
||||
cabHolder: CabHolder?
|
||||
) : AbsOffsetSongAdapter(activity, dataSet, itemLayoutRes, usePalette, cabHolder) {
|
||||
) : AbsOffsetSongAdapter(activity, dataSet, itemLayoutRes, cabHolder) {
|
||||
|
||||
override fun createViewHolder(view: View): SongAdapter.ViewHolder {
|
||||
return ViewHolder(view)
|
||||
|
|
|
@ -6,14 +6,14 @@ import androidx.appcompat.app.AppCompatActivity
|
|||
import code.name.monkey.retromusic.interfaces.CabHolder
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.util.MusicUtil
|
||||
import java.util.*
|
||||
import java.util.ArrayList
|
||||
|
||||
class SimpleSongAdapter(
|
||||
context: AppCompatActivity,
|
||||
songs: ArrayList<Song>,
|
||||
i: Int,
|
||||
layoutRes: Int,
|
||||
cabHolder: CabHolder?
|
||||
) : SongAdapter(context, songs, i, false, cabHolder) {
|
||||
) : SongAdapter(context, songs, layoutRes, cabHolder) {
|
||||
|
||||
override fun swapDataSet(dataSet: ArrayList<Song>) {
|
||||
this.dataSet.clear()
|
||||
|
|
|
@ -25,7 +25,7 @@ import code.name.monkey.retromusic.util.NavigationUtil
|
|||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import com.afollestad.materialcab.MaterialCab
|
||||
import com.bumptech.glide.Glide
|
||||
import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView
|
||||
import me.zhanghai.android.fastscroll.PopupTextProvider
|
||||
import java.util.ArrayList
|
||||
|
||||
/**
|
||||
|
@ -36,21 +36,17 @@ open class SongAdapter(
|
|||
protected val activity: AppCompatActivity,
|
||||
dataSet: ArrayList<Song>,
|
||||
protected var itemLayoutRes: Int,
|
||||
usePalette: Boolean,
|
||||
cabHolder: CabHolder?,
|
||||
showSectionName: Boolean = true
|
||||
) : AbsMultiSelectAdapter<SongAdapter.ViewHolder, Song>(
|
||||
activity, cabHolder, R.menu.menu_media_selection
|
||||
), MaterialCab.Callback, FastScrollRecyclerView.SectionedAdapter {
|
||||
), MaterialCab.Callback, PopupTextProvider {
|
||||
|
||||
var dataSet: ArrayList<Song>
|
||||
|
||||
protected var usePalette = false
|
||||
private var showSectionName = true
|
||||
|
||||
init {
|
||||
this.dataSet = dataSet
|
||||
this.usePalette = usePalette
|
||||
this.showSectionName = showSectionName
|
||||
this.setHasStableIds(true)
|
||||
}
|
||||
|
@ -60,11 +56,6 @@ open class SongAdapter(
|
|||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
open fun usePalette(usePalette: Boolean) {
|
||||
this.usePalette = usePalette
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
override fun getItemId(position: Int): Long {
|
||||
return dataSet[position].id.toLong()
|
||||
}
|
||||
|
@ -113,8 +104,7 @@ open class SongAdapter(
|
|||
}
|
||||
|
||||
override fun onColorReady(color: Int) {
|
||||
if (usePalette) setColors(color, holder)
|
||||
else setColors(defaultFooterColor, holder)
|
||||
setColors(color, holder)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -143,10 +133,7 @@ open class SongAdapter(
|
|||
SongsMenuHelper.handleMenuClick(activity, selection, menuItem.itemId)
|
||||
}
|
||||
|
||||
override fun getSectionName(position: Int): String {
|
||||
if (!showSectionName) {
|
||||
return ""
|
||||
}
|
||||
override fun getPopupText(position: Int): String {
|
||||
val sectionName: String? = when (PreferenceUtil.getInstance(activity).songSortOrder) {
|
||||
SortOrder.SongSortOrder.SONG_A_Z, SortOrder.SongSortOrder.SONG_Z_A -> dataSet[position].title
|
||||
SortOrder.SongSortOrder.SONG_ALBUM -> dataSet[position].albumName
|
||||
|
@ -157,6 +144,7 @@ open class SongAdapter(
|
|||
return ""
|
||||
}
|
||||
}
|
||||
println("File name -> $sectionName")
|
||||
return MusicUtil.getSectionName(sectionName)
|
||||
}
|
||||
|
||||
|
|
|
@ -12,10 +12,9 @@ abstract class AbsLibraryPagerRecyclerViewCustomGridSizeFragment<A : RecyclerVie
|
|||
|
||||
private var gridSize: Int = 0
|
||||
private var sortOrder: String? = null
|
||||
|
||||
private var usePaletteInitialized: Boolean = false
|
||||
private var usePalette: Boolean = false
|
||||
private var currentLayoutRes: Int = 0
|
||||
private val isLandscape: Boolean
|
||||
get() = RetroUtil.isLandscape()
|
||||
|
||||
val maxGridSize: Int
|
||||
get() = if (isLandscape) {
|
||||
|
@ -24,25 +23,24 @@ abstract class AbsLibraryPagerRecyclerViewCustomGridSizeFragment<A : RecyclerVie
|
|||
resources.getInteger(R.integer.max_columns)
|
||||
}
|
||||
|
||||
/**
|
||||
* Override to customize which item layout currentLayoutRes should be used. You might also want to
|
||||
* override [.canUsePalette] then.
|
||||
*
|
||||
* @see .getGridSize
|
||||
*/
|
||||
protected val itemLayoutRes: Int
|
||||
get() = if (getGridSize() > maxGridSizeForList) {
|
||||
R.layout.item_grid
|
||||
fun itemLayoutRes(): Int {
|
||||
return if (getGridSize() > maxGridSizeForList) {
|
||||
loadLayoutRes()
|
||||
} else R.layout.item_list
|
||||
}
|
||||
|
||||
protected val maxGridSizeForList: Int
|
||||
protected abstract fun setLayoutRes(layoutRes: Int)
|
||||
|
||||
fun setAndSaveLayoutRes(layoutRes: Int) {
|
||||
saveLayoutRes(layoutRes)
|
||||
setLayoutRes(layoutRes)
|
||||
}
|
||||
|
||||
private val maxGridSizeForList: Int
|
||||
get() = if (isLandscape) {
|
||||
activity!!.resources.getInteger(R.integer.default_list_columns_land)
|
||||
} else activity!!.resources.getInteger(R.integer.default_list_columns)
|
||||
|
||||
private val isLandscape: Boolean
|
||||
get() = RetroUtil.isLandscape()
|
||||
|
||||
fun getGridSize(): Int {
|
||||
if (gridSize == 0) {
|
||||
gridSize = if (isLandscape) {
|
||||
|
@ -71,19 +69,8 @@ abstract class AbsLibraryPagerRecyclerViewCustomGridSizeFragment<A : RecyclerVie
|
|||
setSortOrder(sortOrder)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return whether the palette should be used at all or not
|
||||
*/
|
||||
fun usePalette(): Boolean {
|
||||
if (!usePaletteInitialized) {
|
||||
usePalette = loadUsePalette()
|
||||
usePaletteInitialized = true
|
||||
}
|
||||
return usePalette
|
||||
}
|
||||
|
||||
fun setAndSaveGridSize(gridSize: Int) {
|
||||
val oldLayoutRes = itemLayoutRes
|
||||
val oldLayoutRes = itemLayoutRes()
|
||||
this.gridSize = gridSize
|
||||
if (isLandscape) {
|
||||
saveGridSizeLand(gridSize)
|
||||
|
@ -91,7 +78,7 @@ abstract class AbsLibraryPagerRecyclerViewCustomGridSizeFragment<A : RecyclerVie
|
|||
saveGridSize(gridSize)
|
||||
}
|
||||
// only recreate the adapter and layout manager if the layout currentLayoutRes has changed
|
||||
if (oldLayoutRes != itemLayoutRes) {
|
||||
if (oldLayoutRes != itemLayoutRes()) {
|
||||
invalidateLayoutManager()
|
||||
invalidateAdapter()
|
||||
} else {
|
||||
|
@ -99,19 +86,6 @@ abstract class AbsLibraryPagerRecyclerViewCustomGridSizeFragment<A : RecyclerVie
|
|||
}
|
||||
}
|
||||
|
||||
fun setAndSaveUsePalette(usePalette: Boolean) {
|
||||
this.usePalette = usePalette
|
||||
saveUsePalette(usePalette)
|
||||
setUsePalette(usePalette)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return whether the palette option should be available for the current item layout or not
|
||||
*/
|
||||
fun canUsePalette(): Boolean {
|
||||
return itemLayoutRes == R.layout.item_card_color
|
||||
}
|
||||
|
||||
protected fun notifyLayoutResChanged(@LayoutRes res: Int) {
|
||||
this.currentLayoutRes = res
|
||||
val recyclerView = recyclerView()
|
||||
|
@ -149,4 +123,8 @@ abstract class AbsLibraryPagerRecyclerViewCustomGridSizeFragment<A : RecyclerVie
|
|||
protected abstract fun loadUsePalette(): Boolean
|
||||
|
||||
protected abstract fun setUsePalette(usePalette: Boolean)
|
||||
|
||||
protected abstract fun loadLayoutRes(): Int
|
||||
|
||||
protected abstract fun saveLayoutRes(layoutRes: Int)
|
||||
}
|
||||
|
|
|
@ -10,15 +10,16 @@ import androidx.recyclerview.widget.RecyclerView
|
|||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||
import code.name.monkey.retromusic.util.DensityUtil
|
||||
import code.name.monkey.retromusic.util.ViewUtil
|
||||
import code.name.monkey.retromusic.util.ThemedFastScroller.create
|
||||
import code.name.monkey.retromusic.views.ScrollingViewOnApplyWindowInsetsListener
|
||||
import com.google.android.material.appbar.AppBarLayout
|
||||
import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView
|
||||
import kotlinx.android.synthetic.main.fragment_main_activity_recycler_view.container
|
||||
import kotlinx.android.synthetic.main.fragment_main_activity_recycler_view.empty
|
||||
import kotlinx.android.synthetic.main.fragment_main_activity_recycler_view.emptyEmoji
|
||||
import kotlinx.android.synthetic.main.fragment_main_activity_recycler_view.emptyText
|
||||
import kotlinx.android.synthetic.main.fragment_main_activity_recycler_view.recyclerView
|
||||
import me.everything.android.ui.overscroll.OverScrollDecoratorHelper
|
||||
import me.zhanghai.android.fastscroll.FastScroller
|
||||
import me.zhanghai.android.fastscroll.FastScrollerBuilder
|
||||
|
||||
abstract class AbsLibraryPagerRecyclerViewFragment<A : RecyclerView.Adapter<*>, LM : RecyclerView.LayoutManager> :
|
||||
AbsLibraryPagerFragment(), AppBarLayout.OnOffsetChangedListener {
|
||||
|
@ -41,13 +42,21 @@ abstract class AbsLibraryPagerRecyclerViewFragment<A : RecyclerView.Adapter<*>,
|
|||
}
|
||||
|
||||
private fun setUpRecyclerView() {
|
||||
if (recyclerView is FastScrollRecyclerView) {
|
||||
ViewUtil.setUpFastScrollRecyclerViewColor(requireActivity(), recyclerView as FastScrollRecyclerView)
|
||||
}
|
||||
|
||||
recyclerView.layoutManager = layoutManager
|
||||
recyclerView.adapter = adapter
|
||||
val fastScroller = create(recyclerView)
|
||||
recyclerView.setOnApplyWindowInsetsListener(
|
||||
ScrollingViewOnApplyWindowInsetsListener(
|
||||
recyclerView,
|
||||
fastScroller
|
||||
)
|
||||
)
|
||||
//OverScrollDecoratorHelper.setUpOverScroll(recyclerView, OverScrollDecoratorHelper.ORIENTATION_VERTICAL)
|
||||
}
|
||||
|
||||
OverScrollDecoratorHelper.setUpOverScroll(recyclerView, OverScrollDecoratorHelper.ORIENTATION_VERTICAL)
|
||||
protected open fun createFastScroller(recyclerView: RecyclerView): FastScroller {
|
||||
return FastScrollerBuilder(recyclerView).useMd2Style().build()
|
||||
}
|
||||
|
||||
private fun initAdapter() {
|
||||
|
|
|
@ -53,13 +53,13 @@ open class AlbumsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<Al
|
|||
}
|
||||
|
||||
override fun createAdapter(): AlbumAdapter {
|
||||
var itemLayoutRes = itemLayoutRes
|
||||
/* var itemLayoutRes = itemLayoutRes
|
||||
notifyLayoutResChanged(itemLayoutRes)
|
||||
if (itemLayoutRes != R.layout.item_list) {
|
||||
itemLayoutRes = PreferenceUtil.getInstance(requireContext()).getAlbumGridStyle(requireContext())
|
||||
}
|
||||
}*/
|
||||
val dataSet = if (adapter == null) ArrayList() else adapter!!.dataSet
|
||||
return AlbumAdapter(libraryFragment.mainActivity, dataSet, itemLayoutRes, loadUsePalette(), libraryFragment)
|
||||
return AlbumAdapter(libraryFragment.mainActivity, dataSet, itemLayoutRes(), loadUsePalette(), libraryFragment)
|
||||
}
|
||||
|
||||
public override fun loadUsePalette(): Boolean {
|
||||
|
@ -76,37 +76,30 @@ open class AlbumsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<Al
|
|||
}
|
||||
|
||||
override fun loadSortOrder(): String {
|
||||
|
||||
return PreferenceUtil.getInstance(requireContext()).albumSortOrder
|
||||
}
|
||||
|
||||
override fun saveSortOrder(sortOrder: String) {
|
||||
|
||||
PreferenceUtil.getInstance(requireContext()).albumSortOrder = sortOrder
|
||||
}
|
||||
|
||||
override fun loadGridSize(): Int {
|
||||
|
||||
return PreferenceUtil.getInstance(requireContext()).getAlbumGridSize(activity!!)
|
||||
}
|
||||
|
||||
override fun saveGridSize(gridColumns: Int) {
|
||||
|
||||
PreferenceUtil.getInstance(requireContext()).setAlbumGridSize(gridColumns)
|
||||
}
|
||||
|
||||
override fun loadGridSizeLand(): Int {
|
||||
|
||||
return PreferenceUtil.getInstance(requireContext()).getAlbumGridSizeLand(activity!!)
|
||||
}
|
||||
|
||||
override fun saveGridSizeLand(gridColumns: Int) {
|
||||
|
||||
PreferenceUtil.getInstance(requireContext()).setAlbumGridSizeLand(gridColumns)
|
||||
}
|
||||
|
||||
override fun saveUsePalette(usePalette: Boolean) {
|
||||
|
||||
PreferenceUtil.getInstance(requireContext()).setAlbumColoredFooters(usePalette)
|
||||
}
|
||||
|
||||
|
@ -122,6 +115,18 @@ open class AlbumsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<Al
|
|||
adapter?.swapDataSet(ArrayList())
|
||||
}
|
||||
|
||||
override fun setLayoutRes(layoutRes: Int) {
|
||||
//adapter?.itemCount?.let { adapter?.notifyItemRangeChanged(0, it) }
|
||||
}
|
||||
|
||||
override fun loadLayoutRes(): Int {
|
||||
return PreferenceUtil.getInstance(requireContext()).albumGridStyle
|
||||
}
|
||||
|
||||
override fun saveLayoutRes(layoutRes: Int) {
|
||||
PreferenceUtil.getInstance(requireContext()).albumGridStyle = layoutRes
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmField
|
||||
var TAG: String = AlbumsFragment::class.java.simpleName
|
||||
|
|
|
@ -61,13 +61,14 @@ class ArtistsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<Artist
|
|||
}
|
||||
|
||||
override fun createAdapter(): ArtistAdapter {
|
||||
var itemLayoutRes = itemLayoutRes
|
||||
notifyLayoutResChanged(itemLayoutRes)
|
||||
if (itemLayoutRes != R.layout.item_list) {
|
||||
itemLayoutRes = PreferenceUtil.getInstance(requireContext()).getArtistGridStyle(requireContext())
|
||||
}
|
||||
val dataSet = if (adapter == null) ArrayList() else adapter!!.dataSet
|
||||
return ArtistAdapter(libraryFragment.mainActivity, dataSet, itemLayoutRes, loadUsePalette(), libraryFragment)
|
||||
return ArtistAdapter(
|
||||
libraryFragment.mainActivity,
|
||||
dataSet,
|
||||
itemLayoutRes(),
|
||||
loadUsePalette(),
|
||||
libraryFragment
|
||||
)
|
||||
}
|
||||
|
||||
override fun loadGridSize(): Int {
|
||||
|
@ -128,4 +129,15 @@ class ArtistsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<Artist
|
|||
return fragment
|
||||
}
|
||||
}
|
||||
|
||||
override fun setLayoutRes(layoutRes: Int) {
|
||||
}
|
||||
|
||||
override fun loadLayoutRes(): Int {
|
||||
return PreferenceUtil.getInstance(requireContext()).artistGridStyle
|
||||
}
|
||||
|
||||
override fun saveLayoutRes(layoutRes: Int) {
|
||||
PreferenceUtil.getInstance(requireContext()).artistGridStyle = layoutRes
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,6 @@ import code.name.monkey.retromusic.util.RetroUtil;
|
|||
import com.afollestad.materialcab.MaterialCab;
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.google.android.material.card.MaterialCardView;
|
||||
import io.reactivex.disposables.CompositeDisposable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class LibraryFragment extends AbsMainActivityFragment implements CabHolder, MainActivityFragmentCallbacks {
|
||||
|
@ -48,8 +47,6 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde
|
|||
|
||||
private MaterialCab cab;
|
||||
|
||||
private CompositeDisposable disposable;
|
||||
|
||||
private FragmentManager fragmentManager;
|
||||
|
||||
private Toolbar toolbar;
|
||||
|
@ -76,7 +73,6 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde
|
|||
@Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.fragment_library, container, false);
|
||||
disposable = new CompositeDisposable();
|
||||
appBarLayout = view.findViewById(R.id.appBarLayout);
|
||||
toolbarContainer = view.findViewById(R.id.toolbarContainer);
|
||||
toolbar = view.findViewById(R.id.toolbar);
|
||||
|
@ -91,11 +87,6 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde
|
|||
inflateFragment();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
disposable.dispose();
|
||||
}
|
||||
|
||||
public void addOnAppBarOffsetChangedListener(
|
||||
@NonNull AppBarLayout.OnOffsetChangedListener onOffsetChangedListener) {
|
||||
|
@ -126,11 +117,18 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde
|
|||
AbsLibraryPagerRecyclerViewCustomGridSizeFragment fragment
|
||||
= (AbsLibraryPagerRecyclerViewCustomGridSizeFragment) currentFragment;
|
||||
|
||||
if (fragment instanceof SongsFragment) {
|
||||
menu.removeItem(R.id.action_grid_size);
|
||||
menu.removeItem(R.id.action_layout_type);
|
||||
} else {
|
||||
MenuItem gridSizeItem = menu.findItem(R.id.action_grid_size);
|
||||
if (RetroUtil.isLandscape()) {
|
||||
gridSizeItem.setTitle(R.string.action_grid_size_land);
|
||||
}
|
||||
setUpGridSizeMenu(fragment, gridSizeItem.getSubMenu());
|
||||
MenuItem layoutItem = menu.findItem(R.id.action_layout_type);
|
||||
setupLayoutMenu(fragment, layoutItem.getSubMenu());
|
||||
}
|
||||
|
||||
setUpSortOrderMenu(fragment, menu.findItem(R.id.action_sort_order).getSubMenu());
|
||||
|
||||
|
@ -157,6 +155,9 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde
|
|||
if (handleGridSizeMenuItem(fragment, item)) {
|
||||
return true;
|
||||
}
|
||||
if (handleLayoutResType(fragment, item)) {
|
||||
return true;
|
||||
}
|
||||
if (handleSortOrderMenuItem(fragment, item)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -220,8 +221,8 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde
|
|||
}
|
||||
|
||||
private boolean handleGridSizeMenuItem(
|
||||
@NonNull AbsLibraryPagerRecyclerViewCustomGridSizeFragment
|
||||
fragment, @NonNull MenuItem item) {
|
||||
@NonNull AbsLibraryPagerRecyclerViewCustomGridSizeFragment fragment,
|
||||
@NonNull MenuItem item) {
|
||||
int gridSize = 0;
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_grid_size_1:
|
||||
|
@ -258,6 +259,38 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde
|
|||
return false;
|
||||
}
|
||||
|
||||
private boolean handleLayoutResType(
|
||||
final AbsLibraryPagerRecyclerViewCustomGridSizeFragment fragment,
|
||||
final MenuItem item) {
|
||||
int layoutRes = -1;
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_layout_normal:
|
||||
layoutRes = R.layout.item_grid;
|
||||
break;
|
||||
case R.id.action_layout_card:
|
||||
layoutRes = R.layout.item_card;
|
||||
break;
|
||||
case R.id.action_layout_colored_card:
|
||||
layoutRes = R.layout.item_card_color;
|
||||
break;
|
||||
case R.id.action_layout_circular:
|
||||
layoutRes = R.layout.item_grid_circle;
|
||||
break;
|
||||
case R.id.action_layout_image:
|
||||
layoutRes = R.layout.image;
|
||||
break;
|
||||
case R.id.action_layout_gradient_image:
|
||||
layoutRes = R.layout.item_image_gradient;
|
||||
break;
|
||||
}
|
||||
if (layoutRes != -1) {
|
||||
item.setChecked(true);
|
||||
fragment.setAndSaveLayoutRes(layoutRes);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean handleSortOrderMenuItem(
|
||||
@NonNull AbsLibraryPagerRecyclerViewCustomGridSizeFragment
|
||||
fragment, @NonNull MenuItem item) {
|
||||
|
@ -448,7 +481,31 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde
|
|||
sortOrderMenu.setGroupCheckable(0, true, true);
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
private void setupLayoutMenu(
|
||||
@NonNull final AbsLibraryPagerRecyclerViewCustomGridSizeFragment fragment,
|
||||
@NonNull final SubMenu subMenu) {
|
||||
switch (fragment.itemLayoutRes()) {
|
||||
case R.layout.item_card:
|
||||
subMenu.findItem(R.id.action_layout_card).setChecked(true);
|
||||
break;
|
||||
case R.layout.item_grid:
|
||||
subMenu.findItem(R.id.action_layout_normal).setChecked(true);
|
||||
break;
|
||||
case R.layout.item_card_color:
|
||||
subMenu.findItem(R.id.action_layout_colored_card).setChecked(true);
|
||||
break;
|
||||
case R.layout.item_grid_circle:
|
||||
subMenu.findItem(R.id.action_layout_circular).setChecked(true);
|
||||
break;
|
||||
case R.layout.image:
|
||||
subMenu.findItem(R.id.action_layout_image).setChecked(true);
|
||||
break;
|
||||
case R.layout.item_image_gradient:
|
||||
subMenu.findItem(R.id.action_layout_gradient_image).setChecked(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void setupToolbar() {
|
||||
toolbar.setBackgroundTintList(
|
||||
ColorStateList.valueOf(ATHUtil.INSTANCE.resolveColor(requireContext(), R.attr.colorSurface)));
|
||||
|
@ -462,6 +519,5 @@ public class LibraryFragment extends AbsMainActivityFragment implements CabHolde
|
|||
getMainActivity().setSupportActionBar(toolbar);
|
||||
toolbar.setNavigationOnClickListener(v -> showMainMenu(OptionsSheetDialogFragment.LIBRARY));
|
||||
ToolbarContentTintHelper.colorBackButton(toolbar);
|
||||
//toolbar.setTitleTextColor(ATHUtil.INSTANCE.resolveColor(requireContext(), R.attr.colorOnSecondary));
|
||||
}
|
||||
}
|
|
@ -2,7 +2,8 @@ package code.name.monkey.retromusic.fragments.mainactivity
|
|||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.annotation.LayoutRes
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import code.name.monkey.retromusic.App
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.adapter.song.ShuffleButtonSongAdapter
|
||||
|
@ -12,15 +13,15 @@ import code.name.monkey.retromusic.model.Song
|
|||
import code.name.monkey.retromusic.mvp.presenter.SongPresenter
|
||||
import code.name.monkey.retromusic.mvp.presenter.SongView
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import java.util.*
|
||||
import java.util.ArrayList
|
||||
import javax.inject.Inject
|
||||
|
||||
class SongsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<SongAdapter, GridLayoutManager>(), SongView {
|
||||
class SongsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<SongAdapter, LinearLayoutManager>(),
|
||||
SongView {
|
||||
|
||||
@Inject
|
||||
lateinit var songPresenter: SongPresenter
|
||||
|
||||
|
||||
override val emptyMessage: Int
|
||||
get() = R.string.no_songs
|
||||
|
||||
|
@ -34,20 +35,18 @@ class SongsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<SongAdap
|
|||
songPresenter.attachView(this)
|
||||
}
|
||||
|
||||
override fun createLayoutManager(): GridLayoutManager {
|
||||
return GridLayoutManager(activity, getGridSize())
|
||||
override fun createLayoutManager(): LinearLayoutManager {
|
||||
return LinearLayoutManager(activity)
|
||||
}
|
||||
|
||||
override fun createAdapter(): SongAdapter {
|
||||
val itemLayoutRes = itemLayoutRes
|
||||
notifyLayoutResChanged(itemLayoutRes)
|
||||
val usePalette = loadUsePalette()
|
||||
|
||||
val dataSet = if (adapter == null) ArrayList() else adapter!!.dataSet
|
||||
|
||||
return if (getGridSize() <= maxGridSizeForList) {
|
||||
ShuffleButtonSongAdapter(libraryFragment.mainActivity, dataSet, itemLayoutRes, usePalette, libraryFragment)
|
||||
} else SongAdapter(libraryFragment.mainActivity, dataSet, itemLayoutRes, usePalette, libraryFragment)
|
||||
return ShuffleButtonSongAdapter(
|
||||
libraryFragment.mainActivity,
|
||||
dataSet,
|
||||
R.layout.item_list,
|
||||
libraryFragment
|
||||
)
|
||||
}
|
||||
|
||||
override fun songs(songs: ArrayList<Song>) {
|
||||
|
@ -83,11 +82,9 @@ class SongsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<SongAdap
|
|||
}
|
||||
|
||||
public override fun setUsePalette(usePalette: Boolean) {
|
||||
adapter?.usePalette(usePalette)
|
||||
}
|
||||
|
||||
override fun setGridSize(gridSize: Int) {
|
||||
layoutManager?.spanCount = gridSize
|
||||
adapter?.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
|
@ -131,4 +128,15 @@ class SongsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<SongAdap
|
|||
return fragment
|
||||
}
|
||||
}
|
||||
|
||||
override fun setLayoutRes(@LayoutRes layoutRes: Int) {
|
||||
}
|
||||
|
||||
@LayoutRes
|
||||
override fun loadLayoutRes(): Int {
|
||||
return R.layout.item_list
|
||||
}
|
||||
|
||||
override fun saveLayoutRes(@LayoutRes layoutRes: Int) {
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -111,6 +111,7 @@ class PlayerPlaybackControlsFragment : AbsPlayerControlsFragment(), OnSharedPref
|
|||
val song = MusicPlayerRemote.currentSong
|
||||
title.text = song.title
|
||||
text.text = song.artistName
|
||||
|
||||
if (PreferenceUtil.getInstance(requireContext()).isSongInfo) {
|
||||
songInfo?.text = getSongInfo(song)
|
||||
} else {
|
||||
|
@ -266,7 +267,7 @@ class PlayerPlaybackControlsFragment : AbsPlayerControlsFragment(), OnSharedPref
|
|||
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
|
||||
println(key)
|
||||
if (key == PreferenceUtil.EXTRA_SONG_INFO) {
|
||||
updateSong()
|
||||
if (activity != null) updateSong()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -41,11 +41,7 @@ class PersonalizeSettingsFragment : AbsSettingsFragment(), SharedPreferences.OnS
|
|||
super.onViewCreated(view, savedInstanceState)
|
||||
PreferenceUtil.getInstance(requireContext()).registerOnSharedPreferenceChangedListener(this)
|
||||
|
||||
var preference: Preference? = findPreference("album_grid_style")
|
||||
setSummary(preference!!)
|
||||
preference = findPreference("artist_grid_style")
|
||||
setSummary(preference!!)
|
||||
preference = findPreference("home_artist_grid_style")
|
||||
var preference: Preference? = findPreference("home_artist_grid_style")
|
||||
setSummary(preference!!)
|
||||
preference = findPreference("tab_text_mode")
|
||||
setSummary(preference!!)
|
||||
|
|
|
@ -16,7 +16,12 @@ package code.name.monkey.retromusic.helper
|
|||
|
||||
import android.annotation.TargetApi
|
||||
import android.app.Activity
|
||||
import android.content.*
|
||||
import android.content.ComponentName
|
||||
import android.content.ContentResolver
|
||||
import android.content.Context
|
||||
import android.content.ContextWrapper
|
||||
import android.content.Intent
|
||||
import android.content.ServiceConnection
|
||||
import android.database.Cursor
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
|
@ -32,8 +37,9 @@ import code.name.monkey.retromusic.model.Song
|
|||
import code.name.monkey.retromusic.service.MusicService
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
|
||||
import java.util.ArrayList
|
||||
import java.util.Random
|
||||
import java.util.WeakHashMap
|
||||
|
||||
object MusicPlayerRemote {
|
||||
val TAG: String = MusicPlayerRemote::class.java.simpleName
|
||||
|
@ -116,7 +122,12 @@ object MusicPlayerRemote {
|
|||
}
|
||||
val binder = ServiceBinder(callback)
|
||||
|
||||
if (contextWrapper.bindService(Intent().setClass(contextWrapper, MusicService::class.java), binder, Context.BIND_AUTO_CREATE)) {
|
||||
if (contextWrapper.bindService(
|
||||
Intent().setClass(contextWrapper, MusicService::class.java),
|
||||
binder,
|
||||
Context.BIND_AUTO_CREATE
|
||||
)
|
||||
) {
|
||||
mConnectionMap[contextWrapper] = binder
|
||||
return ServiceToken(contextWrapper)
|
||||
}
|
||||
|
@ -234,7 +245,11 @@ object MusicPlayerRemote {
|
|||
}
|
||||
}
|
||||
|
||||
private fun tryToHandleOpenPlayingQueue(queue: ArrayList<Song>, startPosition: Int, startPlaying: Boolean): Boolean {
|
||||
private fun tryToHandleOpenPlayingQueue(
|
||||
queue: ArrayList<Song>,
|
||||
startPosition: Int,
|
||||
startPlaying: Boolean
|
||||
): Boolean {
|
||||
if (playingQueue === queue) {
|
||||
if (startPlaying) {
|
||||
playSongAt(startPosition)
|
||||
|
@ -291,7 +306,11 @@ object MusicPlayerRemote {
|
|||
queue.add(song)
|
||||
openQueue(queue, 0, false)
|
||||
}
|
||||
Toast.makeText(musicService, musicService!!.resources.getString(code.name.monkey.retromusic.R.string.added_title_to_playing_queue), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(
|
||||
musicService,
|
||||
musicService!!.resources.getString(code.name.monkey.retromusic.R.string.added_title_to_playing_queue),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
return true
|
||||
}
|
||||
return false
|
||||
|
@ -304,7 +323,11 @@ object MusicPlayerRemote {
|
|||
} else {
|
||||
openQueue(songs, 0, false)
|
||||
}
|
||||
val toast = if (songs.size == 1) musicService!!.resources.getString(code.name.monkey.retromusic.R.string.added_title_to_playing_queue) else musicService!!.resources.getString(code.name.monkey.retromusic.R.string.added_x_titles_to_playing_queue, songs.size)
|
||||
val toast =
|
||||
if (songs.size == 1) musicService!!.resources.getString(code.name.monkey.retromusic.R.string.added_title_to_playing_queue) else musicService!!.resources.getString(
|
||||
code.name.monkey.retromusic.R.string.added_x_titles_to_playing_queue,
|
||||
songs.size
|
||||
)
|
||||
Toast.makeText(musicService, toast, Toast.LENGTH_SHORT).show()
|
||||
return true
|
||||
}
|
||||
|
@ -320,7 +343,11 @@ object MusicPlayerRemote {
|
|||
queue.add(song)
|
||||
openQueue(queue, 0, false)
|
||||
}
|
||||
Toast.makeText(musicService, musicService!!.resources.getString(code.name.monkey.retromusic.R.string.added_title_to_playing_queue), Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(
|
||||
musicService,
|
||||
musicService!!.resources.getString(code.name.monkey.retromusic.R.string.added_title_to_playing_queue),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
return true
|
||||
}
|
||||
return false
|
||||
|
@ -333,7 +360,11 @@ object MusicPlayerRemote {
|
|||
} else {
|
||||
openQueue(songs, 0, false)
|
||||
}
|
||||
val toast = if (songs.size == 1) musicService!!.resources.getString(code.name.monkey.retromusic.R.string.added_title_to_playing_queue) else musicService!!.resources.getString(code.name.monkey.retromusic.R.string.added_x_titles_to_playing_queue, songs.size)
|
||||
val toast =
|
||||
if (songs.size == 1) musicService!!.resources.getString(code.name.monkey.retromusic.R.string.added_title_to_playing_queue) else musicService!!.resources.getString(
|
||||
code.name.monkey.retromusic.R.string.added_x_titles_to_playing_queue,
|
||||
songs.size
|
||||
)
|
||||
Toast.makeText(musicService, toast, Toast.LENGTH_SHORT).show()
|
||||
return true
|
||||
}
|
||||
|
@ -385,18 +416,21 @@ object MusicPlayerRemote {
|
|||
songId = uri.lastPathSegment
|
||||
}
|
||||
if (songId != null) {
|
||||
songs = SongLoader.getSongs(SongLoader.makeSongCursor(
|
||||
songs = SongLoader.getSongs(
|
||||
SongLoader.makeSongCursor(
|
||||
musicService!!,
|
||||
MediaStore.Audio.AudioColumns._ID + "=?",
|
||||
arrayOf(songId)
|
||||
))
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (songs == null) {
|
||||
var songFile: File? = null
|
||||
if (uri.authority != null && uri.authority == "com.android.externalstorage.documents") {
|
||||
songFile = File(Environment.getExternalStorageDirectory(), uri.path?.split(":".toRegex(), 2)?.get(1))
|
||||
songFile =
|
||||
File(Environment.getExternalStorageDirectory(), uri.path?.split(":".toRegex(), 2)?.get(1))
|
||||
}
|
||||
if (songFile == null) {
|
||||
val path = getFilePathFromUri(musicService!!, uri)
|
||||
|
@ -407,11 +441,13 @@ object MusicPlayerRemote {
|
|||
songFile = File(uri.path)
|
||||
}
|
||||
if (songFile != null) {
|
||||
songs = SongLoader.getSongs(SongLoader.makeSongCursor(
|
||||
songs = SongLoader.getSongs(
|
||||
SongLoader.makeSongCursor(
|
||||
musicService!!,
|
||||
MediaStore.Audio.AudioColumns.DATA + "=?",
|
||||
arrayOf(songFile.absolutePath)
|
||||
))
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
if (songs != null && songs.isNotEmpty()) {
|
||||
|
@ -442,5 +478,4 @@ object MusicPlayerRemote {
|
|||
}
|
||||
|
||||
class ServiceToken internal constructor(internal var mWrappedContext: ContextWrapper)
|
||||
|
||||
}
|
||||
|
|
|
@ -112,7 +112,7 @@ public class MusicUtil {
|
|||
|
||||
@NonNull
|
||||
public static String getPlaylistInfoString(@NonNull final Context context, @NonNull List<Song> songs) {
|
||||
final long duration = getTotalDuration(context, songs);
|
||||
final long duration = getTotalDuration(songs);
|
||||
|
||||
return MusicUtil.buildInfoString(
|
||||
MusicUtil.getSongCountString(context, songs.size()),
|
||||
|
@ -388,7 +388,7 @@ public class MusicUtil {
|
|||
if (musicMediaTitle.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
return String.valueOf(musicMediaTitle.charAt(0)).toUpperCase();
|
||||
return musicMediaTitle.substring(0, 1).toUpperCase();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
@ -400,7 +400,7 @@ public class MusicUtil {
|
|||
MusicUtil.playlist = playlist;
|
||||
}
|
||||
|
||||
public static long getTotalDuration(@NonNull final Context context, @NonNull List<Song> songs) {
|
||||
public static long getTotalDuration(@NonNull List<Song> songs) {
|
||||
long duration = 0;
|
||||
for (int i = 0; i < songs.size(); i++) {
|
||||
duration += songs.get(i).getDuration();
|
||||
|
@ -408,7 +408,7 @@ public class MusicUtil {
|
|||
return duration;
|
||||
}
|
||||
|
||||
public static int indexOfSongInList(List<Song> songs, int songId) {
|
||||
public static int indexOfSongInList(@NonNull List<Song> songs, int songId) {
|
||||
for (int i = 0; i < songs.size(); i++) {
|
||||
if (songs.get(i).getId() == songId) {
|
||||
return i;
|
||||
|
|
|
@ -28,7 +28,6 @@ import androidx.annotation.LayoutRes;
|
|||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.StyleRes;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
import code.name.monkey.retromusic.App;
|
||||
import code.name.monkey.retromusic.R;
|
||||
import code.name.monkey.retromusic.activities.MainActivity;
|
||||
import code.name.monkey.retromusic.fragments.AlbumCoverStyle;
|
||||
|
@ -118,11 +117,11 @@ public final class PreferenceUtil {
|
|||
|
||||
public static final String TOGGLE_SEPARATE_LINE = "toggle_separate_line";
|
||||
|
||||
public static final String ALBUM_GRID_STYLE = "album_grid_style";
|
||||
public static final String ALBUM_GRID_STYLE = "album_grid_style_home";
|
||||
|
||||
public static final String HOME_ARTIST_GRID_STYLE = "home_artist_grid_style";
|
||||
|
||||
public static final String ARTIST_GRID_STYLE = "artist_grid_style";
|
||||
public static final String ARTIST_GRID_STYLE = "artist_grid_style_home";
|
||||
|
||||
public static final String TOGGLE_ADD_CONTROLS = "toggle_add_controls";
|
||||
|
||||
|
@ -233,7 +232,7 @@ public final class PreferenceUtil {
|
|||
@NonNull
|
||||
public static PreferenceUtil getInstance(Context context) {
|
||||
if (sInstance == null) {
|
||||
sInstance = new PreferenceUtil(App.Companion.getContext());
|
||||
sInstance = new PreferenceUtil(context);
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
@ -249,7 +248,7 @@ public final class PreferenceUtil {
|
|||
}
|
||||
}
|
||||
|
||||
public static boolean isAllowedToDownloadMetadata(final Context context) {
|
||||
public static boolean isAllowedToDownloadMetadata(@NonNull Context context) {
|
||||
switch (getInstance(context).autoDownloadImagesPolicy()) {
|
||||
case "always":
|
||||
return true;
|
||||
|
@ -392,26 +391,25 @@ public final class PreferenceUtil {
|
|||
return layoutRes;
|
||||
}
|
||||
|
||||
public final int getAlbumGridSize(Context context) {
|
||||
public final int getAlbumGridSize(@NonNull Context context) {
|
||||
return mPreferences
|
||||
.getInt(ALBUM_GRID_SIZE, context.getResources().getInteger(R.integer.default_grid_columns));
|
||||
}
|
||||
|
||||
public final int getAlbumGridSizeLand(Context context) {
|
||||
return mPreferences.getInt(ALBUM_GRID_SIZE_LAND,
|
||||
context.getResources().getInteger(R.integer.default_grid_columns_land));
|
||||
public final int getAlbumGridSizeLand(@NonNull Context context) {
|
||||
return mPreferences
|
||||
.getInt(ALBUM_GRID_SIZE_LAND, context.getResources().getInteger(R.integer.default_grid_columns_land));
|
||||
}
|
||||
|
||||
@LayoutRes
|
||||
public int getAlbumGridStyle(Context context) {
|
||||
int pos = Integer.parseInt(mPreferences.getString(ALBUM_GRID_STYLE, "0"));
|
||||
TypedArray typedArray = context.getResources().obtainTypedArray(R.array.pref_grid_style_layout);
|
||||
int layoutRes = typedArray.getResourceId(pos, -1);
|
||||
typedArray.recycle();
|
||||
if (layoutRes == -1) {
|
||||
return R.layout.item_card;
|
||||
public int getAlbumGridStyle() {
|
||||
return mPreferences.getInt(ALBUM_GRID_STYLE, R.layout.item_grid);
|
||||
}
|
||||
return layoutRes;
|
||||
|
||||
public void setAlbumGridStyle(int layoutRes) {
|
||||
mPreferences.edit()
|
||||
.putInt(ALBUM_GRID_STYLE, layoutRes)
|
||||
.apply();
|
||||
}
|
||||
|
||||
public final String getAlbumSongSortOrder() {
|
||||
|
@ -455,15 +453,12 @@ public final class PreferenceUtil {
|
|||
}
|
||||
|
||||
@LayoutRes
|
||||
public int getArtistGridStyle(Context context) {
|
||||
int pos = Integer.parseInt(Objects.requireNonNull(mPreferences.getString(ARTIST_GRID_STYLE, "0")));
|
||||
TypedArray typedArray = context.getResources().obtainTypedArray(R.array.pref_grid_style_layout);
|
||||
int layoutRes = typedArray.getResourceId(pos, -1);
|
||||
typedArray.recycle();
|
||||
if (layoutRes == -1) {
|
||||
return R.layout.item_card;
|
||||
public int getArtistGridStyle() {
|
||||
return mPreferences.getInt(ARTIST_GRID_STYLE, R.layout.item_grid);
|
||||
}
|
||||
return layoutRes;
|
||||
|
||||
public void setArtistGridStyle(int viewAs) {
|
||||
mPreferences.edit().putInt(ARTIST_GRID_STYLE, viewAs).apply();
|
||||
}
|
||||
|
||||
public final String getArtistSongSortOrder() {
|
||||
|
@ -699,10 +694,6 @@ public final class PreferenceUtil {
|
|||
return mPreferences.getBoolean(SLEEP_TIMER_FINISH_SONG, false);
|
||||
}
|
||||
|
||||
public boolean isSongInfo() {
|
||||
return mPreferences.getBoolean(EXTRA_SONG_INFO, false);
|
||||
}
|
||||
|
||||
public void setSleepTimerFinishMusic(final boolean value) {
|
||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
||||
editor.putBoolean(SLEEP_TIMER_FINISH_SONG, value);
|
||||
|
@ -836,6 +827,10 @@ public final class PreferenceUtil {
|
|||
return mPreferences.getBoolean(SNOW_FALL_EFFECT, false);
|
||||
}
|
||||
|
||||
public boolean isSongInfo() {
|
||||
return mPreferences.getBoolean(EXTRA_SONG_INFO, false);
|
||||
}
|
||||
|
||||
public boolean pauseOnZeroVolume() {
|
||||
return mPreferences.getBoolean(PAUSE_ON_ZERO_VOLUME, false);
|
||||
}
|
||||
|
@ -899,10 +894,6 @@ public final class PreferenceUtil {
|
|||
editor.apply();
|
||||
}
|
||||
|
||||
public void setArtistGridStyle(int viewAs) {
|
||||
mPreferences.edit().putInt(ARTIST_GRID_STYLE, viewAs).apply();
|
||||
}
|
||||
|
||||
public void setBannerImagePath(String bannerImagePath) {
|
||||
mPreferences.edit().putString(BANNER_IMAGE_PATH, bannerImagePath)
|
||||
.apply();
|
||||
|
@ -980,17 +971,6 @@ public final class PreferenceUtil {
|
|||
return mPreferences.getBoolean(SONG_COLORED_FOOTERS, false);
|
||||
}
|
||||
|
||||
public final boolean synchronizedLyricsShow() {
|
||||
return mPreferences.getBoolean(SYNCHRONIZED_LYRICS_SHOW, true);
|
||||
}
|
||||
|
||||
public boolean tabTitles() {
|
||||
return getTabTitleMode() != LabelVisibilityMode.LABEL_VISIBILITY_UNLABELED;
|
||||
}
|
||||
|
||||
public boolean toggleSeparateLine() {
|
||||
return mPreferences.getBoolean(TOGGLE_SEPARATE_LINE, false);
|
||||
}
|
||||
|
||||
public void unregisterOnSharedPreferenceChangedListener(
|
||||
@NonNull OnSharedPreferenceChangeListener sharedPreferenceChangeListener) {
|
||||
|
|
|
@ -19,25 +19,27 @@ import android.content.res.TypedArray;
|
|||
import android.graphics.Paint;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.TypedValue;
|
||||
|
||||
import androidx.annotation.FontRes;
|
||||
|
||||
import com.google.android.material.textview.MaterialTextView;
|
||||
|
||||
import code.name.monkey.retromusic.R;
|
||||
import com.google.android.material.textview.MaterialTextView;
|
||||
|
||||
public class BaselineGridTextView extends MaterialTextView {
|
||||
|
||||
private final float FOUR_DIP;
|
||||
|
||||
private float lineHeightMultiplierHint = 1f;
|
||||
private float lineHeightHint = 0f;
|
||||
private boolean maxLinesByHeight = false;
|
||||
private int extraTopPadding = 0;
|
||||
private int extraBottomPadding = 0;
|
||||
|
||||
private int extraTopPadding = 0;
|
||||
|
||||
private @FontRes
|
||||
int fontResId = 0;
|
||||
|
||||
private float lineHeightHint = 0f;
|
||||
|
||||
private float lineHeightMultiplierHint = 1f;
|
||||
|
||||
private boolean maxLinesByHeight = false;
|
||||
|
||||
public BaselineGridTextView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
@ -73,13 +75,21 @@ public class BaselineGridTextView extends MaterialTextView {
|
|||
computeLineHeight();
|
||||
}
|
||||
|
||||
public float getLineHeightMultiplierHint() {
|
||||
return lineHeightMultiplierHint;
|
||||
@Override
|
||||
public int getCompoundPaddingBottom() {
|
||||
// include extra padding to make the height a multiple of 4dp
|
||||
return super.getCompoundPaddingBottom() + extraBottomPadding;
|
||||
}
|
||||
|
||||
public void setLineHeightMultiplierHint(float lineHeightMultiplierHint) {
|
||||
this.lineHeightMultiplierHint = lineHeightMultiplierHint;
|
||||
computeLineHeight();
|
||||
@Override
|
||||
public int getCompoundPaddingTop() {
|
||||
// include extra padding to place the first line's baseline on the grid
|
||||
return super.getCompoundPaddingTop() + extraTopPadding;
|
||||
}
|
||||
|
||||
public @FontRes
|
||||
int getFontResId() {
|
||||
return fontResId;
|
||||
}
|
||||
|
||||
public float getLineHeightHint() {
|
||||
|
@ -91,6 +101,15 @@ public class BaselineGridTextView extends MaterialTextView {
|
|||
computeLineHeight();
|
||||
}
|
||||
|
||||
public float getLineHeightMultiplierHint() {
|
||||
return lineHeightMultiplierHint;
|
||||
}
|
||||
|
||||
public void setLineHeightMultiplierHint(float lineHeightMultiplierHint) {
|
||||
this.lineHeightMultiplierHint = lineHeightMultiplierHint;
|
||||
computeLineHeight();
|
||||
}
|
||||
|
||||
public boolean getMaxLinesByHeight() {
|
||||
return maxLinesByHeight;
|
||||
}
|
||||
|
@ -100,23 +119,6 @@ public class BaselineGridTextView extends MaterialTextView {
|
|||
requestLayout();
|
||||
}
|
||||
|
||||
public @FontRes
|
||||
int getFontResId() {
|
||||
return fontResId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCompoundPaddingTop() {
|
||||
// include extra padding to place the first line's baseline on the grid
|
||||
return super.getCompoundPaddingTop() + extraTopPadding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCompoundPaddingBottom() {
|
||||
// include extra padding to make the height a multiple of 4dp
|
||||
return super.getCompoundPaddingBottom() + extraBottomPadding;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
extraTopPadding = 0;
|
||||
|
@ -129,18 +131,18 @@ public class BaselineGridTextView extends MaterialTextView {
|
|||
checkMaxLines(height, MeasureSpec.getMode(heightMeasureSpec));
|
||||
}
|
||||
|
||||
private void parseTextAttrs(TypedArray a) {
|
||||
if (a.hasValue(R.styleable.BaselineGridTextView_lineHeightMultiplierHint)) {
|
||||
lineHeightMultiplierHint =
|
||||
a.getFloat(R.styleable.BaselineGridTextView_lineHeightMultiplierHint, 1f);
|
||||
}
|
||||
if (a.hasValue(R.styleable.BaselineGridTextView_lineHeightHint)) {
|
||||
lineHeightHint = a.getDimensionPixelSize(
|
||||
R.styleable.BaselineGridTextView_lineHeightHint, 0);
|
||||
}
|
||||
if (a.hasValue(R.styleable.BaselineGridTextView_android_fontFamily)) {
|
||||
fontResId = a.getResourceId(R.styleable.BaselineGridTextView_android_fontFamily, 0);
|
||||
/**
|
||||
* When measured with an exact height, text can be vertically clipped mid-line. Prevent
|
||||
* this by setting the {@code maxLines} property based on the available space.
|
||||
*/
|
||||
private void checkMaxLines(int height, int heightMode) {
|
||||
if (!maxLinesByHeight || heightMode != MeasureSpec.EXACTLY) {
|
||||
return;
|
||||
}
|
||||
|
||||
int textHeight = height - getCompoundPaddingTop() - getCompoundPaddingBottom();
|
||||
int completeLines = (int) Math.floor(textHeight / getLineHeight());
|
||||
setMaxLines(completeLines);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -181,15 +183,17 @@ public class BaselineGridTextView extends MaterialTextView {
|
|||
return extraBottomPadding;
|
||||
}
|
||||
|
||||
/**
|
||||
* When measured with an exact height, text can be vertically clipped mid-line. Prevent
|
||||
* this by setting the {@code maxLines} property based on the available space.
|
||||
*/
|
||||
private void checkMaxLines(int height, int heightMode) {
|
||||
if (!maxLinesByHeight || heightMode != MeasureSpec.EXACTLY) return;
|
||||
|
||||
int textHeight = height - getCompoundPaddingTop() - getCompoundPaddingBottom();
|
||||
int completeLines = (int) Math.floor(textHeight / getLineHeight());
|
||||
setMaxLines(completeLines);
|
||||
private void parseTextAttrs(TypedArray a) {
|
||||
if (a.hasValue(R.styleable.BaselineGridTextView_lineHeightMultiplierHint)) {
|
||||
lineHeightMultiplierHint =
|
||||
a.getFloat(R.styleable.BaselineGridTextView_lineHeightMultiplierHint, 1f);
|
||||
}
|
||||
if (a.hasValue(R.styleable.BaselineGridTextView_lineHeightHint)) {
|
||||
lineHeightHint = a.getDimensionPixelSize(
|
||||
R.styleable.BaselineGridTextView_lineHeightHint, 0);
|
||||
}
|
||||
if (a.hasValue(R.styleable.BaselineGridTextView_android_fontFamily)) {
|
||||
fontResId = a.getResourceId(R.styleable.BaselineGridTextView_android_fontFamily, 0);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/colorSurface"
|
||||
android:orientation="vertical"
|
||||
tools:ignore="UnusedAttribute">
|
||||
|
||||
|
@ -16,8 +17,7 @@
|
|||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/colorSurface">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/appBarLayout"
|
||||
|
|
|
@ -80,7 +80,7 @@
|
|||
</com.google.android.material.card.MaterialCardView>
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recyclerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
|
|
@ -67,7 +67,7 @@
|
|||
app:contentInsetStart="0dp"
|
||||
app:contentInsetStartWithNavigation="0dp"
|
||||
app:popupTheme="?attr/toolbarPopupTheme"
|
||||
app:title="@string/search_hint"
|
||||
app:title="@string/action_search"
|
||||
app:titleMarginStart="0dp"
|
||||
app:titleTextAppearance="@style/ToolbarTextAppearanceSearch"
|
||||
app:titleTextColor="?android:attr/textColorSecondary"
|
||||
|
|
|
@ -6,14 +6,15 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recyclerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:clipToPadding="false"
|
||||
android:layoutAnimation="@anim/layout_animation_fall_down"
|
||||
android:scrollbars="none"
|
||||
app:layout_dodgeInsetEdges="bottom" />
|
||||
app:layout_dodgeInsetEdges="bottom"
|
||||
tools:listitem="@layout/item_list" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@android:id/empty"
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:gravity="center"
|
||||
android:minWidth="40dp"
|
||||
android:singleLine="true"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
|
@ -31,8 +30,8 @@
|
|||
style="@style/Widget.MaterialProgressBar.ProgressBar.Horizontal"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="8"
|
||||
android:maxHeight="3dp"
|
||||
android:padding="0dp"
|
||||
android:progressDrawable="@drawable/color_progress_seek"
|
||||
android:splitTrack="false"
|
||||
android:thumb="@drawable/switch_thumb_material"
|
||||
|
@ -47,7 +46,7 @@
|
|||
android:layout_width="40dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:gravity="center"
|
||||
android:gravity="end"
|
||||
android:minWidth="40dp"
|
||||
android:singleLine="true"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
|
|
|
@ -26,8 +26,7 @@
|
|||
<menu>
|
||||
<group
|
||||
android:id="@+id/group_grid_size"
|
||||
android:checkableBehavior="single"
|
||||
tools:ignore="HardcodedText">
|
||||
android:checkableBehavior="single">
|
||||
<item
|
||||
android:id="@+id/action_grid_size_1"
|
||||
android:title="@string/grid_size_1" />
|
||||
|
@ -55,12 +54,41 @@
|
|||
</group>
|
||||
</menu>
|
||||
</item>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_layout_type"
|
||||
android:icon="@drawable/ic_grid_size_white_24dp"
|
||||
android:title="@string/grid_style_label"
|
||||
app:showAsAction="never">
|
||||
<menu>
|
||||
<group
|
||||
android:id="@+id/group_layout_type"
|
||||
android:checkableBehavior="single">
|
||||
<item
|
||||
android:id="@+id/action_layout_normal"
|
||||
android:title="@string/normal" />
|
||||
<item
|
||||
android:id="@+id/action_layout_card"
|
||||
android:title="@string/card" />
|
||||
<item
|
||||
android:id="@+id/action_layout_colored_card"
|
||||
android:title="@string/card_color_style" />
|
||||
<item
|
||||
android:id="@+id/action_layout_circular"
|
||||
android:title="@string/circular" />
|
||||
<item
|
||||
android:id="@+id/action_layout_image"
|
||||
android:title="@string/image" />
|
||||
<item
|
||||
android:id="@+id/action_layout_gradient_image"
|
||||
android:title="@string/image_gradient" />
|
||||
</group>
|
||||
</menu>
|
||||
</item>
|
||||
<item
|
||||
android:id="@+id/action_sort_order"
|
||||
android:icon="@drawable/ic_sort_white_24dp"
|
||||
android:title="@string/action_sort_order"
|
||||
app:showAsAction="never">
|
||||
app:showAsAction="ifRoom">
|
||||
<menu></menu>
|
||||
</item>
|
||||
|
||||
|
|
|
@ -8,6 +8,13 @@
|
|||
android:title="@string/pref_title_now_playing_screen_appearance"
|
||||
app:icon="@drawable/ic_play_circle_filled_white_24dp" />
|
||||
|
||||
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATESwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="extra_song_info"
|
||||
android:layout="@layout/list_item_view_switch"
|
||||
android:summary="@string/pref_summary_extra_song_info"
|
||||
android:title="@string/pref_title_extra_song_info" />
|
||||
|
||||
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory
|
||||
android:layout="@layout/preference_category_title"
|
||||
android:title="@string/pref_header_album">
|
||||
|
|
|
@ -3,29 +3,7 @@
|
|||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory
|
||||
android:layout="@layout/preference_category_title"
|
||||
app:title="@string/grid_style_label">
|
||||
<code.name.monkey.retromusic.preferences.MaterialListPreference
|
||||
android:defaultValue="0"
|
||||
android:entries="@array/pref_grid_style_list_titles"
|
||||
android:entryValues="@array/pref_grid_style_list_values"
|
||||
android:key="album_grid_style"
|
||||
android:layout="@layout/list_item_view"
|
||||
android:negativeButtonText="@null"
|
||||
android:positiveButtonText="@null"
|
||||
android:title="@string/pref_title_album_grid_style"
|
||||
app:icon="@drawable/ic_album_white_24dp" />
|
||||
|
||||
<code.name.monkey.retromusic.preferences.MaterialListPreference
|
||||
android:defaultValue="0"
|
||||
android:entries="@array/pref_grid_style_list_titles"
|
||||
android:entryValues="@array/pref_grid_style_list_values"
|
||||
android:key="artist_grid_style"
|
||||
android:layout="@layout/list_item_view"
|
||||
android:negativeButtonText="@null"
|
||||
android:positiveButtonText="@null"
|
||||
android:title="@string/pref_title_artist_grid_style"
|
||||
app:icon="@drawable/ic_artist_white_24dp" />
|
||||
|
||||
app:title="@string/home">
|
||||
|
||||
<code.name.monkey.retromusic.preferences.MaterialListPreference
|
||||
android:defaultValue="0"
|
||||
|
@ -45,12 +23,7 @@
|
|||
android:summary="@string/pref_summary_home_banner"
|
||||
android:title="@string/pref_title_home_banner" />
|
||||
|
||||
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATESwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="extra_song_info"
|
||||
android:layout="@layout/list_item_view_switch"
|
||||
android:summary="@string/pref_summary_extra_song_info"
|
||||
android:title="@string/pref_title_extra_song_info" />
|
||||
|
||||
|
||||
</code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory>
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ public final class TintHelper {
|
|||
}
|
||||
|
||||
@CheckResult
|
||||
@Nullable
|
||||
@NonNull
|
||||
public static Drawable createTintedDrawable(Context context,
|
||||
@DrawableRes int res, @ColorInt int color) {
|
||||
Drawable drawable = ContextCompat.getDrawable(context, res);
|
||||
|
@ -87,7 +87,7 @@ public final class TintHelper {
|
|||
|
||||
// This returns a NEW Drawable because of the mutate() call. The mutate() call is necessary because Drawables with the same resource have shared states otherwise.
|
||||
@CheckResult
|
||||
@Nullable
|
||||
@NonNull
|
||||
public static Drawable createTintedDrawable(@Nullable Drawable drawable, @ColorInt int color) {
|
||||
if (drawable == null) {
|
||||
return null;
|
||||
|
|
Loading…
Reference in a new issue