Skip to content
This repository has been archived by the owner on Feb 4, 2023. It is now read-only.

[Needs improvement] Playlist dialog: Add checkmark to indicate if song is in playlist #432

Open
wants to merge 37 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
6bac337
Playlist dialog: Add checkmark to indicate if song is in playlist
Sogolumbo Feb 12, 2018
f9fba4e
Add Testing Code
Sogolumbo Feb 20, 2018
575bb69
Merge pull request #1 from kabouzeid/master
Sogolumbo Sep 5, 2018
132d597
Update README.md
Sogolumbo Sep 5, 2018
dfba214
Merge pull request #2 from kabouzeid/master
Sogolumbo Jan 12, 2019
67262fa
Update README.md
Sogolumbo Jan 12, 2019
d91f11a
Enable playlist-checking for adding multiple songs to a playlist
Sogolumbo Feb 8, 2019
e81f655
No more duplicate songs added to playlists; Code cleanup
Sogolumbo Feb 8, 2019
7b6f91e
Update README.md
Sogolumbo Feb 8, 2019
6a48d35
Update README.md
Sogolumbo Feb 8, 2019
8cbb569
Update README.md
Sogolumbo Feb 8, 2019
21c0971
Update README.md
Sogolumbo Feb 8, 2019
fa770ff
Update README.md
Sogolumbo Feb 8, 2019
eda7037
Update README.md
Sogolumbo Feb 8, 2019
8254527
Add efficient method PlaylistContains(Songs)
Sogolumbo Jun 3, 2019
2c1b25c
Update README.md
Sogolumbo Jun 3, 2019
780292f
Update README.md
Sogolumbo Jun 3, 2019
7896c8e
Merge remote-tracking branch 'upstream/master'
Sogolumbo Jul 21, 2019
4512b43
Change and add functions in PlaylistUtil
Sogolumbo Jul 21, 2019
7380f4c
Update README.md
Sogolumbo Jul 21, 2019
04fc392
Performance Improvements
Sogolumbo Jul 22, 2019
083d794
Merge branch 'master' into performance-test
Sogolumbo Jul 22, 2019
69505e5
Remove Performance Measurements
Sogolumbo Jul 22, 2019
c477a6d
Bugfix: Wrong Info about Songs in Playlist
Sogolumbo May 27, 2020
0c4e177
Update README.md
Sogolumbo May 27, 2020
14b35fc
Update README.md
Sogolumbo May 27, 2020
fcdba15
Update README.md
Sogolumbo May 27, 2020
ec16d51
Update README.md
Sogolumbo May 27, 2020
28cbfa8
Fix Logical Bug
Sogolumbo Aug 22, 2020
acbf3c5
First Prototype stage
Sogolumbo Aug 22, 2020
84b859f
Second Prototype stage
Sogolumbo Aug 22, 2020
f80dbd3
Remove cancel button from 'add to playlist' dialog
Sogolumbo Aug 29, 2020
66c169e
Change button name 'Apply' to 'Ok' in 'add to playlist...' dialog
Sogolumbo Aug 29, 2020
3984ea2
Update README.md
Sogolumbo Sep 2, 2020
92587c5
Update README.md
Sogolumbo Sep 14, 2020
e481f13
Update README.md
Sogolumbo Sep 14, 2020
ad0fb5c
Merge branch 'Playlist-Checkbox'
Sogolumbo Sep 14, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 29 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,34 @@
# Phonograph
# Phonograph ([Forked from kabouzeid](https://github.com/kabouzeid/Phonograph))

