refactor: Move MokoExtensions to i18n module

This commit is contained in:
Ahmad Ansori Palembani 2024-06-23 18:07:50 +07:00
parent 4a17a7c436
commit 3fa07609bb
Signed by: null2264
GPG key ID: BA64F8B60AF3EFB6
4 changed files with 7 additions and 7 deletions

View file

@ -15,7 +15,7 @@ import okhttp3.Interceptor
import okhttp3.Request import okhttp3.Request
import okhttp3.Response import okhttp3.Response
import yokai.i18n.MR import yokai.i18n.MR
import yokai.util.lang.getMString import yokai.util.lang.getString
import java.io.IOException import java.io.IOException
import java.util.concurrent.* import java.util.concurrent.*
@ -49,7 +49,7 @@ class CloudflareInterceptor(
// Because OkHttp's enqueue only handles IOExceptions, wrap the exception so that // Because OkHttp's enqueue only handles IOExceptions, wrap the exception so that
// we don't crash the entire app // we don't crash the entire app
catch (e: CloudflareBypassException) { catch (e: CloudflareBypassException) {
throw IOException(context.getMString(MR.strings.failed_to_bypass_cloudflare)) throw IOException(context.getString(MR.strings.failed_to_bypass_cloudflare))
} catch (e: Exception) { } catch (e: Exception) {
throw IOException(e) throw IOException(e)
} }

View file

@ -4,7 +4,7 @@ import android.content.Context
import android.widget.Toast import android.widget.Toast
import androidx.annotation.StringRes import androidx.annotation.StringRes
import dev.icerock.moko.resources.StringResource import dev.icerock.moko.resources.StringResource
import yokai.util.lang.getMString import yokai.util.lang.getString
/** /**
* Display a toast in this context. * Display a toast in this context.
@ -23,7 +23,7 @@ fun Context.toast(@StringRes resource: Int, duration: Int = Toast.LENGTH_SHORT)
* @param duration the duration of the toast. Defaults to short. * @param duration the duration of the toast. Defaults to short.
*/ */
fun Context.toast(resource: StringResource, duration: Int = Toast.LENGTH_SHORT) { fun Context.toast(resource: StringResource, duration: Int = Toast.LENGTH_SHORT) {
toast(getMString(resource), duration) toast(getString(resource), duration)
} }
/** /**

View file

@ -5,4 +5,4 @@ import dev.icerock.moko.resources.StringResource
import dev.icerock.moko.resources.desc.Resource import dev.icerock.moko.resources.desc.Resource
import dev.icerock.moko.resources.desc.StringDesc import dev.icerock.moko.resources.desc.StringDesc
fun Context.getMString(stringRes: StringResource): String = StringDesc.Resource(stringRes).toString(this) fun Context.getString(stringRes: StringResource): String = StringDesc.Resource(stringRes).toString(this)

View file

@ -7,7 +7,7 @@ import androidx.glance.LocalContext
import androidx.glance.appwidget.cornerRadius import androidx.glance.appwidget.cornerRadius
import dev.icerock.moko.resources.StringResource import dev.icerock.moko.resources.StringResource
import yokai.presentation.widget.R import yokai.presentation.widget.R
import yokai.util.lang.getMString import yokai.util.lang.getString
fun GlanceModifier.appWidgetBackgroundRadius(): GlanceModifier { fun GlanceModifier.appWidgetBackgroundRadius(): GlanceModifier {
return this.cornerRadius(R.dimen.appwidget_background_radius) return this.cornerRadius(R.dimen.appwidget_background_radius)
@ -19,7 +19,7 @@ fun GlanceModifier.appWidgetInnerRadius(): GlanceModifier {
@Composable @Composable
fun stringResource(id: StringResource): String { fun stringResource(id: StringResource): String {
return LocalContext.current.getMString(id) return LocalContext.current.getString(id)
} }
/** /**