Added text indication which is free or pro
This commit is contained in:
parent
d4d9df6ba5
commit
d33eafd80f
4 changed files with 111 additions and 57 deletions
|
@ -25,20 +25,26 @@ import android.view.View
|
|||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.preference.PreferenceDialogFragmentCompat
|
||||
import androidx.viewpager.widget.PagerAdapter
|
||||
import androidx.viewpager.widget.ViewPager
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.appthemehelper.common.prefs.supportv7.ATEDialogPreference
|
||||
import code.name.monkey.retromusic.App
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.fragments.AlbumCoverStyle
|
||||
import code.name.monkey.retromusic.fragments.AlbumCoverStyle.CARD
|
||||
import code.name.monkey.retromusic.fragments.AlbumCoverStyle.CIRCLE
|
||||
import code.name.monkey.retromusic.fragments.AlbumCoverStyle.FULL_CARD
|
||||
import code.name.monkey.retromusic.fragments.AlbumCoverStyle.values
|
||||
import code.name.monkey.retromusic.util.NavigationUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import code.name.monkey.retromusic.util.ViewUtil
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.customview.customView
|
||||
import com.bumptech.glide.Glide
|
||||
|
||||
|
||||
class AlbumCoverStylePreference : ATEDialogPreference {
|
||||
constructor(context: Context) : super(context)
|
||||
|
||||
|
@ -46,12 +52,17 @@ class AlbumCoverStylePreference : ATEDialogPreference {
|
|||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes)
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(
|
||||
context,
|
||||
attrs,
|
||||
defStyleAttr,
|
||||
defStyleRes
|
||||
)
|
||||
|
||||
private val mLayoutRes = R.layout.preference_dialog_now_playing_screen
|
||||
|
||||
override fun getDialogLayoutResource(): Int {
|
||||
return mLayoutRes;
|
||||
return mLayoutRes
|
||||
}
|
||||
|
||||
init {
|
||||
|
@ -61,13 +72,13 @@ class AlbumCoverStylePreference : ATEDialogPreference {
|
|||
|
||||
class AlbumCoverStylePreferenceDialog : PreferenceDialogFragmentCompat(), ViewPager.OnPageChangeListener {
|
||||
override fun onDialogClosed(positiveResult: Boolean) {
|
||||
|
||||
}
|
||||
|
||||
private var viewPagerPosition: Int = 0
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
@SuppressLint("InflateParams") val view = LayoutInflater.from(activity).inflate(R.layout.preference_dialog_now_playing_screen, null)
|
||||
@SuppressLint("InflateParams") val view =
|
||||
LayoutInflater.from(activity).inflate(R.layout.preference_dialog_now_playing_screen, null)
|
||||
val viewPager = view.findViewById<ViewPager>(R.id.now_playing_screen_view_pager)
|
||||
viewPager.adapter = AlbumCoverStyleAdapter(activity!!)
|
||||
viewPager.addOnPageChangeListener(this)
|
||||
|
@ -78,8 +89,15 @@ class AlbumCoverStylePreferenceDialog : PreferenceDialogFragmentCompat(), ViewPa
|
|||
title(R.string.pref_title_album_cover_style)
|
||||
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
||||
positiveButton(R.string.set) {
|
||||
val nowPlayingScreen = AlbumCoverStyle.values()[viewPagerPosition]
|
||||
PreferenceUtil.getInstance(requireContext()).albumCoverStyle = nowPlayingScreen
|
||||
val coverStyle = values()[viewPagerPosition]
|
||||
if (isAlbumCoverStyle(coverStyle)) {
|
||||
val result = getString(coverStyle.titleRes) + " theme is Pro version feature."
|
||||
Toast.makeText(context, result, Toast.LENGTH_SHORT).show()
|
||||
NavigationUtil.goToProVersion(requireActivity())
|
||||
} else {
|
||||
PreferenceUtil.getInstance(requireContext()).albumCoverStyle = coverStyle
|
||||
}
|
||||
|
||||
}
|
||||
negativeButton(android.R.string.cancel)
|
||||
customView(view = view, scrollable = false, noVerticalPadding = false)
|
||||
|
@ -87,7 +105,6 @@ class AlbumCoverStylePreferenceDialog : PreferenceDialogFragmentCompat(), ViewPa
|
|||
}
|
||||
|
||||
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {
|
||||
|
||||
}
|
||||
|
||||
override fun onPageSelected(position: Int) {
|
||||
|
@ -95,13 +112,12 @@ class AlbumCoverStylePreferenceDialog : PreferenceDialogFragmentCompat(), ViewPa
|
|||
}
|
||||
|
||||
override fun onPageScrollStateChanged(state: Int) {
|
||||
|
||||
}
|
||||
|
||||
private class AlbumCoverStyleAdapter internal constructor(private val context: Context) : PagerAdapter() {
|
||||
|
||||
override fun instantiateItem(collection: ViewGroup, position: Int): Any {
|
||||
val albumCoverStyle = AlbumCoverStyle.values()[position]
|
||||
val albumCoverStyle = values()[position]
|
||||
|
||||
val inflater = LayoutInflater.from(context)
|
||||
val layout = inflater.inflate(R.layout.preference_now_playing_screen_item, collection, false) as ViewGroup
|
||||
|
@ -109,20 +125,27 @@ class AlbumCoverStylePreferenceDialog : PreferenceDialogFragmentCompat(), ViewPa
|
|||
|
||||
val image = layout.findViewById<ImageView>(R.id.image)
|
||||
val title = layout.findViewById<TextView>(R.id.title)
|
||||
val proText = layout.findViewById<TextView>(R.id.proText)
|
||||
Glide.with(context).load(albumCoverStyle.drawableResId).into(image)
|
||||
title.setText(albumCoverStyle.titleRes)
|
||||
|
||||
if (isAlbumCoverStyle(albumCoverStyle)) {
|
||||
proText.setText(R.string.pro)
|
||||
} else {
|
||||
proText.setText(R.string.free)
|
||||
}
|
||||
return layout
|
||||
}
|
||||
|
||||
override fun destroyItem(collection: ViewGroup,
|
||||
position: Int,
|
||||
view: Any) {
|
||||
override fun destroyItem(
|
||||
collection: ViewGroup,
|
||||
position: Int,
|
||||
view: Any
|
||||
) {
|
||||
collection.removeView(view as View)
|
||||
}
|
||||
|
||||
override fun getCount(): Int {
|
||||
return AlbumCoverStyle.values().size
|
||||
return values().size
|
||||
}
|
||||
|
||||
override fun isViewFromObject(view: View, `object`: Any): Boolean {
|
||||
|
@ -130,7 +153,7 @@ class AlbumCoverStylePreferenceDialog : PreferenceDialogFragmentCompat(), ViewPa
|
|||
}
|
||||
|
||||
override fun getPageTitle(position: Int): CharSequence? {
|
||||
return context.getString(AlbumCoverStyle.values()[position].titleRes)
|
||||
return context.getString(values()[position].titleRes)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -146,3 +169,7 @@ class AlbumCoverStylePreferenceDialog : PreferenceDialogFragmentCompat(), ViewPa
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun isAlbumCoverStyle(style: AlbumCoverStyle): Boolean {
|
||||
return (!App.isProVersion() && (style == CIRCLE || style == CARD || style == FULL_CARD))
|
||||
}
|
|
@ -33,6 +33,16 @@ import code.name.monkey.appthemehelper.common.prefs.supportv7.ATEDialogPreferenc
|
|||
import code.name.monkey.retromusic.App
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.fragments.NowPlayingScreen
|
||||
import code.name.monkey.retromusic.fragments.NowPlayingScreen.ADAPTIVE
|
||||
import code.name.monkey.retromusic.fragments.NowPlayingScreen.BLUR
|
||||
import code.name.monkey.retromusic.fragments.NowPlayingScreen.BLUR_CARD
|
||||
import code.name.monkey.retromusic.fragments.NowPlayingScreen.CARD
|
||||
import code.name.monkey.retromusic.fragments.NowPlayingScreen.CIRCLE
|
||||
import code.name.monkey.retromusic.fragments.NowPlayingScreen.COLOR
|
||||
import code.name.monkey.retromusic.fragments.NowPlayingScreen.FULL
|
||||
import code.name.monkey.retromusic.fragments.NowPlayingScreen.PLAIN
|
||||
import code.name.monkey.retromusic.fragments.NowPlayingScreen.SIMPLE
|
||||
import code.name.monkey.retromusic.fragments.NowPlayingScreen.values
|
||||
import code.name.monkey.retromusic.util.NavigationUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import code.name.monkey.retromusic.util.ViewUtil
|
||||
|
@ -42,18 +52,23 @@ import com.bumptech.glide.Glide
|
|||
|
||||
class NowPlayingScreenPreference : ATEDialogPreference {
|
||||
|
||||
constructor(context: Context) : super(context) {}
|
||||
constructor(context: Context) : super(context)
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {}
|
||||
constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {}
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) {}
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(
|
||||
context,
|
||||
attrs,
|
||||
defStyleAttr,
|
||||
defStyleRes
|
||||
)
|
||||
|
||||
private val mLayoutRes = R.layout.preference_dialog_now_playing_screen
|
||||
|
||||
override fun getDialogLayoutResource(): Int {
|
||||
return mLayoutRes;
|
||||
return mLayoutRes
|
||||
}
|
||||
|
||||
init {
|
||||
|
@ -66,11 +81,9 @@ class NowPlayingScreenPreferenceDialog : PreferenceDialogFragmentCompat(), ViewP
|
|||
private var viewPagerPosition: Int = 0
|
||||
|
||||
override fun onPageScrollStateChanged(state: Int) {
|
||||
|
||||
}
|
||||
|
||||
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {
|
||||
|
||||
}
|
||||
|
||||
override fun onPageSelected(position: Int) {
|
||||
|
@ -78,14 +91,13 @@ class NowPlayingScreenPreferenceDialog : PreferenceDialogFragmentCompat(), ViewP
|
|||
}
|
||||
|
||||
override fun onDialogClosed(positiveResult: Boolean) {
|
||||
|
||||
}
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val view = LayoutInflater.from(activity).inflate(R.layout.preference_dialog_now_playing_screen, null)
|
||||
val viewPager = view.findViewById<ViewPager>(R.id.now_playing_screen_view_pager)
|
||||
?: throw IllegalStateException("Dialog view must contain a ViewPager with id 'now_playing_screen_view_pager'")
|
||||
viewPager.adapter = NowPlayingScreenAdapter(activity!!)
|
||||
?: throw IllegalStateException("Dialog view must contain a ViewPager with id 'now_playing_screen_view_pager'")
|
||||
viewPager.adapter = NowPlayingScreenAdapter(requireContext())
|
||||
viewPager.addOnPageChangeListener(this)
|
||||
viewPager.pageMargin = ViewUtil.convertDpToPixel(32f, resources).toInt()
|
||||
viewPager.currentItem = PreferenceUtil.getInstance(requireContext()).nowPlayingScreen.ordinal
|
||||
|
@ -94,7 +106,7 @@ class NowPlayingScreenPreferenceDialog : PreferenceDialogFragmentCompat(), ViewP
|
|||
return MaterialDialog(requireContext()).show {
|
||||
title(R.string.pref_title_now_playing_screen_appearance)
|
||||
positiveButton(R.string.set) {
|
||||
val nowPlayingScreen = NowPlayingScreen.values()[viewPagerPosition]
|
||||
val nowPlayingScreen = values()[viewPagerPosition]
|
||||
if (isNowPlayingThemes(nowPlayingScreen)) {
|
||||
val result = getString(nowPlayingScreen.titleRes) + " theme is Pro version feature."
|
||||
Toast.makeText(context, result, Toast.LENGTH_SHORT).show()
|
||||
|
@ -109,24 +121,6 @@ class NowPlayingScreenPreferenceDialog : PreferenceDialogFragmentCompat(), ViewP
|
|||
}
|
||||
}
|
||||
|
||||
private fun isNowPlayingThemes(nowPlayingScreen: NowPlayingScreen): Boolean {
|
||||
if (nowPlayingScreen == NowPlayingScreen.BLUR_CARD) {
|
||||
PreferenceUtil.getInstance(requireContext()).resetCarouselEffect()
|
||||
PreferenceUtil.getInstance(requireContext()).resetCircularAlbumArt()
|
||||
}
|
||||
|
||||
return (nowPlayingScreen == NowPlayingScreen.FULL ||
|
||||
nowPlayingScreen == NowPlayingScreen.CARD ||
|
||||
nowPlayingScreen == NowPlayingScreen.PLAIN ||
|
||||
nowPlayingScreen == NowPlayingScreen.BLUR ||
|
||||
nowPlayingScreen == NowPlayingScreen.COLOR ||
|
||||
nowPlayingScreen == NowPlayingScreen.SIMPLE ||
|
||||
nowPlayingScreen == NowPlayingScreen.BLUR_CARD ||
|
||||
nowPlayingScreen == NowPlayingScreen.CIRCLE ||
|
||||
nowPlayingScreen == NowPlayingScreen.ADAPTIVE)
|
||||
&& !App.isProVersion()
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun newInstance(key: String): NowPlayingScreenPreferenceDialog {
|
||||
val bundle = Bundle()
|
||||
|
@ -138,10 +132,10 @@ class NowPlayingScreenPreferenceDialog : PreferenceDialogFragmentCompat(), ViewP
|
|||
}
|
||||
}
|
||||
|
||||
private class NowPlayingScreenAdapter internal constructor(private val context: Context) : PagerAdapter() {
|
||||
private class NowPlayingScreenAdapter(private val context: Context) : PagerAdapter() {
|
||||
|
||||
override fun instantiateItem(collection: ViewGroup, position: Int): Any {
|
||||
val nowPlayingScreen = NowPlayingScreen.values()[position]
|
||||
val nowPlayingScreen = values()[position]
|
||||
|
||||
val inflater = LayoutInflater.from(context)
|
||||
val layout = inflater.inflate(R.layout.preference_now_playing_screen_item, collection, false) as ViewGroup
|
||||
|
@ -149,27 +143,47 @@ private class NowPlayingScreenAdapter internal constructor(private val context:
|
|||
|
||||
val image = layout.findViewById<ImageView>(R.id.image)
|
||||
val title = layout.findViewById<TextView>(R.id.title)
|
||||
val proText = layout.findViewById<TextView>(R.id.proText)
|
||||
Glide.with(context).load(nowPlayingScreen.drawableResId).into(image)
|
||||
title.setText(nowPlayingScreen.titleRes)
|
||||
|
||||
if (isNowPlayingThemes(nowPlayingScreen)) {
|
||||
proText.setText(R.string.pro)
|
||||
} else {
|
||||
proText.setText(R.string.free)
|
||||
}
|
||||
return layout
|
||||
}
|
||||
|
||||
override fun destroyItem(collection: ViewGroup,
|
||||
position: Int,
|
||||
view: Any) {
|
||||
override fun destroyItem(
|
||||
collection: ViewGroup,
|
||||
position: Int,
|
||||
view: Any
|
||||
) {
|
||||
collection.removeView(view as View)
|
||||
}
|
||||
|
||||
override fun getCount(): Int {
|
||||
return NowPlayingScreen.values().size
|
||||
return values().size
|
||||
}
|
||||
|
||||
override fun isViewFromObject(view: View, `object`: Any): Boolean {
|
||||
return view === `object`
|
||||
override fun isViewFromObject(view: View, instance: Any): Boolean {
|
||||
return view === instance
|
||||
}
|
||||
|
||||
override fun getPageTitle(position: Int): CharSequence? {
|
||||
return context.getString(NowPlayingScreen.values()[position].titleRes)
|
||||
return context.getString(values()[position].titleRes)
|
||||
}
|
||||
}
|
||||
|
||||
private fun isNowPlayingThemes(screen: NowPlayingScreen): Boolean {
|
||||
return (screen == FULL ||
|
||||
screen == CARD ||
|
||||
screen == PLAIN ||
|
||||
screen == BLUR ||
|
||||
screen == COLOR ||
|
||||
screen == SIMPLE ||
|
||||
screen == BLUR_CARD ||
|
||||
screen == CIRCLE ||
|
||||
screen == ADAPTIVE)
|
||||
&& !App.isProVersion()
|
||||
}
|
|
@ -12,7 +12,6 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="8dp"
|
||||
android:gravity="center"
|
||||
android:padding="8dp"
|
||||
android:textAppearance="@style/TextViewHeadline6"
|
||||
|
@ -25,10 +24,22 @@
|
|||
android:id="@+id/image"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@id/proText"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/title"
|
||||
tools:src="@tools:sample/backgrounds/scenic" />
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/proText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:padding="8dp"
|
||||
android:text="@string/pro"
|
||||
android:textAppearance="@style/TextViewHeadline6"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -825,4 +825,6 @@
|
|||
<string name="share_to_stories">Share to Stories</string>
|
||||
<string name="drive_mode">Drive mode</string>
|
||||
<string name="retro_music_player">Retro Music Player</string>
|
||||
<string name="pro">Pro</string>
|
||||
<string name="free">Free</string>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue