Add clearer warning to ID3 offline setting

This commit is contained in:
tzugen 2022-07-07 18:53:36 +02:00
parent de0cb7713b
commit ecfce59e0f
No known key found for this signature in database
GPG Key ID: 61E9C34BC10EC930
5 changed files with 41 additions and 3 deletions

View File

@ -392,6 +392,8 @@ class NavigationActivity : AppCompatActivity() {
if (!infoDialogDisplayed) { if (!infoDialogDisplayed) {
infoDialogDisplayed = true infoDialogDisplayed = true
Settings.firstInstalledVersion = Util.getVersionCode(UApp.applicationContext())
InfoDialog.Builder(this) InfoDialog.Builder(this)
.setTitle(R.string.main_welcome_title) .setTitle(R.string.main_welcome_title)
.setMessage(R.string.main_welcome_text_demo) .setMessage(R.string.main_welcome_text_demo)

View File

@ -6,11 +6,16 @@ import android.content.DialogInterface
import android.content.Intent import android.content.Intent
import android.content.SharedPreferences import android.content.SharedPreferences
import android.content.SharedPreferences.OnSharedPreferenceChangeListener import android.content.SharedPreferences.OnSharedPreferenceChangeListener
import android.graphics.Color
import android.graphics.Typeface
import android.net.Uri import android.net.Uri
import android.os.Build import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.provider.DocumentsContract import android.provider.DocumentsContract
import android.provider.SearchRecentSuggestions import android.provider.SearchRecentSuggestions
import android.text.SpannableString
import android.text.style.ForegroundColorSpan
import android.text.style.StyleSpan
import android.view.View import android.view.View
import androidx.annotation.StringRes import androidx.annotation.StringRes
import androidx.fragment.app.DialogFragment import androidx.fragment.app.DialogFragment
@ -126,11 +131,35 @@ class SettingsFragment :
customCacheLocation = findPreference(Constants.PREFERENCES_KEY_CUSTOM_CACHE_LOCATION) customCacheLocation = findPreference(Constants.PREFERENCES_KEY_CUSTOM_CACHE_LOCATION)
sharingDefaultGreeting?.text = shareGreeting sharingDefaultGreeting?.text = shareGreeting
setupTextColors()
setupClearSearchPreference() setupClearSearchPreference()
setupCacheLocationPreference() setupCacheLocationPreference()
setupBluetoothDevicePreferences() 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?) { override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState) super.onActivityCreated(savedInstanceState)
update() update()
@ -198,8 +227,10 @@ class SettingsFragment :
setDebugLogToFile(sharedPreferences.getBoolean(key, false)) setDebugLogToFile(sharedPreferences.getBoolean(key, false))
} }
Constants.PREFERENCES_KEY_ID3_TAGS -> { Constants.PREFERENCES_KEY_ID3_TAGS -> {
showArtistPicture?.isEnabled = sharedPreferences.getBoolean(key, false) val enabled = sharedPreferences.getBoolean(key, false)
useId3TagsOffline?.isEnabled = sharedPreferences.getBoolean(key, false) showArtistPicture?.isEnabled = enabled
useId3TagsOffline?.isEnabled = enabled
setupTextColors(enabled)
} }
Constants.PREFERENCES_KEY_THEME -> { Constants.PREFERENCES_KEY_THEME -> {
RxBus.themeChangedEventPublisher.onNext(Unit) RxBus.themeChangedEventPublisher.onNext(Unit)

View File

@ -105,6 +105,7 @@ object Constants {
const val PREFERENCES_KEY_PAUSE_ON_BLUETOOTH_DEVICE = "pauseOnBluetoothDevice" const val PREFERENCES_KEY_PAUSE_ON_BLUETOOTH_DEVICE = "pauseOnBluetoothDevice"
const val PREFERENCES_KEY_DEBUG_LOG_TO_FILE = "debugLogToFile" const val PREFERENCES_KEY_DEBUG_LOG_TO_FILE = "debugLogToFile"
const val PREFERENCES_KEY_OVERRIDE_LANGUAGE = "overrideLanguage" const val PREFERENCES_KEY_OVERRIDE_LANGUAGE = "overrideLanguage"
const val PREFERENCES_FIRST_INSTALLED_VERSION = "firstInstalledVersion"
const val PREFERENCE_VALUE_ALL = 0 const val PREFERENCE_VALUE_ALL = 0
const val PREFERENCE_VALUE_A2DP = 1 const val PREFERENCE_VALUE_A2DP = 1
const val PREFERENCE_VALUE_DISABLED = 2 const val PREFERENCE_VALUE_DISABLED = 2

View File

@ -251,6 +251,9 @@ object Settings {
var useHwOffload by BooleanSetting(Constants.PREFERENCES_KEY_HARDWARE_OFFLOAD, false) 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 // TODO: Remove in December 2022
fun migrateFeatureStorage() { fun migrateFeatureStorage() {
val sp = appContext.getSharedPreferences("feature_flags", Context.MODE_PRIVATE) val sp = appContext.getSharedPreferences("feature_flags", Context.MODE_PRIVATE)

View File

@ -317,7 +317,8 @@
<string name="settings.use_id3">Browse Using ID3 Tags</string> <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_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">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">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="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> <string name="main.video" tools:ignore="UnusedResources">Video</string>