mirror of
https://github.com/wgtunnel/android.git
synced 2026-07-03 14:07:49 +02:00
25 lines
598 B
Kotlin
25 lines
598 B
Kotlin
package com.zaneschepke.wireguardautotunnel.util
|
|
|
|
import android.content.Context
|
|
import androidx.annotation.StringRes
|
|
|
|
sealed class StringValue {
|
|
|
|
data class DynamicString(val value: String) : StringValue()
|
|
|
|
data object Empty : StringValue()
|
|
|
|
class StringResource(
|
|
@StringRes val resId: Int,
|
|
vararg val args: Any
|
|
) : StringValue()
|
|
|
|
fun asString(context: Context?): String {
|
|
return when (this) {
|
|
is Empty -> ""
|
|
is DynamicString -> value
|
|
is StringResource -> context?.getString(resId, *args).orEmpty()
|
|
}
|
|
}
|
|
}
|