Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added play count to details #1211

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 10 additions & 0 deletions app/src/main/java/ch/blinkenlights/android/vanilla/Song.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public class Song implements Comparable<Song> {
MediaLibrary.SongColumns.SONG_NUMBER,
MediaLibrary.SongColumns.DISC_NUMBER,
MediaLibrary.SongColumns.FLAGS,
MediaLibrary.SongColumns.PLAYCOUNT,
};

public static final String[] EMPTY_PLAYLIST_PROJECTION = {
Expand All @@ -83,6 +84,7 @@ public class Song implements Comparable<Song> {
MediaLibrary.SongColumns.SONG_NUMBER,
MediaLibrary.SongColumns.DISC_NUMBER,
MediaLibrary.SongColumns.FLAGS,
MediaLibrary.SongColumns.PLAYCOUNT,
};

/**
Expand Down Expand Up @@ -133,6 +135,10 @@ public class Song implements Comparable<Song> {
* The disc number where this song is present.
*/
public int discNumber;
/**
* Count of times the song was played
*/
public int playCount;

/**
* Song flags. Currently {@link #FLAG_RANDOM} or {@link #FLAG_NO_COVER}.
Expand Down Expand Up @@ -192,9 +198,13 @@ public void populate(Cursor cursor)
trackNumber = cursor.getInt(8);
discNumber = cursor.getInt(9);


// Read and interpret the media library flags of this entry.
// There is no 1:1 mapping, so we must check each flag on its own.
int libraryFlags = cursor.getInt(10);

playCount = cursor.getInt(11);

if ((libraryFlags & MediaLibrary.SONG_FLAG_NO_ALBUM) != 0) {
// Note that we only set, never unset: the song may already
// have the flag set for other reasons.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
final TextView genreView = view.findViewById(R.id.genre);
final TextView trackView = view.findViewById(R.id.track);
final TextView yearView = view.findViewById(R.id.year);

final TextView composerView = view.findViewById(R.id.composer);
final TextView playCountView = view.findViewById(R.id.playcount);

final TextView pathView = view.findViewById(R.id.path);
final TextView formatView = view.findViewById(R.id.format);

Expand All @@ -105,7 +108,10 @@ public void run() {
genreView.setText(metadata.getFirst(MediaMetadataExtractor.GENRE));
trackView.setText(song.getTrackAndDiscNumber());
yearView.setText(metadata.getFirst(MediaMetadataExtractor.YEAR));

composerView.setText(metadata.getFirst(MediaMetadataExtractor.COMPOSER));
playCountView.setText(String.valueOf(song.playCount));

pathView.setText(song.path);
formatView.setText(metadata.getFormat());
}
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/layout/track_details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,15 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
<TextView android:id="@+id/composer" android:textColor="?overlay_foreground_color" />
</TableRow>

<TableRow>
<TextView
android:text="@string/_playcount"
android:textColor="?overlay_foreground_color"
android:paddingRight="5dip"
android:gravity="right" />
<TextView android:id="@+id/playcount" android:textColor="?overlay_foreground_color" />
</TableRow>

<TableRow>
<TextView
android:text="@string/_path"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-uk/translatable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<string name="_genre">жанр</string>
<string name="_track">композиція</string>
<string name="_composer">композитор</string>
<string name="_playcount">прослуховувань</string>
<string name="_path">шлях</string>
<string name="_format">формат</string>
<string name="_title">назва</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/translatable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ THE SOFTWARE.
<string name="_genre">genre</string>
<string name="_track">track</string>
<string name="_composer">composer</string>
<string name="_playcount">play count</string>
<string name="_path">path</string>
<string name="_format">format</string>
<string name="_title">title</string>
Expand Down