add useful information to song details dialog
This commit is contained in:
parent
917b1cb9d9
commit
5197af70a9
6 changed files with 132 additions and 20 deletions
|
|
@ -36,6 +36,19 @@ public class SongDetailDialog extends DialogFragment {
|
||||||
return fileSizeInMB + " MB";
|
return fileSizeInMB + " MB";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String getSampleRateString(int sampleRate) {
|
||||||
|
return sampleRate + " Hz";
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getBitRateString(int bitRate) {
|
||||||
|
int bitRateInKB = bitRate / 1000;
|
||||||
|
return bitRateInKB + " kb/s";
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getBitDepthString(int bitDepth) {
|
||||||
|
return bitDepth + "-bit";
|
||||||
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
|
|
@ -49,25 +62,46 @@ public class SongDetailDialog extends DialogFragment {
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
View dialogView = dialog.getCustomView();
|
View dialogView = dialog.getCustomView();
|
||||||
final TextView filePath = dialogView.findViewById(R.id.file_path);
|
final TextView path = dialogView.findViewById(R.id.file_path);
|
||||||
final TextView fileName = dialogView.findViewById(R.id.file_name);
|
final TextView name = dialogView.findViewById(R.id.file_name);
|
||||||
final TextView fileSize = dialogView.findViewById(R.id.file_size);
|
final TextView size = dialogView.findViewById(R.id.file_size);
|
||||||
final TextView fileFormat = dialogView.findViewById(R.id.file_format);
|
final TextView format = dialogView.findViewById(R.id.file_format);
|
||||||
final TextView trackLength = dialogView.findViewById(R.id.track_length);
|
final TextView length = dialogView.findViewById(R.id.track_length);
|
||||||
final TextView bitRate = dialogView.findViewById(R.id.bit_rate);
|
|
||||||
final TextView sampleRate = dialogView.findViewById(R.id.sample_rate);
|
final TextView sampleRate = dialogView.findViewById(R.id.sample_rate);
|
||||||
|
final TextView bitRate = dialogView.findViewById(R.id.bit_rate);
|
||||||
|
final TextView bitDepth = dialogView.findViewById(R.id.bit_depth);
|
||||||
|
final TextView channels = dialogView.findViewById(R.id.channels);
|
||||||
|
|
||||||
filePath.setText(makeTextWithTitle(context, R.string.label_file_path, "-"));
|
path.setText(makeTextWithTitle(context, R.string.label_file_path, "-"));
|
||||||
fileName.setText(makeTextWithTitle(context, R.string.label_file_name, "-"));
|
name.setText(makeTextWithTitle(context, R.string.label_file_name, "-"));
|
||||||
fileSize.setText(makeTextWithTitle(context, R.string.label_file_size, "-"));
|
size.setText(makeTextWithTitle(context, R.string.label_file_size, "-"));
|
||||||
fileFormat.setText(makeTextWithTitle(context, R.string.label_file_format, "-"));
|
format.setText(makeTextWithTitle(context, R.string.label_file_format, "-"));
|
||||||
trackLength.setText(makeTextWithTitle(context, R.string.label_track_length, "-"));
|
length.setText(makeTextWithTitle(context, R.string.label_track_length, "-"));
|
||||||
bitRate.setText(makeTextWithTitle(context, R.string.label_bit_rate, "-"));
|
|
||||||
sampleRate.setText(makeTextWithTitle(context, R.string.label_sample_rate, "-"));
|
sampleRate.setText(makeTextWithTitle(context, R.string.label_sample_rate, "-"));
|
||||||
|
bitRate.setText(makeTextWithTitle(context, R.string.label_bit_rate, "-"));
|
||||||
|
bitDepth.setText(makeTextWithTitle(context, R.string.label_bit_depth, "-"));
|
||||||
|
channels.setText(makeTextWithTitle(context, R.string.label_channels, "-"));
|
||||||
|
|
||||||
if (song != null) {
|
if (song != null) {
|
||||||
fileName.setText(makeTextWithTitle(context, R.string.label_file_name, song.title));
|
path.setText(makeTextWithTitle(context, R.string.label_file_path, song.path));
|
||||||
trackLength.setText(makeTextWithTitle(context, R.string.label_track_length, MusicUtil.getReadableDurationString(song.duration)));
|
name.setText(makeTextWithTitle(context, R.string.label_file_name, song.title));
|
||||||
|
size.setText(makeTextWithTitle(context, R.string.label_file_size, getFileSizeString(song.size)));
|
||||||
|
|
||||||
|
if (song.container.equals(song.codec)) {
|
||||||
|
format.setText(makeTextWithTitle(context, R.string.label_file_format, song.container.toUpperCase()));
|
||||||
|
} else {
|
||||||
|
format.setText(makeTextWithTitle(context, R.string.label_file_format, song.container.toUpperCase() + ":" + song.codec.toUpperCase()));
|
||||||
|
}
|
||||||
|
|
||||||
|
length.setText(makeTextWithTitle(context, R.string.label_track_length, MusicUtil.getReadableDurationString(song.duration)));
|
||||||
|
sampleRate.setText(makeTextWithTitle(context, R.string.label_sample_rate, getSampleRateString(song.sampleRate)));
|
||||||
|
bitRate.setText(makeTextWithTitle(context, R.string.label_bit_rate, getBitRateString(song.bitRate)));
|
||||||
|
bitDepth.setText(makeTextWithTitle(context, R.string.label_bit_depth, getBitDepthString(song.bitDepth)));
|
||||||
|
channels.setText(makeTextWithTitle(context, R.string.label_channels, Integer.toString(song.channels)));
|
||||||
|
|
||||||
|
if (song.bitDepth == 0) {
|
||||||
|
bitDepth.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return dialog;
|
return dialog;
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@ import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
|
||||||
import org.jellyfin.apiclient.model.dto.BaseItemDto;
|
import org.jellyfin.apiclient.model.dto.BaseItemDto;
|
||||||
|
import org.jellyfin.apiclient.model.dto.MediaSourceInfo;
|
||||||
|
import org.jellyfin.apiclient.model.entities.MediaStream;
|
||||||
|
|
||||||
public class Song implements Parcelable {
|
public class Song implements Parcelable {
|
||||||
public static final Song EMPTY_SONG = new Song(null, "", -1, -1, -1, -1, null, "", null, "", null, false);
|
public static final Song EMPTY_SONG = new Song(null, "", -1, -1, -1, -1, null, "", null, "", null, false);
|
||||||
|
|
@ -24,6 +26,17 @@ public class Song implements Parcelable {
|
||||||
public String primary;
|
public String primary;
|
||||||
public boolean favorite;
|
public boolean favorite;
|
||||||
|
|
||||||
|
public String path;
|
||||||
|
public long size;
|
||||||
|
|
||||||
|
public String container;
|
||||||
|
public String codec;
|
||||||
|
|
||||||
|
public int sampleRate;
|
||||||
|
public int bitRate;
|
||||||
|
public int bitDepth;
|
||||||
|
public int channels;
|
||||||
|
|
||||||
public Song(BaseItemDto itemDto) {
|
public Song(BaseItemDto itemDto) {
|
||||||
this.id = itemDto.getId();
|
this.id = itemDto.getId();
|
||||||
this.title = itemDto.getName();
|
this.title = itemDto.getName();
|
||||||
|
|
@ -45,6 +58,25 @@ public class Song implements Parcelable {
|
||||||
|
|
||||||
this.primary = itemDto.getAlbumPrimaryImageTag() != null ? albumId : null;
|
this.primary = itemDto.getAlbumPrimaryImageTag() != null ? albumId : null;
|
||||||
this.favorite = itemDto.getUserData() != null && itemDto.getUserData().getIsFavorite();
|
this.favorite = itemDto.getUserData() != null && itemDto.getUserData().getIsFavorite();
|
||||||
|
|
||||||
|
if (itemDto.getMediaSources() != null && itemDto.getMediaSources().get(0) != null) {
|
||||||
|
MediaSourceInfo source = itemDto.getMediaSources().get(0);
|
||||||
|
|
||||||
|
this.path = source.getPath();
|
||||||
|
this.size = source.getSize();
|
||||||
|
|
||||||
|
this.container = source.getContainer();
|
||||||
|
this.bitRate = source.getBitrate();
|
||||||
|
|
||||||
|
if (source.getMediaStreams() != null && source.getMediaStreams().get(0) != null) {
|
||||||
|
MediaStream stream = source.getMediaStreams().get(0);
|
||||||
|
|
||||||
|
this.codec = stream.getCodec();
|
||||||
|
this.sampleRate = stream.getSampleRate() != null ? stream.getSampleRate() : 0;
|
||||||
|
this.bitDepth = stream.getBitDepth() != null ? stream.getBitDepth() : 0;
|
||||||
|
this.channels = stream.getChannels() != null ? stream.getChannels() : 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Song(String id, String title, int trackNumber, int discNumber, int year, long duration, String albumId, String albumName, String artistId, String artistName, String primary, boolean favorite) {
|
public Song(String id, String title, int trackNumber, int discNumber, int year, long duration, String albumId, String albumName, String artistId, String artistName, String primary, boolean favorite) {
|
||||||
|
|
@ -106,6 +138,17 @@ public class Song implements Parcelable {
|
||||||
|
|
||||||
dest.writeString(this.primary);
|
dest.writeString(this.primary);
|
||||||
dest.writeString(Boolean.toString(favorite));
|
dest.writeString(Boolean.toString(favorite));
|
||||||
|
|
||||||
|
dest.writeString(this.path);
|
||||||
|
dest.writeLong(this.size);
|
||||||
|
|
||||||
|
dest.writeString(this.container);
|
||||||
|
dest.writeString(this.codec);
|
||||||
|
|
||||||
|
dest.writeInt(this.sampleRate);
|
||||||
|
dest.writeInt(this.bitRate);
|
||||||
|
dest.writeInt(this.bitDepth);
|
||||||
|
dest.writeInt(this.channels);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Song(Parcel in) {
|
protected Song(Parcel in) {
|
||||||
|
|
@ -123,7 +166,18 @@ public class Song implements Parcelable {
|
||||||
this.artistName = in.readString();
|
this.artistName = in.readString();
|
||||||
|
|
||||||
this.primary = in.readString();
|
this.primary = in.readString();
|
||||||
this.favorite = Boolean.valueOf(in.readString());
|
this.favorite = Boolean.parseBoolean(in.readString());
|
||||||
|
|
||||||
|
this.path = in.readString();
|
||||||
|
this.size = in.readLong();
|
||||||
|
|
||||||
|
this.container = in.readString();
|
||||||
|
this.codec = in.readString();
|
||||||
|
|
||||||
|
this.sampleRate = in.readInt();
|
||||||
|
this.bitRate = in.readInt();
|
||||||
|
this.bitDepth = in.readInt();
|
||||||
|
this.channels = in.readInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Creator<Song> CREATOR = new Creator<Song>() {
|
public static final Creator<Song> CREATOR = new Creator<Song>() {
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ import com.dkanada.gramophone.util.QueryUtil;
|
||||||
|
|
||||||
import org.jellyfin.apiclient.interaction.Response;
|
import org.jellyfin.apiclient.interaction.Response;
|
||||||
import org.jellyfin.apiclient.model.dto.BaseItemDto;
|
import org.jellyfin.apiclient.model.dto.BaseItemDto;
|
||||||
|
import org.jellyfin.apiclient.model.querying.ItemFields;
|
||||||
import org.jellyfin.apiclient.model.querying.ItemQuery;
|
import org.jellyfin.apiclient.model.querying.ItemQuery;
|
||||||
import org.jellyfin.apiclient.model.querying.ItemsResult;
|
import org.jellyfin.apiclient.model.querying.ItemsResult;
|
||||||
|
|
||||||
|
|
@ -67,6 +68,7 @@ public class SongsFragment extends AbsLibraryPagerRecyclerViewCustomGridSizeFrag
|
||||||
ItemQuery query = new ItemQuery();
|
ItemQuery query = new ItemQuery();
|
||||||
|
|
||||||
query.setIncludeItemTypes(new String[]{"Audio"});
|
query.setIncludeItemTypes(new String[]{"Audio"});
|
||||||
|
query.setFields(new ItemFields[]{ItemFields.MediaSources});
|
||||||
query.setUserId(App.getApiClient().getCurrentUserId());
|
query.setUserId(App.getApiClient().getCurrentUserId());
|
||||||
query.setRecursive(true);
|
query.setRecursive(true);
|
||||||
query.setLimit(PreferenceUtil.getInstance(App.getInstance()).getMaximumListSize());
|
query.setLimit(PreferenceUtil.getInstance(App.getInstance()).getMaximumListSize());
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,8 @@ public class QueryUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void getItems(ItemQuery query, MediaCallback callback) {
|
public static void getItems(ItemQuery query, MediaCallback callback) {
|
||||||
query.setIncludeItemTypes(new String[]{"MusicArtist", "MusicAlbum", "Audio"});
|
query.setIncludeItemTypes(new String[]{"MusicAlbum", "Audio"});
|
||||||
|
query.setFields(new ItemFields[]{ItemFields.MediaSources});
|
||||||
query.setUserId(App.getApiClient().getCurrentUserId());
|
query.setUserId(App.getApiClient().getCurrentUserId());
|
||||||
query.setLimit(40);
|
query.setLimit(40);
|
||||||
query.setRecursive(true);
|
query.setRecursive(true);
|
||||||
|
|
@ -163,6 +164,7 @@ public class QueryUtil {
|
||||||
|
|
||||||
public static void getSongs(ItemQuery query, MediaCallback callback) {
|
public static void getSongs(ItemQuery query, MediaCallback callback) {
|
||||||
query.setIncludeItemTypes(new String[]{"Audio"});
|
query.setIncludeItemTypes(new String[]{"Audio"});
|
||||||
|
query.setFields(new ItemFields[]{ItemFields.MediaSources});
|
||||||
applyProperties(query);
|
applyProperties(query);
|
||||||
applySortMethod(query, PreferenceUtil.getInstance(App.getInstance()).getSongSortMethod());
|
applySortMethod(query, PreferenceUtil.getInstance(App.getInstance()).getSongSortMethod());
|
||||||
App.getApiClient().GetItemsAsync(query, new Response<ItemsResult>() {
|
App.getApiClient().GetItemsAsync(query, new Response<ItemsResult>() {
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,15 @@
|
||||||
android:textAppearance="?android:textAppearanceMedium"
|
android:textAppearance="?android:textAppearanceMedium"
|
||||||
android:textSize="16sp" />
|
android:textSize="16sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/sample_rate"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:fontFamily="sans-serif"
|
||||||
|
android:paddingTop="16dp"
|
||||||
|
android:textAppearance="?android:textAppearanceMedium"
|
||||||
|
android:textSize="16sp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/bit_rate"
|
android:id="@+id/bit_rate"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
|
@ -60,7 +69,16 @@
|
||||||
android:textSize="16sp" />
|
android:textSize="16sp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/sample_rate"
|
android:id="@+id/bit_depth"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:fontFamily="sans-serif"
|
||||||
|
android:paddingTop="16dp"
|
||||||
|
android:textAppearance="?android:textAppearanceMedium"
|
||||||
|
android:textSize="16sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/channels"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:fontFamily="sans-serif"
|
android:fontFamily="sans-serif"
|
||||||
|
|
|
||||||
|
|
@ -63,13 +63,15 @@
|
||||||
<string name="album">Album</string>
|
<string name="album">Album</string>
|
||||||
|
|
||||||
<string name="label_details">Details</string>
|
<string name="label_details">Details</string>
|
||||||
<string name="label_file_name">File Name</string>
|
<string name="label_file_path">Path</string>
|
||||||
<string name="label_file_path">File Path</string>
|
<string name="label_file_name">Name</string>
|
||||||
<string name="label_file_size">Size</string>
|
<string name="label_file_size">Size</string>
|
||||||
<string name="label_file_format">Format</string>
|
<string name="label_file_format">Format</string>
|
||||||
<string name="label_track_length">Length</string>
|
<string name="label_track_length">Length</string>
|
||||||
<string name="label_bit_rate">Bit Rate</string>
|
|
||||||
<string name="label_sample_rate">Sample Rate</string>
|
<string name="label_sample_rate">Sample Rate</string>
|
||||||
|
<string name="label_bit_rate">Bit Rate</string>
|
||||||
|
<string name="label_bit_depth">Bit Depth</string>
|
||||||
|
<string name="label_channels">Channels</string>
|
||||||
|
|
||||||
<string name="battery_optimizations_title">Battery Optimizations</string>
|
<string name="battery_optimizations_title">Battery Optimizations</string>
|
||||||
<string name="battery_optimizations_message">Please disable battery optimizations for media playback while the screen is off.</string>
|
<string name="battery_optimizations_message">Please disable battery optimizations for media playback while the screen is off.</string>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue