Revert "Add a new smart playlist "Not played lately" playlist (#613)"
This reverts commit 764751381a.
This commit is contained in:
parent
b4d3470096
commit
29371671ee
9 changed files with 8 additions and 144 deletions
|
|
@ -18,7 +18,7 @@ public class LastAddedLoader {
|
|||
}
|
||||
|
||||
public static Cursor makeLastAddedCursor(@NonNull final Context context) {
|
||||
long cutoff = PreferenceUtil.getInstance(context).getLastAddedCutoffTimeSecs();
|
||||
long cutoff = PreferenceUtil.getInstance(context).getLastAddedCutoff();
|
||||
|
||||
return SongLoader.makeSongCursor(
|
||||
context,
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ import androidx.annotation.Nullable;
|
|||
import com.kabouzeid.gramophone.model.Song;
|
||||
import com.kabouzeid.gramophone.provider.HistoryStore;
|
||||
import com.kabouzeid.gramophone.provider.SongPlayCountStore;
|
||||
import com.kabouzeid.gramophone.util.PreferenceUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
|
@ -38,23 +37,6 @@ public class TopAndRecentlyPlayedTracksLoader {
|
|||
return SongLoader.getSongs(makeRecentTracksCursorAndClearUpDatabase(context));
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static ArrayList<Song> getNotRecentlyPlayedTracks
|
||||
(@NonNull Context context) {
|
||||
ArrayList<Song> allSongs = SongLoader.getSongs(
|
||||
SongLoader.makeSongCursor(
|
||||
context,
|
||||
null, null,
|
||||
MediaStore.Audio.Media.DATE_ADDED + " ASC"));
|
||||
|
||||
ArrayList<Song> recentlyPlayedSongs = SongLoader.getSongs(
|
||||
makeRecentTracksCursorAndClearUpDatabase(context));
|
||||
|
||||
allSongs.removeAll(recentlyPlayedSongs);
|
||||
|
||||
return allSongs;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static ArrayList<Song> getTopTracks(@NonNull Context context) {
|
||||
return SongLoader.getSongs(makeTopTracksCursorAndClearUpDatabase(context));
|
||||
|
|
@ -95,8 +77,7 @@ public class TopAndRecentlyPlayedTracksLoader {
|
|||
@Nullable
|
||||
private static SortedLongCursor makeRecentTracksCursorImpl(@NonNull final Context context) {
|
||||
// first get the top results ids from the internal database
|
||||
final long cutoff = PreferenceUtil.getInstance(context).getRecentlyPlayedCutoffTimeMillis();
|
||||
Cursor songs = HistoryStore.getInstance(context).queryRecentIds(cutoff);
|
||||
Cursor songs = HistoryStore.getInstance(context).queryRecentIds();
|
||||
|
||||
try {
|
||||
return makeSortedCursor(context, songs,
|
||||
|
|
|
|||
|
|
@ -1,68 +0,0 @@
|
|||
package com.kabouzeid.gramophone.model.smartplaylist;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Parcel;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.kabouzeid.gramophone.R;
|
||||
import com.kabouzeid.gramophone.loader.TopAndRecentlyPlayedTracksLoader;
|
||||
import com.kabouzeid.gramophone.model.Song;
|
||||
import com.kabouzeid.gramophone.util.MusicUtil;
|
||||
import com.kabouzeid.gramophone.util.PreferenceUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* @author SC (soncaokim)
|
||||
*/
|
||||
public class NotRecentlyPlayedPlaylist extends AbsSmartPlaylist {
|
||||
|
||||
public NotRecentlyPlayedPlaylist(@NonNull Context context) {
|
||||
super(context.getString(R.string.not_recently_played), R.drawable.ic_watch_later_white_24dp);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String getInfoString(@NonNull Context context) {
|
||||
String cutoff = PreferenceUtil.getInstance(context).getRecentlyPlayedCutoffText(context);
|
||||
|
||||
return MusicUtil.buildInfoString(
|
||||
cutoff,
|
||||
super.getInfoString(context)
|
||||
);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ArrayList<Song> getSongs(@NonNull Context context) {
|
||||
return TopAndRecentlyPlayedTracksLoader.getNotRecentlyPlayedTracks(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear(@NonNull Context context) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isClearable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected NotRecentlyPlayedPlaylist(Parcel in) {
|
||||
super(in);
|
||||
}
|
||||
|
||||
public static final Creator<NotRecentlyPlayedPlaylist> CREATOR = new Creator<NotRecentlyPlayedPlaylist>() {
|
||||
public NotRecentlyPlayedPlaylist createFromParcel(Parcel source) {
|
||||
return new NotRecentlyPlayedPlaylist(source);
|
||||
}
|
||||
|
||||
public NotRecentlyPlayedPlaylist[] newArray(int size) {
|
||||
return new NotRecentlyPlayedPlaylist[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -25,7 +25,7 @@ import androidx.annotation.NonNull;
|
|||
import androidx.annotation.Nullable;
|
||||
|
||||
public class HistoryStore extends SQLiteOpenHelper {
|
||||
private static final int MAX_ITEMS_IN_DB = 5000;
|
||||
private static final int MAX_ITEMS_IN_DB = 100;
|
||||
|
||||
public static final String DATABASE_NAME = "history.db";
|
||||
private static final int VERSION = 1;
|
||||
|
|
@ -136,14 +136,10 @@ public class HistoryStore extends SQLiteOpenHelper {
|
|||
return containsId;
|
||||
}
|
||||
|
||||
public Cursor queryRecentIds(long cutoff) {
|
||||
public Cursor queryRecentIds() {
|
||||
final SQLiteDatabase database = getReadableDatabase();
|
||||
|
||||
return database.query(RecentStoreColumns.NAME,
|
||||
new String[]{RecentStoreColumns.ID},
|
||||
RecentStoreColumns.TIME_PLAYED + ">?",
|
||||
new String[]{String.valueOf(cutoff)},
|
||||
null, null,
|
||||
new String[]{RecentStoreColumns.ID}, null, null, null, null,
|
||||
RecentStoreColumns.TIME_PLAYED + " DESC");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ import com.kabouzeid.gramophone.model.Playlist;
|
|||
import com.kabouzeid.gramophone.model.smartplaylist.HistoryPlaylist;
|
||||
import com.kabouzeid.gramophone.model.smartplaylist.LastAddedPlaylist;
|
||||
import com.kabouzeid.gramophone.model.smartplaylist.MyTopTracksPlaylist;
|
||||
import com.kabouzeid.gramophone.model.smartplaylist.NotRecentlyPlayedPlaylist;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
|
@ -81,7 +80,6 @@ public class PlaylistsFragment extends AbsLibraryPagerRecyclerViewFragment<Playl
|
|||
|
||||
playlists.add(new LastAddedPlaylist(context));
|
||||
playlists.add(new HistoryPlaylist(context));
|
||||
playlists.add(new NotRecentlyPlayedPlaylist(context));
|
||||
playlists.add(new MyTopTracksPlaylist(context));
|
||||
|
||||
playlists.addAll(PlaylistLoader.getAllPlaylists(context));
|
||||
|
|
|
|||
|
|
@ -62,7 +62,6 @@ public final class PreferenceUtil {
|
|||
public static final String GAPLESS_PLAYBACK = "gapless_playback";
|
||||
|
||||
public static final String LAST_ADDED_CUTOFF = "last_added_interval";
|
||||
public static final String RECENTLY_PLAYED_CUTOFF = "recently_played_interval";
|
||||
|
||||
public static final String ALBUM_ART_ON_LOCKSCREEN = "album_art_on_lockscreen";
|
||||
public static final String BLURRED_ALBUM_ART = "blurred_album_art";
|
||||
|
|
@ -284,21 +283,11 @@ public final class PreferenceUtil {
|
|||
return mPreferences.getString(GENRE_SORT_ORDER, SortOrder.GenreSortOrder.GENRE_A_Z);
|
||||
}
|
||||
|
||||
// The last added cutoff time is compared against the Android media store timestamps, which is seconds based.
|
||||
public long getLastAddedCutoffTimeSecs() {
|
||||
return getCutoffTimeMillis(LAST_ADDED_CUTOFF) / 1000;
|
||||
}
|
||||
|
||||
// The recently played cutoff time is compared against the internal (private) database timestamps, which is milliseconds based.
|
||||
public long getRecentlyPlayedCutoffTimeMillis() {
|
||||
return getCutoffTimeMillis(RECENTLY_PLAYED_CUTOFF);
|
||||
}
|
||||
|
||||
private long getCutoffTimeMillis(final String cutoff) {
|
||||
public long getLastAddedCutoff() {
|
||||
final CalendarUtil calendarUtil = new CalendarUtil();
|
||||
long interval;
|
||||
|
||||
switch (mPreferences.getString(cutoff, "")) {
|
||||
switch (mPreferences.getString(LAST_ADDED_CUTOFF, "")) {
|
||||
case "today":
|
||||
interval = calendarUtil.getElapsedToday();
|
||||
break;
|
||||
|
|
@ -325,7 +314,7 @@ public final class PreferenceUtil {
|
|||
break;
|
||||
}
|
||||
|
||||
return (System.currentTimeMillis() - interval);
|
||||
return (System.currentTimeMillis() - interval) / 1000;
|
||||
}
|
||||
|
||||
public String getLastAddedCutoffText(Context context) {
|
||||
|
|
|
|||
|
|
@ -130,7 +130,6 @@
|
|||
<string name="pref_title_ignore_media_store_artwork">Ignore Media Store covers</string>
|
||||
<string name="pref_title_gapless_playback">Gapless playback</string>
|
||||
<string name="pref_title_audio_ducking">Reduce volume on focus loss</string>
|
||||
<string name="pref_title_recently_played_interval">Recently played playlist interval</string>
|
||||
<string name="pref_title_last_added_interval">Last added playlist interval</string>
|
||||
<string name="pref_title_synchronized_lyrics_show">Show synchronized lyrics</string>
|
||||
<string name="pref_title_remember_last_tab">Remember last tab</string>
|
||||
|
|
@ -176,7 +175,6 @@
|
|||
<string name="last_added">Last added</string>
|
||||
<string name="history">Recently played</string>
|
||||
<string name="my_top_tracks">My top tracks</string>
|
||||
<string name="not_recently_played">Not recently played</string>
|
||||
<string name="remove_cover">Remove cover</string>
|
||||
<string name="download_from_last_fm">Download from Last.fm</string>
|
||||
<string name="pick_from_local_storage">Pick from local storage</string>
|
||||
|
|
|
|||
|
|
@ -24,28 +24,9 @@
|
|||
<item>never</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="pref_playlists_recently_played_interval_titles">
|
||||
<item>@string/today</item>
|
||||
<item>@string/this_week</item>
|
||||
<item>@string/past_seven_days</item>
|
||||
<item>@string/this_month</item>
|
||||
<item>@string/past_three_months</item>
|
||||
<item>@string/this_year</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="pref_playlists_recently_played_interval_values">
|
||||
<item>today</item>
|
||||
<item>this_week</item>
|
||||
<item>past_seven_days</item>
|
||||
<item>this_month</item>
|
||||
<item>past_three_months</item>
|
||||
<item>this_year</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="pref_playlists_last_added_interval_titles">
|
||||
<item>@string/today</item>
|
||||
<item>@string/this_week</item>
|
||||
<item>@string/past_seven_days</item>
|
||||
<item>@string/this_month</item>
|
||||
<item>@string/past_three_months</item>
|
||||
<item>@string/this_year</item>
|
||||
|
|
@ -54,7 +35,6 @@
|
|||
<string-array name="pref_playlists_last_added_interval_values">
|
||||
<item>today</item>
|
||||
<item>this_week</item>
|
||||
<item>past_seven_days</item>
|
||||
<item>this_month</item>
|
||||
<item>past_three_months</item>
|
||||
<item>this_year</item>
|
||||
|
|
|
|||
|
|
@ -4,16 +4,6 @@
|
|||
<com.kabouzeid.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory android:title="@string/pref_header_playlists">
|
||||
|
||||
<com.kabouzeid.appthemehelper.common.prefs.supportv7.ATEListPreference
|
||||
app:iconSpaceReserved="false"
|
||||
android:defaultValue="this_month"
|
||||
android:entries="@array/pref_playlists_recently_played_interval_titles"
|
||||
android:entryValues="@array/pref_playlists_recently_played_interval_values"
|
||||
android:key="recently_played_interval"
|
||||
android:negativeButtonText="@null"
|
||||
android:positiveButtonText="@null"
|
||||
android:title="@string/pref_title_recently_played_interval" />
|
||||
|
||||
<com.kabouzeid.appthemehelper.common.prefs.supportv7.ATEListPreference
|
||||
app:iconSpaceReserved="false"
|
||||
android:defaultValue="this_month"
|
||||
android:entries="@array/pref_playlists_last_added_interval_titles"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue