From b7d0ca4882fbfea916199f98a1c73ad611052fbc Mon Sep 17 00:00:00 2001 From: Konstantin Aksenov Date: Wed, 3 Jan 2024 20:22:51 +1000 Subject: [PATCH] feat(utilities): add plurals and varargs strings support --- .../kakaocup/kakao/common/utilities/ContextUtils.kt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/kakao/src/main/kotlin/io/github/kakaocup/kakao/common/utilities/ContextUtils.kt b/kakao/src/main/kotlin/io/github/kakaocup/kakao/common/utilities/ContextUtils.kt index 2e8578ec3..286d95a80 100644 --- a/kakao/src/main/kotlin/io/github/kakaocup/kakao/common/utilities/ContextUtils.kt +++ b/kakao/src/main/kotlin/io/github/kakaocup/kakao/common/utilities/ContextUtils.kt @@ -2,13 +2,22 @@ package io.github.kakaocup.kakao.common.utilities import androidx.annotation.ColorRes import androidx.annotation.DrawableRes +import androidx.annotation.PluralsRes import androidx.annotation.StringRes import androidx.core.content.ContextCompat import androidx.test.platform.app.InstrumentationRegistry -fun getResourceString(@StringRes resId: Int) = InstrumentationRegistry.getInstrumentation().targetContext.resources.getString(resId) +fun getResourceString(@StringRes resId: Int) = + InstrumentationRegistry.getInstrumentation().targetContext.resources.getString(resId) + +fun getResourceString(@StringRes resId: Int, vararg args: Any) = + InstrumentationRegistry.getInstrumentation().targetContext.resources.getString(resId, args) + +fun getQuantityString(@PluralsRes resId: Int, quantity: Int) = + InstrumentationRegistry.getInstrumentation().targetContext.resources.getQuantityString(resId, quantity) fun getResourceDrawable(@DrawableRes resId: Int) = ContextCompat.getDrawable(InstrumentationRegistry.getInstrumentation().targetContext, resId) -fun getResourceColor(@ColorRes resId: Int) = ContextCompat.getColor(InstrumentationRegistry.getInstrumentation().targetContext, resId) +fun getResourceColor(@ColorRes resId: Int) = + ContextCompat.getColor(InstrumentationRegistry.getInstrumentation().targetContext, resId)