add setting to save the queue on exit

This commit is contained in:
dkanada 2020-06-19 06:40:09 +09:00
commit a4969338df
6 changed files with 23 additions and 0 deletions

View file

@ -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);

View file

@ -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);
}
}

View file

@ -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);
}
}

View file

@ -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);
}