From 718c152a6a63a20c5a49f32f6f0884e32848f4e9 Mon Sep 17 00:00:00 2001 From: pacien Date: Wed, 22 Aug 2018 22:44:53 +0200 Subject: Re-organise string resources --- .../org/pacien/tincapp/activities/BaseActivity.kt | 28 +++++++++++----------- .../configure/tools/ConfigurationTool.kt | 6 ++--- .../tincapp/activities/start/ConnectionStarter.kt | 6 ++--- .../tincapp/activities/start/StartActivity.kt | 2 +- .../tincapp/activities/status/StatusActivity.kt | 2 +- .../VpnInterfaceConfigurationFormatter.kt | 2 +- .../java/org/pacien/tincapp/commands/TincApp.kt | 2 +- .../main/java/org/pacien/tincapp/context/App.kt | 4 ++-- .../java/org/pacien/tincapp/context/AppInfo.kt | 6 ++--- .../tincapp/context/AppNotificationManager.kt | 4 ++-- .../org/pacien/tincapp/service/TincVpnService.kt | 26 ++++++++++---------- 11 files changed, 44 insertions(+), 44 deletions(-) (limited to 'app/src/main/java/org/pacien') diff --git a/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt b/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt index d9d549b..975d4cf 100644 --- a/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt +++ b/app/src/main/java/org/pacien/tincapp/activities/BaseActivity.kt @@ -85,12 +85,12 @@ abstract class BaseActivity : AppCompatActivity() { fun aboutDialog(m: MenuItem) { AlertDialog.Builder(this) .setTitle(resources.getString(R.string.app_name)) - .setMessage(resources.getString(R.string.app_short_desc) + "\n\n" + - resources.getString(R.string.app_copyright) + " " + - resources.getString(R.string.app_license) + "\n\n" + + .setMessage(resources.getString(R.string.about_app_short_desc) + "\n\n" + + resources.getString(R.string.about_app_copyright) + " " + + resources.getString(R.string.about_app_license) + "\n\n" + AppInfo.all()) - .setNeutralButton(R.string.action_open_project_website) { _, _ -> App.openURL(resources.getString(R.string.app_website_url)) } - .setPositiveButton(R.string.action_close) { _, _ -> Unit } + .setNeutralButton(R.string.about_app_open_project_website) { _, _ -> App.openURL(resources.getString(R.string.about_app_website_url)) } + .setPositiveButton(R.string.generic_action_close) { _, _ -> Unit } .show() } @@ -103,18 +103,18 @@ abstract class BaseActivity : AppCompatActivity() { CrashRecorder.dismissPreviousCrash() AlertDialog.Builder(this) - .setTitle(R.string.title_app_crash) + .setTitle(R.string.crash_modal_title) .setMessage(listOf( - resources.getString(R.string.message_app_crash), - resources.getString(R.string.message_crash_logged, AppPaths.appLogFile().absolutePath) + resources.getString(R.string.crash_modal_message), + resources.getString(R.string.crash_modal_crash_logged, AppPaths.appLogFile().absolutePath) ).joinToString("\n\n")) - .setNeutralButton(R.string.action_send_report) { _, _ -> + .setNeutralButton(R.string.crash_modal_action_send_report) { _, _ -> App.sendMail( - resources.getString(R.string.app_dev_email), - listOf(R.string.app_name, R.string.title_app_crash).joinToString(" / ", transform = resources::getString), + resources.getString(R.string.crash_modal_dev_email), + listOf(R.string.app_name, R.string.crash_modal_title).joinToString(" / ", transform = resources::getString), AppPaths.appLogFile().let { if (it.exists()) it.readText() else "" }) } - .setPositiveButton(R.string.action_close) { _, _ -> Unit } + .setPositiveButton(R.string.generic_action_close) { _, _ -> Unit } .show() } @@ -125,6 +125,6 @@ abstract class BaseActivity : AppCompatActivity() { fun notify(msg: String) = Snackbar.make(base_activity_frame, msg, Snackbar.LENGTH_LONG).show() fun showErrorDialog(msg: String): AlertDialog = AlertDialog.Builder(this) - .setTitle(R.string.title_error).setMessage(msg) - .setPositiveButton(R.string.action_close) { _, _ -> Unit }.show() + .setTitle(R.string.generic_title_error).setMessage(msg) + .setPositiveButton(R.string.generic_action_close) { _, _ -> Unit }.show() } diff --git a/app/src/main/java/org/pacien/tincapp/activities/configure/tools/ConfigurationTool.kt b/app/src/main/java/org/pacien/tincapp/activities/configure/tools/ConfigurationTool.kt index 41d1f55..4fa85f8 100644 --- a/app/src/main/java/org/pacien/tincapp/activities/configure/tools/ConfigurationTool.kt +++ b/app/src/main/java/org/pacien/tincapp/activities/configure/tools/ConfigurationTool.kt @@ -43,7 +43,7 @@ abstract class ConfigurationTool(private val parentActivity: BaseActivity) { .setTitle(title) .setView(view) .setPositiveButton(applyButton) { _, _ -> applyAction(view) } - .setNegativeButton(R.string.action_cancel) { _, _ -> Unit } + .setNegativeButton(R.string.generic_action_cancel) { _, _ -> Unit } .show() } @@ -51,7 +51,7 @@ abstract class ConfigurationTool(private val parentActivity: BaseActivity) { ProgressModal.show(parentActivity, parentActivity.getString(label)).let { progressDialog -> action .whenComplete { _, _ -> progressDialog.dismiss() } - .thenAccept { parentActivity.notify(R.string.message_network_configuration_written) } + .thenAccept { parentActivity.notify(R.string.configure_tools_message_network_configuration_written) } .exceptionallyAccept { parentActivity.runOnUiThread { parentActivity.showErrorDialog(it.cause!!.localizedMessage) } } } } @@ -60,5 +60,5 @@ abstract class ConfigurationTool(private val parentActivity: BaseActivity) { if (networkNamePattern.matcher(netName).matches()) CompletableFuture.completedFuture(Unit) else - CompletableFuture.failedFuture(IllegalArgumentException(parentActivity.getString(R.string.message_invalid_network_name))) + CompletableFuture.failedFuture(IllegalArgumentException(parentActivity.getString(R.string.configure_tools_message_invalid_network_name))) } diff --git a/app/src/main/java/org/pacien/tincapp/activities/start/ConnectionStarter.kt b/app/src/main/java/org/pacien/tincapp/activities/start/ConnectionStarter.kt index 06046e9..d1ccd3f 100644 --- a/app/src/main/java/org/pacien/tincapp/activities/start/ConnectionStarter.kt +++ b/app/src/main/java/org/pacien/tincapp/activities/start/ConnectionStarter.kt @@ -55,10 +55,10 @@ class ConnectionStarter(private val parentActivity: StartActivity) { val dialogView = parentActivity.layoutInflater.inflate(R.layout.dialog_decrypt_keys, parentActivity.base_activity_frame, false) AlertDialog.Builder(parentActivity) - .setTitle(R.string.title_unlock_private_keys) + .setTitle(R.string.decrypt_key_modal_title) .setView(dialogView) - .setPositiveButton(R.string.action_unlock) { _, _ -> tryStart(passphrase = dialogView.passphrase.text.toString()) } - .setNegativeButton(R.string.action_cancel) { _, _ -> Unit } + .setPositiveButton(R.string.decrypt_key_modal_action_unlock) { _, _ -> tryStart(passphrase = dialogView.passphrase.text.toString()) } + .setNegativeButton(R.string.decrypt_key_modal_action_cancel) { _, _ -> Unit } .show() } diff --git a/app/src/main/java/org/pacien/tincapp/activities/start/StartActivity.kt b/app/src/main/java/org/pacien/tincapp/activities/start/StartActivity.kt index 9cc6159..802115f 100644 --- a/app/src/main/java/org/pacien/tincapp/activities/start/StartActivity.kt +++ b/app/src/main/java/org/pacien/tincapp/activities/start/StartActivity.kt @@ -99,7 +99,7 @@ class StartActivity : BaseActivity() { } fun showConnectProgressDialog() { - connectDialog = ProgressModal.show(this, resources.getString(R.string.message_starting_vpn)) + connectDialog = ProgressModal.show(this, resources.getString(R.string.start_starting_vpn)) } @Suppress("UNUSED_PARAMETER") diff --git a/app/src/main/java/org/pacien/tincapp/activities/status/StatusActivity.kt b/app/src/main/java/org/pacien/tincapp/activities/status/StatusActivity.kt index 3815bc9..152ed83 100644 --- a/app/src/main/java/org/pacien/tincapp/activities/status/StatusActivity.kt +++ b/app/src/main/java/org/pacien/tincapp/activities/status/StatusActivity.kt @@ -104,7 +104,7 @@ class StatusActivity : BaseActivity() { } private fun stopVpn() { - shutdownDialog = ProgressModal.show(this, getString(R.string.message_disconnecting_vpn)) + shutdownDialog = ProgressModal.show(this, getString(R.string.status_activity_disconnecting_vpn)) vpnService.disconnect() } diff --git a/app/src/main/java/org/pacien/tincapp/activities/status/networkinfo/VpnInterfaceConfigurationFormatter.kt b/app/src/main/java/org/pacien/tincapp/activities/status/networkinfo/VpnInterfaceConfigurationFormatter.kt index a519d07..568714e 100644 --- a/app/src/main/java/org/pacien/tincapp/activities/status/networkinfo/VpnInterfaceConfigurationFormatter.kt +++ b/app/src/main/java/org/pacien/tincapp/activities/status/networkinfo/VpnInterfaceConfigurationFormatter.kt @@ -30,7 +30,7 @@ object VpnInterfaceConfigurationFormatter { fun formatList(list: List) = when { list.isNotEmpty() -> list.joinToString("\n", transform = this::formatListElement) - else -> resources.getString(R.string.status_network_info_none_value)!! + else -> resources.getString(R.string.status_network_info_value_none)!! } private fun formatListElement(element: Any) = when (element) { diff --git a/app/src/main/java/org/pacien/tincapp/commands/TincApp.kt b/app/src/main/java/org/pacien/tincapp/commands/TincApp.kt index 32fc1f9..e7ad8e5 100644 --- a/app/src/main/java/org/pacien/tincapp/commands/TincApp.kt +++ b/app/src/main/java/org/pacien/tincapp/commands/TincApp.kt @@ -44,7 +44,7 @@ object TincApp { it.ed25519PrivateKeyFile ?: AppPaths.defaultEd25519PrivateKeyFile(netName)) } } catch (e: FileNotFoundException) { - throw FileNotFoundException(App.getResources().getString(R.string.message_network_config_not_found_format, e.message!!)) + throw FileNotFoundException(App.getResources().getString(R.string.notification_error_message_network_config_not_found_format, e.message!!)) } fun removeScripts(netName: String) = runAsyncTask { diff --git a/app/src/main/java/org/pacien/tincapp/context/App.kt b/app/src/main/java/org/pacien/tincapp/context/App.kt index 359cd23..6f28bd0 100644 --- a/app/src/main/java/org/pacien/tincapp/context/App.kt +++ b/app/src/main/java/org/pacien/tincapp/context/App.kt @@ -67,7 +67,7 @@ class App : Application() { fun openURL(url: String) { val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url)) - val chooser = Intent.createChooser(intent, getResources().getString(R.string.action_open_web_page)) + val chooser = Intent.createChooser(intent, getResources().getString(R.string.generic_action_open_web_page)) appContext?.startActivity(chooser.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)) } @@ -78,7 +78,7 @@ class App : Application() { .apply { if (body != null) putExtra(Intent.EXTRA_TEXT, body) } .apply { if (attachment != null) putExtra(Intent.EXTRA_STREAM, Uri.fromFile(attachment)) } - val chooser = Intent.createChooser(intent, getResources().getString(R.string.action_send_email)) + val chooser = Intent.createChooser(intent, getResources().getString(R.string.crash_modal_action_send_email)) appContext?.startActivity(chooser.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)) } } diff --git a/app/src/main/java/org/pacien/tincapp/context/AppInfo.kt b/app/src/main/java/org/pacien/tincapp/context/AppInfo.kt index e0d49f1..a412fa9 100644 --- a/app/src/main/java/org/pacien/tincapp/context/AppInfo.kt +++ b/app/src/main/java/org/pacien/tincapp/context/AppInfo.kt @@ -27,17 +27,17 @@ import org.pacien.tincapp.R */ object AppInfo { private fun appVersion(): String = App.getResources().getString( - R.string.info_version_format, + R.string.about_app_version_format, BuildConfig.VERSION_NAME, BuildConfig.BUILD_TYPE) private fun androidVersion(): String = App.getResources().getString( - R.string.info_running_on_format, + R.string.about_app_running_on_format, Build.VERSION.CODENAME, Build.VERSION.RELEASE) private fun supportedABIs(): String = App.getResources().getString( - R.string.info_supported_abis_format, + R.string.about_app_supported_abis_format, Build.SUPPORTED_ABIS.joinToString(",")) fun all(): String = listOf( diff --git a/app/src/main/java/org/pacien/tincapp/context/AppNotificationManager.kt b/app/src/main/java/org/pacien/tincapp/context/AppNotificationManager.kt index d543210..bdbc8be 100644 --- a/app/src/main/java/org/pacien/tincapp/context/AppNotificationManager.kt +++ b/app/src/main/java/org/pacien/tincapp/context/AppNotificationManager.kt @@ -64,7 +64,7 @@ class AppNotificationManager(private val context: Context) { @RequiresApi(Build.VERSION_CODES.O) private fun registerChannel() { - val name = context.getString(R.string.notification_channel_error_name) + val name = context.getString(R.string.notification_error_channel_name) val importance = NotificationManager.IMPORTANCE_HIGH val channel = NotificationChannel(CHANNEL_ID, name, importance) val notificationManager = context.getSystemService(NotificationManager::class.java) @@ -79,6 +79,6 @@ class AppNotificationManager(private val context: Context) { private fun NotificationCompat.Builder.setManualLink(manualLink: String) = apply { val intent = Intent(Intent.ACTION_VIEW, Uri.parse(manualLink)) val pendingIntent = PendingIntent.getActivity(context, 0, intent, 0) - addAction(R.drawable.ic_help_primary_24dp, context.getString(R.string.action_open_manual), pendingIntent) + addAction(R.drawable.ic_help_primary_24dp, context.getString(R.string.notification_error_action_open_manual), pendingIntent) } } diff --git a/app/src/main/java/org/pacien/tincapp/service/TincVpnService.kt b/app/src/main/java/org/pacien/tincapp/service/TincVpnService.kt index 7176e25..45058e2 100644 --- a/app/src/main/java/org/pacien/tincapp/service/TincVpnService.kt +++ b/app/src/main/java/org/pacien/tincapp/service/TincVpnService.kt @@ -85,16 +85,16 @@ class TincVpnService : VpnService() { private fun startVpn(netName: String, passphrase: String? = null): Unit = synchronized(this) { if (netName.isBlank()) - return reportError(resources.getString(R.string.message_no_network_name_provided), docTopic = "intent-api") + return reportError(resources.getString(R.string.notification_error_message_no_network_name_provided), docTopic = "intent-api") if (TincKeyring.needsPassphrase(netName) && passphrase == null) - return reportError(resources.getString(R.string.message_passphrase_required)) + return reportError(resources.getString(R.string.notification_error_message_passphrase_not_provided)) if (!AppPaths.storageAvailable()) return reportError(resources.getString(R.string.start_network_list_empty_storage_not_available)) if (!AppPaths.confDir(netName).exists()) - return reportError(resources.getString(R.string.message_no_configuration_for_network_format, netName), docTopic = "configuration") + return reportError(resources.getString(R.string.notification_error_message_no_configuration_for_network_format, netName), docTopic = "configuration") log.info("Starting tinc daemon for network \"$netName\".") if (isConnected()) stopVpn() @@ -108,19 +108,19 @@ class TincVpnService : VpnService() { } catch (e: FileNotFoundException) { Pair(null, null) } catch (e: PEMException) { - return reportError(resources.getString(R.string.message_could_not_decrypt_private_keys_format, e.message)) + return reportError(resources.getString(R.string.notification_error_message_could_not_decrypt_private_keys_format, e.message)) } catch (e: Exception) { - return reportError(resources.getString(R.string.message_could_not_read_private_key_format, e.defaultMessage()), e) + return reportError(resources.getString(R.string.notification_error_message_could_not_read_private_key_format, e.defaultMessage()), e) } val interfaceCfg = try { VpnInterfaceConfiguration.fromIfaceConfiguration(AppPaths.existing(AppPaths.netConfFile(netName))) } catch (e: FileNotFoundException) { - return reportError(resources.getString(R.string.message_network_config_not_found_format, e.defaultMessage()), e, "configuration") + return reportError(resources.getString(R.string.notification_error_message_network_config_not_found_format, e.defaultMessage()), e, "configuration") } catch (e: ConversionException) { - return reportError(resources.getString(R.string.message_network_config_invalid_format, e.defaultMessage()), e, "network-interface") + return reportError(resources.getString(R.string.notification_error_message_network_config_invalid_format, e.defaultMessage()), e, "network-interface") } catch (e: Exception) { - return reportError(resources.getString(R.string.message_could_not_read_network_configuration_format, e.defaultMessage()), e) + return reportError(resources.getString(R.string.notification_error_message_could_not_read_network_configuration_format, e.defaultMessage()), e) } val deviceFd = try { @@ -129,11 +129,11 @@ class TincVpnService : VpnService() { .also { applyIgnoringException(it::addDisallowedApplication, BuildConfig.APPLICATION_ID) } .establish()!! } catch (e: IllegalArgumentException) { - return reportError(resources.getString(R.string.message_network_config_invalid_format, e.defaultMessage()), e, "network-interface") + return reportError(resources.getString(R.string.notification_error_message_network_config_invalid_format, e.defaultMessage()), e, "network-interface") } catch (e: NullPointerException) { - return reportError(resources.getString(R.string.message_could_not_bind_iface), e) + return reportError(resources.getString(R.string.notification_error_message_could_not_bind_iface), e) } catch (e: Exception) { - return reportError(resources.getString(R.string.message_could_not_configure_iface, e.defaultMessage()), e) + return reportError(resources.getString(R.string.notification_error_message_could_not_configure_iface, e.defaultMessage()), e) } val daemon = Tincd.start(netName, deviceFd.fd, privateKeys.first?.fd, privateKeys.second?.fd) @@ -145,7 +145,7 @@ class TincVpnService : VpnService() { privateKeys.second?.close() if (exception != null) { - reportError(resources.getString(R.string.message_daemon_exited, exception.cause!!.defaultMessage()), exception) + reportError(resources.getString(R.string.notification_error_message_daemon_exited, exception.cause!!.defaultMessage()), exception) } else { log.info("tinc daemon started.") broadcastEvent(Actions.EVENT_CONNECTED) @@ -171,7 +171,7 @@ class TincVpnService : VpnService() { log.error(msg) broadcastEvent(Actions.EVENT_ABORTED) - App.alert(R.string.title_unable_to_start_tinc, msg, + App.alert(R.string.notification_error_title_unable_to_start_tinc, msg, if (docTopic != null) resources.getString(R.string.app_doc_url_format, docTopic) else null) } -- cgit v1.2.3