Converted PreferencUtil to Kotlin class
This commit is contained in:
parent
df225e179f
commit
e9bd24872f
108 changed files with 1855 additions and 2099 deletions
|
@ -75,10 +75,12 @@ android {
|
||||||
abortOnError false
|
abortOnError false
|
||||||
}
|
}
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility '1.8'
|
sourceCompatibility JavaVersion.VERSION_1_8
|
||||||
targetCompatibility '1.8'
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
|
}
|
||||||
|
kotlinOptions {
|
||||||
|
jvmTarget = "1.8"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
configurations.all {
|
configurations.all {
|
||||||
resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
|
resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
|
||||||
|
@ -89,7 +91,6 @@ android {
|
||||||
kapt {
|
kapt {
|
||||||
generateStubs = true
|
generateStubs = true
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def getProperties(String fileName) {
|
def getProperties(String fileName) {
|
||||||
|
@ -118,15 +119,16 @@ dependencies {
|
||||||
implementation "androidx.gridlayout:gridlayout:1.0.0"
|
implementation "androidx.gridlayout:gridlayout:1.0.0"
|
||||||
implementation "androidx.cardview:cardview:1.0.0"
|
implementation "androidx.cardview:cardview:1.0.0"
|
||||||
implementation "androidx.palette:palette:1.0.0"
|
implementation "androidx.palette:palette:1.0.0"
|
||||||
implementation 'androidx.palette:palette-ktx:1.0.0'
|
|
||||||
implementation "androidx.viewpager2:viewpager2:1.1.0-alpha01"
|
implementation "androidx.viewpager2:viewpager2:1.1.0-alpha01"
|
||||||
implementation 'androidx.appcompat:appcompat:1.1.0'
|
implementation 'androidx.appcompat:appcompat:1.1.0'
|
||||||
implementation 'androidx.annotation:annotation:1.1.0'
|
implementation 'androidx.annotation:annotation:1.1.0'
|
||||||
implementation 'androidx.preference:preference:1.1.1'
|
implementation 'androidx.preference:preference:1.1.1'
|
||||||
|
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
|
||||||
implementation 'androidx.core:core-ktx:1.2.0'
|
implementation 'androidx.core:core-ktx:1.2.0'
|
||||||
implementation 'androidx.fragment:fragment:1.2.4'
|
implementation 'androidx.fragment:fragment-ktx:1.2.4'
|
||||||
|
implementation 'androidx.palette:palette-ktx:1.0.0'
|
||||||
|
|
||||||
|
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||||
implementation 'androidx.recyclerview:recyclerview:1.1.0'
|
implementation 'androidx.recyclerview:recyclerview:1.1.0'
|
||||||
|
|
||||||
implementation 'com.google.android.material:material:1.2.0-alpha06'
|
implementation 'com.google.android.material:material:1.2.0-alpha06'
|
||||||
|
|
|
@ -50,4 +50,80 @@ object Constants {
|
||||||
MediaStore.Audio.AudioColumns.COMPOSER
|
MediaStore.Audio.AudioColumns.COMPOSER
|
||||||
)// 11
|
)// 11
|
||||||
const val NUMBER_OF_TOP_TRACKS = 99
|
const val NUMBER_OF_TOP_TRACKS = 99
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const val LIBRARY_CATEGORIES = "library_categories"
|
||||||
|
const val EXTRA_SONG_INFO = "extra_song_info"
|
||||||
|
const val DESATURATED_COLOR = "desaturated_color"
|
||||||
|
const val BLACK_THEME = "black_theme"
|
||||||
|
const val KEEP_SCREEN_ON = "keep_screen_on"
|
||||||
|
const val TOGGLE_HOME_BANNER = "toggle_home_banner"
|
||||||
|
const val NOW_PLAYING_SCREEN_ID = "now_playing_screen_id"
|
||||||
|
const val CAROUSEL_EFFECT = "carousel_effect"
|
||||||
|
const val COLORED_NOTIFICATION = "colored_notification"
|
||||||
|
const val CLASSIC_NOTIFICATION = "classic_notification"
|
||||||
|
const val GAPLESS_PLAYBACK = "gapless_playback"
|
||||||
|
const val ALBUM_ART_ON_LOCKSCREEN = "album_art_on_lockscreen"
|
||||||
|
const val BLURRED_ALBUM_ART = "blurred_album_art"
|
||||||
|
const val NEW_BLUR_AMOUNT = "new_blur_amount"
|
||||||
|
const val TOGGLE_HEADSET = "toggle_headset"
|
||||||
|
const val GENERAL_THEME = "general_theme"
|
||||||
|
const val CIRCULAR_ALBUM_ART = "circular_album_art"
|
||||||
|
const val USER_NAME = "user_name"
|
||||||
|
const val TOGGLE_FULL_SCREEN = "toggle_full_screen"
|
||||||
|
const val TOGGLE_VOLUME = "toggle_volume"
|
||||||
|
const val ROUND_CORNERS = "corner_window"
|
||||||
|
const val TOGGLE_GENRE = "toggle_genre"
|
||||||
|
const val PROFILE_IMAGE_PATH = "profile_image_path"
|
||||||
|
const val BANNER_IMAGE_PATH = "banner_image_path"
|
||||||
|
const val ADAPTIVE_COLOR_APP = "adaptive_color_app"
|
||||||
|
const val TOGGLE_SEPARATE_LINE = "toggle_separate_line"
|
||||||
|
const val HOME_ARTIST_GRID_STYLE = "home_artist_grid_style"
|
||||||
|
const val TOGGLE_ADD_CONTROLS = "toggle_add_controls"
|
||||||
|
const val ALBUM_COVER_STYLE = "album_cover_style_id"
|
||||||
|
const val ALBUM_COVER_TRANSFORM = "album_cover_transform"
|
||||||
|
const val TAB_TEXT_MODE = "tab_text_mode"
|
||||||
|
const val LANGUAGE_NAME = "language_name"
|
||||||
|
const val DIALOG_CORNER = "dialog_corner"
|
||||||
|
const val SLEEP_TIMER_FINISH_SONG = "sleep_timer_finish_song"
|
||||||
|
const val ALBUM_GRID_STYLE = "album_grid_style_home"
|
||||||
|
const val ARTIST_GRID_STYLE = "artist_grid_style_home"
|
||||||
|
const val SAF_SDCARD_URI = "saf_sdcard_uri"
|
||||||
|
const val SONG_SORT_ORDER = "song_sort_order"
|
||||||
|
const val SONG_GRID_SIZE = "song_grid_size"
|
||||||
|
const val GENRE_SORT_ORDER = "genre_sort_order"
|
||||||
|
const val LAST_PAGE = "last_start_page"
|
||||||
|
const val BLUETOOTH_PLAYBACK = "bluetooth_playback"
|
||||||
|
const val INITIALIZED_BLACKLIST = "initialized_blacklist"
|
||||||
|
const val ARTIST_SORT_ORDER = "artist_sort_order"
|
||||||
|
const val ARTIST_ALBUM_SORT_ORDER = "artist_album_sort_order"
|
||||||
|
const val ALBUM_SORT_ORDER = "album_sort_order"
|
||||||
|
const val ALBUM_SONG_SORT_ORDER = "album_song_sort_order"
|
||||||
|
const val ARTIST_SONG_SORT_ORDER = "artist_song_sort_order"
|
||||||
|
const val ALBUM_GRID_SIZE = "album_grid_size"
|
||||||
|
const val ALBUM_GRID_SIZE_LAND = "album_grid_size_land"
|
||||||
|
const val SONG_GRID_SIZE_LAND = "song_grid_size_land"
|
||||||
|
const val ARTIST_GRID_SIZE = "artist_grid_size"
|
||||||
|
const val ARTIST_GRID_SIZE_LAND = "artist_grid_size_land"
|
||||||
|
const val COLORED_APP_SHORTCUTS = "colored_app_shortcuts"
|
||||||
|
const val AUDIO_DUCKING = "audio_ducking"
|
||||||
|
const val LAST_ADDED_CUTOFF = "last_added_interval"
|
||||||
|
const val LAST_SLEEP_TIMER_VALUE = "last_sleep_timer_value"
|
||||||
|
const val NEXT_SLEEP_TIMER_ELAPSED_REALTIME =
|
||||||
|
"next_sleep_timer_elapsed_real_time"
|
||||||
|
const val IGNORE_MEDIA_STORE_ARTWORK = "ignore_media_store_artwork"
|
||||||
|
const val LAST_CHANGELOG_VERSION = "last_changelog_version"
|
||||||
|
const val AUTO_DOWNLOAD_IMAGES_POLICY = "auto_download_images_policy"
|
||||||
|
const val START_DIRECTORY = "start_directory"
|
||||||
|
const val LOCK_SCREEN = "lock_screen"
|
||||||
|
const val ALBUM_DETAIL_SONG_SORT_ORDER = "album_detail_song_sort_order"
|
||||||
|
const val LYRICS_OPTIONS = "lyrics_tab_position"
|
||||||
|
const val CHOOSE_EQUALIZER = "choose_equalizer"
|
||||||
|
const val TOGGLE_SHUFFLE = "toggle_shuffle"
|
||||||
|
const val SONG_GRID_STYLE = "song_grid_style"
|
||||||
|
const val PAUSE_ON_ZERO_VOLUME = "pause_on_zero_volume"
|
||||||
|
const val FILTER_SONG = "filter_song"
|
||||||
|
const val EXPAND_NOW_PLAYING_PANEL = "expand_now_playing_panel"
|
|
@ -25,9 +25,6 @@ import code.name.monkey.retromusic.adapter.ContributorAdapter
|
||||||
import code.name.monkey.retromusic.extensions.applyToolbar
|
import code.name.monkey.retromusic.extensions.applyToolbar
|
||||||
import code.name.monkey.retromusic.model.Contributor
|
import code.name.monkey.retromusic.model.Contributor
|
||||||
import code.name.monkey.retromusic.util.NavigationUtil
|
import code.name.monkey.retromusic.util.NavigationUtil
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
|
||||||
import com.afollestad.materialdialogs.MaterialDialog
|
|
||||||
import com.afollestad.materialdialogs.list.listItems
|
|
||||||
import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
import com.google.gson.reflect.TypeToken
|
import com.google.gson.reflect.TypeToken
|
||||||
import kotlinx.android.synthetic.main.activity_about.*
|
import kotlinx.android.synthetic.main.activity_about.*
|
||||||
|
@ -121,19 +118,6 @@ class AboutActivity : AbsBaseActivity(), View.OnClickListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showChangeLogOptions() {
|
|
||||||
MaterialDialog(this).show {
|
|
||||||
cornerRadius(PreferenceUtil.getInstance(this@AboutActivity).dialogCorner)
|
|
||||||
listItems(items = listOf("Telegram Channel", "App")) { _, position, _ ->
|
|
||||||
if (position == 0) {
|
|
||||||
openUrl(TELEGRAM_CHANGE_LOG)
|
|
||||||
} else {
|
|
||||||
NavigationUtil.gotoWhatNews(this@AboutActivity)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getAppVersion(): String {
|
private fun getAppVersion(): String {
|
||||||
return try {
|
return try {
|
||||||
val isPro = if (App.isProVersion()) "Pro" else "Free"
|
val isPro = if (App.isProVersion()) "Pro" else "Free"
|
||||||
|
|
|
@ -74,7 +74,7 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C
|
||||||
private lateinit var artistImage: ImageView
|
private lateinit var artistImage: ImageView
|
||||||
private var cab: MaterialCab? = null
|
private var cab: MaterialCab? = null
|
||||||
private val savedSortOrder: String
|
private val savedSortOrder: String
|
||||||
get() = PreferenceUtil.getInstance(this).albumDetailSongSortOrder
|
get() = PreferenceUtilKT.albumDetailSongSortOrder
|
||||||
|
|
||||||
override fun createContentView(): View {
|
override fun createContentView(): View {
|
||||||
return wrapSlidingMusicPanel(R.layout.activity_album)
|
return wrapSlidingMusicPanel(R.layout.activity_album)
|
||||||
|
@ -256,7 +256,7 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C
|
||||||
private fun loadAlbumCover() {
|
private fun loadAlbumCover() {
|
||||||
AlbumGlideRequest.Builder.from(Glide.with(this), album.safeGetFirstSong())
|
AlbumGlideRequest.Builder.from(Glide.with(this), album.safeGetFirstSong())
|
||||||
.checkIgnoreMediaStore(this)
|
.checkIgnoreMediaStore(this)
|
||||||
.ignoreMediaStore(PreferenceUtil.getInstance(this).ignoreMediaStoreArtwork())
|
.ignoreMediaStore(PreferenceUtilKT.isIgnoreMediaStoreArtwork)
|
||||||
.generatePalette(this)
|
.generatePalette(this)
|
||||||
.build()
|
.build()
|
||||||
.dontAnimate()
|
.dontAnimate()
|
||||||
|
@ -269,7 +269,7 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setColors(color: MediaNotificationProcessor) {
|
private fun setColors(color: MediaNotificationProcessor) {
|
||||||
val buttonColor = if (PreferenceUtil.getInstance(this).adaptiveColor)
|
val buttonColor = if (PreferenceUtilKT.isAdaptiveColor)
|
||||||
color.backgroundColor.ripAlpha()
|
color.backgroundColor.ripAlpha()
|
||||||
else
|
else
|
||||||
ATHUtil.resolveColor(this, R.attr.colorSurface)
|
ATHUtil.resolveColor(this, R.attr.colorSurface)
|
||||||
|
@ -362,8 +362,8 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setSaveSortOrder(sortOrder: String?) {
|
private fun setSaveSortOrder(sortOrder: String) {
|
||||||
PreferenceUtil.getInstance(this).albumDetailSongSortOrder = sortOrder
|
PreferenceUtilKT.albumDetailSongSortOrder = sortOrder
|
||||||
when (sortOrder) {
|
when (sortOrder) {
|
||||||
AlbumSongSortOrder.SONG_TRACK_LIST -> album.songs?.sortWith(Comparator { o1, o2 ->
|
AlbumSongSortOrder.SONG_TRACK_LIST -> album.songs?.sortWith(Comparator { o1, o2 ->
|
||||||
o1.trackNumber.compareTo(
|
o1.trackNumber.compareTo(
|
||||||
|
|
|
@ -255,7 +255,7 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailsView,
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setColors(color: MediaNotificationProcessor) {
|
private fun setColors(color: MediaNotificationProcessor) {
|
||||||
val buttonColor = if (PreferenceUtil.getInstance(this).adaptiveColor)
|
val buttonColor = if (PreferenceUtilKT.isAdaptiveColor)
|
||||||
color.backgroundColor.ripAlpha()
|
color.backgroundColor.ripAlpha()
|
||||||
else
|
else
|
||||||
ATHUtil.resolveColor(this, R.attr.colorSurface)
|
ATHUtil.resolveColor(this, R.attr.colorSurface)
|
||||||
|
|
|
@ -31,10 +31,7 @@ import code.name.monkey.retromusic.lyrics.LrcHelper
|
||||||
import code.name.monkey.retromusic.lyrics.LrcView
|
import code.name.monkey.retromusic.lyrics.LrcView
|
||||||
import code.name.monkey.retromusic.model.Song
|
import code.name.monkey.retromusic.model.Song
|
||||||
import code.name.monkey.retromusic.model.lyrics.Lyrics
|
import code.name.monkey.retromusic.model.lyrics.Lyrics
|
||||||
import code.name.monkey.retromusic.util.LyricUtil
|
import code.name.monkey.retromusic.util.*
|
||||||
import code.name.monkey.retromusic.util.MusicUtil
|
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
|
||||||
import code.name.monkey.retromusic.util.RetroUtil
|
|
||||||
import com.afollestad.materialdialogs.MaterialDialog
|
import com.afollestad.materialdialogs.MaterialDialog
|
||||||
import com.afollestad.materialdialogs.input.getInputLayout
|
import com.afollestad.materialdialogs.input.getInputLayout
|
||||||
import com.afollestad.materialdialogs.input.input
|
import com.afollestad.materialdialogs.input.input
|
||||||
|
@ -61,7 +58,7 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener,
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPageSelected(position: Int) {
|
override fun onPageSelected(position: Int) {
|
||||||
PreferenceUtil.getInstance(this).lyricsOptions = position
|
PreferenceUtilKT.lyricsOption = position
|
||||||
if (position == 0) fab.text = getString(R.string.synced_lyrics)
|
if (position == 0) fab.text = getString(R.string.synced_lyrics)
|
||||||
else if (position == 1) fab.text = getString(R.string.lyrics)
|
else if (position == 1) fab.text = getString(R.string.lyrics)
|
||||||
}
|
}
|
||||||
|
@ -107,7 +104,7 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener,
|
||||||
|
|
||||||
viewPager.apply {
|
viewPager.apply {
|
||||||
adapter = PagerAdapter(supportFragmentManager)
|
adapter = PagerAdapter(supportFragmentManager)
|
||||||
currentItem = PreferenceUtil.getInstance(this@LyricsActivity).lyricsOptions
|
currentItem = PreferenceUtilKT.lyricsOption
|
||||||
addOnPageChangeListener(this@LyricsActivity)
|
addOnPageChangeListener(this@LyricsActivity)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,7 +169,6 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener,
|
||||||
|
|
||||||
val materialDialog = MaterialDialog(this)
|
val materialDialog = MaterialDialog(this)
|
||||||
.show {
|
.show {
|
||||||
cornerRadius(PreferenceUtil.getInstance(this@LyricsActivity).dialogCorner)
|
|
||||||
title(R.string.add_time_framed_lryics)
|
title(R.string.add_time_framed_lryics)
|
||||||
negativeButton(R.string.action_search) {
|
negativeButton(R.string.action_search) {
|
||||||
RetroUtil.openUrl(this@LyricsActivity, googleSearchLrcUrl)
|
RetroUtil.openUrl(this@LyricsActivity, googleSearchLrcUrl)
|
||||||
|
@ -210,7 +206,7 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener,
|
||||||
val materialDialog = MaterialDialog(
|
val materialDialog = MaterialDialog(
|
||||||
this
|
this
|
||||||
).show {
|
).show {
|
||||||
cornerRadius(PreferenceUtil.getInstance(this@LyricsActivity).dialogCorner)
|
|
||||||
title(R.string.add_lyrics)
|
title(R.string.add_lyrics)
|
||||||
negativeButton(R.string.action_search) {
|
negativeButton(R.string.action_search) {
|
||||||
RetroUtil.openUrl(this@LyricsActivity, getGoogleSearchUrl())
|
RetroUtil.openUrl(this@LyricsActivity, getGoogleSearchUrl())
|
||||||
|
|
|
@ -1,836 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2020 Hemanth Savarala.
|
|
||||||
*
|
|
||||||
* Licensed under the GNU General Public License v3
|
|
||||||
*
|
|
||||||
* This is free software: you can redistribute it and/or modify it under
|
|
||||||
* the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
* See the GNU General Public License for more details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package code.name.monkey.retromusic.activities;
|
|
||||||
|
|
||||||
import android.app.ActivityOptions;
|
|
||||||
import android.content.BroadcastReceiver;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.IntentFilter;
|
|
||||||
import android.content.IntentSender;
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.content.pm.PackageInfo;
|
|
||||||
import android.content.pm.PackageManager.NameNotFoundException;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.provider.MediaStore;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.SubMenu;
|
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.appcompat.widget.Toolbar;
|
|
||||||
import androidx.core.app.ActivityCompat;
|
|
||||||
import androidx.fragment.app.Fragment;
|
|
||||||
|
|
||||||
import com.afollestad.materialcab.MaterialCab;
|
|
||||||
import com.afollestad.materialcab.MaterialCab.Callback;
|
|
||||||
import com.google.android.material.appbar.AppBarLayout;
|
|
||||||
import com.google.android.material.snackbar.Snackbar;
|
|
||||||
import com.google.android.play.core.appupdate.AppUpdateInfo;
|
|
||||||
import com.google.android.play.core.appupdate.AppUpdateManager;
|
|
||||||
import com.google.android.play.core.appupdate.AppUpdateManagerFactory;
|
|
||||||
import com.google.android.play.core.install.InstallState;
|
|
||||||
import com.google.android.play.core.install.InstallStateUpdatedListener;
|
|
||||||
import com.google.android.play.core.install.model.AppUpdateType;
|
|
||||||
import com.google.android.play.core.install.model.InstallStatus;
|
|
||||||
import com.google.android.play.core.install.model.UpdateAvailability;
|
|
||||||
import com.google.android.play.core.tasks.Task;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import code.name.monkey.appthemehelper.ThemeStore;
|
|
||||||
import code.name.monkey.appthemehelper.util.ATHUtil;
|
|
||||||
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper;
|
|
||||||
import code.name.monkey.retromusic.R;
|
|
||||||
import code.name.monkey.retromusic.activities.base.AbsSlidingMusicPanelActivity;
|
|
||||||
import code.name.monkey.retromusic.dialogs.CreatePlaylistDialog;
|
|
||||||
import code.name.monkey.retromusic.fragments.albums.AlbumsFragment;
|
|
||||||
import code.name.monkey.retromusic.fragments.artists.ArtistsFragment;
|
|
||||||
import code.name.monkey.retromusic.fragments.base.AbsLibraryPagerRecyclerViewCustomGridSizeFragment;
|
|
||||||
import code.name.monkey.retromusic.fragments.genres.GenresFragment;
|
|
||||||
import code.name.monkey.retromusic.fragments.home.BannerHomeFragment;
|
|
||||||
import code.name.monkey.retromusic.fragments.mainactivity.FoldersFragment;
|
|
||||||
import code.name.monkey.retromusic.fragments.playlists.PlaylistsFragment;
|
|
||||||
import code.name.monkey.retromusic.fragments.queue.PlayingQueueFragment;
|
|
||||||
import code.name.monkey.retromusic.fragments.songs.SongsFragment;
|
|
||||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote;
|
|
||||||
import code.name.monkey.retromusic.helper.SearchQueryHelper;
|
|
||||||
import code.name.monkey.retromusic.helper.SortOrder.AlbumSortOrder;
|
|
||||||
import code.name.monkey.retromusic.helper.SortOrder.ArtistSortOrder;
|
|
||||||
import code.name.monkey.retromusic.helper.SortOrder.SongSortOrder;
|
|
||||||
import code.name.monkey.retromusic.interfaces.CabHolder;
|
|
||||||
import code.name.monkey.retromusic.interfaces.MainActivityFragmentCallbacks;
|
|
||||||
import code.name.monkey.retromusic.loaders.AlbumLoader;
|
|
||||||
import code.name.monkey.retromusic.loaders.ArtistLoader;
|
|
||||||
import code.name.monkey.retromusic.loaders.PlaylistSongsLoader;
|
|
||||||
import code.name.monkey.retromusic.model.Song;
|
|
||||||
import code.name.monkey.retromusic.service.MusicService;
|
|
||||||
import code.name.monkey.retromusic.util.AppRater;
|
|
||||||
import code.name.monkey.retromusic.util.NavigationUtil;
|
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil;
|
|
||||||
import code.name.monkey.retromusic.util.RetroColorUtil;
|
|
||||||
import code.name.monkey.retromusic.util.RetroUtil;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by hemanths on 2020-02-19.
|
|
||||||
*/
|
|
||||||
public class MainActivity extends AbsSlidingMusicPanelActivity
|
|
||||||
implements CabHolder, SharedPreferences.OnSharedPreferenceChangeListener {
|
|
||||||
|
|
||||||
public static final String TAG = MainActivity.class.getSimpleName();
|
|
||||||
public static final int APP_INTRO_REQUEST = 100;
|
|
||||||
public static final String EXPAND_PANEL = "expand_panel";
|
|
||||||
private static final int APP_UPDATE_REQUEST_CODE = 9002;
|
|
||||||
private final IntentFilter mIntentFilter = new IntentFilter(Intent.ACTION_SCREEN_OFF);
|
|
||||||
private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
|
|
||||||
@Override
|
|
||||||
public void onReceive(final Context context, final Intent intent) {
|
|
||||||
String action = intent.getAction();
|
|
||||||
if (action != null && action.equals(Intent.ACTION_SCREEN_OFF)) {
|
|
||||||
if (PreferenceUtil.getInstance(context).getLockScreen() && MusicPlayerRemote.isPlaying()) {
|
|
||||||
final Intent activity = new Intent(context, LockScreenActivity.class);
|
|
||||||
activity.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
||||||
activity.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
|
|
||||||
ActivityCompat.startActivity(context, activity, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
private MainActivityFragmentCallbacks currentFragment;
|
|
||||||
private boolean blockRequestPermissions = false;
|
|
||||||
private MaterialCab cab;
|
|
||||||
private AppBarLayout mAppBarLayout;
|
|
||||||
private Toolbar mToolbar;
|
|
||||||
private AppUpdateManager appUpdateManager;
|
|
||||||
InstallStateUpdatedListener listener = new InstallStateUpdatedListener() {
|
|
||||||
@Override
|
|
||||||
public void onStateUpdate(InstallState state) {
|
|
||||||
if (state.installStatus() == InstallStatus.DOWNLOADED) {
|
|
||||||
popupSnackBarForCompleteUpdate();
|
|
||||||
} else if (state.installStatus() == InstallStatus.INSTALLED) {
|
|
||||||
appUpdateManager.unregisterListener(listener);
|
|
||||||
} else {
|
|
||||||
Log.i(TAG, "InstallStateUpdatedListener: state: " + state.installStatus());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private void popupSnackBarForCompleteUpdate() {
|
|
||||||
Snackbar snackbar = Snackbar.make(findViewById(R.id.mainContent), "New app is ready!", Snackbar.LENGTH_INDEFINITE);
|
|
||||||
snackbar.setAction("Install", view -> {
|
|
||||||
if (appUpdateManager != null) {
|
|
||||||
appUpdateManager.completeUpdate();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
snackbar.setActionTextColor(ThemeStore.Companion.accentColor(this));
|
|
||||||
snackbar.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(@Nullable final Bundle savedInstanceState) {
|
|
||||||
setDrawUnderStatusBar();
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setStatusbarColorAuto();
|
|
||||||
setNavigationbarColorAuto();
|
|
||||||
setLightNavigationBar(true);
|
|
||||||
setTaskDescriptionColorAuto();
|
|
||||||
hideStatusBar();
|
|
||||||
setBottomBarVisibility(View.VISIBLE);
|
|
||||||
|
|
||||||
if (savedInstanceState == null) {
|
|
||||||
selectedFragment(PreferenceUtil.getInstance(this).getLastPage());
|
|
||||||
} else {
|
|
||||||
restoreCurrentFragment();
|
|
||||||
}
|
|
||||||
|
|
||||||
mToolbar = findViewById(R.id.toolbar);
|
|
||||||
mAppBarLayout = findViewById(R.id.appBarLayout);
|
|
||||||
|
|
||||||
//checkShowChangelog();
|
|
||||||
AppRater.appLaunched(this);
|
|
||||||
//PremiumShow.launch(this);
|
|
||||||
setupToolbar();
|
|
||||||
checkUpdate();
|
|
||||||
updateTabs();
|
|
||||||
getBottomNavigationView().setSelectedItemId(PreferenceUtil.getInstance(this).getLastPage());
|
|
||||||
getBottomNavigationView().setOnNavigationItemSelectedListener(item -> {
|
|
||||||
PreferenceUtil.getInstance(MainActivity.this).setLastPage(item.getItemId());
|
|
||||||
selectedFragment(item.getItemId());
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
mIntentFilter.addAction(MusicService.MEDIA_STORE_CHANGED);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void checkUpdate() {
|
|
||||||
appUpdateManager = AppUpdateManagerFactory.create(this);
|
|
||||||
appUpdateManager.registerListener(listener);
|
|
||||||
|
|
||||||
Task<AppUpdateInfo> appUpdateInfoTask = appUpdateManager.getAppUpdateInfo();
|
|
||||||
appUpdateInfoTask.addOnSuccessListener(appUpdateInfo -> {
|
|
||||||
if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE
|
|
||||||
&& appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE)) {
|
|
||||||
try {
|
|
||||||
appUpdateManager.startUpdateFlowForResult(
|
|
||||||
appUpdateInfo,
|
|
||||||
AppUpdateType.IMMEDIATE,
|
|
||||||
this,
|
|
||||||
APP_UPDATE_REQUEST_CODE);
|
|
||||||
} catch (IntentSender.SendIntentException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
|
||||||
if (requestCode == APP_INTRO_REQUEST) {
|
|
||||||
blockRequestPermissions = false;
|
|
||||||
if (!hasPermissions()) {
|
|
||||||
requestPermissions();
|
|
||||||
}
|
|
||||||
} else if (requestCode == APP_UPDATE_REQUEST_CODE) {
|
|
||||||
if (resultCode != RESULT_OK) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
registerReceiver(mBroadcastReceiver, mIntentFilter);
|
|
||||||
PreferenceUtil.getInstance(this).registerOnSharedPreferenceChangedListener(this);
|
|
||||||
|
|
||||||
if (getIntent().hasExtra(EXPAND_PANEL) && getIntent().getBooleanExtra(EXPAND_PANEL, false) && PreferenceUtil.getInstance(this).isExpandPanel()) {
|
|
||||||
expandPanel();
|
|
||||||
getIntent().putExtra(EXPAND_PANEL, false);
|
|
||||||
}
|
|
||||||
appUpdateManager.getAppUpdateInfo()
|
|
||||||
.addOnSuccessListener(appUpdateInfo -> {
|
|
||||||
if (appUpdateInfo.installStatus() == InstallStatus.DOWNLOADED) {
|
|
||||||
popupSnackBarForCompleteUpdate();
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
if (appUpdateInfo.updateAvailability() == UpdateAvailability.DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS) {
|
|
||||||
appUpdateManager.startUpdateFlowForResult(
|
|
||||||
appUpdateInfo,
|
|
||||||
AppUpdateType.IMMEDIATE,
|
|
||||||
this,
|
|
||||||
APP_UPDATE_REQUEST_CODE);
|
|
||||||
}
|
|
||||||
} catch (IntentSender.SendIntentException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDestroy() {
|
|
||||||
super.onDestroy();
|
|
||||||
unregisterReceiver(mBroadcastReceiver);
|
|
||||||
PreferenceUtil.getInstance(this).unregisterOnSharedPreferenceChangedListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addOnAppBarOffsetChangedListener(
|
|
||||||
@NonNull AppBarLayout.OnOffsetChangedListener onOffsetChangedListener) {
|
|
||||||
mAppBarLayout.addOnOffsetChangedListener(onOffsetChangedListener);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getTotalAppBarScrollingRange() {
|
|
||||||
return mAppBarLayout.getTotalScrollRange();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean handleBackPress() {
|
|
||||||
if (cab != null && cab.isActive()) {
|
|
||||||
cab.finish();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return super.handleBackPress() || (currentFragment != null && currentFragment.handleBackPress());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCreateOptionsMenu(final Menu menu) {
|
|
||||||
getMenuInflater().inflate(R.menu.menu_main, menu);
|
|
||||||
if (isPlaylistPage()) {
|
|
||||||
menu.add(0, R.id.action_new_playlist, 1, R.string.new_playlist_title)
|
|
||||||
.setIcon(R.drawable.ic_playlist_add_white_24dp)
|
|
||||||
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
|
||||||
}
|
|
||||||
if (isHomePage()) {
|
|
||||||
menu.add(0, R.id.action_mic, 1, getString(R.string.action_search))
|
|
||||||
.setIcon(R.drawable.ic_mic_white_24dp)
|
|
||||||
.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
|
||||||
|
|
||||||
}
|
|
||||||
if (isFolderPage()) {
|
|
||||||
menu.add(0, R.id.action_scan, 0, R.string.scan_media)
|
|
||||||
.setIcon(R.drawable.ic_scanner_white_24dp)
|
|
||||||
.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
|
||||||
menu.add(0, R.id.action_go_to_start_directory, 1, R.string.action_go_to_start_directory)
|
|
||||||
.setIcon(R.drawable.ic_bookmark_music_white_24dp)
|
|
||||||
.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
|
||||||
}
|
|
||||||
Fragment fragment = getCurrentFragment();
|
|
||||||
if (fragment instanceof AbsLibraryPagerRecyclerViewCustomGridSizeFragment) {
|
|
||||||
AbsLibraryPagerRecyclerViewCustomGridSizeFragment currentFragment
|
|
||||||
= (AbsLibraryPagerRecyclerViewCustomGridSizeFragment) fragment;
|
|
||||||
|
|
||||||
MenuItem gridSizeItem = menu.findItem(R.id.action_grid_size);
|
|
||||||
if (RetroUtil.isLandscape()) {
|
|
||||||
gridSizeItem.setTitle(R.string.action_grid_size_land);
|
|
||||||
}
|
|
||||||
setUpGridSizeMenu(currentFragment, gridSizeItem.getSubMenu());
|
|
||||||
MenuItem layoutItem = menu.findItem(R.id.action_layout_type);
|
|
||||||
setupLayoutMenu(currentFragment, layoutItem.getSubMenu());
|
|
||||||
setUpSortOrderMenu(currentFragment, menu.findItem(R.id.action_sort_order).getSubMenu());
|
|
||||||
} else {
|
|
||||||
menu.removeItem(R.id.action_layout_type);
|
|
||||||
menu.removeItem(R.id.action_grid_size);
|
|
||||||
menu.removeItem(R.id.action_sort_order);
|
|
||||||
}
|
|
||||||
menu.add(0, R.id.action_settings, 6, getString(R.string.action_settings))
|
|
||||||
.setIcon(R.drawable.ic_settings_white_24dp)
|
|
||||||
.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
|
||||||
menu.add(0, R.id.action_search, 0, getString(R.string.action_search))
|
|
||||||
.setIcon(R.drawable.ic_search_white_24dp)
|
|
||||||
.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS);
|
|
||||||
return super.onCreateOptionsMenu(menu);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onOptionsItemSelected(@NonNull final MenuItem item) {
|
|
||||||
Fragment fragment = getCurrentFragment();
|
|
||||||
if (fragment instanceof AbsLibraryPagerRecyclerViewCustomGridSizeFragment) {
|
|
||||||
AbsLibraryPagerRecyclerViewCustomGridSizeFragment currentFragment
|
|
||||||
= (AbsLibraryPagerRecyclerViewCustomGridSizeFragment) fragment;
|
|
||||||
if (handleGridSizeMenuItem(currentFragment, item)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (handleLayoutResType(currentFragment, item)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (handleSortOrderMenuItem(currentFragment, item)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int id = item.getItemId();
|
|
||||||
switch (id) {
|
|
||||||
case R.id.action_search:
|
|
||||||
NavigationUtil.goToSearch(this);
|
|
||||||
break;
|
|
||||||
case R.id.action_new_playlist:
|
|
||||||
CreatePlaylistDialog.create().show(getSupportFragmentManager(), "CREATE_PLAYLIST");
|
|
||||||
return true;
|
|
||||||
case R.id.action_mic:
|
|
||||||
ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(this, mToolbar,
|
|
||||||
getString(R.string.transition_toolbar));
|
|
||||||
NavigationUtil.goToSearch(this, true, options);
|
|
||||||
return true;
|
|
||||||
case R.id.action_settings:
|
|
||||||
NavigationUtil.goToSettings(this);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return super.onOptionsItemSelected(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onPrepareOptionsMenu(final Menu menu) {
|
|
||||||
ToolbarContentTintHelper.handleOnPrepareOptionsMenu(this, mToolbar);
|
|
||||||
return super.onPrepareOptionsMenu(menu);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onServiceConnected() {
|
|
||||||
super.onServiceConnected();
|
|
||||||
handlePlaybackIntent(getIntent());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSharedPreferenceChanged(final @NonNull SharedPreferences sharedPreferences,
|
|
||||||
final @NonNull String key) {
|
|
||||||
if (key.equals(PreferenceUtil.GENERAL_THEME) || key.equals(PreferenceUtil.BLACK_THEME) ||
|
|
||||||
key.equals(PreferenceUtil.ADAPTIVE_COLOR_APP) ||
|
|
||||||
key.equals(PreferenceUtil.USER_NAME) || key.equals(PreferenceUtil.TOGGLE_FULL_SCREEN) ||
|
|
||||||
key.equals(PreferenceUtil.TOGGLE_VOLUME) || key.equals(PreferenceUtil.ROUND_CORNERS) ||
|
|
||||||
key.equals(PreferenceUtil.CAROUSEL_EFFECT) || key.equals(PreferenceUtil.NOW_PLAYING_SCREEN_ID) ||
|
|
||||||
key.equals(PreferenceUtil.TOGGLE_GENRE) || key.equals(PreferenceUtil.BANNER_IMAGE_PATH) ||
|
|
||||||
key.equals(PreferenceUtil.PROFILE_IMAGE_PATH) || key.equals(PreferenceUtil.CIRCULAR_ALBUM_ART) ||
|
|
||||||
key.equals(PreferenceUtil.KEEP_SCREEN_ON) || key.equals(PreferenceUtil.TOGGLE_SEPARATE_LINE) ||
|
|
||||||
key.equals(PreferenceUtil.TOGGLE_HOME_BANNER) || key.equals(PreferenceUtil.TOGGLE_ADD_CONTROLS) ||
|
|
||||||
key.equals(PreferenceUtil.ALBUM_COVER_STYLE) || key.equals(PreferenceUtil.HOME_ARTIST_GRID_STYLE) ||
|
|
||||||
key.equals(PreferenceUtil.ALBUM_COVER_TRANSFORM) || key.equals(PreferenceUtil.DESATURATED_COLOR) ||
|
|
||||||
key.equals(PreferenceUtil.EXTRA_SONG_INFO) || key.equals(PreferenceUtil.TAB_TEXT_MODE) ||
|
|
||||||
key.equals(PreferenceUtil.LANGUAGE_NAME) || key.equals(PreferenceUtil.LIBRARY_CATEGORIES)
|
|
||||||
) {
|
|
||||||
postRecreate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
public MaterialCab openCab(final int menuRes, @NotNull final Callback callback) {
|
|
||||||
if (cab != null && cab.isActive()) {
|
|
||||||
cab.finish();
|
|
||||||
}
|
|
||||||
cab = new MaterialCab(this, R.id.cab_stub)
|
|
||||||
.setMenu(menuRes)
|
|
||||||
.setCloseDrawableRes(R.drawable.ic_close_white_24dp)
|
|
||||||
.setBackgroundColor(
|
|
||||||
RetroColorUtil.shiftBackgroundColorForLightText(
|
|
||||||
ATHUtil.INSTANCE.resolveColor(this, R.attr.colorSurface)))
|
|
||||||
.start(callback);
|
|
||||||
return cab;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeOnAppBarOffsetChangedListener(
|
|
||||||
@NonNull AppBarLayout.OnOffsetChangedListener onOffsetChangedListener) {
|
|
||||||
mAppBarLayout.removeOnOffsetChangedListener(onOffsetChangedListener);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCurrentFragment(@NonNull Fragment fragment, @NonNull String tag) {
|
|
||||||
String currentTag = null;
|
|
||||||
if (getSupportFragmentManager().findFragmentByTag(tag) != null) {
|
|
||||||
currentTag = getSupportFragmentManager().findFragmentByTag(tag).getTag();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!tag.equals(currentTag)) {
|
|
||||||
getSupportFragmentManager()
|
|
||||||
.beginTransaction()
|
|
||||||
.replace(R.id.fragment_container, fragment, tag)
|
|
||||||
.commit();
|
|
||||||
currentFragment = (MainActivityFragmentCallbacks) fragment;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
protected View createContentView() {
|
|
||||||
return wrapSlidingMusicPanel(R.layout.activity_main_content);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void requestPermissions() {
|
|
||||||
if (!blockRequestPermissions) {
|
|
||||||
super.requestPermissions();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void checkShowChangelog() {
|
|
||||||
try {
|
|
||||||
final PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
|
|
||||||
final int currentVersion = pInfo.versionCode;
|
|
||||||
if (currentVersion != PreferenceUtil.getInstance(this).getLastChangelogVersion()) {
|
|
||||||
startActivityForResult(new Intent(this, WhatsNewActivity.class), APP_INTRO_REQUEST);
|
|
||||||
}
|
|
||||||
} catch (NameNotFoundException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
private Fragment getCurrentFragment() {
|
|
||||||
return getSupportFragmentManager().findFragmentById(R.id.fragment_container);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean handleGridSizeMenuItem(
|
|
||||||
@NonNull AbsLibraryPagerRecyclerViewCustomGridSizeFragment fragment,
|
|
||||||
@NonNull MenuItem item) {
|
|
||||||
int gridSize = 0;
|
|
||||||
switch (item.getItemId()) {
|
|
||||||
case R.id.action_grid_size_1:
|
|
||||||
gridSize = 1;
|
|
||||||
break;
|
|
||||||
case R.id.action_grid_size_2:
|
|
||||||
gridSize = 2;
|
|
||||||
break;
|
|
||||||
case R.id.action_grid_size_3:
|
|
||||||
gridSize = 3;
|
|
||||||
break;
|
|
||||||
case R.id.action_grid_size_4:
|
|
||||||
gridSize = 4;
|
|
||||||
break;
|
|
||||||
case R.id.action_grid_size_5:
|
|
||||||
gridSize = 5;
|
|
||||||
break;
|
|
||||||
case R.id.action_grid_size_6:
|
|
||||||
gridSize = 6;
|
|
||||||
break;
|
|
||||||
case R.id.action_grid_size_7:
|
|
||||||
gridSize = 7;
|
|
||||||
break;
|
|
||||||
case R.id.action_grid_size_8:
|
|
||||||
gridSize = 8;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gridSize > 0) {
|
|
||||||
item.setChecked(true);
|
|
||||||
fragment.setAndSaveGridSize(gridSize);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean handleLayoutResType(
|
|
||||||
final AbsLibraryPagerRecyclerViewCustomGridSizeFragment fragment,
|
|
||||||
final MenuItem item) {
|
|
||||||
int layoutRes = -1;
|
|
||||||
switch (item.getItemId()) {
|
|
||||||
case R.id.action_layout_normal:
|
|
||||||
layoutRes = R.layout.item_grid;
|
|
||||||
break;
|
|
||||||
case R.id.action_layout_card:
|
|
||||||
layoutRes = R.layout.item_card;
|
|
||||||
break;
|
|
||||||
case R.id.action_layout_colored_card:
|
|
||||||
layoutRes = R.layout.item_card_color;
|
|
||||||
break;
|
|
||||||
case R.id.action_layout_circular:
|
|
||||||
layoutRes = R.layout.item_grid_circle;
|
|
||||||
break;
|
|
||||||
case R.id.action_layout_image:
|
|
||||||
layoutRes = R.layout.image;
|
|
||||||
break;
|
|
||||||
case R.id.action_layout_gradient_image:
|
|
||||||
layoutRes = R.layout.item_image_gradient;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
Log.i(TAG, "handleLayoutResType: " + layoutRes);
|
|
||||||
|
|
||||||
if (layoutRes != -1) {
|
|
||||||
item.setChecked(true);
|
|
||||||
fragment.setAndSaveLayoutRes(layoutRes);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handlePlaybackIntent(@Nullable Intent intent) {
|
|
||||||
if (intent == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Uri uri = intent.getData();
|
|
||||||
String mimeType = intent.getType();
|
|
||||||
boolean handled = false;
|
|
||||||
|
|
||||||
if (intent.getAction() != null && intent.getAction()
|
|
||||||
.equals(MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH)) {
|
|
||||||
final List<Song> songs = SearchQueryHelper.getSongs(this, intent.getExtras());
|
|
||||||
if (MusicPlayerRemote.getShuffleMode() == MusicService.SHUFFLE_MODE_SHUFFLE) {
|
|
||||||
MusicPlayerRemote.openAndShuffleQueue(songs, true);
|
|
||||||
} else {
|
|
||||||
MusicPlayerRemote.openQueue(songs, 0, true);
|
|
||||||
}
|
|
||||||
handled = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (uri != null && uri.toString().length() > 0) {
|
|
||||||
MusicPlayerRemote.playFromUri(uri);
|
|
||||||
handled = true;
|
|
||||||
} else if (MediaStore.Audio.Playlists.CONTENT_TYPE.equals(mimeType)) {
|
|
||||||
final int id = (int) parseIdFromIntent(intent, "playlistId", "playlist");
|
|
||||||
if (id >= 0) {
|
|
||||||
int position = intent.getIntExtra("position", 0);
|
|
||||||
List<Song> songs = new ArrayList<>(PlaylistSongsLoader.getPlaylistSongList(this, id));
|
|
||||||
MusicPlayerRemote.openQueue(songs, position, true);
|
|
||||||
handled = true;
|
|
||||||
}
|
|
||||||
} else if (MediaStore.Audio.Albums.CONTENT_TYPE.equals(mimeType)) {
|
|
||||||
final int id = (int) parseIdFromIntent(intent, "albumId", "album");
|
|
||||||
if (id >= 0) {
|
|
||||||
int position = intent.getIntExtra("position", 0);
|
|
||||||
MusicPlayerRemote.openQueue(AlbumLoader.getAlbum(this, id).getSongs(), position, true);
|
|
||||||
handled = true;
|
|
||||||
}
|
|
||||||
} else if (MediaStore.Audio.Artists.CONTENT_TYPE.equals(mimeType)) {
|
|
||||||
final int id = (int) parseIdFromIntent(intent, "artistId", "artist");
|
|
||||||
if (id >= 0) {
|
|
||||||
int position = intent.getIntExtra("position", 0);
|
|
||||||
MusicPlayerRemote.openQueue(ArtistLoader.getArtist(this, id).getSongs(), position, true);
|
|
||||||
handled = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (handled) {
|
|
||||||
setIntent(new Intent());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean handleSortOrderMenuItem(
|
|
||||||
@NonNull AbsLibraryPagerRecyclerViewCustomGridSizeFragment
|
|
||||||
fragment, @NonNull MenuItem item) {
|
|
||||||
String sortOrder = null;
|
|
||||||
if (fragment instanceof AlbumsFragment) {
|
|
||||||
switch (item.getItemId()) {
|
|
||||||
case R.id.action_album_sort_order_asc:
|
|
||||||
sortOrder = AlbumSortOrder.ALBUM_A_Z;
|
|
||||||
break;
|
|
||||||
case R.id.action_album_sort_order_desc:
|
|
||||||
sortOrder = AlbumSortOrder.ALBUM_Z_A;
|
|
||||||
break;
|
|
||||||
case R.id.action_album_sort_order_artist:
|
|
||||||
sortOrder = AlbumSortOrder.ALBUM_ARTIST;
|
|
||||||
break;
|
|
||||||
case R.id.action_album_sort_order_year:
|
|
||||||
sortOrder = AlbumSortOrder.ALBUM_YEAR;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else if (fragment instanceof ArtistsFragment) {
|
|
||||||
switch (item.getItemId()) {
|
|
||||||
case R.id.action_artist_sort_order_asc:
|
|
||||||
sortOrder = ArtistSortOrder.ARTIST_A_Z;
|
|
||||||
break;
|
|
||||||
case R.id.action_artist_sort_order_desc:
|
|
||||||
sortOrder = ArtistSortOrder.ARTIST_Z_A;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else if (fragment instanceof SongsFragment) {
|
|
||||||
switch (item.getItemId()) {
|
|
||||||
case R.id.action_song_sort_order_asc:
|
|
||||||
sortOrder = SongSortOrder.SONG_A_Z;
|
|
||||||
break;
|
|
||||||
case R.id.action_song_sort_order_desc:
|
|
||||||
sortOrder = SongSortOrder.SONG_Z_A;
|
|
||||||
break;
|
|
||||||
case R.id.action_song_sort_order_artist:
|
|
||||||
sortOrder = SongSortOrder.SONG_ARTIST;
|
|
||||||
break;
|
|
||||||
case R.id.action_song_sort_order_album:
|
|
||||||
sortOrder = SongSortOrder.SONG_ALBUM;
|
|
||||||
break;
|
|
||||||
case R.id.action_song_sort_order_year:
|
|
||||||
sortOrder = SongSortOrder.SONG_YEAR;
|
|
||||||
break;
|
|
||||||
case R.id.action_song_sort_order_date:
|
|
||||||
sortOrder = SongSortOrder.SONG_DATE;
|
|
||||||
break;
|
|
||||||
case R.id.action_song_sort_order_composer:
|
|
||||||
sortOrder = SongSortOrder.COMPOSER;
|
|
||||||
break;
|
|
||||||
case R.id.action_song_sort_order_date_modified:
|
|
||||||
sortOrder = SongSortOrder.SONG_DATE_MODIFIED;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sortOrder != null) {
|
|
||||||
item.setChecked(true);
|
|
||||||
fragment.setAndSaveSortOrder(sortOrder);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isFolderPage() {
|
|
||||||
return getSupportFragmentManager().findFragmentByTag(FoldersFragment.TAG) instanceof FoldersFragment;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isHomePage() {
|
|
||||||
return getSupportFragmentManager().findFragmentByTag(BannerHomeFragment.TAG) instanceof BannerHomeFragment;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isPlaylistPage() {
|
|
||||||
return getSupportFragmentManager().findFragmentByTag(PlaylistsFragment.TAG) instanceof PlaylistsFragment;
|
|
||||||
}
|
|
||||||
|
|
||||||
private long parseIdFromIntent(@NonNull Intent intent, String longKey,
|
|
||||||
String stringKey) {
|
|
||||||
long id = intent.getLongExtra(longKey, -1);
|
|
||||||
if (id < 0) {
|
|
||||||
String idString = intent.getStringExtra(stringKey);
|
|
||||||
if (idString != null) {
|
|
||||||
try {
|
|
||||||
id = Long.parseLong(idString);
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
Log.e(TAG, e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void restoreCurrentFragment() {
|
|
||||||
currentFragment = (MainActivityFragmentCallbacks) getSupportFragmentManager()
|
|
||||||
.findFragmentById(R.id.fragment_container);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void selectedFragment(final int itemId) {
|
|
||||||
switch (itemId) {
|
|
||||||
case R.id.action_album:
|
|
||||||
setCurrentFragment(AlbumsFragment.newInstance(), AlbumsFragment.TAG);
|
|
||||||
break;
|
|
||||||
case R.id.action_artist:
|
|
||||||
setCurrentFragment(ArtistsFragment.newInstance(), ArtistsFragment.TAG);
|
|
||||||
break;
|
|
||||||
case R.id.action_playlist:
|
|
||||||
setCurrentFragment(PlaylistsFragment.newInstance(), PlaylistsFragment.TAG);
|
|
||||||
break;
|
|
||||||
case R.id.action_genre:
|
|
||||||
setCurrentFragment(GenresFragment.newInstance(), GenresFragment.TAG);
|
|
||||||
break;
|
|
||||||
case R.id.action_playing_queue:
|
|
||||||
setCurrentFragment(PlayingQueueFragment.newInstance(), PlayingQueueFragment.TAG);
|
|
||||||
break;
|
|
||||||
case R.id.action_song:
|
|
||||||
setCurrentFragment(SongsFragment.newInstance(), SongsFragment.TAG);
|
|
||||||
break;
|
|
||||||
case R.id.action_folder:
|
|
||||||
setCurrentFragment(FoldersFragment.newInstance(this), FoldersFragment.TAG);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
case R.id.action_home:
|
|
||||||
setCurrentFragment(BannerHomeFragment.newInstance(), BannerHomeFragment.TAG);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void setUpGridSizeMenu(@NonNull AbsLibraryPagerRecyclerViewCustomGridSizeFragment fragment,
|
|
||||||
@NonNull SubMenu gridSizeMenu) {
|
|
||||||
|
|
||||||
switch (fragment.getGridSize()) {
|
|
||||||
case 1:
|
|
||||||
gridSizeMenu.findItem(R.id.action_grid_size_1).setChecked(true);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
gridSizeMenu.findItem(R.id.action_grid_size_2).setChecked(true);
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
gridSizeMenu.findItem(R.id.action_grid_size_3).setChecked(true);
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
gridSizeMenu.findItem(R.id.action_grid_size_4).setChecked(true);
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
gridSizeMenu.findItem(R.id.action_grid_size_5).setChecked(true);
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
gridSizeMenu.findItem(R.id.action_grid_size_6).setChecked(true);
|
|
||||||
break;
|
|
||||||
case 7:
|
|
||||||
gridSizeMenu.findItem(R.id.action_grid_size_7).setChecked(true);
|
|
||||||
break;
|
|
||||||
case 8:
|
|
||||||
gridSizeMenu.findItem(R.id.action_grid_size_8).setChecked(true);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
int maxGridSize = fragment.getMaxGridSize();
|
|
||||||
if (maxGridSize < 8) {
|
|
||||||
gridSizeMenu.findItem(R.id.action_grid_size_8).setVisible(false);
|
|
||||||
}
|
|
||||||
if (maxGridSize < 7) {
|
|
||||||
gridSizeMenu.findItem(R.id.action_grid_size_7).setVisible(false);
|
|
||||||
}
|
|
||||||
if (maxGridSize < 6) {
|
|
||||||
gridSizeMenu.findItem(R.id.action_grid_size_6).setVisible(false);
|
|
||||||
}
|
|
||||||
if (maxGridSize < 5) {
|
|
||||||
gridSizeMenu.findItem(R.id.action_grid_size_5).setVisible(false);
|
|
||||||
}
|
|
||||||
if (maxGridSize < 4) {
|
|
||||||
gridSizeMenu.findItem(R.id.action_grid_size_4).setVisible(false);
|
|
||||||
}
|
|
||||||
if (maxGridSize < 3) {
|
|
||||||
gridSizeMenu.findItem(R.id.action_grid_size_3).setVisible(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setUpSortOrderMenu(
|
|
||||||
@NonNull AbsLibraryPagerRecyclerViewCustomGridSizeFragment fragment,
|
|
||||||
@NonNull SubMenu sortOrderMenu) {
|
|
||||||
String currentSortOrder = fragment.getSortOrder();
|
|
||||||
sortOrderMenu.clear();
|
|
||||||
|
|
||||||
if (fragment instanceof AlbumsFragment) {
|
|
||||||
sortOrderMenu.add(0, R.id.action_album_sort_order_asc, 0, R.string.sort_order_a_z)
|
|
||||||
.setChecked(currentSortOrder.equals(AlbumSortOrder.ALBUM_A_Z));
|
|
||||||
sortOrderMenu.add(0, R.id.action_album_sort_order_desc, 1, R.string.sort_order_z_a)
|
|
||||||
.setChecked(currentSortOrder.equals(AlbumSortOrder.ALBUM_Z_A));
|
|
||||||
sortOrderMenu.add(0, R.id.action_album_sort_order_artist, 2, R.string.sort_order_artist)
|
|
||||||
.setChecked(currentSortOrder.equals(AlbumSortOrder.ALBUM_ARTIST));
|
|
||||||
sortOrderMenu.add(0, R.id.action_album_sort_order_year, 3, R.string.sort_order_year)
|
|
||||||
.setChecked(currentSortOrder.equals(AlbumSortOrder.ALBUM_YEAR));
|
|
||||||
} else if (fragment instanceof ArtistsFragment) {
|
|
||||||
sortOrderMenu.add(0, R.id.action_artist_sort_order_asc, 0, R.string.sort_order_a_z)
|
|
||||||
.setChecked(currentSortOrder.equals(ArtistSortOrder.ARTIST_A_Z));
|
|
||||||
sortOrderMenu.add(0, R.id.action_artist_sort_order_desc, 1, R.string.sort_order_z_a)
|
|
||||||
.setChecked(currentSortOrder.equals(ArtistSortOrder.ARTIST_Z_A));
|
|
||||||
} else if (fragment instanceof SongsFragment) {
|
|
||||||
sortOrderMenu.add(0, R.id.action_song_sort_order_asc, 0, R.string.sort_order_a_z)
|
|
||||||
.setChecked(currentSortOrder.equals(SongSortOrder.SONG_A_Z));
|
|
||||||
sortOrderMenu.add(0, R.id.action_song_sort_order_desc, 1, R.string.sort_order_z_a)
|
|
||||||
.setChecked(currentSortOrder.equals(SongSortOrder.SONG_Z_A));
|
|
||||||
sortOrderMenu.add(0, R.id.action_song_sort_order_artist, 2, R.string.sort_order_artist)
|
|
||||||
.setChecked(currentSortOrder.equals(SongSortOrder.SONG_ARTIST));
|
|
||||||
sortOrderMenu.add(0, R.id.action_song_sort_order_album, 3, R.string.sort_order_album)
|
|
||||||
.setChecked(currentSortOrder.equals(SongSortOrder.SONG_ALBUM));
|
|
||||||
sortOrderMenu.add(0, R.id.action_song_sort_order_year, 4, R.string.sort_order_year)
|
|
||||||
.setChecked(currentSortOrder.equals(SongSortOrder.SONG_YEAR));
|
|
||||||
sortOrderMenu.add(0, R.id.action_song_sort_order_date, 5, R.string.sort_order_date)
|
|
||||||
.setChecked(currentSortOrder.equals(SongSortOrder.SONG_DATE));
|
|
||||||
sortOrderMenu.add(0, R.id.action_song_sort_order_date_modified, 6, R.string.sort_order_date_modified)
|
|
||||||
.setChecked(currentSortOrder.equals(SongSortOrder.SONG_DATE_MODIFIED));
|
|
||||||
sortOrderMenu.add(0, R.id.action_song_sort_order_composer, 7, R.string.sort_order_composer)
|
|
||||||
.setChecked(currentSortOrder.equals(SongSortOrder.COMPOSER));
|
|
||||||
}
|
|
||||||
sortOrderMenu.setGroupCheckable(0, true, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setupLayoutMenu(
|
|
||||||
@NonNull final AbsLibraryPagerRecyclerViewCustomGridSizeFragment fragment,
|
|
||||||
@NonNull final SubMenu subMenu) {
|
|
||||||
switch (fragment.itemLayoutRes()) {
|
|
||||||
case R.layout.item_card:
|
|
||||||
subMenu.findItem(R.id.action_layout_card).setChecked(true);
|
|
||||||
break;
|
|
||||||
case R.layout.item_card_color:
|
|
||||||
subMenu.findItem(R.id.action_layout_colored_card).setChecked(true);
|
|
||||||
break;
|
|
||||||
case R.layout.item_grid_circle:
|
|
||||||
subMenu.findItem(R.id.action_layout_circular).setChecked(true);
|
|
||||||
break;
|
|
||||||
case R.layout.image:
|
|
||||||
subMenu.findItem(R.id.action_layout_image).setChecked(true);
|
|
||||||
break;
|
|
||||||
case R.layout.item_image_gradient:
|
|
||||||
subMenu.findItem(R.id.action_layout_gradient_image).setChecked(true);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
case R.layout.item_grid:
|
|
||||||
subMenu.findItem(R.id.action_layout_normal).setChecked(true);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setupToolbar() {
|
|
||||||
setTitle(null);
|
|
||||||
mToolbar.setBackgroundColor(ATHUtil.INSTANCE.resolveColor(this, R.attr.colorSurface));
|
|
||||||
mAppBarLayout.setBackgroundColor(ATHUtil.INSTANCE.resolveColor(this, R.attr.colorSurface));
|
|
||||||
setSupportActionBar(mToolbar);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,775 @@
|
||||||
|
package code.name.monkey.retromusic.activities
|
||||||
|
|
||||||
|
import android.app.ActivityOptions
|
||||||
|
import android.content.*
|
||||||
|
import android.content.IntentSender.SendIntentException
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.provider.MediaStore
|
||||||
|
import android.util.Log
|
||||||
|
import android.view.Menu
|
||||||
|
import android.view.MenuItem
|
||||||
|
import android.view.SubMenu
|
||||||
|
import android.view.View
|
||||||
|
import androidx.core.app.ActivityCompat
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import androidx.fragment.app.commit
|
||||||
|
import code.name.monkey.appthemehelper.ThemeStore.Companion.accentColor
|
||||||
|
import code.name.monkey.appthemehelper.util.ATHUtil.resolveColor
|
||||||
|
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
||||||
|
import code.name.monkey.retromusic.*
|
||||||
|
import code.name.monkey.retromusic.activities.base.AbsSlidingMusicPanelActivity
|
||||||
|
import code.name.monkey.retromusic.dialogs.CreatePlaylistDialog.Companion.create
|
||||||
|
import code.name.monkey.retromusic.fragments.albums.AlbumsFragment
|
||||||
|
import code.name.monkey.retromusic.fragments.artists.ArtistsFragment
|
||||||
|
import code.name.monkey.retromusic.fragments.base.AbsLibraryPagerRecyclerViewCustomGridSizeFragment
|
||||||
|
import code.name.monkey.retromusic.fragments.genres.GenresFragment
|
||||||
|
import code.name.monkey.retromusic.fragments.home.BannerHomeFragment
|
||||||
|
import code.name.monkey.retromusic.fragments.mainactivity.FoldersFragment
|
||||||
|
import code.name.monkey.retromusic.fragments.playlists.PlaylistsFragment
|
||||||
|
import code.name.monkey.retromusic.fragments.queue.PlayingQueueFragment
|
||||||
|
import code.name.monkey.retromusic.fragments.songs.SongsFragment
|
||||||
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote.isPlaying
|
||||||
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote.openAndShuffleQueue
|
||||||
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote.openQueue
|
||||||
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote.playFromUri
|
||||||
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote.shuffleMode
|
||||||
|
import code.name.monkey.retromusic.helper.SearchQueryHelper.getSongs
|
||||||
|
import code.name.monkey.retromusic.helper.SortOrder.*
|
||||||
|
import code.name.monkey.retromusic.interfaces.CabHolder
|
||||||
|
import code.name.monkey.retromusic.interfaces.MainActivityFragmentCallbacks
|
||||||
|
import code.name.monkey.retromusic.loaders.AlbumLoader.getAlbum
|
||||||
|
import code.name.monkey.retromusic.loaders.ArtistLoader.getArtist
|
||||||
|
import code.name.monkey.retromusic.loaders.PlaylistSongsLoader.getPlaylistSongList
|
||||||
|
import code.name.monkey.retromusic.model.Song
|
||||||
|
import code.name.monkey.retromusic.service.MusicService
|
||||||
|
import code.name.monkey.retromusic.util.AppRater.appLaunched
|
||||||
|
import code.name.monkey.retromusic.util.NavigationUtil
|
||||||
|
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||||
|
import code.name.monkey.retromusic.util.RetroColorUtil
|
||||||
|
import code.name.monkey.retromusic.util.RetroUtil
|
||||||
|
import com.afollestad.materialcab.MaterialCab
|
||||||
|
import com.google.android.material.appbar.AppBarLayout
|
||||||
|
import com.google.android.material.snackbar.Snackbar
|
||||||
|
import com.google.android.play.core.appupdate.AppUpdateInfo
|
||||||
|
import com.google.android.play.core.appupdate.AppUpdateManager
|
||||||
|
import com.google.android.play.core.appupdate.AppUpdateManagerFactory
|
||||||
|
import com.google.android.play.core.install.InstallState
|
||||||
|
import com.google.android.play.core.install.InstallStateUpdatedListener
|
||||||
|
import com.google.android.play.core.install.model.AppUpdateType
|
||||||
|
import com.google.android.play.core.install.model.InstallStatus
|
||||||
|
import com.google.android.play.core.install.model.UpdateAvailability
|
||||||
|
import com.google.android.play.core.tasks.Task
|
||||||
|
import kotlinx.android.synthetic.main.activity_main_content.*
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
class MainActivity : AbsSlidingMusicPanelActivity(),
|
||||||
|
SharedPreferences.OnSharedPreferenceChangeListener, CabHolder {
|
||||||
|
companion object {
|
||||||
|
const val TAG = "MainActivity"
|
||||||
|
const val EXPAND_PANEL = "expand_panel"
|
||||||
|
const val APP_UPDATE_REQUEST_CODE = 9002
|
||||||
|
}
|
||||||
|
|
||||||
|
private lateinit var cab: MaterialCab
|
||||||
|
private val intentFilter = IntentFilter(Intent.ACTION_SCREEN_OFF)
|
||||||
|
private lateinit var currentFragment: MainActivityFragmentCallbacks
|
||||||
|
private var appUpdateManager: AppUpdateManager? = null
|
||||||
|
private var blockRequestPermissions = false
|
||||||
|
private val listener = object : InstallStateUpdatedListener {
|
||||||
|
override fun onStateUpdate(state: InstallState) {
|
||||||
|
when {
|
||||||
|
state.installStatus() == InstallStatus.DOWNLOADED -> {
|
||||||
|
popupSnackBarForCompleteUpdate()
|
||||||
|
}
|
||||||
|
state.installStatus() == InstallStatus.INSTALLED -> {
|
||||||
|
appUpdateManager?.unregisterListener(this)
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
Log.i(TAG, "InstallStateUpdatedListener: state: " + state.installStatus())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private val broadcastReceiver: BroadcastReceiver = object : BroadcastReceiver() {
|
||||||
|
override fun onReceive(context: Context, intent: Intent) {
|
||||||
|
val action = intent.action
|
||||||
|
if (action != null && action == Intent.ACTION_SCREEN_OFF) {
|
||||||
|
if (PreferenceUtilKT.isLockScreen && isPlaying) {
|
||||||
|
val activity = Intent(context, LockScreenActivity::class.java)
|
||||||
|
activity.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||||
|
activity.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY)
|
||||||
|
ActivityCompat.startActivity(context, activity, null)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun createContentView(): View {
|
||||||
|
return wrapSlidingMusicPanel(R.layout.activity_main_content)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
setDrawUnderStatusBar()
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
setStatusbarColorAuto()
|
||||||
|
setNavigationbarColorAuto()
|
||||||
|
setLightNavigationBar(true)
|
||||||
|
setTaskDescriptionColorAuto()
|
||||||
|
hideStatusBar()
|
||||||
|
setBottomBarVisibility(View.VISIBLE)
|
||||||
|
|
||||||
|
if (savedInstanceState == null) {
|
||||||
|
selectedFragment(PreferenceUtilKT.lastPage)
|
||||||
|
} else {
|
||||||
|
restoreCurrentFragment()
|
||||||
|
}
|
||||||
|
|
||||||
|
appLaunched(this)
|
||||||
|
setupToolbar()
|
||||||
|
checkUpdate()
|
||||||
|
getBottomNavigationView().selectedItemId = PreferenceUtilKT.lastPage
|
||||||
|
getBottomNavigationView().setOnNavigationItemSelectedListener {
|
||||||
|
PreferenceUtilKT.lastPage = it.itemId
|
||||||
|
selectedFragment(it.itemId)
|
||||||
|
true
|
||||||
|
}
|
||||||
|
updateTabs()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResume() {
|
||||||
|
super.onResume()
|
||||||
|
registerReceiver(broadcastReceiver, intentFilter)
|
||||||
|
PreferenceUtilKT.registerOnSharedPreferenceChangedListener(this)
|
||||||
|
if (intent.hasExtra(EXPAND_PANEL) &&
|
||||||
|
intent.getBooleanExtra(EXPAND_PANEL, false) &&
|
||||||
|
PreferenceUtilKT.isExpandPanel
|
||||||
|
) {
|
||||||
|
expandPanel()
|
||||||
|
intent.removeExtra(EXPAND_PANEL)
|
||||||
|
}
|
||||||
|
|
||||||
|
appUpdateManager?.appUpdateInfo
|
||||||
|
?.addOnSuccessListener { appUpdateInfo: AppUpdateInfo ->
|
||||||
|
if (appUpdateInfo.installStatus() == InstallStatus.DOWNLOADED) {
|
||||||
|
popupSnackBarForCompleteUpdate()
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if (appUpdateInfo.updateAvailability() == UpdateAvailability.DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS) {
|
||||||
|
appUpdateManager!!.startUpdateFlowForResult(
|
||||||
|
appUpdateInfo,
|
||||||
|
AppUpdateType.IMMEDIATE,
|
||||||
|
this,
|
||||||
|
APP_UPDATE_REQUEST_CODE
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} catch (e: SendIntentException) {
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDestroy() {
|
||||||
|
super.onDestroy()
|
||||||
|
unregisterReceiver(broadcastReceiver)
|
||||||
|
PreferenceUtilKT.unregisterOnSharedPreferenceChangedListener(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPrepareOptionsMenu(menu: Menu?): Boolean {
|
||||||
|
ToolbarContentTintHelper.handleOnPrepareOptionsMenu(this, toolbar)
|
||||||
|
return super.onPrepareOptionsMenu(menu)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
|
||||||
|
menuInflater.inflate(R.menu.menu_main, menu)
|
||||||
|
menu ?: return super.onCreateOptionsMenu(menu)
|
||||||
|
if (isPlaylistPage()) {
|
||||||
|
menu.add(0, R.id.action_new_playlist, 1, R.string.new_playlist_title)
|
||||||
|
.setIcon(R.drawable.ic_playlist_add_white_24dp)
|
||||||
|
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM)
|
||||||
|
}
|
||||||
|
if (isHomePage()) {
|
||||||
|
menu.add(0, R.id.action_mic, 1, getString(R.string.action_search))
|
||||||
|
.setIcon(R.drawable.ic_mic_white_24dp)
|
||||||
|
.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM)
|
||||||
|
}
|
||||||
|
if (isFolderPage()) {
|
||||||
|
menu.add(0, R.id.action_scan, 0, R.string.scan_media)
|
||||||
|
.setIcon(R.drawable.ic_scanner_white_24dp)
|
||||||
|
.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM)
|
||||||
|
menu.add(0, R.id.action_go_to_start_directory, 1, R.string.action_go_to_start_directory)
|
||||||
|
.setIcon(R.drawable.ic_bookmark_music_white_24dp)
|
||||||
|
.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM)
|
||||||
|
}
|
||||||
|
val fragment: Fragment? = getCurrentFragment()
|
||||||
|
if (fragment != null && fragment is AbsLibraryPagerRecyclerViewCustomGridSizeFragment<*, *>) {
|
||||||
|
val gridSizeItem: MenuItem = menu.findItem(R.id.action_grid_size)
|
||||||
|
if (RetroUtil.isLandscape()) {
|
||||||
|
gridSizeItem.setTitle(R.string.action_grid_size_land)
|
||||||
|
}
|
||||||
|
setUpGridSizeMenu(fragment, gridSizeItem.subMenu)
|
||||||
|
|
||||||
|
val layoutItem: MenuItem = menu.findItem(R.id.action_layout_type)
|
||||||
|
setupLayoutMenu(fragment, layoutItem.subMenu)
|
||||||
|
|
||||||
|
setUpSortOrderMenu(fragment, menu.findItem(R.id.action_sort_order).subMenu)
|
||||||
|
} else {
|
||||||
|
menu.removeItem(R.id.action_layout_type)
|
||||||
|
menu.removeItem(R.id.action_grid_size)
|
||||||
|
menu.removeItem(R.id.action_sort_order)
|
||||||
|
}
|
||||||
|
menu.add(0, R.id.action_settings, 6, getString(R.string.action_settings))
|
||||||
|
.setIcon(R.drawable.ic_settings_white_24dp)
|
||||||
|
.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM)
|
||||||
|
menu.add(0, R.id.action_search, 0, getString(R.string.action_search))
|
||||||
|
.setIcon(R.drawable.ic_search_white_24dp)
|
||||||
|
.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS)
|
||||||
|
return super.onCreateOptionsMenu(menu)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
|
val fragment = getCurrentFragment()
|
||||||
|
if (fragment is AbsLibraryPagerRecyclerViewCustomGridSizeFragment<*, *>) {
|
||||||
|
if (handleGridSizeMenuItem(fragment, item)) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if (handleLayoutResType(fragment, item)) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if (handleSortOrderMenuItem(fragment, item)) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
when (item.itemId) {
|
||||||
|
R.id.action_search -> NavigationUtil.goToSearch(this)
|
||||||
|
R.id.action_new_playlist -> {
|
||||||
|
create().show(supportFragmentManager, "CREATE_PLAYLIST")
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
R.id.action_mic -> {
|
||||||
|
val options = ActivityOptions.makeSceneTransitionAnimation(
|
||||||
|
this, toolbar,
|
||||||
|
getString(R.string.transition_toolbar)
|
||||||
|
)
|
||||||
|
NavigationUtil.goToSearch(this, true, options)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
R.id.action_settings -> {
|
||||||
|
NavigationUtil.goToSettings(this)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return super.onOptionsItemSelected(item)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun handleSortOrderMenuItem(
|
||||||
|
fragment: AbsLibraryPagerRecyclerViewCustomGridSizeFragment<*, *>,
|
||||||
|
item: MenuItem
|
||||||
|
): Boolean {
|
||||||
|
var sortOrder: String? = null
|
||||||
|
when (fragment) {
|
||||||
|
is AlbumsFragment -> {
|
||||||
|
when (item.itemId) {
|
||||||
|
R.id.action_album_sort_order_asc -> sortOrder = AlbumSortOrder.ALBUM_A_Z
|
||||||
|
R.id.action_album_sort_order_desc -> sortOrder = AlbumSortOrder.ALBUM_Z_A
|
||||||
|
R.id.action_album_sort_order_artist -> sortOrder = AlbumSortOrder.ALBUM_ARTIST
|
||||||
|
R.id.action_album_sort_order_year -> sortOrder = AlbumSortOrder.ALBUM_YEAR
|
||||||
|
}
|
||||||
|
}
|
||||||
|
is ArtistsFragment -> {
|
||||||
|
when (item.itemId) {
|
||||||
|
R.id.action_artist_sort_order_asc -> sortOrder = ArtistSortOrder.ARTIST_A_Z
|
||||||
|
R.id.action_artist_sort_order_desc -> sortOrder = ArtistSortOrder.ARTIST_Z_A
|
||||||
|
}
|
||||||
|
}
|
||||||
|
is SongsFragment -> {
|
||||||
|
when (item.itemId) {
|
||||||
|
R.id.action_song_sort_order_asc -> sortOrder = SongSortOrder.SONG_A_Z
|
||||||
|
R.id.action_song_sort_order_desc -> sortOrder = SongSortOrder.SONG_Z_A
|
||||||
|
R.id.action_song_sort_order_artist -> sortOrder = SongSortOrder.SONG_ARTIST
|
||||||
|
R.id.action_song_sort_order_album -> sortOrder = SongSortOrder.SONG_ALBUM
|
||||||
|
R.id.action_song_sort_order_year -> sortOrder = SongSortOrder.SONG_YEAR
|
||||||
|
R.id.action_song_sort_order_date -> sortOrder = SongSortOrder.SONG_DATE
|
||||||
|
R.id.action_song_sort_order_composer -> sortOrder = SongSortOrder.COMPOSER
|
||||||
|
R.id.action_song_sort_order_date_modified ->
|
||||||
|
sortOrder = SongSortOrder.SONG_DATE_MODIFIED
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sortOrder != null) {
|
||||||
|
item.isChecked = true
|
||||||
|
fragment.setAndSaveSortOrder(sortOrder)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun handleLayoutResType(
|
||||||
|
fragment: AbsLibraryPagerRecyclerViewCustomGridSizeFragment<*, *>,
|
||||||
|
item: MenuItem
|
||||||
|
): Boolean {
|
||||||
|
var layoutRes = -1
|
||||||
|
when (item.itemId) {
|
||||||
|
R.id.action_layout_normal -> layoutRes = R.layout.item_grid
|
||||||
|
R.id.action_layout_card -> layoutRes = R.layout.item_card
|
||||||
|
R.id.action_layout_colored_card -> layoutRes = R.layout.item_card_color
|
||||||
|
R.id.action_layout_circular -> layoutRes = R.layout.item_grid_circle
|
||||||
|
R.id.action_layout_image -> layoutRes = R.layout.image
|
||||||
|
R.id.action_layout_gradient_image -> layoutRes = R.layout.item_image_gradient
|
||||||
|
}
|
||||||
|
if (layoutRes != -1) {
|
||||||
|
item.isChecked = true
|
||||||
|
fragment.setAndSaveLayoutRes(layoutRes)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun handleGridSizeMenuItem(
|
||||||
|
fragment: AbsLibraryPagerRecyclerViewCustomGridSizeFragment<*, *>,
|
||||||
|
item: MenuItem
|
||||||
|
): Boolean {
|
||||||
|
var gridSize = 0
|
||||||
|
when (item.itemId) {
|
||||||
|
R.id.action_grid_size_1 -> gridSize = 1
|
||||||
|
R.id.action_grid_size_2 -> gridSize = 2
|
||||||
|
R.id.action_grid_size_3 -> gridSize = 3
|
||||||
|
R.id.action_grid_size_4 -> gridSize = 4
|
||||||
|
R.id.action_grid_size_5 -> gridSize = 5
|
||||||
|
R.id.action_grid_size_6 -> gridSize = 6
|
||||||
|
R.id.action_grid_size_7 -> gridSize = 7
|
||||||
|
R.id.action_grid_size_8 -> gridSize = 8
|
||||||
|
}
|
||||||
|
if (gridSize > 0) {
|
||||||
|
item.isChecked = true
|
||||||
|
fragment.setAndSaveGridSize(gridSize)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setUpGridSizeMenu(
|
||||||
|
fragment: AbsLibraryPagerRecyclerViewCustomGridSizeFragment<*, *>,
|
||||||
|
gridSizeMenu: SubMenu
|
||||||
|
) {
|
||||||
|
when (fragment.getGridSize()) {
|
||||||
|
1 -> gridSizeMenu.findItem(R.id.action_grid_size_1).isChecked = true
|
||||||
|
2 -> gridSizeMenu.findItem(R.id.action_grid_size_2).isChecked = true
|
||||||
|
3 -> gridSizeMenu.findItem(R.id.action_grid_size_3).isChecked = true
|
||||||
|
4 -> gridSizeMenu.findItem(R.id.action_grid_size_4).isChecked = true
|
||||||
|
5 -> gridSizeMenu.findItem(R.id.action_grid_size_5).isChecked = true
|
||||||
|
6 -> gridSizeMenu.findItem(R.id.action_grid_size_6).isChecked = true
|
||||||
|
7 -> gridSizeMenu.findItem(R.id.action_grid_size_7).isChecked = true
|
||||||
|
8 -> gridSizeMenu.findItem(R.id.action_grid_size_8).isChecked = true
|
||||||
|
}
|
||||||
|
val maxGridSize = fragment.maxGridSize
|
||||||
|
if (maxGridSize < 8) {
|
||||||
|
gridSizeMenu.findItem(R.id.action_grid_size_8).isVisible = false
|
||||||
|
}
|
||||||
|
if (maxGridSize < 7) {
|
||||||
|
gridSizeMenu.findItem(R.id.action_grid_size_7).isVisible = false
|
||||||
|
}
|
||||||
|
if (maxGridSize < 6) {
|
||||||
|
gridSizeMenu.findItem(R.id.action_grid_size_6).isVisible = false
|
||||||
|
}
|
||||||
|
if (maxGridSize < 5) {
|
||||||
|
gridSizeMenu.findItem(R.id.action_grid_size_5).isVisible = false
|
||||||
|
}
|
||||||
|
if (maxGridSize < 4) {
|
||||||
|
gridSizeMenu.findItem(R.id.action_grid_size_4).isVisible = false
|
||||||
|
}
|
||||||
|
if (maxGridSize < 3) {
|
||||||
|
gridSizeMenu.findItem(R.id.action_grid_size_3).isVisible = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setupLayoutMenu(
|
||||||
|
fragment: AbsLibraryPagerRecyclerViewCustomGridSizeFragment<*, *>,
|
||||||
|
subMenu: SubMenu
|
||||||
|
) {
|
||||||
|
when (fragment.itemLayoutRes()) {
|
||||||
|
R.layout.item_card ->
|
||||||
|
subMenu.findItem(R.id.action_layout_card).isChecked = true
|
||||||
|
R.layout.item_card_color ->
|
||||||
|
subMenu.findItem(R.id.action_layout_colored_card).isChecked = true
|
||||||
|
R.layout.item_grid_circle ->
|
||||||
|
subMenu.findItem(R.id.action_layout_circular).isChecked = true
|
||||||
|
R.layout.image ->
|
||||||
|
subMenu.findItem(R.id.action_layout_image).isChecked = true
|
||||||
|
R.layout.item_image_gradient ->
|
||||||
|
subMenu.findItem(R.id.action_layout_gradient_image).isChecked = true
|
||||||
|
R.layout.item_grid ->
|
||||||
|
subMenu.findItem(R.id.action_layout_normal).isChecked = true
|
||||||
|
else ->
|
||||||
|
subMenu.findItem(R.id.action_layout_normal).isChecked = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setUpSortOrderMenu(
|
||||||
|
fragment: AbsLibraryPagerRecyclerViewCustomGridSizeFragment<*, *>,
|
||||||
|
sortOrderMenu: SubMenu
|
||||||
|
) {
|
||||||
|
val currentSortOrder = fragment.getSortOrder()
|
||||||
|
sortOrderMenu.clear()
|
||||||
|
when (fragment) {
|
||||||
|
is AlbumsFragment -> {
|
||||||
|
sortOrderMenu.add(
|
||||||
|
0,
|
||||||
|
R.id.action_album_sort_order_asc,
|
||||||
|
0,
|
||||||
|
R.string.sort_order_a_z
|
||||||
|
).isChecked =
|
||||||
|
currentSortOrder == AlbumSortOrder.ALBUM_A_Z
|
||||||
|
sortOrderMenu.add(
|
||||||
|
0,
|
||||||
|
R.id.action_album_sort_order_desc,
|
||||||
|
1,
|
||||||
|
R.string.sort_order_z_a
|
||||||
|
).isChecked =
|
||||||
|
currentSortOrder == AlbumSortOrder.ALBUM_Z_A
|
||||||
|
sortOrderMenu.add(
|
||||||
|
0,
|
||||||
|
R.id.action_album_sort_order_artist,
|
||||||
|
2,
|
||||||
|
R.string.sort_order_artist
|
||||||
|
).isChecked =
|
||||||
|
currentSortOrder == AlbumSortOrder.ALBUM_ARTIST
|
||||||
|
sortOrderMenu.add(
|
||||||
|
0,
|
||||||
|
R.id.action_album_sort_order_year,
|
||||||
|
3,
|
||||||
|
R.string.sort_order_year
|
||||||
|
).isChecked =
|
||||||
|
currentSortOrder == AlbumSortOrder.ALBUM_YEAR
|
||||||
|
}
|
||||||
|
is ArtistsFragment -> {
|
||||||
|
sortOrderMenu.add(
|
||||||
|
0,
|
||||||
|
R.id.action_artist_sort_order_asc,
|
||||||
|
0,
|
||||||
|
R.string.sort_order_a_z
|
||||||
|
).isChecked =
|
||||||
|
currentSortOrder == ArtistSortOrder.ARTIST_A_Z
|
||||||
|
sortOrderMenu.add(
|
||||||
|
0,
|
||||||
|
R.id.action_artist_sort_order_desc,
|
||||||
|
1,
|
||||||
|
R.string.sort_order_z_a
|
||||||
|
).isChecked =
|
||||||
|
currentSortOrder == ArtistSortOrder.ARTIST_Z_A
|
||||||
|
}
|
||||||
|
is SongsFragment -> {
|
||||||
|
sortOrderMenu.add(
|
||||||
|
0,
|
||||||
|
R.id.action_song_sort_order_asc,
|
||||||
|
0,
|
||||||
|
R.string.sort_order_a_z
|
||||||
|
).isChecked =
|
||||||
|
currentSortOrder == SongSortOrder.SONG_A_Z
|
||||||
|
sortOrderMenu.add(
|
||||||
|
0,
|
||||||
|
R.id.action_song_sort_order_desc,
|
||||||
|
1,
|
||||||
|
R.string.sort_order_z_a
|
||||||
|
).isChecked =
|
||||||
|
currentSortOrder == SongSortOrder.SONG_Z_A
|
||||||
|
sortOrderMenu.add(
|
||||||
|
0,
|
||||||
|
R.id.action_song_sort_order_artist,
|
||||||
|
2,
|
||||||
|
R.string.sort_order_artist
|
||||||
|
).isChecked =
|
||||||
|
currentSortOrder == SongSortOrder.SONG_ARTIST
|
||||||
|
sortOrderMenu.add(
|
||||||
|
0,
|
||||||
|
R.id.action_song_sort_order_album,
|
||||||
|
3,
|
||||||
|
R.string.sort_order_album
|
||||||
|
).isChecked =
|
||||||
|
currentSortOrder == SongSortOrder.SONG_ALBUM
|
||||||
|
sortOrderMenu.add(
|
||||||
|
0,
|
||||||
|
R.id.action_song_sort_order_year,
|
||||||
|
4,
|
||||||
|
R.string.sort_order_year
|
||||||
|
).isChecked =
|
||||||
|
currentSortOrder == SongSortOrder.SONG_YEAR
|
||||||
|
sortOrderMenu.add(
|
||||||
|
0,
|
||||||
|
R.id.action_song_sort_order_date,
|
||||||
|
5,
|
||||||
|
R.string.sort_order_date
|
||||||
|
).isChecked =
|
||||||
|
currentSortOrder == SongSortOrder.SONG_DATE
|
||||||
|
sortOrderMenu.add(
|
||||||
|
0,
|
||||||
|
R.id.action_song_sort_order_date_modified,
|
||||||
|
6,
|
||||||
|
R.string.sort_order_date_modified
|
||||||
|
).isChecked = currentSortOrder == SongSortOrder.SONG_DATE_MODIFIED
|
||||||
|
sortOrderMenu.add(
|
||||||
|
0,
|
||||||
|
R.id.action_song_sort_order_composer,
|
||||||
|
7,
|
||||||
|
R.string.sort_order_composer
|
||||||
|
).isChecked = currentSortOrder == SongSortOrder.COMPOSER
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sortOrderMenu.setGroupCheckable(0, true, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getCurrentFragment(): Fragment? {
|
||||||
|
return supportFragmentManager.findFragmentById(R.id.fragment_container)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun isFolderPage(): Boolean {
|
||||||
|
return supportFragmentManager.findFragmentByTag(FoldersFragment.TAG) is FoldersFragment
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun isHomePage(): Boolean {
|
||||||
|
return supportFragmentManager.findFragmentByTag(BannerHomeFragment.TAG) is BannerHomeFragment
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun isPlaylistPage(): Boolean {
|
||||||
|
return supportFragmentManager.findFragmentByTag(PlaylistsFragment.TAG) is PlaylistsFragment
|
||||||
|
}
|
||||||
|
|
||||||
|
fun addOnAppBarOffsetChangedListener(
|
||||||
|
changedListener: AppBarLayout.OnOffsetChangedListener
|
||||||
|
) {
|
||||||
|
appBarLayout.addOnOffsetChangedListener(changedListener)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun removeOnAppBarOffsetChangedListener(
|
||||||
|
changedListener: AppBarLayout.OnOffsetChangedListener
|
||||||
|
) {
|
||||||
|
appBarLayout.removeOnOffsetChangedListener(changedListener)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getTotalAppBarScrollingRange(): Int {
|
||||||
|
return appBarLayout.totalScrollRange
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun requestPermissions() {
|
||||||
|
if (!blockRequestPermissions) {
|
||||||
|
super.requestPermissions()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||||
|
super.onActivityResult(requestCode, resultCode, data)
|
||||||
|
|
||||||
|
if (!hasPermissions()) {
|
||||||
|
requestPermissions()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private fun setupToolbar() {
|
||||||
|
toolbar.setBackgroundColor(resolveColor(this, R.attr.colorSurface))
|
||||||
|
appBarLayout.setBackgroundColor(resolveColor(this, R.attr.colorSurface))
|
||||||
|
setSupportActionBar(toolbar)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun checkUpdate() {
|
||||||
|
appUpdateManager = AppUpdateManagerFactory.create(this)
|
||||||
|
appUpdateManager?.registerListener(listener)
|
||||||
|
|
||||||
|
val appUpdateInfoTask: Task<AppUpdateInfo>? = appUpdateManager?.appUpdateInfo
|
||||||
|
appUpdateInfoTask?.addOnSuccessListener { appUpdateInfo ->
|
||||||
|
if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE
|
||||||
|
&& appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE)
|
||||||
|
) {
|
||||||
|
try {
|
||||||
|
appUpdateManager?.startUpdateFlowForResult(
|
||||||
|
appUpdateInfo,
|
||||||
|
AppUpdateType.IMMEDIATE,
|
||||||
|
this,
|
||||||
|
APP_UPDATE_REQUEST_CODE
|
||||||
|
)
|
||||||
|
} catch (e: SendIntentException) {
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun popupSnackBarForCompleteUpdate() {
|
||||||
|
val snackBar =
|
||||||
|
Snackbar.make(
|
||||||
|
findViewById(R.id.mainContent),
|
||||||
|
"New app is ready!",
|
||||||
|
Snackbar.LENGTH_INDEFINITE
|
||||||
|
)
|
||||||
|
snackBar.setAction(
|
||||||
|
"Install"
|
||||||
|
) {
|
||||||
|
appUpdateManager?.completeUpdate()
|
||||||
|
}
|
||||||
|
snackBar.setActionTextColor(accentColor(this))
|
||||||
|
snackBar.show()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setCurrentFragment(
|
||||||
|
fragment: Fragment,
|
||||||
|
tag: String
|
||||||
|
) {
|
||||||
|
supportFragmentManager.commit {
|
||||||
|
replace(R.id.fragment_container, fragment, tag)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun selectedFragment(itemId: Int) {
|
||||||
|
when (itemId) {
|
||||||
|
R.id.action_album -> setCurrentFragment(
|
||||||
|
AlbumsFragment.newInstance(),
|
||||||
|
AlbumsFragment.TAG
|
||||||
|
)
|
||||||
|
R.id.action_artist -> setCurrentFragment(
|
||||||
|
ArtistsFragment.newInstance(),
|
||||||
|
ArtistsFragment.TAG
|
||||||
|
)
|
||||||
|
R.id.action_playlist -> setCurrentFragment(
|
||||||
|
PlaylistsFragment.newInstance(),
|
||||||
|
PlaylistsFragment.TAG
|
||||||
|
)
|
||||||
|
R.id.action_genre -> setCurrentFragment(
|
||||||
|
GenresFragment.newInstance(),
|
||||||
|
GenresFragment.TAG
|
||||||
|
)
|
||||||
|
R.id.action_playing_queue -> setCurrentFragment(
|
||||||
|
PlayingQueueFragment.newInstance(),
|
||||||
|
PlayingQueueFragment.TAG
|
||||||
|
)
|
||||||
|
R.id.action_song -> setCurrentFragment(
|
||||||
|
SongsFragment.newInstance(),
|
||||||
|
SongsFragment.TAG
|
||||||
|
)
|
||||||
|
R.id.action_folder -> setCurrentFragment(
|
||||||
|
FoldersFragment.newInstance(this),
|
||||||
|
FoldersFragment.TAG
|
||||||
|
)
|
||||||
|
R.id.action_home -> setCurrentFragment(
|
||||||
|
BannerHomeFragment.newInstance(),
|
||||||
|
BannerHomeFragment.TAG
|
||||||
|
)
|
||||||
|
else -> setCurrentFragment(
|
||||||
|
BannerHomeFragment.newInstance(),
|
||||||
|
BannerHomeFragment.TAG
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun restoreCurrentFragment() {
|
||||||
|
val fragment = supportFragmentManager.findFragmentById(R.id.fragment_container)
|
||||||
|
if (fragment != null) {
|
||||||
|
currentFragment = fragment as MainActivityFragmentCallbacks
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
|
||||||
|
if (key == GENERAL_THEME || key == BLACK_THEME || key == ADAPTIVE_COLOR_APP || key == USER_NAME || key == TOGGLE_FULL_SCREEN || key == TOGGLE_VOLUME || key == ROUND_CORNERS || key == CAROUSEL_EFFECT || key == NOW_PLAYING_SCREEN_ID || key == TOGGLE_GENRE || key == BANNER_IMAGE_PATH || key == PROFILE_IMAGE_PATH || key == CIRCULAR_ALBUM_ART || key == KEEP_SCREEN_ON || key == TOGGLE_SEPARATE_LINE || key == TOGGLE_HOME_BANNER || key == TOGGLE_ADD_CONTROLS || key == ALBUM_COVER_STYLE || key == HOME_ARTIST_GRID_STYLE || key == ALBUM_COVER_TRANSFORM || key == DESATURATED_COLOR || key == EXTRA_SONG_INFO || key == TAB_TEXT_MODE || key == LANGUAGE_NAME || key == LIBRARY_CATEGORIES
|
||||||
|
) {
|
||||||
|
postRecreate()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onServiceConnected() {
|
||||||
|
super.onServiceConnected()
|
||||||
|
handlePlaybackIntent(intent)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun handlePlaybackIntent(intent: Intent?) {
|
||||||
|
if (intent == null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
val uri = intent.data
|
||||||
|
val mimeType = intent.type
|
||||||
|
var handled = false
|
||||||
|
if (intent.action != null && (intent.action == MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH)
|
||||||
|
) {
|
||||||
|
val songs: List<Song> =
|
||||||
|
getSongs(this, intent.extras!!)
|
||||||
|
if (shuffleMode == MusicService.SHUFFLE_MODE_SHUFFLE) {
|
||||||
|
openAndShuffleQueue(songs, true)
|
||||||
|
} else {
|
||||||
|
openQueue(songs, 0, true)
|
||||||
|
}
|
||||||
|
handled = true
|
||||||
|
}
|
||||||
|
if (uri != null && uri.toString().isNotEmpty()) {
|
||||||
|
playFromUri(uri)
|
||||||
|
handled = true
|
||||||
|
} else if (MediaStore.Audio.Playlists.CONTENT_TYPE == mimeType) {
|
||||||
|
val id = parseIdFromIntent(intent, "playlistId", "playlist").toInt()
|
||||||
|
if (id >= 0) {
|
||||||
|
val position = intent.getIntExtra("position", 0)
|
||||||
|
val songs: List<Song> =
|
||||||
|
ArrayList(getPlaylistSongList(this, id))
|
||||||
|
openQueue(songs, position, true)
|
||||||
|
handled = true
|
||||||
|
}
|
||||||
|
} else if (MediaStore.Audio.Albums.CONTENT_TYPE == mimeType) {
|
||||||
|
val id = parseIdFromIntent(intent, "albumId", "album").toInt()
|
||||||
|
if (id >= 0) {
|
||||||
|
val position = intent.getIntExtra("position", 0)
|
||||||
|
openQueue(getAlbum(this, id).songs!!, position, true)
|
||||||
|
handled = true
|
||||||
|
}
|
||||||
|
} else if (MediaStore.Audio.Artists.CONTENT_TYPE == mimeType) {
|
||||||
|
val id = parseIdFromIntent(intent, "artistId", "artist").toInt()
|
||||||
|
if (id >= 0) {
|
||||||
|
val position = intent.getIntExtra("position", 0)
|
||||||
|
openQueue(getArtist(this, id).songs, position, true)
|
||||||
|
handled = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (handled) {
|
||||||
|
setIntent(Intent())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun parseIdFromIntent(
|
||||||
|
intent: Intent, longKey: String,
|
||||||
|
stringKey: String
|
||||||
|
): Long {
|
||||||
|
var id = intent.getLongExtra(longKey, -1)
|
||||||
|
if (id < 0) {
|
||||||
|
val idString = intent.getStringExtra(stringKey)
|
||||||
|
if (idString != null) {
|
||||||
|
try {
|
||||||
|
id = idString.toLong()
|
||||||
|
} catch (e: NumberFormatException) {
|
||||||
|
Log.e(MainActivity.TAG, e.message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return id
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun handleBackPress(): Boolean {
|
||||||
|
if (cab.isActive) {
|
||||||
|
cab.finish()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return super.handleBackPress() || currentFragment.handleBackPress()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun openCab(menuRes: Int, callback: MaterialCab.Callback): MaterialCab {
|
||||||
|
if (cab != null && cab.isActive) {
|
||||||
|
cab.finish()
|
||||||
|
}
|
||||||
|
cab = MaterialCab(this, R.id.cab_stub)
|
||||||
|
.setMenu(menuRes)
|
||||||
|
.setCloseDrawableRes(R.drawable.ic_close_white_24dp)
|
||||||
|
.setBackgroundColor(
|
||||||
|
RetroColorUtil.shiftBackgroundColorForLightText(
|
||||||
|
resolveColor(this, R.attr.colorSurface)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.start(callback)
|
||||||
|
return cab
|
||||||
|
}
|
||||||
|
}
|
|
@ -21,7 +21,7 @@ import code.name.monkey.retromusic.extensions.applyToolbar
|
||||||
import code.name.monkey.retromusic.glide.ProfileBannerGlideRequest
|
import code.name.monkey.retromusic.glide.ProfileBannerGlideRequest
|
||||||
import code.name.monkey.retromusic.glide.UserProfileGlideRequest
|
import code.name.monkey.retromusic.glide.UserProfileGlideRequest
|
||||||
import code.name.monkey.retromusic.util.ImageUtil
|
import code.name.monkey.retromusic.util.ImageUtil
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||||
import com.bumptech.glide.request.RequestListener
|
import com.bumptech.glide.request.RequestListener
|
||||||
|
@ -50,7 +50,7 @@ class UserInfoActivity : AbsBaseActivity() {
|
||||||
applyToolbar(toolbar)
|
applyToolbar(toolbar)
|
||||||
|
|
||||||
MaterialUtil.setTint(nameContainer, false)
|
MaterialUtil.setTint(nameContainer, false)
|
||||||
name.setText(PreferenceUtil.getInstance(this).userName)
|
name.setText(PreferenceUtilKT.userName)
|
||||||
|
|
||||||
userImage.setOnClickListener {
|
userImage.setOnClickListener {
|
||||||
pickNewPhoto()
|
pickNewPhoto()
|
||||||
|
@ -66,7 +66,7 @@ class UserInfoActivity : AbsBaseActivity() {
|
||||||
Toast.makeText(this, "Umm name is empty", Toast.LENGTH_SHORT).show()
|
Toast.makeText(this, "Umm name is empty", Toast.LENGTH_SHORT).show()
|
||||||
return@setOnClickListener
|
return@setOnClickListener
|
||||||
}
|
}
|
||||||
PreferenceUtil.getInstance(this).userName = nameString
|
PreferenceUtilKT.userName = nameString
|
||||||
setResult(Activity.RESULT_OK)
|
setResult(Activity.RESULT_OK)
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ import code.name.monkey.appthemehelper.util.MaterialValueHelper;
|
||||||
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper;
|
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper;
|
||||||
import code.name.monkey.retromusic.R;
|
import code.name.monkey.retromusic.R;
|
||||||
import code.name.monkey.retromusic.activities.base.AbsBaseActivity;
|
import code.name.monkey.retromusic.activities.base.AbsBaseActivity;
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil;
|
import code.name.monkey.retromusic.util.PreferenceUtilKT;
|
||||||
|
|
||||||
public class WhatsNewActivity extends AbsBaseActivity {
|
public class WhatsNewActivity extends AbsBaseActivity {
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ public class WhatsNewActivity extends AbsBaseActivity {
|
||||||
try {
|
try {
|
||||||
PackageInfo pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
|
PackageInfo pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
|
||||||
int currentVersion = pInfo.versionCode;
|
int currentVersion = pInfo.versionCode;
|
||||||
PreferenceUtil.getInstance(context).setLastChangeLogVersion(currentVersion);
|
PreferenceUtilKT.INSTANCE.setLastVersion(currentVersion);
|
||||||
} catch (PackageManager.NameNotFoundException e) {
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ import code.name.monkey.retromusic.fragments.player.tiny.TinyPlayerFragment
|
||||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||||
import code.name.monkey.retromusic.model.CategoryInfo
|
import code.name.monkey.retromusic.model.CategoryInfo
|
||||||
import code.name.monkey.retromusic.util.DensityUtil
|
import code.name.monkey.retromusic.util.DensityUtil
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||||
import code.name.monkey.retromusic.views.BottomNavigationBarTinted
|
import code.name.monkey.retromusic.views.BottomNavigationBarTinted
|
||||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||||
import com.google.android.material.shape.MaterialShapeDrawable
|
import com.google.android.material.shape.MaterialShapeDrawable
|
||||||
|
@ -117,7 +117,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(),
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
if (cps != PreferenceUtil.getInstance(this).nowPlayingScreen) {
|
if (cps != PreferenceUtilKT.nowPlayingScreen) {
|
||||||
postRecreate()
|
postRecreate()
|
||||||
}
|
}
|
||||||
behavior.addBottomSheetCallback(bottomSheetCallbackList)
|
behavior.addBottomSheetCallback(bottomSheetCallbackList)
|
||||||
|
@ -239,8 +239,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(),
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun chooseFragmentForTheme() {
|
private fun chooseFragmentForTheme() {
|
||||||
cps = PreferenceUtil.getInstance(this).nowPlayingScreen
|
cps = PreferenceUtilKT.nowPlayingScreen
|
||||||
|
|
||||||
val fragment: Fragment = when (cps) {
|
val fragment: Fragment = when (cps) {
|
||||||
Blur -> BlurPlayerFragment()
|
Blur -> BlurPlayerFragment()
|
||||||
Adaptive -> AdaptiveFragment()
|
Adaptive -> AdaptiveFragment()
|
||||||
|
@ -311,7 +310,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(),
|
||||||
|
|
||||||
val isColorLight = ColorUtil.isColorLight(paletteColor)
|
val isColorLight = ColorUtil.isColorLight(paletteColor)
|
||||||
|
|
||||||
if (PreferenceUtil.getInstance(this).adaptiveColor && (cps == Normal || cps == Flat)) {
|
if (PreferenceUtilKT.isAdaptiveColor && (cps == Normal || cps == Flat)) {
|
||||||
super.setLightNavigationBar(true)
|
super.setLightNavigationBar(true)
|
||||||
super.setLightStatusbar(isColorLight)
|
super.setLightStatusbar(isColorLight)
|
||||||
} else if (cps == Card || cps == Blur || cps == BlurCard) {
|
} else if (cps == Card || cps == Blur || cps == BlurCard) {
|
||||||
|
@ -375,8 +374,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(),
|
||||||
|
|
||||||
fun updateTabs() {
|
fun updateTabs() {
|
||||||
bottomNavigationView.menu.clear()
|
bottomNavigationView.menu.clear()
|
||||||
val currentTabs: List<CategoryInfo> =
|
val currentTabs: List<CategoryInfo> = PreferenceUtilKT.libraryCategory
|
||||||
PreferenceUtil.getInstance(this).libraryCategoryInfos
|
|
||||||
for (tab in currentTabs) {
|
for (tab in currentTabs) {
|
||||||
if (tab.visible) {
|
if (tab.visible) {
|
||||||
val menu = tab.category
|
val menu = tab.category
|
||||||
|
|
|
@ -2,7 +2,6 @@ package code.name.monkey.retromusic.activities.base
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.graphics.drawable.Drawable
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.view.KeyEvent
|
import android.view.KeyEvent
|
||||||
|
@ -10,17 +9,15 @@ import android.view.View
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
import androidx.annotation.ColorInt
|
import androidx.annotation.ColorInt
|
||||||
import androidx.appcompat.app.AppCompatDelegate.setDefaultNightMode
|
import androidx.appcompat.app.AppCompatDelegate.setDefaultNightMode
|
||||||
import androidx.core.content.ContextCompat
|
|
||||||
import code.name.monkey.appthemehelper.ATH
|
import code.name.monkey.appthemehelper.ATH
|
||||||
import code.name.monkey.appthemehelper.ThemeStore
|
import code.name.monkey.appthemehelper.ThemeStore
|
||||||
import code.name.monkey.appthemehelper.common.ATHToolbarActivity
|
import code.name.monkey.appthemehelper.common.ATHToolbarActivity
|
||||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||||
import code.name.monkey.appthemehelper.util.TintHelper
|
|
||||||
import code.name.monkey.appthemehelper.util.VersionUtils
|
import code.name.monkey.appthemehelper.util.VersionUtils
|
||||||
import code.name.monkey.retromusic.LanguageContextWrapper
|
import code.name.monkey.retromusic.LanguageContextWrapper
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||||
import code.name.monkey.retromusic.util.RetroUtil
|
import code.name.monkey.retromusic.util.RetroUtil
|
||||||
import code.name.monkey.retromusic.util.theme.ThemeManager
|
import code.name.monkey.retromusic.util.theme.ThemeManager
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
@ -45,7 +42,7 @@ abstract class AbsThemeActivity : ATHToolbarActivity(), Runnable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun toggleScreenOn() {
|
private fun toggleScreenOn() {
|
||||||
if (PreferenceUtil.getInstance(this).isScreenOnEnabled) {
|
if (PreferenceUtilKT.isScreenOnEnabled) {
|
||||||
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||||
} else {
|
} else {
|
||||||
window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||||
|
@ -64,7 +61,7 @@ abstract class AbsThemeActivity : ATHToolbarActivity(), Runnable {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun hideStatusBar() {
|
fun hideStatusBar() {
|
||||||
hideStatusBar(PreferenceUtil.getInstance(this).fullScreenMode)
|
hideStatusBar(PreferenceUtilKT.isFullScreenMode)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun hideStatusBar(fullscreen: Boolean) {
|
private fun hideStatusBar(fullscreen: Boolean) {
|
||||||
|
@ -74,18 +71,6 @@ abstract class AbsThemeActivity : ATHToolbarActivity(), Runnable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun changeBackgroundShape() {
|
|
||||||
var background: Drawable? = if (PreferenceUtil.getInstance(this).isRoundCorners)
|
|
||||||
ContextCompat.getDrawable(this, R.drawable.round_window)
|
|
||||||
else ContextCompat.getDrawable(this, R.drawable.square_window)
|
|
||||||
background =
|
|
||||||
TintHelper.createTintedDrawable(
|
|
||||||
background,
|
|
||||||
ATHUtil.resolveColor(this, android.R.attr.windowBackground)
|
|
||||||
)
|
|
||||||
window.setBackgroundDrawable(background)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setDrawUnderStatusBar() {
|
fun setDrawUnderStatusBar() {
|
||||||
RetroUtil.setAllowDrawUnderStatusBar(window)
|
RetroUtil.setAllowDrawUnderStatusBar(window)
|
||||||
}
|
}
|
||||||
|
@ -179,7 +164,7 @@ abstract class AbsThemeActivity : ATHToolbarActivity(), Runnable {
|
||||||
val flags =
|
val flags =
|
||||||
(View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_FULLSCREEN or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY)
|
(View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_FULLSCREEN or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY)
|
||||||
|
|
||||||
if (PreferenceUtil.getInstance(this).fullScreenMode) {
|
if (PreferenceUtilKT.isFullScreenMode) {
|
||||||
window.decorView.systemUiVisibility = flags
|
window.decorView.systemUiVisibility = flags
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -212,7 +197,7 @@ abstract class AbsThemeActivity : ATHToolbarActivity(), Runnable {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun attachBaseContext(newBase: Context?) {
|
override fun attachBaseContext(newBase: Context?) {
|
||||||
val code = PreferenceUtil.getInstance(newBase).languageCode
|
val code = PreferenceUtilKT.languageCode
|
||||||
if (code != "auto") {
|
if (code != "auto") {
|
||||||
super.attachBaseContext(LanguageContextWrapper.wrap(newBase, Locale(code)))
|
super.attachBaseContext(LanguageContextWrapper.wrap(newBase, Locale(code)))
|
||||||
} else super.attachBaseContext(newBase)
|
} else super.attachBaseContext(newBase)
|
||||||
|
|
|
@ -11,7 +11,7 @@ import androidx.annotation.IntRange;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil;
|
import code.name.monkey.retromusic.util.PreferenceUtilKT;
|
||||||
|
|
||||||
public class DeviceInfo {
|
public class DeviceInfo {
|
||||||
|
|
||||||
|
@ -75,10 +75,10 @@ public class DeviceInfo {
|
||||||
versionCode = -1;
|
versionCode = -1;
|
||||||
versionName = null;
|
versionName = null;
|
||||||
}
|
}
|
||||||
baseTheme = PreferenceUtil.getInstance(context).getBaseTheme();
|
baseTheme = PreferenceUtilKT.INSTANCE.getBaseTheme();
|
||||||
nowPlayingTheme = context.getString(PreferenceUtil.getInstance(context).getNowPlayingScreen().getTitleRes());
|
nowPlayingTheme = context.getString(PreferenceUtilKT.INSTANCE.getNowPlayingScreen().getTitleRes());
|
||||||
isAdaptive = PreferenceUtil.getInstance(context).getAdaptiveColor();
|
isAdaptive = PreferenceUtilKT.INSTANCE.isAdaptiveColor();
|
||||||
selectedLang = PreferenceUtil.getInstance(context).getLanguageCode();
|
selectedLang = PreferenceUtilKT.INSTANCE.getLanguageCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toMarkdown() {
|
public String toMarkdown() {
|
||||||
|
|
|
@ -22,7 +22,7 @@ import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.R.drawable
|
import code.name.monkey.retromusic.R.drawable
|
||||||
import code.name.monkey.retromusic.activities.base.AbsBaseActivity
|
import code.name.monkey.retromusic.activities.base.AbsBaseActivity
|
||||||
import code.name.monkey.retromusic.activities.saf.SAFGuideActivity
|
import code.name.monkey.retromusic.activities.saf.SAFGuideActivity
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
|
||||||
import code.name.monkey.retromusic.util.RetroUtil
|
import code.name.monkey.retromusic.util.RetroUtil
|
||||||
import code.name.monkey.retromusic.util.SAFUtil
|
import code.name.monkey.retromusic.util.SAFUtil
|
||||||
import com.afollestad.materialdialogs.LayoutMode
|
import com.afollestad.materialdialogs.LayoutMode
|
||||||
|
@ -53,7 +53,6 @@ abstract class AbsTagEditorActivity : AbsBaseActivity() {
|
||||||
|
|
||||||
protected val show: MaterialDialog
|
protected val show: MaterialDialog
|
||||||
get() = MaterialDialog(this).show {
|
get() = MaterialDialog(this).show {
|
||||||
cornerRadius(PreferenceUtil.getInstance(this@AbsTagEditorActivity).dialogCorner)
|
|
||||||
title(R.string.update_image)
|
title(R.string.update_image)
|
||||||
listItems(items = items) { _, position, _ ->
|
listItems(items = items) { _, position, _ ->
|
||||||
when (position) {
|
when (position) {
|
||||||
|
|
|
@ -20,7 +20,8 @@ import code.name.monkey.retromusic.model.Album
|
||||||
import code.name.monkey.retromusic.model.Artist
|
import code.name.monkey.retromusic.model.Artist
|
||||||
import code.name.monkey.retromusic.model.Home
|
import code.name.monkey.retromusic.model.Home
|
||||||
import code.name.monkey.retromusic.model.Playlist
|
import code.name.monkey.retromusic.model.Playlist
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
|
||||||
|
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||||
|
|
||||||
class HomeAdapter(
|
class HomeAdapter(
|
||||||
private val activity: AppCompatActivity,
|
private val activity: AppCompatActivity,
|
||||||
|
@ -117,7 +118,7 @@ class HomeAdapter(
|
||||||
val artistAdapter = ArtistAdapter(
|
val artistAdapter = ArtistAdapter(
|
||||||
activity,
|
activity,
|
||||||
list,
|
list,
|
||||||
PreferenceUtil.getInstance(activity).getHomeGridStyle(activity),
|
PreferenceUtilKT.homeGridStyle,
|
||||||
null
|
null
|
||||||
)
|
)
|
||||||
recyclerView.apply {
|
recyclerView.apply {
|
||||||
|
|
|
@ -22,7 +22,7 @@ import code.name.monkey.retromusic.model.Album
|
||||||
import code.name.monkey.retromusic.model.Song
|
import code.name.monkey.retromusic.model.Song
|
||||||
import code.name.monkey.retromusic.util.MusicUtil
|
import code.name.monkey.retromusic.util.MusicUtil
|
||||||
import code.name.monkey.retromusic.util.NavigationUtil
|
import code.name.monkey.retromusic.util.NavigationUtil
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||||
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import me.zhanghai.android.fastscroll.PopupTextProvider
|
import me.zhanghai.android.fastscroll.PopupTextProvider
|
||||||
|
@ -153,7 +153,7 @@ open class AlbumAdapter(
|
||||||
|
|
||||||
private fun getSectionName(position: Int): String {
|
private fun getSectionName(position: Int): String {
|
||||||
var sectionName: String? = null
|
var sectionName: String? = null
|
||||||
when (PreferenceUtil.getInstance(activity).albumSortOrder) {
|
when (PreferenceUtilKT.albumSortOrder) {
|
||||||
SortOrder.AlbumSortOrder.ALBUM_A_Z, SortOrder.AlbumSortOrder.ALBUM_Z_A -> sectionName =
|
SortOrder.AlbumSortOrder.ALBUM_A_Z, SortOrder.AlbumSortOrder.ALBUM_Z_A -> sectionName =
|
||||||
dataSet[position].title
|
dataSet[position].title
|
||||||
SortOrder.AlbumSortOrder.ALBUM_ARTIST -> sectionName = dataSet[position].artistName
|
SortOrder.AlbumSortOrder.ALBUM_ARTIST -> sectionName = dataSet[position].artistName
|
||||||
|
|
|
@ -15,7 +15,8 @@ import code.name.monkey.retromusic.glide.SongGlideRequest
|
||||||
import code.name.monkey.retromusic.misc.CustomFragmentStatePagerAdapter
|
import code.name.monkey.retromusic.misc.CustomFragmentStatePagerAdapter
|
||||||
import code.name.monkey.retromusic.model.Song
|
import code.name.monkey.retromusic.model.Song
|
||||||
import code.name.monkey.retromusic.util.NavigationUtil
|
import code.name.monkey.retromusic.util.NavigationUtil
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
|
||||||
|
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||||
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
|
|
||||||
|
@ -90,7 +91,7 @@ class AlbumCoverPagerAdapter(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getLayoutWithPlayerTheme(): Int {
|
private fun getLayoutWithPlayerTheme(): Int {
|
||||||
return when (PreferenceUtil.getInstance(requireContext()).nowPlayingScreen) {
|
return when (PreferenceUtilKT.nowPlayingScreen) {
|
||||||
Card,
|
Card,
|
||||||
Fit,
|
Fit,
|
||||||
Tiny,
|
Tiny,
|
||||||
|
@ -99,11 +100,10 @@ class AlbumCoverPagerAdapter(
|
||||||
Gradient,
|
Gradient,
|
||||||
Full -> R.layout.fragment_album_full_cover
|
Full -> R.layout.fragment_album_full_cover
|
||||||
else -> {
|
else -> {
|
||||||
if (PreferenceUtil.getInstance(requireContext()).carouselEffect()
|
if (PreferenceUtilKT.isCarouselEffect) {
|
||||||
) {
|
|
||||||
R.layout.fragment_album_carousel_cover
|
R.layout.fragment_album_carousel_cover
|
||||||
} else {
|
} else {
|
||||||
when (PreferenceUtil.getInstance(requireContext()).albumCoverStyle) {
|
when (PreferenceUtilKT.albumCoverStyle) {
|
||||||
AlbumCoverStyle.NORMAL -> R.layout.fragment_album_cover
|
AlbumCoverStyle.NORMAL -> R.layout.fragment_album_cover
|
||||||
AlbumCoverStyle.FLAT -> R.layout.fragment_album_flat_cover
|
AlbumCoverStyle.FLAT -> R.layout.fragment_album_flat_cover
|
||||||
AlbumCoverStyle.CIRCLE -> R.layout.fragment_album_circle_cover
|
AlbumCoverStyle.CIRCLE -> R.layout.fragment_album_circle_cover
|
||||||
|
@ -111,7 +111,6 @@ class AlbumCoverPagerAdapter(
|
||||||
AlbumCoverStyle.MATERIAL -> R.layout.fragment_album_material_cover
|
AlbumCoverStyle.MATERIAL -> R.layout.fragment_album_material_cover
|
||||||
AlbumCoverStyle.FULL -> R.layout.fragment_album_full_cover
|
AlbumCoverStyle.FULL -> R.layout.fragment_album_full_cover
|
||||||
AlbumCoverStyle.FULL_CARD -> R.layout.fragment_album_full_card_cover
|
AlbumCoverStyle.FULL_CARD -> R.layout.fragment_album_full_card_cover
|
||||||
else -> R.layout.fragment_album_cover
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,8 @@ import code.name.monkey.retromusic.interfaces.CabHolder
|
||||||
import code.name.monkey.retromusic.model.Song
|
import code.name.monkey.retromusic.model.Song
|
||||||
import code.name.monkey.retromusic.util.MusicUtil
|
import code.name.monkey.retromusic.util.MusicUtil
|
||||||
import code.name.monkey.retromusic.util.NavigationUtil
|
import code.name.monkey.retromusic.util.NavigationUtil
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||||
|
|
||||||
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
||||||
import com.afollestad.materialcab.MaterialCab
|
import com.afollestad.materialcab.MaterialCab
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
|
@ -144,7 +145,7 @@ open class SongAdapter(
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getPopupText(position: Int): String {
|
override fun getPopupText(position: Int): String {
|
||||||
val sectionName: String? = when (PreferenceUtil.getInstance(activity).songSortOrder) {
|
val sectionName: String? = when (PreferenceUtilKT.songSortOrder) {
|
||||||
SortOrder.SongSortOrder.SONG_A_Z, SortOrder.SongSortOrder.SONG_Z_A -> dataSet[position].title
|
SortOrder.SongSortOrder.SONG_A_Z, SortOrder.SongSortOrder.SONG_Z_A -> dataSet[position].title
|
||||||
SortOrder.SongSortOrder.SONG_ALBUM -> dataSet[position].albumName
|
SortOrder.SongSortOrder.SONG_ALBUM -> dataSet[position].albumName
|
||||||
SortOrder.SongSortOrder.SONG_ARTIST -> dataSet[position].artistName
|
SortOrder.SongSortOrder.SONG_ARTIST -> dataSet[position].artistName
|
||||||
|
|
|
@ -25,13 +25,13 @@ import android.util.TypedValue
|
||||||
import androidx.annotation.RequiresApi
|
import androidx.annotation.RequiresApi
|
||||||
import code.name.monkey.appthemehelper.ThemeStore
|
import code.name.monkey.appthemehelper.ThemeStore
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||||
import code.name.monkey.retromusic.util.RetroUtil
|
import code.name.monkey.retromusic.util.RetroUtil
|
||||||
|
|
||||||
@RequiresApi(Build.VERSION_CODES.N_MR1)
|
@RequiresApi(Build.VERSION_CODES.N_MR1)
|
||||||
object AppShortcutIconGenerator {
|
object AppShortcutIconGenerator {
|
||||||
fun generateThemedIcon(context: Context, iconId: Int): Icon {
|
fun generateThemedIcon(context: Context, iconId: Int): Icon {
|
||||||
return if (PreferenceUtil.getInstance(context).coloredAppShortcuts()) {
|
return if (PreferenceUtilKT.isColoredAppShortcuts) {
|
||||||
generateUserThemedIcon(context, iconId)
|
generateUserThemedIcon(context, iconId)
|
||||||
} else {
|
} else {
|
||||||
generateDefaultThemedIcon(context, iconId)
|
generateDefaultThemedIcon(context, iconId)
|
||||||
|
|
|
@ -21,7 +21,7 @@ import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.loaders.PlaylistLoader
|
import code.name.monkey.retromusic.loaders.PlaylistLoader
|
||||||
import code.name.monkey.retromusic.model.Song
|
import code.name.monkey.retromusic.model.Song
|
||||||
import code.name.monkey.retromusic.util.PlaylistsUtil
|
import code.name.monkey.retromusic.util.PlaylistsUtil
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
|
||||||
import com.afollestad.materialdialogs.LayoutMode
|
import com.afollestad.materialdialogs.LayoutMode
|
||||||
import com.afollestad.materialdialogs.MaterialDialog
|
import com.afollestad.materialdialogs.MaterialDialog
|
||||||
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
||||||
|
@ -41,7 +41,7 @@ class AddToPlaylistDialog : DialogFragment() {
|
||||||
|
|
||||||
return MaterialDialog(requireContext()).show {
|
return MaterialDialog(requireContext()).show {
|
||||||
title(R.string.add_playlist_title)
|
title(R.string.add_playlist_title)
|
||||||
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
|
||||||
listItems(items = playlistNames) { dialog, index, _ ->
|
listItems(items = playlistNames) { dialog, index, _ ->
|
||||||
val songs =
|
val songs =
|
||||||
requireArguments().getParcelableArrayList<Song>("songs") ?: return@listItems
|
requireArguments().getParcelableArrayList<Song>("songs") ?: return@listItems
|
||||||
|
|
|
@ -23,7 +23,7 @@ import android.os.Environment
|
||||||
import androidx.core.app.ActivityCompat
|
import androidx.core.app.ActivityCompat
|
||||||
import androidx.fragment.app.DialogFragment
|
import androidx.fragment.app.DialogFragment
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
|
||||||
import com.afollestad.materialdialogs.LayoutMode
|
import com.afollestad.materialdialogs.LayoutMode
|
||||||
import com.afollestad.materialdialogs.MaterialDialog
|
import com.afollestad.materialdialogs.MaterialDialog
|
||||||
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
||||||
|
@ -88,7 +88,7 @@ class BlacklistFolderChooserDialog : DialogFragment() {
|
||||||
) {
|
) {
|
||||||
return MaterialDialog(requireActivity()).show {
|
return MaterialDialog(requireActivity()).show {
|
||||||
title(R.string.md_error_label)
|
title(R.string.md_error_label)
|
||||||
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
|
||||||
message(R.string.md_storage_perm_error)
|
message(R.string.md_storage_perm_error)
|
||||||
positiveButton(android.R.string.ok)
|
positiveButton(android.R.string.ok)
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ class BlacklistFolderChooserDialog : DialogFragment() {
|
||||||
|
|
||||||
return MaterialDialog(requireContext()).show {
|
return MaterialDialog(requireContext()).show {
|
||||||
title(text = parentFolder!!.absolutePath)
|
title(text = parentFolder!!.absolutePath)
|
||||||
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
|
||||||
listItems(items = contentsArray(), waitForPositiveButton = false) { _, index, _ ->
|
listItems(items = contentsArray(), waitForPositiveButton = false) { _, index, _ ->
|
||||||
onSelection(index)
|
onSelection(index)
|
||||||
}
|
}
|
||||||
|
@ -146,7 +146,7 @@ class BlacklistFolderChooserDialog : DialogFragment() {
|
||||||
val dialog = dialog as MaterialDialog?
|
val dialog = dialog as MaterialDialog?
|
||||||
|
|
||||||
dialog?.apply {
|
dialog?.apply {
|
||||||
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
|
||||||
setTitle(parentFolder!!.absolutePath)
|
setTitle(parentFolder!!.absolutePath)
|
||||||
listItems(items = contentsArray()) { _, index, _ ->
|
listItems(items = contentsArray()) { _, index, _ ->
|
||||||
onSelection(index)
|
onSelection(index)
|
||||||
|
|
|
@ -20,7 +20,7 @@ import androidx.core.text.HtmlCompat
|
||||||
import androidx.fragment.app.DialogFragment
|
import androidx.fragment.app.DialogFragment
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.model.smartplaylist.AbsSmartPlaylist
|
import code.name.monkey.retromusic.model.smartplaylist.AbsSmartPlaylist
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
|
||||||
import com.afollestad.materialdialogs.LayoutMode
|
import com.afollestad.materialdialogs.LayoutMode
|
||||||
import com.afollestad.materialdialogs.MaterialDialog
|
import com.afollestad.materialdialogs.MaterialDialog
|
||||||
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
||||||
|
@ -40,7 +40,7 @@ class ClearSmartPlaylistDialog : DialogFragment() {
|
||||||
|
|
||||||
return MaterialDialog(requireContext()).show {
|
return MaterialDialog(requireContext()).show {
|
||||||
title(title)
|
title(title)
|
||||||
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
|
||||||
message(text = content)
|
message(text = content)
|
||||||
positiveButton(R.string.clear_action) {
|
positiveButton(R.string.clear_action) {
|
||||||
if (activity == null) {
|
if (activity == null) {
|
||||||
|
|
|
@ -26,7 +26,7 @@ import code.name.monkey.retromusic.R.string
|
||||||
import code.name.monkey.retromusic.extensions.appHandleColor
|
import code.name.monkey.retromusic.extensions.appHandleColor
|
||||||
import code.name.monkey.retromusic.model.Song
|
import code.name.monkey.retromusic.model.Song
|
||||||
import code.name.monkey.retromusic.util.PlaylistsUtil
|
import code.name.monkey.retromusic.util.PlaylistsUtil
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
|
||||||
import com.afollestad.materialdialogs.LayoutMode
|
import com.afollestad.materialdialogs.LayoutMode
|
||||||
import com.afollestad.materialdialogs.MaterialDialog
|
import com.afollestad.materialdialogs.MaterialDialog
|
||||||
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
||||||
|
@ -45,7 +45,7 @@ class CreatePlaylistDialog : DialogFragment() {
|
||||||
): Dialog {
|
): Dialog {
|
||||||
val materialDialog = MaterialDialog(requireContext())
|
val materialDialog = MaterialDialog(requireContext())
|
||||||
.show {
|
.show {
|
||||||
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
|
||||||
title(string.new_playlist_title)
|
title(string.new_playlist_title)
|
||||||
customView(layout.dialog_playlist)
|
customView(layout.dialog_playlist)
|
||||||
negativeButton(android.R.string.cancel)
|
negativeButton(android.R.string.cancel)
|
||||||
|
|
|
@ -22,7 +22,7 @@ import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.R.string
|
import code.name.monkey.retromusic.R.string
|
||||||
import code.name.monkey.retromusic.model.Playlist
|
import code.name.monkey.retromusic.model.Playlist
|
||||||
import code.name.monkey.retromusic.util.PlaylistsUtil
|
import code.name.monkey.retromusic.util.PlaylistsUtil
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
|
||||||
import com.afollestad.materialdialogs.LayoutMode
|
import com.afollestad.materialdialogs.LayoutMode
|
||||||
import com.afollestad.materialdialogs.MaterialDialog
|
import com.afollestad.materialdialogs.MaterialDialog
|
||||||
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
||||||
|
@ -51,7 +51,7 @@ class DeletePlaylistDialog : DialogFragment() {
|
||||||
|
|
||||||
return MaterialDialog(requireContext())
|
return MaterialDialog(requireContext())
|
||||||
.show {
|
.show {
|
||||||
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
|
||||||
title(title)
|
title(title)
|
||||||
message(text = content)
|
message(text = content)
|
||||||
negativeButton(android.R.string.cancel)
|
negativeButton(android.R.string.cancel)
|
||||||
|
|
|
@ -25,7 +25,7 @@ import code.name.monkey.retromusic.activities.saf.SAFGuideActivity
|
||||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||||
import code.name.monkey.retromusic.model.Song
|
import code.name.monkey.retromusic.model.Song
|
||||||
import code.name.monkey.retromusic.util.MusicUtil
|
import code.name.monkey.retromusic.util.MusicUtil
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
|
||||||
import code.name.monkey.retromusic.util.SAFUtil
|
import code.name.monkey.retromusic.util.SAFUtil
|
||||||
import com.afollestad.materialdialogs.LayoutMode
|
import com.afollestad.materialdialogs.LayoutMode
|
||||||
import com.afollestad.materialdialogs.MaterialDialog
|
import com.afollestad.materialdialogs.MaterialDialog
|
||||||
|
@ -65,7 +65,7 @@ class DeleteSongsDialog : DialogFragment() {
|
||||||
negativeButton(android.R.string.cancel) {
|
negativeButton(android.R.string.cancel) {
|
||||||
dismiss()
|
dismiss()
|
||||||
}
|
}
|
||||||
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
|
||||||
noAutoDismiss()
|
noAutoDismiss()
|
||||||
positiveButton(R.string.action_delete) {
|
positiveButton(R.string.action_delete) {
|
||||||
if (songs != null) {
|
if (songs != null) {
|
||||||
|
|
|
@ -22,7 +22,7 @@ import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.R.string
|
import code.name.monkey.retromusic.R.string
|
||||||
import code.name.monkey.retromusic.model.PlaylistSong
|
import code.name.monkey.retromusic.model.PlaylistSong
|
||||||
import code.name.monkey.retromusic.util.PlaylistsUtil
|
import code.name.monkey.retromusic.util.PlaylistsUtil
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
|
||||||
import com.afollestad.materialdialogs.LayoutMode
|
import com.afollestad.materialdialogs.LayoutMode
|
||||||
import com.afollestad.materialdialogs.MaterialDialog
|
import com.afollestad.materialdialogs.MaterialDialog
|
||||||
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
||||||
|
@ -67,7 +67,7 @@ class RemoveFromPlaylistDialog : DialogFragment() {
|
||||||
songs as MutableList<PlaylistSong>
|
songs as MutableList<PlaylistSong>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ import code.name.monkey.retromusic.R.layout
|
||||||
import code.name.monkey.retromusic.R.string
|
import code.name.monkey.retromusic.R.string
|
||||||
import code.name.monkey.retromusic.extensions.appHandleColor
|
import code.name.monkey.retromusic.extensions.appHandleColor
|
||||||
import code.name.monkey.retromusic.util.PlaylistsUtil
|
import code.name.monkey.retromusic.util.PlaylistsUtil
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
|
||||||
import com.afollestad.materialdialogs.LayoutMode
|
import com.afollestad.materialdialogs.LayoutMode
|
||||||
import com.afollestad.materialdialogs.MaterialDialog
|
import com.afollestad.materialdialogs.MaterialDialog
|
||||||
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
||||||
|
@ -41,7 +41,7 @@ class RenamePlaylistDialog : DialogFragment() {
|
||||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||||
val materialDialog = MaterialDialog(requireContext())
|
val materialDialog = MaterialDialog(requireContext())
|
||||||
.show {
|
.show {
|
||||||
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
|
||||||
title(string.rename_playlist_title)
|
title(string.rename_playlist_title)
|
||||||
customView(layout.dialog_playlist)
|
customView(layout.dialog_playlist)
|
||||||
negativeButton(android.R.string.cancel)
|
negativeButton(android.R.string.cancel)
|
||||||
|
|
|
@ -35,13 +35,12 @@ import code.name.monkey.retromusic.service.MusicService
|
||||||
import code.name.monkey.retromusic.service.MusicService.ACTION_PENDING_QUIT
|
import code.name.monkey.retromusic.service.MusicService.ACTION_PENDING_QUIT
|
||||||
import code.name.monkey.retromusic.service.MusicService.ACTION_QUIT
|
import code.name.monkey.retromusic.service.MusicService.ACTION_QUIT
|
||||||
import code.name.monkey.retromusic.util.MusicUtil
|
import code.name.monkey.retromusic.util.MusicUtil
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
|
||||||
|
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||||
import code.name.monkey.retromusic.util.ViewUtil
|
import code.name.monkey.retromusic.util.ViewUtil
|
||||||
import com.afollestad.materialdialogs.LayoutMode
|
|
||||||
import com.afollestad.materialdialogs.MaterialDialog
|
import com.afollestad.materialdialogs.MaterialDialog
|
||||||
import com.afollestad.materialdialogs.WhichButton
|
import com.afollestad.materialdialogs.WhichButton
|
||||||
import com.afollestad.materialdialogs.actions.getActionButton
|
import com.afollestad.materialdialogs.actions.getActionButton
|
||||||
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
|
||||||
import com.afollestad.materialdialogs.callbacks.onShow
|
import com.afollestad.materialdialogs.callbacks.onShow
|
||||||
import com.afollestad.materialdialogs.customview.customView
|
import com.afollestad.materialdialogs.customview.customView
|
||||||
import com.afollestad.materialdialogs.customview.getCustomView
|
import com.afollestad.materialdialogs.customview.getCustomView
|
||||||
|
@ -60,18 +59,12 @@ class SleepTimerDialog : DialogFragment() {
|
||||||
|
|
||||||
materialDialog = MaterialDialog(requireContext())
|
materialDialog = MaterialDialog(requireContext())
|
||||||
.title(R.string.action_sleep_timer)
|
.title(R.string.action_sleep_timer)
|
||||||
.cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
|
||||||
.positiveButton(R.string.action_set) {
|
.positiveButton(R.string.action_set) {
|
||||||
PreferenceUtil.getInstance(requireContext()).sleepTimerFinishMusic =
|
PreferenceUtilKT.isSleepTimerFinishMusic = shouldFinishLastSong.isChecked
|
||||||
shouldFinishLastSong.isChecked
|
|
||||||
|
|
||||||
val minutes = seekArcProgress
|
val minutes = seekArcProgress
|
||||||
|
|
||||||
val pi = makeTimerPendingIntent(PendingIntent.FLAG_CANCEL_CURRENT)
|
val pi = makeTimerPendingIntent(PendingIntent.FLAG_CANCEL_CURRENT)
|
||||||
|
|
||||||
val nextSleepTimerElapsedTime = SystemClock.elapsedRealtime() + minutes * 60 * 1000
|
val nextSleepTimerElapsedTime = SystemClock.elapsedRealtime() + minutes * 60 * 1000
|
||||||
PreferenceUtil.getInstance(requireContext())
|
PreferenceUtilKT.nextSleepTimerElapsedRealTime = nextSleepTimerElapsedTime.toInt()
|
||||||
.setNextSleepTimerElapsedRealtime(nextSleepTimerElapsedTime)
|
|
||||||
val am = requireContext().getSystemService(Context.ALARM_SERVICE) as AlarmManager
|
val am = requireContext().getSystemService(Context.ALARM_SERVICE) as AlarmManager
|
||||||
am.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, nextSleepTimerElapsedTime, pi)
|
am.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, nextSleepTimerElapsedTime, pi)
|
||||||
|
|
||||||
|
@ -131,11 +124,11 @@ class SleepTimerDialog : DialogFragment() {
|
||||||
false
|
false
|
||||||
)
|
)
|
||||||
|
|
||||||
val finishMusic = PreferenceUtil.getInstance(requireContext()).sleepTimerFinishMusic
|
val finishMusic = PreferenceUtilKT.isSleepTimerFinishMusic
|
||||||
shouldFinishLastSong.isChecked = finishMusic
|
shouldFinishLastSong.isChecked = finishMusic
|
||||||
|
|
||||||
|
|
||||||
seekArcProgress = PreferenceUtil.getInstance(requireContext()).lastSleepTimerValue
|
seekArcProgress = PreferenceUtilKT.lastSleepTimerValue
|
||||||
updateTimeDisplayTime()
|
updateTimeDisplayTime()
|
||||||
seekBar.progress = seekArcProgress
|
seekBar.progress = seekArcProgress
|
||||||
|
|
||||||
|
@ -155,7 +148,7 @@ class SleepTimerDialog : DialogFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStopTrackingTouch(seekBar: SeekBar) {
|
override fun onStopTrackingTouch(seekBar: SeekBar) {
|
||||||
PreferenceUtil.getInstance(requireContext()).lastSleepTimerValue = seekArcProgress
|
PreferenceUtilKT.lastSleepTimerValue = seekArcProgress
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -187,10 +180,11 @@ class SleepTimerDialog : DialogFragment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private inner class TimerUpdater internal constructor() : CountDownTimer(
|
private inner class TimerUpdater internal constructor() :
|
||||||
PreferenceUtil.getInstance(requireContext()).nextSleepTimerElapsedRealTime - SystemClock.elapsedRealtime(),
|
CountDownTimer(
|
||||||
1000
|
PreferenceUtilKT.nextSleepTimerElapsedRealTime - SystemClock.elapsedRealtime(),
|
||||||
) {
|
1000
|
||||||
|
) {
|
||||||
|
|
||||||
override fun onTick(millisUntilFinished: Long) {
|
override fun onTick(millisUntilFinished: Long) {
|
||||||
materialDialog.getActionButton(WhichButton.NEGATIVE).text = String.format(
|
materialDialog.getActionButton(WhichButton.NEGATIVE).text = String.format(
|
||||||
|
|
|
@ -29,7 +29,7 @@ import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.R.string
|
import code.name.monkey.retromusic.R.string
|
||||||
import code.name.monkey.retromusic.model.Song
|
import code.name.monkey.retromusic.model.Song
|
||||||
import code.name.monkey.retromusic.util.MusicUtil
|
import code.name.monkey.retromusic.util.MusicUtil
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
|
||||||
import com.afollestad.materialdialogs.LayoutMode
|
import com.afollestad.materialdialogs.LayoutMode
|
||||||
import com.afollestad.materialdialogs.MaterialDialog
|
import com.afollestad.materialdialogs.MaterialDialog
|
||||||
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
||||||
|
@ -63,7 +63,7 @@ class SongDetailDialog : DialogFragment() {
|
||||||
)
|
)
|
||||||
positiveButton(android.R.string.ok)
|
positiveButton(android.R.string.ok)
|
||||||
title(string.action_details)
|
title(string.action_details)
|
||||||
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
|
||||||
}
|
}
|
||||||
val dialogView = materialDialog.getCustomView()
|
val dialogView = materialDialog.getCustomView()
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.activities.ShareInstagramStory
|
import code.name.monkey.retromusic.activities.ShareInstagramStory
|
||||||
import code.name.monkey.retromusic.model.Song
|
import code.name.monkey.retromusic.model.Song
|
||||||
import code.name.monkey.retromusic.util.MusicUtil
|
import code.name.monkey.retromusic.util.MusicUtil
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
|
||||||
import com.afollestad.materialdialogs.LayoutMode
|
import com.afollestad.materialdialogs.LayoutMode
|
||||||
import com.afollestad.materialdialogs.MaterialDialog
|
import com.afollestad.materialdialogs.MaterialDialog
|
||||||
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
||||||
|
@ -37,7 +37,7 @@ class SongShareDialog : DialogFragment() {
|
||||||
return MaterialDialog(requireContext())
|
return MaterialDialog(requireContext())
|
||||||
.title(R.string.what_do_you_want_to_share)
|
.title(R.string.what_do_you_want_to_share)
|
||||||
.show {
|
.show {
|
||||||
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
|
||||||
listItems(
|
listItems(
|
||||||
items = listOf(
|
items = listOf(
|
||||||
getString(code.name.monkey.retromusic.R.string.the_audio_file),
|
getString(code.name.monkey.retromusic.R.string.the_audio_file),
|
||||||
|
|
|
@ -14,8 +14,13 @@
|
||||||
|
|
||||||
package code.name.monkey.retromusic.extensions
|
package code.name.monkey.retromusic.extensions
|
||||||
|
|
||||||
|
import androidx.annotation.IdRes
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import androidx.fragment.app.FragmentActivity
|
||||||
|
import androidx.fragment.app.FragmentTransaction
|
||||||
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
||||||
|
import code.name.monkey.retromusic.R
|
||||||
import com.google.android.material.appbar.MaterialToolbar
|
import com.google.android.material.appbar.MaterialToolbar
|
||||||
|
|
||||||
fun AppCompatActivity.applyToolbar(toolbar: MaterialToolbar) {
|
fun AppCompatActivity.applyToolbar(toolbar: MaterialToolbar) {
|
||||||
|
@ -24,3 +29,37 @@ fun AppCompatActivity.applyToolbar(toolbar: MaterialToolbar) {
|
||||||
setSupportActionBar(toolbar)
|
setSupportActionBar(toolbar)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun FragmentActivity?.addFragment(
|
||||||
|
@IdRes idRes: Int = R.id.container,
|
||||||
|
fragment: Fragment,
|
||||||
|
tag: String? = null,
|
||||||
|
addToBackStack: Boolean = false
|
||||||
|
) {
|
||||||
|
val compatActivity = this as? AppCompatActivity ?: return
|
||||||
|
compatActivity.supportFragmentManager.beginTransaction()
|
||||||
|
.apply {
|
||||||
|
add(fragment, tag)
|
||||||
|
setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
|
||||||
|
if (addToBackStack) {
|
||||||
|
addToBackStack(null)
|
||||||
|
}
|
||||||
|
commitNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun AppCompatActivity.replaceFragment(
|
||||||
|
@IdRes id: Int = R.id.container,
|
||||||
|
fragment: Fragment,
|
||||||
|
tag: String? = null,
|
||||||
|
addToBackStack: Boolean = false
|
||||||
|
) {
|
||||||
|
val compatActivity = this ?: return
|
||||||
|
compatActivity.supportFragmentManager.beginTransaction()
|
||||||
|
.apply {
|
||||||
|
replace(id, fragment, tag)
|
||||||
|
if (addToBackStack) {
|
||||||
|
addToBackStack(null)
|
||||||
|
}
|
||||||
|
commit()
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
package code.name.monkey.retromusic.extensions
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.res.Configuration
|
||||||
|
import android.os.PowerManager
|
||||||
|
import androidx.annotation.IntegerRes
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||||
|
|
||||||
|
fun Fragment.getIntRes(@IntegerRes int: Int): Int {
|
||||||
|
return resources.getInteger(int)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Context.getIntRes(@IntegerRes int: Int): Int {
|
||||||
|
return resources.getInteger(int)
|
||||||
|
}
|
||||||
|
|
||||||
|
val Context.generalThemeValue
|
||||||
|
get() = PreferenceUtilKT.getGeneralThemeValue(isSystemDarkModeEnabled())
|
||||||
|
|
||||||
|
|
||||||
|
fun Context.isSystemDarkModeEnabled(): Boolean {
|
||||||
|
val isBatterySaverEnabled =
|
||||||
|
(getSystemService(Context.POWER_SERVICE) as PowerManager?)?.isPowerSaveMode ?: false
|
||||||
|
val isDarkModeEnabled =
|
||||||
|
(resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES
|
||||||
|
return isBatterySaverEnabled or isDarkModeEnabled
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package code.name.monkey.retromusic.extensions
|
||||||
|
|
||||||
|
import android.content.SharedPreferences
|
||||||
|
|
||||||
|
fun SharedPreferences.getStringOrDefault(key: String, default: String): String {
|
||||||
|
return getString(key, default) ?: default
|
||||||
|
}
|
|
@ -11,6 +11,7 @@ import android.view.*
|
||||||
import android.view.animation.DecelerateInterpolator
|
import android.view.animation.DecelerateInterpolator
|
||||||
import code.name.monkey.appthemehelper.ThemeStore
|
import code.name.monkey.appthemehelper.ThemeStore
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
|
import code.name.monkey.retromusic.extensions.show
|
||||||
import code.name.monkey.retromusic.extensions.textColorPrimary
|
import code.name.monkey.retromusic.extensions.textColorPrimary
|
||||||
import code.name.monkey.retromusic.extensions.textColorSecondary
|
import code.name.monkey.retromusic.extensions.textColorSecondary
|
||||||
import code.name.monkey.retromusic.fragments.base.AbsMusicServiceFragment
|
import code.name.monkey.retromusic.fragments.base.AbsMusicServiceFragment
|
||||||
|
@ -18,7 +19,7 @@ import code.name.monkey.retromusic.glide.SongGlideRequest
|
||||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||||
import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper
|
import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper
|
||||||
import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
|
import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||||
import code.name.monkey.retromusic.util.RetroUtil
|
import code.name.monkey.retromusic.util.RetroUtil
|
||||||
import code.name.monkey.retromusic.util.ViewUtil
|
import code.name.monkey.retromusic.util.ViewUtil
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
|
@ -56,16 +57,16 @@ open class MiniPlayerFragment : AbsMusicServiceFragment(), MusicProgressViewUpda
|
||||||
setUpMiniPlayer()
|
setUpMiniPlayer()
|
||||||
|
|
||||||
if (RetroUtil.isTablet()) {
|
if (RetroUtil.isTablet()) {
|
||||||
actionNext.visibility = View.VISIBLE
|
actionNext.show()
|
||||||
actionPrevious.visibility = View.VISIBLE
|
actionPrevious.show()
|
||||||
actionNext?.visibility = View.VISIBLE
|
actionNext?.show()
|
||||||
actionPrevious?.visibility = View.VISIBLE
|
actionPrevious?.show()
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
actionNext.visibility =
|
actionNext.visibility =
|
||||||
if (PreferenceUtil.getInstance(requireContext()).isExtraControls) View.VISIBLE else View.GONE
|
if (PreferenceUtilKT.isExtraControls) View.VISIBLE else View.GONE
|
||||||
actionPrevious.visibility =
|
actionPrevious.visibility =
|
||||||
if (PreferenceUtil.getInstance(requireContext()).isExtraControls) View.VISIBLE else View.GONE
|
if (PreferenceUtilKT.isExtraControls) View.VISIBLE else View.GONE
|
||||||
}
|
}
|
||||||
actionNext.setOnClickListener(this)
|
actionNext.setOnClickListener(this)
|
||||||
actionPrevious.setOnClickListener(this)
|
actionPrevious.setOnClickListener(this)
|
||||||
|
@ -103,7 +104,7 @@ open class MiniPlayerFragment : AbsMusicServiceFragment(), MusicProgressViewUpda
|
||||||
Glide.with(requireContext()),
|
Glide.with(requireContext()),
|
||||||
MusicPlayerRemote.currentSong
|
MusicPlayerRemote.currentSong
|
||||||
).checkIgnoreMediaStore(requireContext())
|
).checkIgnoreMediaStore(requireContext())
|
||||||
.ignoreMediaStore(PreferenceUtil.isAllowedToDownloadMetadata(requireContext()))
|
.ignoreMediaStore(PreferenceUtilKT.isAllowedToDownloadMetadata())
|
||||||
.asBitmap()
|
.asBitmap()
|
||||||
.build()
|
.build()
|
||||||
.into(it)
|
.into(it)
|
||||||
|
|
|
@ -14,7 +14,7 @@ import code.name.monkey.appthemehelper.ThemeStore
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.extensions.applyColor
|
import code.name.monkey.retromusic.extensions.applyColor
|
||||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||||
import code.name.monkey.retromusic.volume.AudioVolumeObserver
|
import code.name.monkey.retromusic.volume.AudioVolumeObserver
|
||||||
import code.name.monkey.retromusic.volume.OnAudioVolumeChangedListener
|
import code.name.monkey.retromusic.volume.OnAudioVolumeChangedListener
|
||||||
import kotlinx.android.synthetic.main.fragment_volume.*
|
import kotlinx.android.synthetic.main.fragment_volume.*
|
||||||
|
@ -113,11 +113,10 @@ class VolumeFragment : Fragment(), SeekBar.OnSeekBarChangeListener, OnAudioVolum
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setPauseWhenZeroVolume(pauseWhenZeroVolume: Boolean) {
|
private fun setPauseWhenZeroVolume(pauseWhenZeroVolume: Boolean) {
|
||||||
if (PreferenceUtil.getInstance(requireContext())
|
if (PreferenceUtilKT.isPauseOnZeroVolume)
|
||||||
.pauseOnZeroVolume()
|
if (MusicPlayerRemote.isPlaying && pauseWhenZeroVolume)
|
||||||
) if (MusicPlayerRemote.isPlaying && pauseWhenZeroVolume) {
|
MusicPlayerRemote.pauseSong()
|
||||||
MusicPlayerRemote.pauseSong()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setTintableColor(color: Int) {
|
fun setTintableColor(color: Int) {
|
||||||
|
|
|
@ -9,7 +9,7 @@ import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.adapter.album.AlbumAdapter
|
import code.name.monkey.retromusic.adapter.album.AlbumAdapter
|
||||||
import code.name.monkey.retromusic.fragments.base.AbsLibraryPagerRecyclerViewCustomGridSizeFragment
|
import code.name.monkey.retromusic.fragments.base.AbsLibraryPagerRecyclerViewCustomGridSizeFragment
|
||||||
import code.name.monkey.retromusic.interfaces.MainActivityFragmentCallbacks
|
import code.name.monkey.retromusic.interfaces.MainActivityFragmentCallbacks
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||||
|
|
||||||
class AlbumsFragment :
|
class AlbumsFragment :
|
||||||
AbsLibraryPagerRecyclerViewCustomGridSizeFragment<AlbumAdapter, GridLayoutManager>(),
|
AbsLibraryPagerRecyclerViewCustomGridSizeFragment<AlbumAdapter, GridLayoutManager>(),
|
||||||
|
@ -51,27 +51,27 @@ class AlbumsFragment :
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun loadSortOrder(): String {
|
override fun loadSortOrder(): String {
|
||||||
return PreferenceUtil.getInstance(requireContext()).albumSortOrder
|
return PreferenceUtilKT.albumSortOrder
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun saveSortOrder(sortOrder: String) {
|
override fun saveSortOrder(sortOrder: String) {
|
||||||
PreferenceUtil.getInstance(requireContext()).albumSortOrder = sortOrder
|
PreferenceUtilKT.albumSortOrder = sortOrder
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun loadGridSize(): Int {
|
override fun loadGridSize(): Int {
|
||||||
return PreferenceUtil.getInstance(requireContext()).getAlbumGridSize(requireContext())
|
return PreferenceUtilKT.albumGridSize
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun saveGridSize(gridColumns: Int) {
|
override fun saveGridSize(gridColumns: Int) {
|
||||||
PreferenceUtil.getInstance(requireContext()).setAlbumGridSize(gridColumns)
|
PreferenceUtilKT.albumGridSize = gridColumns
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun loadGridSizeLand(): Int {
|
override fun loadGridSizeLand(): Int {
|
||||||
return PreferenceUtil.getInstance(requireContext()).getAlbumGridSizeLand(requireContext())
|
return PreferenceUtilKT.albumGridSizeLand
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun saveGridSizeLand(gridColumns: Int) {
|
override fun saveGridSizeLand(gridColumns: Int) {
|
||||||
PreferenceUtil.getInstance(requireContext()).setAlbumGridSizeLand(gridColumns)
|
PreferenceUtilKT.albumGridSizeLand = gridColumns
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onMediaStoreChanged() {
|
override fun onMediaStoreChanged() {
|
||||||
|
@ -84,12 +84,11 @@ class AlbumsFragment :
|
||||||
|
|
||||||
|
|
||||||
override fun loadLayoutRes(): Int {
|
override fun loadLayoutRes(): Int {
|
||||||
println("loadLayoutRes ${PreferenceUtil.getInstance(requireContext()).albumGridStyle}")
|
return PreferenceUtilKT.albumGridStyle
|
||||||
return PreferenceUtil.getInstance(requireContext()).albumGridStyle
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun saveLayoutRes(layoutRes: Int) {
|
override fun saveLayoutRes(layoutRes: Int) {
|
||||||
PreferenceUtil.getInstance(requireContext()).albumGridStyle = layoutRes
|
PreferenceUtilKT.albumGridStyle = layoutRes
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun handleBackPress(): Boolean {
|
override fun handleBackPress(): Boolean {
|
||||||
|
|
|
@ -9,7 +9,7 @@ import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.adapter.artist.ArtistAdapter
|
import code.name.monkey.retromusic.adapter.artist.ArtistAdapter
|
||||||
import code.name.monkey.retromusic.fragments.base.AbsLibraryPagerRecyclerViewCustomGridSizeFragment
|
import code.name.monkey.retromusic.fragments.base.AbsLibraryPagerRecyclerViewCustomGridSizeFragment
|
||||||
import code.name.monkey.retromusic.interfaces.MainActivityFragmentCallbacks
|
import code.name.monkey.retromusic.interfaces.MainActivityFragmentCallbacks
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||||
|
|
||||||
class ArtistsFragment :
|
class ArtistsFragment :
|
||||||
AbsLibraryPagerRecyclerViewCustomGridSizeFragment<ArtistAdapter, GridLayoutManager>(),
|
AbsLibraryPagerRecyclerViewCustomGridSizeFragment<ArtistAdapter, GridLayoutManager>(),
|
||||||
|
@ -60,19 +60,19 @@ class ArtistsFragment :
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun loadGridSize(): Int {
|
override fun loadGridSize(): Int {
|
||||||
return PreferenceUtil.getInstance(requireContext()).getArtistGridSize(requireActivity())
|
return PreferenceUtilKT.artistGridSize
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun saveGridSize(gridColumns: Int) {
|
override fun saveGridSize(gridColumns: Int) {
|
||||||
PreferenceUtil.getInstance(requireContext()).setArtistGridSize(gridColumns)
|
PreferenceUtilKT.artistGridSize = gridColumns
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun loadGridSizeLand(): Int {
|
override fun loadGridSizeLand(): Int {
|
||||||
return PreferenceUtil.getInstance(requireContext()).getArtistGridSizeLand(requireActivity())
|
return PreferenceUtilKT.artistGridSizeLand
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun saveGridSizeLand(gridColumns: Int) {
|
override fun saveGridSizeLand(gridColumns: Int) {
|
||||||
PreferenceUtil.getInstance(requireContext()).setArtistGridSizeLand(gridColumns)
|
PreferenceUtilKT.artistGridSizeLand = gridColumns
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setGridSize(gridSize: Int) {
|
override fun setGridSize(gridSize: Int) {
|
||||||
|
@ -81,19 +81,19 @@ class ArtistsFragment :
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun loadSortOrder(): String {
|
override fun loadSortOrder(): String {
|
||||||
return PreferenceUtil.getInstance(requireContext()).artistSortOrder
|
return PreferenceUtilKT.artistSortOrder
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun saveSortOrder(sortOrder: String) {
|
override fun saveSortOrder(sortOrder: String) {
|
||||||
PreferenceUtil.getInstance(requireContext()).artistSortOrder = sortOrder
|
PreferenceUtilKT.artistSortOrder = sortOrder
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun loadLayoutRes(): Int {
|
override fun loadLayoutRes(): Int {
|
||||||
return PreferenceUtil.getInstance(requireContext()).artistGridStyle
|
return PreferenceUtilKT.artistGridStyle
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun saveLayoutRes(layoutRes: Int) {
|
override fun saveLayoutRes(layoutRes: Int) {
|
||||||
PreferenceUtil.getInstance(requireContext()).artistGridStyle = layoutRes
|
PreferenceUtilKT.artistGridStyle = layoutRes
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
|
@ -104,7 +104,7 @@ abstract class AbsLibraryPagerRecyclerViewFragment<A : RecyclerView.Adapter<*>,
|
||||||
container.paddingLeft,
|
container.paddingLeft,
|
||||||
container.paddingTop,
|
container.paddingTop,
|
||||||
container.paddingRight,
|
container.paddingRight,
|
||||||
mainActivity.totalAppBarScrollingRange + i
|
mainActivity.getTotalAppBarScrollingRange() + i
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,8 @@ import android.view.animation.DecelerateInterpolator
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.fragments.VolumeFragment
|
import code.name.monkey.retromusic.fragments.VolumeFragment
|
||||||
import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper
|
import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
|
||||||
|
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||||
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -62,7 +63,7 @@ abstract class AbsPlayerControlsFragment : AbsMusicServiceFragment(),
|
||||||
protected var volumeFragment: VolumeFragment? = null
|
protected var volumeFragment: VolumeFragment? = null
|
||||||
|
|
||||||
private fun hideVolumeIfAvailable() {
|
private fun hideVolumeIfAvailable() {
|
||||||
if (PreferenceUtil.getInstance(requireContext()).volumeToggle) {
|
if (PreferenceUtilKT.isVolumeVisibilityMode) {
|
||||||
childFragmentManager.beginTransaction().replace(R.id.volumeFragmentContainer, VolumeFragment()).commit()
|
childFragmentManager.beginTransaction().replace(R.id.volumeFragmentContainer, VolumeFragment()).commit()
|
||||||
childFragmentManager.executePendingTransactions()
|
childFragmentManager.executePendingTransactions()
|
||||||
volumeFragment = childFragmentManager.findFragmentById(R.id.volumeFragmentContainer) as VolumeFragment?
|
volumeFragment = childFragmentManager.findFragmentById(R.id.volumeFragmentContainer) as VolumeFragment?
|
||||||
|
|
|
@ -255,7 +255,7 @@ abstract class AbsPlayerFragment : AbsMusicServiceFragment(),
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
if (PreferenceUtil.getInstance(requireContext()).fullScreenMode &&
|
if (PreferenceUtilKT.isFullScreenMode &&
|
||||||
view.findViewById<View>(R.id.status_bar) != null
|
view.findViewById<View>(R.id.status_bar) != null
|
||||||
) {
|
) {
|
||||||
view.findViewById<View>(R.id.status_bar).visibility = View.GONE
|
view.findViewById<View>(R.id.status_bar).visibility = View.GONE
|
||||||
|
|
|
@ -28,7 +28,7 @@ import code.name.monkey.retromusic.interfaces.MainActivityFragmentCallbacks
|
||||||
class GenresFragment : AbsLibraryPagerRecyclerViewFragment<GenreAdapter, LinearLayoutManager>(),
|
class GenresFragment : AbsLibraryPagerRecyclerViewFragment<GenreAdapter, LinearLayoutManager>(),
|
||||||
MainActivityFragmentCallbacks {
|
MainActivityFragmentCallbacks {
|
||||||
|
|
||||||
lateinit var genreViewModel: GenreViewModel
|
private lateinit var genreViewModel: GenreViewModel
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
|
@ -34,7 +34,8 @@ import code.name.monkey.retromusic.model.smartplaylist.HistoryPlaylist
|
||||||
import code.name.monkey.retromusic.model.smartplaylist.LastAddedPlaylist
|
import code.name.monkey.retromusic.model.smartplaylist.LastAddedPlaylist
|
||||||
import code.name.monkey.retromusic.model.smartplaylist.MyTopTracksPlaylist
|
import code.name.monkey.retromusic.model.smartplaylist.MyTopTracksPlaylist
|
||||||
import code.name.monkey.retromusic.util.NavigationUtil
|
import code.name.monkey.retromusic.util.NavigationUtil
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
|
||||||
|
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import kotlinx.android.synthetic.main.abs_playlists.*
|
import kotlinx.android.synthetic.main.abs_playlists.*
|
||||||
import kotlinx.android.synthetic.main.fragment_banner_home.*
|
import kotlinx.android.synthetic.main.fragment_banner_home.*
|
||||||
|
@ -51,7 +52,7 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
|
||||||
savedInstanceState: Bundle?
|
savedInstanceState: Bundle?
|
||||||
): View? {
|
): View? {
|
||||||
return inflater.inflate(
|
return inflater.inflate(
|
||||||
if (PreferenceUtil.getInstance(requireContext()).isHomeBanner) R.layout.fragment_banner_home else R.layout.fragment_home,
|
if (PreferenceUtilKT.isHomeBanner) R.layout.fragment_banner_home else R.layout.fragment_home,
|
||||||
viewGroup,
|
viewGroup,
|
||||||
false
|
false
|
||||||
)
|
)
|
||||||
|
@ -114,7 +115,7 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
|
||||||
NavigationUtil.goToUserInfo(requireActivity(), options)
|
NavigationUtil.goToUserInfo(requireActivity(), options)
|
||||||
}
|
}
|
||||||
titleWelcome?.text =
|
titleWelcome?.text =
|
||||||
String.format("%s", PreferenceUtil.getInstance(requireContext()).userName)
|
String.format("%s", PreferenceUtilKT.userName)
|
||||||
|
|
||||||
homeAdapter = HomeAdapter(mainActivity, displayMetrics)
|
homeAdapter = HomeAdapter(mainActivity, displayMetrics)
|
||||||
recyclerView.apply {
|
recyclerView.apply {
|
||||||
|
|
|
@ -68,7 +68,7 @@ import code.name.monkey.retromusic.misc.WrappedAsyncTaskLoader;
|
||||||
import code.name.monkey.retromusic.model.Song;
|
import code.name.monkey.retromusic.model.Song;
|
||||||
import code.name.monkey.retromusic.util.DensityUtil;
|
import code.name.monkey.retromusic.util.DensityUtil;
|
||||||
import code.name.monkey.retromusic.util.FileUtil;
|
import code.name.monkey.retromusic.util.FileUtil;
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil;
|
import code.name.monkey.retromusic.util.PreferenceUtilKT;
|
||||||
import code.name.monkey.retromusic.util.RetroColorUtil;
|
import code.name.monkey.retromusic.util.RetroColorUtil;
|
||||||
import code.name.monkey.retromusic.util.ThemedFastScroller;
|
import code.name.monkey.retromusic.util.ThemedFastScroller;
|
||||||
import code.name.monkey.retromusic.views.BreadCrumbLayout;
|
import code.name.monkey.retromusic.views.BreadCrumbLayout;
|
||||||
|
@ -134,7 +134,7 @@ public class FoldersFragment extends AbsMainActivityFragment implements
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FoldersFragment newInstance(Context context) {
|
public static FoldersFragment newInstance(Context context) {
|
||||||
return newInstance(PreferenceUtil.getInstance(context).getStartDirectory());
|
return newInstance(PreferenceUtilKT.INSTANCE.getStartDirectory());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static File tryGetCanonicalFile(File file) {
|
private static File tryGetCanonicalFile(File file) {
|
||||||
|
@ -238,7 +238,7 @@ public class FoldersFragment extends AbsMainActivityFragment implements
|
||||||
getFileComparator()));
|
getFileComparator()));
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_set_as_start_directory:
|
case R.id.action_set_as_start_directory:
|
||||||
PreferenceUtil.getInstance(requireContext()).setStartDirectory(file);
|
PreferenceUtilKT.INSTANCE.setStartDirectory(file);
|
||||||
Toast.makeText(getActivity(),
|
Toast.makeText(getActivity(),
|
||||||
String.format(getString(R.string.new_start_directory), file.getPath()),
|
String.format(getString(R.string.new_start_directory), file.getPath()),
|
||||||
Toast.LENGTH_SHORT).show();
|
Toast.LENGTH_SHORT).show();
|
||||||
|
@ -341,7 +341,7 @@ public class FoldersFragment extends AbsMainActivityFragment implements
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case R.id.action_go_to_start_directory:
|
case R.id.action_go_to_start_directory:
|
||||||
setCrumb(new BreadCrumbLayout.Crumb(
|
setCrumb(new BreadCrumbLayout.Crumb(
|
||||||
tryGetCanonicalFile(PreferenceUtil.getInstance(requireContext()).getStartDirectory())), true);
|
tryGetCanonicalFile(PreferenceUtilKT.INSTANCE.getStartDirectory())), true);
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_scan:
|
case R.id.action_scan:
|
||||||
BreadCrumbLayout.Crumb crumb = getActiveCrumb();
|
BreadCrumbLayout.Crumb crumb = getActiveCrumb();
|
||||||
|
|
|
@ -13,7 +13,8 @@ import code.name.monkey.retromusic.fragments.base.AbsMusicServiceFragment
|
||||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||||
import code.name.monkey.retromusic.transform.CarousalPagerTransformer
|
import code.name.monkey.retromusic.transform.CarousalPagerTransformer
|
||||||
import code.name.monkey.retromusic.transform.ParallaxPagerTransformer
|
import code.name.monkey.retromusic.transform.ParallaxPagerTransformer
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
|
||||||
|
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||||
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
||||||
import kotlinx.android.synthetic.main.fragment_player_album_cover.*
|
import kotlinx.android.synthetic.main.fragment_player_album_cover.*
|
||||||
|
|
||||||
|
@ -45,14 +46,14 @@ class PlayerAlbumCoverFragment : AbsMusicServiceFragment(), ViewPager.OnPageChan
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
viewPager.addOnPageChangeListener(this)
|
viewPager.addOnPageChangeListener(this)
|
||||||
val nps = PreferenceUtil.getInstance(requireContext()).nowPlayingScreen
|
val nps = PreferenceUtilKT.nowPlayingScreen
|
||||||
|
|
||||||
val metrics = resources.displayMetrics
|
val metrics = resources.displayMetrics
|
||||||
val ratio = metrics.heightPixels.toFloat() / metrics.widthPixels.toFloat()
|
val ratio = metrics.heightPixels.toFloat() / metrics.widthPixels.toFloat()
|
||||||
|
|
||||||
if (nps == Full || nps == Classic || nps == Fit || nps == Gradient) {
|
if (nps == Full || nps == Classic || nps == Fit || nps == Gradient) {
|
||||||
viewPager.offscreenPageLimit = 2
|
viewPager.offscreenPageLimit = 2
|
||||||
} else if (PreferenceUtil.getInstance(requireContext()).carouselEffect()) {
|
} else if (PreferenceUtilKT.isCarouselEffect) {
|
||||||
viewPager.clipToPadding = false
|
viewPager.clipToPadding = false
|
||||||
val padding =
|
val padding =
|
||||||
if (ratio >= 1.777f) {
|
if (ratio >= 1.777f) {
|
||||||
|
@ -67,7 +68,7 @@ class PlayerAlbumCoverFragment : AbsMusicServiceFragment(), ViewPager.OnPageChan
|
||||||
viewPager.offscreenPageLimit = 2
|
viewPager.offscreenPageLimit = 2
|
||||||
viewPager.setPageTransformer(
|
viewPager.setPageTransformer(
|
||||||
true,
|
true,
|
||||||
PreferenceUtil.getInstance(requireContext()).albumCoverTransform
|
PreferenceUtilKT.albumCoverTransform
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,8 @@ import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
|
||||||
import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
|
import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
|
||||||
import code.name.monkey.retromusic.service.MusicService
|
import code.name.monkey.retromusic.service.MusicService
|
||||||
import code.name.monkey.retromusic.util.MusicUtil
|
import code.name.monkey.retromusic.util.MusicUtil
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
|
||||||
|
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||||
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
||||||
import kotlinx.android.synthetic.main.fragment_adaptive_player_playback_controls.*
|
import kotlinx.android.synthetic.main.fragment_adaptive_player_playback_controls.*
|
||||||
|
|
||||||
|
@ -66,7 +67,7 @@ class AdaptivePlaybackControlsFragment : AbsPlayerControlsFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateSong() {
|
private fun updateSong() {
|
||||||
if (PreferenceUtil.getInstance(requireContext()).isSongInfo) {
|
if (PreferenceUtilKT.isSongInfo) {
|
||||||
songInfo?.text = getSongInfo(MusicPlayerRemote.currentSong)
|
songInfo?.text = getSongInfo(MusicPlayerRemote.currentSong)
|
||||||
songInfo.show()
|
songInfo.show()
|
||||||
} else {
|
} else {
|
||||||
|
@ -130,7 +131,7 @@ class AdaptivePlaybackControlsFragment : AbsPlayerControlsFragment() {
|
||||||
updatePrevNextColor()
|
updatePrevNextColor()
|
||||||
updatePlayPauseColor()
|
updatePlayPauseColor()
|
||||||
|
|
||||||
val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
|
val colorFinal = if (PreferenceUtilKT.isAdaptiveColor) {
|
||||||
color.primaryTextColor
|
color.primaryTextColor
|
||||||
} else {
|
} else {
|
||||||
ThemeStore.accentColor(requireContext())
|
ThemeStore.accentColor(requireContext())
|
||||||
|
|
|
@ -25,7 +25,8 @@ import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
|
||||||
import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
|
import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
|
||||||
import code.name.monkey.retromusic.service.MusicService
|
import code.name.monkey.retromusic.service.MusicService
|
||||||
import code.name.monkey.retromusic.util.MusicUtil
|
import code.name.monkey.retromusic.util.MusicUtil
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
|
||||||
|
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||||
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
||||||
import kotlinx.android.synthetic.main.fragment_blur_player_playback_controls.*
|
import kotlinx.android.synthetic.main.fragment_blur_player_playback_controls.*
|
||||||
import kotlinx.android.synthetic.main.fragment_blur_player_playback_controls.nextButton
|
import kotlinx.android.synthetic.main.fragment_blur_player_playback_controls.nextButton
|
||||||
|
@ -81,7 +82,7 @@ class BlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
||||||
title.text = song.title
|
title.text = song.title
|
||||||
text.text = String.format("%s • %s", song.artistName, song.albumName)
|
text.text = String.format("%s • %s", song.artistName, song.albumName)
|
||||||
|
|
||||||
if (PreferenceUtil.getInstance(requireContext()).isSongInfo) {
|
if (PreferenceUtilKT.isSongInfo) {
|
||||||
songInfo.show()
|
songInfo.show()
|
||||||
songInfo?.text = getSongInfo(song)
|
songInfo?.text = getSongInfo(song)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -9,6 +9,7 @@ import android.view.ViewGroup
|
||||||
import androidx.appcompat.widget.Toolbar
|
import androidx.appcompat.widget.Toolbar
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
||||||
|
import code.name.monkey.retromusic.NEW_BLUR_AMOUNT
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
|
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
|
||||||
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
|
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
|
||||||
|
@ -17,7 +18,6 @@ import code.name.monkey.retromusic.glide.RetroMusicColoredTarget
|
||||||
import code.name.monkey.retromusic.glide.SongGlideRequest
|
import code.name.monkey.retromusic.glide.SongGlideRequest
|
||||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||||
import code.name.monkey.retromusic.model.Song
|
import code.name.monkey.retromusic.model.Song
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
|
||||||
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import kotlinx.android.synthetic.main.fragment_blur.*
|
import kotlinx.android.synthetic.main.fragment_blur.*
|
||||||
|
@ -98,7 +98,7 @@ class BlurPlayerFragment : AbsPlayerFragment(), SharedPreferences.OnSharedPrefer
|
||||||
|
|
||||||
private fun updateBlur() {
|
private fun updateBlur() {
|
||||||
val blurAmount = PreferenceManager.getDefaultSharedPreferences(requireContext())
|
val blurAmount = PreferenceManager.getDefaultSharedPreferences(requireContext())
|
||||||
.getInt(PreferenceUtil.NEW_BLUR_AMOUNT, 25)
|
.getInt(NEW_BLUR_AMOUNT, 25)
|
||||||
colorBackground.clearColorFilter()
|
colorBackground.clearColorFilter()
|
||||||
SongGlideRequest.Builder.from(Glide.with(requireActivity()), MusicPlayerRemote.currentSong)
|
SongGlideRequest.Builder.from(Glide.with(requireActivity()), MusicPlayerRemote.currentSong)
|
||||||
.checkIgnoreMediaStore(requireContext())
|
.checkIgnoreMediaStore(requireContext())
|
||||||
|
@ -141,7 +141,7 @@ class BlurPlayerFragment : AbsPlayerFragment(), SharedPreferences.OnSharedPrefer
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
|
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
|
||||||
if (key == PreferenceUtil.NEW_BLUR_AMOUNT) {
|
if (key == NEW_BLUR_AMOUNT) {
|
||||||
updateBlur()
|
updateBlur()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,8 @@ import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
|
||||||
import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
|
import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
|
||||||
import code.name.monkey.retromusic.service.MusicService
|
import code.name.monkey.retromusic.service.MusicService
|
||||||
import code.name.monkey.retromusic.util.MusicUtil
|
import code.name.monkey.retromusic.util.MusicUtil
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
|
||||||
|
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||||
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
||||||
import kotlinx.android.synthetic.main.fragment_card_player_playback_controls.*
|
import kotlinx.android.synthetic.main.fragment_card_player_playback_controls.*
|
||||||
import kotlinx.android.synthetic.main.media_button.*
|
import kotlinx.android.synthetic.main.media_button.*
|
||||||
|
@ -68,7 +69,7 @@ class CardPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
||||||
title.text = song.title
|
title.text = song.title
|
||||||
text.text = song.artistName
|
text.text = song.artistName
|
||||||
|
|
||||||
if (PreferenceUtil.getInstance(requireContext()).isSongInfo) {
|
if (PreferenceUtilKT.isSongInfo) {
|
||||||
songInfo.text = getSongInfo(MusicPlayerRemote.currentSong)
|
songInfo.text = getSongInfo(MusicPlayerRemote.currentSong)
|
||||||
songInfo.show()
|
songInfo.show()
|
||||||
} else {
|
} else {
|
||||||
|
@ -128,7 +129,7 @@ class CardPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
||||||
updatePlayPauseColor()
|
updatePlayPauseColor()
|
||||||
updateProgressTextColor()
|
updateProgressTextColor()
|
||||||
|
|
||||||
val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
|
val colorFinal = if (PreferenceUtilKT.isAdaptiveColor) {
|
||||||
color.primaryTextColor
|
color.primaryTextColor
|
||||||
} else {
|
} else {
|
||||||
ThemeStore.accentColor(requireContext()).ripAlpha()
|
ThemeStore.accentColor(requireContext()).ripAlpha()
|
||||||
|
|
|
@ -9,6 +9,7 @@ import android.view.ViewGroup
|
||||||
import androidx.appcompat.widget.Toolbar
|
import androidx.appcompat.widget.Toolbar
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
||||||
|
import code.name.monkey.retromusic.NEW_BLUR_AMOUNT
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
|
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
|
||||||
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
|
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
|
||||||
|
@ -18,7 +19,7 @@ import code.name.monkey.retromusic.glide.RetroMusicColoredTarget
|
||||||
import code.name.monkey.retromusic.glide.SongGlideRequest
|
import code.name.monkey.retromusic.glide.SongGlideRequest
|
||||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||||
import code.name.monkey.retromusic.model.Song
|
import code.name.monkey.retromusic.model.Song
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
|
||||||
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import kotlinx.android.synthetic.main.fragment_card_blur_player.*
|
import kotlinx.android.synthetic.main.fragment_card_blur_player.*
|
||||||
|
@ -88,7 +89,9 @@ class CardBlurFragment : AbsPlayerFragment(), SharedPreferences.OnSharedPreferen
|
||||||
private fun setUpSubFragments() {
|
private fun setUpSubFragments() {
|
||||||
playbackControlsFragment =
|
playbackControlsFragment =
|
||||||
childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as CardBlurPlaybackControlsFragment
|
childFragmentManager.findFragmentById(R.id.playbackControlsFragment) as CardBlurPlaybackControlsFragment
|
||||||
(childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment?)?.setCallbacks(this)
|
(childFragmentManager.findFragmentById(R.id.playerAlbumCoverFragment) as PlayerAlbumCoverFragment?)?.setCallbacks(
|
||||||
|
this
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setUpPlayerToolbar() {
|
private fun setUpPlayerToolbar() {
|
||||||
|
@ -123,7 +126,7 @@ class CardBlurFragment : AbsPlayerFragment(), SharedPreferences.OnSharedPreferen
|
||||||
|
|
||||||
private fun updateBlur() {
|
private fun updateBlur() {
|
||||||
val blurAmount = PreferenceManager.getDefaultSharedPreferences(requireContext())
|
val blurAmount = PreferenceManager.getDefaultSharedPreferences(requireContext())
|
||||||
.getInt(PreferenceUtil.NEW_BLUR_AMOUNT, 25)
|
.getInt(NEW_BLUR_AMOUNT, 25)
|
||||||
colorBackground!!.clearColorFilter()
|
colorBackground!!.clearColorFilter()
|
||||||
SongGlideRequest.Builder.from(Glide.with(requireActivity()), MusicPlayerRemote.currentSong)
|
SongGlideRequest.Builder.from(Glide.with(requireActivity()), MusicPlayerRemote.currentSong)
|
||||||
.checkIgnoreMediaStore(requireContext())
|
.checkIgnoreMediaStore(requireContext())
|
||||||
|
@ -155,7 +158,7 @@ class CardBlurFragment : AbsPlayerFragment(), SharedPreferences.OnSharedPreferen
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
|
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
|
||||||
if (key == PreferenceUtil.NEW_BLUR_AMOUNT) {
|
if (key == NEW_BLUR_AMOUNT) {
|
||||||
updateBlur()
|
updateBlur()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,8 @@ import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
|
||||||
import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
|
import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
|
||||||
import code.name.monkey.retromusic.service.MusicService
|
import code.name.monkey.retromusic.service.MusicService
|
||||||
import code.name.monkey.retromusic.util.MusicUtil
|
import code.name.monkey.retromusic.util.MusicUtil
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||||
|
|
||||||
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
||||||
import kotlinx.android.synthetic.main.fragment_card_blur_player_playback_controls.*
|
import kotlinx.android.synthetic.main.fragment_card_blur_player_playback_controls.*
|
||||||
import kotlinx.android.synthetic.main.media_button.*
|
import kotlinx.android.synthetic.main.media_button.*
|
||||||
|
@ -113,7 +114,7 @@ class CardBlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateSong() {
|
private fun updateSong() {
|
||||||
if (PreferenceUtil.getInstance(requireContext()).isSongInfo) {
|
if (PreferenceUtilKT.isSongInfo) {
|
||||||
songInfo.text = getSongInfo(MusicPlayerRemote.currentSong)
|
songInfo.text = getSongInfo(MusicPlayerRemote.currentSong)
|
||||||
songInfo.show()
|
songInfo.show()
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -44,7 +44,8 @@ import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper.Callback
|
||||||
import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
|
import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
|
||||||
import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
|
import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
|
||||||
import code.name.monkey.retromusic.util.MusicUtil
|
import code.name.monkey.retromusic.util.MusicUtil
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||||
|
|
||||||
import code.name.monkey.retromusic.util.ViewUtil
|
import code.name.monkey.retromusic.util.ViewUtil
|
||||||
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
||||||
import code.name.monkey.retromusic.views.SeekArc
|
import code.name.monkey.retromusic.views.SeekArc
|
||||||
|
@ -195,7 +196,7 @@ class CirclePlayerFragment : AbsPlayerFragment(), Callback, OnAudioVolumeChanged
|
||||||
title.text = song.title
|
title.text = song.title
|
||||||
text.text = song.artistName
|
text.text = song.artistName
|
||||||
|
|
||||||
if (PreferenceUtil.getInstance(requireContext()).isSongInfo) {
|
if (PreferenceUtilKT.isSongInfo) {
|
||||||
songInfo.text = getSongInfo(song)
|
songInfo.text = getSongInfo(song)
|
||||||
songInfo.show()
|
songInfo.show()
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -36,7 +36,8 @@ import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
|
||||||
import code.name.monkey.retromusic.model.Song
|
import code.name.monkey.retromusic.model.Song
|
||||||
import code.name.monkey.retromusic.service.MusicService
|
import code.name.monkey.retromusic.service.MusicService
|
||||||
import code.name.monkey.retromusic.util.MusicUtil
|
import code.name.monkey.retromusic.util.MusicUtil
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
|
||||||
|
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||||
import code.name.monkey.retromusic.util.ViewUtil
|
import code.name.monkey.retromusic.util.ViewUtil
|
||||||
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
||||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||||
|
@ -154,7 +155,7 @@ class ClassicPlayerFragment : AbsPlayerFragment(), View.OnLayoutChangeListener,
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun hideVolumeIfAvailable() {
|
private fun hideVolumeIfAvailable() {
|
||||||
if (PreferenceUtil.getInstance(requireContext()).volumeToggle) {
|
if (PreferenceUtilKT.isVolumeVisibilityMode) {
|
||||||
childFragmentManager.beginTransaction()
|
childFragmentManager.beginTransaction()
|
||||||
.replace(R.id.volumeFragmentContainer, VolumeFragment.newInstance())
|
.replace(R.id.volumeFragmentContainer, VolumeFragment.newInstance())
|
||||||
.commit()
|
.commit()
|
||||||
|
@ -185,7 +186,7 @@ class ClassicPlayerFragment : AbsPlayerFragment(), View.OnLayoutChangeListener,
|
||||||
title.text = song.title
|
title.text = song.title
|
||||||
text.text = song.artistName
|
text.text = song.artistName
|
||||||
|
|
||||||
if (PreferenceUtil.getInstance(requireContext()).isSongInfo) {
|
if (PreferenceUtilKT.isSongInfo) {
|
||||||
songInfo.text = getSongInfo(song)
|
songInfo.text = getSongInfo(song)
|
||||||
songInfo.show()
|
songInfo.show()
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -23,7 +23,8 @@ import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
|
||||||
import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
|
import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
|
||||||
import code.name.monkey.retromusic.service.MusicService
|
import code.name.monkey.retromusic.service.MusicService
|
||||||
import code.name.monkey.retromusic.util.MusicUtil
|
import code.name.monkey.retromusic.util.MusicUtil
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||||
|
|
||||||
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
||||||
import kotlinx.android.synthetic.main.fragment_color_player_playback_controls.*
|
import kotlinx.android.synthetic.main.fragment_color_player_playback_controls.*
|
||||||
|
|
||||||
|
@ -68,7 +69,7 @@ class ColorPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
||||||
title.text = song.title
|
title.text = song.title
|
||||||
text.text = song.artistName
|
text.text = song.artistName
|
||||||
|
|
||||||
if (PreferenceUtil.getInstance(requireContext()).isSongInfo) {
|
if (PreferenceUtilKT.isSongInfo) {
|
||||||
songInfo.text = getSongInfo(song)
|
songInfo.text = getSongInfo(song)
|
||||||
songInfo.show()
|
songInfo.show()
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -26,7 +26,8 @@ import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
|
||||||
import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
|
import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
|
||||||
import code.name.monkey.retromusic.service.MusicService
|
import code.name.monkey.retromusic.service.MusicService
|
||||||
import code.name.monkey.retromusic.util.MusicUtil
|
import code.name.monkey.retromusic.util.MusicUtil
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
|
||||||
|
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||||
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
||||||
import kotlinx.android.synthetic.main.fragment_fit_playback_controls.*
|
import kotlinx.android.synthetic.main.fragment_fit_playback_controls.*
|
||||||
|
|
||||||
|
@ -71,7 +72,7 @@ class FitPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
||||||
val song = MusicPlayerRemote.currentSong
|
val song = MusicPlayerRemote.currentSong
|
||||||
title.text = song.title
|
title.text = song.title
|
||||||
text.text = song.artistName
|
text.text = song.artistName
|
||||||
if (PreferenceUtil.getInstance(requireContext()).isSongInfo) {
|
if (PreferenceUtilKT.isSongInfo) {
|
||||||
songInfo.text = getSongInfo(song)
|
songInfo.text = getSongInfo(song)
|
||||||
songInfo.show()
|
songInfo.show()
|
||||||
} else {
|
} else {
|
||||||
|
@ -126,7 +127,7 @@ class FitPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
||||||
MaterialValueHelper.getPrimaryDisabledTextColor(activity, false)
|
MaterialValueHelper.getPrimaryDisabledTextColor(activity, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
|
val colorFinal = if (PreferenceUtilKT.isAdaptiveColor) {
|
||||||
color.primaryTextColor
|
color.primaryTextColor
|
||||||
} else {
|
} else {
|
||||||
ThemeStore.accentColor(requireContext()).ripAlpha()
|
ThemeStore.accentColor(requireContext()).ripAlpha()
|
||||||
|
|
|
@ -27,7 +27,8 @@ import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
|
||||||
import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
|
import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
|
||||||
import code.name.monkey.retromusic.service.MusicService
|
import code.name.monkey.retromusic.service.MusicService
|
||||||
import code.name.monkey.retromusic.util.MusicUtil
|
import code.name.monkey.retromusic.util.MusicUtil
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
|
||||||
|
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||||
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
||||||
import kotlinx.android.synthetic.main.fragment_flat_player_playback_controls.*
|
import kotlinx.android.synthetic.main.fragment_flat_player_playback_controls.*
|
||||||
|
|
||||||
|
@ -95,7 +96,7 @@ class FlatPlaybackControlsFragment : AbsPlayerControlsFragment(), Callback {
|
||||||
MaterialValueHelper.getPrimaryDisabledTextColor(requireContext(), false)
|
MaterialValueHelper.getPrimaryDisabledTextColor(requireContext(), false)
|
||||||
}
|
}
|
||||||
|
|
||||||
val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
|
val colorFinal = if (PreferenceUtilKT.isAdaptiveColor) {
|
||||||
color.primaryTextColor
|
color.primaryTextColor
|
||||||
} else {
|
} else {
|
||||||
ThemeStore.accentColor(requireContext()).ripAlpha()
|
ThemeStore.accentColor(requireContext()).ripAlpha()
|
||||||
|
@ -165,7 +166,7 @@ class FlatPlaybackControlsFragment : AbsPlayerControlsFragment(), Callback {
|
||||||
val song = MusicPlayerRemote.currentSong
|
val song = MusicPlayerRemote.currentSong
|
||||||
title.text = song.title
|
title.text = song.title
|
||||||
text.text = song.artistName
|
text.text = song.artistName
|
||||||
if (PreferenceUtil.getInstance(requireContext()).isSongInfo) {
|
if (PreferenceUtilKT.isSongInfo) {
|
||||||
songInfo.text = getSongInfo(song)
|
songInfo.text = getSongInfo(song)
|
||||||
songInfo.show()
|
songInfo.show()
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -17,7 +17,8 @@ import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
|
||||||
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
|
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
|
||||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||||
import code.name.monkey.retromusic.model.Song
|
import code.name.monkey.retromusic.model.Song
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
|
||||||
|
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||||
import code.name.monkey.retromusic.util.ViewUtil
|
import code.name.monkey.retromusic.util.ViewUtil
|
||||||
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
||||||
import code.name.monkey.retromusic.views.DrawableGradient
|
import code.name.monkey.retromusic.views.DrawableGradient
|
||||||
|
@ -98,7 +99,7 @@ class FlatPlayerFragment : AbsPlayerFragment() {
|
||||||
|
|
||||||
override fun toolbarIconColor(): Int {
|
override fun toolbarIconColor(): Int {
|
||||||
val isLight = ColorUtil.isColorLight(paletteColor)
|
val isLight = ColorUtil.isColorLight(paletteColor)
|
||||||
return if (PreferenceUtil.getInstance(requireContext()).adaptiveColor)
|
return if (PreferenceUtilKT.isAdaptiveColor)
|
||||||
MaterialValueHelper.getPrimaryTextColor(requireContext(), isLight)
|
MaterialValueHelper.getPrimaryTextColor(requireContext(), isLight)
|
||||||
else
|
else
|
||||||
ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal)
|
ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal)
|
||||||
|
@ -109,12 +110,12 @@ class FlatPlayerFragment : AbsPlayerFragment() {
|
||||||
controlsFragment.setColor(color)
|
controlsFragment.setColor(color)
|
||||||
callbacks?.onPaletteColorChanged()
|
callbacks?.onPaletteColorChanged()
|
||||||
val isLight = ColorUtil.isColorLight(color.backgroundColor)
|
val isLight = ColorUtil.isColorLight(color.backgroundColor)
|
||||||
val iconColor = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor)
|
val iconColor = if (PreferenceUtilKT.isAdaptiveColor)
|
||||||
MaterialValueHelper.getPrimaryTextColor(requireContext(), isLight)
|
MaterialValueHelper.getPrimaryTextColor(requireContext(), isLight)
|
||||||
else
|
else
|
||||||
ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal)
|
ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal)
|
||||||
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, iconColor, requireActivity())
|
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, iconColor, requireActivity())
|
||||||
if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
|
if (PreferenceUtilKT.isAdaptiveColor) {
|
||||||
colorize(color.backgroundColor)
|
colorize(color.backgroundColor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,8 @@ import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
|
||||||
import code.name.monkey.retromusic.model.Song
|
import code.name.monkey.retromusic.model.Song
|
||||||
import code.name.monkey.retromusic.service.MusicService
|
import code.name.monkey.retromusic.service.MusicService
|
||||||
import code.name.monkey.retromusic.util.MusicUtil
|
import code.name.monkey.retromusic.util.MusicUtil
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||||
|
|
||||||
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
||||||
import kotlinx.android.synthetic.main.fragment_full_player_controls.*
|
import kotlinx.android.synthetic.main.fragment_full_player_controls.*
|
||||||
|
|
||||||
|
@ -128,7 +129,7 @@ class FullPlaybackControlsFragment : AbsPlayerControlsFragment(),
|
||||||
title.text = song.title
|
title.text = song.title
|
||||||
text.text = song.artistName
|
text.text = song.artistName
|
||||||
updateIsFavorite()
|
updateIsFavorite()
|
||||||
if (PreferenceUtil.getInstance(requireContext()).isSongInfo) {
|
if (PreferenceUtilKT.isSongInfo) {
|
||||||
songInfo.text = getSongInfo(song)
|
songInfo.text = getSongInfo(song)
|
||||||
songInfo.show()
|
songInfo.show()
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -38,7 +38,8 @@ import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
|
||||||
import code.name.monkey.retromusic.model.Song
|
import code.name.monkey.retromusic.model.Song
|
||||||
import code.name.monkey.retromusic.service.MusicService
|
import code.name.monkey.retromusic.service.MusicService
|
||||||
import code.name.monkey.retromusic.util.MusicUtil
|
import code.name.monkey.retromusic.util.MusicUtil
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
|
||||||
|
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||||
import code.name.monkey.retromusic.util.ViewUtil
|
import code.name.monkey.retromusic.util.ViewUtil
|
||||||
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
||||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||||
|
@ -243,7 +244,7 @@ class GradientPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelpe
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun hideVolumeIfAvailable() {
|
private fun hideVolumeIfAvailable() {
|
||||||
if (PreferenceUtil.getInstance(requireContext()).volumeToggle) {
|
if (PreferenceUtilKT.isVolumeVisibilityMode) {
|
||||||
childFragmentManager.beginTransaction()
|
childFragmentManager.beginTransaction()
|
||||||
.replace(R.id.volumeFragmentContainer, VolumeFragment.newInstance())
|
.replace(R.id.volumeFragmentContainer, VolumeFragment.newInstance())
|
||||||
.commit()
|
.commit()
|
||||||
|
@ -284,7 +285,7 @@ class GradientPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelpe
|
||||||
title.text = song.title
|
title.text = song.title
|
||||||
text.text = song.artistName
|
text.text = song.artistName
|
||||||
updateLabel()
|
updateLabel()
|
||||||
if (PreferenceUtil.getInstance(requireContext()).isSongInfo) {
|
if (PreferenceUtilKT.isSongInfo) {
|
||||||
songInfo.text = getSongInfo(song)
|
songInfo.text = getSongInfo(song)
|
||||||
songInfo.show()
|
songInfo.show()
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -38,7 +38,8 @@ import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
|
||||||
import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
|
import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
|
||||||
import code.name.monkey.retromusic.service.MusicService
|
import code.name.monkey.retromusic.service.MusicService
|
||||||
import code.name.monkey.retromusic.util.MusicUtil
|
import code.name.monkey.retromusic.util.MusicUtil
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
|
||||||
|
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||||
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
||||||
import kotlinx.android.synthetic.main.fragment_lock_screen_playback_controls.*
|
import kotlinx.android.synthetic.main.fragment_lock_screen_playback_controls.*
|
||||||
|
|
||||||
|
@ -125,7 +126,7 @@ class LockScreenPlayerControlsFragment : AbsPlayerControlsFragment() {
|
||||||
MaterialValueHelper.getPrimaryDisabledTextColor(requireContext(), false)
|
MaterialValueHelper.getPrimaryDisabledTextColor(requireContext(), false)
|
||||||
}
|
}
|
||||||
|
|
||||||
val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
|
val colorFinal = if (PreferenceUtilKT.isAdaptiveColor) {
|
||||||
color.primaryTextColor
|
color.primaryTextColor
|
||||||
} else {
|
} else {
|
||||||
textColorSecondary()
|
textColorSecondary()
|
||||||
|
|
|
@ -19,7 +19,8 @@ import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
|
||||||
import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
|
import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
|
||||||
import code.name.monkey.retromusic.service.MusicService
|
import code.name.monkey.retromusic.service.MusicService
|
||||||
import code.name.monkey.retromusic.util.MusicUtil
|
import code.name.monkey.retromusic.util.MusicUtil
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
|
||||||
|
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||||
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
||||||
import kotlinx.android.synthetic.main.fragment_material_playback_controls.*
|
import kotlinx.android.synthetic.main.fragment_material_playback_controls.*
|
||||||
|
|
||||||
|
@ -56,7 +57,7 @@ class MaterialControlsFragment : AbsPlayerControlsFragment() {
|
||||||
title.text = song.title
|
title.text = song.title
|
||||||
text.text = song.artistName
|
text.text = song.artistName
|
||||||
|
|
||||||
if (PreferenceUtil.getInstance(requireContext()).isSongInfo) {
|
if (PreferenceUtilKT.isSongInfo) {
|
||||||
songInfo.text = getSongInfo(song)
|
songInfo.text = getSongInfo(song)
|
||||||
songInfo.show()
|
songInfo.show()
|
||||||
} else {
|
} else {
|
||||||
|
@ -113,7 +114,7 @@ class MaterialControlsFragment : AbsPlayerControlsFragment() {
|
||||||
updateRepeatState()
|
updateRepeatState()
|
||||||
updateShuffleState()
|
updateShuffleState()
|
||||||
|
|
||||||
val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
|
val colorFinal = if (PreferenceUtilKT.isAdaptiveColor) {
|
||||||
lastPlaybackControlsColor
|
lastPlaybackControlsColor
|
||||||
} else {
|
} else {
|
||||||
textColorSecondary()
|
textColorSecondary()
|
||||||
|
|
|
@ -15,7 +15,8 @@ import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
|
||||||
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
|
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
|
||||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||||
import code.name.monkey.retromusic.model.Song
|
import code.name.monkey.retromusic.model.Song
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
|
||||||
|
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||||
import code.name.monkey.retromusic.util.ViewUtil
|
import code.name.monkey.retromusic.util.ViewUtil
|
||||||
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
||||||
import code.name.monkey.retromusic.views.DrawableGradient
|
import code.name.monkey.retromusic.views.DrawableGradient
|
||||||
|
@ -85,7 +86,7 @@ class PlayerFragment : AbsPlayerFragment() {
|
||||||
requireActivity()
|
requireActivity()
|
||||||
)
|
)
|
||||||
|
|
||||||
if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
|
if (PreferenceUtilKT.isAdaptiveColor) {
|
||||||
colorize(color.backgroundColor)
|
colorize(color.backgroundColor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,8 @@ import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
|
||||||
import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
|
import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
|
||||||
import code.name.monkey.retromusic.service.MusicService
|
import code.name.monkey.retromusic.service.MusicService
|
||||||
import code.name.monkey.retromusic.util.MusicUtil
|
import code.name.monkey.retromusic.util.MusicUtil
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
|
||||||
|
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||||
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
||||||
import kotlinx.android.synthetic.main.fragment_player_playback_controls.*
|
import kotlinx.android.synthetic.main.fragment_player_playback_controls.*
|
||||||
|
|
||||||
|
@ -77,7 +78,7 @@ class PlayerPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
||||||
MaterialValueHelper.getPrimaryDisabledTextColor(requireContext(), false)
|
MaterialValueHelper.getPrimaryDisabledTextColor(requireContext(), false)
|
||||||
}
|
}
|
||||||
|
|
||||||
val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
|
val colorFinal = if (PreferenceUtilKT.isAdaptiveColor) {
|
||||||
color.primaryTextColor
|
color.primaryTextColor
|
||||||
} else {
|
} else {
|
||||||
ThemeStore.accentColor(requireContext())
|
ThemeStore.accentColor(requireContext())
|
||||||
|
@ -104,7 +105,7 @@ class PlayerPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
||||||
title.text = song.title
|
title.text = song.title
|
||||||
text.text = song.artistName
|
text.text = song.artistName
|
||||||
|
|
||||||
if (PreferenceUtil.getInstance(requireContext()).isSongInfo) {
|
if (PreferenceUtilKT.isSongInfo) {
|
||||||
songInfo.text = getSongInfo(song)
|
songInfo.text = getSongInfo(song)
|
||||||
songInfo.show()
|
songInfo.show()
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -36,7 +36,8 @@ import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
|
||||||
import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
|
import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
|
||||||
import code.name.monkey.retromusic.service.MusicService
|
import code.name.monkey.retromusic.service.MusicService
|
||||||
import code.name.monkey.retromusic.util.MusicUtil
|
import code.name.monkey.retromusic.util.MusicUtil
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
|
||||||
|
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||||
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
||||||
import kotlinx.android.synthetic.main.fragment_peak_control_player.*
|
import kotlinx.android.synthetic.main.fragment_peak_control_player.*
|
||||||
|
|
||||||
|
@ -89,7 +90,7 @@ class PeakPlayerControlFragment : AbsPlayerControlsFragment() {
|
||||||
|
|
||||||
override fun setColor(color: MediaNotificationProcessor) {
|
override fun setColor(color: MediaNotificationProcessor) {
|
||||||
val controlsColor =
|
val controlsColor =
|
||||||
if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
|
if (PreferenceUtilKT.isAdaptiveColor) {
|
||||||
color.primaryTextColor
|
color.primaryTextColor
|
||||||
} else {
|
} else {
|
||||||
ThemeStore.accentColor(requireContext())
|
ThemeStore.accentColor(requireContext())
|
||||||
|
|
|
@ -27,7 +27,8 @@ import code.name.monkey.retromusic.extensions.show
|
||||||
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
|
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
|
||||||
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
|
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
|
||||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||||
|
|
||||||
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
||||||
import kotlinx.android.synthetic.main.fragment_peak_player.*
|
import kotlinx.android.synthetic.main.fragment_peak_player.*
|
||||||
|
|
||||||
|
@ -113,7 +114,7 @@ class PeakPlayerFragment : AbsPlayerFragment() {
|
||||||
title.text = song.title
|
title.text = song.title
|
||||||
text.text = song.artistName
|
text.text = song.artistName
|
||||||
|
|
||||||
if (PreferenceUtil.getInstance(requireContext()).isSongInfo) {
|
if (PreferenceUtilKT.isSongInfo) {
|
||||||
songInfo.text = getSongInfo(song)
|
songInfo.text = getSongInfo(song)
|
||||||
songInfo.show()
|
songInfo.show()
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -26,7 +26,8 @@ import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
|
||||||
import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
|
import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
|
||||||
import code.name.monkey.retromusic.service.MusicService
|
import code.name.monkey.retromusic.service.MusicService
|
||||||
import code.name.monkey.retromusic.util.MusicUtil
|
import code.name.monkey.retromusic.util.MusicUtil
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
|
||||||
|
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||||
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
||||||
import kotlinx.android.synthetic.main.fragment_adaptive_player_playback_controls.*
|
import kotlinx.android.synthetic.main.fragment_adaptive_player_playback_controls.*
|
||||||
import kotlinx.android.synthetic.main.fragment_plain_controls_fragment.nextButton
|
import kotlinx.android.synthetic.main.fragment_plain_controls_fragment.nextButton
|
||||||
|
@ -73,7 +74,7 @@ class PlainPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateSong() {
|
private fun updateSong() {
|
||||||
if (PreferenceUtil.getInstance(requireContext()).isSongInfo) {
|
if (PreferenceUtilKT.isSongInfo) {
|
||||||
songInfo.text = getSongInfo(MusicPlayerRemote.currentSong)
|
songInfo.text = getSongInfo(MusicPlayerRemote.currentSong)
|
||||||
songInfo.show()
|
songInfo.show()
|
||||||
} else {
|
} else {
|
||||||
|
@ -156,7 +157,7 @@ class PlainPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
||||||
MaterialValueHelper.getPrimaryDisabledTextColor(requireContext(), false)
|
MaterialValueHelper.getPrimaryDisabledTextColor(requireContext(), false)
|
||||||
}
|
}
|
||||||
|
|
||||||
val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
|
val colorFinal = if (PreferenceUtilKT.isAdaptiveColor) {
|
||||||
color.primaryTextColor
|
color.primaryTextColor
|
||||||
} else {
|
} else {
|
||||||
ThemeStore.accentColor(requireContext())
|
ThemeStore.accentColor(requireContext())
|
||||||
|
|
|
@ -20,7 +20,8 @@ import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper
|
||||||
import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
|
import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
|
||||||
import code.name.monkey.retromusic.service.MusicService
|
import code.name.monkey.retromusic.service.MusicService
|
||||||
import code.name.monkey.retromusic.util.MusicUtil
|
import code.name.monkey.retromusic.util.MusicUtil
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
|
||||||
|
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||||
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
||||||
import kotlinx.android.synthetic.main.fragment_simple_controls_fragment.*
|
import kotlinx.android.synthetic.main.fragment_simple_controls_fragment.*
|
||||||
|
|
||||||
|
@ -155,7 +156,7 @@ class SimplePlaybackControlsFragment : AbsPlayerControlsFragment() {
|
||||||
title.text = song.title
|
title.text = song.title
|
||||||
text.text = song.artistName
|
text.text = song.artistName
|
||||||
|
|
||||||
if (PreferenceUtil.getInstance(requireContext()).isSongInfo) {
|
if (PreferenceUtilKT.isSongInfo) {
|
||||||
songInfo.text = getSongInfo(song)
|
songInfo.text = getSongInfo(song)
|
||||||
songInfo.show()
|
songInfo.show()
|
||||||
} else {
|
} else {
|
||||||
|
@ -212,7 +213,7 @@ class SimplePlaybackControlsFragment : AbsPlayerControlsFragment() {
|
||||||
MaterialValueHelper.getPrimaryDisabledTextColor(requireContext(), false)
|
MaterialValueHelper.getPrimaryDisabledTextColor(requireContext(), false)
|
||||||
}
|
}
|
||||||
|
|
||||||
val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
|
val colorFinal = if (PreferenceUtilKT.isAdaptiveColor) {
|
||||||
color.primaryTextColor
|
color.primaryTextColor
|
||||||
} else {
|
} else {
|
||||||
ThemeStore.accentColor(requireContext())
|
ThemeStore.accentColor(requireContext())
|
||||||
|
|
|
@ -21,7 +21,8 @@ import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper
|
||||||
import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
|
import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
|
||||||
import code.name.monkey.retromusic.model.Song
|
import code.name.monkey.retromusic.model.Song
|
||||||
import code.name.monkey.retromusic.util.MusicUtil
|
import code.name.monkey.retromusic.util.MusicUtil
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||||
|
|
||||||
import code.name.monkey.retromusic.util.ViewUtil
|
import code.name.monkey.retromusic.util.ViewUtil
|
||||||
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
||||||
import kotlinx.android.synthetic.main.fragment_tiny_player.*
|
import kotlinx.android.synthetic.main.fragment_tiny_player.*
|
||||||
|
@ -102,7 +103,7 @@ class TinyPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Ca
|
||||||
title.text = song.title
|
title.text = song.title
|
||||||
text.text = String.format("%s \nby - %s", song.albumName, song.artistName)
|
text.text = String.format("%s \nby - %s", song.albumName, song.artistName)
|
||||||
|
|
||||||
if (PreferenceUtil.getInstance(requireContext()).isSongInfo) {
|
if (PreferenceUtilKT.isSongInfo) {
|
||||||
songInfo.text = getSongInfo(song)
|
songInfo.text = getSongInfo(song)
|
||||||
songInfo.show()
|
songInfo.show()
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -75,7 +75,7 @@ abstract class AbsSettingsFragment : ATEPreferenceFragmentCompat() {
|
||||||
|
|
||||||
override fun onCreatePreferenceDialog(preference: Preference): DialogFragment? {
|
override fun onCreatePreferenceDialog(preference: Preference): DialogFragment? {
|
||||||
return when (preference) {
|
return when (preference) {
|
||||||
is LibraryPreference -> LibraryPreferenceDialog.newInstance(preference.key)
|
is LibraryPreference -> LibraryPreferenceDialog.newInstance()
|
||||||
is NowPlayingScreenPreference -> NowPlayingScreenPreferenceDialog.newInstance(preference.key)
|
is NowPlayingScreenPreference -> NowPlayingScreenPreferenceDialog.newInstance(preference.key)
|
||||||
is AlbumCoverStylePreference -> AlbumCoverStylePreferenceDialog.newInstance(preference.key)
|
is AlbumCoverStylePreference -> AlbumCoverStylePreferenceDialog.newInstance(preference.key)
|
||||||
is MaterialListPreference -> {
|
is MaterialListPreference -> {
|
||||||
|
|
|
@ -20,7 +20,7 @@ import android.os.Bundle
|
||||||
import androidx.preference.Preference
|
import androidx.preference.Preference
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.util.NavigationUtil
|
import code.name.monkey.retromusic.util.NavigationUtil
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Hemanth S (h4h13).
|
* @author Hemanth S (h4h13).
|
||||||
|
@ -29,7 +29,7 @@ import code.name.monkey.retromusic.util.PreferenceUtil
|
||||||
class AudioSettings : AbsSettingsFragment() {
|
class AudioSettings : AbsSettingsFragment() {
|
||||||
override fun invalidateSettings() {
|
override fun invalidateSettings() {
|
||||||
val findPreference: Preference = findPreference("equalizer")!!
|
val findPreference: Preference = findPreference("equalizer")!!
|
||||||
if (!hasEqualizer() && PreferenceUtil.getInstance(requireContext()).selectedEqualizer != "retro") {
|
if (!hasEqualizer() ) {
|
||||||
findPreference.isEnabled = false
|
findPreference.isEnabled = false
|
||||||
findPreference.summary = resources.getString(R.string.no_equalizer)
|
findPreference.summary = resources.getString(R.string.no_equalizer)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -20,8 +20,9 @@ import android.os.Build.VERSION_CODES
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.preference.Preference
|
import androidx.preference.Preference
|
||||||
import androidx.preference.TwoStatePreference
|
import androidx.preference.TwoStatePreference
|
||||||
|
import code.name.monkey.retromusic.CLASSIC_NOTIFICATION
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -31,7 +32,7 @@ import code.name.monkey.retromusic.util.PreferenceUtil
|
||||||
class NotificationSettingsFragment : AbsSettingsFragment(),
|
class NotificationSettingsFragment : AbsSettingsFragment(),
|
||||||
SharedPreferences.OnSharedPreferenceChangeListener {
|
SharedPreferences.OnSharedPreferenceChangeListener {
|
||||||
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
|
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
|
||||||
if (key == PreferenceUtil.CLASSIC_NOTIFICATION) {
|
if (key == CLASSIC_NOTIFICATION) {
|
||||||
if (VERSION.SDK_INT >= VERSION_CODES.O) {
|
if (VERSION.SDK_INT >= VERSION_CODES.O) {
|
||||||
findPreference<Preference>("colored_notification")?.isEnabled =
|
findPreference<Preference>("colored_notification")?.isEnabled =
|
||||||
sharedPreferences?.getBoolean(key, false)!!
|
sharedPreferences?.getBoolean(key, false)!!
|
||||||
|
@ -46,11 +47,10 @@ class NotificationSettingsFragment : AbsSettingsFragment(),
|
||||||
classicNotification?.isVisible = false
|
classicNotification?.isVisible = false
|
||||||
} else {
|
} else {
|
||||||
classicNotification?.apply {
|
classicNotification?.apply {
|
||||||
isChecked = PreferenceUtil.getInstance(requireContext()).classicNotification()
|
isChecked = PreferenceUtilKT.isClassicNotification
|
||||||
setOnPreferenceChangeListener { _, newValue ->
|
setOnPreferenceChangeListener { _, newValue ->
|
||||||
// Save preference
|
// Save preference
|
||||||
PreferenceUtil.getInstance(requireContext())
|
PreferenceUtilKT.isClassicNotification = newValue as Boolean
|
||||||
.setClassicNotification(newValue as Boolean)
|
|
||||||
invalidateSettings()
|
invalidateSettings()
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
@ -59,14 +59,12 @@ class NotificationSettingsFragment : AbsSettingsFragment(),
|
||||||
|
|
||||||
val coloredNotification: TwoStatePreference? = findPreference("colored_notification")
|
val coloredNotification: TwoStatePreference? = findPreference("colored_notification")
|
||||||
if (VERSION.SDK_INT >= VERSION_CODES.O) {
|
if (VERSION.SDK_INT >= VERSION_CODES.O) {
|
||||||
coloredNotification?.isEnabled =
|
coloredNotification?.isEnabled = PreferenceUtilKT.isClassicNotification
|
||||||
PreferenceUtil.getInstance(requireContext()).classicNotification()
|
|
||||||
} else {
|
} else {
|
||||||
coloredNotification?.apply {
|
coloredNotification?.apply {
|
||||||
isChecked = PreferenceUtil.getInstance(requireContext()).coloredNotification()
|
isChecked = PreferenceUtilKT.isColoredNotification
|
||||||
setOnPreferenceChangeListener { _, newValue ->
|
setOnPreferenceChangeListener { _, newValue ->
|
||||||
PreferenceUtil.getInstance(requireContext())
|
PreferenceUtilKT.isColoredNotification = newValue as Boolean
|
||||||
.setColoredNotification(newValue as Boolean)
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,13 +73,12 @@ class NotificationSettingsFragment : AbsSettingsFragment(),
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
PreferenceUtil.getInstance(requireContext()).registerOnSharedPreferenceChangedListener(this)
|
PreferenceUtilKT.registerOnSharedPreferenceChangedListener(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
super.onDestroyView()
|
super.onDestroyView()
|
||||||
PreferenceUtil.getInstance(requireContext())
|
PreferenceUtilKT.unregisterOnSharedPreferenceChangedListener(this)
|
||||||
.unregisterOnSharedPreferenceChangedListener(this)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||||
|
|
|
@ -19,9 +19,8 @@ import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.preference.Preference
|
import androidx.preference.Preference
|
||||||
import androidx.preference.TwoStatePreference
|
import androidx.preference.TwoStatePreference
|
||||||
import code.name.monkey.retromusic.App
|
import code.name.monkey.retromusic.*
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil.*
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Hemanth S (h4h13).
|
* @author Hemanth S (h4h13).
|
||||||
|
@ -50,24 +49,24 @@ class NowPlayingSettingsFragment : AbsSettingsFragment(),
|
||||||
|
|
||||||
private fun updateAlbumCoverStyleSummary() {
|
private fun updateAlbumCoverStyleSummary() {
|
||||||
val preference: Preference = findPreference(ALBUM_COVER_STYLE)!!
|
val preference: Preference = findPreference(ALBUM_COVER_STYLE)!!
|
||||||
preference.setSummary(getInstance(requireContext()).albumCoverStyle.titleRes)
|
preference.setSummary(PreferenceUtilKT.albumCoverStyle.titleRes)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateNowPlayingScreenSummary() {
|
private fun updateNowPlayingScreenSummary() {
|
||||||
val preference: Preference = findPreference(NOW_PLAYING_SCREEN_ID)!!
|
val preference: Preference = findPreference(NOW_PLAYING_SCREEN_ID)!!
|
||||||
preference.setSummary(getInstance(requireContext()).nowPlayingScreen.titleRes)
|
preference.setSummary(PreferenceUtilKT.nowPlayingScreen.titleRes)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
getInstance(requireContext()).registerOnSharedPreferenceChangedListener(this)
|
PreferenceUtilKT.registerOnSharedPreferenceChangedListener(this)
|
||||||
val preference: Preference = findPreference("album_cover_transform")!!
|
val preference: Preference = findPreference("album_cover_transform")!!
|
||||||
setSummary(preference)
|
setSummary(preference)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
super.onDestroyView()
|
super.onDestroyView()
|
||||||
getInstance(requireContext()).unregisterOnSharedPreferenceChangedListener(this)
|
PreferenceUtilKT.unregisterOnSharedPreferenceChangedListener(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) {
|
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) {
|
||||||
|
|
|
@ -19,8 +19,10 @@ import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.preference.Preference
|
import androidx.preference.Preference
|
||||||
import androidx.preference.TwoStatePreference
|
import androidx.preference.TwoStatePreference
|
||||||
|
import code.name.monkey.retromusic.CAROUSEL_EFFECT
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
|
||||||
|
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||||
|
|
||||||
class PersonalizeSettingsFragment : AbsSettingsFragment(),
|
class PersonalizeSettingsFragment : AbsSettingsFragment(),
|
||||||
SharedPreferences.OnSharedPreferenceChangeListener {
|
SharedPreferences.OnSharedPreferenceChangeListener {
|
||||||
|
@ -40,7 +42,7 @@ class PersonalizeSettingsFragment : AbsSettingsFragment(),
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
PreferenceUtil.getInstance(requireContext()).registerOnSharedPreferenceChangedListener(this)
|
PreferenceUtilKT.registerOnSharedPreferenceChangedListener(this)
|
||||||
|
|
||||||
var preference: Preference? = findPreference("home_artist_grid_style")
|
var preference: Preference? = findPreference("home_artist_grid_style")
|
||||||
setSummary(preference!!)
|
setSummary(preference!!)
|
||||||
|
@ -50,13 +52,12 @@ class PersonalizeSettingsFragment : AbsSettingsFragment(),
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
super.onDestroyView()
|
super.onDestroyView()
|
||||||
PreferenceUtil.getInstance(requireContext())
|
PreferenceUtilKT.unregisterOnSharedPreferenceChangedListener(this)
|
||||||
.unregisterOnSharedPreferenceChangedListener(this)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) {
|
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) {
|
||||||
when (key) {
|
when (key) {
|
||||||
PreferenceUtil.CAROUSEL_EFFECT -> invalidateSettings()
|
CAROUSEL_EFFECT -> invalidateSettings()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,9 +26,10 @@ import code.name.monkey.appthemehelper.common.prefs.supportv7.ATESwitchPreferenc
|
||||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||||
import code.name.monkey.appthemehelper.util.VersionUtils
|
import code.name.monkey.appthemehelper.util.VersionUtils
|
||||||
import code.name.monkey.retromusic.App
|
import code.name.monkey.retromusic.App
|
||||||
|
import code.name.monkey.retromusic.DESATURATED_COLOR
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.appshortcuts.DynamicShortcutManager
|
import code.name.monkey.retromusic.appshortcuts.DynamicShortcutManager
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||||
import com.afollestad.materialdialogs.MaterialDialog
|
import com.afollestad.materialdialogs.MaterialDialog
|
||||||
import com.afollestad.materialdialogs.color.colorChooser
|
import com.afollestad.materialdialogs.color.colorChooser
|
||||||
|
|
||||||
|
@ -48,7 +49,7 @@ class ThemeSettingsFragment : AbsSettingsFragment() {
|
||||||
ThemeStore.markChanged(requireContext())
|
ThemeStore.markChanged(requireContext())
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
|
||||||
requireActivity().setTheme(PreferenceUtil.getThemeResFromPrefValue(theme))
|
requireActivity().setTheme(PreferenceUtilKT.themeResFromPrefValue(theme))
|
||||||
DynamicShortcutManager(requireContext()).updateDynamicShortcuts()
|
DynamicShortcutManager(requireContext()).updateDynamicShortcuts()
|
||||||
}
|
}
|
||||||
requireActivity().recreate()
|
requireActivity().recreate()
|
||||||
|
@ -62,7 +63,6 @@ class ThemeSettingsFragment : AbsSettingsFragment() {
|
||||||
|
|
||||||
accentColorPref.setOnPreferenceClickListener {
|
accentColorPref.setOnPreferenceClickListener {
|
||||||
MaterialDialog(requireActivity()).show {
|
MaterialDialog(requireActivity()).show {
|
||||||
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
|
||||||
title(R.string.accent_color)
|
title(R.string.accent_color)
|
||||||
positiveButton(R.string.set)
|
positiveButton(R.string.set)
|
||||||
colorChooser(
|
colorChooser(
|
||||||
|
@ -75,7 +75,6 @@ class ThemeSettingsFragment : AbsSettingsFragment() {
|
||||||
DynamicShortcutManager(requireContext()).updateDynamicShortcuts()
|
DynamicShortcutManager(requireContext()).updateDynamicShortcuts()
|
||||||
|
|
||||||
requireActivity().recreate()
|
requireActivity().recreate()
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return@setOnPreferenceClickListener true
|
return@setOnPreferenceClickListener true
|
||||||
|
@ -88,22 +87,21 @@ class ThemeSettingsFragment : AbsSettingsFragment() {
|
||||||
}
|
}
|
||||||
ThemeStore.markChanged(requireContext())
|
ThemeStore.markChanged(requireContext())
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
|
||||||
requireActivity().setTheme(PreferenceUtil.getThemeResFromPrefValue("black"))
|
requireActivity().setTheme(PreferenceUtilKT.themeResFromPrefValue("black"))
|
||||||
DynamicShortcutManager(requireContext()).updateDynamicShortcuts()
|
DynamicShortcutManager(requireContext()).updateDynamicShortcuts()
|
||||||
}
|
}
|
||||||
requireActivity().recreate()
|
requireActivity().recreate()
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
val desaturatedColor: ATESwitchPreference? =
|
val desaturatedColor: ATESwitchPreference? = findPreference(DESATURATED_COLOR)
|
||||||
findPreference(PreferenceUtil.DESATURATED_COLOR)
|
|
||||||
desaturatedColor?.setOnPreferenceChangeListener { _, value ->
|
desaturatedColor?.setOnPreferenceChangeListener { _, value ->
|
||||||
val desaturated = value as Boolean
|
val desaturated = value as Boolean
|
||||||
ThemeStore.prefs(requireContext())
|
ThemeStore.prefs(requireContext())
|
||||||
.edit()
|
.edit()
|
||||||
.putBoolean("desaturated_color", desaturated)
|
.putBoolean("desaturated_color", desaturated)
|
||||||
.apply()
|
.apply()
|
||||||
PreferenceUtil.getInstance(requireContext()).setDesaturatedColor(desaturated)
|
PreferenceUtilKT.isDesaturatedColor = desaturated
|
||||||
requireActivity().recreate()
|
requireActivity().recreate()
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
@ -113,12 +111,9 @@ class ThemeSettingsFragment : AbsSettingsFragment() {
|
||||||
if (!VersionUtils.hasNougatMR()) {
|
if (!VersionUtils.hasNougatMR()) {
|
||||||
colorAppShortcuts.isVisible = false
|
colorAppShortcuts.isVisible = false
|
||||||
} else {
|
} else {
|
||||||
colorAppShortcuts.isChecked =
|
colorAppShortcuts.isChecked = PreferenceUtilKT.isColoredAppShortcuts
|
||||||
PreferenceUtil.getInstance(requireContext()).coloredAppShortcuts()
|
|
||||||
colorAppShortcuts.setOnPreferenceChangeListener { _, newValue ->
|
colorAppShortcuts.setOnPreferenceChangeListener { _, newValue ->
|
||||||
// Save preference
|
PreferenceUtilKT.isColoredAppShortcuts = newValue as Boolean
|
||||||
PreferenceUtil.getInstance(requireContext())
|
|
||||||
.setColoredAppShortcuts(newValue as Boolean)
|
|
||||||
DynamicShortcutManager(requireContext()).updateDynamicShortcuts()
|
DynamicShortcutManager(requireContext()).updateDynamicShortcuts()
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ import code.name.monkey.retromusic.interfaces.MainActivityFragmentCallbacks
|
||||||
import code.name.monkey.retromusic.model.Song
|
import code.name.monkey.retromusic.model.Song
|
||||||
import code.name.monkey.retromusic.mvp.presenter.SongPresenter
|
import code.name.monkey.retromusic.mvp.presenter.SongPresenter
|
||||||
import code.name.monkey.retromusic.mvp.presenter.SongView
|
import code.name.monkey.retromusic.mvp.presenter.SongView
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@ -70,19 +70,19 @@ class SongsFragment :
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun loadGridSize(): Int {
|
override fun loadGridSize(): Int {
|
||||||
return PreferenceUtil.getInstance(requireContext()).getSongGridSize(requireContext())
|
return PreferenceUtilKT.songGridSize
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun saveGridSize(gridColumns: Int) {
|
override fun saveGridSize(gridColumns: Int) {
|
||||||
PreferenceUtil.getInstance(requireContext()).setSongGridSize(gridColumns)
|
PreferenceUtilKT.songGridSize = gridColumns
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun loadGridSizeLand(): Int {
|
override fun loadGridSizeLand(): Int {
|
||||||
return PreferenceUtil.getInstance(requireContext()).getSongGridSizeLand(requireContext())
|
return PreferenceUtilKT.songGridSizeLand
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun saveGridSizeLand(gridColumns: Int) {
|
override fun saveGridSizeLand(gridColumns: Int) {
|
||||||
PreferenceUtil.getInstance(requireContext()).setSongGridSizeLand(gridColumns)
|
PreferenceUtilKT.songGridSizeLand = gridColumns
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setGridSize(gridSize: Int) {
|
override fun setGridSize(gridSize: Int) {
|
||||||
|
@ -105,11 +105,20 @@ class SongsFragment :
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun loadSortOrder(): String {
|
override fun loadSortOrder(): String {
|
||||||
return PreferenceUtil.getInstance(requireContext()).songSortOrder
|
return PreferenceUtilKT.songSortOrder
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun saveSortOrder(sortOrder: String) {
|
override fun saveSortOrder(sortOrder: String) {
|
||||||
PreferenceUtil.getInstance(requireContext()).songSortOrder = sortOrder
|
PreferenceUtilKT.songSortOrder = sortOrder
|
||||||
|
}
|
||||||
|
|
||||||
|
@LayoutRes
|
||||||
|
override fun loadLayoutRes(): Int {
|
||||||
|
return PreferenceUtilKT.songGridStyle
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun saveLayoutRes(@LayoutRes layoutRes: Int) {
|
||||||
|
PreferenceUtilKT.songGridStyle = layoutRes
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setSortOrder(sortOrder: String) {
|
override fun setSortOrder(sortOrder: String) {
|
||||||
|
@ -129,14 +138,6 @@ class SongsFragment :
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@LayoutRes
|
|
||||||
override fun loadLayoutRes(): Int {
|
|
||||||
return PreferenceUtil.getInstance(requireContext()).songGridStyle
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun saveLayoutRes(@LayoutRes layoutRes: Int) {
|
|
||||||
PreferenceUtil.getInstance(requireContext()).songGridStyle = layoutRes
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun handleBackPress(): Boolean {
|
override fun handleBackPress(): Boolean {
|
||||||
return false
|
return false
|
||||||
|
|
|
@ -20,7 +20,7 @@ import code.name.monkey.retromusic.glide.palette.BitmapPaletteTranscoder;
|
||||||
import code.name.monkey.retromusic.glide.palette.BitmapPaletteWrapper;
|
import code.name.monkey.retromusic.glide.palette.BitmapPaletteWrapper;
|
||||||
import code.name.monkey.retromusic.model.Song;
|
import code.name.monkey.retromusic.model.Song;
|
||||||
import code.name.monkey.retromusic.util.MusicUtil;
|
import code.name.monkey.retromusic.util.MusicUtil;
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil;
|
import code.name.monkey.retromusic.util.PreferenceUtilKT;
|
||||||
|
|
||||||
public class AlbumGlideRequest {
|
public class AlbumGlideRequest {
|
||||||
private static final DiskCacheStrategy DEFAULT_DISK_CACHE_STRATEGY = DiskCacheStrategy.NONE;
|
private static final DiskCacheStrategy DEFAULT_DISK_CACHE_STRATEGY = DiskCacheStrategy.NONE;
|
||||||
|
@ -70,7 +70,7 @@ public class AlbumGlideRequest {
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
public Builder checkIgnoreMediaStore(@NonNull Context context) {
|
public Builder checkIgnoreMediaStore(@NonNull Context context) {
|
||||||
return ignoreMediaStore(PreferenceUtil.getInstance(context).ignoreMediaStoreArtwork());
|
return ignoreMediaStore(PreferenceUtilKT.INSTANCE.isIgnoreMediaStoreArtwork());
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
|
|
|
@ -34,7 +34,7 @@ import code.name.monkey.retromusic.glide.palette.BitmapPaletteTranscoder;
|
||||||
import code.name.monkey.retromusic.glide.palette.BitmapPaletteWrapper;
|
import code.name.monkey.retromusic.glide.palette.BitmapPaletteWrapper;
|
||||||
import code.name.monkey.retromusic.model.Song;
|
import code.name.monkey.retromusic.model.Song;
|
||||||
import code.name.monkey.retromusic.util.MusicUtil;
|
import code.name.monkey.retromusic.util.MusicUtil;
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil;
|
import code.name.monkey.retromusic.util.PreferenceUtilKT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by hemanths on 2019-09-15.
|
* Created by hemanths on 2019-09-15.
|
||||||
|
@ -88,7 +88,7 @@ public class SongGlideRequest {
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
public Builder checkIgnoreMediaStore(@NonNull Context context) {
|
public Builder checkIgnoreMediaStore(@NonNull Context context) {
|
||||||
return ignoreMediaStore(PreferenceUtil.getInstance(context).ignoreMediaStoreArtwork());
|
return ignoreMediaStore(PreferenceUtilKT.INSTANCE.isIgnoreMediaStoreArtwork());
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
|
|
|
@ -18,7 +18,7 @@ import android.content.Context
|
||||||
import code.name.monkey.retromusic.deezer.Data
|
import code.name.monkey.retromusic.deezer.Data
|
||||||
import code.name.monkey.retromusic.deezer.DeezerApiService
|
import code.name.monkey.retromusic.deezer.DeezerApiService
|
||||||
import code.name.monkey.retromusic.util.MusicUtil
|
import code.name.monkey.retromusic.util.MusicUtil
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||||
import com.bumptech.glide.Priority
|
import com.bumptech.glide.Priority
|
||||||
import com.bumptech.glide.integration.okhttp3.OkHttpUrlLoader
|
import com.bumptech.glide.integration.okhttp3.OkHttpUrlLoader
|
||||||
import com.bumptech.glide.load.data.DataFetcher
|
import com.bumptech.glide.load.data.DataFetcher
|
||||||
|
@ -62,9 +62,8 @@ class ArtistImageFetcher(
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun loadData(priority: Priority?): InputStream? {
|
override fun loadData(priority: Priority?): InputStream? {
|
||||||
if (!MusicUtil.isArtistNameUnknown(model.artistName) && PreferenceUtil.isAllowedToDownloadMetadata(
|
if (!MusicUtil.isArtistNameUnknown(model.artistName) &&
|
||||||
context
|
PreferenceUtilKT.isAllowedToDownloadMetadata()
|
||||||
)
|
|
||||||
) {
|
) {
|
||||||
val artists = model.artistName.split(",")
|
val artists = model.artistName.split(",")
|
||||||
val response = deezerApiService.getArtistImage(artists[0]).execute()
|
val response = deezerApiService.getArtistImage(artists[0]).execute()
|
||||||
|
|
|
@ -29,7 +29,8 @@ import androidx.core.content.ContextCompat
|
||||||
import code.name.monkey.retromusic.loaders.SongLoader
|
import code.name.monkey.retromusic.loaders.SongLoader
|
||||||
import code.name.monkey.retromusic.model.Song
|
import code.name.monkey.retromusic.model.Song
|
||||||
import code.name.monkey.retromusic.service.MusicService
|
import code.name.monkey.retromusic.service.MusicService
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
|
||||||
|
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
|
@ -212,7 +213,7 @@ object MusicPlayerRemote {
|
||||||
) && musicService != null
|
) && musicService != null
|
||||||
) {
|
) {
|
||||||
musicService?.openQueue(queue, startPosition, startPlaying)
|
musicService?.openQueue(queue, startPosition, startPlaying)
|
||||||
if (PreferenceUtil.getInstance(musicService).isShuffleModeOn)
|
if (PreferenceUtilKT.isShuffleModeOn)
|
||||||
setShuffleMode(MusicService.SHUFFLE_MODE_NONE)
|
setShuffleMode(MusicService.SHUFFLE_MODE_NONE)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,11 +16,10 @@ package code.name.monkey.retromusic.loaders
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.provider.MediaStore.Audio.AudioColumns
|
import android.provider.MediaStore.Audio.AudioColumns
|
||||||
import code.name.monkey.retromusic.App
|
|
||||||
import code.name.monkey.retromusic.helper.SortOrder
|
import code.name.monkey.retromusic.helper.SortOrder
|
||||||
import code.name.monkey.retromusic.model.Album
|
import code.name.monkey.retromusic.model.Album
|
||||||
import code.name.monkey.retromusic.model.Song
|
import code.name.monkey.retromusic.model.Song
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.collections.ArrayList
|
import kotlin.collections.ArrayList
|
||||||
|
|
||||||
|
@ -40,7 +39,7 @@ object AlbumLoader {
|
||||||
context,
|
context,
|
||||||
AudioColumns.ALBUM + " LIKE ?",
|
AudioColumns.ALBUM + " LIKE ?",
|
||||||
arrayOf("%$query%"),
|
arrayOf("%$query%"),
|
||||||
getSongLoaderSortOrder(context)
|
getSongLoaderSortOrder()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return splitIntoAlbums(songs)
|
return splitIntoAlbums(songs)
|
||||||
|
@ -56,7 +55,7 @@ object AlbumLoader {
|
||||||
context,
|
context,
|
||||||
AudioColumns.ALBUM_ID + "=?",
|
AudioColumns.ALBUM_ID + "=?",
|
||||||
arrayOf(albumId.toString()),
|
arrayOf(albumId.toString()),
|
||||||
getSongLoaderSortOrder(context)
|
getSongLoaderSortOrder()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
val album = Album(songs)
|
val album = Album(songs)
|
||||||
|
@ -72,7 +71,7 @@ object AlbumLoader {
|
||||||
context,
|
context,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
getSongLoaderSortOrder(context)
|
getSongLoaderSortOrder()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return splitIntoAlbums(songs)
|
return splitIntoAlbums(songs)
|
||||||
|
@ -108,7 +107,7 @@ object AlbumLoader {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun sortSongsByTrackNumber(album: Album) {
|
private fun sortSongsByTrackNumber(album: Album) {
|
||||||
when (PreferenceUtil.getInstance(App.getContext()).albumDetailSongSortOrder) {
|
when (PreferenceUtilKT.albumDetailSongSortOrder) {
|
||||||
SortOrder.AlbumSongSortOrder.SONG_TRACK_LIST -> album.songs?.sortWith(Comparator { o1, o2 ->
|
SortOrder.AlbumSongSortOrder.SONG_TRACK_LIST -> album.songs?.sortWith(Comparator { o1, o2 ->
|
||||||
o1.trackNumber.compareTo(
|
o1.trackNumber.compareTo(
|
||||||
o2.trackNumber
|
o2.trackNumber
|
||||||
|
@ -132,8 +131,8 @@ object AlbumLoader {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getSongLoaderSortOrder(context: Context): String {
|
private fun getSongLoaderSortOrder(): String {
|
||||||
return PreferenceUtil.getInstance(context).albumSortOrder + ", " +
|
return PreferenceUtilKT.albumSortOrder + ", " +
|
||||||
PreferenceUtil.getInstance(context).albumSongSortOrder
|
PreferenceUtilKT.albumSongSortOrder
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,13 +18,13 @@ import android.content.Context
|
||||||
import android.provider.MediaStore.Audio.AudioColumns
|
import android.provider.MediaStore.Audio.AudioColumns
|
||||||
import code.name.monkey.retromusic.model.Album
|
import code.name.monkey.retromusic.model.Album
|
||||||
import code.name.monkey.retromusic.model.Artist
|
import code.name.monkey.retromusic.model.Artist
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||||
|
|
||||||
object ArtistLoader {
|
object ArtistLoader {
|
||||||
private fun getSongLoaderSortOrder(context: Context): String {
|
private fun getSongLoaderSortOrder(context: Context): String {
|
||||||
return PreferenceUtil.getInstance(context).artistSortOrder + ", " +
|
return PreferenceUtilKT.artistSortOrder + ", " +
|
||||||
PreferenceUtil.getInstance(context).artistAlbumSortOrder + ", " +
|
PreferenceUtilKT.artistAlbumSortOrder + ", " +
|
||||||
PreferenceUtil.getInstance(context).artistSongSortOrder
|
PreferenceUtilKT.artistSongSortOrder
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getAllArtists(context: Context): ArrayList<Artist> {
|
fun getAllArtists(context: Context): ArrayList<Artist> {
|
||||||
|
|
|
@ -23,7 +23,7 @@ import code.name.monkey.retromusic.Constants.BASE_SELECTION
|
||||||
import code.name.monkey.retromusic.Constants.baseProjection
|
import code.name.monkey.retromusic.Constants.baseProjection
|
||||||
import code.name.monkey.retromusic.model.Genre
|
import code.name.monkey.retromusic.model.Genre
|
||||||
import code.name.monkey.retromusic.model.Song
|
import code.name.monkey.retromusic.model.Song
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||||
|
|
||||||
|
|
||||||
object GenreLoader {
|
object GenreLoader {
|
||||||
|
@ -98,7 +98,7 @@ object GenreLoader {
|
||||||
baseProjection,
|
baseProjection,
|
||||||
BASE_SELECTION,
|
BASE_SELECTION,
|
||||||
null,
|
null,
|
||||||
PreferenceUtil.getInstance(context).songSortOrder
|
PreferenceUtilKT.songSortOrder
|
||||||
)
|
)
|
||||||
} catch (e: SecurityException) {
|
} catch (e: SecurityException) {
|
||||||
return null
|
return null
|
||||||
|
@ -154,7 +154,7 @@ object GenreLoader {
|
||||||
projection,
|
projection,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
PreferenceUtil.getInstance(context).genreSortOrder
|
PreferenceUtilKT.genreSortOrder
|
||||||
)
|
)
|
||||||
} catch (e: SecurityException) {
|
} catch (e: SecurityException) {
|
||||||
return null
|
return null
|
||||||
|
|
|
@ -20,7 +20,7 @@ import android.provider.MediaStore
|
||||||
import code.name.monkey.retromusic.model.Album
|
import code.name.monkey.retromusic.model.Album
|
||||||
import code.name.monkey.retromusic.model.Artist
|
import code.name.monkey.retromusic.model.Artist
|
||||||
import code.name.monkey.retromusic.model.Song
|
import code.name.monkey.retromusic.model.Song
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by hemanths on 16/08/17.
|
* Created by hemanths on 16/08/17.
|
||||||
|
@ -33,8 +33,7 @@ object LastAddedSongsLoader {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun makeLastAddedCursor(context: Context): Cursor? {
|
private fun makeLastAddedCursor(context: Context): Cursor? {
|
||||||
val cutoff = PreferenceUtil.getInstance(context).lastAddedCutoff
|
val cutoff = PreferenceUtilKT.lastAddedCutoff
|
||||||
|
|
||||||
return SongLoader.makeSongCursor(
|
return SongLoader.makeSongCursor(
|
||||||
context,
|
context,
|
||||||
MediaStore.Audio.Media.DATE_ADDED + ">?",
|
MediaStore.Audio.Media.DATE_ADDED + ">?",
|
||||||
|
|
|
@ -22,7 +22,8 @@ import code.name.monkey.retromusic.Constants.BASE_SELECTION
|
||||||
import code.name.monkey.retromusic.Constants.baseProjection
|
import code.name.monkey.retromusic.Constants.baseProjection
|
||||||
import code.name.monkey.retromusic.model.Song
|
import code.name.monkey.retromusic.model.Song
|
||||||
import code.name.monkey.retromusic.providers.BlacklistStore
|
import code.name.monkey.retromusic.providers.BlacklistStore
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
|
||||||
|
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -106,7 +107,7 @@ object SongLoader {
|
||||||
context: Context,
|
context: Context,
|
||||||
selection: String?,
|
selection: String?,
|
||||||
selectionValues: Array<String>?,
|
selectionValues: Array<String>?,
|
||||||
sortOrder: String = PreferenceUtil.getInstance(context).songSortOrder
|
sortOrder: String = PreferenceUtilKT.songSortOrder
|
||||||
): Cursor? {
|
): Cursor? {
|
||||||
var selectionFinal = selection
|
var selectionFinal = selection
|
||||||
var selectionValuesFinal = selectionValues
|
var selectionValuesFinal = selectionValues
|
||||||
|
@ -128,7 +129,7 @@ object SongLoader {
|
||||||
MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
|
MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
|
||||||
baseProjection,
|
baseProjection,
|
||||||
selectionFinal + " AND " + MediaStore.Audio.Media.DURATION + ">= " +
|
selectionFinal + " AND " + MediaStore.Audio.Media.DURATION + ">= " +
|
||||||
(PreferenceUtil.getInstance(context).filterLength * 1000),
|
(PreferenceUtilKT.filterLength * 1000),
|
||||||
selectionValuesFinal,
|
selectionValuesFinal,
|
||||||
sortOrder
|
sortOrder
|
||||||
)
|
)
|
||||||
|
|
|
@ -37,7 +37,8 @@ import code.name.monkey.retromusic.extensions.colorControlNormal
|
||||||
import code.name.monkey.retromusic.fragments.AlbumCoverStyle
|
import code.name.monkey.retromusic.fragments.AlbumCoverStyle
|
||||||
import code.name.monkey.retromusic.fragments.AlbumCoverStyle.*
|
import code.name.monkey.retromusic.fragments.AlbumCoverStyle.*
|
||||||
import code.name.monkey.retromusic.util.NavigationUtil
|
import code.name.monkey.retromusic.util.NavigationUtil
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
|
||||||
|
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||||
import code.name.monkey.retromusic.util.ViewUtil
|
import code.name.monkey.retromusic.util.ViewUtil
|
||||||
import com.afollestad.materialdialogs.MaterialDialog
|
import com.afollestad.materialdialogs.MaterialDialog
|
||||||
import com.afollestad.materialdialogs.customview.customView
|
import com.afollestad.materialdialogs.customview.customView
|
||||||
|
@ -80,11 +81,11 @@ class AlbumCoverStylePreferenceDialog : PreferenceDialogFragmentCompat(),
|
||||||
viewPager.adapter = AlbumCoverStyleAdapter(requireContext())
|
viewPager.adapter = AlbumCoverStyleAdapter(requireContext())
|
||||||
viewPager.addOnPageChangeListener(this)
|
viewPager.addOnPageChangeListener(this)
|
||||||
viewPager.pageMargin = ViewUtil.convertDpToPixel(32f, resources).toInt()
|
viewPager.pageMargin = ViewUtil.convertDpToPixel(32f, resources).toInt()
|
||||||
viewPager.currentItem = PreferenceUtil.getInstance(requireContext()).albumCoverStyle.ordinal
|
viewPager.currentItem = PreferenceUtilKT.albumCoverStyle.ordinal
|
||||||
|
|
||||||
return MaterialDialog(requireActivity()).show {
|
return MaterialDialog(requireActivity()).show {
|
||||||
title(R.string.pref_title_album_cover_style)
|
title(R.string.pref_title_album_cover_style)
|
||||||
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
|
||||||
positiveButton(R.string.set) {
|
positiveButton(R.string.set) {
|
||||||
val coverStyle = values()[viewPagerPosition]
|
val coverStyle = values()[viewPagerPosition]
|
||||||
if (isAlbumCoverStyle(coverStyle)) {
|
if (isAlbumCoverStyle(coverStyle)) {
|
||||||
|
@ -92,9 +93,8 @@ class AlbumCoverStylePreferenceDialog : PreferenceDialogFragmentCompat(),
|
||||||
Toast.makeText(context, result, Toast.LENGTH_SHORT).show()
|
Toast.makeText(context, result, Toast.LENGTH_SHORT).show()
|
||||||
NavigationUtil.goToProVersion(requireActivity())
|
NavigationUtil.goToProVersion(requireActivity())
|
||||||
} else {
|
} else {
|
||||||
PreferenceUtil.getInstance(requireContext()).albumCoverStyle = coverStyle
|
PreferenceUtilKT.albumCoverStyle = coverStyle
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
negativeButton(android.R.string.cancel)
|
negativeButton(android.R.string.cancel)
|
||||||
customView(view = view, scrollable = false, noVerticalPadding = false)
|
customView(view = view, scrollable = false, noVerticalPadding = false)
|
||||||
|
|
|
@ -27,7 +27,7 @@ import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.dialogs.BlacklistFolderChooserDialog
|
import code.name.monkey.retromusic.dialogs.BlacklistFolderChooserDialog
|
||||||
import code.name.monkey.retromusic.extensions.colorControlNormal
|
import code.name.monkey.retromusic.extensions.colorControlNormal
|
||||||
import code.name.monkey.retromusic.providers.BlacklistStore
|
import code.name.monkey.retromusic.providers.BlacklistStore
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
|
||||||
import com.afollestad.materialdialogs.MaterialDialog
|
import com.afollestad.materialdialogs.MaterialDialog
|
||||||
import com.afollestad.materialdialogs.list.listItems
|
import com.afollestad.materialdialogs.list.listItems
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
@ -63,7 +63,7 @@ class BlacklistPreferenceDialog : DialogFragment(), BlacklistFolderChooserDialog
|
||||||
refreshBlacklistData()
|
refreshBlacklistData()
|
||||||
return MaterialDialog(requireContext()).show {
|
return MaterialDialog(requireContext()).show {
|
||||||
title(R.string.blacklist)
|
title(R.string.blacklist)
|
||||||
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
|
||||||
positiveButton(android.R.string.ok) {
|
positiveButton(android.R.string.ok) {
|
||||||
dismiss()
|
dismiss()
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ class BlacklistPreferenceDialog : DialogFragment(), BlacklistFolderChooserDialog
|
||||||
MaterialDialog(requireContext()).show {
|
MaterialDialog(requireContext()).show {
|
||||||
title(code.name.monkey.retromusic.R.string.clear_blacklist)
|
title(code.name.monkey.retromusic.R.string.clear_blacklist)
|
||||||
message(code.name.monkey.retromusic.R.string.do_you_want_to_clear_the_blacklist)
|
message(code.name.monkey.retromusic.R.string.do_you_want_to_clear_the_blacklist)
|
||||||
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
|
||||||
positiveButton(code.name.monkey.retromusic.R.string.clear_action) {
|
positiveButton(code.name.monkey.retromusic.R.string.clear_action) {
|
||||||
BlacklistStore.getInstance(requireContext()).clear()
|
BlacklistStore.getInstance(requireContext()).clear()
|
||||||
refreshBlacklistData()
|
refreshBlacklistData()
|
||||||
|
@ -86,7 +86,7 @@ class BlacklistPreferenceDialog : DialogFragment(), BlacklistFolderChooserDialog
|
||||||
}
|
}
|
||||||
listItems(items = paths, waitForPositiveButton = false) { _, _, text ->
|
listItems(items = paths, waitForPositiveButton = false) { _, _, text ->
|
||||||
MaterialDialog(requireContext()).show {
|
MaterialDialog(requireContext()).show {
|
||||||
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
|
||||||
title(code.name.monkey.retromusic.R.string.remove_from_blacklist)
|
title(code.name.monkey.retromusic.R.string.remove_from_blacklist)
|
||||||
message(
|
message(
|
||||||
text = HtmlCompat.fromHtml(
|
text = HtmlCompat.fromHtml(
|
||||||
|
|
|
@ -18,6 +18,7 @@ import android.app.Dialog
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
|
import android.view.LayoutInflater
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.core.graphics.BlendModeColorFilterCompat
|
import androidx.core.graphics.BlendModeColorFilterCompat
|
||||||
import androidx.core.graphics.BlendModeCompat.SRC_IN
|
import androidx.core.graphics.BlendModeCompat.SRC_IN
|
||||||
|
@ -29,10 +30,10 @@ import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.adapter.CategoryInfoAdapter
|
import code.name.monkey.retromusic.adapter.CategoryInfoAdapter
|
||||||
import code.name.monkey.retromusic.extensions.colorControlNormal
|
import code.name.monkey.retromusic.extensions.colorControlNormal
|
||||||
import code.name.monkey.retromusic.model.CategoryInfo
|
import code.name.monkey.retromusic.model.CategoryInfo
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
|
||||||
|
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||||
import com.afollestad.materialdialogs.MaterialDialog
|
import com.afollestad.materialdialogs.MaterialDialog
|
||||||
import com.afollestad.materialdialogs.customview.customView
|
import com.afollestad.materialdialogs.customview.customView
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
class LibraryPreference @JvmOverloads constructor(
|
class LibraryPreference @JvmOverloads constructor(
|
||||||
context: Context,
|
context: Context,
|
||||||
|
@ -59,17 +60,9 @@ class LibraryPreferenceDialog : PreferenceDialogFragmentCompat() {
|
||||||
lateinit var adapter: CategoryInfoAdapter
|
lateinit var adapter: CategoryInfoAdapter
|
||||||
|
|
||||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||||
val view = requireActivity().layoutInflater.inflate(
|
val view = LayoutInflater.from(requireContext())
|
||||||
R.layout.preference_dialog_library_categories,
|
.inflate(R.layout.preference_dialog_library_categories, null)
|
||||||
null
|
adapter = CategoryInfoAdapter(PreferenceUtilKT.libraryCategory)
|
||||||
)
|
|
||||||
|
|
||||||
val categoryInfos: List<CategoryInfo> = if (savedInstanceState != null) {
|
|
||||||
savedInstanceState.getParcelableArrayList(PreferenceUtil.LIBRARY_CATEGORIES)!!
|
|
||||||
} else {
|
|
||||||
PreferenceUtil.getInstance(requireContext()).libraryCategoryInfos
|
|
||||||
}
|
|
||||||
adapter = CategoryInfoAdapter(categoryInfos)
|
|
||||||
|
|
||||||
val recyclerView = view.findViewById<RecyclerView>(R.id.recycler_view)
|
val recyclerView = view.findViewById<RecyclerView>(R.id.recycler_view)
|
||||||
recyclerView.layoutManager = LinearLayoutManager(activity)
|
recyclerView.layoutManager = LinearLayoutManager(activity)
|
||||||
|
@ -79,7 +72,6 @@ class LibraryPreferenceDialog : PreferenceDialogFragmentCompat() {
|
||||||
|
|
||||||
return MaterialDialog(requireContext())
|
return MaterialDialog(requireContext())
|
||||||
.title(R.string.library_categories)
|
.title(R.string.library_categories)
|
||||||
.cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
|
||||||
.customView(view = view)
|
.customView(view = view)
|
||||||
.positiveButton(android.R.string.ok) {
|
.positiveButton(android.R.string.ok) {
|
||||||
updateCategories(adapter.categoryInfos)
|
updateCategories(adapter.categoryInfos)
|
||||||
|
@ -89,27 +81,18 @@ class LibraryPreferenceDialog : PreferenceDialogFragmentCompat() {
|
||||||
dismiss()
|
dismiss()
|
||||||
}
|
}
|
||||||
.neutralButton(R.string.reset_action) {
|
.neutralButton(R.string.reset_action) {
|
||||||
adapter.categoryInfos =
|
adapter.categoryInfos = PreferenceUtilKT.defaultCategories
|
||||||
PreferenceUtil.getInstance(requireContext()).defaultLibraryCategoryInfos
|
|
||||||
}
|
}
|
||||||
.noAutoDismiss()
|
.noAutoDismiss()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onSaveInstanceState(outState: Bundle) {
|
|
||||||
super.onSaveInstanceState(outState)
|
|
||||||
outState.putParcelableArrayList(
|
|
||||||
PreferenceUtil.LIBRARY_CATEGORIES,
|
|
||||||
ArrayList(adapter.categoryInfos)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun updateCategories(categories: List<CategoryInfo>) {
|
private fun updateCategories(categories: List<CategoryInfo>) {
|
||||||
if (getSelected(categories) == 0) return
|
if (getSelected(categories) == 0) return
|
||||||
if (getSelected(categories) > 5) {
|
if (getSelected(categories) > 5) {
|
||||||
Toast.makeText(context, "Not more than 5 items", Toast.LENGTH_SHORT).show()
|
Toast.makeText(context, "Not more than 5 items", Toast.LENGTH_SHORT).show()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
PreferenceUtil.getInstance(requireContext()).libraryCategoryInfos = categories
|
PreferenceUtilKT.libraryCategory = categories
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getSelected(categories: List<CategoryInfo>): Int {
|
private fun getSelected(categories: List<CategoryInfo>): Int {
|
||||||
|
@ -122,13 +105,8 @@ class LibraryPreferenceDialog : PreferenceDialogFragmentCompat() {
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
fun newInstance(): LibraryPreferenceDialog {
|
||||||
fun newInstance(key: String): LibraryPreferenceDialog {
|
return LibraryPreferenceDialog()
|
||||||
val bundle = Bundle()
|
|
||||||
bundle.putString(ARG_KEY, key)
|
|
||||||
val fragment = LibraryPreferenceDialog()
|
|
||||||
fragment.arguments = bundle
|
|
||||||
return fragment
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -26,7 +26,6 @@ import androidx.preference.PreferenceDialogFragmentCompat
|
||||||
import code.name.monkey.appthemehelper.ThemeStore
|
import code.name.monkey.appthemehelper.ThemeStore
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
import code.name.monkey.retromusic.extensions.colorControlNormal
|
import code.name.monkey.retromusic.extensions.colorControlNormal
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
|
||||||
import com.afollestad.materialdialogs.MaterialDialog
|
import com.afollestad.materialdialogs.MaterialDialog
|
||||||
import com.afollestad.materialdialogs.WhichButton
|
import com.afollestad.materialdialogs.WhichButton
|
||||||
import com.afollestad.materialdialogs.actions.getActionButton
|
import com.afollestad.materialdialogs.actions.getActionButton
|
||||||
|
@ -76,7 +75,6 @@ class MaterialListPreferenceDialog : PreferenceDialogFragmentCompat() {
|
||||||
materialDialog = MaterialDialog(requireContext())
|
materialDialog = MaterialDialog(requireContext())
|
||||||
.title(text = materialListPreference.title.toString())
|
.title(text = materialListPreference.title.toString())
|
||||||
.positiveButton(R.string.set)
|
.positiveButton(R.string.set)
|
||||||
.cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
|
||||||
.listItemsSingleChoice(
|
.listItemsSingleChoice(
|
||||||
items = entries,
|
items = entries,
|
||||||
initialSelection = position,
|
initialSelection = position,
|
||||||
|
|
|
@ -36,7 +36,7 @@ import code.name.monkey.retromusic.extensions.colorControlNormal
|
||||||
import code.name.monkey.retromusic.fragments.NowPlayingScreen
|
import code.name.monkey.retromusic.fragments.NowPlayingScreen
|
||||||
import code.name.monkey.retromusic.fragments.NowPlayingScreen.*
|
import code.name.monkey.retromusic.fragments.NowPlayingScreen.*
|
||||||
import code.name.monkey.retromusic.util.NavigationUtil
|
import code.name.monkey.retromusic.util.NavigationUtil
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||||
import code.name.monkey.retromusic.util.ViewUtil
|
import code.name.monkey.retromusic.util.ViewUtil
|
||||||
import com.afollestad.materialdialogs.MaterialDialog
|
import com.afollestad.materialdialogs.MaterialDialog
|
||||||
import com.afollestad.materialdialogs.customview.customView
|
import com.afollestad.materialdialogs.customview.customView
|
||||||
|
@ -89,9 +89,7 @@ class NowPlayingScreenPreferenceDialog : PreferenceDialogFragmentCompat(),
|
||||||
viewPager.adapter = NowPlayingScreenAdapter(requireContext())
|
viewPager.adapter = NowPlayingScreenAdapter(requireContext())
|
||||||
viewPager.addOnPageChangeListener(this)
|
viewPager.addOnPageChangeListener(this)
|
||||||
viewPager.pageMargin = ViewUtil.convertDpToPixel(32f, resources).toInt()
|
viewPager.pageMargin = ViewUtil.convertDpToPixel(32f, resources).toInt()
|
||||||
viewPager.currentItem =
|
viewPager.currentItem = PreferenceUtilKT.nowPlayingScreen.ordinal
|
||||||
PreferenceUtil.getInstance(requireContext()).nowPlayingScreen.ordinal
|
|
||||||
|
|
||||||
|
|
||||||
return MaterialDialog(requireContext()).show {
|
return MaterialDialog(requireContext()).show {
|
||||||
title(R.string.pref_title_now_playing_screen_appearance)
|
title(R.string.pref_title_now_playing_screen_appearance)
|
||||||
|
@ -103,10 +101,10 @@ class NowPlayingScreenPreferenceDialog : PreferenceDialogFragmentCompat(),
|
||||||
Toast.makeText(context, result, Toast.LENGTH_SHORT).show()
|
Toast.makeText(context, result, Toast.LENGTH_SHORT).show()
|
||||||
NavigationUtil.goToProVersion(requireContext())
|
NavigationUtil.goToProVersion(requireContext())
|
||||||
} else {
|
} else {
|
||||||
PreferenceUtil.getInstance(requireContext()).nowPlayingScreen = nowPlayingScreen
|
PreferenceUtilKT.nowPlayingScreen = nowPlayingScreen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
|
||||||
negativeButton(android.R.string.cancel)
|
negativeButton(android.R.string.cancel)
|
||||||
customView(view = view, scrollable = false, noVerticalPadding = false)
|
customView(view = view, scrollable = false, noVerticalPadding = false)
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import code.name.monkey.retromusic.util.FileUtil;
|
import code.name.monkey.retromusic.util.FileUtil;
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil;
|
import code.name.monkey.retromusic.util.PreferenceUtilKT;
|
||||||
|
|
||||||
import static code.name.monkey.retromusic.service.MusicService.MEDIA_STORE_CHANGED;
|
import static code.name.monkey.retromusic.service.MusicService.MEDIA_STORE_CHANGED;
|
||||||
|
|
||||||
|
@ -47,13 +47,13 @@ public class BlacklistStore extends SQLiteOpenHelper {
|
||||||
public static synchronized BlacklistStore getInstance(@NonNull final Context context) {
|
public static synchronized BlacklistStore getInstance(@NonNull final Context context) {
|
||||||
if (sInstance == null) {
|
if (sInstance == null) {
|
||||||
sInstance = new BlacklistStore(context.getApplicationContext());
|
sInstance = new BlacklistStore(context.getApplicationContext());
|
||||||
if (!PreferenceUtil.getInstance(context).initializedBlacklist()) {
|
if (!PreferenceUtilKT.INSTANCE.isInitializedBlacklist()) {
|
||||||
// blacklisted by default
|
// blacklisted by default
|
||||||
sInstance.addPathImpl(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_ALARMS));
|
sInstance.addPathImpl(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_ALARMS));
|
||||||
sInstance.addPathImpl(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_NOTIFICATIONS));
|
sInstance.addPathImpl(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_NOTIFICATIONS));
|
||||||
sInstance.addPathImpl(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_RINGTONES));
|
sInstance.addPathImpl(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_RINGTONES));
|
||||||
|
|
||||||
PreferenceUtil.getInstance(context).setInitializedBlacklist();
|
PreferenceUtilKT.INSTANCE.setInitializedBlacklist(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return sInstance;
|
return sInstance;
|
||||||
|
|
|
@ -29,7 +29,7 @@ import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import code.name.monkey.retromusic.R;
|
import code.name.monkey.retromusic.R;
|
||||||
import code.name.monkey.retromusic.service.playback.Playback;
|
import code.name.monkey.retromusic.service.playback.Playback;
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil;
|
import code.name.monkey.retromusic.util.PreferenceUtilKT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Andrew Neal, Karim Abou Zeid (kabouzeid)
|
* @author Andrew Neal, Karim Abou Zeid (kabouzeid)
|
||||||
|
@ -130,7 +130,7 @@ public class MultiPlayer implements Playback, MediaPlayer.OnErrorListener, Media
|
||||||
if (path == null) {
|
if (path == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (PreferenceUtil.getInstance(context).gaplessPlayback()) {
|
if (PreferenceUtilKT.INSTANCE.isGapLessPlayback()) {
|
||||||
mNextMediaPlayer = new MediaPlayer();
|
mNextMediaPlayer = new MediaPlayer();
|
||||||
mNextMediaPlayer.setWakeMode(context, PowerManager.PARTIAL_WAKE_LOCK);
|
mNextMediaPlayer.setWakeMode(context, PowerManager.PARTIAL_WAKE_LOCK);
|
||||||
mNextMediaPlayer.setAudioSessionId(getAudioSessionId());
|
mNextMediaPlayer.setAudioSessionId(getAudioSessionId());
|
||||||
|
|
|
@ -81,9 +81,16 @@ import code.name.monkey.retromusic.service.notification.PlayingNotificationImpl;
|
||||||
import code.name.monkey.retromusic.service.notification.PlayingNotificationOreo;
|
import code.name.monkey.retromusic.service.notification.PlayingNotificationOreo;
|
||||||
import code.name.monkey.retromusic.service.playback.Playback;
|
import code.name.monkey.retromusic.service.playback.Playback;
|
||||||
import code.name.monkey.retromusic.util.MusicUtil;
|
import code.name.monkey.retromusic.util.MusicUtil;
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil;
|
import code.name.monkey.retromusic.util.PreferenceUtilKT;
|
||||||
import code.name.monkey.retromusic.util.RetroUtil;
|
import code.name.monkey.retromusic.util.RetroUtil;
|
||||||
|
|
||||||
|
import static code.name.monkey.retromusic.ConstantsKt.ALBUM_ART_ON_LOCKSCREEN;
|
||||||
|
import static code.name.monkey.retromusic.ConstantsKt.BLURRED_ALBUM_ART;
|
||||||
|
import static code.name.monkey.retromusic.ConstantsKt.CLASSIC_NOTIFICATION;
|
||||||
|
import static code.name.monkey.retromusic.ConstantsKt.COLORED_NOTIFICATION;
|
||||||
|
import static code.name.monkey.retromusic.ConstantsKt.GAPLESS_PLAYBACK;
|
||||||
|
import static code.name.monkey.retromusic.ConstantsKt.TOGGLE_HEADSET;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Karim Abou Zeid (kabouzeid), Andrew Neal
|
* @author Karim Abou Zeid (kabouzeid), Andrew Neal
|
||||||
*/
|
*/
|
||||||
|
@ -250,7 +257,7 @@ public class MusicService extends Service implements
|
||||||
String action = intent.getAction();
|
String action = intent.getAction();
|
||||||
if (action != null) {
|
if (action != null) {
|
||||||
if (BluetoothDevice.ACTION_ACL_CONNECTED.equals(action) &&
|
if (BluetoothDevice.ACTION_ACL_CONNECTED.equals(action) &&
|
||||||
PreferenceUtil.getInstance(context).bluetoothSpeaker()) {
|
PreferenceUtilKT.INSTANCE.isBluetoothSpeaker()) {
|
||||||
if (VERSION.SDK_INT >= VERSION_CODES.M) {
|
if (VERSION.SDK_INT >= VERSION_CODES.M) {
|
||||||
if (getAudioManager().getDevices(AudioManager.GET_DEVICES_OUTPUTS).length > 0) {
|
if (getAudioManager().getDevices(AudioManager.GET_DEVICES_OUTPUTS).length > 0) {
|
||||||
play();
|
play();
|
||||||
|
@ -381,7 +388,7 @@ public class MusicService extends Service implements
|
||||||
getContentResolver()
|
getContentResolver()
|
||||||
.registerContentObserver(MediaStore.Audio.Playlists.INTERNAL_CONTENT_URI, true, mediaStoreObserver);
|
.registerContentObserver(MediaStore.Audio.Playlists.INTERNAL_CONTENT_URI, true, mediaStoreObserver);
|
||||||
|
|
||||||
PreferenceUtil.getInstance(this).registerOnSharedPreferenceChangedListener(this);
|
PreferenceUtilKT.INSTANCE.registerOnSharedPreferenceChangedListener(this);
|
||||||
|
|
||||||
restoreState();
|
restoreState();
|
||||||
|
|
||||||
|
@ -411,7 +418,7 @@ public class MusicService extends Service implements
|
||||||
quit();
|
quit();
|
||||||
releaseResources();
|
releaseResources();
|
||||||
getContentResolver().unregisterContentObserver(mediaStoreObserver);
|
getContentResolver().unregisterContentObserver(mediaStoreObserver);
|
||||||
PreferenceUtil.getInstance(this).unregisterOnSharedPreferenceChangedListener(this);
|
PreferenceUtilKT.INSTANCE.unregisterOnSharedPreferenceChangedListener(this);
|
||||||
wakeLock.release();
|
wakeLock.release();
|
||||||
|
|
||||||
sendBroadcast(new Intent("code.name.monkey.retromusic.RETRO_MUSIC_SERVICE_DESTROYED"));
|
sendBroadcast(new Intent("code.name.monkey.retromusic.RETRO_MUSIC_SERVICE_DESTROYED"));
|
||||||
|
@ -656,8 +663,8 @@ public class MusicService extends Service implements
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initNotification() {
|
public void initNotification() {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && !PreferenceUtil.getInstance(this)
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N &&
|
||||||
.classicNotification()) {
|
!PreferenceUtilKT.INSTANCE.isClassicNotification()) {
|
||||||
playingNotification = new PlayingNotificationImpl();
|
playingNotification = new PlayingNotificationImpl();
|
||||||
} else {
|
} else {
|
||||||
playingNotification = new PlayingNotificationOreo();
|
playingNotification = new PlayingNotificationOreo();
|
||||||
|
@ -719,7 +726,7 @@ public class MusicService extends Service implements
|
||||||
@Override
|
@Override
|
||||||
public void onSharedPreferenceChanged(@NonNull SharedPreferences sharedPreferences, @NonNull String key) {
|
public void onSharedPreferenceChanged(@NonNull SharedPreferences sharedPreferences, @NonNull String key) {
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case PreferenceUtil.GAPLESS_PLAYBACK:
|
case GAPLESS_PLAYBACK:
|
||||||
if (sharedPreferences.getBoolean(key, false)) {
|
if (sharedPreferences.getBoolean(key, false)) {
|
||||||
prepareNext();
|
prepareNext();
|
||||||
} else {
|
} else {
|
||||||
|
@ -728,18 +735,18 @@ public class MusicService extends Service implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PreferenceUtil.ALBUM_ART_ON_LOCKSCREEN:
|
case ALBUM_ART_ON_LOCKSCREEN:
|
||||||
case PreferenceUtil.BLURRED_ALBUM_ART:
|
case BLURRED_ALBUM_ART:
|
||||||
updateMediaSessionMetaData();
|
updateMediaSessionMetaData();
|
||||||
break;
|
break;
|
||||||
case PreferenceUtil.COLORED_NOTIFICATION:
|
case COLORED_NOTIFICATION:
|
||||||
updateNotification();
|
updateNotification();
|
||||||
break;
|
break;
|
||||||
case PreferenceUtil.CLASSIC_NOTIFICATION:
|
case CLASSIC_NOTIFICATION:
|
||||||
initNotification();
|
initNotification();
|
||||||
updateNotification();
|
updateNotification();
|
||||||
break;
|
break;
|
||||||
case PreferenceUtil.TOGGLE_HEADSET:
|
case TOGGLE_HEADSET:
|
||||||
registerHeadsetEvents();
|
registerHeadsetEvents();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1103,13 +1110,13 @@ public class MusicService extends Service implements
|
||||||
.putBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART, null)
|
.putBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART, null)
|
||||||
.putLong(MediaMetadataCompat.METADATA_KEY_NUM_TRACKS, getPlayingQueue().size());
|
.putLong(MediaMetadataCompat.METADATA_KEY_NUM_TRACKS, getPlayingQueue().size());
|
||||||
|
|
||||||
if (PreferenceUtil.getInstance(this).albumArtOnLockscreen()) {
|
if (PreferenceUtilKT.INSTANCE.isAlbumArtOnLockScreen()) {
|
||||||
final Point screenSize = RetroUtil.getScreenSize(MusicService.this);
|
final Point screenSize = RetroUtil.getScreenSize(MusicService.this);
|
||||||
final BitmapRequestBuilder<?, Bitmap> request = SongGlideRequest.Builder
|
final BitmapRequestBuilder<?, Bitmap> request = SongGlideRequest.Builder
|
||||||
.from(Glide.with(MusicService.this), song)
|
.from(Glide.with(MusicService.this), song)
|
||||||
.checkIgnoreMediaStore(MusicService.this)
|
.checkIgnoreMediaStore(MusicService.this)
|
||||||
.asBitmap().build();
|
.asBitmap().build();
|
||||||
if (PreferenceUtil.getInstance(this).blurredAlbumArt()) {
|
if (PreferenceUtilKT.INSTANCE.isBlurredAlbumArt()) {
|
||||||
request.transform(new BlurTransformation.Builder(MusicService.this).build());
|
request.transform(new BlurTransformation.Builder(MusicService.this).build());
|
||||||
}
|
}
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
|
@ -1252,7 +1259,7 @@ public class MusicService extends Service implements
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerHeadsetEvents() {
|
private void registerHeadsetEvents() {
|
||||||
if (!headsetReceiverRegistered && PreferenceUtil.getInstance(this).getHeadsetPlugged()) {
|
if (!headsetReceiverRegistered && PreferenceUtilKT.INSTANCE.isHeadsetPlugged()) {
|
||||||
registerReceiver(headsetReceiver, headsetReceiverIntentFilter);
|
registerReceiver(headsetReceiver, headsetReceiverIntentFilter);
|
||||||
headsetReceiverRegistered = true;
|
headsetReceiverRegistered = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
|
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil;
|
import code.name.monkey.retromusic.util.PreferenceUtilKT;
|
||||||
|
|
||||||
import static code.name.monkey.retromusic.service.MusicService.DUCK;
|
import static code.name.monkey.retromusic.service.MusicService.DUCK;
|
||||||
import static code.name.monkey.retromusic.service.MusicService.META_CHANGED;
|
import static code.name.monkey.retromusic.service.MusicService.META_CHANGED;
|
||||||
|
@ -52,7 +52,7 @@ class PlaybackHandler extends Handler {
|
||||||
|
|
||||||
switch (msg.what) {
|
switch (msg.what) {
|
||||||
case MusicService.DUCK:
|
case MusicService.DUCK:
|
||||||
if (PreferenceUtil.getInstance(service).audioDucking()) {
|
if (PreferenceUtilKT.INSTANCE.isAudioDucking()) {
|
||||||
currentDuckVolume -= .05f;
|
currentDuckVolume -= .05f;
|
||||||
if (currentDuckVolume > .2f) {
|
if (currentDuckVolume > .2f) {
|
||||||
sendEmptyMessageDelayed(DUCK, 10);
|
sendEmptyMessageDelayed(DUCK, 10);
|
||||||
|
@ -66,7 +66,7 @@ class PlaybackHandler extends Handler {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MusicService.UNDUCK:
|
case MusicService.UNDUCK:
|
||||||
if (PreferenceUtil.getInstance(service).audioDucking()) {
|
if (PreferenceUtilKT.INSTANCE.isAudioDucking()) {
|
||||||
currentDuckVolume += .03f;
|
currentDuckVolume += .03f;
|
||||||
if (currentDuckVolume < 1f) {
|
if (currentDuckVolume < 1f) {
|
||||||
sendEmptyMessageDelayed(MusicService.UNDUCK, 10);
|
sendEmptyMessageDelayed(MusicService.UNDUCK, 10);
|
||||||
|
|
|
@ -32,7 +32,7 @@ import code.name.monkey.retromusic.glide.palette.BitmapPaletteWrapper
|
||||||
import code.name.monkey.retromusic.service.MusicService
|
import code.name.monkey.retromusic.service.MusicService
|
||||||
import code.name.monkey.retromusic.service.MusicService.*
|
import code.name.monkey.retromusic.service.MusicService.*
|
||||||
import code.name.monkey.retromusic.util.MusicUtil
|
import code.name.monkey.retromusic.util.MusicUtil
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||||
import code.name.monkey.retromusic.util.RetroColorUtil
|
import code.name.monkey.retromusic.util.RetroColorUtil
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import com.bumptech.glide.request.animation.GlideAnimation
|
import com.bumptech.glide.request.animation.GlideAnimation
|
||||||
|
@ -149,9 +149,8 @@ class PlayingNotificationImpl : PlayingNotification() {
|
||||||
.setShowActionsInCompactView(1, 2, 3)
|
.setShowActionsInCompactView(1, 2, 3)
|
||||||
)
|
)
|
||||||
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
|
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
|
||||||
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.O && PreferenceUtil.getInstance(
|
if (Build.VERSION.SDK_INT <=
|
||||||
service
|
Build.VERSION_CODES.O && PreferenceUtilKT.isColoredNotification
|
||||||
).coloredNotification()
|
|
||||||
) {
|
) {
|
||||||
builder.color = color
|
builder.color = color
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ import android.graphics.Color
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
import android.widget.RemoteViews
|
import android.widget.RemoteViews
|
||||||
import androidx.core.app.NotificationCompat
|
import androidx.core.app.NotificationCompat
|
||||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
import code.name.monkey.appthemehelper.util.ATHUtil.resolveColor
|
||||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||||
import code.name.monkey.appthemehelper.util.MaterialValueHelper
|
import code.name.monkey.appthemehelper.util.MaterialValueHelper
|
||||||
import code.name.monkey.retromusic.R
|
import code.name.monkey.retromusic.R
|
||||||
|
@ -33,7 +33,7 @@ import code.name.monkey.retromusic.glide.palette.BitmapPaletteWrapper
|
||||||
import code.name.monkey.retromusic.model.Song
|
import code.name.monkey.retromusic.model.Song
|
||||||
import code.name.monkey.retromusic.service.MusicService
|
import code.name.monkey.retromusic.service.MusicService
|
||||||
import code.name.monkey.retromusic.service.MusicService.*
|
import code.name.monkey.retromusic.service.MusicService.*
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||||
import code.name.monkey.retromusic.util.RetroUtil
|
import code.name.monkey.retromusic.util.RetroUtil
|
||||||
import code.name.monkey.retromusic.util.RetroUtil.createBitmap
|
import code.name.monkey.retromusic.util.RetroUtil.createBitmap
|
||||||
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
||||||
|
@ -123,7 +123,7 @@ class PlayingNotificationOreo : PlayingNotification() {
|
||||||
super.onLoadFailed(e, errorDrawable)
|
super.onLoadFailed(e, errorDrawable)
|
||||||
update(
|
update(
|
||||||
null,
|
null,
|
||||||
ATHUtil.resolveColor(service, R.attr.colorSurface, Color.WHITE)
|
resolveColor(service, R.attr.colorSurface, Color.WHITE)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,9 +143,8 @@ class PlayingNotificationOreo : PlayingNotification() {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!PreferenceUtil.getInstance(service).coloredNotification()) {
|
if (!PreferenceUtilKT.isColoredNotification) {
|
||||||
bgColorFinal =
|
bgColorFinal = resolveColor(service, R.attr.colorPrimary, Color.WHITE)
|
||||||
ATHUtil.resolveColor(service, R.attr.colorPrimary, Color.WHITE)
|
|
||||||
}
|
}
|
||||||
setBackgroundColor(bgColorFinal)
|
setBackgroundColor(bgColorFinal)
|
||||||
setNotificationContent(ColorUtil.isColorLight(bgColorFinal))
|
setNotificationContent(ColorUtil.isColorLight(bgColorFinal))
|
||||||
|
|
|
@ -67,8 +67,6 @@ object AppRater {
|
||||||
private fun showRateDialog(context: Context, editor: SharedPreferences.Editor) {
|
private fun showRateDialog(context: Context, editor: SharedPreferences.Editor) {
|
||||||
MaterialDialog(context)
|
MaterialDialog(context)
|
||||||
.show {
|
.show {
|
||||||
|
|
||||||
cornerRadius(PreferenceUtil.getInstance(context).dialogCorner)
|
|
||||||
title(text = "Rate this App")
|
title(text = "Rate this App")
|
||||||
message(text = "If you enjoy using Retro Music, please take a moment to rate it. Thanks for your support!")
|
message(text = "If you enjoy using Retro Music, please take a moment to rate it. Thanks for your support!")
|
||||||
positiveButton(R.string.app_name) {
|
positiveButton(R.string.app_name) {
|
||||||
|
|
|
@ -1,790 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2019 Hemanth Savarala.
|
|
||||||
*
|
|
||||||
* Licensed under the GNU General Public License v3
|
|
||||||
*
|
|
||||||
* This is free software: you can redistribute it and/or modify it under
|
|
||||||
* the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
* See the GNU General Public License for more details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package code.name.monkey.retromusic.util;
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.content.SharedPreferences.Editor;
|
|
||||||
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
|
||||||
import android.content.res.TypedArray;
|
|
||||||
import android.net.ConnectivityManager;
|
|
||||||
import android.net.NetworkInfo;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
|
|
||||||
import androidx.annotation.LayoutRes;
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.annotation.StyleRes;
|
|
||||||
import androidx.viewpager.widget.ViewPager;
|
|
||||||
|
|
||||||
import com.google.android.material.bottomnavigation.LabelVisibilityMode;
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.JsonSyntaxException;
|
|
||||||
import com.google.gson.reflect.TypeToken;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import code.name.monkey.retromusic.R;
|
|
||||||
import code.name.monkey.retromusic.fragments.AlbumCoverStyle;
|
|
||||||
import code.name.monkey.retromusic.fragments.NowPlayingScreen;
|
|
||||||
import code.name.monkey.retromusic.fragments.mainactivity.FoldersFragment;
|
|
||||||
import code.name.monkey.retromusic.helper.SortOrder.AlbumSongSortOrder;
|
|
||||||
import code.name.monkey.retromusic.model.CategoryInfo;
|
|
||||||
import code.name.monkey.retromusic.model.CategoryInfo.Category;
|
|
||||||
import code.name.monkey.retromusic.transform.CascadingPageTransformer;
|
|
||||||
import code.name.monkey.retromusic.transform.DepthTransformation;
|
|
||||||
import code.name.monkey.retromusic.transform.HingeTransformation;
|
|
||||||
import code.name.monkey.retromusic.transform.HorizontalFlipTransformation;
|
|
||||||
import code.name.monkey.retromusic.transform.NormalPageTransformer;
|
|
||||||
import code.name.monkey.retromusic.transform.VerticalFlipTransformation;
|
|
||||||
import code.name.monkey.retromusic.transform.VerticalStackTransformer;
|
|
||||||
import code.name.monkey.retromusic.util.theme.ThemeMode;
|
|
||||||
|
|
||||||
import static code.name.monkey.retromusic.helper.SortOrder.AlbumSortOrder;
|
|
||||||
import static code.name.monkey.retromusic.helper.SortOrder.ArtistAlbumSortOrder;
|
|
||||||
import static code.name.monkey.retromusic.helper.SortOrder.ArtistSongSortOrder;
|
|
||||||
import static code.name.monkey.retromusic.helper.SortOrder.ArtistSortOrder;
|
|
||||||
import static code.name.monkey.retromusic.helper.SortOrder.GenreSortOrder;
|
|
||||||
import static code.name.monkey.retromusic.helper.SortOrder.SongSortOrder;
|
|
||||||
|
|
||||||
public final class PreferenceUtil {
|
|
||||||
|
|
||||||
public static final String LIBRARY_CATEGORIES = "library_categories";
|
|
||||||
public static final String EXTRA_SONG_INFO = "extra_song_info";
|
|
||||||
public static final String DESATURATED_COLOR = "desaturated_color";
|
|
||||||
public static final String BLACK_THEME = "black_theme";
|
|
||||||
public static final String KEEP_SCREEN_ON = "keep_screen_on";
|
|
||||||
public static final String TOGGLE_HOME_BANNER = "toggle_home_banner";
|
|
||||||
public static final String NOW_PLAYING_SCREEN_ID = "now_playing_screen_id";
|
|
||||||
public static final String CAROUSEL_EFFECT = "carousel_effect";
|
|
||||||
public static final String COLORED_NOTIFICATION = "colored_notification";
|
|
||||||
public static final String CLASSIC_NOTIFICATION = "classic_notification";
|
|
||||||
public static final String GAPLESS_PLAYBACK = "gapless_playback";
|
|
||||||
public static final String ALBUM_ART_ON_LOCKSCREEN = "album_art_on_lockscreen";
|
|
||||||
public static final String BLURRED_ALBUM_ART = "blurred_album_art";
|
|
||||||
public static final String NEW_BLUR_AMOUNT = "new_blur_amount";
|
|
||||||
public static final String TOGGLE_HEADSET = "toggle_headset";
|
|
||||||
public static final String GENERAL_THEME = "general_theme";
|
|
||||||
public static final String CIRCULAR_ALBUM_ART = "circular_album_art";
|
|
||||||
public static final String USER_NAME = "user_name";
|
|
||||||
public static final String TOGGLE_FULL_SCREEN = "toggle_full_screen";
|
|
||||||
public static final String TOGGLE_VOLUME = "toggle_volume";
|
|
||||||
public static final String ROUND_CORNERS = "corner_window";
|
|
||||||
public static final String TOGGLE_GENRE = "toggle_genre";
|
|
||||||
public static final String PROFILE_IMAGE_PATH = "profile_image_path";
|
|
||||||
public static final String BANNER_IMAGE_PATH = "banner_image_path";
|
|
||||||
public static final String ADAPTIVE_COLOR_APP = "adaptive_color_app";
|
|
||||||
public static final String TOGGLE_SEPARATE_LINE = "toggle_separate_line";
|
|
||||||
public static final String HOME_ARTIST_GRID_STYLE = "home_artist_grid_style";
|
|
||||||
public static final String TOGGLE_ADD_CONTROLS = "toggle_add_controls";
|
|
||||||
public static final String ALBUM_COVER_STYLE = "album_cover_style_id";
|
|
||||||
public static final String ALBUM_COVER_TRANSFORM = "album_cover_transform";
|
|
||||||
public static final String TAB_TEXT_MODE = "tab_text_mode";
|
|
||||||
public static final String LANGUAGE_NAME = "language_name";
|
|
||||||
private static final String DIALOG_CORNER = "dialog_corner";
|
|
||||||
private static final String SLEEP_TIMER_FINISH_SONG = "sleep_timer_finish_song";
|
|
||||||
private static final String ALBUM_GRID_STYLE = "album_grid_style_home";
|
|
||||||
private static final String ARTIST_GRID_STYLE = "artist_grid_style_home";
|
|
||||||
private static final String SAF_SDCARD_URI = "saf_sdcard_uri";
|
|
||||||
private static final String SONG_SORT_ORDER = "song_sort_order";
|
|
||||||
private static final String SONG_GRID_SIZE = "song_grid_size";
|
|
||||||
private static final String GENRE_SORT_ORDER = "genre_sort_order";
|
|
||||||
private static final String LAST_PAGE = "last_start_page";
|
|
||||||
private static final String BLUETOOTH_PLAYBACK = "bluetooth_playback";
|
|
||||||
private static final String INITIALIZED_BLACKLIST = "initialized_blacklist";
|
|
||||||
private static final String ARTIST_SORT_ORDER = "artist_sort_order";
|
|
||||||
private static final String ARTIST_ALBUM_SORT_ORDER = "artist_album_sort_order";
|
|
||||||
private static final String ALBUM_SORT_ORDER = "album_sort_order";
|
|
||||||
private static final String ALBUM_SONG_SORT_ORDER = "album_song_sort_order";
|
|
||||||
private static final String ARTIST_SONG_SORT_ORDER = "artist_song_sort_order";
|
|
||||||
private static final String ALBUM_GRID_SIZE = "album_grid_size";
|
|
||||||
private static final String ALBUM_GRID_SIZE_LAND = "album_grid_size_land";
|
|
||||||
private static final String SONG_GRID_SIZE_LAND = "song_grid_size_land";
|
|
||||||
private static final String ARTIST_GRID_SIZE = "artist_grid_size";
|
|
||||||
private static final String ARTIST_GRID_SIZE_LAND = "artist_grid_size_land";
|
|
||||||
private static final String COLORED_APP_SHORTCUTS = "colored_app_shortcuts";
|
|
||||||
private static final String AUDIO_DUCKING = "audio_ducking";
|
|
||||||
private static final String LAST_ADDED_CUTOFF = "last_added_interval";
|
|
||||||
private static final String LAST_SLEEP_TIMER_VALUE = "last_sleep_timer_value";
|
|
||||||
private static final String NEXT_SLEEP_TIMER_ELAPSED_REALTIME = "next_sleep_timer_elapsed_real_time";
|
|
||||||
private static final String IGNORE_MEDIA_STORE_ARTWORK = "ignore_media_store_artwork";
|
|
||||||
private static final String LAST_CHANGELOG_VERSION = "last_changelog_version";
|
|
||||||
private static final String AUTO_DOWNLOAD_IMAGES_POLICY = "auto_download_images_policy";
|
|
||||||
private static final String START_DIRECTORY = "start_directory";
|
|
||||||
private static final String LOCK_SCREEN = "lock_screen";
|
|
||||||
private static final String ALBUM_DETAIL_SONG_SORT_ORDER = "album_detail_song_sort_order";
|
|
||||||
private static final String LYRICS_OPTIONS = "lyrics_tab_position";
|
|
||||||
private static final String CHOOSE_EQUALIZER = "choose_equalizer";
|
|
||||||
private static final String TOGGLE_SHUFFLE = "toggle_shuffle";
|
|
||||||
private static final String SONG_GRID_STYLE = "song_grid_style";
|
|
||||||
private static final String PAUSE_ON_ZERO_VOLUME = "pause_on_zero_volume";
|
|
||||||
private static final String FILTER_SONG = "filter_song";
|
|
||||||
private static final String EXPAND_NOW_PLAYING_PANEL = "expand_now_playing_panel";
|
|
||||||
private static PreferenceUtil sInstance;
|
|
||||||
private final SharedPreferences mPreferences;
|
|
||||||
|
|
||||||
private PreferenceUtil(@NonNull final Context context) {
|
|
||||||
mPreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
public static PreferenceUtil getInstance(Context context) {
|
|
||||||
if (sInstance == null) {
|
|
||||||
sInstance = new PreferenceUtil(context);
|
|
||||||
}
|
|
||||||
return sInstance;
|
|
||||||
}
|
|
||||||
|
|
||||||
@StyleRes
|
|
||||||
public static int getThemeResFromPrefValue(@NonNull String themePrefValue) {
|
|
||||||
switch (themePrefValue) {
|
|
||||||
case "light":
|
|
||||||
return R.style.Theme_RetroMusic_Light;
|
|
||||||
case "dark":
|
|
||||||
default:
|
|
||||||
return R.style.Theme_RetroMusic;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isAllowedToDownloadMetadata(@NonNull Context context) {
|
|
||||||
switch (getInstance(context).autoDownloadImagesPolicy()) {
|
|
||||||
case "always":
|
|
||||||
return true;
|
|
||||||
case "only_wifi":
|
|
||||||
final ConnectivityManager connectivityManager = (ConnectivityManager) context
|
|
||||||
.getSystemService(Context.CONNECTIVITY_SERVICE);
|
|
||||||
NetworkInfo netInfo = null;
|
|
||||||
if (connectivityManager != null) {
|
|
||||||
netInfo = connectivityManager.getActiveNetworkInfo();
|
|
||||||
}
|
|
||||||
return netInfo != null && netInfo.getType() == ConnectivityManager.TYPE_WIFI && netInfo
|
|
||||||
.isConnectedOrConnecting();
|
|
||||||
case "never":
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public final boolean albumArtOnLockscreen() {
|
|
||||||
return mPreferences.getBoolean(ALBUM_ART_ON_LOCKSCREEN, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final boolean audioDucking() {
|
|
||||||
return mPreferences.getBoolean(AUDIO_DUCKING, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final String autoDownloadImagesPolicy() {
|
|
||||||
return mPreferences.getString(AUTO_DOWNLOAD_IMAGES_POLICY, "only_wifi");
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean bluetoothSpeaker() {
|
|
||||||
return mPreferences.getBoolean(BLUETOOTH_PLAYBACK, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final boolean blurredAlbumArt() {
|
|
||||||
return mPreferences.getBoolean(BLURRED_ALBUM_ART, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean carouselEffect() {
|
|
||||||
return mPreferences.getBoolean(CAROUSEL_EFFECT, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final boolean classicNotification() {
|
|
||||||
return mPreferences.getBoolean(CLASSIC_NOTIFICATION, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final boolean coloredAppShortcuts() {
|
|
||||||
return mPreferences.getBoolean(COLORED_APP_SHORTCUTS, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final boolean coloredNotification() {
|
|
||||||
return mPreferences.getBoolean(COLORED_NOTIFICATION, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean desaturatedColor() {
|
|
||||||
return mPreferences.getBoolean(DESATURATED_COLOR, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final boolean gaplessPlayback() {
|
|
||||||
return mPreferences.getBoolean(GAPLESS_PLAYBACK, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getAdaptiveColor() {
|
|
||||||
return mPreferences.getBoolean(ADAPTIVE_COLOR_APP, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final AlbumCoverStyle getAlbumCoverStyle() {
|
|
||||||
int id = mPreferences.getInt(ALBUM_COVER_STYLE, 0);
|
|
||||||
for (AlbumCoverStyle albumCoverStyle : AlbumCoverStyle.values()) {
|
|
||||||
if (albumCoverStyle.getId() == id) {
|
|
||||||
return albumCoverStyle;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return AlbumCoverStyle.CARD;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAlbumCoverStyle(AlbumCoverStyle albumCoverStyle) {
|
|
||||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
|
||||||
editor.putInt(ALBUM_COVER_STYLE, albumCoverStyle.getId());
|
|
||||||
editor.apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ViewPager.PageTransformer getAlbumCoverTransform() {
|
|
||||||
int style = Integer.parseInt(Objects.requireNonNull(mPreferences.getString(ALBUM_COVER_TRANSFORM, "0")));
|
|
||||||
switch (style) {
|
|
||||||
default:
|
|
||||||
case 0:
|
|
||||||
return new NormalPageTransformer();
|
|
||||||
case 1:
|
|
||||||
return new CascadingPageTransformer();
|
|
||||||
case 2:
|
|
||||||
return new DepthTransformation();
|
|
||||||
case 3:
|
|
||||||
return new HorizontalFlipTransformation();
|
|
||||||
case 4:
|
|
||||||
return new VerticalFlipTransformation();
|
|
||||||
case 5:
|
|
||||||
return new HingeTransformation();
|
|
||||||
case 6:
|
|
||||||
return new VerticalStackTransformer();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAlbumDetailSongSortOrder() {
|
|
||||||
return mPreferences
|
|
||||||
.getString(ALBUM_DETAIL_SONG_SORT_ORDER, AlbumSongSortOrder.SONG_TRACK_LIST);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAlbumDetailSongSortOrder(String sortOrder) {
|
|
||||||
Editor edit = this.mPreferences.edit();
|
|
||||||
edit.putString(ALBUM_DETAIL_SONG_SORT_ORDER, sortOrder);
|
|
||||||
edit.apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
public final int getAlbumGridSize(@NonNull Context context) {
|
|
||||||
return mPreferences
|
|
||||||
.getInt(ALBUM_GRID_SIZE, context.getResources().getInteger(R.integer.default_grid_columns));
|
|
||||||
}
|
|
||||||
|
|
||||||
public final int getAlbumGridSizeLand(@NonNull Context context) {
|
|
||||||
return mPreferences
|
|
||||||
.getInt(ALBUM_GRID_SIZE_LAND, context.getResources().getInteger(R.integer.default_grid_columns_land));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@LayoutRes
|
|
||||||
public int getAlbumGridStyle() {
|
|
||||||
return mPreferences.getInt(ALBUM_GRID_STYLE, R.layout.item_grid);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAlbumGridStyle(int layoutRes) {
|
|
||||||
mPreferences.edit()
|
|
||||||
.putInt(ALBUM_GRID_STYLE, layoutRes)
|
|
||||||
.apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
public final String getAlbumSongSortOrder() {
|
|
||||||
return mPreferences
|
|
||||||
.getString(ALBUM_SONG_SORT_ORDER, AlbumSongSortOrder.SONG_TRACK_LIST);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final String getArtistSongSortOrder() {
|
|
||||||
return mPreferences
|
|
||||||
.getString(ARTIST_SONG_SORT_ORDER, ArtistSongSortOrder.SONG_A_Z);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final String getAlbumSortOrder() {
|
|
||||||
return mPreferences.getString(ALBUM_SORT_ORDER, AlbumSortOrder.ALBUM_A_Z);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAlbumSortOrder(final String sortOrder) {
|
|
||||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
|
||||||
editor.putString(ALBUM_SORT_ORDER, sortOrder);
|
|
||||||
editor.apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
public final String getArtistAlbumSortOrder() {
|
|
||||||
return mPreferences.getString(ARTIST_ALBUM_SORT_ORDER, ArtistAlbumSortOrder.ALBUM_A_Z);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final int getArtistGridSize(Context context) {
|
|
||||||
return mPreferences.getInt(ARTIST_GRID_SIZE,
|
|
||||||
context.getResources().getInteger(R.integer.default_list_artist_columns));
|
|
||||||
}
|
|
||||||
|
|
||||||
public final int getArtistGridSizeLand(Context context) {
|
|
||||||
return mPreferences.getInt(ARTIST_GRID_SIZE_LAND,
|
|
||||||
context.getResources().getInteger(R.integer.default_list_artist_columns_land));
|
|
||||||
}
|
|
||||||
|
|
||||||
@LayoutRes
|
|
||||||
public int getArtistGridStyle() {
|
|
||||||
return mPreferences.getInt(ARTIST_GRID_STYLE, R.layout.item_grid_circle);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setArtistGridStyle(@LayoutRes int artistGridStyle) {
|
|
||||||
mPreferences.edit().putInt(ARTIST_GRID_STYLE, artistGridStyle).apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
public final String getArtistSortOrder() {
|
|
||||||
return mPreferences.getString(ARTIST_SORT_ORDER, ArtistSortOrder.ARTIST_A_Z);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setArtistSortOrder(final String sortOrder) {
|
|
||||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
|
||||||
editor.putString(ARTIST_SORT_ORDER, sortOrder);
|
|
||||||
editor.apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getBannerImage() {
|
|
||||||
return mPreferences.getString(BANNER_IMAGE_PATH, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getBaseTheme() {
|
|
||||||
return mPreferences.getString(GENERAL_THEME, "auto");
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
public List<CategoryInfo> getDefaultLibraryCategoryInfos() {
|
|
||||||
List<CategoryInfo> defaultCategoryInfos = new ArrayList<>(8);
|
|
||||||
defaultCategoryInfos.add(new CategoryInfo(Category.HOME, true));
|
|
||||||
defaultCategoryInfos.add(new CategoryInfo(Category.SONGS, true));
|
|
||||||
defaultCategoryInfos.add(new CategoryInfo(Category.ALBUMS, true));
|
|
||||||
defaultCategoryInfos.add(new CategoryInfo(Category.ARTISTS, true));
|
|
||||||
defaultCategoryInfos.add(new CategoryInfo(Category.PLAYLISTS, true));
|
|
||||||
defaultCategoryInfos.add(new CategoryInfo(Category.GENRES, false));
|
|
||||||
defaultCategoryInfos.add(new CategoryInfo(Category.QUEUE, false));
|
|
||||||
defaultCategoryInfos.add(new CategoryInfo(Category.FOLDER, false));
|
|
||||||
return defaultCategoryInfos;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getDialogCorner() {
|
|
||||||
return mPreferences.getInt(DIALOG_CORNER, 16);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getFilterLength() {
|
|
||||||
return mPreferences.getInt(FILTER_SONG, 20);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getFullScreenMode() {
|
|
||||||
return mPreferences.getBoolean(TOGGLE_FULL_SCREEN, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
public ThemeMode getGeneralThemeValue(boolean isSystemDark) {
|
|
||||||
String themeMode = mPreferences.getString(GENERAL_THEME, "auto");
|
|
||||||
if (isBlackMode() && isSystemDark) {
|
|
||||||
return ThemeMode.BLACK;
|
|
||||||
} else if (themeMode != null) {
|
|
||||||
if (isBlackMode() && themeMode.equals("dark")) {
|
|
||||||
return ThemeMode.BLACK;
|
|
||||||
} else {
|
|
||||||
switch (themeMode) {
|
|
||||||
case "light":
|
|
||||||
return ThemeMode.LIGHT;
|
|
||||||
case "dark":
|
|
||||||
return ThemeMode.DARK;
|
|
||||||
case "auto":
|
|
||||||
default:
|
|
||||||
return ThemeMode.AUTO;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ThemeMode.AUTO;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final String getGenreSortOrder() {
|
|
||||||
return mPreferences.getString(GENRE_SORT_ORDER, GenreSortOrder.GENRE_A_Z);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getHeadsetPlugged() {
|
|
||||||
return mPreferences.getBoolean(TOGGLE_HEADSET, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@LayoutRes
|
|
||||||
public int getHomeGridStyle(@NonNull Context context) {
|
|
||||||
String position = mPreferences.getString(HOME_ARTIST_GRID_STYLE, "0");
|
|
||||||
int pos = 0;
|
|
||||||
if (position != null) {
|
|
||||||
pos = Integer.parseInt(position);
|
|
||||||
}
|
|
||||||
TypedArray typedArray = context.getResources().obtainTypedArray(R.array.pref_home_grid_style_layout);
|
|
||||||
int layoutRes = typedArray.getResourceId(pos, 0);
|
|
||||||
typedArray.recycle();
|
|
||||||
if (layoutRes == 0) {
|
|
||||||
return R.layout.item_artist;
|
|
||||||
}
|
|
||||||
return layoutRes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getLastAddedCutoff() {
|
|
||||||
final CalendarUtil calendarUtil = new CalendarUtil();
|
|
||||||
long interval = calendarUtil.getElapsedMonth();
|
|
||||||
String cutOff = mPreferences.getString(LAST_ADDED_CUTOFF, "this_month");
|
|
||||||
if (cutOff != null) {
|
|
||||||
switch (cutOff) {
|
|
||||||
case "today":
|
|
||||||
interval = calendarUtil.getElapsedToday();
|
|
||||||
break;
|
|
||||||
case "this_week":
|
|
||||||
interval = calendarUtil.getElapsedWeek();
|
|
||||||
break;
|
|
||||||
case "past_three_months":
|
|
||||||
interval = calendarUtil.getElapsedMonths(3);
|
|
||||||
break;
|
|
||||||
case "this_year":
|
|
||||||
interval = calendarUtil.getElapsedYear();
|
|
||||||
break;
|
|
||||||
case "this_month":
|
|
||||||
default:
|
|
||||||
interval = calendarUtil.getElapsedMonth();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (System.currentTimeMillis() - interval) / 1000;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final int getLastChangelogVersion() {
|
|
||||||
return mPreferences.getInt(LAST_CHANGELOG_VERSION, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final int getLastPage() {
|
|
||||||
return mPreferences.getInt(LAST_PAGE, R.id.action_song);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLastPage(final int value) {
|
|
||||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
|
||||||
editor.putInt(LAST_PAGE, value);
|
|
||||||
editor.apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getLastSleepTimerValue() {
|
|
||||||
return mPreferences.getInt(LAST_SLEEP_TIMER_VALUE, 30);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLastSleepTimerValue(final int value) {
|
|
||||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
|
||||||
editor.putInt(LAST_SLEEP_TIMER_VALUE, value);
|
|
||||||
editor.apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
public List<CategoryInfo> getLibraryCategoryInfos() {
|
|
||||||
String data = mPreferences.getString(LIBRARY_CATEGORIES, null);
|
|
||||||
if (data != null) {
|
|
||||||
Gson gson = new Gson();
|
|
||||||
Type collectionType = new TypeToken<List<CategoryInfo>>() {
|
|
||||||
}.getType();
|
|
||||||
|
|
||||||
try {
|
|
||||||
return gson.fromJson(data, collectionType);
|
|
||||||
} catch (JsonSyntaxException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return getDefaultLibraryCategoryInfos();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLibraryCategoryInfos(List<CategoryInfo> categories) {
|
|
||||||
Gson gson = new Gson();
|
|
||||||
Type collectionType = new TypeToken<List<CategoryInfo>>() {
|
|
||||||
}.getType();
|
|
||||||
|
|
||||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
|
||||||
editor.putString(LIBRARY_CATEGORIES, gson.toJson(categories, collectionType));
|
|
||||||
editor.apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getLockScreen() {
|
|
||||||
return mPreferences.getBoolean(LOCK_SCREEN, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getLyricsOptions() {
|
|
||||||
return mPreferences.getInt(LYRICS_OPTIONS, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLyricsOptions(int i) {
|
|
||||||
mPreferences.edit().putInt(LYRICS_OPTIONS, i).apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getNextSleepTimerElapsedRealTime() {
|
|
||||||
return mPreferences.getLong(NEXT_SLEEP_TIMER_ELAPSED_REALTIME, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final NowPlayingScreen getNowPlayingScreen() {
|
|
||||||
int id = mPreferences.getInt(NOW_PLAYING_SCREEN_ID, 0);
|
|
||||||
for (NowPlayingScreen nowPlayingScreen : NowPlayingScreen.values()) {
|
|
||||||
if (nowPlayingScreen.getId() == id) {
|
|
||||||
return nowPlayingScreen;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return NowPlayingScreen.Adaptive;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("CommitPrefEdits")
|
|
||||||
public void setNowPlayingScreen(NowPlayingScreen nowPlayingScreen) {
|
|
||||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
|
||||||
editor.putInt(NOW_PLAYING_SCREEN_ID, nowPlayingScreen.getId());
|
|
||||||
editor.apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public final String getSAFSDCardUri() {
|
|
||||||
return mPreferences.getString(SAF_SDCARD_URI, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void setSAFSDCardUri(Uri uri) {
|
|
||||||
mPreferences.edit().putString(SAF_SDCARD_URI, uri.toString()).apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSelectedEqualizer() {
|
|
||||||
return mPreferences.getString(CHOOSE_EQUALIZER, "system");
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getSleepTimerFinishMusic() {
|
|
||||||
return mPreferences.getBoolean(SLEEP_TIMER_FINISH_SONG, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSleepTimerFinishMusic(final boolean value) {
|
|
||||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
|
||||||
editor.putBoolean(SLEEP_TIMER_FINISH_SONG, value);
|
|
||||||
editor.apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
public final int getSongGridSize(Context context) {
|
|
||||||
return mPreferences
|
|
||||||
.getInt(SONG_GRID_SIZE, context.getResources().getInteger(R.integer.default_list_columns));
|
|
||||||
}
|
|
||||||
|
|
||||||
public final int getSongGridSizeLand(Context context) {
|
|
||||||
return mPreferences.getInt(SONG_GRID_SIZE_LAND,
|
|
||||||
context.getResources().getInteger(R.integer.default_list_columns_land));
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getSongGridStyle() {
|
|
||||||
return mPreferences.getInt(SONG_GRID_STYLE, R.layout.item_list);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSongGridStyle(int viewAs) {
|
|
||||||
mPreferences.edit().putInt(SONG_GRID_STYLE, viewAs).apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
public final String getSongSortOrder() {
|
|
||||||
return mPreferences.getString(SONG_SORT_ORDER, SongSortOrder.SONG_A_Z);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSongSortOrder(final String sortOrder) {
|
|
||||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
|
||||||
editor.putString(SONG_SORT_ORDER, sortOrder);
|
|
||||||
editor.apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
public final File getStartDirectory() {
|
|
||||||
String folderPath = FoldersFragment.getDefaultStartDirectory().getPath();
|
|
||||||
String file = mPreferences.getString(START_DIRECTORY, folderPath);
|
|
||||||
if (file != null) {
|
|
||||||
return new File(file);
|
|
||||||
}
|
|
||||||
return new File(FoldersFragment.getDefaultStartDirectory().getPath());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStartDirectory(File file) {
|
|
||||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
|
||||||
editor.putString(START_DIRECTORY, FileUtil.safeGetCanonicalPath(file));
|
|
||||||
editor.apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
@LabelVisibilityMode
|
|
||||||
public int getTabTitleMode() {
|
|
||||||
String textMode = mPreferences.getString(TAB_TEXT_MODE, "1");
|
|
||||||
int mode = 0;
|
|
||||||
if (textMode != null) {
|
|
||||||
mode = Integer.parseInt(textMode);
|
|
||||||
}
|
|
||||||
switch (mode) {
|
|
||||||
default:
|
|
||||||
case 1:
|
|
||||||
return LabelVisibilityMode.LABEL_VISIBILITY_LABELED;
|
|
||||||
case 0:
|
|
||||||
return LabelVisibilityMode.LABEL_VISIBILITY_AUTO;
|
|
||||||
case 2:
|
|
||||||
return LabelVisibilityMode.LABEL_VISIBILITY_SELECTED;
|
|
||||||
case 3:
|
|
||||||
return LabelVisibilityMode.LABEL_VISIBILITY_UNLABELED;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public String getUserName() {
|
|
||||||
return mPreferences.getString(USER_NAME, "User");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUserName(String name) {
|
|
||||||
mPreferences.edit().putString(USER_NAME, name).apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getVolumeToggle() {
|
|
||||||
return mPreferences.getBoolean(TOGGLE_VOLUME, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final boolean ignoreMediaStoreArtwork() {
|
|
||||||
return mPreferences.getBoolean(IGNORE_MEDIA_STORE_ARTWORK, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final boolean initializedBlacklist() {
|
|
||||||
return mPreferences.getBoolean(INITIALIZED_BLACKLIST, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isBlackMode() {
|
|
||||||
return mPreferences.getBoolean(BLACK_THEME, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public boolean isExtraControls() {
|
|
||||||
return mPreferences.getBoolean(TOGGLE_ADD_CONTROLS, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public final boolean isHomeBanner() {
|
|
||||||
return mPreferences.getBoolean(TOGGLE_HOME_BANNER, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isRoundCorners() {
|
|
||||||
return mPreferences.getBoolean(ROUND_CORNERS, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isScreenOnEnabled() {
|
|
||||||
return mPreferences.getBoolean(KEEP_SCREEN_ON, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isShuffleModeOn() {
|
|
||||||
return mPreferences.getBoolean(TOGGLE_SHUFFLE, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public boolean isSongInfo() {
|
|
||||||
return mPreferences.getBoolean(EXTRA_SONG_INFO, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean pauseOnZeroVolume() {
|
|
||||||
return mPreferences.getBoolean(PAUSE_ON_ZERO_VOLUME, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void registerOnSharedPreferenceChangedListener(
|
|
||||||
SharedPreferences.OnSharedPreferenceChangeListener sharedPreferenceChangeListener) {
|
|
||||||
mPreferences.registerOnSharedPreferenceChangeListener(sharedPreferenceChangeListener);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void setAlbumGridSize(final int gridSize) {
|
|
||||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
|
||||||
editor.putInt(ALBUM_GRID_SIZE, gridSize);
|
|
||||||
editor.apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAlbumGridSizeLand(final int gridSize) {
|
|
||||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
|
||||||
editor.putInt(ALBUM_GRID_SIZE_LAND, gridSize);
|
|
||||||
editor.apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void setArtistGridSize(final int gridSize) {
|
|
||||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
|
||||||
editor.putInt(ARTIST_GRID_SIZE, gridSize);
|
|
||||||
editor.apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setArtistGridSizeLand(final int gridSize) {
|
|
||||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
|
||||||
editor.putInt(ARTIST_GRID_SIZE_LAND, gridSize);
|
|
||||||
editor.apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBannerImagePath(String bannerImagePath) {
|
|
||||||
mPreferences.edit().putString(BANNER_IMAGE_PATH, bannerImagePath)
|
|
||||||
.apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setClassicNotification(final boolean value) {
|
|
||||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
|
||||||
editor.putBoolean(CLASSIC_NOTIFICATION, value);
|
|
||||||
editor.apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setColoredAppShortcuts(final boolean value) {
|
|
||||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
|
||||||
editor.putBoolean(COLORED_APP_SHORTCUTS, value);
|
|
||||||
editor.apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void setColoredNotification(boolean b) {
|
|
||||||
mPreferences.edit().putBoolean(COLORED_NOTIFICATION, b).apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDesaturatedColor(boolean value) {
|
|
||||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
|
||||||
editor.putBoolean(DESATURATED_COLOR, value);
|
|
||||||
editor.apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setInitializedBlacklist() {
|
|
||||||
final Editor editor = mPreferences.edit();
|
|
||||||
editor.putBoolean(INITIALIZED_BLACKLIST, true);
|
|
||||||
editor.apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLastChangeLogVersion(int version) {
|
|
||||||
mPreferences.edit().putInt(LAST_CHANGELOG_VERSION, version).apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void setNextSleepTimerElapsedRealtime(final long value) {
|
|
||||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
|
||||||
editor.putLong(NEXT_SLEEP_TIMER_ELAPSED_REALTIME, value);
|
|
||||||
editor.apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSongGridSize(final int gridSize) {
|
|
||||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
|
||||||
editor.putInt(SONG_GRID_SIZE, gridSize);
|
|
||||||
editor.apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSongGridSizeLand(final int gridSize) {
|
|
||||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
|
||||||
editor.putInt(SONG_GRID_SIZE_LAND, gridSize);
|
|
||||||
editor.apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void unregisterOnSharedPreferenceChangedListener(
|
|
||||||
@NonNull OnSharedPreferenceChangeListener sharedPreferenceChangeListener) {
|
|
||||||
mPreferences.unregisterOnSharedPreferenceChangeListener(sharedPreferenceChangeListener);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isExpandPanel() {
|
|
||||||
return mPreferences.getBoolean(EXPAND_NOW_PLAYING_PANEL, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLanguageCode() {
|
|
||||||
return mPreferences.getString(LANGUAGE_NAME, "auto");
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,552 @@
|
||||||
|
package code.name.monkey.retromusic.util
|
||||||
|
|
||||||
|
import android.content.SharedPreferences.OnSharedPreferenceChangeListener
|
||||||
|
import android.net.ConnectivityManager
|
||||||
|
import android.net.NetworkInfo
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
|
import androidx.core.content.edit
|
||||||
|
import androidx.preference.PreferenceManager
|
||||||
|
import androidx.viewpager.widget.ViewPager
|
||||||
|
import code.name.monkey.retromusic.*
|
||||||
|
import code.name.monkey.retromusic.extensions.getIntRes
|
||||||
|
import code.name.monkey.retromusic.extensions.getStringOrDefault
|
||||||
|
import code.name.monkey.retromusic.fragments.AlbumCoverStyle
|
||||||
|
import code.name.monkey.retromusic.fragments.NowPlayingScreen
|
||||||
|
import code.name.monkey.retromusic.fragments.mainactivity.FoldersFragment
|
||||||
|
import code.name.monkey.retromusic.helper.SortOrder.*
|
||||||
|
import code.name.monkey.retromusic.model.CategoryInfo
|
||||||
|
import code.name.monkey.retromusic.transform.*
|
||||||
|
import code.name.monkey.retromusic.util.theme.ThemeMode
|
||||||
|
import com.google.android.material.bottomnavigation.LabelVisibilityMode
|
||||||
|
import com.google.gson.Gson
|
||||||
|
import com.google.gson.JsonSyntaxException
|
||||||
|
import com.google.gson.reflect.TypeToken
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
object PreferenceUtilKT {
|
||||||
|
private val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(App.getContext())
|
||||||
|
|
||||||
|
val defaultCategories = listOf(
|
||||||
|
CategoryInfo(CategoryInfo.Category.HOME, true),
|
||||||
|
CategoryInfo(CategoryInfo.Category.SONGS, true),
|
||||||
|
CategoryInfo(CategoryInfo.Category.ALBUMS, true),
|
||||||
|
CategoryInfo(CategoryInfo.Category.ARTISTS, true),
|
||||||
|
CategoryInfo(CategoryInfo.Category.PLAYLISTS, true),
|
||||||
|
CategoryInfo(CategoryInfo.Category.GENRES, false),
|
||||||
|
CategoryInfo(CategoryInfo.Category.QUEUE, false),
|
||||||
|
CategoryInfo(CategoryInfo.Category.FOLDER, false)
|
||||||
|
)
|
||||||
|
|
||||||
|
var libraryCategory: List<CategoryInfo>
|
||||||
|
get() {
|
||||||
|
val gson = Gson()
|
||||||
|
val collectionType = object : TypeToken<List<CategoryInfo>>() {}.type
|
||||||
|
|
||||||
|
val data = sharedPreferences.getStringOrDefault(
|
||||||
|
LIBRARY_CATEGORIES,
|
||||||
|
gson.toJson(defaultCategories, collectionType)
|
||||||
|
)
|
||||||
|
return try {
|
||||||
|
Gson().fromJson(data, collectionType)
|
||||||
|
} catch (e: JsonSyntaxException) {
|
||||||
|
e.printStackTrace()
|
||||||
|
return defaultCategories
|
||||||
|
}
|
||||||
|
}
|
||||||
|
set(value) {
|
||||||
|
val collectionType = object : TypeToken<List<CategoryInfo?>?>() {}.type
|
||||||
|
sharedPreferences.edit {
|
||||||
|
putString(LIBRARY_CATEGORIES, Gson().toJson(value, collectionType))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun registerOnSharedPreferenceChangedListener(
|
||||||
|
changeListener: OnSharedPreferenceChangeListener
|
||||||
|
) {
|
||||||
|
sharedPreferences.registerOnSharedPreferenceChangeListener(changeListener)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun unregisterOnSharedPreferenceChangedListener(
|
||||||
|
changeListener: OnSharedPreferenceChangeListener
|
||||||
|
) {
|
||||||
|
sharedPreferences.unregisterOnSharedPreferenceChangeListener(changeListener)
|
||||||
|
}
|
||||||
|
|
||||||
|
val baseTheme get() = sharedPreferences.getStringOrDefault(GENERAL_THEME, "auto")
|
||||||
|
|
||||||
|
fun getGeneralThemeValue(isSystemDark: Boolean): ThemeMode {
|
||||||
|
val themeMode: String =
|
||||||
|
sharedPreferences.getStringOrDefault(GENERAL_THEME, "auto")
|
||||||
|
return if (isBlackMode && isSystemDark) {
|
||||||
|
ThemeMode.BLACK
|
||||||
|
} else {
|
||||||
|
if (isBlackMode && themeMode == "dark") {
|
||||||
|
ThemeMode.BLACK
|
||||||
|
} else {
|
||||||
|
when (themeMode) {
|
||||||
|
"light" -> ThemeMode.LIGHT
|
||||||
|
"dark" -> ThemeMode.DARK
|
||||||
|
"auto" -> ThemeMode.AUTO
|
||||||
|
else -> ThemeMode.AUTO
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val languageCode get() = sharedPreferences.getString(LANGUAGE_NAME, "auto")
|
||||||
|
|
||||||
|
var userName
|
||||||
|
get() = sharedPreferences.getString(USER_NAME, "User Name")
|
||||||
|
set(value) = sharedPreferences.edit {
|
||||||
|
putString(USER_NAME, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
var safSdCardUri
|
||||||
|
get() = sharedPreferences.getStringOrDefault(SAF_SDCARD_URI, "")
|
||||||
|
set(value) = sharedPreferences.edit {
|
||||||
|
putString(SAF_SDCARD_URI, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
val selectedEqualizer
|
||||||
|
get() = sharedPreferences.getStringOrDefault(
|
||||||
|
CHOOSE_EQUALIZER,
|
||||||
|
"system"
|
||||||
|
)
|
||||||
|
|
||||||
|
val autoDownloadImagesPolicy
|
||||||
|
get() = sharedPreferences.getStringOrDefault(
|
||||||
|
AUTO_DOWNLOAD_IMAGES_POLICY,
|
||||||
|
"only_wifi"
|
||||||
|
)
|
||||||
|
|
||||||
|
var albumDetailSongSortOrder
|
||||||
|
get() = sharedPreferences.getStringOrDefault(
|
||||||
|
ALBUM_DETAIL_SONG_SORT_ORDER,
|
||||||
|
AlbumSongSortOrder.SONG_TRACK_LIST
|
||||||
|
)
|
||||||
|
set(value) = sharedPreferences.edit { putString(ALBUM_DETAIL_SONG_SORT_ORDER, value) }
|
||||||
|
|
||||||
|
var songSortOrder
|
||||||
|
get() = sharedPreferences.getStringOrDefault(
|
||||||
|
SONG_SORT_ORDER,
|
||||||
|
SongSortOrder.SONG_A_Z
|
||||||
|
)
|
||||||
|
set(value) = sharedPreferences.edit {
|
||||||
|
putString(SONG_SORT_ORDER, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
var albumSortOrder
|
||||||
|
get() = sharedPreferences.getStringOrDefault(
|
||||||
|
ALBUM_SORT_ORDER,
|
||||||
|
AlbumSortOrder.ALBUM_A_Z
|
||||||
|
)
|
||||||
|
set(value) = sharedPreferences.edit {
|
||||||
|
putString(ALBUM_SORT_ORDER, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
var artistSortOrder
|
||||||
|
get() = sharedPreferences.getStringOrDefault(
|
||||||
|
ARTIST_SORT_ORDER,
|
||||||
|
AlbumSortOrder.ALBUM_A_Z
|
||||||
|
)
|
||||||
|
set(value) = sharedPreferences.edit {
|
||||||
|
putString(ARTIST_SORT_ORDER, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
val albumSongSortOrder
|
||||||
|
get() = sharedPreferences.getStringOrDefault(
|
||||||
|
ALBUM_SONG_SORT_ORDER,
|
||||||
|
AlbumSongSortOrder.SONG_TRACK_LIST
|
||||||
|
)
|
||||||
|
|
||||||
|
val artistSongSortOrder
|
||||||
|
get() = sharedPreferences.getStringOrDefault(
|
||||||
|
ARTIST_SONG_SORT_ORDER,
|
||||||
|
AlbumSongSortOrder.SONG_TRACK_LIST
|
||||||
|
)
|
||||||
|
|
||||||
|
val artistAlbumSortOrder
|
||||||
|
get() = sharedPreferences.getStringOrDefault(
|
||||||
|
ARTIST_ALBUM_SORT_ORDER,
|
||||||
|
ArtistAlbumSortOrder.ALBUM_A_Z
|
||||||
|
)
|
||||||
|
|
||||||
|
val genreSortOrder
|
||||||
|
get() = sharedPreferences.getStringOrDefault(
|
||||||
|
GENRE_SORT_ORDER,
|
||||||
|
GenreSortOrder.GENRE_A_Z
|
||||||
|
)
|
||||||
|
|
||||||
|
val isIgnoreMediaStoreArtwork
|
||||||
|
get() = sharedPreferences.getBoolean(
|
||||||
|
IGNORE_MEDIA_STORE_ARTWORK,
|
||||||
|
false
|
||||||
|
)
|
||||||
|
|
||||||
|
val isVolumeVisibilityMode
|
||||||
|
get() = sharedPreferences.getBoolean(
|
||||||
|
TOGGLE_VOLUME, false
|
||||||
|
)
|
||||||
|
|
||||||
|
var isInitializedBlacklist
|
||||||
|
get() = sharedPreferences.getBoolean(
|
||||||
|
INITIALIZED_BLACKLIST, false
|
||||||
|
)
|
||||||
|
set(value) = sharedPreferences.edit {
|
||||||
|
putBoolean(INITIALIZED_BLACKLIST, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
private val isBlackMode
|
||||||
|
get() = sharedPreferences.getBoolean(
|
||||||
|
BLACK_THEME, false
|
||||||
|
)
|
||||||
|
|
||||||
|
val isExtraControls
|
||||||
|
get() = sharedPreferences.getBoolean(
|
||||||
|
TOGGLE_ADD_CONTROLS, false
|
||||||
|
)
|
||||||
|
|
||||||
|
val isHomeBanner
|
||||||
|
get() = sharedPreferences.getBoolean(
|
||||||
|
TOGGLE_HOME_BANNER, false
|
||||||
|
)
|
||||||
|
var isClassicNotification
|
||||||
|
get() = sharedPreferences.getBoolean(CLASSIC_NOTIFICATION, false)
|
||||||
|
set(value) = sharedPreferences.edit { putBoolean(CLASSIC_NOTIFICATION, value) }
|
||||||
|
|
||||||
|
val isScreenOnEnabled get() = sharedPreferences.getBoolean(KEEP_SCREEN_ON, false)
|
||||||
|
|
||||||
|
val isShuffleModeOn get() = sharedPreferences.getBoolean(TOGGLE_SHUFFLE, false)
|
||||||
|
|
||||||
|
val isSongInfo get() = sharedPreferences.getBoolean(EXTRA_SONG_INFO, false)
|
||||||
|
|
||||||
|
val isPauseOnZeroVolume get() = sharedPreferences.getBoolean(PAUSE_ON_ZERO_VOLUME, false)
|
||||||
|
|
||||||
|
var isSleepTimerFinishMusic
|
||||||
|
get() = sharedPreferences.getBoolean(
|
||||||
|
SLEEP_TIMER_FINISH_SONG, false
|
||||||
|
)
|
||||||
|
set(value) = sharedPreferences.edit {
|
||||||
|
putBoolean(SLEEP_TIMER_FINISH_SONG, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
val isExpandPanel get() = sharedPreferences.getBoolean(EXPAND_NOW_PLAYING_PANEL, false)
|
||||||
|
|
||||||
|
val isHeadsetPlugged
|
||||||
|
get() = sharedPreferences.getBoolean(
|
||||||
|
TOGGLE_HEADSET, false
|
||||||
|
)
|
||||||
|
|
||||||
|
val isAlbumArtOnLockScreen
|
||||||
|
get() = sharedPreferences.getBoolean(
|
||||||
|
ALBUM_ART_ON_LOCKSCREEN, false
|
||||||
|
)
|
||||||
|
|
||||||
|
val isAudioDucking
|
||||||
|
get() = sharedPreferences.getBoolean(
|
||||||
|
AUDIO_DUCKING, true
|
||||||
|
)
|
||||||
|
|
||||||
|
val isBluetoothSpeaker
|
||||||
|
get() = sharedPreferences.getBoolean(
|
||||||
|
BLUETOOTH_PLAYBACK, false
|
||||||
|
)
|
||||||
|
|
||||||
|
val isBlurredAlbumArt
|
||||||
|
get() = sharedPreferences.getBoolean(
|
||||||
|
BLURRED_ALBUM_ART, false
|
||||||
|
)
|
||||||
|
|
||||||
|
val isCarouselEffect
|
||||||
|
get() = sharedPreferences.getBoolean(
|
||||||
|
CAROUSEL_EFFECT, false
|
||||||
|
)
|
||||||
|
|
||||||
|
var isColoredAppShortcuts
|
||||||
|
get() = sharedPreferences.getBoolean(
|
||||||
|
COLORED_APP_SHORTCUTS, true
|
||||||
|
)
|
||||||
|
set(value) = sharedPreferences.edit {
|
||||||
|
putBoolean(COLORED_APP_SHORTCUTS, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
var isColoredNotification
|
||||||
|
get() = sharedPreferences.getBoolean(
|
||||||
|
COLORED_NOTIFICATION, true
|
||||||
|
)
|
||||||
|
set(value) = sharedPreferences.edit {
|
||||||
|
putBoolean(COLORED_NOTIFICATION, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
var isDesaturatedColor
|
||||||
|
get() = sharedPreferences.getBoolean(
|
||||||
|
DESATURATED_COLOR, false
|
||||||
|
)
|
||||||
|
set(value) = sharedPreferences.edit {
|
||||||
|
putBoolean(DESATURATED_COLOR, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
val isGapLessPlayback
|
||||||
|
get() = sharedPreferences.getBoolean(
|
||||||
|
GAPLESS_PLAYBACK, false
|
||||||
|
)
|
||||||
|
|
||||||
|
val isAdaptiveColor
|
||||||
|
get() = sharedPreferences.getBoolean(
|
||||||
|
ADAPTIVE_COLOR_APP, false
|
||||||
|
)
|
||||||
|
|
||||||
|
val isFullScreenMode
|
||||||
|
get() = sharedPreferences.getBoolean(
|
||||||
|
TOGGLE_FULL_SCREEN, false
|
||||||
|
)
|
||||||
|
|
||||||
|
val isLockScreen get() = sharedPreferences.getBoolean(LOCK_SCREEN, false)
|
||||||
|
|
||||||
|
fun isAllowedToDownloadMetadata(): Boolean {
|
||||||
|
return when (autoDownloadImagesPolicy) {
|
||||||
|
"always" -> true
|
||||||
|
"only_wifi" -> {
|
||||||
|
val connectivityManager = ContextCompat.getSystemService(
|
||||||
|
App.getContext(),
|
||||||
|
ConnectivityManager::class.java
|
||||||
|
)
|
||||||
|
var netInfo: NetworkInfo? = null
|
||||||
|
if (connectivityManager != null) {
|
||||||
|
netInfo = connectivityManager.activeNetworkInfo
|
||||||
|
}
|
||||||
|
netInfo != null && netInfo.type == ConnectivityManager.TYPE_WIFI && netInfo.isConnectedOrConnecting
|
||||||
|
}
|
||||||
|
"never" -> false
|
||||||
|
else -> false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var lyricsOption
|
||||||
|
get() = sharedPreferences.getInt(LYRICS_OPTIONS, 1)
|
||||||
|
set(value) = sharedPreferences.edit {
|
||||||
|
putInt(LYRICS_OPTIONS, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
var songGridStyle
|
||||||
|
get() = sharedPreferences.getInt(SONG_GRID_STYLE, R.layout.item_grid)
|
||||||
|
set(value) = sharedPreferences.edit {
|
||||||
|
putInt(SONG_GRID_STYLE, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
var albumGridStyle
|
||||||
|
get() = sharedPreferences.getInt(ALBUM_GRID_STYLE, R.layout.item_grid)
|
||||||
|
set(value) = sharedPreferences.edit {
|
||||||
|
putInt(ALBUM_GRID_STYLE, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
var artistGridStyle
|
||||||
|
get() = sharedPreferences.getInt(ARTIST_GRID_STYLE, R.layout.item_grid_circle)
|
||||||
|
set(value) = sharedPreferences.edit {
|
||||||
|
putInt(ARTIST_GRID_STYLE, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
val filterLength get() = sharedPreferences.getInt(FILTER_SONG, 20)
|
||||||
|
|
||||||
|
var lastVersion
|
||||||
|
get() = sharedPreferences.getInt(LAST_CHANGELOG_VERSION, 0)
|
||||||
|
set(value) = sharedPreferences.edit {
|
||||||
|
putInt(LAST_CHANGELOG_VERSION, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
var lastSleepTimerValue
|
||||||
|
get() = sharedPreferences.getInt(
|
||||||
|
LAST_SLEEP_TIMER_VALUE,
|
||||||
|
30
|
||||||
|
)
|
||||||
|
set(value) = sharedPreferences.edit {
|
||||||
|
putInt(LAST_SLEEP_TIMER_VALUE, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
var lastPage
|
||||||
|
get() = sharedPreferences.getInt(LAST_PAGE, R.id.action_song)
|
||||||
|
set(value) = sharedPreferences.edit {
|
||||||
|
putInt(LAST_PAGE, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
var nextSleepTimerElapsedRealTime
|
||||||
|
get() = sharedPreferences.getInt(
|
||||||
|
NEXT_SLEEP_TIMER_ELAPSED_REALTIME,
|
||||||
|
-1
|
||||||
|
)
|
||||||
|
set(value) = sharedPreferences.edit {
|
||||||
|
putInt(NEXT_SLEEP_TIMER_ELAPSED_REALTIME, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun themeResFromPrefValue(themePrefValue: String): Int {
|
||||||
|
return when (themePrefValue) {
|
||||||
|
"light" -> R.style.Theme_RetroMusic_Light
|
||||||
|
"dark" -> R.style.Theme_RetroMusic
|
||||||
|
else -> R.style.Theme_RetroMusic
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val homeGridStyle: Int
|
||||||
|
get() {
|
||||||
|
val position =
|
||||||
|
sharedPreferences.getStringOrDefault(
|
||||||
|
HOME_ARTIST_GRID_STYLE, "0"
|
||||||
|
).toInt()
|
||||||
|
val typedArray =
|
||||||
|
App.getContext().resources.obtainTypedArray(R.array.pref_home_grid_style_layout)
|
||||||
|
val layoutRes = typedArray.getResourceId(position, 0)
|
||||||
|
typedArray.recycle()
|
||||||
|
return if (layoutRes == 0) {
|
||||||
|
R.layout.item_artist
|
||||||
|
} else layoutRes
|
||||||
|
}
|
||||||
|
|
||||||
|
val tabTitleMode: Int
|
||||||
|
get() {
|
||||||
|
return when (sharedPreferences.getStringOrDefault(
|
||||||
|
TAB_TEXT_MODE, "1"
|
||||||
|
).toInt()) {
|
||||||
|
1 -> LabelVisibilityMode.LABEL_VISIBILITY_LABELED
|
||||||
|
0 -> LabelVisibilityMode.LABEL_VISIBILITY_AUTO
|
||||||
|
2 -> LabelVisibilityMode.LABEL_VISIBILITY_SELECTED
|
||||||
|
3 -> LabelVisibilityMode.LABEL_VISIBILITY_UNLABELED
|
||||||
|
else -> LabelVisibilityMode.LABEL_VISIBILITY_LABELED
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var songGridSize
|
||||||
|
get() = sharedPreferences.getInt(
|
||||||
|
SONG_GRID_SIZE,
|
||||||
|
App.getContext().getIntRes(R.integer.default_grid_columns)
|
||||||
|
)
|
||||||
|
set(value) = sharedPreferences.edit {
|
||||||
|
putInt(SONG_GRID_SIZE, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
var songGridSizeLand
|
||||||
|
get() = sharedPreferences.getInt(
|
||||||
|
SONG_GRID_SIZE_LAND,
|
||||||
|
App.getContext().getIntRes(R.integer.default_grid_columns_land)
|
||||||
|
)
|
||||||
|
set(value) = sharedPreferences.edit {
|
||||||
|
putInt(SONG_GRID_SIZE_LAND, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var albumGridSize: Int
|
||||||
|
get() = sharedPreferences.getInt(
|
||||||
|
ALBUM_GRID_SIZE,
|
||||||
|
App.getContext().getIntRes(R.integer.default_grid_columns)
|
||||||
|
)
|
||||||
|
set(value) = sharedPreferences.edit {
|
||||||
|
putInt(ALBUM_GRID_SIZE, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var albumGridSizeLand
|
||||||
|
get() = sharedPreferences.getInt(
|
||||||
|
ALBUM_GRID_SIZE_LAND,
|
||||||
|
App.getContext().getIntRes(R.integer.default_grid_columns_land)
|
||||||
|
)
|
||||||
|
set(value) = sharedPreferences.edit {
|
||||||
|
putInt(ALBUM_GRID_SIZE_LAND, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var artistGridSize
|
||||||
|
get() = sharedPreferences.getInt(
|
||||||
|
ARTIST_GRID_SIZE,
|
||||||
|
App.getContext().getIntRes(R.integer.default_grid_columns)
|
||||||
|
)
|
||||||
|
set(value) = sharedPreferences.edit {
|
||||||
|
putInt(ARTIST_GRID_SIZE, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var artistGridSizeLand
|
||||||
|
get() = sharedPreferences.getInt(
|
||||||
|
ALBUM_GRID_SIZE_LAND,
|
||||||
|
App.getContext().getIntRes(R.integer.default_grid_columns_land)
|
||||||
|
)
|
||||||
|
set(value) = sharedPreferences.edit {
|
||||||
|
putInt(ALBUM_GRID_SIZE_LAND, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var albumCoverStyle: AlbumCoverStyle
|
||||||
|
get() {
|
||||||
|
val id: Int = sharedPreferences.getInt(ALBUM_COVER_STYLE, 0)
|
||||||
|
for (albumCoverStyle in AlbumCoverStyle.values()) {
|
||||||
|
if (albumCoverStyle.id == id) {
|
||||||
|
return albumCoverStyle
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return AlbumCoverStyle.CARD
|
||||||
|
}
|
||||||
|
set(value) = sharedPreferences.edit { putInt(ALBUM_COVER_STYLE, value.id) }
|
||||||
|
|
||||||
|
|
||||||
|
var nowPlayingScreen: NowPlayingScreen
|
||||||
|
get() {
|
||||||
|
val id: Int = sharedPreferences.getInt(NOW_PLAYING_SCREEN_ID, 0)
|
||||||
|
for (nowPlayingScreen in NowPlayingScreen.values()) {
|
||||||
|
if (nowPlayingScreen.id == id) {
|
||||||
|
return nowPlayingScreen
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NowPlayingScreen.Adaptive
|
||||||
|
}
|
||||||
|
set(value) = sharedPreferences.edit {
|
||||||
|
putInt(NOW_PLAYING_SCREEN_ID, value.id)
|
||||||
|
}
|
||||||
|
|
||||||
|
val albumCoverTransform: ViewPager.PageTransformer
|
||||||
|
get() {
|
||||||
|
val style = sharedPreferences.getStringOrDefault(
|
||||||
|
ALBUM_COVER_TRANSFORM,
|
||||||
|
"0"
|
||||||
|
).toInt()
|
||||||
|
return when (style) {
|
||||||
|
0 -> NormalPageTransformer()
|
||||||
|
1 -> CascadingPageTransformer()
|
||||||
|
2 -> DepthTransformation()
|
||||||
|
3 -> HorizontalFlipTransformation()
|
||||||
|
4 -> VerticalFlipTransformation()
|
||||||
|
5 -> HingeTransformation()
|
||||||
|
6 -> VerticalStackTransformer()
|
||||||
|
else -> NormalPageTransformer()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var startDirectory: File
|
||||||
|
get() {
|
||||||
|
val folderPath = FoldersFragment.getDefaultStartDirectory().path
|
||||||
|
val filePath: String = sharedPreferences.getStringOrDefault(START_DIRECTORY, folderPath)
|
||||||
|
return File(filePath) ?: File(FoldersFragment.getDefaultStartDirectory().path)
|
||||||
|
}
|
||||||
|
set(value) = sharedPreferences.edit {
|
||||||
|
putString(
|
||||||
|
START_DIRECTORY,
|
||||||
|
FileUtil.safeGetCanonicalPath(value)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
val lastAddedCutoff: Long
|
||||||
|
get() {
|
||||||
|
val calendarUtil = CalendarUtil()
|
||||||
|
val interval =
|
||||||
|
when (sharedPreferences.getStringOrDefault(LAST_ADDED_CUTOFF, "this_month")) {
|
||||||
|
"today" -> calendarUtil.elapsedToday
|
||||||
|
"this_week" -> calendarUtil.elapsedWeek
|
||||||
|
"past_three_months" -> calendarUtil.getElapsedMonths(3)
|
||||||
|
"this_year" -> calendarUtil.elapsedYear
|
||||||
|
"this_month" -> calendarUtil.elapsedMonth
|
||||||
|
else -> calendarUtil.elapsedMonth
|
||||||
|
}
|
||||||
|
return (System.currentTimeMillis() - interval) / 1000
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -142,7 +142,7 @@ public class RetroUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isAllowedToDownloadMetadata(final @NonNull Context context) {
|
public static boolean isAllowedToDownloadMetadata(final @NonNull Context context) {
|
||||||
switch (PreferenceUtil.getInstance(context).autoDownloadImagesPolicy()) {
|
switch (PreferenceUtilKT.INSTANCE.getAutoDownloadImagesPolicy()) {
|
||||||
case "always":
|
case "always":
|
||||||
return true;
|
return true;
|
||||||
case "only_wifi":
|
case "only_wifi":
|
||||||
|
|
|
@ -76,7 +76,6 @@ class RingtoneManager(val context: Context) {
|
||||||
|
|
||||||
fun getDialog(context: Context): MaterialDialog {
|
fun getDialog(context: Context): MaterialDialog {
|
||||||
return MaterialDialog(context).show {
|
return MaterialDialog(context).show {
|
||||||
cornerRadius(PreferenceUtil.getInstance(context).dialogCorner)
|
|
||||||
title(R.string.dialog_title_set_ringtone)
|
title(R.string.dialog_title_set_ringtone)
|
||||||
message(R.string.dialog_message_set_ringtone)
|
message(R.string.dialog_message_set_ringtone)
|
||||||
positiveButton(android.R.string.ok) {
|
positiveButton(android.R.string.ok) {
|
||||||
|
|
|
@ -119,19 +119,19 @@ public class SAFUtil {
|
||||||
public static void saveTreeUri(Context context, Intent data) {
|
public static void saveTreeUri(Context context, Intent data) {
|
||||||
Uri uri = data.getData();
|
Uri uri = data.getData();
|
||||||
context.getContentResolver().takePersistableUriPermission(uri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
context.getContentResolver().takePersistableUriPermission(uri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
PreferenceUtil.getInstance(context).setSAFSDCardUri(uri);
|
PreferenceUtilKT.INSTANCE.setSafSdCardUri(uri.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||||
public static boolean isTreeUriSaved(Context context) {
|
public static boolean isTreeUriSaved(Context context) {
|
||||||
return !TextUtils.isEmpty(PreferenceUtil.getInstance(context).getSAFSDCardUri());
|
return !TextUtils.isEmpty(PreferenceUtilKT.INSTANCE.getSafSdCardUri());
|
||||||
}
|
}
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||||
public static boolean isSDCardAccessGranted(Context context) {
|
public static boolean isSDCardAccessGranted(Context context) {
|
||||||
if (!isTreeUriSaved(context)) return false;
|
if (!isTreeUriSaved(context)) return false;
|
||||||
|
|
||||||
String sdcardUri = PreferenceUtil.getInstance(context).getSAFSDCardUri();
|
String sdcardUri = PreferenceUtilKT.INSTANCE.getSafSdCardUri();
|
||||||
|
|
||||||
List<UriPermission> perms = context.getContentResolver().getPersistedUriPermissions();
|
List<UriPermission> perms = context.getContentResolver().getPersistedUriPermissions();
|
||||||
for (UriPermission perm : perms) {
|
for (UriPermission perm : perms) {
|
||||||
|
@ -198,7 +198,7 @@ public class SAFUtil {
|
||||||
|
|
||||||
if (isTreeUriSaved(context)) {
|
if (isTreeUriSaved(context)) {
|
||||||
List<String> pathSegments = new ArrayList<>(Arrays.asList(audio.getFile().getAbsolutePath().split("/")));
|
List<String> pathSegments = new ArrayList<>(Arrays.asList(audio.getFile().getAbsolutePath().split("/")));
|
||||||
Uri sdcard = Uri.parse(PreferenceUtil.getInstance(context).getSAFSDCardUri());
|
Uri sdcard = Uri.parse(PreferenceUtilKT.INSTANCE.getSafSdCardUri());
|
||||||
uri = findDocument(DocumentFile.fromTreeUri(context, sdcard), pathSegments);
|
uri = findDocument(DocumentFile.fromTreeUri(context, sdcard), pathSegments);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -271,7 +271,7 @@ public class SAFUtil {
|
||||||
|
|
||||||
if (isTreeUriSaved(context)) {
|
if (isTreeUriSaved(context)) {
|
||||||
List<String> pathSegments = new ArrayList<>(Arrays.asList(path.split("/")));
|
List<String> pathSegments = new ArrayList<>(Arrays.asList(path.split("/")));
|
||||||
Uri sdcard = Uri.parse(PreferenceUtil.getInstance(context).getSAFSDCardUri());
|
Uri sdcard = Uri.parse(PreferenceUtilKT.INSTANCE.getSafSdCardUri());
|
||||||
uri = findDocument(DocumentFile.fromTreeUri(context, sdcard), pathSegments);
|
uri = findDocument(DocumentFile.fromTreeUri(context, sdcard), pathSegments);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue