cleanup strings and translate toasts

This commit is contained in:
Ax333l 2024-12-19 21:18:54 +01:00
parent 783c74712f
commit b60bdb4685
No known key found for this signature in database
GPG Key ID: D2B4D85271127D23
3 changed files with 16 additions and 12 deletions

View File

@ -138,7 +138,7 @@ fun SelectedAppInfoScreen(
activeSearchJob = vm.activePluginAction,
hasRoot = vm.hasRoot,
onDismissRequest = vm::dismissSourceSelector,
onSelectPlugin = vm::searchInPlugin,
onSelectPlugin = vm::searchUsingPlugin,
requiredVersion = requiredVersion,
onSelect = {
vm.selectedApp = it

View File

@ -5,6 +5,7 @@ import android.app.Application
import android.content.Intent
import android.content.pm.PackageInfo
import android.os.Parcelable
import android.util.Log
import androidx.activity.result.ActivityResult
import androidx.annotation.StringRes
import androidx.compose.runtime.MutableState
@ -37,7 +38,10 @@ import app.revanced.manager.ui.model.SelectedApp
import app.revanced.manager.util.Options
import app.revanced.manager.util.PM
import app.revanced.manager.util.PatchSelection
import app.revanced.manager.util.simpleMessage
import app.revanced.manager.util.tag
import app.revanced.manager.util.toast
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
@ -178,7 +182,7 @@ class SelectedAppInfoViewModel(input: Params) : ViewModel(), KoinComponent {
showSourceSelector = false
}
fun searchInPlugin(plugin: LoadedDownloaderPlugin) {
fun searchUsingPlugin(plugin: LoadedDownloaderPlugin) {
cancelPluginAction()
pluginAction = plugin to viewModelScope.launch {
try {
@ -212,7 +216,7 @@ class SelectedAppInfoViewModel(input: Params) : ViewModel(), KoinComponent {
plugin.get(scope, packageName, desiredVersion)
}?.let { (data, version) ->
if (desiredVersion != null && version != desiredVersion) {
app.toast("Plugin returned a package with the wrong version")
app.toast(app.getString(R.string.downloader_invalid_version))
return@launch
}
selectedApp = SelectedApp.Download(
@ -220,9 +224,14 @@ class SelectedAppInfoViewModel(input: Params) : ViewModel(), KoinComponent {
version,
ParceledDownloaderData(plugin, data)
)
} ?: app.toast("App was not found")
} ?: app.toast(app.getString(R.string.downloader_app_not_found))
} catch (e: UserInteractionException.Activity) {
app.toast(e.message!!)
} catch (e: CancellationException) {
throw e
} catch (e: Exception) {
app.toast(app.getString(R.string.downloader_error, e.simpleMessage()))
Log.e(tag, "Downloader.get threw an exception", e)
} finally {
pluginAction = null
dismissSourceSelector()

View File

@ -244,14 +244,9 @@
<string name="unpatch_app">Unpatch app?</string>
<string name="unpatch_description">Are you sure you want to unpatch this app?</string>
<string name="error_occurred">An error occurred</string>
<string name="already_downloaded">Already downloaded</string>
<string name="select_version">Select version</string>
<string name="downloadable_versions">Downloadable versions</string>
<string name="downloaded_versions">Downloaded versions</string>
<string name="downloader_select">Select downloader</string>
<string name="downloader_not_selected">No downloader selected</string>
<string name="downloader_no_versions">No downloadable versions found</string>
<string name="downloader_invalid_version">Downloader did not fetch the correct version</string>
<string name="downloader_app_not_found">Downloader did not find the app</string>
<string name="downloader_error">Downloader error: %s</string>
<string name="downloader_no_plugins_installed">No plugins installed.</string>
<string name="downloader_no_plugins_available">No trusted plugins available for use. Check your settings.</string>
<string name="already_patched">Already patched</string>