From 724f743627c5ea912d99de1b285e73cd0a4a9517 Mon Sep 17 00:00:00 2001
From: = <=>
Date: Wed, 26 Feb 2020 22:19:24 +0530
Subject: [PATCH] Code refactor and Flat, Fit, Full, Circle theme toolbar
shadow fixes
---
app/build.gradle | 6 +-
app/src/main/assets/index.html | 5 +-
app/src/main/assets/retro-changelog.html | 2 +-
.../java/code/name/monkey/retromusic/App.kt | 10 +-
.../code/name/monkey/retromusic/Constants.kt | 32 +-
.../retromusic/activities/AboutActivity.kt | 21 +-
.../activities/AlbumDetailsActivity.kt | 43 +-
.../activities/ArtistDetailActivity.kt | 43 +-
.../activities/DriveModeActivity.kt | 27 +-
.../activities/GenreDetailsActivity.kt | 10 +-
.../activities/LicenseActivity.java | 14 +-
.../activities/LockScreenActivity.kt | 13 +-
.../retromusic/activities/LyricsActivity.kt | 29 +-
.../retromusic/activities/MainActivity.java | 67 +--
.../activities/PlayingQueueActivity.kt | 4 +-
.../activities/PlaylistDetailActivity.kt | 9 +-
.../retromusic/activities/PurchaseActivity.kt | 4 +-
.../retromusic/activities/SearchActivity.kt | 26 +-
.../retromusic/activities/SettingsActivity.kt | 9 +-
.../activities/ShareInstagramStory.kt | 19 +-
.../activities/WhatsNewActivity.java | 44 +-
.../base/AbsMusicServiceActivity.kt | 17 +-
.../base/AbsSlidingMusicPanelActivity.kt | 48 +-
.../activities/base/AbsThemeActivity.kt | 11 +-
.../activities/bugreport/BugReportActivity.kt | 16 +-
.../bugreport/model/DeviceInfo.java | 5 +-
.../activities/saf/SAFGuideActivity.java | 5 +-
.../tageditor/AbsTagEditorActivity.kt | 5 +-
.../tageditor/AlbumTagEditorActivity.kt | 19 +-
.../tageditor/SongTagEditorActivity.kt | 23 +-
.../tageditor/WriteTagsAsyncTask.java | 67 ++-
.../adapter/CategoryInfoAdapter.java | 37 +-
.../retromusic/adapter/ContributorAdapter.kt | 1 -
.../adapter/base/AbsMultiSelectAdapter.java | 16 +-
.../adapter/base/MediaEntryViewHolder.java | 5 +-
.../adapter/playlist/PlaylistAdapter.kt | 5 +-
.../adapter/song/AbsOffsetSongAdapter.kt | 3 +-
.../song/OrderablePlaylistSongAdapter.kt | 3 +-
.../adapter/song/PlayingQueueAdapter.kt | 11 +-
.../appshortcuts/AppShortcutIconGenerator.kt | 104 ++--
.../AppShortcutLauncherActivity.kt | 111 ++--
.../appshortcuts/DynamicShortcutManager.kt | 76 +--
.../shortcuttype/BaseShortcutType.kt | 46 +-
.../shortcuttype/LastAddedShortcutType.kt | 35 +-
.../shortcuttype/SearchShortCutType.kt | 31 +-
.../shortcuttype/ShuffleAllShortcutType.kt | 31 +-
.../shortcuttype/TopTracksShortcutType.kt | 31 +-
.../retromusic/appwidgets/AppWidgetBig.kt | 129 ++---
.../retromusic/appwidgets/AppWidgetCard.kt | 402 ++++++-------
.../retromusic/appwidgets/AppWidgetClassic.kt | 25 +-
.../retromusic/appwidgets/AppWidgetSmall.kt | 133 +++--
.../retromusic/appwidgets/AppWidgetText.kt | 249 ++++----
.../retromusic/appwidgets/BootReceiver.kt | 58 +-
.../appwidgets/base/BaseAppWidget.kt | 277 ++++-----
.../retromusic/dagger/MusicComponent.kt | 13 +-
.../dagger/module/PresenterModile.kt | 12 +-
.../retromusic/deezer/DeezerApiService.kt | 2 +-
.../retromusic/dialogs/AddToPlaylistDialog.kt | 7 +-
.../dialogs/BlacklistFolderChooserDialog.kt | 6 +-
.../dialogs/CreatePlaylistDialog.kt | 10 +-
.../dialogs/DeletePlaylistDialog.kt | 2 +-
.../dialogs/DeleteSongsAsyncTask.java | 69 +--
.../retromusic/dialogs/DeleteSongsDialog.kt | 8 +-
.../dialogs/OptionsSheetDialogFragment.kt | 6 +-
.../dialogs/RenamePlaylistDialog.kt | 11 +-
.../retromusic/dialogs/SleepTimerDialog.kt | 12 +-
.../retromusic/dialogs/SongDetailDialog.kt | 24 +-
.../retromusic/dialogs/SongShareDialog.kt | 5 +-
.../retromusic/fragments/AlbumCoverStyle.kt | 10 +-
.../fragments/MiniPlayerFragment.kt | 18 +-
.../retromusic/fragments/VolumeFragment.kt | 14 +-
.../fragments/base/AbsMusicServiceFragment.kt | 5 +-
.../base/AbsPlayerControlsFragment.kt | 9 +-
.../fragments/base/AbsPlayerFragment.kt | 37 +-
.../fragments/mainactivity/AlbumsFragment.kt | 6 +-
.../fragments/mainactivity/ArtistsFragment.kt | 4 +-
.../mainactivity/BannerHomeFragment.kt | 43 +-
.../mainactivity/FoldersFragment.java | 534 +++++++++---------
.../fragments/mainactivity/GenresFragment.kt | 1 +
.../mainactivity/PlayingQueueFragment.kt | 12 +-
.../mainactivity/PlaylistsFragment.kt | 3 +-
.../fragments/mainactivity/SongsFragment.kt | 5 +-
.../player/PlayerAlbumCoverFragment.kt | 11 +-
.../player/adaptive/AdaptiveFragment.kt | 26 +-
.../AdaptivePlaybackControlsFragment.kt | 40 +-
.../blur/BlurPlaybackControlsFragment.kt | 25 +-
.../player/blur/BlurPlayerFragment.kt | 6 +-
.../fragments/player/card/CardFragment.kt | 2 +-
.../card/CardPlaybackControlsFragment.kt | 43 +-
.../player/cardblur/CardBlurFragment.kt | 6 +-
.../CardBlurPlaybackControlsFragment.kt | 27 +-
.../player/circle/CirclePlayerFragment.kt | 30 +-
.../fragments/player/color/ColorFragment.kt | 77 +--
.../fragments/player/fit/FitFragment.kt | 2 +-
.../player/flat/FlatPlayerFragment.kt | 3 +-
.../player/full/FullPlayerFragment.kt | 32 +-
.../LockScreenPlayerControlsFragment.kt | 27 +-
.../player/material/MaterialFragment.kt | 2 +-
.../fragments/player/normal/PlayerFragment.kt | 42 +-
.../player/peak/PeakPlayerFragment.kt | 12 +-
.../player/plain/PlainPlayerFragment.kt | 4 +-
.../simple/SimplePlaybackControlsFragment.kt | 32 +-
.../player/simple/SimplePlayerFragment.kt | 2 +-
.../tiny/TinyPlaybackControlsFragment.kt | 25 +-
.../fragments/settings/AbsSettingsFragment.kt | 14 +-
.../settings/MainSettingsFragment.kt | 41 +-
.../settings/NotificationSettingsFragment.kt | 18 +-
.../settings/NowPlayingSettingsFragment.kt | 3 +-
.../settings/PersonalizeSettingsFragment.kt | 6 +-
.../settings/ThemeSettingsFragment.kt | 18 +-
.../retromusic/glide/AlbumGlideRequest.java | 53 +-
.../retromusic/glide/ArtistGlideRequest.java | 60 +-
.../retromusic/glide/BlurTransformation.kt | 14 +-
.../glide/RetroMusicColoredTarget.kt | 15 +-
.../retromusic/glide/RetroMusicGlideModule.kt | 7 +-
.../retromusic/glide/SongGlideRequest.java | 51 +-
.../glide/artistimage/ArtistImageLoader.kt | 22 +-
.../audiocover/AudioFileCoverLoader.java | 1 -
.../glide/palette/BitmapPaletteWrapper.java | 1 +
.../helper/HorizontalAdapterHelper.kt | 8 +-
.../retromusic/helper/MusicPlayerRemote.kt | 33 +-
.../retromusic/helper/SearchQueryHelper.kt | 32 +-
.../monkey/retromusic/helper/StackBlur.java | 12 +-
.../retromusic/helper/menu/GenreMenuHelper.kt | 2 +-
.../helper/menu/PlaylistMenuHelper.kt | 29 +-
.../retromusic/helper/menu/SongMenuHelper.kt | 3 +-
.../retromusic/helper/menu/SongsMenuHelper.kt | 12 +-
.../monkey/retromusic/loaders/AlbumLoader.kt | 53 +-
.../monkey/retromusic/loaders/ArtistLoader.kt | 4 +-
.../monkey/retromusic/loaders/GenreLoader.kt | 27 +-
.../loaders/LastAddedSongsLoader.kt | 9 +-
.../retromusic/loaders/PlaylistLoader.kt | 2 +-
.../retromusic/loaders/PlaylistSongsLoader.kt | 3 +-
.../monkey/retromusic/loaders/SearchLoader.kt | 2 +-
.../monkey/retromusic/loaders/SongLoader.kt | 2 +-
.../retromusic/loaders/SortedCursor.java | 1 +
.../retromusic/loaders/SortedLongCursor.java | 1 +
.../TopAndRecentlyPlayedTracksLoader.kt | 2 +-
.../monkey/retromusic/lyrics/LrcHelper.java | 8 +-
.../name/monkey/retromusic/lyrics/LrcView.kt | 146 +++--
.../misc/AsyncSearchResultLoader.kt | 3 +-
.../misc/CustomFragmentStatePagerAdapter.java | 8 +-
.../retromusic/misc/DialogAsyncTask.java | 1 +
...teToastMediaScannerCompletionListener.java | 13 +-
.../retromusic/misc/WeakContextAsyncTask.kt | 2 +-
.../retromusic/misc/WrappedAsyncTaskLoader.kt | 2 +-
.../retromusic/model/AbsCustomPlaylist.java | 5 +-
.../name/monkey/retromusic/model/Album.kt | 2 +-
.../name/monkey/retromusic/model/Artist.kt | 2 +-
.../monkey/retromusic/model/CategoryInfo.java | 69 ++-
.../monkey/retromusic/model/Playlist.java | 5 +-
.../monkey/retromusic/model/PlaylistSong.java | 29 +-
.../retromusic/model/lyrics/Lyrics.java | 14 +-
.../model/smartplaylist/AbsSmartPlaylist.java | 2 +
.../model/smartplaylist/HistoryPlaylist.java | 8 +-
.../smartplaylist/LastAddedPlaylist.java | 8 +-
.../smartplaylist/MyTopTracksPlaylist.java | 8 +-
.../smartplaylist/ShuffleAllPlaylist.java | 8 +-
.../mvp/presenter/AlbumDetailsPresenter.kt | 6 +-
.../mvp/presenter/AlbumPresenter.kt | 6 +-
.../mvp/presenter/ArtistDetailsPresenter.kt | 8 +-
.../mvp/presenter/ArtistPresenter.kt | 6 +-
.../mvp/presenter/GenreDetailsPresenter.kt | 6 +-
.../mvp/presenter/GenrePresenter.kt | 6 +-
.../retromusic/mvp/presenter/HomePresenter.kt | 6 +-
.../mvp/presenter/PlaylistPresenter.kt | 6 +-
.../mvp/presenter/PlaylistSongsPresenter.kt | 6 +-
.../mvp/presenter/SearchPresenter.kt | 6 +-
.../retromusic/mvp/presenter/SongPresenter.kt | 6 +-
.../AlbumCoverStylePreferenceDialog.kt | 25 +-
.../preferences/BlacklistPreferenceDialog.kt | 7 +-
.../preferences/LibraryPreference.kt | 20 +-
.../NowPlayingScreenPreferenceDialog.kt | 29 +-
.../retromusic/providers/HistoryStore.java | 1 +
.../providers/MusicPlaybackQueueStore.java | 25 +-
.../retromusic/providers/RepositoryImpl.kt | 29 +-
.../providers/interfaces/Repository.kt | 7 +-
.../retromusic/rest/LastFMRestClient.java | 15 +-
.../retromusic/rest/model/LastFmAlbum.java | 142 +++--
.../retromusic/rest/model/LastFmArtist.java | 71 ++-
.../service/MediaButtonIntentReceiver.kt | 13 +-
.../service/MediaSessionCallback.kt | 5 +-
.../retromusic/service/MediaStoreObserver.kt | 4 +-
.../retromusic/service/MultiPlayer.java | 5 +-
.../retromusic/service/MusicService.java | 363 +++++-------
.../retromusic/service/PlaybackHandler.java | 22 +-
.../retromusic/service/QueueSaveHandler.kt | 4 +-
.../service/ThrottledSeekHandler.kt | 4 +-
.../notification/PlayingNotification.kt | 13 +-
.../notification/PlayingNotificationImpl.kt | 154 +++--
.../notification/PlayingNotificationOreo.kt | 221 +++++---
.../transform/ParallaxPagerTransformer.kt | 1 -
.../retromusic/util/ArtistSignatureUtil.java | 1 +
.../retromusic/util/CustomArtistImageUtil.kt | 99 ++--
.../monkey/retromusic/util/MusicUtil.java | 24 +-
.../retromusic/util/NavigationUtil.java | 25 +-
.../monkey/retromusic/util/PlaylistsUtil.java | 37 +-
.../retromusic/util/PreferenceUtil.java | 82 ++-
.../retromusic/util/RetroColorUtil.java | 2 -
.../monkey/retromusic/util/RetroUtil.java | 11 +-
.../monkey/retromusic/util/RingtoneManager.kt | 12 +-
.../retromusic/util/SwipeAndDragHelper.java | 2 +-
.../monkey/retromusic/util/ThemeManager.kt | 21 +-
.../name/monkey/retromusic/util/ViewUtil.kt | 10 +-
.../views/BaselineGridTextView.java | 5 +-
.../views/BottomNavigationBarTinted.kt | 12 +-
.../retromusic/views/BreadCrumbLayout.java | 250 ++++----
.../retromusic/views/CircularImageView.java | 3 +-
.../retromusic/views/ContributorsView.java | 1 +
.../monkey/retromusic/views/ListItemView.kt | 6 +-
.../views/MetalRecyclerViewPager.kt | 15 +-
.../retromusic/views/PopupBackground.java | 14 +-
...ollingViewOnApplyWindowInsetsListener.java | 1 +
.../name/monkey/retromusic/views/SeekArc.java | 95 ++--
.../volume/AudioVolumeContentObserver.java | 5 +-
.../volume/AudioVolumeObserver.java | 1 +
.../res/drawable-hdpi/default_album_art.webp | Bin 5936 -> 4522 bytes
.../res/drawable-hdpi/default_artist_art.webp | Bin 4062 -> 2692 bytes
.../res/drawable-hdpi/default_audio_art.webp | Bin 2748 -> 1444 bytes
.../res/drawable-mdpi/default_album_art.webp | Bin 3538 -> 2390 bytes
.../res/drawable-mdpi/default_artist_art.webp | Bin 2410 -> 1762 bytes
.../res/drawable-mdpi/default_audio_art.webp | Bin 1546 -> 932 bytes
.../drawable-v21/widget_selector_light.xml | 2 +-
.../res/drawable-xhdpi/default_album_art.webp | Bin 8320 -> 5526 bytes
.../drawable-xhdpi/default_artist_art.webp | Bin 6056 -> 3732 bytes
.../res/drawable-xhdpi/default_audio_art.webp | Bin 4188 -> 1964 bytes
.../drawable-xxhdpi/default_album_art.webp | Bin 14094 -> 9048 bytes
.../drawable-xxhdpi/default_artist_art.webp | Bin 10834 -> 5794 bytes
.../drawable-xxhdpi/default_audio_art.webp | Bin 8136 -> 3252 bytes
.../drawable-xxxhdpi/default_album_art.webp | Bin 21488 -> 12568 bytes
.../drawable-xxxhdpi/default_artist_art.webp | Bin 16950 -> 8084 bytes
.../drawable-xxxhdpi/default_audio_art.webp | Bin 13032 -> 4588 bytes
app/src/main/res/drawable/circle_progress.xml | 40 +-
.../drawable/ic_app_shortcut_background.xml | 4 +-
.../drawable/ic_app_shortcut_shuffle_all.xml | 4 +-
.../drawable/ic_app_shortcut_top_tracks.xml | 4 +-
.../drawable/ic_arrow_forward_white_24dp.xml | 10 +-
.../drawable/ic_bookmark_music_white_24dp.xml | 4 +-
.../drawable/ic_card_giftcard_white_24dp.xml | 3 +-
.../res/drawable/ic_clear_all_black_24dp.xml | 3 +-
.../main/res/drawable/ic_close_white_24dp.xml | 3 +-
.../res/drawable/ic_cookie_white_24dp.xml | 10 +-
.../res/drawable/ic_dashboard_white_24dp.xml | 13 +-
.../drawable/ic_drag_vertical_white_24dp.xml | 4 +-
.../res/drawable/ic_drive_eta_white_24dp.xml | 13 +-
.../main/res/drawable/ic_edit_white_24dp.xml | 3 +-
.../main/res/drawable/ic_flag_white_24dp.xml | 3 +-
.../res/drawable/ic_folder_white_24dp.xml | 3 +-
.../drawable/ic_github_circle_white_24dp.xml | 4 +-
.../res/drawable/ic_guitar_white_24dp.xml | 3 +-
.../main/res/drawable/ic_help_white_24dp.xml | 3 +-
.../drawable/ic_library_add_white_24dp.xml | 3 +-
.../main/res/drawable/ic_mic_white_24dp.xml | 3 +-
app/src/main/res/drawable/ic_person_flat.xml | 32 +-
.../res/drawable/ic_play_arrow_white_24dp.xml | 3 +-
.../main/res/drawable/ic_save_white_24dp.xml | 3 +-
.../res/drawable/ic_search_white_24dp.xml | 13 +-
.../ic_skip_previous_round_white_32dp.xml | 3 +-
.../main/res/drawable/ic_sort_white_24dp.xml | 3 +-
.../main/res/drawable/ic_telegram_white.xml | 10 +-
.../res/drawable/ic_testing_white_24dp.xml | 2 +-
.../res/drawable/ic_twitter_white_24dp.xml | 10 +-
.../res/drawable/ic_volume_up_white_24dp.xml | 3 +-
app/src/main/res/drawable/line_button.xml | 10 +-
app/src/main/res/drawable/shadow_down.xml | 4 +-
.../main/res/drawable/shadow_down_strong.xml | 4 +-
app/src/main/res/drawable/shadow_up.xml | 4 +-
.../main/res/drawable/shadow_up_edited.xml | 4 +-
app/src/main/res/drawable/square_window.xml | 2 +-
app/src/main/res/drawable/widget_selector.xml | 8 +-
.../res/drawable/widget_selector_light.xml | 8 +-
.../main/res/layout-land/activity_album.xml | 6 +-
.../layout-land/activity_album_tag_editor.xml | 4 +-
.../main/res/layout-land/fragment_blur.xml | 2 +-
.../res/layout-land/fragment_card_player.xml | 74 +--
.../layout-land/fragment_circle_player.xml | 2 +-
.../res/layout-xlarge/activity_user_info.xml | 4 +-
app/src/main/res/layout/activity_album.xml | 9 +-
.../res/layout/activity_artist_content.xml | 4 +-
.../res/layout/activity_artist_details.xml | 2 +-
.../main/res/layout/activity_drive_mode.xml | 2 +-
app/src/main/res/layout/activity_license.xml | 2 +-
.../main/res/layout/activity_main_content.xml | 6 +-
.../main/res/layout/app_widget_classic.xml | 164 +++---
app/src/main/res/layout/card_credit.xml | 2 +-
...ment_adaptive_player_playback_controls.xml | 10 +-
.../main/res/layout/fragment_card_player.xml | 66 +--
...fragment_card_player_playback_controls.xml | 2 +-
.../res/layout/fragment_circle_player.xml | 2 +-
...ragment_color_player_playback_controls.xml | 2 +-
app/src/main/res/layout/fragment_fit.xml | 2 +
...fragment_flat_player_playback_controls.xml | 2 +-
.../fragment_main_activity_recycler_view.xml | 2 +-
.../layout/fragment_peak_control_player.xml | 2 +-
app/src/main/res/layout/item_artist_card.xml | 4 +-
app/src/main/res/layout/item_contributor.xml | 2 +-
.../res/layout/item_contributor_header.xml | 6 +-
.../res/layout/item_list_quick_actions.xml | 3 +-
.../main/res/menu/menu_playlist_detail.xml | 2 +-
app/src/main/res/menu/menu_search.xml | 4 +-
.../res/mipmap-anydpi-v26/ic_launcher.xml | 4 +-
.../mipmap-anydpi-v26/ic_launcher_round.xml | 4 +-
app/src/main/res/values/contributor_attrs.xml | 3 +-
app/src/main/res/values/lrc_view_attrs.xml | 3 +-
304 files changed, 3874 insertions(+), 3524 deletions(-)
diff --git a/app/build.gradle b/app/build.gradle
index db468026..c1c507b3 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -15,7 +15,7 @@ proguardDictionaries {
android {
compileSdkVersion 29
buildToolsVersion = '29.0.2'
-
+
defaultConfig {
minSdkVersion 21
targetSdkVersion 29
@@ -24,8 +24,8 @@ android {
vectorDrawables.useSupportLibrary = true
applicationId "code.name.monkey.retromusic"
- versionCode 411
- versionName '3.4.950'
+ versionCode 413
+ versionName '3.4.970'
multiDexEnabled true
diff --git a/app/src/main/assets/index.html b/app/src/main/assets/index.html
index 4d858fba..037d52fa 100644
--- a/app/src/main/assets/index.html
+++ b/app/src/main/assets/index.html
@@ -2,8 +2,8 @@
-
-
diff --git a/app/src/main/assets/retro-changelog.html b/app/src/main/assets/retro-changelog.html
index 2e173e32..8717202f 100644
--- a/app/src/main/assets/retro-changelog.html
+++ b/app/src/main/assets/retro-changelog.html
@@ -1 +1 @@
-
v3.4.950
- Major code refactor for library tabs
- Folder option now in available in tabs
- Improved drive mode page
- Added date modified option to sort songs
- Added toggle bluetooth connection to play on device as soon as it connected
- Fix tablet version of app
- Fix Album and Artist details toolbar full width for better accessibility
v3.4.900
- Added playlist search
- Added Drive mode
- Added Album and Artist layout change option in library
- Added Show more album and artist information in details
- Added Pixel style scroller bar
- Added current now playing share
- Fix font issues and colors in some places
- Improved Full now playing theme
v3.4.850
- Added new theme called circle
- Added tiny color card style for home artists
- Added extra track info details to now playing themes
- Added scroll animation
- Added smooth transition animations 🤔
- Added current playing tab options for Bottom Navigation View
- Added search in genre
- Improved selecting feedback effect(ripple with corners)
- Fix bugs & crashes
- Fix crashing on lyrics
- Fix genre details last song is under mini player
- Fix colors mistakes and font sizes
- Fix slider jumping while scrolling in now playing themes
v3.4.800
- Improved dark theme colors and Follow system theme
- Rounded rectangle ripple for BottomNavigationView
- Follow sleep timer dialog checkbox color as accent
- Added song list selection for Album and Artist details
- Fixed Toolbar popup text color when selecting songs
v3.4.700
- Added splash screen(for app loading time)
- Updated dark theme colors
- Added circular progress view
- Hiding year if not showing
v3.4.600
- Fix notification layout height
- Fix folder list last item not showing
- Added auto hide/ show controls according to first and last item
v3.4.500
- Added peak theme
- Added app rating dialog
- Fix song name scrolling in now playing themes if it's long
- Fix playing queue last item hiding FAB
- Added desaturated color option for dark mode
- Fix slow search loading
- Fix last added slow loading
- Fix home banner toolbar corner
- Fix home crashing when switching between two tabs
- Fix remaining time in playing queue
- Fix font not applied for some components
- Fix crashing on album details sorting
- Fixed lot of internal bugs
- Fix dialog expand
- Fix list card color
- Removed SlidingUpPanel to replace with BottomSheet
- Removed color theme as per material design guidelines
- Removed classic theme(We're bringing back)
- Replace line switch to Material Switch in settings
- Performance improved
- Updated internal libraries
- Updated translation
- Limiting the use of Theme engine for making use of system colors
- Change home icon from the user icon
- Corrected all toolbar with elevation when scrolling
If you see entire app white or dark or black select same theme in settings to fix
FAQ's
*If you face any UI related issues you clear app data and cache, if its
not working try to
uninstall and install again.
\ No newline at end of file
+
v3.4.970
- Updated internal libraries
- Added default cover with accent color
- Major code refactor for library tabs
- Folder option now in available in tabs
- Improved drive mode page
- Added date modified option to sort songs
- Added toggle bluetooth connection to play on device as soon as it connected
- Fix tablet version of app
- Fix Album and Artist details toolbar full width for better accessibility
v3.4.900
- Added playlist search
- Added Drive mode
- Added Album and Artist layout change option in library
- Added Show more album and artist information in details
- Added Pixel style scroller bar
- Added current now playing share
- Fix font issues and colors in some places
- Improved Full now playing theme
v3.4.850
- Added new theme called circle
- Added tiny color card style for home artists
- Added extra track info details to now playing themes
- Added scroll animation
- Added smooth transition animations 🤔
- Added current playing tab options for Bottom Navigation View
- Added search in genre
- Improved selecting feedback effect(ripple with corners)
- Fix bugs & crashes
- Fix crashing on lyrics
- Fix genre details last song is under mini player
- Fix colors mistakes and font sizes
- Fix slider jumping while scrolling in now playing themes
v3.4.800
- Improved dark theme colors and Follow system theme
- Rounded rectangle ripple for BottomNavigationView
- Follow sleep timer dialog checkbox color as accent
- Added song list selection for Album and Artist details
- Fixed Toolbar popup text color when selecting songs
v3.4.700
- Added splash screen(for app loading time)
- Updated dark theme colors
- Added circular progress view
- Hiding year if not showing
v3.4.600
- Fix notification layout height
- Fix folder list last item not showing
- Added auto hide/ show controls according to first and last item
v3.4.500
- Added peak theme
- Added app rating dialog
- Fix song name scrolling in now playing themes if it's long
- Fix playing queue last item hiding FAB
- Added desaturated color option for dark mode
- Fix slow search loading
- Fix last added slow loading
- Fix home banner toolbar corner
- Fix home crashing when switching between two tabs
- Fix remaining time in playing queue
- Fix font not applied for some components
- Fix crashing on album details sorting
- Fixed lot of internal bugs
- Fix dialog expand
- Fix list card color
- Removed SlidingUpPanel to replace with BottomSheet
- Removed color theme as per material design guidelines
- Removed classic theme(We're bringing back)
- Replace line switch to Material Switch in settings
- Performance improved
- Updated internal libraries
- Updated translation
- Limiting the use of Theme engine for making use of system colors
- Change home icon from the user icon
- Corrected all toolbar with elevation when scrolling
If you see entire app white or dark or black select same theme in settings to fix
FAQ's
*If you face any UI related issues you clear app data and cache, if its
not working try to
uninstall and install again.
\ No newline at end of file
diff --git a/app/src/main/java/code/name/monkey/retromusic/App.kt b/app/src/main/java/code/name/monkey/retromusic/App.kt
index e00eeb31..afabc12b 100644
--- a/app/src/main/java/code/name/monkey/retromusic/App.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/App.kt
@@ -51,7 +51,11 @@ class App : MultiDexApplication() {
override fun onProductPurchased(productId: String, details: TransactionDetails?) {}
override fun onPurchaseHistoryRestored() {
- Toast.makeText(this@App, R.string.restored_previous_purchase_please_restart, Toast.LENGTH_LONG)
+ Toast.makeText(
+ this@App,
+ R.string.restored_previous_purchase_please_restart,
+ Toast.LENGTH_LONG
+ )
.show()
}
@@ -79,7 +83,9 @@ class App : MultiDexApplication() {
}
fun isProVersion(): Boolean {
- return BuildConfig.DEBUG || instance?.billingProcessor!!.isPurchased(PRO_VERSION_PRODUCT_ID)
+ return BuildConfig.DEBUG || instance?.billingProcessor!!.isPurchased(
+ PRO_VERSION_PRODUCT_ID
+ )
}
lateinit var musicComponent: MusicComponent
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 3da9b547..0b3c6fa9 100644
--- a/app/src/main/java/code/name/monkey/retromusic/Constants.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/Constants.kt
@@ -19,7 +19,8 @@ import android.provider.MediaStore
object Constants {
- const val RATE_ON_GOOGLE_PLAY = "https://play.google.com/store/apps/details?id=code.name.monkey.retromusic"
+ const val RATE_ON_GOOGLE_PLAY =
+ "https://play.google.com/store/apps/details?id=code.name.monkey.retromusic"
const val TRANSLATE = "http://monkeycodeapp.oneskyapp.com/collaboration/project?id=238534"
const val GITHUB_PROJECT = "https://github.com/h4h13/RetroMusicPlayer"
const val TELEGRAM_CHANGE_LOG = "https://t.me/retromusiclog"
@@ -31,19 +32,22 @@ object Constants {
const val FAQ_LINK = "https://github.com/h4h13/RetroMusicPlayer/blob/master/FAQ.md"
const val PINTEREST = "https://in.pinterest.com/retromusicapp/"
- const val BASE_SELECTION = MediaStore.Audio.AudioColumns.IS_MUSIC + "=1" + " AND " + MediaStore.Audio.AudioColumns.TITLE + " != ''"
+ const val BASE_SELECTION =
+ MediaStore.Audio.AudioColumns.IS_MUSIC + "=1" + " AND " + MediaStore.Audio.AudioColumns.TITLE + " != ''"
- val baseProjection = arrayOf(BaseColumns._ID, // 0
- MediaStore.Audio.AudioColumns.TITLE, // 1
- MediaStore.Audio.AudioColumns.TRACK, // 2
- MediaStore.Audio.AudioColumns.YEAR, // 3
- MediaStore.Audio.AudioColumns.DURATION, // 4
- MediaStore.Audio.AudioColumns.DATA, // 5
- MediaStore.Audio.AudioColumns.DATE_MODIFIED, // 6
- MediaStore.Audio.AudioColumns.ALBUM_ID, // 7
- MediaStore.Audio.AudioColumns.ALBUM, // 8
- MediaStore.Audio.AudioColumns.ARTIST_ID, // 9
- MediaStore.Audio.AudioColumns.ARTIST,// 10
- MediaStore.Audio.AudioColumns.COMPOSER)// 11
+ val baseProjection = arrayOf(
+ BaseColumns._ID, // 0
+ MediaStore.Audio.AudioColumns.TITLE, // 1
+ MediaStore.Audio.AudioColumns.TRACK, // 2
+ MediaStore.Audio.AudioColumns.YEAR, // 3
+ MediaStore.Audio.AudioColumns.DURATION, // 4
+ MediaStore.Audio.AudioColumns.DATA, // 5
+ MediaStore.Audio.AudioColumns.DATE_MODIFIED, // 6
+ MediaStore.Audio.AudioColumns.ALBUM_ID, // 7
+ MediaStore.Audio.AudioColumns.ALBUM, // 8
+ MediaStore.Audio.AudioColumns.ARTIST_ID, // 9
+ MediaStore.Audio.AudioColumns.ARTIST,// 10
+ MediaStore.Audio.AudioColumns.COMPOSER
+ )// 11
const val NUMBER_OF_TOP_TRACKS = 99
}
diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/AboutActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/AboutActivity.kt
index 21e44354..bc1b8506 100644
--- a/app/src/main/java/code/name/monkey/retromusic/activities/AboutActivity.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/activities/AboutActivity.kt
@@ -32,22 +32,11 @@ import com.afollestad.materialdialogs.bottomsheets.BottomSheet
import com.afollestad.materialdialogs.list.listItems
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
-import kotlinx.android.synthetic.main.activity_about.toolbar
-import kotlinx.android.synthetic.main.card_credit.recyclerView
-import kotlinx.android.synthetic.main.card_other.changelog
-import kotlinx.android.synthetic.main.card_other.openSource
-import kotlinx.android.synthetic.main.card_other.version
-import kotlinx.android.synthetic.main.card_retro_info.appGithub
-import kotlinx.android.synthetic.main.card_retro_info.appRate
-import kotlinx.android.synthetic.main.card_retro_info.appShare
-import kotlinx.android.synthetic.main.card_retro_info.appTranslation
-import kotlinx.android.synthetic.main.card_retro_info.bugReportLink
-import kotlinx.android.synthetic.main.card_retro_info.donateLink
-import kotlinx.android.synthetic.main.card_retro_info.faqLink
-import kotlinx.android.synthetic.main.card_social.instagramLink
-import kotlinx.android.synthetic.main.card_social.pinterestLink
-import kotlinx.android.synthetic.main.card_social.telegramLink
-import kotlinx.android.synthetic.main.card_social.twitterLink
+import kotlinx.android.synthetic.main.activity_about.*
+import kotlinx.android.synthetic.main.card_credit.*
+import kotlinx.android.synthetic.main.card_other.*
+import kotlinx.android.synthetic.main.card_retro_info.*
+import kotlinx.android.synthetic.main.card_social.*
import java.io.IOException
import java.nio.charset.StandardCharsets
diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/AlbumDetailsActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/AlbumDetailsActivity.kt
index 02466a3f..569ffc73 100644
--- a/app/src/main/java/code/name/monkey/retromusic/activities/AlbumDetailsActivity.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/activities/AlbumDetailsActivity.kt
@@ -30,7 +30,6 @@ import code.name.monkey.retromusic.extensions.show
import code.name.monkey.retromusic.glide.AlbumGlideRequest
import code.name.monkey.retromusic.glide.ArtistGlideRequest
import code.name.monkey.retromusic.glide.RetroMusicColoredTarget
-import code.name.monkey.retromusic.glide.SongGlideRequest
import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.helper.SortOrder.AlbumSongSortOrder
import code.name.monkey.retromusic.interfaces.CabHolder
@@ -39,31 +38,12 @@ import code.name.monkey.retromusic.model.Artist
import code.name.monkey.retromusic.mvp.presenter.AlbumDetailsPresenter
import code.name.monkey.retromusic.mvp.presenter.AlbumDetailsView
import code.name.monkey.retromusic.rest.model.LastFmAlbum
-import code.name.monkey.retromusic.util.MusicUtil
-import code.name.monkey.retromusic.util.NavigationUtil
-import code.name.monkey.retromusic.util.PreferenceUtil
-import code.name.monkey.retromusic.util.RetroColorUtil
-import code.name.monkey.retromusic.util.RetroUtil
+import code.name.monkey.retromusic.util.*
import com.afollestad.materialcab.MaterialCab
import com.bumptech.glide.Glide
-import kotlinx.android.synthetic.main.activity_album.albumCoverContainer
-import kotlinx.android.synthetic.main.activity_album.albumText
-import kotlinx.android.synthetic.main.activity_album.albumTitle
-import kotlinx.android.synthetic.main.activity_album.image
-import kotlinx.android.synthetic.main.activity_album.toolbar
-import kotlinx.android.synthetic.main.activity_album_content.aboutAlbumText
-import kotlinx.android.synthetic.main.activity_album_content.aboutAlbumTitle
-import kotlinx.android.synthetic.main.activity_album_content.listeners
-import kotlinx.android.synthetic.main.activity_album_content.listenersLabel
-import kotlinx.android.synthetic.main.activity_album_content.moreRecyclerView
-import kotlinx.android.synthetic.main.activity_album_content.moreTitle
-import kotlinx.android.synthetic.main.activity_album_content.playAction
-import kotlinx.android.synthetic.main.activity_album_content.recyclerView
-import kotlinx.android.synthetic.main.activity_album_content.scrobbles
-import kotlinx.android.synthetic.main.activity_album_content.scrobblesLabel
-import kotlinx.android.synthetic.main.activity_album_content.shuffleAction
-import kotlinx.android.synthetic.main.activity_album_content.songTitle
-import java.util.ArrayList
+import kotlinx.android.synthetic.main.activity_album.*
+import kotlinx.android.synthetic.main.activity_album_content.*
+import java.util.*
import javax.inject.Inject
import android.util.Pair as UtilPair
@@ -127,7 +107,8 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C
if (intent.extras!!.containsKey(EXTRA_ALBUM_ID)) {
intent.extras?.getInt(EXTRA_ALBUM_ID)?.let {
albumDetailsPresenter.loadAlbum(it)
- albumCoverContainer?.transitionName = "${getString(R.string.transition_album_art)}_$it"
+ albumCoverContainer?.transitionName =
+ "${getString(R.string.transition_album_art)}_$it"
}
} else {
finish()
@@ -357,7 +338,8 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C
R.id.action_sort_order_title -> sortOrder = AlbumSongSortOrder.SONG_A_Z
R.id.action_sort_order_title_desc -> sortOrder = AlbumSongSortOrder.SONG_Z_A
R.id.action_sort_order_track_list -> sortOrder = AlbumSongSortOrder.SONG_TRACK_LIST
- R.id.action_sort_order_artist_song_duration -> sortOrder = AlbumSongSortOrder.SONG_DURATION
+ R.id.action_sort_order_artist_song_duration -> sortOrder =
+ AlbumSongSortOrder.SONG_DURATION
}
if (sortOrder != null) {
item.isChecked = true
@@ -368,9 +350,12 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C
private fun setUpSortOrderMenu(sortOrder: SubMenu) {
when (savedSortOrder) {
- AlbumSongSortOrder.SONG_A_Z -> sortOrder.findItem(R.id.action_sort_order_title).isChecked = true
- AlbumSongSortOrder.SONG_Z_A -> sortOrder.findItem(R.id.action_sort_order_title_desc).isChecked = true
- AlbumSongSortOrder.SONG_TRACK_LIST -> sortOrder.findItem(R.id.action_sort_order_track_list).isChecked =
+ AlbumSongSortOrder.SONG_A_Z -> sortOrder.findItem(R.id.action_sort_order_title)
+ .isChecked = true
+ AlbumSongSortOrder.SONG_Z_A -> sortOrder.findItem(R.id.action_sort_order_title_desc)
+ .isChecked = true
+ AlbumSongSortOrder.SONG_TRACK_LIST -> sortOrder.findItem(R.id.action_sort_order_track_list)
+ .isChecked =
true
AlbumSongSortOrder.SONG_DURATION -> sortOrder.findItem(R.id.action_sort_order_artist_song_duration)
.isChecked = true
diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/ArtistDetailActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/ArtistDetailActivity.kt
index 30a80ee0..8575ce82 100755
--- a/app/src/main/java/code/name/monkey/retromusic/activities/ArtistDetailActivity.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/activities/ArtistDetailActivity.kt
@@ -33,32 +33,14 @@ import code.name.monkey.retromusic.model.Artist
import code.name.monkey.retromusic.mvp.presenter.ArtistDetailsPresenter
import code.name.monkey.retromusic.mvp.presenter.ArtistDetailsView
import code.name.monkey.retromusic.rest.model.LastFmArtist
-import code.name.monkey.retromusic.util.CustomArtistImageUtil
-import code.name.monkey.retromusic.util.MusicUtil
-import code.name.monkey.retromusic.util.PreferenceUtil
-import code.name.monkey.retromusic.util.RetroColorUtil
-import code.name.monkey.retromusic.util.RetroUtil
+import code.name.monkey.retromusic.util.*
import com.afollestad.materialcab.MaterialCab
import com.bumptech.glide.Glide
-import kotlinx.android.synthetic.main.activity_artist_content.albumRecyclerView
-import kotlinx.android.synthetic.main.activity_artist_content.albumTitle
-import kotlinx.android.synthetic.main.activity_artist_content.biographyText
-import kotlinx.android.synthetic.main.activity_artist_content.biographyTitle
-import kotlinx.android.synthetic.main.activity_artist_content.listeners
-import kotlinx.android.synthetic.main.activity_artist_content.listenersLabel
-import kotlinx.android.synthetic.main.activity_artist_content.playAction
-import kotlinx.android.synthetic.main.activity_artist_content.recyclerView
-import kotlinx.android.synthetic.main.activity_artist_content.scrobbles
-import kotlinx.android.synthetic.main.activity_artist_content.scrobblesLabel
-import kotlinx.android.synthetic.main.activity_artist_content.shuffleAction
-import kotlinx.android.synthetic.main.activity_artist_content.songTitle
-import kotlinx.android.synthetic.main.activity_artist_details.artistCoverContainer
-import kotlinx.android.synthetic.main.activity_artist_details.artistTitle
-import kotlinx.android.synthetic.main.activity_artist_details.image
-import kotlinx.android.synthetic.main.activity_artist_details.text
-import kotlinx.android.synthetic.main.activity_artist_details.toolbar
-import java.util.Locale
+import kotlinx.android.synthetic.main.activity_artist_content.*
+import kotlinx.android.synthetic.main.activity_artist_details.*
+import java.util.*
import javax.inject.Inject
+import kotlin.collections.ArrayList
class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailsView, CabHolder {
override fun openCab(menuRes: Int, callback: MaterialCab.Callback): MaterialCab {
@@ -238,8 +220,10 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailsView,
scrobbles.show()
scrobblesLabel.show()
- listeners.text = RetroUtil.formatValue(lastFmArtist.artist.stats.listeners.toFloat())
- scrobbles.text = RetroUtil.formatValue(lastFmArtist.artist.stats.playcount.toFloat())
+ listeners.text =
+ RetroUtil.formatValue(lastFmArtist.artist.stats.listeners.toFloat())
+ scrobbles.text =
+ RetroUtil.formatValue(lastFmArtist.artist.stats.playcount.toFloat())
}
}
}
@@ -318,9 +302,14 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailsView,
return true
}
R.id.action_reset_artist_image -> {
- Toast.makeText(this@ArtistDetailActivity, resources.getString(R.string.updating), Toast.LENGTH_SHORT)
+ Toast.makeText(
+ this@ArtistDetailActivity,
+ resources.getString(R.string.updating),
+ Toast.LENGTH_SHORT
+ )
.show()
- CustomArtistImageUtil.getInstance(this@ArtistDetailActivity).resetCustomArtistImage(artist)
+ CustomArtistImageUtil.getInstance(this@ArtistDetailActivity)
+ .resetCustomArtistImage(artist)
forceDownload = true
return true
}
diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/DriveModeActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/DriveModeActivity.kt
index 7b5ceef6..633bf0fd 100644
--- a/app/src/main/java/code/name/monkey/retromusic/activities/DriveModeActivity.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/activities/DriveModeActivity.kt
@@ -35,19 +35,7 @@ import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.util.MusicUtil
import com.bumptech.glide.Glide
-import kotlinx.android.synthetic.main.activity_drive_mode.close
-import kotlinx.android.synthetic.main.activity_drive_mode.image
-import kotlinx.android.synthetic.main.activity_drive_mode.nextButton
-import kotlinx.android.synthetic.main.activity_drive_mode.playPauseButton
-import kotlinx.android.synthetic.main.activity_drive_mode.previousButton
-import kotlinx.android.synthetic.main.activity_drive_mode.progressSlider
-import kotlinx.android.synthetic.main.activity_drive_mode.repeatButton
-import kotlinx.android.synthetic.main.activity_drive_mode.shuffleButton
-import kotlinx.android.synthetic.main.activity_drive_mode.songCurrentProgress
-import kotlinx.android.synthetic.main.activity_drive_mode.songFavourite
-import kotlinx.android.synthetic.main.activity_drive_mode.songText
-import kotlinx.android.synthetic.main.activity_drive_mode.songTitle
-import kotlinx.android.synthetic.main.activity_drive_mode.songTotalTime
+import kotlinx.android.synthetic.main.activity_drive_mode.*
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
@@ -96,7 +84,8 @@ class DriveModeActivity : AbsMusicServiceActivity(), Callback {
private fun toggleFavourite() {
CoroutineScope(Dispatchers.IO).launch {
- val isFavourite = MusicUtil.isFavorite(this@DriveModeActivity, MusicPlayerRemote.currentSong)
+ val isFavourite =
+ MusicUtil.isFavorite(this@DriveModeActivity, MusicPlayerRemote.currentSong)
withContext(Dispatchers.Main) {
songFavourite.setImageResource(if (isFavourite) R.drawable.ic_favorite_white_24dp else R.drawable.ic_favorite_border_white_24dp)
}
@@ -183,7 +172,10 @@ class DriveModeActivity : AbsMusicServiceActivity(), Callback {
lastPlaybackControlsColor,
PorterDuff.Mode.SRC_IN
)
- else -> shuffleButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
+ else -> shuffleButton.setColorFilter(
+ lastDisabledPlaybackControlsColor,
+ PorterDuff.Mode.SRC_IN
+ )
}
}
@@ -191,7 +183,10 @@ class DriveModeActivity : AbsMusicServiceActivity(), Callback {
when (MusicPlayerRemote.repeatMode) {
MusicService.REPEAT_MODE_NONE -> {
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
- repeatButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
+ repeatButton.setColorFilter(
+ lastDisabledPlaybackControlsColor,
+ PorterDuff.Mode.SRC_IN
+ )
}
MusicService.REPEAT_MODE_ALL -> {
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/GenreDetailsActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/GenreDetailsActivity.kt
index d3e2de87..3f57ac58 100644
--- a/app/src/main/java/code/name/monkey/retromusic/activities/GenreDetailsActivity.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/activities/GenreDetailsActivity.kt
@@ -21,11 +21,8 @@ import code.name.monkey.retromusic.mvp.presenter.GenreDetailsView
import code.name.monkey.retromusic.util.DensityUtil
import code.name.monkey.retromusic.util.RetroColorUtil
import com.afollestad.materialcab.MaterialCab
-import kotlinx.android.synthetic.main.activity_playlist_detail.empty
-import kotlinx.android.synthetic.main.activity_playlist_detail.emptyEmoji
-import kotlinx.android.synthetic.main.activity_playlist_detail.recyclerView
-import kotlinx.android.synthetic.main.activity_playlist_detail.toolbar
-import java.util.ArrayList
+import kotlinx.android.synthetic.main.activity_playlist_detail.*
+import java.util.*
import javax.inject.Inject
/**
@@ -134,7 +131,8 @@ class GenreDetailsActivity : AbsSlidingMusicPanelActivity(), CabHolder, GenreDet
override fun openCab(menuRes: Int, callback: MaterialCab.Callback): MaterialCab {
if (cab != null && cab!!.isActive) cab?.finish()
- cab = MaterialCab(this, R.id.cab_stub).setMenu(menuRes).setCloseDrawableRes(R.drawable.ic_close_white_24dp)
+ cab = MaterialCab(this, R.id.cab_stub).setMenu(menuRes)
+ .setCloseDrawableRes(R.drawable.ic_close_white_24dp)
.setBackgroundColor(
RetroColorUtil.shiftBackgroundColorForLightText(
ATHUtil.resolveColor(
diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/LicenseActivity.java b/app/src/main/java/code/name/monkey/retromusic/activities/LicenseActivity.java
index 11881b94..d2117129 100644
--- a/app/src/main/java/code/name/monkey/retromusic/activities/LicenseActivity.java
+++ b/app/src/main/java/code/name/monkey/retromusic/activities/LicenseActivity.java
@@ -18,19 +18,23 @@ import android.graphics.Color;
import android.os.Bundle;
import android.view.MenuItem;
import android.webkit.WebView;
+
import androidx.annotation.NonNull;
import androidx.appcompat.widget.Toolbar;
+
+import org.jetbrains.annotations.Nullable;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
+
import code.name.monkey.appthemehelper.ThemeStore;
import code.name.monkey.appthemehelper.util.ATHUtil;
import code.name.monkey.appthemehelper.util.ColorUtil;
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper;
import code.name.monkey.retromusic.R;
import code.name.monkey.retromusic.activities.base.AbsBaseActivity;
-import java.io.BufferedReader;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.nio.charset.StandardCharsets;
-import org.jetbrains.annotations.Nullable;
/**
* Created by hemanths on 2019-09-27.
diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/LockScreenActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/LockScreenActivity.kt
index f2e2bc98..5af09dfe 100644
--- a/app/src/main/java/code/name/monkey/retromusic/activities/LockScreenActivity.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/activities/LockScreenActivity.kt
@@ -18,7 +18,7 @@ import com.r0adkll.slidr.Slidr
import com.r0adkll.slidr.model.SlidrConfig
import com.r0adkll.slidr.model.SlidrListener
import com.r0adkll.slidr.model.SlidrPosition
-import kotlinx.android.synthetic.main.activity_lock_screen.image
+import kotlinx.android.synthetic.main.activity_lock_screen.*
class LockScreenActivity : AbsMusicServiceActivity() {
private var fragment: LockScreenPlayerControlsFragment? = null
@@ -29,9 +29,11 @@ class LockScreenActivity : AbsMusicServiceActivity() {
setShowWhenLocked(true)
setTurnScreenOn(true)
} else {
- this.window.addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD or
- WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED or
- WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON)
+ this.window.addFlags(
+ WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD or
+ WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED or
+ WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
+ )
}
setDrawUnderStatusBar()
setContentView(R.layout.activity_lock_screen)
@@ -53,7 +55,8 @@ class LockScreenActivity : AbsMusicServiceActivity() {
override fun onSlideClosed(): Boolean {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
- val keyguardManager = getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager
+ val keyguardManager =
+ getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager
keyguardManager.requestDismissKeyguard(this@LockScreenActivity, null)
}
finish()
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 9dc03ef9..06b59f87 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
@@ -8,11 +8,7 @@ import android.os.Build
import android.os.Bundle
import android.text.InputType
import android.text.TextUtils
-import android.view.LayoutInflater
-import android.view.MenuItem
-import android.view.View
-import android.view.ViewGroup
-import android.view.WindowManager
+import android.view.*
import androidx.annotation.StringRes
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
@@ -20,13 +16,8 @@ import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentStatePagerAdapter
import androidx.viewpager.widget.ViewPager
import code.name.monkey.appthemehelper.ThemeStore
-import code.name.monkey.appthemehelper.util.ATHUtil
+import code.name.monkey.appthemehelper.util.*
import code.name.monkey.appthemehelper.util.ATHUtil.resolveColor
-import code.name.monkey.appthemehelper.util.ColorUtil
-import code.name.monkey.appthemehelper.util.MaterialUtil
-import code.name.monkey.appthemehelper.util.MaterialValueHelper
-import code.name.monkey.appthemehelper.util.TintHelper
-import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
import code.name.monkey.retromusic.App
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.activities.base.AbsMusicServiceActivity
@@ -47,17 +38,17 @@ import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
import com.afollestad.materialdialogs.input.getInputLayout
import com.afollestad.materialdialogs.input.input
-import kotlinx.android.synthetic.main.activity_lyrics.fab
-import kotlinx.android.synthetic.main.activity_lyrics.tabs
-import kotlinx.android.synthetic.main.activity_lyrics.toolbar
-import kotlinx.android.synthetic.main.activity_lyrics.viewPager
-import kotlinx.android.synthetic.main.fragment_lyrics.offlineLyrics
-import kotlinx.android.synthetic.main.fragment_synced.lyricsView
+import kotlinx.android.synthetic.main.activity_lyrics.*
+import kotlinx.android.synthetic.main.fragment_lyrics.*
+import kotlinx.android.synthetic.main.fragment_synced.*
import org.jaudiotagger.tag.FieldKey
import java.io.File
-import java.util.EnumMap
+import java.util.*
+import kotlin.collections.ArrayList
+import kotlin.collections.set
-class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener, ViewPager.OnPageChangeListener {
+class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener,
+ ViewPager.OnPageChangeListener {
override fun onPageScrollStateChanged(state: Int) {
when (state) {
ViewPager.SCROLL_STATE_IDLE -> fab.show()
diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/MainActivity.java b/app/src/main/java/code/name/monkey/retromusic/activities/MainActivity.java
index e8f80904..aa2db905 100644
--- a/app/src/main/java/code/name/monkey/retromusic/activities/MainActivity.java
+++ b/app/src/main/java/code/name/monkey/retromusic/activities/MainActivity.java
@@ -33,11 +33,25 @@ import android.view.Menu;
import android.view.MenuItem;
import android.view.SubMenu;
import android.view.View;
+
import androidx.annotation.NonNull;
import androidx.appcompat.widget.Toolbar;
import androidx.core.app.ActivityCompat;
import androidx.fragment.app.Fragment;
import androidx.transition.TransitionManager;
+
+import com.afollestad.materialcab.MaterialCab;
+import com.afollestad.materialcab.MaterialCab.Callback;
+import com.google.android.material.appbar.AppBarLayout;
+import com.google.android.material.card.MaterialCardView;
+import com.google.android.material.textview.MaterialTextView;
+
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.ArrayList;
+import java.util.List;
+
import code.name.monkey.appthemehelper.util.ATHUtil;
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper;
import code.name.monkey.retromusic.R;
@@ -47,12 +61,12 @@ import code.name.monkey.retromusic.dialogs.OptionsSheetDialogFragment;
import code.name.monkey.retromusic.fragments.base.AbsLibraryPagerRecyclerViewCustomGridSizeFragment;
import code.name.monkey.retromusic.fragments.mainactivity.AlbumsFragment;
import code.name.monkey.retromusic.fragments.mainactivity.ArtistsFragment;
+import code.name.monkey.retromusic.fragments.mainactivity.BannerHomeFragment;
+import code.name.monkey.retromusic.fragments.mainactivity.FoldersFragment;
import code.name.monkey.retromusic.fragments.mainactivity.GenresFragment;
import code.name.monkey.retromusic.fragments.mainactivity.PlayingQueueFragment;
import code.name.monkey.retromusic.fragments.mainactivity.PlaylistsFragment;
import code.name.monkey.retromusic.fragments.mainactivity.SongsFragment;
-import code.name.monkey.retromusic.fragments.mainactivity.FoldersFragment;
-import code.name.monkey.retromusic.fragments.mainactivity.BannerHomeFragment;
import code.name.monkey.retromusic.helper.MusicPlayerRemote;
import code.name.monkey.retromusic.helper.SearchQueryHelper;
import code.name.monkey.retromusic.helper.SortOrder.AlbumSortOrder;
@@ -70,15 +84,6 @@ import code.name.monkey.retromusic.util.NavigationUtil;
import code.name.monkey.retromusic.util.PreferenceUtil;
import code.name.monkey.retromusic.util.RetroColorUtil;
import code.name.monkey.retromusic.util.RetroUtil;
-import com.afollestad.materialcab.MaterialCab;
-import com.afollestad.materialcab.MaterialCab.Callback;
-import com.google.android.material.appbar.AppBarLayout;
-import com.google.android.material.card.MaterialCardView;
-import com.google.android.material.textview.MaterialTextView;
-import java.util.ArrayList;
-import java.util.List;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
/**
* Created by hemanths on 2020-02-19.
@@ -91,18 +96,6 @@ public class MainActivity extends AbsSlidingMusicPanelActivity
public static final int APP_INTRO_REQUEST = 100;
public static final String EXPAND_PANEL = "expand_panel";
-
- @Nullable
- MainActivityFragmentCallbacks currentFragment;
-
- private boolean blockRequestPermissions = false;
-
- private MaterialCab cab;
-
- private AppBarLayout mAppBarLayout;
-
- private MaterialTextView mAppTitle;
-
private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(final Context context, final Intent intent) {
@@ -117,11 +110,14 @@ public class MainActivity extends AbsSlidingMusicPanelActivity
}
}
};
-
private final IntentFilter mIntentFilter = new IntentFilter(Intent.ACTION_SCREEN_OFF);
-
+ @Nullable
+ MainActivityFragmentCallbacks currentFragment;
+ private boolean blockRequestPermissions = false;
+ private MaterialCab cab;
+ private AppBarLayout mAppBarLayout;
+ private MaterialTextView mAppTitle;
private Toolbar mToolbar;
-
private MaterialCardView mToolbarContainer;
@Override
@@ -298,7 +294,7 @@ public class MainActivity extends AbsSlidingMusicPanelActivity
@Override
public void onSharedPreferenceChanged(final @NonNull SharedPreferences sharedPreferences,
- final @NonNull String key) {
+ final @NonNull String key) {
if (key.equals(PreferenceUtil.GENERAL_THEME) || key.equals(PreferenceUtil.BLACK_THEME) ||
key.equals(PreferenceUtil.ADAPTIVE_COLOR_APP) || key.equals(PreferenceUtil.DOMINANT_COLOR) ||
key.equals(PreferenceUtil.USER_NAME) || key.equals(PreferenceUtil.TOGGLE_FULL_SCREEN) ||
@@ -344,22 +340,14 @@ public class MainActivity extends AbsSlidingMusicPanelActivity
}
if (!tag.equals(currentTag)) {
- getSupportFragmentManager().beginTransaction()
+ getSupportFragmentManager()
+ .beginTransaction()
.replace(R.id.fragment_container, fragment, tag)
.commit();
currentFragment = (MainActivityFragmentCallbacks) fragment;
}
}
- public void setMusicChooser(final int option) {
- PreferenceUtil.getInstance(this).setLastMusicChooser(option);
- if (option == OptionsSheetDialogFragment.FOLDER) {
- setCurrentFragment(FoldersFragment.newInstance(this), FoldersFragment.TAG);
- } else {
- selectedFragment(PreferenceUtil.getInstance(this).getLastPage());
- }
- }
-
@NotNull
@Override
protected View createContentView() {
@@ -591,7 +579,7 @@ public class MainActivity extends AbsSlidingMusicPanelActivity
}
private long parseIdFromIntent(@NonNull Intent intent, String longKey,
- String stringKey) {
+ String stringKey) {
long id = intent.getLongExtra(longKey, -1);
if (id < 0) {
String idString = intent.getStringExtra(stringKey);
@@ -641,8 +629,9 @@ public class MainActivity extends AbsSlidingMusicPanelActivity
}
}
+
private void setUpGridSizeMenu(@NonNull AbsLibraryPagerRecyclerViewCustomGridSizeFragment fragment,
- @NonNull SubMenu gridSizeMenu) {
+ @NonNull SubMenu gridSizeMenu) {
switch (fragment.getGridSize()) {
case 1:
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 4af72c3a..d68e2b96 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
@@ -19,9 +19,7 @@ import com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropM
import com.h6ah4i.android.widget.advrecyclerview.swipeable.RecyclerViewSwipeManager
import com.h6ah4i.android.widget.advrecyclerview.touchguard.RecyclerViewTouchActionGuardManager
import com.h6ah4i.android.widget.advrecyclerview.utils.WrapperAdapterUtils
-import kotlinx.android.synthetic.main.activity_playing_queue.clearQueue
-import kotlinx.android.synthetic.main.activity_playing_queue.recyclerView
-import kotlinx.android.synthetic.main.activity_playing_queue.toolbar
+import kotlinx.android.synthetic.main.activity_playing_queue.*
open class PlayingQueueActivity : AbsMusicServiceActivity() {
diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/PlaylistDetailActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/PlaylistDetailActivity.kt
index ab22a62e..4541ecb5 100644
--- a/app/src/main/java/code/name/monkey/retromusic/activities/PlaylistDetailActivity.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/activities/PlaylistDetailActivity.kt
@@ -28,11 +28,7 @@ import com.afollestad.materialcab.MaterialCab
import com.h6ah4i.android.widget.advrecyclerview.animator.RefactoredDefaultItemAnimator
import com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager
import com.h6ah4i.android.widget.advrecyclerview.utils.WrapperAdapterUtils
-import kotlinx.android.synthetic.main.activity_playlist_detail.empty
-import kotlinx.android.synthetic.main.activity_playlist_detail.emptyEmoji
-import kotlinx.android.synthetic.main.activity_playlist_detail.emptyText
-import kotlinx.android.synthetic.main.activity_playlist_detail.recyclerView
-import kotlinx.android.synthetic.main.activity_playlist_detail.toolbar
+import kotlinx.android.synthetic.main.activity_playlist_detail.*
import javax.inject.Inject
class PlaylistDetailActivity : AbsSlidingMusicPanelActivity(), CabHolder, PlaylistSongsView {
@@ -148,7 +144,8 @@ class PlaylistDetailActivity : AbsSlidingMusicPanelActivity(), CabHolder, Playli
if (cab != null && cab!!.isActive) {
cab!!.finish()
}
- cab = MaterialCab(this, R.id.cab_stub).setMenu(menuRes).setCloseDrawableRes(R.drawable.ic_close_white_24dp)
+ cab = MaterialCab(this, R.id.cab_stub).setMenu(menuRes)
+ .setCloseDrawableRes(R.drawable.ic_close_white_24dp)
.setBackgroundColor(
RetroColorUtil.shiftBackgroundColorForLightText(
ATHUtil.resolveColor(
diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/PurchaseActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/PurchaseActivity.kt
index 07c1ee04..f2a5ee8e 100644
--- a/app/src/main/java/code/name/monkey/retromusic/activities/PurchaseActivity.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/activities/PurchaseActivity.kt
@@ -14,9 +14,7 @@ import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.activities.base.AbsBaseActivity
import com.anjlab.android.iab.v3.BillingProcessor
import com.anjlab.android.iab.v3.TransactionDetails
-import kotlinx.android.synthetic.main.activity_pro_version.purchaseButton
-import kotlinx.android.synthetic.main.activity_pro_version.restoreButton
-import kotlinx.android.synthetic.main.activity_pro_version.toolbar
+import kotlinx.android.synthetic.main.activity_pro_version.*
import java.lang.ref.WeakReference
class PurchaseActivity : AbsBaseActivity(), BillingProcessor.IBillingHandler {
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 850aaae3..494b6dd5 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
@@ -29,17 +29,12 @@ import code.name.monkey.retromusic.mvp.presenter.SearchPresenter
import code.name.monkey.retromusic.mvp.presenter.SearchView
import code.name.monkey.retromusic.util.RetroUtil
import com.google.android.material.textfield.TextInputEditText
-import kotlinx.android.synthetic.main.activity_search.appBarLayout
-import kotlinx.android.synthetic.main.activity_search.back
-import kotlinx.android.synthetic.main.activity_search.clearText
-import kotlinx.android.synthetic.main.activity_search.empty
-import kotlinx.android.synthetic.main.activity_search.keyboardPopup
-import kotlinx.android.synthetic.main.activity_search.recyclerView
-import kotlinx.android.synthetic.main.activity_search.searchContainer
-import kotlinx.android.synthetic.main.activity_search.searchView
-import kotlinx.android.synthetic.main.activity_search.voiceSearch
-import java.util.Locale
+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
@@ -71,7 +66,8 @@ class SearchActivity : AbsMusicServiceActivity(), OnQueryTextListener, TextWatch
back.setOnClickListener { onBackPressed() }
voiceSearch.setOnClickListener { startMicSearch() }
clearText.setOnClickListener { searchView.clearText() }
- searchContainer.backgroundTintList = ColorStateList.valueOf(ATHUtil.resolveColor(this, R.attr.colorSurface))
+ searchContainer.backgroundTintList =
+ ColorStateList.valueOf(ATHUtil.resolveColor(this, R.attr.colorSurface))
keyboardPopup.setOnClickListener {
val inputManager = getSystemService(Service.INPUT_METHOD_SERVICE) as InputMethodManager
@@ -80,7 +76,10 @@ class SearchActivity : AbsMusicServiceActivity(), OnQueryTextListener, TextWatch
keyboardPopup.backgroundTintList = ColorStateList.valueOf(ThemeStore.accentColor(this))
ColorStateList.valueOf(
- MaterialValueHelper.getPrimaryTextColor(this, ColorUtil.isColorLight(ThemeStore.accentColor(this)))
+ MaterialValueHelper.getPrimaryTextColor(
+ this,
+ ColorUtil.isColorLight(ThemeStore.accentColor(this))
+ )
).apply {
keyboardPopup.setTextColor(this)
keyboardPopup.iconTint = this
@@ -175,7 +174,8 @@ class SearchActivity : AbsMusicServiceActivity(), OnQueryTextListener, TextWatch
when (requestCode) {
REQ_CODE_SPEECH_INPUT -> {
if (resultCode == Activity.RESULT_OK && null != data) {
- val result: ArrayList? = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS)
+ val result: ArrayList? =
+ data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS)
query = result?.get(0)
searchView.setText(query, BufferType.EDITABLE)
searchPresenter.search(query!!)
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 8a7568db..a788e567 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,14 +4,12 @@ import android.os.Bundle
import android.view.MenuItem
import androidx.annotation.StringRes
import androidx.fragment.app.Fragment
-import androidx.transition.TransitionManager
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.fragments.settings.MainSettingsFragment
-import kotlinx.android.synthetic.main.activity_settings.appBarLayout
-import kotlinx.android.synthetic.main.activity_settings.toolbar
+import kotlinx.android.synthetic.main.activity_settings.*
class SettingsActivity : AbsBaseActivity() {
@@ -28,7 +26,8 @@ class SettingsActivity : AbsBaseActivity() {
setupToolbar()
if (savedInstanceState == null) {
- fragmentManager.beginTransaction().replace(R.id.contentFrame, MainSettingsFragment()).commit()
+ fragmentManager.beginTransaction().replace(R.id.contentFrame, MainSettingsFragment())
+ .commit()
}
}
@@ -51,12 +50,10 @@ class SettingsActivity : AbsBaseActivity() {
android.R.anim.slide_in_left,
android.R.anim.slide_out_right
)
-
fragmentTransaction.replace(R.id.contentFrame, fragment, fragment.tag)
fragmentTransaction.addToBackStack(null)
fragmentTransaction.commit()
- TransitionManager.beginDelayedTransition(appBarLayout)
setTitle(titleName)
}
diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/ShareInstagramStory.kt b/app/src/main/java/code/name/monkey/retromusic/activities/ShareInstagramStory.kt
index 944ccfbe..ae633470 100644
--- a/app/src/main/java/code/name/monkey/retromusic/activities/ShareInstagramStory.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/activities/ShareInstagramStory.kt
@@ -33,12 +33,7 @@ import code.name.monkey.retromusic.glide.SongGlideRequest
import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.util.Share
import com.bumptech.glide.Glide
-import kotlinx.android.synthetic.main.activity_share_instagram.image
-import kotlinx.android.synthetic.main.activity_share_instagram.mainContent
-import kotlinx.android.synthetic.main.activity_share_instagram.shareButton
-import kotlinx.android.synthetic.main.activity_share_instagram.shareText
-import kotlinx.android.synthetic.main.activity_share_instagram.shareTitle
-import kotlinx.android.synthetic.main.activity_share_instagram.toolbar
+import kotlinx.android.synthetic.main.activity_share_instagram.*
/**
* Created by hemanths on 2020-02-02.
@@ -107,7 +102,12 @@ class ShareInstagramStory : AbsBaseActivity() {
private fun setColors(colorLight: Boolean, color: Int) {
setLightStatusbar(colorLight)
- toolbar.setTitleTextColor(MaterialValueHelper.getPrimaryTextColor(this@ShareInstagramStory, colorLight))
+ toolbar.setTitleTextColor(
+ MaterialValueHelper.getPrimaryTextColor(
+ this@ShareInstagramStory,
+ colorLight
+ )
+ )
toolbar.navigationIcon?.setTintList(
ColorStateList.valueOf(
MaterialValueHelper.getPrimaryTextColor(
@@ -117,6 +117,9 @@ class ShareInstagramStory : AbsBaseActivity() {
)
)
mainContent.background =
- GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, intArrayOf(color, Color.BLACK))
+ GradientDrawable(
+ GradientDrawable.Orientation.TOP_BOTTOM,
+ intArrayOf(color, Color.BLACK)
+ )
}
}
diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/WhatsNewActivity.java b/app/src/main/java/code/name/monkey/retromusic/activities/WhatsNewActivity.java
index dea4e151..631db15c 100644
--- a/app/src/main/java/code/name/monkey/retromusic/activities/WhatsNewActivity.java
+++ b/app/src/main/java/code/name/monkey/retromusic/activities/WhatsNewActivity.java
@@ -7,10 +7,19 @@ import android.content.pm.PackageManager;
import android.graphics.Color;
import android.os.Bundle;
import android.webkit.WebView;
+
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.Toolbar;
import androidx.core.widget.NestedScrollView;
+
+import com.google.android.material.appbar.AppBarLayout;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
+
import code.name.monkey.appthemehelper.ThemeStore;
import code.name.monkey.appthemehelper.util.ATHUtil;
import code.name.monkey.appthemehelper.util.ColorUtil;
@@ -18,11 +27,6 @@ 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.util.PreferenceUtil;
-import com.google.android.material.appbar.AppBarLayout;
-import java.io.BufferedReader;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.nio.charset.StandardCharsets;
public class WhatsNewActivity extends AbsBaseActivity {
@@ -32,6 +36,21 @@ public class WhatsNewActivity extends AbsBaseActivity {
WebView webView;
+ private static String colorToCSS(int color) {
+ return String.format("rgb(%d, %d, %d)", Color.red(color), Color.green(color),
+ Color.blue(color)); // on API 29, WebView doesn't load with hex colors
+ }
+
+ private static void setChangelogRead(@NonNull Context context) {
+ try {
+ PackageInfo pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
+ int currentVersion = pInfo.versionCode;
+ PreferenceUtil.getInstance(context).setLastChangeLogVersion(currentVersion);
+ } catch (PackageManager.NameNotFoundException e) {
+ e.printStackTrace();
+ }
+ }
+
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
setDrawUnderStatusBar();
@@ -80,19 +99,4 @@ public class WhatsNewActivity extends AbsBaseActivity {
}
setChangelogRead(this);
}
-
- private static String colorToCSS(int color) {
- return String.format("rgb(%d, %d, %d)", Color.red(color), Color.green(color),
- Color.blue(color)); // on API 29, WebView doesn't load with hex colors
- }
-
- private static void setChangelogRead(@NonNull Context context) {
- try {
- PackageInfo pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
- int currentVersion = pInfo.versionCode;
- PreferenceUtil.getInstance(context).setLastChangeLogVersion(currentVersion);
- } catch (PackageManager.NameNotFoundException e) {
- e.printStackTrace();
- }
- }
}
\ No newline at end of file
diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsMusicServiceActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsMusicServiceActivity.kt
index a5c87309..c545b338 100644
--- a/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsMusicServiceActivity.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsMusicServiceActivity.kt
@@ -1,26 +1,15 @@
package code.name.monkey.retromusic.activities.base
import android.Manifest
-import android.content.BroadcastReceiver
-import android.content.ComponentName
-import android.content.Context
-import android.content.Intent
-import android.content.IntentFilter
-import android.content.ServiceConnection
+import android.content.*
import android.os.Bundle
import android.os.IBinder
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.interfaces.MusicServiceEventListener
-import code.name.monkey.retromusic.service.MusicService.FAVORITE_STATE_CHANGED
-import code.name.monkey.retromusic.service.MusicService.MEDIA_STORE_CHANGED
-import code.name.monkey.retromusic.service.MusicService.META_CHANGED
-import code.name.monkey.retromusic.service.MusicService.PLAY_STATE_CHANGED
-import code.name.monkey.retromusic.service.MusicService.QUEUE_CHANGED
-import code.name.monkey.retromusic.service.MusicService.REPEAT_MODE_CHANGED
-import code.name.monkey.retromusic.service.MusicService.SHUFFLE_MODE_CHANGED
+import code.name.monkey.retromusic.service.MusicService.*
import java.lang.ref.WeakReference
-import java.util.ArrayList
+import java.util.*
abstract class AbsMusicServiceActivity : AbsBaseActivity(), MusicServiceEventListener {
diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsSlidingMusicPanelActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsSlidingMusicPanelActivity.kt
index 8ab5d13b..3a84f55b 100644
--- a/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsSlidingMusicPanelActivity.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsSlidingMusicPanelActivity.kt
@@ -16,21 +16,7 @@ import code.name.monkey.retromusic.extensions.hide
import code.name.monkey.retromusic.extensions.show
import code.name.monkey.retromusic.fragments.MiniPlayerFragment
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.FIT
-import code.name.monkey.retromusic.fragments.NowPlayingScreen.FLAT
-import code.name.monkey.retromusic.fragments.NowPlayingScreen.FULL
-import code.name.monkey.retromusic.fragments.NowPlayingScreen.MATERIAL
-import code.name.monkey.retromusic.fragments.NowPlayingScreen.NORMAL
-import code.name.monkey.retromusic.fragments.NowPlayingScreen.PEAK
-import code.name.monkey.retromusic.fragments.NowPlayingScreen.PLAIN
-import code.name.monkey.retromusic.fragments.NowPlayingScreen.SIMPLE
-import code.name.monkey.retromusic.fragments.NowPlayingScreen.TINY
+import code.name.monkey.retromusic.fragments.NowPlayingScreen.*
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
import code.name.monkey.retromusic.fragments.player.adaptive.AdaptiveFragment
import code.name.monkey.retromusic.fragments.player.blur.BlurPlayerFragment
@@ -53,11 +39,10 @@ import code.name.monkey.retromusic.util.DensityUtil
import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.views.BottomNavigationBarTinted
import com.google.android.material.bottomsheet.BottomSheetBehavior
-import kotlinx.android.synthetic.main.sliding_music_panel_layout.bottomNavigationView
-import kotlinx.android.synthetic.main.sliding_music_panel_layout.dimBackground
-import kotlinx.android.synthetic.main.sliding_music_panel_layout.slidingPanel
+import kotlinx.android.synthetic.main.sliding_music_panel_layout.*
-abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(), AbsPlayerFragment.Callbacks {
+abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(),
+ AbsPlayerFragment.Callbacks {
companion object {
val TAG: String = AbsSlidingMusicPanelActivity::class.java.simpleName
}
@@ -133,8 +118,10 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(), AbsPlay
}
protected fun wrapSlidingMusicPanel(@LayoutRes resId: Int): View {
- val slidingMusicPanelLayout = layoutInflater.inflate(R.layout.sliding_music_panel_layout, null)
- val contentContainer = slidingMusicPanelLayout.findViewById(R.id.mainContentFrame)
+ val slidingMusicPanelLayout =
+ layoutInflater.inflate(R.layout.sliding_music_panel_layout, null)
+ val contentContainer =
+ slidingMusicPanelLayout.findViewById(R.id.mainContentFrame)
layoutInflater.inflate(resId, contentContainer)
return slidingMusicPanelLayout
}
@@ -183,7 +170,8 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(), AbsPlay
}
private fun setupSlidingUpPanel() {
- slidingPanel.viewTreeObserver.addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener {
+ slidingPanel.viewTreeObserver.addOnGlobalLayoutListener(object :
+ ViewTreeObserver.OnGlobalLayoutListener {
override fun onGlobalLayout() {
slidingPanel.viewTreeObserver.removeOnGlobalLayoutListener(this)
if (currentNowPlayingScreen != PEAK) {
@@ -210,7 +198,8 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(), AbsPlay
private fun hideBottomBar(hide: Boolean) {
val heightOfBar = resources.getDimensionPixelSize(R.dimen.mini_player_height)
- val heightOfBarWithTabs = resources.getDimensionPixelSize(R.dimen.mini_player_height_expanded)
+ val heightOfBarWithTabs =
+ resources.getDimensionPixelSize(R.dimen.mini_player_height_expanded)
if (hide) {
bottomSheetBehavior.isHideable = true
@@ -258,15 +247,18 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(), AbsPlay
.commit()
supportFragmentManager.executePendingTransactions()
- playerFragment = supportFragmentManager.findFragmentById(R.id.playerFragmentContainer) as AbsPlayerFragment
- miniPlayerFragment = supportFragmentManager.findFragmentById(R.id.miniPlayerFragment) as MiniPlayerFragment
+ playerFragment =
+ supportFragmentManager.findFragmentById(R.id.playerFragmentContainer) as AbsPlayerFragment
+ miniPlayerFragment =
+ supportFragmentManager.findFragmentById(R.id.miniPlayerFragment) as MiniPlayerFragment
miniPlayerFragment?.view?.setOnClickListener { expandPanel() }
}
override fun onServiceConnected() {
super.onServiceConnected()
if (MusicPlayerRemote.playingQueue.isNotEmpty()) {
- slidingPanel.viewTreeObserver.addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener {
+ slidingPanel.viewTreeObserver.addOnGlobalLayoutListener(object :
+ ViewTreeObserver.OnGlobalLayoutListener {
override fun onGlobalLayout() {
slidingPanel.viewTreeObserver.removeOnGlobalLayoutListener(this)
hideBottomBar(false)
@@ -303,7 +295,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(), AbsPlay
if (PreferenceUtil.getInstance(this).adaptiveColor && (currentNowPlayingScreen == NORMAL || currentNowPlayingScreen == FLAT)) {
super.setLightNavigationBar(true)
super.setLightStatusbar(isColorLight)
- } else if (currentNowPlayingScreen == FULL || currentNowPlayingScreen == CARD || currentNowPlayingScreen == FIT || currentNowPlayingScreen == BLUR || currentNowPlayingScreen == BLUR_CARD) {
+ } else if (currentNowPlayingScreen == FULL || currentNowPlayingScreen == CARD || currentNowPlayingScreen == BLUR || currentNowPlayingScreen == BLUR_CARD) {
super.setLightStatusbar(false)
super.setLightNavigationBar(true)
super.setNavigationbarColor(Color.BLACK)
@@ -311,6 +303,8 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(), AbsPlay
super.setNavigationbarColor(paletteColor)
super.setLightNavigationBar(isColorLight)
super.setLightStatusbar(isColorLight)
+ } else if (currentNowPlayingScreen == FIT) {
+ super.setLightStatusbar(false)
} else {
super.setLightStatusbar(
ColorUtil.isColorLight(
diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsThemeActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsThemeActivity.kt
index 6ea53f26..74bf61c5 100644
--- a/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsThemeActivity.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsThemeActivity.kt
@@ -69,7 +69,10 @@ abstract class AbsThemeActivity : ATHToolbarActivity(), Runnable {
ContextCompat.getDrawable(this, R.drawable.round_window)
else ContextCompat.getDrawable(this, R.drawable.square_window)
background =
- TintHelper.createTintedDrawable(background, ATHUtil.resolveColor(this, android.R.attr.windowBackground))
+ TintHelper.createTintedDrawable(
+ background,
+ ATHUtil.resolveColor(this, android.R.attr.windowBackground)
+ )
window.setBackgroundDrawable(background)
}
@@ -92,7 +95,11 @@ abstract class AbsThemeActivity : ATHToolbarActivity(), Runnable {
if (statusBar != null) {
when {
VersionUtils.hasMarshmallow() -> statusBar.setBackgroundColor(color)
- VersionUtils.hasLollipop() -> statusBar.setBackgroundColor(ColorUtil.darkenColor(color))
+ VersionUtils.hasLollipop() -> statusBar.setBackgroundColor(
+ ColorUtil.darkenColor(
+ color
+ )
+ )
else -> statusBar.setBackgroundColor(color)
}
} else {
diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/bugreport/BugReportActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/bugreport/BugReportActivity.kt
index 44f8af2b..4ee68b9b 100644
--- a/app/src/main/java/code/name/monkey/retromusic/activities/bugreport/BugReportActivity.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/activities/bugreport/BugReportActivity.kt
@@ -32,19 +32,9 @@ import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.callbacks.onCancel
import com.google.android.material.floatingactionbutton.FloatingActionButton
import com.google.android.material.textfield.TextInputLayout
-import kotlinx.android.synthetic.main.activity_bug_report.sendFab
-import kotlinx.android.synthetic.main.activity_bug_report.toolbar
-import kotlinx.android.synthetic.main.bug_report_card_device_info.airTextDeviceInfo
-import kotlinx.android.synthetic.main.bug_report_card_report.inputDescription
-import kotlinx.android.synthetic.main.bug_report_card_report.inputLayoutDescription
-import kotlinx.android.synthetic.main.bug_report_card_report.inputLayoutPassword
-import kotlinx.android.synthetic.main.bug_report_card_report.inputLayoutTitle
-import kotlinx.android.synthetic.main.bug_report_card_report.inputLayoutUsername
-import kotlinx.android.synthetic.main.bug_report_card_report.inputPassword
-import kotlinx.android.synthetic.main.bug_report_card_report.inputTitle
-import kotlinx.android.synthetic.main.bug_report_card_report.inputUsername
-import kotlinx.android.synthetic.main.bug_report_card_report.optionAnonymous
-import kotlinx.android.synthetic.main.bug_report_card_report.optionUseAccount
+import kotlinx.android.synthetic.main.activity_bug_report.*
+import kotlinx.android.synthetic.main.bug_report_card_device_info.*
+import kotlinx.android.synthetic.main.bug_report_card_report.*
import org.eclipse.egit.github.core.Issue
import org.eclipse.egit.github.core.client.GitHubClient
import org.eclipse.egit.github.core.client.RequestException
diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/bugreport/model/DeviceInfo.java b/app/src/main/java/code/name/monkey/retromusic/activities/bugreport/model/DeviceInfo.java
index 94879474..ff67d14a 100644
--- a/app/src/main/java/code/name/monkey/retromusic/activities/bugreport/model/DeviceInfo.java
+++ b/app/src/main/java/code/name/monkey/retromusic/activities/bugreport/model/DeviceInfo.java
@@ -5,10 +5,13 @@ import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Build;
+
import androidx.annotation.IntRange;
-import code.name.monkey.retromusic.util.PreferenceUtil;
+
import java.util.Arrays;
+import code.name.monkey.retromusic.util.PreferenceUtil;
+
public class DeviceInfo {
@SuppressLint("NewApi")
diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/saf/SAFGuideActivity.java b/app/src/main/java/code/name/monkey/retromusic/activities/saf/SAFGuideActivity.java
index ef7ce78d..a5f2d908 100644
--- a/app/src/main/java/code/name/monkey/retromusic/activities/saf/SAFGuideActivity.java
+++ b/app/src/main/java/code/name/monkey/retromusic/activities/saf/SAFGuideActivity.java
@@ -16,11 +16,14 @@ package code.name.monkey.retromusic.activities.saf;
import android.os.Build;
import android.os.Bundle;
+
import androidx.annotation.Nullable;
-import code.name.monkey.retromusic.R;
+
import com.heinrichreimersoftware.materialintro.app.IntroActivity;
import com.heinrichreimersoftware.materialintro.slide.SimpleSlide;
+import code.name.monkey.retromusic.R;
+
/**
* Created by hemanths on 2019-07-31.
*/
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 c26551d5..ed170e63 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
@@ -30,13 +30,12 @@ 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.editorImage
-import kotlinx.android.synthetic.main.activity_album_tag_editor.imageContainer
+import kotlinx.android.synthetic.main.activity_album_tag_editor.*
import org.jaudiotagger.audio.AudioFile
import org.jaudiotagger.audio.AudioFileIO
import org.jaudiotagger.tag.FieldKey
import java.io.File
-import java.util.Collections
+import java.util.*
abstract class AbsTagEditorActivity : AbsBaseActivity() {
diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/AlbumTagEditorActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/AlbumTagEditorActivity.kt
index b4c5da25..6dabc933 100755
--- a/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/AlbumTagEditorActivity.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/AlbumTagEditorActivity.kt
@@ -27,19 +27,9 @@ import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.request.animation.GlideAnimation
import com.bumptech.glide.request.target.SimpleTarget
-import kotlinx.android.synthetic.main.activity_album_tag_editor.albumArtistContainer
-import kotlinx.android.synthetic.main.activity_album_tag_editor.albumArtistText
-import kotlinx.android.synthetic.main.activity_album_tag_editor.albumText
-import kotlinx.android.synthetic.main.activity_album_tag_editor.albumTitleContainer
-import kotlinx.android.synthetic.main.activity_album_tag_editor.genreContainer
-import kotlinx.android.synthetic.main.activity_album_tag_editor.genreTitle
-import kotlinx.android.synthetic.main.activity_album_tag_editor.imageContainer
-import kotlinx.android.synthetic.main.activity_album_tag_editor.toolbar
-import kotlinx.android.synthetic.main.activity_album_tag_editor.yearContainer
-import kotlinx.android.synthetic.main.activity_album_tag_editor.yearTitle
+import kotlinx.android.synthetic.main.activity_album_tag_editor.*
import org.jaudiotagger.tag.FieldKey
-import java.util.ArrayList
-import java.util.EnumMap
+import java.util.*
class AlbumTagEditorActivity : AbsTagEditorActivity(), TextWatcher {
override val contentViewLayout: Int
@@ -71,7 +61,10 @@ class AlbumTagEditorActivity : AbsTagEditorActivity(), TextWatcher {
albumArtBitmap,
getColor(
resource?.palette,
- ATHUtil.resolveColor(this@AlbumTagEditorActivity, R.attr.defaultFooterColor)
+ ATHUtil.resolveColor(
+ this@AlbumTagEditorActivity,
+ R.attr.defaultFooterColor
+ )
)
)
deleteAlbumArt = false
diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/SongTagEditorActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/SongTagEditorActivity.kt
index 887b7770..d99bb70c 100755
--- a/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/SongTagEditorActivity.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/SongTagEditorActivity.kt
@@ -9,28 +9,9 @@ import code.name.monkey.appthemehelper.util.MaterialUtil
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.extensions.appHandleColor
import code.name.monkey.retromusic.loaders.SongLoader
-import kotlinx.android.synthetic.main.activity_song_tag_editor.albumArtistContainer
-import kotlinx.android.synthetic.main.activity_song_tag_editor.albumArtistText
-import kotlinx.android.synthetic.main.activity_song_tag_editor.albumText
-import kotlinx.android.synthetic.main.activity_song_tag_editor.albumTextContainer
-import kotlinx.android.synthetic.main.activity_song_tag_editor.artistContainer
-import kotlinx.android.synthetic.main.activity_song_tag_editor.artistText
-import kotlinx.android.synthetic.main.activity_song_tag_editor.composerContainer
-import kotlinx.android.synthetic.main.activity_song_tag_editor.genreContainer
-import kotlinx.android.synthetic.main.activity_song_tag_editor.genreText
-import kotlinx.android.synthetic.main.activity_song_tag_editor.lyricsContainer
-import kotlinx.android.synthetic.main.activity_song_tag_editor.lyricsText
-import kotlinx.android.synthetic.main.activity_song_tag_editor.songComposerText
-import kotlinx.android.synthetic.main.activity_song_tag_editor.songText
-import kotlinx.android.synthetic.main.activity_song_tag_editor.songTextContainer
-import kotlinx.android.synthetic.main.activity_song_tag_editor.toolbar
-import kotlinx.android.synthetic.main.activity_song_tag_editor.trackNumberContainer
-import kotlinx.android.synthetic.main.activity_song_tag_editor.trackNumberText
-import kotlinx.android.synthetic.main.activity_song_tag_editor.yearContainer
-import kotlinx.android.synthetic.main.activity_song_tag_editor.yearText
+import kotlinx.android.synthetic.main.activity_song_tag_editor.*
import org.jaudiotagger.tag.FieldKey
-import java.util.ArrayList
-import java.util.EnumMap
+import java.util.*
class SongTagEditorActivity : AbsTagEditorActivity(), TextWatcher {
diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/WriteTagsAsyncTask.java b/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/WriteTagsAsyncTask.java
index 4873959f..29970c38 100644
--- a/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/WriteTagsAsyncTask.java
+++ b/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/WriteTagsAsyncTask.java
@@ -7,21 +7,12 @@ import android.graphics.Bitmap;
import android.media.MediaScannerConnection;
import android.net.Uri;
import android.os.Build;
+
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-import code.name.monkey.retromusic.R;
-import code.name.monkey.retromusic.misc.DialogAsyncTask;
-import code.name.monkey.retromusic.misc.UpdateToastMediaScannerCompletionListener;
-import code.name.monkey.retromusic.util.MusicUtil;
-import code.name.monkey.retromusic.util.SAFUtil;
+
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.lang.ref.WeakReference;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Map;
+
import org.jaudiotagger.audio.AudioFile;
import org.jaudiotagger.audio.AudioFileIO;
import org.jaudiotagger.tag.FieldKey;
@@ -29,28 +20,23 @@ import org.jaudiotagger.tag.Tag;
import org.jaudiotagger.tag.images.Artwork;
import org.jaudiotagger.tag.images.ArtworkFactory;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.lang.ref.WeakReference;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Map;
+
+import code.name.monkey.retromusic.R;
+import code.name.monkey.retromusic.misc.DialogAsyncTask;
+import code.name.monkey.retromusic.misc.UpdateToastMediaScannerCompletionListener;
+import code.name.monkey.retromusic.util.MusicUtil;
+import code.name.monkey.retromusic.util.SAFUtil;
+
public class WriteTagsAsyncTask extends
DialogAsyncTask {
- public static class LoadingInfo {
-
- @Nullable
- final Map fieldKeyValueMap;
-
- final Collection filePaths;
-
- @Nullable
- private AbsTagEditorActivity.ArtworkInfo artworkInfo;
-
- public LoadingInfo(Collection filePaths,
- @Nullable Map fieldKeyValueMap,
- @Nullable AbsTagEditorActivity.ArtworkInfo artworkInfo) {
- this.filePaths = filePaths;
- this.fieldKeyValueMap = fieldKeyValueMap;
- this.artworkInfo = artworkInfo;
- }
- }
-
private WeakReference activity;
public WriteTagsAsyncTask(@NonNull Activity activity) {
@@ -184,4 +170,23 @@ public class WriteTagsAsyncTask extends
new UpdateToastMediaScannerCompletionListener(activity, toBeScanned));
}
}
+
+ public static class LoadingInfo {
+
+ @Nullable
+ final Map fieldKeyValueMap;
+
+ final Collection filePaths;
+
+ @Nullable
+ private AbsTagEditorActivity.ArtworkInfo artworkInfo;
+
+ public LoadingInfo(Collection filePaths,
+ @Nullable Map fieldKeyValueMap,
+ @Nullable AbsTagEditorActivity.ArtworkInfo artworkInfo) {
+ this.filePaths = filePaths;
+ this.fieldKeyValueMap = fieldKeyValueMap;
+ this.artworkInfo = artworkInfo;
+ }
+ }
}
\ No newline at end of file
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 b502d172..426eafb1 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
@@ -39,26 +39,7 @@ import code.name.monkey.retromusic.util.SwipeAndDragHelper;
public class CategoryInfoAdapter extends RecyclerView.Adapter
implements SwipeAndDragHelper.ActionCompletionContract {
- static class ViewHolder extends RecyclerView.ViewHolder {
-
- MaterialCheckBox checkBox;
-
- View dragView;
-
- TextView title;
-
- ViewHolder(View view) {
- super(view);
- checkBox = view.findViewById(R.id.checkbox);
- checkBox.setButtonTintList(
- ColorStateList.valueOf(ThemeStore.Companion.accentColor(checkBox.getContext())));
- title = view.findViewById(R.id.title);
- dragView = view.findViewById(R.id.drag_view);
- }
- }
-
private List categoryInfos;
-
private ItemTouchHelper touchHelper;
public CategoryInfoAdapter(@NonNull List categoryInfos) {
@@ -139,4 +120,22 @@ public class CategoryInfoAdapter extends RecyclerView.Adapter extends RecyclerView.Adapter
implements MaterialCab.Callback {
- private MaterialCab cab;
-
@Nullable
private final CabHolder cabHolder;
-
- private ArrayList checked;
-
private final Context context;
-
+ private MaterialCab cab;
+ private ArrayList checked;
private int menuRes;
public AbsMultiSelectAdapter(@NonNull Context context, @Nullable CabHolder cabHolder, @MenuRes int menuRes) {
diff --git a/app/src/main/java/code/name/monkey/retromusic/adapter/base/MediaEntryViewHolder.java b/app/src/main/java/code/name/monkey/retromusic/adapter/base/MediaEntryViewHolder.java
index 014d7ea1..01971b12 100644
--- a/app/src/main/java/code/name/monkey/retromusic/adapter/base/MediaEntryViewHolder.java
+++ b/app/src/main/java/code/name/monkey/retromusic/adapter/base/MediaEntryViewHolder.java
@@ -20,13 +20,16 @@ import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
+
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
-import code.name.monkey.retromusic.R;
+
import com.google.android.material.card.MaterialCardView;
import com.h6ah4i.android.widget.advrecyclerview.utils.AbstractDraggableSwipeableItemViewHolder;
+import code.name.monkey.retromusic.R;
+
public class MediaEntryViewHolder extends AbstractDraggableSwipeableItemViewHolder
implements View.OnLongClickListener, View.OnClickListener {
diff --git a/app/src/main/java/code/name/monkey/retromusic/adapter/playlist/PlaylistAdapter.kt b/app/src/main/java/code/name/monkey/retromusic/adapter/playlist/PlaylistAdapter.kt
index c13f116c..8c6a6c80 100755
--- a/app/src/main/java/code/name/monkey/retromusic/adapter/playlist/PlaylistAdapter.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/adapter/playlist/PlaylistAdapter.kt
@@ -30,7 +30,7 @@ import code.name.monkey.retromusic.model.smartplaylist.AbsSmartPlaylist
import code.name.monkey.retromusic.model.smartplaylist.LastAddedPlaylist
import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.NavigationUtil
-import java.util.ArrayList
+import java.util.*
class PlaylistAdapter(
private val activity: AppCompatActivity,
@@ -172,7 +172,8 @@ class PlaylistAdapter(
init {
image?.apply {
- val iconPadding = activity.resources.getDimensionPixelSize(R.dimen.list_item_image_icon_padding)
+ val iconPadding =
+ activity.resources.getDimensionPixelSize(R.dimen.list_item_image_icon_padding)
setPadding(iconPadding, iconPadding, iconPadding, iconPadding)
}
diff --git a/app/src/main/java/code/name/monkey/retromusic/adapter/song/AbsOffsetSongAdapter.kt b/app/src/main/java/code/name/monkey/retromusic/adapter/song/AbsOffsetSongAdapter.kt
index 5d216fff..89d3e511 100644
--- a/app/src/main/java/code/name/monkey/retromusic/adapter/song/AbsOffsetSongAdapter.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/adapter/song/AbsOffsetSongAdapter.kt
@@ -19,7 +19,8 @@ abstract class AbsOffsetSongAdapter(
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SongAdapter.ViewHolder {
if (viewType == OFFSET_ITEM) {
- val view = LayoutInflater.from(activity).inflate(R.layout.item_list_quick_actions, parent, false)
+ val view = LayoutInflater.from(activity)
+ .inflate(R.layout.item_list_quick_actions, parent, false)
return createViewHolder(view)
}
return super.onCreateViewHolder(parent, viewType)
diff --git a/app/src/main/java/code/name/monkey/retromusic/adapter/song/OrderablePlaylistSongAdapter.kt b/app/src/main/java/code/name/monkey/retromusic/adapter/song/OrderablePlaylistSongAdapter.kt
index a8d764b9..74a2f7eb 100644
--- a/app/src/main/java/code/name/monkey/retromusic/adapter/song/OrderablePlaylistSongAdapter.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/adapter/song/OrderablePlaylistSongAdapter.kt
@@ -91,7 +91,8 @@ class OrderablePlaylistSongAdapter(
fun onMoveItem(fromPosition: Int, toPosition: Int)
}
- inner class ViewHolder(itemView: View) : PlaylistSongAdapter.ViewHolder(itemView), DraggableItemViewHolder {
+ inner class ViewHolder(itemView: View) : PlaylistSongAdapter.ViewHolder(itemView),
+ DraggableItemViewHolder {
@DraggableItemStateFlags
private var mDragStateFlags: Int = 0
diff --git a/app/src/main/java/code/name/monkey/retromusic/adapter/song/PlayingQueueAdapter.kt b/app/src/main/java/code/name/monkey/retromusic/adapter/song/PlayingQueueAdapter.kt
index 1a722bd3..04a998e6 100644
--- a/app/src/main/java/code/name/monkey/retromusic/adapter/song/PlayingQueueAdapter.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/adapter/song/PlayingQueueAdapter.kt
@@ -23,7 +23,7 @@ import com.h6ah4i.android.widget.advrecyclerview.swipeable.action.SwipeResultAct
import com.h6ah4i.android.widget.advrecyclerview.swipeable.action.SwipeResultActionRemoveItem
import com.h6ah4i.android.widget.advrecyclerview.swipeable.annotation.SwipeableItemResults
import me.zhanghai.android.fastscroll.PopupTextProvider
-import java.util.ArrayList
+import java.util.*
class PlayingQueueAdapter(
activity: AppCompatActivity,
@@ -32,7 +32,8 @@ class PlayingQueueAdapter(
itemLayoutRes: Int
) : SongAdapter(
activity, dataSet, itemLayoutRes, null
-), DraggableItemAdapter, SwipeableItemAdapter,
+), DraggableItemAdapter,
+ SwipeableItemAdapter,
PopupTextProvider {
private var color = -1
@@ -107,7 +108,11 @@ class PlayingQueueAdapter(
}
override fun onCheckCanStartDrag(holder: ViewHolder, position: Int, x: Int, y: Int): Boolean {
- return ViewUtil.hitTest(holder.imageText!!, x, y) || ViewUtil.hitTest(holder.dragView!!, x, y)
+ return ViewUtil.hitTest(holder.imageText!!, x, y) || ViewUtil.hitTest(
+ holder.dragView!!,
+ x,
+ y
+ )
}
override fun onGetItemDraggableRange(holder: ViewHolder, position: Int): ItemDraggableRange? {
diff --git a/app/src/main/java/code/name/monkey/retromusic/appshortcuts/AppShortcutIconGenerator.kt b/app/src/main/java/code/name/monkey/retromusic/appshortcuts/AppShortcutIconGenerator.kt
index 70565d5a..15e1b302 100644
--- a/app/src/main/java/code/name/monkey/retromusic/appshortcuts/AppShortcutIconGenerator.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/appshortcuts/AppShortcutIconGenerator.kt
@@ -15,69 +15,73 @@
package code.name.monkey.retromusic.appshortcuts
import android.content.Context
-import android.graphics.*
-import android.graphics.drawable.*
+import android.graphics.Bitmap
+import android.graphics.Canvas
+import android.graphics.drawable.Drawable
+import android.graphics.drawable.Icon
+import android.graphics.drawable.LayerDrawable
import android.os.Build
import android.util.TypedValue
import androidx.annotation.RequiresApi
import code.name.monkey.appthemehelper.ThemeStore
import code.name.monkey.retromusic.R
-import code.name.monkey.retromusic.util.*
+import code.name.monkey.retromusic.util.PreferenceUtil
+import code.name.monkey.retromusic.util.RetroUtil
@RequiresApi(Build.VERSION_CODES.N_MR1)
object AppShortcutIconGenerator {
- fun generateThemedIcon(context: Context, iconId: Int): Icon {
- return if (PreferenceUtil.getInstance(context).coloredAppShortcuts()) {
- generateUserThemedIcon(context, iconId)
- } else {
- generateDefaultThemedIcon(context, iconId)
- }
- }
+ fun generateThemedIcon(context: Context, iconId: Int): Icon {
+ return if (PreferenceUtil.getInstance(context).coloredAppShortcuts()) {
+ generateUserThemedIcon(context, iconId)
+ } else {
+ generateDefaultThemedIcon(context, iconId)
+ }
+ }
- private fun generateDefaultThemedIcon(context: Context, iconId: Int): Icon {
- // Return an Icon of iconId with default colors
- return generateThemedIcon(
- context,
- iconId,
- context.getColor(R.color.app_shortcut_default_foreground),
- context.getColor(R.color.app_shortcut_default_background)
- )
- }
+ private fun generateDefaultThemedIcon(context: Context, iconId: Int): Icon {
+ // Return an Icon of iconId with default colors
+ return generateThemedIcon(
+ context,
+ iconId,
+ context.getColor(R.color.app_shortcut_default_foreground),
+ context.getColor(R.color.app_shortcut_default_background)
+ )
+ }
- private fun generateUserThemedIcon(context: Context, iconId: Int): Icon {
- // Get background color from context's theme
- val typedColorBackground = TypedValue()
- context.theme.resolveAttribute(android.R.attr.colorBackground, typedColorBackground, true)
+ private fun generateUserThemedIcon(context: Context, iconId: Int): Icon {
+ // Get background color from context's theme
+ val typedColorBackground = TypedValue()
+ context.theme.resolveAttribute(android.R.attr.colorBackground, typedColorBackground, true)
- // Return an Icon of iconId with those colors
- return generateThemedIcon(
- context, iconId, ThemeStore.accentColor(context), typedColorBackground.data
- )
- }
+ // Return an Icon of iconId with those colors
+ return generateThemedIcon(
+ context, iconId, ThemeStore.accentColor(context), typedColorBackground.data
+ )
+ }
- private fun generateThemedIcon(
- context: Context, iconId: Int, foregroundColor: Int, backgroundColor: Int
- ): Icon {
- // Get and tint foreground and background drawables
- val vectorDrawable = RetroUtil.getTintedVectorDrawable(context, iconId, foregroundColor)
- val backgroundDrawable = RetroUtil.getTintedVectorDrawable(
- context, R.drawable.ic_app_shortcut_background, backgroundColor
- )
+ private fun generateThemedIcon(
+ context: Context, iconId: Int, foregroundColor: Int, backgroundColor: Int
+ ): Icon {
+ // Get and tint foreground and background drawables
+ val vectorDrawable = RetroUtil.getTintedVectorDrawable(context, iconId, foregroundColor)
+ val backgroundDrawable = RetroUtil.getTintedVectorDrawable(
+ context, R.drawable.ic_app_shortcut_background, backgroundColor
+ )
- // Squash the two drawables together
- val layerDrawable = LayerDrawable(arrayOf(backgroundDrawable, vectorDrawable))
+ // Squash the two drawables together
+ val layerDrawable = LayerDrawable(arrayOf(backgroundDrawable, vectorDrawable))
- // Return as an Icon
- return Icon.createWithBitmap(drawableToBitmap(layerDrawable))
- }
+ // Return as an Icon
+ return Icon.createWithBitmap(drawableToBitmap(layerDrawable))
+ }
- private fun drawableToBitmap(drawable: Drawable): Bitmap {
- val bitmap = Bitmap.createBitmap(
- drawable.intrinsicWidth, drawable.intrinsicHeight, Bitmap.Config.ARGB_8888
- )
- val canvas = Canvas(bitmap)
- drawable.setBounds(0, 0, canvas.width, canvas.height)
- drawable.draw(canvas)
- return bitmap
- }
+ private fun drawableToBitmap(drawable: Drawable): Bitmap {
+ val bitmap = Bitmap.createBitmap(
+ drawable.intrinsicWidth, drawable.intrinsicHeight, Bitmap.Config.ARGB_8888
+ )
+ val canvas = Canvas(bitmap)
+ drawable.setBounds(0, 0, canvas.width, canvas.height)
+ drawable.draw(canvas)
+ return bitmap
+ }
}
diff --git a/app/src/main/java/code/name/monkey/retromusic/appshortcuts/AppShortcutLauncherActivity.kt b/app/src/main/java/code/name/monkey/retromusic/appshortcuts/AppShortcutLauncherActivity.kt
index 0426ff65..1bf1e90c 100644
--- a/app/src/main/java/code/name/monkey/retromusic/appshortcuts/AppShortcutLauncherActivity.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/appshortcuts/AppShortcutLauncherActivity.kt
@@ -18,71 +18,76 @@ import android.app.Activity
import android.content.Intent
import android.os.Bundle
import code.name.monkey.retromusic.activities.SearchActivity
-import code.name.monkey.retromusic.appshortcuts.shortcuttype.*
+import code.name.monkey.retromusic.appshortcuts.shortcuttype.LastAddedShortcutType
+import code.name.monkey.retromusic.appshortcuts.shortcuttype.SearchShortCutType
+import code.name.monkey.retromusic.appshortcuts.shortcuttype.ShuffleAllShortcutType
+import code.name.monkey.retromusic.appshortcuts.shortcuttype.TopTracksShortcutType
import code.name.monkey.retromusic.model.Playlist
-import code.name.monkey.retromusic.model.smartplaylist.*
+import code.name.monkey.retromusic.model.smartplaylist.LastAddedPlaylist
+import code.name.monkey.retromusic.model.smartplaylist.MyTopTracksPlaylist
+import code.name.monkey.retromusic.model.smartplaylist.ShuffleAllPlaylist
import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.service.MusicService.*
class AppShortcutLauncherActivity : Activity() {
- public override fun onCreate(savedInstanceState: Bundle?) {
- super.onCreate(savedInstanceState)
+ public override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
- var shortcutType = SHORTCUT_TYPE_NONE
+ var shortcutType = SHORTCUT_TYPE_NONE
- // Set shortcutType from the intent extras
- val extras = intent.extras
- if (extras != null) {
- shortcutType = extras.getInt(KEY_SHORTCUT_TYPE, SHORTCUT_TYPE_NONE)
- }
+ // Set shortcutType from the intent extras
+ val extras = intent.extras
+ if (extras != null) {
+ shortcutType = extras.getInt(KEY_SHORTCUT_TYPE, SHORTCUT_TYPE_NONE)
+ }
- when (shortcutType) {
- SHORTCUT_TYPE_SHUFFLE_ALL -> {
- startServiceWithPlaylist(
- MusicService.SHUFFLE_MODE_SHUFFLE, ShuffleAllPlaylist(applicationContext)
- )
- DynamicShortcutManager.reportShortcutUsed(this, ShuffleAllShortcutType.id)
- }
- SHORTCUT_TYPE_TOP_TRACKS -> {
- startServiceWithPlaylist(
- MusicService.SHUFFLE_MODE_NONE, MyTopTracksPlaylist(applicationContext)
- )
- DynamicShortcutManager.reportShortcutUsed(this, TopTracksShortcutType.id)
- }
- SHORTCUT_TYPE_LAST_ADDED -> {
- startServiceWithPlaylist(
- MusicService.SHUFFLE_MODE_NONE, LastAddedPlaylist(applicationContext)
- )
- DynamicShortcutManager.reportShortcutUsed(this, LastAddedShortcutType.id)
- }
- SHORTCUT_TYPE_SEARCH -> {
- startActivity(Intent(this, SearchActivity::class.java))
- DynamicShortcutManager.reportShortcutUsed(this, SearchShortCutType.id)
- }
- }
- finish()
- }
+ when (shortcutType) {
+ SHORTCUT_TYPE_SHUFFLE_ALL -> {
+ startServiceWithPlaylist(
+ MusicService.SHUFFLE_MODE_SHUFFLE, ShuffleAllPlaylist(applicationContext)
+ )
+ DynamicShortcutManager.reportShortcutUsed(this, ShuffleAllShortcutType.id)
+ }
+ SHORTCUT_TYPE_TOP_TRACKS -> {
+ startServiceWithPlaylist(
+ MusicService.SHUFFLE_MODE_NONE, MyTopTracksPlaylist(applicationContext)
+ )
+ DynamicShortcutManager.reportShortcutUsed(this, TopTracksShortcutType.id)
+ }
+ SHORTCUT_TYPE_LAST_ADDED -> {
+ startServiceWithPlaylist(
+ MusicService.SHUFFLE_MODE_NONE, LastAddedPlaylist(applicationContext)
+ )
+ DynamicShortcutManager.reportShortcutUsed(this, LastAddedShortcutType.id)
+ }
+ SHORTCUT_TYPE_SEARCH -> {
+ startActivity(Intent(this, SearchActivity::class.java))
+ DynamicShortcutManager.reportShortcutUsed(this, SearchShortCutType.id)
+ }
+ }
+ finish()
+ }
- private fun startServiceWithPlaylist(shuffleMode: Int, playlist: Playlist) {
- val intent = Intent(this, MusicService::class.java)
- intent.action = ACTION_PLAY_PLAYLIST
+ private fun startServiceWithPlaylist(shuffleMode: Int, playlist: Playlist) {
+ val intent = Intent(this, MusicService::class.java)
+ intent.action = ACTION_PLAY_PLAYLIST
- val bundle = Bundle()
- bundle.putParcelable(INTENT_EXTRA_PLAYLIST, playlist)
- bundle.putInt(INTENT_EXTRA_SHUFFLE_MODE, shuffleMode)
+ val bundle = Bundle()
+ bundle.putParcelable(INTENT_EXTRA_PLAYLIST, playlist)
+ bundle.putInt(INTENT_EXTRA_SHUFFLE_MODE, shuffleMode)
- intent.putExtras(bundle)
+ intent.putExtras(bundle)
- startService(intent)
- }
+ startService(intent)
+ }
- companion object {
- const val KEY_SHORTCUT_TYPE = "code.name.monkey.retromusic.appshortcuts.ShortcutType"
- const val SHORTCUT_TYPE_SHUFFLE_ALL = 0
- const val SHORTCUT_TYPE_TOP_TRACKS = 1
- const val SHORTCUT_TYPE_LAST_ADDED = 2
- const val SHORTCUT_TYPE_SEARCH = 3
- const val SHORTCUT_TYPE_NONE = 4
- }
+ companion object {
+ const val KEY_SHORTCUT_TYPE = "code.name.monkey.retromusic.appshortcuts.ShortcutType"
+ const val SHORTCUT_TYPE_SHUFFLE_ALL = 0
+ const val SHORTCUT_TYPE_TOP_TRACKS = 1
+ const val SHORTCUT_TYPE_LAST_ADDED = 2
+ const val SHORTCUT_TYPE_SEARCH = 3
+ const val SHORTCUT_TYPE_NONE = 4
+ }
}
diff --git a/app/src/main/java/code/name/monkey/retromusic/appshortcuts/DynamicShortcutManager.kt b/app/src/main/java/code/name/monkey/retromusic/appshortcuts/DynamicShortcutManager.kt
index 790afe57..c77df6b5 100644
--- a/app/src/main/java/code/name/monkey/retromusic/appshortcuts/DynamicShortcutManager.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/appshortcuts/DynamicShortcutManager.kt
@@ -15,52 +15,58 @@
package code.name.monkey.retromusic.appshortcuts
import android.annotation.TargetApi
-import android.content.*
-import android.content.pm.*
+import android.content.Context
+import android.content.Intent
+import android.content.pm.ShortcutInfo
+import android.content.pm.ShortcutManager
import android.graphics.drawable.Icon
import android.os.Build
-import code.name.monkey.retromusic.appshortcuts.shortcuttype.*
+import code.name.monkey.retromusic.appshortcuts.shortcuttype.LastAddedShortcutType
+import code.name.monkey.retromusic.appshortcuts.shortcuttype.SearchShortCutType
+import code.name.monkey.retromusic.appshortcuts.shortcuttype.ShuffleAllShortcutType
+import code.name.monkey.retromusic.appshortcuts.shortcuttype.TopTracksShortcutType
import java.util.*
@TargetApi(Build.VERSION_CODES.N_MR1)
class DynamicShortcutManager(private val context: Context) {
- private val shortcutManager: ShortcutManager = this.context.getSystemService(ShortcutManager::class.java)
+ private val shortcutManager: ShortcutManager =
+ this.context.getSystemService(ShortcutManager::class.java)
- private val defaultShortcuts: List
- get() = Arrays.asList(
- SearchShortCutType(context).shortcutInfo,
- ShuffleAllShortcutType(context).shortcutInfo,
- TopTracksShortcutType(context).shortcutInfo,
- LastAddedShortcutType(context).shortcutInfo
+ private val defaultShortcuts: List
+ get() = Arrays.asList(
+ SearchShortCutType(context).shortcutInfo,
+ ShuffleAllShortcutType(context).shortcutInfo,
+ TopTracksShortcutType(context).shortcutInfo,
+ LastAddedShortcutType(context).shortcutInfo
- )
+ )
- fun initDynamicShortcuts() {
- //if (shortcutManager.dynamicShortcuts.size == 0) {
- shortcutManager.dynamicShortcuts = defaultShortcuts
- //}
- }
+ fun initDynamicShortcuts() {
+ //if (shortcutManager.dynamicShortcuts.size == 0) {
+ shortcutManager.dynamicShortcuts = defaultShortcuts
+ //}
+ }
- fun updateDynamicShortcuts() {
- shortcutManager.updateShortcuts(defaultShortcuts)
- }
+ fun updateDynamicShortcuts() {
+ shortcutManager.updateShortcuts(defaultShortcuts)
+ }
- companion object {
+ companion object {
- fun createShortcut(
- context: Context,
- id: String,
- shortLabel: String,
- longLabel: String,
- icon: Icon,
- intent: Intent
- ): ShortcutInfo {
- return ShortcutInfo.Builder(context, id).setShortLabel(shortLabel)
- .setLongLabel(longLabel).setIcon(icon).setIntent(intent).build()
- }
+ fun createShortcut(
+ context: Context,
+ id: String,
+ shortLabel: String,
+ longLabel: String,
+ icon: Icon,
+ intent: Intent
+ ): ShortcutInfo {
+ return ShortcutInfo.Builder(context, id).setShortLabel(shortLabel)
+ .setLongLabel(longLabel).setIcon(icon).setIntent(intent).build()
+ }
- fun reportShortcutUsed(context: Context, shortcutId: String) {
- context.getSystemService(ShortcutManager::class.java).reportShortcutUsed(shortcutId)
- }
- }
+ fun reportShortcutUsed(context: Context, shortcutId: String) {
+ context.getSystemService(ShortcutManager::class.java).reportShortcutUsed(shortcutId)
+ }
+ }
}
diff --git a/app/src/main/java/code/name/monkey/retromusic/appshortcuts/shortcuttype/BaseShortcutType.kt b/app/src/main/java/code/name/monkey/retromusic/appshortcuts/shortcuttype/BaseShortcutType.kt
index 5ca1284d..c2b376de 100644
--- a/app/src/main/java/code/name/monkey/retromusic/appshortcuts/shortcuttype/BaseShortcutType.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/appshortcuts/shortcuttype/BaseShortcutType.kt
@@ -15,34 +15,36 @@
package code.name.monkey.retromusic.appshortcuts.shortcuttype
import android.annotation.TargetApi
-import android.content.*
+import android.content.Context
+import android.content.Intent
import android.content.pm.ShortcutInfo
-import android.os.*
+import android.os.Build
+import android.os.Bundle
import code.name.monkey.retromusic.appshortcuts.AppShortcutLauncherActivity
@TargetApi(Build.VERSION_CODES.N_MR1)
abstract class BaseShortcutType(internal var context: Context) {
- internal abstract val shortcutInfo: ShortcutInfo
+ internal abstract val shortcutInfo: ShortcutInfo
- /**
- * Creates an Intent that will launch MainActivtiy and immediately play {@param songs} in either shuffle or normal mode
- *
- * @param shortcutType Describes the type of shortcut to create (ShuffleAll, TopTracks, custom playlist, etc.)
- * @return
- */
- internal fun getPlaySongsIntent(shortcutType: Int): Intent {
- val intent = Intent(context, AppShortcutLauncherActivity::class.java)
- intent.action = Intent.ACTION_VIEW
- val b = Bundle()
- b.putInt(AppShortcutLauncherActivity.KEY_SHORTCUT_TYPE, shortcutType)
- intent.putExtras(b)
- return intent
- }
+ /**
+ * Creates an Intent that will launch MainActivtiy and immediately play {@param songs} in either shuffle or normal mode
+ *
+ * @param shortcutType Describes the type of shortcut to create (ShuffleAll, TopTracks, custom playlist, etc.)
+ * @return
+ */
+ internal fun getPlaySongsIntent(shortcutType: Int): Intent {
+ val intent = Intent(context, AppShortcutLauncherActivity::class.java)
+ intent.action = Intent.ACTION_VIEW
+ val b = Bundle()
+ b.putInt(AppShortcutLauncherActivity.KEY_SHORTCUT_TYPE, shortcutType)
+ intent.putExtras(b)
+ return intent
+ }
- companion object {
- internal const val ID_PREFIX = "code.name.monkey.retromusic.appshortcuts.id."
- val id: String
- get() = ID_PREFIX + "invalid"
- }
+ companion object {
+ internal const val ID_PREFIX = "code.name.monkey.retromusic.appshortcuts.id."
+ val id: String
+ get() = ID_PREFIX + "invalid"
+ }
}
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 df92969b..b590a943 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
@@ -19,27 +19,28 @@ import android.content.Context
import android.content.pm.ShortcutInfo
import android.os.Build
import code.name.monkey.retromusic.R
-import code.name.monkey.retromusic.appshortcuts.*
+import code.name.monkey.retromusic.appshortcuts.AppShortcutIconGenerator
+import code.name.monkey.retromusic.appshortcuts.AppShortcutLauncherActivity
@TargetApi(Build.VERSION_CODES.N_MR1)
class LastAddedShortcutType(context: Context) : BaseShortcutType(context) {
- override val shortcutInfo: ShortcutInfo
- get() = ShortcutInfo.Builder(
- context,
- id
- ).setShortLabel(context.getString(R.string.app_shortcut_last_added_short)).setLongLabel(
- context.getString(R.string.app_shortcut_last_added_long)
- ).setIcon(
- AppShortcutIconGenerator.generateThemedIcon(
- context,
- R.drawable.ic_app_shortcut_last_added
- )
- ).setIntent(getPlaySongsIntent(AppShortcutLauncherActivity.SHORTCUT_TYPE_LAST_ADDED)).build()
+ override val shortcutInfo: ShortcutInfo
+ get() = ShortcutInfo.Builder(
+ context,
+ id
+ ).setShortLabel(context.getString(R.string.app_shortcut_last_added_short)).setLongLabel(
+ context.getString(R.string.app_shortcut_last_added_long)
+ ).setIcon(
+ AppShortcutIconGenerator.generateThemedIcon(
+ context,
+ R.drawable.ic_app_shortcut_last_added
+ )
+ ).setIntent(getPlaySongsIntent(AppShortcutLauncherActivity.SHORTCUT_TYPE_LAST_ADDED)).build()
- companion object {
+ companion object {
- val id: String
- get() = BaseShortcutType.ID_PREFIX + "last_added"
- }
+ val id: String
+ get() = BaseShortcutType.ID_PREFIX + "last_added"
+ }
}
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 ca2e7c4a..60c91883 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
@@ -19,24 +19,25 @@ import android.content.Context
import android.content.pm.ShortcutInfo
import android.os.Build
import code.name.monkey.retromusic.R
-import code.name.monkey.retromusic.appshortcuts.*
+import code.name.monkey.retromusic.appshortcuts.AppShortcutIconGenerator
+import code.name.monkey.retromusic.appshortcuts.AppShortcutLauncherActivity
@TargetApi(Build.VERSION_CODES.N_MR1)
class SearchShortCutType(context: Context) : BaseShortcutType(context) {
- companion object {
+ companion object {
- val id: String
- get() = BaseShortcutType.ID_PREFIX + "search"
- }
+ val id: String
+ get() = BaseShortcutType.ID_PREFIX + "search"
+ }
- override val shortcutInfo: ShortcutInfo
- get() = ShortcutInfo.Builder(
- context,
- id
- ).setShortLabel(context.getString(R.string.action_search)).setLongLabel(context.getString(R.string.search_hint)).setIcon(
- AppShortcutIconGenerator.generateThemedIcon(
- context,
- R.drawable.ic_app_shortcut_search
- )
- ).setIntent(getPlaySongsIntent(AppShortcutLauncherActivity.SHORTCUT_TYPE_SEARCH)).build()
+ override val shortcutInfo: ShortcutInfo
+ get() = ShortcutInfo.Builder(
+ context,
+ id
+ ).setShortLabel(context.getString(R.string.action_search)).setLongLabel(context.getString(R.string.search_hint)).setIcon(
+ AppShortcutIconGenerator.generateThemedIcon(
+ context,
+ R.drawable.ic_app_shortcut_search
+ )
+ ).setIntent(getPlaySongsIntent(AppShortcutLauncherActivity.SHORTCUT_TYPE_SEARCH)).build()
}
\ No newline at end of file
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 c5b7f24c..8f869d20 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
@@ -19,25 +19,26 @@ import android.content.Context
import android.content.pm.ShortcutInfo
import android.os.Build
import code.name.monkey.retromusic.R
-import code.name.monkey.retromusic.appshortcuts.*
+import code.name.monkey.retromusic.appshortcuts.AppShortcutIconGenerator
+import code.name.monkey.retromusic.appshortcuts.AppShortcutLauncherActivity
@TargetApi(Build.VERSION_CODES.N_MR1)
class ShuffleAllShortcutType(context: Context) : BaseShortcutType(context) {
- override val shortcutInfo: ShortcutInfo
- get() = ShortcutInfo.Builder(
- context, id
- ).setShortLabel(context.getString(R.string.app_shortcut_shuffle_all_short)).setLongLabel(
- context.getString(R.string.app_shortcut_shuffle_all_long)
- ).setIcon(
- AppShortcutIconGenerator.generateThemedIcon(
- context, R.drawable.ic_app_shortcut_shuffle_all
- )
- ).setIntent(getPlaySongsIntent(AppShortcutLauncherActivity.SHORTCUT_TYPE_SHUFFLE_ALL)).build()
+ override val shortcutInfo: ShortcutInfo
+ get() = ShortcutInfo.Builder(
+ context, id
+ ).setShortLabel(context.getString(R.string.app_shortcut_shuffle_all_short)).setLongLabel(
+ context.getString(R.string.app_shortcut_shuffle_all_long)
+ ).setIcon(
+ AppShortcutIconGenerator.generateThemedIcon(
+ context, R.drawable.ic_app_shortcut_shuffle_all
+ )
+ ).setIntent(getPlaySongsIntent(AppShortcutLauncherActivity.SHORTCUT_TYPE_SHUFFLE_ALL)).build()
- companion object {
+ companion object {
- val id: String
- get() = BaseShortcutType.ID_PREFIX + "shuffle_all"
- }
+ val id: String
+ get() = BaseShortcutType.ID_PREFIX + "shuffle_all"
+ }
}
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 32e53e41..ed274cdd 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
@@ -19,25 +19,26 @@ import android.content.Context
import android.content.pm.ShortcutInfo
import android.os.Build
import code.name.monkey.retromusic.R
-import code.name.monkey.retromusic.appshortcuts.*
+import code.name.monkey.retromusic.appshortcuts.AppShortcutIconGenerator
+import code.name.monkey.retromusic.appshortcuts.AppShortcutLauncherActivity
@TargetApi(Build.VERSION_CODES.N_MR1)
class TopTracksShortcutType(context: Context) : BaseShortcutType(context) {
- override val shortcutInfo: ShortcutInfo
- get() = ShortcutInfo.Builder(
- context, id
- ).setShortLabel(context.getString(R.string.app_shortcut_top_tracks_short)).setLongLabel(
- context.getString(R.string.app_shortcut_top_tracks_long)
- ).setIcon(
- AppShortcutIconGenerator.generateThemedIcon(
- context, R.drawable.ic_app_shortcut_top_tracks
- )
- ).setIntent(getPlaySongsIntent(AppShortcutLauncherActivity.SHORTCUT_TYPE_TOP_TRACKS)).build()
+ override val shortcutInfo: ShortcutInfo
+ get() = ShortcutInfo.Builder(
+ context, id
+ ).setShortLabel(context.getString(R.string.app_shortcut_top_tracks_short)).setLongLabel(
+ context.getString(R.string.app_shortcut_top_tracks_long)
+ ).setIcon(
+ AppShortcutIconGenerator.generateThemedIcon(
+ context, R.drawable.ic_app_shortcut_top_tracks
+ )
+ ).setIntent(getPlaySongsIntent(AppShortcutLauncherActivity.SHORTCUT_TYPE_TOP_TRACKS)).build()
- companion object {
+ companion object {
- val id: String
- get() = BaseShortcutType.ID_PREFIX + "top_tracks"
- }
+ val id: String
+ get() = BaseShortcutType.ID_PREFIX + "top_tracks"
+ }
}
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 a440b0bc..22951613 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
@@ -45,40 +45,40 @@ class AppWidgetBig : BaseAppWidget() {
*/
override fun defaultAppWidget(context: Context, appWidgetIds: IntArray) {
val appWidgetView = RemoteViews(
- context.packageName, code.name.monkey.retromusic.R.layout.app_widget_big
+ context.packageName, code.name.monkey.retromusic.R.layout.app_widget_big
)
appWidgetView.setViewVisibility(
- code.name.monkey.retromusic.R.id.media_titles,
- View.INVISIBLE
+ code.name.monkey.retromusic.R.id.media_titles,
+ View.INVISIBLE
)
appWidgetView.setImageViewResource(R.id.image, R.drawable.default_audio_art)
appWidgetView.setImageViewBitmap(
- R.id.button_next, BaseAppWidget.createBitmap(
+ R.id.button_next, BaseAppWidget.createBitmap(
RetroUtil.getTintedVectorDrawable(
- context,
- code.name.monkey.retromusic.R.drawable.ic_skip_next_white_24dp,
- MaterialValueHelper.getPrimaryTextColor(context, false)
+ context,
+ code.name.monkey.retromusic.R.drawable.ic_skip_next_white_24dp,
+ MaterialValueHelper.getPrimaryTextColor(context, false)
)!!, 1f
- )
+ )
)
appWidgetView.setImageViewBitmap(
- R.id.button_prev, BaseAppWidget.Companion.createBitmap(
+ R.id.button_prev, BaseAppWidget.Companion.createBitmap(
RetroUtil.getTintedVectorDrawable(
- context,
- code.name.monkey.retromusic.R.drawable.ic_skip_previous_white_24dp,
- MaterialValueHelper.getPrimaryTextColor(context, false)
+ context,
+ code.name.monkey.retromusic.R.drawable.ic_skip_previous_white_24dp,
+ MaterialValueHelper.getPrimaryTextColor(context, false)
)!!, 1f
- )
+ )
)
appWidgetView.setImageViewBitmap(
- R.id.button_toggle_play_pause, BaseAppWidget.Companion.createBitmap(
+ R.id.button_toggle_play_pause, BaseAppWidget.Companion.createBitmap(
RetroUtil.getTintedVectorDrawable(
- context,
- code.name.monkey.retromusic.R.drawable.ic_play_arrow_white_32dp,
- MaterialValueHelper.getPrimaryTextColor(context, false)
+ context,
+ code.name.monkey.retromusic.R.drawable.ic_play_arrow_white_32dp,
+ MaterialValueHelper.getPrimaryTextColor(context, false)
)!!, 1f
- )
+ )
)
linkButtons(context, appWidgetView)
@@ -90,7 +90,7 @@ class AppWidgetBig : BaseAppWidget() {
*/
override fun performUpdate(service: MusicService, appWidgetIds: IntArray?) {
val appWidgetView = RemoteViews(
- service.packageName, code.name.monkey.retromusic.R.layout.app_widget_big
+ service.packageName, code.name.monkey.retromusic.R.layout.app_widget_big
)
val isPlaying = service.isPlaying
@@ -99,51 +99,52 @@ class AppWidgetBig : BaseAppWidget() {
// Set the titles and artwork
if (TextUtils.isEmpty(song.title) && TextUtils.isEmpty(song.artistName)) {
appWidgetView.setViewVisibility(
- code.name.monkey.retromusic.R.id.media_titles,
- View.INVISIBLE
+ code.name.monkey.retromusic.R.id.media_titles,
+ View.INVISIBLE
)
} else {
appWidgetView.setViewVisibility(
- code.name.monkey.retromusic.R.id.media_titles,
- View.VISIBLE
+ code.name.monkey.retromusic.R.id.media_titles,
+ View.VISIBLE
)
appWidgetView.setTextViewText(code.name.monkey.retromusic.R.id.title, song.title)
appWidgetView.setTextViewText(
- code.name.monkey.retromusic.R.id.text,
- getSongArtistAndAlbum(song)
+ code.name.monkey.retromusic.R.id.text,
+ getSongArtistAndAlbum(song)
)
}
// Set correct drawable for pause state
- val playPauseRes = if (isPlaying) code.name.monkey.retromusic.R.drawable.ic_pause_white_24dp else code.name.monkey.retromusic.R.drawable.ic_play_arrow_white_32dp
+ val playPauseRes =
+ if (isPlaying) code.name.monkey.retromusic.R.drawable.ic_pause_white_24dp else code.name.monkey.retromusic.R.drawable.ic_play_arrow_white_32dp
appWidgetView.setImageViewBitmap(
- R.id.button_toggle_play_pause, BaseAppWidget.createBitmap(
+ R.id.button_toggle_play_pause, BaseAppWidget.createBitmap(
RetroUtil.getTintedVectorDrawable(
- service,
- playPauseRes,
- MaterialValueHelper.getPrimaryTextColor(service, false)
+ service,
+ playPauseRes,
+ MaterialValueHelper.getPrimaryTextColor(service, false)
)!!, 1f
- )
+ )
)
// Set prev/next button drawables
appWidgetView.setImageViewBitmap(
- R.id.button_next, BaseAppWidget.Companion.createBitmap(
+ R.id.button_next, BaseAppWidget.Companion.createBitmap(
RetroUtil.getTintedVectorDrawable(
- service,
- code.name.monkey.retromusic.R.drawable.ic_skip_next_white_24dp,
- MaterialValueHelper.getPrimaryTextColor(service, false)
+ service,
+ code.name.monkey.retromusic.R.drawable.ic_skip_next_white_24dp,
+ MaterialValueHelper.getPrimaryTextColor(service, false)
)!!, 1f
- )
+ )
)
appWidgetView.setImageViewBitmap(
- R.id.button_prev, BaseAppWidget.Companion.createBitmap(
+ R.id.button_prev, BaseAppWidget.Companion.createBitmap(
RetroUtil.getTintedVectorDrawable(
- service,
- code.name.monkey.retromusic.R.drawable.ic_skip_previous_white_24dp,
- MaterialValueHelper.getPrimaryTextColor(service, false)
+ service,
+ code.name.monkey.retromusic.R.drawable.ic_skip_previous_white_24dp,
+ MaterialValueHelper.getPrimaryTextColor(service, false)
)!!, 1f
- )
+ )
)
// Link actions buttons to intents
@@ -158,32 +159,32 @@ class AppWidgetBig : BaseAppWidget() {
Glide.clear(target)
}
target = SongGlideRequest.Builder.from(Glide.with(appContext), song)
- .checkIgnoreMediaStore(appContext).asBitmap().build()
- .into(object : SimpleTarget(widgetImageSize, widgetImageSize) {
- override fun onResourceReady(
- resource: Bitmap,
- glideAnimation: GlideAnimation
- ) {
- update(resource)
- }
+ .checkIgnoreMediaStore(appContext).asBitmap().build()
+ .into(object : SimpleTarget(widgetImageSize, widgetImageSize) {
+ override fun onResourceReady(
+ resource: Bitmap,
+ glideAnimation: GlideAnimation
+ ) {
+ update(resource)
+ }
- override fun onLoadFailed(e: Exception?, errorDrawable: Drawable?) {
- super.onLoadFailed(e, errorDrawable)
- update(null)
- }
+ override fun onLoadFailed(e: Exception?, errorDrawable: Drawable?) {
+ super.onLoadFailed(e, errorDrawable)
+ update(null)
+ }
- private fun update(bitmap: Bitmap?) {
- if (bitmap == null) {
- appWidgetView.setImageViewResource(
- R.id.image,
- R.drawable.default_audio_art
- )
- } else {
- appWidgetView.setImageViewBitmap(R.id.image, bitmap)
- }
- pushUpdate(appContext, appWidgetIds, appWidgetView)
+ private fun update(bitmap: Bitmap?) {
+ if (bitmap == null) {
+ appWidgetView.setImageViewResource(
+ R.id.image,
+ R.drawable.default_audio_art
+ )
+ } else {
+ appWidgetView.setImageViewBitmap(R.id.image, bitmap)
}
- });
+ pushUpdate(appContext, appWidgetIds, appWidgetView)
+ }
+ });
}
}
diff --git a/app/src/main/java/code/name/monkey/retromusic/appwidgets/AppWidgetCard.kt b/app/src/main/java/code/name/monkey/retromusic/appwidgets/AppWidgetCard.kt
index c92772e5..38b73698 100644
--- a/app/src/main/java/code/name/monkey/retromusic/appwidgets/AppWidgetCard.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/appwidgets/AppWidgetCard.kt
@@ -15,7 +15,9 @@
package code.name.monkey.retromusic.appwidgets
import android.app.PendingIntent
-import android.content.*
+import android.content.ComponentName
+import android.content.Context
+import android.content.Intent
import android.graphics.Bitmap
import android.graphics.drawable.Drawable
import android.text.TextUtils
@@ -29,231 +31,235 @@ import code.name.monkey.retromusic.glide.SongGlideRequest
import code.name.monkey.retromusic.glide.palette.BitmapPaletteWrapper
import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.service.MusicService.*
-import code.name.monkey.retromusic.util.*
+import code.name.monkey.retromusic.util.ImageUtil
+import code.name.monkey.retromusic.util.RetroUtil
import com.bumptech.glide.Glide
import com.bumptech.glide.request.animation.GlideAnimation
-import com.bumptech.glide.request.target.*
+import com.bumptech.glide.request.target.SimpleTarget
import com.bumptech.glide.request.target.Target
class AppWidgetCard : BaseAppWidget() {
- private var target: Target? = null // for cancellation
+ private var target: Target? = null // for cancellation
- /**
- * Initialize given widgets to default state, where we launch Music on default click and hide
- * actions if service not running.
- */
- override fun defaultAppWidget(context: Context, appWidgetIds: IntArray) {
- val appWidgetView = RemoteViews(context.packageName, R.layout.app_widget_card)
+ /**
+ * Initialize given widgets to default state, where we launch Music on default click and hide
+ * actions if service not running.
+ */
+ override fun defaultAppWidget(context: Context, appWidgetIds: IntArray) {
+ val appWidgetView = RemoteViews(context.packageName, R.layout.app_widget_card)
- appWidgetView.setViewVisibility(R.id.media_titles, View.INVISIBLE)
- appWidgetView.setImageViewResource(R.id.image, R.drawable.default_audio_art)
- appWidgetView.setImageViewBitmap(
- R.id.button_next, createBitmap(
- RetroUtil.getTintedVectorDrawable(
- context,
- R.drawable.ic_skip_next_white_24dp,
- MaterialValueHelper.getSecondaryTextColor(
- context, true
- )
- )!!, 1f
- )
- )
- appWidgetView.setImageViewBitmap(
- R.id.button_prev, createBitmap(
- RetroUtil.getTintedVectorDrawable(
- context,
- R.drawable.ic_skip_previous_white_24dp,
- MaterialValueHelper.getSecondaryTextColor(
- context, true
- )
- )!!, 1f
- )
- )
- appWidgetView.setImageViewBitmap(
- R.id.button_toggle_play_pause, createBitmap(
- RetroUtil.getTintedVectorDrawable(
- context,
- R.drawable.ic_play_arrow_white_32dp,
- MaterialValueHelper.getSecondaryTextColor(
- context, true
- )
- )!!, 1f
- )
- )
+ appWidgetView.setViewVisibility(R.id.media_titles, View.INVISIBLE)
+ appWidgetView.setImageViewResource(R.id.image, R.drawable.default_audio_art)
+ appWidgetView.setImageViewBitmap(
+ R.id.button_next, createBitmap(
+ RetroUtil.getTintedVectorDrawable(
+ context,
+ R.drawable.ic_skip_next_white_24dp,
+ MaterialValueHelper.getSecondaryTextColor(
+ context, true
+ )
+ )!!, 1f
+ )
+ )
+ appWidgetView.setImageViewBitmap(
+ R.id.button_prev, createBitmap(
+ RetroUtil.getTintedVectorDrawable(
+ context,
+ R.drawable.ic_skip_previous_white_24dp,
+ MaterialValueHelper.getSecondaryTextColor(
+ context, true
+ )
+ )!!, 1f
+ )
+ )
+ appWidgetView.setImageViewBitmap(
+ R.id.button_toggle_play_pause, createBitmap(
+ RetroUtil.getTintedVectorDrawable(
+ context,
+ R.drawable.ic_play_arrow_white_32dp,
+ MaterialValueHelper.getSecondaryTextColor(
+ context, true
+ )
+ )!!, 1f
+ )
+ )
- linkButtons(context, appWidgetView)
- pushUpdate(context, appWidgetIds, appWidgetView)
- }
+ linkButtons(context, appWidgetView)
+ pushUpdate(context, appWidgetIds, appWidgetView)
+ }
- /**
- * Update all active widget instances by pushing changes
- */
- override fun performUpdate(service: MusicService, appWidgetIds: IntArray?) {
- val appWidgetView = RemoteViews(service.packageName, R.layout.app_widget_card)
+ /**
+ * Update all active widget instances by pushing changes
+ */
+ override fun performUpdate(service: MusicService, appWidgetIds: IntArray?) {
+ val appWidgetView = RemoteViews(service.packageName, R.layout.app_widget_card)
- val isPlaying = service.isPlaying
- val song = service.currentSong
+ val isPlaying = service.isPlaying
+ val song = service.currentSong
- // Set the titles and artwork
- if (TextUtils.isEmpty(song.title) && TextUtils.isEmpty(song.artistName)) {
- appWidgetView.setViewVisibility(R.id.media_titles, View.INVISIBLE)
- } else {
- appWidgetView.setViewVisibility(R.id.media_titles, View.VISIBLE)
- appWidgetView.setTextViewText(R.id.title, song.title)
- appWidgetView.setTextViewText(R.id.text, getSongArtistAndAlbum(song))
- }
+ // Set the titles and artwork
+ if (TextUtils.isEmpty(song.title) && TextUtils.isEmpty(song.artistName)) {
+ appWidgetView.setViewVisibility(R.id.media_titles, View.INVISIBLE)
+ } else {
+ appWidgetView.setViewVisibility(R.id.media_titles, View.VISIBLE)
+ appWidgetView.setTextViewText(R.id.title, song.title)
+ appWidgetView.setTextViewText(R.id.text, getSongArtistAndAlbum(song))
+ }
- // Set correct drawable for pause state
- val playPauseRes = if (isPlaying) R.drawable.ic_pause_white_24dp else R.drawable.ic_play_arrow_white_32dp
- appWidgetView.setImageViewBitmap(
- R.id.button_toggle_play_pause, createBitmap(
- RetroUtil.getTintedVectorDrawable(
- service,
- playPauseRes,
- MaterialValueHelper.getSecondaryTextColor(service, true)
- )!!, 1f
- )
- )
+ // Set correct drawable for pause state
+ val playPauseRes =
+ if (isPlaying) R.drawable.ic_pause_white_24dp else R.drawable.ic_play_arrow_white_32dp
+ appWidgetView.setImageViewBitmap(
+ R.id.button_toggle_play_pause, createBitmap(
+ RetroUtil.getTintedVectorDrawable(
+ service,
+ playPauseRes,
+ MaterialValueHelper.getSecondaryTextColor(service, true)
+ )!!, 1f
+ )
+ )
- // Set prev/next button drawables
- appWidgetView.setImageViewBitmap(
- R.id.button_next, createBitmap(
- RetroUtil.getTintedVectorDrawable(
- service,
- R.drawable.ic_skip_next_white_24dp,
- MaterialValueHelper.getSecondaryTextColor(service, true)
- )!!, 1f
- )
- )
- appWidgetView.setImageViewBitmap(
- R.id.button_prev, createBitmap(
- RetroUtil.getTintedVectorDrawable(
- service,
- R.drawable.ic_skip_previous_white_24dp,
- MaterialValueHelper.getSecondaryTextColor(service, true)
- )!!, 1f
- )
- )
+ // Set prev/next button drawables
+ appWidgetView.setImageViewBitmap(
+ R.id.button_next, createBitmap(
+ RetroUtil.getTintedVectorDrawable(
+ service,
+ R.drawable.ic_skip_next_white_24dp,
+ MaterialValueHelper.getSecondaryTextColor(service, true)
+ )!!, 1f
+ )
+ )
+ appWidgetView.setImageViewBitmap(
+ R.id.button_prev, createBitmap(
+ RetroUtil.getTintedVectorDrawable(
+ service,
+ R.drawable.ic_skip_previous_white_24dp,
+ MaterialValueHelper.getSecondaryTextColor(service, true)
+ )!!, 1f
+ )
+ )
- // Link actions buttons to intents
- linkButtons(service, appWidgetView)
+ // Link actions buttons to intents
+ linkButtons(service, appWidgetView)
- if (imageSize == 0) {
- imageSize = service.resources.getDimensionPixelSize(code.name.monkey.retromusic.R.dimen.app_widget_card_image_size)
- }
- if (cardRadius == 0f) {
- cardRadius = service.resources.getDimension(code.name.monkey.retromusic.R.dimen.app_widget_card_radius)
- }
- val appContext = service.applicationContext
- // Load the album cover async and push the update on completion
- service.runOnUiThread {
- if (target != null) {
- Glide.clear(target)
- }
- target = SongGlideRequest.Builder.from(Glide.with(service), song)
- .checkIgnoreMediaStore(service).generatePalette(service).build().centerCrop()
- .into(object : SimpleTarget(imageSize, imageSize) {
- override fun onResourceReady(
- resource: BitmapPaletteWrapper,
- glideAnimation: GlideAnimation
- ) {
- val palette = resource.palette
- update(
- resource.bitmap, palette.getVibrantColor(
- palette.getMutedColor(
- MaterialValueHelper.getSecondaryTextColor(
- service, true
- )
- )
- )
- )
- }
+ if (imageSize == 0) {
+ imageSize =
+ service.resources.getDimensionPixelSize(code.name.monkey.retromusic.R.dimen.app_widget_card_image_size)
+ }
+ if (cardRadius == 0f) {
+ cardRadius =
+ service.resources.getDimension(code.name.monkey.retromusic.R.dimen.app_widget_card_radius)
+ }
+ val appContext = service.applicationContext
+ // Load the album cover async and push the update on completion
+ service.runOnUiThread {
+ if (target != null) {
+ Glide.clear(target)
+ }
+ target = SongGlideRequest.Builder.from(Glide.with(service), song)
+ .checkIgnoreMediaStore(service).generatePalette(service).build().centerCrop()
+ .into(object : SimpleTarget(imageSize, imageSize) {
+ override fun onResourceReady(
+ resource: BitmapPaletteWrapper,
+ glideAnimation: GlideAnimation
+ ) {
+ val palette = resource.palette
+ update(
+ resource.bitmap, palette.getVibrantColor(
+ palette.getMutedColor(
+ MaterialValueHelper.getSecondaryTextColor(
+ service, true
+ )
+ )
+ )
+ )
+ }
- override fun onLoadFailed(e: Exception?, errorDrawable: Drawable?) {
- super.onLoadFailed(e, errorDrawable)
- update(null, MaterialValueHelper.getSecondaryTextColor(service, true))
- }
+ override fun onLoadFailed(e: Exception?, errorDrawable: Drawable?) {
+ super.onLoadFailed(e, errorDrawable)
+ update(null, MaterialValueHelper.getSecondaryTextColor(service, true))
+ }
- private fun update(bitmap: Bitmap?, color: Int) {
- // Set correct drawable for pause state
- appWidgetView.setImageViewBitmap(
- R.id.button_toggle_play_pause, ImageUtil.createBitmap(
- ImageUtil.getTintedVectorDrawable(
- service, playPauseRes, color
- )
- )
- )
+ private fun update(bitmap: Bitmap?, color: Int) {
+ // Set correct drawable for pause state
+ appWidgetView.setImageViewBitmap(
+ R.id.button_toggle_play_pause, ImageUtil.createBitmap(
+ ImageUtil.getTintedVectorDrawable(
+ service, playPauseRes, color
+ )
+ )
+ )
- // Set prev/next button drawables
- appWidgetView.setImageViewBitmap(
- R.id.button_next, ImageUtil.createBitmap(
- ImageUtil.getTintedVectorDrawable(
- service, R.drawable.ic_skip_next_white_24dp, color
- )
- )
- )
- appWidgetView.setImageViewBitmap(
- R.id.button_prev, ImageUtil.createBitmap(
- ImageUtil.getTintedVectorDrawable(
- service, R.drawable.ic_skip_previous_white_24dp, color
- )
- )
- )
+ // Set prev/next button drawables
+ appWidgetView.setImageViewBitmap(
+ R.id.button_next, ImageUtil.createBitmap(
+ ImageUtil.getTintedVectorDrawable(
+ service, R.drawable.ic_skip_next_white_24dp, color
+ )
+ )
+ )
+ appWidgetView.setImageViewBitmap(
+ R.id.button_prev, ImageUtil.createBitmap(
+ ImageUtil.getTintedVectorDrawable(
+ service, R.drawable.ic_skip_previous_white_24dp, color
+ )
+ )
+ )
- val image = getAlbumArtDrawable(service.resources, bitmap)
- val roundedBitmap = createRoundedBitmap(
- image, imageSize, imageSize, cardRadius, 0F, cardRadius, 0F
- )
- appWidgetView.setImageViewBitmap(R.id.image, roundedBitmap)
+ val image = getAlbumArtDrawable(service.resources, bitmap)
+ val roundedBitmap = createRoundedBitmap(
+ image, imageSize, imageSize, cardRadius, 0F, cardRadius, 0F
+ )
+ appWidgetView.setImageViewBitmap(R.id.image, roundedBitmap)
- pushUpdate(service, appWidgetIds, appWidgetView)
- }
- })
- }
- }
+ pushUpdate(service, appWidgetIds, appWidgetView)
+ }
+ })
+ }
+ }
- /**
- * Link up various button actions using [PendingIntent].
- */
- private fun linkButtons(context: Context, views: RemoteViews) {
- val action: Intent = Intent(context, MainActivity::class.java).putExtra("expand", true)
- var pendingIntent: PendingIntent
+ /**
+ * Link up various button actions using [PendingIntent].
+ */
+ private fun linkButtons(context: Context, views: RemoteViews) {
+ val action: Intent = Intent(context, MainActivity::class.java).putExtra("expand", true)
+ var pendingIntent: PendingIntent
- val serviceName = ComponentName(context, MusicService::class.java)
+ val serviceName = ComponentName(context, MusicService::class.java)
- // Home
- action.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP
- pendingIntent = PendingIntent.getActivity(context, 0, action, 0)
- views.setOnClickPendingIntent(R.id.image, pendingIntent)
- views.setOnClickPendingIntent(R.id.media_titles, pendingIntent)
+ // Home
+ action.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP
+ pendingIntent = PendingIntent.getActivity(context, 0, action, 0)
+ views.setOnClickPendingIntent(R.id.image, pendingIntent)
+ views.setOnClickPendingIntent(R.id.media_titles, pendingIntent)
- // Previous track
- pendingIntent = buildPendingIntent(context, ACTION_REWIND, serviceName)
- views.setOnClickPendingIntent(R.id.button_prev, pendingIntent)
+ // Previous track
+ pendingIntent = buildPendingIntent(context, ACTION_REWIND, serviceName)
+ views.setOnClickPendingIntent(R.id.button_prev, pendingIntent)
- // Play and pause
- pendingIntent = buildPendingIntent(context, ACTION_TOGGLE_PAUSE, serviceName)
- views.setOnClickPendingIntent(R.id.button_toggle_play_pause, pendingIntent)
+ // Play and pause
+ pendingIntent = buildPendingIntent(context, ACTION_TOGGLE_PAUSE, serviceName)
+ views.setOnClickPendingIntent(R.id.button_toggle_play_pause, pendingIntent)
- // Next track
- pendingIntent = buildPendingIntent(context, ACTION_SKIP, serviceName)
- views.setOnClickPendingIntent(R.id.button_next, pendingIntent)
- }
+ // Next track
+ pendingIntent = buildPendingIntent(context, ACTION_SKIP, serviceName)
+ views.setOnClickPendingIntent(R.id.button_next, pendingIntent)
+ }
- companion object {
+ companion object {
- const val NAME = "app_widget_card"
+ const val NAME = "app_widget_card"
- private var mInstance: AppWidgetCard? = null
- private var imageSize = 0
- private var cardRadius = 0f
+ private var mInstance: AppWidgetCard? = null
+ private var imageSize = 0
+ private var cardRadius = 0f
- val instance: AppWidgetCard
- @Synchronized get() {
- if (mInstance == null) {
- mInstance = AppWidgetCard()
- }
- return mInstance!!
- }
- }
+ val instance: AppWidgetCard
+ @Synchronized get() {
+ if (mInstance == null) {
+ mInstance = AppWidgetCard()
+ }
+ return mInstance!!
+ }
+ }
}
diff --git a/app/src/main/java/code/name/monkey/retromusic/appwidgets/AppWidgetClassic.kt b/app/src/main/java/code/name/monkey/retromusic/appwidgets/AppWidgetClassic.kt
index 24f24c09..a8581501 100644
--- a/app/src/main/java/code/name/monkey/retromusic/appwidgets/AppWidgetClassic.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/appwidgets/AppWidgetClassic.kt
@@ -31,9 +31,7 @@ import code.name.monkey.retromusic.appwidgets.base.BaseAppWidget
import code.name.monkey.retromusic.glide.SongGlideRequest
import code.name.monkey.retromusic.glide.palette.BitmapPaletteWrapper
import code.name.monkey.retromusic.service.MusicService
-import code.name.monkey.retromusic.service.MusicService.ACTION_REWIND
-import code.name.monkey.retromusic.service.MusicService.ACTION_SKIP
-import code.name.monkey.retromusic.service.MusicService.ACTION_TOGGLE_PAUSE
+import code.name.monkey.retromusic.service.MusicService.*
import code.name.monkey.retromusic.util.ImageUtil
import code.name.monkey.retromusic.util.RetroUtil
import com.bumptech.glide.Glide
@@ -111,7 +109,8 @@ class AppWidgetClassic : BaseAppWidget() {
linkButtons(service, appWidgetView)
if (imageSize == 0) {
- imageSize = service.resources.getDimensionPixelSize(R.dimen.app_widget_classic_image_size)
+ imageSize =
+ service.resources.getDimensionPixelSize(R.dimen.app_widget_classic_image_size)
}
if (cardRadius == 0f) {
cardRadius = service.resources.getDimension(R.dimen.app_widget_card_radius)
@@ -155,7 +154,13 @@ class AppWidgetClassic : BaseAppWidget() {
if (isPlaying) R.drawable.ic_pause_white_24dp else R.drawable.ic_play_arrow_white_24dp
appWidgetView.setImageViewBitmap(
R.id.button_toggle_play_pause,
- ImageUtil.createBitmap(ImageUtil.getTintedVectorDrawable(service, playPauseRes, color))
+ ImageUtil.createBitmap(
+ ImageUtil.getTintedVectorDrawable(
+ service,
+ playPauseRes,
+ color
+ )
+ )
)
// Set prev/next button drawables
@@ -182,7 +187,15 @@ class AppWidgetClassic : BaseAppWidget() {
val image = getAlbumArtDrawable(service.resources, bitmap)
val roundedBitmap =
- createRoundedBitmap(image, imageSize, imageSize, cardRadius, 0F, cardRadius, 0F)
+ createRoundedBitmap(
+ image,
+ imageSize,
+ imageSize,
+ cardRadius,
+ 0F,
+ cardRadius,
+ 0F
+ )
appWidgetView.setImageViewBitmap(R.id.image, roundedBitmap)
pushUpdate(appContext, appWidgetIds, appWidgetView)
diff --git a/app/src/main/java/code/name/monkey/retromusic/appwidgets/AppWidgetSmall.kt b/app/src/main/java/code/name/monkey/retromusic/appwidgets/AppWidgetSmall.kt
index 53715e96..0eae1a4e 100644
--- a/app/src/main/java/code/name/monkey/retromusic/appwidgets/AppWidgetSmall.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/appwidgets/AppWidgetSmall.kt
@@ -49,9 +49,36 @@ class AppWidgetSmall : BaseAppWidget() {
appWidgetView.setViewVisibility(R.id.media_titles, View.INVISIBLE)
appWidgetView.setImageViewResource(R.id.image, R.drawable.default_audio_art)
- appWidgetView.setImageViewBitmap(R.id.button_next, createBitmap(RetroUtil.getTintedVectorDrawable(context, R.drawable.ic_skip_next_white_24dp, MaterialValueHelper.getSecondaryTextColor(context, true))!!, 1f))
- appWidgetView.setImageViewBitmap(R.id.button_prev, createBitmap(RetroUtil.getTintedVectorDrawable(context, R.drawable.ic_skip_previous_white_24dp, MaterialValueHelper.getSecondaryTextColor(context, true))!!, 1f))
- appWidgetView.setImageViewBitmap(R.id.button_toggle_play_pause, createBitmap(RetroUtil.getTintedVectorDrawable(context, R.drawable.ic_play_arrow_white_32dp, MaterialValueHelper.getSecondaryTextColor(context, true))!!, 1f))
+ appWidgetView.setImageViewBitmap(
+ R.id.button_next,
+ createBitmap(
+ RetroUtil.getTintedVectorDrawable(
+ context,
+ R.drawable.ic_skip_next_white_24dp,
+ MaterialValueHelper.getSecondaryTextColor(context, true)
+ )!!, 1f
+ )
+ )
+ appWidgetView.setImageViewBitmap(
+ R.id.button_prev,
+ createBitmap(
+ RetroUtil.getTintedVectorDrawable(
+ context,
+ R.drawable.ic_skip_previous_white_24dp,
+ MaterialValueHelper.getSecondaryTextColor(context, true)
+ )!!, 1f
+ )
+ )
+ appWidgetView.setImageViewBitmap(
+ R.id.button_toggle_play_pause,
+ createBitmap(
+ RetroUtil.getTintedVectorDrawable(
+ context,
+ R.drawable.ic_play_arrow_white_32dp,
+ MaterialValueHelper.getSecondaryTextColor(context, true)
+ )!!, 1f
+ )
+ )
linkButtons(context, appWidgetView)
pushUpdate(context, appWidgetIds, appWidgetView)
@@ -98,66 +125,66 @@ class AppWidgetSmall : BaseAppWidget() {
Glide.clear(target)
}
target = SongGlideRequest.Builder.from(Glide.with(service), song)
- .checkIgnoreMediaStore(service).generatePalette(service).build().centerCrop()
- .into(object : SimpleTarget(imageSize, imageSize) {
- override fun onResourceReady(
- resource: BitmapPaletteWrapper,
- glideAnimation: GlideAnimation
- ) {
- val palette = resource.palette
- update(
- resource.bitmap, palette.getVibrantColor(
- palette.getMutedColor(
- MaterialValueHelper.getSecondaryTextColor(
- service, true
- )
+ .checkIgnoreMediaStore(service).generatePalette(service).build().centerCrop()
+ .into(object : SimpleTarget(imageSize, imageSize) {
+ override fun onResourceReady(
+ resource: BitmapPaletteWrapper,
+ glideAnimation: GlideAnimation
+ ) {
+ val palette = resource.palette
+ update(
+ resource.bitmap, palette.getVibrantColor(
+ palette.getMutedColor(
+ MaterialValueHelper.getSecondaryTextColor(
+ service, true
)
+ )
)
- )
- }
+ )
+ }
- override fun onLoadFailed(e: Exception?, errorDrawable: Drawable?) {
- super.onLoadFailed(e, errorDrawable)
- update(null, MaterialValueHelper.getSecondaryTextColor(service, true))
- }
+ override fun onLoadFailed(e: Exception?, errorDrawable: Drawable?) {
+ super.onLoadFailed(e, errorDrawable)
+ update(null, MaterialValueHelper.getSecondaryTextColor(service, true))
+ }
- private fun update(bitmap: Bitmap?, color: Int) {
- // Set correct drawable for pause state
- val playPauseRes = if (isPlaying) R.drawable.ic_pause_white_24dp
- else R.drawable.ic_play_arrow_white_32dp
- appWidgetView.setImageViewBitmap(
- R.id.button_toggle_play_pause, createBitmap(
- RetroUtil.getTintedVectorDrawable(
- service, playPauseRes, color
- )!!, 1f
- )
+ private fun update(bitmap: Bitmap?, color: Int) {
+ // Set correct drawable for pause state
+ val playPauseRes = if (isPlaying) R.drawable.ic_pause_white_24dp
+ else R.drawable.ic_play_arrow_white_32dp
+ appWidgetView.setImageViewBitmap(
+ R.id.button_toggle_play_pause, createBitmap(
+ RetroUtil.getTintedVectorDrawable(
+ service, playPauseRes, color
+ )!!, 1f
)
+ )
- // Set prev/next button drawables
- appWidgetView.setImageViewBitmap(
- R.id.button_next, createBitmap(
- RetroUtil.getTintedVectorDrawable(
- service, R.drawable.ic_skip_next_white_24dp, color
- )!!, 1f
- )
- )
- appWidgetView.setImageViewBitmap(
- R.id.button_prev, createBitmap(
- RetroUtil.getTintedVectorDrawable(
- service, R.drawable.ic_skip_previous_white_24dp, color
- )!!, 1f
+ // Set prev/next button drawables
+ appWidgetView.setImageViewBitmap(
+ R.id.button_next, createBitmap(
+ RetroUtil.getTintedVectorDrawable(
+ service, R.drawable.ic_skip_next_white_24dp, color
+ )!!, 1f
)
+ )
+ appWidgetView.setImageViewBitmap(
+ R.id.button_prev, createBitmap(
+ RetroUtil.getTintedVectorDrawable(
+ service, R.drawable.ic_skip_previous_white_24dp, color
+ )!!, 1f
)
+ )
- val image = getAlbumArtDrawable(service.resources, bitmap)
- val roundedBitmap = createRoundedBitmap(
- image, imageSize, imageSize, cardRadius, 0f, 0f, 0f
- )
- appWidgetView.setImageViewBitmap(R.id.image, roundedBitmap)
+ val image = getAlbumArtDrawable(service.resources, bitmap)
+ val roundedBitmap = createRoundedBitmap(
+ image, imageSize, imageSize, cardRadius, 0f, 0f, 0f
+ )
+ appWidgetView.setImageViewBitmap(R.id.image, roundedBitmap)
- pushUpdate(appContext, appWidgetIds, appWidgetView)
- }
- })
+ pushUpdate(appContext, appWidgetIds, appWidgetView)
+ }
+ })
}
}
diff --git a/app/src/main/java/code/name/monkey/retromusic/appwidgets/AppWidgetText.kt b/app/src/main/java/code/name/monkey/retromusic/appwidgets/AppWidgetText.kt
index 88bba6a8..c47136e6 100644
--- a/app/src/main/java/code/name/monkey/retromusic/appwidgets/AppWidgetText.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/appwidgets/AppWidgetText.kt
@@ -15,12 +15,15 @@
package code.name.monkey.retromusic.appwidgets
import android.app.PendingIntent
-import android.content.*
+import android.content.ComponentName
+import android.content.Context
+import android.content.Intent
import android.text.TextUtils
import android.view.View
import android.widget.RemoteViews
import androidx.core.content.ContextCompat
-import code.name.monkey.retromusic.*
+import code.name.monkey.retromusic.App
+import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.activities.MainActivity
import code.name.monkey.retromusic.appwidgets.base.BaseAppWidget
import code.name.monkey.retromusic.service.MusicService
@@ -28,146 +31,146 @@ import code.name.monkey.retromusic.service.MusicService.*
import code.name.monkey.retromusic.util.RetroUtil
class AppWidgetText : BaseAppWidget() {
- override fun defaultAppWidget(context: Context, appWidgetIds: IntArray) {
- val appWidgetView = RemoteViews(context.packageName, R.layout.app_widget_text)
+ override fun defaultAppWidget(context: Context, appWidgetIds: IntArray) {
+ val appWidgetView = RemoteViews(context.packageName, R.layout.app_widget_text)
- appWidgetView.setImageViewBitmap(
- R.id.button_next, createBitmap(
- RetroUtil.getTintedVectorDrawable(
- context, R.drawable.ic_skip_next_white_24dp, ContextCompat.getColor(
- context, R.color.md_white_1000
- )
- )!!, 1f
- )
- )
- appWidgetView.setImageViewBitmap(
- R.id.button_prev, createBitmap(
- RetroUtil.getTintedVectorDrawable(
- context, R.drawable.ic_skip_previous_white_24dp, ContextCompat.getColor(
- context, R.color.md_white_1000
- )
- )!!, 1f
- )
- )
- appWidgetView.setImageViewBitmap(
- R.id.button_toggle_play_pause, createBitmap(
- RetroUtil.getTintedVectorDrawable(
- context, R.drawable.ic_play_arrow_white_32dp, ContextCompat.getColor(
- context, R.color.md_white_1000
- )
- )!!, 1f
- )
- )
+ appWidgetView.setImageViewBitmap(
+ R.id.button_next, createBitmap(
+ RetroUtil.getTintedVectorDrawable(
+ context, R.drawable.ic_skip_next_white_24dp, ContextCompat.getColor(
+ context, R.color.md_white_1000
+ )
+ )!!, 1f
+ )
+ )
+ appWidgetView.setImageViewBitmap(
+ R.id.button_prev, createBitmap(
+ RetroUtil.getTintedVectorDrawable(
+ context, R.drawable.ic_skip_previous_white_24dp, ContextCompat.getColor(
+ context, R.color.md_white_1000
+ )
+ )!!, 1f
+ )
+ )
+ appWidgetView.setImageViewBitmap(
+ R.id.button_toggle_play_pause, createBitmap(
+ RetroUtil.getTintedVectorDrawable(
+ context, R.drawable.ic_play_arrow_white_32dp, ContextCompat.getColor(
+ context, R.color.md_white_1000
+ )
+ )!!, 1f
+ )
+ )
- appWidgetView.setTextColor(
- R.id.title, ContextCompat.getColor(context, R.color.md_white_1000)
- )
- appWidgetView.setTextColor(
- R.id.text, ContextCompat.getColor(context, R.color.md_white_1000)
- )
+ appWidgetView.setTextColor(
+ R.id.title, ContextCompat.getColor(context, R.color.md_white_1000)
+ )
+ appWidgetView.setTextColor(
+ R.id.text, ContextCompat.getColor(context, R.color.md_white_1000)
+ )
- linkButtons(context, appWidgetView)
- pushUpdate(context, appWidgetIds, appWidgetView)
- }
+ linkButtons(context, appWidgetView)
+ pushUpdate(context, appWidgetIds, appWidgetView)
+ }
- /**
- * Link up various button actions using [PendingIntent].
- */
- private fun linkButtons(context: Context, views: RemoteViews) {
- val action = Intent(context, MainActivity::class.java).putExtra("expand", true)
- var pendingIntent: PendingIntent
+ /**
+ * Link up various button actions using [PendingIntent].
+ */
+ private fun linkButtons(context: Context, views: RemoteViews) {
+ val action = Intent(context, MainActivity::class.java).putExtra("expand", true)
+ var pendingIntent: PendingIntent
- val serviceName = ComponentName(context, MusicService::class.java)
+ val serviceName = ComponentName(context, MusicService::class.java)
- // Home
- action.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP
- pendingIntent = PendingIntent.getActivity(context, 0, action, 0)
- views.setOnClickPendingIntent(R.id.image, pendingIntent)
- views.setOnClickPendingIntent(R.id.media_titles, pendingIntent)
+ // Home
+ action.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP
+ pendingIntent = PendingIntent.getActivity(context, 0, action, 0)
+ views.setOnClickPendingIntent(R.id.image, pendingIntent)
+ views.setOnClickPendingIntent(R.id.media_titles, pendingIntent)
- // Previous track
- pendingIntent = buildPendingIntent(context, ACTION_REWIND, serviceName)
- views.setOnClickPendingIntent(R.id.button_prev, pendingIntent)
+ // Previous track
+ pendingIntent = buildPendingIntent(context, ACTION_REWIND, serviceName)
+ views.setOnClickPendingIntent(R.id.button_prev, pendingIntent)
- // Play and pause
- pendingIntent = buildPendingIntent(context, ACTION_TOGGLE_PAUSE, serviceName)
- views.setOnClickPendingIntent(R.id.button_toggle_play_pause, pendingIntent)
+ // Play and pause
+ pendingIntent = buildPendingIntent(context, ACTION_TOGGLE_PAUSE, serviceName)
+ views.setOnClickPendingIntent(R.id.button_toggle_play_pause, pendingIntent)
- // Next track
- pendingIntent = buildPendingIntent(context, ACTION_SKIP, serviceName)
- views.setOnClickPendingIntent(R.id.button_next, pendingIntent)
- }
+ // Next track
+ pendingIntent = buildPendingIntent(context, ACTION_SKIP, serviceName)
+ views.setOnClickPendingIntent(R.id.button_next, pendingIntent)
+ }
- override fun performUpdate(service: MusicService, appWidgetIds: IntArray?) {
- val appWidgetView = RemoteViews(service.packageName, R.layout.app_widget_text)
+ override fun performUpdate(service: MusicService, appWidgetIds: IntArray?) {
+ val appWidgetView = RemoteViews(service.packageName, R.layout.app_widget_text)
- val isPlaying = service.isPlaying
- val song = service.currentSong
+ val isPlaying = service.isPlaying
+ val song = service.currentSong
- // Set the titles and artwork
- if (TextUtils.isEmpty(song.title) && TextUtils.isEmpty(song.artistName)) {
- appWidgetView.setViewVisibility(R.id.media_titles, View.INVISIBLE)
- } else {
- appWidgetView.setViewVisibility(R.id.media_titles, View.VISIBLE)
- appWidgetView.setTextViewText(R.id.title, song.title)
- appWidgetView.setTextViewText(R.id.text, song.artistName)
- }
- // Link actions buttons to intents
- linkButtons(service, appWidgetView)
+ // Set the titles and artwork
+ if (TextUtils.isEmpty(song.title) && TextUtils.isEmpty(song.artistName)) {
+ appWidgetView.setViewVisibility(R.id.media_titles, View.INVISIBLE)
+ } else {
+ appWidgetView.setViewVisibility(R.id.media_titles, View.VISIBLE)
+ appWidgetView.setTextViewText(R.id.title, song.title)
+ appWidgetView.setTextViewText(R.id.text, song.artistName)
+ }
+ // Link actions buttons to intents
+ linkButtons(service, appWidgetView)
- // Set correct drawable for pause state
- val playPauseRes = if (isPlaying) R.drawable.ic_pause_white_24dp
- else R.drawable.ic_play_arrow_white_32dp
- appWidgetView.setImageViewBitmap(
- R.id.button_toggle_play_pause, createBitmap(
- RetroUtil.getTintedVectorDrawable(
- App.getContext(), playPauseRes, ContextCompat.getColor(
- App.getContext(), R.color.md_white_1000
- )
- )!!, 1f
- )
- )
- appWidgetView.setImageViewBitmap(
- R.id.button_next, createBitmap(
- RetroUtil.getTintedVectorDrawable(
- App.getContext(),
- R.drawable.ic_skip_next_white_24dp,
- ContextCompat.getColor(
- App.getContext(), R.color.md_white_1000
- )
- )!!, 1f
- )
- )
- appWidgetView.setImageViewBitmap(
- R.id.button_prev, createBitmap(
- RetroUtil.getTintedVectorDrawable(
- App.getContext(),
- R.drawable.ic_skip_previous_white_24dp,
- ContextCompat.getColor(
- App.getContext(), R.color.md_white_1000
- )
- )!!, 1f
- )
- )
+ // Set correct drawable for pause state
+ val playPauseRes = if (isPlaying) R.drawable.ic_pause_white_24dp
+ else R.drawable.ic_play_arrow_white_32dp
+ appWidgetView.setImageViewBitmap(
+ R.id.button_toggle_play_pause, createBitmap(
+ RetroUtil.getTintedVectorDrawable(
+ App.getContext(), playPauseRes, ContextCompat.getColor(
+ App.getContext(), R.color.md_white_1000
+ )
+ )!!, 1f
+ )
+ )
+ appWidgetView.setImageViewBitmap(
+ R.id.button_next, createBitmap(
+ RetroUtil.getTintedVectorDrawable(
+ App.getContext(),
+ R.drawable.ic_skip_next_white_24dp,
+ ContextCompat.getColor(
+ App.getContext(), R.color.md_white_1000
+ )
+ )!!, 1f
+ )
+ )
+ appWidgetView.setImageViewBitmap(
+ R.id.button_prev, createBitmap(
+ RetroUtil.getTintedVectorDrawable(
+ App.getContext(),
+ R.drawable.ic_skip_previous_white_24dp,
+ ContextCompat.getColor(
+ App.getContext(), R.color.md_white_1000
+ )
+ )!!, 1f
+ )
+ )
- pushUpdate(service.applicationContext, appWidgetIds, appWidgetView)
+ pushUpdate(service.applicationContext, appWidgetIds, appWidgetView)
- }
+ }
- companion object {
+ companion object {
- const val NAME: String = "app_widget_text"
+ const val NAME: String = "app_widget_text"
- private var mInstance: AppWidgetText? = null
+ private var mInstance: AppWidgetText? = null
- val instance: AppWidgetText
- @Synchronized get() {
- if (mInstance == null) {
- mInstance = AppWidgetText()
- }
- return mInstance!!
- }
- }
+ val instance: AppWidgetText
+ @Synchronized get() {
+ if (mInstance == null) {
+ mInstance = AppWidgetText()
+ }
+ return mInstance!!
+ }
+ }
}
diff --git a/app/src/main/java/code/name/monkey/retromusic/appwidgets/BootReceiver.kt b/app/src/main/java/code/name/monkey/retromusic/appwidgets/BootReceiver.kt
index 90a9cf8a..5f82c2af 100644
--- a/app/src/main/java/code/name/monkey/retromusic/appwidgets/BootReceiver.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/appwidgets/BootReceiver.kt
@@ -15,36 +15,40 @@
package code.name.monkey.retromusic.appwidgets
import android.appwidget.AppWidgetManager
-import android.content.*
+import android.content.BroadcastReceiver
+import android.content.ComponentName
+import android.content.Context
+import android.content.Intent
import android.os.Build
import code.name.monkey.retromusic.service.MusicService
class BootReceiver : BroadcastReceiver() {
- override fun onReceive(context: Context, intent: Intent) {
- val widgetManager = AppWidgetManager.getInstance(context)
+ override fun onReceive(context: Context, intent: Intent) {
+ val widgetManager = AppWidgetManager.getInstance(context)
- // Start music service if there are any existing widgets
- if (widgetManager.getAppWidgetIds(
- ComponentName(
- context, AppWidgetBig::class.java
- )
- ).isNotEmpty() || widgetManager.getAppWidgetIds(
- ComponentName(
- context, AppWidgetClassic::class.java
- )
- ).isNotEmpty() || widgetManager.getAppWidgetIds(
- ComponentName(
- context, AppWidgetSmall::class.java
- )
- ).isNotEmpty() || widgetManager.getAppWidgetIds(
- ComponentName(
- context, AppWidgetCard::class.java
- )
- ).isNotEmpty()) {
- val serviceIntent = Intent(context, MusicService::class.java)
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) { // not allowed on Oreo
- context.startService(serviceIntent)
- }
- }
- }
+ // Start music service if there are any existing widgets
+ if (widgetManager.getAppWidgetIds(
+ ComponentName(
+ context, AppWidgetBig::class.java
+ )
+ ).isNotEmpty() || widgetManager.getAppWidgetIds(
+ ComponentName(
+ context, AppWidgetClassic::class.java
+ )
+ ).isNotEmpty() || widgetManager.getAppWidgetIds(
+ ComponentName(
+ context, AppWidgetSmall::class.java
+ )
+ ).isNotEmpty() || widgetManager.getAppWidgetIds(
+ ComponentName(
+ context, AppWidgetCard::class.java
+ )
+ ).isNotEmpty()
+ ) {
+ val serviceIntent = Intent(context, MusicService::class.java)
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) { // not allowed on Oreo
+ context.startService(serviceIntent)
+ }
+ }
+ }
}
diff --git a/app/src/main/java/code/name/monkey/retromusic/appwidgets/base/BaseAppWidget.kt b/app/src/main/java/code/name/monkey/retromusic/appwidgets/base/BaseAppWidget.kt
index c8a2e905..29f0d748 100644
--- a/app/src/main/java/code/name/monkey/retromusic/appwidgets/base/BaseAppWidget.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/appwidgets/base/BaseAppWidget.kt
@@ -15,170 +15,175 @@
package code.name.monkey.retromusic.appwidgets.base
import android.app.PendingIntent
-import android.appwidget.*
-import android.content.*
+import android.appwidget.AppWidgetManager
+import android.appwidget.AppWidgetProvider
+import android.content.ComponentName
+import android.content.Context
+import android.content.Intent
import android.content.res.Resources
import android.graphics.*
-import android.graphics.drawable.*
+import android.graphics.drawable.BitmapDrawable
+import android.graphics.drawable.Drawable
import android.os.Build
import android.text.TextUtils
import android.widget.RemoteViews
import androidx.core.content.ContextCompat
-import code.name.monkey.retromusic.*
+import code.name.monkey.retromusic.App
+import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.service.MusicService.*
abstract class BaseAppWidget : AppWidgetProvider() {
- /**
- * {@inheritDoc}
- */
- override fun onUpdate(
- context: Context, appWidgetManager: AppWidgetManager, appWidgetIds: IntArray
- ) {
- defaultAppWidget(context, appWidgetIds)
- val updateIntent = Intent(APP_WIDGET_UPDATE)
- updateIntent.putExtra(EXTRA_APP_WIDGET_NAME, NAME)
- updateIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, appWidgetIds)
- updateIntent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY)
- context.sendBroadcast(updateIntent)
- }
+ /**
+ * {@inheritDoc}
+ */
+ override fun onUpdate(
+ context: Context, appWidgetManager: AppWidgetManager, appWidgetIds: IntArray
+ ) {
+ defaultAppWidget(context, appWidgetIds)
+ val updateIntent = Intent(APP_WIDGET_UPDATE)
+ updateIntent.putExtra(EXTRA_APP_WIDGET_NAME, NAME)
+ updateIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, appWidgetIds)
+ updateIntent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY)
+ context.sendBroadcast(updateIntent)
+ }
- /**
- * Handle a change notification coming over from [MusicService]
- */
- fun notifyChange(service: MusicService, what: String) {
- if (hasInstances(service)) {
- if (META_CHANGED == what || PLAY_STATE_CHANGED == what) {
- performUpdate(service, null)
- }
- }
- }
+ /**
+ * Handle a change notification coming over from [MusicService]
+ */
+ fun notifyChange(service: MusicService, what: String) {
+ if (hasInstances(service)) {
+ if (META_CHANGED == what || PLAY_STATE_CHANGED == what) {
+ performUpdate(service, null)
+ }
+ }
+ }
- protected fun pushUpdate(
- context: Context, appWidgetIds: IntArray?, views: RemoteViews
- ) {
- val appWidgetManager = AppWidgetManager.getInstance(context)
- if (appWidgetIds != null) {
- appWidgetManager.updateAppWidget(appWidgetIds, views)
- } else {
- appWidgetManager.updateAppWidget(ComponentName(context, javaClass), views)
- }
- }
+ protected fun pushUpdate(
+ context: Context, appWidgetIds: IntArray?, views: RemoteViews
+ ) {
+ val appWidgetManager = AppWidgetManager.getInstance(context)
+ if (appWidgetIds != null) {
+ appWidgetManager.updateAppWidget(appWidgetIds, views)
+ } else {
+ appWidgetManager.updateAppWidget(ComponentName(context, javaClass), views)
+ }
+ }
- /**
- * Check against [AppWidgetManager] if there are any instances of this widget.
- */
- private fun hasInstances(context: Context): Boolean {
- val appWidgetManager = AppWidgetManager.getInstance(context)
- val mAppWidgetIds = appWidgetManager.getAppWidgetIds(
- ComponentName(
- context, javaClass
- )
- )
- return mAppWidgetIds.isNotEmpty()
- }
+ /**
+ * Check against [AppWidgetManager] if there are any instances of this widget.
+ */
+ private fun hasInstances(context: Context): Boolean {
+ val appWidgetManager = AppWidgetManager.getInstance(context)
+ val mAppWidgetIds = appWidgetManager.getAppWidgetIds(
+ ComponentName(
+ context, javaClass
+ )
+ )
+ return mAppWidgetIds.isNotEmpty()
+ }
- protected fun buildPendingIntent(
- context: Context, action: String, serviceName: ComponentName
- ): PendingIntent {
- val intent = Intent(action)
- intent.component = serviceName
- return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
- PendingIntent.getForegroundService(context, 0, intent, 0)
- } else {
- PendingIntent.getService(context, 0, intent, 0)
- }
- }
+ protected fun buildPendingIntent(
+ context: Context, action: String, serviceName: ComponentName
+ ): PendingIntent {
+ val intent = Intent(action)
+ intent.component = serviceName
+ return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+ PendingIntent.getForegroundService(context, 0, intent, 0)
+ } else {
+ PendingIntent.getService(context, 0, intent, 0)
+ }
+ }
- protected abstract fun defaultAppWidget(context: Context, appWidgetIds: IntArray)
+ protected abstract fun defaultAppWidget(context: Context, appWidgetIds: IntArray)
- abstract fun performUpdate(service: MusicService, appWidgetIds: IntArray?)
+ abstract fun performUpdate(service: MusicService, appWidgetIds: IntArray?)
- protected fun getAlbumArtDrawable(resources: Resources, bitmap: Bitmap?): Drawable {
- return if (bitmap == null) {
- ContextCompat.getDrawable(App.getContext(), R.drawable.default_audio_art)!!
- } else {
- BitmapDrawable(resources, bitmap)
- }
- }
+ protected fun getAlbumArtDrawable(resources: Resources, bitmap: Bitmap?): Drawable {
+ return if (bitmap == null) {
+ ContextCompat.getDrawable(App.getContext(), R.drawable.default_audio_art)!!
+ } else {
+ BitmapDrawable(resources, bitmap)
+ }
+ }
- protected fun getSongArtistAndAlbum(song: Song): String {
- val builder = StringBuilder()
- builder.append(song.artistName)
- if (!TextUtils.isEmpty(song.artistName) && !TextUtils.isEmpty(song.albumName)) {
- builder.append(" • ")
- }
- builder.append(song.albumName)
- return builder.toString()
- }
+ protected fun getSongArtistAndAlbum(song: Song): String {
+ val builder = StringBuilder()
+ builder.append(song.artistName)
+ if (!TextUtils.isEmpty(song.artistName) && !TextUtils.isEmpty(song.albumName)) {
+ builder.append(" • ")
+ }
+ builder.append(song.albumName)
+ return builder.toString()
+ }
- companion object {
+ companion object {
- const val NAME: String = "app_widget"
+ const val NAME: String = "app_widget"
- fun createRoundedBitmap(
- drawable: Drawable?,
- width: Int,
- height: Int,
- tl: Float,
- tr: Float,
- bl: Float,
- br: Float
- ): Bitmap? {
- if (drawable == null) {
- return null
- }
+ fun createRoundedBitmap(
+ drawable: Drawable?,
+ width: Int,
+ height: Int,
+ tl: Float,
+ tr: Float,
+ bl: Float,
+ br: Float
+ ): Bitmap? {
+ if (drawable == null) {
+ return null
+ }
- val bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888)
- val c = Canvas(bitmap)
- drawable.setBounds(0, 0, width, height)
- drawable.draw(c)
+ val bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888)
+ val c = Canvas(bitmap)
+ drawable.setBounds(0, 0, width, height)
+ drawable.draw(c)
- val rounded = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888)
+ val rounded = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888)
- val canvas = Canvas(rounded)
- val paint = Paint()
- paint.shader = BitmapShader(bitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP)
- paint.isAntiAlias = true
- canvas.drawPath(
- composeRoundedRectPath(
- RectF(0f, 0f, width.toFloat(), height.toFloat()), tl, tr, bl, br
- ), paint
- )
+ val canvas = Canvas(rounded)
+ val paint = Paint()
+ paint.shader = BitmapShader(bitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP)
+ paint.isAntiAlias = true
+ canvas.drawPath(
+ composeRoundedRectPath(
+ RectF(0f, 0f, width.toFloat(), height.toFloat()), tl, tr, bl, br
+ ), paint
+ )
- return rounded
- }
+ return rounded
+ }
- fun createBitmap(drawable: Drawable, sizeMultiplier: Float): Bitmap {
- val bitmap = Bitmap.createBitmap(
- (drawable.intrinsicWidth * sizeMultiplier).toInt(),
- (drawable.intrinsicHeight * sizeMultiplier).toInt(),
- Bitmap.Config.ARGB_8888
- )
- val c = Canvas(bitmap)
- drawable.setBounds(0, 0, c.width, c.height)
- drawable.draw(c)
- return bitmap
- }
+ fun createBitmap(drawable: Drawable, sizeMultiplier: Float): Bitmap {
+ val bitmap = Bitmap.createBitmap(
+ (drawable.intrinsicWidth * sizeMultiplier).toInt(),
+ (drawable.intrinsicHeight * sizeMultiplier).toInt(),
+ Bitmap.Config.ARGB_8888
+ )
+ val c = Canvas(bitmap)
+ drawable.setBounds(0, 0, c.width, c.height)
+ drawable.draw(c)
+ return bitmap
+ }
- protected fun composeRoundedRectPath(
- rect: RectF, tl: Float, tr: Float, bl: Float, br: Float
- ): Path {
- val path = Path()
- path.moveTo(rect.left + tl, rect.top)
- path.lineTo(rect.right - tr, rect.top)
- path.quadTo(rect.right, rect.top, rect.right, rect.top + tr)
- path.lineTo(rect.right, rect.bottom - br)
- path.quadTo(rect.right, rect.bottom, rect.right - br, rect.bottom)
- path.lineTo(rect.left + bl, rect.bottom)
- path.quadTo(rect.left, rect.bottom, rect.left, rect.bottom - bl)
- path.lineTo(rect.left, rect.top + tl)
- path.quadTo(rect.left, rect.top, rect.left + tl, rect.top)
- path.close()
+ protected fun composeRoundedRectPath(
+ rect: RectF, tl: Float, tr: Float, bl: Float, br: Float
+ ): Path {
+ val path = Path()
+ path.moveTo(rect.left + tl, rect.top)
+ path.lineTo(rect.right - tr, rect.top)
+ path.quadTo(rect.right, rect.top, rect.right, rect.top + tr)
+ path.lineTo(rect.right, rect.bottom - br)
+ path.quadTo(rect.right, rect.bottom, rect.right - br, rect.bottom)
+ path.lineTo(rect.left + bl, rect.bottom)
+ path.quadTo(rect.left, rect.bottom, rect.left, rect.bottom - bl)
+ path.lineTo(rect.left, rect.top + tl)
+ path.quadTo(rect.left, rect.top, rect.left + tl, rect.top)
+ path.close()
- return path
- }
- }
+ return path
+ }
+ }
}
diff --git a/app/src/main/java/code/name/monkey/retromusic/dagger/MusicComponent.kt b/app/src/main/java/code/name/monkey/retromusic/dagger/MusicComponent.kt
index efa9a1c5..361bb91a 100644
--- a/app/src/main/java/code/name/monkey/retromusic/dagger/MusicComponent.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/dagger/MusicComponent.kt
@@ -14,19 +14,10 @@
package code.name.monkey.retromusic.dagger
-import code.name.monkey.retromusic.activities.AlbumDetailsActivity
-import code.name.monkey.retromusic.activities.ArtistDetailActivity
-import code.name.monkey.retromusic.activities.GenreDetailsActivity
-import code.name.monkey.retromusic.activities.PlaylistDetailActivity
-import code.name.monkey.retromusic.activities.SearchActivity
+import code.name.monkey.retromusic.activities.*
import code.name.monkey.retromusic.dagger.module.AppModule
import code.name.monkey.retromusic.dagger.module.PresenterModule
-import code.name.monkey.retromusic.fragments.mainactivity.AlbumsFragment
-import code.name.monkey.retromusic.fragments.mainactivity.ArtistsFragment
-import code.name.monkey.retromusic.fragments.mainactivity.GenresFragment
-import code.name.monkey.retromusic.fragments.mainactivity.PlaylistsFragment
-import code.name.monkey.retromusic.fragments.mainactivity.SongsFragment
-import code.name.monkey.retromusic.fragments.mainactivity.BannerHomeFragment
+import code.name.monkey.retromusic.fragments.mainactivity.*
import dagger.Component
import javax.inject.Singleton
diff --git a/app/src/main/java/code/name/monkey/retromusic/dagger/module/PresenterModile.kt b/app/src/main/java/code/name/monkey/retromusic/dagger/module/PresenterModile.kt
index 707f369c..880ecc88 100644
--- a/app/src/main/java/code/name/monkey/retromusic/dagger/module/PresenterModile.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/dagger/module/PresenterModile.kt
@@ -15,27 +15,17 @@
package code.name.monkey.retromusic.dagger.module
import android.content.Context
-import code.name.monkey.retromusic.mvp.presenter.AlbumDetailsPresenter
+import code.name.monkey.retromusic.mvp.presenter.*
import code.name.monkey.retromusic.mvp.presenter.AlbumDetailsPresenter.AlbumDetailsPresenterImpl
-import code.name.monkey.retromusic.mvp.presenter.AlbumsPresenter
import code.name.monkey.retromusic.mvp.presenter.AlbumsPresenter.AlbumsPresenterImpl
-import code.name.monkey.retromusic.mvp.presenter.ArtistDetailsPresenter
import code.name.monkey.retromusic.mvp.presenter.ArtistDetailsPresenter.ArtistDetailsPresenterImpl
-import code.name.monkey.retromusic.mvp.presenter.ArtistsPresenter
import code.name.monkey.retromusic.mvp.presenter.ArtistsPresenter.ArtistsPresenterImpl
-import code.name.monkey.retromusic.mvp.presenter.GenreDetailsPresenter
import code.name.monkey.retromusic.mvp.presenter.GenreDetailsPresenter.GenreDetailsPresenterImpl
-import code.name.monkey.retromusic.mvp.presenter.GenresPresenter
import code.name.monkey.retromusic.mvp.presenter.GenresPresenter.GenresPresenterImpl
-import code.name.monkey.retromusic.mvp.presenter.HomePresenter
import code.name.monkey.retromusic.mvp.presenter.HomePresenter.HomePresenterImpl
-import code.name.monkey.retromusic.mvp.presenter.PlaylistSongsPresenter
import code.name.monkey.retromusic.mvp.presenter.PlaylistSongsPresenter.PlaylistSongsPresenterImpl
-import code.name.monkey.retromusic.mvp.presenter.PlaylistsPresenter
import code.name.monkey.retromusic.mvp.presenter.PlaylistsPresenter.PlaylistsPresenterImpl
-import code.name.monkey.retromusic.mvp.presenter.SearchPresenter
import code.name.monkey.retromusic.mvp.presenter.SearchPresenter.SearchPresenterImpl
-import code.name.monkey.retromusic.mvp.presenter.SongPresenter
import code.name.monkey.retromusic.mvp.presenter.SongPresenter.SongPresenterImpl
import code.name.monkey.retromusic.providers.RepositoryImpl
import code.name.monkey.retromusic.providers.interfaces.Repository
diff --git a/app/src/main/java/code/name/monkey/retromusic/deezer/DeezerApiService.kt b/app/src/main/java/code/name/monkey/retromusic/deezer/DeezerApiService.kt
index d8f46796..95daf6bd 100644
--- a/app/src/main/java/code/name/monkey/retromusic/deezer/DeezerApiService.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/deezer/DeezerApiService.kt
@@ -11,7 +11,7 @@ import retrofit2.create
import retrofit2.http.GET
import retrofit2.http.Query
import java.io.File
-import java.util.Locale
+import java.util.*
private const val BASE_QUERY_ARTIST = "search/artist"
private const val BASE_URL = "https://api.deezer.com/"
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 9ae8af57..c805bae2 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
@@ -51,7 +51,12 @@ class AddToPlaylistDialog : DialogFragment() {
}
} else {
dialog.dismiss()
- PlaylistsUtil.addToPlaylist(requireContext(), songs, playlists[index - 1].id, true)
+ PlaylistsUtil.addToPlaylist(
+ requireContext(),
+ songs,
+ playlists[index - 1].id,
+ true
+ )
}
}
}
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 be3b01d3..e91ed492 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
@@ -81,7 +81,11 @@ class BlacklistFolderChooserDialog : DialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
var savedInstanceStateFinal = savedInstanceState
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M &&
- ActivityCompat.checkSelfPermission(requireActivity(), Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
+ ActivityCompat.checkSelfPermission(
+ requireActivity(),
+ Manifest.permission.READ_EXTERNAL_STORAGE
+ ) != PackageManager.PERMISSION_GRANTED
+ ) {
return MaterialDialog(requireActivity(), BottomSheet(LayoutMode.WRAP_CONTENT)).show {
title(R.string.md_error_label)
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
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 56318bfc..ab750306 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
@@ -57,7 +57,10 @@ class CreatePlaylistDialog : DialogFragment() {
?: return@positiveButton
if (playlistView.text.toString().trim { it <= ' ' }.isNotEmpty()) {
- val playlistId = PlaylistsUtil.createPlaylist(requireContext(), playlistView.text.toString())
+ val playlistId = PlaylistsUtil.createPlaylist(
+ requireContext(),
+ playlistView.text.toString()
+ )
if (playlistId != -1 && activity != null) {
PlaylistsUtil.addToPlaylist(requireContext(), songs, playlistId, true)
}
@@ -73,7 +76,10 @@ class CreatePlaylistDialog : DialogFragment() {
val playlistId = arguments!!.getLong(MediaStore.Audio.Playlists.Members.PLAYLIST_ID)
playlistView.appHandleColor()
- .setText(PlaylistsUtil.getNameForPlaylist(requireContext(), playlistId), TextView.BufferType.EDITABLE)
+ .setText(
+ PlaylistsUtil.getNameForPlaylist(requireContext(), playlistId),
+ TextView.BufferType.EDITABLE
+ )
return materialDialog
}
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 6e022020..76535bb8 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
@@ -26,7 +26,7 @@ import code.name.monkey.retromusic.util.PreferenceUtil
import com.afollestad.materialdialogs.LayoutMode
import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
-import java.util.ArrayList
+import java.util.*
class DeletePlaylistDialog : DialogFragment() {
diff --git a/app/src/main/java/code/name/monkey/retromusic/dialogs/DeleteSongsAsyncTask.java b/app/src/main/java/code/name/monkey/retromusic/dialogs/DeleteSongsAsyncTask.java
index 70b70780..e55488c7 100644
--- a/app/src/main/java/code/name/monkey/retromusic/dialogs/DeleteSongsAsyncTask.java
+++ b/app/src/main/java/code/name/monkey/retromusic/dialogs/DeleteSongsAsyncTask.java
@@ -21,54 +21,29 @@ import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.util.Log;
+
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.FragmentActivity;
+
+import com.google.android.material.dialog.MaterialAlertDialogBuilder;
+
+import java.lang.ref.WeakReference;
+import java.util.Collections;
+import java.util.List;
+
import code.name.monkey.retromusic.R;
import code.name.monkey.retromusic.activities.saf.SAFGuideActivity;
import code.name.monkey.retromusic.misc.DialogAsyncTask;
import code.name.monkey.retromusic.model.Song;
import code.name.monkey.retromusic.util.SAFUtil;
-import com.google.android.material.dialog.MaterialAlertDialogBuilder;
-import java.lang.ref.WeakReference;
-import java.util.Collections;
-import java.util.List;
/**
* Created by hemanths on 2019-07-31.
*/
public class DeleteSongsAsyncTask extends DialogAsyncTask {
- public static class LoadingInfo {
-
- public Intent intent;
-
- public boolean isIntent;
-
- public int requestCode;
-
- public int resultCode;
-
- public List safUris;
-
- public List songs;
-
- public LoadingInfo(List songs, List safUris) {
- this.isIntent = false;
- this.songs = songs;
- this.safUris = safUris;
- }
-
- public LoadingInfo(int requestCode, int resultCode, Intent intent) {
- this.isIntent = true;
- this.requestCode = requestCode;
- this.resultCode = resultCode;
- this.intent = intent;
- }
- }
-
private WeakReference activityWeakReference;
-
private WeakReference dialogReference;
public DeleteSongsAsyncTask(@NonNull DeleteSongsDialog dialog) {
@@ -138,4 +113,32 @@ public class DeleteSongsAsyncTask extends DialogAsyncTask safUris;
+
+ public List songs;
+
+ public LoadingInfo(List songs, List safUris) {
+ this.isIntent = false;
+ this.songs = songs;
+ this.safUris = safUris;
+ }
+
+ public LoadingInfo(int requestCode, int resultCode, Intent intent) {
+ this.isIntent = true;
+ this.requestCode = requestCode;
+ this.resultCode = resultCode;
+ this.intent = intent;
+ }
+ }
}
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 902c245e..aa9b0d68 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
@@ -87,7 +87,13 @@ class DeleteSongsDialog : DialogFragment() {
deleteSongsAsyncTask?.cancel(true)
}
deleteSongsAsyncTask = DeleteSongsAsyncTask(this)
- deleteSongsAsyncTask?.execute(DeleteSongsAsyncTask.LoadingInfo(requestCode, resultCode, data))
+ deleteSongsAsyncTask?.execute(
+ DeleteSongsAsyncTask.LoadingInfo(
+ requestCode,
+ resultCode,
+ data
+ )
+ )
}
}
}
diff --git a/app/src/main/java/code/name/monkey/retromusic/dialogs/OptionsSheetDialogFragment.kt b/app/src/main/java/code/name/monkey/retromusic/dialogs/OptionsSheetDialogFragment.kt
index 28434ecb..3f6140af 100644
--- a/app/src/main/java/code/name/monkey/retromusic/dialogs/OptionsSheetDialogFragment.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/dialogs/OptionsSheetDialogFragment.kt
@@ -74,7 +74,11 @@ class OptionsSheetDialogFragment : DialogFragment(), View.OnClickListener {
return materialDialog
}
- override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
+ override fun onCreateView(
+ inflater: LayoutInflater,
+ container: ViewGroup?,
+ savedInstanceState: Bundle?
+ ): View? {
dialog?.window?.let {
(requireActivity() as MainActivity).setNavigationbarColorAuto()
(requireActivity() as MainActivity).setLightNavigationBar(true)
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 c0df8987..ca123feb 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
@@ -48,7 +48,11 @@ class RenamePlaylistDialog : DialogFragment() {
positiveButton(string.action_rename) {
if (playlistView.toString().trim { it <= ' ' } != "") {
val playlistId = arguments!!.getLong(PLAYLIST_ID)
- PlaylistsUtil.renamePlaylist(context, playlistId, playlistView.text!!.toString())
+ PlaylistsUtil.renamePlaylist(
+ context,
+ playlistId,
+ playlistView.text!!.toString()
+ )
}
}
}
@@ -61,7 +65,10 @@ class RenamePlaylistDialog : DialogFragment() {
val playlistId = arguments!!.getLong(PLAYLIST_ID)
playlistView.appHandleColor()
- .setText(PlaylistsUtil.getNameForPlaylist(context!!, playlistId), TextView.BufferType.EDITABLE)
+ .setText(
+ PlaylistsUtil.getNameForPlaylist(context!!, playlistId),
+ TextView.BufferType.EDITABLE
+ )
return materialDialog
}
diff --git a/app/src/main/java/code/name/monkey/retromusic/dialogs/SleepTimerDialog.kt b/app/src/main/java/code/name/monkey/retromusic/dialogs/SleepTimerDialog.kt
index 11ff4a36..d469bf0c 100755
--- a/app/src/main/java/code/name/monkey/retromusic/dialogs/SleepTimerDialog.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/dialogs/SleepTimerDialog.kt
@@ -62,7 +62,8 @@ class SleepTimerDialog : DialogFragment() {
.title(R.string.action_sleep_timer)
.cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
.positiveButton(R.string.action_set) {
- PreferenceUtil.getInstance(requireContext()).sleepTimerFinishMusic = shouldFinishLastSong.isChecked
+ PreferenceUtil.getInstance(requireContext()).sleepTimerFinishMusic =
+ shouldFinishLastSong.isChecked
val minutes = seekArcProgress
@@ -119,10 +120,15 @@ class SleepTimerDialog : DialogFragment() {
return materialDialog
}
- shouldFinishLastSong = materialDialog.getCustomView().findViewById(R.id.shouldFinishLastSong)
+ shouldFinishLastSong =
+ materialDialog.getCustomView().findViewById(R.id.shouldFinishLastSong)
seekBar = materialDialog.getCustomView().findViewById(R.id.seekBar)
timerDisplay = materialDialog.getCustomView().findViewById(R.id.timerDisplay)
- TintHelper.setTintAuto(shouldFinishLastSong, ThemeStore.accentColor(requireContext()), false)
+ TintHelper.setTintAuto(
+ shouldFinishLastSong,
+ ThemeStore.accentColor(requireContext()),
+ false
+ )
val finishMusic = PreferenceUtil.getInstance(requireContext()).sleepTimerFinishMusic
shouldFinishLastSong.isChecked = finishMusic
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 d8620ada..4db8bb86 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
@@ -86,22 +86,36 @@ class SongDetailDialog : DialogFragment() {
val songFile = File(song.data)
if (songFile.exists()) {
fileName.text = makeTextWithTitle(context, string.label_file_name, songFile.name)
- filePath.text = makeTextWithTitle(context, string.label_file_path, songFile.absolutePath)
+ filePath.text =
+ makeTextWithTitle(context, string.label_file_path, songFile.absolutePath)
fileSize.text =
- makeTextWithTitle(context, string.label_file_size, getFileSizeString(songFile.length()))
+ makeTextWithTitle(
+ context,
+ string.label_file_size,
+ getFileSizeString(songFile.length())
+ )
try {
val audioFile = AudioFileIO.read(songFile)
val audioHeader = audioFile.audioHeader
- fileFormat.text = makeTextWithTitle(context, string.label_file_format, audioHeader.format)
+ fileFormat.text =
+ makeTextWithTitle(context, string.label_file_format, audioHeader.format)
trackLength.text = makeTextWithTitle(
context,
string.label_track_length,
MusicUtil.getReadableDurationString((audioHeader.trackLength * 1000).toLong())
)
- bitRate.text = makeTextWithTitle(context, string.label_bit_rate, audioHeader.bitRate + " kb/s")
+ bitRate.text = makeTextWithTitle(
+ context,
+ string.label_bit_rate,
+ audioHeader.bitRate + " kb/s"
+ )
samplingRate.text =
- makeTextWithTitle(context, string.label_sampling_rate, audioHeader.sampleRate + " Hz")
+ makeTextWithTitle(
+ context,
+ string.label_sampling_rate,
+ audioHeader.sampleRate + " Hz"
+ )
} catch (@NonNull e: CannotReadException) {
Log.e(TAG, "error while reading the song file", e)
// fallback
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 f57b92cb..dc26f98a 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
@@ -68,7 +68,10 @@ class SongShareDialog : DialogFragment() {
2 -> {
if (song != null) {
startActivity(
- Intent(requireContext(), ShareInstagramStory::class.java).putExtra(
+ Intent(
+ requireContext(),
+ ShareInstagramStory::class.java
+ ).putExtra(
ShareInstagramStory.EXTRA_SONG,
song
)
diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/AlbumCoverStyle.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/AlbumCoverStyle.kt
index 48764425..94087932 100644
--- a/app/src/main/java/code/name/monkey/retromusic/fragments/AlbumCoverStyle.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/fragments/AlbumCoverStyle.kt
@@ -5,10 +5,12 @@ import androidx.annotation.StringRes
import code.name.monkey.retromusic.R
-enum class AlbumCoverStyle(@param:StringRes @field:StringRes
- val titleRes: Int,
- @param:DrawableRes @field:DrawableRes
- val drawableResId: Int, val id: Int) {
+enum class AlbumCoverStyle(
+ @param:StringRes @field:StringRes
+ val titleRes: Int,
+ @param:DrawableRes @field:DrawableRes
+ val drawableResId: Int, val id: Int
+) {
NORMAL(R.string.normal, R.drawable.np_normal, 0),
FLAT(R.string.flat, R.drawable.np_flat, 1),
CIRCLE(R.string.circular, R.drawable.np_circle, 2),
diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/MiniPlayerFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/MiniPlayerFragment.kt
index f19b2bd6..9efa2f46 100644
--- a/app/src/main/java/code/name/monkey/retromusic/fragments/MiniPlayerFragment.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/fragments/MiniPlayerFragment.kt
@@ -7,11 +7,7 @@ import android.os.Bundle
import android.text.SpannableString
import android.text.SpannableStringBuilder
import android.text.style.ForegroundColorSpan
-import android.view.GestureDetector
-import android.view.LayoutInflater
-import android.view.MotionEvent
-import android.view.View
-import android.view.ViewGroup
+import android.view.*
import android.view.animation.DecelerateInterpolator
import code.name.monkey.appthemehelper.ThemeStore
import code.name.monkey.retromusic.R
@@ -24,11 +20,7 @@ import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.RetroUtil
import code.name.monkey.retromusic.util.ViewUtil
-import kotlinx.android.synthetic.main.fragment_mini_player.actionNext
-import kotlinx.android.synthetic.main.fragment_mini_player.actionPrevious
-import kotlinx.android.synthetic.main.fragment_mini_player.miniPlayerPlayPauseButton
-import kotlinx.android.synthetic.main.fragment_mini_player.miniPlayerTitle
-import kotlinx.android.synthetic.main.fragment_mini_player.progressBar
+import kotlinx.android.synthetic.main.fragment_mini_player.*
import kotlin.math.abs
open class MiniPlayerFragment : AbsMusicServiceFragment(), MusicProgressViewUpdateHelper.Callback,
@@ -41,7 +33,11 @@ open class MiniPlayerFragment : AbsMusicServiceFragment(), MusicProgressViewUpda
progressViewUpdateHelper = MusicProgressViewUpdateHelper(this)
}
- override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
+ override fun onCreateView(
+ inflater: LayoutInflater,
+ container: ViewGroup?,
+ savedInstanceState: Bundle?
+ ): View? {
return inflater.inflate(R.layout.fragment_mini_player, container, false)
}
diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/VolumeFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/VolumeFragment.kt
index c7900e5d..ca890310 100755
--- a/app/src/main/java/code/name/monkey/retromusic/fragments/VolumeFragment.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/fragments/VolumeFragment.kt
@@ -11,6 +11,7 @@ import android.view.ViewGroup
import androidx.fragment.app.Fragment
import code.name.monkey.appthemehelper.ThemeStore
import code.name.monkey.retromusic.R
+import code.name.monkey.retromusic.extensions.setRange
import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.ViewUtil
@@ -18,9 +19,7 @@ import code.name.monkey.retromusic.volume.AudioVolumeObserver
import code.name.monkey.retromusic.volume.OnAudioVolumeChangedListener
import com.google.android.material.slider.Slider
import com.google.android.material.slider.Slider.OnChangeListener
-import kotlinx.android.synthetic.main.fragment_volume.volumeDown
-import kotlinx.android.synthetic.main.fragment_volume.volumeSeekBar
-import kotlinx.android.synthetic.main.fragment_volume.volumeUp
+import kotlinx.android.synthetic.main.fragment_volume.*
class VolumeFragment : Fragment(), OnAudioVolumeChangedListener,
View.OnClickListener, OnChangeListener {
@@ -52,7 +51,8 @@ class VolumeFragment : Fragment(), OnAudioVolumeChangedListener,
val audioManager = audioManager
if (audioManager != null) {
- volumeSeekBar.valueTo = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC).toFloat()
+ volumeSeekBar.valueTo =
+ audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC).toFloat()
volumeSeekBar.value = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC).toFloat()
}
volumeSeekBar.addOnChangeListener(this)
@@ -62,11 +62,10 @@ class VolumeFragment : Fragment(), OnAudioVolumeChangedListener,
if (volumeSeekBar == null) {
return
}
- if (maxVolume <= 0) {
+ if (maxVolume <= 0.0f) {
return
}
- volumeSeekBar.valueTo = maxVolume
- volumeSeekBar.valueFrom = currentVolume
+ volumeSeekBar.setRange(currentVolume, maxVolume)
volumeDown.setImageResource(if (currentVolume == 0.0f) R.drawable.ic_volume_off_white_24dp else R.drawable.ic_volume_down_white_24dp)
}
@@ -110,7 +109,6 @@ class VolumeFragment : Fragment(), OnAudioVolumeChangedListener,
fun setTintableColor(color: Int) {
volumeDown.setColorFilter(color, PorterDuff.Mode.SRC_IN)
volumeUp.setColorFilter(color, PorterDuff.Mode.SRC_IN)
- //TintHelper.setTint(volumeSeekBar, color, false)
ViewUtil.setProgressDrawable(volumeSeekBar, color, true)
}
diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsMusicServiceFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsMusicServiceFragment.kt
index 12573abb..3ec3fbad 100644
--- a/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsMusicServiceFragment.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsMusicServiceFragment.kt
@@ -13,7 +13,7 @@ import code.name.monkey.retromusic.util.RetroUtil
import org.jaudiotagger.audio.AudioFileIO
import java.io.File
import java.net.URLEncoder
-import java.util.Locale
+import java.util.*
/**
* Created by hemanths on 18/08/17.
@@ -81,7 +81,8 @@ open class AbsMusicServiceFragment : Fragment(), MusicServiceEventListener {
val uriFile = Uri.fromFile(file)
string.append(getMimeType(uriFile.toString())).append(" • ")
string.append(audioHeader.bitRate).append(" kb/s").append(" • ")
- string.append(RetroUtil.frequencyCount(audioHeader.sampleRate.toInt())).append(" kHz")
+ string.append(RetroUtil.frequencyCount(audioHeader.sampleRate.toInt()))
+ .append(" kHz")
string.toString()
} catch (er: Exception) {
" - "
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 85017dbd..0ac2d8c8 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
@@ -13,7 +13,8 @@ import code.name.monkey.retromusic.util.PreferenceUtil
* Created by hemanths on 24/09/17.
*/
-abstract class AbsPlayerControlsFragment : AbsMusicServiceFragment(), MusicProgressViewUpdateHelper.Callback {
+abstract class AbsPlayerControlsFragment : AbsMusicServiceFragment(),
+ MusicProgressViewUpdateHelper.Callback {
protected abstract fun show()
@@ -61,9 +62,11 @@ abstract class AbsPlayerControlsFragment : AbsMusicServiceFragment(), MusicProgr
private fun hideVolumeIfAvailable() {
if (PreferenceUtil.getInstance(requireContext()).volumeToggle) {
- 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/base/AbsPlayerFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsPlayerFragment.kt
index 019f2261..18f08379 100644
--- a/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsPlayerFragment.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsPlayerFragment.kt
@@ -18,25 +18,15 @@ import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.activities.tageditor.AbsTagEditorActivity
import code.name.monkey.retromusic.activities.tageditor.SongTagEditorActivity
-import code.name.monkey.retromusic.dialogs.AddToPlaylistDialog
-import code.name.monkey.retromusic.dialogs.CreatePlaylistDialog
-import code.name.monkey.retromusic.dialogs.DeleteSongsDialog
-import code.name.monkey.retromusic.dialogs.SleepTimerDialog
-import code.name.monkey.retromusic.dialogs.SongDetailDialog
-import code.name.monkey.retromusic.dialogs.SongShareDialog
+import code.name.monkey.retromusic.dialogs.*
import code.name.monkey.retromusic.extensions.hide
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.interfaces.PaletteColorHolder
import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.model.lyrics.Lyrics
-import code.name.monkey.retromusic.util.LyricUtil
-import code.name.monkey.retromusic.util.MusicUtil
-import code.name.monkey.retromusic.util.NavigationUtil
-import code.name.monkey.retromusic.util.PreferenceUtil
-import code.name.monkey.retromusic.util.RetroUtil
-import code.name.monkey.retromusic.util.RingtoneManager
-import kotlinx.android.synthetic.main.shadow_statusbar_toolbar.statusBarShadow
+import code.name.monkey.retromusic.util.*
+import kotlinx.android.synthetic.main.shadow_statusbar_toolbar.*
import java.io.FileNotFoundException
abstract class AbsPlayerFragment : AbsMusicServiceFragment(),
@@ -141,9 +131,13 @@ abstract class AbsPlayerFragment : AbsMusicServiceFragment(),
R.id.action_go_to_genre -> {
val retriever = MediaMetadataRetriever()
val trackUri =
- ContentUris.withAppendedId(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, song.id.toLong())
+ ContentUris.withAppendedId(
+ MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
+ song.id.toLong()
+ )
retriever.setDataSource(activity, trackUri)
- var genre: String? = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_GENRE)
+ var genre: String? =
+ retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_GENRE)
if (genre == null) {
genre = "Not Specified"
}
@@ -204,10 +198,14 @@ abstract class AbsPlayerFragment : AbsMusicServiceFragment(),
else
R.drawable.ic_favorite_border_white_24dp
- val drawable = RetroUtil.getTintedVectorDrawable(requireContext(), res, toolbarIconColor())
+ val drawable =
+ RetroUtil.getTintedVectorDrawable(requireContext(), res, toolbarIconColor())
if (playerToolbar() != null && playerToolbar()!!.menu.findItem(R.id.action_toggle_favorite) != null)
- playerToolbar()!!.menu.findItem(R.id.action_toggle_favorite).setIcon(drawable).title =
- if (isFavorite) getString(R.string.action_remove_from_favorites) else getString(R.string.action_add_to_favorites)
+ playerToolbar()!!.menu.findItem(R.id.action_toggle_favorite).setIcon(drawable)
+ .title =
+ if (isFavorite) getString(R.string.action_remove_from_favorites) else getString(
+ R.string.action_add_to_favorites
+ )
}
}.execute(MusicPlayerRemote.currentSong)
}
@@ -224,7 +222,8 @@ abstract class AbsPlayerFragment : AbsMusicServiceFragment(),
override fun doInBackground(vararg params: Song): Lyrics? {
try {
- var data: String? = LyricUtil.getStringFromFile(params[0].title, params[0].artistName)
+ var data: String? =
+ LyricUtil.getStringFromFile(params[0].title, params[0].artistName)
return if (TextUtils.isEmpty(data)) {
data = MusicUtil.getLyrics(params[0])
return if (TextUtils.isEmpty(data)) {
diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/mainactivity/AlbumsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/mainactivity/AlbumsFragment.kt
index 4130925e..32c374d7 100644
--- a/app/src/main/java/code/name/monkey/retromusic/fragments/mainactivity/AlbumsFragment.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/fragments/mainactivity/AlbumsFragment.kt
@@ -14,7 +14,8 @@ import code.name.monkey.retromusic.mvp.presenter.AlbumsView
import code.name.monkey.retromusic.util.PreferenceUtil
import javax.inject.Inject
-class AlbumsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment(),
+class AlbumsFragment :
+ AbsLibraryPagerRecyclerViewCustomGridSizeFragment(),
AlbumsView, MainActivityFragmentCallbacks {
@Inject
@@ -118,7 +119,8 @@ class AlbumsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment(),
+class ArtistsFragment :
+ AbsLibraryPagerRecyclerViewCustomGridSizeFragment(),
ArtistsView, MainActivityFragmentCallbacks {
override fun handleBackPress(): Boolean {
@@ -111,6 +112,7 @@ class ArtistsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment> {
- public static class ListPathsAsyncTask extends
- ListingFilesDialogAsyncTask {
-
- public static class LoadingInfo {
-
- public final File file;
-
- final FileFilter fileFilter;
-
- public LoadingInfo(File file, FileFilter fileFilter) {
- this.file = file;
- this.fileFilter = fileFilter;
- }
- }
-
- public interface OnPathsListedCallback {
-
- void onPathsListed(@NonNull String[] paths);
- }
-
- private WeakReference onPathsListedCallbackWeakReference;
-
- public ListPathsAsyncTask(Context context, OnPathsListedCallback callback) {
- super(context);
- onPathsListedCallbackWeakReference = new WeakReference<>(callback);
- }
-
- @Override
- protected String[] doInBackground(LoadingInfo... params) {
- try {
- if (isCancelled() || checkCallbackReference() == null) {
- return null;
- }
-
- LoadingInfo info = params[0];
-
- final String[] paths;
-
- if (info.file.isDirectory()) {
- List files = FileUtil.listFilesDeep(info.file, info.fileFilter);
-
- if (isCancelled() || checkCallbackReference() == null) {
- return null;
- }
-
- paths = new String[files.size()];
- for (int i = 0; i < files.size(); i++) {
- File f = files.get(i);
- paths[i] = FileUtil.safeGetCanonicalPath(f);
-
- if (isCancelled() || checkCallbackReference() == null) {
- return null;
- }
- }
- } else {
- paths = new String[1];
- paths[0] = info.file.getPath();
- }
-
- return paths;
- } catch (Exception e) {
- e.printStackTrace();
- cancel(false);
- return null;
- }
- }
-
- @Override
- protected void onPostExecute(String[] paths) {
- super.onPostExecute(paths);
- OnPathsListedCallback callback = checkCallbackReference();
- if (callback != null && paths != null) {
- callback.onPathsListed(paths);
- }
- }
-
- @Override
- protected void onPreExecute() {
- super.onPreExecute();
- checkCallbackReference();
- }
-
- private OnPathsListedCallback checkCallbackReference() {
- OnPathsListedCallback callback = onPathsListedCallbackWeakReference.get();
- if (callback == null) {
- cancel(false);
- }
- return callback;
- }
- }
-
- private static class AsyncFileLoader extends WrappedAsyncTaskLoader> {
-
- private WeakReference fragmentWeakReference;
-
- AsyncFileLoader(FoldersFragment foldersFragment) {
- super(Objects.requireNonNull(foldersFragment.getActivity()));
- fragmentWeakReference = new WeakReference<>(foldersFragment);
- }
-
- @Override
- public List loadInBackground() {
- FoldersFragment foldersFragment = fragmentWeakReference.get();
- File directory = null;
- if (foldersFragment != null) {
- BreadCrumbLayout.Crumb crumb = foldersFragment.getActiveCrumb();
- if (crumb != null) {
- directory = crumb.getFile();
- }
- }
- if (directory != null) {
- List files = FileUtil.listFiles(directory, AUDIO_FILE_FILTER);
- Collections.sort(files, foldersFragment.getFileComparator());
- return files;
- } else {
- return new LinkedList<>();
- }
- }
- }
-
- private static class ListSongsAsyncTask
- extends ListingFilesDialogAsyncTask> {
-
- static class LoadingInfo {
-
- final Comparator fileComparator;
-
- final FileFilter fileFilter;
-
- final List files;
-
- LoadingInfo(@NonNull List files, @NonNull FileFilter fileFilter,
- @NonNull Comparator fileComparator) {
- this.fileComparator = fileComparator;
- this.fileFilter = fileFilter;
- this.files = files;
- }
- }
-
- public interface OnSongsListedCallback {
-
- void onSongsListed(@NonNull ArrayList songs, Object extra);
- }
-
- private WeakReference callbackWeakReference;
-
- private WeakReference contextWeakReference;
-
- private final Object extra;
-
- ListSongsAsyncTask(Context context, Object extra, OnSongsListedCallback callback) {
- super(context);
- this.extra = extra;
- contextWeakReference = new WeakReference<>(context);
- callbackWeakReference = new WeakReference<>(callback);
- }
-
- @Override
- protected ArrayList doInBackground(LoadingInfo... params) {
- try {
- LoadingInfo info = params[0];
- List files = FileUtil.listFilesDeep(info.files, info.fileFilter);
-
- if (isCancelled() || checkContextReference() == null
- || checkCallbackReference() == null) {
- return null;
- }
-
- Collections.sort(files, info.fileComparator);
-
- Context context = checkContextReference();
- if (isCancelled() || context == null || checkCallbackReference() == null) {
- return null;
- }
-
- return FileUtil.matchFilesWithMediaStore(context, files);
- } catch (Exception e) {
- e.printStackTrace();
- cancel(false);
- return null;
- }
- }
-
- @Override
- protected void onPostExecute(ArrayList songs) {
- super.onPostExecute(songs);
- OnSongsListedCallback callback = checkCallbackReference();
- if (songs != null && callback != null) {
- callback.onSongsListed(songs, extra);
- }
- }
-
- @Override
- protected void onPreExecute() {
- super.onPreExecute();
- checkCallbackReference();
- checkContextReference();
- }
-
- private OnSongsListedCallback checkCallbackReference() {
- OnSongsListedCallback callback = callbackWeakReference.get();
- if (callback == null) {
- cancel(false);
- }
- return callback;
- }
-
- private Context checkContextReference() {
- Context context = contextWeakReference.get();
- if (context == null) {
- cancel(false);
- }
- return context;
- }
- }
-
- private static abstract class ListingFilesDialogAsyncTask extends
- DialogAsyncTask {
-
- ListingFilesDialogAsyncTask(Context context) {
- super(context);
- }
-
- public ListingFilesDialogAsyncTask(Context context, int showDelay) {
- super(context, showDelay);
- }
-
- @Override
- protected Dialog createDialog(@NonNull Context context) {
- return new MaterialAlertDialogBuilder(context)
- .setTitle(R.string.listing_files)
- .setCancelable(false)
- .setView(R.layout.loading)
- .setOnCancelListener(dialog -> cancel(false))
- .setOnDismissListener(dialog -> cancel(false))
- .create();
- }
- }
-
public static final String TAG = FoldersFragment.class.getSimpleName();
-
public static final FileFilter AUDIO_FILE_FILTER = file -> !file.isHidden() && (file.isDirectory() ||
FileUtil.fileIsMimeType(file, "audio/*", MimeTypeMap.getSingleton()) ||
FileUtil.fileIsMimeType(file, "application/opus", MimeTypeMap.getSingleton()) ||
FileUtil.fileIsMimeType(file, "application/ogg", MimeTypeMap.getSingleton()));
-
private static final String PATH = "path";
-
private static final String CRUMBS = "crumbs";
-
private static final int LOADER_ID = LoaderIds.Companion.getFOLDERS_FRAGMENT();
-
private SongFileAdapter adapter;
-
private BreadCrumbLayout breadCrumbs;
-
private MaterialCab cab;
-
private View coordinatorLayout, empty;
-
private TextView emojiText;
-
private Comparator fileComparator = (lhs, rhs) -> {
if (lhs.isDirectory() && !rhs.isDirectory()) {
return -1;
@@ -349,9 +104,10 @@ public class FoldersFragment extends AbsMainActivityFragment implements
(rhs.getName());
}
};
-
private RecyclerView recyclerView;
+ public FoldersFragment() {
+ }
public static File getDefaultStartDirectory() {
File musicDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC);
@@ -381,14 +137,20 @@ public class FoldersFragment extends AbsMainActivityFragment implements
return newInstance(PreferenceUtil.getInstance(context).getStartDirectory());
}
- public FoldersFragment() {
+ private static File tryGetCanonicalFile(File file) {
+ try {
+ return file.getCanonicalFile();
+ } catch (IOException e) {
+ e.printStackTrace();
+ return file;
+ }
}
@NonNull
@Override
public View onCreateView(@NonNull LayoutInflater inflater,
- ViewGroup container,
- Bundle savedInstanceState) {
+ ViewGroup container,
+ Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_folder, container, false);
initViews(view);
return view;
@@ -737,12 +499,240 @@ public class FoldersFragment extends AbsMainActivityFragment implements
}
}
- private static File tryGetCanonicalFile(File file) {
- try {
- return file.getCanonicalFile();
- } catch (IOException e) {
- e.printStackTrace();
- return file;
+ public static class ListPathsAsyncTask extends
+ ListingFilesDialogAsyncTask {
+
+ private WeakReference onPathsListedCallbackWeakReference;
+
+ public ListPathsAsyncTask(Context context, OnPathsListedCallback callback) {
+ super(context);
+ onPathsListedCallbackWeakReference = new WeakReference<>(callback);
+ }
+
+ @Override
+ protected String[] doInBackground(LoadingInfo... params) {
+ try {
+ if (isCancelled() || checkCallbackReference() == null) {
+ return null;
+ }
+
+ LoadingInfo info = params[0];
+
+ final String[] paths;
+
+ if (info.file.isDirectory()) {
+ List files = FileUtil.listFilesDeep(info.file, info.fileFilter);
+
+ if (isCancelled() || checkCallbackReference() == null) {
+ return null;
+ }
+
+ paths = new String[files.size()];
+ for (int i = 0; i < files.size(); i++) {
+ File f = files.get(i);
+ paths[i] = FileUtil.safeGetCanonicalPath(f);
+
+ if (isCancelled() || checkCallbackReference() == null) {
+ return null;
+ }
+ }
+ } else {
+ paths = new String[1];
+ paths[0] = info.file.getPath();
+ }
+
+ return paths;
+ } catch (Exception e) {
+ e.printStackTrace();
+ cancel(false);
+ return null;
+ }
+ }
+
+ @Override
+ protected void onPostExecute(String[] paths) {
+ super.onPostExecute(paths);
+ OnPathsListedCallback callback = checkCallbackReference();
+ if (callback != null && paths != null) {
+ callback.onPathsListed(paths);
+ }
+ }
+
+ @Override
+ protected void onPreExecute() {
+ super.onPreExecute();
+ checkCallbackReference();
+ }
+
+ private OnPathsListedCallback checkCallbackReference() {
+ OnPathsListedCallback callback = onPathsListedCallbackWeakReference.get();
+ if (callback == null) {
+ cancel(false);
+ }
+ return callback;
+ }
+
+ public interface OnPathsListedCallback {
+
+ void onPathsListed(@NonNull String[] paths);
+ }
+
+ public static class LoadingInfo {
+
+ public final File file;
+
+ final FileFilter fileFilter;
+
+ public LoadingInfo(File file, FileFilter fileFilter) {
+ this.file = file;
+ this.fileFilter = fileFilter;
+ }
+ }
+ }
+
+ private static class AsyncFileLoader extends WrappedAsyncTaskLoader> {
+
+ private WeakReference fragmentWeakReference;
+
+ AsyncFileLoader(FoldersFragment foldersFragment) {
+ super(Objects.requireNonNull(foldersFragment.getActivity()));
+ fragmentWeakReference = new WeakReference<>(foldersFragment);
+ }
+
+ @Override
+ public List loadInBackground() {
+ FoldersFragment foldersFragment = fragmentWeakReference.get();
+ File directory = null;
+ if (foldersFragment != null) {
+ BreadCrumbLayout.Crumb crumb = foldersFragment.getActiveCrumb();
+ if (crumb != null) {
+ directory = crumb.getFile();
+ }
+ }
+ if (directory != null) {
+ List files = FileUtil.listFiles(directory, AUDIO_FILE_FILTER);
+ Collections.sort(files, foldersFragment.getFileComparator());
+ return files;
+ } else {
+ return new LinkedList<>();
+ }
+ }
+ }
+
+ private static class ListSongsAsyncTask
+ extends ListingFilesDialogAsyncTask> {
+
+ private final Object extra;
+ private WeakReference callbackWeakReference;
+ private WeakReference contextWeakReference;
+
+ ListSongsAsyncTask(Context context, Object extra, OnSongsListedCallback callback) {
+ super(context);
+ this.extra = extra;
+ contextWeakReference = new WeakReference<>(context);
+ callbackWeakReference = new WeakReference<>(callback);
+ }
+
+ @Override
+ protected ArrayList doInBackground(LoadingInfo... params) {
+ try {
+ LoadingInfo info = params[0];
+ List files = FileUtil.listFilesDeep(info.files, info.fileFilter);
+
+ if (isCancelled() || checkContextReference() == null
+ || checkCallbackReference() == null) {
+ return null;
+ }
+
+ Collections.sort(files, info.fileComparator);
+
+ Context context = checkContextReference();
+ if (isCancelled() || context == null || checkCallbackReference() == null) {
+ return null;
+ }
+
+ return FileUtil.matchFilesWithMediaStore(context, files);
+ } catch (Exception e) {
+ e.printStackTrace();
+ cancel(false);
+ return null;
+ }
+ }
+
+ @Override
+ protected void onPostExecute(ArrayList songs) {
+ super.onPostExecute(songs);
+ OnSongsListedCallback callback = checkCallbackReference();
+ if (songs != null && callback != null) {
+ callback.onSongsListed(songs, extra);
+ }
+ }
+
+ @Override
+ protected void onPreExecute() {
+ super.onPreExecute();
+ checkCallbackReference();
+ checkContextReference();
+ }
+
+ private OnSongsListedCallback checkCallbackReference() {
+ OnSongsListedCallback callback = callbackWeakReference.get();
+ if (callback == null) {
+ cancel(false);
+ }
+ return callback;
+ }
+
+ private Context checkContextReference() {
+ Context context = contextWeakReference.get();
+ if (context == null) {
+ cancel(false);
+ }
+ return context;
+ }
+
+ public interface OnSongsListedCallback {
+
+ void onSongsListed(@NonNull ArrayList songs, Object extra);
+ }
+
+ static class LoadingInfo {
+
+ final Comparator fileComparator;
+
+ final FileFilter fileFilter;
+
+ final List files;
+
+ LoadingInfo(@NonNull List files, @NonNull FileFilter fileFilter,
+ @NonNull Comparator fileComparator) {
+ this.fileComparator = fileComparator;
+ this.fileFilter = fileFilter;
+ this.files = files;
+ }
+ }
+ }
+
+ private static abstract class ListingFilesDialogAsyncTask extends
+ DialogAsyncTask {
+
+ ListingFilesDialogAsyncTask(Context context) {
+ super(context);
+ }
+
+ public ListingFilesDialogAsyncTask(Context context, int showDelay) {
+ super(context, showDelay);
+ }
+
+ @Override
+ protected Dialog createDialog(@NonNull Context context) {
+ return new MaterialAlertDialogBuilder(context)
+ .setTitle(R.string.listing_files)
+ .setCancelable(false)
+ .setView(R.layout.loading)
+ .setOnCancelListener(dialog -> cancel(false))
+ .setOnDismissListener(dialog -> cancel(false))
+ .create();
}
}
}
diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/mainactivity/GenresFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/mainactivity/GenresFragment.kt
index 46ebc440..bf0dc49c 100644
--- a/app/src/main/java/code/name/monkey/retromusic/fragments/mainactivity/GenresFragment.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/fragments/mainactivity/GenresFragment.kt
@@ -85,6 +85,7 @@ class GenresFragment : AbsLibraryPagerRecyclerViewFragment(),
+class PlayingQueueFragment :
+ AbsLibraryPagerRecyclerViewFragment(),
MainActivityFragmentCallbacks {
override fun handleBackPress(): Boolean {
@@ -57,8 +58,10 @@ class PlayingQueueFragment : AbsLibraryPagerRecyclerViewFragment
- wrappedAdapter = recyclerViewSwipeManager?.createWrappedAdapter(wrappedAdapter) as RecyclerView.Adapter<*>
+ wrappedAdapter =
+ recyclerViewDragDropManager?.createWrappedAdapter(adapter!!) as RecyclerView.Adapter<*>
+ wrappedAdapter =
+ recyclerViewSwipeManager?.createWrappedAdapter(wrappedAdapter) as RecyclerView.Adapter<*>
recyclerView().layoutManager = layoutManager
recyclerView().adapter = wrappedAdapter
recyclerView().itemAnimator = animator
@@ -137,6 +140,7 @@ class PlayingQueueFragment : AbsLibraryPagerRecyclerViewFragment(), PlaylistView,
+class PlaylistsFragment :
+ AbsLibraryPagerRecyclerViewFragment(), PlaylistView,
MainActivityFragmentCallbacks {
override fun handleBackPress(): Boolean {
diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/mainactivity/SongsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/mainactivity/SongsFragment.kt
index 66529505..10c12e76 100644
--- a/app/src/main/java/code/name/monkey/retromusic/fragments/mainactivity/SongsFragment.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/fragments/mainactivity/SongsFragment.kt
@@ -14,10 +14,11 @@ import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.mvp.presenter.SongPresenter
import code.name.monkey.retromusic.mvp.presenter.SongView
import code.name.monkey.retromusic.util.PreferenceUtil
-import java.util.ArrayList
+import java.util.*
import javax.inject.Inject
-class SongsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment(),
+class SongsFragment :
+ AbsLibraryPagerRecyclerViewCustomGridSizeFragment(),
SongView, MainActivityFragmentCallbacks {
@Inject
diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/PlayerAlbumCoverFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/PlayerAlbumCoverFragment.kt
index d1901524..9801c9b6 100644
--- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/PlayerAlbumCoverFragment.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/PlayerAlbumCoverFragment.kt
@@ -8,15 +8,13 @@ import androidx.viewpager.widget.ViewPager
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.adapter.album.AlbumCoverPagerAdapter
import code.name.monkey.retromusic.adapter.album.AlbumCoverPagerAdapter.AlbumCoverFragment
-import code.name.monkey.retromusic.fragments.NowPlayingScreen.ADAPTIVE
-import code.name.monkey.retromusic.fragments.NowPlayingScreen.FIT
-import code.name.monkey.retromusic.fragments.NowPlayingScreen.FULL
+import code.name.monkey.retromusic.fragments.NowPlayingScreen.*
import code.name.monkey.retromusic.fragments.base.AbsMusicServiceFragment
import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.transform.CarousalPagerTransformer
import code.name.monkey.retromusic.transform.ParallaxPagerTransformer
import code.name.monkey.retromusic.util.PreferenceUtil
-import kotlinx.android.synthetic.main.fragment_player_album_cover.viewPager
+import kotlinx.android.synthetic.main.fragment_player_album_cover.*
class PlayerAlbumCoverFragment : AbsMusicServiceFragment(), ViewPager.OnPageChangeListener {
private var callbacks: Callbacks? = null
@@ -56,7 +54,10 @@ class PlayerAlbumCoverFragment : AbsMusicServiceFragment(), ViewPager.OnPageChan
viewPager.setPageTransformer(false, CarousalPagerTransformer(requireContext()))
} else {
viewPager.offscreenPageLimit = 2
- viewPager.setPageTransformer(true, PreferenceUtil.getInstance(requireContext()).albumCoverTransform)
+ viewPager.setPageTransformer(
+ true,
+ PreferenceUtil.getInstance(requireContext()).albumCoverTransform
+ )
}
}
diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/adaptive/AdaptiveFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/adaptive/AdaptiveFragment.kt
index ffa7e448..c8f4b13d 100644
--- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/adaptive/AdaptiveFragment.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/adaptive/AdaptiveFragment.kt
@@ -19,7 +19,7 @@ import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper
import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.model.lyrics.AbsSynchronizedLyrics
import code.name.monkey.retromusic.model.lyrics.Lyrics
-import kotlinx.android.synthetic.main.fragment_adaptive_player.playerToolbar
+import kotlinx.android.synthetic.main.fragment_adaptive_player.*
class AdaptiveFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Callback {
@@ -55,7 +55,10 @@ class AdaptiveFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Call
lyricsLine2.visibility = View.VISIBLE
lyricsLine2.measure(
- View.MeasureSpec.makeMeasureSpec(lyricsLine2.measuredWidth, View.MeasureSpec.EXACTLY),
+ View.MeasureSpec.makeMeasureSpec(
+ lyricsLine2.measuredWidth,
+ View.MeasureSpec.EXACTLY
+ ),
View.MeasureSpec.UNSPECIFIED
)
val h: Float = lyricsLine2.measuredHeight.toFloat()
@@ -79,12 +82,13 @@ class AdaptiveFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Call
}
private fun hideLyricsLayout() {
- lyricsLayout.animate().alpha(0f).setDuration(VISIBILITY_ANIM_DURATION).withEndAction(Runnable {
- if (!isLyricsLayoutBound()) return@Runnable
- lyricsLayout.visibility = View.GONE
- lyricsLine1.text = null
- lyricsLine2.text = null
- })
+ lyricsLayout.animate().alpha(0f).setDuration(VISIBILITY_ANIM_DURATION)
+ .withEndAction(Runnable {
+ if (!isLyricsLayoutBound()) return@Runnable
+ lyricsLayout.visibility = View.GONE
+ lyricsLine1.text = null
+ lyricsLine2.text = null
+ })
}
override fun setLyrics(l: Lyrics?) {
@@ -116,7 +120,11 @@ class AdaptiveFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Call
private var lastColor: Int = 0
private lateinit var playbackControlsFragment: AdaptivePlaybackControlsFragment
- override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
+ override fun onCreateView(
+ inflater: LayoutInflater,
+ container: ViewGroup?,
+ savedInstanceState: Bundle?
+ ): View? {
return inflater.inflate(R.layout.fragment_adaptive_player, container, false)
}
diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/adaptive/AdaptivePlaybackControlsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/adaptive/AdaptivePlaybackControlsFragment.kt
index bd8b2d93..90bf493c 100644
--- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/adaptive/AdaptivePlaybackControlsFragment.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/adaptive/AdaptivePlaybackControlsFragment.kt
@@ -23,15 +23,7 @@ import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.ViewUtil
-import kotlinx.android.synthetic.main.fragment_adaptive_player_playback_controls.nextButton
-import kotlinx.android.synthetic.main.fragment_adaptive_player_playback_controls.playPauseButton
-import kotlinx.android.synthetic.main.fragment_adaptive_player_playback_controls.previousButton
-import kotlinx.android.synthetic.main.fragment_adaptive_player_playback_controls.progressSlider
-import kotlinx.android.synthetic.main.fragment_adaptive_player_playback_controls.repeatButton
-import kotlinx.android.synthetic.main.fragment_adaptive_player_playback_controls.shuffleButton
-import kotlinx.android.synthetic.main.fragment_adaptive_player_playback_controls.songCurrentProgress
-import kotlinx.android.synthetic.main.fragment_adaptive_player_playback_controls.songInfo
-import kotlinx.android.synthetic.main.fragment_adaptive_player_playback_controls.songTotalTime
+import kotlinx.android.synthetic.main.fragment_adaptive_player_playback_controls.*
class AdaptivePlaybackControlsFragment : AbsPlayerControlsFragment() {
@@ -48,7 +40,11 @@ class AdaptivePlaybackControlsFragment : AbsPlayerControlsFragment() {
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
- return inflater.inflate(R.layout.fragment_adaptive_player_playback_controls, container, false)
+ return inflater.inflate(
+ R.layout.fragment_adaptive_player_playback_controls,
+ container,
+ false
+ )
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
@@ -109,12 +105,20 @@ class AdaptivePlaybackControlsFragment : AbsPlayerControlsFragment() {
}
override fun setDark(color: Int) {
- if (ColorUtil.isColorLight(ATHUtil.resolveColor(context, android.R.attr.windowBackground))) {
+ if (ColorUtil.isColorLight(
+ ATHUtil.resolveColor(
+ context,
+ android.R.attr.windowBackground
+ )
+ )
+ ) {
lastPlaybackControlsColor = MaterialValueHelper.getSecondaryTextColor(activity, true)
- lastDisabledPlaybackControlsColor = MaterialValueHelper.getSecondaryDisabledTextColor(activity, true)
+ lastDisabledPlaybackControlsColor =
+ MaterialValueHelper.getSecondaryDisabledTextColor(activity, true)
} else {
lastPlaybackControlsColor = MaterialValueHelper.getPrimaryTextColor(activity, false)
- lastDisabledPlaybackControlsColor = MaterialValueHelper.getPrimaryDisabledTextColor(activity, false)
+ lastDisabledPlaybackControlsColor =
+ MaterialValueHelper.getPrimaryDisabledTextColor(activity, false)
}
updateRepeatState()
@@ -183,7 +187,10 @@ class AdaptivePlaybackControlsFragment : AbsPlayerControlsFragment() {
lastPlaybackControlsColor,
PorterDuff.Mode.SRC_IN
)
- else -> shuffleButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
+ else -> shuffleButton.setColorFilter(
+ lastDisabledPlaybackControlsColor,
+ PorterDuff.Mode.SRC_IN
+ )
}
}
@@ -195,7 +202,10 @@ class AdaptivePlaybackControlsFragment : AbsPlayerControlsFragment() {
when (MusicPlayerRemote.repeatMode) {
MusicService.REPEAT_MODE_NONE -> {
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
- repeatButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
+ repeatButton.setColorFilter(
+ lastDisabledPlaybackControlsColor,
+ PorterDuff.Mode.SRC_IN
+ )
}
MusicService.REPEAT_MODE_ALL -> {
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
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 cb466d23..085e60ec 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
@@ -23,17 +23,7 @@ import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.PreferenceUtil
-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_blur_player_playback_controls.*
class BlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
@@ -119,7 +109,8 @@ class BlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
override fun setDark(color: Int) {
lastPlaybackControlsColor = Color.WHITE
- lastDisabledPlaybackControlsColor = ContextCompat.getColor(requireContext(), R.color.md_grey_500)
+ lastDisabledPlaybackControlsColor =
+ ContextCompat.getColor(requireContext(), R.color.md_grey_500)
title.setTextColor(lastPlaybackControlsColor)
@@ -188,7 +179,10 @@ class BlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
lastPlaybackControlsColor,
PorterDuff.Mode.SRC_IN
)
- else -> shuffleButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
+ else -> shuffleButton.setColorFilter(
+ lastDisabledPlaybackControlsColor,
+ PorterDuff.Mode.SRC_IN
+ )
}
}
@@ -200,7 +194,10 @@ class BlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
when (MusicPlayerRemote.repeatMode) {
MusicService.REPEAT_MODE_NONE -> {
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
- repeatButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
+ repeatButton.setColorFilter(
+ lastDisabledPlaybackControlsColor,
+ PorterDuff.Mode.SRC_IN
+ )
}
MusicService.REPEAT_MODE_ALL -> {
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/blur/BlurPlayerFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/blur/BlurPlayerFragment.kt
index 570e6805..6c5002b5 100644
--- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/blur/BlurPlayerFragment.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/blur/BlurPlayerFragment.kt
@@ -19,8 +19,7 @@ import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.util.PreferenceUtil
import com.bumptech.glide.Glide
-import kotlinx.android.synthetic.main.fragment_blur.colorBackground
-import kotlinx.android.synthetic.main.fragment_blur.playerToolbar
+import kotlinx.android.synthetic.main.fragment_blur.*
class BlurPlayerFragment : AbsPlayerFragment(), SharedPreferences.OnSharedPreferenceChangeListener {
@@ -126,7 +125,8 @@ class BlurPlayerFragment : AbsPlayerFragment(), SharedPreferences.OnSharedPrefer
override fun onResume() {
super.onResume()
- PreferenceManager.getDefaultSharedPreferences(requireContext()).registerOnSharedPreferenceChangeListener(this)
+ PreferenceManager.getDefaultSharedPreferences(requireContext())
+ .registerOnSharedPreferenceChangeListener(this)
}
override fun onDestroyView() {
diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/card/CardFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/card/CardFragment.kt
index 91f9cea7..d347f81b 100644
--- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/card/CardFragment.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/card/CardFragment.kt
@@ -13,7 +13,7 @@ import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
import code.name.monkey.retromusic.fragments.player.normal.PlayerFragment
import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.model.Song
-import kotlinx.android.synthetic.main.fragment_card_player.playerToolbar
+import kotlinx.android.synthetic.main.fragment_card_player.*
class CardFragment : AbsPlayerFragment() {
override fun playerToolbar(): Toolbar {
diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/card/CardPlaybackControlsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/card/CardPlaybackControlsFragment.kt
index e04de9fa..e2bdf4cd 100644
--- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/card/CardPlaybackControlsFragment.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/card/CardPlaybackControlsFragment.kt
@@ -25,18 +25,8 @@ 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.PreferenceUtil
-import kotlinx.android.synthetic.main.fragment_card_player_playback_controls.image
-import kotlinx.android.synthetic.main.fragment_card_player_playback_controls.progressSlider
-import kotlinx.android.synthetic.main.fragment_card_player_playback_controls.songCurrentProgress
-import kotlinx.android.synthetic.main.fragment_card_player_playback_controls.songInfo
-import kotlinx.android.synthetic.main.fragment_card_player_playback_controls.songTotalTime
-import kotlinx.android.synthetic.main.fragment_card_player_playback_controls.text
-import kotlinx.android.synthetic.main.fragment_card_player_playback_controls.title
-import kotlinx.android.synthetic.main.media_button.nextButton
-import kotlinx.android.synthetic.main.media_button.playPauseButton
-import kotlinx.android.synthetic.main.media_button.previousButton
-import kotlinx.android.synthetic.main.media_button.repeatButton
-import kotlinx.android.synthetic.main.media_button.shuffleButton
+import kotlinx.android.synthetic.main.fragment_card_player_playback_controls.*
+import kotlinx.android.synthetic.main.media_button.*
class CardPlaybackControlsFragment : AbsPlayerControlsFragment() {
@@ -121,12 +111,20 @@ class CardPlaybackControlsFragment : AbsPlayerControlsFragment() {
override fun setDark(color: Int) {
- if (ColorUtil.isColorLight(ATHUtil.resolveColor(context, android.R.attr.windowBackground))) {
+ if (ColorUtil.isColorLight(
+ ATHUtil.resolveColor(
+ context,
+ android.R.attr.windowBackground
+ )
+ )
+ ) {
lastPlaybackControlsColor = MaterialValueHelper.getSecondaryTextColor(activity, true)
- lastDisabledPlaybackControlsColor = MaterialValueHelper.getSecondaryDisabledTextColor(activity, true)
+ lastDisabledPlaybackControlsColor =
+ MaterialValueHelper.getSecondaryDisabledTextColor(activity, true)
} else {
lastPlaybackControlsColor = MaterialValueHelper.getPrimaryTextColor(activity, false)
- lastDisabledPlaybackControlsColor = MaterialValueHelper.getPrimaryDisabledTextColor(activity, false)
+ lastDisabledPlaybackControlsColor =
+ MaterialValueHelper.getPrimaryDisabledTextColor(activity, false)
}
updateRepeatState()
@@ -196,7 +194,10 @@ class CardPlaybackControlsFragment : AbsPlayerControlsFragment() {
lastPlaybackControlsColor,
PorterDuff.Mode.SRC_IN
)
- else -> shuffleButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
+ else -> shuffleButton.setColorFilter(
+ lastDisabledPlaybackControlsColor,
+ PorterDuff.Mode.SRC_IN
+ )
}
}
@@ -208,7 +209,10 @@ class CardPlaybackControlsFragment : AbsPlayerControlsFragment() {
when (MusicPlayerRemote.repeatMode) {
MusicService.REPEAT_MODE_NONE -> {
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
- repeatButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
+ repeatButton.setColorFilter(
+ lastDisabledPlaybackControlsColor,
+ PorterDuff.Mode.SRC_IN
+ )
}
MusicService.REPEAT_MODE_ALL -> {
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
@@ -252,7 +256,10 @@ class CardPlaybackControlsFragment : AbsPlayerControlsFragment() {
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
if (fromUser) {
MusicPlayerRemote.seekTo(progress)
- onUpdateProgressViews(MusicPlayerRemote.songProgressMillis, MusicPlayerRemote.songDurationMillis)
+ onUpdateProgressViews(
+ MusicPlayerRemote.songProgressMillis,
+ MusicPlayerRemote.songDurationMillis
+ )
}
}
})
diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/cardblur/CardBlurFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/cardblur/CardBlurFragment.kt
index f1854004..05ce400c 100644
--- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/cardblur/CardBlurFragment.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/cardblur/CardBlurFragment.kt
@@ -20,8 +20,7 @@ import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.util.PreferenceUtil
import com.bumptech.glide.Glide
-import kotlinx.android.synthetic.main.fragment_card_blur_player.colorBackground
-import kotlinx.android.synthetic.main.fragment_card_blur_player.playerToolbar
+import kotlinx.android.synthetic.main.fragment_card_blur_player.*
class CardBlurFragment : AbsPlayerFragment(), SharedPreferences.OnSharedPreferenceChangeListener {
override fun playerToolbar(): Toolbar {
@@ -146,7 +145,8 @@ class CardBlurFragment : AbsPlayerFragment(), SharedPreferences.OnSharedPreferen
override fun onResume() {
super.onResume()
- PreferenceManager.getDefaultSharedPreferences(requireContext()).registerOnSharedPreferenceChangeListener(this)
+ PreferenceManager.getDefaultSharedPreferences(requireContext())
+ .registerOnSharedPreferenceChangeListener(this)
}
override fun onDestroyView() {
diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/cardblur/CardBlurPlaybackControlsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/cardblur/CardBlurPlaybackControlsFragment.kt
index 7326d247..a6463964 100644
--- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/cardblur/CardBlurPlaybackControlsFragment.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/cardblur/CardBlurPlaybackControlsFragment.kt
@@ -22,15 +22,8 @@ import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.ViewUtil
-import kotlinx.android.synthetic.main.fragment_card_blur_player_playback_controls.progressSlider
-import kotlinx.android.synthetic.main.fragment_card_blur_player_playback_controls.songCurrentProgress
-import kotlinx.android.synthetic.main.fragment_card_blur_player_playback_controls.songInfo
-import kotlinx.android.synthetic.main.fragment_card_blur_player_playback_controls.songTotalTime
-import kotlinx.android.synthetic.main.media_button.nextButton
-import kotlinx.android.synthetic.main.media_button.playPauseButton
-import kotlinx.android.synthetic.main.media_button.previousButton
-import kotlinx.android.synthetic.main.media_button.repeatButton
-import kotlinx.android.synthetic.main.media_button.shuffleButton
+import kotlinx.android.synthetic.main.fragment_card_blur_player_playback_controls.*
+import kotlinx.android.synthetic.main.media_button.*
class CardBlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
@@ -48,7 +41,11 @@ class CardBlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
savedInstanceState: Bundle?
): View? {
- return inflater.inflate(R.layout.fragment_card_blur_player_playback_controls, container, false)
+ return inflater.inflate(
+ R.layout.fragment_card_blur_player_playback_controls,
+ container,
+ false
+ )
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
@@ -163,7 +160,10 @@ class CardBlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
lastPlaybackControlsColor,
PorterDuff.Mode.SRC_IN
)
- else -> shuffleButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
+ else -> shuffleButton.setColorFilter(
+ lastDisabledPlaybackControlsColor,
+ PorterDuff.Mode.SRC_IN
+ )
}
}
@@ -175,7 +175,10 @@ class CardBlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
when (MusicPlayerRemote.repeatMode) {
MusicService.REPEAT_MODE_NONE -> {
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
- repeatButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
+ repeatButton.setColorFilter(
+ lastDisabledPlaybackControlsColor,
+ PorterDuff.Mode.SRC_IN
+ )
}
MusicService.REPEAT_MODE_ALL -> {
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/circle/CirclePlayerFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/circle/CirclePlayerFragment.kt
index dea50e38..75053811 100644
--- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/circle/CirclePlayerFragment.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/circle/CirclePlayerFragment.kt
@@ -43,23 +43,14 @@ import code.name.monkey.retromusic.views.SeekArc
import code.name.monkey.retromusic.views.SeekArc.OnSeekArcChangeListener
import code.name.monkey.retromusic.volume.AudioVolumeObserver
import code.name.monkey.retromusic.volume.OnAudioVolumeChangedListener
-import kotlinx.android.synthetic.main.fragment_circle_player.nextButton
-import kotlinx.android.synthetic.main.fragment_circle_player.playPauseButton
-import kotlinx.android.synthetic.main.fragment_circle_player.playerToolbar
-import kotlinx.android.synthetic.main.fragment_circle_player.previousButton
-import kotlinx.android.synthetic.main.fragment_circle_player.progressSlider
-import kotlinx.android.synthetic.main.fragment_circle_player.songCurrentProgress
-import kotlinx.android.synthetic.main.fragment_circle_player.songInfo
-import kotlinx.android.synthetic.main.fragment_circle_player.songTotalTime
-import kotlinx.android.synthetic.main.fragment_circle_player.text
-import kotlinx.android.synthetic.main.fragment_circle_player.title
-import kotlinx.android.synthetic.main.fragment_circle_player.volumeSeekBar
+import kotlinx.android.synthetic.main.fragment_circle_player.*
/**
* Created by hemanths on 2020-01-06.
*/
-class CirclePlayerFragment : AbsPlayerFragment(), Callback, OnAudioVolumeChangedListener, OnSeekArcChangeListener {
+class CirclePlayerFragment : AbsPlayerFragment(), Callback, OnAudioVolumeChangedListener,
+ OnSeekArcChangeListener {
private lateinit var progressViewUpdateHelper: MusicProgressViewUpdateHelper
private var audioVolumeObserver: AudioVolumeObserver? = null
@@ -72,7 +63,11 @@ class CirclePlayerFragment : AbsPlayerFragment(), Callback, OnAudioVolumeChanged
progressViewUpdateHelper = MusicProgressViewUpdateHelper(this)
}
- override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
+ override fun onCreateView(
+ inflater: LayoutInflater,
+ container: ViewGroup?,
+ savedInstanceState: Bundle?
+ ): View? {
return inflater.inflate(R.layout.fragment_circle_player, container, false)
}
@@ -97,7 +92,11 @@ class CirclePlayerFragment : AbsPlayerFragment(), Callback, OnAudioVolumeChanged
private fun setupViews() {
setUpProgressSlider()
- ViewUtil.setProgressDrawable(progressSlider, ThemeStore.accentColor(requireContext()))
+ ViewUtil.setProgressDrawable(
+ progressSlider,
+ ThemeStore.accentColor(requireContext()),
+ false
+ )
volumeSeekBar.progressColor = ThemeStore.accentColor(requireContext())
setUpPlayPauseFab()
setUpPrevNext()
@@ -155,7 +154,8 @@ class CirclePlayerFragment : AbsPlayerFragment(), Callback, OnAudioVolumeChanged
override fun onBackPressed(): Boolean = false
- override fun toolbarIconColor(): Int = ATHUtil.resolveColor(requireContext(), android.R.attr.colorControlNormal)
+ override fun toolbarIconColor(): Int =
+ ATHUtil.resolveColor(requireContext(), android.R.attr.colorControlNormal)
override val paletteColor: Int
get() = Color.BLACK
diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/color/ColorFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/color/ColorFragment.kt
index 547e898d..ec36604d 100644
--- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/color/ColorFragment.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/color/ColorFragment.kt
@@ -22,9 +22,7 @@ import code.name.monkey.retromusic.util.NavigationUtil
import code.name.monkey.retromusic.util.RetroColorUtil
import com.bumptech.glide.Glide
import com.bumptech.glide.request.animation.GlideAnimation
-import kotlinx.android.synthetic.main.fragment_color_player.colorGradientBackground
-import kotlinx.android.synthetic.main.fragment_color_player.playerImage
-import kotlinx.android.synthetic.main.fragment_color_player.playerToolbar
+import kotlinx.android.synthetic.main.fragment_color_player.*
class ColorFragment : AbsPlayerFragment() {
@@ -80,7 +78,11 @@ class ColorFragment : AbsPlayerFragment() {
}
}
- override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
+ override fun onCreateView(
+ inflater: LayoutInflater,
+ container: ViewGroup?,
+ savedInstanceState: Bundle?
+ ): View? {
return inflater.inflate(R.layout.fragment_color_player, container, false)
}
@@ -94,7 +96,8 @@ class ColorFragment : AbsPlayerFragment() {
}
private fun setUpSubFragments() {
- playbackControlsFragment = childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as ColorPlaybackControlsFragment
+ playbackControlsFragment =
+ childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as ColorPlaybackControlsFragment
}
private fun setUpPlayerToolbar() {
@@ -102,7 +105,11 @@ class ColorFragment : AbsPlayerFragment() {
inflateMenu(R.menu.menu_player)
setNavigationOnClickListener { requireActivity().onBackPressed() }
setOnMenuItemClickListener(this@ColorFragment)
- ToolbarContentTintHelper.colorizeToolbar(this, ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal), requireActivity())
+ ToolbarContentTintHelper.colorizeToolbar(
+ this,
+ ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal),
+ requireActivity()
+ )
}
}
@@ -118,39 +125,43 @@ class ColorFragment : AbsPlayerFragment() {
private fun updateSong() {
Builder.from(Glide.with(requireActivity()), MusicPlayerRemote.currentSong)
- .checkIgnoreMediaStore(requireContext())
- .generatePalette(requireContext())
- .build()
- .into(object : RetroMusicColoredTarget(playerImage) {
- override fun onColorReady(color: Int) {
+ .checkIgnoreMediaStore(requireContext())
+ .generatePalette(requireContext())
+ .build()
+ .into(object : RetroMusicColoredTarget(playerImage) {
+ override fun onColorReady(color: Int) {
- }
+ }
- override fun onResourceReady(
- resource: BitmapPaletteWrapper?,
- glideAnimation: GlideAnimation?
- ) {
- super.onResourceReady(resource, glideAnimation)
- resource?.let {
- val palette = resource.palette
- val swatch = RetroColorUtil.getSwatch(palette)
+ override fun onResourceReady(
+ resource: BitmapPaletteWrapper?,
+ glideAnimation: GlideAnimation?
+ ) {
+ super.onResourceReady(resource, glideAnimation)
+ resource?.let {
+ val palette = resource.palette
+ val swatch = RetroColorUtil.getSwatch(palette)
- val textColor = RetroColorUtil.getTextColor(palette)
- val backgroundColor = swatch.rgb
+ val textColor = RetroColorUtil.getTextColor(palette)
+ val backgroundColor = swatch.rgb
- setColors(backgroundColor, textColor)
- }
-
- }
-
- override fun onLoadFailed(e: Exception?, errorDrawable: Drawable?) {
- super.onLoadFailed(e, errorDrawable)
- val backgroundColor = defaultFooterColor
- val textColor = if (ColorUtil.isColorLight(defaultFooterColor)) MaterialValueHelper.getPrimaryTextColor(requireContext(), true)
- else MaterialValueHelper.getPrimaryTextColor(requireContext(), false)
setColors(backgroundColor, textColor)
}
- })
+
+ }
+
+ override fun onLoadFailed(e: Exception?, errorDrawable: Drawable?) {
+ super.onLoadFailed(e, errorDrawable)
+ val backgroundColor = defaultFooterColor
+ val textColor =
+ if (ColorUtil.isColorLight(defaultFooterColor)) MaterialValueHelper.getPrimaryTextColor(
+ requireContext(),
+ true
+ )
+ else MaterialValueHelper.getPrimaryTextColor(requireContext(), false)
+ setColors(backgroundColor, textColor)
+ }
+ })
}
private fun setColors(backgroundColor: Int, componentsColor: Int) {
diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/fit/FitFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/fit/FitFragment.kt
index 64bf03b6..44461b37 100644
--- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/fit/FitFragment.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/fit/FitFragment.kt
@@ -12,7 +12,7 @@ import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.model.Song
-import kotlinx.android.synthetic.main.fragment_fit.playerToolbar
+import kotlinx.android.synthetic.main.fragment_fit.*
class FitFragment : AbsPlayerFragment() {
override fun playerToolbar(): Toolbar {
diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/flat/FlatPlayerFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/flat/FlatPlayerFragment.kt
index 8c3155fb..ed558b3a 100644
--- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/flat/FlatPlayerFragment.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/flat/FlatPlayerFragment.kt
@@ -20,8 +20,7 @@ import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.ViewUtil
import code.name.monkey.retromusic.views.DrawableGradient
-import kotlinx.android.synthetic.main.fragment_flat_player.colorGradientBackground
-import kotlinx.android.synthetic.main.fragment_flat_player.playerToolbar
+import kotlinx.android.synthetic.main.fragment_flat_player.*
class FlatPlayerFragment : AbsPlayerFragment() {
override fun playerToolbar(): Toolbar {
diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/full/FullPlayerFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/full/FullPlayerFragment.kt
index e8bab308..2af78fe8 100644
--- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/full/FullPlayerFragment.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/full/FullPlayerFragment.kt
@@ -25,10 +25,7 @@ import code.name.monkey.retromusic.model.lyrics.AbsSynchronizedLyrics
import code.name.monkey.retromusic.model.lyrics.Lyrics
import code.name.monkey.retromusic.util.NavigationUtil
import com.bumptech.glide.Glide
-import kotlinx.android.synthetic.main.fragment_full.artistImage
-import kotlinx.android.synthetic.main.fragment_full.nextSong
-import kotlinx.android.synthetic.main.fragment_full.nextSongLabel
-import kotlinx.android.synthetic.main.fragment_full.playerToolbar
+import kotlinx.android.synthetic.main.fragment_full.*
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
@@ -67,7 +64,10 @@ class FullPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Ca
lyricsLine2.visibility = View.VISIBLE
lyricsLine2.measure(
- View.MeasureSpec.makeMeasureSpec(lyricsLine2.measuredWidth, View.MeasureSpec.EXACTLY),
+ View.MeasureSpec.makeMeasureSpec(
+ lyricsLine2.measuredWidth,
+ View.MeasureSpec.EXACTLY
+ ),
View.MeasureSpec.UNSPECIFIED
)
val h: Float = lyricsLine2.measuredHeight.toFloat()
@@ -91,12 +91,13 @@ class FullPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Ca
}
private fun hideLyricsLayout() {
- lyricsLayout.animate().alpha(0f).setDuration(VISIBILITY_ANIM_DURATION).withEndAction(Runnable {
- if (!isLyricsLayoutBound()) return@Runnable
- lyricsLayout.visibility = View.GONE
- lyricsLine1.text = null
- lyricsLine2.text = null
- })
+ lyricsLayout.animate().alpha(0f).setDuration(VISIBILITY_ANIM_DURATION)
+ .withEndAction(Runnable {
+ if (!isLyricsLayoutBound()) return@Runnable
+ lyricsLayout.visibility = View.GONE
+ lyricsLine1.text = null
+ lyricsLine2.text = null
+ })
}
override fun setLyrics(l: Lyrics?) {
@@ -158,7 +159,11 @@ class FullPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Ca
val transitionName =
"${getString(R.string.transition_artist_image)}_${MusicPlayerRemote.currentSong.artistId}"
val activityOptions =
- ActivityOptions.makeSceneTransitionAnimation(requireActivity(), artistImage, transitionName)
+ ActivityOptions.makeSceneTransitionAnimation(
+ requireActivity(),
+ artistImage,
+ transitionName
+ )
NavigationUtil.goToArtistOptions(
requireActivity(),
MusicPlayerRemote.currentSong.artistId,
@@ -229,7 +234,8 @@ class FullPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Ca
private fun updateArtistImage() {
CoroutineScope(Dispatchers.IO).launch {
- val artist = ArtistLoader.getArtist(requireContext(), MusicPlayerRemote.currentSong.artistId)
+ val artist =
+ ArtistLoader.getArtist(requireContext(), MusicPlayerRemote.currentSong.artistId)
withContext(Dispatchers.Main) {
ArtistGlideRequest.Builder.from(Glide.with(requireContext()), artist)
.generatePalette(requireContext())
diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/lockscreen/LockScreenPlayerControlsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/lockscreen/LockScreenPlayerControlsFragment.kt
index 2eb8797b..b0c8672d 100644
--- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/lockscreen/LockScreenPlayerControlsFragment.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/lockscreen/LockScreenPlayerControlsFragment.kt
@@ -39,16 +39,7 @@ import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.ViewUtil
-import kotlinx.android.synthetic.main.fragment_lock_screen_playback_controls.nextButton
-import kotlinx.android.synthetic.main.fragment_lock_screen_playback_controls.playPauseButton
-import kotlinx.android.synthetic.main.fragment_lock_screen_playback_controls.previousButton
-import kotlinx.android.synthetic.main.fragment_lock_screen_playback_controls.progressSlider
-import kotlinx.android.synthetic.main.fragment_lock_screen_playback_controls.repeatButton
-import kotlinx.android.synthetic.main.fragment_lock_screen_playback_controls.shuffleButton
-import kotlinx.android.synthetic.main.fragment_lock_screen_playback_controls.songCurrentProgress
-import kotlinx.android.synthetic.main.fragment_lock_screen_playback_controls.songTotalTime
-import kotlinx.android.synthetic.main.fragment_lock_screen_playback_controls.text
-import kotlinx.android.synthetic.main.fragment_lock_screen_playback_controls.title
+import kotlinx.android.synthetic.main.fragment_lock_screen_playback_controls.*
/**
* @author Hemanth S (h4h13).
@@ -122,11 +113,13 @@ class LockScreenPlayerControlsFragment : AbsPlayerControlsFragment() {
val colorBg = ATHUtil.resolveColor(requireContext(), android.R.attr.colorBackground)
if (ColorUtil.isColorLight(colorBg)) {
- lastPlaybackControlsColor = MaterialValueHelper.getSecondaryTextColor(requireContext(), true)
+ lastPlaybackControlsColor =
+ MaterialValueHelper.getSecondaryTextColor(requireContext(), true)
lastDisabledPlaybackControlsColor =
MaterialValueHelper.getSecondaryDisabledTextColor(requireContext(), true)
} else {
- lastPlaybackControlsColor = MaterialValueHelper.getPrimaryTextColor(requireContext(), false)
+ lastPlaybackControlsColor =
+ MaterialValueHelper.getPrimaryTextColor(requireContext(), false)
lastDisabledPlaybackControlsColor =
MaterialValueHelper.getPrimaryDisabledTextColor(requireContext(), false)
}
@@ -194,7 +187,10 @@ class LockScreenPlayerControlsFragment : AbsPlayerControlsFragment() {
lastPlaybackControlsColor,
PorterDuff.Mode.SRC_IN
)
- else -> shuffleButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
+ else -> shuffleButton.setColorFilter(
+ lastDisabledPlaybackControlsColor,
+ PorterDuff.Mode.SRC_IN
+ )
}
}
@@ -206,7 +202,10 @@ class LockScreenPlayerControlsFragment : AbsPlayerControlsFragment() {
when (MusicPlayerRemote.repeatMode) {
MusicService.REPEAT_MODE_NONE -> {
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
- repeatButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
+ repeatButton.setColorFilter(
+ lastDisabledPlaybackControlsColor,
+ PorterDuff.Mode.SRC_IN
+ )
}
MusicService.REPEAT_MODE_ALL -> {
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/material/MaterialFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/material/MaterialFragment.kt
index eb4f5834..3b40917f 100644
--- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/material/MaterialFragment.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/material/MaterialFragment.kt
@@ -13,7 +13,7 @@ import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
import code.name.monkey.retromusic.fragments.player.normal.PlayerFragment
import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.model.Song
-import kotlinx.android.synthetic.main.fragment_material.playerToolbar
+import kotlinx.android.synthetic.main.fragment_material.*
/**
* @author Hemanth S (h4h13).
diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/normal/PlayerFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/normal/PlayerFragment.kt
index f31e4883..db186aa5 100644
--- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/normal/PlayerFragment.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/normal/PlayerFragment.kt
@@ -36,12 +36,20 @@ class PlayerFragment : AbsPlayerFragment() {
valueAnimator?.cancel()
}
- valueAnimator = ValueAnimator.ofObject(ArgbEvaluator(), ATHUtil.resolveColor(requireContext(), R.attr.colorSurface), i)
+ valueAnimator = ValueAnimator.ofObject(
+ ArgbEvaluator(),
+ ATHUtil.resolveColor(requireContext(), R.attr.colorSurface),
+ i
+ )
valueAnimator?.addUpdateListener { animation ->
if (isAdded) {
- val drawable = DrawableGradient(GradientDrawable.Orientation.TOP_BOTTOM,
- intArrayOf(animation.animatedValue as Int,
- ATHUtil.resolveColor(requireContext(), R.attr.colorSurface)), 0)
+ val drawable = DrawableGradient(
+ GradientDrawable.Orientation.TOP_BOTTOM,
+ intArrayOf(
+ animation.animatedValue as Int,
+ ATHUtil.resolveColor(requireContext(), R.attr.colorSurface)
+ ), 0
+ )
colorGradientBackground?.background = drawable
}
}
@@ -70,7 +78,11 @@ class PlayerFragment : AbsPlayerFragment() {
lastColor = color
callbacks?.onPaletteColorChanged()
- ToolbarContentTintHelper.colorizeToolbar(playerToolbar, ATHUtil.resolveColor(context, R.attr.colorControlNormal), requireActivity())
+ ToolbarContentTintHelper.colorizeToolbar(
+ playerToolbar,
+ ATHUtil.resolveColor(context, R.attr.colorControlNormal),
+ requireActivity()
+ )
if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
colorize(color)
@@ -89,8 +101,10 @@ class PlayerFragment : AbsPlayerFragment() {
}
- override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
- savedInstanceState: Bundle?): View? {
+ override fun onCreateView(
+ inflater: LayoutInflater, container: ViewGroup?,
+ savedInstanceState: Bundle?
+ ): View? {
return inflater.inflate(R.layout.fragment_player, container, false)
}
@@ -103,17 +117,23 @@ class PlayerFragment : AbsPlayerFragment() {
private fun setUpSubFragments() {
- playbackControlsFragment = childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as PlayerPlaybackControlsFragment
- val playerAlbumCoverFragment = childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment
+ playbackControlsFragment =
+ childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as PlayerPlaybackControlsFragment
+ val playerAlbumCoverFragment =
+ childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment
playerAlbumCoverFragment.setCallbacks(this)
}
private fun setUpPlayerToolbar() {
playerToolbar.inflateMenu(R.menu.menu_player)
- playerToolbar.setNavigationOnClickListener {requireActivity().onBackPressed() }
+ playerToolbar.setNavigationOnClickListener { requireActivity().onBackPressed() }
playerToolbar.setOnMenuItemClickListener(this)
- ToolbarContentTintHelper.colorizeToolbar(playerToolbar, ATHUtil.resolveColor(context, R.attr.colorControlNormal), requireActivity())
+ ToolbarContentTintHelper.colorizeToolbar(
+ playerToolbar,
+ ATHUtil.resolveColor(context, R.attr.colorControlNormal),
+ requireActivity()
+ )
}
override fun onServiceConnected() {
diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/peak/PeakPlayerFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/peak/PeakPlayerFragment.kt
index 6b454ebb..4e9a9391 100644
--- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/peak/PeakPlayerFragment.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/peak/PeakPlayerFragment.kt
@@ -31,11 +31,7 @@ import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.util.NavigationUtil
import code.name.monkey.retromusic.util.PreferenceUtil
import com.bumptech.glide.Glide
-import kotlinx.android.synthetic.main.fragment_peak_player.playerImage
-import kotlinx.android.synthetic.main.fragment_peak_player.playerToolbar
-import kotlinx.android.synthetic.main.fragment_peak_player.songInfo
-import kotlinx.android.synthetic.main.fragment_peak_player.text
-import kotlinx.android.synthetic.main.fragment_peak_player.title
+import kotlinx.android.synthetic.main.fragment_peak_player.*
/**
* Created by hemanths on 2019-10-03.
@@ -46,7 +42,11 @@ class PeakPlayerFragment : AbsPlayerFragment() {
private lateinit var playbackControlsFragment: PeakPlayerControlFragment
private var lastColor: Int = 0
- override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
+ override fun onCreateView(
+ inflater: LayoutInflater,
+ container: ViewGroup?,
+ savedInstanceState: Bundle?
+ ): View? {
return inflater.inflate(R.layout.fragment_peak_player, container, false)
}
diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/plain/PlainPlayerFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/plain/PlainPlayerFragment.kt
index 30241f14..d609f7d6 100644
--- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/plain/PlainPlayerFragment.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/plain/PlainPlayerFragment.kt
@@ -12,9 +12,7 @@ import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.model.Song
-import kotlinx.android.synthetic.main.fragment_plain_player.playerToolbar
-import kotlinx.android.synthetic.main.fragment_plain_player.text
-import kotlinx.android.synthetic.main.fragment_plain_player.title
+import kotlinx.android.synthetic.main.fragment_plain_player.*
class PlainPlayerFragment : AbsPlayerFragment() {
override fun playerToolbar(): Toolbar {
diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/simple/SimplePlaybackControlsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/simple/SimplePlaybackControlsFragment.kt
index 1d2da9ba..39539e31 100644
--- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/simple/SimplePlaybackControlsFragment.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/simple/SimplePlaybackControlsFragment.kt
@@ -21,15 +21,7 @@ import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.PreferenceUtil
-import kotlinx.android.synthetic.main.fragment_simple_controls_fragment.nextButton
-import kotlinx.android.synthetic.main.fragment_simple_controls_fragment.playPauseButton
-import kotlinx.android.synthetic.main.fragment_simple_controls_fragment.previousButton
-import kotlinx.android.synthetic.main.fragment_simple_controls_fragment.repeatButton
-import kotlinx.android.synthetic.main.fragment_simple_controls_fragment.shuffleButton
-import kotlinx.android.synthetic.main.fragment_simple_controls_fragment.songCurrentProgress
-import kotlinx.android.synthetic.main.fragment_simple_controls_fragment.songInfo
-import kotlinx.android.synthetic.main.fragment_simple_controls_fragment.text
-import kotlinx.android.synthetic.main.fragment_simple_controls_fragment.title
+import kotlinx.android.synthetic.main.fragment_simple_controls_fragment.*
/**
* @author Hemanth S (h4h13).
@@ -65,7 +57,11 @@ class SimplePlaybackControlsFragment : AbsPlayerControlsFragment() {
progressViewUpdateHelper = MusicProgressViewUpdateHelper(this)
}
- override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
+ override fun onCreateView(
+ inflater: LayoutInflater,
+ container: ViewGroup?,
+ savedInstanceState: Bundle?
+ ): View? {
return inflater.inflate(R.layout.fragment_simple_controls_fragment, container, false)
}
@@ -122,7 +118,10 @@ class SimplePlaybackControlsFragment : AbsPlayerControlsFragment() {
lastPlaybackControlsColor,
PorterDuff.Mode.SRC_IN
)
- else -> shuffleButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
+ else -> shuffleButton.setColorFilter(
+ lastDisabledPlaybackControlsColor,
+ PorterDuff.Mode.SRC_IN
+ )
}
}
@@ -134,7 +133,10 @@ class SimplePlaybackControlsFragment : AbsPlayerControlsFragment() {
when (MusicPlayerRemote.repeatMode) {
MusicService.REPEAT_MODE_NONE -> {
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
- repeatButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
+ repeatButton.setColorFilter(
+ lastDisabledPlaybackControlsColor,
+ PorterDuff.Mode.SRC_IN
+ )
}
MusicService.REPEAT_MODE_ALL -> {
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
@@ -199,10 +201,12 @@ class SimplePlaybackControlsFragment : AbsPlayerControlsFragment() {
val colorBg = ATHUtil.resolveColor(context!!, android.R.attr.colorBackground)
if (ColorUtil.isColorLight(colorBg)) {
lastPlaybackControlsColor = MaterialValueHelper.getSecondaryTextColor(context!!, true)
- lastDisabledPlaybackControlsColor = MaterialValueHelper.getSecondaryDisabledTextColor(context!!, true)
+ lastDisabledPlaybackControlsColor =
+ MaterialValueHelper.getSecondaryDisabledTextColor(context!!, true)
} else {
lastPlaybackControlsColor = MaterialValueHelper.getPrimaryTextColor(context!!, false)
- lastDisabledPlaybackControlsColor = MaterialValueHelper.getPrimaryDisabledTextColor(context!!, false)
+ lastDisabledPlaybackControlsColor =
+ MaterialValueHelper.getPrimaryDisabledTextColor(context!!, false)
}
val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/simple/SimplePlayerFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/simple/SimplePlayerFragment.kt
index 4b08839f..525b5f81 100644
--- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/simple/SimplePlayerFragment.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/simple/SimplePlayerFragment.kt
@@ -12,7 +12,7 @@ import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.model.Song
-import kotlinx.android.synthetic.main.fragment_simple_player.playerToolbar
+import kotlinx.android.synthetic.main.fragment_simple_player.*
/**
* @author Hemanth S (h4h13).
diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/tiny/TinyPlaybackControlsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/tiny/TinyPlaybackControlsFragment.kt
index 686f556e..070f0429 100644
--- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/tiny/TinyPlaybackControlsFragment.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/tiny/TinyPlaybackControlsFragment.kt
@@ -11,8 +11,7 @@ import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.service.MusicService
-import kotlinx.android.synthetic.main.fragment_tiny_controls_fragment.playerRepeatButton
-import kotlinx.android.synthetic.main.fragment_tiny_controls_fragment.playerShuffleButton
+import kotlinx.android.synthetic.main.fragment_tiny_controls_fragment.*
class TinyPlaybackControlsFragment : AbsPlayerControlsFragment() {
@@ -28,11 +27,13 @@ class TinyPlaybackControlsFragment : AbsPlayerControlsFragment() {
override fun setDark(color: Int) {
if (ColorUtil.isColorLight(color)) {
- lastPlaybackControlsColor = MaterialValueHelper.getSecondaryTextColor(requireContext(), true)
+ lastPlaybackControlsColor =
+ MaterialValueHelper.getSecondaryTextColor(requireContext(), true)
lastDisabledPlaybackControlsColor =
MaterialValueHelper.getSecondaryDisabledTextColor(requireContext(), true)
} else {
- lastPlaybackControlsColor = MaterialValueHelper.getPrimaryTextColor(requireContext(), false)
+ lastPlaybackControlsColor =
+ MaterialValueHelper.getPrimaryTextColor(requireContext(), false)
lastDisabledPlaybackControlsColor =
MaterialValueHelper.getPrimaryDisabledTextColor(requireContext(), false)
}
@@ -47,7 +48,11 @@ class TinyPlaybackControlsFragment : AbsPlayerControlsFragment() {
private var lastPlaybackControlsColor: Int = 0
private var lastDisabledPlaybackControlsColor: Int = 0
- override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
+ override fun onCreateView(
+ inflater: LayoutInflater,
+ container: ViewGroup?,
+ savedInstanceState: Bundle?
+ ): View? {
return inflater.inflate(R.layout.fragment_tiny_controls_fragment, container, false)
}
@@ -76,7 +81,10 @@ class TinyPlaybackControlsFragment : AbsPlayerControlsFragment() {
lastPlaybackControlsColor,
PorterDuff.Mode.SRC_IN
)
- else -> playerShuffleButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
+ else -> playerShuffleButton.setColorFilter(
+ lastDisabledPlaybackControlsColor,
+ PorterDuff.Mode.SRC_IN
+ )
}
}
@@ -84,7 +92,10 @@ class TinyPlaybackControlsFragment : AbsPlayerControlsFragment() {
when (MusicPlayerRemote.repeatMode) {
MusicService.REPEAT_MODE_NONE -> {
playerRepeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
- playerRepeatButton.setColorFilter(lastDisabledPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
+ playerRepeatButton.setColorFilter(
+ lastDisabledPlaybackControlsColor,
+ PorterDuff.Mode.SRC_IN
+ )
}
MusicService.REPEAT_MODE_ALL -> {
playerRepeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
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 97b96baa..225f936f 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
@@ -26,16 +26,7 @@ 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.AlbumCoverStylePreference
-import code.name.monkey.retromusic.preferences.AlbumCoverStylePreferenceDialog
-import code.name.monkey.retromusic.preferences.BlacklistPreference
-import code.name.monkey.retromusic.preferences.BlacklistPreferenceDialog
-import code.name.monkey.retromusic.preferences.LibraryPreference
-import code.name.monkey.retromusic.preferences.LibraryPreferenceDialog
-import code.name.monkey.retromusic.preferences.MaterialListPreference
-import code.name.monkey.retromusic.preferences.MaterialListPreferenceDialog
-import code.name.monkey.retromusic.preferences.NowPlayingScreenPreference
-import code.name.monkey.retromusic.preferences.NowPlayingScreenPreferenceDialog
+import code.name.monkey.retromusic.preferences.*
import code.name.monkey.retromusic.util.NavigationUtil
/**
@@ -45,7 +36,8 @@ import code.name.monkey.retromusic.util.NavigationUtil
abstract class AbsSettingsFragment : ATEPreferenceFragmentCompat() {
internal fun showProToastAndNavigate(message: String) {
- Toast.makeText(requireContext(), "$message is Pro version feature.", Toast.LENGTH_SHORT).show()
+ Toast.makeText(requireContext(), "$message is Pro version feature.", Toast.LENGTH_SHORT)
+ .show()
NavigationUtil.goToProVersion(requireActivity())
}
diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/settings/MainSettingsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/settings/MainSettingsFragment.kt
index b2c10eb8..2a690c08 100644
--- a/app/src/main/java/code/name/monkey/retromusic/fragments/settings/MainSettingsFragment.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/fragments/settings/MainSettingsFragment.kt
@@ -28,27 +28,32 @@ import code.name.monkey.retromusic.activities.SettingsActivity
import code.name.monkey.retromusic.extensions.hide
import code.name.monkey.retromusic.extensions.show
import code.name.monkey.retromusic.util.NavigationUtil
-import kotlinx.android.synthetic.main.fragment_main_settings.aboutSettings
-import kotlinx.android.synthetic.main.fragment_main_settings.audioSettings
-import kotlinx.android.synthetic.main.fragment_main_settings.buyPremium
-import kotlinx.android.synthetic.main.fragment_main_settings.buyProContainer
-import kotlinx.android.synthetic.main.fragment_main_settings.diamondIcon
-import kotlinx.android.synthetic.main.fragment_main_settings.generalSettings
-import kotlinx.android.synthetic.main.fragment_main_settings.imageSettings
-import kotlinx.android.synthetic.main.fragment_main_settings.notificationSettings
-import kotlinx.android.synthetic.main.fragment_main_settings.nowPlayingSettings
-import kotlinx.android.synthetic.main.fragment_main_settings.otherSettings
-import kotlinx.android.synthetic.main.fragment_main_settings.personalizeSettings
+import kotlinx.android.synthetic.main.fragment_main_settings.*
class MainSettingsFragment : Fragment(), View.OnClickListener {
override fun onClick(view: View) {
when (view.id) {
- R.id.generalSettings -> inflateFragment(ThemeSettingsFragment(), R.string.general_settings_title)
+ R.id.generalSettings -> inflateFragment(
+ ThemeSettingsFragment(),
+ R.string.general_settings_title
+ )
R.id.audioSettings -> inflateFragment(AudioSettings(), R.string.pref_header_audio)
- R.id.nowPlayingSettings -> inflateFragment(NowPlayingSettingsFragment(), R.string.now_playing)
- R.id.personalizeSettings -> inflateFragment(PersonalizeSettingsFragment(), R.string.personalize)
- R.id.imageSettings -> inflateFragment(ImageSettingFragment(), R.string.pref_header_images)
- R.id.notificationSettings -> inflateFragment(NotificationSettingsFragment(), R.string.notification)
+ R.id.nowPlayingSettings -> inflateFragment(
+ NowPlayingSettingsFragment(),
+ R.string.now_playing
+ )
+ R.id.personalizeSettings -> inflateFragment(
+ PersonalizeSettingsFragment(),
+ R.string.personalize
+ )
+ R.id.imageSettings -> inflateFragment(
+ ImageSettingFragment(),
+ R.string.pref_header_images
+ )
+ R.id.notificationSettings -> inflateFragment(
+ NotificationSettingsFragment(),
+ R.string.notification
+ )
R.id.otherSettings -> inflateFragment(OtherSettingsFragment(), R.string.others)
R.id.aboutSettings -> NavigationUtil.goToAbout(requireActivity())
}
@@ -88,6 +93,10 @@ class MainSettingsFragment : Fragment(), View.OnClickListener {
}
}
+ companion object {
+
+ }
+
private fun inflateFragment(fragment: Fragment, @StringRes title: Int) {
(requireActivity() as SettingsActivity).setupFragment(fragment, title)
}
diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/settings/NotificationSettingsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/settings/NotificationSettingsFragment.kt
index dfd74f15..63458bbc 100644
--- a/app/src/main/java/code/name/monkey/retromusic/fragments/settings/NotificationSettingsFragment.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/fragments/settings/NotificationSettingsFragment.kt
@@ -28,11 +28,13 @@ import code.name.monkey.retromusic.util.PreferenceUtil
* @author Hemanth S (h4h13).
*/
-class NotificationSettingsFragment : AbsSettingsFragment(), SharedPreferences.OnSharedPreferenceChangeListener {
+class NotificationSettingsFragment : AbsSettingsFragment(),
+ SharedPreferences.OnSharedPreferenceChangeListener {
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
if (key == PreferenceUtil.CLASSIC_NOTIFICATION) {
if (VERSION.SDK_INT >= VERSION_CODES.O) {
- findPreference("colored_notification")?.isEnabled = sharedPreferences?.getBoolean(key, false)!!
+ findPreference("colored_notification")?.isEnabled =
+ sharedPreferences?.getBoolean(key, false)!!
}
}
}
@@ -47,7 +49,8 @@ class NotificationSettingsFragment : AbsSettingsFragment(), SharedPreferences.On
isChecked = PreferenceUtil.getInstance(requireContext()).classicNotification()
setOnPreferenceChangeListener { _, newValue ->
// Save preference
- PreferenceUtil.getInstance(requireContext()).setClassicNotification(newValue as Boolean)
+ PreferenceUtil.getInstance(requireContext())
+ .setClassicNotification(newValue as Boolean)
invalidateSettings()
true
}
@@ -56,12 +59,14 @@ class NotificationSettingsFragment : AbsSettingsFragment(), SharedPreferences.On
val coloredNotification: TwoStatePreference? = findPreference("colored_notification")
if (VERSION.SDK_INT >= VERSION_CODES.O) {
- coloredNotification?.isEnabled = PreferenceUtil.getInstance(requireContext()).classicNotification()
+ coloredNotification?.isEnabled =
+ PreferenceUtil.getInstance(requireContext()).classicNotification()
} else {
coloredNotification?.apply {
isChecked = PreferenceUtil.getInstance(requireContext()).coloredNotification()
setOnPreferenceChangeListener { _, newValue ->
- PreferenceUtil.getInstance(requireContext()).setColoredNotification(newValue as Boolean)
+ PreferenceUtil.getInstance(requireContext())
+ .setColoredNotification(newValue as Boolean)
true
}
}
@@ -75,7 +80,8 @@ class NotificationSettingsFragment : AbsSettingsFragment(), SharedPreferences.On
override fun onDestroyView() {
super.onDestroyView()
- PreferenceUtil.getInstance(requireContext()).unregisterOnSharedPreferenceChangedListener(this)
+ PreferenceUtil.getInstance(requireContext())
+ .unregisterOnSharedPreferenceChangedListener(this)
}
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/settings/NowPlayingSettingsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/settings/NowPlayingSettingsFragment.kt
index b596729b..ffccd739 100644
--- a/app/src/main/java/code/name/monkey/retromusic/fragments/settings/NowPlayingSettingsFragment.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/fragments/settings/NowPlayingSettingsFragment.kt
@@ -27,7 +27,8 @@ import code.name.monkey.retromusic.util.PreferenceUtil.*
* @author Hemanth S (h4h13).
*/
-class NowPlayingSettingsFragment : AbsSettingsFragment(), SharedPreferences.OnSharedPreferenceChangeListener {
+class NowPlayingSettingsFragment : AbsSettingsFragment(),
+ SharedPreferences.OnSharedPreferenceChangeListener {
override fun invalidateSettings() {
updateNowPlayingScreenSummary()
diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/settings/PersonalizeSettingsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/settings/PersonalizeSettingsFragment.kt
index fd49bdb2..6877c714 100644
--- a/app/src/main/java/code/name/monkey/retromusic/fragments/settings/PersonalizeSettingsFragment.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/fragments/settings/PersonalizeSettingsFragment.kt
@@ -22,7 +22,8 @@ import androidx.preference.TwoStatePreference
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.util.PreferenceUtil
-class PersonalizeSettingsFragment : AbsSettingsFragment(), SharedPreferences.OnSharedPreferenceChangeListener {
+class PersonalizeSettingsFragment : AbsSettingsFragment(),
+ SharedPreferences.OnSharedPreferenceChangeListener {
override fun invalidateSettings() {
@@ -49,7 +50,8 @@ class PersonalizeSettingsFragment : AbsSettingsFragment(), SharedPreferences.OnS
override fun onDestroyView() {
super.onDestroyView()
- PreferenceUtil.getInstance(requireContext()).unregisterOnSharedPreferenceChangedListener(this)
+ PreferenceUtil.getInstance(requireContext())
+ .unregisterOnSharedPreferenceChangedListener(this)
}
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) {
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 c5ce30e6..55855880 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
@@ -67,7 +67,11 @@ class ThemeSettingsFragment : AbsSettingsFragment() {
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
title(R.string.accent_color)
positiveButton(R.string.set)
- colorChooser(colors = ACCENT_COLORS, allowCustomArgb = true, subColors = ACCENT_COLORS_SUB) { _, color ->
+ colorChooser(
+ colors = ACCENT_COLORS,
+ allowCustomArgb = true,
+ subColors = ACCENT_COLORS_SUB
+ ) { _, color ->
ThemeStore.editTheme(requireContext()).accentColor(color).commit()
if (VersionUtils.hasNougatMR())
DynamicShortcutManager(requireContext()).updateDynamicShortcuts()
@@ -91,10 +95,12 @@ class ThemeSettingsFragment : AbsSettingsFragment() {
true
}
- val desaturatedColor: ATESwitchPreference? = findPreference(PreferenceUtil.DESATURATED_COLOR)
+ val desaturatedColor: ATESwitchPreference? =
+ findPreference(PreferenceUtil.DESATURATED_COLOR)
desaturatedColor?.setOnPreferenceChangeListener { _, value ->
val desaturated = value as Boolean
- ThemeStore.prefs(requireContext()).edit().putBoolean("desaturated_color", desaturated).apply()
+ ThemeStore.prefs(requireContext()).edit().putBoolean("desaturated_color", desaturated)
+ .apply()
PreferenceUtil.getInstance(requireContext()).setDesaturatedColor(desaturated)
requireActivity().recreate()
true
@@ -105,10 +111,12 @@ class ThemeSettingsFragment : AbsSettingsFragment() {
if (!VersionUtils.hasNougatMR()) {
colorAppShortcuts.isVisible = false
} else {
- colorAppShortcuts.isChecked = PreferenceUtil.getInstance(requireContext()).coloredAppShortcuts()
+ colorAppShortcuts.isChecked =
+ PreferenceUtil.getInstance(requireContext()).coloredAppShortcuts()
colorAppShortcuts.setOnPreferenceChangeListener { _, newValue ->
// Save preference
- PreferenceUtil.getInstance(requireContext()).setColoredAppShortcuts(newValue as Boolean)
+ PreferenceUtil.getInstance(requireContext())
+ .setColoredAppShortcuts(newValue as Boolean)
DynamicShortcutManager(requireContext()).updateDynamicShortcuts()
true
}
diff --git a/app/src/main/java/code/name/monkey/retromusic/glide/AlbumGlideRequest.java b/app/src/main/java/code/name/monkey/retromusic/glide/AlbumGlideRequest.java
index 41b2744a..aed589d3 100644
--- a/app/src/main/java/code/name/monkey/retromusic/glide/AlbumGlideRequest.java
+++ b/app/src/main/java/code/name/monkey/retromusic/glide/AlbumGlideRequest.java
@@ -4,7 +4,6 @@ import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
-import android.graphics.drawable.Drawable;
import androidx.annotation.NonNull;
@@ -17,8 +16,6 @@ import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.load.resource.drawable.GlideDrawable;
import com.bumptech.glide.signature.MediaStoreSignature;
-import code.name.monkey.appthemehelper.ThemeStore;
-import code.name.monkey.appthemehelper.util.TintHelper;
import code.name.monkey.retromusic.R;
import code.name.monkey.retromusic.glide.audiocover.AudioFileCover;
import code.name.monkey.retromusic.glide.palette.BitmapPaletteTranscoder;
@@ -32,21 +29,37 @@ public class AlbumGlideRequest {
private static final int DEFAULT_ERROR_IMAGE = R.drawable.default_album_art;
private static final int DEFAULT_ANIMATION = android.R.anim.fade_in;
+ @NonNull
+ private static DrawableTypeRequest createBaseRequest(@NonNull RequestManager requestManager,
+ @NonNull Song song,
+ boolean ignoreMediaStore) {
+ if (ignoreMediaStore) {
+ return requestManager.load(new AudioFileCover(song.getData()));
+ } else {
+ return requestManager.loadFromMediaStore(MusicUtil.getMediaStoreAlbumCoverUri(song.getAlbumId()));
+ }
+ }
+
+ @NonNull
+ private static Key createSignature(@NonNull Song song) {
+ return new MediaStoreSignature("", song.getDateModified(), 0);
+ }
+
public static class Builder {
final RequestManager requestManager;
final Song song;
boolean ignoreMediaStore;
- @NonNull
- public static Builder from(@NonNull RequestManager requestManager, Song song) {
- return new Builder(requestManager, song);
- }
-
private Builder(@NonNull RequestManager requestManager, Song song) {
this.requestManager = requestManager;
this.song = song;
}
+ @NonNull
+ public static Builder from(@NonNull RequestManager requestManager, Song song) {
+ return new Builder(requestManager, song);
+ }
+
@NonNull
public PaletteBuilder generatePalette(@NonNull Context context) {
return new PaletteBuilder(this, context);
@@ -98,6 +111,7 @@ public class AlbumGlideRequest {
}
public static class PaletteBuilder {
+ private static final String TAG = "PaletteBuilder";
final Context context;
private final Builder builder;
@@ -107,32 +121,15 @@ public class AlbumGlideRequest {
}
public BitmapRequestBuilder, BitmapPaletteWrapper> build() {
- Drawable drawable = TintHelper.createTintedDrawable(context, DEFAULT_ERROR_IMAGE, ThemeStore.Companion.accentColor(context));
+
//noinspection unchecked
return createBaseRequest(builder.requestManager, builder.song, builder.ignoreMediaStore)
.asBitmap()
.transcode(new BitmapPaletteTranscoder(context), BitmapPaletteWrapper.class)
.diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY)
- .placeholder(drawable)
- .error(drawable)
+ .error(DEFAULT_ERROR_IMAGE)
.animate(DEFAULT_ANIMATION)
.signature(createSignature(builder.song));
}
}
-
- @NonNull
- private static DrawableTypeRequest createBaseRequest(@NonNull RequestManager requestManager,
- @NonNull Song song,
- boolean ignoreMediaStore) {
- if (ignoreMediaStore) {
- return requestManager.load(new AudioFileCover(song.getData()));
- } else {
- return requestManager.loadFromMediaStore(MusicUtil.getMediaStoreAlbumCoverUri(song.getAlbumId()));
- }
- }
-
- @NonNull
- private static Key createSignature(@NonNull Song song) {
- return new MediaStoreSignature("", song.getDateModified(), 0);
- }
-}
+}
\ No newline at end of file
diff --git a/app/src/main/java/code/name/monkey/retromusic/glide/ArtistGlideRequest.java b/app/src/main/java/code/name/monkey/retromusic/glide/ArtistGlideRequest.java
index 1e566f8a..175c3442 100644
--- a/app/src/main/java/code/name/monkey/retromusic/glide/ArtistGlideRequest.java
+++ b/app/src/main/java/code/name/monkey/retromusic/glide/ArtistGlideRequest.java
@@ -16,7 +16,6 @@ package code.name.monkey.retromusic.glide;
import android.content.Context;
import android.graphics.Bitmap;
-import android.graphics.drawable.Drawable;
import androidx.annotation.NonNull;
@@ -30,8 +29,6 @@ import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.load.resource.drawable.GlideDrawable;
import com.bumptech.glide.request.target.Target;
-import code.name.monkey.appthemehelper.ThemeStore;
-import code.name.monkey.appthemehelper.util.TintHelper;
import code.name.monkey.retromusic.App;
import code.name.monkey.retromusic.R;
import code.name.monkey.retromusic.glide.artistimage.ArtistImage;
@@ -49,25 +46,40 @@ public class ArtistGlideRequest {
private static final int DEFAULT_ERROR_IMAGE = R.drawable.default_artist_art;
+ @NonNull
+ public static Key createSignature(@NonNull Artist artist) {
+ return ArtistSignatureUtil.getInstance(App.Companion.getContext()).getArtistSignature(artist.getName());
+ }
+
+ @NonNull
+ private static DrawableTypeRequest createBaseRequest(@NonNull RequestManager requestManager,
+ @NonNull Artist artist,
+ boolean noCustomImage, boolean forceDownload) {
+ boolean hasCustomImage = CustomArtistImageUtil.Companion.getInstance(App.Companion.getContext())
+ .hasCustomArtistImage(artist);
+ if (noCustomImage || !hasCustomImage) {
+ return requestManager.load(new ArtistImage(artist.getName()));
+ } else {
+ return requestManager.load(CustomArtistImageUtil.getFile(artist));
+ }
+ }
+
public static class Builder {
final Artist artist;
-
- boolean forceDownload;
-
- boolean noCustomImage;
-
final RequestManager requestManager;
-
- public static Builder from(@NonNull RequestManager requestManager, Artist artist) {
- return new Builder(requestManager, artist);
- }
+ boolean forceDownload;
+ boolean noCustomImage;
private Builder(@NonNull RequestManager requestManager, Artist artist) {
this.requestManager = requestManager;
this.artist = artist;
}
+ public static Builder from(@NonNull RequestManager requestManager, Artist artist) {
+ return new Builder(requestManager, artist);
+ }
+
public BitmapBuilder asBitmap() {
return new BitmapBuilder(this);
}
@@ -132,38 +144,18 @@ public class ArtistGlideRequest {
}
public BitmapRequestBuilder, BitmapPaletteWrapper> build() {
- Drawable drawable = TintHelper.createTintedDrawable(context, DEFAULT_ERROR_IMAGE, ThemeStore.Companion.accentColor(context));
//noinspection unchecked
return createBaseRequest(builder.requestManager, builder.artist, builder.noCustomImage,
builder.forceDownload)
.asBitmap()
.transcode(new BitmapPaletteTranscoder(context), BitmapPaletteWrapper.class)
.diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY)
- .placeholder(drawable)
- .error(drawable)
+ .placeholder(DEFAULT_ERROR_IMAGE)
+ .error(DEFAULT_ERROR_IMAGE)
.animate(DEFAULT_ANIMATION)
.priority(Priority.LOW)
.override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL)
.signature(createSignature(builder.artist));
}
}
-
-
- @NonNull
- public static Key createSignature(@NonNull Artist artist) {
- return ArtistSignatureUtil.getInstance(App.Companion.getContext()).getArtistSignature(artist.getName());
- }
-
- @NonNull
- private static DrawableTypeRequest createBaseRequest(@NonNull RequestManager requestManager,
- @NonNull Artist artist,
- boolean noCustomImage, boolean forceDownload) {
- boolean hasCustomImage = CustomArtistImageUtil.Companion.getInstance(App.Companion.getContext())
- .hasCustomArtistImage(artist);
- if (noCustomImage || !hasCustomImage) {
- return requestManager.load(new ArtistImage(artist.getName()));
- } else {
- return requestManager.load(CustomArtistImageUtil.getFile(artist));
- }
- }
}
\ No newline at end of file
diff --git a/app/src/main/java/code/name/monkey/retromusic/glide/BlurTransformation.kt b/app/src/main/java/code/name/monkey/retromusic/glide/BlurTransformation.kt
index 969fc743..0c2af3db 100644
--- a/app/src/main/java/code/name/monkey/retromusic/glide/BlurTransformation.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/glide/BlurTransformation.kt
@@ -87,7 +87,12 @@ class BlurTransformation : BitmapTransformation {
}
}
- override fun transform(pool: BitmapPool, toTransform: Bitmap, outWidth: Int, outHeight: Int): Bitmap? {
+ override fun transform(
+ pool: BitmapPool,
+ toTransform: Bitmap,
+ outWidth: Int,
+ outHeight: Int
+ ): Bitmap? {
val sampling: Int
if (this.sampling == 0) {
sampling = ImageUtil.calculateInSampleSize(toTransform.width, toTransform.height, 100)
@@ -114,7 +119,12 @@ class BlurTransformation : BitmapTransformation {
if (Build.VERSION.SDK_INT >= 17) {
try {
val rs = RenderScript.create(context!!.applicationContext)
- val input = Allocation.createFromBitmap(rs, out, Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT)
+ val input = Allocation.createFromBitmap(
+ rs,
+ out,
+ Allocation.MipmapControl.MIPMAP_NONE,
+ Allocation.USAGE_SCRIPT
+ )
val output = Allocation.createTyped(rs, input.type)
val script = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs))
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 63a20dfb..7fbb8a12 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
@@ -40,15 +40,20 @@ abstract class RetroMusicColoredTarget(view: ImageView) : BitmapPaletteTarget(vi
onColorReady(defaultFooterColor)
}
- override fun onResourceReady(resource: BitmapPaletteWrapper?, glideAnimation: GlideAnimation?) {
+ override fun onResourceReady(
+ resource: BitmapPaletteWrapper?,
+ glideAnimation: GlideAnimation?
+ ) {
super.onResourceReady(resource, glideAnimation)
val defaultColor = defaultFooterColor
resource?.let {
- onColorReady(if (PreferenceUtil.getInstance(getView().context).isDominantColor)
- RetroColorUtil.getDominantColor(it.bitmap, defaultColor)
- else
- RetroColorUtil.getColor(it.palette, defaultColor))
+ onColorReady(
+ if (PreferenceUtil.getInstance(getView().context).isDominantColor)
+ RetroColorUtil.getDominantColor(it.bitmap, defaultColor)
+ else
+ RetroColorUtil.getColor(it.palette, defaultColor)
+ )
}
}
}
diff --git a/app/src/main/java/code/name/monkey/retromusic/glide/RetroMusicGlideModule.kt b/app/src/main/java/code/name/monkey/retromusic/glide/RetroMusicGlideModule.kt
index 816a324f..078871cd 100644
--- a/app/src/main/java/code/name/monkey/retromusic/glide/RetroMusicGlideModule.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/glide/RetroMusicGlideModule.kt
@@ -16,7 +16,6 @@ package code.name.monkey.retromusic.glide
import android.content.Context
import code.name.monkey.retromusic.glide.artistimage.ArtistImage
-import code.name.monkey.retromusic.glide.artistimage.ArtistImageLoader
import code.name.monkey.retromusic.glide.artistimage.Factory
import code.name.monkey.retromusic.glide.audiocover.AudioFileCover
import code.name.monkey.retromusic.glide.audiocover.AudioFileCoverLoader
@@ -30,7 +29,11 @@ class RetroMusicGlideModule : GlideModule {
}
override fun registerComponents(context: Context, glide: Glide) {
- glide.register(AudioFileCover::class.java, InputStream::class.java, AudioFileCoverLoader.Factory())
+ glide.register(
+ AudioFileCover::class.java,
+ InputStream::class.java,
+ AudioFileCoverLoader.Factory()
+ )
glide.register(ArtistImage::class.java, InputStream::class.java, Factory(context))
}
}
diff --git a/app/src/main/java/code/name/monkey/retromusic/glide/SongGlideRequest.java b/app/src/main/java/code/name/monkey/retromusic/glide/SongGlideRequest.java
index 8bbfb935..acc90640 100644
--- a/app/src/main/java/code/name/monkey/retromusic/glide/SongGlideRequest.java
+++ b/app/src/main/java/code/name/monkey/retromusic/glide/SongGlideRequest.java
@@ -16,7 +16,6 @@ package code.name.monkey.retromusic.glide;
import android.content.Context;
import android.graphics.Bitmap;
-import android.graphics.drawable.Drawable;
import androidx.annotation.NonNull;
@@ -29,8 +28,6 @@ import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.load.resource.drawable.GlideDrawable;
import com.bumptech.glide.signature.MediaStoreSignature;
-import code.name.monkey.appthemehelper.ThemeStore;
-import code.name.monkey.appthemehelper.util.TintHelper;
import code.name.monkey.retromusic.R;
import code.name.monkey.retromusic.glide.audiocover.AudioFileCover;
import code.name.monkey.retromusic.glide.palette.BitmapPaletteTranscoder;
@@ -48,21 +45,37 @@ public class SongGlideRequest {
private static final int DEFAULT_ERROR_IMAGE = R.drawable.default_audio_art;
private static final int DEFAULT_ANIMATION = android.R.anim.fade_in;
+ @NonNull
+ private static DrawableTypeRequest createBaseRequest(@NonNull RequestManager requestManager,
+ @NonNull Song song,
+ boolean ignoreMediaStore) {
+ if (ignoreMediaStore) {
+ return requestManager.load(new AudioFileCover(song.getData()));
+ } else {
+ return requestManager.loadFromMediaStore(MusicUtil.getMediaStoreAlbumCoverUri(song.getAlbumId()));
+ }
+ }
+
+ @NonNull
+ private static Key createSignature(@NonNull Song song) {
+ return new MediaStoreSignature("", song.getDateModified(), 0);
+ }
+
public static class Builder {
final RequestManager requestManager;
final Song song;
boolean ignoreMediaStore;
- @NonNull
- public static Builder from(@NonNull RequestManager requestManager, Song song) {
- return new Builder(requestManager, song);
- }
-
private Builder(@NonNull RequestManager requestManager, Song song) {
this.requestManager = requestManager;
this.song = song;
}
+ @NonNull
+ public static Builder from(@NonNull RequestManager requestManager, Song song) {
+ return new Builder(requestManager, song);
+ }
+
@NonNull
public PaletteBuilder generatePalette(@NonNull Context context) {
return new PaletteBuilder(this, context);
@@ -90,7 +103,6 @@ public class SongGlideRequest {
return createBaseRequest(requestManager, song, ignoreMediaStore)
.diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY)
.error(DEFAULT_ERROR_IMAGE)
- .placeholder(DEFAULT_ERROR_IMAGE)
.animate(DEFAULT_ANIMATION)
.signature(createSignature(song));
}
@@ -109,7 +121,6 @@ public class SongGlideRequest {
.asBitmap()
.diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY)
.error(DEFAULT_ERROR_IMAGE)
- .placeholder(DEFAULT_ERROR_IMAGE)
.animate(DEFAULT_ANIMATION)
.signature(createSignature(builder.song));
}
@@ -125,32 +136,14 @@ public class SongGlideRequest {
}
public BitmapRequestBuilder, BitmapPaletteWrapper> build() {
- Drawable drawable = TintHelper.createTintedDrawable(context, DEFAULT_ERROR_IMAGE, ThemeStore.Companion.accentColor(context));
//noinspection unchecked
return createBaseRequest(builder.requestManager, builder.song, builder.ignoreMediaStore)
.asBitmap()
.transcode(new BitmapPaletteTranscoder(context), BitmapPaletteWrapper.class)
.diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY)
- .placeholder(drawable)
- .error(drawable)
+ .error(DEFAULT_ERROR_IMAGE)
.animate(DEFAULT_ANIMATION)
.signature(createSignature(builder.song));
}
}
-
- @NonNull
- private static DrawableTypeRequest createBaseRequest(@NonNull RequestManager requestManager,
- @NonNull Song song,
- boolean ignoreMediaStore) {
- if (ignoreMediaStore) {
- return requestManager.load(new AudioFileCover(song.getData()));
- } else {
- return requestManager.loadFromMediaStore(MusicUtil.getMediaStoreAlbumCoverUri(song.getAlbumId()));
- }
- }
-
- @NonNull
- private static Key createSignature(@NonNull Song song) {
- return new MediaStoreSignature("", song.getDateModified(), 0);
- }
}
diff --git a/app/src/main/java/code/name/monkey/retromusic/glide/artistimage/ArtistImageLoader.kt b/app/src/main/java/code/name/monkey/retromusic/glide/artistimage/ArtistImageLoader.kt
index 6bf62d7e..0ed4e892 100644
--- a/app/src/main/java/code/name/monkey/retromusic/glide/artistimage/ArtistImageLoader.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/glide/artistimage/ArtistImageLoader.kt
@@ -60,7 +60,10 @@ class ArtistImageFetcher(
}
override fun loadData(priority: Priority?): InputStream? {
- if (!MusicUtil.isArtistNameUnknown(model.artistName) && PreferenceUtil.isAllowedToDownloadMetadata(context)) {
+ if (!MusicUtil.isArtistNameUnknown(model.artistName) && PreferenceUtil.isAllowedToDownloadMetadata(
+ context
+ )
+ ) {
val artists = model.artistName.split(",")
val response = deezerApiService.getArtistImage(artists[0]).execute()
@@ -100,7 +103,11 @@ class ArtistImageLoader(
private val urlLoader: ModelLoader
) : StreamModelLoader {
- override fun getResourceFetcher(model: ArtistImage, width: Int, height: Int): DataFetcher {
+ override fun getResourceFetcher(
+ model: ArtistImage,
+ width: Int,
+ height: Int
+ ): DataFetcher {
return ArtistImageFetcher(context, deezerApiService, model, urlLoader, width, height)
}
}
@@ -129,8 +136,15 @@ class Factory(
)
}
- override fun build(context: Context?, factories: GenericLoaderFactory?): ModelLoader {
- return ArtistImageLoader(context!!, deezerApiService, okHttpFactory.build(context, factories))
+ override fun build(
+ context: Context?,
+ factories: GenericLoaderFactory?
+ ): ModelLoader {
+ return ArtistImageLoader(
+ context!!,
+ deezerApiService,
+ okHttpFactory.build(context, factories)
+ )
}
override fun teardown() {
diff --git a/app/src/main/java/code/name/monkey/retromusic/glide/audiocover/AudioFileCoverLoader.java b/app/src/main/java/code/name/monkey/retromusic/glide/audiocover/AudioFileCoverLoader.java
index 591d5a35..1da3ec8c 100644
--- a/app/src/main/java/code/name/monkey/retromusic/glide/audiocover/AudioFileCoverLoader.java
+++ b/app/src/main/java/code/name/monkey/retromusic/glide/audiocover/AudioFileCoverLoader.java
@@ -25,7 +25,6 @@ import com.bumptech.glide.load.model.stream.StreamModelLoader;
import java.io.InputStream;
-
public class AudioFileCoverLoader implements StreamModelLoader {
@Override
diff --git a/app/src/main/java/code/name/monkey/retromusic/glide/palette/BitmapPaletteWrapper.java b/app/src/main/java/code/name/monkey/retromusic/glide/palette/BitmapPaletteWrapper.java
index 4aa89e08..105d09f0 100644
--- a/app/src/main/java/code/name/monkey/retromusic/glide/palette/BitmapPaletteWrapper.java
+++ b/app/src/main/java/code/name/monkey/retromusic/glide/palette/BitmapPaletteWrapper.java
@@ -15,6 +15,7 @@
package code.name.monkey.retromusic.glide.palette;
import android.graphics.Bitmap;
+
import androidx.palette.graphics.Palette;
public class BitmapPaletteWrapper {
diff --git a/app/src/main/java/code/name/monkey/retromusic/helper/HorizontalAdapterHelper.kt b/app/src/main/java/code/name/monkey/retromusic/helper/HorizontalAdapterHelper.kt
index 0980a9ac..86bc78d6 100644
--- a/app/src/main/java/code/name/monkey/retromusic/helper/HorizontalAdapterHelper.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/helper/HorizontalAdapterHelper.kt
@@ -27,10 +27,12 @@ object HorizontalAdapterHelper {
private const val TYPE_MIDDLE = 2
private const val TYPE_LAST = 3
- fun applyMarginToLayoutParams(context: Context,
- layoutParams: ViewGroup.MarginLayoutParams, viewType: Int) {
+ fun applyMarginToLayoutParams(
+ context: Context,
+ layoutParams: ViewGroup.MarginLayoutParams, viewType: Int
+ ) {
val listMargin = context.resources
- .getDimensionPixelSize(R.dimen.now_playing_top_margin)
+ .getDimensionPixelSize(R.dimen.now_playing_top_margin)
if (viewType == TYPE_FIRST) {
layoutParams.leftMargin = listMargin
} else if (viewType == TYPE_LAST) {
diff --git a/app/src/main/java/code/name/monkey/retromusic/helper/MusicPlayerRemote.kt b/app/src/main/java/code/name/monkey/retromusic/helper/MusicPlayerRemote.kt
index cc40680b..22f3b83a 100644
--- a/app/src/main/java/code/name/monkey/retromusic/helper/MusicPlayerRemote.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/helper/MusicPlayerRemote.kt
@@ -16,12 +16,7 @@ package code.name.monkey.retromusic.helper
import android.annotation.TargetApi
import android.app.Activity
-import android.content.ComponentName
-import android.content.ContentResolver
-import android.content.Context
-import android.content.ContextWrapper
-import android.content.Intent
-import android.content.ServiceConnection
+import android.content.*
import android.database.Cursor
import android.net.Uri
import android.os.Build
@@ -36,9 +31,7 @@ import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.util.PreferenceUtil
import java.io.File
-import java.util.ArrayList
-import java.util.Random
-import java.util.WeakHashMap
+import java.util.*
object MusicPlayerRemote {
val TAG: String = MusicPlayerRemote::class.java.simpleName
@@ -209,7 +202,12 @@ object MusicPlayerRemote {
*/
@JvmStatic
fun openQueue(queue: List, startPosition: Int, startPlaying: Boolean) {
- if (!tryToHandleOpenPlayingQueue(queue, startPosition, startPlaying) && musicService != null) {
+ if (!tryToHandleOpenPlayingQueue(
+ queue,
+ startPosition,
+ startPlaying
+ ) && musicService != null
+ ) {
musicService?.openQueue(queue, startPosition, startPlaying)
if (PreferenceUtil.getInstance(musicService).isShuffleModeOn)
setShuffleMode(MusicService.SHUFFLE_MODE_NONE)
@@ -226,7 +224,12 @@ object MusicPlayerRemote {
startPosition = Random().nextInt(queue.size)
}
- if (!tryToHandleOpenPlayingQueue(queue, startPosition, startPlaying) && musicService != null) {
+ if (!tryToHandleOpenPlayingQueue(
+ queue,
+ startPosition,
+ startPlaying
+ ) && musicService != null
+ ) {
openQueue(queue, startPosition, startPlaying)
setShuffleMode(MusicService.SHUFFLE_MODE_SHUFFLE)
}
@@ -419,7 +422,10 @@ object MusicPlayerRemote {
var songFile: File? = null
if (uri.authority != null && uri.authority == "com.android.externalstorage.documents") {
songFile =
- File(Environment.getExternalStorageDirectory(), uri.path?.split(":".toRegex(), 2)?.get(1))
+ File(
+ Environment.getExternalStorageDirectory(),
+ uri.path?.split(":".toRegex(), 2)?.get(1)
+ )
}
if (songFile == null) {
val path = getFilePathFromUri(musicService!!, uri)
@@ -453,7 +459,8 @@ object MusicPlayerRemote {
return DocumentsContract.getDocumentId(uri).split(":".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()[1]
}
- class ServiceBinder internal constructor(private val mCallback: ServiceConnection?) : ServiceConnection {
+ class ServiceBinder internal constructor(private val mCallback: ServiceConnection?) :
+ ServiceConnection {
override fun onServiceConnected(className: ComponentName, service: IBinder) {
val binder = service as MusicService.MusicBinder
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 78ea3e6d..4273931e 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
@@ -20,7 +20,7 @@ import android.os.Bundle
import android.provider.MediaStore
import code.name.monkey.retromusic.loaders.SongLoader
import code.name.monkey.retromusic.model.Song
-import java.util.ArrayList
+import java.util.*
object SearchQueryHelper {
private const val TITLE_SELECTION = "lower(" + MediaStore.Audio.AudioColumns.TITLE + ") = ?"
@@ -41,7 +41,11 @@ object SearchQueryHelper {
SongLoader.makeSongCursor(
context,
ARTIST_SELECTION + AND + ALBUM_SELECTION + AND + TITLE_SELECTION,
- arrayOf(artistName.toLowerCase(), albumName.toLowerCase(), titleName.toLowerCase())
+ arrayOf(
+ artistName.toLowerCase(),
+ albumName.toLowerCase(),
+ titleName.toLowerCase()
+ )
)
)
}
@@ -109,16 +113,34 @@ object SearchQueryHelper {
return songs
}
songs =
- SongLoader.getSongs(SongLoader.makeSongCursor(context, ARTIST_SELECTION, arrayOf(query.toLowerCase())))
+ SongLoader.getSongs(
+ SongLoader.makeSongCursor(
+ context,
+ ARTIST_SELECTION,
+ arrayOf(query.toLowerCase())
+ )
+ )
if (songs.isNotEmpty()) {
return songs
}
- songs = SongLoader.getSongs(SongLoader.makeSongCursor(context, ALBUM_SELECTION, arrayOf(query.toLowerCase())))
+ songs = SongLoader.getSongs(
+ SongLoader.makeSongCursor(
+ context,
+ ALBUM_SELECTION,
+ arrayOf(query.toLowerCase())
+ )
+ )
if (songs.isNotEmpty()) {
return songs
}
- songs = SongLoader.getSongs(SongLoader.makeSongCursor(context, TITLE_SELECTION, arrayOf(query.toLowerCase())))
+ songs = SongLoader.getSongs(
+ SongLoader.makeSongCursor(
+ context,
+ TITLE_SELECTION,
+ arrayOf(query.toLowerCase())
+ )
+ )
return if (songs.isNotEmpty()) {
songs
} else ArrayList()
diff --git a/app/src/main/java/code/name/monkey/retromusic/helper/StackBlur.java b/app/src/main/java/code/name/monkey/retromusic/helper/StackBlur.java
index 3e812e8a..112b554b 100644
--- a/app/src/main/java/code/name/monkey/retromusic/helper/StackBlur.java
+++ b/app/src/main/java/code/name/monkey/retromusic/helper/StackBlur.java
@@ -24,12 +24,12 @@ import java.util.concurrent.Executors;
* on the left side of the stack.
*
* @author Enrique López Mañas
- * http://www.neo-tech.es
- *
- * Author of the original algorithm: Mario Klingemann
- *
- * Based heavily on http://vitiy.info/Code/stackblur.cpp
- * See http://vitiy.info/stackblur-algorithm-multi-threaded-blur-for-cpp/
+ * http://www.neo-tech.es
+ *
+ * Author of the original algorithm: Mario Klingemann
+ *
+ * Based heavily on http://vitiy.info/Code/stackblur.cpp
+ * See http://vitiy.info/stackblur-algorithm-multi-threaded-blur-for-cpp/
* @copyright: Enrique López Mañas
* @license: Apache License 2.0
*/
diff --git a/app/src/main/java/code/name/monkey/retromusic/helper/menu/GenreMenuHelper.kt b/app/src/main/java/code/name/monkey/retromusic/helper/menu/GenreMenuHelper.kt
index 50610499..af790d95 100644
--- a/app/src/main/java/code/name/monkey/retromusic/helper/menu/GenreMenuHelper.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/helper/menu/GenreMenuHelper.kt
@@ -39,7 +39,7 @@ object GenreMenuHelper {
}
R.id.action_add_to_playlist -> {
AddToPlaylistDialog.create(getGenreSongs(activity, genre))
- .show(activity.supportFragmentManager, "ADD_PLAYLIST")
+ .show(activity.supportFragmentManager, "ADD_PLAYLIST")
return true
}
R.id.action_add_to_current_playing -> {
diff --git a/app/src/main/java/code/name/monkey/retromusic/helper/menu/PlaylistMenuHelper.kt b/app/src/main/java/code/name/monkey/retromusic/helper/menu/PlaylistMenuHelper.kt
index 082500dc..ef9729dc 100644
--- a/app/src/main/java/code/name/monkey/retromusic/helper/menu/PlaylistMenuHelper.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/helper/menu/PlaylistMenuHelper.kt
@@ -37,8 +37,10 @@ import java.util.*
object PlaylistMenuHelper {
- fun handleMenuClick(activity: AppCompatActivity,
- playlist: Playlist, item: MenuItem): Boolean {
+ fun handleMenuClick(
+ activity: AppCompatActivity,
+ playlist: Playlist, item: MenuItem
+ ): Boolean {
when (item.itemId) {
R.id.action_play -> {
MusicPlayerRemote.openQueue(getPlaylistSongs(activity, playlist), 9, true)
@@ -50,7 +52,7 @@ object PlaylistMenuHelper {
}
R.id.action_add_to_playlist -> {
AddToPlaylistDialog.create(getPlaylistSongs(activity, playlist))
- .show(activity.supportFragmentManager, "ADD_PLAYLIST")
+ .show(activity.supportFragmentManager, "ADD_PLAYLIST")
return true
}
R.id.action_add_to_current_playing -> {
@@ -59,12 +61,12 @@ object PlaylistMenuHelper {
}
R.id.action_rename_playlist -> {
RenamePlaylistDialog.create(playlist.id.toLong())
- .show(activity.supportFragmentManager, "RENAME_PLAYLIST")
+ .show(activity.supportFragmentManager, "RENAME_PLAYLIST")
return true
}
R.id.action_delete_playlist -> {
DeletePlaylistDialog.create(playlist)
- .show(activity.supportFragmentManager, "DELETE_PLAYLIST")
+ .show(activity.supportFragmentManager, "DELETE_PLAYLIST")
return true
}
R.id.action_save_playlist -> {
@@ -75,8 +77,10 @@ object PlaylistMenuHelper {
return false
}
- private fun getPlaylistSongs(activity: Activity,
- playlist: Playlist): ArrayList {
+ private fun getPlaylistSongs(
+ activity: Activity,
+ playlist: Playlist
+ ): ArrayList {
return if (playlist is AbsCustomPlaylist) {
playlist.getSongs(activity)
} else {
@@ -84,11 +88,16 @@ object PlaylistMenuHelper {
}
}
- private class SavePlaylistAsyncTask internal constructor(context: Context) : WeakContextAsyncTask(context) {
+ private class SavePlaylistAsyncTask internal constructor(context: Context) :
+ WeakContextAsyncTask(context) {
override fun doInBackground(vararg params: Playlist): String {
- return String.format(App.getContext().getString(R.string
- .saved_playlist_to), PlaylistsUtil.savePlaylist(App.getContext(), params[0]))
+ return String.format(
+ App.getContext().getString(
+ R.string
+ .saved_playlist_to
+ ), PlaylistsUtil.savePlaylist(App.getContext(), params[0])
+ )
}
override fun onPostExecute(string: String) {
diff --git a/app/src/main/java/code/name/monkey/retromusic/helper/menu/SongMenuHelper.kt b/app/src/main/java/code/name/monkey/retromusic/helper/menu/SongMenuHelper.kt
index bc125739..c2b5f5ff 100644
--- a/app/src/main/java/code/name/monkey/retromusic/helper/menu/SongMenuHelper.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/helper/menu/SongMenuHelper.kt
@@ -60,7 +60,8 @@ object SongMenuHelper {
return true
}
R.id.action_add_to_playlist -> {
- AddToPlaylistDialog.create(song).show(activity.supportFragmentManager, "ADD_PLAYLIST")
+ AddToPlaylistDialog.create(song)
+ .show(activity.supportFragmentManager, "ADD_PLAYLIST")
return true
}
R.id.action_play_next -> {
diff --git a/app/src/main/java/code/name/monkey/retromusic/helper/menu/SongsMenuHelper.kt b/app/src/main/java/code/name/monkey/retromusic/helper/menu/SongsMenuHelper.kt
index cd0af61e..36d110f5 100644
--- a/app/src/main/java/code/name/monkey/retromusic/helper/menu/SongsMenuHelper.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/helper/menu/SongsMenuHelper.kt
@@ -25,7 +25,11 @@ import java.util.*
object SongsMenuHelper {
- fun handleMenuClick(activity: FragmentActivity, songs: ArrayList, menuItemId: Int): Boolean {
+ fun handleMenuClick(
+ activity: FragmentActivity,
+ songs: ArrayList,
+ menuItemId: Int
+ ): Boolean {
when (menuItemId) {
R.id.action_play_next -> {
MusicPlayerRemote.playNext(songs)
@@ -36,11 +40,13 @@ object SongsMenuHelper {
return true
}
R.id.action_add_to_playlist -> {
- AddToPlaylistDialog.create(songs).show(activity.supportFragmentManager, "ADD_PLAYLIST")
+ AddToPlaylistDialog.create(songs)
+ .show(activity.supportFragmentManager, "ADD_PLAYLIST")
return true
}
R.id.action_delete_from_device -> {
- DeleteSongsDialog.create(songs).show(activity.supportFragmentManager, "DELETE_SONGS")
+ DeleteSongsDialog.create(songs)
+ .show(activity.supportFragmentManager, "DELETE_SONGS")
return true
}
}
diff --git a/app/src/main/java/code/name/monkey/retromusic/loaders/AlbumLoader.kt b/app/src/main/java/code/name/monkey/retromusic/loaders/AlbumLoader.kt
index d28fb1ae..49342d0d 100644
--- a/app/src/main/java/code/name/monkey/retromusic/loaders/AlbumLoader.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/loaders/AlbumLoader.kt
@@ -19,7 +19,10 @@ import android.provider.MediaStore.Audio.AudioColumns
import code.name.monkey.retromusic.model.Album
import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.util.PreferenceUtil
-import java.util.Comparator
+import java.util.*
+import kotlin.collections.ArrayList
+import kotlin.collections.isNotEmpty
+import kotlin.collections.sortWith
/**
@@ -29,42 +32,54 @@ import java.util.Comparator
object AlbumLoader {
fun getAlbums(
- context: Context,
- query: String
+ context: Context,
+ query: String
): ArrayList {
- val songs = SongLoader.getSongs(SongLoader.makeSongCursor(
+ val songs = SongLoader.getSongs(
+ SongLoader.makeSongCursor(
context,
AudioColumns.ALBUM + " LIKE ?",
arrayOf("%$query%"),
- getSongLoaderSortOrder(context))
+ getSongLoaderSortOrder(context)
+ )
)
return splitIntoAlbums(songs)
}
+
@JvmStatic
fun getAlbum(
- context: Context,
- albumId: Int
+ context: Context,
+ albumId: Int
): Album {
val songs = SongLoader.getSongs(
- SongLoader.makeSongCursor(
- context,
- AudioColumns.ALBUM_ID + "=?",
- arrayOf(albumId.toString()),
- getSongLoaderSortOrder(context)))
+ SongLoader.makeSongCursor(
+ context,
+ AudioColumns.ALBUM_ID + "=?",
+ arrayOf(albumId.toString()),
+ getSongLoaderSortOrder(context)
+ )
+ )
val album = Album(songs)
sortSongsByTrackNumber(album)
return album
}
fun getAllAlbums(
- context: Context
+ context: Context
): ArrayList {
- val songs = SongLoader.getSongs(SongLoader.makeSongCursor(context, null, null, getSongLoaderSortOrder(context)))
+ val songs = SongLoader.getSongs(
+ SongLoader.makeSongCursor(
+ context,
+ null,
+ null,
+ getSongLoaderSortOrder(context)
+ )
+ )
return splitIntoAlbums(songs)
}
fun splitIntoAlbums(
- songs: ArrayList?
+ songs: ArrayList?
): ArrayList {
val albums = ArrayList()
if (songs != null) {
@@ -79,8 +94,8 @@ object AlbumLoader {
}
private fun getOrCreateAlbum(
- albums: ArrayList,
- albumId: Int
+ albums: ArrayList,
+ albumId: Int
): Album {
for (album in albums) {
if (album.songs!!.isNotEmpty() && album.songs[0].albumId == albumId) {
@@ -97,6 +112,8 @@ object AlbumLoader {
}
private fun getSongLoaderSortOrder(context: Context): String {
- return PreferenceUtil.getInstance(context).albumSortOrder + ", " + PreferenceUtil.getInstance(context).albumSongSortOrder
+ return PreferenceUtil.getInstance(context).albumSortOrder + ", " + PreferenceUtil.getInstance(
+ context
+ ).albumSongSortOrder
}
}
diff --git a/app/src/main/java/code/name/monkey/retromusic/loaders/ArtistLoader.kt b/app/src/main/java/code/name/monkey/retromusic/loaders/ArtistLoader.kt
index cd994be1..cde5b43f 100644
--- a/app/src/main/java/code/name/monkey/retromusic/loaders/ArtistLoader.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/loaders/ArtistLoader.kt
@@ -22,7 +22,9 @@ import code.name.monkey.retromusic.util.PreferenceUtil
object ArtistLoader {
private fun getSongLoaderSortOrder(context: Context): String {
- return PreferenceUtil.getInstance(context).artistSortOrder + ", " + PreferenceUtil.getInstance(context).artistAlbumSortOrder + ", " + PreferenceUtil.getInstance(
+ return PreferenceUtil.getInstance(context).artistSortOrder + ", " + PreferenceUtil.getInstance(
+ context
+ ).artistAlbumSortOrder + ", " + PreferenceUtil.getInstance(
context
).albumSongSortOrder
}
diff --git a/app/src/main/java/code/name/monkey/retromusic/loaders/GenreLoader.kt b/app/src/main/java/code/name/monkey/retromusic/loaders/GenreLoader.kt
index 09afd12a..c92cde62 100644
--- a/app/src/main/java/code/name/monkey/retromusic/loaders/GenreLoader.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/loaders/GenreLoader.kt
@@ -82,8 +82,9 @@ object GenreLoader {
private fun makeAllSongsWithGenreCursor(context: Context): Cursor? {
try {
return context.contentResolver.query(
- Uri.parse("content://media/external/audio/genres/all/members"),
- arrayOf(Genres.Members.AUDIO_ID), null, null, null)
+ Uri.parse("content://media/external/audio/genres/all/members"),
+ arrayOf(Genres.Members.AUDIO_ID), null, null, null
+ )
} catch (e: SecurityException) {
return null
}
@@ -93,8 +94,12 @@ object GenreLoader {
private fun makeGenreSongCursor(context: Context, genreId: Int): Cursor? {
try {
return context.contentResolver.query(
- Genres.Members.getContentUri("external", genreId.toLong()),
- baseProjection, BASE_SELECTION, null, PreferenceUtil.getInstance(context).songSortOrder)
+ Genres.Members.getContentUri("external", genreId.toLong()),
+ baseProjection,
+ BASE_SELECTION,
+ null,
+ PreferenceUtil.getInstance(context).songSortOrder
+ )
} catch (e: SecurityException) {
return null
}
@@ -112,7 +117,11 @@ object GenreLoader {
} else {
// try to remove the empty genre from the media store
try {
- context.contentResolver.delete(Genres.EXTERNAL_CONTENT_URI, Genres._ID + " == " + genre.id, null)
+ context.contentResolver.delete(
+ Genres.EXTERNAL_CONTENT_URI,
+ Genres._ID + " == " + genre.id,
+ null
+ )
} catch (e: Exception) {
e.printStackTrace()
}
@@ -140,7 +149,13 @@ object GenreLoader {
private fun makeGenreCursor(context: Context): Cursor? {
val projection = arrayOf(Genres._ID, Genres.NAME)
try {
- return context.contentResolver.query(Genres.EXTERNAL_CONTENT_URI, projection, null, null, PreferenceUtil.getInstance(context).genreSortOrder)
+ return context.contentResolver.query(
+ Genres.EXTERNAL_CONTENT_URI,
+ projection,
+ null,
+ null,
+ PreferenceUtil.getInstance(context).genreSortOrder
+ )
} catch (e: SecurityException) {
return null
}
diff --git a/app/src/main/java/code/name/monkey/retromusic/loaders/LastAddedSongsLoader.kt b/app/src/main/java/code/name/monkey/retromusic/loaders/LastAddedSongsLoader.kt
index 358bd595..3a9e2d50 100644
--- a/app/src/main/java/code/name/monkey/retromusic/loaders/LastAddedSongsLoader.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/loaders/LastAddedSongsLoader.kt
@@ -36,10 +36,11 @@ object LastAddedSongsLoader {
val cutoff = PreferenceUtil.getInstance(context).lastAddedCutoff
return SongLoader.makeSongCursor(
- context,
- MediaStore.Audio.Media.DATE_ADDED + ">?",
- arrayOf(cutoff.toString()),
- MediaStore.Audio.Media.DATE_ADDED + " DESC")
+ context,
+ MediaStore.Audio.Media.DATE_ADDED + ">?",
+ arrayOf(cutoff.toString()),
+ MediaStore.Audio.Media.DATE_ADDED + " DESC"
+ )
}
fun getLastAddedAlbums(context: Context): ArrayList {
diff --git a/app/src/main/java/code/name/monkey/retromusic/loaders/PlaylistLoader.kt b/app/src/main/java/code/name/monkey/retromusic/loaders/PlaylistLoader.kt
index 1bfa9334..12eff6df 100644
--- a/app/src/main/java/code/name/monkey/retromusic/loaders/PlaylistLoader.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/loaders/PlaylistLoader.kt
@@ -20,7 +20,7 @@ import android.provider.BaseColumns
import android.provider.MediaStore
import android.provider.MediaStore.Audio.PlaylistsColumns
import code.name.monkey.retromusic.model.Playlist
-import java.util.ArrayList
+import java.util.*
/**
* Created by hemanths on 16/08/17.
diff --git a/app/src/main/java/code/name/monkey/retromusic/loaders/PlaylistSongsLoader.kt b/app/src/main/java/code/name/monkey/retromusic/loaders/PlaylistSongsLoader.kt
index c6a3c297..546f538f 100644
--- a/app/src/main/java/code/name/monkey/retromusic/loaders/PlaylistSongsLoader.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/loaders/PlaylistSongsLoader.kt
@@ -23,7 +23,7 @@ import code.name.monkey.retromusic.model.AbsCustomPlaylist
import code.name.monkey.retromusic.model.Playlist
import code.name.monkey.retromusic.model.PlaylistSong
import code.name.monkey.retromusic.model.Song
-import java.util.ArrayList
+import java.util.*
/**
* Created by hemanths on 16/08/17.
@@ -38,6 +38,7 @@ object PlaylistSongsLoader {
return (playlist as? AbsCustomPlaylist)?.getSongs(context)
?: getPlaylistSongList(context, playlist.id)
}
+
@JvmStatic
fun getPlaylistSongList(context: Context, playlistId: Int): ArrayList {
val songs = arrayListOf()
diff --git a/app/src/main/java/code/name/monkey/retromusic/loaders/SearchLoader.kt b/app/src/main/java/code/name/monkey/retromusic/loaders/SearchLoader.kt
index cd42dd97..d13990ad 100644
--- a/app/src/main/java/code/name/monkey/retromusic/loaders/SearchLoader.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/loaders/SearchLoader.kt
@@ -17,7 +17,7 @@ package code.name.monkey.retromusic.loaders
import android.content.Context
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.model.Genre
-import java.util.Locale
+import java.util.*
object SearchLoader {
fun searchAll(context: Context, query: String?): MutableList {
diff --git a/app/src/main/java/code/name/monkey/retromusic/loaders/SongLoader.kt b/app/src/main/java/code/name/monkey/retromusic/loaders/SongLoader.kt
index e03b6ef7..aa9fc369 100644
--- a/app/src/main/java/code/name/monkey/retromusic/loaders/SongLoader.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/loaders/SongLoader.kt
@@ -23,7 +23,7 @@ import code.name.monkey.retromusic.Constants.baseProjection
import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.providers.BlacklistStore
import code.name.monkey.retromusic.util.PreferenceUtil
-import java.util.ArrayList
+import java.util.*
/**
* Created by hemanths on 10/08/17.
diff --git a/app/src/main/java/code/name/monkey/retromusic/loaders/SortedCursor.java b/app/src/main/java/code/name/monkey/retromusic/loaders/SortedCursor.java
index 2a509570..54049643 100644
--- a/app/src/main/java/code/name/monkey/retromusic/loaders/SortedCursor.java
+++ b/app/src/main/java/code/name/monkey/retromusic/loaders/SortedCursor.java
@@ -15,6 +15,7 @@ package code.name.monkey.retromusic.loaders;
import android.database.AbstractCursor;
import android.database.Cursor;
+
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
diff --git a/app/src/main/java/code/name/monkey/retromusic/loaders/SortedLongCursor.java b/app/src/main/java/code/name/monkey/retromusic/loaders/SortedLongCursor.java
index 4189dfc1..8368c040 100644
--- a/app/src/main/java/code/name/monkey/retromusic/loaders/SortedLongCursor.java
+++ b/app/src/main/java/code/name/monkey/retromusic/loaders/SortedLongCursor.java
@@ -15,6 +15,7 @@ package code.name.monkey.retromusic.loaders;
import android.database.AbstractCursor;
import android.database.Cursor;
+
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
diff --git a/app/src/main/java/code/name/monkey/retromusic/loaders/TopAndRecentlyPlayedTracksLoader.kt b/app/src/main/java/code/name/monkey/retromusic/loaders/TopAndRecentlyPlayedTracksLoader.kt
index d7f6bee3..0948d517 100644
--- a/app/src/main/java/code/name/monkey/retromusic/loaders/TopAndRecentlyPlayedTracksLoader.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/loaders/TopAndRecentlyPlayedTracksLoader.kt
@@ -23,7 +23,7 @@ import code.name.monkey.retromusic.model.Artist
import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.providers.HistoryStore
import code.name.monkey.retromusic.providers.SongPlayCountStore
-import java.util.ArrayList
+import java.util.*
/**
* Created by hemanths on 16/08/17.
diff --git a/app/src/main/java/code/name/monkey/retromusic/lyrics/LrcHelper.java b/app/src/main/java/code/name/monkey/retromusic/lyrics/LrcHelper.java
index d2c05193..385b7856 100644
--- a/app/src/main/java/code/name/monkey/retromusic/lyrics/LrcHelper.java
+++ b/app/src/main/java/code/name/monkey/retromusic/lyrics/LrcHelper.java
@@ -127,10 +127,10 @@ public class LrcHelper {
String mil = timeMatcher.group(3);
Lrc lrc = new Lrc();
if (content != null && content.length() != 0) {
- if(Integer.parseInt(mil)< 100){
- lrc.setTime(Long.parseLong(min) * 60 * 1000 + Long.parseLong(sec) * 1000
- + Long.parseLong(mil) * 10);}
- else{
+ if (Integer.parseInt(mil) < 100) {
+ lrc.setTime(Long.parseLong(min) * 60 * 1000 + Long.parseLong(sec) * 1000
+ + Long.parseLong(mil) * 10);
+ } else {
lrc.setTime(Long.parseLong(min) * 60 * 1000 + Long.parseLong(sec) * 1000
+ Long.parseLong(mil)
);
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 eb00f0db..9541e1c6 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
@@ -47,7 +47,11 @@ import java.util.*
* Blog : http://www.jianshu.com/u/e76853f863a9
* Email : freedompaladin@gmail.com
*/
-class LrcView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) : View(context, attrs, defStyleAttr) {
+class LrcView @JvmOverloads constructor(
+ context: Context,
+ attrs: AttributeSet? = null,
+ defStyleAttr: Int = 0
+) : View(context, attrs, defStyleAttr) {
private var mLrcData: MutableList? = null
private var mTextPaint: TextPaint? = null
private var mDefaultContent: String? = null
@@ -142,25 +146,55 @@ class LrcView @JvmOverloads constructor(context: Context, attrs: AttributeSet? =
private fun init(context: Context, attrs: AttributeSet?) {
val typedArray = context.obtainStyledAttributes(attrs, R.styleable.LrcView)
- mLrcTextSize = typedArray.getDimension(R.styleable.LrcView_lrcTextSize, sp2px(context, 15f).toFloat())
- mLrcLineSpaceHeight = typedArray.getDimension(R.styleable.LrcView_lrcLineSpaceSize, dp2px(context, 20f).toFloat())
+ mLrcTextSize =
+ typedArray.getDimension(R.styleable.LrcView_lrcTextSize, sp2px(context, 15f).toFloat())
+ mLrcLineSpaceHeight = typedArray.getDimension(
+ R.styleable.LrcView_lrcLineSpaceSize,
+ dp2px(context, 20f).toFloat()
+ )
mTouchDelay = typedArray.getInt(R.styleable.LrcView_lrcTouchDelay, 3500)
mIndicatorTouchDelay = typedArray.getInt(R.styleable.LrcView_indicatorTouchDelay, 2500)
mNormalColor = typedArray.getColor(R.styleable.LrcView_lrcNormalTextColor, Color.GRAY)
- mCurrentPlayLineColor = typedArray.getColor(R.styleable.LrcView_lrcCurrentTextColor, Color.BLUE)
- mNoLrcTextSize = typedArray.getDimension(R.styleable.LrcView_noLrcTextSize, dp2px(context, 20f).toFloat())
+ mCurrentPlayLineColor =
+ typedArray.getColor(R.styleable.LrcView_lrcCurrentTextColor, Color.BLUE)
+ mNoLrcTextSize = typedArray.getDimension(
+ R.styleable.LrcView_noLrcTextSize,
+ dp2px(context, 20f).toFloat()
+ )
mNoLrcTextColor = typedArray.getColor(R.styleable.LrcView_noLrcTextColor, Color.BLACK)
- mIndicatorLineWidth = typedArray.getDimension(R.styleable.LrcView_indicatorLineHeight, dp2px(context, 0.5f).toFloat())
- mIndicatorTextSize = typedArray.getDimension(R.styleable.LrcView_indicatorTextSize, sp2px(context, 13f).toFloat())
- mIndicatorTextColor = typedArray.getColor(R.styleable.LrcView_indicatorTextColor, Color.GRAY)
- mCurrentIndicateLineTextColor = typedArray.getColor(R.styleable.LrcView_currentIndicateLrcColor, Color.GRAY)
- mIndicatorLineColor = typedArray.getColor(R.styleable.LrcView_indicatorLineColor, Color.GRAY)
- mIndicatorMargin = typedArray.getDimension(R.styleable.LrcView_indicatorStartEndMargin, dp2px(context, 5f).toFloat())
- mIconLineGap = typedArray.getDimension(R.styleable.LrcView_iconLineGap, dp2px(context, 3f).toFloat())
- mIconWidth = typedArray.getDimension(R.styleable.LrcView_playIconWidth, dp2px(context, 20f).toFloat())
- mIconHeight = typedArray.getDimension(R.styleable.LrcView_playIconHeight, dp2px(context, 20f).toFloat())
+ mIndicatorLineWidth = typedArray.getDimension(
+ R.styleable.LrcView_indicatorLineHeight,
+ dp2px(context, 0.5f).toFloat()
+ )
+ mIndicatorTextSize = typedArray.getDimension(
+ R.styleable.LrcView_indicatorTextSize,
+ sp2px(context, 13f).toFloat()
+ )
+ mIndicatorTextColor =
+ typedArray.getColor(R.styleable.LrcView_indicatorTextColor, Color.GRAY)
+ mCurrentIndicateLineTextColor =
+ typedArray.getColor(R.styleable.LrcView_currentIndicateLrcColor, Color.GRAY)
+ mIndicatorLineColor =
+ typedArray.getColor(R.styleable.LrcView_indicatorLineColor, Color.GRAY)
+ mIndicatorMargin = typedArray.getDimension(
+ R.styleable.LrcView_indicatorStartEndMargin,
+ dp2px(context, 5f).toFloat()
+ )
+ mIconLineGap =
+ typedArray.getDimension(R.styleable.LrcView_iconLineGap, dp2px(context, 3f).toFloat())
+ mIconWidth = typedArray.getDimension(
+ R.styleable.LrcView_playIconWidth,
+ dp2px(context, 20f).toFloat()
+ )
+ mIconHeight = typedArray.getDimension(
+ R.styleable.LrcView_playIconHeight,
+ dp2px(context, 20f).toFloat()
+ )
mPlayDrawable = typedArray.getDrawable(R.styleable.LrcView_playIcon)
- mPlayDrawable = if (mPlayDrawable == null) ContextCompat.getDrawable(context, R.drawable.ic_play_arrow_white_24dp) else mPlayDrawable
+ mPlayDrawable = if (mPlayDrawable == null) ContextCompat.getDrawable(
+ context,
+ R.drawable.ic_play_arrow_white_24dp
+ ) else mPlayDrawable
typedArray.recycle()
setupConfigs(context)
@@ -238,12 +272,20 @@ class LrcView @JvmOverloads constructor(context: Context, attrs: AttributeSet? =
val time = mLrcData!![indicatePosition].time
val timeWidth = mIndicatorPaint!!.measureText(LrcHelper.formatTime(time))
mIndicatorPaint!!.color = mIndicatorLineColor
- canvas.drawLine(mPlayRect!!.right + mIconLineGap, (height / 2).toFloat(),
- width - timeWidth * 1.3f, (height / 2).toFloat(), mIndicatorPaint!!)
+ canvas.drawLine(
+ mPlayRect!!.right + mIconLineGap, (height / 2).toFloat(),
+ width - timeWidth * 1.3f, (height / 2).toFloat(), mIndicatorPaint!!
+ )
val baseX = (width - timeWidth * 1.1f).toInt()
- val baseline = (height / 2).toFloat() - (mIndicatorPaint!!.descent() - mIndicatorPaint!!.ascent()) / 2 - mIndicatorPaint!!.ascent()
+ val baseline =
+ (height / 2).toFloat() - (mIndicatorPaint!!.descent() - mIndicatorPaint!!.ascent()) / 2 - mIndicatorPaint!!.ascent()
mIndicatorPaint!!.color = mIndicatorTextColor
- canvas.drawText(LrcHelper.formatTime(time), baseX.toFloat(), baseline, mIndicatorPaint!!)
+ canvas.drawText(
+ LrcHelper.formatTime(time),
+ baseX.toFloat(),
+ baseline,
+ mIndicatorPaint!!
+ )
}
}
@@ -257,7 +299,15 @@ class LrcView @JvmOverloads constructor(context: Context, attrs: AttributeSet? =
var staticLayout: StaticLayout? = mLrcMap[text]
if (staticLayout == null) {
mTextPaint!!.textSize = mLrcTextSize
- staticLayout = StaticLayout(text, mTextPaint, lrcWidth, Layout.Alignment.ALIGN_NORMAL, 1f, 0f, false)
+ staticLayout = StaticLayout(
+ text,
+ mTextPaint,
+ lrcWidth,
+ Layout.Alignment.ALIGN_NORMAL,
+ 1f,
+ 0f,
+ false
+ )
mLrcMap[text] = staticLayout
}
canvas.save()
@@ -272,8 +322,10 @@ class LrcView @JvmOverloads constructor(context: Context, attrs: AttributeSet? =
mTextPaint!!.color = mNoLrcTextColor
mTextPaint!!.textSize = mNoLrcTextSize
canvas.save()
- val staticLayout = StaticLayout(mDefaultContent, mTextPaint,
- lrcWidth, Layout.Alignment.ALIGN_NORMAL, 1f, 0f, false)
+ val staticLayout = StaticLayout(
+ mDefaultContent, mTextPaint,
+ lrcWidth, Layout.Alignment.ALIGN_NORMAL, 1f, 0f, false
+ )
val margin = dip2px(context, 16f).toFloat();
canvas.translate(margin, margin)
staticLayout.draw(canvas)
@@ -335,8 +387,10 @@ class LrcView @JvmOverloads constructor(context: Context, attrs: AttributeSet? =
var staticLayout: StaticLayout? = mStaticLayoutHashMap[text]
if (staticLayout == null) {
mTextPaint!!.textSize = mLrcTextSize
- staticLayout = StaticLayout(text, mTextPaint,
- lrcWidth, Layout.Alignment.ALIGN_NORMAL, 1f, 0f, false)
+ staticLayout = StaticLayout(
+ text, mTextPaint,
+ lrcWidth, Layout.Alignment.ALIGN_NORMAL, 1f, 0f, false
+ )
mStaticLayoutHashMap[text] = staticLayout
}
return staticLayout.height.toFloat()
@@ -405,20 +459,30 @@ class LrcView @JvmOverloads constructor(context: Context, attrs: AttributeSet? =
private fun handleActionUp(event: MotionEvent) {
if (isEnableShowIndicator) {
- ViewCompat.postOnAnimationDelayed(this@LrcView, mHideIndicatorRunnable, mIndicatorTouchDelay.toLong())
+ ViewCompat.postOnAnimationDelayed(
+ this@LrcView,
+ mHideIndicatorRunnable,
+ mIndicatorTouchDelay.toLong()
+ )
}
if (isShowTimeIndicator && mPlayRect != null && onClickPlayButton(event)) {
isShowTimeIndicator = false
invalidateView()
if (mOnPlayIndicatorLineListener != null) {
- mOnPlayIndicatorLineListener!!.onPlay(mLrcData!![indicatePosition].time,
- mLrcData!![indicatePosition].text)
+ mOnPlayIndicatorLineListener!!.onPlay(
+ mLrcData!![indicatePosition].time,
+ mLrcData!![indicatePosition].text
+ )
}
}
if (overScrolled() && mOffset < 0) {
scrollToPosition(0)
if (isAutoAdjustPosition) {
- ViewCompat.postOnAnimationDelayed(this@LrcView, mScrollRunnable, mTouchDelay.toLong())
+ ViewCompat.postOnAnimationDelayed(
+ this@LrcView,
+ mScrollRunnable,
+ mTouchDelay.toLong()
+ )
}
return
}
@@ -426,7 +490,11 @@ class LrcView @JvmOverloads constructor(context: Context, attrs: AttributeSet? =
if (overScrolled() && mOffset > getItemOffsetY(lrcCount - 1)) {
scrollToPosition(lrcCount - 1)
if (isAutoAdjustPosition) {
- ViewCompat.postOnAnimationDelayed(this@LrcView, mScrollRunnable, mTouchDelay.toLong())
+ ViewCompat.postOnAnimationDelayed(
+ this@LrcView,
+ mScrollRunnable,
+ mTouchDelay.toLong()
+ )
}
return
}
@@ -435,9 +503,11 @@ class LrcView @JvmOverloads constructor(context: Context, attrs: AttributeSet? =
val YVelocity = mVelocityTracker!!.yVelocity
val absYVelocity = Math.abs(YVelocity)
if (absYVelocity > mMinimumFlingVelocity) {
- mOverScroller!!.fling(0, mOffset.toInt(), 0, (-YVelocity).toInt(), 0,
- 0, 0, getItemOffsetY(lrcCount - 1).toInt(),
- 0, getTextHeight(0).toInt())
+ mOverScroller!!.fling(
+ 0, mOffset.toInt(), 0, (-YVelocity).toInt(), 0,
+ 0, 0, getItemOffsetY(lrcCount - 1).toInt(),
+ 0, getTextHeight(0).toInt()
+ )
invalidateView()
}
releaseVelocityTracker()
@@ -493,13 +563,17 @@ class LrcView @JvmOverloads constructor(context: Context, attrs: AttributeSet? =
}
fun dp2px(context: Context, dpVal: Float): Int {
- return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
- dpVal, context.resources.displayMetrics).toInt()
+ return TypedValue.applyDimension(
+ TypedValue.COMPLEX_UNIT_DIP,
+ dpVal, context.resources.displayMetrics
+ ).toInt()
}
fun sp2px(context: Context, spVal: Float): Int {
- return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP,
- spVal, context.resources.displayMetrics).toInt()
+ return TypedValue.applyDimension(
+ TypedValue.COMPLEX_UNIT_SP,
+ spVal, context.resources.displayMetrics
+ ).toInt()
}
/**
diff --git a/app/src/main/java/code/name/monkey/retromusic/misc/AsyncSearchResultLoader.kt b/app/src/main/java/code/name/monkey/retromusic/misc/AsyncSearchResultLoader.kt
index a9c9486a..4127292e 100644
--- a/app/src/main/java/code/name/monkey/retromusic/misc/AsyncSearchResultLoader.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/misc/AsyncSearchResultLoader.kt
@@ -22,7 +22,8 @@ import code.name.monkey.retromusic.loaders.ArtistLoader
import code.name.monkey.retromusic.loaders.SongLoader
import java.util.*
-internal class AsyncSearchResultLoader(context: Context, private val query: String) : WrappedAsyncTaskLoader>(context) {
+internal class AsyncSearchResultLoader(context: Context, private val query: String) :
+ WrappedAsyncTaskLoader>(context) {
override fun loadInBackground(): List? {
val results = ArrayList()
diff --git a/app/src/main/java/code/name/monkey/retromusic/misc/CustomFragmentStatePagerAdapter.java b/app/src/main/java/code/name/monkey/retromusic/misc/CustomFragmentStatePagerAdapter.java
index f9e68b65..31ce1874 100644
--- a/app/src/main/java/code/name/monkey/retromusic/misc/CustomFragmentStatePagerAdapter.java
+++ b/app/src/main/java/code/name/monkey/retromusic/misc/CustomFragmentStatePagerAdapter.java
@@ -16,6 +16,10 @@ package code.name.monkey.retromusic.misc;
import android.os.Bundle;
import android.os.Parcelable;
+import android.util.Log;
+import android.view.View;
+import android.view.ViewGroup;
+
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
@@ -23,10 +27,6 @@ import androidx.fragment.app.FragmentPagerAdapter;
import androidx.fragment.app.FragmentTransaction;
import androidx.viewpager.widget.PagerAdapter;
-import android.util.Log;
-import android.view.View;
-import android.view.ViewGroup;
-
import java.util.ArrayList;
/**
diff --git a/app/src/main/java/code/name/monkey/retromusic/misc/DialogAsyncTask.java b/app/src/main/java/code/name/monkey/retromusic/misc/DialogAsyncTask.java
index 2a2026ce..88e38762 100644
--- a/app/src/main/java/code/name/monkey/retromusic/misc/DialogAsyncTask.java
+++ b/app/src/main/java/code/name/monkey/retromusic/misc/DialogAsyncTask.java
@@ -17,6 +17,7 @@ package code.name.monkey.retromusic.misc;
import android.app.Dialog;
import android.content.Context;
import android.os.Handler;
+
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
diff --git a/app/src/main/java/code/name/monkey/retromusic/misc/UpdateToastMediaScannerCompletionListener.java b/app/src/main/java/code/name/monkey/retromusic/misc/UpdateToastMediaScannerCompletionListener.java
index 98b52dd1..84aa17c1 100644
--- a/app/src/main/java/code/name/monkey/retromusic/misc/UpdateToastMediaScannerCompletionListener.java
+++ b/app/src/main/java/code/name/monkey/retromusic/misc/UpdateToastMediaScannerCompletionListener.java
@@ -19,9 +19,11 @@ import android.app.Activity;
import android.media.MediaScannerConnection;
import android.net.Uri;
import android.widget.Toast;
-import code.name.monkey.retromusic.R;
+
import java.lang.ref.WeakReference;
+import code.name.monkey.retromusic.R;
+
/**
* @author Karim Abou Zeid (kabouzeid)
*/
@@ -30,15 +32,10 @@ public class UpdateToastMediaScannerCompletionListener implements MediaScannerCo
private final WeakReference activityWeakReference;
private final String couldNotScanFiles;
-
- private int failed = 0;
-
- private int scanned = 0;
-
private final String scannedFiles;
-
private final String[] toBeScanned;
-
+ private int failed = 0;
+ private int scanned = 0;
private Toast toast;
@SuppressLint("ShowToast")
diff --git a/app/src/main/java/code/name/monkey/retromusic/misc/WeakContextAsyncTask.kt b/app/src/main/java/code/name/monkey/retromusic/misc/WeakContextAsyncTask.kt
index f81a3dce..9b9b4896 100644
--- a/app/src/main/java/code/name/monkey/retromusic/misc/WeakContextAsyncTask.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/misc/WeakContextAsyncTask.kt
@@ -1 +1 @@
-/*
* Copyright (c) 2019 Hemanth Savarala.
*
* Licensed under the GNU General Public License v3
*
* This is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*/
package code.name.monkey.retromusic.misc
import android.content.Context
import android.os.AsyncTask
import java.lang.ref.WeakReference
abstract class WeakContextAsyncTask(context: Context) : AsyncTask() {
private val contextWeakReference: WeakReference = WeakReference(context)
protected val context: Context?
get() = contextWeakReference.get()
}
\ No newline at end of file
+/*
* Copyright (c) 2019 Hemanth Savarala.
*
* Licensed under the GNU General Public License v3
*
* This is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*/
package code.name.monkey.retromusic.misc
import android.content.Context
import android.os.AsyncTask
import java.lang.ref.WeakReference
abstract class WeakContextAsyncTask(context: Context) :
AsyncTask() {
private val contextWeakReference: WeakReference = WeakReference(context)
protected val context: Context?
get() = contextWeakReference.get()
}
\ No newline at end of file
diff --git a/app/src/main/java/code/name/monkey/retromusic/misc/WrappedAsyncTaskLoader.kt b/app/src/main/java/code/name/monkey/retromusic/misc/WrappedAsyncTaskLoader.kt
index 6c717bea..b798cc52 100644
--- a/app/src/main/java/code/name/monkey/retromusic/misc/WrappedAsyncTaskLoader.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/misc/WrappedAsyncTaskLoader.kt
@@ -29,7 +29,7 @@ abstract class WrappedAsyncTaskLoader
*
* @param context The [Context] to use.
*/
-(context: Context) : AsyncTaskLoader(context) {
+ (context: Context) : AsyncTaskLoader(context) {
private var mData: D? = null
diff --git a/app/src/main/java/code/name/monkey/retromusic/model/AbsCustomPlaylist.java b/app/src/main/java/code/name/monkey/retromusic/model/AbsCustomPlaylist.java
index 367e309b..819371b7 100644
--- a/app/src/main/java/code/name/monkey/retromusic/model/AbsCustomPlaylist.java
+++ b/app/src/main/java/code/name/monkey/retromusic/model/AbsCustomPlaylist.java
@@ -16,10 +16,13 @@ package code.name.monkey.retromusic.model;
import android.content.Context;
import android.os.Parcel;
+
import androidx.annotation.NonNull;
-import java.util.ArrayList;
+
import org.jetbrains.annotations.NotNull;
+import java.util.ArrayList;
+
/**
* @author Karim Abou Zeid (kabouzeid)
*/
diff --git a/app/src/main/java/code/name/monkey/retromusic/model/Album.kt b/app/src/main/java/code/name/monkey/retromusic/model/Album.kt
index 3796b900..4e5e35a1 100644
--- a/app/src/main/java/code/name/monkey/retromusic/model/Album.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/model/Album.kt
@@ -14,7 +14,7 @@
package code.name.monkey.retromusic.model
-import java.util.ArrayList
+import java.util.*
class Album {
diff --git a/app/src/main/java/code/name/monkey/retromusic/model/Artist.kt b/app/src/main/java/code/name/monkey/retromusic/model/Artist.kt
index 8d8462ef..5cad27b1 100644
--- a/app/src/main/java/code/name/monkey/retromusic/model/Artist.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/model/Artist.kt
@@ -15,7 +15,7 @@
package code.name.monkey.retromusic.model
import code.name.monkey.retromusic.util.MusicUtil
-import java.util.ArrayList
+import java.util.*
class Artist {
val albums: ArrayList?
diff --git a/app/src/main/java/code/name/monkey/retromusic/model/CategoryInfo.java b/app/src/main/java/code/name/monkey/retromusic/model/CategoryInfo.java
index fd90a013..db5b6d63 100644
--- a/app/src/main/java/code/name/monkey/retromusic/model/CategoryInfo.java
+++ b/app/src/main/java/code/name/monkey/retromusic/model/CategoryInfo.java
@@ -16,11 +16,45 @@ package code.name.monkey.retromusic.model;
import android.os.Parcel;
import android.os.Parcelable;
+
import code.name.monkey.retromusic.R;
public class CategoryInfo implements Parcelable {
+ public static final Creator CREATOR = new Creator() {
+ public CategoryInfo createFromParcel(Parcel source) {
+ return new CategoryInfo(source);
+ }
+
+ public CategoryInfo[] newArray(int size) {
+ return new CategoryInfo[size];
+ }
+ };
+ public Category category;
+ public boolean visible;
+
+ public CategoryInfo(Category category, boolean visible) {
+ this.category = category;
+ this.visible = visible;
+ }
+
+
+ private CategoryInfo(Parcel source) {
+ category = (Category) source.readSerializable();
+ visible = source.readInt() == 1;
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeSerializable(category);
+ dest.writeInt(visible ? 1 : 0);
+ }
+
public enum Category {
HOME(R.id.action_home, R.string.home, R.drawable.ic_home_white_24dp),
SONGS(R.id.action_song, R.string.songs, R.drawable.ic_audiotrack_white_24dp),
@@ -43,39 +77,4 @@ public class CategoryInfo implements Parcelable {
this.icon = icon;
}
}
-
- public static final Creator CREATOR = new Creator() {
- public CategoryInfo createFromParcel(Parcel source) {
- return new CategoryInfo(source);
- }
-
- public CategoryInfo[] newArray(int size) {
- return new CategoryInfo[size];
- }
- };
-
- public Category category;
-
- public boolean visible;
-
-
- public CategoryInfo(Category category, boolean visible) {
- this.category = category;
- this.visible = visible;
- }
-
- private CategoryInfo(Parcel source) {
- category = (Category) source.readSerializable();
- visible = source.readInt() == 1;
- }
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- public void writeToParcel(Parcel dest, int flags) {
- dest.writeSerializable(category);
- dest.writeInt(visible ? 1 : 0);
- }
}
diff --git a/app/src/main/java/code/name/monkey/retromusic/model/Playlist.java b/app/src/main/java/code/name/monkey/retromusic/model/Playlist.java
index ae9a6ee1..2b0af369 100644
--- a/app/src/main/java/code/name/monkey/retromusic/model/Playlist.java
+++ b/app/src/main/java/code/name/monkey/retromusic/model/Playlist.java
@@ -17,10 +17,13 @@ package code.name.monkey.retromusic.model;
import android.content.Context;
import android.os.Parcel;
import android.os.Parcelable;
+
import androidx.annotation.NonNull;
-import code.name.monkey.retromusic.loaders.PlaylistSongsLoader;
+
import java.util.ArrayList;
+import code.name.monkey.retromusic.loaders.PlaylistSongsLoader;
+
public class Playlist implements Parcelable {
diff --git a/app/src/main/java/code/name/monkey/retromusic/model/PlaylistSong.java b/app/src/main/java/code/name/monkey/retromusic/model/PlaylistSong.java
index c1bd50b9..01b335bf 100644
--- a/app/src/main/java/code/name/monkey/retromusic/model/PlaylistSong.java
+++ b/app/src/main/java/code/name/monkey/retromusic/model/PlaylistSong.java
@@ -14,9 +14,10 @@
package code.name.monkey.retromusic.model;
-import kotlinx.android.parcel.Parcelize;
import org.jetbrains.annotations.NotNull;
+import kotlinx.android.parcel.Parcelize;
+
/**
* Created by hemanths on 3/4/19
*/
@@ -28,19 +29,19 @@ public class PlaylistSong extends Song {
final int playlistId;
public PlaylistSong(int id,
- @NotNull String title,
- int trackNumber,
- int year,
- long duration,
- @NotNull String data,
- long dateModified,
- int albumId,
- @NotNull String albumName,
- int artistId,
- @NotNull String artistName,
- int playlistId,
- int idInPlayList,
- @NotNull String composer) {
+ @NotNull String title,
+ int trackNumber,
+ int year,
+ long duration,
+ @NotNull String data,
+ long dateModified,
+ int albumId,
+ @NotNull String albumName,
+ int artistId,
+ @NotNull String artistName,
+ int playlistId,
+ int idInPlayList,
+ @NotNull String composer) {
super(id, title, trackNumber, year, duration, data, dateModified, albumId, albumName, artistId, artistName,
composer);
this.playlistId = playlistId;
diff --git a/app/src/main/java/code/name/monkey/retromusic/model/lyrics/Lyrics.java b/app/src/main/java/code/name/monkey/retromusic/model/lyrics/Lyrics.java
index f3efe92d..32bbfd4a 100644
--- a/app/src/main/java/code/name/monkey/retromusic/model/lyrics/Lyrics.java
+++ b/app/src/main/java/code/name/monkey/retromusic/model/lyrics/Lyrics.java
@@ -15,19 +15,21 @@
package code.name.monkey.retromusic.model.lyrics;
-import code.name.monkey.retromusic.model.Song;
import java.util.ArrayList;
+import code.name.monkey.retromusic.model.Song;
+
public class Lyrics {
private static final ArrayList> FORMATS = new ArrayList<>();
+ static {
+ Lyrics.FORMATS.add(SynchronizedLyricsLRC.class);
+ }
+
public String data;
-
public Song song;
-
protected boolean parsed = false;
-
protected boolean valid = false;
public static boolean isSynchronized(String data) {
@@ -82,8 +84,4 @@ public class Lyrics {
this.data = data;
return this;
}
-
- static {
- Lyrics.FORMATS.add(SynchronizedLyricsLRC.class);
- }
}
diff --git a/app/src/main/java/code/name/monkey/retromusic/model/smartplaylist/AbsSmartPlaylist.java b/app/src/main/java/code/name/monkey/retromusic/model/smartplaylist/AbsSmartPlaylist.java
index 12d00acb..0e7338cc 100644
--- a/app/src/main/java/code/name/monkey/retromusic/model/smartplaylist/AbsSmartPlaylist.java
+++ b/app/src/main/java/code/name/monkey/retromusic/model/smartplaylist/AbsSmartPlaylist.java
@@ -16,8 +16,10 @@ package code.name.monkey.retromusic.model.smartplaylist;
import android.content.Context;
import android.os.Parcel;
+
import androidx.annotation.DrawableRes;
import androidx.annotation.Nullable;
+
import code.name.monkey.retromusic.R;
import code.name.monkey.retromusic.model.AbsCustomPlaylist;
diff --git a/app/src/main/java/code/name/monkey/retromusic/model/smartplaylist/HistoryPlaylist.java b/app/src/main/java/code/name/monkey/retromusic/model/smartplaylist/HistoryPlaylist.java
index a7f47a5d..5e5cf7b1 100644
--- a/app/src/main/java/code/name/monkey/retromusic/model/smartplaylist/HistoryPlaylist.java
+++ b/app/src/main/java/code/name/monkey/retromusic/model/smartplaylist/HistoryPlaylist.java
@@ -16,13 +16,17 @@ package code.name.monkey.retromusic.model.smartplaylist;
import android.content.Context;
import android.os.Parcel;
+
import androidx.annotation.NonNull;
+
+import org.jetbrains.annotations.NotNull;
+
+import java.util.ArrayList;
+
import code.name.monkey.retromusic.R;
import code.name.monkey.retromusic.loaders.TopAndRecentlyPlayedTracksLoader;
import code.name.monkey.retromusic.model.Song;
import code.name.monkey.retromusic.providers.HistoryStore;
-import java.util.ArrayList;
-import org.jetbrains.annotations.NotNull;
/**
* @author Karim Abou Zeid (kabouzeid)
diff --git a/app/src/main/java/code/name/monkey/retromusic/model/smartplaylist/LastAddedPlaylist.java b/app/src/main/java/code/name/monkey/retromusic/model/smartplaylist/LastAddedPlaylist.java
index 2d716212..08371a00 100644
--- a/app/src/main/java/code/name/monkey/retromusic/model/smartplaylist/LastAddedPlaylist.java
+++ b/app/src/main/java/code/name/monkey/retromusic/model/smartplaylist/LastAddedPlaylist.java
@@ -16,12 +16,16 @@ package code.name.monkey.retromusic.model.smartplaylist;
import android.content.Context;
import android.os.Parcel;
+
import androidx.annotation.NonNull;
+
+import org.jetbrains.annotations.NotNull;
+
+import java.util.ArrayList;
+
import code.name.monkey.retromusic.R;
import code.name.monkey.retromusic.loaders.LastAddedSongsLoader;
import code.name.monkey.retromusic.model.Song;
-import java.util.ArrayList;
-import org.jetbrains.annotations.NotNull;
public class LastAddedPlaylist extends AbsSmartPlaylist {
diff --git a/app/src/main/java/code/name/monkey/retromusic/model/smartplaylist/MyTopTracksPlaylist.java b/app/src/main/java/code/name/monkey/retromusic/model/smartplaylist/MyTopTracksPlaylist.java
index 7a1346c0..5bff552a 100644
--- a/app/src/main/java/code/name/monkey/retromusic/model/smartplaylist/MyTopTracksPlaylist.java
+++ b/app/src/main/java/code/name/monkey/retromusic/model/smartplaylist/MyTopTracksPlaylist.java
@@ -16,13 +16,17 @@ package code.name.monkey.retromusic.model.smartplaylist;
import android.content.Context;
import android.os.Parcel;
+
import androidx.annotation.NonNull;
+
+import org.jetbrains.annotations.NotNull;
+
+import java.util.ArrayList;
+
import code.name.monkey.retromusic.R;
import code.name.monkey.retromusic.loaders.TopAndRecentlyPlayedTracksLoader;
import code.name.monkey.retromusic.model.Song;
import code.name.monkey.retromusic.providers.SongPlayCountStore;
-import java.util.ArrayList;
-import org.jetbrains.annotations.NotNull;
/**
* @author Karim Abou Zeid (kabouzeid)
diff --git a/app/src/main/java/code/name/monkey/retromusic/model/smartplaylist/ShuffleAllPlaylist.java b/app/src/main/java/code/name/monkey/retromusic/model/smartplaylist/ShuffleAllPlaylist.java
index e3133212..8c26b7af 100644
--- a/app/src/main/java/code/name/monkey/retromusic/model/smartplaylist/ShuffleAllPlaylist.java
+++ b/app/src/main/java/code/name/monkey/retromusic/model/smartplaylist/ShuffleAllPlaylist.java
@@ -16,12 +16,16 @@ package code.name.monkey.retromusic.model.smartplaylist;
import android.content.Context;
import android.os.Parcel;
+
import androidx.annotation.NonNull;
+
+import org.jetbrains.annotations.NotNull;
+
+import java.util.ArrayList;
+
import code.name.monkey.retromusic.R;
import code.name.monkey.retromusic.loaders.SongLoader;
import code.name.monkey.retromusic.model.Song;
-import java.util.ArrayList;
-import org.jetbrains.annotations.NotNull;
public class ShuffleAllPlaylist extends AbsSmartPlaylist {
diff --git a/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/AlbumDetailsPresenter.kt b/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/AlbumDetailsPresenter.kt
index d6fde1bb..8b53f370 100644
--- a/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/AlbumDetailsPresenter.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/AlbumDetailsPresenter.kt
@@ -21,11 +21,7 @@ import code.name.monkey.retromusic.mvp.Presenter
import code.name.monkey.retromusic.mvp.PresenterImpl
import code.name.monkey.retromusic.providers.interfaces.Repository
import code.name.monkey.retromusic.rest.model.LastFmAlbum
-import kotlinx.coroutines.CoroutineScope
-import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.Job
-import kotlinx.coroutines.launch
-import kotlinx.coroutines.withContext
+import kotlinx.coroutines.*
import javax.inject.Inject
import kotlin.coroutines.CoroutineContext
diff --git a/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/AlbumPresenter.kt b/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/AlbumPresenter.kt
index e0b632b9..936fd44b 100644
--- a/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/AlbumPresenter.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/AlbumPresenter.kt
@@ -21,11 +21,7 @@ import code.name.monkey.retromusic.mvp.BaseView
import code.name.monkey.retromusic.mvp.Presenter
import code.name.monkey.retromusic.mvp.PresenterImpl
import code.name.monkey.retromusic.providers.interfaces.Repository
-import kotlinx.coroutines.CoroutineScope
-import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.Job
-import kotlinx.coroutines.launch
-import kotlinx.coroutines.withContext
+import kotlinx.coroutines.*
import javax.inject.Inject
import kotlin.coroutines.CoroutineContext
diff --git a/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/ArtistDetailsPresenter.kt b/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/ArtistDetailsPresenter.kt
index 888114b6..649df094 100644
--- a/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/ArtistDetailsPresenter.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/ArtistDetailsPresenter.kt
@@ -22,12 +22,8 @@ import code.name.monkey.retromusic.mvp.Presenter
import code.name.monkey.retromusic.mvp.PresenterImpl
import code.name.monkey.retromusic.providers.interfaces.Repository
import code.name.monkey.retromusic.rest.model.LastFmArtist
-import kotlinx.coroutines.CoroutineScope
-import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.Job
-import kotlinx.coroutines.launch
-import kotlinx.coroutines.withContext
-import java.util.Locale
+import kotlinx.coroutines.*
+import java.util.*
import javax.inject.Inject
import kotlin.coroutines.CoroutineContext
diff --git a/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/ArtistPresenter.kt b/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/ArtistPresenter.kt
index d78e12d6..42a941da 100644
--- a/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/ArtistPresenter.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/ArtistPresenter.kt
@@ -21,11 +21,7 @@ import code.name.monkey.retromusic.mvp.BaseView
import code.name.monkey.retromusic.mvp.Presenter
import code.name.monkey.retromusic.mvp.PresenterImpl
import code.name.monkey.retromusic.providers.interfaces.Repository
-import kotlinx.coroutines.CoroutineScope
-import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.Job
-import kotlinx.coroutines.launch
-import kotlinx.coroutines.withContext
+import kotlinx.coroutines.*
import javax.inject.Inject
import kotlin.coroutines.CoroutineContext
diff --git a/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/GenreDetailsPresenter.kt b/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/GenreDetailsPresenter.kt
index 5469ddf9..ed664155 100644
--- a/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/GenreDetailsPresenter.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/GenreDetailsPresenter.kt
@@ -21,11 +21,7 @@ import code.name.monkey.retromusic.mvp.BaseView
import code.name.monkey.retromusic.mvp.Presenter
import code.name.monkey.retromusic.mvp.PresenterImpl
import code.name.monkey.retromusic.providers.interfaces.Repository
-import kotlinx.coroutines.CoroutineScope
-import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.Job
-import kotlinx.coroutines.launch
-import kotlinx.coroutines.withContext
+import kotlinx.coroutines.*
import javax.inject.Inject
import kotlin.coroutines.CoroutineContext
diff --git a/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/GenrePresenter.kt b/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/GenrePresenter.kt
index 62d2474c..50f0722c 100644
--- a/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/GenrePresenter.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/GenrePresenter.kt
@@ -21,11 +21,7 @@ import code.name.monkey.retromusic.mvp.BaseView
import code.name.monkey.retromusic.mvp.Presenter
import code.name.monkey.retromusic.mvp.PresenterImpl
import code.name.monkey.retromusic.providers.interfaces.Repository
-import kotlinx.coroutines.CoroutineScope
-import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.Job
-import kotlinx.coroutines.launch
-import kotlinx.coroutines.withContext
+import kotlinx.coroutines.*
import javax.inject.Inject
import kotlin.coroutines.CoroutineContext
diff --git a/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/HomePresenter.kt b/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/HomePresenter.kt
index 1d1f81a9..1bdf66e9 100644
--- a/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/HomePresenter.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/HomePresenter.kt
@@ -20,11 +20,7 @@ import code.name.monkey.retromusic.mvp.BaseView
import code.name.monkey.retromusic.mvp.Presenter
import code.name.monkey.retromusic.mvp.PresenterImpl
import code.name.monkey.retromusic.providers.interfaces.Repository
-import kotlinx.coroutines.CoroutineScope
-import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.Job
-import kotlinx.coroutines.launch
-import kotlinx.coroutines.withContext
+import kotlinx.coroutines.*
import javax.inject.Inject
import kotlin.coroutines.CoroutineContext
diff --git a/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/PlaylistPresenter.kt b/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/PlaylistPresenter.kt
index 2767dc44..dcd8d921 100644
--- a/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/PlaylistPresenter.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/PlaylistPresenter.kt
@@ -20,11 +20,7 @@ import code.name.monkey.retromusic.mvp.BaseView
import code.name.monkey.retromusic.mvp.Presenter
import code.name.monkey.retromusic.mvp.PresenterImpl
import code.name.monkey.retromusic.providers.interfaces.Repository
-import kotlinx.coroutines.CoroutineScope
-import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.Job
-import kotlinx.coroutines.launch
-import kotlinx.coroutines.withContext
+import kotlinx.coroutines.*
import javax.inject.Inject
import kotlin.coroutines.CoroutineContext
diff --git a/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/PlaylistSongsPresenter.kt b/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/PlaylistSongsPresenter.kt
index 20b43388..d02bc52a 100644
--- a/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/PlaylistSongsPresenter.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/PlaylistSongsPresenter.kt
@@ -22,11 +22,7 @@ import code.name.monkey.retromusic.mvp.BaseView
import code.name.monkey.retromusic.mvp.Presenter
import code.name.monkey.retromusic.mvp.PresenterImpl
import code.name.monkey.retromusic.providers.interfaces.Repository
-import kotlinx.coroutines.CoroutineScope
-import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.Job
-import kotlinx.coroutines.launch
-import kotlinx.coroutines.withContext
+import kotlinx.coroutines.*
import javax.inject.Inject
import kotlin.coroutines.CoroutineContext
diff --git a/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/SearchPresenter.kt b/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/SearchPresenter.kt
index d920bb90..b371cb7b 100644
--- a/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/SearchPresenter.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/SearchPresenter.kt
@@ -20,11 +20,7 @@ import code.name.monkey.retromusic.mvp.BaseView
import code.name.monkey.retromusic.mvp.Presenter
import code.name.monkey.retromusic.mvp.PresenterImpl
import code.name.monkey.retromusic.providers.interfaces.Repository
-import kotlinx.coroutines.CoroutineScope
-import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.Job
-import kotlinx.coroutines.launch
-import kotlinx.coroutines.withContext
+import kotlinx.coroutines.*
import javax.inject.Inject
import kotlin.coroutines.CoroutineContext
diff --git a/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/SongPresenter.kt b/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/SongPresenter.kt
index bf076302..ceb6b45c 100644
--- a/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/SongPresenter.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/SongPresenter.kt
@@ -19,11 +19,7 @@ import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.mvp.Presenter
import code.name.monkey.retromusic.mvp.PresenterImpl
import code.name.monkey.retromusic.providers.interfaces.Repository
-import kotlinx.coroutines.CoroutineScope
-import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.Job
-import kotlinx.coroutines.launch
-import kotlinx.coroutines.withContext
+import kotlinx.coroutines.*
import javax.inject.Inject
import kotlin.coroutines.CoroutineContext
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 900404b0..89592f28 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
@@ -35,10 +35,7 @@ import code.name.monkey.retromusic.App
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.extensions.colorControlNormal
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.fragments.AlbumCoverStyle.*
import code.name.monkey.retromusic.util.NavigationUtil
import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.ViewUtil
@@ -61,11 +58,15 @@ class AlbumCoverStylePreference @JvmOverloads constructor(
init {
icon?.colorFilter =
- BlendModeColorFilterCompat.createBlendModeColorFilterCompat(colorControlNormal(context), SRC_IN)
+ BlendModeColorFilterCompat.createBlendModeColorFilterCompat(
+ colorControlNormal(context),
+ SRC_IN
+ )
}
}
-class AlbumCoverStylePreferenceDialog : PreferenceDialogFragmentCompat(), ViewPager.OnPageChangeListener {
+class AlbumCoverStylePreferenceDialog : PreferenceDialogFragmentCompat(),
+ ViewPager.OnPageChangeListener {
override fun onDialogClosed(positiveResult: Boolean) {
}
@@ -73,7 +74,8 @@ class AlbumCoverStylePreferenceDialog : PreferenceDialogFragmentCompat(), ViewPa
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
@SuppressLint("InflateParams") val view =
- LayoutInflater.from(activity).inflate(R.layout.preference_dialog_now_playing_screen, null)
+ LayoutInflater.from(activity)
+ .inflate(R.layout.preference_dialog_now_playing_screen, null)
val viewPager = view.findViewById(R.id.now_playing_screen_view_pager)
viewPager.adapter = AlbumCoverStyleAdapter(activity!!)
viewPager.addOnPageChangeListener(this)
@@ -109,13 +111,18 @@ class AlbumCoverStylePreferenceDialog : PreferenceDialogFragmentCompat(), ViewPa
override fun onPageScrollStateChanged(state: Int) {
}
- private class AlbumCoverStyleAdapter internal constructor(private val context: Context) : PagerAdapter() {
+ private class AlbumCoverStyleAdapter internal constructor(private val context: Context) :
+ PagerAdapter() {
override fun instantiateItem(collection: ViewGroup, position: Int): Any {
val albumCoverStyle = values()[position]
val inflater = LayoutInflater.from(context)
- val layout = inflater.inflate(R.layout.preference_now_playing_screen_item, collection, false) as ViewGroup
+ val layout = inflater.inflate(
+ R.layout.preference_now_playing_screen_item,
+ collection,
+ false
+ ) as ViewGroup
collection.addView(layout)
val image = layout.findViewById(R.id.image)
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 1d4fab50..e0681d61 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
@@ -33,7 +33,7 @@ import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
import com.afollestad.materialdialogs.list.listItems
import java.io.File
-import java.util.ArrayList
+import java.util.*
class BlacklistPreference @JvmOverloads constructor(
context: Context,
@@ -44,7 +44,10 @@ class BlacklistPreference @JvmOverloads constructor(
init {
icon?.colorFilter =
- BlendModeColorFilterCompat.createBlendModeColorFilterCompat(colorControlNormal(context), SRC_IN)
+ BlendModeColorFilterCompat.createBlendModeColorFilterCompat(
+ colorControlNormal(context),
+ SRC_IN
+ )
}
}
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 b07aa0a5..cec2e2f6 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
@@ -34,7 +34,7 @@ import com.afollestad.materialdialogs.LayoutMode
import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
import com.afollestad.materialdialogs.customview.customView
-import java.util.ArrayList
+import java.util.*
class LibraryPreference @JvmOverloads constructor(
context: Context,
@@ -46,7 +46,10 @@ class LibraryPreference @JvmOverloads constructor(
init {
icon?.colorFilter =
- BlendModeColorFilterCompat.createBlendModeColorFilterCompat(colorControlNormal(context), SRC_IN)
+ BlendModeColorFilterCompat.createBlendModeColorFilterCompat(
+ colorControlNormal(context),
+ SRC_IN
+ )
}
}
@@ -58,7 +61,10 @@ class LibraryPreferenceDialog : PreferenceDialogFragmentCompat() {
lateinit var adapter: CategoryInfoAdapter
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
- val view = requireActivity().layoutInflater.inflate(R.layout.preference_dialog_library_categories, null)
+ val view = requireActivity().layoutInflater.inflate(
+ R.layout.preference_dialog_library_categories,
+ null
+ )
val categoryInfos: List = if (savedInstanceState != null) {
savedInstanceState.getParcelableArrayList(PreferenceUtil.LIBRARY_CATEGORIES)!!
@@ -85,14 +91,18 @@ class LibraryPreferenceDialog : PreferenceDialogFragmentCompat() {
dismiss()
}
.neutralButton(R.string.reset_action) {
- adapter.categoryInfos = PreferenceUtil.getInstance(requireContext()).defaultLibraryCategoryInfos
+ adapter.categoryInfos =
+ PreferenceUtil.getInstance(requireContext()).defaultLibraryCategoryInfos
}
.noAutoDismiss()
}
override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
- outState.putParcelableArrayList(PreferenceUtil.LIBRARY_CATEGORIES, ArrayList(adapter.categoryInfos))
+ outState.putParcelableArrayList(
+ PreferenceUtil.LIBRARY_CATEGORIES,
+ ArrayList(adapter.categoryInfos)
+ )
}
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 1eb98ce5..2ef3b5af 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
@@ -34,16 +34,7 @@ import code.name.monkey.retromusic.App
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.extensions.colorControlNormal
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.fragments.NowPlayingScreen.*
import code.name.monkey.retromusic.util.NavigationUtil
import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.ViewUtil
@@ -72,7 +63,8 @@ class NowPlayingScreenPreference @JvmOverloads constructor(
}
}
-class NowPlayingScreenPreferenceDialog : PreferenceDialogFragmentCompat(), ViewPager.OnPageChangeListener {
+class NowPlayingScreenPreferenceDialog : PreferenceDialogFragmentCompat(),
+ ViewPager.OnPageChangeListener {
private var viewPagerPosition: Int = 0
@@ -90,13 +82,15 @@ class NowPlayingScreenPreferenceDialog : PreferenceDialogFragmentCompat(), ViewP
}
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
- val view = LayoutInflater.from(activity).inflate(R.layout.preference_dialog_now_playing_screen, null)
+ val view = LayoutInflater.from(activity)
+ .inflate(R.layout.preference_dialog_now_playing_screen, null)
val viewPager = view.findViewById(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(requireContext())
viewPager.addOnPageChangeListener(this)
viewPager.pageMargin = ViewUtil.convertDpToPixel(32f, resources).toInt()
- viewPager.currentItem = PreferenceUtil.getInstance(requireContext()).nowPlayingScreen.ordinal
+ viewPager.currentItem =
+ PreferenceUtil.getInstance(requireContext()).nowPlayingScreen.ordinal
return MaterialDialog(requireContext()).show {
@@ -104,7 +98,8 @@ class NowPlayingScreenPreferenceDialog : PreferenceDialogFragmentCompat(), ViewP
positiveButton(R.string.set) {
val nowPlayingScreen = values()[viewPagerPosition]
if (isNowPlayingThemes(nowPlayingScreen)) {
- val result = getString(nowPlayingScreen.titleRes) + " theme is Pro version feature."
+ val result =
+ getString(nowPlayingScreen.titleRes) + " theme is Pro version feature."
Toast.makeText(context, result, Toast.LENGTH_SHORT).show()
NavigationUtil.goToProVersion(activity!!)
} else {
@@ -134,7 +129,11 @@ private class NowPlayingScreenAdapter(private val context: Context) : PagerAdapt
val nowPlayingScreen = values()[position]
val inflater = LayoutInflater.from(context)
- val layout = inflater.inflate(R.layout.preference_now_playing_screen_item, collection, false) as ViewGroup
+ val layout = inflater.inflate(
+ R.layout.preference_now_playing_screen_item,
+ collection,
+ false
+ ) as ViewGroup
collection.addView(layout)
val image = layout.findViewById(R.id.image)
diff --git a/app/src/main/java/code/name/monkey/retromusic/providers/HistoryStore.java b/app/src/main/java/code/name/monkey/retromusic/providers/HistoryStore.java
index c6708f44..0e283f3d 100644
--- a/app/src/main/java/code/name/monkey/retromusic/providers/HistoryStore.java
+++ b/app/src/main/java/code/name/monkey/retromusic/providers/HistoryStore.java
@@ -19,6 +19,7 @@ import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
+
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
diff --git a/app/src/main/java/code/name/monkey/retromusic/providers/MusicPlaybackQueueStore.java b/app/src/main/java/code/name/monkey/retromusic/providers/MusicPlaybackQueueStore.java
index 935d2689..528ca7e9 100644
--- a/app/src/main/java/code/name/monkey/retromusic/providers/MusicPlaybackQueueStore.java
+++ b/app/src/main/java/code/name/monkey/retromusic/providers/MusicPlaybackQueueStore.java
@@ -20,11 +20,14 @@ import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.provider.BaseColumns;
import android.provider.MediaStore.Audio.AudioColumns;
+
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
+
+import java.util.ArrayList;
+
import code.name.monkey.retromusic.loaders.SongLoader;
import code.name.monkey.retromusic.model.Song;
-import java.util.ArrayList;
/**
* @author Andrew Neal, modified for Phonograph by Karim Abou Zeid
@@ -44,6 +47,15 @@ public class MusicPlaybackQueueStore extends SQLiteOpenHelper {
@Nullable
private static MusicPlaybackQueueStore sInstance = null;
+ /**
+ * Constructor of MusicPlaybackState
+ *
+ * @param context The {@link Context} to use
+ */
+ public MusicPlaybackQueueStore(final @NonNull Context context) {
+ super(context, DATABASE_NAME, null, VERSION);
+ }
+
/**
* @param context The {@link Context} to use
* @return A new instance of this class.
@@ -56,15 +68,6 @@ public class MusicPlaybackQueueStore extends SQLiteOpenHelper {
return sInstance;
}
- /**
- * Constructor of MusicPlaybackState
- *
- * @param context The {@link Context} to use
- */
- public MusicPlaybackQueueStore(final @NonNull Context context) {
- super(context, DATABASE_NAME, null, VERSION);
- }
-
@Override
public void onCreate(@NonNull final SQLiteDatabase db) {
createTable(db, PLAYING_QUEUE_TABLE_NAME);
@@ -98,7 +101,7 @@ public class MusicPlaybackQueueStore extends SQLiteOpenHelper {
}
public synchronized void saveQueues(@NonNull final ArrayList playingQueue,
- @NonNull final ArrayList originalPlayingQueue) {
+ @NonNull final ArrayList originalPlayingQueue) {
saveQueue(PLAYING_QUEUE_TABLE_NAME, playingQueue);
saveQueue(ORIGINAL_PLAYING_QUEUE_TABLE_NAME, originalPlayingQueue);
}
diff --git a/app/src/main/java/code/name/monkey/retromusic/providers/RepositoryImpl.kt b/app/src/main/java/code/name/monkey/retromusic/providers/RepositoryImpl.kt
index 20a1b3b3..91d4f947 100644
--- a/app/src/main/java/code/name/monkey/retromusic/providers/RepositoryImpl.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/providers/RepositoryImpl.kt
@@ -20,22 +20,8 @@ import code.name.monkey.retromusic.Result
import code.name.monkey.retromusic.Result.Error
import code.name.monkey.retromusic.Result.Success
import code.name.monkey.retromusic.adapter.HomeAdapter
-import code.name.monkey.retromusic.loaders.AlbumLoader
-import code.name.monkey.retromusic.loaders.ArtistLoader
-import code.name.monkey.retromusic.loaders.GenreLoader
-import code.name.monkey.retromusic.loaders.LastAddedSongsLoader
-import code.name.monkey.retromusic.loaders.PlaylistLoader
-import code.name.monkey.retromusic.loaders.PlaylistSongsLoader
-import code.name.monkey.retromusic.loaders.SearchLoader
-import code.name.monkey.retromusic.loaders.SongLoader
-import code.name.monkey.retromusic.loaders.TopAndRecentlyPlayedTracksLoader
-import code.name.monkey.retromusic.model.AbsCustomPlaylist
-import code.name.monkey.retromusic.model.Album
-import code.name.monkey.retromusic.model.Artist
-import code.name.monkey.retromusic.model.Genre
-import code.name.monkey.retromusic.model.Home
-import code.name.monkey.retromusic.model.Playlist
-import code.name.monkey.retromusic.model.Song
+import code.name.monkey.retromusic.loaders.*
+import code.name.monkey.retromusic.model.*
import code.name.monkey.retromusic.providers.interfaces.Repository
import code.name.monkey.retromusic.rest.LastFMRestClient
import code.name.monkey.retromusic.rest.model.LastFmAlbum
@@ -299,8 +285,9 @@ class RepositoryImpl @Inject constructor(private val context: Context) : Reposit
}
}
-suspend fun safeApiCall(call: suspend () -> Result, errorMessage: String): Result = try {
- call.invoke()
-} catch (e: Exception) {
- Error(IOException(errorMessage, e))
-}
+suspend fun safeApiCall(call: suspend () -> Result, errorMessage: String): Result =
+ try {
+ call.invoke()
+ } catch (e: Exception) {
+ Error(IOException(errorMessage, e))
+ }
diff --git a/app/src/main/java/code/name/monkey/retromusic/providers/interfaces/Repository.kt b/app/src/main/java/code/name/monkey/retromusic/providers/interfaces/Repository.kt
index aec8eaea..a3e9f4d8 100644
--- a/app/src/main/java/code/name/monkey/retromusic/providers/interfaces/Repository.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/providers/interfaces/Repository.kt
@@ -15,12 +15,7 @@
package code.name.monkey.retromusic.providers.interfaces
import code.name.monkey.retromusic.Result
-import code.name.monkey.retromusic.model.Album
-import code.name.monkey.retromusic.model.Artist
-import code.name.monkey.retromusic.model.Genre
-import code.name.monkey.retromusic.model.Home
-import code.name.monkey.retromusic.model.Playlist
-import code.name.monkey.retromusic.model.Song
+import code.name.monkey.retromusic.model.*
import code.name.monkey.retromusic.rest.model.LastFmAlbum
import code.name.monkey.retromusic.rest.model.LastFmArtist
diff --git a/app/src/main/java/code/name/monkey/retromusic/rest/LastFMRestClient.java b/app/src/main/java/code/name/monkey/retromusic/rest/LastFMRestClient.java
index d5c67f09..8e1113ea 100644
--- a/app/src/main/java/code/name/monkey/retromusic/rest/LastFMRestClient.java
+++ b/app/src/main/java/code/name/monkey/retromusic/rest/LastFMRestClient.java
@@ -15,11 +15,14 @@
package code.name.monkey.retromusic.rest;
import android.content.Context;
+
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-import code.name.monkey.retromusic.rest.service.LastFMService;
+
import java.io.File;
import java.util.concurrent.TimeUnit;
+
+import code.name.monkey.retromusic.rest.service.LastFMService;
import okhttp3.Cache;
import okhttp3.Call;
import okhttp3.ConnectionPool;
@@ -51,11 +54,6 @@ public class LastFMRestClient {
apiService = restAdapter.create(LastFMService.class);
}
- @NonNull
- public LastFMService getApiService() {
- return apiService;
- }
-
private static Interceptor createCacheControlInterceptor() {
return chain -> {
Request modifiedRequest = chain.request().newBuilder()
@@ -93,4 +91,9 @@ public class LastFMRestClient {
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
return interceptor;
}
+
+ @NonNull
+ public LastFMService getApiService() {
+ return apiService;
+ }
}
diff --git a/app/src/main/java/code/name/monkey/retromusic/rest/model/LastFmAlbum.java b/app/src/main/java/code/name/monkey/retromusic/rest/model/LastFmAlbum.java
index ae4da518..7c3ca35e 100644
--- a/app/src/main/java/code/name/monkey/retromusic/rest/model/LastFmAlbum.java
+++ b/app/src/main/java/code/name/monkey/retromusic/rest/model/LastFmAlbum.java
@@ -16,13 +16,82 @@ package code.name.monkey.retromusic.rest.model;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
+
import java.util.ArrayList;
import java.util.List;
public class LastFmAlbum {
+ @Expose
+ private Album album;
+
+ public Album getAlbum() {
+ return album;
+ }
+
+ public void setAlbum(Album album) {
+ this.album = album;
+ }
+
public static class Album {
+ @Expose
+ public String listeners;
+ @Expose
+ public String playcount;
+ @Expose
+ private List image = new ArrayList<>();
+ @Expose
+ private String name;
+ @Expose
+ private Tags tags;
+ @Expose
+ private Wiki wiki;
+
+ public List getImage() {
+ return image;
+ }
+
+ public void setImage(List image) {
+ this.image = image;
+ }
+
+ public String getListeners() {
+ return listeners;
+ }
+
+ public void setListeners(final String listeners) {
+ this.listeners = listeners;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ public String getPlaycount() {
+ return playcount;
+ }
+
+ public void setPlaycount(final String playcount) {
+ this.playcount = playcount;
+ }
+
+ public Tags getTags() {
+ return tags;
+ }
+
+ public Wiki getWiki() {
+ return wiki;
+ }
+
+ public void setWiki(Wiki wiki) {
+ this.wiki = wiki;
+ }
+
public static class Image {
@SerializedName("#text")
@@ -100,78 +169,5 @@ public class LastFmAlbum {
this.published = published;
}
}
-
- @Expose
- public String listeners;
-
- @Expose
- public String playcount;
-
- @Expose
- private List image = new ArrayList<>();
-
- @Expose
- private String name;
-
- @Expose
- private Tags tags;
-
- @Expose
- private Wiki wiki;
-
- public List getImage() {
- return image;
- }
-
- public void setImage(List image) {
- this.image = image;
- }
-
- public String getListeners() {
- return listeners;
- }
-
- public void setListeners(final String listeners) {
- this.listeners = listeners;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(final String name) {
- this.name = name;
- }
-
- public String getPlaycount() {
- return playcount;
- }
-
- public void setPlaycount(final String playcount) {
- this.playcount = playcount;
- }
-
- public Tags getTags() {
- return tags;
- }
-
- public Wiki getWiki() {
- return wiki;
- }
-
- public void setWiki(Wiki wiki) {
- this.wiki = wiki;
- }
- }
-
- @Expose
- private Album album;
-
- public Album getAlbum() {
- return album;
- }
-
- public void setAlbum(Album album) {
- this.album = album;
}
}
diff --git a/app/src/main/java/code/name/monkey/retromusic/rest/model/LastFmArtist.java b/app/src/main/java/code/name/monkey/retromusic/rest/model/LastFmArtist.java
index 4afc19cd..84de1182 100644
--- a/app/src/main/java/code/name/monkey/retromusic/rest/model/LastFmArtist.java
+++ b/app/src/main/java/code/name/monkey/retromusic/rest/model/LastFmArtist.java
@@ -16,13 +16,48 @@ package code.name.monkey.retromusic.rest.model;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
+
import java.util.ArrayList;
import java.util.List;
public class LastFmArtist {
+ @Expose
+ private Artist artist;
+
+ public Artist getArtist() {
+ return artist;
+ }
+
+ public void setArtist(Artist artist) {
+ this.artist = artist;
+ }
+
public static class Artist {
+ @Expose
+ public Stats stats;
+ @Expose
+ private Bio bio;
+ @Expose
+ private List image = new ArrayList<>();
+
+ public Bio getBio() {
+ return bio;
+ }
+
+ public void setBio(Bio bio) {
+ this.bio = bio;
+ }
+
+ public List getImage() {
+ return image;
+ }
+
+ public void setImage(List image) {
+ this.image = image;
+ }
+
public static class Image {
@SerializedName("#text")
@@ -87,41 +122,5 @@ public class LastFmArtist {
this.content = content;
}
}
-
- @Expose
- public Stats stats;
-
- @Expose
- private Bio bio;
-
- @Expose
- private List image = new ArrayList<>();
-
- public Bio getBio() {
- return bio;
- }
-
- public void setBio(Bio bio) {
- this.bio = bio;
- }
-
- public List getImage() {
- return image;
- }
-
- public void setImage(List image) {
- this.image = image;
- }
- }
-
- @Expose
- private Artist artist;
-
- public Artist getArtist() {
- return artist;
- }
-
- public void setArtist(Artist artist) {
- this.artist = artist;
}
}
diff --git a/app/src/main/java/code/name/monkey/retromusic/service/MediaButtonIntentReceiver.kt b/app/src/main/java/code/name/monkey/retromusic/service/MediaButtonIntentReceiver.kt
index 09c282a7..d77a7d75 100644
--- a/app/src/main/java/code/name/monkey/retromusic/service/MediaButtonIntentReceiver.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/service/MediaButtonIntentReceiver.kt
@@ -87,7 +87,7 @@ class MediaButtonIntentReceiver : BroadcastReceiver() {
val intentAction = intent.action
if (Intent.ACTION_MEDIA_BUTTON == intentAction) {
val event = intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT)
- ?: return false
+ ?: return false
val keycode = event.keyCode
val action = event.action
@@ -99,7 +99,8 @@ class MediaButtonIntentReceiver : BroadcastReceiver() {
var command: String? = null
when (keycode) {
KeyEvent.KEYCODE_MEDIA_STOP -> command = ACTION_STOP
- KeyEvent.KEYCODE_HEADSETHOOK, KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE -> command = ACTION_TOGGLE_PAUSE
+ KeyEvent.KEYCODE_HEADSETHOOK, KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE -> command =
+ ACTION_TOGGLE_PAUSE
KeyEvent.KEYCODE_MEDIA_NEXT -> command = ACTION_SKIP
KeyEvent.KEYCODE_MEDIA_PREVIOUS -> command = ACTION_REWIND
KeyEvent.KEYCODE_MEDIA_PAUSE -> command = ACTION_PAUSE
@@ -125,7 +126,8 @@ class MediaButtonIntentReceiver : BroadcastReceiver() {
mHandler.removeMessages(MSG_HEADSET_DOUBLE_CLICK_TIMEOUT)
val msg = mHandler.obtainMessage(
- MSG_HEADSET_DOUBLE_CLICK_TIMEOUT, mClickCounter, 0, context)
+ MSG_HEADSET_DOUBLE_CLICK_TIMEOUT, mClickCounter, 0, context
+ )
val delay = (if (mClickCounter < 3) DOUBLE_CLICK else 0).toLong()
if (mClickCounter >= 3) {
@@ -164,7 +166,10 @@ class MediaButtonIntentReceiver : BroadcastReceiver() {
if (wakeLock == null) {
val appContext = context.applicationContext
val pm = appContext.getSystemService(Context.POWER_SERVICE) as PowerManager
- wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "RetroMusicApp:Wakelock headset button")
+ wakeLock = pm.newWakeLock(
+ PowerManager.PARTIAL_WAKE_LOCK,
+ "RetroMusicApp:Wakelock headset button"
+ )
wakeLock!!.setReferenceCounted(false)
}
if (DEBUG) Log.v(TAG, "Acquiring wake lock and sending " + msg.what)
diff --git a/app/src/main/java/code/name/monkey/retromusic/service/MediaSessionCallback.kt b/app/src/main/java/code/name/monkey/retromusic/service/MediaSessionCallback.kt
index ce823ffe..00ed323b 100644
--- a/app/src/main/java/code/name/monkey/retromusic/service/MediaSessionCallback.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/service/MediaSessionCallback.kt
@@ -30,8 +30,9 @@ import java.util.*
* Created by hemanths on 2019-08-01.
*/
-class MediaSessionCallback(private val context: Context,
- private val musicService: MusicService
+class MediaSessionCallback(
+ private val context: Context,
+ private val musicService: MusicService
) : MediaSessionCompat.Callback() {
override fun onPlay() {
diff --git a/app/src/main/java/code/name/monkey/retromusic/service/MediaStoreObserver.kt b/app/src/main/java/code/name/monkey/retromusic/service/MediaStoreObserver.kt
index 5aad0f00..27a6c3cc 100644
--- a/app/src/main/java/code/name/monkey/retromusic/service/MediaStoreObserver.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/service/MediaStoreObserver.kt
@@ -18,8 +18,8 @@ import android.database.ContentObserver
import android.os.Handler
class MediaStoreObserver(
- private val musicService: MusicService,
- private val mHandler: Handler
+ private val musicService: MusicService,
+ private val mHandler: Handler
) : ContentObserver(mHandler), Runnable {
override fun onChange(selfChange: Boolean) {
diff --git a/app/src/main/java/code/name/monkey/retromusic/service/MultiPlayer.java b/app/src/main/java/code/name/monkey/retromusic/service/MultiPlayer.java
index d8ecf574..9bc0078e 100644
--- a/app/src/main/java/code/name/monkey/retromusic/service/MultiPlayer.java
+++ b/app/src/main/java/code/name/monkey/retromusic/service/MultiPlayer.java
@@ -21,11 +21,12 @@ import android.media.MediaPlayer;
import android.media.audiofx.AudioEffect;
import android.net.Uri;
import android.os.PowerManager;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import android.util.Log;
import android.widget.Toast;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
import code.name.monkey.retromusic.R;
import code.name.monkey.retromusic.service.playback.Playback;
import code.name.monkey.retromusic.util.PreferenceUtil;
diff --git a/app/src/main/java/code/name/monkey/retromusic/service/MusicService.java b/app/src/main/java/code/name/monkey/retromusic/service/MusicService.java
index 9218131d..148ff5e7 100644
--- a/app/src/main/java/code/name/monkey/retromusic/service/MusicService.java
+++ b/app/src/main/java/code/name/monkey/retromusic/service/MusicService.java
@@ -47,9 +47,21 @@ import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.widget.Toast;
+
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.preference.PreferenceManager;
+
+import com.bumptech.glide.BitmapRequestBuilder;
+import com.bumptech.glide.Glide;
+import com.bumptech.glide.request.animation.GlideAnimation;
+import com.bumptech.glide.request.target.SimpleTarget;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+import java.util.Random;
+
import code.name.monkey.retromusic.R;
import code.name.monkey.retromusic.appwidgets.AppWidgetBig;
import code.name.monkey.retromusic.appwidgets.AppWidgetCard;
@@ -71,14 +83,6 @@ import code.name.monkey.retromusic.service.playback.Playback;
import code.name.monkey.retromusic.util.MusicUtil;
import code.name.monkey.retromusic.util.PreferenceUtil;
import code.name.monkey.retromusic.util.RetroUtil;
-import com.bumptech.glide.BitmapRequestBuilder;
-import com.bumptech.glide.Glide;
-import com.bumptech.glide.request.animation.GlideAnimation;
-import com.bumptech.glide.request.target.SimpleTarget;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
-import java.util.Random;
/**
* @author Karim Abou Zeid (kabouzeid), Andrew Neal
@@ -86,107 +90,53 @@ import java.util.Random;
public class MusicService extends Service implements
SharedPreferences.OnSharedPreferenceChangeListener, Playback.PlaybackCallbacks {
- public class MusicBinder extends Binder {
-
- @NonNull
- public MusicService getService() {
- return MusicService.this;
- }
- }
-
public static final String TAG = MusicService.class.getSimpleName();
-
public static final String RETRO_MUSIC_PACKAGE_NAME = "code.name.monkey.retromusic";
-
public static final String MUSIC_PACKAGE_NAME = "com.android.music";
-
public static final String ACTION_TOGGLE_PAUSE = RETRO_MUSIC_PACKAGE_NAME + ".togglepause";
-
public static final String ACTION_PLAY = RETRO_MUSIC_PACKAGE_NAME + ".play";
-
public static final String ACTION_PLAY_PLAYLIST = RETRO_MUSIC_PACKAGE_NAME + ".play.playlist";
-
public static final String ACTION_PAUSE = RETRO_MUSIC_PACKAGE_NAME + ".pause";
-
public static final String ACTION_STOP = RETRO_MUSIC_PACKAGE_NAME + ".stop";
-
public static final String ACTION_SKIP = RETRO_MUSIC_PACKAGE_NAME + ".skip";
-
public static final String ACTION_REWIND = RETRO_MUSIC_PACKAGE_NAME + ".rewind";
-
public static final String ACTION_QUIT = RETRO_MUSIC_PACKAGE_NAME + ".quitservice";
-
public static final String ACTION_PENDING_QUIT = RETRO_MUSIC_PACKAGE_NAME + ".pendingquitservice";
-
public static final String INTENT_EXTRA_PLAYLIST = RETRO_MUSIC_PACKAGE_NAME + "intentextra.playlist";
-
public static final String INTENT_EXTRA_SHUFFLE_MODE = RETRO_MUSIC_PACKAGE_NAME + ".intentextra.shufflemode";
-
public static final String APP_WIDGET_UPDATE = RETRO_MUSIC_PACKAGE_NAME + ".appwidgetupdate";
-
public static final String EXTRA_APP_WIDGET_NAME = RETRO_MUSIC_PACKAGE_NAME + "app_widget_name";
-
// Do not change these three strings as it will break support with other apps (e.g. last.fm scrobbling)
public static final String META_CHANGED = RETRO_MUSIC_PACKAGE_NAME + ".metachanged";
-
public static final String QUEUE_CHANGED = RETRO_MUSIC_PACKAGE_NAME + ".queuechanged";
-
public static final String PLAY_STATE_CHANGED = RETRO_MUSIC_PACKAGE_NAME + ".playstatechanged";
-
public static final String FAVORITE_STATE_CHANGED = RETRO_MUSIC_PACKAGE_NAME + "favoritestatechanged";
-
public static final String REPEAT_MODE_CHANGED = RETRO_MUSIC_PACKAGE_NAME + ".repeatmodechanged";
-
public static final String SHUFFLE_MODE_CHANGED = RETRO_MUSIC_PACKAGE_NAME + ".shufflemodechanged";
-
public static final String MEDIA_STORE_CHANGED = RETRO_MUSIC_PACKAGE_NAME + ".mediastorechanged";
-
public static final String CYCLE_REPEAT = RETRO_MUSIC_PACKAGE_NAME + ".cyclerepeat";
-
public static final String TOGGLE_SHUFFLE = RETRO_MUSIC_PACKAGE_NAME + ".toggleshuffle";
-
public static final String TOGGLE_FAVORITE = RETRO_MUSIC_PACKAGE_NAME + ".togglefavorite";
-
public static final String SAVED_POSITION = "POSITION";
-
public static final String SAVED_POSITION_IN_TRACK = "POSITION_IN_TRACK";
-
public static final String SAVED_SHUFFLE_MODE = "SHUFFLE_MODE";
-
public static final String SAVED_REPEAT_MODE = "REPEAT_MODE";
-
public static final int RELEASE_WAKELOCK = 0;
-
public static final int TRACK_ENDED = 1;
-
public static final int TRACK_WENT_TO_NEXT = 2;
-
public static final int PLAY_SONG = 3;
-
public static final int PREPARE_NEXT = 4;
-
public static final int SET_POSITION = 5;
-
public static final int FOCUS_CHANGE = 6;
-
public static final int DUCK = 7;
-
public static final int UNDUCK = 8;
-
public static final int RESTORE_QUEUES = 9;
-
public static final int SHUFFLE_MODE_NONE = 0;
-
public static final int SHUFFLE_MODE_SHUFFLE = 1;
-
public static final int REPEAT_MODE_NONE = 0;
-
public static final int REPEAT_MODE_ALL = 1;
-
public static final int REPEAT_MODE_THIS = 2;
-
public static final int SAVE_QUEUES = 0;
-
private static final long MEDIA_SESSION_ACTIONS = PlaybackStateCompat.ACTION_PLAY
| PlaybackStateCompat.ACTION_PAUSE
| PlaybackStateCompat.ACTION_PLAY_PAUSE
@@ -194,7 +144,7 @@ public class MusicService extends Service implements
| PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS
| PlaybackStateCompat.ACTION_STOP
| PlaybackStateCompat.ACTION_SEEK_TO;
-
+ private final IBinder musicBind = new MusicBinder();
public int nextPosition = -1;
public boolean pendingQuit = false;
@@ -213,144 +163,6 @@ public class MusicService extends Service implements
private AppWidgetSmall appWidgetSmall = AppWidgetSmall.Companion.getInstance();
private AppWidgetText appWidgetText = AppWidgetText.Companion.getInstance();
-
- private AudioManager audioManager;
-
- private IntentFilter becomingNoisyReceiverIntentFilter = new IntentFilter(
- AudioManager.ACTION_AUDIO_BECOMING_NOISY);
-
- private boolean becomingNoisyReceiverRegistered;
-
- private IntentFilter bluetoothConnectedIntentFilter = new IntentFilter(BluetoothDevice.ACTION_ACL_CONNECTED);
-
- private boolean bluetoothConnectedRegistered = false;
-
- private IntentFilter headsetReceiverIntentFilter = new IntentFilter(Intent.ACTION_HEADSET_PLUG);
-
- private boolean headsetReceiverRegistered = false;
-
- private MediaSessionCompat mediaSession;
-
- private ContentObserver mediaStoreObserver;
-
- private final IBinder musicBind = new MusicBinder();
-
- private HandlerThread musicPlayerHandlerThread;
-
- private boolean notHandledMetaChangedForCurrentTrack;
-
- private ArrayList originalPlayingQueue = new ArrayList<>();
-
- private boolean pausedByTransientLossOfFocus;
-
- private final BroadcastReceiver becomingNoisyReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, @NonNull Intent intent) {
- if (intent.getAction() != null && intent.getAction().equals(AudioManager.ACTION_AUDIO_BECOMING_NOISY)) {
- pause();
- }
- }
- };
-
- private PlaybackHandler playerHandler;
-
- private final AudioManager.OnAudioFocusChangeListener audioFocusListener
- = new AudioManager.OnAudioFocusChangeListener() {
- @Override
- public void onAudioFocusChange(final int focusChange) {
- playerHandler.obtainMessage(FOCUS_CHANGE, focusChange, 0).sendToTarget();
- }
- };
-
- private PlayingNotification playingNotification;
-
- private ArrayList playingQueue = new ArrayList<>();
-
- private QueueSaveHandler queueSaveHandler;
-
- private HandlerThread queueSaveHandlerThread;
-
- private boolean queuesRestored;
-
- private int repeatMode;
-
- private int shuffleMode;
-
- private SongPlayCountHelper songPlayCountHelper = new SongPlayCountHelper();
-
- private final BroadcastReceiver bluetoothReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(final Context context, final Intent intent) {
- String action = intent.getAction();
- if (action != null) {
- if (BluetoothDevice.ACTION_ACL_CONNECTED.equals(action) &&
- PreferenceUtil.getInstance(context).bluetoothSpeaker()) {
- if (VERSION.SDK_INT >= VERSION_CODES.M) {
- if (getAudioManager().getDevices(AudioManager.GET_DEVICES_OUTPUTS).length > 0) {
- play();
- }
- } else {
- if (getAudioManager().isBluetoothA2dpOn()) {
- play();
- }
- }
- }
- }
- }
- };
-
- private PhoneStateListener phoneStateListener = new PhoneStateListener() {
- @Override
- public void onCallStateChanged(int state, String incomingNumber) {
- switch (state) {
- case TelephonyManager.CALL_STATE_IDLE:
- //Not in call: Play music
- play();
- break;
- case TelephonyManager.CALL_STATE_RINGING:
- case TelephonyManager.CALL_STATE_OFFHOOK:
- //A call is dialing, active or on hold
- pause();
- break;
- default:
- }
- super.onCallStateChanged(state, incomingNumber);
- }
- };
-
- private BroadcastReceiver headsetReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- String action = intent.getAction();
- if (action != null) {
- if (Intent.ACTION_HEADSET_PLUG.equals(action)) {
- int state = intent.getIntExtra("state", -1);
- switch (state) {
- case 0:
- pause();
- break;
- case 1:
- play();
- break;
- }
- }
- }
- }
- };
-
- private ThrottledSeekHandler throttledSeekHandler;
-
- private Handler uiThreadHandler;
-
- private final BroadcastReceiver updateFavoriteReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(final Context context, final Intent intent) {
- updateNotification();
- }
- };
-
- private PowerManager.WakeLock wakeLock;
-
private final BroadcastReceiver widgetIntentReceiver = new BroadcastReceiver() {
@Override
public void onReceive(final Context context, final Intent intent) {
@@ -383,6 +195,134 @@ public class MusicService extends Service implements
}
};
+ private AudioManager audioManager;
+ private IntentFilter becomingNoisyReceiverIntentFilter = new IntentFilter(
+ AudioManager.ACTION_AUDIO_BECOMING_NOISY);
+ private boolean becomingNoisyReceiverRegistered;
+ private IntentFilter bluetoothConnectedIntentFilter = new IntentFilter(BluetoothDevice.ACTION_ACL_CONNECTED);
+ private boolean bluetoothConnectedRegistered = false;
+ private IntentFilter headsetReceiverIntentFilter = new IntentFilter(Intent.ACTION_HEADSET_PLUG);
+ private boolean headsetReceiverRegistered = false;
+ private MediaSessionCompat mediaSession;
+ private ContentObserver mediaStoreObserver;
+ private HandlerThread musicPlayerHandlerThread;
+
+ private boolean notHandledMetaChangedForCurrentTrack;
+
+ private ArrayList originalPlayingQueue = new ArrayList<>();
+
+ private boolean pausedByTransientLossOfFocus;
+
+ private final BroadcastReceiver becomingNoisyReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, @NonNull Intent intent) {
+ if (intent.getAction() != null && intent.getAction().equals(AudioManager.ACTION_AUDIO_BECOMING_NOISY)) {
+ pause();
+ }
+ }
+ };
+
+ private PlaybackHandler playerHandler;
+
+ private final AudioManager.OnAudioFocusChangeListener audioFocusListener
+ = new AudioManager.OnAudioFocusChangeListener() {
+ @Override
+ public void onAudioFocusChange(final int focusChange) {
+ playerHandler.obtainMessage(FOCUS_CHANGE, focusChange, 0).sendToTarget();
+ }
+ };
+
+ private PlayingNotification playingNotification;
+ private final BroadcastReceiver updateFavoriteReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(final Context context, final Intent intent) {
+ updateNotification();
+ }
+ };
+ private ArrayList playingQueue = new ArrayList<>();
+ private QueueSaveHandler queueSaveHandler;
+ private HandlerThread queueSaveHandlerThread;
+ private boolean queuesRestored;
+ private int repeatMode;
+ private int shuffleMode;
+ private SongPlayCountHelper songPlayCountHelper = new SongPlayCountHelper();
+ private final BroadcastReceiver bluetoothReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(final Context context, final Intent intent) {
+ String action = intent.getAction();
+ if (action != null) {
+ if (BluetoothDevice.ACTION_ACL_CONNECTED.equals(action) &&
+ PreferenceUtil.getInstance(context).bluetoothSpeaker()) {
+ if (VERSION.SDK_INT >= VERSION_CODES.M) {
+ if (getAudioManager().getDevices(AudioManager.GET_DEVICES_OUTPUTS).length > 0) {
+ play();
+ }
+ } else {
+ if (getAudioManager().isBluetoothA2dpOn()) {
+ play();
+ }
+ }
+ }
+ }
+ }
+ };
+ private PhoneStateListener phoneStateListener = new PhoneStateListener() {
+ @Override
+ public void onCallStateChanged(int state, String incomingNumber) {
+ switch (state) {
+ case TelephonyManager.CALL_STATE_IDLE:
+ //Not in call: Play music
+ play();
+ break;
+ case TelephonyManager.CALL_STATE_RINGING:
+ case TelephonyManager.CALL_STATE_OFFHOOK:
+ //A call is dialing, active or on hold
+ pause();
+ break;
+ default:
+ }
+ super.onCallStateChanged(state, incomingNumber);
+ }
+ };
+ private BroadcastReceiver headsetReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ String action = intent.getAction();
+ if (action != null) {
+ if (Intent.ACTION_HEADSET_PLUG.equals(action)) {
+ int state = intent.getIntExtra("state", -1);
+ switch (state) {
+ case 0:
+ pause();
+ break;
+ case 1:
+ play();
+ break;
+ }
+ }
+ }
+ }
+ };
+ private ThrottledSeekHandler throttledSeekHandler;
+ private Handler uiThreadHandler;
+ private PowerManager.WakeLock wakeLock;
+
+ private static Bitmap copy(Bitmap bitmap) {
+ Bitmap.Config config = bitmap.getConfig();
+ if (config == null) {
+ config = Bitmap.Config.RGB_565;
+ }
+ try {
+ return bitmap.copy(config, false);
+ } catch (OutOfMemoryError e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ private static String getTrackUri(@NonNull Song song) {
+ return MusicUtil.getSongFileUri(song.getId()).toString();
+ }
@Override
public void onCreate() {
@@ -876,7 +816,7 @@ public class MusicService extends Service implements
}
public void openQueue(@Nullable final List playingQueue, final int startPosition,
- final boolean startPlaying) {
+ final boolean startPlaying) {
if (playingQueue != null && !playingQueue.isEmpty() && startPosition >= 0 && startPosition < playingQueue
.size()) {
// it is important to copy the playing queue here first as we might add/remove songs later
@@ -1424,20 +1364,11 @@ public class MusicService extends Service implements
}
- private static Bitmap copy(Bitmap bitmap) {
- Bitmap.Config config = bitmap.getConfig();
- if (config == null) {
- config = Bitmap.Config.RGB_565;
- }
- try {
- return bitmap.copy(config, false);
- } catch (OutOfMemoryError e) {
- e.printStackTrace();
- return null;
- }
- }
+ public class MusicBinder extends Binder {
- private static String getTrackUri(@NonNull Song song) {
- return MusicUtil.getSongFileUri(song.getId()).toString();
+ @NonNull
+ public MusicService getService() {
+ return MusicService.this;
+ }
}
}
\ No newline at end of file
diff --git a/app/src/main/java/code/name/monkey/retromusic/service/PlaybackHandler.java b/app/src/main/java/code/name/monkey/retromusic/service/PlaybackHandler.java
index 92eed06f..2fe34fbe 100644
--- a/app/src/main/java/code/name/monkey/retromusic/service/PlaybackHandler.java
+++ b/app/src/main/java/code/name/monkey/retromusic/service/PlaybackHandler.java
@@ -14,6 +14,17 @@
package code.name.monkey.retromusic.service;
+import android.media.AudioManager;
+import android.os.Handler;
+import android.os.Looper;
+import android.os.Message;
+
+import androidx.annotation.NonNull;
+
+import java.lang.ref.WeakReference;
+
+import code.name.monkey.retromusic.util.PreferenceUtil;
+
import static code.name.monkey.retromusic.service.MusicService.DUCK;
import static code.name.monkey.retromusic.service.MusicService.META_CHANGED;
import static code.name.monkey.retromusic.service.MusicService.PLAY_STATE_CHANGED;
@@ -21,20 +32,11 @@ import static code.name.monkey.retromusic.service.MusicService.REPEAT_MODE_NONE;
import static code.name.monkey.retromusic.service.MusicService.TRACK_ENDED;
import static code.name.monkey.retromusic.service.MusicService.TRACK_WENT_TO_NEXT;
-import android.media.AudioManager;
-import android.os.Handler;
-import android.os.Looper;
-import android.os.Message;
-import androidx.annotation.NonNull;
-import code.name.monkey.retromusic.util.PreferenceUtil;
-import java.lang.ref.WeakReference;
-
class PlaybackHandler extends Handler {
- private float currentDuckVolume = 1.0f;
-
@NonNull
private final WeakReference mService;
+ private float currentDuckVolume = 1.0f;
PlaybackHandler(final MusicService service, @NonNull final Looper looper) {
super(looper);
diff --git a/app/src/main/java/code/name/monkey/retromusic/service/QueueSaveHandler.kt b/app/src/main/java/code/name/monkey/retromusic/service/QueueSaveHandler.kt
index 44f3eb84..9abc3120 100644
--- a/app/src/main/java/code/name/monkey/retromusic/service/QueueSaveHandler.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/service/QueueSaveHandler.kt
@@ -21,8 +21,8 @@ import code.name.monkey.retromusic.service.MusicService.SAVE_QUEUES
import java.lang.ref.WeakReference
internal class QueueSaveHandler(
- musicService: MusicService,
- looper: Looper
+ musicService: MusicService,
+ looper: Looper
) : Handler(looper) {
private val service: WeakReference = WeakReference(musicService)
diff --git a/app/src/main/java/code/name/monkey/retromusic/service/ThrottledSeekHandler.kt b/app/src/main/java/code/name/monkey/retromusic/service/ThrottledSeekHandler.kt
index 9f2b9fed..71f4cb46 100644
--- a/app/src/main/java/code/name/monkey/retromusic/service/ThrottledSeekHandler.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/service/ThrottledSeekHandler.kt
@@ -20,8 +20,8 @@ import android.os.Handler
import code.name.monkey.retromusic.service.MusicService.PLAY_STATE_CHANGED
class ThrottledSeekHandler(
- private val musicService: MusicService,
- private val handler: Handler
+ private val musicService: MusicService,
+ private val handler: Handler
) : Runnable {
fun notifySeek() {
diff --git a/app/src/main/java/code/name/monkey/retromusic/service/notification/PlayingNotification.kt b/app/src/main/java/code/name/monkey/retromusic/service/notification/PlayingNotification.kt
index 5bb8d56c..4d0476ca 100644
--- a/app/src/main/java/code/name/monkey/retromusic/service/notification/PlayingNotification.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/service/notification/PlayingNotification.kt
@@ -73,12 +73,15 @@ abstract class PlayingNotification {
@RequiresApi(26)
private fun createNotificationChannel() {
var notificationChannel: NotificationChannel? = notificationManager!!
- .getNotificationChannel(NOTIFICATION_CHANNEL_ID)
+ .getNotificationChannel(NOTIFICATION_CHANNEL_ID)
if (notificationChannel == null) {
- notificationChannel = NotificationChannel(NOTIFICATION_CHANNEL_ID,
- service.getString(R.string.playing_notification_name),
- NotificationManager.IMPORTANCE_LOW)
- notificationChannel.description = service.getString(R.string.playing_notification_description)
+ notificationChannel = NotificationChannel(
+ NOTIFICATION_CHANNEL_ID,
+ service.getString(R.string.playing_notification_name),
+ NotificationManager.IMPORTANCE_LOW
+ )
+ notificationChannel.description =
+ service.getString(R.string.playing_notification_description)
notificationChannel.enableLights(false)
notificationChannel.enableVibration(false)
notificationChannel.setShowBadge(false)
diff --git a/app/src/main/java/code/name/monkey/retromusic/service/notification/PlayingNotificationImpl.kt b/app/src/main/java/code/name/monkey/retromusic/service/notification/PlayingNotificationImpl.kt
index 47072a8b..f2a95ef5 100644
--- a/app/src/main/java/code/name/monkey/retromusic/service/notification/PlayingNotificationImpl.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/service/notification/PlayingNotificationImpl.kt
@@ -48,13 +48,16 @@ class PlayingNotificationImpl : PlayingNotification() {
val song = service.currentSong
val isPlaying = service.isPlaying
val isFavorite = MusicUtil.isFavorite(service, song)
- val playButtonResId = if (isPlaying) R.drawable.ic_pause_white_48dp else R.drawable.ic_play_arrow_white_48dp
- val favoriteResId = if (isFavorite) R.drawable.ic_favorite_white_24dp else R.drawable.ic_favorite_border_white_24dp
+ val playButtonResId =
+ if (isPlaying) R.drawable.ic_pause_white_48dp else R.drawable.ic_play_arrow_white_48dp
+ val favoriteResId =
+ if (isFavorite) R.drawable.ic_favorite_white_24dp else R.drawable.ic_favorite_border_white_24dp
val action = Intent(service, MainActivity::class.java)
action.putExtra("expand", true)
action.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP
- val clickIntent = PendingIntent.getActivity(service, 0, action, PendingIntent.FLAG_UPDATE_CURRENT)
+ val clickIntent =
+ PendingIntent.getActivity(service, 0, action, PendingIntent.FLAG_UPDATE_CURRENT)
val serviceName = ComponentName(service, MusicService::class.java)
val intent = Intent(ACTION_QUIT)
@@ -62,71 +65,108 @@ class PlayingNotificationImpl : PlayingNotification() {
val deleteIntent = PendingIntent.getService(service, 0, intent, 0)
val bigNotificationImageSize = service.resources
- .getDimensionPixelSize(R.dimen.notification_big_image_size)
+ .getDimensionPixelSize(R.dimen.notification_big_image_size)
service.runOnUiThread {
if (target != null) {
Glide.clear(target)
}
target = SongGlideRequest.Builder.from(Glide.with(service), song)
- .checkIgnoreMediaStore(service)
- .generatePalette(service).build()
- .centerCrop()
- .into(object : SimpleTarget(bigNotificationImageSize, bigNotificationImageSize) {
- override fun onResourceReady(resource: BitmapPaletteWrapper, glideAnimation: GlideAnimation) {
- update(resource.bitmap, when {
- PreferenceUtil.getInstance(service).isDominantColor -> RetroColorUtil.getDominantColor(resource.bitmap, Color.TRANSPARENT)
+ .checkIgnoreMediaStore(service)
+ .generatePalette(service).build()
+ .centerCrop()
+ .into(object : SimpleTarget(
+ bigNotificationImageSize,
+ bigNotificationImageSize
+ ) {
+ override fun onResourceReady(
+ resource: BitmapPaletteWrapper,
+ glideAnimation: GlideAnimation
+ ) {
+ update(
+ resource.bitmap, when {
+ PreferenceUtil.getInstance(service).isDominantColor -> RetroColorUtil.getDominantColor(
+ resource.bitmap,
+ Color.TRANSPARENT
+ )
else -> RetroColorUtil.getColor(resource.palette, Color.TRANSPARENT)
- })
+ }
+ )
+ }
+
+ override fun onLoadFailed(e: Exception?, errorDrawable: Drawable?) {
+ super.onLoadFailed(e, errorDrawable)
+ update(null, Color.TRANSPARENT)
+ }
+
+ fun update(bitmap: Bitmap?, color: Int) {
+ var bitmapFinal = bitmap
+ if (bitmapFinal == null) {
+ bitmapFinal = BitmapFactory.decodeResource(
+ service.resources,
+ R.drawable.default_audio_art
+ )
}
- override fun onLoadFailed(e: Exception?, errorDrawable: Drawable?) {
- super.onLoadFailed(e, errorDrawable)
- update(null, Color.TRANSPARENT)
+ val toggleFavorite = NotificationCompat.Action(
+ favoriteResId,
+ service.getString(R.string.action_toggle_favorite),
+ retrievePlaybackAction(TOGGLE_FAVORITE)
+ )
+ val playPauseAction = NotificationCompat.Action(
+ playButtonResId,
+ service.getString(R.string.action_play_pause),
+ retrievePlaybackAction(ACTION_TOGGLE_PAUSE)
+ )
+ val previousAction = NotificationCompat.Action(
+ R.drawable.ic_skip_previous_round_white_32dp,
+ service.getString(R.string.action_previous),
+ retrievePlaybackAction(ACTION_REWIND)
+ )
+ val nextAction = NotificationCompat.Action(
+ R.drawable.ic_skip_next_round_white_32dp,
+ service.getString(R.string.action_next),
+ retrievePlaybackAction(ACTION_SKIP)
+ )
+
+ val builder = NotificationCompat.Builder(
+ service,
+ NOTIFICATION_CHANNEL_ID
+ )
+ .setSmallIcon(R.drawable.ic_notification)
+ .setLargeIcon(bitmapFinal)
+ .setContentIntent(clickIntent)
+ .setDeleteIntent(deleteIntent)
+ .setContentTitle(Html.fromHtml("" + song.title + ""))
+ .setContentText(song.artistName)
+ .setSubText(Html.fromHtml("" + song.albumName + ""))
+ .setOngoing(isPlaying)
+ .setShowWhen(false)
+ .addAction(toggleFavorite)
+ .addAction(previousAction)
+ .addAction(playPauseAction)
+ .addAction(nextAction)
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ builder.setStyle(
+ MediaStyle()
+ .setMediaSession(service.mediaSession.sessionToken)
+ .setShowActionsInCompactView(1, 2, 3)
+ )
+ .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
+ if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.O && PreferenceUtil.getInstance(
+ service
+ ).coloredNotification()
+ ) {
+ builder.color = color
+ }
}
- fun update(bitmap: Bitmap?, color: Int) {
- var bitmapFinal = bitmap
- if (bitmapFinal == null) {
- bitmapFinal = BitmapFactory.decodeResource(service.resources, R.drawable.default_audio_art)
- }
-
- val toggleFavorite = NotificationCompat.Action(favoriteResId, service.getString(R.string.action_toggle_favorite), retrievePlaybackAction(TOGGLE_FAVORITE))
- val playPauseAction = NotificationCompat.Action(playButtonResId, service.getString(R.string.action_play_pause), retrievePlaybackAction(ACTION_TOGGLE_PAUSE))
- val previousAction = NotificationCompat.Action(R.drawable.ic_skip_previous_round_white_32dp, service.getString(R.string.action_previous), retrievePlaybackAction(ACTION_REWIND))
- val nextAction = NotificationCompat.Action(R.drawable.ic_skip_next_round_white_32dp, service.getString(R.string.action_next), retrievePlaybackAction(ACTION_SKIP))
-
- val builder = NotificationCompat.Builder(service,
- NOTIFICATION_CHANNEL_ID)
- .setSmallIcon(R.drawable.ic_notification)
- .setLargeIcon(bitmapFinal)
- .setContentIntent(clickIntent)
- .setDeleteIntent(deleteIntent)
- .setContentTitle(Html.fromHtml("" + song.title + ""))
- .setContentText(song.artistName)
- .setSubText(Html.fromHtml("" + song.albumName + ""))
- .setOngoing(isPlaying)
- .setShowWhen(false)
- .addAction(toggleFavorite)
- .addAction(previousAction)
- .addAction(playPauseAction)
- .addAction(nextAction)
-
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
- builder.setStyle(MediaStyle()
- .setMediaSession(service.mediaSession.sessionToken)
- .setShowActionsInCompactView(1, 2, 3))
- .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
- if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.O && PreferenceUtil.getInstance(service).coloredNotification()) {
- builder.color = color
- }
- }
-
- if (stopped) {
- return // notification has been stopped before loading was finished
- }
- updateNotifyModeAndPostNotification(builder.build())
+ if (stopped) {
+ return // notification has been stopped before loading was finished
}
- })
+ updateNotifyModeAndPostNotification(builder.build())
+ }
+ })
}
}
diff --git a/app/src/main/java/code/name/monkey/retromusic/service/notification/PlayingNotificationOreo.kt b/app/src/main/java/code/name/monkey/retromusic/service/notification/PlayingNotificationOreo.kt
index ebf79e47..39ce02f9 100644
--- a/app/src/main/java/code/name/monkey/retromusic/service/notification/PlayingNotificationOreo.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/service/notification/PlayingNotificationOreo.kt
@@ -50,8 +50,14 @@ class PlayingNotificationOreo : PlayingNotification() {
private var target: Target? = null
private fun getCombinedRemoteViews(collapsed: Boolean, song: Song): RemoteViews {
- val remoteViews = RemoteViews(service.packageName, if (collapsed) R.layout.layout_notification_collapsed else R.layout.layout_notification_expanded)
- remoteViews.setTextViewText(R.id.appName, service.getString(R.string.app_name) + " • " + song.albumName)
+ val remoteViews = RemoteViews(
+ service.packageName,
+ if (collapsed) R.layout.layout_notification_collapsed else R.layout.layout_notification_expanded
+ )
+ remoteViews.setTextViewText(
+ R.id.appName,
+ service.getString(R.string.app_name) + " • " + song.albumName
+ )
remoteViews.setTextViewText(R.id.title, song.title)
remoteViews.setTextViewText(R.id.subtitle, song.artistName)
linkButtons(remoteViews)
@@ -71,103 +77,162 @@ class PlayingNotificationOreo : PlayingNotification() {
action.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP
val clickIntent = PendingIntent
- .getActivity(service, 0, action, PendingIntent.FLAG_UPDATE_CURRENT)
+ .getActivity(service, 0, action, PendingIntent.FLAG_UPDATE_CURRENT)
val deleteIntent = buildPendingIntent(service, ACTION_QUIT, null)
val builder = NotificationCompat.Builder(service, NOTIFICATION_CHANNEL_ID)
- .setSmallIcon(R.drawable.ic_notification)
- .setContentIntent(clickIntent)
- .setDeleteIntent(deleteIntent)
- .setCategory(NotificationCompat.CATEGORY_SERVICE)
- .setPriority(NotificationCompat.PRIORITY_MAX)
- .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
- .setCustomContentView(notificationLayout)
- .setCustomBigContentView(notificationLayoutBig)
- .setOngoing(isPlaying)
+ .setSmallIcon(R.drawable.ic_notification)
+ .setContentIntent(clickIntent)
+ .setDeleteIntent(deleteIntent)
+ .setCategory(NotificationCompat.CATEGORY_SERVICE)
+ .setPriority(NotificationCompat.PRIORITY_MAX)
+ .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
+ .setCustomContentView(notificationLayout)
+ .setCustomBigContentView(notificationLayoutBig)
+ .setOngoing(isPlaying)
val bigNotificationImageSize = service.resources
- .getDimensionPixelSize(R.dimen.notification_big_image_size)
+ .getDimensionPixelSize(R.dimen.notification_big_image_size)
service.runOnUiThread {
if (target != null) {
Glide.clear(target)
}
target = SongGlideRequest.Builder.from(Glide.with(service), song)
- .checkIgnoreMediaStore(service)
- .generatePalette(service).build()
- .centerCrop()
- .into(object : SimpleTarget(bigNotificationImageSize, bigNotificationImageSize) {
- override fun onResourceReady(resource: BitmapPaletteWrapper, glideAnimation: GlideAnimation) {
- val mediaNotificationProcessor = MediaNotificationProcessor(service, service) { i, _ -> update(resource.bitmap, i) }
- mediaNotificationProcessor.processNotification(resource.bitmap)
+ .checkIgnoreMediaStore(service)
+ .generatePalette(service).build()
+ .centerCrop()
+ .into(object : SimpleTarget(
+ bigNotificationImageSize,
+ bigNotificationImageSize
+ ) {
+ override fun onResourceReady(
+ resource: BitmapPaletteWrapper,
+ glideAnimation: GlideAnimation
+ ) {
+ val mediaNotificationProcessor = MediaNotificationProcessor(
+ service,
+ service
+ ) { i, _ -> update(resource.bitmap, i) }
+ mediaNotificationProcessor.processNotification(resource.bitmap)
+ }
+
+ override fun onLoadFailed(e: Exception?, errorDrawable: Drawable?) {
+ super.onLoadFailed(e, errorDrawable)
+ update(
+ null,
+ ATHUtil.resolveColor(service, R.attr.colorSurface, Color.WHITE)
+ )
+ }
+
+ private fun update(bitmap: Bitmap?, bgColor: Int) {
+ var bgColorFinal = bgColor
+ if (bitmap != null) {
+ notificationLayout.setImageViewBitmap(R.id.largeIcon, bitmap)
+ notificationLayoutBig.setImageViewBitmap(R.id.largeIcon, bitmap)
+ } else {
+ notificationLayout.setImageViewResource(
+ R.id.largeIcon,
+ R.drawable.default_audio_art
+ )
+ notificationLayoutBig.setImageViewResource(
+ R.id.largeIcon,
+ R.drawable.default_audio_art
+ )
}
- override fun onLoadFailed(e: Exception?, errorDrawable: Drawable?) {
- super.onLoadFailed(e, errorDrawable)
- update(null, ATHUtil.resolveColor(service, R.attr.colorSurface, Color.WHITE))
+ if (!PreferenceUtil.getInstance(service).coloredNotification()) {
+ bgColorFinal =
+ ATHUtil.resolveColor(service, R.attr.colorPrimary, Color.WHITE)
}
+ setBackgroundColor(bgColorFinal)
+ setNotificationContent(ColorUtil.isColorLight(bgColorFinal))
- private fun update(bitmap: Bitmap?, bgColor: Int) {
- var bgColorFinal = bgColor
- if (bitmap != null) {
- notificationLayout.setImageViewBitmap(R.id.largeIcon, bitmap)
- notificationLayoutBig.setImageViewBitmap(R.id.largeIcon, bitmap)
- } else {
- notificationLayout.setImageViewResource(R.id.largeIcon, R.drawable.default_audio_art)
- notificationLayoutBig.setImageViewResource(R.id.largeIcon, R.drawable.default_audio_art)
- }
-
- if (!PreferenceUtil.getInstance(service).coloredNotification()) {
- bgColorFinal = ATHUtil.resolveColor(service, R.attr.colorPrimary, Color.WHITE)
- }
- setBackgroundColor(bgColorFinal)
- setNotificationContent(ColorUtil.isColorLight(bgColorFinal))
-
- if (stopped) {
- return // notification has been stopped before loading was finished
- }
- updateNotifyModeAndPostNotification(builder.build())
+ if (stopped) {
+ return // notification has been stopped before loading was finished
}
+ updateNotifyModeAndPostNotification(builder.build())
+ }
- private fun setBackgroundColor(color: Int) {
- notificationLayout.setInt(R.id.image, "setBackgroundColor", color)
- notificationLayoutBig.setInt(R.id.image, "setBackgroundColor", color)
- }
+ private fun setBackgroundColor(color: Int) {
+ notificationLayout.setInt(R.id.image, "setBackgroundColor", color)
+ notificationLayoutBig.setInt(R.id.image, "setBackgroundColor", color)
+ }
- private fun setNotificationContent(dark: Boolean) {
- val primary = MaterialValueHelper.getPrimaryTextColor(service, dark)
- val secondary = MaterialValueHelper.getSecondaryTextColor(service, dark)
+ private fun setNotificationContent(dark: Boolean) {
+ val primary = MaterialValueHelper.getPrimaryTextColor(service, dark)
+ val secondary = MaterialValueHelper.getSecondaryTextColor(service, dark)
- val close = createBitmap(RetroUtil.getTintedVectorDrawable(service, R.drawable.ic_close_white_24dp, primary)!!, NOTIFICATION_CONTROLS_SIZE_MULTIPLIER)
- val prev = createBitmap(RetroUtil.getTintedVectorDrawable(service, R.drawable.ic_skip_previous_round_white_32dp, primary)!!, NOTIFICATION_CONTROLS_SIZE_MULTIPLIER)
- val next = createBitmap(RetroUtil.getTintedVectorDrawable(service, R.drawable.ic_skip_next_round_white_32dp, primary)!!, NOTIFICATION_CONTROLS_SIZE_MULTIPLIER)
- val playPause = createBitmap(RetroUtil.getTintedVectorDrawable(service,
- if (isPlaying)
- R.drawable.ic_pause_white_48dp
- else
- R.drawable.ic_play_arrow_white_48dp, primary)!!, NOTIFICATION_CONTROLS_SIZE_MULTIPLIER)
+ val close = createBitmap(
+ RetroUtil.getTintedVectorDrawable(
+ service,
+ R.drawable.ic_close_white_24dp,
+ primary
+ )!!, NOTIFICATION_CONTROLS_SIZE_MULTIPLIER
+ )
+ val prev = createBitmap(
+ RetroUtil.getTintedVectorDrawable(
+ service,
+ R.drawable.ic_skip_previous_round_white_32dp,
+ primary
+ )!!, NOTIFICATION_CONTROLS_SIZE_MULTIPLIER
+ )
+ val next = createBitmap(
+ RetroUtil.getTintedVectorDrawable(
+ service,
+ R.drawable.ic_skip_next_round_white_32dp,
+ primary
+ )!!, NOTIFICATION_CONTROLS_SIZE_MULTIPLIER
+ )
+ val playPause = createBitmap(
+ RetroUtil.getTintedVectorDrawable(
+ service,
+ if (isPlaying)
+ R.drawable.ic_pause_white_48dp
+ else
+ R.drawable.ic_play_arrow_white_48dp, primary
+ )!!, NOTIFICATION_CONTROLS_SIZE_MULTIPLIER
+ )
- notificationLayout.setTextColor(R.id.title, primary)
- notificationLayout.setTextColor(R.id.subtitle, secondary)
- notificationLayout.setTextColor(R.id.appName, secondary)
+ notificationLayout.setTextColor(R.id.title, primary)
+ notificationLayout.setTextColor(R.id.subtitle, secondary)
+ notificationLayout.setTextColor(R.id.appName, secondary)
- notificationLayout.setImageViewBitmap(R.id.action_prev, prev)
- notificationLayout.setImageViewBitmap(R.id.action_next, next)
- notificationLayout.setImageViewBitmap(R.id.action_play_pause, playPause)
+ notificationLayout.setImageViewBitmap(R.id.action_prev, prev)
+ notificationLayout.setImageViewBitmap(R.id.action_next, next)
+ notificationLayout.setImageViewBitmap(R.id.action_play_pause, playPause)
- notificationLayoutBig.setTextColor(R.id.title, primary)
- notificationLayoutBig.setTextColor(R.id.subtitle, secondary)
- notificationLayoutBig.setTextColor(R.id.appName, secondary)
+ notificationLayoutBig.setTextColor(R.id.title, primary)
+ notificationLayoutBig.setTextColor(R.id.subtitle, secondary)
+ notificationLayoutBig.setTextColor(R.id.appName, secondary)
- notificationLayoutBig.setImageViewBitmap(R.id.action_quit, close)
- notificationLayoutBig.setImageViewBitmap(R.id.action_prev, prev)
- notificationLayoutBig.setImageViewBitmap(R.id.action_next, next)
- notificationLayoutBig.setImageViewBitmap(R.id.action_play_pause, playPause)
+ notificationLayoutBig.setImageViewBitmap(R.id.action_quit, close)
+ notificationLayoutBig.setImageViewBitmap(R.id.action_prev, prev)
+ notificationLayoutBig.setImageViewBitmap(R.id.action_next, next)
+ notificationLayoutBig.setImageViewBitmap(R.id.action_play_pause, playPause)
- notificationLayout.setImageViewBitmap(R.id.smallIcon, createBitmap(RetroUtil.getTintedVectorDrawable(service, R.drawable.ic_notification, secondary)!!, 0.6f))
- notificationLayoutBig.setImageViewBitmap(R.id.smallIcon, createBitmap(RetroUtil.getTintedVectorDrawable(service, R.drawable.ic_notification, secondary)!!, 0.6f))
+ notificationLayout.setImageViewBitmap(
+ R.id.smallIcon,
+ createBitmap(
+ RetroUtil.getTintedVectorDrawable(
+ service,
+ R.drawable.ic_notification,
+ secondary
+ )!!, 0.6f
+ )
+ )
+ notificationLayoutBig.setImageViewBitmap(
+ R.id.smallIcon,
+ createBitmap(
+ RetroUtil.getTintedVectorDrawable(
+ service,
+ R.drawable.ic_notification,
+ secondary
+ )!!, 0.6f
+ )
+ )
- }
- })
+ }
+ })
}
if (stopped) {
@@ -177,8 +242,10 @@ class PlayingNotificationOreo : PlayingNotification() {
}
- private fun buildPendingIntent(context: Context, action: String,
- serviceName: ComponentName?): PendingIntent {
+ private fun buildPendingIntent(
+ context: Context, action: String,
+ serviceName: ComponentName?
+ ): PendingIntent {
val intent = Intent(action)
intent.component = serviceName
return PendingIntent.getService(context, 0, intent, 0)
diff --git a/app/src/main/java/code/name/monkey/retromusic/transform/ParallaxPagerTransformer.kt b/app/src/main/java/code/name/monkey/retromusic/transform/ParallaxPagerTransformer.kt
index 9e5ec9df..ba25df77 100644
--- a/app/src/main/java/code/name/monkey/retromusic/transform/ParallaxPagerTransformer.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/transform/ParallaxPagerTransformer.kt
@@ -16,7 +16,6 @@ package code.name.monkey.retromusic.transform
import android.annotation.TargetApi
import android.os.Build
-import android.util.Log
import android.view.View
import androidx.viewpager.widget.ViewPager
diff --git a/app/src/main/java/code/name/monkey/retromusic/util/ArtistSignatureUtil.java b/app/src/main/java/code/name/monkey/retromusic/util/ArtistSignatureUtil.java
index 6b749345..fece1ea5 100644
--- a/app/src/main/java/code/name/monkey/retromusic/util/ArtistSignatureUtil.java
+++ b/app/src/main/java/code/name/monkey/retromusic/util/ArtistSignatureUtil.java
@@ -17,6 +17,7 @@ package code.name.monkey.retromusic.util;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;
+
import androidx.annotation.NonNull;
import com.bumptech.glide.signature.StringSignature;
diff --git a/app/src/main/java/code/name/monkey/retromusic/util/CustomArtistImageUtil.kt b/app/src/main/java/code/name/monkey/retromusic/util/CustomArtistImageUtil.kt
index 46dfe37d..a3b221b8 100644
--- a/app/src/main/java/code/name/monkey/retromusic/util/CustomArtistImageUtil.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/util/CustomArtistImageUtil.kt
@@ -33,7 +33,7 @@ import java.io.BufferedOutputStream
import java.io.File
import java.io.FileOutputStream
import java.io.IOException
-import java.util.Locale
+import java.util.*
class CustomArtistImageUtil private constructor(context: Context) {
@@ -41,53 +41,65 @@ class CustomArtistImageUtil private constructor(context: Context) {
private val mPreferences: SharedPreferences
init {
- mPreferences = context.applicationContext.getSharedPreferences(CUSTOM_ARTIST_IMAGE_PREFS, Context.MODE_PRIVATE)
+ mPreferences = context.applicationContext.getSharedPreferences(
+ CUSTOM_ARTIST_IMAGE_PREFS,
+ Context.MODE_PRIVATE
+ )
}
fun setCustomArtistImage(artist: Artist, uri: Uri) {
Glide.with(App.getContext())
- .load(uri)
- .asBitmap()
- .diskCacheStrategy(DiskCacheStrategy.NONE)
- .skipMemoryCache(true)
- .into(object : SimpleTarget() {
- override fun onLoadFailed(e: Exception?, errorDrawable: Drawable?) {
- super.onLoadFailed(e, errorDrawable)
- e!!.printStackTrace()
- Toast.makeText(App.getContext(), e.toString(), Toast.LENGTH_LONG).show()
- }
+ .load(uri)
+ .asBitmap()
+ .diskCacheStrategy(DiskCacheStrategy.NONE)
+ .skipMemoryCache(true)
+ .into(object : SimpleTarget() {
+ override fun onLoadFailed(e: Exception?, errorDrawable: Drawable?) {
+ super.onLoadFailed(e, errorDrawable)
+ e!!.printStackTrace()
+ Toast.makeText(App.getContext(), e.toString(), Toast.LENGTH_LONG).show()
+ }
- override fun onResourceReady(resource: Bitmap, glideAnimation: GlideAnimation) {
- object : AsyncTask() {
- @SuppressLint("ApplySharedPref")
- override fun doInBackground(vararg params: Void): Void? {
- val dir = File(App.getContext().filesDir, FOLDER_NAME)
- if (!dir.exists()) {
- if (!dir.mkdirs()) { // create the folder
- return null
- }
+ override fun onResourceReady(
+ resource: Bitmap,
+ glideAnimation: GlideAnimation
+ ) {
+ object : AsyncTask() {
+ @SuppressLint("ApplySharedPref")
+ override fun doInBackground(vararg params: Void): Void? {
+ val dir = File(App.getContext().filesDir, FOLDER_NAME)
+ if (!dir.exists()) {
+ if (!dir.mkdirs()) { // create the folder
+ return null
}
- val file = File(dir, getFileName(artist))
-
- var succesful = false
- try {
- val os = BufferedOutputStream(FileOutputStream(file))
- succesful = ImageUtil.resizeBitmap(resource, 2048).compress(Bitmap.CompressFormat.JPEG, 100, os)
- os.close()
- } catch (e: IOException) {
- Toast.makeText(App.getContext(), e.toString(), Toast.LENGTH_LONG).show()
- }
-
- if (succesful) {
- mPreferences.edit().putBoolean(getFileName(artist), true).commit()
- ArtistSignatureUtil.getInstance(App.getContext()).updateArtistSignature(artist.name)
- App.getContext().contentResolver.notifyChange(MediaStore.Audio.Artists.EXTERNAL_CONTENT_URI, null) // trigger media store changed to force artist image reload
- }
- return null
}
- }.execute()
- }
- })
+ val file = File(dir, getFileName(artist))
+
+ var succesful = false
+ try {
+ val os = BufferedOutputStream(FileOutputStream(file))
+ succesful = ImageUtil.resizeBitmap(resource, 2048)
+ .compress(Bitmap.CompressFormat.JPEG, 100, os)
+ os.close()
+ } catch (e: IOException) {
+ Toast.makeText(App.getContext(), e.toString(), Toast.LENGTH_LONG)
+ .show()
+ }
+
+ if (succesful) {
+ mPreferences.edit().putBoolean(getFileName(artist), true).commit()
+ ArtistSignatureUtil.getInstance(App.getContext())
+ .updateArtistSignature(artist.name)
+ App.getContext().contentResolver.notifyChange(
+ MediaStore.Audio.Artists.EXTERNAL_CONTENT_URI,
+ null
+ ) // trigger media store changed to force artist image reload
+ }
+ return null
+ }
+ }.execute()
+ }
+ })
}
fun resetCustomArtistImage(artist: Artist) {
@@ -96,7 +108,10 @@ class CustomArtistImageUtil private constructor(context: Context) {
override fun doInBackground(vararg params: Void): Void? {
mPreferences.edit().putBoolean(getFileName(artist), false).commit()
ArtistSignatureUtil.getInstance(App.getContext()).updateArtistSignature(artist.name)
- App.getContext().contentResolver.notifyChange(MediaStore.Audio.Artists.EXTERNAL_CONTENT_URI, null) // trigger media store changed to force artist image reload
+ App.getContext().contentResolver.notifyChange(
+ MediaStore.Audio.Artists.EXTERNAL_CONTENT_URI,
+ null
+ ) // trigger media store changed to force artist image reload
val file = getFile(artist)
if (!file.exists()) {
diff --git a/app/src/main/java/code/name/monkey/retromusic/util/MusicUtil.java b/app/src/main/java/code/name/monkey/retromusic/util/MusicUtil.java
index 440bc6d1..adbd8d5c 100644
--- a/app/src/main/java/code/name/monkey/retromusic/util/MusicUtil.java
+++ b/app/src/main/java/code/name/monkey/retromusic/util/MusicUtil.java
@@ -27,9 +27,21 @@ import android.provider.BaseColumns;
import android.provider.MediaStore;
import android.text.TextUtils;
import android.widget.Toast;
+
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.FileProvider;
+
+import org.jaudiotagger.audio.AudioFileIO;
+import org.jaudiotagger.tag.FieldKey;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+import java.util.regex.Pattern;
+
import code.name.monkey.retromusic.R;
import code.name.monkey.retromusic.helper.MusicPlayerRemote;
import code.name.monkey.retromusic.loaders.PlaylistLoader;
@@ -39,14 +51,6 @@ import code.name.monkey.retromusic.model.Playlist;
import code.name.monkey.retromusic.model.Song;
import code.name.monkey.retromusic.model.lyrics.AbsSynchronizedLyrics;
import code.name.monkey.retromusic.service.MusicService;
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
-import java.util.regex.Pattern;
-import org.jaudiotagger.audio.AudioFileIO;
-import org.jaudiotagger.tag.FieldKey;
public class MusicUtil {
@@ -188,7 +192,7 @@ public class MusicUtil {
@NonNull
public static String getArtistInfoString(@NonNull final Context context,
- @NonNull final Artist artist) {
+ @NonNull final Artist artist) {
int albumCount = artist.getAlbumCount();
int songCount = artist.getSongCount();
String albumString = albumCount == 1 ? context.getResources().getString(R.string.album)
@@ -379,7 +383,7 @@ public class MusicUtil {
}
public static boolean isFavoritePlaylist(@NonNull final Context context,
- @NonNull final Playlist playlist) {
+ @NonNull final Playlist playlist) {
return playlist.name != null && playlist.name.equals(context.getString(R.string.favorites));
}
diff --git a/app/src/main/java/code/name/monkey/retromusic/util/NavigationUtil.java b/app/src/main/java/code/name/monkey/retromusic/util/NavigationUtil.java
index 8ce25a27..c6812aeb 100755
--- a/app/src/main/java/code/name/monkey/retromusic/util/NavigationUtil.java
+++ b/app/src/main/java/code/name/monkey/retromusic/util/NavigationUtil.java
@@ -14,9 +14,6 @@
package code.name.monkey.retromusic.util;
-import static code.name.monkey.retromusic.Constants.RATE_ON_GOOGLE_PLAY;
-import static code.name.monkey.retromusic.util.RetroUtil.openUrl;
-
import android.app.Activity;
import android.app.ActivityOptions;
import android.content.ActivityNotFoundException;
@@ -24,8 +21,12 @@ import android.content.Context;
import android.content.Intent;
import android.media.audiofx.AudioEffect;
import android.widget.Toast;
+
import androidx.annotation.NonNull;
import androidx.core.app.ActivityCompat;
+
+import org.jetbrains.annotations.NotNull;
+
import code.name.monkey.retromusic.R;
import code.name.monkey.retromusic.activities.AboutActivity;
import code.name.monkey.retromusic.activities.AlbumDetailsActivity;
@@ -46,7 +47,9 @@ import code.name.monkey.retromusic.activities.bugreport.BugReportActivity;
import code.name.monkey.retromusic.helper.MusicPlayerRemote;
import code.name.monkey.retromusic.model.Genre;
import code.name.monkey.retromusic.model.Playlist;
-import org.jetbrains.annotations.NotNull;
+
+import static code.name.monkey.retromusic.Constants.RATE_ON_GOOGLE_PLAY;
+import static code.name.monkey.retromusic.util.RetroUtil.openUrl;
public class NavigationUtil {
@@ -66,8 +69,8 @@ public class NavigationUtil {
}
public static void goToAlbumOptions(@NonNull Activity activity,
- int albumId,
- @NonNull ActivityOptions options) {
+ int albumId,
+ @NonNull ActivityOptions options) {
Intent intent = new Intent(activity, AlbumDetailsActivity.class);
intent.putExtra(AlbumDetailsActivity.EXTRA_ALBUM_ID, albumId);
ActivityCompat.startActivity(activity, intent, options.toBundle());
@@ -80,8 +83,8 @@ public class NavigationUtil {
}
public static void goToArtistOptions(@NotNull Activity activity,
- int artistId,
- @NonNull ActivityOptions options) {
+ int artistId,
+ @NonNull ActivityOptions options) {
Intent intent = new Intent(activity, ArtistDetailActivity.class);
intent.putExtra(ArtistDetailActivity.EXTRA_ARTIST_ID, artistId);
@@ -123,13 +126,13 @@ public class NavigationUtil {
}
public static void goToSearch(@NonNull Activity activity,
- @NonNull ActivityOptions activityOptions) {
+ @NonNull ActivityOptions activityOptions) {
ActivityCompat.startActivity(activity, new Intent(activity, SearchActivity.class),
activityOptions.toBundle());
}
public static void goToSearch(@NonNull Activity activity, boolean isMicOpen,
- @NonNull ActivityOptions activityOptions) {
+ @NonNull ActivityOptions activityOptions) {
ActivityCompat.startActivity(activity, new Intent(activity, SearchActivity.class)
.putExtra(SearchActivity.EXTRA_SHOW_MIC, isMicOpen),
activityOptions.toBundle());
@@ -144,7 +147,7 @@ public class NavigationUtil {
}
public static void goToUserInfo(@NonNull Activity activity,
- @NonNull ActivityOptions activityOptions) {
+ @NonNull ActivityOptions activityOptions) {
ActivityCompat.startActivity(activity, new Intent(activity, UserInfoActivity.class),
activityOptions.toBundle());
}
diff --git a/app/src/main/java/code/name/monkey/retromusic/util/PlaylistsUtil.java b/app/src/main/java/code/name/monkey/retromusic/util/PlaylistsUtil.java
index 422f9a21..b6df807e 100644
--- a/app/src/main/java/code/name/monkey/retromusic/util/PlaylistsUtil.java
+++ b/app/src/main/java/code/name/monkey/retromusic/util/PlaylistsUtil.java
@@ -14,8 +14,6 @@
package code.name.monkey.retromusic.util;
-import static android.provider.MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI;
-
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
@@ -25,24 +23,29 @@ import android.os.Environment;
import android.provider.BaseColumns;
import android.provider.MediaStore;
import android.widget.Toast;
+
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-import code.name.monkey.retromusic.R;
-import code.name.monkey.retromusic.helper.M3UWriter;
-import code.name.monkey.retromusic.model.Playlist;
-import code.name.monkey.retromusic.model.PlaylistSong;
-import code.name.monkey.retromusic.model.Song;
+
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
+import code.name.monkey.retromusic.R;
+import code.name.monkey.retromusic.helper.M3UWriter;
+import code.name.monkey.retromusic.model.Playlist;
+import code.name.monkey.retromusic.model.PlaylistSong;
+import code.name.monkey.retromusic.model.Song;
+
+import static android.provider.MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI;
+
public class PlaylistsUtil {
public static void addToPlaylist(@NonNull Context context,
- @NonNull List songs,
- int playlistId,
- boolean showToastOnFinish) {
+ @NonNull List songs,
+ int playlistId,
+ boolean showToastOnFinish) {
ArrayList noSongs = new ArrayList();
for (Song song : songs) {
@@ -130,7 +133,7 @@ public class PlaylistsUtil {
}
static boolean doPlaylistContains(@NonNull final Context context, final long playlistId,
- final int songId) {
+ final int songId) {
if (playlistId != -1) {
try {
Cursor c = context.getContentResolver().query(
@@ -179,7 +182,7 @@ public class PlaylistsUtil {
@NonNull
public static ContentValues[] makeInsertItems(@NonNull final List songs, final int offset, int len,
- final int base) {
+ final int base) {
if (offset + len > songs.size()) {
len = songs.size() - offset;
}
@@ -246,21 +249,21 @@ public class PlaylistsUtil {
@Nullable
public static File savePlaylist(@NonNull Context context,
- @NonNull Playlist playlist) throws IOException {
+ @NonNull Playlist playlist) throws IOException {
return M3UWriter.write(context, new File(Environment.getExternalStorageDirectory(), "Playlists"), playlist);
}
static void addToPlaylist(@NonNull Context context,
- @NonNull Song song,
- int playlistId,
- boolean showToastOnFinish) {
+ @NonNull Song song,
+ int playlistId,
+ boolean showToastOnFinish) {
List helperList = new ArrayList<>();
helperList.add(song);
addToPlaylist(context, helperList, playlistId, showToastOnFinish);
}
private static boolean doesPlaylistExist(@NonNull Context context, @NonNull final String selection,
- @NonNull final String[] values) {
+ @NonNull final String[] values) {
Cursor cursor = context.getContentResolver().query(EXTERNAL_CONTENT_URI,
new String[]{}, selection, values, null);
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 02cffb40..d54dfaeb 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
@@ -24,10 +24,24 @@ import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.preference.PreferenceManager;
+import android.util.Log;
+
import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import androidx.annotation.StyleRes;
import androidx.viewpager.widget.ViewPager;
+
+import com.google.android.material.bottomnavigation.LabelVisibilityMode;
+import com.google.gson.Gson;
+import com.google.gson.JsonSyntaxException;
+import com.google.gson.reflect.TypeToken;
+
+import java.io.File;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+
import code.name.monkey.retromusic.R;
import code.name.monkey.retromusic.dialogs.OptionsSheetDialogFragment;
import code.name.monkey.retromusic.fragments.AlbumCoverStyle;
@@ -44,15 +58,6 @@ import code.name.monkey.retromusic.transform.HorizontalFlipTransformation;
import code.name.monkey.retromusic.transform.NormalPageTransformer;
import code.name.monkey.retromusic.transform.VerticalFlipTransformation;
import code.name.monkey.retromusic.transform.VerticalStackTransformer;
-import com.google.android.material.bottomnavigation.LabelVisibilityMode;
-import com.google.gson.Gson;
-import com.google.gson.JsonSyntaxException;
-import com.google.gson.reflect.TypeToken;
-import java.io.File;
-import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
public final class PreferenceUtil {
@@ -133,37 +138,21 @@ public final class PreferenceUtil {
public static final String TAB_TEXT_MODE = "tab_text_mode";
public static final String SAF_SDCARD_URI = "saf_sdcard_uri";
-
- private static final String GENRE_SORT_ORDER = "genre_sort_order";
-
- private static final String LAST_PAGE = "last_start_page";
-
- private static final String BLUETOOTH_PLAYBACK = "bluetooth_playback";
-
- private static final String LAST_MUSIC_CHOOSER = "last_music_chooser";
-
- private static final String DEFAULT_START_PAGE = "default_start_page";
-
- private static final String INITIALIZED_BLACKLIST = "initialized_blacklist";
-
- private static final String ARTIST_SORT_ORDER = "artist_sort_order";
-
- private static final String ARTIST_SONG_SORT_ORDER = "artist_song_sort_order";
-
- private static final String ARTIST_ALBUM_SORT_ORDER = "artist_album_sort_order";
-
- private static final String ALBUM_SORT_ORDER = "album_sort_order";
-
- private static final String ALBUM_SONG_SORT_ORDER = "album_song_sort_order";
-
public static final String SONG_SORT_ORDER = "song_sort_order";
-
- private static final String ALBUM_GRID_SIZE = "album_grid_size";
-
- private static final String ALBUM_GRID_SIZE_LAND = "album_grid_size_land";
-
public static final String SONG_GRID_SIZE = "song_grid_size";
-
+ private static final String GENRE_SORT_ORDER = "genre_sort_order";
+ private static final String LAST_PAGE = "last_start_page";
+ private static final String BLUETOOTH_PLAYBACK = "bluetooth_playback";
+ private static final String LAST_MUSIC_CHOOSER = "last_music_chooser";
+ private static final String DEFAULT_START_PAGE = "default_start_page";
+ private static final String INITIALIZED_BLACKLIST = "initialized_blacklist";
+ private static final String ARTIST_SORT_ORDER = "artist_sort_order";
+ private static final String ARTIST_SONG_SORT_ORDER = "artist_song_sort_order";
+ private static final String ARTIST_ALBUM_SORT_ORDER = "artist_album_sort_order";
+ private static final String ALBUM_SORT_ORDER = "album_sort_order";
+ private static final String ALBUM_SONG_SORT_ORDER = "album_song_sort_order";
+ private static final String ALBUM_GRID_SIZE = "album_grid_size";
+ private static final String ALBUM_GRID_SIZE_LAND = "album_grid_size_land";
private static final String SONG_GRID_SIZE_LAND = "song_grid_size_land";
private static final String ARTIST_GRID_SIZE = "artist_grid_size";
@@ -227,11 +216,14 @@ public final class PreferenceUtil {
private static final String SNOW_FALL_EFFECT = "snow_fall_effect";
private static final String FILTER_SONG = "filter_song";
-
+ private static final String TAG = "PreferenceUtil";
private static PreferenceUtil sInstance;
-
private final SharedPreferences mPreferences;
+ private PreferenceUtil(@NonNull final Context context) {
+ mPreferences = PreferenceManager.getDefaultSharedPreferences(context);
+ }
+
@NonNull
public static PreferenceUtil getInstance(Context context) {
if (sInstance == null) {
@@ -267,10 +259,6 @@ public final class PreferenceUtil {
}
}
- private PreferenceUtil(@NonNull final Context context) {
- mPreferences = PreferenceManager.getDefaultSharedPreferences(context);
- }
-
public final boolean albumArtOnLockscreen() {
return mPreferences.getBoolean(ALBUM_ART_ON_LOCKSCREEN, true);
}
@@ -410,6 +398,9 @@ public final class PreferenceUtil {
@LayoutRes
public int getAlbumGridStyle() {
+ if (mPreferences.contains(ALBUM_GRID_STYLE)) {
+ Log.i(TAG, "getAlbumGridStyle: " + mPreferences.getInt(ALBUM_GRID_STYLE, -10));
+ }
return mPreferences.getInt(ALBUM_GRID_STYLE, R.layout.item_grid);
}
@@ -461,6 +452,9 @@ public final class PreferenceUtil {
@LayoutRes
public int getArtistGridStyle() {
+ if (mPreferences.contains(ARTIST_GRID_STYLE)) {
+ Log.i(TAG, "getArtistGridStyle: " + mPreferences.getInt(ARTIST_GRID_STYLE, -10));
+ }
return mPreferences.getInt(ARTIST_GRID_STYLE, R.layout.item_grid);
}
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 7e93bff2..d41c69c6 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
@@ -29,9 +29,7 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.List;
-import code.name.monkey.appthemehelper.util.ATHUtil;
import code.name.monkey.appthemehelper.util.ColorUtil;
-import code.name.monkey.retromusic.R;
public class RetroColorUtil {
public static int desaturateColor(int color, float ratio) {
diff --git a/app/src/main/java/code/name/monkey/retromusic/util/RetroUtil.java b/app/src/main/java/code/name/monkey/retromusic/util/RetroUtil.java
index 80a0bc49..d4f5d368 100755
--- a/app/src/main/java/code/name/monkey/retromusic/util/RetroUtil.java
+++ b/app/src/main/java/code/name/monkey/retromusic/util/RetroUtil.java
@@ -35,14 +35,17 @@ import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
+
import androidx.annotation.ColorInt;
import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat;
+
+import java.text.DecimalFormat;
+
import code.name.monkey.appthemehelper.util.TintHelper;
import code.name.monkey.retromusic.App;
-import java.text.DecimalFormat;
public class RetroUtil {
@@ -105,20 +108,20 @@ public class RetroUtil {
@Nullable
public static Drawable getTintedVectorDrawable(@NonNull Context context, @DrawableRes int id,
- @ColorInt int color) {
+ @ColorInt int color) {
return TintHelper.createTintedDrawable(
getVectorDrawable(context.getResources(), id, context.getTheme()), color);
}
@Nullable
public static Drawable getTintedVectorDrawable(@NonNull Resources res, @DrawableRes int resId,
- @Nullable Resources.Theme theme, @ColorInt int color) {
+ @Nullable Resources.Theme theme, @ColorInt int color) {
return TintHelper.createTintedDrawable(getVectorDrawable(res, resId, theme), color);
}
@Nullable
public static Drawable getVectorDrawable(@NonNull Resources res, @DrawableRes int resId,
- @Nullable Resources.Theme theme) {
+ @Nullable Resources.Theme theme) {
if (Build.VERSION.SDK_INT >= 21) {
return res.getDrawable(resId, theme);
}
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 013587f3..dfe7e725 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
@@ -45,16 +45,18 @@ class RingtoneManager(val context: Context) {
try {
- val cursor = resolver.query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
- arrayOf(MediaStore.MediaColumns.TITLE),
- BaseColumns._ID + "=?",
- arrayOf(song.id.toString()), null)
+ val cursor = resolver.query(
+ MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
+ arrayOf(MediaStore.MediaColumns.TITLE),
+ BaseColumns._ID + "=?",
+ arrayOf(song.id.toString()), null
+ )
cursor.use { cursorSong ->
if (cursorSong != null && cursorSong.count == 1) {
cursorSong.moveToFirst()
Settings.System.putString(resolver, Settings.System.RINGTONE, uri.toString())
val message = context
- .getString(R.string.x_has_been_set_as_ringtone, cursorSong.getString(0))
+ .getString(R.string.x_has_been_set_as_ringtone, cursorSong.getString(0))
Toast.makeText(context, message, Toast.LENGTH_SHORT).show()
}
}
diff --git a/app/src/main/java/code/name/monkey/retromusic/util/SwipeAndDragHelper.java b/app/src/main/java/code/name/monkey/retromusic/util/SwipeAndDragHelper.java
index f8fa85da..a5f740db 100644
--- a/app/src/main/java/code/name/monkey/retromusic/util/SwipeAndDragHelper.java
+++ b/app/src/main/java/code/name/monkey/retromusic/util/SwipeAndDragHelper.java
@@ -17,8 +17,8 @@ package code.name.monkey.retromusic.util;
import android.graphics.Canvas;
import androidx.annotation.NonNull;
-import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.ItemTouchHelper;
+import androidx.recyclerview.widget.RecyclerView;
public class SwipeAndDragHelper extends ItemTouchHelper.Callback {
diff --git a/app/src/main/java/code/name/monkey/retromusic/util/ThemeManager.kt b/app/src/main/java/code/name/monkey/retromusic/util/ThemeManager.kt
index 30eb755c..4eaa224b 100644
--- a/app/src/main/java/code/name/monkey/retromusic/util/ThemeManager.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/util/ThemeManager.kt
@@ -13,18 +13,21 @@ import code.name.monkey.retromusic.R
object ThemeManager {
@StyleRes
- fun getThemeResValue(context: Context): Int = when (PreferenceUtil.getInstance(context).generalThemeValue) {
- "light" -> R.style.Theme_RetroMusic_Light
- "dark" -> R.style.Theme_RetroMusic_Base
- "auto" -> R.style.Theme_RetroMusic_FollowSystem
- "black" -> R.style.Theme_RetroMusic_Black
- else -> R.style.Theme_RetroMusic_FollowSystem
- }
+ fun getThemeResValue(context: Context): Int =
+ when (PreferenceUtil.getInstance(context).generalThemeValue) {
+ "light" -> R.style.Theme_RetroMusic_Light
+ "dark" -> R.style.Theme_RetroMusic_Base
+ "auto" -> R.style.Theme_RetroMusic_FollowSystem
+ "black" -> R.style.Theme_RetroMusic_Black
+ else -> R.style.Theme_RetroMusic_FollowSystem
+ }
private fun isSystemDarkModeEnabled(context: Context): Boolean {
- val isBatterySaverEnabled = (context.getSystemService(Context.POWER_SERVICE) as PowerManager?)?.isPowerSaveMode
+ val isBatterySaverEnabled =
+ (context.getSystemService(Context.POWER_SERVICE) as PowerManager?)?.isPowerSaveMode
?: false
- val isDarkModeEnabled = (context.resources.configuration.uiMode and UI_MODE_NIGHT_MASK) == UI_MODE_NIGHT_YES
+ val isDarkModeEnabled =
+ (context.resources.configuration.uiMode and UI_MODE_NIGHT_MASK) == UI_MODE_NIGHT_YES
return isBatterySaverEnabled or isDarkModeEnabled
}
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 15438f9a..dcc75ba7 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
@@ -67,7 +67,8 @@ object ViewUtil {
BlendModeColorFilterCompat.createBlendModeColorFilterCompat(newColor, SRC_IN)
val background = layerDrawable.findDrawableByLayerId(android.R.id.background)
- val primaryColor = ATHUtil.resolveColor(progressSlider.context, android.R.attr.windowBackground)
+ val primaryColor =
+ ATHUtil.resolveColor(progressSlider.context, android.R.attr.windowBackground)
background.colorFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(
MaterialValueHelper.getPrimaryDisabledTextColor(
progressSlider.context,
@@ -77,7 +78,12 @@ object ViewUtil {
val secondaryProgress = layerDrawable.findDrawableByLayerId(android.R.id.secondaryProgress)
secondaryProgress?.colorFilter =
- BlendModeColorFilterCompat.createBlendModeColorFilterCompat(ColorUtil.withAlpha(newColor, 0.65f), SRC_IN)
+ BlendModeColorFilterCompat.createBlendModeColorFilterCompat(
+ ColorUtil.withAlpha(
+ newColor,
+ 0.65f
+ ), SRC_IN
+ )
}
fun hitTest(v: View, x: Int, y: Int): Boolean {
diff --git a/app/src/main/java/code/name/monkey/retromusic/views/BaselineGridTextView.java b/app/src/main/java/code/name/monkey/retromusic/views/BaselineGridTextView.java
index 7d82b758..8cce44b1 100644
--- a/app/src/main/java/code/name/monkey/retromusic/views/BaselineGridTextView.java
+++ b/app/src/main/java/code/name/monkey/retromusic/views/BaselineGridTextView.java
@@ -19,10 +19,13 @@ import android.content.res.TypedArray;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.util.TypedValue;
+
import androidx.annotation.FontRes;
-import code.name.monkey.retromusic.R;
+
import com.google.android.material.textview.MaterialTextView;
+import code.name.monkey.retromusic.R;
+
public class BaselineGridTextView extends MaterialTextView {
private final float FOUR_DIP;
diff --git a/app/src/main/java/code/name/monkey/retromusic/views/BottomNavigationBarTinted.kt b/app/src/main/java/code/name/monkey/retromusic/views/BottomNavigationBarTinted.kt
index 71d4ad81..c7e6f155 100644
--- a/app/src/main/java/code/name/monkey/retromusic/views/BottomNavigationBarTinted.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/views/BottomNavigationBarTinted.kt
@@ -41,8 +41,16 @@ class BottomNavigationBarTinted @JvmOverloads constructor(
val iconColor = ATHUtil.resolveColor(context, android.R.attr.colorControlNormal)
val accentColor = ThemeStore.accentColor(context)
- NavigationViewUtil.setItemIconColors(this, ColorUtil.withAlpha(iconColor, 0.5f), accentColor)
- NavigationViewUtil.setItemTextColors(this, ColorUtil.withAlpha(iconColor, 0.5f), accentColor)
+ NavigationViewUtil.setItemIconColors(
+ this,
+ ColorUtil.withAlpha(iconColor, 0.5f),
+ accentColor
+ )
+ NavigationViewUtil.setItemTextColors(
+ this,
+ ColorUtil.withAlpha(iconColor, 0.5f),
+ accentColor
+ )
itemBackground = RippleDrawable(
RippleUtils.convertToRippleDrawableColor(
ColorStateList.valueOf(
diff --git a/app/src/main/java/code/name/monkey/retromusic/views/BreadCrumbLayout.java b/app/src/main/java/code/name/monkey/retromusic/views/BreadCrumbLayout.java
index d8c3d131..944ca9c1 100644
--- a/app/src/main/java/code/name/monkey/retromusic/views/BreadCrumbLayout.java
+++ b/app/src/main/java/code/name/monkey/retromusic/views/BreadCrumbLayout.java
@@ -26,156 +26,35 @@ import android.widget.HorizontalScrollView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
+
import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
-import code.name.monkey.appthemehelper.util.ATHUtil;
-import code.name.monkey.retromusic.R;
+
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
+import code.name.monkey.appthemehelper.util.ATHUtil;
+import code.name.monkey.retromusic.R;
+
/**
* @author Aidan Follestad (afollestad), modified for Phonograph by Karim Abou Zeid (kabouzeid)
*/
public class BreadCrumbLayout extends HorizontalScrollView implements View.OnClickListener {
- public static class Crumb implements Parcelable {
-
- public static final Creator CREATOR = new Creator() {
- @Override
- public Crumb createFromParcel(Parcel source) {
- return new Crumb(source);
- }
-
- @Override
- public Crumb[] newArray(int size) {
- return new Crumb[size];
- }
- };
-
- private final File file;
-
- private int scrollPos;
-
- public Crumb(File file) {
- this.file = file;
- }
-
- protected Crumb(Parcel in) {
- this.file = (File) in.readSerializable();
- this.scrollPos = in.readInt();
- }
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- @Override
- public boolean equals(Object o) {
- return (o instanceof Crumb) && ((Crumb) o).getFile() != null &&
- ((Crumb) o).getFile().equals(getFile());
- }
-
- public File getFile() {
- return file;
- }
-
- public int getScrollPosition() {
- return scrollPos;
- }
-
- public void setScrollPosition(int scrollY) {
- this.scrollPos = scrollY;
- }
-
- public String getTitle() {
- return file.getPath().equals("/") ? "root" : file.getName();
- }
-
- @Override
- public String toString() {
- return "Crumb{" +
- "file=" + file +
- ", scrollPos=" + scrollPos +
- '}';
- }
-
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- dest.writeSerializable(this.file);
- dest.writeInt(this.scrollPos);
- }
- }
-
- public static class SavedStateWrapper implements Parcelable {
-
- public static final Creator CREATOR = new Creator() {
- public SavedStateWrapper createFromParcel(Parcel source) {
- return new SavedStateWrapper(source);
- }
-
- public SavedStateWrapper[] newArray(int size) {
- return new SavedStateWrapper[size];
- }
- };
-
- public final int mActive;
-
- public final List mCrumbs;
-
- public final int mVisibility;
-
- public SavedStateWrapper(BreadCrumbLayout view) {
- mActive = view.mActive;
- mCrumbs = view.mCrumbs;
- mVisibility = view.getVisibility();
- }
-
- protected SavedStateWrapper(Parcel in) {
- this.mActive = in.readInt();
- this.mCrumbs = in.createTypedArrayList(Crumb.CREATOR);
- this.mVisibility = in.readInt();
- }
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- dest.writeInt(this.mActive);
- dest.writeTypedList(mCrumbs);
- dest.writeInt(this.mVisibility);
- }
- }
-
- public interface SelectionCallback {
-
- void onCrumbSelection(Crumb crumb, int index);
- }
-
@ColorInt
private int contentColorActivated;
-
@ColorInt
private int contentColorDeactivated;
-
private int mActive;
-
private SelectionCallback mCallback;
-
private LinearLayout mChildFrame;
-
// Stores currently visible crumbs
private List mCrumbs;
-
// Stores user's navigation history, like a fragment back stack
private List mHistory;
-
// Used in setActiveOrAdd() between clearing crumbs and adding the new set, nullified afterwards
private List mOldCrumbs;
@@ -422,7 +301,7 @@ public class BreadCrumbLayout extends HorizontalScrollView implements View.OnCli
}
private TextView invalidateActivated(View view, final boolean isActive, final boolean noArrowIfAlone,
- final boolean allowArrowVisible) {
+ final boolean allowArrowVisible) {
int contentColor = isActive ? contentColorActivated : contentColorDeactivated;
LinearLayout child = (LinearLayout) view;
TextView tv = (TextView) child.getChildAt(0);
@@ -448,4 +327,121 @@ public class BreadCrumbLayout extends HorizontalScrollView implements View.OnCli
}
return success;
}
+
+ public interface SelectionCallback {
+
+ void onCrumbSelection(Crumb crumb, int index);
+ }
+
+ public static class Crumb implements Parcelable {
+
+ public static final Creator CREATOR = new Creator() {
+ @Override
+ public Crumb createFromParcel(Parcel source) {
+ return new Crumb(source);
+ }
+
+ @Override
+ public Crumb[] newArray(int size) {
+ return new Crumb[size];
+ }
+ };
+
+ private final File file;
+
+ private int scrollPos;
+
+ public Crumb(File file) {
+ this.file = file;
+ }
+
+ protected Crumb(Parcel in) {
+ this.file = (File) in.readSerializable();
+ this.scrollPos = in.readInt();
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ return (o instanceof Crumb) && ((Crumb) o).getFile() != null &&
+ ((Crumb) o).getFile().equals(getFile());
+ }
+
+ public File getFile() {
+ return file;
+ }
+
+ public int getScrollPosition() {
+ return scrollPos;
+ }
+
+ public void setScrollPosition(int scrollY) {
+ this.scrollPos = scrollY;
+ }
+
+ public String getTitle() {
+ return file.getPath().equals("/") ? "root" : file.getName();
+ }
+
+ @Override
+ public String toString() {
+ return "Crumb{" +
+ "file=" + file +
+ ", scrollPos=" + scrollPos +
+ '}';
+ }
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeSerializable(this.file);
+ dest.writeInt(this.scrollPos);
+ }
+ }
+
+ public static class SavedStateWrapper implements Parcelable {
+
+ public static final Creator CREATOR = new Creator() {
+ public SavedStateWrapper createFromParcel(Parcel source) {
+ return new SavedStateWrapper(source);
+ }
+
+ public SavedStateWrapper[] newArray(int size) {
+ return new SavedStateWrapper[size];
+ }
+ };
+
+ public final int mActive;
+
+ public final List mCrumbs;
+
+ public final int mVisibility;
+
+ public SavedStateWrapper(BreadCrumbLayout view) {
+ mActive = view.mActive;
+ mCrumbs = view.mCrumbs;
+ mVisibility = view.getVisibility();
+ }
+
+ protected SavedStateWrapper(Parcel in) {
+ this.mActive = in.readInt();
+ this.mCrumbs = in.createTypedArrayList(Crumb.CREATOR);
+ this.mVisibility = in.readInt();
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeInt(this.mActive);
+ dest.writeTypedList(mCrumbs);
+ dest.writeInt(this.mVisibility);
+ }
+ }
}
\ No newline at end of file
diff --git a/app/src/main/java/code/name/monkey/retromusic/views/CircularImageView.java b/app/src/main/java/code/name/monkey/retromusic/views/CircularImageView.java
index d99f77bd..3b555cf2 100644
--- a/app/src/main/java/code/name/monkey/retromusic/views/CircularImageView.java
+++ b/app/src/main/java/code/name/monkey/retromusic/views/CircularImageView.java
@@ -25,10 +25,11 @@ import android.graphics.Paint;
import android.graphics.Shader;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
-import androidx.appcompat.widget.AppCompatImageView;
import android.util.AttributeSet;
import android.util.Log;
+import androidx.appcompat.widget.AppCompatImageView;
+
import code.name.monkey.retromusic.R;
public class CircularImageView extends AppCompatImageView {
diff --git a/app/src/main/java/code/name/monkey/retromusic/views/ContributorsView.java b/app/src/main/java/code/name/monkey/retromusic/views/ContributorsView.java
index cd72ea55..f5e25904 100644
--- a/app/src/main/java/code/name/monkey/retromusic/views/ContributorsView.java
+++ b/app/src/main/java/code/name/monkey/retromusic/views/ContributorsView.java
@@ -25,6 +25,7 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
+
import code.name.monkey.retromusic.R;
import static code.name.monkey.retromusic.util.RetroUtil.openUrl;
diff --git a/app/src/main/java/code/name/monkey/retromusic/views/ListItemView.kt b/app/src/main/java/code/name/monkey/retromusic/views/ListItemView.kt
index aea3312c..0a0ca03a 100644
--- a/app/src/main/java/code/name/monkey/retromusic/views/ListItemView.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/views/ListItemView.kt
@@ -37,7 +37,11 @@ class ListItemView : FrameLayout {
init(context, attrs)
}
- constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
+ constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(
+ context,
+ attrs,
+ defStyleAttr
+ ) {
init(context, attrs)
}
diff --git a/app/src/main/java/code/name/monkey/retromusic/views/MetalRecyclerViewPager.kt b/app/src/main/java/code/name/monkey/retromusic/views/MetalRecyclerViewPager.kt
index c044bd26..29bab7ba 100644
--- a/app/src/main/java/code/name/monkey/retromusic/views/MetalRecyclerViewPager.kt
+++ b/app/src/main/java/code/name/monkey/retromusic/views/MetalRecyclerViewPager.kt
@@ -36,15 +36,21 @@ class MetalRecyclerViewPager : RecyclerView {
init(context, attrs)
}
- constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
+ constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(
+ context,
+ attrs,
+ defStyleAttr
+ ) {
init(context, attrs)
}
private var itemMargin: Int = 0
fun init(context: Context, attrs: AttributeSet?) {
- val typedArray = context.obtainStyledAttributes(attrs, R.styleable.MetalRecyclerViewPager, 0, 0)
- itemMargin = typedArray.getDimension(R.styleable.MetalRecyclerViewPager_itemMargin, 0f).toInt()
+ val typedArray =
+ context.obtainStyledAttributes(attrs, R.styleable.MetalRecyclerViewPager, 0, 0)
+ itemMargin =
+ typedArray.getDimension(R.styleable.MetalRecyclerViewPager_itemMargin, 0f).toInt()
typedArray.recycle()
layoutManager = LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)
@@ -62,7 +68,8 @@ class MetalRecyclerViewPager : RecyclerView {
super.setAdapter(adapter)
}
- abstract class MetalAdapter(@NonNull val displayMetrics: DisplayMetrics) : RecyclerView.Adapter() {
+ abstract class MetalAdapter(@NonNull val displayMetrics: DisplayMetrics) :
+ RecyclerView.Adapter() {
private var itemMargin: Int = 0
private var itemWidth: Int = 0
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 4bdac34a..0d6c6737 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
@@ -27,9 +27,11 @@ import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.view.View;
+
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.graphics.drawable.DrawableCompat;
+
import code.name.monkey.appthemehelper.ThemeStore;
import code.name.monkey.retromusic.R;
@@ -58,6 +60,12 @@ public class PopupBackground extends Drawable {
mPaddingEnd = resources.getDimensionPixelOffset(R.dimen.afs_md2_popup_padding_end);
}
+ private static void pathArcTo(@NonNull Path path, float centerX, float centerY, float radius,
+ float startAngle, float sweepAngle) {
+ path.arcTo(centerX - radius, centerY - radius, centerX + radius, centerY + radius,
+ startAngle, sweepAngle, false);
+ }
+
@Override
public void draw(@NonNull Canvas canvas) {
canvas.drawPath(mPath, mPaint);
@@ -146,10 +154,4 @@ public class PopupBackground extends Drawable {
mTempMatrix.postTranslate(bounds.left, bounds.top);
mPath.transform(mTempMatrix);
}
-
- private static void pathArcTo(@NonNull Path path, float centerX, float centerY, float radius,
- float startAngle, float sweepAngle) {
- path.arcTo(centerX - radius, centerY - radius, centerX + radius, centerY + radius,
- startAngle, sweepAngle, false);
- }
}
\ No newline at end of file
diff --git a/app/src/main/java/code/name/monkey/retromusic/views/ScrollingViewOnApplyWindowInsetsListener.java b/app/src/main/java/code/name/monkey/retromusic/views/ScrollingViewOnApplyWindowInsetsListener.java
index d8f49015..1abe0bac 100644
--- a/app/src/main/java/code/name/monkey/retromusic/views/ScrollingViewOnApplyWindowInsetsListener.java
+++ b/app/src/main/java/code/name/monkey/retromusic/views/ScrollingViewOnApplyWindowInsetsListener.java
@@ -20,6 +20,7 @@ import android.view.WindowInsets;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
+
import me.zhanghai.android.fastscroll.FastScroller;
public class ScrollingViewOnApplyWindowInsetsListener implements View.OnApplyWindowInsetsListener {
diff --git a/app/src/main/java/code/name/monkey/retromusic/views/SeekArc.java b/app/src/main/java/code/name/monkey/retromusic/views/SeekArc.java
index 38128504..726a5f73 100644
--- a/app/src/main/java/code/name/monkey/retromusic/views/SeekArc.java
+++ b/app/src/main/java/code/name/monkey/retromusic/views/SeekArc.java
@@ -24,11 +24,12 @@ import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
+
import code.name.monkey.retromusic.R;
/**
* SeekArc.java
- *
+ *
* This is a class that functions much like a SeekBar but
* follows a circle path instead of a straight line.
*
@@ -36,129 +37,70 @@ import code.name.monkey.retromusic.R;
*/
public class SeekArc extends View {
- public interface OnSeekArcChangeListener {
-
- /**
- * Notification that the progress level has changed. Clients can use the
- * fromUser parameter to distinguish user-initiated changes from those
- * that occurred programmatically.
- *
- * @param seekArc The SeekArc whose progress has changed
- * @param progress The current progress level. This will be in the range
- * 0..max where max was set by
- * {@link ProgressArc#setMax(int)}. (The default value for
- * max is 100.)
- * @param fromUser True if the progress change was initiated by the user.
- */
- void onProgressChanged(SeekArc seekArc, int progress, boolean fromUser);
-
- /**
- * Notification that the user has started a touch gesture. Clients may
- * want to use this to disable advancing the seekbar.
- *
- * @param seekArc The SeekArc in which the touch gesture began
- */
- void onStartTrackingTouch(SeekArc seekArc);
-
- /**
- * Notification that the user has finished a touch gesture. Clients may
- * want to use this to re-enable advancing the seekarc.
- *
- * @param seekArc The SeekArc in which the touch gesture began
- */
- void onStopTrackingTouch(SeekArc seekArc);
- }
-
private static final String TAG = SeekArc.class.getSimpleName();
-
private static int INVALID_PROGRESS_VALUE = -1;
-
// The initial rotational offset -90 means we start at 12 o'clock
private final int mAngleOffset = -90;
-
private Paint mArcPaint;
-
// Internal variables
private int mArcRadius = 0;
-
private RectF mArcRect = new RectF();
-
/**
* The Width of the background arc for the SeekArc
*/
private int mArcWidth = 2;
-
/**
* Will the progress increase clockwise or anti-clockwise
*/
private boolean mClockwise = true;
-
/**
* is the control enabled/touchable
*/
private boolean mEnabled = true;
-
/**
* The Maximum value that this SeekArc can be set to
*/
private int mMax = 100;
-
private OnSeekArcChangeListener mOnSeekArcChangeListener;
-
/**
* The Current value that the SeekArc is set to
*/
private int mProgress = 0;
-
private Paint mProgressPaint;
-
private float mProgressSweep = 0;
-
/**
* The width of the progress line for this SeekArc
*/
private int mProgressWidth = 4;
-
/**
* The rotation of the SeekArc- 0 is twelve o'clock
*/
private int mRotation = 0;
-
/**
* Give the SeekArc rounded edges
*/
private boolean mRoundedEdges = false;
-
/**
* The Angle to start drawing this Arc from
*/
private int mStartAngle = 0;
-
/**
* The Angle through which to draw the arc (Max is 360)
*/
private int mSweepAngle = 360;
-
/**
* The Drawable for the seek arc thumbnail
*/
private Drawable mThumb;
-
private int mThumbXPos;
-
private int mThumbYPos;
-
private double mTouchAngle;
-
private float mTouchIgnoreRadius;
-
/**
* Enable touch inside the SeekArc
*/
private boolean mTouchInside = true;
-
private int mTranslateX;
-
private int mTranslateY;
public SeekArc(Context context) {
@@ -574,4 +516,37 @@ public class SeekArc extends View {
private float valuePerDegree() {
return (float) mMax / mSweepAngle;
}
+
+ public interface OnSeekArcChangeListener {
+
+ /**
+ * Notification that the progress level has changed. Clients can use the
+ * fromUser parameter to distinguish user-initiated changes from those
+ * that occurred programmatically.
+ *
+ * @param seekArc The SeekArc whose progress has changed
+ * @param progress The current progress level. This will be in the range
+ * 0..max where max was set by
+ * {@link ProgressArc#setMax(int)}. (The default value for
+ * max is 100.)
+ * @param fromUser True if the progress change was initiated by the user.
+ */
+ void onProgressChanged(SeekArc seekArc, int progress, boolean fromUser);
+
+ /**
+ * Notification that the user has started a touch gesture. Clients may
+ * want to use this to disable advancing the seekbar.
+ *
+ * @param seekArc The SeekArc in which the touch gesture began
+ */
+ void onStartTrackingTouch(SeekArc seekArc);
+
+ /**
+ * Notification that the user has finished a touch gesture. Clients may
+ * want to use this to re-enable advancing the seekarc.
+ *
+ * @param seekArc The SeekArc in which the touch gesture began
+ */
+ void onStopTrackingTouch(SeekArc seekArc);
+ }
}
\ No newline at end of file
diff --git a/app/src/main/java/code/name/monkey/retromusic/volume/AudioVolumeContentObserver.java b/app/src/main/java/code/name/monkey/retromusic/volume/AudioVolumeContentObserver.java
index f11c4bd3..2378cc36 100644
--- a/app/src/main/java/code/name/monkey/retromusic/volume/AudioVolumeContentObserver.java
+++ b/app/src/main/java/code/name/monkey/retromusic/volume/AudioVolumeContentObserver.java
@@ -18,6 +18,7 @@ import android.database.ContentObserver;
import android.media.AudioManager;
import android.net.Uri;
import android.os.Handler;
+
import androidx.annotation.NonNull;
public class AudioVolumeContentObserver extends ContentObserver {
@@ -31,8 +32,8 @@ public class AudioVolumeContentObserver extends ContentObserver {
private float mLastVolume;
AudioVolumeContentObserver(@NonNull Handler handler, @NonNull AudioManager audioManager,
- int audioStreamType,
- @NonNull OnAudioVolumeChangedListener listener) {
+ int audioStreamType,
+ @NonNull OnAudioVolumeChangedListener listener) {
super(handler);
mAudioManager = audioManager;
diff --git a/app/src/main/java/code/name/monkey/retromusic/volume/AudioVolumeObserver.java b/app/src/main/java/code/name/monkey/retromusic/volume/AudioVolumeObserver.java
index 7e97571c..e5b002a5 100644
--- a/app/src/main/java/code/name/monkey/retromusic/volume/AudioVolumeObserver.java
+++ b/app/src/main/java/code/name/monkey/retromusic/volume/AudioVolumeObserver.java
@@ -17,6 +17,7 @@ package code.name.monkey.retromusic.volume;
import android.content.Context;
import android.media.AudioManager;
import android.os.Handler;
+
import androidx.annotation.NonNull;
public class AudioVolumeObserver {
diff --git a/app/src/main/res/drawable-hdpi/default_album_art.webp b/app/src/main/res/drawable-hdpi/default_album_art.webp
index 11a82d86d6dc3017f9870d9fa389ebdbb803f575..7444895683a8e692ce792b865bbf0ad7781198af 100644
GIT binary patch
literal 4522
zcmb7|=RXvH;f%9K_UO(ga%W~;_EF|nMkLNAJ6lF)hR8ltCfim-|Tsr;LZFzxq{ogxK%oFWTwQR35i%bP0=&XI}5XO%fI2e^DtI0*>WzHjPRy
z5YN)O7YrO!msL`a`{<&yCi9X%pnM}knmA>sCSa{2mzl7%PfnM!a&GXOR}zy6c_edE
zt*Fz|tMd9;!@a6AS}U?GwW9^h(&;r>-vWGVi{P<6Ojz(V
z8D4G?^!=^yWWN4L!Bo$yQ_QOf^khNMu~WP7XL6zq!#{5^sCz+G=+l=n1%Azp=m&F~
z+)tJPoc`)1Y!BmSX|^3zp$;`wuf))Y`Md4{;`%vVDO}GV;OkJrs&crNn2`2;_F8=_
zIY)Hef=N~3Yo{!&Yfq{e(G-;q_k_uVg6y8K^bTG1JtJCku7H29tlmU=dBrIEb?7Fm
zOBfkU&avi*(95^5?Z28(-rn2CLwb=x?CS%zGw57Usleo~KzKZV3MGM-uR}{hLqL;e_xED6fv38iSMgppD=!t*cI
z@I^H6O=2KHu)zTLGCZ5BW=Om;V~UNhu3YU;Fv9TU
zqV>?$h4^6#vwTiok$WNES(2!SIU1WAwn%#)q7T*zKHT*$YuzWKNG(>S+e%JM?E0P>
zGC`)38upvYO-C?lVb@i?Y_6kB6oJIQYQ;uL7iI~r@1fUoIfWr+aI-x9jBVA%5&tssCq{lYP+Rg4S6+@oZY
zmT8OzOU#-o_YoSRG`&Wa@@fE?O7kh86Wr6OFEY@+*ecbY&EctZ8PnIMP=qGN{
zY&Q2!V3J9*7m3Lyi-`_!`z;!bNYm-}$~o3+Om{1|KG0mz>&d~kS;l;LgZxT!Nwbg)vSdpXxBny^y8K46UyNC&
zqp|y!V}baU2&hidI)E_>qBB#ZZzM2h;NX{4%bh;USL1f*o+WMzl^nF80^0^uOY;K*
zs<|YE5c#$8*aN<)f^OGSF$-mE?%V1uM`lm6e`b&gbJvK`B{q}<_RKJI&zWTx7*l$5
z05@k-+9QHkU&kq+e%D44wfEu)920hw=>7y1_PFObg*;bzkLq}WhVh7W6GYE!G$WSG
zc&2-=%f08rJ+-msuadzPFd=#$=$!YsU~**;eC6gNmLBN&Vs@v3mzrWL*Cl?f4NhqmR
zDVda_3Bac>>llbIKdVkNDxUQYAQv&z?*Sn0v&g!f_LEl0X`+lk`!pd)YL^S#mYIGM
z&e{OaS5*!&Ddn9g8M~)rmVty&$FY#nh9Lvrt>xme?BEK4|$OO7<2-&
zF}rhhX1oYPK8b=*L1m0lmJ&;yzb5R-%R|zZvqi+sp1ou9Exd}Ifgztp<1nb)(oF*y
z5|52v77P(iIU=HoJy0F>2lCQ>|9m_u>`Ug=6D4){^ntON0O{icsW~bQqz@J+hdM}W
zu7E_0Jv=OSFX~$?Syj=A!;$bL9vPC6+{T^t-30zeh&+*jueY-iS-NRqG4u-pgVDCJ
zIObv~GH{K)hNg)aA1H+jpVmZBwlSpFKCKsOV4PiUP)$R)XTY&C%b4LE?U-315o=9^
z7E%MA8Hmb=r$8}fD|yhn8&=o~R}Xx}mR#oxp8SfkmD~!->|&d>;Da(M<~-m0R>>
ze)&~$ZWQT%xcv@*uA#wMeA~#o%P~TBe=M@9SfAse+eH>l`hUyR?lQ%o9xj5`@#~K1
z)lYSe`NmBksgBjY875ZdtmI@W=Jp?8k>*50?F7-g8>ZM=y!P6F3dVGRZ&(WWz(v_v
zO+~A^7{L#4Sy5z*32`Y*B%d7Y@nBel%+<)EN@|=AF~BW`LG47z1((z|gcY-ktY)tI
zP@z`YWgIfXn4K+GZd}0AR@9rCV7;^;u=2ySL2s_I}y
zR}Rc83+*ArbsXGAtUF6Q1Dx>+>JjX72#qb9flJ1D5Jts0y(R+1IgmK|4GyP8fjyc*
zB}kp}P%5D8(@uJl$Lfd8l|D64I3UC06LXvun-tD|yHy)-G`Yel#;;(?o1IK?Bt0Cz
zEN1$cbne;DwG|=m*c$zpx=IieUZK2Y3BGH-Eq&<{c4zDk+m=++vkuRT52~XiLCe9BKN}|8X
zlKOly{~nYc7X-n{3oZLcLw88pb2HQJB^@w@CF7xMtDUyGv7vTw@!)p}^6AOSOcS&k
z4)U6bSvtD9WzatA-3n?Nmh^N+NJW4y