Merge branch 'dev' into Confirm-add-to-playlist-#1283
This commit is contained in:
commit
c37fca4a5e
8 changed files with 71 additions and 12 deletions
|
@ -164,3 +164,4 @@ const val WALLPAPER_ACCENT = "wallpaper_accent"
|
|||
const val SCREEN_ON_LYRICS = "screen_on_lyrics"
|
||||
const val CIRCLE_PLAY_BUTTON = "circle_play_button"
|
||||
const val SWIPE_ANYWHERE_NOW_PLAYING = "swipe_anywhere_now_playing"
|
||||
const val PAUSE_HISTORY = "pause_history"
|
|
@ -31,6 +31,7 @@ import code.name.monkey.retromusic.service.MusicService.Companion.PLAY_STATE_CHA
|
|||
import code.name.monkey.retromusic.service.MusicService.Companion.QUEUE_CHANGED
|
||||
import code.name.monkey.retromusic.service.MusicService.Companion.REPEAT_MODE_CHANGED
|
||||
import code.name.monkey.retromusic.service.MusicService.Companion.SHUFFLE_MODE_CHANGED
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import org.koin.android.ext.android.inject
|
||||
|
@ -123,7 +124,10 @@ abstract class AbsMusicServiceActivity : AbsBaseActivity(), IMusicServiceEventLi
|
|||
if (entity != null) {
|
||||
repository.updateHistorySong(MusicPlayerRemote.currentSong)
|
||||
} else {
|
||||
repository.addSongToHistory(MusicPlayerRemote.currentSong)
|
||||
// Check whether pause history option is ON or OFF
|
||||
if (!PreferenceUtil.pauseHistory) {
|
||||
repository.addSongToHistory(MusicPlayerRemote.currentSong)
|
||||
}
|
||||
}
|
||||
val songs = repository.checkSongExistInPlayCount(MusicPlayerRemote.currentSong.id)
|
||||
if (songs.isNotEmpty()) {
|
||||
|
|
|
@ -50,6 +50,7 @@ class LibraryViewModel(
|
|||
private val searchResults = MutableLiveData<List<Any>>()
|
||||
private val fabMargin = MutableLiveData(0)
|
||||
private val songHistory = MutableLiveData<List<Song>>()
|
||||
private var previousSongHistory = ArrayList<HistoryEntity>()
|
||||
val paletteColor: LiveData<Int> = _paletteColor
|
||||
|
||||
init {
|
||||
|
@ -342,11 +343,27 @@ class LibraryViewModel(
|
|||
|
||||
fun clearHistory() {
|
||||
viewModelScope.launch(IO) {
|
||||
previousSongHistory = repository.historySong() as ArrayList<HistoryEntity>
|
||||
|
||||
repository.clearSongHistory()
|
||||
}
|
||||
songHistory.value = emptyList()
|
||||
}
|
||||
|
||||
|
||||
fun restoreHistory() {
|
||||
viewModelScope.launch(IO) {
|
||||
if (previousSongHistory.isNotEmpty()) {
|
||||
val history = ArrayList<Song>()
|
||||
for (song in previousSongHistory) {
|
||||
repository.addSongToHistory(song.toSong())
|
||||
history.add(song.toSong())
|
||||
}
|
||||
songHistory.postValue(history)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun favorites() = repository.favorites()
|
||||
|
||||
fun clearSearchResult() {
|
||||
|
|
|
@ -14,14 +14,13 @@
|
|||
*/
|
||||
package code.name.monkey.retromusic.fragments.other
|
||||
|
||||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.view.Menu
|
||||
import android.view.MenuInflater
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.view.*
|
||||
import androidx.activity.addCallback
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.core.view.doOnPreDraw
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.navigation.fragment.FragmentNavigatorExtras
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.navigation.fragment.navArgs
|
||||
|
@ -44,6 +43,7 @@ import code.name.monkey.retromusic.interfaces.ICabCallback
|
|||
import code.name.monkey.retromusic.interfaces.ICabHolder
|
||||
import code.name.monkey.retromusic.model.Album
|
||||
import code.name.monkey.retromusic.model.Artist
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import code.name.monkey.retromusic.util.RetroColorUtil
|
||||
import code.name.monkey.retromusic.util.RetroUtil
|
||||
import com.afollestad.materialcab.attached.AttachedCab
|
||||
|
@ -51,8 +51,10 @@ import com.afollestad.materialcab.attached.destroy
|
|||
import com.afollestad.materialcab.attached.isActive
|
||||
import com.afollestad.materialcab.createCab
|
||||
import com.google.android.material.shape.MaterialShapeDrawable
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import com.google.android.material.transition.MaterialSharedAxis
|
||||
|
||||
|
||||
class DetailListFragment : AbsMainActivityFragment(R.layout.fragment_playlist_detail),
|
||||
IArtistClickListener, IAlbumClickListener, ICabHolder {
|
||||
private val args by navArgs<DetailListFragmentArgs>()
|
||||
|
@ -162,9 +164,12 @@ class DetailListFragment : AbsMainActivityFragment(R.layout.fragment_playlist_de
|
|||
adapter = songAdapter
|
||||
layoutManager = linearLayoutManager()
|
||||
}
|
||||
|
||||
libraryViewModel.observableHistorySongs().observe(viewLifecycleOwner) {
|
||||
songAdapter.swapDataSet(it)
|
||||
binding.empty.isVisible = it.isEmpty()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun loadFavorite() {
|
||||
|
@ -236,6 +241,7 @@ class DetailListFragment : AbsMainActivityFragment(R.layout.fragment_playlist_de
|
|||
return if (RetroUtil.isLandscape()) 4 else 2
|
||||
}
|
||||
|
||||
|
||||
override fun onArtist(artistId: Long, view: View) {
|
||||
findNavController().navigate(
|
||||
R.id.artistDetailsFragment,
|
||||
|
@ -305,11 +311,24 @@ class DetailListFragment : AbsMainActivityFragment(R.layout.fragment_playlist_de
|
|||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
|
||||
when (item.itemId) {
|
||||
R.id.action_clear_history -> libraryViewModel.clearHistory()
|
||||
/*
|
||||
TODO("Show a snackbar showing that history has been successfully
|
||||
cleared and that will have an undo button")
|
||||
*/
|
||||
R.id.action_clear_history -> {
|
||||
if (binding.recyclerView.adapter?.itemCount!! > 0) {
|
||||
libraryViewModel.clearHistory()
|
||||
|
||||
val snackBar =
|
||||
Snackbar.make(binding.container,
|
||||
getString(R.string.history_cleared),
|
||||
Snackbar.LENGTH_LONG)
|
||||
.setAction(getString(R.string.history_undo_button)) {
|
||||
libraryViewModel.restoreHistory()
|
||||
}
|
||||
.setActionTextColor(Color.YELLOW)
|
||||
val snackBarView = snackBar.view
|
||||
snackBarView.translationY =
|
||||
-(resources.getDimension(R.dimen.mini_player_height))
|
||||
snackBar.show()
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -637,6 +637,12 @@ object PreferenceUtil {
|
|||
true
|
||||
)
|
||||
|
||||
val pauseHistory: Boolean
|
||||
get() = sharedPreferences.getBoolean(
|
||||
PAUSE_HISTORY,
|
||||
false
|
||||
)
|
||||
|
||||
var audioFadeDuration
|
||||
get() = sharedPreferences
|
||||
.getInt(AUDIO_FADE_DURATION, 0)
|
||||
|
|
|
@ -67,6 +67,7 @@
|
|||
android:textAppearance="@style/TextViewHeadline5"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
tools:visibility="visible" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<com.google.android.material.progressindicator.CircularProgressIndicator
|
||||
|
|
|
@ -356,6 +356,7 @@
|
|||
<string name="pref_summary_toggle_volume">If enough space is available, show volume controls in the now playing screen</string>
|
||||
<string name="pref_summary_wallpaper_accent">Extract accent color from wallpaper</string>
|
||||
<string name="pref_summary_whitelist">Only show music from /Music Folder</string>
|
||||
<string name="pref_summary_pause_history">When enabled, newly played songs won\'t show in history</string>
|
||||
<string name="pref_title_album_art_on_lockscreen">Show album cover</string>
|
||||
<string name="pref_title_album_artists_only">Navigate by Album Artist</string>
|
||||
<string name="pref_title_album_cover_style">Album cover theme</string>
|
||||
|
@ -402,6 +403,7 @@
|
|||
<string name="pref_title_toggle_volume">Volume controls</string>
|
||||
<string name="pref_title_wallpaper_accent">Wallpaper accent color</string>
|
||||
<string name="pref_title_whitelist">Whitelist music</string>
|
||||
<string name="pref_title_pause_history">Pause history</string>
|
||||
<string name="pro">Pro</string>
|
||||
<string name="pro_summary">Black theme, Now playing themes, Carousel effect and more..</string>
|
||||
<string name="profile">Profile</string>
|
||||
|
@ -547,4 +549,6 @@
|
|||
<string name="playlist_created_sucessfully">%s created successfully</string>
|
||||
<string name="playList_already_exits">Playlist already exists</string>
|
||||
<string name="added_song_count_to_playlist">Added %d song(s) to %s</string>
|
||||
<string name="history_cleared">History cleared</string>
|
||||
<string name="history_undo_button">Undo</string>
|
||||
</resources>
|
||||
|
|
|
@ -40,6 +40,13 @@
|
|||
android:summary="@string/pref_summary_suggestions"
|
||||
android:title="@string/pref_title_suggestions" />
|
||||
|
||||
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATESwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="pause_history"
|
||||
android:layout="@layout/list_item_view_switch"
|
||||
android:summary="@string/pref_summary_pause_history"
|
||||
android:title="@string/pref_title_pause_history" />
|
||||
|
||||
</code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory>
|
||||
|
||||
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue