1.7.100
This commit is contained in:
parent
74ae7f517e
commit
e5774b422c
22 changed files with 756 additions and 637 deletions
|
@ -10,6 +10,7 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
|
@ -20,6 +21,7 @@ import code.name.monkey.retromusic.model.Playlist;
|
|||
import code.name.monkey.retromusic.model.Song;
|
||||
import code.name.monkey.retromusic.ui.adapter.playlist.AddToPlaylist;
|
||||
import code.name.monkey.retromusic.views.RoundedBottomSheetDialogFragment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
|
@ -27,60 +29,62 @@ import java.util.ArrayList;
|
|||
*/
|
||||
public class AddToPlaylistDialog extends RoundedBottomSheetDialogFragment {
|
||||
|
||||
@BindView(R.id.playlists)
|
||||
RecyclerView playlist;
|
||||
@BindView(R.id.title)
|
||||
TextView title;
|
||||
ArrayList<Playlist> playlists;
|
||||
@BindView(R.id.playlists)
|
||||
RecyclerView playlist;
|
||||
|
||||
@NonNull
|
||||
public static AddToPlaylistDialog create(Song song) {
|
||||
ArrayList<Song> list = new ArrayList<>();
|
||||
list.add(song);
|
||||
return create(list);
|
||||
}
|
||||
@BindView(R.id.title)
|
||||
TextView title;
|
||||
|
||||
@NonNull
|
||||
public static AddToPlaylistDialog create(ArrayList<Song> songs) {
|
||||
AddToPlaylistDialog dialog = new AddToPlaylistDialog();
|
||||
Bundle args = new Bundle();
|
||||
args.putParcelableArrayList("songs", songs);
|
||||
dialog.setArguments(args);
|
||||
return dialog;
|
||||
}
|
||||
ArrayList<Playlist> playlists;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
View layout = inflater.inflate(R.layout.dialog_add_to_playlist, container, false);
|
||||
ButterKnife.bind(this, layout);
|
||||
return layout;
|
||||
}
|
||||
@NonNull
|
||||
public static AddToPlaylistDialog create(Song song) {
|
||||
ArrayList<Song> list = new ArrayList<>();
|
||||
list.add(song);
|
||||
return create(list);
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@OnClick(R.id.action_add_playlist)
|
||||
void newPlaylist() {
|
||||
final ArrayList<Song> songs = getArguments().getParcelableArrayList("songs");
|
||||
CreatePlaylistDialog.create(songs)
|
||||
.show(getActivity().getSupportFragmentManager(), "ADD_TO_PLAYLIST");
|
||||
dismiss();
|
||||
}
|
||||
@NonNull
|
||||
public static AddToPlaylistDialog create(ArrayList<Song> songs) {
|
||||
AddToPlaylistDialog dialog = new AddToPlaylistDialog();
|
||||
Bundle args = new Bundle();
|
||||
args.putParcelableArrayList("songs", songs);
|
||||
dialog.setArguments(args);
|
||||
return dialog;
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
View layout = inflater.inflate(R.layout.dialog_add_to_playlist, container, false);
|
||||
ButterKnife.bind(this, layout);
|
||||
return layout;
|
||||
}
|
||||
|
||||
title.setTextColor(ThemeStore.textColorPrimary(getContext()));
|
||||
final ArrayList<Song> songs = getArguments().getParcelableArrayList("songs");
|
||||
playlists = PlaylistLoader.getAllPlaylists(getActivity()).blockingFirst();
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@OnClick(R.id.action_add_playlist)
|
||||
void newPlaylist() {
|
||||
final ArrayList<Song> songs = getArguments().getParcelableArrayList("songs");
|
||||
CreatePlaylistDialog.create(songs)
|
||||
.show(getActivity().getSupportFragmentManager(), "ADD_TO_PLAYLIST");
|
||||
dismiss();
|
||||
}
|
||||
|
||||
AddToPlaylist playlistAdapter = new AddToPlaylist(getActivity(), playlists,
|
||||
R.layout.item_playlist, songs, getDialog());
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
playlist.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
playlist.setItemAnimator(new DefaultItemAnimator());
|
||||
playlist.setAdapter(playlistAdapter);
|
||||
}
|
||||
title.setTextColor(ThemeStore.textColorPrimary(getContext()));
|
||||
final ArrayList<Song> songs = getArguments().getParcelableArrayList("songs");
|
||||
playlists = PlaylistLoader.getAllPlaylists(getActivity()).blockingFirst();
|
||||
|
||||
AddToPlaylist playlistAdapter = new AddToPlaylist(getActivity(), playlists,
|
||||
R.layout.item_playlist, songs, getDialog());
|
||||
|
||||
playlist.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
playlist.setItemAnimator(new DefaultItemAnimator());
|
||||
playlist.setAdapter(playlistAdapter);
|
||||
}
|
||||
}
|
|
@ -3,12 +3,12 @@ package code.name.monkey.retromusic.dialogs;
|
|||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.BottomSheetDialogFragment;
|
||||
import android.support.design.widget.TextInputEditText;
|
||||
import android.support.v7.widget.CardView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
|
@ -17,7 +17,8 @@ import butterknife.BindView;
|
|||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
import code.name.monkey.appthemehelper.ThemeStore;
|
||||
import code.name.monkey.appthemehelper.util.TintHelper;
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil;
|
||||
import code.name.monkey.appthemehelper.util.MaterialValueHelper;
|
||||
import code.name.monkey.retromusic.R;
|
||||
import code.name.monkey.retromusic.model.Song;
|
||||
import code.name.monkey.retromusic.util.PlaylistsUtil;
|
||||
|
@ -29,11 +30,16 @@ import code.name.monkey.retromusic.views.RoundedBottomSheetDialogFragment;
|
|||
public class CreatePlaylistDialog extends RoundedBottomSheetDialogFragment {
|
||||
|
||||
@BindView(R.id.option_1)
|
||||
EditText playlistName;
|
||||
TextInputEditText playlistName;
|
||||
|
||||
@BindView(R.id.action_cancel)
|
||||
Button actionCancel;
|
||||
TextView actionCancel;
|
||||
|
||||
@BindView(R.id.action_create)
|
||||
Button actionCreate;
|
||||
TextView actionCreate;
|
||||
|
||||
@BindView(R.id.action_create_container)
|
||||
CardView actionCreateContainer;
|
||||
|
||||
@NonNull
|
||||
public static CreatePlaylistDialog create() {
|
||||
|
@ -70,9 +76,17 @@ public class CreatePlaylistDialog extends RoundedBottomSheetDialogFragment {
|
|||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
int accentColor = ThemeStore.accentColor(Objects.requireNonNull(getContext()));
|
||||
TintHelper.setTintAuto(playlistName, accentColor, true);
|
||||
TintHelper.setTintAuto(actionCreate, accentColor, true);
|
||||
actionCancel.setTextColor(accentColor);
|
||||
actionCreateContainer.setCardBackgroundColor(ThemeStore.accentColor(getContext()));
|
||||
|
||||
int primaryTextColor = MaterialValueHelper.getPrimaryTextColor(getContext(), ColorUtil
|
||||
.isColorLight(accentColor));
|
||||
int secondaryTextColor = MaterialValueHelper.getSecondaryTextColor(getContext(), ColorUtil
|
||||
.isColorLight(accentColor));
|
||||
|
||||
actionCreate.setTextColor(primaryTextColor);
|
||||
actionCancel.setTextColor(secondaryTextColor);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@OnClick({R.id.action_cancel, R.id.action_create})
|
||||
|
|
|
@ -8,85 +8,93 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
import code.name.monkey.appthemehelper.ThemeStore;
|
||||
import code.name.monkey.retromusic.R;
|
||||
import code.name.monkey.retromusic.model.Song;
|
||||
import code.name.monkey.retromusic.util.MusicUtil;
|
||||
import code.name.monkey.retromusic.views.RoundedBottomSheetDialogFragment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class DeleteSongsDialog extends RoundedBottomSheetDialogFragment {
|
||||
|
||||
@BindView(R.id.action_delete)
|
||||
TextView delete;
|
||||
@BindView(R.id.title)
|
||||
TextView title;
|
||||
@BindView(R.id.action_cancel)
|
||||
TextView cancel;
|
||||
@BindView(R.id.action_delete)
|
||||
TextView delete;
|
||||
@BindView(R.id.title)
|
||||
TextView title;
|
||||
@BindView(R.id.action_cancel)
|
||||
TextView cancel;
|
||||
|
||||
@NonNull
|
||||
public static DeleteSongsDialog create(Song song) {
|
||||
ArrayList<Song> list = new ArrayList<>();
|
||||
list.add(song);
|
||||
return create(list);
|
||||
}
|
||||
@NonNull
|
||||
public static DeleteSongsDialog create(Song song) {
|
||||
ArrayList<Song> list = new ArrayList<>();
|
||||
list.add(song);
|
||||
return create(list);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static DeleteSongsDialog create(ArrayList<Song> songs) {
|
||||
DeleteSongsDialog dialog = new DeleteSongsDialog();
|
||||
Bundle args = new Bundle();
|
||||
args.putParcelableArrayList("songs", songs);
|
||||
dialog.setArguments(args);
|
||||
return dialog;
|
||||
}
|
||||
@NonNull
|
||||
public static DeleteSongsDialog create(ArrayList<Song> songs) {
|
||||
DeleteSongsDialog dialog = new DeleteSongsDialog();
|
||||
Bundle args = new Bundle();
|
||||
args.putParcelableArrayList("songs", songs);
|
||||
dialog.setArguments(args);
|
||||
return dialog;
|
||||
}
|
||||
|
||||
@OnClick({R.id.action_cancel, R.id.action_delete})
|
||||
void actions(View view) {
|
||||
//noinspection ConstantConditions
|
||||
final ArrayList<Song> songs = getArguments().getParcelableArrayList("songs");
|
||||
switch (view.getId()) {
|
||||
case R.id.action_delete:
|
||||
if (getActivity() == null) {
|
||||
return;
|
||||
@OnClick({R.id.action_cancel, R.id.action_delete})
|
||||
void actions(View view) {
|
||||
//noinspection ConstantConditions
|
||||
final ArrayList<Song> songs = getArguments().getParcelableArrayList("songs");
|
||||
switch (view.getId()) {
|
||||
case R.id.action_delete:
|
||||
if (getActivity() == null) {
|
||||
return;
|
||||
}
|
||||
if (songs != null) {
|
||||
MusicUtil.deleteTracks(getActivity(), songs);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
delete.setTextColor(ThemeStore.textColorPrimary(getContext()));
|
||||
title.setTextColor(ThemeStore.textColorPrimary(getContext()));
|
||||
cancel.setTextColor(ThemeStore.textColorPrimary(getContext()));
|
||||
|
||||
|
||||
//noinspection unchecked,ConstantConditions
|
||||
final ArrayList<Song> songs = getArguments().getParcelableArrayList("songs");
|
||||
int title;
|
||||
CharSequence content;
|
||||
if (songs != null) {
|
||||
MusicUtil.deleteTracks(getActivity(), songs);
|
||||
if (songs.size() > 1) {
|
||||
title = R.string.delete_songs_title;
|
||||
content = Html.fromHtml(getString(R.string.delete_x_songs, songs.size()));
|
||||
} else {
|
||||
title = R.string.delete_song_title;
|
||||
content = Html.fromHtml(getString(R.string.delete_song_x, songs.get(0).title));
|
||||
}
|
||||
this.title.setText(title);
|
||||
this.delete.setText(content);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
//noinspection unchecked,ConstantConditions
|
||||
final ArrayList<Song> songs = getArguments().getParcelableArrayList("songs");
|
||||
int title;
|
||||
CharSequence content;
|
||||
if (songs != null) {
|
||||
if (songs.size() > 1) {
|
||||
title = R.string.delete_songs_title;
|
||||
content = Html.fromHtml(getString(R.string.delete_x_songs, songs.size()));
|
||||
} else {
|
||||
title = R.string.delete_song_title;
|
||||
content = Html.fromHtml(getString(R.string.delete_song_x, songs.get(0).title));
|
||||
}
|
||||
this.title.setText(title);
|
||||
this.delete.setText(content);
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
View layout = inflater.inflate(R.layout.dialog_delete_songs, container, false);
|
||||
ButterKnife.bind(this, layout);
|
||||
return layout;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
View layout = inflater.inflate(R.layout.dialog_delete_songs, container, false);
|
||||
ButterKnife.bind(this, layout);
|
||||
return layout;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,14 +9,21 @@ import android.support.v7.widget.AppCompatTextView;
|
|||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.BindViews;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
import butterknife.Unbinder;
|
||||
import code.name.monkey.appthemehelper.ThemeStore;
|
||||
import code.name.monkey.appthemehelper.common.views.ATEPrimaryTextView;
|
||||
import code.name.monkey.appthemehelper.common.views.ATESecondaryTextView;
|
||||
import code.name.monkey.retromusic.R;
|
||||
import code.name.monkey.retromusic.RetroApplication;
|
||||
import code.name.monkey.retromusic.ui.activities.MainActivity;
|
||||
|
@ -46,6 +53,12 @@ public class HomeOptionDialog extends RoundedBottomSheetDialogFragment {
|
|||
@BindView(R.id.title_welcome)
|
||||
AppCompatTextView titleWelcome;
|
||||
|
||||
@BindViews({R.id.tv_about, R.id.title_welcome, R.id.text, R.id.tv_buy_pro, R.id.tv_folder, R.id.tv_rate_app,
|
||||
R.id.tv_settings, R.id.tv_sleep_timer})
|
||||
List<TextView> textViews;
|
||||
|
||||
static ButterKnife.Setter<TextView, Integer> textColor = (view, value, index) -> view.setTextColor(value.intValue());
|
||||
|
||||
private CompositeDisposable disposable = new CompositeDisposable();
|
||||
|
||||
@Nullable
|
||||
|
@ -56,6 +69,7 @@ public class HomeOptionDialog extends RoundedBottomSheetDialogFragment {
|
|||
mUnbinder = ButterKnife.bind(this, layout);
|
||||
layout.findViewById(R.id.action_buy_pro).setVisibility(RetroApplication.isProVersion() ? View
|
||||
.GONE : View.VISIBLE);
|
||||
ButterKnife.apply(textViews, textColor, ThemeStore.textColorPrimary(getContext()));
|
||||
return layout;
|
||||
}
|
||||
|
||||
|
@ -97,12 +111,13 @@ public class HomeOptionDialog extends RoundedBottomSheetDialogFragment {
|
|||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@OnClick({R.id.action_about, R.id.user_info_container, R.id.action_buy_pro, R.id.action_folder,
|
||||
R.id.action_settings, R.id.action_sleep_timer,R.id.action_rate})
|
||||
R.id.action_settings, R.id.action_sleep_timer, R.id.action_rate})
|
||||
public void onViewClicked(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.user_info_container:
|
||||
NavigationUtil.goToUserInfo(getActivity());
|
||||
break; case R.id.action_rate:
|
||||
break;
|
||||
case R.id.action_rate:
|
||||
NavigationUtil.goToPlayStore(getActivity());
|
||||
break;
|
||||
case R.id.action_folder:
|
||||
|
|
|
@ -5,6 +5,9 @@ import android.app.PendingIntent;
|
|||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.ClipDrawable;
|
||||
import android.graphics.drawable.LayerDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.os.CountDownTimer;
|
||||
import android.os.SystemClock;
|
||||
|
@ -24,7 +27,6 @@ import butterknife.BindView;
|
|||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
import code.name.monkey.appthemehelper.ThemeStore;
|
||||
import code.name.monkey.appthemehelper.util.TintHelper;
|
||||
import code.name.monkey.retromusic.R;
|
||||
import code.name.monkey.retromusic.service.MusicService;
|
||||
import code.name.monkey.retromusic.util.MusicUtil;
|
||||
|
@ -39,9 +41,9 @@ public class SleepTimerDialog extends RoundedBottomSheetDialogFragment {
|
|||
@BindView(R.id.timer_display)
|
||||
TextView timerDisplay;
|
||||
@BindView(R.id.action_set)
|
||||
Button setButton;
|
||||
TextView setButton;
|
||||
@BindView(R.id.action_cancel)
|
||||
Button cancelButton;
|
||||
TextView cancelButton;
|
||||
|
||||
private int seekArcProgress;
|
||||
private TimerUpdater timerUpdater;
|
||||
|
@ -68,6 +70,12 @@ public class SleepTimerDialog extends RoundedBottomSheetDialogFragment {
|
|||
return layout;
|
||||
}
|
||||
|
||||
private void setProgressBarColor(int dark) {
|
||||
LayerDrawable ld = (LayerDrawable) seekArc.getProgressDrawable();
|
||||
ClipDrawable clipDrawable = (ClipDrawable) ld.findDrawableByLayerId(android.R.id.progress);
|
||||
clipDrawable.setColorFilter(dark, PorterDuff.Mode.SRC_IN);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
@ -77,10 +85,8 @@ public class SleepTimerDialog extends RoundedBottomSheetDialogFragment {
|
|||
updateTimeDisplayTime();
|
||||
seekArc.setProgress(seekArcProgress);
|
||||
|
||||
int accentColor = ThemeStore.accentColor(getContext());
|
||||
TintHelper.setTintAuto(seekArc, accentColor, true);
|
||||
setButton.setTextColor(accentColor);
|
||||
cancelButton.setTextColor(accentColor);
|
||||
//noinspection ConstantConditions
|
||||
setProgressBarColor(ThemeStore.accentColor(getContext()));
|
||||
|
||||
seekArc.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||
@Override
|
||||
|
|
|
@ -23,7 +23,12 @@ import org.jaudiotagger.tag.TagException;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.BindViews;
|
||||
import butterknife.ButterKnife;
|
||||
import code.name.monkey.appthemehelper.ThemeStore;
|
||||
import code.name.monkey.retromusic.R;
|
||||
import code.name.monkey.retromusic.model.Song;
|
||||
import code.name.monkey.retromusic.util.MusicUtil;
|
||||
|
@ -55,60 +60,65 @@ public class SongDetailDialog extends RoundedBottomSheetDialogFragment {
|
|||
return fileSizeInMB + " MB";
|
||||
}
|
||||
|
||||
private void setTextColor(List<TextView> textColor) {
|
||||
for (TextView textView : textColor) {
|
||||
//noinspection ConstantConditions
|
||||
textView.setTextColor(ThemeStore.textColorPrimary(getContext()));
|
||||
}
|
||||
}
|
||||
|
||||
@BindViews({R.id.title,
|
||||
R.id.file_name,
|
||||
R.id.file_path,
|
||||
R.id.file_size,
|
||||
R.id.file_format,
|
||||
R.id.track_length,
|
||||
R.id.bitrate,
|
||||
R.id.sampling_rate})
|
||||
List<TextView> textViews;
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
View dialogView = inflater.inflate(R.layout.dialog_file_details, container, false);
|
||||
ButterKnife.bind(this, dialogView);
|
||||
Context context = getContext();
|
||||
|
||||
final TextView fileName = dialogView.findViewById(R.id.file_name);
|
||||
final TextView filePath = dialogView.findViewById(R.id.file_path);
|
||||
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.bitrate);
|
||||
final TextView samplingRate = dialogView.findViewById(R.id.sampling_rate);
|
||||
setTextColor(textViews);
|
||||
|
||||
fileName.setText(makeTextWithTitle(context, R.string.label_file_name, "-"));
|
||||
filePath.setText(makeTextWithTitle(context, R.string.label_file_path, "-"));
|
||||
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, "-"));
|
||||
samplingRate.setText(makeTextWithTitle(context, R.string.label_sampling_rate, "-"));
|
||||
textViews.get(1).setText(makeTextWithTitle(context, R.string.label_file_name, "-"));
|
||||
textViews.get(2).setText(makeTextWithTitle(context, R.string.label_file_path, "-"));
|
||||
textViews.get(3).setText(makeTextWithTitle(context, R.string.label_file_size, "-"));
|
||||
textViews.get(4).setText(makeTextWithTitle(context, R.string.label_file_format, "-"));
|
||||
textViews.get(5).setText(makeTextWithTitle(context, R.string.label_track_length, "-"));
|
||||
textViews.get(6).setText(makeTextWithTitle(context, R.string.label_bit_rate, "-"));
|
||||
textViews.get(7).setText(makeTextWithTitle(context, R.string.label_sampling_rate, "-"));
|
||||
|
||||
final Song song = getArguments().getParcelable("song");
|
||||
if (song != null) {
|
||||
final File songFile = new File(song.data);
|
||||
if (songFile.exists()) {
|
||||
fileName.setText(makeTextWithTitle(context, R.string.label_file_name, songFile.getName()));
|
||||
filePath.setText(
|
||||
makeTextWithTitle(context, R.string.label_file_path, songFile.getAbsolutePath()));
|
||||
fileSize.setText(makeTextWithTitle(context, R.string.label_file_size,
|
||||
getFileSizeString(songFile.length())));
|
||||
textViews.get(1).setText(makeTextWithTitle(context, R.string.label_file_name, songFile.getName()));
|
||||
textViews.get(2).setText(makeTextWithTitle(context, R.string.label_file_path, songFile.getAbsolutePath()));
|
||||
textViews.get(3).setText(makeTextWithTitle(context, R.string.label_file_size, getFileSizeString(songFile.length())));
|
||||
try {
|
||||
AudioFile audioFile = AudioFileIO.read(songFile);
|
||||
AudioHeader audioHeader = audioFile.getAudioHeader();
|
||||
|
||||
fileFormat.setText(
|
||||
makeTextWithTitle(context, R.string.label_file_format, audioHeader.getFormat()));
|
||||
trackLength.setText(makeTextWithTitle(context, R.string.label_track_length, MusicUtil
|
||||
.getReadableDurationString(audioHeader.getTrackLength() * 1000)));
|
||||
bitRate.setText(makeTextWithTitle(context, R.string.label_bit_rate,
|
||||
audioHeader.getBitRate() + " kb/s"));
|
||||
samplingRate.setText(makeTextWithTitle(context, R.string.label_sampling_rate,
|
||||
audioHeader.getSampleRate() + " Hz"));
|
||||
textViews.get(4).setText(makeTextWithTitle(context, R.string.label_file_format, audioHeader.getFormat()));
|
||||
textViews.get(5).setText(makeTextWithTitle(context, R.string.label_track_length, MusicUtil.getReadableDurationString(audioHeader.getTrackLength() * 1000)));
|
||||
textViews.get(6).setText(makeTextWithTitle(context, R.string.label_bit_rate, audioHeader.getBitRate() + " kb/s"));
|
||||
textViews.get(7).setText(makeTextWithTitle(context, R.string.label_sampling_rate, audioHeader.getSampleRate() + " Hz"));
|
||||
} catch (@NonNull CannotReadException | IOException | TagException | ReadOnlyFileException | InvalidAudioFrameException e) {
|
||||
Log.e(TAG, "error while reading the song file", e);
|
||||
// fallback
|
||||
trackLength.setText(makeTextWithTitle(context, R.string.label_track_length,
|
||||
MusicUtil.getReadableDurationString(song.duration)));
|
||||
textViews.get(5).setText(makeTextWithTitle(context, R.string.label_track_length, MusicUtil.getReadableDurationString(song.duration)));
|
||||
}
|
||||
} else {
|
||||
// fallback
|
||||
fileName.setText(makeTextWithTitle(context, R.string.label_file_name, song.title));
|
||||
trackLength.setText(makeTextWithTitle(context, R.string.label_track_length,
|
||||
MusicUtil.getReadableDurationString(song.duration)));
|
||||
textViews.get(1).setText(makeTextWithTitle(context, R.string.label_file_name, song.title));
|
||||
textViews.get(5).setText(makeTextWithTitle(context, R.string.label_track_length, MusicUtil.getReadableDurationString(song.duration)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue