From 4056a0c1c5c4ea64eb95cfcc4153bab31ee85108 Mon Sep 17 00:00:00 2001 From: Hemanth S Date: Sat, 23 May 2020 19:23:10 +0530 Subject: [PATCH] Kotlin refactoring --- app/src/main/assets/oldindex.html | 1 + app/src/main/assets/retro-changelog.html | 40 +++--- .../code/name/monkey/retromusic/Constants.kt | 1 - .../retromusic/activities/LyricsActivity.kt | 5 +- .../retromusic/activities/SearchActivity.kt | 2 - .../retromusic/activities/SettingsActivity.kt | 4 - .../activities/base/AbsBaseActivity.kt | 2 +- .../tageditor/AbsTagEditorActivity.kt | 3 - .../adapter/CategoryInfoAdapter.java | 3 +- .../shortcuttype/LastAddedShortcutType.kt | 3 +- .../shortcuttype/SearchShortCutType.kt | 3 +- .../shortcuttype/ShuffleAllShortcutType.kt | 3 +- .../shortcuttype/TopTracksShortcutType.kt | 3 +- .../retromusic/appwidgets/AppWidgetBig.kt | 3 +- .../retromusic/dialogs/AddToPlaylistDialog.kt | 3 - .../dialogs/BlacklistFolderChooserDialog.kt | 3 - .../dialogs/ClearSmartPlaylistDialog.kt | 3 - .../dialogs/CreatePlaylistDialog.kt | 3 - .../dialogs/DeletePlaylistDialog.kt | 3 - .../retromusic/dialogs/DeleteSongsDialog.kt | 4 +- .../dialogs/RemoveFromPlaylistDialog.kt | 3 - .../dialogs/RenamePlaylistDialog.kt | 3 - .../retromusic/dialogs/SongDetailDialog.kt | 3 - .../retromusic/dialogs/SongShareDialog.kt | 3 - .../retromusic/extensions/DrawableExt.kt | 7 +- .../fragments/albums/AlbumViewModel.kt | 2 +- .../base/AbsPlayerControlsFragment.kt | 6 +- .../fragments/genres/GenreViewModel.kt | 2 +- .../blur/BlurPlaybackControlsFragment.kt | 13 -- .../fragments/settings/AbsSettingsFragment.kt | 32 +++-- .../fragments/settings/AudioSettings.kt | 2 +- .../glide/RetroMusicColoredTarget.kt | 2 +- .../retromusic/helper/EqualizerHelper.kt | 1 + .../retromusic/helper/SearchQueryHelper.kt | 1 + .../name/monkey/retromusic/lyrics/LrcView.kt | 7 +- .../AlbumCoverStylePreferenceDialog.kt | 33 ++--- .../preferences/BlacklistPreferenceDialog.kt | 1 - .../preferences/LibraryPreference.kt | 66 +++++----- .../NowPlayingScreenPreferenceDialog.kt | 39 +++--- .../name/monkey/retromusic/util/AppRater.kt | 3 +- .../monkey/retromusic/util/PremiumShow.kt | 1 + .../monkey/retromusic/util/RingtoneManager.kt | 2 - .../name/monkey/retromusic/util/ViewUtil.kt | 3 +- .../retromusic/views/PopupBackground.java | 2 +- .../drawable-anydpi-v24/ic_notification.xml | 13 +- .../drawable-v24/ic_launcher_foreground.xml | 115 ++++++++++-------- .../drawable/ic_check_circle_white_24dp.xml | 13 +- .../drawable/ic_expand_less_white_24dp.xml | 13 +- .../drawable/ic_invert_colors_white_24dp.xml | 13 +- .../main/res/drawable/ic_retro_music_icon.xml | 108 ++++++++-------- .../main/res/layout/fragment_home_player.xml | 1 + app/src/main/res/layout/item_card.xml | 4 +- .../res/mipmap-anydpi-v26/ic_launcher.xml | 4 +- .../mipmap-anydpi-v26/ic_launcher_round.xml | 4 +- app/src/main/res/values/styles.xml | 3 + app/src/main/res/xml/pref_advanced.xml | 2 +- 56 files changed, 317 insertions(+), 308 deletions(-) diff --git a/app/src/main/assets/oldindex.html b/app/src/main/assets/oldindex.html index b2977366..a6ce8895 100644 --- a/app/src/main/assets/oldindex.html +++ b/app/src/main/assets/oldindex.html @@ -25,6 +25,7 @@ } + diff --git a/app/src/main/assets/retro-changelog.html b/app/src/main/assets/retro-changelog.html index 4c86d4d4..04dcc205 100644 --- a/app/src/main/assets/retro-changelog.html +++ b/app/src/main/assets/retro-changelog.html @@ -53,27 +53,29 @@ font-size: 1rem; } {style-placeholder} + -
April 30, 2020
-

v3.5.110

- Beta version -

What's New

- -

Improved

- - -

*If you face any UI related issues you clear app data and cache, if itsnot working try to uninstall and install - again.

+
April 30, 2020
+

v3.5.110

+Beta version +

What's New

+ +

Improved

+ + +

*If you face any UI related issues you clear app data and cache, if itsnot working try to + uninstall and install + again.

\ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/Constants.kt b/app/src/main/java/code/name/monkey/retromusic/Constants.kt index 2ce144a0..e69e3e1f 100644 --- a/app/src/main/java/code/name/monkey/retromusic/Constants.kt +++ b/app/src/main/java/code/name/monkey/retromusic/Constants.kt @@ -52,7 +52,6 @@ object Constants { const val NUMBER_OF_TOP_TRACKS = 99 - } const val LIBRARY_CATEGORIES = "library_categories" 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 b1b3060e..a6d5dd39 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 @@ -31,7 +31,10 @@ 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.util.* +import code.name.monkey.retromusic.util.LyricUtil +import code.name.monkey.retromusic.util.MusicUtil +import code.name.monkey.retromusic.util.PreferenceUtilKT +import code.name.monkey.retromusic.util.RetroUtil import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.input.getInputLayout import com.afollestad.materialdialogs.input.input diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/SearchActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/SearchActivity.kt index 494b6dd5..d198bd5c 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/SearchActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/SearchActivity.kt @@ -33,8 +33,6 @@ import kotlinx.android.synthetic.main.activity_search.* import java.util.* import javax.inject.Inject import kotlin.collections.ArrayList -import kotlin.collections.MutableList -import kotlin.collections.emptyList class SearchActivity : AbsMusicServiceActivity(), OnQueryTextListener, TextWatcher, SearchView { @Inject diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/SettingsActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/SettingsActivity.kt index a5502acb..6872f1ea 100755 --- a/app/src/main/java/code/name/monkey/retromusic/activities/SettingsActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/SettingsActivity.kt @@ -4,8 +4,6 @@ import android.os.Bundle import android.view.MenuItem import androidx.annotation.StringRes import androidx.fragment.app.Fragment -import code.name.monkey.appthemehelper.util.ATHUtil -import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper import code.name.monkey.retromusic.R import code.name.monkey.retromusic.activities.base.AbsBaseActivity import code.name.monkey.retromusic.extensions.applyToolbar @@ -23,7 +21,6 @@ class SettingsActivity : AbsBaseActivity() { setStatusbarColorAuto() setNavigationbarColorAuto() setLightNavigationBar(true) - setupToolbar() if (savedInstanceState == null) { @@ -49,7 +46,6 @@ class SettingsActivity : AbsBaseActivity() { fragmentTransaction.replace(R.id.contentFrame, fragment, fragment.tag) fragmentTransaction.addToBackStack(null) fragmentTransaction.commit() - setTitle(titleName) } diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsBaseActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsBaseActivity.kt index d198cff6..1afa57b4 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsBaseActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsBaseActivity.kt @@ -137,7 +137,7 @@ abstract class AbsBaseActivity : AbsThemeActivity() { } } hadPermissions = true - onHasPermissionsChanged(true) + onHasPermissionsChanged(true) } } diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/AbsTagEditorActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/AbsTagEditorActivity.kt index ce2d85b5..7d81bcee 100755 --- a/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/AbsTagEditorActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/AbsTagEditorActivity.kt @@ -22,12 +22,9 @@ import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R.drawable import code.name.monkey.retromusic.activities.base.AbsBaseActivity import code.name.monkey.retromusic.activities.saf.SAFGuideActivity - import code.name.monkey.retromusic.util.RetroUtil import code.name.monkey.retromusic.util.SAFUtil -import com.afollestad.materialdialogs.LayoutMode import com.afollestad.materialdialogs.MaterialDialog -import com.afollestad.materialdialogs.bottomsheets.BottomSheet import com.afollestad.materialdialogs.list.listItems import com.google.android.material.button.MaterialButton import kotlinx.android.synthetic.main.activity_album_tag_editor.* diff --git a/app/src/main/java/code/name/monkey/retromusic/adapter/CategoryInfoAdapter.java b/app/src/main/java/code/name/monkey/retromusic/adapter/CategoryInfoAdapter.java index 8c169ef6..58d6ce75 100644 --- a/app/src/main/java/code/name/monkey/retromusic/adapter/CategoryInfoAdapter.java +++ b/app/src/main/java/code/name/monkey/retromusic/adapter/CategoryInfoAdapter.java @@ -42,8 +42,7 @@ public class CategoryInfoAdapter extends RecyclerView.Adapter categoryInfos; private ItemTouchHelper touchHelper; - public CategoryInfoAdapter(@NonNull List categoryInfos) { - this.categoryInfos = categoryInfos; + public CategoryInfoAdapter() { SwipeAndDragHelper swipeAndDragHelper = new SwipeAndDragHelper(this); touchHelper = new ItemTouchHelper(swipeAndDragHelper); } diff --git a/app/src/main/java/code/name/monkey/retromusic/appshortcuts/shortcuttype/LastAddedShortcutType.kt b/app/src/main/java/code/name/monkey/retromusic/appshortcuts/shortcuttype/LastAddedShortcutType.kt index b590a943..ef80bc0e 100644 --- a/app/src/main/java/code/name/monkey/retromusic/appshortcuts/shortcuttype/LastAddedShortcutType.kt +++ b/app/src/main/java/code/name/monkey/retromusic/appshortcuts/shortcuttype/LastAddedShortcutType.kt @@ -36,7 +36,8 @@ class LastAddedShortcutType(context: Context) : BaseShortcutType(context) { context, R.drawable.ic_app_shortcut_last_added ) - ).setIntent(getPlaySongsIntent(AppShortcutLauncherActivity.SHORTCUT_TYPE_LAST_ADDED)).build() + ).setIntent(getPlaySongsIntent(AppShortcutLauncherActivity.SHORTCUT_TYPE_LAST_ADDED)) + .build() companion object { diff --git a/app/src/main/java/code/name/monkey/retromusic/appshortcuts/shortcuttype/SearchShortCutType.kt b/app/src/main/java/code/name/monkey/retromusic/appshortcuts/shortcuttype/SearchShortCutType.kt index 60c91883..dfcd55d0 100644 --- a/app/src/main/java/code/name/monkey/retromusic/appshortcuts/shortcuttype/SearchShortCutType.kt +++ b/app/src/main/java/code/name/monkey/retromusic/appshortcuts/shortcuttype/SearchShortCutType.kt @@ -34,7 +34,8 @@ class SearchShortCutType(context: Context) : BaseShortcutType(context) { get() = ShortcutInfo.Builder( context, id - ).setShortLabel(context.getString(R.string.action_search)).setLongLabel(context.getString(R.string.search_hint)).setIcon( + ).setShortLabel(context.getString(R.string.action_search)) + .setLongLabel(context.getString(R.string.search_hint)).setIcon( AppShortcutIconGenerator.generateThemedIcon( context, R.drawable.ic_app_shortcut_search diff --git a/app/src/main/java/code/name/monkey/retromusic/appshortcuts/shortcuttype/ShuffleAllShortcutType.kt b/app/src/main/java/code/name/monkey/retromusic/appshortcuts/shortcuttype/ShuffleAllShortcutType.kt index 8f869d20..dc86fa83 100644 --- a/app/src/main/java/code/name/monkey/retromusic/appshortcuts/shortcuttype/ShuffleAllShortcutType.kt +++ b/app/src/main/java/code/name/monkey/retromusic/appshortcuts/shortcuttype/ShuffleAllShortcutType.kt @@ -34,7 +34,8 @@ class ShuffleAllShortcutType(context: Context) : BaseShortcutType(context) { AppShortcutIconGenerator.generateThemedIcon( context, R.drawable.ic_app_shortcut_shuffle_all ) - ).setIntent(getPlaySongsIntent(AppShortcutLauncherActivity.SHORTCUT_TYPE_SHUFFLE_ALL)).build() + ).setIntent(getPlaySongsIntent(AppShortcutLauncherActivity.SHORTCUT_TYPE_SHUFFLE_ALL)) + .build() companion object { diff --git a/app/src/main/java/code/name/monkey/retromusic/appshortcuts/shortcuttype/TopTracksShortcutType.kt b/app/src/main/java/code/name/monkey/retromusic/appshortcuts/shortcuttype/TopTracksShortcutType.kt index ed274cdd..1317977c 100644 --- a/app/src/main/java/code/name/monkey/retromusic/appshortcuts/shortcuttype/TopTracksShortcutType.kt +++ b/app/src/main/java/code/name/monkey/retromusic/appshortcuts/shortcuttype/TopTracksShortcutType.kt @@ -34,7 +34,8 @@ class TopTracksShortcutType(context: Context) : BaseShortcutType(context) { AppShortcutIconGenerator.generateThemedIcon( context, R.drawable.ic_app_shortcut_top_tracks ) - ).setIntent(getPlaySongsIntent(AppShortcutLauncherActivity.SHORTCUT_TYPE_TOP_TRACKS)).build() + ).setIntent(getPlaySongsIntent(AppShortcutLauncherActivity.SHORTCUT_TYPE_TOP_TRACKS)) + .build() companion object { diff --git a/app/src/main/java/code/name/monkey/retromusic/appwidgets/AppWidgetBig.kt b/app/src/main/java/code/name/monkey/retromusic/appwidgets/AppWidgetBig.kt index 3593369e..4a55376f 100644 --- a/app/src/main/java/code/name/monkey/retromusic/appwidgets/AppWidgetBig.kt +++ b/app/src/main/java/code/name/monkey/retromusic/appwidgets/AppWidgetBig.kt @@ -193,7 +193,8 @@ class AppWidgetBig : BaseAppWidget() { * Link up various button actions using [PendingIntent]. */ private fun linkButtons(context: Context, views: RemoteViews) { - val action = Intent(context, MainActivity::class.java).putExtra(MainActivity.EXPAND_PANEL, true) + val action = + Intent(context, MainActivity::class.java).putExtra(MainActivity.EXPAND_PANEL, true) var pendingIntent: PendingIntent val serviceName = ComponentName(context, MusicService::class.java) diff --git a/app/src/main/java/code/name/monkey/retromusic/dialogs/AddToPlaylistDialog.kt b/app/src/main/java/code/name/monkey/retromusic/dialogs/AddToPlaylistDialog.kt index ed6b4666..659bf59d 100644 --- a/app/src/main/java/code/name/monkey/retromusic/dialogs/AddToPlaylistDialog.kt +++ b/app/src/main/java/code/name/monkey/retromusic/dialogs/AddToPlaylistDialog.kt @@ -21,10 +21,7 @@ import code.name.monkey.retromusic.R import code.name.monkey.retromusic.loaders.PlaylistLoader import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.util.PlaylistsUtil - -import com.afollestad.materialdialogs.LayoutMode import com.afollestad.materialdialogs.MaterialDialog -import com.afollestad.materialdialogs.bottomsheets.BottomSheet import com.afollestad.materialdialogs.list.listItems class AddToPlaylistDialog : DialogFragment() { diff --git a/app/src/main/java/code/name/monkey/retromusic/dialogs/BlacklistFolderChooserDialog.kt b/app/src/main/java/code/name/monkey/retromusic/dialogs/BlacklistFolderChooserDialog.kt index 9af36561..25ace5fa 100644 --- a/app/src/main/java/code/name/monkey/retromusic/dialogs/BlacklistFolderChooserDialog.kt +++ b/app/src/main/java/code/name/monkey/retromusic/dialogs/BlacklistFolderChooserDialog.kt @@ -23,10 +23,7 @@ import android.os.Environment import androidx.core.app.ActivityCompat import androidx.fragment.app.DialogFragment import code.name.monkey.retromusic.R - -import com.afollestad.materialdialogs.LayoutMode import com.afollestad.materialdialogs.MaterialDialog -import com.afollestad.materialdialogs.bottomsheets.BottomSheet import com.afollestad.materialdialogs.list.listItems import java.io.File import java.util.* diff --git a/app/src/main/java/code/name/monkey/retromusic/dialogs/ClearSmartPlaylistDialog.kt b/app/src/main/java/code/name/monkey/retromusic/dialogs/ClearSmartPlaylistDialog.kt index 1b64d6d2..fb9d9fdc 100644 --- a/app/src/main/java/code/name/monkey/retromusic/dialogs/ClearSmartPlaylistDialog.kt +++ b/app/src/main/java/code/name/monkey/retromusic/dialogs/ClearSmartPlaylistDialog.kt @@ -20,10 +20,7 @@ import androidx.core.text.HtmlCompat import androidx.fragment.app.DialogFragment import code.name.monkey.retromusic.R import code.name.monkey.retromusic.model.smartplaylist.AbsSmartPlaylist - -import com.afollestad.materialdialogs.LayoutMode import com.afollestad.materialdialogs.MaterialDialog -import com.afollestad.materialdialogs.bottomsheets.BottomSheet class ClearSmartPlaylistDialog : DialogFragment() { 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 61004621..f14a5ac1 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 @@ -26,10 +26,7 @@ import code.name.monkey.retromusic.R.string import code.name.monkey.retromusic.extensions.appHandleColor import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.util.PlaylistsUtil - -import com.afollestad.materialdialogs.LayoutMode import com.afollestad.materialdialogs.MaterialDialog -import com.afollestad.materialdialogs.bottomsheets.BottomSheet import com.afollestad.materialdialogs.customview.customView import com.afollestad.materialdialogs.customview.getCustomView import com.google.android.material.textfield.TextInputEditText diff --git a/app/src/main/java/code/name/monkey/retromusic/dialogs/DeletePlaylistDialog.kt b/app/src/main/java/code/name/monkey/retromusic/dialogs/DeletePlaylistDialog.kt index ad86ae0f..6ca075f2 100644 --- a/app/src/main/java/code/name/monkey/retromusic/dialogs/DeletePlaylistDialog.kt +++ b/app/src/main/java/code/name/monkey/retromusic/dialogs/DeletePlaylistDialog.kt @@ -22,10 +22,7 @@ import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R.string import code.name.monkey.retromusic.model.Playlist import code.name.monkey.retromusic.util.PlaylistsUtil - -import com.afollestad.materialdialogs.LayoutMode import com.afollestad.materialdialogs.MaterialDialog -import com.afollestad.materialdialogs.bottomsheets.BottomSheet import java.util.* class DeletePlaylistDialog : DialogFragment() { diff --git a/app/src/main/java/code/name/monkey/retromusic/dialogs/DeleteSongsDialog.kt b/app/src/main/java/code/name/monkey/retromusic/dialogs/DeleteSongsDialog.kt index ef6bb1cd..0601acf4 100644 --- a/app/src/main/java/code/name/monkey/retromusic/dialogs/DeleteSongsDialog.kt +++ b/app/src/main/java/code/name/monkey/retromusic/dialogs/DeleteSongsDialog.kt @@ -25,15 +25,13 @@ import code.name.monkey.retromusic.activities.saf.SAFGuideActivity import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.util.MusicUtil - import code.name.monkey.retromusic.util.SAFUtil -import com.afollestad.materialdialogs.LayoutMode import com.afollestad.materialdialogs.MaterialDialog -import com.afollestad.materialdialogs.bottomsheets.BottomSheet class DeleteSongsDialog : DialogFragment() { @JvmField var currentSong: Song? = null + @JvmField var songsToRemove: List? = null diff --git a/app/src/main/java/code/name/monkey/retromusic/dialogs/RemoveFromPlaylistDialog.kt b/app/src/main/java/code/name/monkey/retromusic/dialogs/RemoveFromPlaylistDialog.kt index 3cecab48..5d28482e 100644 --- a/app/src/main/java/code/name/monkey/retromusic/dialogs/RemoveFromPlaylistDialog.kt +++ b/app/src/main/java/code/name/monkey/retromusic/dialogs/RemoveFromPlaylistDialog.kt @@ -22,10 +22,7 @@ import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R.string import code.name.monkey.retromusic.model.PlaylistSong import code.name.monkey.retromusic.util.PlaylistsUtil - -import com.afollestad.materialdialogs.LayoutMode import com.afollestad.materialdialogs.MaterialDialog -import com.afollestad.materialdialogs.bottomsheets.BottomSheet class RemoveFromPlaylistDialog : DialogFragment() { diff --git a/app/src/main/java/code/name/monkey/retromusic/dialogs/RenamePlaylistDialog.kt b/app/src/main/java/code/name/monkey/retromusic/dialogs/RenamePlaylistDialog.kt index a0430470..34482502 100644 --- a/app/src/main/java/code/name/monkey/retromusic/dialogs/RenamePlaylistDialog.kt +++ b/app/src/main/java/code/name/monkey/retromusic/dialogs/RenamePlaylistDialog.kt @@ -25,10 +25,7 @@ import code.name.monkey.retromusic.R.layout import code.name.monkey.retromusic.R.string import code.name.monkey.retromusic.extensions.appHandleColor import code.name.monkey.retromusic.util.PlaylistsUtil - -import com.afollestad.materialdialogs.LayoutMode import com.afollestad.materialdialogs.MaterialDialog -import com.afollestad.materialdialogs.bottomsheets.BottomSheet import com.afollestad.materialdialogs.customview.customView import com.afollestad.materialdialogs.customview.getCustomView import com.google.android.material.textfield.TextInputEditText diff --git a/app/src/main/java/code/name/monkey/retromusic/dialogs/SongDetailDialog.kt b/app/src/main/java/code/name/monkey/retromusic/dialogs/SongDetailDialog.kt index 7832fcfd..8fcaf79b 100644 --- a/app/src/main/java/code/name/monkey/retromusic/dialogs/SongDetailDialog.kt +++ b/app/src/main/java/code/name/monkey/retromusic/dialogs/SongDetailDialog.kt @@ -29,10 +29,7 @@ import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R.string import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.util.MusicUtil - -import com.afollestad.materialdialogs.LayoutMode import com.afollestad.materialdialogs.MaterialDialog -import com.afollestad.materialdialogs.bottomsheets.BottomSheet import com.afollestad.materialdialogs.customview.customView import com.afollestad.materialdialogs.customview.getCustomView import org.jaudiotagger.audio.AudioFileIO diff --git a/app/src/main/java/code/name/monkey/retromusic/dialogs/SongShareDialog.kt b/app/src/main/java/code/name/monkey/retromusic/dialogs/SongShareDialog.kt index fd49bd5f..b5bd3c88 100644 --- a/app/src/main/java/code/name/monkey/retromusic/dialogs/SongShareDialog.kt +++ b/app/src/main/java/code/name/monkey/retromusic/dialogs/SongShareDialog.kt @@ -22,10 +22,7 @@ import code.name.monkey.retromusic.R import code.name.monkey.retromusic.activities.ShareInstagramStory import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.util.MusicUtil - -import com.afollestad.materialdialogs.LayoutMode import com.afollestad.materialdialogs.MaterialDialog -import com.afollestad.materialdialogs.bottomsheets.BottomSheet import com.afollestad.materialdialogs.list.listItems class SongShareDialog : DialogFragment() { diff --git a/app/src/main/java/code/name/monkey/retromusic/extensions/DrawableExt.kt b/app/src/main/java/code/name/monkey/retromusic/extensions/DrawableExt.kt index d25742af..dc86fb94 100644 --- a/app/src/main/java/code/name/monkey/retromusic/extensions/DrawableExt.kt +++ b/app/src/main/java/code/name/monkey/retromusic/extensions/DrawableExt.kt @@ -26,9 +26,12 @@ import androidx.annotation.DimenRes import androidx.annotation.DrawableRes import androidx.core.content.ContextCompat import code.name.monkey.retromusic.R -import code.name.monkey.retromusic.util.DensityUtil -fun Context.scaledDrawableResources(@DrawableRes id: Int, @DimenRes width: Int, @DimenRes height: Int): Drawable { +fun Context.scaledDrawableResources( + @DrawableRes id: Int, + @DimenRes width: Int, + @DimenRes height: Int +): Drawable { val w = resources.getDimension(width).toInt() val h = resources.getDimension(height).toInt() return scaledDrawable(id, w, h) diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/albums/AlbumViewModel.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/albums/AlbumViewModel.kt index 7c3260e6..40771a08 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/albums/AlbumViewModel.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/albums/AlbumViewModel.kt @@ -20,7 +20,7 @@ class AlbumViewModel(application: Application) : AndroidViewModel(application) { val result = RepositoryImpl(getApplication()).allAlbums() if (result is Result.Success) { albums.value = result.data - }else { + } else { albums.value = listOf() } } diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsPlayerControlsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsPlayerControlsFragment.kt index 1ae24276..48794563 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsPlayerControlsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsPlayerControlsFragment.kt @@ -64,9 +64,11 @@ abstract class AbsPlayerControlsFragment : AbsMusicServiceFragment(), private fun hideVolumeIfAvailable() { if (PreferenceUtilKT.isVolumeVisibilityMode) { - childFragmentManager.beginTransaction().replace(R.id.volumeFragmentContainer, VolumeFragment()).commit() + childFragmentManager.beginTransaction() + .replace(R.id.volumeFragmentContainer, VolumeFragment()).commit() childFragmentManager.executePendingTransactions() - volumeFragment = childFragmentManager.findFragmentById(R.id.volumeFragmentContainer) as VolumeFragment? + volumeFragment = + childFragmentManager.findFragmentById(R.id.volumeFragmentContainer) as VolumeFragment? } } diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/genres/GenreViewModel.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/genres/GenreViewModel.kt index e737a1a1..4aac159a 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/genres/GenreViewModel.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/genres/GenreViewModel.kt @@ -20,7 +20,7 @@ class GenreViewModel(application: Application) : AndroidViewModel(application) { val result = RepositoryImpl(getApplication()).allGenres() if (result is Success) { genres.value = result.data - }else { + } else { genres.value = listOf() } } diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/blur/BlurPlaybackControlsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/blur/BlurPlaybackControlsFragment.kt index 217b8232..facbe674 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/blur/BlurPlaybackControlsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/blur/BlurPlaybackControlsFragment.kt @@ -25,22 +25,9 @@ import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener import code.name.monkey.retromusic.service.MusicService import code.name.monkey.retromusic.util.MusicUtil - import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.color.MediaNotificationProcessor import kotlinx.android.synthetic.main.fragment_blur_player_playback_controls.* -import kotlinx.android.synthetic.main.fragment_blur_player_playback_controls.nextButton -import kotlinx.android.synthetic.main.fragment_blur_player_playback_controls.playPauseButton -import kotlinx.android.synthetic.main.fragment_blur_player_playback_controls.previousButton -import kotlinx.android.synthetic.main.fragment_blur_player_playback_controls.progressSlider -import kotlinx.android.synthetic.main.fragment_blur_player_playback_controls.repeatButton -import kotlinx.android.synthetic.main.fragment_blur_player_playback_controls.shuffleButton -import kotlinx.android.synthetic.main.fragment_blur_player_playback_controls.songCurrentProgress -import kotlinx.android.synthetic.main.fragment_blur_player_playback_controls.songInfo -import kotlinx.android.synthetic.main.fragment_blur_player_playback_controls.songTotalTime -import kotlinx.android.synthetic.main.fragment_blur_player_playback_controls.text -import kotlinx.android.synthetic.main.fragment_blur_player_playback_controls.title -import kotlinx.android.synthetic.main.fragment_player_playback_controls.* class BlurPlaybackControlsFragment : AbsPlayerControlsFragment() { 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 b84ba5dd..4c323310 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 @@ -19,11 +19,10 @@ import android.graphics.drawable.ColorDrawable import android.os.Bundle import android.view.View 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.common.prefs.supportv7.ATEPreferenceFragmentCompat import code.name.monkey.appthemehelper.util.ATHUtil import code.name.monkey.retromusic.R import code.name.monkey.retromusic.preferences.* @@ -33,7 +32,7 @@ import code.name.monkey.retromusic.util.NavigationUtil * @author Hemanth S (h4h13). */ -abstract class AbsSettingsFragment : ATEPreferenceFragmentCompat() { +abstract class AbsSettingsFragment : PreferenceFragmentCompat() { internal fun showProToastAndNavigate(message: String) { Toast.makeText(requireContext(), "$message is Pro version feature.", Toast.LENGTH_SHORT) @@ -73,16 +72,25 @@ abstract class AbsSettingsFragment : ATEPreferenceFragmentCompat() { invalidateSettings() } - override fun onCreatePreferenceDialog(preference: Preference): DialogFragment? { - return when (preference) { - is LibraryPreference -> LibraryPreferenceDialog.newInstance() - is NowPlayingScreenPreference -> NowPlayingScreenPreferenceDialog.newInstance(preference.key) - is AlbumCoverStylePreference -> AlbumCoverStylePreferenceDialog.newInstance(preference.key) - is MaterialListPreference -> { - MaterialListPreferenceDialog.newInstance(preference) + override fun onDisplayPreferenceDialog(preference: Preference?) { + when (preference) { + is LibraryPreference -> { + val fragment = LibraryPreferenceDialog.newInstance() + fragment.show(childFragmentManager, preference.key) } - is BlacklistPreference -> BlacklistPreferenceDialog.newInstance() - else -> super.onCreatePreferenceDialog(preference) + is NowPlayingScreenPreference -> { + val fragment = NowPlayingScreenPreferenceDialog.newInstance() + fragment.show(childFragmentManager, preference.key) + } + is AlbumCoverStylePreference -> { + val fragment = AlbumCoverStylePreferenceDialog.newInstance() + fragment.show(childFragmentManager, preference.key) + } + is BlacklistPreference -> { + val fragment = BlacklistPreferenceDialog.newInstance() + fragment.show(childFragmentManager, preference.key) + } + else -> super.onDisplayPreferenceDialog(preference) } } } diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/settings/AudioSettings.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/settings/AudioSettings.kt index 92e125bb..be06d30d 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/settings/AudioSettings.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/settings/AudioSettings.kt @@ -29,7 +29,7 @@ import code.name.monkey.retromusic.util.NavigationUtil class AudioSettings : AbsSettingsFragment() { override fun invalidateSettings() { val findPreference: Preference = findPreference("equalizer")!! - if (!hasEqualizer() ) { + if (!hasEqualizer()) { findPreference.isEnabled = false findPreference.summary = resources.getString(R.string.no_equalizer) } else { diff --git a/app/src/main/java/code/name/monkey/retromusic/glide/RetroMusicColoredTarget.kt b/app/src/main/java/code/name/monkey/retromusic/glide/RetroMusicColoredTarget.kt index 6a4d67e3..fb9ad3c9 100644 --- a/app/src/main/java/code/name/monkey/retromusic/glide/RetroMusicColoredTarget.kt +++ b/app/src/main/java/code/name/monkey/retromusic/glide/RetroMusicColoredTarget.kt @@ -34,7 +34,7 @@ abstract class RetroMusicColoredTarget(view: ImageView) : BitmapPaletteTarget(vi override fun onLoadFailed(e: Exception?, errorDrawable: Drawable?) { super.onLoadFailed(e, errorDrawable) - val colors = MediaNotificationProcessor(App.getContext(),errorDrawable) + val colors = MediaNotificationProcessor(App.getContext(), errorDrawable) onColorReady(colors) /* MediaNotificationProcessor(App.getContext()).getPaletteAsync({ onColorReady(it) diff --git a/app/src/main/java/code/name/monkey/retromusic/helper/EqualizerHelper.kt b/app/src/main/java/code/name/monkey/retromusic/helper/EqualizerHelper.kt index 02ed03c4..4bb74e9f 100644 --- a/app/src/main/java/code/name/monkey/retromusic/helper/EqualizerHelper.kt +++ b/app/src/main/java/code/name/monkey/retromusic/helper/EqualizerHelper.kt @@ -99,6 +99,7 @@ class EqualizerHelper private constructor() : EqualizerInterface { companion object { private val TAG = "EqualizerHelper" + @Volatile private var ourInstance: EqualizerHelper? = null diff --git a/app/src/main/java/code/name/monkey/retromusic/helper/SearchQueryHelper.kt b/app/src/main/java/code/name/monkey/retromusic/helper/SearchQueryHelper.kt index 4273931e..1efe9c57 100644 --- a/app/src/main/java/code/name/monkey/retromusic/helper/SearchQueryHelper.kt +++ b/app/src/main/java/code/name/monkey/retromusic/helper/SearchQueryHelper.kt @@ -28,6 +28,7 @@ object SearchQueryHelper { private const val ARTIST_SELECTION = "lower(" + MediaStore.Audio.AudioColumns.ARTIST + ") = ?" private const val AND = " AND " var songs = ArrayList() + @JvmStatic fun getSongs(context: Context, extras: Bundle): ArrayList { val query = extras.getString(SearchManager.QUERY, null) diff --git a/app/src/main/java/code/name/monkey/retromusic/lyrics/LrcView.kt b/app/src/main/java/code/name/monkey/retromusic/lyrics/LrcView.kt index 7cb4babf..9a195139 100644 --- a/app/src/main/java/code/name/monkey/retromusic/lyrics/LrcView.kt +++ b/app/src/main/java/code/name/monkey/retromusic/lyrics/LrcView.kt @@ -35,7 +35,6 @@ import android.view.animation.DecelerateInterpolator import android.widget.OverScroller import androidx.annotation.ColorInt import androidx.core.content.ContextCompat -import androidx.core.content.res.ResourcesCompat import androidx.core.view.ViewCompat import code.name.monkey.retromusic.BuildConfig import code.name.monkey.retromusic.R @@ -216,9 +215,9 @@ class LrcView @JvmOverloads constructor( isAntiAlias = true textAlign = Paint.Align.LEFT textSize = mLrcTextSize - /* if (BuildConfig.FLAVOR != "nofont") { - typeface = ResourcesCompat.getFont(context, R.font.circular) - }*/ + /* if (BuildConfig.FLAVOR != "nofont") { + typeface = ResourcesCompat.getFont(context, R.font.circular) + }*/ } mDefaultContent = DEFAULT_CONTENT diff --git a/app/src/main/java/code/name/monkey/retromusic/preferences/AlbumCoverStylePreferenceDialog.kt b/app/src/main/java/code/name/monkey/retromusic/preferences/AlbumCoverStylePreferenceDialog.kt index dbe09b2a..eed6adee 100644 --- a/app/src/main/java/code/name/monkey/retromusic/preferences/AlbumCoverStylePreferenceDialog.kt +++ b/app/src/main/java/code/name/monkey/retromusic/preferences/AlbumCoverStylePreferenceDialog.kt @@ -27,7 +27,7 @@ import android.widget.TextView import android.widget.Toast import androidx.core.graphics.BlendModeColorFilterCompat import androidx.core.graphics.BlendModeCompat.SRC_IN -import androidx.preference.PreferenceDialogFragmentCompat +import androidx.fragment.app.DialogFragment import androidx.viewpager.widget.PagerAdapter import androidx.viewpager.widget.ViewPager import code.name.monkey.appthemehelper.common.prefs.supportv7.ATEDialogPreference @@ -37,12 +37,10 @@ import code.name.monkey.retromusic.extensions.colorControlNormal import code.name.monkey.retromusic.fragments.AlbumCoverStyle import code.name.monkey.retromusic.fragments.AlbumCoverStyle.* import code.name.monkey.retromusic.util.NavigationUtil - import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.ViewUtil -import com.afollestad.materialdialogs.MaterialDialog -import com.afollestad.materialdialogs.customview.customView import com.bumptech.glide.Glide +import com.google.android.material.dialog.MaterialAlertDialogBuilder class AlbumCoverStylePreference @JvmOverloads constructor( context: Context, @@ -66,10 +64,8 @@ class AlbumCoverStylePreference @JvmOverloads constructor( } } -class AlbumCoverStylePreferenceDialog : PreferenceDialogFragmentCompat(), +class AlbumCoverStylePreferenceDialog : DialogFragment(), ViewPager.OnPageChangeListener { - override fun onDialogClosed(positiveResult: Boolean) { - } private var viewPagerPosition: Int = 0 @@ -83,10 +79,9 @@ class AlbumCoverStylePreferenceDialog : PreferenceDialogFragmentCompat(), viewPager.pageMargin = ViewUtil.convertDpToPixel(32f, resources).toInt() viewPager.currentItem = PreferenceUtilKT.albumCoverStyle.ordinal - return MaterialDialog(requireActivity()).show { - title(R.string.pref_title_album_cover_style) - - positiveButton(R.string.set) { + return MaterialAlertDialogBuilder(requireActivity()) + .setTitle(R.string.pref_title_album_cover_style) + .setPositiveButton(R.string.set) { _, _ -> val coverStyle = values()[viewPagerPosition] if (isAlbumCoverStyle(coverStyle)) { val result = getString(coverStyle.titleRes) + " theme is Pro version feature." @@ -96,9 +91,11 @@ class AlbumCoverStylePreferenceDialog : PreferenceDialogFragmentCompat(), PreferenceUtilKT.albumCoverStyle = coverStyle } } - negativeButton(android.R.string.cancel) - customView(view = view, scrollable = false, noVerticalPadding = false) - } + .setNegativeButton(android.R.string.cancel) { _, _ -> + dismiss() + } + .setView(view) + .create() } override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) { @@ -162,12 +159,8 @@ class AlbumCoverStylePreferenceDialog : PreferenceDialogFragmentCompat(), companion object { val TAG: String = AlbumCoverStylePreferenceDialog::class.java.simpleName - fun newInstance(key: String): AlbumCoverStylePreferenceDialog { - val bundle = Bundle() - bundle.putString(ARG_KEY, key) - val fragment = AlbumCoverStylePreferenceDialog() - fragment.arguments = bundle - return fragment + fun newInstance(): AlbumCoverStylePreferenceDialog { + return AlbumCoverStylePreferenceDialog() } } } diff --git a/app/src/main/java/code/name/monkey/retromusic/preferences/BlacklistPreferenceDialog.kt b/app/src/main/java/code/name/monkey/retromusic/preferences/BlacklistPreferenceDialog.kt index 653cb1ee..ec53c080 100644 --- a/app/src/main/java/code/name/monkey/retromusic/preferences/BlacklistPreferenceDialog.kt +++ b/app/src/main/java/code/name/monkey/retromusic/preferences/BlacklistPreferenceDialog.kt @@ -63,7 +63,6 @@ class BlacklistPreferenceDialog : DialogFragment(), BlacklistFolderChooserDialog refreshBlacklistData() return MaterialDialog(requireContext()).show { title(R.string.blacklist) - positiveButton(android.R.string.ok) { dismiss() } diff --git a/app/src/main/java/code/name/monkey/retromusic/preferences/LibraryPreference.kt b/app/src/main/java/code/name/monkey/retromusic/preferences/LibraryPreference.kt index 794a20e7..e7c91f11 100644 --- a/app/src/main/java/code/name/monkey/retromusic/preferences/LibraryPreference.kt +++ b/app/src/main/java/code/name/monkey/retromusic/preferences/LibraryPreference.kt @@ -14,15 +14,17 @@ package code.name.monkey.retromusic.preferences +import android.annotation.SuppressLint import android.app.Dialog import android.content.Context import android.os.Bundle import android.util.AttributeSet import android.view.LayoutInflater import android.widget.Toast +import androidx.appcompat.app.AlertDialog import androidx.core.graphics.BlendModeColorFilterCompat import androidx.core.graphics.BlendModeCompat.SRC_IN -import androidx.preference.PreferenceDialogFragmentCompat +import androidx.fragment.app.DialogFragment import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import code.name.monkey.appthemehelper.common.prefs.supportv7.ATEDialogPreference @@ -30,60 +32,52 @@ import code.name.monkey.retromusic.R import code.name.monkey.retromusic.adapter.CategoryInfoAdapter import code.name.monkey.retromusic.extensions.colorControlNormal import code.name.monkey.retromusic.model.CategoryInfo - import code.name.monkey.retromusic.util.PreferenceUtilKT -import com.afollestad.materialdialogs.MaterialDialog -import com.afollestad.materialdialogs.customview.customView +import com.google.android.material.dialog.MaterialAlertDialogBuilder + class LibraryPreference @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, - defStyleAttr: Int = -1, - defStyleRes: Int = -1 -) : - ATEDialogPreference(context, attrs, defStyleAttr, defStyleRes) { - + defStyleAttr: Int = 0, + defStyleRes: Int = 0 +) : ATEDialogPreference(context, attrs, defStyleAttr, defStyleRes) { init { - icon?.colorFilter = - BlendModeColorFilterCompat.createBlendModeColorFilterCompat( - context.colorControlNormal(), - SRC_IN - ) + icon?.colorFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat( + context.colorControlNormal(), + SRC_IN + ) } } -class LibraryPreferenceDialog : PreferenceDialogFragmentCompat() { - - override fun onDialogClosed(positiveResult: Boolean) { - } - - lateinit var adapter: CategoryInfoAdapter +class LibraryPreferenceDialog : DialogFragment() { + @SuppressLint("InflateParams") override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { val view = LayoutInflater.from(requireContext()) .inflate(R.layout.preference_dialog_library_categories, null) - adapter = CategoryInfoAdapter(PreferenceUtilKT.libraryCategory) + val categoryAdapter = CategoryInfoAdapter() + categoryAdapter.categoryInfos = PreferenceUtilKT.libraryCategory val recyclerView = view.findViewById(R.id.recycler_view) recyclerView.layoutManager = LinearLayoutManager(activity) - recyclerView.adapter = adapter + recyclerView.adapter = categoryAdapter + categoryAdapter.attachToRecyclerView(recyclerView) - adapter.attachToRecyclerView(recyclerView) - return MaterialDialog(requireContext()) - .title(R.string.library_categories) - .customView(view = view) - .positiveButton(android.R.string.ok) { - updateCategories(adapter.categoryInfos) - dismiss() + return MaterialAlertDialogBuilder(requireContext()) + .setTitle(R.string.library_categories) + .setNeutralButton( + R.string.reset_action + ) { _, _ -> + categoryAdapter.categoryInfos = PreferenceUtilKT.defaultCategories } - .negativeButton(android.R.string.cancel) { - dismiss() - } - .neutralButton(R.string.reset_action) { - adapter.categoryInfos = PreferenceUtilKT.defaultCategories - } - .noAutoDismiss() + .setNegativeButton(android.R.string.cancel, null) + .setPositiveButton( + android.R.string.ok + ) { _, _ -> updateCategories(categoryAdapter.categoryInfos) } + .setView(view) + .create() } private fun updateCategories(categories: List) { diff --git a/app/src/main/java/code/name/monkey/retromusic/preferences/NowPlayingScreenPreferenceDialog.kt b/app/src/main/java/code/name/monkey/retromusic/preferences/NowPlayingScreenPreferenceDialog.kt index cafcf34e..aaf000c2 100644 --- a/app/src/main/java/code/name/monkey/retromusic/preferences/NowPlayingScreenPreferenceDialog.kt +++ b/app/src/main/java/code/name/monkey/retromusic/preferences/NowPlayingScreenPreferenceDialog.kt @@ -26,7 +26,7 @@ import android.widget.TextView import android.widget.Toast import androidx.core.graphics.BlendModeColorFilterCompat import androidx.core.graphics.BlendModeCompat.SRC_IN -import androidx.preference.PreferenceDialogFragmentCompat +import androidx.fragment.app.DialogFragment import androidx.viewpager.widget.PagerAdapter import androidx.viewpager.widget.ViewPager import code.name.monkey.appthemehelper.common.prefs.supportv7.ATEDialogPreference @@ -38,9 +38,8 @@ import code.name.monkey.retromusic.fragments.NowPlayingScreen.* import code.name.monkey.retromusic.util.NavigationUtil import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.ViewUtil -import com.afollestad.materialdialogs.MaterialDialog -import com.afollestad.materialdialogs.customview.customView import com.bumptech.glide.Glide +import com.google.android.material.dialog.MaterialAlertDialogBuilder class NowPlayingScreenPreference @JvmOverloads constructor( context: Context, @@ -63,8 +62,7 @@ class NowPlayingScreenPreference @JvmOverloads constructor( } } -class NowPlayingScreenPreferenceDialog : PreferenceDialogFragmentCompat(), - ViewPager.OnPageChangeListener { +class NowPlayingScreenPreferenceDialog : DialogFragment(), ViewPager.OnPageChangeListener { private var viewPagerPosition: Int = 0 @@ -78,9 +76,6 @@ class NowPlayingScreenPreferenceDialog : PreferenceDialogFragmentCompat(), this.viewPagerPosition = position } - override fun onDialogClosed(positiveResult: Boolean) { - } - override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { val view = LayoutInflater.from(requireContext()) .inflate(R.layout.preference_dialog_now_playing_screen, null) @@ -91,7 +86,23 @@ class NowPlayingScreenPreferenceDialog : PreferenceDialogFragmentCompat(), viewPager.pageMargin = ViewUtil.convertDpToPixel(32f, resources).toInt() viewPager.currentItem = PreferenceUtilKT.nowPlayingScreen.ordinal - return MaterialDialog(requireContext()).show { + return MaterialAlertDialogBuilder(requireContext()) + .setTitle(R.string.pref_title_now_playing_screen_appearance) + .setCancelable(false) + .setPositiveButton(R.string.set) { _, _ -> + 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() + NavigationUtil.goToProVersion(requireContext()) + } else { + PreferenceUtilKT.nowPlayingScreen = nowPlayingScreen + } + } + .setView(view) + .create() + /*.show { title(R.string.pref_title_now_playing_screen_appearance) positiveButton(R.string.set) { val nowPlayingScreen = values()[viewPagerPosition] @@ -107,16 +118,12 @@ class NowPlayingScreenPreferenceDialog : PreferenceDialogFragmentCompat(), negativeButton(android.R.string.cancel) customView(view = view, scrollable = false, noVerticalPadding = false) - } + }*/ } companion object { - fun newInstance(key: String): NowPlayingScreenPreferenceDialog { - val bundle = Bundle() - bundle.putString(ARG_KEY, key) - val fragment = NowPlayingScreenPreferenceDialog() - fragment.arguments = bundle - return fragment + fun newInstance(): NowPlayingScreenPreferenceDialog { + return NowPlayingScreenPreferenceDialog() } } } diff --git a/app/src/main/java/code/name/monkey/retromusic/util/AppRater.kt b/app/src/main/java/code/name/monkey/retromusic/util/AppRater.kt index c8c5859a..4c31a4a4 100644 --- a/app/src/main/java/code/name/monkey/retromusic/util/AppRater.kt +++ b/app/src/main/java/code/name/monkey/retromusic/util/AppRater.kt @@ -20,11 +20,9 @@ import android.content.SharedPreferences import android.graphics.Color import android.net.Uri import code.name.monkey.retromusic.R -import com.afollestad.materialdialogs.LayoutMode import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.WhichButton import com.afollestad.materialdialogs.actions.getActionButton -import com.afollestad.materialdialogs.bottomsheets.BottomSheet object AppRater { private const val DO_NOT_SHOW_AGAIN = "do_not_show_again"// Package Name @@ -34,6 +32,7 @@ object AppRater { private const val DAYS_UNTIL_PROMPT = 3//Min number of days private const val LAUNCHES_UNTIL_PROMPT = 5//Min number of launches + @JvmStatic fun appLaunched(context: Context) { val prefs = context.getSharedPreferences(APP_RATING, 0) diff --git a/app/src/main/java/code/name/monkey/retromusic/util/PremiumShow.kt b/app/src/main/java/code/name/monkey/retromusic/util/PremiumShow.kt index 32adff22..e85870d7 100644 --- a/app/src/main/java/code/name/monkey/retromusic/util/PremiumShow.kt +++ b/app/src/main/java/code/name/monkey/retromusic/util/PremiumShow.kt @@ -10,6 +10,7 @@ object PremiumShow { private const val PREF_NAME = "premium_show" private const val LAUNCH_COUNT = "launch_count" private const val DATE_FIRST_LAUNCH = "date_first_launch" + @JvmStatic fun launch(context: Context) { val pref = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE) diff --git a/app/src/main/java/code/name/monkey/retromusic/util/RingtoneManager.kt b/app/src/main/java/code/name/monkey/retromusic/util/RingtoneManager.kt index 119401f2..6d99d0bb 100644 --- a/app/src/main/java/code/name/monkey/retromusic/util/RingtoneManager.kt +++ b/app/src/main/java/code/name/monkey/retromusic/util/RingtoneManager.kt @@ -26,9 +26,7 @@ import android.widget.Toast import code.name.monkey.retromusic.R import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.util.MusicUtil.getSongFileUri -import com.afollestad.materialdialogs.LayoutMode import com.afollestad.materialdialogs.MaterialDialog -import com.afollestad.materialdialogs.bottomsheets.BottomSheet class RingtoneManager(val context: Context) { fun setRingtone(song: Song) { diff --git a/app/src/main/java/code/name/monkey/retromusic/util/ViewUtil.kt b/app/src/main/java/code/name/monkey/retromusic/util/ViewUtil.kt index b256915d..d20338fb 100644 --- a/app/src/main/java/code/name/monkey/retromusic/util/ViewUtil.kt +++ b/app/src/main/java/code/name/monkey/retromusic/util/ViewUtil.kt @@ -41,7 +41,8 @@ object ViewUtil { if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP_MR1) { val layerDrawable = progressSlider.progressDrawable as LayerDrawable val progressDrawable = layerDrawable.findDrawableByLayerId(android.R.id.progress) - progressDrawable.colorFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(newColor, SRC_IN) + progressDrawable.colorFilter = + BlendModeColorFilterCompat.createBlendModeColorFilterCompat(newColor, SRC_IN) } else { progressSlider.progressTintList = ColorStateList.valueOf(newColor) } diff --git a/app/src/main/java/code/name/monkey/retromusic/views/PopupBackground.java b/app/src/main/java/code/name/monkey/retromusic/views/PopupBackground.java index 36b6aac9..88b930c7 100644 --- a/app/src/main/java/code/name/monkey/retromusic/views/PopupBackground.java +++ b/app/src/main/java/code/name/monkey/retromusic/views/PopupBackground.java @@ -118,7 +118,7 @@ public class PopupBackground extends Drawable { updatePath(); return true; } - + @Override protected void onBoundsChange(@NonNull Rect bounds) { diff --git a/app/src/main/res/drawable-anydpi-v24/ic_notification.xml b/app/src/main/res/drawable-anydpi-v24/ic_notification.xml index 4dbbe7f3..5f83d481 100644 --- a/app/src/main/res/drawable-anydpi-v24/ic_notification.xml +++ b/app/src/main/res/drawable-anydpi-v24/ic_notification.xml @@ -4,10 +4,11 @@ android:viewportWidth="26.086956" android:viewportHeight="26.086956" android:tint="#FFFFFF"> - - - + + + diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml index 33f5953d..da4d42d6 100644 --- a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -4,55 +4,68 @@ android:height="108dp" android:viewportWidth="921.0526" android:viewportHeight="921.0526"> - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_check_circle_white_24dp.xml b/app/src/main/res/drawable/ic_check_circle_white_24dp.xml index 7cdc15de..5ab22cc6 100644 --- a/app/src/main/res/drawable/ic_check_circle_white_24dp.xml +++ b/app/src/main/res/drawable/ic_check_circle_white_24dp.xml @@ -1,5 +1,10 @@ - - + + diff --git a/app/src/main/res/drawable/ic_expand_less_white_24dp.xml b/app/src/main/res/drawable/ic_expand_less_white_24dp.xml index 5042d801..076afd8b 100644 --- a/app/src/main/res/drawable/ic_expand_less_white_24dp.xml +++ b/app/src/main/res/drawable/ic_expand_less_white_24dp.xml @@ -1,5 +1,10 @@ - - + + diff --git a/app/src/main/res/drawable/ic_invert_colors_white_24dp.xml b/app/src/main/res/drawable/ic_invert_colors_white_24dp.xml index e4002361..ff8356e2 100644 --- a/app/src/main/res/drawable/ic_invert_colors_white_24dp.xml +++ b/app/src/main/res/drawable/ic_invert_colors_white_24dp.xml @@ -1,5 +1,10 @@ - - + + diff --git a/app/src/main/res/drawable/ic_retro_music_icon.xml b/app/src/main/res/drawable/ic_retro_music_icon.xml index 059ba1c2..4c3025df 100644 --- a/app/src/main/res/drawable/ic_retro_music_icon.xml +++ b/app/src/main/res/drawable/ic_retro_music_icon.xml @@ -4,52 +4,64 @@ android:height="350dp" android:viewportWidth="276" android:viewportHeight="350"> - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/fragment_home_player.xml b/app/src/main/res/layout/fragment_home_player.xml index 397147ce..d99613cc 100644 --- a/app/src/main/res/layout/fragment_home_player.xml +++ b/app/src/main/res/layout/fragment_home_player.xml @@ -67,6 +67,7 @@ app:layout_constraintEnd_toEndOf="parent" tools:text="@tools:sample/full_names" tools:textColor="@color/md_black_1000" /> + + tools:text="@tools:sample/full_names" /> + tools:text="@tools:sample/full_names" /> diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml index bbd3e021..eca70cfe 100644 --- a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -1,5 +1,5 @@ - - + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml index bbd3e021..eca70cfe 100644 --- a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -1,5 +1,5 @@ - - + + \ No newline at end of file diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 74b5ec94..095d7080 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -5,16 +5,19 @@