Fix error background

This commit is contained in:
h4h13 2019-11-16 19:07:37 +05:30
parent 19d30f247e
commit 58bd6ad447
3 changed files with 348 additions and 334 deletions

View file

@ -2,40 +2,28 @@ package code.name.monkey.retromusic.activities
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.content.res.ColorStateList import android.content.res.ColorStateList
import android.os.AsyncTask import android.os.*
import android.os.Build import android.text.*
import android.os.Bundle
import android.text.InputType
import android.text.TextUtils
import android.view.* import android.view.*
import androidx.annotation.StringRes import androidx.annotation.StringRes
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment import androidx.fragment.app.*
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentStatePagerAdapter
import androidx.viewpager.widget.ViewPager import androidx.viewpager.widget.ViewPager
import code.name.monkey.appthemehelper.ThemeStore import code.name.monkey.appthemehelper.ThemeStore
import code.name.monkey.appthemehelper.util.* import code.name.monkey.appthemehelper.util.*
import code.name.monkey.retromusic.App import code.name.monkey.retromusic.*
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.activities.base.AbsMusicServiceActivity import code.name.monkey.retromusic.activities.base.AbsMusicServiceActivity
import code.name.monkey.retromusic.activities.tageditor.WriteTagsAsyncTask import code.name.monkey.retromusic.activities.tageditor.WriteTagsAsyncTask
import code.name.monkey.retromusic.fragments.base.AbsMusicServiceFragment import code.name.monkey.retromusic.fragments.base.AbsMusicServiceFragment
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.*
import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper import code.name.monkey.retromusic.lyrics.*
import code.name.monkey.retromusic.lyrics.LrcHelper
import code.name.monkey.retromusic.lyrics.LrcView
import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.model.lyrics.Lyrics import code.name.monkey.retromusic.model.lyrics.Lyrics
import code.name.monkey.retromusic.util.LyricUtil import code.name.monkey.retromusic.util.*
import code.name.monkey.retromusic.util.MusicUtil import com.afollestad.materialdialogs.*
import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.RetroUtil
import com.afollestad.materialdialogs.LayoutMode
import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.bottomsheets.BottomSheet import com.afollestad.materialdialogs.bottomsheets.BottomSheet
import com.afollestad.materialdialogs.input.getInputLayout import com.afollestad.materialdialogs.input.*
import com.afollestad.materialdialogs.input.input
import kotlinx.android.synthetic.main.activity_lyrics.* import kotlinx.android.synthetic.main.activity_lyrics.*
import kotlinx.android.synthetic.main.fragment_lyrics.* import kotlinx.android.synthetic.main.fragment_lyrics.*
import kotlinx.android.synthetic.main.fragment_synced.* import kotlinx.android.synthetic.main.fragment_synced.*
@ -47,11 +35,8 @@ import kotlin.collections.ArrayList
class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener, ViewPager.OnPageChangeListener { class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener, ViewPager.OnPageChangeListener {
override fun onPageScrollStateChanged(state: Int) { override fun onPageScrollStateChanged(state: Int) {
when (state) { when (state) {
ViewPager.SCROLL_STATE_IDLE -> ViewPager.SCROLL_STATE_IDLE -> fab.show()
fab.show() ViewPager.SCROLL_STATE_DRAGGING, ViewPager.SCROLL_STATE_SETTLING -> fab.hide()
ViewPager.SCROLL_STATE_DRAGGING,
ViewPager.SCROLL_STATE_SETTLING ->
fab.hide()
} }
} }
@ -97,17 +82,23 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener, ViewPage
setBackgroundColor(primaryColor) setBackgroundColor(primaryColor)
navigationIcon = TintHelper.createTintedDrawable( navigationIcon = TintHelper.createTintedDrawable(
ContextCompat.getDrawable( ContextCompat.getDrawable(
this@LyricsActivity, this@LyricsActivity, R.drawable.ic_keyboard_backspace_black_24dp
R.drawable.ic_keyboard_backspace_black_24dp ), ThemeStore.textColorSecondary(this@LyricsActivity)
),
ThemeStore.textColorSecondary(this@LyricsActivity)
) )
setSupportActionBar(toolbar) setSupportActionBar(toolbar)
} }
fab.backgroundTintList = ColorStateList.valueOf(ThemeStore.accentColor(this)) fab.backgroundTintList = ColorStateList.valueOf(ThemeStore.accentColor(this))
ColorStateList.valueOf(MaterialValueHelper.getPrimaryTextColor(this, ColorUtil.isColorLight(ThemeStore.accentColor(this)))).apply { ColorStateList.valueOf(
MaterialValueHelper.getPrimaryTextColor(
this, ColorUtil.isColorLight(
ThemeStore.accentColor(
this
)
)
)
).apply {
fab.setTextColor(this) fab.setTextColor(this)
fab.iconTint = this fab.iconTint = this
} }
@ -121,8 +112,17 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener, ViewPage
tabs.apply { tabs.apply {
setupWithViewPager(viewPager) setupWithViewPager(viewPager)
setSelectedTabIndicator(TintHelper.createTintedDrawable(ContextCompat.getDrawable(this@LyricsActivity, R.drawable.tab_indicator), ThemeStore.accentColor(this@LyricsActivity))) setSelectedTabIndicator(
setTabTextColors(ThemeStore.textColorSecondary(this@LyricsActivity), ThemeStore.accentColor(this@LyricsActivity)) TintHelper.createTintedDrawable(
ContextCompat.getDrawable(
this@LyricsActivity, R.drawable.tab_indicator
), ThemeStore.accentColor(this@LyricsActivity)
)
)
setTabTextColors(
ThemeStore.textColorSecondary(this@LyricsActivity),
ThemeStore.accentColor(this@LyricsActivity)
)
setSelectedTabIndicatorColor(ThemeStore.accentColor(context)) setSelectedTabIndicatorColor(ThemeStore.accentColor(context))
} }
fab.setOnClickListener(this) fab.setOnClickListener(this)
@ -167,11 +167,14 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener, ViewPage
} }
val materialDialog = MaterialDialog( val materialDialog = MaterialDialog(
this, this, BottomSheet(LayoutMode.WRAP_CONTENT)
BottomSheet(LayoutMode.WRAP_CONTENT)
).show { ).show {
title(R.string.add_time_framed_lryics) title(R.string.add_time_framed_lryics)
negativeButton(R.string.action_search) { RetroUtil.openUrl(this@LyricsActivity, googleSearchLrcUrl) } negativeButton(R.string.action_search) {
RetroUtil.openUrl(
this@LyricsActivity, googleSearchLrcUrl
)
}
input( input(
hint = getString(R.string.paste_lyrics_here), hint = getString(R.string.paste_lyrics_here),
prefill = content, prefill = content,
@ -204,7 +207,11 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener, ViewPage
this, BottomSheet(LayoutMode.WRAP_CONTENT) this, BottomSheet(LayoutMode.WRAP_CONTENT)
).show { ).show {
title(R.string.add_lyrics) title(R.string.add_lyrics)
negativeButton(R.string.action_search) { RetroUtil.openUrl(this@LyricsActivity, getGoogleSearchUrl()) } negativeButton(R.string.action_search) {
RetroUtil.openUrl(
this@LyricsActivity, getGoogleSearchUrl()
)
}
input( input(
hint = getString(R.string.paste_lyrics_here), hint = getString(R.string.paste_lyrics_here),
prefill = content, prefill = content,
@ -212,7 +219,11 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener, ViewPage
) { _, input -> ) { _, input ->
val fieldKeyValueMap = EnumMap<FieldKey, String>(FieldKey::class.java) val fieldKeyValueMap = EnumMap<FieldKey, String>(FieldKey::class.java)
fieldKeyValueMap[FieldKey.LYRICS] = input.toString() fieldKeyValueMap[FieldKey.LYRICS] = input.toString()
WriteTagsAsyncTask(this@LyricsActivity).execute(WriteTagsAsyncTask.LoadingInfo(getSongPaths(song), fieldKeyValueMap, null)) WriteTagsAsyncTask(this@LyricsActivity).execute(
WriteTagsAsyncTask.LoadingInfo(
getSongPaths(song), fieldKeyValueMap, null
)
)
} }
positiveButton(android.R.string.ok) { positiveButton(android.R.string.ok) {
updateSong() updateSong()
@ -235,10 +246,11 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener, ViewPage
return baseUrl return baseUrl
} }
class PagerAdapter(fm: FragmentManager) : FragmentStatePagerAdapter(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) { class PagerAdapter(fm: FragmentManager) : FragmentStatePagerAdapter(
fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT
) {
class Tabs( class Tabs(
@StringRes val title: Int, @StringRes val title: Int, val fragment: Fragment
val fragment: Fragment
) )
private var tabs = ArrayList<Tabs>() private var tabs = ArrayList<Tabs>()
@ -331,11 +343,13 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener, ViewPage
override fun onDestroyView() { override fun onDestroyView() {
super.onDestroyView() super.onDestroyView()
if (updateLyricsAsyncTask != null && !updateLyricsAsyncTask!!.isCancelled) { if (updateLyricsAsyncTask != null && !updateLyricsAsyncTask!!.isCancelled) {
updateLyricsAsyncTask!!.cancel(true) updateLyricsAsyncTask?.cancel(true)
} }
} }
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_lyrics, container, false) return inflater.inflate(R.layout.fragment_lyrics, container, false)
} }
} }
@ -346,7 +360,9 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener, ViewPage
} }
private lateinit var updateHelper: MusicProgressViewUpdateHelper private lateinit var updateHelper: MusicProgressViewUpdateHelper
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_synced, container, false) return inflater.inflate(R.layout.fragment_synced, container, false)
} }

