add system option for language selection
This commit is contained in:
parent
dac4909554
commit
82365bc920
3 changed files with 16 additions and 10 deletions
|
|
@ -7,6 +7,7 @@ import android.content.DialogInterface
|
|||
import android.content.Intent
|
||||
import android.content.SharedPreferences
|
||||
import android.content.pm.PackageManager
|
||||
import android.content.res.Resources
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.os.PowerManager
|
||||
|
|
@ -68,12 +69,15 @@ class GeneralSettingsFragment : BaseSettingsFragment() {
|
|||
}
|
||||
|
||||
findPreference<ListPreference>("app_language")?.apply {
|
||||
if (value.isNullOrBlank()) {
|
||||
value = Locale.getDefault().language
|
||||
}
|
||||
value = Locale.getDefault().language
|
||||
summary = Locale.getDefault().displayLanguage
|
||||
|
||||
setOnPreferenceChangeListener { _, newValue ->
|
||||
AppCompatDelegate.setApplicationLocales(LocaleListCompat.forLanguageTags(newValue.toString()))
|
||||
if (newValue == "system") {
|
||||
AppCompatDelegate.setApplicationLocales(LocaleListCompat.forLanguageTags(null))
|
||||
}else{
|
||||
AppCompatDelegate.setApplicationLocales(LocaleListCompat.forLanguageTags(newValue.toString()))
|
||||
}
|
||||
summary = Locale.getDefault().displayLanguage
|
||||
true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -280,9 +280,12 @@ class DownloadWorker(
|
|||
}
|
||||
}catch (e: Exception){
|
||||
e.printStackTrace()
|
||||
handler.postDelayed({
|
||||
Toast.makeText(context, e.message, Toast.LENGTH_SHORT).show()
|
||||
}, 1000)
|
||||
if (e.message?.isNotBlank() == true) {
|
||||
handler.postDelayed({
|
||||
Toast.makeText(context, e.message, Toast.LENGTH_SHORT).show()
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -387,9 +390,6 @@ class DownloadWorker(
|
|||
}
|
||||
|
||||
tempFileDir.delete()
|
||||
handler.postDelayed({
|
||||
Toast.makeText(context, it.message, Toast.LENGTH_LONG).show()
|
||||
}, 1000)
|
||||
|
||||
Log.e(TAG, context.getString(R.string.failed_download), it)
|
||||
notificationUtil.cancelDownloadNotification(downloadItem.id.toInt())
|
||||
|
|
|
|||
|
|
@ -127,6 +127,7 @@
|
|||
|
||||
|
||||
<string-array name="language_entries">
|
||||
<item>System</item>
|
||||
<item>English</item>
|
||||
<item>العربية</item>
|
||||
<item>Azərbaycanca</item>
|
||||
|
|
@ -171,6 +172,7 @@
|
|||
</string-array>
|
||||
|
||||
<string-array name="language_values">
|
||||
<item>system</item>
|
||||
<item>en</item>
|
||||
<item>ar</item>
|
||||
<item>az</item>
|
||||
|
|
|
|||
Loading…
Reference in a new issue