Localize strings

This commit is contained in:
Mygod
2020-07-04 04:34:58 +08:00
parent 5e5016b059
commit 46d0544df2
5 changed files with 27 additions and 15 deletions

View File

@@ -165,23 +165,25 @@ sealed class TetherManager(protected val parent: TetheringFragment) : Manager(),
override val title get() = parent.getString(R.string.tethering_manage_wifi)
override val tetherType get() = TetherType.WIFI
override val type get() = VIEW_TYPE_WIFI
override val text get() = listOfNotNull(failureReason?.let { WifiApManager.failureReasonLookup(it) },
override val text get() = listOfNotNull(failureReason?.let { WifiApManager.failureReasonLookup(it) }, baseError,
if (frequency != 0 || bandwidth != WifiApManager.CHANNEL_WIDTH_INVALID) {
"$frequency MHz, channel ${SoftApConfigurationCompat.frequencyToChannel(frequency)}, width " +
WifiApManager.channelWidthLookup(bandwidth, true)
parent.getString(R.string.tethering_manage_wifi_info, frequency,
SoftApConfigurationCompat.frequencyToChannel(frequency),
WifiApManager.channelWidthLookup(bandwidth, true))
} else null,
capability?.let { (maxSupportedClients, supportedFeatures) ->
"${numClients ?: "?"}/$maxSupportedClients clients connected\nSupported features: " + sequence {
app.getString(R.string.tethering_manage_wifi_capabilities, numClients ?: "?",
maxSupportedClients, sequence {
var features = supportedFeatures
if (features == 0L) yield("None") else while (features != 0L) {
if (features == 0L) yield(parent.getString(R.string.tethering_manage_wifi_no_features))
else while (features != 0L) {
@OptIn(ExperimentalStdlibApi::class)
val bit = features.takeLowestOneBit()
yield(WifiApManager.featureLookup(bit, true))
features = features and bit.inv()
}
}.joinToString()
},
baseError).joinToString("\n")
}.joinToString())
}).joinToString("\n")
override fun start() = TetheringManager.startTethering(TetheringManager.TETHERING_WIFI, true, this)
override fun stop() = TetheringManager.stopTethering(TetheringManager.TETHERING_WIFI, this::onException)

View File

@@ -44,7 +44,7 @@ enum class TetherType(@DrawableRes val icon: Int) {
private fun Pair<String?, Resources>.getRegexs(name: String) = second.getIdentifier(name, "array", first).let {
if (it == 0) {
Timber.i("$name is empty")
if (name == "config_tether_wigig_regexs") Timber.i("$name is empty") else Timber.w(Exception(name))
emptyList()
} else second.getStringArray(it).filterNotNull().map { it.toPattern() }
}

View File

@@ -148,7 +148,8 @@ class WifiApDialogFragment : AlertDialogFragment<WifiApDialogFragment.Arg, WifiA
if (!arg.readOnly) dialogView.password.addTextChangedListener(this@WifiApDialogFragment)
if (!arg.p2pMode && Build.VERSION.SDK_INT < 28) dialogView.autoShutdown.isGone = true
if (arg.p2pMode || Build.VERSION.SDK_INT >= 30) {
dialogView.timeoutWrapper.helperText = "Default timeout: ${TetherTimeoutMonitor.defaultTimeout}ms"
dialogView.timeoutWrapper.helperText = getString(R.string.wifi_hotspot_timeout_default,
TetherTimeoutMonitor.defaultTimeout)
if (!arg.readOnly) dialogView.timeout.addTextChangedListener(this@WifiApDialogFragment)
} else dialogView.timeoutWrapper.isGone = true
if (Build.VERSION.SDK_INT >= 23 || arg.p2pMode) dialogView.band.apply {