Removed libs folder
This commit is contained in:
parent
f77b426617
commit
960b057e0a
80 changed files with 1192 additions and 1673 deletions
|
@ -2,11 +2,9 @@ package code.name.monkey.retromusic.ui.activities;
|
|||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.Color;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.text.InputType;
|
||||
import android.text.TextUtils;
|
||||
|
@ -16,18 +14,6 @@ import android.view.WindowManager;
|
|||
import android.widget.RadioButton;
|
||||
import android.widget.RadioGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.afollestad.materialdialogs.DialogAction;
|
||||
import com.afollestad.materialdialogs.MaterialDialog;
|
||||
import com.bumptech.glide.Glide;
|
||||
|
||||
import org.jaudiotagger.tag.FieldKey;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
|
@ -45,348 +31,300 @@ import code.name.monkey.retromusic.util.LyricUtil;
|
|||
import code.name.monkey.retromusic.util.MusicUtil;
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil;
|
||||
import code.name.monkey.retromusic.util.RetroUtil;
|
||||
import code.name.monkey.retromusic.views.LyricView;
|
||||
import com.afollestad.materialdialogs.DialogAction;
|
||||
import com.afollestad.materialdialogs.MaterialDialog;
|
||||
import com.bumptech.glide.Glide;
|
||||
import io.reactivex.disposables.CompositeDisposable;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
import org.jaudiotagger.tag.FieldKey;
|
||||
|
||||
public class LyricsActivity extends AbsMusicServiceActivity implements MusicProgressViewUpdateHelper.Callback {
|
||||
public class LyricsActivity extends AbsMusicServiceActivity implements
|
||||
MusicProgressViewUpdateHelper.Callback {
|
||||
|
||||
@BindView(R.id.title)
|
||||
TextView songTitle;
|
||||
@BindView(R.id.text)
|
||||
TextView songText;
|
||||
@BindView(R.id.lyrics)
|
||||
LyricView lyricView;
|
||||
@BindView(R.id.toolbar)
|
||||
Toolbar toolbar;
|
||||
@BindView(R.id.offline_lyrics)
|
||||
TextView offlineLyrics;
|
||||
@BindView(R.id.actions)
|
||||
RadioGroup actionsLayout;
|
||||
@BindView(R.id.gradient_background)
|
||||
View background;
|
||||
@BindView(R.id.title)
|
||||
TextView songTitle;
|
||||
@BindView(R.id.text)
|
||||
TextView songText;
|
||||
|
||||
private MusicProgressViewUpdateHelper updateHelper;
|
||||
private AsyncTask updateLyricsAsyncTask;
|
||||
private CompositeDisposable disposable;
|
||||
private Song song;
|
||||
private Lyrics lyrics;
|
||||
@BindView(R.id.toolbar)
|
||||
Toolbar toolbar;
|
||||
@BindView(R.id.offline_lyrics)
|
||||
TextView offlineLyrics;
|
||||
@BindView(R.id.actions)
|
||||
RadioGroup actionsLayout;
|
||||
@BindView(R.id.gradient_background)
|
||||
View background;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_lyrics);
|
||||
ButterKnife.bind(this);
|
||||
private MusicProgressViewUpdateHelper updateHelper;
|
||||
private AsyncTask updateLyricsAsyncTask;
|
||||
private CompositeDisposable disposable;
|
||||
private Song song;
|
||||
private Lyrics lyrics;
|
||||
|
||||
setStatusbarColorAuto();
|
||||
setNavigationbarColorAuto();
|
||||
setTaskDescriptionColorAuto();
|
||||
setLightNavigationBar(true);
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_lyrics);
|
||||
ButterKnife.bind(this);
|
||||
|
||||
updateHelper = new MusicProgressViewUpdateHelper(this, 500, 1000);
|
||||
setStatusbarColorAuto();
|
||||
setNavigationbarColorAuto();
|
||||
setTaskDescriptionColorAuto();
|
||||
setLightNavigationBar(true);
|
||||
|
||||
setupToolbar();
|
||||
setupLyricsView();
|
||||
setupWakelock();
|
||||
updateHelper = new MusicProgressViewUpdateHelper(this, 500, 1000);
|
||||
|
||||
actionsLayout.setOnCheckedChangeListener((group, checkedId) -> selectLyricsTye(checkedId));
|
||||
setupToolbar();
|
||||
setupLyricsView();
|
||||
setupWakelock();
|
||||
|
||||
actionsLayout.setOnCheckedChangeListener((group, checkedId) -> selectLyricsTye(checkedId));
|
||||
}
|
||||
|
||||
private void selectLyricsTye(int group) {
|
||||
|
||||
RadioButton radioButton = actionsLayout.findViewById(group);
|
||||
radioButton.setBackgroundTintList(ColorStateList.valueOf(ThemeStore.accentColor(this)));
|
||||
radioButton.setTextColor(ThemeStore.textColorPrimary(this));
|
||||
|
||||
offlineLyrics.setVisibility(View.GONE);
|
||||
|
||||
switch (group) {
|
||||
case R.id.synced_lyrics:
|
||||
loadLRCLyrics();
|
||||
|
||||
break;
|
||||
default:
|
||||
case R.id.normal_lyrics:
|
||||
loadSongLyrics();
|
||||
offlineLyrics.setVisibility(View.VISIBLE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void selectLyricsTye(int group) {
|
||||
|
||||
RadioButton radioButton = actionsLayout.findViewById(group);
|
||||
radioButton.setBackgroundTintList(ColorStateList.valueOf(ThemeStore.accentColor(this)));
|
||||
radioButton.setTextColor(ThemeStore.textColorPrimary(this));
|
||||
|
||||
offlineLyrics.setVisibility(View.GONE);
|
||||
lyricView.setVisibility(View.GONE);
|
||||
switch (group) {
|
||||
case R.id.synced_lyrics:
|
||||
loadLRCLyrics();
|
||||
lyricView.setVisibility(View.VISIBLE);
|
||||
break;
|
||||
default:
|
||||
case R.id.normal_lyrics:
|
||||
loadSongLyrics();
|
||||
offlineLyrics.setVisibility(View.VISIBLE);
|
||||
break;
|
||||
}
|
||||
private void loadLRCLyrics() {
|
||||
if (LyricUtil.isLrcFileExist(song.title, song.artistName)) {
|
||||
showLyricsLocal(LyricUtil.getLocalLyricFile(song.title, song.artistName));
|
||||
}
|
||||
}
|
||||
|
||||
private void loadLRCLyrics() {
|
||||
if (LyricUtil.isLrcFileExist(song.title, song.artistName)) {
|
||||
showLyricsLocal(LyricUtil.getLocalLyricFile(song.title, song.artistName));
|
||||
}
|
||||
private void setupWakelock() {
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
}
|
||||
|
||||
private void setupLyricsView() {
|
||||
disposable = new CompositeDisposable();
|
||||
}
|
||||
|
||||
private void setupToolbar() {
|
||||
toolbar.setBackgroundColor(ThemeStore.primaryColor(this));
|
||||
toolbar.setTitle("");
|
||||
toolbar.setNavigationOnClickListener(v -> onBackPressed());
|
||||
setSupportActionBar(toolbar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayingMetaChanged() {
|
||||
super.onPlayingMetaChanged();
|
||||
loadLrcFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
updateHelper.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
updateHelper.stop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onServiceConnected() {
|
||||
super.onServiceConnected();
|
||||
loadLrcFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
disposable.clear();
|
||||
|
||||
if (updateLyricsAsyncTask != null && !updateLyricsAsyncTask.isCancelled()) {
|
||||
updateLyricsAsyncTask.cancel(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void setupWakelock() {
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (item.getItemId() == android.R.id.home) {
|
||||
onBackPressed();
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
private void setupLyricsView() {
|
||||
disposable = new CompositeDisposable();
|
||||
//lyricView.setLineSpace(15.0f);
|
||||
//lyricView.setTextSize(17.0f);
|
||||
//lyricView.setPlayable(true);
|
||||
//lyricView.setTranslationY(DensityUtil.getScreenWidth(this) + DensityUtil.dip2px(this, 120));
|
||||
lyricView.setOnPlayerClickListener((progress, content) -> MusicPlayerRemote.seekTo((int) progress));
|
||||
@Override
|
||||
public void onUpdateProgressViews(int progress, int total) {
|
||||
|
||||
//lyricView.setHighLightTextColor(ThemeStore.accentColor(this));
|
||||
lyricView.setDefaultColor(ContextCompat.getColor(this, R.color.md_grey_400));
|
||||
//lyricView.setTouchable(false);
|
||||
lyricView.setHintColor(Color.WHITE);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void setupToolbar() {
|
||||
toolbar.setBackgroundColor(ThemeStore.primaryColor(this));
|
||||
toolbar.setTitle("");
|
||||
toolbar.setNavigationOnClickListener(v -> onBackPressed());
|
||||
setSupportActionBar(toolbar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayingMetaChanged() {
|
||||
super.onPlayingMetaChanged();
|
||||
loadLrcFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
updateHelper.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
updateHelper.stop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onServiceConnected() {
|
||||
super.onServiceConnected();
|
||||
loadLrcFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
disposable.clear();
|
||||
lyricView.setOnPlayerClickListener(null);
|
||||
|
||||
if (updateLyricsAsyncTask != null && !updateLyricsAsyncTask.isCancelled()) {
|
||||
updateLyricsAsyncTask.cancel(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (item.getItemId() == android.R.id.home) {
|
||||
onBackPressed();
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateProgressViews(int progress, int total) {
|
||||
lyricView.setCurrentTimeMillis(progress);
|
||||
}
|
||||
|
||||
private void loadLrcFile() {
|
||||
song = MusicPlayerRemote.getCurrentSong();
|
||||
songTitle.setText(song.title);
|
||||
songText.setText(song.artistName);
|
||||
SongGlideRequest.Builder.from(Glide.with(this), song)
|
||||
.checkIgnoreMediaStore(this)
|
||||
.generatePalette(this)
|
||||
.build()
|
||||
.into(new RetroMusicColoredTarget(findViewById(R.id.image)) {
|
||||
@Override
|
||||
public void onColorReady(int color) {
|
||||
if (PreferenceUtil.getInstance(LyricsActivity.this).getAdaptiveColor()) {
|
||||
background.setBackgroundColor(color);
|
||||
}
|
||||
}
|
||||
});
|
||||
selectLyricsTye(actionsLayout.getCheckedRadioButtonId());
|
||||
}
|
||||
|
||||
private void showLyricsLocal(File file) {
|
||||
if (file == null) {
|
||||
lyricView.reset();
|
||||
lyricView.setVisibility(View.GONE);
|
||||
} else {
|
||||
lyricView.setVisibility(View.VISIBLE);
|
||||
lyricView.setLyricFile(file, "UTF-8");
|
||||
}
|
||||
}
|
||||
|
||||
@OnClick({R.id.edit_lyrics})
|
||||
public void onViewClicked(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.edit_lyrics:
|
||||
switch (actionsLayout.getCheckedRadioButtonId()) {
|
||||
case R.id.synced_lyrics:
|
||||
showSyncedLyrics();
|
||||
break;
|
||||
case R.id.normal_lyrics:
|
||||
showLyricsSaveDialog();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private void loadSongLyrics() {
|
||||
if (updateLyricsAsyncTask != null) updateLyricsAsyncTask.cancel(false);
|
||||
final Song song = MusicPlayerRemote.getCurrentSong();
|
||||
updateLyricsAsyncTask = new AsyncTask<Void, Void, Lyrics>() {
|
||||
@Override
|
||||
protected Lyrics doInBackground(Void... params) {
|
||||
String data = MusicUtil.getLyrics(song);
|
||||
if (TextUtils.isEmpty(data)) {
|
||||
return null;
|
||||
}
|
||||
return Lyrics.parse(song, data);
|
||||
private void loadLrcFile() {
|
||||
song = MusicPlayerRemote.getCurrentSong();
|
||||
songTitle.setText(song.title);
|
||||
songText.setText(song.artistName);
|
||||
SongGlideRequest.Builder.from(Glide.with(this), song)
|
||||
.checkIgnoreMediaStore(this)
|
||||
.generatePalette(this)
|
||||
.build()
|
||||
.into(new RetroMusicColoredTarget(findViewById(R.id.image)) {
|
||||
@Override
|
||||
public void onColorReady(int color) {
|
||||
if (PreferenceUtil.getInstance(LyricsActivity.this).getAdaptiveColor()) {
|
||||
background.setBackgroundColor(color);
|
||||
}
|
||||
}
|
||||
});
|
||||
selectLyricsTye(actionsLayout.getCheckedRadioButtonId());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
super.onPreExecute();
|
||||
lyrics = null;
|
||||
}
|
||||
private void showLyricsLocal(File file) {
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Lyrics l) {
|
||||
lyrics = l;
|
||||
offlineLyrics.setVisibility(View.VISIBLE);
|
||||
if (l == null) {
|
||||
offlineLyrics.setText(R.string.no_lyrics_found);
|
||||
return;
|
||||
}
|
||||
offlineLyrics.setText(l.data);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCancelled(Lyrics s) {
|
||||
onPostExecute(null);
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
|
||||
private void showSyncedLyrics() {
|
||||
String content = "";
|
||||
try {
|
||||
content = LyricUtil.getStringFromFile(song.title, song.artistName);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@OnClick({R.id.edit_lyrics})
|
||||
public void onViewClicked(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.edit_lyrics:
|
||||
switch (actionsLayout.getCheckedRadioButtonId()) {
|
||||
case R.id.synced_lyrics:
|
||||
showSyncedLyrics();
|
||||
break;
|
||||
case R.id.normal_lyrics:
|
||||
showLyricsSaveDialog();
|
||||
break;
|
||||
}
|
||||
new MaterialDialog.Builder(this)
|
||||
.title("Add lyrics")
|
||||
.neutralText("Search")
|
||||
.content("Add time frame lyrics")
|
||||
.negativeText("Delete")
|
||||
.onNegative((dialog, which) -> {
|
||||
LyricUtil.deleteLrcFile(song.title, song.artistName);
|
||||
loadLrcFile();
|
||||
})
|
||||
.onNeutral((dialog, which) -> RetroUtil.openUrl(LyricsActivity.this, getGoogleSearchLrcUrl()))
|
||||
.inputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE)
|
||||
.input("Paste lyrics here", content, (dialog, input) -> {
|
||||
LyricUtil.writeLrcToLoc(song.title, song.artistName, input.toString());
|
||||
loadLrcFile();
|
||||
}).show();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private String getGoogleSearchLrcUrl() {
|
||||
String baseUrl = "http://www.google.com/search?";
|
||||
String query = song.title + "+" + song.artistName;
|
||||
query = "q=" + query.replace(" ", "+") + " .lrc";
|
||||
baseUrl += query;
|
||||
return baseUrl;
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private void loadSongLyrics() {
|
||||
if (updateLyricsAsyncTask != null) {
|
||||
updateLyricsAsyncTask.cancel(false);
|
||||
}
|
||||
|
||||
private void showLyricsSaveDialog() {
|
||||
String content = "";
|
||||
if (lyrics == null) {
|
||||
content = "";
|
||||
} else {
|
||||
content = lyrics.data;
|
||||
final Song song = MusicPlayerRemote.getCurrentSong();
|
||||
updateLyricsAsyncTask = new AsyncTask<Void, Void, Lyrics>() {
|
||||
@Override
|
||||
protected Lyrics doInBackground(Void... params) {
|
||||
String data = MusicUtil.getLyrics(song);
|
||||
if (TextUtils.isEmpty(data)) {
|
||||
return null;
|
||||
}
|
||||
new MaterialDialog.Builder(this)
|
||||
.title("Add lyrics")
|
||||
.neutralText("Search")
|
||||
.onNeutral(new MaterialDialog.SingleButtonCallback() {
|
||||
@Override
|
||||
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
|
||||
RetroUtil.openUrl(LyricsActivity.this, getGoogleSearchUrl(song.title, song.artistName));
|
||||
}
|
||||
})
|
||||
.inputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE)
|
||||
.input("Paste lyrics here", content, (dialog, input) -> {
|
||||
Map<FieldKey, String> fieldKeyValueMap = new EnumMap<>(FieldKey.class);
|
||||
fieldKeyValueMap.put(FieldKey.LYRICS, input.toString());
|
||||
return Lyrics.parse(song, data);
|
||||
}
|
||||
|
||||
new WriteTagsAsyncTask(LyricsActivity.this)
|
||||
.execute(new WriteTagsAsyncTask.LoadingInfo(getSongPaths(song), fieldKeyValueMap, null));
|
||||
loadLrcFile();
|
||||
})
|
||||
.show();
|
||||
}
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
super.onPreExecute();
|
||||
lyrics = null;
|
||||
}
|
||||
|
||||
private ArrayList<String> getSongPaths(Song song) {
|
||||
ArrayList<String> paths = new ArrayList<>(1);
|
||||
paths.add(song.data);
|
||||
return paths;
|
||||
}
|
||||
|
||||
private String getGoogleSearchUrl(String title, String text) {
|
||||
String baseUrl = "http://www.google.com/search?";
|
||||
String query = title + "+" + text;
|
||||
query = "q=" + query.replace(" ", "+") + " lyrics";
|
||||
baseUrl += query;
|
||||
return baseUrl;
|
||||
}
|
||||
|
||||
/*
|
||||
private void loadLyricsWIki(String title, String artist) {
|
||||
offlineLyrics.setVisibility(View.GONE);
|
||||
if (lyricsWikiTask != null) {
|
||||
lyricsWikiTask.cancel(false);
|
||||
@Override
|
||||
protected void onPostExecute(Lyrics l) {
|
||||
lyrics = l;
|
||||
offlineLyrics.setVisibility(View.VISIBLE);
|
||||
if (l == null) {
|
||||
offlineLyrics.setText(R.string.no_lyrics_found);
|
||||
return;
|
||||
}
|
||||
lyricsWikiTask = new ParseLyrics(new ParseLyrics.LyricsCallback() {
|
||||
@Override
|
||||
public void onShowLyrics(String lyrics) {
|
||||
offlineLyrics.setVisibility(View.VISIBLE);
|
||||
offlineLyrics.setText(lyrics);
|
||||
}
|
||||
offlineLyrics.setText(l.data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
loadSongLyrics();
|
||||
}
|
||||
}).execute(title, artist);
|
||||
}
|
||||
@Override
|
||||
protected void onCancelled(Lyrics s) {
|
||||
onPostExecute(null);
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
|
||||
private void callAgain(final String title, final String artist) {
|
||||
disposable.clear();
|
||||
disposable.add(loadLyrics.downloadLrcFile(title, artist, MusicPlayerRemote.getSongDurationMillis())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.doOnSubscribe(disposable -> {
|
||||
refresh.startAnimation(rotateAnimation);
|
||||
})
|
||||
.subscribe(this::showLyricsLocal, throwable -> {
|
||||
refresh.clearAnimation();
|
||||
showLyricsLocal(null);
|
||||
//loadLyricsWIki(songTitle, artist);
|
||||
toggleSyncLyrics(View.GONE);
|
||||
}, () -> {
|
||||
refresh.clearAnimation();
|
||||
Toast.makeText(this, "Lyrics downloaded", Toast.LENGTH_SHORT).show();
|
||||
}));
|
||||
private void showSyncedLyrics() {
|
||||
String content = "";
|
||||
try {
|
||||
content = LyricUtil.getStringFromFile(song.title, song.artistName);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
*/
|
||||
new MaterialDialog.Builder(this)
|
||||
.title("Add lyrics")
|
||||
.neutralText("Search")
|
||||
.content("Add time frame lyrics")
|
||||
.negativeText("Delete")
|
||||
.onNegative((dialog, which) -> {
|
||||
LyricUtil.deleteLrcFile(song.title, song.artistName);
|
||||
loadLrcFile();
|
||||
})
|
||||
.onNeutral(
|
||||
(dialog, which) -> RetroUtil.openUrl(LyricsActivity.this, getGoogleSearchLrcUrl()))
|
||||
.inputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE)
|
||||
.input("Paste lyrics here", content, (dialog, input) -> {
|
||||
LyricUtil.writeLrcToLoc(song.title, song.artistName, input.toString());
|
||||
loadLrcFile();
|
||||
}).show();
|
||||
}
|
||||
|
||||
private String getGoogleSearchLrcUrl() {
|
||||
String baseUrl = "http://www.google.com/search?";
|
||||
String query = song.title + "+" + song.artistName;
|
||||
query = "q=" + query.replace(" ", "+") + " .lrc";
|
||||
baseUrl += query;
|
||||
return baseUrl;
|
||||
}
|
||||
|
||||
private void showLyricsSaveDialog() {
|
||||
String content = "";
|
||||
if (lyrics == null) {
|
||||
content = "";
|
||||
} else {
|
||||
content = lyrics.data;
|
||||
}
|
||||
new MaterialDialog.Builder(this)
|
||||
.title("Add lyrics")
|
||||
.neutralText("Search")
|
||||
.onNeutral(new MaterialDialog.SingleButtonCallback() {
|
||||
@Override
|
||||
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
|
||||
RetroUtil.openUrl(LyricsActivity.this, getGoogleSearchUrl(song.title, song.artistName));
|
||||
}
|
||||
})
|
||||
.inputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE)
|
||||
.input("Paste lyrics here", content, (dialog, input) -> {
|
||||
Map<FieldKey, String> fieldKeyValueMap = new EnumMap<>(FieldKey.class);
|
||||
fieldKeyValueMap.put(FieldKey.LYRICS, input.toString());
|
||||
|
||||
new WriteTagsAsyncTask(LyricsActivity.this)
|
||||
.execute(
|
||||
new WriteTagsAsyncTask.LoadingInfo(getSongPaths(song), fieldKeyValueMap, null));
|
||||
loadLrcFile();
|
||||
})
|
||||
.show();
|
||||
}
|
||||
|
||||
private ArrayList<String> getSongPaths(Song song) {
|
||||
ArrayList<String> paths = new ArrayList<>(1);
|
||||
paths.add(song.data);
|
||||
return paths;
|
||||
}
|
||||
|
||||
private String getGoogleSearchUrl(String title, String text) {
|
||||
String baseUrl = "http://www.google.com/search?";
|
||||
String query = title + "+" + text;
|
||||
query = "q=" + query.replace(" ", "+") + " lyrics";
|
||||
baseUrl += query;
|
||||
return baseUrl;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue