Merge pull request #2711 from Isira-Seneviratne/ConfigurationCompat

Use ConfigurationCompat.getLocales().
This commit is contained in:
Bnyro 2023-01-16 15:02:00 +01:00 committed by GitHub
commit b925c58119
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 6 deletions

View File

@ -27,6 +27,7 @@ import android.widget.Toast
import androidx.annotation.RequiresApi
import androidx.constraintlayout.motion.widget.MotionLayout
import androidx.core.net.toUri
import androidx.core.os.ConfigurationCompat
import androidx.core.os.bundleOf
import androidx.core.view.isVisible
import androidx.fragment.app.activityViewModels
@ -829,11 +830,8 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
}
private fun localizedDate(date: String?): String? {
return if (SDK_INT >= Build.VERSION_CODES.N) {
TextUtils.localizeDate(date, resources.configuration.locales[0])
} else {
TextUtils.localizeDate(date)
}
val locale = ConfigurationCompat.getLocales(resources.configuration)[0]!!
return TextUtils.localizeDate(date, locale)
}
private fun handleLiveVideo() {

View File

@ -45,7 +45,7 @@ object TextUtils {
* @param locale The locale to use, otherwise uses system default
* return Localized date string
*/
fun localizeDate(date: String?, locale: Locale? = null): String? {
fun localizeDate(date: String?, locale: Locale): String? {
date ?: return null
// relative time span