diff --git a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/activity/NavigationActivity.kt b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/activity/NavigationActivity.kt index 7c399d6c..5dac3838 100644 --- a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/activity/NavigationActivity.kt +++ b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/activity/NavigationActivity.kt @@ -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) diff --git a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/fragment/SettingsFragment.kt b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/fragment/SettingsFragment.kt index 3b383089..5e90715d 100644 --- a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/fragment/SettingsFragment.kt +++ b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/fragment/SettingsFragment.kt @@ -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) diff --git a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/util/Constants.kt b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/util/Constants.kt index 9f44202b..0f12af49 100644 --- a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/util/Constants.kt +++ b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/util/Constants.kt @@ -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 diff --git a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/util/Settings.kt b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/util/Settings.kt index a6a131ec..018fa98c 100644 --- a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/util/Settings.kt +++ b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/util/Settings.kt @@ -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) diff --git a/ultrasonic/src/main/res/values/strings.xml b/ultrasonic/src/main/res/values/strings.xml index b4e81c76..551043dc 100644 --- a/ultrasonic/src/main/res/values/strings.xml +++ b/ultrasonic/src/main/res/values/strings.xml @@ -317,7 +317,8 @@ Browse Using ID3 Tags Use ID3 tag methods instead of file system based methods Use ID3 method also when offline - (Experimental) + Experimental: If you enable this Setting it will only show the music that you have downloaded with Ultrasonic 4.0 or later. + 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. Show artist picture in artist list Displays the artist picture in the artist list if available Video