Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d2b63667 authored by Chaohui Wang's avatar Chaohui Wang
Browse files

Annotate SafeVarargs to formatString

So no warnings when using in Java.

Bug: 199230342
Test: Robo test
Change-Id: Icf43f5aa6c9415d0d2ef713f9b1e08a72acd4f45
parent 818be438
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -25,10 +25,12 @@ import androidx.annotation.StringRes
import java.util.Locale

@RequiresApi(Build.VERSION_CODES.N)
@SafeVarargs
fun Context.formatString(@StringRes resId: Int, vararg arguments: Pair<String, Any>): String =
    resources.formatString(resId, *arguments)

@RequiresApi(Build.VERSION_CODES.N)
@SafeVarargs
fun Resources.formatString(@StringRes resId: Int, vararg arguments: Pair<String, Any>): String =
    MessageFormat(getString(resId), Locale.getDefault(Locale.Category.FORMAT))
        .format(mapOf(*arguments))