add useful information to song details dialog

This commit is contained in:
dkanada 2020-08-29 15:37:08 +09:00
commit 5197af70a9
6 changed files with 132 additions and 20 deletions

View file

@ -36,6 +36,19 @@ public class SongDetailDialog extends DialogFragment {
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
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
@ -49,25 +62,46 @@ public class SongDetailDialog extends DialogFragment {
.build();
View dialogView = dialog.getCustomView();
final TextView filePath = dialogView.findViewById(R.id.file_path);
final TextView fileName = dialogView.findViewById(R.id.file_name);
final TextView fileSize = dialogView.findViewById(R.id.file_size);
final TextView fileFormat = dialogView.findViewById(R.id.file_format);
final TextView trackLength = dialogView.findViewById(R.id.track_length);
final TextView bitRate = dialogView.findViewById(R.id.bit_rate);
final TextView path = dialogView.findViewById(R.id.file_path);
final TextView name = dialogView.findViewById(R.id.file_name);
final TextView size = dialogView.findViewById(R.id.file_size);
final TextView format = dialogView.findViewById(R.id.file_format);
final TextView length = dialogView.findViewById(R.id.track_length);
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, "-"));
fileName.setText(makeTextWithTitle(context, R.string.label_file_name, "-"));
fileSize.setText(makeTextWithTitle(context, R.string.label_file_size, "-"));
fileFormat.setText(makeTextWithTitle(context, R.string.label_file_format, "-"));
trackLength.setText(makeTextWithTitle(context, R.string.label_track_length, "-"));
bitRate.setText(makeTextWithTitle(context, R.string.label_bit_rate, "-"));
path.setText(makeTextWithTitle(context, R.string.label_file_path, "-"));
name.setText(makeTextWithTitle(context, R.string.label_file_name, "-"));
size.setText(makeTextWithTitle(context, R.string.label_file_size, "-"));
format.setText(makeTextWithTitle(context, R.string.label_file_format, "-"));
length.setText(makeTextWithTitle(context, R.string.label_track_length, "-"));
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) {
fileName.setText(makeTextWithTitle(context, R.string.label_file_name, song.title));
trackLength.setText(makeTextWithTitle(context, R.string.label_track_length, MusicUtil.getReadableDurationString(song.duration)));
path.setText(makeTextWithTitle(context, R.string.label_file_path, song.path));
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;