Compare commits
2 Commits
de0cb7713b
...
798d795e81
Author | SHA1 | Date |
---|---|---|
tzugen | 798d795e81 | |
tzugen | ecfce59e0f |
|
@ -392,6 +392,8 @@ class NavigationActivity : AppCompatActivity() {
|
|||
if (!infoDialogDisplayed) {
|
||||
infoDialogDisplayed = true
|
||||
|
||||
Settings.firstInstalledVersion = Util.getVersionCode(UApp.applicationContext())
|
||||
|
||||
InfoDialog.Builder(this)
|
||||
.setTitle(R.string.main_welcome_title)
|
||||
.setMessage(R.string.main_welcome_text_demo)
|
||||
|
|
|
@ -19,6 +19,12 @@ interface AlbumDao : GenericDao<Album> {
|
|||
@Query("SELECT * FROM albums")
|
||||
fun get(): List<Album>
|
||||
|
||||
/**
|
||||
* Get all albums in a specific range
|
||||
*/
|
||||
@Query("SELECT * FROM albums LIMIT :offset,:size")
|
||||
fun get(size: Int, offset: Int = 0): List<Album>
|
||||
|
||||
/**
|
||||
* Get album by id
|
||||
*/
|
||||
|
|
|
@ -66,17 +66,17 @@ class MainFragment : Fragment(), KoinComponent {
|
|||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
var shouldRestart = false
|
||||
var shouldRelayout = false
|
||||
val currentId3Setting = Settings.shouldUseId3Tags
|
||||
|
||||
// If setting has changed...
|
||||
if (currentId3Setting != cachedId3Setting) {
|
||||
cachedId3Setting = currentId3Setting
|
||||
shouldRestart = true
|
||||
if (currentId3Setting != useId3) {
|
||||
useId3 = currentId3Setting
|
||||
shouldRelayout = true
|
||||
}
|
||||
|
||||
// then setup the list anew.
|
||||
if (shouldRestart) {
|
||||
if (shouldRelayout) {
|
||||
setupItemVisibility()
|
||||
}
|
||||
}
|
||||
|
@ -109,17 +109,19 @@ class MainFragment : Fragment(), KoinComponent {
|
|||
|
||||
private fun setupItemVisibility() {
|
||||
// Cache some values
|
||||
cachedId3Setting = Settings.shouldUseId3Tags
|
||||
useId3 = Settings.shouldUseId3Tags
|
||||
useId3Offline = Settings.useId3TagsOffline
|
||||
|
||||
val isOnline = !isOffline()
|
||||
|
||||
// Music
|
||||
musicTitle.isVisible = true
|
||||
artistsButton.isVisible = true
|
||||
albumsButton.isVisible = isOnline
|
||||
albumsButton.isVisible = isOnline || useId3Offline
|
||||
genresButton.isVisible = true
|
||||
|
||||
// Songs
|
||||
songsTitle.isVisible = isOnline
|
||||
songsTitle.isVisible = true
|
||||
randomSongsButton.isVisible = true
|
||||
songsStarredButton.isVisible = isOnline
|
||||
|
||||
|
@ -128,7 +130,7 @@ class MainFragment : Fragment(), KoinComponent {
|
|||
albumsNewestButton.isVisible = isOnline
|
||||
albumsRecentButton.isVisible = isOnline
|
||||
albumsFrequentButton.isVisible = isOnline
|
||||
albumsHighestButton.isVisible = isOnline && !cachedId3Setting
|
||||
albumsHighestButton.isVisible = isOnline && !useId3
|
||||
albumsRandomButton.isVisible = isOnline
|
||||
albumsStarredButton.isVisible = isOnline
|
||||
albumsAlphaByNameButton.isVisible = isOnline
|
||||
|
@ -240,6 +242,7 @@ class MainFragment : Fragment(), KoinComponent {
|
|||
}
|
||||
|
||||
companion object {
|
||||
private var cachedId3Setting = false
|
||||
private var useId3 = false
|
||||
private var useId3Offline = false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,11 +6,16 @@ import android.content.DialogInterface
|
|||
import android.content.Intent
|
||||
import android.content.SharedPreferences
|
||||
import android.content.SharedPreferences.OnSharedPreferenceChangeListener
|
||||
import android.graphics.Color
|
||||
import android.graphics.Typeface
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.provider.DocumentsContract
|
||||
import android.provider.SearchRecentSuggestions
|
||||
import android.text.SpannableString
|
||||
import android.text.style.ForegroundColorSpan
|
||||
import android.text.style.StyleSpan
|
||||
import android.view.View
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.fragment.app.DialogFragment
|
||||
|
@ -126,11 +131,35 @@ class SettingsFragment :
|
|||
customCacheLocation = findPreference(Constants.PREFERENCES_KEY_CUSTOM_CACHE_LOCATION)
|
||||
|
||||
sharingDefaultGreeting?.text = shareGreeting
|
||||
|
||||
setupTextColors()
|
||||
setupClearSearchPreference()
|
||||
setupCacheLocationPreference()
|
||||
setupBluetoothDevicePreferences()
|
||||
}
|
||||
|
||||
private fun setupTextColors(enabled: Boolean = shouldUseId3Tags) {
|
||||
val firstPart = getString(R.string.settings_use_id3_offline_warning)
|
||||
var secondPart = getString(R.string.settings_use_id3_offline_summary)
|
||||
|
||||
// Little hack to circumvent a bug in Android. If we just change the color,
|
||||
// the text is not refreshed. If we also change the string, it is refreshed.
|
||||
if (enabled) secondPart += " "
|
||||
|
||||
val color = if (enabled) "#bd5164" else "#813b48"
|
||||
|
||||
Timber.i(color)
|
||||
|
||||
val warning = SpannableString(firstPart + "\n" + secondPart)
|
||||
warning.setSpan(
|
||||
ForegroundColorSpan(Color.parseColor(color)), 0, firstPart.length, 0
|
||||
)
|
||||
warning.setSpan(
|
||||
StyleSpan(Typeface.BOLD), 0, firstPart.length, 0
|
||||
)
|
||||
useId3TagsOffline?.summary = warning
|
||||
}
|
||||
|
||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||
super.onActivityCreated(savedInstanceState)
|
||||
update()
|
||||
|
@ -198,8 +227,10 @@ class SettingsFragment :
|
|||
setDebugLogToFile(sharedPreferences.getBoolean(key, false))
|
||||
}
|
||||
Constants.PREFERENCES_KEY_ID3_TAGS -> {
|
||||
showArtistPicture?.isEnabled = sharedPreferences.getBoolean(key, false)
|
||||
useId3TagsOffline?.isEnabled = sharedPreferences.getBoolean(key, false)
|
||||
val enabled = sharedPreferences.getBoolean(key, false)
|
||||
showArtistPicture?.isEnabled = enabled
|
||||
useId3TagsOffline?.isEnabled = enabled
|
||||
setupTextColors(enabled)
|
||||
}
|
||||
Constants.PREFERENCES_KEY_THEME -> {
|
||||
RxBus.themeChangedEventPublisher.onNext(Unit)
|
||||
|
|
|
@ -328,7 +328,8 @@ class OfflineMusicService : MusicService, KoinComponent {
|
|||
offset: Int,
|
||||
musicFolderId: String?
|
||||
): List<Album> {
|
||||
throw OfflineException("getAlbumList2 isn't available in offline mode")
|
||||
// TODO: Implement filtering by musicFolder?
|
||||
return cachedAlbums.get(size, offset)
|
||||
}
|
||||
|
||||
@Throws(Exception::class)
|
||||
|
|
|
@ -105,6 +105,7 @@ object Constants {
|
|||
const val PREFERENCES_KEY_PAUSE_ON_BLUETOOTH_DEVICE = "pauseOnBluetoothDevice"
|
||||
const val PREFERENCES_KEY_DEBUG_LOG_TO_FILE = "debugLogToFile"
|
||||
const val PREFERENCES_KEY_OVERRIDE_LANGUAGE = "overrideLanguage"
|
||||
const val PREFERENCES_FIRST_INSTALLED_VERSION = "firstInstalledVersion"
|
||||
const val PREFERENCE_VALUE_ALL = 0
|
||||
const val PREFERENCE_VALUE_A2DP = 1
|
||||
const val PREFERENCE_VALUE_DISABLED = 2
|
||||
|
|
|
@ -251,6 +251,9 @@ object Settings {
|
|||
|
||||
var useHwOffload by BooleanSetting(Constants.PREFERENCES_KEY_HARDWARE_OFFLOAD, false)
|
||||
|
||||
@JvmStatic
|
||||
var firstInstalledVersion by IntSetting(Constants.PREFERENCES_FIRST_INSTALLED_VERSION, 0)
|
||||
|
||||
// TODO: Remove in December 2022
|
||||
fun migrateFeatureStorage() {
|
||||
val sp = appContext.getSharedPreferences("feature_flags", Context.MODE_PRIVATE)
|
||||
|
|
|
@ -317,7 +317,8 @@
|
|||
<string name="settings.use_id3">Browse Using ID3 Tags</string>
|
||||
<string name="settings.use_id3_summary">Use ID3 tag methods instead of file system based methods</string>
|
||||
<string name="settings.use_id3_offline">Use ID3 method also when offline</string>
|
||||
<string name="settings.use_id3_offline_summary">(Experimental)</string>
|
||||
<string name="settings.use_id3_offline_warning">Experimental: If you enable this Setting it will only show the music that you have downloaded with Ultrasonic 4.0 or later.</string>
|
||||
<string name="settings.use_id3_offline_summary">Earlier downloads don\'t have the necessary metadata downloaded. You can toggle between Pin and Save mode to trigger the download of the missing metadata.</string>
|
||||
<string name="settings.show_artist_picture">Show artist picture in artist list</string>
|
||||
<string name="settings.show_artist_picture_summary">Displays the artist picture in the artist list if available</string>
|
||||
<string name="main.video" tools:ignore="UnusedResources">Video</string>
|
||||
|
|
Loading…
Reference in New Issue