[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](https://github.com/kabouzeid/Phonograph/blob/master/LICENSE.txt)

**A material designed local music player for Android.**

![Screenshots](./art/art.jpg?raw=true)
## About this fork
The purpose of this fork is to implement an easy to use and powerful way to manage your playlists. The goals are:
- [x] See whether the selected song is already in a playlist
- [x] See whether multiple songs are already in a playlist
- [x] Do not add songs to playlist which would become duplicates
- [x] Material Design for the checkmark
- [x] Remove a song from a playlist without having to manually search in the playlist
- [ ] Option to remove duplicate songs from existing playlists
- [ ] Sync playlists (with other devices, using textfiles export and imports)

In the playlist-menu checkboxes indicate whether a song / a number of songs are already in a list.
If multiple songs were selected and only some of them are in the playlist the checkbox will not be checked. Instead a checkmark in brackets will be shown at the end of the playlist name.
This is not a good design but very functional. The plan is to implement a third state of the checkbox which will replace this behaviour.

This fork is different from kabouzeid/master in these and more commits:

[6bac337](https://github.com/Sogolumbo/Phonograph/commit/6bac3379636d97a68f50ebb1672654ef1aa310fb),
[d91f11a](https://github.com/Sogolumbo/Phonograph/commit/d91f11ad068192806979da79a0d089835d574524),
[e81f655](https://github.com/Sogolumbo/Phonograph/commit/e81f655c802bb2953d6e6d093cc3a1c774b897c4),
[8254527](https://github.com/Sogolumbo/Phonograph/commit/8254527339ba7e8acd5cc522b34e3ee724ba9b5a),
[4512b43](https://github.com/Sogolumbo/Phonograph/commit/4512b43529231a57636b7d62fcbade9fb81329b9),
[c477a6d](https://github.com/Sogolumbo/Phonograph/commit/c477a6db7713f73f4252040eb4990b3ff97d9595).

## Contributing
I love any support, feedback or new ideas. So feel free to contribute in any possible way. I don't have any experience with android programming so I really need help D:

[<img src="https://fdroid.gitlab.io/artwork/badge/get-it-on.png"
alt="Get it on F-Droid"
height="80">](https://f-droid.org/packages/com.kabouzeid.gramophone/)
[<img src="https://play.google.com/intl/en_us/badges/images/generic/en-play-badge.png"
alt="Get it on Google Play"
height="80">](https://play.google.com/store/apps/details?id=com.kabouzeid.gramophone)
## Download
Binaries are available under [releases](https://github.com/Sogolumbo/Phonograph/releases).
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
package com.kabouzeid.gramophone.dialogs;

import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.fragment.app.DialogFragment;

import com.afollestad.materialdialogs.DialogAction;
import com.afollestad.materialdialogs.MaterialDialog;
import com.kabouzeid.gramophone.R;
import com.kabouzeid.gramophone.loader.PlaylistLoader;
import com.kabouzeid.gramophone.model.Playlist;
import com.kabouzeid.gramophone.model.Song;
import com.kabouzeid.gramophone.util.MusicUtil;
import com.kabouzeid.gramophone.util.PlaylistsUtil;

import java.util.ArrayList;
Expand Down Expand Up @@ -40,26 +43,84 @@ public static AddToPlaylistDialog create(List<Song> songs) {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final List<Playlist> playlists = PlaylistLoader.getAllPlaylists(getActivity());
CharSequence[] playlistNames = new CharSequence[playlists.size() + 1];
playlistNames[0] = getActivity().getResources().getString(R.string.action_new_playlist);
for (int i = 1; i < playlistNames.length; i++) {
playlistNames[i] = playlists.get(i - 1).name;
CharSequence[] playlistNames = new CharSequence[playlists.size()];
for (int i = 0; i < playlistNames.length; i++) {
playlistNames[i] = playlists.get(i).name;
}
final ArrayList<Song> songs = getArguments().getParcelableArrayList("songs");

int[] songIds = new int[songs.size()];

boolean isAnySongInPlaylist[] = new boolean[playlists.size()];
boolean areAllSongsInPlaylist[] = new boolean[playlists.size()];
List<Integer> checkedPlaylists = new ArrayList<Integer>();

if(songs != null)
{
for(int i = 0; i < songs.size(); i++){
songIds[i] = songs.get(i).id;
}

for (int i = 0; i < playlists.size(); i++) {
int playlistId = playlists.get(i).id;

isAnySongInPlaylist[i] = PlaylistsUtil.doPlaylistContainsAnySong(getActivity(), playlistId, songIds);
areAllSongsInPlaylist[i] = PlaylistsUtil.doPlaylistContainsAllSongs(getActivity(), playlistId, songIds);

//TODO: display checkboxes instead of checkmark
if (isAnySongInPlaylist[i]) {
if(areAllSongsInPlaylist[i]){
playlistNames[i] = playlists.get(i).name + " \u2713"; //Add checkmark
}
else{
playlistNames[i] = playlists.get(i).name + " (\u2713)"; //Add checkmark in brackets
}
}

if (areAllSongsInPlaylist[i]){
checkedPlaylists.add(i);
}
}
}

Integer[] temp = checkedPlaylists.toArray(new Integer[0]); //TODO



return new MaterialDialog.Builder(getActivity())
.title(R.string.add_playlist_title)
.items(playlistNames)
.itemsCallback((materialDialog, view, i, charSequence) -> {
//noinspection unchecked
final List<Song> songs = getArguments().getParcelableArrayList("songs");
if (songs == null) return;
if (i == 0) {
materialDialog.dismiss();
.itemsCallbackMultiChoice(temp, new MaterialDialog.ListCallbackMultiChoice() { //TODO
@Override
public boolean onSelection(MaterialDialog materialDialog, Integer[] which, CharSequence[] charSequence) {
boolean[] checked = new boolean[playlistNames.length];
for (int i: which){
checked[i] = true;
}
for (int i = 0; i < playlists.size(); i++){
if (checked[i] ^ areAllSongsInPlaylist[i]){
if(checked[i]){
PlaylistsUtil.addToPlaylistWithoutDuplicates(getActivity(), songs, songIds, playlists.get(i).id, true);
}
else{
for(Song song : songs){
PlaylistsUtil.removeFromPlaylist(getActivity(), song, playlists.get(i).id);
}
}
}
}
return true;
}
})
.positiveText(R.string.action_ok)
.neutralText(R.string.action_new_playlist)
.onNeutral( new MaterialDialog.SingleButtonCallback(){
@Override
public void onClick(MaterialDialog dialog, DialogAction action){
CreatePlaylistDialog.create(songs).show(getActivity().getSupportFragmentManager(), "ADD_TO_PLAYLIST");
} else {
materialDialog.dismiss();
PlaylistsUtil.addToPlaylist(getActivity(), songs, playlists.get(i - 1).id, true);
}
})
.build();

}
}
Loading