Removed bottom sheet dialog for Activity leaks

This commit is contained in:
h4h13 2020-04-26 22:44:18 +05:30
parent 162535e3dd
commit 58dc709a7e
19 changed files with 27 additions and 29 deletions

View file

@ -128,7 +128,7 @@ class AboutActivity : AbsBaseActivity(), View.OnClickListener {
} }
private fun showChangeLogOptions() { private fun showChangeLogOptions() {
MaterialDialog(this, BottomSheet(LayoutMode.WRAP_CONTENT)).show { MaterialDialog(this).show {
cornerRadius(PreferenceUtil.getInstance(this@AboutActivity).dialogCorner) cornerRadius(PreferenceUtil.getInstance(this@AboutActivity).dialogCorner)
listItems(items = listOf("Telegram Channel", "App")) { _, position, _ -> listItems(items = listOf("Telegram Channel", "App")) { _, position, _ ->
if (position == 0) { if (position == 0) {

View file

@ -170,7 +170,7 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener,
e.printStackTrace() e.printStackTrace()
} }
val materialDialog = MaterialDialog(this, BottomSheet(LayoutMode.WRAP_CONTENT)) val materialDialog = MaterialDialog(this)
.show { .show {
cornerRadius(PreferenceUtil.getInstance(this@LyricsActivity).dialogCorner) cornerRadius(PreferenceUtil.getInstance(this@LyricsActivity).dialogCorner)
title(R.string.add_time_framed_lryics) title(R.string.add_time_framed_lryics)
@ -208,7 +208,7 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener,
} }
val materialDialog = MaterialDialog( val materialDialog = MaterialDialog(
this, BottomSheet(LayoutMode.WRAP_CONTENT) this
).show { ).show {
cornerRadius(PreferenceUtil.getInstance(this@LyricsActivity).dialogCorner) cornerRadius(PreferenceUtil.getInstance(this@LyricsActivity).dialogCorner)
title(R.string.add_lyrics) title(R.string.add_lyrics)

View file

@ -62,7 +62,7 @@ class UserInfoActivity : AbsBaseActivity() {
loadBannerFromStorage(PreferenceUtil.getInstance(this).bannerImage) loadBannerFromStorage(PreferenceUtil.getInstance(this).bannerImage)
} }
userImage.setOnClickListener { userImage.setOnClickListener {
MaterialDialog(this, BottomSheet(LayoutMode.WRAP_CONTENT)).show { MaterialDialog(this).show {
cornerRadius(PreferenceUtil.getInstance(this@UserInfoActivity).dialogCorner) cornerRadius(PreferenceUtil.getInstance(this@UserInfoActivity).dialogCorner)
title(text = getString(R.string.set_photo)) title(text = getString(R.string.set_photo))
listItems( listItems(
@ -79,7 +79,7 @@ class UserInfoActivity : AbsBaseActivity() {
} }
} }
bannerSelect.setOnClickListener { bannerSelect.setOnClickListener {
MaterialDialog(this, BottomSheet(LayoutMode.WRAP_CONTENT)).show { MaterialDialog(this).show {
cornerRadius(PreferenceUtil.getInstance(this@UserInfoActivity).dialogCorner) cornerRadius(PreferenceUtil.getInstance(this@UserInfoActivity).dialogCorner)
title(R.string.select_banner_photo) title(R.string.select_banner_photo)
listItems( listItems(

View file

@ -52,7 +52,7 @@ abstract class AbsTagEditorActivity : AbsBaseActivity() {
private var savedArtworkInfo: ArtworkInfo? = null private var savedArtworkInfo: ArtworkInfo? = null
protected val show: MaterialDialog protected val show: MaterialDialog
get() = MaterialDialog(this, BottomSheet(LayoutMode.WRAP_CONTENT)).show { get() = MaterialDialog(this).show {
cornerRadius(PreferenceUtil.getInstance(this@AbsTagEditorActivity).dialogCorner) cornerRadius(PreferenceUtil.getInstance(this@AbsTagEditorActivity).dialogCorner)
title(R.string.update_image) title(R.string.update_image)
listItems(items = items) { _, position, _ -> listItems(items = items) { _, position, _ ->

View file

@ -39,7 +39,7 @@ class AddToPlaylistDialog : DialogFragment() {
playlistNames.add(p.name) playlistNames.add(p.name)
} }
return MaterialDialog(requireContext(), BottomSheet(LayoutMode.WRAP_CONTENT)).show { return MaterialDialog(requireContext()).show {
title(R.string.add_playlist_title) title(R.string.add_playlist_title)
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner) cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
listItems(items = playlistNames) { dialog, index, _ -> listItems(items = playlistNames) { dialog, index, _ ->

View file

@ -38,7 +38,7 @@ class ClearSmartPlaylistDialog : DialogFragment() {
HtmlCompat.FROM_HTML_MODE_LEGACY HtmlCompat.FROM_HTML_MODE_LEGACY
) )
return MaterialDialog(requireContext(), BottomSheet(LayoutMode.WRAP_CONTENT)).show { return MaterialDialog(requireContext()).show {
title(title) title(title)
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner) cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
message(text = content) message(text = content)

View file

@ -43,7 +43,7 @@ class CreatePlaylistDialog : DialogFragment() {
override fun onCreateDialog( override fun onCreateDialog(
savedInstanceState: Bundle? savedInstanceState: Bundle?
): Dialog { ): Dialog {
val materialDialog = MaterialDialog(requireContext(), BottomSheet(LayoutMode.WRAP_CONTENT)) val materialDialog = MaterialDialog(requireContext())
.show { .show {
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner) cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
title(string.new_playlist_title) title(string.new_playlist_title)

View file

@ -49,7 +49,7 @@ class DeletePlaylistDialog : DialogFragment() {
) )
} }
return MaterialDialog(requireContext(), BottomSheet(LayoutMode.WRAP_CONTENT)) return MaterialDialog(requireContext())
.show { .show {
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner) cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
title(title) title(title)

View file

@ -59,7 +59,7 @@ class DeleteSongsDialog : DialogFragment() {
} }
} }
return MaterialDialog(requireContext(), BottomSheet(LayoutMode.WRAP_CONTENT)).show { return MaterialDialog(requireContext()).show {
title(title) title(title)
message(text = content) message(text = content)
negativeButton(android.R.string.cancel) { negativeButton(android.R.string.cancel) {

View file

@ -54,7 +54,7 @@ class RemoveFromPlaylistDialog : DialogFragment() {
} }
return MaterialDialog(requireContext(), BottomSheet(LayoutMode.WRAP_CONTENT)) return MaterialDialog(requireContext())
.show { .show {
title(title) title(title)
message(text = content) message(text = content)

View file

@ -39,7 +39,7 @@ class RenamePlaylistDialog : DialogFragment() {
private lateinit var actionNewPlaylistContainer: TextInputLayout private lateinit var actionNewPlaylistContainer: TextInputLayout
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val materialDialog = MaterialDialog(requireContext(), BottomSheet(LayoutMode.WRAP_CONTENT)) val materialDialog = MaterialDialog(requireContext())
.show { .show {
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner) cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
title(string.rename_playlist_title) title(string.rename_playlist_title)

View file

@ -58,7 +58,7 @@ class SleepTimerDialog : DialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
timerUpdater = TimerUpdater() timerUpdater = TimerUpdater()
materialDialog = MaterialDialog(requireContext(), BottomSheet(LayoutMode.WRAP_CONTENT)) materialDialog = MaterialDialog(requireContext())
.title(R.string.action_sleep_timer) .title(R.string.action_sleep_timer)
.cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner) .cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
.positiveButton(R.string.action_set) { .positiveButton(R.string.action_set) {

View file

@ -55,7 +55,7 @@ class SongDetailDialog : DialogFragment() {
val context: Context = requireContext() val context: Context = requireContext()
val song = requireArguments().getParcelable<Song>("song") val song = requireArguments().getParcelable<Song>("song")
val materialDialog = MaterialDialog(requireContext(), BottomSheet(LayoutMode.WRAP_CONTENT)) val materialDialog = MaterialDialog(requireContext())
.show { .show {
customView( customView(
R.layout.dialog_file_details, R.layout.dialog_file_details,

View file

@ -34,7 +34,7 @@ class SongShareDialog : DialogFragment() {
val currentlyListening: String = val currentlyListening: String =
getString(R.string.currently_listening_to_x_by_x, song?.title, song?.artistName) getString(R.string.currently_listening_to_x_by_x, song?.title, song?.artistName)
return MaterialDialog(requireContext(), BottomSheet(LayoutMode.WRAP_CONTENT)) return MaterialDialog(requireContext())
.title(R.string.what_do_you_want_to_share) .title(R.string.what_do_you_want_to_share)
.show { .show {
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner) cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)

View file

@ -16,7 +16,6 @@ package code.name.monkey.retromusic.fragments.settings
import android.os.Build import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.os.Handler
import androidx.preference.Preference import androidx.preference.Preference
import androidx.preference.TwoStatePreference import androidx.preference.TwoStatePreference
import code.name.monkey.appthemehelper.ACCENT_COLORS import code.name.monkey.appthemehelper.ACCENT_COLORS
@ -30,9 +29,7 @@ import code.name.monkey.retromusic.App
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.appshortcuts.DynamicShortcutManager import code.name.monkey.retromusic.appshortcuts.DynamicShortcutManager
import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.util.PreferenceUtil
import com.afollestad.materialdialogs.LayoutMode
import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
import com.afollestad.materialdialogs.color.colorChooser import com.afollestad.materialdialogs.color.colorChooser
@ -64,7 +61,7 @@ class ThemeSettingsFragment : AbsSettingsFragment() {
accentColorPref.setColor(accentColor, ColorUtil.darkenColor(accentColor)) accentColorPref.setColor(accentColor, ColorUtil.darkenColor(accentColor))
accentColorPref.setOnPreferenceClickListener { accentColorPref.setOnPreferenceClickListener {
MaterialDialog(requireActivity(), BottomSheet(LayoutMode.WRAP_CONTENT)).show { MaterialDialog(requireActivity()).show {
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner) cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
title(R.string.accent_color) title(R.string.accent_color)
positiveButton(R.string.set) positiveButton(R.string.set)
@ -76,9 +73,9 @@ class ThemeSettingsFragment : AbsSettingsFragment() {
ThemeStore.editTheme(requireContext()).accentColor(color).commit() ThemeStore.editTheme(requireContext()).accentColor(color).commit()
if (VersionUtils.hasNougatMR()) if (VersionUtils.hasNougatMR())
DynamicShortcutManager(requireContext()).updateDynamicShortcuts() DynamicShortcutManager(requireContext()).updateDynamicShortcuts()
Handler().postDelayed({
requireActivity().recreate() requireActivity().recreate()
}, 400)
} }
} }
return@setOnPreferenceClickListener true return@setOnPreferenceClickListener true
@ -102,7 +99,9 @@ class ThemeSettingsFragment : AbsSettingsFragment() {
findPreference(PreferenceUtil.DESATURATED_COLOR) findPreference(PreferenceUtil.DESATURATED_COLOR)
desaturatedColor?.setOnPreferenceChangeListener { _, value -> desaturatedColor?.setOnPreferenceChangeListener { _, value ->
val desaturated = value as Boolean val desaturated = value as Boolean
ThemeStore.prefs(requireContext()).edit().putBoolean("desaturated_color", desaturated) ThemeStore.prefs(requireContext())
.edit()
.putBoolean("desaturated_color", desaturated)
.apply() .apply()
PreferenceUtil.getInstance(requireContext()).setDesaturatedColor(desaturated) PreferenceUtil.getInstance(requireContext()).setDesaturatedColor(desaturated)
requireActivity().recreate() requireActivity().recreate()

View file

@ -30,9 +30,7 @@ import code.name.monkey.retromusic.adapter.CategoryInfoAdapter
import code.name.monkey.retromusic.extensions.colorControlNormal import code.name.monkey.retromusic.extensions.colorControlNormal
import code.name.monkey.retromusic.model.CategoryInfo import code.name.monkey.retromusic.model.CategoryInfo
import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.util.PreferenceUtil
import com.afollestad.materialdialogs.LayoutMode
import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
import com.afollestad.materialdialogs.customview.customView import com.afollestad.materialdialogs.customview.customView
import java.util.* import java.util.*
@ -79,7 +77,7 @@ class LibraryPreferenceDialog : PreferenceDialogFragmentCompat() {
adapter.attachToRecyclerView(recyclerView) adapter.attachToRecyclerView(recyclerView)
return MaterialDialog(requireContext(), BottomSheet(LayoutMode.WRAP_CONTENT)) return MaterialDialog(requireContext())
.title(R.string.library_categories) .title(R.string.library_categories)
.cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner) .cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
.customView(view = view) .customView(view = view)

View file

@ -65,7 +65,7 @@ object AppRater {
} }
private fun showRateDialog(context: Context, editor: SharedPreferences.Editor) { private fun showRateDialog(context: Context, editor: SharedPreferences.Editor) {
MaterialDialog(context, BottomSheet(LayoutMode.WRAP_CONTENT)) MaterialDialog(context)
.show { .show {
cornerRadius(PreferenceUtil.getInstance(context).dialogCorner) cornerRadius(PreferenceUtil.getInstance(context).dialogCorner)

View file

@ -75,7 +75,7 @@ class RingtoneManager(val context: Context) {
} }
fun getDialog(context: Context): MaterialDialog { fun getDialog(context: Context): MaterialDialog {
return MaterialDialog(context, BottomSheet(LayoutMode.WRAP_CONTENT)).show { return MaterialDialog(context).show {
cornerRadius(PreferenceUtil.getInstance(context).dialogCorner) cornerRadius(PreferenceUtil.getInstance(context).dialogCorner)
title(R.string.dialog_title_set_ringtone) title(R.string.dialog_title_set_ringtone)
message(R.string.dialog_message_set_ringtone) message(R.string.dialog_message_set_ringtone)

View file

@ -12,6 +12,7 @@
<style name="Theme.RetroMusic.FollowSystem" parent="Theme.RetroMusic.Base.Adaptive" > <style name="Theme.RetroMusic.FollowSystem" parent="Theme.RetroMusic.Base.Adaptive" >
<item name="android:windowBackground">@color/window_color</item> <item name="android:windowBackground">@color/window_color</item>
<item name="android:scrollbars">none</item>
</style> </style>
<style name="Theme.RetroMusic.Notification" parent="@android:style/TextAppearance.StatusBar.EventContent" /> <style name="Theme.RetroMusic.Notification" parent="@android:style/TextAppearance.StatusBar.EventContent" />