diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/PlayingQueueActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/PlayingQueueActivity.kt index 8302a497..ada47244 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/PlayingQueueActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/PlayingQueueActivity.kt @@ -27,14 +27,21 @@ class PlayingQueueActivity : AbsMusicServiceActivity() { private var playingQueueAdapter: PlayingQueueAdapter? = null private lateinit var linearLayoutManager: LinearLayoutManager - private val upNextAndQueueTime: String - get() = resources.getString(R.string.up_next) + " • " + MusicUtil.getReadableDurationString(MusicPlayerRemote.getQueueDurationMillis(MusicPlayerRemote.position)) + + protected fun getUpNextAndQueueTime(): String { + val duration = MusicPlayerRemote.getQueueDurationMillis(MusicPlayerRemote.position) + + return MusicUtil.buildInfoString( + resources.getString(R.string.up_next), + MusicUtil.getReadableDurationString(duration) + ) + } override fun onCreate( savedInstanceState: Bundle? ) { super.onCreate(savedInstanceState) - setContentView(R.layout.activity_playing_queue) + setContentView(code.name.monkey.retromusic.R.layout.activity_playing_queue) setStatusbarColorAuto() setNavigationbarColorAuto() @@ -67,7 +74,7 @@ class PlayingQueueActivity : AbsMusicServiceActivity() { this, MusicPlayerRemote.playingQueue, MusicPlayerRemote.position, - R.layout.item_queue) + code.name.monkey.retromusic.R.layout.item_queue) wrappedAdapter = recyclerViewDragDropManager!!.createWrappedAdapter(playingQueueAdapter!!) linearLayoutManager = LinearLayoutManager(this) @@ -107,7 +114,9 @@ class PlayingQueueActivity : AbsMusicServiceActivity() { updateCurrentSong() } - private fun updateCurrentSong() {} + private fun updateCurrentSong() { + playerQueueSubHeader.text = getUpNextAndQueueTime() + } override fun onPlayingMetaChanged() { updateQueuePosition() @@ -116,6 +125,7 @@ class PlayingQueueActivity : AbsMusicServiceActivity() { private fun updateQueuePosition() { playingQueueAdapter!!.setCurrent(MusicPlayerRemote.position) resetToCurrentPosition() + playerQueueSubHeader.text = getUpNextAndQueueTime() } private fun updateQueue() { @@ -141,8 +151,6 @@ class PlayingQueueActivity : AbsMusicServiceActivity() { recyclerViewDragDropManager = null } - - if (wrappedAdapter != null) { WrapperAdapterUtils.releaseAll(wrappedAdapter) wrappedAdapter = null @@ -152,7 +160,7 @@ class PlayingQueueActivity : AbsMusicServiceActivity() { } private fun setupToolbar() { - playerQueueSubHeader.text = upNextAndQueueTime + playerQueueSubHeader.text = getUpNextAndQueueTime() playerQueueSubHeader.setTextColor(ThemeStore.accentColor(this)) applyToolbar(toolbar) diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/settings/AbsSettingsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/settings/AbsSettingsFragment.kt index 8af78efb..d191153c 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/settings/AbsSettingsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/settings/AbsSettingsFragment.kt @@ -22,9 +22,9 @@ import android.widget.Toast import androidx.fragment.app.DialogFragment import androidx.preference.ListPreference import androidx.preference.Preference -import androidx.preference.PreferenceFragmentCompat import androidx.preference.PreferenceManager import code.name.monkey.appthemehelper.ThemeStore +import code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceFragmentCompat import code.name.monkey.retromusic.preferences.* import code.name.monkey.retromusic.util.NavigationUtil @@ -32,7 +32,7 @@ import code.name.monkey.retromusic.util.NavigationUtil * @author Hemanth S (h4h13). */ -abstract class AbsSettingsFragment : PreferenceFragmentCompat() { +abstract class AbsSettingsFragment : ATEPreferenceFragmentCompat() { internal fun showProToastAndNavigate(message: String) { Toast.makeText(requireContext(), "$message is Pro version feature.", Toast.LENGTH_SHORT).show() @@ -67,7 +67,7 @@ abstract class AbsSettingsFragment : PreferenceFragmentCompat() { invalidateSettings() } - override fun onDisplayPreferenceDialog(preference: Preference) { + /*override fun onDisplayPreferenceDialog(preference: Preference) { var dialogFragment: DialogFragment? = null// Dialog creation could not be handled here. Try with the super method. // The dialog was created (it was one of our custom Preferences), show the dialog for it when (preference) { @@ -89,5 +89,18 @@ abstract class AbsSettingsFragment : PreferenceFragmentCompat() { // Dialog creation could not be handled here. Try with the super method. super.onDisplayPreferenceDialog(preference); } + }*/ + override fun onCreatePreferenceDialog(preference: Preference): DialogFragment? { + return when (preference) { + is LibraryPreference -> LibraryPreferenceDialog.newInstance(preference.key) + is NowPlayingScreenPreference -> NowPlayingScreenPreferenceDialog.newInstance(preference.key) + is AlbumCoverStylePreference -> AlbumCoverStylePreferenceDialog.newInstance(preference.key) + is MaterialListPreference -> { + preference.entries + MaterialListPreferenceDialog.newInstance(preference) + } + is BlacklistPreference -> BlacklistPreferenceDialog.newInstance() + else -> super.onCreatePreferenceDialog(preference) + } } } diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/settings/ThemeSettingsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/settings/ThemeSettingsFragment.kt index a5297472..411aef0b 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/settings/ThemeSettingsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/settings/ThemeSettingsFragment.kt @@ -15,15 +15,15 @@ package code.name.monkey.retromusic.fragments.settings import android.graphics.Color -import android.graphics.Color.BLUE import android.os.Build import android.os.Bundle import androidx.core.content.ContextCompat import androidx.preference.Preference import androidx.preference.TwoStatePreference -import code.name.monkey.appthemehelper.* +import code.name.monkey.appthemehelper.ACCENT_COLORS +import code.name.monkey.appthemehelper.ACCENT_COLORS_SUB +import code.name.monkey.appthemehelper.ThemeStore import code.name.monkey.appthemehelper.common.prefs.supportv7.ATEColorPreference -import code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory import code.name.monkey.appthemehelper.util.ColorUtil import code.name.monkey.appthemehelper.util.VersionUtils import code.name.monkey.retromusic.App @@ -49,45 +49,7 @@ class ThemeSettingsFragment : AbsSettingsFragment() { override fun invalidateSettings() { - val categoryColor: ATEPreferenceCategory? = findPreference("category_color") - val primaryColorPref = ATEColorPreference(preferenceScreen.context) - val primaryColor = ThemeStore.primaryColor(requireContext()) - - primaryColorPref.apply { - key = "primary_color" - isPersistent = false - setSummary(R.string.primary_color_desc) - setTitle(R.string.primary_color) - isCopyingEnabled = true - setIcon(R.drawable.ic_colorize_white_24dp) - setColor(primaryColor, ColorUtil.darkenColor(primaryColor)) - setOnPreferenceClickListener { - materialDialog = MaterialDialog(requireContext(), BottomSheet()).show { - title(R.string.primary_color) - positiveButton(R.string.set) - colorChooser(initialSelection = BLUE, - allowCustomArgb = true, - colors = PRIMARY_COLORS, - subColors = PRIMARY_COLORS_SUB) { _, color -> - - val theme = if (ColorUtil.isColorLight(color)) - PreferenceUtil.getThemeResFromPrefValue("light") - else - PreferenceUtil.getThemeResFromPrefValue("dark") - - ThemeStore.editTheme(requireContext()).activityTheme(theme).primaryColor(color).commit() - - if (VersionUtils.hasNougatMR()) - DynamicShortcutManager(context).updateDynamicShortcuts() - requireActivity().recreate() - } - } - true - } - } - val generalTheme: Preference? = findPreference("general_theme") - generalTheme?.let { setSummary(it) it.setOnPreferenceChangeListener { _, newValue -> @@ -100,17 +62,20 @@ class ThemeSettingsFragment : AbsSettingsFragment() { setSummary(generalTheme, newValue) - when (theme) { - "light" -> ThemeStore.editTheme(requireContext()).primaryColor(Color.WHITE).commit() - "black" -> ThemeStore.editTheme(requireContext()).primaryColor(Color.BLACK).commit() - "dark" -> ThemeStore.editTheme(requireContext()).primaryColor(ContextCompat.getColor(requireContext(), R.color.md_grey_900)).commit() - "color" -> ThemeStore.editTheme(requireContext()).primaryColor(ContextCompat.getColor(requireContext(), R.color.md_blue_grey_800)).commit() + val color = when (theme) { + "light" -> Color.WHITE + "black" -> Color.BLACK + "dark" -> ContextCompat.getColor(requireContext(), R.color.md_grey_900) + else -> Color.WHITE } ThemeStore.editTheme(requireContext()) .activityTheme(PreferenceUtil.getThemeResFromPrefValue(theme)) + .primaryColor(color) .commit() + ThemeStore.markChanged(requireContext()) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) { requireActivity().setTheme(PreferenceUtil.getThemeResFromPrefValue(theme)) DynamicShortcutManager(requireContext()).updateDynamicShortcuts() @@ -129,10 +94,6 @@ class ThemeSettingsFragment : AbsSettingsFragment() { title(R.string.accent_color) positiveButton(R.string.set) colorChooser(colors = ACCENT_COLORS, allowCustomArgb = true, subColors = ACCENT_COLORS_SUB) { _, color -> - /*var colorFinal = Color.BLACK; - if (!ColorUtil.isColorSaturated(color)) { - colorFinal = color - }*/ ThemeStore.editTheme(requireContext()).accentColor(color).commit() if (VersionUtils.hasNougatMR()) DynamicShortcutManager(requireContext()).updateDynamicShortcuts() @@ -154,10 +115,6 @@ class ThemeSettingsFragment : AbsSettingsFragment() { true } } - - if (PreferenceUtil.getInstance().generalTheme == R.style.Theme_RetroMusic_Color && App.isProVersion) { - categoryColor?.addPreference(primaryColorPref) - } } override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { diff --git a/app/src/main/java/code/name/monkey/retromusic/preferences/MaterialListPreference.kt b/app/src/main/java/code/name/monkey/retromusic/preferences/MaterialListPreference.kt index cff272f2..f5ead3cc 100644 --- a/app/src/main/java/code/name/monkey/retromusic/preferences/MaterialListPreference.kt +++ b/app/src/main/java/code/name/monkey/retromusic/preferences/MaterialListPreference.kt @@ -78,20 +78,23 @@ class MaterialListPreferenceDialog : PreferenceDialogFragmentCompat() { val entries = arguments?.getStringArrayList(EXTRA_ENTRIES) val entriesValues = arguments?.getStringArrayList(EXTRA_ENTRIES_VALUES) - materialDialog = MaterialDialog(activity!!, BottomSheet()) - .show { - title(text = materialListPreference.title.toString()) - positiveButton(R.string.set) - listItemsSingleChoice(items = entries, initialSelection = position, waitForPositiveButton = true) { _, index, _ -> - materialListPreference.callChangeListener(entriesValues!![index]) - materialListPreference.setCustomValue(entriesValues[index]) - materialListPreference.summary = entries!![index] - dismiss() - } + materialDialog = MaterialDialog(requireContext(), BottomSheet()) + .title(text = materialListPreference.title.toString()) + .positiveButton(R.string.set) + .listItemsSingleChoice(items = entries, initialSelection = position, waitForPositiveButton = true) { _, index, _ -> + materialListPreference.callChangeListener(entriesValues!![index]) + materialListPreference.setCustomValue(entriesValues[index]) + materialListPreference.summary = entries!![index] + dismiss() } return materialDialog } + override fun onDestroyView() { + super.onDestroyView() + materialDialog.dismiss() + } + private lateinit var materialDialog: MaterialDialog override fun onDialogClosed(positiveResult: Boolean) { diff --git a/app/src/main/java/code/name/monkey/retromusic/util/PreferenceUtil.java b/app/src/main/java/code/name/monkey/retromusic/util/PreferenceUtil.java index 761eabd8..e6ce27da 100644 --- a/app/src/main/java/code/name/monkey/retromusic/util/PreferenceUtil.java +++ b/app/src/main/java/code/name/monkey/retromusic/util/PreferenceUtil.java @@ -150,16 +150,12 @@ public final class PreferenceUtil { } @StyleRes - public static int getThemeResFromPrefValue(String themePrefValue) { + public static int getThemeResFromPrefValue(@NonNull String themePrefValue) { switch (themePrefValue) { case "light": return R.style.Theme_RetroMusic_Light; - case "color": - return R.style.Theme_RetroMusic_Color; case "black": return R.style.Theme_RetroMusic_Black; - case "daynight": - return R.style.Theme_RetroMusic_DayNight; case "dark": default: return R.style.Theme_RetroMusic; diff --git a/app/src/main/java/code/name/monkey/retromusic/util/RetroColorUtil.java b/app/src/main/java/code/name/monkey/retromusic/util/RetroColorUtil.java index 8eab3524..7f7b69f9 100644 --- a/app/src/main/java/code/name/monkey/retromusic/util/RetroColorUtil.java +++ b/app/src/main/java/code/name/monkey/retromusic/util/RetroColorUtil.java @@ -37,7 +37,7 @@ import code.name.monkey.retromusic.R; public class RetroColorUtil { public static int toolbarColor(@NonNull Context context) { int color = ThemeStore.Companion.primaryColor(context); - if (ATHUtil.INSTANCE.isWindowBackgroundDark(context) && PreferenceUtil.getInstance().getGeneralTheme() != R.style.Theme_RetroMusic_Color) { + if (ATHUtil.INSTANCE.isWindowBackgroundDark(context)) { return ATHUtil.INSTANCE.resolveColor(context, R.attr.cardBackgroundColor); } else { return color; diff --git a/app/src/main/res/font/circular_std_black.otf b/app/src/main/res/font/circular_std_black.otf old mode 100755 new mode 100644 diff --git a/app/src/main/res/font/circular_std_book.otf b/app/src/main/res/font/circular_std_book.otf old mode 100755 new mode 100644 diff --git a/app/src/main/res/font/circular_std_medium.otf b/app/src/main/res/font/circular_std_medium.otf old mode 100755 new mode 100644 diff --git a/app/src/main/res/values-night/styles-parents.xml b/app/src/main/res/values-night/styles-parents.xml deleted file mode 100644 index 03effed6..00000000 --- a/app/src/main/res/values-night/styles-parents.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - \ No newline at end of file diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 95f3f5df..35c90471 100755 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -44,7 +44,6 @@ @string/light_theme_name @string/dark_theme_name @string/black_theme_name - @string/color_theme_name @@ -96,7 +95,6 @@ light dark black - color diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index fbe24c14..892f0b3e 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -6,8 +6,6 @@ - -