Add Russian (ru) translation

This commit is contained in:
Oleg Koretsky
2023-03-02 20:41:22 +02:00
parent 0da542fede
commit 0369b45385
8 changed files with 186 additions and 47 deletions
@@ -21,7 +21,6 @@ import com.vitorpamplona.amethyst.service.relays.Client
import com.vitorpamplona.amethyst.ui.screen.AccountScreen
import com.vitorpamplona.amethyst.ui.screen.AccountStateViewModel
import com.vitorpamplona.amethyst.ui.theme.AmethystTheme
import java.util.Locale
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
@@ -9,12 +9,11 @@ import android.os.Environment
import android.provider.MediaStore
import androidx.annotation.RequiresApi
import androidx.core.net.toUri
import java.io.File
import com.vitorpamplona.amethyst.R
import okhttp3.*
import okio.BufferedSource
import okio.IOException
import okio.sink
import java.io.File
object ImageSaver {
@@ -50,7 +49,7 @@ object ImageSaver {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
val contentType = response.header("Content-Type")
checkNotNull(contentType) {
context.getString(R.string.can_t_find_out_the_content_type)
"Can't find out the content type"
}
saveContentQ(
@@ -58,7 +57,6 @@ object ImageSaver {
contentType = contentType,
contentSource = response.body.source(),
contentResolver = context.contentResolver,
context = context
)
} else {
saveContentDefault(
@@ -82,7 +80,6 @@ object ImageSaver {
contentType: String,
contentSource: BufferedSource,
contentResolver: ContentResolver,
context: Context
) {
val contentValues = ContentValues().apply {
put(MediaStore.MediaColumns.DISPLAY_NAME, displayName)
@@ -96,13 +93,13 @@ object ImageSaver {
val uri =
contentResolver.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, contentValues)
checkNotNull(uri) {
context.getString(R.string.can_t_insert_the_new_content)
"Can't insert the new content"
}
try {
val outputStream = contentResolver.openOutputStream(uri)
checkNotNull(outputStream) {
context.getString(R.string.can_t_open_the_content_output_stream)
"Can't open the content output stream"
}
outputStream.use {
@@ -1,23 +1,14 @@
package com.vitorpamplona.amethyst.ui.actions
import android.content.ContentResolver
import android.content.Context
import android.net.Uri
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import java.io.IOException
import java.util.UUID
import okhttp3.Call
import okhttp3.Callback
import okhttp3.MediaType
import com.vitorpamplona.amethyst.R
import okhttp3.*
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.MultipartBody
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.RequestBody
import okhttp3.Response
import okio.BufferedSink
import okio.source
import java.io.IOException
import java.util.*
object ImageUploader {
fun uploadImage(
@@ -25,7 +16,6 @@ object ImageUploader {
contentResolver: ContentResolver,
onSuccess: (String) -> Unit,
onError: (Throwable) -> Unit,
context : Context
) {
val contentType = contentResolver.getType(uri)
@@ -43,7 +33,7 @@ object ImageUploader {
override fun writeTo(sink: BufferedSink) {
val imageInputStream = contentResolver.openInputStream(uri)
checkNotNull(imageInputStream) {
context.getString(R.string.can_t_open_the_image_input_stream)
"Can't open the image input stream"
}
imageInputStream.source().use(sink::writeAll)
@@ -66,7 +56,7 @@ object ImageUploader {
val tree = jacksonObjectMapper().readTree(body.string())
val url = tree?.get("data")?.get("link")?.asText()
checkNotNull(url) {
context.getString(R.string.there_must_be_an_uploaded_image_url_in_the_response)
"There must be an uploaded image URL in the response"
}
onSuccess(url)
@@ -9,12 +9,7 @@ import androidx.compose.ui.text.TextRange
import androidx.compose.ui.text.input.TextFieldValue
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.vitorpamplona.amethyst.model.Account
import com.vitorpamplona.amethyst.model.LocalCache
import com.vitorpamplona.amethyst.model.Note
import com.vitorpamplona.amethyst.model.User
import com.vitorpamplona.amethyst.model.parseDirtyWordForKey
import com.vitorpamplona.amethyst.R
import com.vitorpamplona.amethyst.model.*
import com.vitorpamplona.amethyst.ui.components.isValidURL
import com.vitorpamplona.amethyst.ui.components.noProtocolUrlValidator
import kotlinx.coroutines.flow.MutableSharedFlow
@@ -134,10 +129,9 @@ class NewPostViewModel: ViewModel() {
onError = {
isUploadingImage = false
viewModelScope.launch {
imageUploadingError.emit(context.getString(R.string.failed_to_upload_the_image))
imageUploadingError.emit("Failed to upload the image")
}
},
context = context
}
)
}