From 83a3b5a02c44d3e53ed964670b8f97024705539f Mon Sep 17 00:00:00 2001 From: h4h13 Date: Fri, 17 May 2019 00:22:48 +0530 Subject: [PATCH] Fix lyrics dialog --- .../retromusic/activities/LyricsActivity.kt | 15 +++++--- .../monkey/retromusic/adapter/HomeAdapter.kt | 31 +++++----------- .../dialogs/CreatePlaylistDialog.kt | 37 ------------------- .../main/res/layout/fragment_mini_player.xml | 2 +- app/src/main/res/values/styles_parents.xml | 6 +-- .../appthemehelper/util/MaterialUtil.kt | 5 --- 6 files changed, 23 insertions(+), 73 deletions(-) diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/LyricsActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/LyricsActivity.kt index 50fe5088..ed2c4f1a 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/LyricsActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/LyricsActivity.kt @@ -16,24 +16,27 @@ import androidx.fragment.app.FragmentStatePagerAdapter import androidx.viewpager.widget.ViewPager import code.name.monkey.appthemehelper.ThemeStore 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.TintHelper import code.name.monkey.retromusic.App 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.MusicProgressViewUpdateHelper 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.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.MusicUtil import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.util.RetroUtil import com.afollestad.materialdialogs.MaterialDialog +import com.afollestad.materialdialogs.bottomsheets.BottomSheet +import com.afollestad.materialdialogs.input.getInputLayout import com.afollestad.materialdialogs.input.input import kotlinx.android.synthetic.main.activity_lyrics.* import kotlinx.android.synthetic.main.fragment_lyrics.* @@ -153,7 +156,7 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener, ViewPage e.printStackTrace() } - MaterialDialog(this).show { + val materialDialog = MaterialDialog(this, BottomSheet()).show { title(R.string.add_time_framed_lryics) negativeButton(R.string.action_search) { RetroUtil.openUrl(this@LyricsActivity, googleSearchLrcUrl) } input(hint = getString(R.string.paste_lyrics_here), @@ -165,6 +168,7 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener, ViewPage updateSong() } } + MaterialUtil.setTint(materialDialog.getInputLayout(), false) } private fun updateSong() { @@ -181,7 +185,7 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener, ViewPage lyricsString!! } - MaterialDialog(this).show { + val materialDialog = MaterialDialog(this, BottomSheet()).show { title(R.string.add_lyrics) negativeButton(R.string.action_search) { RetroUtil.openUrl(this@LyricsActivity, getGoogleSearchUrl()) } input(hint = getString(R.string.paste_lyrics_here), @@ -195,6 +199,7 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener, ViewPage updateSong() } } + MaterialUtil.setTint(materialDialog.getInputLayout(), false) } private fun getSongPaths(song: Song): ArrayList { diff --git a/app/src/main/java/code/name/monkey/retromusic/adapter/HomeAdapter.kt b/app/src/main/java/code/name/monkey/retromusic/adapter/HomeAdapter.kt index c4a8038f..3d770904 100644 --- a/app/src/main/java/code/name/monkey/retromusic/adapter/HomeAdapter.kt +++ b/app/src/main/java/code/name/monkey/retromusic/adapter/HomeAdapter.kt @@ -18,7 +18,6 @@ import code.name.monkey.retromusic.loaders.PlaylistSongsLoader import code.name.monkey.retromusic.model.* import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.views.IconImageView -import code.name.monkey.retromusic.views.MetalRecyclerViewPager class HomeAdapter(private val activity: AppCompatActivity, private var homes: List, private val displayMetrics: DisplayMetrics) : RecyclerView.Adapter() { @@ -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) { recyclerView.apply { adapter = AlbumFullWidthAdapter(activity, home.arrayList as ArrayList, displayMetrics) @@ -95,14 +94,9 @@ class HomeAdapter(private val activity: AppCompatActivity, private var homes: Li title.text = activity.getString(home.title) 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) { recyclerView.apply { 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) 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) { recyclerView.apply { val genreAdapter = GenreAdapter(activity, home.arrayList as ArrayList, R.layout.item_list) @@ -129,14 +119,9 @@ class HomeAdapter(private val activity: AppCompatActivity, private var homes: Li title.text = activity.getString(home.title) 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) { val songs = PlaylistSongsLoader.getPlaylistSongList(activity, home.arrayList[0] as Playlist).blockingFirst() recyclerView.apply { @@ -148,9 +133,11 @@ class HomeAdapter(private val activity: AppCompatActivity, private var homes: Li title.text = activity.getString(home.title) 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 open inner class AbsHomeViewItem(itemView: View) : RecyclerView.ViewHolder(itemView) { + val recyclerView: RecyclerView = itemView.findViewById(R.id.recyclerView) + val title: TextView = itemView.findViewById(R.id.sectionTitle) + val icon: IconImageView = itemView.findViewById(R.id.sectionIcon) } } \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/dialogs/CreatePlaylistDialog.kt b/app/src/main/java/code/name/monkey/retromusic/dialogs/CreatePlaylistDialog.kt index d1a54f52..6e361e27 100644 --- a/app/src/main/java/code/name/monkey/retromusic/dialogs/CreatePlaylistDialog.kt +++ b/app/src/main/java/code/name/monkey/retromusic/dialogs/CreatePlaylistDialog.kt @@ -38,43 +38,6 @@ import com.google.android.material.textfield.TextInputLayout 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("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 actionNewPlaylistContainer: TextInputLayout diff --git a/app/src/main/res/layout/fragment_mini_player.xml b/app/src/main/res/layout/fragment_mini_player.xml index 549e399f..2d9aab6f 100644 --- a/app/src/main/res/layout/fragment_mini_player.xml +++ b/app/src/main/res/layout/fragment_mini_player.xml @@ -15,7 +15,7 @@ android:layout_height="match_parent" android:orientation="horizontal" android:paddingStart="0dp" - android:paddingEnd="14dp"> + android:paddingEnd="8dp"> - 12dp + 16dp @font/circular @font/circular @font/circular @@ -52,7 +52,7 @@