Fix lyrics dialog

This commit is contained in:
h4h13 2019-05-17 00:22:48 +05:30
parent 97d08eaaff
commit 83a3b5a02c
6 changed files with 23 additions and 73 deletions

View file

@ -16,24 +16,27 @@ 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.ColorUtil import code.name.monkey.appthemehelper.util.ColorUtil
import code.name.monkey.appthemehelper.util.MaterialUtil
import code.name.monkey.appthemehelper.util.MaterialValueHelper import code.name.monkey.appthemehelper.util.MaterialValueHelper
import code.name.monkey.appthemehelper.util.TintHelper import code.name.monkey.appthemehelper.util.TintHelper
import code.name.monkey.retromusic.App import code.name.monkey.retromusic.App
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.tageditor.WriteTagsAsyncTask
import code.name.monkey.retromusic.fragments.base.AbsMusicServiceFragment
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper
import code.name.monkey.retromusic.lyrics.LrcHelper import code.name.monkey.retromusic.lyrics.LrcHelper
import code.name.monkey.retromusic.lyrics.LrcView 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.activities.base.AbsMusicServiceActivity
import code.name.monkey.retromusic.activities.tageditor.WriteTagsAsyncTask
import code.name.monkey.retromusic.fragments.base.AbsMusicServiceFragment
import code.name.monkey.retromusic.util.LyricUtil import code.name.monkey.retromusic.util.LyricUtil
import code.name.monkey.retromusic.util.MusicUtil import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.RetroUtil import code.name.monkey.retromusic.util.RetroUtil
import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
import com.afollestad.materialdialogs.input.getInputLayout
import com.afollestad.materialdialogs.input.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.*
@ -153,7 +156,7 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener, ViewPage
e.printStackTrace() e.printStackTrace()
} }
MaterialDialog(this).show { val materialDialog = MaterialDialog(this, BottomSheet()).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(hint = getString(R.string.paste_lyrics_here), input(hint = getString(R.string.paste_lyrics_here),
@ -165,6 +168,7 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener, ViewPage
updateSong() updateSong()
} }
} }
MaterialUtil.setTint(materialDialog.getInputLayout(), false)
} }
private fun updateSong() { private fun updateSong() {
@ -181,7 +185,7 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener, ViewPage
lyricsString!! lyricsString!!
} }
MaterialDialog(this).show { val materialDialog = MaterialDialog(this, BottomSheet()).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(hint = getString(R.string.paste_lyrics_here), input(hint = getString(R.string.paste_lyrics_here),
@ -195,6 +199,7 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener, ViewPage
updateSong() updateSong()
} }
} }
MaterialUtil.setTint(materialDialog.getInputLayout(), false)
} }
private fun getSongPaths(song: Song): ArrayList<String> { private fun getSongPaths(song: Song): ArrayList<String> {

View file

@ -18,7 +18,6 @@ import code.name.monkey.retromusic.loaders.PlaylistSongsLoader
import code.name.monkey.retromusic.model.* import code.name.monkey.retromusic.model.*
import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.views.IconImageView import code.name.monkey.retromusic.views.IconImageView
import code.name.monkey.retromusic.views.MetalRecyclerViewPager
class HomeAdapter(private val activity: AppCompatActivity, private var homes: List<Home>, private val displayMetrics: DisplayMetrics) : RecyclerView.Adapter<RecyclerView.ViewHolder>() { class HomeAdapter(private val activity: AppCompatActivity, private var homes: List<Home>, private val displayMetrics: DisplayMetrics) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
@ -87,7 +86,7 @@ class HomeAdapter(private val activity: AppCompatActivity, private var homes: Li
} }
private inner class AlbumViewHolder(view: View) : RecyclerView.ViewHolder(view) { private inner class AlbumViewHolder(view: View) : AbsHomeViewItem(view) {
fun bindView(home: Home) { fun bindView(home: Home) {
recyclerView.apply { recyclerView.apply {
adapter = AlbumFullWidthAdapter(activity, home.arrayList as ArrayList<Album>, displayMetrics) adapter = AlbumFullWidthAdapter(activity, home.arrayList as ArrayList<Album>, displayMetrics)
@ -95,14 +94,9 @@ class HomeAdapter(private val activity: AppCompatActivity, private var homes: Li
title.text = activity.getString(home.title) title.text = activity.getString(home.title)
icon.setImageResource(home.icon) icon.setImageResource(home.icon)
} }
private val recyclerView: MetalRecyclerViewPager = view.findViewById(R.id.recyclerView)
private val title: TextView = view.findViewById(R.id.sectionTitle)
private val icon: IconImageView = itemView.findViewById(R.id.sectionIcon)
} }
private inner class ArtistViewHolder(view: View) : RecyclerView.ViewHolder(view) { private inner class ArtistViewHolder(view: View) : AbsHomeViewItem(view) {
fun bindView(home: Home) { fun bindView(home: Home) {
recyclerView.apply { recyclerView.apply {
layoutManager = GridLayoutManager(activity, 1, GridLayoutManager.HORIZONTAL, false) layoutManager = GridLayoutManager(activity, 1, GridLayoutManager.HORIZONTAL, false)
@ -112,13 +106,9 @@ class HomeAdapter(private val activity: AppCompatActivity, private var homes: Li
title.text = activity.getString(home.title) title.text = activity.getString(home.title)
icon.setImageResource(home.icon) icon.setImageResource(home.icon)
} }
private val recyclerView: RecyclerView = view.findViewById(R.id.recyclerView)
private val title: TextView = view.findViewById(R.id.sectionTitle)
private val icon: IconImageView = itemView.findViewById(R.id.sectionIcon)
} }
private inner class GenreViewHolder(view: View) : RecyclerView.ViewHolder(view) { private inner class GenreViewHolder(view: View) : AbsHomeViewItem(view) {
fun bindView(home: Home) { fun bindView(home: Home) {
recyclerView.apply { recyclerView.apply {
val genreAdapter = GenreAdapter(activity, home.arrayList as ArrayList<Genre>, R.layout.item_list) val genreAdapter = GenreAdapter(activity, home.arrayList as ArrayList<Genre>, R.layout.item_list)
@ -129,14 +119,9 @@ class HomeAdapter(private val activity: AppCompatActivity, private var homes: Li
title.text = activity.getString(home.title) title.text = activity.getString(home.title)
icon.setImageResource(home.icon) icon.setImageResource(home.icon)
} }
private val recyclerView: RecyclerView = view.findViewById(R.id.recyclerView)
private val title: TextView = view.findViewById(R.id.sectionTitle)
private val icon: IconImageView = itemView.findViewById(R.id.sectionIcon)
} }
private inner class PlaylistViewHolder(view: View) : RecyclerView.ViewHolder(view) { private inner class PlaylistViewHolder(view: View) : AbsHomeViewItem(view) {
fun bindView(home: Home) { fun bindView(home: Home) {
val songs = PlaylistSongsLoader.getPlaylistSongList(activity, home.arrayList[0] as Playlist).blockingFirst() val songs = PlaylistSongsLoader.getPlaylistSongList(activity, home.arrayList[0] as Playlist).blockingFirst()
recyclerView.apply { recyclerView.apply {
@ -148,9 +133,11 @@ class HomeAdapter(private val activity: AppCompatActivity, private var homes: Li
title.text = activity.getString(home.title) title.text = activity.getString(home.title)
icon.setImageResource(home.icon) icon.setImageResource(home.icon)
} }
}
private val recyclerView: RecyclerView = view.findViewById(R.id.recyclerView) private open inner class AbsHomeViewItem(itemView: View) : RecyclerView.ViewHolder(itemView) {
private val title: TextView = view.findViewById(R.id.sectionTitle) val recyclerView: RecyclerView = itemView.findViewById(R.id.recyclerView)
private val icon: IconImageView = itemView.findViewById(R.id.sectionIcon) val title: TextView = itemView.findViewById(R.id.sectionTitle)
val icon: IconImageView = itemView.findViewById(R.id.sectionIcon)
} }
} }

View file

@ -38,43 +38,6 @@ import com.google.android.material.textfield.TextInputLayout
class CreatePlaylistDialog : DialogFragment() { class CreatePlaylistDialog : DialogFragment() {
/* override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.dialog_playlist, container, false)
}*/
/* override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
val accentColor = ThemeStore.accentColor(context!!)
MaterialUtil.setTint(actionCreate, true)
MaterialUtil.setTint(actionCancel, false)
MaterialUtil.setTint(actionNewPlaylistContainer, false)
actionNewPlaylist.setHintTextColor(ColorStateList.valueOf(accentColor))
actionNewPlaylist.setTextColor(ThemeStore.textColorPrimary(context!!))
val songs = arguments!!.getParcelableArrayList<Song>("songs")
actionCancel.setOnClickListener { dismiss() }
actionCreate.setOnClickListener {
if (activity == null) {
return@setOnClickListener
}
if (!actionNewPlaylist!!.text!!.toString().trim { it <= ' ' }.isEmpty()) {
val playlistId = PlaylistsUtil.createPlaylist(activity!!, actionNewPlaylist!!.text!!.toString())
if (playlistId != -1 && activity != null) {
if (songs != null) {
PlaylistsUtil.addToPlaylist(activity!!, songs, playlistId, true)
}
}
}
dismiss()
}
}*/
private lateinit var playlistView: TextInputEditText private lateinit var playlistView: TextInputEditText
private lateinit var actionNewPlaylistContainer: TextInputLayout private lateinit var actionNewPlaylistContainer: TextInputLayout

View file

@ -15,7 +15,7 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="horizontal" android:orientation="horizontal"
android:paddingStart="0dp" android:paddingStart="0dp"
android:paddingEnd="14dp"> android:paddingEnd="8dp">
<code.name.monkey.retromusic.views.IconImageView <code.name.monkey.retromusic.views.IconImageView
android:id="@+id/mini_player_image" android:id="@+id/mini_player_image"

View file

@ -4,7 +4,7 @@
<style name="Theme.RetroMusic.DayNight" parent="Theme.MaterialComponents.DayNight.NoActionBar"> <style name="Theme.RetroMusic.DayNight" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<item name="md_corner_radius">12dp</item> <item name="md_corner_radius">16dp</item>
<item name="md_font_title">@font/circular</item> <item name="md_font_title">@font/circular</item>
<item name="md_font_body">@font/circular</item> <item name="md_font_body">@font/circular</item>
<item name="md_font_button">@font/circular</item> <item name="md_font_button">@font/circular</item>
@ -52,7 +52,7 @@
<style name="Theme.RetroMusic.Base" parent="Theme.MaterialComponents.NoActionBar"> <style name="Theme.RetroMusic.Base" parent="Theme.MaterialComponents.NoActionBar">
<item name="md_corner_radius">12dp</item> <item name="md_corner_radius">16dp</item>
<item name="md_font_title">@font/circular</item> <item name="md_font_title">@font/circular</item>
<item name="md_font_body">@font/circular</item> <item name="md_font_body">@font/circular</item>
<item name="md_font_button">@font/circular</item> <item name="md_font_button">@font/circular</item>
@ -133,7 +133,7 @@
<style name="Theme.RetroMusic.Base.Light" parent="Theme.MaterialComponents.Light.NoActionBar"> <style name="Theme.RetroMusic.Base.Light" parent="Theme.MaterialComponents.Light.NoActionBar">
<item name="md_corner_radius">12dp</item> <item name="md_corner_radius">16dp</item>
<item name="md_font_title">@font/circular</item> <item name="md_font_title">@font/circular</item>
<item name="md_font_body">@font/circular</item> <item name="md_font_body">@font/circular</item>
<item name="md_font_button">@font/circular</item> <item name="md_font_button">@font/circular</item>

View file

@ -2,7 +2,6 @@ package code.name.monkey.appthemehelper.util
import android.content.res.ColorStateList import android.content.res.ColorStateList
import android.graphics.PorterDuff import android.graphics.PorterDuff
import android.graphics.drawable.Drawable
import android.widget.EditText import android.widget.EditText
import android.widget.TextView import android.widget.TextView
import androidx.annotation.ColorInt import androidx.annotation.ColorInt
@ -47,14 +46,10 @@ object MaterialUtil {
textInputLayout.boxStrokeColor = accentColor textInputLayout.boxStrokeColor = accentColor
textInputLayout.defaultHintTextColor = colorState textInputLayout.defaultHintTextColor = colorState
textInputLayout.isHintAnimationEnabled = true textInputLayout.isHintAnimationEnabled = true
} }
} }
private fun setCursorPointerColor(view: EditText, @ColorInt color: Int) { private fun setCursorPointerColor(view: EditText, @ColorInt color: Int) {
try { try {
//get the pointer resource id //get the pointer resource id