Merge branch 'dev' of https://github.com/h4h13/RetroMusicPlayer into dev
Conflicts: README.md app/build.gradle app/src/main/java/code/name/monkey/retromusic/activities/PurchaseActivity.kt app/src/main/java/code/name/monkey/retromusic/activities/SupportDevelopmentActivity.kt app/src/main/java/code/name/monkey/retromusic/fragments/player/lockscreen/LockScreenPlayerControlsFragment.kt app/src/main/java/code/name/monkey/retromusic/interfaces/CabHolder.kt app/src/main/java/code/name/monkey/retromusic/interfaces/MainActivityFragmentCallbacks.kt app/src/main/java/code/name/monkey/retromusic/interfaces/MusicServiceEventListener.kt app/src/main/java/code/name/monkey/retromusic/interfaces/PaletteColorHolder.kt app/src/main/java/code/name/monkey/retromusic/util/AppRater.kt app/src/main/java/io/github/muntashirakon/music/App.kt app/src/main/java/io/github/muntashirakon/music/Constants.kt app/src/main/java/io/github/muntashirakon/music/HomeSection.kt app/src/main/java/io/github/muntashirakon/music/MainModule.kt app/src/main/java/io/github/muntashirakon/music/activities/DriveModeActivity.kt app/src/main/java/io/github/muntashirakon/music/activities/LicenseActivity.java app/src/main/java/io/github/muntashirakon/music/activities/LockScreenActivity.kt app/src/main/java/io/github/muntashirakon/music/activities/LyricsActivity.kt app/src/main/java/io/github/muntashirakon/music/activities/MainActivity.kt app/src/main/java/io/github/muntashirakon/music/activities/PermissionActivity.kt app/src/main/java/io/github/muntashirakon/music/activities/PlayingQueueActivity.kt app/src/main/java/io/github/muntashirakon/music/activities/SettingsActivity.kt app/src/main/java/io/github/muntashirakon/music/activities/ShareInstagramStory.kt app/src/main/java/io/github/muntashirakon/music/activities/UserInfoActivity.kt app/src/main/java/io/github/muntashirakon/music/activities/WhatsNewActivity.java app/src/main/java/io/github/muntashirakon/music/activities/base/AbsBaseActivity.kt app/src/main/java/io/github/muntashirakon/music/activities/base/AbsMusicServiceActivity.kt app/src/main/java/io/github/muntashirakon/music/activities/base/AbsSlidingMusicPanelActivity.kt app/src/main/java/io/github/muntashirakon/music/activities/base/AbsThemeActivity.kt app/src/main/java/io/github/muntashirakon/music/activities/bugreport/BugReportActivity.kt app/src/main/java/io/github/muntashirakon/music/activities/bugreport/model/DeviceInfo.java app/src/main/java/io/github/muntashirakon/music/activities/bugreport/model/Report.java app/src/main/java/io/github/muntashirakon/music/activities/saf/SAFGuideActivity.java app/src/main/java/io/github/muntashirakon/music/activities/tageditor/AbsTagEditorActivity.kt app/src/main/java/io/github/muntashirakon/music/activities/tageditor/AlbumTagEditorActivity.kt app/src/main/java/io/github/muntashirakon/music/activities/tageditor/SongTagEditorActivity.kt app/src/main/java/io/github/muntashirakon/music/activities/tageditor/WriteTagsAsyncTask.java app/src/main/java/io/github/muntashirakon/music/adapter/CategoryInfoAdapter.java app/src/main/java/io/github/muntashirakon/music/adapter/ContributorAdapter.kt app/src/main/java/io/github/muntashirakon/music/adapter/GenreAdapter.kt app/src/main/java/io/github/muntashirakon/music/adapter/HomeAdapter.kt app/src/main/java/io/github/muntashirakon/music/adapter/SearchAdapter.kt app/src/main/java/io/github/muntashirakon/music/adapter/SongFileAdapter.kt app/src/main/java/io/github/muntashirakon/music/adapter/TranslatorsAdapter.kt app/src/main/java/io/github/muntashirakon/music/adapter/album/AlbumAdapter.kt app/src/main/java/io/github/muntashirakon/music/adapter/album/AlbumCoverPagerAdapter.kt app/src/main/java/io/github/muntashirakon/music/adapter/album/HorizontalAlbumAdapter.kt app/src/main/java/io/github/muntashirakon/music/adapter/artist/ArtistAdapter.kt app/src/main/java/io/github/muntashirakon/music/adapter/base/AbsMultiSelectAdapter.java app/src/main/java/io/github/muntashirakon/music/adapter/base/MediaEntryViewHolder.java app/src/main/java/io/github/muntashirakon/music/adapter/playlist/LegacyPlaylistAdapter.kt app/src/main/java/io/github/muntashirakon/music/adapter/playlist/PlaylistAdapter.kt app/src/main/java/io/github/muntashirakon/music/adapter/song/AbsOffsetSongAdapter.kt app/src/main/java/io/github/muntashirakon/music/adapter/song/OrderablePlaylistSongAdapter.kt app/src/main/java/io/github/muntashirakon/music/adapter/song/PlayingQueueAdapter.kt app/src/main/java/io/github/muntashirakon/music/adapter/song/PlaylistSongAdapter.kt app/src/main/java/io/github/muntashirakon/music/adapter/song/ShuffleButtonSongAdapter.kt app/src/main/java/io/github/muntashirakon/music/adapter/song/SimpleSongAdapter.kt app/src/main/java/io/github/muntashirakon/music/adapter/song/SongAdapter.kt app/src/main/java/io/github/muntashirakon/music/appshortcuts/AppShortcutIconGenerator.kt app/src/main/java/io/github/muntashirakon/music/appshortcuts/AppShortcutLauncherActivity.kt app/src/main/java/io/github/muntashirakon/music/appshortcuts/DynamicShortcutManager.kt app/src/main/java/io/github/muntashirakon/music/appshortcuts/shortcuttype/BaseShortcutType.kt app/src/main/java/io/github/muntashirakon/music/appshortcuts/shortcuttype/LastAddedShortcutType.kt app/src/main/java/io/github/muntashirakon/music/appshortcuts/shortcuttype/ShuffleAllShortcutType.kt app/src/main/java/io/github/muntashirakon/music/appshortcuts/shortcuttype/TopTracksShortcutType.kt app/src/main/java/io/github/muntashirakon/music/appwidgets/AppWidgetBig.kt app/src/main/java/io/github/muntashirakon/music/appwidgets/AppWidgetCard.kt app/src/main/java/io/github/muntashirakon/music/appwidgets/AppWidgetClassic.kt app/src/main/java/io/github/muntashirakon/music/appwidgets/AppWidgetSmall.kt app/src/main/java/io/github/muntashirakon/music/appwidgets/AppWidgetText.kt app/src/main/java/io/github/muntashirakon/music/appwidgets/BootReceiver.kt app/src/main/java/io/github/muntashirakon/music/appwidgets/base/BaseAppWidget.kt app/src/main/java/io/github/muntashirakon/music/db/BlackListStoreDao.kt app/src/main/java/io/github/muntashirakon/music/db/BlackListStoreEntity.kt app/src/main/java/io/github/muntashirakon/music/db/HistoryDao.kt app/src/main/java/io/github/muntashirakon/music/db/HistoryEntity.kt app/src/main/java/io/github/muntashirakon/music/db/LyricsDao.kt app/src/main/java/io/github/muntashirakon/music/db/LyricsEntity.kt app/src/main/java/io/github/muntashirakon/music/db/PlayCountDao.kt app/src/main/java/io/github/muntashirakon/music/db/PlayCountEntity.kt app/src/main/java/io/github/muntashirakon/music/db/PlaylistDao.kt app/src/main/java/io/github/muntashirakon/music/db/PlaylistEntity.kt app/src/main/java/io/github/muntashirakon/music/db/PlaylistWithSongs.kt app/src/main/java/io/github/muntashirakon/music/db/RetroDatabase.kt app/src/main/java/io/github/muntashirakon/music/db/SongEntity.kt app/src/main/java/io/github/muntashirakon/music/db/SongExtension.kt app/src/main/java/io/github/muntashirakon/music/dialogs/AddToPlaylistDialog.kt app/src/main/java/io/github/muntashirakon/music/dialogs/BlacklistFolderChooserDialog.java app/src/main/java/io/github/muntashirakon/music/dialogs/CreatePlaylistDialog.kt app/src/main/java/io/github/muntashirakon/music/dialogs/DeletePlaylistDialog.kt app/src/main/java/io/github/muntashirakon/music/dialogs/DeleteSongsDialog.kt app/src/main/java/io/github/muntashirakon/music/dialogs/ImportPlaylistDialog.kt app/src/main/java/io/github/muntashirakon/music/dialogs/LyricsDialog.kt app/src/main/java/io/github/muntashirakon/music/dialogs/RemoveSongFromPlaylistDialog.kt app/src/main/java/io/github/muntashirakon/music/dialogs/RenamePlaylistDialog.kt app/src/main/java/io/github/muntashirakon/music/dialogs/SavePlaylistDialog.kt app/src/main/java/io/github/muntashirakon/music/dialogs/SleepTimerDialog.kt app/src/main/java/io/github/muntashirakon/music/dialogs/SongDetailDialog.kt app/src/main/java/io/github/muntashirakon/music/dialogs/SongShareDialog.kt app/src/main/java/io/github/muntashirakon/music/extensions/ActivityEx.kt app/src/main/java/io/github/muntashirakon/music/extensions/ColorExt.kt app/src/main/java/io/github/muntashirakon/music/extensions/CursorExtensions.kt app/src/main/java/io/github/muntashirakon/music/extensions/DialogExtension.kt app/src/main/java/io/github/muntashirakon/music/extensions/DimenExtension.kt app/src/main/java/io/github/muntashirakon/music/extensions/DrawableExt.kt app/src/main/java/io/github/muntashirakon/music/extensions/FragmentExt.kt app/src/main/java/io/github/muntashirakon/music/extensions/NavigationExtensions.kt app/src/main/java/io/github/muntashirakon/music/extensions/PaletteEX.kt app/src/main/java/io/github/muntashirakon/music/extensions/Preference.kt app/src/main/java/io/github/muntashirakon/music/extensions/ViewExtensions.kt app/src/main/java/io/github/muntashirakon/music/fragments/AlbumCoverStyle.kt app/src/main/java/io/github/muntashirakon/music/fragments/CoroutineViewModel.kt app/src/main/java/io/github/muntashirakon/music/fragments/DetailListFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/LibraryViewModel.kt app/src/main/java/io/github/muntashirakon/music/fragments/MiniPlayerFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/NowPlayingScreen.kt app/src/main/java/io/github/muntashirakon/music/fragments/VolumeFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/about/AboutFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/albums/AlbumDetailsFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/albums/AlbumDetailsViewModel.kt app/src/main/java/io/github/muntashirakon/music/fragments/albums/AlbumsFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/artists/ArtistDetailsFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/artists/ArtistDetailsViewModel.kt app/src/main/java/io/github/muntashirakon/music/fragments/artists/ArtistsFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/base/AbsMainActivityFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/base/AbsMusicServiceFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/base/AbsPlayerControlsFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/base/AbsPlayerFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/base/AbsRecyclerViewCustomGridSizeFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/base/AbsRecyclerViewFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/folder/FoldersFragment.java app/src/main/java/io/github/muntashirakon/music/fragments/genres/GenreDetailsFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/genres/GenreDetailsViewModel.kt app/src/main/java/io/github/muntashirakon/music/fragments/genres/GenresFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/home/HomeFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/library/LibraryFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/player/NowPlayingPlayerFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/player/PlayerAlbumCoverFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/player/adaptive/AdaptiveFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/player/adaptive/AdaptivePlaybackControlsFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/player/blur/BlurPlaybackControlsFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/player/blur/BlurPlayerFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/player/card/CardFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/player/card/CardPlaybackControlsFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/player/cardblur/CardBlurFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/player/cardblur/CardBlurPlaybackControlsFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/player/circle/CirclePlayerFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/player/classic/ClassicPlayerFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/player/color/ColorFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/player/color/ColorPlaybackControlsFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/player/fit/FitFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/player/fit/FitPlaybackControlsFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/player/flat/FlatPlaybackControlsFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/player/flat/FlatPlayerFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/player/full/FullPlaybackControlsFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/player/full/FullPlayerFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/player/gradient/GradientPlayerFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/player/home/HomePlayerFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/player/lockscreen/LockScreenControlsFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/player/lockscreen/LockScreenPlayerControlsFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/player/material/MaterialControlsFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/player/material/MaterialFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/player/normal/PlayerFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/player/normal/PlayerPlaybackControlsFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/player/peak/PeakPlayerControlFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/player/peak/PeakPlayerFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/player/plain/PlainPlaybackControlsFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/player/plain/PlainPlayerFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/player/simple/SimplePlaybackControlsFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/player/simple/SimplePlayerFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/player/tiny/TinyPlaybackControlsFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/player/tiny/TinyPlayerFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/playlists/PlaylistDetailsFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/playlists/PlaylistDetailsViewModel.kt app/src/main/java/io/github/muntashirakon/music/fragments/playlists/PlaylistsFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/search/SearchFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/search/SearchViewModel.kt app/src/main/java/io/github/muntashirakon/music/fragments/settings/AbsSettingsFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/settings/AudioSettings.kt app/src/main/java/io/github/muntashirakon/music/fragments/settings/ImageSettingFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/settings/MainSettingsFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/settings/NotificationSettingsFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/settings/NowPlayingSettingsFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/settings/OtherSettingsFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/settings/PersonalizeSettingsFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/settings/ThemeSettingsFragment.kt app/src/main/java/io/github/muntashirakon/music/fragments/songs/SongsFragment.kt app/src/main/java/io/github/muntashirakon/music/glide/AlbumGlideRequest.java app/src/main/java/io/github/muntashirakon/music/glide/ArtistGlideRequest.java app/src/main/java/io/github/muntashirakon/music/glide/BlurTransformation.kt app/src/main/java/io/github/muntashirakon/music/glide/ProfileBannerGlideRequest.java app/src/main/java/io/github/muntashirakon/music/glide/RetroMusicColoredTarget.kt app/src/main/java/io/github/muntashirakon/music/glide/RetroMusicGlideModule.kt app/src/main/java/io/github/muntashirakon/music/glide/SingleColorTarget.kt app/src/main/java/io/github/muntashirakon/music/glide/SongGlideRequest.java app/src/main/java/io/github/muntashirakon/music/glide/UserProfileGlideRequest.java app/src/main/java/io/github/muntashirakon/music/glide/artistimage/ArtistImageLoader.kt app/src/main/java/io/github/muntashirakon/music/glide/palette/BitmapPaletteTranscoder.java app/src/main/java/io/github/muntashirakon/music/helper/HorizontalAdapterHelper.kt app/src/main/java/io/github/muntashirakon/music/helper/MusicPlayerRemote.kt app/src/main/java/io/github/muntashirakon/music/helper/MusicProgressViewUpdateHelper.kt app/src/main/java/io/github/muntashirakon/music/helper/PlayPauseButtonOnClickHandler.kt app/src/main/java/io/github/muntashirakon/music/helper/SearchQueryHelper.kt app/src/main/java/io/github/muntashirakon/music/helper/ShuffleHelper.kt app/src/main/java/io/github/muntashirakon/music/helper/StopWatch.kt app/src/main/java/io/github/muntashirakon/music/helper/menu/GenreMenuHelper.kt app/src/main/java/io/github/muntashirakon/music/helper/menu/PlaylistMenuHelper.kt app/src/main/java/io/github/muntashirakon/music/helper/menu/SongMenuHelper.kt app/src/main/java/io/github/muntashirakon/music/helper/menu/SongsMenuHelper.kt app/src/main/java/io/github/muntashirakon/music/interfaces/CabHolder.kt app/src/main/java/io/github/muntashirakon/music/interfaces/Callbacks.kt app/src/main/java/io/github/muntashirakon/music/interfaces/ICabHolder.kt app/src/main/java/io/github/muntashirakon/music/interfaces/IMainActivityFragmentCallbacks.kt app/src/main/java/io/github/muntashirakon/music/interfaces/IMusicServiceEventListener.kt app/src/main/java/io/github/muntashirakon/music/interfaces/IPaletteColorHolder.kt app/src/main/java/io/github/muntashirakon/music/interfaces/MainActivityFragmentCallbacks.kt app/src/main/java/io/github/muntashirakon/music/interfaces/MusicServiceEventListener.kt app/src/main/java/io/github/muntashirakon/music/interfaces/PaletteColorHolder.kt app/src/main/java/io/github/muntashirakon/music/lyrics/LrcView.java app/src/main/java/io/github/muntashirakon/music/model/Artist.kt app/src/main/java/io/github/muntashirakon/music/model/lyrics/Lyrics.java app/src/main/java/io/github/muntashirakon/music/providers/BlacklistStore.java app/src/main/java/io/github/muntashirakon/music/providers/MusicPlaybackQueueStore.java app/src/main/java/io/github/muntashirakon/music/repository/GenreRepository.kt app/src/main/java/io/github/muntashirakon/music/repository/PlaylistSongsLoader.kt app/src/main/java/io/github/muntashirakon/music/repository/Repository.kt app/src/main/java/io/github/muntashirakon/music/repository/RoomRepository.kt app/src/main/java/io/github/muntashirakon/music/repository/SongRepository.kt app/src/main/java/io/github/muntashirakon/music/service/MultiPlayer.java app/src/main/java/io/github/muntashirakon/music/service/MusicService.java app/src/main/java/io/github/muntashirakon/music/service/PlaybackHandler.java app/src/main/java/io/github/muntashirakon/music/util/FileUtil.java app/src/main/java/io/github/muntashirakon/music/util/NavigationUtil.java app/src/main/java/io/github/muntashirakon/music/util/PlaylistsUtil.java app/src/main/java/io/github/muntashirakon/music/util/PreferenceUtil.kt app/src/main/java/io/github/muntashirakon/music/util/RetroUtil.java app/src/main/java/io/github/muntashirakon/music/util/SAFUtil.java app/src/main/java/io/github/muntashirakon/music/util/color/MediaNotificationProcessor.java app/src/main/java/io/github/muntashirakon/music/util/color/NotificationColorUtil.java app/src/main/java/io/github/muntashirakon/music/views/BaselineGridTextView.java app/src/main/java/io/github/muntashirakon/music/views/BreadCrumbLayout.java app/src/main/java/io/github/muntashirakon/music/views/CircularImageView.java app/src/main/java/io/github/muntashirakon/music/views/ContributorsView.java app/src/main/java/io/github/muntashirakon/music/views/NetworkImageView.java app/src/main/java/io/github/muntashirakon/music/views/SeekArc.java app/src/main/res/layout-land/fragment_home.xml app/src/main/res/layout-xlarge-land/fragment_blur.xml app/src/main/res/layout/activity_lock_screen.xml app/src/main/res/layout/activity_user_info.xml app/src/main/res/layout/fragment_banner_home.xml app/src/main/res/layout/fragment_classic_player.xml app/src/main/res/layout/fragment_folder.xml app/src/main/res/layout/fragment_home.xml app/src/main/res/layout/item_image.xml app/src/main/res/layout/sliding_music_panel_layout.xml app/src/main/res/navigation/now_playing.xml
This commit is contained in:
commit
3c0fc790d1
442 changed files with 18453 additions and 14559 deletions
|
@ -1,17 +1,17 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Hemanth Savarala.
|
||||
* Copyright (c) 2020 Hemanth Savarla.
|
||||
*
|
||||
* 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 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 io.github.muntashirakon.music.activities
|
||||
|
||||
import android.animation.ObjectAnimator
|
||||
|
@ -234,4 +234,4 @@ class DriveModeActivity : AbsMusicServiceActivity(), Callback {
|
|||
songTotalTime.text = MusicUtil.getReadableDurationString(total.toLong())
|
||||
songCurrentProgress.text = MusicUtil.getReadableDurationString(progress.toLong())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,82 +18,86 @@ 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 io.github.muntashirakon.music.R;
|
||||
import io.github.muntashirakon.music.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.
|
||||
*/
|
||||
/** Created by hemanths on 2019-09-27. */
|
||||
public class LicenseActivity extends AbsBaseActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
setDrawUnderStatusBar();
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_license);
|
||||
setStatusbarColorAuto();
|
||||
setNavigationbarColorAuto();
|
||||
setLightNavigationBar(true);
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
ToolbarContentTintHelper.colorBackButton(toolbar);
|
||||
toolbar.setBackgroundColor(ATHUtil.INSTANCE.resolveColor(this, R.attr.colorSurface));
|
||||
WebView webView = findViewById(R.id.license);
|
||||
try {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
InputStream json = getAssets().open("oldindex.html");
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(json, StandardCharsets.UTF_8));
|
||||
String str;
|
||||
while ((str = in.readLine()) != null) {
|
||||
buf.append(str);
|
||||
}
|
||||
in.close();
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
setDrawUnderStatusBar();
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_license);
|
||||
setStatusbarColorAuto();
|
||||
setNavigationbarColorAuto();
|
||||
setLightNavigationBar(true);
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
ToolbarContentTintHelper.colorBackButton(toolbar);
|
||||
toolbar.setBackgroundColor(ATHUtil.INSTANCE.resolveColor(this, R.attr.colorSurface));
|
||||
WebView webView = findViewById(R.id.license);
|
||||
try {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
InputStream json = getAssets().open("oldindex.html");
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(json, StandardCharsets.UTF_8));
|
||||
String str;
|
||||
while ((str = in.readLine()) != null) {
|
||||
buf.append(str);
|
||||
}
|
||||
in.close();
|
||||
|
||||
// Inject color values for WebView body background and links
|
||||
final boolean isDark = ATHUtil.INSTANCE.isWindowBackgroundDark(this);
|
||||
final String backgroundColor = colorToCSS(ATHUtil.INSTANCE.resolveColor(this, R.attr.colorSurface,
|
||||
Color.parseColor(isDark ? "#424242" : "#ffffff")));
|
||||
final String contentColor = colorToCSS(Color.parseColor(isDark ? "#ffffff" : "#000000"));
|
||||
final String changeLog = buf.toString()
|
||||
.replace("{style-placeholder}",
|
||||
String.format("body { background-color: %s; color: %s; }", backgroundColor, contentColor))
|
||||
.replace("{link-color}", colorToCSS(ThemeStore.Companion.accentColor(this)))
|
||||
.replace("{link-color-active}",
|
||||
colorToCSS(ColorUtil.INSTANCE.lightenColor(ThemeStore.Companion.accentColor(this))));
|
||||
|
||||
webView.loadData(changeLog, "text/html", "UTF-8");
|
||||
} catch (Throwable e) {
|
||||
webView.loadData("<h1>Unable to load</h1><p>" + e.getLocalizedMessage() + "</p>", "text/html", "UTF-8");
|
||||
}
|
||||
// Inject color values for WebView body background and links
|
||||
final boolean isDark = ATHUtil.INSTANCE.isWindowBackgroundDark(this);
|
||||
final String backgroundColor =
|
||||
colorToCSS(
|
||||
ATHUtil.INSTANCE.resolveColor(
|
||||
this, R.attr.colorSurface, Color.parseColor(isDark ? "#424242" : "#ffffff")));
|
||||
final String contentColor = colorToCSS(Color.parseColor(isDark ? "#ffffff" : "#000000"));
|
||||
final String changeLog =
|
||||
buf.toString()
|
||||
.replace(
|
||||
"{style-placeholder}",
|
||||
String.format(
|
||||
"body { background-color: %s; color: %s; }", backgroundColor, contentColor))
|
||||
.replace("{link-color}", colorToCSS(ThemeStore.Companion.accentColor(this)))
|
||||
.replace(
|
||||
"{link-color-active}",
|
||||
colorToCSS(
|
||||
ColorUtil.INSTANCE.lightenColor(ThemeStore.Companion.accentColor(this))));
|
||||
|
||||
webView.loadData(changeLog, "text/html", "UTF-8");
|
||||
} catch (Throwable e) {
|
||||
webView.loadData(
|
||||
"<h1>Unable to load</h1><p>" + e.getLocalizedMessage() + "</p>", "text/html", "UTF-8");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||
if (item.getItemId() == android.R.id.home) {
|
||||
onBackPressed();
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||
if (item.getItemId() == android.R.id.home) {
|
||||
onBackPressed();
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
private 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 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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,17 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Hemanth Savarla.
|
||||
*
|
||||
* 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 io.github.muntashirakon.music.activities
|
||||
|
||||
import android.app.KeyguardManager
|
||||
|
@ -9,7 +23,8 @@ import android.view.WindowManager
|
|||
import androidx.core.view.ViewCompat
|
||||
import io.github.muntashirakon.music.R
|
||||
import io.github.muntashirakon.music.activities.base.AbsMusicServiceActivity
|
||||
import io.github.muntashirakon.music.fragments.player.lockscreen.LockScreenPlayerControlsFragment
|
||||
import io.github.muntashirakon.music.extensions.whichFragment
|
||||
import io.github.muntashirakon.music.fragments.player.lockscreen.LockScreenControlsFragment
|
||||
import io.github.muntashirakon.music.glide.RetroMusicColoredTarget
|
||||
import io.github.muntashirakon.music.glide.SongGlideRequest
|
||||
import io.github.muntashirakon.music.helper.MusicPlayerRemote
|
||||
|
@ -22,21 +37,12 @@ import com.r0adkll.slidr.model.SlidrPosition
|
|||
import kotlinx.android.synthetic.main.activity_lock_screen.*
|
||||
|
||||
class LockScreenActivity : AbsMusicServiceActivity() {
|
||||
private var fragment: LockScreenPlayerControlsFragment? = null
|
||||
private var fragment: LockScreenControlsFragment? = null
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
setDrawUnderStatusBar()
|
||||
super.onCreate(savedInstanceState)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
|
||||
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
|
||||
)
|
||||
}
|
||||
lockScreenInit()
|
||||
setContentView(R.layout.activity_lock_screen)
|
||||
hideStatusBar()
|
||||
setStatusbarColorAuto()
|
||||
|
@ -67,8 +73,7 @@ class LockScreenActivity : AbsMusicServiceActivity() {
|
|||
|
||||
Slidr.attach(this, config)
|
||||
|
||||
fragment =
|
||||
supportFragmentManager.findFragmentById(R.id.playback_controls_fragment) as LockScreenPlayerControlsFragment?
|
||||
fragment = whichFragment<LockScreenControlsFragment>(R.id.playback_controls_fragment)
|
||||
|
||||
findViewById<View>(R.id.slide).apply {
|
||||
translationY = 100f
|
||||
|
@ -77,6 +82,19 @@ class LockScreenActivity : AbsMusicServiceActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun lockScreenInit() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
|
||||
setShowWhenLocked(true)
|
||||
val keyguardManager: KeyguardManager = getSystemService(KeyguardManager::class.java)
|
||||
keyguardManager.requestDismissKeyguard(this, null)
|
||||
} else {
|
||||
this.window.addFlags(
|
||||
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD or
|
||||
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPlayingMetaChanged() {
|
||||
super.onPlayingMetaChanged()
|
||||
updateSongs()
|
||||
|
@ -97,4 +115,4 @@ class LockScreenActivity : AbsMusicServiceActivity() {
|
|||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,25 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Hemanth Savarla.
|
||||
*
|
||||
* 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 io.github.muntashirakon.music.activities
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.view.WindowManager
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.interpolator.view.animation.FastOutSlowInInterpolator
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
||||
import io.github.muntashirakon.music.R
|
||||
|
@ -15,6 +31,10 @@ import io.github.muntashirakon.music.lyrics.LrcView
|
|||
import io.github.muntashirakon.music.model.Song
|
||||
import io.github.muntashirakon.music.util.LyricUtil
|
||||
import io.github.muntashirakon.music.util.RetroUtil
|
||||
import com.google.android.material.color.MaterialColors
|
||||
import com.google.android.material.transition.platform.MaterialArcMotion
|
||||
import com.google.android.material.transition.platform.MaterialContainerTransform
|
||||
import com.google.android.material.transition.platform.MaterialContainerTransformSharedElementCallback
|
||||
import kotlinx.android.synthetic.main.activity_lyrics.*
|
||||
|
||||
class LyricsActivity : AbsMusicServiceActivity(), MusicProgressViewUpdateHelper.Callback {
|
||||
|
@ -31,9 +51,20 @@ class LyricsActivity : AbsMusicServiceActivity(), MusicProgressViewUpdateHelper.
|
|||
return baseUrl
|
||||
}
|
||||
|
||||
private fun buildContainerTransform(): MaterialContainerTransform {
|
||||
val transform = MaterialContainerTransform()
|
||||
transform.setAllContainerColors(
|
||||
MaterialColors.getColor(findViewById(R.id.container), R.attr.colorSurface)
|
||||
)
|
||||
transform.addTarget(R.id.container)
|
||||
transform.duration = 300
|
||||
return transform
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_lyrics)
|
||||
ViewCompat.setTransitionName(container, "lyrics")
|
||||
setStatusbarColorAuto()
|
||||
setTaskDescriptionColorAuto()
|
||||
setNavigationbarColorAuto()
|
||||
|
@ -122,4 +153,4 @@ class LyricsActivity : AbsMusicServiceActivity(), MusicProgressViewUpdateHelper.
|
|||
}
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,17 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Hemanth Savarla.
|
||||
*
|
||||
* 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 io.github.muntashirakon.music.activities
|
||||
|
||||
import android.content.Intent
|
||||
|
@ -8,17 +22,45 @@ import android.os.Bundle
|
|||
import android.provider.MediaStore
|
||||
import android.view.View
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import io.github.muntashirakon.music.*
|
||||
import androidx.navigation.ui.NavigationUI
|
||||
import io.github.muntashirakon.music.ADAPTIVE_COLOR_APP
|
||||
import io.github.muntashirakon.music.ALBUM_COVER_STYLE
|
||||
import io.github.muntashirakon.music.ALBUM_COVER_TRANSFORM
|
||||
import io.github.muntashirakon.music.BANNER_IMAGE_PATH
|
||||
import io.github.muntashirakon.music.BLACK_THEME
|
||||
import io.github.muntashirakon.music.CAROUSEL_EFFECT
|
||||
import io.github.muntashirakon.music.CIRCULAR_ALBUM_ART
|
||||
import io.github.muntashirakon.music.DESATURATED_COLOR
|
||||
import io.github.muntashirakon.music.EXTRA_SONG_INFO
|
||||
import io.github.muntashirakon.music.GENERAL_THEME
|
||||
import io.github.muntashirakon.music.HOME_ARTIST_GRID_STYLE
|
||||
import io.github.muntashirakon.music.KEEP_SCREEN_ON
|
||||
import io.github.muntashirakon.music.LANGUAGE_NAME
|
||||
import io.github.muntashirakon.music.LIBRARY_CATEGORIES
|
||||
import io.github.muntashirakon.music.NOW_PLAYING_SCREEN_ID
|
||||
import io.github.muntashirakon.music.PROFILE_IMAGE_PATH
|
||||
import io.github.muntashirakon.music.R
|
||||
import io.github.muntashirakon.music.ROUND_CORNERS
|
||||
import io.github.muntashirakon.music.TAB_TEXT_MODE
|
||||
import io.github.muntashirakon.music.TOGGLE_ADD_CONTROLS
|
||||
import io.github.muntashirakon.music.TOGGLE_FULL_SCREEN
|
||||
import io.github.muntashirakon.music.TOGGLE_GENRE
|
||||
import io.github.muntashirakon.music.TOGGLE_HOME_BANNER
|
||||
import io.github.muntashirakon.music.TOGGLE_SEPARATE_LINE
|
||||
import io.github.muntashirakon.music.TOGGLE_VOLUME
|
||||
import io.github.muntashirakon.music.USER_NAME
|
||||
import io.github.muntashirakon.music.activities.base.AbsSlidingMusicPanelActivity
|
||||
import io.github.muntashirakon.music.extensions.findNavController
|
||||
import io.github.muntashirakon.music.helper.MusicPlayerRemote
|
||||
import io.github.muntashirakon.music.helper.SearchQueryHelper.getSongs
|
||||
import io.github.muntashirakon.music.model.CategoryInfo
|
||||
import io.github.muntashirakon.music.model.Song
|
||||
import io.github.muntashirakon.music.repository.PlaylistSongsLoader
|
||||
import io.github.muntashirakon.music.service.MusicService
|
||||
import io.github.muntashirakon.music.util.PreferenceUtil
|
||||
import kotlinx.coroutines.Dispatchers.IO
|
||||
import kotlinx.coroutines.launch
|
||||
import org.koin.android.ext.android.get
|
||||
|
||||
class MainActivity : AbsSlidingMusicPanelActivity(), OnSharedPreferenceChangeListener {
|
||||
companion object {
|
||||
|
@ -28,21 +70,43 @@ class MainActivity : AbsSlidingMusicPanelActivity(), OnSharedPreferenceChangeLis
|
|||
}
|
||||
|
||||
override fun createContentView(): View {
|
||||
return wrapSlidingMusicPanel(R.layout.activity_main_content)
|
||||
return wrapSlidingMusicPanel()
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
setDrawUnderStatusBar()
|
||||
super.onCreate(savedInstanceState)
|
||||
if (!hasPermissions()) {
|
||||
findNavController(R.id.fragment_container).navigate(R.id.permissionFragment)
|
||||
}
|
||||
setStatusbarColorAuto()
|
||||
setNavigationbarColorAuto()
|
||||
setLightNavigationBar(true)
|
||||
setTaskDescriptionColorAuto()
|
||||
hideStatusBar()
|
||||
updateTabs()
|
||||
|
||||
// NavigationUI.setupWithNavController(getBottomNavigationView(), findNavController(R.id.fragment_container))
|
||||
setupNavigationController()
|
||||
if (!hasPermissions()) {
|
||||
findNavController(R.id.fragment_container).navigate(R.id.permissionFragment)
|
||||
}
|
||||
|
||||
showPromotionalDialog()
|
||||
}
|
||||
|
||||
private fun showPromotionalDialog() {
|
||||
|
||||
}
|
||||
|
||||
private fun setupNavigationController() {
|
||||
val navController = findNavController(R.id.fragment_container)
|
||||
val navInflater = navController.navInflater
|
||||
val navGraph = navInflater.inflate(R.navigation.main_graph)
|
||||
|
||||
val categoryInfo: CategoryInfo = PreferenceUtil.libraryCategory.first { it.visible }
|
||||
if (categoryInfo.visible) {
|
||||
navGraph.startDestination = categoryInfo.category.id
|
||||
}
|
||||
navController.graph = navGraph
|
||||
NavigationUI.setupWithNavController(getBottomNavigationView(), navController)
|
||||
}
|
||||
|
||||
override fun onSupportNavigateUp(): Boolean =
|
||||
|
@ -98,8 +162,7 @@ class MainActivity : AbsSlidingMusicPanelActivity(), OnSharedPreferenceChangeLis
|
|||
val id = parseLongFromIntent(intent, "playlistId", "playlist")
|
||||
if (id >= 0L) {
|
||||
val position: Int = intent.getIntExtra("position", 0)
|
||||
val songs: List<Song> =
|
||||
PlaylistSongsLoader.getPlaylistSongList(this@MainActivity, id)
|
||||
val songs: List<Song> = PlaylistSongsLoader.getPlaylistSongList(get(), id)
|
||||
MusicPlayerRemote.openQueue(songs, position, true)
|
||||
handled = true
|
||||
}
|
||||
|
@ -107,8 +170,9 @@ class MainActivity : AbsSlidingMusicPanelActivity(), OnSharedPreferenceChangeLis
|
|||
val id = parseLongFromIntent(intent, "albumId", "album")
|
||||
if (id >= 0L) {
|
||||
val position: Int = intent.getIntExtra("position", 0)
|
||||
val songs = libraryViewModel.albumById(id).songs
|
||||
MusicPlayerRemote.openQueue(
|
||||
libraryViewModel.albumById(id).songs,
|
||||
songs,
|
||||
position,
|
||||
true
|
||||
)
|
||||
|
@ -118,8 +182,9 @@ class MainActivity : AbsSlidingMusicPanelActivity(), OnSharedPreferenceChangeLis
|
|||
val id = parseLongFromIntent(intent, "artistId", "artist")
|
||||
if (id >= 0L) {
|
||||
val position: Int = intent.getIntExtra("position", 0)
|
||||
val songs: List<Song> = libraryViewModel.artistById(id).songs
|
||||
MusicPlayerRemote.openQueue(
|
||||
libraryViewModel.artistById(id).songs,
|
||||
songs,
|
||||
position,
|
||||
true
|
||||
)
|
||||
|
@ -130,11 +195,11 @@ class MainActivity : AbsSlidingMusicPanelActivity(), OnSharedPreferenceChangeLis
|
|||
setIntent(Intent())
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun parseLongFromIntent(
|
||||
intent: Intent, longKey: String,
|
||||
intent: Intent,
|
||||
longKey: String,
|
||||
stringKey: String
|
||||
): Long {
|
||||
var id = intent.getLongExtra(longKey, -1)
|
||||
|
@ -150,4 +215,4 @@ class MainActivity : AbsSlidingMusicPanelActivity(), OnSharedPreferenceChangeLis
|
|||
}
|
||||
return id
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,17 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Hemanth Savarla.
|
||||
*
|
||||
* 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 io.github.muntashirakon.music.activities
|
||||
|
||||
import android.content.Intent
|
||||
|
@ -13,7 +27,6 @@ import io.github.muntashirakon.music.extensions.show
|
|||
import io.github.muntashirakon.music.util.RingtoneManager
|
||||
import kotlinx.android.synthetic.main.activity_permission.*
|
||||
|
||||
|
||||
class PermissionActivity : AbsMusicServiceActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
@ -37,7 +50,7 @@ class PermissionActivity : AbsMusicServiceActivity() {
|
|||
}
|
||||
finish.accentBackgroundColor()
|
||||
finish.setOnClickListener {
|
||||
if (hasPermissions() && !RingtoneManager.requiresDialog(this)) {
|
||||
if (hasPermissions()) {
|
||||
startActivity(
|
||||
Intent(this, MainActivity::class.java).addFlags(
|
||||
Intent.FLAG_ACTIVITY_NEW_TASK or
|
||||
|
@ -56,4 +69,4 @@ class PermissionActivity : AbsMusicServiceActivity() {
|
|||
)
|
||||
appNameText.text = appName
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,17 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Hemanth Savarla.
|
||||
*
|
||||
* 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 io.github.muntashirakon.music.activities
|
||||
|
||||
import android.content.res.ColorStateList
|
||||
|
|
|
@ -1,8 +1,23 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Hemanth Savarla.
|
||||
*
|
||||
* 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 io.github.muntashirakon.music.activities
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.MenuItem
|
||||
import androidx.navigation.NavController
|
||||
import androidx.navigation.NavDestination
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.appthemehelper.util.VersionUtils
|
||||
import com.afollestad.materialdialogs.color.ColorChooserDialog
|
||||
|
@ -29,10 +44,26 @@ class SettingsActivity : AbsBaseActivity(), ColorChooserDialog.ColorCallback {
|
|||
applyToolbar(toolbar)
|
||||
val navController: NavController = findNavController(R.id.contentFrame)
|
||||
navController.addOnDestinationChangedListener { _, _, _ ->
|
||||
toolbar.title = navController.currentDestination?.label
|
||||
toolbar.title = navController.currentDestination?.let { getStringFromDestination(it) }
|
||||
}
|
||||
}
|
||||
|
||||
private fun getStringFromDestination(currentDestination: NavDestination): String {
|
||||
val idRes = when (currentDestination.id) {
|
||||
R.id.mainSettingsFragment -> R.string.action_settings
|
||||
R.id.audioSettings -> R.string.pref_header_audio
|
||||
R.id.imageSettingFragment -> R.string.pref_header_images
|
||||
R.id.notificationSettingsFragment -> R.string.notification
|
||||
R.id.nowPlayingSettingsFragment -> R.string.now_playing
|
||||
R.id.otherSettingsFragment -> R.string.others
|
||||
R.id.personalizeSettingsFragment -> R.string.personalize
|
||||
R.id.themeSettingsFragment -> R.string.general_settings_title
|
||||
R.id.aboutActivity -> R.string.action_about
|
||||
else -> R.id.action_settings
|
||||
}
|
||||
return getString(idRes)
|
||||
}
|
||||
|
||||
override fun onSupportNavigateUp(): Boolean {
|
||||
return findNavController(R.id.contentFrame).navigateUp() || super.onSupportNavigateUp()
|
||||
}
|
||||
|
@ -49,7 +80,6 @@ class SettingsActivity : AbsBaseActivity(), ColorChooserDialog.ColorCallback {
|
|||
}
|
||||
|
||||
override fun onColorChooserDismissed(dialog: ColorChooserDialog) {
|
||||
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
|
@ -58,4 +88,4 @@ class SettingsActivity : AbsBaseActivity(), ColorChooserDialog.ColorCallback {
|
|||
}
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Hemanth Savarala.
|
||||
* Copyright (c) 2020 Hemanth Savarla.
|
||||
*
|
||||
* 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 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 io.github.muntashirakon.music.activities
|
||||
|
||||
import android.content.res.ColorStateList
|
||||
|
|
|
@ -1,3 +1,17 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Hemanth Savarla.
|
||||
*
|
||||
* 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 io.github.muntashirakon.music.activities
|
||||
|
||||
import android.app.Activity
|
||||
|
@ -11,12 +25,6 @@ import android.view.MenuItem
|
|||
import android.widget.Toast
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||
import code.name.monkey.appthemehelper.util.MaterialValueHelper
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||
import com.bumptech.glide.request.RequestListener
|
||||
import com.bumptech.glide.request.target.Target
|
||||
import com.github.dhaval2404.imagepicker.ImagePicker
|
||||
import com.github.dhaval2404.imagepicker.constant.ImageProvider
|
||||
import io.github.muntashirakon.music.Constants.USER_BANNER
|
||||
import io.github.muntashirakon.music.Constants.USER_PROFILE
|
||||
import io.github.muntashirakon.music.R
|
||||
|
@ -27,15 +35,21 @@ import io.github.muntashirakon.music.glide.ProfileBannerGlideRequest
|
|||
import io.github.muntashirakon.music.glide.UserProfileGlideRequest
|
||||
import io.github.muntashirakon.music.util.ImageUtil
|
||||
import io.github.muntashirakon.music.util.PreferenceUtil
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||
import com.bumptech.glide.request.RequestListener
|
||||
import com.bumptech.glide.request.target.Target
|
||||
import com.github.dhaval2404.imagepicker.ImagePicker
|
||||
import com.github.dhaval2404.imagepicker.constant.ImageProvider
|
||||
import java.io.BufferedOutputStream
|
||||
import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
import java.io.IOException
|
||||
import kotlinx.android.synthetic.main.activity_user_info.*
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.io.BufferedOutputStream
|
||||
import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
import java.io.IOException
|
||||
|
||||
class UserInfoActivity : AbsBaseActivity() {
|
||||
|
||||
|
@ -55,7 +69,7 @@ class UserInfoActivity : AbsBaseActivity() {
|
|||
pickNewPhoto()
|
||||
}
|
||||
|
||||
bannerSelect.setOnClickListener {
|
||||
bannerImage.setOnClickListener {
|
||||
selectBannerImage()
|
||||
}
|
||||
|
||||
|
@ -114,7 +128,6 @@ class UserInfoActivity : AbsBaseActivity() {
|
|||
.start(PICK_IMAGE_REQUEST)
|
||||
}
|
||||
|
||||
|
||||
public override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
if (resultCode == Activity.RESULT_OK && requestCode == PICK_IMAGE_REQUEST) {
|
||||
|
@ -209,9 +222,8 @@ class UserInfoActivity : AbsBaseActivity() {
|
|||
.into(userImage)
|
||||
}
|
||||
|
||||
|
||||
companion object {
|
||||
private const val PICK_IMAGE_REQUEST = 9002
|
||||
private const val PICK_BANNER_REQUEST = 9004
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,23 +1,14 @@
|
|||
package io.github.muntashirakon.music.activities;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageInfo;
|
||||
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 java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Locale;
|
||||
|
||||
import code.name.monkey.appthemehelper.ThemeStore;
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil;
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil;
|
||||
|
@ -26,65 +17,95 @@ import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper;
|
|||
import io.github.muntashirakon.music.R;
|
||||
import io.github.muntashirakon.music.activities.base.AbsBaseActivity;
|
||||
import io.github.muntashirakon.music.util.PreferenceUtil;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Locale;
|
||||
|
||||
public class WhatsNewActivity extends AbsBaseActivity {
|
||||
|
||||
private static String colorToCSS(int color) {
|
||||
return String.format(Locale.getDefault(), "rgba(%d, %d, %d, %d)", Color.red(color), Color.green(color),
|
||||
Color.blue(color), Color.alpha(color)); // on API 29, WebView doesn't load with hex colors
|
||||
private static String colorToCSS(int color) {
|
||||
return String.format(
|
||||
Locale.getDefault(),
|
||||
"rgba(%d, %d, %d, %d)",
|
||||
Color.red(color),
|
||||
Color.green(color),
|
||||
Color.blue(color),
|
||||
Color.alpha(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.INSTANCE.setLastVersion(currentVersion);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void setChangelogRead(@NonNull Context context) {
|
||||
try {
|
||||
PackageInfo pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
|
||||
int currentVersion = pInfo.versionCode;
|
||||
PreferenceUtil.INSTANCE.setLastVersion(currentVersion);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
setDrawUnderStatusBar();
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_whats_new);
|
||||
setStatusbarColorAuto();
|
||||
setNavigationbarColorAuto();
|
||||
setTaskDescriptionColorAuto();
|
||||
|
||||
WebView webView = findViewById(R.id.webView);
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
toolbar.setBackgroundColor(ATHUtil.INSTANCE.resolveColor(this, R.attr.colorSurface));
|
||||
toolbar.setNavigationOnClickListener(v -> onBackPressed());
|
||||
ToolbarContentTintHelper.colorBackButton(toolbar);
|
||||
|
||||
try {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
InputStream json = getAssets().open("retro-changelog.html");
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(json, StandardCharsets.UTF_8));
|
||||
String str;
|
||||
while ((str = in.readLine()) != null) {
|
||||
buf.append(str);
|
||||
}
|
||||
in.close();
|
||||
|
||||
// Inject color values for WebView body background and links
|
||||
final boolean isDark = ATHUtil.INSTANCE.isWindowBackgroundDark(this);
|
||||
final int accentColor = ThemeStore.Companion.accentColor(this);
|
||||
final String backgroundColor =
|
||||
colorToCSS(
|
||||
ATHUtil.INSTANCE.resolveColor(
|
||||
this, R.attr.colorSurface, Color.parseColor(isDark ? "#424242" : "#ffffff")));
|
||||
final String contentColor = colorToCSS(Color.parseColor(isDark ? "#ffffff" : "#000000"));
|
||||
final String textColor = colorToCSS(Color.parseColor(isDark ? "#60FFFFFF" : "#80000000"));
|
||||
final String accentColorString = colorToCSS(ThemeStore.Companion.accentColor(this));
|
||||
final String accentTextColor =
|
||||
colorToCSS(
|
||||
MaterialValueHelper.getPrimaryTextColor(
|
||||
this, ColorUtil.INSTANCE.isColorLight(accentColor)));
|
||||
final String changeLog =
|
||||
buf.toString()
|
||||
.replace(
|
||||
"{style-placeholder}",
|
||||
String.format(
|
||||
"body { background-color: %s; color: %s; } li {color: %s;} .colorHeader {background-color: %s; color: %s;} .tag {color: %s;}",
|
||||
backgroundColor,
|
||||
contentColor,
|
||||
textColor,
|
||||
accentColorString,
|
||||
accentTextColor,
|
||||
accentColorString))
|
||||
.replace("{link-color}", colorToCSS(ThemeStore.Companion.accentColor(this)))
|
||||
.replace(
|
||||
"{link-color-active}",
|
||||
colorToCSS(
|
||||
ColorUtil.INSTANCE.lightenColor(ThemeStore.Companion.accentColor(this))));
|
||||
webView.loadData(changeLog, "text/html", "UTF-8");
|
||||
} catch (Throwable e) {
|
||||
webView.loadData(
|
||||
"<h1>Unable to load</h1><p>" + e.getLocalizedMessage() + "</p>", "text/html", "UTF-8");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
setDrawUnderStatusBar();
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_whats_new);
|
||||
setStatusbarColorAuto();
|
||||
setNavigationbarColorAuto();
|
||||
setTaskDescriptionColorAuto();
|
||||
|
||||
WebView webView = findViewById(R.id.webView);
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
toolbar.setBackgroundColor(ATHUtil.INSTANCE.resolveColor(this, R.attr.colorSurface));
|
||||
toolbar.setNavigationOnClickListener(v -> onBackPressed());
|
||||
ToolbarContentTintHelper.colorBackButton(toolbar);
|
||||
|
||||
try {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
InputStream json = getAssets().open("retro-changelog.html");
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(json, StandardCharsets.UTF_8));
|
||||
String str;
|
||||
while ((str = in.readLine()) != null) {
|
||||
buf.append(str);
|
||||
}
|
||||
in.close();
|
||||
|
||||
// Inject color values for WebView body background and links
|
||||
final boolean isDark = ATHUtil.INSTANCE.isWindowBackgroundDark(this);
|
||||
final int accentColor = ThemeStore.Companion.accentColor(this);
|
||||
final String backgroundColor = colorToCSS(ATHUtil.INSTANCE.resolveColor(this, R.attr.colorSurface, Color.parseColor(isDark ? "#424242" : "#ffffff")));
|
||||
final String contentColor = colorToCSS(Color.parseColor(isDark ? "#ffffff" : "#000000"));
|
||||
final String textColor = colorToCSS(Color.parseColor(isDark ? "#60FFFFFF" : "#80000000"));
|
||||
final String accentColorString = colorToCSS(ThemeStore.Companion.accentColor(this));
|
||||
final String accentTextColor = colorToCSS(MaterialValueHelper.getPrimaryTextColor(this, ColorUtil.INSTANCE.isColorLight(accentColor)));
|
||||
final String changeLog = buf.toString()
|
||||
.replace("{style-placeholder}", String.format("body { background-color: %s; color: %s; } li {color: %s;} .colorHeader {background-color: %s; color: %s;} .tag {color: %s;}", backgroundColor, contentColor, textColor, accentColorString, accentTextColor, accentColorString))
|
||||
.replace("{link-color}", colorToCSS(ThemeStore.Companion.accentColor(this)))
|
||||
.replace("{link-color-active}", colorToCSS(ColorUtil.INSTANCE.lightenColor(ThemeStore.Companion.accentColor(this))));
|
||||
webView.loadData(changeLog, "text/html", "UTF-8");
|
||||
} catch (Throwable e) {
|
||||
webView.loadData("<h1>Unable to load</h1><p>" + e.getLocalizedMessage() + "</p>", "text/html", "UTF-8");
|
||||
}
|
||||
setChangelogRead(this);
|
||||
}
|
||||
}
|
||||
setChangelogRead(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,17 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Hemanth Savarla.
|
||||
*
|
||||
* 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 io.github.muntashirakon.music.activities.base
|
||||
|
||||
import android.Manifest
|
||||
|
@ -12,8 +26,8 @@ import android.view.KeyEvent
|
|||
import android.view.View
|
||||
import androidx.core.app.ActivityCompat
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import io.github.muntashirakon.music.R
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
|
||||
abstract class AbsBaseActivity : AbsThemeActivity() {
|
||||
private var hadPermissions: Boolean = false
|
||||
|
@ -46,7 +60,7 @@ abstract class AbsBaseActivity : AbsThemeActivity() {
|
|||
override fun onPostCreate(savedInstanceState: Bundle?) {
|
||||
super.onPostCreate(savedInstanceState)
|
||||
if (!hasPermissions()) {
|
||||
//requestPermissions()
|
||||
// requestPermissions()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -107,7 +121,7 @@ abstract class AbsBaseActivity : AbsThemeActivity() {
|
|||
this@AbsBaseActivity, Manifest.permission.WRITE_EXTERNAL_STORAGE
|
||||
)
|
||||
) {
|
||||
//User has deny from permission dialog
|
||||
// User has deny from permission dialog
|
||||
Snackbar.make(
|
||||
snackBarContainer,
|
||||
permissionDeniedMessage!!,
|
||||
|
|
|
@ -1,25 +1,44 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Hemanth Savarla.
|
||||
*
|
||||
* 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 io.github.muntashirakon.music.activities.base
|
||||
|
||||
import android.Manifest
|
||||
import android.content.*
|
||||
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.os.Bundle
|
||||
import android.os.IBinder
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import io.github.muntashirakon.music.R
|
||||
import io.github.muntashirakon.music.db.toPlayCount
|
||||
import io.github.muntashirakon.music.helper.MusicPlayerRemote
|
||||
import io.github.muntashirakon.music.interfaces.MusicServiceEventListener
|
||||
import io.github.muntashirakon.music.interfaces.IMusicServiceEventListener
|
||||
import io.github.muntashirakon.music.repository.RealRepository
|
||||
import io.github.muntashirakon.music.service.MusicService.*
|
||||
import java.lang.ref.WeakReference
|
||||
import java.util.*
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import org.koin.android.ext.android.inject
|
||||
import java.lang.ref.WeakReference
|
||||
import java.util.*
|
||||
|
||||
abstract class AbsMusicServiceActivity : AbsBaseActivity(), MusicServiceEventListener {
|
||||
abstract class AbsMusicServiceActivity : AbsBaseActivity(), IMusicServiceEventListener {
|
||||
|
||||
private val mMusicServiceEventListeners = ArrayList<MusicServiceEventListener>()
|
||||
private val mMusicServiceEventListeners = ArrayList<IMusicServiceEventListener>()
|
||||
private val repository: RealRepository by inject()
|
||||
private var serviceToken: MusicPlayerRemote.ServiceToken? = null
|
||||
private var musicStateReceiver: MusicStateReceiver? = null
|
||||
|
@ -49,15 +68,15 @@ abstract class AbsMusicServiceActivity : AbsBaseActivity(), MusicServiceEventLis
|
|||
}
|
||||
}
|
||||
|
||||
fun addMusicServiceEventListener(listener: MusicServiceEventListener?) {
|
||||
if (listener != null) {
|
||||
mMusicServiceEventListeners.add(listener)
|
||||
fun addMusicServiceEventListener(listenerI: IMusicServiceEventListener?) {
|
||||
if (listenerI != null) {
|
||||
mMusicServiceEventListeners.add(listenerI)
|
||||
}
|
||||
}
|
||||
|
||||
fun removeMusicServiceEventListener(listener: MusicServiceEventListener?) {
|
||||
if (listener != null) {
|
||||
mMusicServiceEventListeners.remove(listener)
|
||||
fun removeMusicServiceEventListener(listenerI: IMusicServiceEventListener?) {
|
||||
if (listenerI != null) {
|
||||
mMusicServiceEventListeners.remove(listenerI)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,30 +1,63 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Hemanth Savarla.
|
||||
*
|
||||
* 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 io.github.muntashirakon.music.activities.base
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.ViewTreeObserver
|
||||
import android.widget.FrameLayout
|
||||
import androidx.annotation.LayoutRes
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.lifecycle.Observer
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.commit
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||
import io.github.muntashirakon.music.R
|
||||
import io.github.muntashirakon.music.RetroBottomSheetBehavior
|
||||
import io.github.muntashirakon.music.extensions.hide
|
||||
import io.github.muntashirakon.music.extensions.whichFragment
|
||||
import io.github.muntashirakon.music.extensions.*
|
||||
import io.github.muntashirakon.music.fragments.LibraryViewModel
|
||||
import io.github.muntashirakon.music.fragments.MiniPlayerFragment
|
||||
import io.github.muntashirakon.music.fragments.NowPlayingScreen
|
||||
import io.github.muntashirakon.music.fragments.NowPlayingScreen.*
|
||||
import io.github.muntashirakon.music.fragments.base.AbsPlayerFragment
|
||||
import io.github.muntashirakon.music.fragments.player.adaptive.AdaptiveFragment
|
||||
import io.github.muntashirakon.music.fragments.player.blur.BlurPlayerFragment
|
||||
import io.github.muntashirakon.music.fragments.player.card.CardFragment
|
||||
import io.github.muntashirakon.music.fragments.player.cardblur.CardBlurFragment
|
||||
import io.github.muntashirakon.music.fragments.player.circle.CirclePlayerFragment
|
||||
import io.github.muntashirakon.music.fragments.player.classic.ClassicPlayerFragment
|
||||
import io.github.muntashirakon.music.fragments.player.color.ColorFragment
|
||||
import io.github.muntashirakon.music.fragments.player.fit.FitFragment
|
||||
import io.github.muntashirakon.music.fragments.player.flat.FlatPlayerFragment
|
||||
import io.github.muntashirakon.music.fragments.player.full.FullPlayerFragment
|
||||
import io.github.muntashirakon.music.fragments.player.gradient.GradientPlayerFragment
|
||||
import io.github.muntashirakon.music.fragments.player.material.MaterialFragment
|
||||
import io.github.muntashirakon.music.fragments.player.normal.PlayerFragment
|
||||
import io.github.muntashirakon.music.fragments.player.peak.PeakPlayerFragment
|
||||
import io.github.muntashirakon.music.fragments.player.plain.PlainPlayerFragment
|
||||
import io.github.muntashirakon.music.fragments.player.simple.SimplePlayerFragment
|
||||
import io.github.muntashirakon.music.fragments.player.tiny.TinyPlayerFragment
|
||||
import io.github.muntashirakon.music.helper.MusicPlayerRemote
|
||||
import io.github.muntashirakon.music.model.CategoryInfo
|
||||
import io.github.muntashirakon.music.util.PreferenceUtil
|
||||
import io.github.muntashirakon.music.views.BottomNavigationBarTinted
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior.*
|
||||
import kotlinx.android.synthetic.main.sliding_music_panel_layout.*
|
||||
import org.koin.androidx.viewmodel.ext.android.viewModel
|
||||
|
||||
|
@ -34,9 +67,10 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
|||
}
|
||||
|
||||
protected val libraryViewModel by viewModel<LibraryViewModel>()
|
||||
private lateinit var behavior: RetroBottomSheetBehavior<FrameLayout>
|
||||
private lateinit var bottomSheetBehavior: RetroBottomSheetBehavior<FrameLayout>
|
||||
private var playerFragment: AbsPlayerFragment? = null
|
||||
private var miniPlayerFragment: MiniPlayerFragment? = null
|
||||
private var cps: NowPlayingScreen? = null
|
||||
private var nowPlayingScreen: NowPlayingScreen? = null
|
||||
private var navigationBarColor: Int = 0
|
||||
private var taskColor: Int = 0
|
||||
private var lightStatusBar: Boolean = false
|
||||
|
@ -44,88 +78,90 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
|||
private var paletteColor: Int = Color.WHITE
|
||||
protected abstract fun createContentView(): View
|
||||
private val panelState: Int
|
||||
get() = behavior.state
|
||||
get() = bottomSheetBehavior.state
|
||||
|
||||
private val bottomSheetCallbackList = object : BottomSheetBehavior.BottomSheetCallback() {
|
||||
private val bottomSheetCallbackList = object : BottomSheetCallback() {
|
||||
|
||||
override fun onSlide(bottomSheet: View, slideOffset: Float) {
|
||||
setMiniPlayerAlphaProgress(slideOffset)
|
||||
dimBackground.show()
|
||||
dimBackground.alpha = slideOffset
|
||||
}
|
||||
|
||||
override fun onStateChanged(bottomSheet: View, newState: Int) {
|
||||
when (newState) {
|
||||
BottomSheetBehavior.STATE_EXPANDED -> {
|
||||
STATE_EXPANDED -> {
|
||||
onPanelExpanded()
|
||||
}
|
||||
BottomSheetBehavior.STATE_COLLAPSED -> {
|
||||
STATE_COLLAPSED -> {
|
||||
onPanelCollapsed()
|
||||
dimBackground.hide()
|
||||
}
|
||||
else -> {
|
||||
|
||||
println("Do something")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun getBottomSheetBehavior() = bottomSheetBehavior
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(createContentView())
|
||||
chooseFragmentForTheme()
|
||||
setupSlidingUpPanel()
|
||||
|
||||
setupBottomSheet()
|
||||
updateColor()
|
||||
|
||||
libraryViewModel.paletteColorLiveData.observe(this, Observer {
|
||||
this.paletteColor = it
|
||||
onPaletteColorChanged()
|
||||
})
|
||||
val themeColor = ATHUtil.resolveColor(this, android.R.attr.windowBackground, Color.GRAY)
|
||||
dimBackground.setBackgroundColor(ColorUtil.withAlpha(themeColor, 0.5f))
|
||||
dimBackground.setOnClickListener {
|
||||
println("dimBackground")
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
fun getBottomSheetBehavior() = behavior
|
||||
|
||||
private fun setupBottomSheet() {
|
||||
behavior = BottomSheetBehavior.from(slidingPanel) as RetroBottomSheetBehavior
|
||||
behavior.addBottomSheetCallback(bottomSheetCallbackList)
|
||||
|
||||
if (behavior.state == BottomSheetBehavior.STATE_EXPANDED) {
|
||||
setMiniPlayerAlphaProgress(1f)
|
||||
}
|
||||
bottomSheetBehavior = from(slidingPanel) as RetroBottomSheetBehavior
|
||||
bottomSheetBehavior.addBottomSheetCallback(bottomSheetCallbackList)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
if (cps != PreferenceUtil.nowPlayingScreen) {
|
||||
if (nowPlayingScreen != PreferenceUtil.nowPlayingScreen) {
|
||||
postRecreate()
|
||||
}
|
||||
if (bottomSheetBehavior.state == BottomSheetBehavior.STATE_EXPANDED) {
|
||||
setMiniPlayerAlphaProgress(1f)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
behavior.removeBottomSheetCallback(bottomSheetCallbackList)
|
||||
bottomSheetBehavior.removeBottomSheetCallback(bottomSheetCallbackList)
|
||||
}
|
||||
|
||||
protected fun wrapSlidingMusicPanel(@LayoutRes resId: Int): View {
|
||||
@SuppressLint("InflateParams")
|
||||
protected fun wrapSlidingMusicPanel(): View {
|
||||
val slidingMusicPanelLayout =
|
||||
layoutInflater.inflate(R.layout.sliding_music_panel_layout, null)
|
||||
val contentContainer: ViewGroup =
|
||||
slidingMusicPanelLayout.findViewById(R.id.mainContentFrame)
|
||||
layoutInflater.inflate(resId, contentContainer)
|
||||
layoutInflater.inflate(R.layout.activity_main_content, contentContainer)
|
||||
return slidingMusicPanelLayout
|
||||
}
|
||||
|
||||
fun collapsePanel() {
|
||||
behavior.state = BottomSheetBehavior.STATE_COLLAPSED
|
||||
setMiniPlayerAlphaProgress(0f)
|
||||
bottomSheetBehavior.state = STATE_COLLAPSED
|
||||
}
|
||||
|
||||
fun expandPanel() {
|
||||
behavior.state = BottomSheetBehavior.STATE_EXPANDED
|
||||
bottomSheetBehavior.state = STATE_EXPANDED
|
||||
setMiniPlayerAlphaProgress(1f)
|
||||
}
|
||||
|
||||
private fun setMiniPlayerAlphaProgress(progress: Float) {
|
||||
if (miniPlayerFragment?.view == null) return
|
||||
val alpha = 1 - progress
|
||||
miniPlayerFragment?.view?.alpha = alpha
|
||||
miniPlayerFragment?.view?.visibility = if (alpha == 0f) View.GONE else View.VISIBLE
|
||||
|
@ -150,11 +186,16 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
|||
ViewTreeObserver.OnGlobalLayoutListener {
|
||||
override fun onGlobalLayout() {
|
||||
slidingPanel.viewTreeObserver.removeOnGlobalLayoutListener(this)
|
||||
if (nowPlayingScreen != Peak) {
|
||||
val params = slidingPanel.layoutParams as ViewGroup.LayoutParams
|
||||
params.height = ViewGroup.LayoutParams.MATCH_PARENT
|
||||
slidingPanel.layoutParams = params
|
||||
}
|
||||
when (panelState) {
|
||||
BottomSheetBehavior.STATE_EXPANDED -> onPanelExpanded()
|
||||
BottomSheetBehavior.STATE_COLLAPSED -> onPanelCollapsed()
|
||||
STATE_EXPANDED -> onPanelExpanded()
|
||||
STATE_COLLAPSED -> onPanelCollapsed()
|
||||
else -> {
|
||||
//playerFragment!!.onHide()
|
||||
// playerFragment!!.onHide()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -165,35 +206,6 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
|||
return bottomNavigationView
|
||||
}
|
||||
|
||||
fun hideBottomBarVisibility(visible: Boolean) {
|
||||
bottomNavigationView.isVisible = visible
|
||||
hideBottomBar(MusicPlayerRemote.playingQueue.isEmpty())
|
||||
}
|
||||
|
||||
private fun hideBottomBar(hide: Boolean) {
|
||||
val heightOfBar = bottomNavigationView.height
|
||||
val isBottomBarVisible = bottomNavigationView.isVisible
|
||||
|
||||
if (hide) {
|
||||
behavior.isHideable = true
|
||||
behavior.peekHeight = 0
|
||||
collapsePanel()
|
||||
ViewCompat.setElevation(slidingPanel, 0f)
|
||||
ViewCompat.setElevation(bottomNavigationView, 10f)
|
||||
} else {
|
||||
ViewCompat.setElevation(bottomNavigationView, 10f)
|
||||
ViewCompat.setElevation(slidingPanel, 10f)
|
||||
behavior.isHideable = false
|
||||
behavior.peekHeight = (if (isBottomBarVisible) heightOfBar * 2 else heightOfBar) - 24
|
||||
}
|
||||
}
|
||||
|
||||
private fun chooseFragmentForTheme() {
|
||||
cps = PreferenceUtil.nowPlayingScreen
|
||||
miniPlayerFragment = whichFragment<MiniPlayerFragment>(R.id.miniPlayerFragment)
|
||||
miniPlayerFragment?.view?.setOnClickListener { expandPanel() }
|
||||
}
|
||||
|
||||
override fun onServiceConnected() {
|
||||
super.onServiceConnected()
|
||||
if (MusicPlayerRemote.playingQueue.isNotEmpty()) {
|
||||
|
@ -216,36 +228,38 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
|||
if (!handleBackPress()) super.onBackPressed()
|
||||
}
|
||||
|
||||
open fun handleBackPress(): Boolean {
|
||||
if (panelState == BottomSheetBehavior.STATE_EXPANDED) {
|
||||
private fun handleBackPress(): Boolean {
|
||||
if (bottomSheetBehavior.peekHeight != 0 && playerFragment!!.onBackPressed()) return true
|
||||
if (panelState == STATE_EXPANDED) {
|
||||
collapsePanel()
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
private fun onPaletteColorChanged() {
|
||||
if (panelState == BottomSheetBehavior.STATE_EXPANDED) {
|
||||
if (panelState == STATE_EXPANDED) {
|
||||
super.setTaskDescriptionColor(paletteColor)
|
||||
val isColorLight = ColorUtil.isColorLight(paletteColor)
|
||||
if (PreferenceUtil.isAdaptiveColor && (cps == Normal || cps == Flat)) {
|
||||
if (PreferenceUtil.isAdaptiveColor && (nowPlayingScreen == Normal || nowPlayingScreen == Flat)) {
|
||||
super.setLightNavigationBar(true)
|
||||
super.setLightStatusbar(isColorLight)
|
||||
} else if (cps == Card || cps == Blur || cps == BlurCard) {
|
||||
} else if (nowPlayingScreen == Card || nowPlayingScreen == Blur || nowPlayingScreen == BlurCard) {
|
||||
super.setLightStatusbar(false)
|
||||
super.setLightNavigationBar(true)
|
||||
super.setNavigationbarColor(Color.BLACK)
|
||||
} else if (cps == Color || cps == Tiny || cps == Gradient) {
|
||||
} else if (nowPlayingScreen == Color || nowPlayingScreen == Tiny || nowPlayingScreen == Gradient) {
|
||||
super.setNavigationbarColor(paletteColor)
|
||||
super.setLightNavigationBar(isColorLight)
|
||||
super.setLightStatusbar(isColorLight)
|
||||
} else if (cps == Full) {
|
||||
} else if (nowPlayingScreen == Full) {
|
||||
super.setNavigationbarColor(paletteColor)
|
||||
super.setLightNavigationBar(isColorLight)
|
||||
super.setLightStatusbar(false)
|
||||
} else if (cps == Classic) {
|
||||
} else if (nowPlayingScreen == Classic) {
|
||||
super.setLightStatusbar(false)
|
||||
} else if (cps == Fit) {
|
||||
} else if (nowPlayingScreen == Fit) {
|
||||
super.setLightStatusbar(false)
|
||||
} else {
|
||||
super.setLightStatusbar(
|
||||
|
@ -263,38 +277,32 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
|||
|
||||
override fun setLightStatusbar(enabled: Boolean) {
|
||||
lightStatusBar = enabled
|
||||
if (panelState == BottomSheetBehavior.STATE_COLLAPSED) {
|
||||
if (panelState == STATE_COLLAPSED) {
|
||||
super.setLightStatusbar(enabled)
|
||||
}
|
||||
}
|
||||
|
||||
override fun setLightNavigationBar(enabled: Boolean) {
|
||||
lightNavigationBar = enabled
|
||||
if (panelState == BottomSheetBehavior.STATE_COLLAPSED) {
|
||||
if (panelState == STATE_COLLAPSED) {
|
||||
super.setLightNavigationBar(enabled)
|
||||
}
|
||||
}
|
||||
|
||||
override fun setNavigationbarColor(color: Int) {
|
||||
navigationBarColor = color
|
||||
if (panelState == BottomSheetBehavior.STATE_COLLAPSED) {
|
||||
if (panelState == STATE_COLLAPSED) {
|
||||
super.setNavigationbarColor(color)
|
||||
}
|
||||
}
|
||||
|
||||
override fun setTaskDescriptionColor(color: Int) {
|
||||
taskColor = color
|
||||
if (panelState == BottomSheetBehavior.STATE_COLLAPSED) {
|
||||
if (panelState == STATE_COLLAPSED) {
|
||||
super.setTaskDescriptionColor(color)
|
||||
}
|
||||
}
|
||||
|
||||
fun hideBottomNavigation() {
|
||||
behavior.isHideable = true
|
||||
behavior.peekHeight = 0
|
||||
hideBottomBarVisibility(false)
|
||||
}
|
||||
|
||||
fun updateTabs() {
|
||||
bottomNavigationView.menu.clear()
|
||||
val currentTabs: List<CategoryInfo> = PreferenceUtil.libraryCategory
|
||||
|
@ -308,4 +316,74 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
|||
bottomNavigationView.hide()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateColor() {
|
||||
libraryViewModel.paletteColor.observe(this, { color ->
|
||||
this.paletteColor = color
|
||||
onPaletteColorChanged()
|
||||
})
|
||||
}
|
||||
|
||||
fun setBottomBarVisibility(visible: Int) {
|
||||
bottomNavigationView.visibility = visible
|
||||
hideBottomBar(MusicPlayerRemote.playingQueue.isEmpty())
|
||||
}
|
||||
|
||||
private fun hideBottomBar(hide: Boolean) {
|
||||
val heightOfBar = dip(R.dimen.mini_player_height)
|
||||
val heightOfBarWithTabs = dip(R.dimen.mini_player_height_expanded)
|
||||
val isVisible = bottomNavigationView.isVisible
|
||||
if (hide) {
|
||||
bottomSheetBehavior.isHideable = true
|
||||
bottomSheetBehavior.peekHeight = 0
|
||||
ViewCompat.setElevation(slidingPanel, 0f)
|
||||
ViewCompat.setElevation(bottomNavigationView, 10f)
|
||||
collapsePanel()
|
||||
} else {
|
||||
if (MusicPlayerRemote.playingQueue.isNotEmpty()) {
|
||||
bottomSheetBehavior.isHideable = false
|
||||
ViewCompat.setElevation(slidingPanel, 10f)
|
||||
ViewCompat.setElevation(bottomNavigationView, 10f)
|
||||
if (isVisible) {
|
||||
bottomSheetBehavior.peekHeight = heightOfBarWithTabs
|
||||
bottomNavigationView.translateYAnimate(0f)
|
||||
} else {
|
||||
bottomNavigationView.translateYAnimate(150f)
|
||||
bottomSheetBehavior.peekHeight = heightOfBar
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun chooseFragmentForTheme() {
|
||||
nowPlayingScreen = PreferenceUtil.nowPlayingScreen
|
||||
|
||||
val fragment: Fragment = when (nowPlayingScreen) {
|
||||
Blur -> BlurPlayerFragment()
|
||||
Adaptive -> AdaptiveFragment()
|
||||
Normal -> PlayerFragment()
|
||||
Card -> CardFragment()
|
||||
BlurCard -> CardBlurFragment()
|
||||
Fit -> FitFragment()
|
||||
Flat -> FlatPlayerFragment()
|
||||
Full -> FullPlayerFragment()
|
||||
Plain -> PlainPlayerFragment()
|
||||
Simple -> SimplePlayerFragment()
|
||||
Material -> MaterialFragment()
|
||||
Color -> ColorFragment()
|
||||
Gradient -> GradientPlayerFragment()
|
||||
Tiny -> TinyPlayerFragment()
|
||||
Peak -> PeakPlayerFragment()
|
||||
Circle -> CirclePlayerFragment()
|
||||
Classic -> ClassicPlayerFragment()
|
||||
else -> PlayerFragment()
|
||||
} // must implement AbsPlayerFragment
|
||||
supportFragmentManager.commit {
|
||||
replace(R.id.playerFragmentContainer, fragment)
|
||||
}
|
||||
supportFragmentManager.executePendingTransactions()
|
||||
playerFragment = whichFragment<AbsPlayerFragment>(R.id.playerFragmentContainer)
|
||||
miniPlayerFragment = whichFragment<MiniPlayerFragment>(R.id.miniPlayerFragment)
|
||||
miniPlayerFragment?.view?.setOnClickListener { expandPanel() }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,17 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Hemanth Savarla.
|
||||
*
|
||||
* 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 io.github.muntashirakon.music.activities.base
|
||||
|
||||
import android.content.Context
|
||||
|
@ -37,7 +51,6 @@ abstract class AbsThemeActivity : ATHToolbarActivity(), Runnable {
|
|||
MaterialDialogsUtil.updateMaterialDialogsThemeSingleton(this)
|
||||
}
|
||||
|
||||
|
||||
private fun updateTheme() {
|
||||
setTheme(ThemeManager.getThemeResValue(this))
|
||||
setDefaultNightMode(ThemeManager.getNightMode(this))
|
||||
|
@ -204,4 +217,4 @@ abstract class AbsThemeActivity : ATHToolbarActivity(), Runnable {
|
|||
super.attachBaseContext(LanguageContextWrapper.wrap(newBase, Locale(code)))
|
||||
} else super.attachBaseContext(newBase)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,17 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Hemanth Savarla.
|
||||
*
|
||||
* 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 io.github.muntashirakon.music.activities.bugreport
|
||||
|
||||
import android.app.Activity
|
||||
|
@ -31,6 +45,7 @@ import io.github.muntashirakon.music.misc.DialogAsyncTask
|
|||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
import com.google.android.material.textfield.TextInputLayout
|
||||
import java.io.IOException
|
||||
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.*
|
||||
|
@ -38,7 +53,6 @@ import org.eclipse.egit.github.core.Issue
|
|||
import org.eclipse.egit.github.core.client.GitHubClient
|
||||
import org.eclipse.egit.github.core.client.RequestException
|
||||
import org.eclipse.egit.github.core.service.IssueService
|
||||
import java.io.IOException
|
||||
|
||||
private const val RESULT_SUCCESS = "RESULT_OK"
|
||||
private const val RESULT_BAD_CREDENTIALS = "RESULT_BAD_CREDENTIALS"
|
||||
|
@ -306,7 +320,6 @@ open class BugReportActivity : AbsThemeActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
companion object {
|
||||
|
||||
fun report(
|
||||
|
|
|
@ -5,129 +5,197 @@ import android.content.Context;
|
|||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Build;
|
||||
|
||||
import androidx.annotation.IntRange;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil;
|
||||
import java.util.Arrays;
|
||||
import java.util.Locale;
|
||||
|
||||
import io.github.muntashirakon.music.util.PreferenceUtil;
|
||||
|
||||
public class DeviceInfo {
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
@SuppressWarnings("deprecation")
|
||||
private final String[] abis = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ?
|
||||
Build.SUPPORTED_ABIS : new String[]{Build.CPU_ABI, Build.CPU_ABI2};
|
||||
@SuppressLint("NewApi")
|
||||
@SuppressWarnings("deprecation")
|
||||
private final String[] abis =
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP
|
||||
? Build.SUPPORTED_ABIS
|
||||
: new String[] {Build.CPU_ABI, Build.CPU_ABI2};
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
private final String[] abis32Bits = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ?
|
||||
Build.SUPPORTED_32_BIT_ABIS : null;
|
||||
@SuppressLint("NewApi")
|
||||
private final String[] abis32Bits =
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? Build.SUPPORTED_32_BIT_ABIS : null;
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
private final String[] abis64Bits = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ?
|
||||
Build.SUPPORTED_64_BIT_ABIS : null;
|
||||
@SuppressLint("NewApi")
|
||||
private final String[] abis64Bits =
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? Build.SUPPORTED_64_BIT_ABIS : null;
|
||||
|
||||
private final String baseTheme;
|
||||
private final String baseTheme;
|
||||
|
||||
private final String brand = Build.BRAND;
|
||||
private final String brand = Build.BRAND;
|
||||
|
||||
private final String buildID = Build.DISPLAY;
|
||||
private final String buildID = Build.DISPLAY;
|
||||
|
||||
private final String buildVersion = Build.VERSION.INCREMENTAL;
|
||||
private final String buildVersion = Build.VERSION.INCREMENTAL;
|
||||
|
||||
private final String device = Build.DEVICE;
|
||||
private final String device = Build.DEVICE;
|
||||
|
||||
private final String hardware = Build.HARDWARE;
|
||||
private final String hardware = Build.HARDWARE;
|
||||
|
||||
private final boolean isAdaptive;
|
||||
private final boolean isAdaptive;
|
||||
|
||||
private final String manufacturer = Build.MANUFACTURER;
|
||||
private final String manufacturer = Build.MANUFACTURER;
|
||||
|
||||
private final String model = Build.MODEL;
|
||||
private final String model = Build.MODEL;
|
||||
|
||||
private final String nowPlayingTheme;
|
||||
private final String nowPlayingTheme;
|
||||
|
||||
private final String product = Build.PRODUCT;
|
||||
private final String product = Build.PRODUCT;
|
||||
|
||||
private final String releaseVersion = Build.VERSION.RELEASE;
|
||||
private final String releaseVersion = Build.VERSION.RELEASE;
|
||||
|
||||
@IntRange(from = 0)
|
||||
private final int sdkVersion = Build.VERSION.SDK_INT;
|
||||
@IntRange(from = 0)
|
||||
private final int sdkVersion = Build.VERSION.SDK_INT;
|
||||
|
||||
private final int versionCode;
|
||||
private final int versionCode;
|
||||
|
||||
private final String versionName;
|
||||
private final String selectedLang;
|
||||
private final String versionName;
|
||||
private final String selectedLang;
|
||||
|
||||
public DeviceInfo(Context context) {
|
||||
PackageInfo packageInfo;
|
||||
try {
|
||||
packageInfo = context.getPackageManager()
|
||||
.getPackageInfo(context.getPackageName(), 0);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
packageInfo = null;
|
||||
}
|
||||
if (packageInfo != null) {
|
||||
versionCode = packageInfo.versionCode;
|
||||
versionName = packageInfo.versionName;
|
||||
} else {
|
||||
versionCode = -1;
|
||||
versionName = null;
|
||||
}
|
||||
baseTheme = PreferenceUtil.INSTANCE.getBaseTheme();
|
||||
nowPlayingTheme = context.getString(PreferenceUtil.INSTANCE.getNowPlayingScreen().getTitleRes());
|
||||
isAdaptive = PreferenceUtil.INSTANCE.isAdaptiveColor();
|
||||
selectedLang = PreferenceUtil.INSTANCE.getLanguageCode();
|
||||
public DeviceInfo(Context context) {
|
||||
PackageInfo packageInfo;
|
||||
try {
|
||||
packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
packageInfo = null;
|
||||
}
|
||||
|
||||
public String toMarkdown() {
|
||||
return "Device info:\n"
|
||||
+ "---\n"
|
||||
+ "<table>\n"
|
||||
+ "<tr><td><b>App version</b></td><td>" + versionName + "</td></tr>\n"
|
||||
+ "<tr><td>App version code</td><td>" + versionCode + "</td></tr>\n"
|
||||
+ "<tr><td>Android build version</td><td>" + buildVersion + "</td></tr>\n"
|
||||
+ "<tr><td>Android release version</td><td>" + releaseVersion + "</td></tr>\n"
|
||||
+ "<tr><td>Android SDK version</td><td>" + sdkVersion + "</td></tr>\n"
|
||||
+ "<tr><td>Android build ID</td><td>" + buildID + "</td></tr>\n"
|
||||
+ "<tr><td>Device brand</td><td>" + brand + "</td></tr>\n"
|
||||
+ "<tr><td>Device manufacturer</td><td>" + manufacturer + "</td></tr>\n"
|
||||
+ "<tr><td>Device name</td><td>" + device + "</td></tr>\n"
|
||||
+ "<tr><td>Device model</td><td>" + model + "</td></tr>\n"
|
||||
+ "<tr><td>Device product name</td><td>" + product + "</td></tr>\n"
|
||||
+ "<tr><td>Device hardware name</td><td>" + hardware + "</td></tr>\n"
|
||||
+ "<tr><td>ABIs</td><td>" + Arrays.toString(abis) + "</td></tr>\n"
|
||||
+ "<tr><td>ABIs (32bit)</td><td>" + Arrays.toString(abis32Bits) + "</td></tr>\n"
|
||||
+ "<tr><td>ABIs (64bit)</td><td>" + Arrays.toString(abis64Bits) + "</td></tr>\n"
|
||||
+ "<tr><td>Language</td><td>" + selectedLang + "</td></tr>\n"
|
||||
+ "</table>\n";
|
||||
if (packageInfo != null) {
|
||||
versionCode = packageInfo.versionCode;
|
||||
versionName = packageInfo.versionName;
|
||||
} else {
|
||||
versionCode = -1;
|
||||
versionName = null;
|
||||
}
|
||||
baseTheme = PreferenceUtil.INSTANCE.getBaseTheme();
|
||||
nowPlayingTheme =
|
||||
context.getString(PreferenceUtil.INSTANCE.getNowPlayingScreen().getTitleRes());
|
||||
isAdaptive = PreferenceUtil.INSTANCE.isAdaptiveColor();
|
||||
selectedLang = PreferenceUtil.INSTANCE.getLanguageCode();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String toMarkdown() {
|
||||
return "Device info:\n"
|
||||
+ "---\n"
|
||||
+ "<table>\n"
|
||||
+ "<tr><td><b>App version</b></td><td>"
|
||||
+ versionName
|
||||
+ "</td></tr>\n"
|
||||
+ "<tr><td>App version code</td><td>"
|
||||
+ versionCode
|
||||
+ "</td></tr>\n"
|
||||
+ "<tr><td>Android build version</td><td>"
|
||||
+ buildVersion
|
||||
+ "</td></tr>\n"
|
||||
+ "<tr><td>Android release version</td><td>"
|
||||
+ releaseVersion
|
||||
+ "</td></tr>\n"
|
||||
+ "<tr><td>Android SDK version</td><td>"
|
||||
+ sdkVersion
|
||||
+ "</td></tr>\n"
|
||||
+ "<tr><td>Android build ID</td><td>"
|
||||
+ buildID
|
||||
+ "</td></tr>\n"
|
||||
+ "<tr><td>Device brand</td><td>"
|
||||
+ brand
|
||||
+ "</td></tr>\n"
|
||||
+ "<tr><td>Device manufacturer</td><td>"
|
||||
+ manufacturer
|
||||
+ "</td></tr>\n"
|
||||
+ "<tr><td>Device name</td><td>"
|
||||
+ device
|
||||
+ "</td></tr>\n"
|
||||
+ "<tr><td>Device model</td><td>"
|
||||
+ model
|
||||
+ "</td></tr>\n"
|
||||
+ "<tr><td>Device product name</td><td>"
|
||||
+ product
|
||||
+ "</td></tr>\n"
|
||||
+ "<tr><td>Device hardware name</td><td>"
|
||||
+ hardware
|
||||
+ "</td></tr>\n"
|
||||
+ "<tr><td>ABIs</td><td>"
|
||||
+ Arrays.toString(abis)
|
||||
+ "</td></tr>\n"
|
||||
+ "<tr><td>ABIs (32bit)</td><td>"
|
||||
+ Arrays.toString(abis32Bits)
|
||||
+ "</td></tr>\n"
|
||||
+ "<tr><td>ABIs (64bit)</td><td>"
|
||||
+ Arrays.toString(abis64Bits)
|
||||
+ "</td></tr>\n"
|
||||
+ "<tr><td>Language</td><td>"
|
||||
+ selectedLang
|
||||
+ "</td></tr>\n"
|
||||
+ "</table>\n";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String toString() {
|
||||
return "App version: " + versionName + "\n"
|
||||
+ "App version code: " + versionCode + "\n"
|
||||
+ "Android build version: " + buildVersion + "\n"
|
||||
+ "Android release version: " + releaseVersion + "\n"
|
||||
+ "Android SDK version: " + sdkVersion + "\n"
|
||||
+ "Android build ID: " + buildID + "\n"
|
||||
+ "Device brand: " + brand + "\n"
|
||||
+ "Device manufacturer: " + manufacturer + "\n"
|
||||
+ "Device name: " + device + "\n"
|
||||
+ "Device model: " + model + "\n"
|
||||
+ "Device product name: " + product + "\n"
|
||||
+ "Device hardware name: " + hardware + "\n"
|
||||
+ "ABIs: " + Arrays.toString(abis) + "\n"
|
||||
+ "ABIs (32bit): " + Arrays.toString(abis32Bits) + "\n"
|
||||
+ "ABIs (64bit): " + Arrays.toString(abis64Bits) + "\n"
|
||||
+ "Base theme: " + baseTheme + "\n"
|
||||
+ "Now playing theme: " + nowPlayingTheme + "\n"
|
||||
+ "Adaptive: " + isAdaptive + "\n"
|
||||
+ "System language: " + Locale.getDefault().toLanguageTag() + "\n"
|
||||
+ "In-App Language: " + selectedLang;
|
||||
}
|
||||
public String toString() {
|
||||
return "App version: "
|
||||
+ versionName
|
||||
+ "\n"
|
||||
+ "App version code: "
|
||||
+ versionCode
|
||||
+ "\n"
|
||||
+ "Android build version: "
|
||||
+ buildVersion
|
||||
+ "\n"
|
||||
+ "Android release version: "
|
||||
+ releaseVersion
|
||||
+ "\n"
|
||||
+ "Android SDK version: "
|
||||
+ sdkVersion
|
||||
+ "\n"
|
||||
+ "Android build ID: "
|
||||
+ buildID
|
||||
+ "\n"
|
||||
+ "Device brand: "
|
||||
+ brand
|
||||
+ "\n"
|
||||
+ "Device manufacturer: "
|
||||
+ manufacturer
|
||||
+ "\n"
|
||||
+ "Device name: "
|
||||
+ device
|
||||
+ "\n"
|
||||
+ "Device model: "
|
||||
+ model
|
||||
+ "\n"
|
||||
+ "Device product name: "
|
||||
+ product
|
||||
+ "\n"
|
||||
+ "Device hardware name: "
|
||||
+ hardware
|
||||
+ "\n"
|
||||
+ "ABIs: "
|
||||
+ Arrays.toString(abis)
|
||||
+ "\n"
|
||||
+ "ABIs (32bit): "
|
||||
+ Arrays.toString(abis32Bits)
|
||||
+ "\n"
|
||||
+ "ABIs (64bit): "
|
||||
+ Arrays.toString(abis64Bits)
|
||||
+ "\n"
|
||||
+ "Base theme: "
|
||||
+ baseTheme
|
||||
+ "\n"
|
||||
+ "Now playing theme: "
|
||||
+ nowPlayingTheme
|
||||
+ "\n"
|
||||
+ "Adaptive: "
|
||||
+ isAdaptive
|
||||
+ "\n"
|
||||
+ "System language: "
|
||||
+ Locale.getDefault().toLanguageTag()
|
||||
+ "\n"
|
||||
+ "In-App Language: "
|
||||
+ selectedLang;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,33 +1,34 @@
|
|||
package io.github.muntashirakon.music.activities.bugreport.model;
|
||||
|
||||
|
||||
import io.github.muntashirakon.music.activities.bugreport.model.github.ExtraInfo;
|
||||
|
||||
public class Report {
|
||||
|
||||
private final String description;
|
||||
private final String description;
|
||||
|
||||
private final DeviceInfo deviceInfo;
|
||||
private final DeviceInfo deviceInfo;
|
||||
|
||||
private final ExtraInfo extraInfo;
|
||||
private final ExtraInfo extraInfo;
|
||||
|
||||
private final String title;
|
||||
private final String title;
|
||||
|
||||
public Report(String title, String description, DeviceInfo deviceInfo, ExtraInfo extraInfo) {
|
||||
this.title = title;
|
||||
this.description = description;
|
||||
this.deviceInfo = deviceInfo;
|
||||
this.extraInfo = extraInfo;
|
||||
}
|
||||
public Report(String title, String description, DeviceInfo deviceInfo, ExtraInfo extraInfo) {
|
||||
this.title = title;
|
||||
this.description = description;
|
||||
this.deviceInfo = deviceInfo;
|
||||
this.extraInfo = extraInfo;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description + "\n\n"
|
||||
+ "-\n\n"
|
||||
+ deviceInfo.toMarkdown() + "\n\n"
|
||||
+ extraInfo.toMarkdown();
|
||||
}
|
||||
public String getDescription() {
|
||||
return description
|
||||
+ "\n\n"
|
||||
+ "-\n\n"
|
||||
+ deviceInfo.toMarkdown()
|
||||
+ "\n\n"
|
||||
+ extraInfo.toMarkdown();
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,58 +5,57 @@ import java.util.Map;
|
|||
|
||||
public class ExtraInfo {
|
||||
|
||||
private final Map<String, String> extraInfo = new LinkedHashMap<>();
|
||||
private final Map<String, String> extraInfo = new LinkedHashMap<>();
|
||||
|
||||
public void put(String key, String value) {
|
||||
extraInfo.put(key, value);
|
||||
public void put(String key, String value) {
|
||||
extraInfo.put(key, value);
|
||||
}
|
||||
|
||||
public void put(String key, boolean value) {
|
||||
extraInfo.put(key, Boolean.toString(value));
|
||||
}
|
||||
|
||||
public void put(String key, double value) {
|
||||
extraInfo.put(key, Double.toString(value));
|
||||
}
|
||||
|
||||
public void put(String key, float value) {
|
||||
extraInfo.put(key, Float.toString(value));
|
||||
}
|
||||
|
||||
public void put(String key, long value) {
|
||||
extraInfo.put(key, Long.toString(value));
|
||||
}
|
||||
|
||||
public void put(String key, int value) {
|
||||
extraInfo.put(key, Integer.toString(value));
|
||||
}
|
||||
|
||||
public void put(String key, Object value) {
|
||||
extraInfo.put(key, String.valueOf(value));
|
||||
}
|
||||
|
||||
public void remove(String key) {
|
||||
extraInfo.remove(key);
|
||||
}
|
||||
|
||||
public String toMarkdown() {
|
||||
if (extraInfo.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
|
||||
public void put(String key, boolean value) {
|
||||
extraInfo.put(key, Boolean.toString(value));
|
||||
StringBuilder output = new StringBuilder();
|
||||
output.append("Extra info:\n" + "---\n" + "<table>\n");
|
||||
for (String key : extraInfo.keySet()) {
|
||||
output
|
||||
.append("<tr><td>")
|
||||
.append(key)
|
||||
.append("</td><td>")
|
||||
.append(extraInfo.get(key))
|
||||
.append("</td></tr>\n");
|
||||
}
|
||||
output.append("</table>\n");
|
||||
|
||||
public void put(String key, double value) {
|
||||
extraInfo.put(key, Double.toString(value));
|
||||
}
|
||||
|
||||
public void put(String key, float value) {
|
||||
extraInfo.put(key, Float.toString(value));
|
||||
}
|
||||
|
||||
public void put(String key, long value) {
|
||||
extraInfo.put(key, Long.toString(value));
|
||||
}
|
||||
|
||||
public void put(String key, int value) {
|
||||
extraInfo.put(key, Integer.toString(value));
|
||||
}
|
||||
|
||||
public void put(String key, Object value) {
|
||||
extraInfo.put(key, String.valueOf(value));
|
||||
}
|
||||
|
||||
public void remove(String key) {
|
||||
extraInfo.remove(key);
|
||||
}
|
||||
|
||||
public String toMarkdown() {
|
||||
if (extraInfo.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
|
||||
StringBuilder output = new StringBuilder();
|
||||
output.append("Extra info:\n"
|
||||
+ "---\n"
|
||||
+ "<table>\n");
|
||||
for (String key : extraInfo.keySet()) {
|
||||
output.append("<tr><td>")
|
||||
.append(key)
|
||||
.append("</td><td>")
|
||||
.append(extraInfo.get(key))
|
||||
.append("</td></tr>\n");
|
||||
}
|
||||
output.append("</table>\n");
|
||||
|
||||
return output.toString();
|
||||
}
|
||||
return output.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,38 +4,37 @@ import android.text.TextUtils;
|
|||
|
||||
public class GithubLogin {
|
||||
|
||||
private final String apiToken;
|
||||
private final String apiToken;
|
||||
|
||||
private final String password;
|
||||
private final String password;
|
||||
|
||||
private final String username;
|
||||
private final String username;
|
||||
|
||||
public GithubLogin(String username, String password) {
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
this.apiToken = null;
|
||||
}
|
||||
public GithubLogin(String username, String password) {
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
this.apiToken = null;
|
||||
}
|
||||
|
||||
public GithubLogin(String apiToken) {
|
||||
this.username = null;
|
||||
this.password = null;
|
||||
this.apiToken = apiToken;
|
||||
}
|
||||
public GithubLogin(String apiToken) {
|
||||
this.username = null;
|
||||
this.password = null;
|
||||
this.apiToken = apiToken;
|
||||
}
|
||||
|
||||
public String getApiToken() {
|
||||
return apiToken;
|
||||
}
|
||||
public String getApiToken() {
|
||||
return apiToken;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public boolean shouldUseApiToken() {
|
||||
return TextUtils.isEmpty(username) || TextUtils.isEmpty(password);
|
||||
}
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public boolean shouldUseApiToken() {
|
||||
return TextUtils.isEmpty(username) || TextUtils.isEmpty(password);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,20 +2,20 @@ package io.github.muntashirakon.music.activities.bugreport.model.github;
|
|||
|
||||
public class GithubTarget {
|
||||
|
||||
private final String repository;
|
||||
private final String repository;
|
||||
|
||||
private final String username;
|
||||
private final String username;
|
||||
|
||||
public GithubTarget(String username, String repository) {
|
||||
this.username = username;
|
||||
this.repository = repository;
|
||||
}
|
||||
public GithubTarget(String username, String repository) {
|
||||
this.username = username;
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
public String getRepository() {
|
||||
return repository;
|
||||
}
|
||||
public String getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,57 +16,58 @@ package io.github.muntashirakon.music.activities.saf;
|
|||
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import io.github.muntashirakon.music.R;
|
||||
import com.heinrichreimersoftware.materialintro.app.IntroActivity;
|
||||
import com.heinrichreimersoftware.materialintro.slide.SimpleSlide;
|
||||
|
||||
import io.github.muntashirakon.music.R;
|
||||
|
||||
/**
|
||||
* Created by hemanths on 2019-07-31.
|
||||
*/
|
||||
/** Created by hemanths on 2019-07-31. */
|
||||
public class SAFGuideActivity extends IntroActivity {
|
||||
|
||||
public static final int REQUEST_CODE_SAF_GUIDE = 98;
|
||||
public static final int REQUEST_CODE_SAF_GUIDE = 98;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setButtonCtaVisible(false);
|
||||
setButtonNextVisible(false);
|
||||
setButtonBackVisible(false);
|
||||
setButtonCtaVisible(false);
|
||||
setButtonNextVisible(false);
|
||||
setButtonBackVisible(false);
|
||||
|
||||
setButtonCtaTintMode(BUTTON_CTA_TINT_MODE_TEXT);
|
||||
setButtonCtaTintMode(BUTTON_CTA_TINT_MODE_TEXT);
|
||||
|
||||
String title = String.format(getString(R.string.saf_guide_slide1_title), getString(R.string.app_name));
|
||||
String title =
|
||||
String.format(getString(R.string.saf_guide_slide1_title), getString(R.string.app_name));
|
||||
|
||||
addSlide(new SimpleSlide.Builder()
|
||||
.title(title)
|
||||
.description(Build.VERSION.SDK_INT <= Build.VERSION_CODES.N_MR1
|
||||
? R.string.saf_guide_slide1_description_before_o : R.string.saf_guide_slide1_description)
|
||||
.image(R.drawable.saf_guide_1)
|
||||
.background(R.color.md_deep_purple_300)
|
||||
.backgroundDark(R.color.md_deep_purple_400)
|
||||
.layout(R.layout.fragment_simple_slide_large_image)
|
||||
.build());
|
||||
addSlide(new SimpleSlide.Builder()
|
||||
.title(R.string.saf_guide_slide2_title)
|
||||
.description(R.string.saf_guide_slide2_description)
|
||||
.image(R.drawable.saf_guide_2)
|
||||
.background(R.color.md_deep_purple_500)
|
||||
.backgroundDark(R.color.md_deep_purple_600)
|
||||
.layout(R.layout.fragment_simple_slide_large_image)
|
||||
.build());
|
||||
addSlide(new SimpleSlide.Builder()
|
||||
.title(R.string.saf_guide_slide3_title)
|
||||
.description(R.string.saf_guide_slide3_description)
|
||||
.image(R.drawable.saf_guide_3)
|
||||
.background(R.color.md_deep_purple_700)
|
||||
.backgroundDark(R.color.md_deep_purple_800)
|
||||
.layout(R.layout.fragment_simple_slide_large_image)
|
||||
.build());
|
||||
}
|
||||
addSlide(
|
||||
new SimpleSlide.Builder()
|
||||
.title(title)
|
||||
.description(
|
||||
Build.VERSION.SDK_INT <= Build.VERSION_CODES.N_MR1
|
||||
? R.string.saf_guide_slide1_description_before_o
|
||||
: R.string.saf_guide_slide1_description)
|
||||
.image(R.drawable.saf_guide_1)
|
||||
.background(R.color.md_deep_purple_300)
|
||||
.backgroundDark(R.color.md_deep_purple_400)
|
||||
.layout(R.layout.fragment_simple_slide_large_image)
|
||||
.build());
|
||||
addSlide(
|
||||
new SimpleSlide.Builder()
|
||||
.title(R.string.saf_guide_slide2_title)
|
||||
.description(R.string.saf_guide_slide2_description)
|
||||
.image(R.drawable.saf_guide_2)
|
||||
.background(R.color.md_deep_purple_500)
|
||||
.backgroundDark(R.color.md_deep_purple_600)
|
||||
.layout(R.layout.fragment_simple_slide_large_image)
|
||||
.build());
|
||||
addSlide(
|
||||
new SimpleSlide.Builder()
|
||||
.title(R.string.saf_guide_slide3_title)
|
||||
.description(R.string.saf_guide_slide3_description)
|
||||
.image(R.drawable.saf_guide_3)
|
||||
.background(R.color.md_deep_purple_700)
|
||||
.backgroundDark(R.color.md_deep_purple_800)
|
||||
.layout(R.layout.fragment_simple_slide_large_image)
|
||||
.build());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,25 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Hemanth Savarla.
|
||||
*
|
||||
* 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 io.github.muntashirakon.music.activities.tageditor
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.SearchManager
|
||||
import android.content.Intent
|
||||
import android.content.res.ColorStateList
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.BitmapFactory
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.MenuItem
|
||||
|
@ -16,18 +28,19 @@ import android.view.animation.OvershootInterpolator
|
|||
import androidx.appcompat.app.AlertDialog
|
||||
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.MaterialValueHelper
|
||||
import code.name.monkey.appthemehelper.util.TintHelper
|
||||
import com.google.android.material.button.MaterialButton
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import io.github.muntashirakon.music.R
|
||||
import io.github.muntashirakon.music.R.drawable
|
||||
import io.github.muntashirakon.music.activities.base.AbsBaseActivity
|
||||
import io.github.muntashirakon.music.activities.saf.SAFGuideActivity
|
||||
import io.github.muntashirakon.music.extensions.accentColor
|
||||
import io.github.muntashirakon.music.model.ArtworkInfo
|
||||
import io.github.muntashirakon.music.model.LoadingInfo
|
||||
import io.github.muntashirakon.music.repository.Repository
|
||||
import io.github.muntashirakon.music.util.RetroUtil
|
||||
import io.github.muntashirakon.music.util.SAFUtil
|
||||
import com.google.android.material.button.MaterialButton
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import kotlinx.android.synthetic.main.activity_album_tag_editor.*
|
||||
import org.jaudiotagger.audio.AudioFile
|
||||
import org.jaudiotagger.audio.AudioFileIO
|
||||
|
@ -49,6 +62,8 @@ abstract class AbsTagEditorActivity : AbsBaseActivity() {
|
|||
private val currentSongPath: String? = null
|
||||
private var savedTags: Map<FieldKey, String>? = null
|
||||
private var savedArtworkInfo: ArtworkInfo? = null
|
||||
protected abstract val contentViewLayout: Int
|
||||
protected abstract fun loadImageFromFile(selectedFile: Uri?)
|
||||
|
||||
protected val show: AlertDialog
|
||||
get() =
|
||||
|
@ -62,7 +77,6 @@ abstract class AbsTagEditorActivity : AbsBaseActivity() {
|
|||
}
|
||||
}
|
||||
.show()
|
||||
protected abstract val contentViewLayout: Int
|
||||
|
||||
internal val albumArtist: String?
|
||||
get() {
|
||||
|
@ -182,6 +196,7 @@ abstract class AbsTagEditorActivity : AbsBaseActivity() {
|
|||
getIntentExtras()
|
||||
|
||||
songPaths = getSongPaths()
|
||||
println(songPaths?.size)
|
||||
if (songPaths!!.isEmpty()) {
|
||||
finish()
|
||||
}
|
||||
|
@ -198,9 +213,9 @@ abstract class AbsTagEditorActivity : AbsBaseActivity() {
|
|||
private fun setUpImageView() {
|
||||
loadCurrentImage()
|
||||
items = listOf(
|
||||
getString(io.github.muntashirakon.music.R.string.pick_from_local_storage),
|
||||
getString(io.github.muntashirakon.music.R.string.web_search),
|
||||
getString(io.github.muntashirakon.music.R.string.remove_cover)
|
||||
getString(R.string.pick_from_local_storage),
|
||||
getString(R.string.web_search),
|
||||
getString(R.string.remove_cover)
|
||||
)
|
||||
editorImage?.setOnClickListener { show }
|
||||
}
|
||||
|
@ -211,7 +226,7 @@ abstract class AbsTagEditorActivity : AbsBaseActivity() {
|
|||
startActivityForResult(
|
||||
Intent.createChooser(
|
||||
intent,
|
||||
getString(io.github.muntashirakon.music.R.string.pick_from_local_storage)
|
||||
getString(R.string.pick_from_local_storage)
|
||||
), REQUEST_CODE_SELECT_IMAGE
|
||||
)
|
||||
}
|
||||
|
@ -223,20 +238,7 @@ abstract class AbsTagEditorActivity : AbsBaseActivity() {
|
|||
protected abstract fun deleteImage()
|
||||
|
||||
private fun setUpFab() {
|
||||
saveFab.backgroundTintList = ColorStateList.valueOf(ThemeStore.accentColor(this))
|
||||
ColorStateList.valueOf(
|
||||
MaterialValueHelper.getPrimaryTextColor(
|
||||
this,
|
||||
ColorUtil.isColorLight(
|
||||
ThemeStore.accentColor(
|
||||
this
|
||||
)
|
||||
)
|
||||
)
|
||||
).apply {
|
||||
saveFab.setTextColor(this)
|
||||
saveFab.iconTint = this
|
||||
}
|
||||
saveFab.accentColor()
|
||||
saveFab.apply {
|
||||
scaleX = 0f
|
||||
scaleY = 0f
|
||||
|
@ -324,35 +326,25 @@ abstract class AbsTagEditorActivity : AbsBaseActivity() {
|
|||
}
|
||||
|
||||
protected fun writeValuesToFiles(
|
||||
fieldKeyValueMap: Map<FieldKey, String>, artworkInfo: ArtworkInfo?
|
||||
fieldKeyValueMap: Map<FieldKey, String>,
|
||||
artworkInfo: ArtworkInfo?
|
||||
) {
|
||||
RetroUtil.hideSoftKeyboard(this)
|
||||
|
||||
hideFab()
|
||||
|
||||
savedSongPaths = songPaths
|
||||
savedTags = fieldKeyValueMap
|
||||
savedArtworkInfo = artworkInfo
|
||||
|
||||
if (!SAFUtil.isSAFRequired(savedSongPaths)) {
|
||||
writeTags(savedSongPaths)
|
||||
} else {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
if (SAFUtil.isSDCardAccessGranted(this)) {
|
||||
writeTags(savedSongPaths)
|
||||
} else {
|
||||
startActivityForResult(
|
||||
Intent(this, SAFGuideActivity::class.java),
|
||||
SAFGuideActivity.REQUEST_CODE_SAF_GUIDE
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
println(fieldKeyValueMap)
|
||||
WriteTagsAsyncTask(this).execute(
|
||||
LoadingInfo(
|
||||
songPaths,
|
||||
fieldKeyValueMap,
|
||||
artworkInfo
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
private fun writeTags(paths: List<String>?) {
|
||||
WriteTagsAsyncTask(this).execute(
|
||||
WriteTagsAsyncTask.LoadingInfo(
|
||||
LoadingInfo(
|
||||
paths,
|
||||
savedTags,
|
||||
savedArtworkInfo
|
||||
|
@ -360,6 +352,7 @@ abstract class AbsTagEditorActivity : AbsBaseActivity() {
|
|||
)
|
||||
}
|
||||
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, intent: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, intent)
|
||||
when (requestCode) {
|
||||
|
@ -385,7 +378,6 @@ abstract class AbsTagEditorActivity : AbsBaseActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
protected abstract fun loadImageFromFile(selectedFile: Uri?)
|
||||
|
||||
private fun getAudioFile(path: String): AudioFile {
|
||||
return try {
|
||||
|
@ -396,7 +388,6 @@ abstract class AbsTagEditorActivity : AbsBaseActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
class ArtworkInfo constructor(val albumId: Long, val artwork: Bitmap?)
|
||||
|
||||
companion object {
|
||||
|
||||
|
@ -405,5 +396,4 @@ abstract class AbsTagEditorActivity : AbsBaseActivity() {
|
|||
private val TAG = AbsTagEditorActivity::class.java.simpleName
|
||||
private const val REQUEST_CODE_SELECT_IMAGE = 1000
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,3 +1,17 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Hemanth Savarla.
|
||||
*
|
||||
* 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 io.github.muntashirakon.music.activities.tageditor
|
||||
|
||||
import android.app.Activity
|
||||
|
@ -18,6 +32,7 @@ import io.github.muntashirakon.music.R
|
|||
import io.github.muntashirakon.music.extensions.appHandleColor
|
||||
import io.github.muntashirakon.music.glide.palette.BitmapPaletteTranscoder
|
||||
import io.github.muntashirakon.music.glide.palette.BitmapPaletteWrapper
|
||||
import io.github.muntashirakon.music.model.ArtworkInfo
|
||||
import io.github.muntashirakon.music.model.Song
|
||||
import io.github.muntashirakon.music.util.ImageUtil
|
||||
import io.github.muntashirakon.music.util.RetroColorUtil.generatePalette
|
||||
|
@ -26,9 +41,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 java.util.*
|
||||
import kotlinx.android.synthetic.main.activity_album_tag_editor.*
|
||||
import org.jaudiotagger.tag.FieldKey
|
||||
import java.util.*
|
||||
|
||||
class AlbumTagEditorActivity : AbsTagEditorActivity(), TextWatcher {
|
||||
|
||||
|
@ -155,7 +170,7 @@ class AlbumTagEditorActivity : AbsTagEditorActivity(), TextWatcher {
|
|||
override fun save() {
|
||||
val fieldKeyValueMap = EnumMap<FieldKey, String>(FieldKey::class.java)
|
||||
fieldKeyValueMap[FieldKey.ALBUM] = albumText.text.toString()
|
||||
//android seems not to recognize album_artist field so we additionally write the normal artist field
|
||||
// android seems not to recognize album_artist field so we additionally write the normal artist field
|
||||
fieldKeyValueMap[FieldKey.ARTIST] = albumArtistText.text.toString()
|
||||
fieldKeyValueMap[FieldKey.ALBUM_ARTIST] = albumArtistText.text.toString()
|
||||
fieldKeyValueMap[FieldKey.GENRE] = genreTitle.text.toString()
|
||||
|
@ -163,8 +178,11 @@ class AlbumTagEditorActivity : AbsTagEditorActivity(), TextWatcher {
|
|||
|
||||
writeValuesToFiles(
|
||||
fieldKeyValueMap,
|
||||
if (deleteAlbumArt) ArtworkInfo(id, null)
|
||||
else if (albumArtBitmap == null) null else ArtworkInfo(id, albumArtBitmap!!)
|
||||
when {
|
||||
deleteAlbumArt -> ArtworkInfo(id, null)
|
||||
albumArtBitmap == null -> null
|
||||
else -> ArtworkInfo(id, albumArtBitmap!!)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,17 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Hemanth Savarla.
|
||||
*
|
||||
* 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 io.github.muntashirakon.music.activities.tageditor
|
||||
|
||||
import android.net.Uri
|
||||
|
@ -88,11 +102,7 @@ class SongTagEditorActivity : AbsTagEditorActivity(), TextWatcher {
|
|||
writeValuesToFiles(fieldKeyValueMap, null)
|
||||
}
|
||||
|
||||
override fun getSongPaths(): List<String> {
|
||||
val paths = ArrayList<String>(1)
|
||||
paths.add(songRepository.song(id).data)
|
||||
return paths
|
||||
}
|
||||
override fun getSongPaths(): List<String> = listOf(songRepository.song(id).data)
|
||||
|
||||
override fun loadImageFromFile(selectedFile: Uri?) {
|
||||
}
|
||||
|
@ -111,5 +121,3 @@ class SongTagEditorActivity : AbsTagEditorActivity(), TextWatcher {
|
|||
val TAG: String = SongTagEditorActivity::class.java.simpleName
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -5,67 +5,54 @@ import android.app.Dialog;
|
|||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.media.MediaScannerConnection;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import com.afollestad.materialdialogs.MaterialDialog;
|
||||
|
||||
import org.jaudiotagger.audio.AudioFile;
|
||||
import org.jaudiotagger.audio.AudioFileIO;
|
||||
import org.jaudiotagger.audio.exceptions.CannotReadException;
|
||||
import org.jaudiotagger.audio.exceptions.CannotWriteException;
|
||||
import org.jaudiotagger.audio.exceptions.InvalidAudioFrameException;
|
||||
import org.jaudiotagger.audio.exceptions.ReadOnlyFileException;
|
||||
import org.jaudiotagger.tag.FieldKey;
|
||||
import org.jaudiotagger.tag.Tag;
|
||||
import org.jaudiotagger.tag.TagException;
|
||||
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.List;
|
||||
import java.util.Map;
|
||||
|
||||
import io.github.muntashirakon.music.R;
|
||||
import io.github.muntashirakon.music.misc.DialogAsyncTask;
|
||||
import io.github.muntashirakon.music.misc.UpdateToastMediaScannerCompletionListener;
|
||||
import io.github.muntashirakon.music.model.LoadingInfo;
|
||||
import io.github.muntashirakon.music.util.MusicUtil;
|
||||
import io.github.muntashirakon.music.util.SAFUtil;
|
||||
|
||||
public class WriteTagsAsyncTask extends DialogAsyncTask<WriteTagsAsyncTask.LoadingInfo, Integer, String[]> {
|
||||
public class WriteTagsAsyncTask extends DialogAsyncTask<LoadingInfo, Integer, List<String>> {
|
||||
|
||||
private WeakReference<Activity> activity;
|
||||
|
||||
public WriteTagsAsyncTask(@NonNull Activity activity) {
|
||||
super(activity);
|
||||
this.activity = new WeakReference<>(activity);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected Dialog createDialog(@NonNull Context context) {
|
||||
|
||||
return new MaterialAlertDialogBuilder(context)
|
||||
.setTitle(R.string.saving_changes)
|
||||
.setCancelable(false)
|
||||
.setView(R.layout.loading)
|
||||
.create();
|
||||
public WriteTagsAsyncTask(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String[] doInBackground(LoadingInfo... params) {
|
||||
protected List<String> doInBackground(LoadingInfo... params) {
|
||||
try {
|
||||
LoadingInfo info = params[0];
|
||||
|
||||
Artwork artwork = null;
|
||||
File albumArtFile = null;
|
||||
if (info.artworkInfo != null && info.artworkInfo.getArtwork() != null) {
|
||||
if (info.getArtworkInfo() != null && info.getArtworkInfo().getArtwork() != null) {
|
||||
try {
|
||||
albumArtFile = MusicUtil.INSTANCE.createAlbumArtFile().getCanonicalFile();
|
||||
info.artworkInfo.getArtwork()
|
||||
.compress(Bitmap.CompressFormat.PNG, 0, new FileOutputStream(albumArtFile));
|
||||
info.getArtworkInfo().getArtwork().compress(Bitmap.CompressFormat.PNG, 0, new FileOutputStream(albumArtFile));
|
||||
artwork = ArtworkFactory.createArtworkFromFile(albumArtFile);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -75,21 +62,14 @@ public class WriteTagsAsyncTask extends DialogAsyncTask<WriteTagsAsyncTask.Loadi
|
|||
int counter = 0;
|
||||
boolean wroteArtwork = false;
|
||||
boolean deletedArtwork = false;
|
||||
for (String filePath : info.filePaths) {
|
||||
publishProgress(++counter, info.filePaths.size());
|
||||
for (String filePath : info.getFilePaths()) {
|
||||
publishProgress(++counter, info.getFilePaths().size());
|
||||
try {
|
||||
Uri safUri = null;
|
||||
if (filePath.contains(SAFUtil.SEPARATOR)) {
|
||||
String[] fragments = filePath.split(SAFUtil.SEPARATOR);
|
||||
filePath = fragments[0];
|
||||
safUri = Uri.parse(fragments[1]);
|
||||
}
|
||||
|
||||
AudioFile audioFile = AudioFileIO.read(new File(filePath));
|
||||
Tag tag = audioFile.getTagOrCreateAndSetDefault();
|
||||
|
||||
if (info.fieldKeyValueMap != null) {
|
||||
for (Map.Entry<FieldKey, String> entry : info.fieldKeyValueMap.entrySet()) {
|
||||
if (info.getFieldKeyValueMap() != null) {
|
||||
for (Map.Entry<FieldKey, String> entry : info.getFieldKeyValueMap().entrySet()) {
|
||||
try {
|
||||
tag.setField(entry.getKey(), entry.getValue());
|
||||
} catch (Exception e) {
|
||||
|
@ -98,8 +78,8 @@ public class WriteTagsAsyncTask extends DialogAsyncTask<WriteTagsAsyncTask.Loadi
|
|||
}
|
||||
}
|
||||
|
||||
if (info.artworkInfo != null) {
|
||||
if (info.artworkInfo.getArtwork() == null) {
|
||||
if (info.getArtworkInfo() != null) {
|
||||
if (info.getArtworkInfo().getArtwork() == null) {
|
||||
tag.deleteArtworkField();
|
||||
deletedArtwork = true;
|
||||
} else if (artwork != null) {
|
||||
|
@ -109,10 +89,8 @@ public class WriteTagsAsyncTask extends DialogAsyncTask<WriteTagsAsyncTask.Loadi
|
|||
}
|
||||
}
|
||||
|
||||
Activity activity = this.activity.get();
|
||||
SAFUtil.write(activity, audioFile, safUri);
|
||||
|
||||
} catch (@NonNull Exception e) {
|
||||
audioFile.commit();
|
||||
} catch (@NonNull CannotReadException | IOException | CannotWriteException | TagException | ReadOnlyFileException | InvalidAudioFrameException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
@ -120,24 +98,13 @@ public class WriteTagsAsyncTask extends DialogAsyncTask<WriteTagsAsyncTask.Loadi
|
|||
Context context = getContext();
|
||||
if (context != null) {
|
||||
if (wroteArtwork) {
|
||||
MusicUtil.INSTANCE.insertAlbumArt(context, info.artworkInfo.getAlbumId(), albumArtFile.getPath());
|
||||
MusicUtil.INSTANCE.insertAlbumArt(context, info.getArtworkInfo().getAlbumId(), albumArtFile.getPath());
|
||||
} else if (deletedArtwork) {
|
||||
MusicUtil.INSTANCE.deleteAlbumArt(context, info.artworkInfo.getAlbumId());
|
||||
MusicUtil.INSTANCE.deleteAlbumArt(context, info.getArtworkInfo().getAlbumId());
|
||||
}
|
||||
}
|
||||
|
||||
Collection<String> paths = info.filePaths;
|
||||
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) {
|
||||
paths = new ArrayList<>(info.filePaths.size());
|
||||
for (String path : info.filePaths) {
|
||||
if (path.contains(SAFUtil.SEPARATOR)) {
|
||||
path = path.split(SAFUtil.SEPARATOR)[0];
|
||||
}
|
||||
paths.add(path);
|
||||
}
|
||||
}
|
||||
|
||||
return paths.toArray(new String[paths.size()]);
|
||||
return info.getFilePaths();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
|
@ -145,48 +112,40 @@ public class WriteTagsAsyncTask extends DialogAsyncTask<WriteTagsAsyncTask.Loadi
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void onCancelled(String[] toBeScanned) {
|
||||
super.onCancelled(toBeScanned);
|
||||
scan(toBeScanned);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(String[] toBeScanned) {
|
||||
protected void onPostExecute(List<String> toBeScanned) {
|
||||
super.onPostExecute(toBeScanned);
|
||||
scan(toBeScanned);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCancelled(List<String> toBeScanned) {
|
||||
super.onCancelled(toBeScanned);
|
||||
scan(toBeScanned);
|
||||
}
|
||||
|
||||
private void scan(List<String> toBeScanned) {
|
||||
Context context = getContext();
|
||||
if (toBeScanned == null || toBeScanned.isEmpty()) {
|
||||
Log.i("scan", "scan: Empty");
|
||||
Toast.makeText(context, "Scan file from folder", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
MediaScannerConnection.scanFile(context, toBeScanned.toArray(new String[0]), null, context instanceof Activity ? new UpdateToastMediaScannerCompletionListener((Activity) context, toBeScanned) : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Dialog createDialog(@NonNull Context context) {
|
||||
return new MaterialDialog.Builder(context)
|
||||
.title(R.string.saving_changes)
|
||||
.cancelable(false)
|
||||
.progress(false, 0)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onProgressUpdate(@NonNull Dialog dialog, Integer... values) {
|
||||
super.onProgressUpdate(dialog, values);
|
||||
//((MaterialDialog) dialog).setMaxProgress(values[1]);
|
||||
//((MaterialDialog) dialog).setProgress(values[0]);
|
||||
((MaterialDialog) dialog).setMaxProgress(values[1]);
|
||||
((MaterialDialog) dialog).setProgress(values[0]);
|
||||
}
|
||||
|
||||
private void scan(String[] toBeScanned) {
|
||||
Activity activity = this.activity.get();
|
||||
if (activity != null) {
|
||||
MediaScannerConnection.scanFile(activity, toBeScanned, null,
|
||||
new UpdateToastMediaScannerCompletionListener(activity, toBeScanned));
|
||||
}
|
||||
}
|
||||
|
||||
public static class LoadingInfo {
|
||||
|
||||
@Nullable
|
||||
final Map<FieldKey, String> fieldKeyValueMap;
|
||||
|
||||
final Collection<String> filePaths;
|
||||
|
||||
@Nullable
|
||||
private AbsTagEditorActivity.ArtworkInfo artworkInfo;
|
||||
|
||||
public LoadingInfo(Collection<String> filePaths,
|
||||
@Nullable Map<FieldKey, String> fieldKeyValueMap,
|
||||
@Nullable AbsTagEditorActivity.ArtworkInfo artworkInfo) {
|
||||
this.filePaths = filePaths;
|
||||
this.fieldKeyValueMap = fieldKeyValueMap;
|
||||
this.artworkInfo = artworkInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue