add setting to save the queue on exit
This commit is contained in:
parent
76e39f88b7
commit
a4969338df
6 changed files with 23 additions and 0 deletions
|
|
@ -26,9 +26,12 @@ import android.provider.MediaStore.Audio.AudioColumns;
|
|||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.dkanada.gramophone.App;
|
||||
import com.dkanada.gramophone.loader.SongLoader;
|
||||
import com.dkanada.gramophone.model.Song;
|
||||
import com.dkanada.gramophone.util.PreferenceUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class QueueStore extends SQLiteOpenHelper {
|
||||
|
|
@ -175,6 +178,10 @@ public class QueueStore extends SQLiteOpenHelper {
|
|||
|
||||
@NonNull
|
||||
private List<Song> getQueue(@NonNull final String tableName) {
|
||||
if (!PreferenceUtil.getInstance(App.getInstance()).getRememberQueue()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
Cursor cursor = getReadableDatabase().query(tableName, null,
|
||||
null, null, null, null, null);
|
||||
return SongLoader.getSongs(cursor);
|
||||
|
|
|
|||
|
|
@ -178,6 +178,7 @@ public class PlayingNotificationImpl extends PlayingNotification {
|
|||
private PendingIntent buildPendingIntent(Context context, final String action, final ComponentName serviceName) {
|
||||
Intent intent = new Intent(action);
|
||||
intent.setComponent(serviceName);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||
return PendingIntent.getService(context, 0, intent, 0);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,6 +110,7 @@ public class PlayingNotificationImpl24 extends PlayingNotification {
|
|||
final ComponentName serviceName = new ComponentName(service, MusicService.class);
|
||||
Intent intent = new Intent(action);
|
||||
intent.setComponent(serviceName);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||
return PendingIntent.getService(service, 0, intent, 0);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ public final class PreferenceUtil {
|
|||
public static final String MAXIMUM_BITRATE = "maximum_bitrate";
|
||||
public static final String AUDIO_DUCKING = "audio_ducking";
|
||||
public static final String REMEMBER_SHUFFLE = "remember_shuffle";
|
||||
public static final String REMEMBER_QUEUE = "remember_queue";
|
||||
|
||||
public static final String SHOW_ALBUM_COVER = "show_album_cover";
|
||||
public static final String BLUR_ALBUM_COVER = "blur_album_cover";
|
||||
|
|
@ -183,6 +184,10 @@ public final class PreferenceUtil {
|
|||
return mPreferences.getBoolean(REMEMBER_SHUFFLE, true);
|
||||
}
|
||||
|
||||
public final boolean getRememberQueue() {
|
||||
return mPreferences.getBoolean(REMEMBER_QUEUE, true);
|
||||
}
|
||||
|
||||
public final boolean getShowAlbumCover() {
|
||||
return mPreferences.getBoolean(SHOW_ALBUM_COVER, true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@
|
|||
<string name="pref_title_audio_ducking">Audio Ducking</string>
|
||||
<string name="pref_title_remember_last_tab">Remember Tab</string>
|
||||
<string name="pref_title_remember_shuffle">Remember Shuffle</string>
|
||||
<string name="pref_title_remember_queue">Remember Queue</string>
|
||||
<string name="primary_color_desc">The primary theme color for control elements.</string>
|
||||
<string name="accent_color_desc">An alternate color used to accent elements.</string>
|
||||
<string name="pref_summary_album_art_on_lockscreen">Uses the current song\'s album cover as the lockscreen wallpaper.</string>
|
||||
|
|
@ -124,6 +125,7 @@
|
|||
<string name="pref_summary_gapless_playback">"This can cause playback issues on some devices."</string>
|
||||
<string name="pref_summary_remember_shuffle">Shuffle mode will stay on when selecting a new list of songs for the queue.</string>
|
||||
<string name="pref_summary_colored_navigation_bar">Colors the navigation bar in the primary color.</string>
|
||||
<string name="pref_summary_remember_queue">Save the queue when closing the app so it can persist across sessions.</string>
|
||||
<string name="pref_summary_colored_app_shortcuts">Colors the app shortcuts in the primary color.</string>
|
||||
<string name="pref_summary_remember_last_tab">Go to the last opened tab on launch.</string>
|
||||
<string name="pref_summary_library_categories">Configure visibility and order of library categories.</string>
|
||||
|
|
|
|||
|
|
@ -38,6 +38,13 @@
|
|||
android:summary="@string/pref_summary_remember_shuffle"
|
||||
android:title="@string/pref_title_remember_shuffle" />
|
||||
|
||||
<com.kabouzeid.appthemehelper.common.prefs.supportv7.ATESwitchPreference
|
||||
app:iconSpaceReserved="false"
|
||||
android:defaultValue="true"
|
||||
android:key="remember_queue"
|
||||
android:summary="@string/pref_summary_remember_queue"
|
||||
android:title="@string/pref_title_remember_queue" />
|
||||
|
||||
</com.kabouzeid.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory>
|
||||
|
||||
</androidx.preference.PreferenceScreen>
|
||||
Loading…
Add table
Add a link
Reference in a new issue