Rewrite SpanFormatter for more kotlin

This commit is contained in:
Mygod
2021-05-26 19:49:45 -04:00
parent 7a40927bcc
commit a69d635f93
4 changed files with 56 additions and 93 deletions

View File

@@ -13,8 +13,8 @@ import androidx.preference.Preference
import be.mygod.vpnhotspot.R
import be.mygod.vpnhotspot.net.monitor.FallbackUpstreamMonitor
import be.mygod.vpnhotspot.net.monitor.UpstreamMonitor
import be.mygod.vpnhotspot.util.SpanFormatter
import be.mygod.vpnhotspot.util.allRoutes
import be.mygod.vpnhotspot.util.format
import be.mygod.vpnhotspot.util.parseNumericAddress
import timber.log.Timber
@@ -72,7 +72,7 @@ class UpstreamsPreference(context: Context, attrs: AttributeSet) : Preference(co
}
private fun onUpdate() = (context as LifecycleOwner).lifecycleScope.launchWhenStarted {
summary = SpanFormatter.format(context.getText(R.string.settings_service_upstream_monitor_summary),
primary.charSequence, fallback.charSequence)
summary = context.getText(R.string.settings_service_upstream_monitor_summary).format(
context.resources.configuration.locale, primary.charSequence, fallback.charSequence)
}
}