View file

@ -16,7 +16,6 @@ package code.name.monkey.retromusic.util;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Base64; import android.util.Base64;
import android.util.Log;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
@ -101,7 +100,6 @@ public class LyricUtil {
} }
public static String getLrcPath2(String title, String artist) { public static String getLrcPath2(String title, String artist) {
Log.i("HEM", "getLrcPath2: " + title);
if (!TextUtils.isEmpty(title)) { if (!TextUtils.isEmpty(title)) {
String x2; String x2;
if (title.endsWith(".flac") || title.endsWith(".mogg") || title.endsWith(".alac") || title.endsWith(".aiff") || title.endsWith(".webv")) { if (title.endsWith(".flac") || title.endsWith(".mogg") || title.endsWith(".alac") || title.endsWith(".aiff") || title.endsWith(".webv")) {

View file

@ -26,8 +26,7 @@
<item name="toolbarPopupTheme">@style/ThemeOverlay.AppCompat</item> <item name="toolbarPopupTheme">@style/ThemeOverlay.AppCompat</item>
<!-- just in case-->
<item name="android:windowBackground">@color/md_red_500</item>
<!-- necessary to find the overflow button later in the layout--> <!-- necessary to find the overflow button later in the layout-->
<item name="android:actionOverflowButtonStyle">@style/Widget.ActionButton.Overflow</item> <item name="android:actionOverflowButtonStyle">@style/Widget.ActionButton.Overflow</item>
@ -49,8 +48,9 @@
<item name="colorOnSecondary">@color/mi_text_color_secondary_dark</item> <item name="colorOnSecondary">@color/mi_text_color_secondary_dark</item>
<item name="colorAccent">@color/md_deep_purple_A200</item> <item name="colorAccent">@color/md_deep_purple_A200</item>
<!-- just in case-->
<item name="android:colorBackground">@color/md_red_500</item> <item name="android:windowBackground">@color/darkColorBackground</item>
<item name="android:colorBackground">@color/darkColorBackground</item>
<item name="colorSurface">@color/darkColorSurface</item> <item name="colorSurface">@color/darkColorSurface</item>
<item name="colorOnSurface">@color/mi_text_color_primary_dark</item> <item name="colorOnSurface">@color/mi_text_color_primary_dark</item>
<item name="colorOnBackground">@color/mi_text_color_secondary_dark</item> <item name="colorOnBackground">@color/mi_text_color_secondary_dark</item>