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

View File

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