From 5038f9afa15aebeaadf69184f96bf5d550ac694c Mon Sep 17 00:00:00 2001 From: h4h13 Date: Mon, 6 Jan 2020 01:55:55 +0530 Subject: [PATCH] Added scroll animation --- .../activities/AlbumDetailsActivity.kt | 4 +- .../retromusic/activities/SettingsActivity.kt | 4 +- .../tageditor/AlbumTagEditorActivity.kt | 16 +- .../mainactivity/home/BannerHomeFragment.kt | 4 +- .../settings/MainSettingsFragment.kt | 4 +- .../settings/PersonalizeSettingsFragment.kt | 1 - .../retromusic/util/PreferenceUtil.java | 1192 +++++++++-------- .../res/drawable/ic_search_white_24dp.xml | 5 + app/src/main/res/layout/activity_settings.xml | 2 +- .../main/res/layout/fragment_banner_home.xml | 4 +- .../res/layout/fragment_main_settings.xml | 6 +- app/src/main/res/values/strings.xml | 2 +- app/src/main/res/xml/pref_ui.xml | 7 +- 13 files changed, 684 insertions(+), 567 deletions(-) create mode 100644 app/src/main/res/drawable/ic_search_white_24dp.xml diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/AlbumDetailsActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/AlbumDetailsActivity.kt index f7d95e1c..faed5b25 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/AlbumDetailsActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/AlbumDetailsActivity.kt @@ -304,8 +304,8 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C intent.putExtra(AbsTagEditorActivity.EXTRA_ID, album.id) val options = ActivityOptions.makeSceneTransitionAnimation( this, - image, - getString(R.string.transition_album_art) + albumCoverContainer, + "${getString(R.string.transition_album_art)}_${album.id}" ) startActivityForResult(intent, TAG_EDITOR_REQUEST, options.toBundle()) return true diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/SettingsActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/SettingsActivity.kt index b1128732..2c639035 100755 --- a/app/src/main/java/code/name/monkey/retromusic/activities/SettingsActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/SettingsActivity.kt @@ -10,7 +10,9 @@ import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper import code.name.monkey.retromusic.R import code.name.monkey.retromusic.activities.base.AbsBaseActivity import code.name.monkey.retromusic.fragments.settings.MainSettingsFragment -import kotlinx.android.synthetic.main.activity_settings.* +import kotlinx.android.synthetic.main.activity_settings.appBarLayout +import kotlinx.android.synthetic.main.activity_settings.detailContentFrame +import kotlinx.android.synthetic.main.activity_settings.toolbar class SettingsActivity : AbsBaseActivity() { diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/AlbumTagEditorActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/AlbumTagEditorActivity.kt index 7c2dec8d..90257de7 100755 --- a/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/AlbumTagEditorActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/AlbumTagEditorActivity.kt @@ -11,6 +11,7 @@ import android.os.Bundle import android.text.Editable import android.text.TextUtils import android.text.TextWatcher +import android.transition.Slide import android.widget.Toast import code.name.monkey.appthemehelper.util.ATHUtil import code.name.monkey.appthemehelper.util.MaterialUtil @@ -37,6 +38,7 @@ import kotlinx.android.synthetic.main.activity_album_tag_editor.albumText import kotlinx.android.synthetic.main.activity_album_tag_editor.albumTitleContainer import kotlinx.android.synthetic.main.activity_album_tag_editor.genreContainer import kotlinx.android.synthetic.main.activity_album_tag_editor.genreTitle +import kotlinx.android.synthetic.main.activity_album_tag_editor.imageContainer import kotlinx.android.synthetic.main.activity_album_tag_editor.toolbar import kotlinx.android.synthetic.main.activity_album_tag_editor.yearContainer import kotlinx.android.synthetic.main.activity_album_tag_editor.yearTitle @@ -48,6 +50,16 @@ class AlbumTagEditorActivity : AbsTagEditorActivity(), TextWatcher { override val contentViewLayout: Int get() = R.layout.activity_album_tag_editor + private fun windowEnterTransition() { + val slide = Slide() + slide.excludeTarget(R.id.appBarLayout, true) + slide.excludeTarget(R.id.status_bar, true) + slide.excludeTarget(android.R.id.statusBarBackground, true) + slide.excludeTarget(android.R.id.navigationBarBackground, true) + + window.enterTransition = slide + } + override fun loadImageFromFile(selectedFileUri: Uri?) { Glide.with(this@AlbumTagEditorActivity).load(selectedFileUri).asBitmap() @@ -93,8 +105,10 @@ class AlbumTagEditorActivity : AbsTagEditorActivity(), TextWatcher { override fun onCreate(savedInstanceState: Bundle?) { setDrawUnderStatusBar() super.onCreate(savedInstanceState) + window.sharedElementsUseOverlay = true lastFMRestClient = LastFMRestClient(this) - + imageContainer?.transitionName = "${getString(R.string.transition_album_art)}_$id" + windowEnterTransition() setUpViews() setupToolbar() } diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/mainactivity/home/BannerHomeFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/mainactivity/home/BannerHomeFragment.kt index f0731d1f..c2fcc7ad 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/mainactivity/home/BannerHomeFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/mainactivity/home/BannerHomeFragment.kt @@ -149,8 +149,10 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba } private fun setupToolbar() { + toolbar.apply { - backgroundTintList = ColorStateList.valueOf(ATHUtil.resolveColor(requireContext(), R.attr.colorSurface)) + backgroundTintList = + ColorStateList.valueOf(ATHUtil.resolveColor(requireContext(), R.attr.colorSurface)) setNavigationIcon(R.drawable.ic_menu_white_24dp) setOnClickListener { val options = ActivityOptions.makeSceneTransitionAnimation( diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/settings/MainSettingsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/settings/MainSettingsFragment.kt index e60dc8ca..4cbf4dfb 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/settings/MainSettingsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/settings/MainSettingsFragment.kt @@ -32,7 +32,6 @@ import kotlinx.android.synthetic.main.fragment_main_settings.aboutSettings import kotlinx.android.synthetic.main.fragment_main_settings.audioSettings import kotlinx.android.synthetic.main.fragment_main_settings.buyPremium import kotlinx.android.synthetic.main.fragment_main_settings.buyProContainer -import kotlinx.android.synthetic.main.fragment_main_settings.container import kotlinx.android.synthetic.main.fragment_main_settings.diamondIcon import kotlinx.android.synthetic.main.fragment_main_settings.generalSettings import kotlinx.android.synthetic.main.fragment_main_settings.imageSettings @@ -40,6 +39,7 @@ import kotlinx.android.synthetic.main.fragment_main_settings.notificationSetting import kotlinx.android.synthetic.main.fragment_main_settings.nowPlayingSettings import kotlinx.android.synthetic.main.fragment_main_settings.otherSettings import kotlinx.android.synthetic.main.fragment_main_settings.personalizeSettings +import kotlinx.android.synthetic.main.fragment_main_settings.scrollView import me.everything.android.ui.overscroll.OverScrollDecoratorHelper class MainSettingsFragment : Fragment(), View.OnClickListener { @@ -88,7 +88,7 @@ class MainSettingsFragment : Fragment(), View.OnClickListener { buyPremium.setTextColor(it) diamondIcon.imageTintList = ColorStateList.valueOf(it) } - OverScrollDecoratorHelper.setUpOverScroll(container) + OverScrollDecoratorHelper.setUpOverScroll(scrollView) } private fun inflateFragment(fragment: Fragment, @StringRes title: Int) { diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/settings/PersonalizeSettingsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/settings/PersonalizeSettingsFragment.kt index 7b1f01c4..e17af8f2 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/settings/PersonalizeSettingsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/settings/PersonalizeSettingsFragment.kt @@ -22,7 +22,6 @@ import androidx.preference.TwoStatePreference import code.name.monkey.retromusic.R import code.name.monkey.retromusic.util.PreferenceUtil - class PersonalizeSettingsFragment : AbsSettingsFragment(), SharedPreferences.OnSharedPreferenceChangeListener { override fun invalidateSettings() { diff --git a/app/src/main/java/code/name/monkey/retromusic/util/PreferenceUtil.java b/app/src/main/java/code/name/monkey/retromusic/util/PreferenceUtil.java index 324eb5ed..02fc53c5 100644 --- a/app/src/main/java/code/name/monkey/retromusic/util/PreferenceUtil.java +++ b/app/src/main/java/code/name/monkey/retromusic/util/PreferenceUtil.java @@ -23,23 +23,10 @@ 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.App; import code.name.monkey.retromusic.R; import code.name.monkey.retromusic.activities.MainActivity; @@ -56,113 +43,192 @@ import code.name.monkey.retromusic.transform.HorizontalFlipTransformation; import code.name.monkey.retromusic.transform.NormalPageTransformer; import code.name.monkey.retromusic.transform.VerticalFlipTransformation; import code.name.monkey.retromusic.transform.VerticalStackTransformer; +import com.google.android.material.bottomnavigation.LabelVisibilityMode; +import com.google.gson.Gson; +import com.google.gson.JsonSyntaxException; +import com.google.gson.reflect.TypeToken; +import java.io.File; +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; public final class PreferenceUtil { + public static final String LIBRARY_CATEGORIES = "library_categories"; + + public static final String HIDE_HOME_BANNER_SEARCH = "hide_home_banner_search"; + public static final String DESATURATED_COLOR = "desaturated_color"; + public static final String BLACK_THEME = "black_theme"; + public static final String DIALOG_CORNER = "dialog_corner"; + 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 SLEEP_TIMER_FINISH_SONG = "sleep_timer_finish_song"; + public static final String TOGGLE_HEADSET = "toggle_headset"; + public static final String DOMINANT_COLOR = "dominant_color"; + 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 USER_BIO = "user_bio"; + public static final String TOGGLE_FULL_SCREEN = "toggle_full_screen"; + public static final String TOGGLE_VOLUME = "toggle_volume"; + public static final String TOGGLE_TAB_TITLES = "toggle_tab_titles"; + 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 ALBUM_GRID_STYLE = "album_grid_style"; + public static final String HOME_ARTIST_GRID_STYLE = "home_artist_grid_style"; + public static final String ARTIST_GRID_STYLE = "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 SAF_SDCARD_URI = "saf_sdcard_uri"; + private static final String GENRE_SORT_ORDER = "genre_sort_order"; + private static final String LAST_PAGE = "last_start_page"; + private static final String LAST_MUSIC_CHOOSER = "last_music_chooser"; + private static final String DEFAULT_START_PAGE = "default_start_page"; + private static final String INITIALIZED_BLACKLIST = "initialized_blacklist"; + private static final String ARTIST_SORT_ORDER = "artist_sort_order"; + private static final String ARTIST_SONG_SORT_ORDER = "artist_song_sort_order"; + private static final String ARTIST_ALBUM_SORT_ORDER = "artist_album_sort_order"; + private static final String ALBUM_SORT_ORDER = "album_sort_order"; + private static final String ALBUM_SONG_SORT_ORDER = "album_song_sort_order"; + private static final String SONG_SORT_ORDER = "song_sort_order"; + private static final String ALBUM_GRID_SIZE = "album_grid_size"; + private static final String ALBUM_GRID_SIZE_LAND = "album_grid_size_land"; + private static final String SONG_GRID_SIZE = "song_grid_size"; + 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 ALBUM_COLORED_FOOTERS = "album_colored_footers"; + private static final String SONG_COLORED_FOOTERS = "song_colored_footers"; + private static final String ARTIST_COLORED_FOOTERS = "artist_colored_footers"; + private static final String ALBUM_ARTIST_COLORED_FOOTERS = "album_artist_colored_footers"; + 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 INTRO_SHOWN = "intro_shown"; + private static final String AUTO_DOWNLOAD_IMAGES_POLICY = "auto_download_images_policy"; + private static final String START_DIRECTORY = "start_directory"; + private static final String SYNCHRONIZED_LYRICS_SHOW = "synchronized_lyrics_show"; + 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 ARTIST_DETAIL_SONG_SORT_ORDER = "artist_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 TOGGLE_ANIMATIONS = "toggle_animations"; + private static final String LAST_KNOWN_LYRICS_TYPE = "LAST_KNOWN_LYRICS_TYPE"; + private static final String ALBUM_DETAIL_STYLE = "album_detail_style"; + private static final String PAUSE_ON_ZERO_VOLUME = "pause_on_zero_volume"; + private static final String NOW_PLAYING_SCREEN = "now_playing_screen"; + private static final String SNOW_FALL_EFFECT = "snow_fall_effect"; + private static final String FILTER_SONG = "filter_song"; + private static PreferenceUtil sInstance; + private final SharedPreferences mPreferences; - private PreferenceUtil(@NonNull final Context context) { - mPreferences = PreferenceManager.getDefaultSharedPreferences(context); - } - - public static boolean isAllowedToDownloadMetadata(final Context context) { - switch (getInstance(context).autoDownloadImagesPolicy()) { - case "always": - return true; - case "only_wifi": - final ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); - NetworkInfo netInfo = connectivityManager.getActiveNetworkInfo(); - return netInfo != null && netInfo.getType() == ConnectivityManager.TYPE_WIFI && netInfo.isConnectedOrConnecting(); - case "never": - default: - return false; - } - } - @NonNull public static PreferenceUtil getInstance(Context context) { if (sInstance == null) { @@ -182,198 +248,84 @@ public final class PreferenceUtil { } } - public boolean desaturatedColor() { - return mPreferences.getBoolean(DESATURATED_COLOR, false); + public static boolean isAllowedToDownloadMetadata(final Context context) { + switch (getInstance(context).autoDownloadImagesPolicy()) { + case "always": + return true; + case "only_wifi": + final ConnectivityManager connectivityManager = (ConnectivityManager) context + .getSystemService(Context.CONNECTIVITY_SERVICE); + NetworkInfo netInfo = connectivityManager.getActiveNetworkInfo(); + return netInfo != null && netInfo.getType() == ConnectivityManager.TYPE_WIFI && netInfo + .isConnectedOrConnecting(); + case "never": + default: + return false; + } } - public void setDesaturatedColor(boolean value) { - final SharedPreferences.Editor editor = mPreferences.edit(); - editor.putBoolean(DESATURATED_COLOR, value); - editor.apply(); + private PreferenceUtil(@NonNull final Context context) { + mPreferences = PreferenceManager.getDefaultSharedPreferences(context); } - public boolean getSleepTimerFinishMusic() { - return mPreferences.getBoolean(SLEEP_TIMER_FINISH_SONG, false); + public final boolean albumArtOnLockscreen() { + return mPreferences.getBoolean(ALBUM_ART_ON_LOCKSCREEN, true); } - public void setSleepTimerFinishMusic(final boolean value) { - final SharedPreferences.Editor editor = mPreferences.edit(); - editor.putBoolean(SLEEP_TIMER_FINISH_SONG, value); - editor.apply(); + public final boolean albumArtistColoredFooters() { + return mPreferences.getBoolean(ALBUM_ARTIST_COLORED_FOOTERS, true); } - public boolean isBlackMode() { - return mPreferences.getBoolean(BLACK_THEME, false); + public final boolean albumColoredFooters() { + return mPreferences.getBoolean(ALBUM_COLORED_FOOTERS, false); } - public String getUserBio() { - return mPreferences.getString(USER_BIO, ""); + public final boolean artistColoredFooters() { + return mPreferences.getBoolean(ARTIST_COLORED_FOOTERS, true); } - public void setUserBio(String bio) { - mPreferences.edit().putString(USER_BIO, bio).apply(); + public final boolean audioDucking() { + return mPreferences.getBoolean(AUDIO_DUCKING, true); } - public int getFilterLength() { - return mPreferences.getInt(FILTER_SONG, 20); + public final String autoDownloadImagesPolicy() { + return mPreferences.getString(AUTO_DOWNLOAD_IMAGES_POLICY, "only_wifi"); } - public float getDialogCorner() { - return mPreferences.getInt(DIALOG_CORNER, 16); - } - - public boolean isSnowFall() { - return mPreferences.getBoolean(SNOW_FALL_EFFECT, false); - } - - public final String getArtistSortOrder() { - return mPreferences.getString(ARTIST_SORT_ORDER, SortOrder.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 final String getArtistSongSortOrder() { - return mPreferences.getString(ARTIST_SONG_SORT_ORDER, SortOrder.ArtistSongSortOrder.SONG_A_Z); - } - - public final boolean isHomeBanner() { - return mPreferences.getBoolean(TOGGLE_HOME_BANNER, false); - } - - public final String getArtistAlbumSortOrder() { - return mPreferences.getString(ARTIST_ALBUM_SORT_ORDER, SortOrder.ArtistAlbumSortOrder.ALBUM_YEAR); - } - - public final String getAlbumSortOrder() { - return mPreferences.getString(ALBUM_SORT_ORDER, SortOrder.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 getAlbumSongSortOrder() { - return mPreferences - .getString(ALBUM_SONG_SORT_ORDER, AlbumSongSortOrder.SONG_TRACK_LIST); - } - - public final String getSongSortOrder() { - return mPreferences.getString(SONG_SORT_ORDER, SortOrder.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 String getGenreSortOrder() { - return mPreferences.getString(GENRE_SORT_ORDER, SortOrder.GenreSortOrder.GENRE_A_Z); - } - - public boolean isScreenOnEnabled() { - return mPreferences.getBoolean(KEEP_SCREEN_ON, false); - } - - public void setInitializedBlacklist() { - final Editor editor = mPreferences.edit(); - editor.putBoolean(INITIALIZED_BLACKLIST, true); - editor.apply(); - } - - public final boolean initializedBlacklist() { - return mPreferences.getBoolean(INITIALIZED_BLACKLIST, false); - } - - public boolean isExtraControls() { - return mPreferences.getBoolean(TOGGLE_ADD_CONTROLS, false); + public final boolean blurredAlbumArt() { + return mPreferences.getBoolean(BLURRED_ALBUM_ART, false); } public boolean carouselEffect() { return mPreferences.getBoolean(CAROUSEL_EFFECT, false); } - public boolean isRoundCorners() { - return mPreferences.getBoolean(ROUND_CORNERS, false); + public final boolean classicNotification() { + return mPreferences.getBoolean(CLASSIC_NOTIFICATION, false); } - public void registerOnSharedPreferenceChangedListener( - SharedPreferences.OnSharedPreferenceChangeListener sharedPreferenceChangeListener) { - mPreferences.registerOnSharedPreferenceChangeListener(sharedPreferenceChangeListener); - } - - public void unregisterOnSharedPreferenceChangedListener( - SharedPreferences.OnSharedPreferenceChangeListener sharedPreferenceChangeListener) { - mPreferences.unregisterOnSharedPreferenceChangeListener(sharedPreferenceChangeListener); - } - - public final int getDefaultStartPage() { - return Integer.parseInt(mPreferences.getString(DEFAULT_START_PAGE, "-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 void setLastLyricsType(int group) { - final SharedPreferences.Editor editor = mPreferences.edit(); - editor.putInt(LAST_KNOWN_LYRICS_TYPE, group); - editor.apply(); - } - - public final int getLastMusicChooser() { - return mPreferences.getInt(LAST_MUSIC_CHOOSER, MainActivity.HOME); - } - - public void setLastMusicChooser(int value) { - mPreferences.edit().putInt(LAST_MUSIC_CHOOSER, value).apply(); + public final boolean coloredAppShortcuts() { + return mPreferences.getBoolean(COLORED_APP_SHORTCUTS, true); } public final boolean coloredNotification() { return mPreferences.getBoolean(COLORED_NOTIFICATION, true); } - public final void setColoredNotification(boolean b) { - mPreferences.edit().putBoolean(COLORED_NOTIFICATION, b).apply(); + public boolean desaturatedColor() { + return mPreferences.getBoolean(DESATURATED_COLOR, false); } - public final boolean classicNotification() { - return mPreferences.getBoolean(CLASSIC_NOTIFICATION, false); + public boolean enableAnimations() { + return mPreferences.getBoolean(TOGGLE_ANIMATIONS, false); } - public void setClassicNotification(final boolean value) { - final SharedPreferences.Editor editor = mPreferences.edit(); - editor.putBoolean(CLASSIC_NOTIFICATION, value); - editor.apply(); + public final boolean gaplessPlayback() { + return mPreferences.getBoolean(GAPLESS_PLAYBACK, false); } - 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 boolean getAdaptiveColor() { + return mPreferences.getBoolean(ADAPTIVE_COLOR_APP, false); } public final AlbumCoverStyle getAlbumCoverStyle() { @@ -392,54 +344,51 @@ public final class PreferenceUtil { editor.apply(); } - public void setColoredAppShortcuts(final boolean value) { - final SharedPreferences.Editor editor = mPreferences.edit(); - editor.putBoolean(COLORED_APP_SHORTCUTS, value); - 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 final boolean coloredAppShortcuts() { - return mPreferences.getBoolean(COLORED_APP_SHORTCUTS, true); + public String getAlbumDetailSongSortOrder() { + return mPreferences + .getString(ALBUM_DETAIL_SONG_SORT_ORDER, AlbumSongSortOrder.SONG_TRACK_LIST); } - public final boolean gaplessPlayback() { - return mPreferences.getBoolean(GAPLESS_PLAYBACK, false); + public void setAlbumDetailSongSortOrder(String sortOrder) { + Editor edit = this.mPreferences.edit(); + edit.putString(ALBUM_DETAIL_SONG_SORT_ORDER, sortOrder); + edit.apply(); } - public final boolean audioDucking() { - return mPreferences.getBoolean(AUDIO_DUCKING, true); + public String getAlbumDetailsStyle() { + return mPreferences.getString(ALBUM_DETAIL_STYLE, "0"); } - public final boolean albumArtOnLockscreen() { - return mPreferences.getBoolean(ALBUM_ART_ON_LOCKSCREEN, true); - } - - public final boolean blurredAlbumArt() { - return mPreferences.getBoolean(BLURRED_ALBUM_ART, false); - } - - public final boolean ignoreMediaStoreArtwork() { - return mPreferences.getBoolean(IGNORE_MEDIA_STORE_ARTWORK, false); - } - - 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(); - } - - public long getNextSleepTimerElapsedRealTime() { - return mPreferences.getLong(NEXT_SLEEP_TIMER_ELAPSED_REALTIME, -1); - } - - public void setNextSleepTimerElapsedRealtime(final long value) { - final SharedPreferences.Editor editor = mPreferences.edit(); - editor.putLong(NEXT_SLEEP_TIMER_ELAPSED_REALTIME, value); - editor.apply(); + public int getAlbumDetailsStyle(Context context) { + int pos = Integer.parseInt(Objects.requireNonNull(mPreferences.getString(ALBUM_DETAIL_STYLE, "0"))); + TypedArray typedArray = context.getResources().obtainTypedArray(R.array.pref_album_details_style_layout); + int layoutRes = typedArray.getResourceId(pos, -1); + typedArray.recycle(); + if (layoutRes == -1) { + return R.layout.activity_album; + } + return layoutRes; } public final int getAlbumGridSize(Context context) { @@ -447,142 +396,128 @@ public final class PreferenceUtil { .getInt(ALBUM_GRID_SIZE, context.getResources().getInteger(R.integer.default_grid_columns)); } - public void setSongGridSize(final int gridSize) { - final SharedPreferences.Editor editor = mPreferences.edit(); - editor.putInt(SONG_GRID_SIZE, gridSize); - editor.apply(); + public final int getAlbumGridSizeLand(Context context) { + return mPreferences.getInt(ALBUM_GRID_SIZE_LAND, + context.getResources().getInteger(R.integer.default_grid_columns_land)); } - public final int getSongGridSize(Context context) { + @LayoutRes + public int getAlbumGridStyle(Context context) { + int pos = Integer.parseInt(mPreferences.getString(ALBUM_GRID_STYLE, "0")); + TypedArray typedArray = context.getResources().obtainTypedArray(R.array.pref_grid_style_layout); + int layoutRes = typedArray.getResourceId(pos, -1); + typedArray.recycle(); + if (layoutRes == -1) { + return R.layout.item_card; + } + return layoutRes; + } + + public final String getAlbumSongSortOrder() { return mPreferences - .getInt(SONG_GRID_SIZE, context.getResources().getInteger(R.integer.default_list_columns)); + .getString(ALBUM_SONG_SORT_ORDER, AlbumSongSortOrder.SONG_TRACK_LIST); } - public void setArtistGridSize(final int gridSize) { + public final String getAlbumSortOrder() { + return mPreferences.getString(ALBUM_SORT_ORDER, SortOrder.AlbumSortOrder.ALBUM_A_Z); + } + + public void setAlbumSortOrder(final String sortOrder) { final SharedPreferences.Editor editor = mPreferences.edit(); - editor.putInt(ARTIST_GRID_SIZE, gridSize); + editor.putString(ALBUM_SORT_ORDER, sortOrder); editor.apply(); } + public final String getArtistAlbumSortOrder() { + return mPreferences.getString(ARTIST_ALBUM_SORT_ORDER, SortOrder.ArtistAlbumSortOrder.ALBUM_YEAR); + } + + public String getArtistDetailSongSortOrder() { + return mPreferences + .getString(ARTIST_DETAIL_SONG_SORT_ORDER, SortOrder.ArtistSongSortOrder.SONG_A_Z); + } + + public void setArtistDetailSongSortOrder(String sortOrder) { + Editor edit = this.mPreferences.edit(); + edit.putString(ARTIST_DETAIL_SONG_SORT_ORDER, sortOrder); + edit.apply(); + } + public final int getArtistGridSize(Context context) { return mPreferences.getInt(ARTIST_GRID_SIZE, context.getResources().getInteger(R.integer.default_list_artist_columns)); } - public void setAlbumGridSizeLand(final int gridSize) { - final SharedPreferences.Editor editor = mPreferences.edit(); - editor.putInt(ALBUM_GRID_SIZE_LAND, gridSize); - editor.apply(); - } - - public final int getAlbumGridSizeLand(Context context) { - return mPreferences.getInt(ALBUM_GRID_SIZE_LAND, - context.getResources().getInteger(R.integer.default_grid_columns_land)); - } - - public void setSongGridSizeLand(final int gridSize) { - final SharedPreferences.Editor editor = mPreferences.edit(); - editor.putInt(SONG_GRID_SIZE_LAND, gridSize); - editor.apply(); - } - - public final int getSongGridSizeLand(Context context) { - return mPreferences.getInt(SONG_GRID_SIZE_LAND, - context.getResources().getInteger(R.integer.default_list_columns_land)); - } - - public void setArtistGridSizeLand(final int gridSize) { - final SharedPreferences.Editor editor = mPreferences.edit(); - editor.putInt(ARTIST_GRID_SIZE_LAND, gridSize); - editor.apply(); - } - public final int getArtistGridSizeLand(Context context) { return mPreferences.getInt(ARTIST_GRID_SIZE_LAND, context.getResources().getInteger(R.integer.default_list_artist_columns_land)); } - public void setAlbumGridSize(final int gridSize) { + @LayoutRes + public int getArtistGridStyle(Context context) { + int pos = Integer.parseInt(Objects.requireNonNull(mPreferences.getString(ARTIST_GRID_STYLE, "0"))); + TypedArray typedArray = context.getResources().obtainTypedArray(R.array.pref_grid_style_layout); + int layoutRes = typedArray.getResourceId(pos, -1); + typedArray.recycle(); + if (layoutRes == -1) { + return R.layout.item_card; + } + return layoutRes; + } + + public final String getArtistSongSortOrder() { + return mPreferences.getString(ARTIST_SONG_SORT_ORDER, SortOrder.ArtistSongSortOrder.SONG_A_Z); + } + + public final String getArtistSortOrder() { + return mPreferences.getString(ARTIST_SORT_ORDER, SortOrder.ArtistSortOrder.ARTIST_A_Z); + } + + public void setArtistSortOrder(final String sortOrder) { final SharedPreferences.Editor editor = mPreferences.edit(); - editor.putInt(ALBUM_GRID_SIZE, gridSize); + editor.putString(ARTIST_SORT_ORDER, sortOrder); editor.apply(); } - public void setAlbumColoredFooters(final boolean value) { - final SharedPreferences.Editor editor = mPreferences.edit(); - editor.putBoolean(ALBUM_COLORED_FOOTERS, value); - editor.apply(); + public String getBannerImage() { + return mPreferences.getString(BANNER_IMAGE_PATH, ""); } - public final boolean albumColoredFooters() { - return mPreferences.getBoolean(ALBUM_COLORED_FOOTERS, false); + public String getBaseTheme() { + return mPreferences.getString(GENERAL_THEME, "dark"); } - public void setAlbumArtistColoredFooters(final boolean value) { - final SharedPreferences.Editor editor = mPreferences.edit(); - editor.putBoolean(ALBUM_ARTIST_COLORED_FOOTERS, value); - editor.apply(); + @NonNull + public List getDefaultLibraryCategoryInfos() { + List defaultCategoryInfos = new ArrayList<>(7); + defaultCategoryInfos.add(new CategoryInfo(CategoryInfo.Category.HOME, true)); + defaultCategoryInfos.add(new CategoryInfo(CategoryInfo.Category.SONGS, true)); + defaultCategoryInfos.add(new CategoryInfo(CategoryInfo.Category.ALBUMS, true)); + defaultCategoryInfos.add(new CategoryInfo(CategoryInfo.Category.ARTISTS, true)); + defaultCategoryInfos.add(new CategoryInfo(CategoryInfo.Category.PLAYLISTS, true)); + defaultCategoryInfos.add(new CategoryInfo(CategoryInfo.Category.GENRES, false)); + defaultCategoryInfos.add(new CategoryInfo(CategoryInfo.Category.QUEUE, false)); + return defaultCategoryInfos; } - public final boolean albumArtistColoredFooters() { - return mPreferences.getBoolean(ALBUM_ARTIST_COLORED_FOOTERS, true); + public final int getDefaultStartPage() { + return Integer.parseInt(mPreferences.getString(DEFAULT_START_PAGE, "-1")); } - public void setSongColoredFooters(final boolean value) { - final SharedPreferences.Editor editor = mPreferences.edit(); - editor.putBoolean(SONG_COLORED_FOOTERS, value); - editor.apply(); + public float getDialogCorner() { + return mPreferences.getInt(DIALOG_CORNER, 16); } - public final boolean songColoredFooters() { - return mPreferences.getBoolean(SONG_COLORED_FOOTERS, false); + public int getFilterLength() { + return mPreferences.getInt(FILTER_SONG, 20); } - public void setArtistColoredFooters(final boolean value) { - final SharedPreferences.Editor editor = mPreferences.edit(); - editor.putBoolean(ARTIST_COLORED_FOOTERS, value); - editor.apply(); + public boolean getFullScreenMode() { + return mPreferences.getBoolean(TOGGLE_FULL_SCREEN, false); } - public final boolean artistColoredFooters() { - return mPreferences.getBoolean(ARTIST_COLORED_FOOTERS, true); - } - - public void setLastChangeLogVersion(int version) { - mPreferences.edit().putInt(LAST_CHANGELOG_VERSION, version).apply(); - } - - public final int getLastChangelogVersion() { - return mPreferences.getInt(LAST_CHANGELOG_VERSION, -1); - } - - @SuppressLint("CommitPrefEdits") - public void setIntroShown() { - // don't use apply here - mPreferences.edit().putBoolean(INTRO_SHOWN, true).commit(); - } - - public final File getStartDirectory() { - return new File(mPreferences - .getString(START_DIRECTORY, FoldersFragment.getDefaultStartDirectory().getPath())); - } - - public void setStartDirectory(File file) { - final SharedPreferences.Editor editor = mPreferences.edit(); - editor.putString(START_DIRECTORY, FileUtil.safeGetCanonicalPath(file)); - editor.apply(); - } - - public final boolean introShown() { - return mPreferences.getBoolean(INTRO_SHOWN, false); - } - - public final String autoDownloadImagesPolicy() { - return mPreferences.getString(AUTO_DOWNLOAD_IMAGES_POLICY, "only_wifi"); - } - - public final boolean synchronizedLyricsShow() { - return mPreferences.getBoolean(SYNCHRONIZED_LYRICS_SHOW, true); + public void setFullScreenMode(int newValue) { + mPreferences.edit().putInt(TOGGLE_FULL_SCREEN, newValue).apply(); } public int getGeneralTheme() { @@ -597,13 +532,31 @@ public final class PreferenceUtil { @NonNull public String getGeneralThemeValue() { - if (isBlackMode()) return "black"; - else + if (isBlackMode()) { + return "black"; + } else { return mPreferences.getString(GENERAL_THEME, "dark"); + } } - public String getBaseTheme() { - return mPreferences.getString(GENERAL_THEME, "dark"); + public final String getGenreSortOrder() { + return mPreferences.getString(GENRE_SORT_ORDER, SortOrder.GenreSortOrder.GENRE_A_Z); + } + + public boolean getHeadsetPlugged() { + return mPreferences.getBoolean(TOGGLE_HEADSET, false); + } + + @LayoutRes + public int getHomeGridStyle(@NonNull Context context) { + int pos = Integer.parseInt(mPreferences.getString(HOME_ARTIST_GRID_STYLE, "0")); + TypedArray typedArray = context.getResources().obtainTypedArray(R.array.pref_home_grid_style_layout); + int layoutRes = typedArray.getResourceId(pos, -1); + typedArray.recycle(); + if (layoutRes == -1) { + return R.layout.item_artist; + } + return layoutRes; } public long getLastAddedCutoff() { @@ -632,227 +585,36 @@ public final class PreferenceUtil { return (System.currentTimeMillis() - interval) / 1000; } - public boolean getAdaptiveColor() { - return mPreferences.getBoolean(ADAPTIVE_COLOR_APP, false); + public final int getLastChangelogVersion() { + return mPreferences.getInt(LAST_CHANGELOG_VERSION, -1); } - public boolean getLockScreen() { - return mPreferences.getBoolean(LOCK_SCREEN, false); + public final int getLastMusicChooser() { + return mPreferences.getInt(LAST_MUSIC_CHOOSER, MainActivity.HOME); } - public String getUserName() { - return mPreferences.getString(USER_NAME, "User"); + public void setLastMusicChooser(int value) { + mPreferences.edit().putInt(LAST_MUSIC_CHOOSER, value).apply(); } - public void setUserName(String name) { - mPreferences.edit().putString(USER_NAME, name).apply(); + public final int getLastPage() { + return mPreferences.getInt(LAST_PAGE, R.id.action_song); } - public boolean getFullScreenMode() { - return mPreferences.getBoolean(TOGGLE_FULL_SCREEN, false); + public void setLastPage(final int value) { + final SharedPreferences.Editor editor = mPreferences.edit(); + editor.putInt(LAST_PAGE, value); + editor.apply(); } - public void setFullScreenMode(int newValue) { - mPreferences.edit().putInt(TOGGLE_FULL_SCREEN, newValue).apply(); + public int getLastSleepTimerValue() { + return mPreferences.getInt(LAST_SLEEP_TIMER_VALUE, 30); } - public void saveProfileImage(String profileImagePath) { - mPreferences.edit().putString(PROFILE_IMAGE_PATH, profileImagePath).apply(); - } - - public String getProfileImage() { - return mPreferences.getString(PROFILE_IMAGE_PATH, ""); - } - - public String getBannerImage() { - return mPreferences.getString(BANNER_IMAGE_PATH, ""); - } - - public void setBannerImagePath(String bannerImagePath) { - mPreferences.edit().putString(BANNER_IMAGE_PATH, bannerImagePath) - .apply(); - } - - 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 String getArtistDetailSongSortOrder() { - return mPreferences - .getString(ARTIST_DETAIL_SONG_SORT_ORDER, SortOrder.ArtistSongSortOrder.SONG_A_Z); - } - - public void setArtistDetailSongSortOrder(String sortOrder) { - Editor edit = this.mPreferences.edit(); - edit.putString(ARTIST_DETAIL_SONG_SORT_ORDER, sortOrder); - edit.apply(); - } - - public boolean getVolumeToggle() { - return mPreferences.getBoolean(TOGGLE_VOLUME, false); - } - - public int getLyricsOptions() { - return mPreferences.getInt(LYRICS_OPTIONS, 1); - } - - public void setLyricsOptions(int i) { - mPreferences.edit().putInt(LYRICS_OPTIONS, i).apply(); - } - - public boolean getHeadsetPlugged() { - return mPreferences.getBoolean(TOGGLE_HEADSET, false); - } - - public boolean isDominantColor() { - return mPreferences.getBoolean(DOMINANT_COLOR, false); - } - - public boolean isGenreShown() { - return mPreferences.getBoolean(TOGGLE_GENRE, false); - } - - public String getSelectedEqualizer() { - return mPreferences.getString(CHOOSE_EQUALIZER, "system"); - } - - public boolean isShuffleModeOn() { - return mPreferences.getBoolean(TOGGLE_SHUFFLE, false); - } - - public void resetCarouselEffect() { - mPreferences.edit().putBoolean(CAROUSEL_EFFECT, false).apply(); - } - - public void resetCircularAlbumArt() { - mPreferences.edit().putBoolean(CIRCULAR_ALBUM_ART, false).apply(); - } - - public String getAlbumDetailsStyle() { - return mPreferences.getString(ALBUM_DETAIL_STYLE, "0"); - } - - public int getAlbumDetailsStyle(Context context) { - int pos = Integer.parseInt(Objects.requireNonNull(mPreferences.getString(ALBUM_DETAIL_STYLE, "0"))); - TypedArray typedArray = context.getResources().obtainTypedArray(R.array.pref_album_details_style_layout); - int layoutRes = typedArray.getResourceId(pos, -1); - typedArray.recycle(); - if (layoutRes == -1) { - return R.layout.activity_album; - } - return layoutRes; - } - - public void setArtistGridStyle(int viewAs) { - mPreferences.edit().putInt(ARTIST_GRID_STYLE, viewAs).apply(); - } - - public boolean toggleSeparateLine() { - return mPreferences.getBoolean(TOGGLE_SEPARATE_LINE, false); - } - - 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 boolean enableAnimations() { - return mPreferences.getBoolean(TOGGLE_ANIMATIONS, false); - } - - public boolean pauseOnZeroVolume() { - return mPreferences.getBoolean(PAUSE_ON_ZERO_VOLUME, false); - } - - 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(); - } - } - - @LabelVisibilityMode - public int getTabTitleMode() { - int mode = Integer.parseInt(mPreferences.getString(TAB_TEXT_MODE, "1")); - 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 boolean tabTitles() { - return getTabTitleMode() != LabelVisibilityMode.LABEL_VISIBILITY_UNLABELED; - } - - @LayoutRes - public int getHomeGridStyle(@NonNull Context context) { - int pos = Integer.parseInt(mPreferences.getString(HOME_ARTIST_GRID_STYLE, "0")); - TypedArray typedArray = context.getResources().obtainTypedArray(R.array.pref_home_grid_style_layout); - int layoutRes = typedArray.getResourceId(pos, -1); - typedArray.recycle(); - if (layoutRes == -1) { - return R.layout.item_artist; - } - return layoutRes; - } - - @LayoutRes - public int getArtistGridStyle(Context context) { - int pos = Integer.parseInt(Objects.requireNonNull(mPreferences.getString(ARTIST_GRID_STYLE, "0"))); - TypedArray typedArray = context.getResources().obtainTypedArray(R.array.pref_grid_style_layout); - int layoutRes = typedArray.getResourceId(pos, -1); - typedArray.recycle(); - if (layoutRes == -1) { - return R.layout.item_card; - } - return layoutRes; - } - - @LayoutRes - public int getAlbumGridStyle(Context context) { - int pos = Integer.parseInt(mPreferences.getString(ALBUM_GRID_STYLE, "0")); - TypedArray typedArray = context.getResources().obtainTypedArray(R.array.pref_grid_style_layout); - int layoutRes = typedArray.getResourceId(pos, -1); - typedArray.recycle(); - if (layoutRes == -1) { - return R.layout.item_card; - } - return layoutRes; - } - - public boolean isClickOrSave() { - return mPreferences.getBoolean(NOW_PLAYING_SCREEN, false); + public void setLastSleepTimerValue(final int value) { + final SharedPreferences.Editor editor = mPreferences.edit(); + editor.putInt(LAST_SLEEP_TIMER_VALUE, value); + editor.apply(); } @NonNull @@ -883,17 +645,41 @@ public final class PreferenceUtil { editor.apply(); } - @NonNull - public List getDefaultLibraryCategoryInfos() { - List defaultCategoryInfos = new ArrayList<>(7); - defaultCategoryInfos.add(new CategoryInfo(CategoryInfo.Category.HOME, true)); - defaultCategoryInfos.add(new CategoryInfo(CategoryInfo.Category.SONGS, true)); - defaultCategoryInfos.add(new CategoryInfo(CategoryInfo.Category.ALBUMS, true)); - defaultCategoryInfos.add(new CategoryInfo(CategoryInfo.Category.ARTISTS, true)); - defaultCategoryInfos.add(new CategoryInfo(CategoryInfo.Category.PLAYLISTS, true)); - defaultCategoryInfos.add(new CategoryInfo(CategoryInfo.Category.GENRES, false)); - defaultCategoryInfos.add(new CategoryInfo(CategoryInfo.Category.QUEUE, false)); - return defaultCategoryInfos; + 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 String getProfileImage() { + return mPreferences.getString(PROFILE_IMAGE_PATH, ""); } public final String getSAFSDCardUri() { @@ -903,4 +689,310 @@ public final class PreferenceUtil { 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 boolean getBannerSearchEnable() { + return mPreferences.getBoolean(HIDE_HOME_BANNER_SEARCH, 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, SortOrder.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() { + return new File(mPreferences + .getString(START_DIRECTORY, 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() { + int mode = Integer.parseInt(mPreferences.getString(TAB_TEXT_MODE, "1")); + 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 getUserBio() { + return mPreferences.getString(USER_BIO, ""); + } + + public void setUserBio(String bio) { + mPreferences.edit().putString(USER_BIO, bio).apply(); + } + + 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); + } + + public final boolean introShown() { + return mPreferences.getBoolean(INTRO_SHOWN, false); + } + + public boolean isBlackMode() { + return mPreferences.getBoolean(BLACK_THEME, false); + } + + public boolean isClickOrSave() { + return mPreferences.getBoolean(NOW_PLAYING_SCREEN, false); + } + + public boolean isDominantColor() { + return mPreferences.getBoolean(DOMINANT_COLOR, false); + } + + public boolean isExtraControls() { + return mPreferences.getBoolean(TOGGLE_ADD_CONTROLS, false); + } + + public boolean isGenreShown() { + return mPreferences.getBoolean(TOGGLE_GENRE, 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 isSnowFall() { + return mPreferences.getBoolean(SNOW_FALL_EFFECT, false); + } + + public boolean pauseOnZeroVolume() { + return mPreferences.getBoolean(PAUSE_ON_ZERO_VOLUME, false); + } + + public void registerOnSharedPreferenceChangedListener( + SharedPreferences.OnSharedPreferenceChangeListener sharedPreferenceChangeListener) { + mPreferences.registerOnSharedPreferenceChangeListener(sharedPreferenceChangeListener); + } + + public void resetCarouselEffect() { + mPreferences.edit().putBoolean(CAROUSEL_EFFECT, false).apply(); + } + + public void resetCircularAlbumArt() { + mPreferences.edit().putBoolean(CIRCULAR_ALBUM_ART, false).apply(); + } + + public void saveProfileImage(String profileImagePath) { + mPreferences.edit().putString(PROFILE_IMAGE_PATH, profileImagePath).apply(); + } + + public void setAlbumArtistColoredFooters(final boolean value) { + final SharedPreferences.Editor editor = mPreferences.edit(); + editor.putBoolean(ALBUM_ARTIST_COLORED_FOOTERS, value); + editor.apply(); + } + + public void setAlbumColoredFooters(final boolean value) { + final SharedPreferences.Editor editor = mPreferences.edit(); + editor.putBoolean(ALBUM_COLORED_FOOTERS, value); + editor.apply(); + } + + 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 setArtistColoredFooters(final boolean value) { + final SharedPreferences.Editor editor = mPreferences.edit(); + editor.putBoolean(ARTIST_COLORED_FOOTERS, value); + 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 setArtistGridStyle(int viewAs) { + mPreferences.edit().putInt(ARTIST_GRID_STYLE, viewAs).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(); + } + + @SuppressLint("CommitPrefEdits") + public void setIntroShown() { + // don't use apply here + mPreferences.edit().putBoolean(INTRO_SHOWN, true).commit(); + } + + public void setLastChangeLogVersion(int version) { + mPreferences.edit().putInt(LAST_CHANGELOG_VERSION, version).apply(); + } + + public void setLastLyricsType(int group) { + final SharedPreferences.Editor editor = mPreferences.edit(); + editor.putInt(LAST_KNOWN_LYRICS_TYPE, group); + editor.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 setSongColoredFooters(final boolean value) { + final SharedPreferences.Editor editor = mPreferences.edit(); + editor.putBoolean(SONG_COLORED_FOOTERS, 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 final boolean songColoredFooters() { + return mPreferences.getBoolean(SONG_COLORED_FOOTERS, false); + } + + public final boolean synchronizedLyricsShow() { + return mPreferences.getBoolean(SYNCHRONIZED_LYRICS_SHOW, true); + } + + public boolean tabTitles() { + return getTabTitleMode() != LabelVisibilityMode.LABEL_VISIBILITY_UNLABELED; + } + + public boolean toggleSeparateLine() { + return mPreferences.getBoolean(TOGGLE_SEPARATE_LINE, false); + } + + public void unregisterOnSharedPreferenceChangedListener( + SharedPreferences.OnSharedPreferenceChangeListener sharedPreferenceChangeListener) { + mPreferences.unregisterOnSharedPreferenceChangeListener(sharedPreferenceChangeListener); + } } diff --git a/app/src/main/res/drawable/ic_search_white_24dp.xml b/app/src/main/res/drawable/ic_search_white_24dp.xml new file mode 100644 index 00000000..be5ad99c --- /dev/null +++ b/app/src/main/res/drawable/ic_search_white_24dp.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index 9cf9d87f..0225787f 100755 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -26,7 +26,7 @@ + android:layout_height="wrap_content" /> @@ -53,7 +53,6 @@ android:layout_width="match_parent" android:layout_height="wrap_content"> - - + android:layout_height="wrap_content" + android:overScrollMode="never"> Primary color The primary theme color, defaults to blue grey, for now works with dark colors - Now playing themes, Carousel effect and more.. + Black theme, Now playing themes, Carousel effect and more.. Profile diff --git a/app/src/main/res/xml/pref_ui.xml b/app/src/main/res/xml/pref_ui.xml index 40538306..3df9f9d1 100644 --- a/app/src/main/res/xml/pref_ui.xml +++ b/app/src/main/res/xml/pref_ui.xml @@ -47,6 +47,12 @@ android:layout="@layout/list_item_view_switch" android:summary="@string/pref_summary_home_banner" android:title="@string/pref_title_home_banner" /> + @@ -77,7 +83,6 @@ android:layout="@layout/preference_category_title" android:title="@string/window"> -