Fix circlar UI and lyrics
This commit is contained in:
commit
c5aa167c1c
10 changed files with 148 additions and 98 deletions
|
@ -150,8 +150,13 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener, ViewPage
|
|||
private fun showSyncedLyrics() {
|
||||
var content = ""
|
||||
try {
|
||||
content = LyricUtil.getStringFromFile(song.title, song.artistName)
|
||||
content = LyricUtil.getStringFromFile(song.data, song.artistName)
|
||||
} catch (e: Exception) {
|
||||
try {
|
||||
content = LyricUtil.getStringFromFile(song.title, song.artistName)
|
||||
} catch (e2: Exception) {
|
||||
|
||||
}
|
||||
e.printStackTrace()
|
||||
}
|
||||
|
||||
|
@ -161,7 +166,7 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener, ViewPage
|
|||
input(hint = getString(R.string.paste_lyrics_here),
|
||||
prefill = content,
|
||||
inputType = InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_MULTI_LINE) { _, input ->
|
||||
LyricUtil.writeLrcToLoc(song.title, song.artistName, input.toString())
|
||||
LyricUtil.writeLrcToLoc(song.data, song.artistName, input.toString())
|
||||
}
|
||||
positiveButton(android.R.string.ok) {
|
||||
updateSong()
|
||||
|
@ -215,7 +220,7 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener, ViewPage
|
|||
return baseUrl
|
||||
}
|
||||
|
||||
class PagerAdapter(fm: FragmentManager) : FragmentStatePagerAdapter(fm) {
|
||||
class PagerAdapter(fm: FragmentManager) : FragmentStatePagerAdapter(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) {
|
||||
class Tabs(@StringRes val title: Int,
|
||||
val fragment: Fragment)
|
||||
|
||||
|
@ -364,8 +369,12 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener, ViewPage
|
|||
|
||||
private fun loadLRCLyrics() {
|
||||
val song = MusicPlayerRemote.currentSong
|
||||
if (LyricUtil.isLrcFileExist(song.title, song.artistName)) {
|
||||
showLyricsLocal(LyricUtil.getLocalLyricFile(song.title, song.artistName))
|
||||
if (LyricUtil.isLrcFile2Exist(song.data, song.artistName)) {
|
||||
showLyricsLocal(LyricUtil.getLocalLyricFile(song.data, song.artistName))
|
||||
} else {
|
||||
if (LyricUtil.isLrcFileExist(song.title, song.artistName)) {
|
||||
showLyricsLocal(LyricUtil.getLocalLyricFile(song.title, song.artistName))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -375,4 +384,4 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener, ViewPage
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,10 +11,6 @@ import android.view.*
|
|||
import android.view.animation.DecelerateInterpolator
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.extensions.fistElement
|
||||
import code.name.monkey.retromusic.extensions.hide
|
||||
import code.name.monkey.retromusic.extensions.lastElement
|
||||
import code.name.monkey.retromusic.extensions.show
|
||||
import code.name.monkey.retromusic.fragments.base.AbsMusicServiceFragment
|
||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||
import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper
|
||||
|
@ -96,7 +92,6 @@ open class MiniPlayerFragment : AbsMusicServiceFragment(), MusicProgressViewUpda
|
|||
override fun onServiceConnected() {
|
||||
updateSongTitle()
|
||||
updatePlayPauseDrawableState()
|
||||
updateButtons()
|
||||
}
|
||||
|
||||
override fun onPlayingMetaChanged() {
|
||||
|
@ -105,24 +100,8 @@ open class MiniPlayerFragment : AbsMusicServiceFragment(), MusicProgressViewUpda
|
|||
|
||||
override fun onPlayStateChanged() {
|
||||
updatePlayPauseDrawableState()
|
||||
updateButtons()
|
||||
}
|
||||
|
||||
private fun updateButtons() {
|
||||
if (PreferenceUtil.getInstance(requireContext()).isExtraControls) {
|
||||
if (MusicPlayerRemote.playingQueue.fistElement()) {
|
||||
actionPrevious.hide()
|
||||
} else {
|
||||
actionPrevious.show()
|
||||
}
|
||||
|
||||
if (MusicPlayerRemote.playingQueue.lastElement()) {
|
||||
actionNext.hide()
|
||||
} else {
|
||||
actionNext.show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onUpdateProgressViews(progress: Int, total: Int) {
|
||||
progressBar.max = total
|
||||
|
@ -146,7 +125,7 @@ open class MiniPlayerFragment : AbsMusicServiceFragment(), MusicProgressViewUpda
|
|||
if (MusicPlayerRemote.isPlaying) {
|
||||
miniPlayerPlayPauseButton!!.setImageResource(R.drawable.ic_pause_white_24dp)
|
||||
} else {
|
||||
miniPlayerPlayPauseButton!!.setImageResource(R.drawable.ic_play_arrow_white_32dp)
|
||||
miniPlayerPlayPauseButton!!.setImageResource(R.drawable.ic_play_arrow_white_24dp)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,15 +5,9 @@ import android.view.View
|
|||
import android.view.animation.AccelerateInterpolator
|
||||
import android.view.animation.DecelerateInterpolator
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.extensions.fistElement
|
||||
import code.name.monkey.retromusic.extensions.hidden
|
||||
import code.name.monkey.retromusic.extensions.lastElement
|
||||
import code.name.monkey.retromusic.extensions.show
|
||||
import code.name.monkey.retromusic.fragments.VolumeFragment
|
||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||
import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import kotlinx.android.synthetic.main.fragment_adaptive_player_playback_controls.*
|
||||
|
||||
|
||||
/**
|
||||
|
@ -78,27 +72,5 @@ abstract class AbsPlayerControlsFragment : AbsMusicServiceFragment(), MusicProgr
|
|||
const val SLIDER_ANIMATION_TIME: Long = 400
|
||||
}
|
||||
|
||||
override fun onServiceConnected() {
|
||||
super.onServiceConnected()
|
||||
updateButtons()
|
||||
}
|
||||
|
||||
override fun onPlayingMetaChanged() {
|
||||
super.onPlayingMetaChanged()
|
||||
updateButtons()
|
||||
}
|
||||
|
||||
private fun updateButtons() {
|
||||
if (MusicPlayerRemote.playingQueue.fistElement()) {
|
||||
previousButton?.hidden()
|
||||
} else {
|
||||
previousButton?.show()
|
||||
}
|
||||
|
||||
if (MusicPlayerRemote.playingQueue.lastElement()) {
|
||||
nextButton?.hidden()
|
||||
} else {
|
||||
nextButton?.show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -213,7 +213,7 @@ abstract class AbsPlayerFragment : AbsMusicServiceFragment(),
|
|||
|
||||
override fun doInBackground(vararg params: Song): Lyrics? {
|
||||
try {
|
||||
var data: String? = LyricUtil.getStringFromFile(params[0].title, params[0].artistName)
|
||||
var data: String? = LyricUtil.getStringFromFile(params[0].data, params[0].artistName)
|
||||
return if (TextUtils.isEmpty(data)) {
|
||||
data = MusicUtil.getLyrics(params[0])
|
||||
return if (TextUtils.isEmpty(data)) {
|
||||
|
|
|
@ -42,8 +42,8 @@ public class LrcHelper {
|
|||
|
||||
private static final String CHARSET = "utf-8";
|
||||
//[03:56.00][03:18.00][02:06.00][01:07.00]原谅我这一生不羁放纵爱自由
|
||||
private static final String LINE_REGEX = "((\\[\\d{2}:\\d{2}\\.\\d{2}])+)(.*)";
|
||||
private static final String TIME_REGEX = "\\[(\\d{2}):(\\d{2})\\.(\\d{2})]";
|
||||
private static final String LINE_REGEX = "((\\[\\d{2}:\\d{2}\\.\\d{2,3}])+)(.*)";
|
||||
private static final String TIME_REGEX = "\\[(\\d{2}):(\\d{2})\\.(\\d{2,3})]";
|
||||
|
||||
public static List<Lrc> parseLrcFromAssets(Context context, String fileName) {
|
||||
try {
|
||||
|
@ -127,8 +127,14 @@ public class LrcHelper {
|
|||
String mil = timeMatcher.group(3);
|
||||
Lrc lrc = new Lrc();
|
||||
if (content != null && content.length() != 0) {
|
||||
lrc.setTime(Long.parseLong(min) * 60 * 1000 + Long.parseLong(sec) * 1000
|
||||
+ Long.parseLong(mil) * 10);
|
||||
if(Integer.parseInt(mil)< 100){
|
||||
lrc.setTime(Long.parseLong(min) * 60 * 1000 + Long.parseLong(sec) * 1000
|
||||
+ Long.parseLong(mil) * 10);}
|
||||
else{
|
||||
lrc.setTime(Long.parseLong(min) * 60 * 1000 + Long.parseLong(sec) * 1000
|
||||
+ Long.parseLong(mil)
|
||||
);
|
||||
}
|
||||
lrc.setText(content);
|
||||
lrcs.add(lrc);
|
||||
}
|
||||
|
@ -148,4 +154,4 @@ public class LrcHelper {
|
|||
}
|
||||
return time + "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@ package code.name.monkey.retromusic.util;
|
|||
|
||||
import android.util.Base64;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
|
@ -25,8 +27,6 @@ import java.io.InputStream;
|
|||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
/**
|
||||
* Created by hefuyi on 2016/11/8.
|
||||
*/
|
||||
|
@ -40,11 +40,11 @@ public class LyricUtil {
|
|||
public static File writeLrcToLoc(@NonNull String title, @NonNull String artist, @NonNull String lrcContext) {
|
||||
FileWriter writer = null;
|
||||
try {
|
||||
File file = new File(getLrcPath(title, artist));
|
||||
if (!file.getParentFile().exists()) {
|
||||
file.getParentFile().mkdirs();
|
||||
File file = new File(getLrcPath2(title, artist));
|
||||
if (!file.exists()) {
|
||||
file.mkdirs();
|
||||
}
|
||||
writer = new FileWriter(getLrcPath(title, artist));
|
||||
writer = new FileWriter(getLrcPath2(title, artist));
|
||||
writer.write(lrcContext);
|
||||
return file;
|
||||
} catch (IOException e) {
|
||||
|
@ -70,17 +70,46 @@ public class LyricUtil {
|
|||
return file.exists();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static File getLocalLyricFile(@NonNull String title, @NonNull String artist) {
|
||||
File file = new File(getLrcPath(title, artist));
|
||||
if (file.exists()) {
|
||||
return file;
|
||||
} else {
|
||||
return new File("lyric file not exist");
|
||||
}
|
||||
public static boolean isLrcFile2Exist(@NonNull String title, @NonNull String artist) {
|
||||
File file = new File(getLrcPath2(title, artist));
|
||||
|
||||
return file.exists();
|
||||
}
|
||||
|
||||
private static String getLrcPath(String title, String artist) {
|
||||
@NonNull
|
||||
public static File getLocalLyricFile(@NonNull String title, @NonNull String artist) {
|
||||
try{
|
||||
File file = new File(getLrcPath(title, artist));
|
||||
File file2 = new File(getLrcPath2(title, artist));
|
||||
if (file.exists()) {
|
||||
|
||||
return file;
|
||||
} else if (file2.exists()) {
|
||||
|
||||
return file2;
|
||||
}
|
||||
else {
|
||||
|
||||
return new File("lyric file not exist");
|
||||
}} catch (Exception dfs){
|
||||
dfs.printStackTrace();
|
||||
return new File("lyric file not exist");
|
||||
|
||||
}
|
||||
}
|
||||
public static String getLrcPath2(String title, String artist) {
|
||||
String x2;
|
||||
if(title.endsWith(".flac")||title.endsWith(".mogg")||title.endsWith(".alac")||title.endsWith(".aiff")||title.endsWith(".webv")){
|
||||
x2= title.substring(0, title.length() -5 ) + ".lrc";
|
||||
}
|
||||
else{
|
||||
x2= title.substring(0, title.length() -4 ) + ".lrc";}
|
||||
|
||||
|
||||
return x2;
|
||||
}
|
||||
|
||||
public static String getLrcPath(String title, String artist) {
|
||||
return lrcRootPath + title + " - " + artist + ".lrc";
|
||||
}
|
||||
|
||||
|
@ -103,10 +132,18 @@ public class LyricUtil {
|
|||
|
||||
@NonNull
|
||||
public static String getStringFromFile(@NonNull String title, @NonNull String artist) throws Exception {
|
||||
File file = new File(getLrcPath(title, artist));
|
||||
File file;
|
||||
File file2 = new File(getLrcPath(title, artist));
|
||||
File file3 = new File(getLrcPath2(title, artist));
|
||||
if(file2.exists()){
|
||||
file = file2;
|
||||
} else {
|
||||
file = file3;
|
||||
}
|
||||
FileInputStream fin = new FileInputStream(file);
|
||||
String ret = convertStreamToString(fin);
|
||||
fin.close();
|
||||
// Log.d("damn2",ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ object ViewUtil {
|
|||
background.setColorFilter(MaterialValueHelper.getPrimaryDisabledTextColor(progressSlider.context, ColorUtil.isColorLight(primaryColor)), PorterDuff.Mode.SRC_IN)
|
||||
|
||||
val secondaryProgress = ld.findDrawableByLayerId(android.R.id.secondaryProgress)
|
||||
secondaryProgress.setColorFilter(ColorUtil.withAlpha(newColor, 0.65f), PorterDuff.Mode.SRC_IN)
|
||||
secondaryProgress?.setColorFilter(ColorUtil.withAlpha(newColor, 0.65f), PorterDuff.Mode.SRC_IN)
|
||||
}
|
||||
|
||||
private fun createColorAnimator(target: Any, propertyName: String, @ColorInt startColor: Int, @ColorInt endColor: Int): Animator {
|
||||
|
|
35
app/src/main/res/drawable/circle_progress.xml
Normal file
35
app/src/main/res/drawable/circle_progress.xml
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Copyright (c) 2019 Hemanth Savarala.
|
||||
~
|
||||
~ Licensed under the GNU General Public License v3
|
||||
~
|
||||
~ This is free software: you can redistribute it and/or modify it under
|
||||
~ the terms of the GNU General Public License as published by
|
||||
~ the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
||||
~
|
||||
~ This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
~ without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
~ See the GNU General Public License for more details.
|
||||
-->
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:id="@android:id/background">
|
||||
<shape
|
||||
android:dither="true"
|
||||
android:shape="ring"
|
||||
android:thickness="4dp"
|
||||
android:type="sweep"
|
||||
android:useLevel="false">
|
||||
<solid android:color="?colorOnSecondary" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:id="@android:id/progress">
|
||||
<shape
|
||||
android:shape="ring"
|
||||
android:thickness="4dp"
|
||||
android:type="sweep"
|
||||
android:useLevel="true">
|
||||
<solid android:color="?colorAccent" />
|
||||
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
|
@ -58,17 +58,34 @@
|
|||
app:srcCompat="@drawable/ic_skip_previous_white_24dp"
|
||||
app:tint="?colorOnSecondary" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/miniPlayerPlayPauseButton"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
<FrameLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:background="?roundSelector"
|
||||
android:padding="6dp"
|
||||
android:scaleType="center"
|
||||
app:srcCompat="@drawable/ic_pause_white_24dp"
|
||||
app:tint="?colorOnSecondary"
|
||||
tools:ignore="ContentDescription" />
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/miniPlayerPlayPauseButton"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_gravity="center"
|
||||
android:background="?roundSelector"
|
||||
android:scaleType="center"
|
||||
app:srcCompat="@drawable/ic_pause_white_24dp"
|
||||
app:tint="?colorOnSecondary"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progressBar"
|
||||
style="?android:attr/progressBarStyleHorizontal"
|
||||
android:layout_width="44dp"
|
||||
android:layout_height="44dp"
|
||||
android:rotation="270"
|
||||
android:layout_gravity="center"
|
||||
android:progressTint="?colorAccent"
|
||||
android:indeterminate="false"
|
||||
android:progressDrawable="@drawable/circle_progress"
|
||||
tools:progress="80" />
|
||||
</FrameLayout>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/actionNext"
|
||||
|
@ -95,10 +112,5 @@
|
|||
|
||||
</LinearLayout>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progressBar"
|
||||
style="@style/Widget.MaterialProgressBar.ProgressBar.Horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="3dp"
|
||||
tools:progress="20" />
|
||||
|
||||
</FrameLayout>
|
|
@ -25,10 +25,10 @@
|
|||
android:layout_height="wrap_content"
|
||||
app:behavior_hideable="false"
|
||||
app:behavior_peekHeight="0dp"
|
||||
app:cardCornerRadius="0dp"
|
||||
app:cardElevation="0dp"
|
||||
app:cardUseCompatPadding="false"
|
||||
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
|
||||
app:cardBackgroundColor="?colorSecondary"
|
||||
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior"
|
||||
app:shapeAppearanceOverlay="@style/TopCornerCardView">
|
||||
|
||||
|
||||
<FrameLayout
|
||||
|
|
Loading…
Reference in a new issue