Add gsNotLocalised in ResourceHelper
This commit is contained in:
parent
62443f6738
commit
04ef92eb78
2 changed files with 9 additions and 0 deletions
|
@ -10,6 +10,7 @@ interface ResourceHelper {
|
|||
fun gs(@StringRes id: Int): String
|
||||
fun gs(@StringRes id: Int, vararg args: Any?): String
|
||||
fun gq(@PluralsRes id: Int, quantity: Int, vararg args: Any?): String
|
||||
fun gsNotLocalised(@StringRes id: Int, vararg args: Any?): String
|
||||
fun gc(@ColorRes id: Int): Int
|
||||
fun gd(@DrawableRes id: Int): Drawable?
|
||||
fun gb(@BoolRes id :Int) : Boolean
|
||||
|
|
|
@ -3,6 +3,7 @@ package info.nightscout.androidaps.utils.resources
|
|||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.res.AssetFileDescriptor
|
||||
import android.content.res.Configuration
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.BitmapFactory
|
||||
import android.graphics.drawable.Drawable
|
||||
|
@ -10,6 +11,7 @@ import android.util.DisplayMetrics
|
|||
import androidx.annotation.*
|
||||
import androidx.core.content.ContextCompat
|
||||
import info.nightscout.androidaps.core.R
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
|
@ -24,6 +26,12 @@ class ResourceHelperImplementation @Inject constructor(private val context: Cont
|
|||
override fun gq(@PluralsRes id: Int, quantity: Int, vararg args: Any?): String =
|
||||
context.resources.getQuantityString(id, quantity, *args)
|
||||
|
||||
override fun gsNotLocalised(@StringRes id: Int, vararg args: Any?) : String =
|
||||
with(Configuration(context.resources.configuration)) {
|
||||
setLocale(Locale.ENGLISH)
|
||||
context.createConfigurationContext(this).getString(id, args)
|
||||
}
|
||||
|
||||
override fun gc(@ColorRes id: Int): Int = ContextCompat.getColor(context, id)
|
||||
|
||||
override fun gd(@DrawableRes id: Int): Drawable? = context.getDrawable(id)
|
||||
|
|
Loading…
Reference in a new issue