KakaoCup / Kakao

Nice and simple DSL for Espresso in Kotlin
https://kakaocup.github.io/Kakao/
Apache License 2.0
324 stars 28 forks source link

Implement more extensions to access android resources #110

Closed MarinaShaposhnikova closed 7 months ago

MarinaShaposhnikova commented 8 months ago

Steps to reproduce:

  1. Open ContextUtils.kt
  2. Observe only 3 ext methods
  3. Call Vacxe

Expected Results:

I would like to have more extension to use because right now the codebase is not consistent. We use the ext method getResourceString to access the string, but if we would like to access the string with args or a quantity string, we have to either have our own ext or invoke InstrumentationRegistry directly.

Relevant Code:

fun getQuantityString(@PluralsRes resId: Int, quantity: Int) = 
   InstrumentationRegistry.getInstrumentation().targetContext.resources.getQuantityString(
                resId,
                quantity,
            )
fun getResourceString(@StringRes resId: Int, vararg args: Any) = 
    InstrumentationRegistry.getInstrumentation().targetContext.resources.getString(
                resId,
                args,
            ) 

PR with reproduction on Sample App