2023-06-17 15:30:23 +02:00
|
|
|
package com.cappielloantonio.tempo.util
|
2023-03-06 21:59:10 +01:00
|
|
|
|
2024-06-01 15:23:40 +02:00
|
|
|
import android.util.Log
|
2023-06-17 15:30:23 +02:00
|
|
|
import com.cappielloantonio.tempo.App
|
2024-03-23 21:33:11 +01:00
|
|
|
import com.cappielloantonio.tempo.model.HomeSector
|
2024-02-17 23:43:02 +01:00
|
|
|
import com.cappielloantonio.tempo.subsonic.models.OpenSubsonicExtension
|
|
|
|
|
import com.google.gson.Gson
|
|
|
|
|
|
|
|
|
|
|
2023-03-06 21:59:10 +01:00
|
|
|
object Preferences {
|
|
|
|
|
const val THEME = "theme"
|
|
|
|
|
private const val SERVER = "server"
|
|
|
|
|
private const val USER = "user"
|
|
|
|
|
private const val PASSWORD = "password"
|
|
|
|
|
private const val TOKEN = "token"
|
|
|
|
|
private const val SALT = "salt"
|
|
|
|
|
private const val LOW_SECURITY = "low_security"
|
2023-06-24 12:12:14 +02:00
|
|
|
private const val BATTERY_OPTIMIZATION = "battery_optimization"
|
2023-03-06 21:59:10 +01:00
|
|
|
private const val SERVER_ID = "server_id"
|
2024-02-17 23:43:02 +01:00
|
|
|
private const val OPEN_SUBSONIC = "open_subsonic"
|
|
|
|
|
private const val OPEN_SUBSONIC_EXTENSIONS = "open_subsonic_extensions"
|
2024-06-01 15:23:40 +02:00
|
|
|
private const val LOCAL_ADDRESS = "local_address"
|
|
|
|
|
private const val IN_USE_SERVER_ADDRESS = "in_use_server_address"
|
|
|
|
|
private const val NEXT_SERVER_SWITCH = "next_server_switch"
|
2023-03-06 21:59:10 +01:00
|
|
|
private const val PLAYBACK_SPEED = "playback_speed"
|
|
|
|
|
private const val SKIP_SILENCE = "skip_silence"
|
|
|
|
|
private const val IMAGE_CACHE_SIZE = "image_cache_size"
|
2024-03-11 17:21:28 +08:00
|
|
|
private const val STREAMING_CACHE_SIZE = "streaming_cache_size"
|
2023-03-06 21:59:10 +01:00
|
|
|
private const val IMAGE_SIZE = "image_size"
|
|
|
|
|
private const val MAX_BITRATE_WIFI = "max_bitrate_wifi"
|
|
|
|
|
private const val MAX_BITRATE_MOBILE = "max_bitrate_mobile"
|
|
|
|
|
private const val AUDIO_TRANSCODE_FORMAT_WIFI = "audio_transcode_format_wifi"
|
|
|
|
|
private const val AUDIO_TRANSCODE_FORMAT_MOBILE = "audio_transcode_format_mobile"
|
|
|
|
|
private const val WIFI_ONLY = "wifi_only"
|
|
|
|
|
private const val DATA_SAVING_MODE = "data_saving_mode"
|
2023-03-13 10:55:50 +01:00
|
|
|
private const val SERVER_UNREACHABLE = "server_unreachable"
|
2023-03-06 21:59:10 +01:00
|
|
|
private const val SYNC_STARRED_TRACKS_FOR_OFFLINE_USE = "sync_starred_tracks_for_offline_use"
|
2023-03-14 11:55:35 +01:00
|
|
|
private const val QUEUE_SYNCING = "queue_syncing"
|
|
|
|
|
private const val QUEUE_SYNCING_COUNTDOWN = "queue_syncing_countdown"
|
2023-03-16 19:47:39 +01:00
|
|
|
private const val ROUNDED_CORNER = "rounded_corner"
|
|
|
|
|
private const val ROUNDED_CORNER_SIZE = "rounded_corner_size"
|
2023-06-04 11:59:25 +02:00
|
|
|
private const val PODCAST_SECTION_VISIBILITY = "podcast_section_visibility"
|
|
|
|
|
private const val RADIO_SECTION_VISIBILITY = "radio_section_visibility"
|
2023-07-02 19:36:39 +02:00
|
|
|
private const val MUSIC_DIRECTORY_SECTION_VISIBILITY = "music_directory_section_visibility"
|
2023-07-02 23:36:52 +02:00
|
|
|
private const val REPLAY_GAIN_MODE = "replay_gain_mode"
|
2023-07-20 17:20:57 +02:00
|
|
|
private const val AUDIO_TRANSCODE_PRIORITY = "audio_transcode_priority"
|
2024-05-26 14:49:57 +02:00
|
|
|
private const val STREAMING_CACHE_STORAGE = "streaming_cache_storage"
|
2023-08-04 23:46:33 +02:00
|
|
|
private const val DOWNLOAD_STORAGE = "download_storage"
|
2023-08-12 11:17:46 +02:00
|
|
|
private const val DEFAULT_DOWNLOAD_VIEW_TYPE = "default_download_view_type"
|
2023-08-13 23:17:24 +02:00
|
|
|
private const val AUDIO_TRANSCODE_DOWNLOAD = "audio_transcode_download"
|
|
|
|
|
private const val AUDIO_TRANSCODE_DOWNLOAD_PRIORITY = "audio_transcode_download_priority"
|
|
|
|
|
private const val MAX_BITRATE_DOWNLOAD = "max_bitrate_download"
|
|
|
|
|
private const val AUDIO_TRANSCODE_FORMAT_DOWNLOAD = "audio_transcode_format_download"
|
2023-09-17 18:51:22 +02:00
|
|
|
private const val SHARE = "share"
|
2023-11-26 16:39:05 +01:00
|
|
|
private const val SCROBBLING = "scrobbling"
|
2023-09-17 19:12:45 +02:00
|
|
|
private const val ESTIMATE_CONTENT_LENGTH = "estimate_content_length"
|
2023-11-26 19:10:21 +01:00
|
|
|
private const val BUFFERING_STRATEGY = "buffering_strategy"
|
2023-11-29 19:21:42 +01:00
|
|
|
private const val SKIP_MIN_STAR_RATING = "skip_min_star_rating"
|
|
|
|
|
private const val MIN_STAR_RATING = "min_star_rating"
|
2024-01-28 23:22:03 +01:00
|
|
|
private const val ALWAYS_ON_DISPLAY = "always_on_display"
|
2024-02-18 17:14:41 +01:00
|
|
|
private const val AUDIO_QUALITY_PER_ITEM = "audio_quality_per_item"
|
2024-03-23 21:33:11 +01:00
|
|
|
private const val HOME_SECTOR_LIST = "home_sector_list"
|
2024-03-24 00:45:19 +01:00
|
|
|
private const val RATING_PER_ITEM = "rating_per_item"
|
2024-05-31 22:41:01 +02:00
|
|
|
private const val NEXT_UPDATE_CHECK = "next_update_check"
|
2023-11-29 19:21:42 +01:00
|
|
|
|
2023-03-06 21:59:10 +01:00
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun getServer(): String? {
|
2024-06-01 15:23:40 +02:00
|
|
|
Log.d("Preferences++", "getServer()")
|
2023-03-06 21:59:10 +01:00
|
|
|
return App.getInstance().preferences.getString(SERVER, null)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun setServer(server: String?) {
|
|
|
|
|
App.getInstance().preferences.edit().putString(SERVER, server).apply()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun getUser(): String? {
|
|
|
|
|
return App.getInstance().preferences.getString(USER, null)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun setUser(user: String?) {
|
|
|
|
|
App.getInstance().preferences.edit().putString(USER, user).apply()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun getPassword(): String? {
|
|
|
|
|
return App.getInstance().preferences.getString(PASSWORD, null)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun setPassword(password: String?) {
|
|
|
|
|
App.getInstance().preferences.edit().putString(PASSWORD, password).apply()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun getToken(): String? {
|
|
|
|
|
return App.getInstance().preferences.getString(TOKEN, null)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun setToken(token: String?) {
|
|
|
|
|
App.getInstance().preferences.edit().putString(TOKEN, token).apply()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun getSalt(): String? {
|
|
|
|
|
return App.getInstance().preferences.getString(SALT, null)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun setSalt(salt: String?) {
|
|
|
|
|
App.getInstance().preferences.edit().putString(SALT, salt).apply()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun isLowScurity(): Boolean {
|
|
|
|
|
return App.getInstance().preferences.getBoolean(LOW_SECURITY, false)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun setLowSecurity(isLowSecurity: Boolean) {
|
|
|
|
|
App.getInstance().preferences.edit().putBoolean(LOW_SECURITY, isLowSecurity).apply()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun getServerId(): String? {
|
|
|
|
|
return App.getInstance().preferences.getString(SERVER_ID, null)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun setServerId(serverId: String?) {
|
|
|
|
|
App.getInstance().preferences.edit().putString(SERVER_ID, serverId).apply()
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-17 23:43:02 +01:00
|
|
|
@JvmStatic
|
|
|
|
|
fun isOpenSubsonic(): Boolean {
|
|
|
|
|
return App.getInstance().preferences.getBoolean(OPEN_SUBSONIC, false)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun setOpenSubsonic(isOpenSubsonic: Boolean) {
|
|
|
|
|
App.getInstance().preferences.edit().putBoolean(OPEN_SUBSONIC, isOpenSubsonic).apply()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun getOpenSubsonicExtensions(): String? {
|
|
|
|
|
return App.getInstance().preferences.getString(OPEN_SUBSONIC_EXTENSIONS, null)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun setOpenSubsonicExtensions(extension: List<OpenSubsonicExtension>) {
|
|
|
|
|
App.getInstance().preferences.edit().putString(OPEN_SUBSONIC_EXTENSIONS, Gson().toJson(extension)).apply()
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-01 15:23:40 +02:00
|
|
|
@JvmStatic
|
|
|
|
|
fun getLocalAddress(): String? {
|
|
|
|
|
return App.getInstance().preferences.getString(LOCAL_ADDRESS, null)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun setLocalAddress(address: String?) {
|
|
|
|
|
App.getInstance().preferences.edit().putString(LOCAL_ADDRESS, address).apply()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun getInUseServerAddress(): String? {
|
|
|
|
|
return App.getInstance().preferences.getString(IN_USE_SERVER_ADDRESS, getServer())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun isInUseServerAddressLocal(): Boolean {
|
|
|
|
|
return getInUseServerAddress() == getLocalAddress()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun switchInUseServerAddress() {
|
|
|
|
|
val inUseAddress = if (getInUseServerAddress() == getServer()) getLocalAddress() else getServer()
|
|
|
|
|
App.getInstance().preferences.edit().putString(IN_USE_SERVER_ADDRESS, inUseAddress).apply()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun isServerSwitchable(): Boolean {
|
|
|
|
|
return App.getInstance().preferences.getLong(
|
|
|
|
|
NEXT_SERVER_SWITCH, 0
|
2024-06-02 16:21:29 +02:00
|
|
|
) + 15000 < System.currentTimeMillis()
|
2024-06-01 15:23:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun setServerSwitchableTimer() {
|
|
|
|
|
App.getInstance().preferences.edit().putLong(NEXT_SERVER_SWITCH, System.currentTimeMillis()).apply()
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-24 12:12:14 +02:00
|
|
|
@JvmStatic
|
2023-07-30 16:57:18 +02:00
|
|
|
fun askForOptimization(): Boolean {
|
2023-06-24 12:12:14 +02:00
|
|
|
return App.getInstance().preferences.getBoolean(BATTERY_OPTIMIZATION, true)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun dontAskForOptimization() {
|
|
|
|
|
App.getInstance().preferences.edit().putBoolean(BATTERY_OPTIMIZATION, false).apply()
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-06 21:59:10 +01:00
|
|
|
@JvmStatic
|
|
|
|
|
fun getPlaybackSpeed(): Float {
|
|
|
|
|
return App.getInstance().preferences.getFloat(PLAYBACK_SPEED, 1f)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun setPlaybackSpeed(playbackSpeed: Float) {
|
|
|
|
|
App.getInstance().preferences.edit().putFloat(PLAYBACK_SPEED, playbackSpeed).apply()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun isSkipSilenceMode(): Boolean {
|
|
|
|
|
return App.getInstance().preferences.getBoolean(SKIP_SILENCE, false)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun setSkipSilenceMode(isSkipSilenceMode: Boolean) {
|
2023-03-14 11:55:35 +01:00
|
|
|
App.getInstance().preferences.edit().putBoolean(SKIP_SILENCE, isSkipSilenceMode).apply()
|
2023-03-06 21:59:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun getImageCacheSize(): Int {
|
2023-03-14 11:55:35 +01:00
|
|
|
return App.getInstance().preferences.getString(IMAGE_CACHE_SIZE, "500")!!.toInt()
|
2023-03-06 21:59:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun getImageSize(): Int {
|
|
|
|
|
return App.getInstance().preferences.getString(IMAGE_SIZE, "-1")!!.toInt()
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-11 17:21:28 +08:00
|
|
|
@JvmStatic
|
|
|
|
|
fun getStreamingCacheSize(): Long {
|
|
|
|
|
return App.getInstance().preferences.getString(STREAMING_CACHE_SIZE, "256")!!.toLong()
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-06 21:59:10 +01:00
|
|
|
@JvmStatic
|
|
|
|
|
fun getMaxBitrateWifi(): String {
|
|
|
|
|
return App.getInstance().preferences.getString(MAX_BITRATE_WIFI, "0")!!
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun getMaxBitrateMobile(): String {
|
|
|
|
|
return App.getInstance().preferences.getString(MAX_BITRATE_MOBILE, "0")!!
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun getAudioTranscodeFormatWifi(): String {
|
|
|
|
|
return App.getInstance().preferences.getString(AUDIO_TRANSCODE_FORMAT_WIFI, "raw")!!
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun getAudioTranscodeFormatMobile(): String {
|
|
|
|
|
return App.getInstance().preferences.getString(AUDIO_TRANSCODE_FORMAT_MOBILE, "raw")!!
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun isWifiOnly(): Boolean {
|
|
|
|
|
return App.getInstance().preferences.getBoolean(WIFI_ONLY, false)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun isDataSavingMode(): Boolean {
|
|
|
|
|
return App.getInstance().preferences.getBoolean(DATA_SAVING_MODE, false)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun setDataSavingMode(isDataSavingModeEnabled: Boolean) {
|
2023-03-14 11:55:35 +01:00
|
|
|
App.getInstance().preferences.edit().putBoolean(DATA_SAVING_MODE, isDataSavingModeEnabled)
|
2024-06-01 15:23:40 +02:00
|
|
|
.apply()
|
2023-03-06 21:59:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun isStarredSyncEnabled(): Boolean {
|
2023-03-14 11:55:35 +01:00
|
|
|
return App.getInstance().preferences.getBoolean(SYNC_STARRED_TRACKS_FOR_OFFLINE_USE, false)
|
2023-03-06 21:59:10 +01:00
|
|
|
}
|
|
|
|
|
|
2023-03-13 21:10:10 +01:00
|
|
|
@JvmStatic
|
|
|
|
|
fun setStarredSyncEnabled(isStarredSyncEnabled: Boolean) {
|
|
|
|
|
App.getInstance().preferences.edit().putBoolean(
|
2024-06-01 15:23:40 +02:00
|
|
|
SYNC_STARRED_TRACKS_FOR_OFFLINE_USE, isStarredSyncEnabled
|
2023-03-13 21:10:10 +01:00
|
|
|
).apply()
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-13 10:55:50 +01:00
|
|
|
@JvmStatic
|
|
|
|
|
fun showServerUnreachableDialog(): Boolean {
|
2023-03-13 17:00:43 +01:00
|
|
|
return App.getInstance().preferences.getLong(
|
2024-06-01 15:23:40 +02:00
|
|
|
SERVER_UNREACHABLE, 0
|
2024-05-31 22:41:01 +02:00
|
|
|
) + 86400000 < System.currentTimeMillis()
|
2023-03-13 10:55:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JvmStatic
|
2024-05-31 22:41:01 +02:00
|
|
|
fun setServerUnreachableDatetime() {
|
|
|
|
|
App.getInstance().preferences.edit().putLong(SERVER_UNREACHABLE, System.currentTimeMillis()).apply()
|
2023-03-14 11:55:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun isSyncronizationEnabled(): Boolean {
|
|
|
|
|
return App.getInstance().preferences.getBoolean(QUEUE_SYNCING, false)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun getSyncCountdownTimer(): Int {
|
|
|
|
|
return App.getInstance().preferences.getString(QUEUE_SYNCING_COUNTDOWN, "5")!!.toInt()
|
2023-03-13 10:55:50 +01:00
|
|
|
}
|
2023-03-16 19:47:39 +01:00
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun isCornerRoundingEnabled(): Boolean {
|
|
|
|
|
return App.getInstance().preferences.getBoolean(ROUNDED_CORNER, false)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun getRoundedCornerSize(): Int {
|
|
|
|
|
return App.getInstance().preferences.getString(ROUNDED_CORNER_SIZE, "12")!!.toInt()
|
|
|
|
|
}
|
2023-06-04 11:59:25 +02:00
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun isPodcastSectionVisible(): Boolean {
|
|
|
|
|
return App.getInstance().preferences.getBoolean(PODCAST_SECTION_VISIBILITY, true)
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-04 18:37:53 +02:00
|
|
|
@JvmStatic
|
|
|
|
|
fun setPodcastSectionHidden() {
|
|
|
|
|
App.getInstance().preferences.edit().putBoolean(PODCAST_SECTION_VISIBILITY, false).apply()
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-04 11:59:25 +02:00
|
|
|
@JvmStatic
|
|
|
|
|
fun isRadioSectionVisible(): Boolean {
|
|
|
|
|
return App.getInstance().preferences.getBoolean(RADIO_SECTION_VISIBILITY, true)
|
|
|
|
|
}
|
2023-06-04 18:37:53 +02:00
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun setRadioSectionHidden() {
|
|
|
|
|
App.getInstance().preferences.edit().putBoolean(RADIO_SECTION_VISIBILITY, false).apply()
|
|
|
|
|
}
|
2023-07-02 19:36:39 +02:00
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun isMusicDirectorySectionVisible(): Boolean {
|
|
|
|
|
return App.getInstance().preferences.getBoolean(MUSIC_DIRECTORY_SECTION_VISIBILITY, true)
|
|
|
|
|
}
|
2023-07-02 23:36:52 +02:00
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun getReplayGainMode(): String? {
|
|
|
|
|
return App.getInstance().preferences.getString(REPLAY_GAIN_MODE, "disabled")
|
|
|
|
|
}
|
2023-07-20 17:20:57 +02:00
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun isServerPrioritized(): Boolean {
|
|
|
|
|
return App.getInstance().preferences.getBoolean(AUDIO_TRANSCODE_PRIORITY, false)
|
|
|
|
|
}
|
2023-08-04 23:46:33 +02:00
|
|
|
|
2024-05-26 14:49:57 +02:00
|
|
|
@JvmStatic
|
|
|
|
|
fun getStreamingCacheStoragePreference(): Int {
|
|
|
|
|
return App.getInstance().preferences.getString(STREAMING_CACHE_STORAGE, "0")!!.toInt()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun setStreamingCacheStoragePreference(streamingCachePreference: Int) {
|
|
|
|
|
return App.getInstance().preferences.edit().putString(
|
|
|
|
|
STREAMING_CACHE_STORAGE,
|
|
|
|
|
streamingCachePreference.toString()
|
|
|
|
|
).apply()
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-04 23:46:33 +02:00
|
|
|
@JvmStatic
|
|
|
|
|
fun getDownloadStoragePreference(): Int {
|
|
|
|
|
return App.getInstance().preferences.getString(DOWNLOAD_STORAGE, "0")!!.toInt()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun setDownloadStoragePreference(storagePreference: Int) {
|
|
|
|
|
return App.getInstance().preferences.edit().putString(
|
2024-06-01 15:23:40 +02:00
|
|
|
DOWNLOAD_STORAGE,
|
|
|
|
|
storagePreference.toString()
|
2023-08-04 23:46:33 +02:00
|
|
|
).apply()
|
|
|
|
|
}
|
2023-08-12 11:17:46 +02:00
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun getDefaultDownloadViewType(): String {
|
|
|
|
|
return App.getInstance().preferences.getString(
|
2024-06-01 15:23:40 +02:00
|
|
|
DEFAULT_DOWNLOAD_VIEW_TYPE,
|
|
|
|
|
Constants.DOWNLOAD_TYPE_TRACK
|
2023-08-12 11:17:46 +02:00
|
|
|
)!!
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun setDefaultDownloadViewType(viewType: String) {
|
|
|
|
|
return App.getInstance().preferences.edit().putString(
|
2024-06-01 15:23:40 +02:00
|
|
|
DEFAULT_DOWNLOAD_VIEW_TYPE,
|
|
|
|
|
viewType
|
2023-08-12 11:17:46 +02:00
|
|
|
).apply()
|
|
|
|
|
}
|
2023-08-13 23:17:24 +02:00
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun preferTranscodedDownload(): Boolean {
|
|
|
|
|
return App.getInstance().preferences.getBoolean(AUDIO_TRANSCODE_DOWNLOAD, false)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun isServerPrioritizedInTranscodedDownload(): Boolean {
|
|
|
|
|
return App.getInstance().preferences.getBoolean(AUDIO_TRANSCODE_DOWNLOAD_PRIORITY, false)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun getBitrateTranscodedDownload(): String {
|
|
|
|
|
return App.getInstance().preferences.getString(MAX_BITRATE_DOWNLOAD, "0")!!
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun getAudioTranscodeFormatTranscodedDownload(): String {
|
|
|
|
|
return App.getInstance().preferences.getString(AUDIO_TRANSCODE_FORMAT_DOWNLOAD, "raw")!!
|
|
|
|
|
}
|
2023-09-17 18:51:22 +02:00
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun isSharingEnabled(): Boolean {
|
|
|
|
|
return App.getInstance().preferences.getBoolean(SHARE, false)
|
|
|
|
|
}
|
2023-09-17 19:12:45 +02:00
|
|
|
|
2023-11-26 16:39:05 +01:00
|
|
|
@JvmStatic
|
|
|
|
|
fun isScrobblingEnabled(): Boolean {
|
|
|
|
|
return App.getInstance().preferences.getBoolean(SCROBBLING, true)
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-17 19:12:45 +02:00
|
|
|
@JvmStatic
|
|
|
|
|
fun askForEstimateContentLength(): Boolean {
|
|
|
|
|
return App.getInstance().preferences.getBoolean(ESTIMATE_CONTENT_LENGTH, false)
|
|
|
|
|
}
|
2023-11-26 19:10:21 +01:00
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun getBufferingStrategy(): Double {
|
|
|
|
|
return App.getInstance().preferences.getString(BUFFERING_STRATEGY, "1")!!.toDouble()
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-29 19:21:42 +01:00
|
|
|
@JvmStatic
|
|
|
|
|
fun getMinStarRatingAccepted(): Int {
|
|
|
|
|
return App.getInstance().preferences.getInt(MIN_STAR_RATING, 0)
|
|
|
|
|
}
|
2024-01-28 23:03:20 +01:00
|
|
|
|
2024-01-28 23:22:03 +01:00
|
|
|
@JvmStatic
|
|
|
|
|
fun isDisplayAlwaysOn(): Boolean {
|
|
|
|
|
return App.getInstance().preferences.getBoolean(ALWAYS_ON_DISPLAY, false)
|
|
|
|
|
}
|
2024-02-18 17:14:41 +01:00
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun showAudioQuality(): Boolean {
|
|
|
|
|
return App.getInstance().preferences.getBoolean(AUDIO_QUALITY_PER_ITEM, false)
|
|
|
|
|
}
|
2024-03-23 21:33:11 +01:00
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun getHomeSectorList(): String? {
|
|
|
|
|
return App.getInstance().preferences.getString(HOME_SECTOR_LIST, null)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun setHomeSectorList(extension: List<HomeSector>?) {
|
|
|
|
|
App.getInstance().preferences.edit().putString(HOME_SECTOR_LIST, Gson().toJson(extension)).apply()
|
|
|
|
|
}
|
2024-03-24 00:45:19 +01:00
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun showItemRating(): Boolean {
|
|
|
|
|
return App.getInstance().preferences.getBoolean(RATING_PER_ITEM, false)
|
|
|
|
|
}
|
2024-05-31 22:41:01 +02:00
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun showTempoUpdateDialog(): Boolean {
|
|
|
|
|
return App.getInstance().preferences.getLong(
|
|
|
|
|
NEXT_UPDATE_CHECK, 0
|
|
|
|
|
) + 86400000 < System.currentTimeMillis()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun setTempoUpdateReminder() {
|
|
|
|
|
App.getInstance().preferences.edit().putLong(NEXT_UPDATE_CHECK, System.currentTimeMillis()).apply()
|
|
|
|
|
}
|
2023-03-06 21:59:10 +01:00
|
|
|
}
|