diff options
author | Harsh Shandilya <me@msfjarvis.dev> | 2020-03-27 15:16:30 +0530 |
---|---|---|
committer | Harsh Shandilya <me@msfjarvis.dev> | 2020-03-27 15:38:04 +0530 |
commit | 536a6f3f83ad25df65114581d5dde36a8e74ed98 (patch) | |
tree | 2ab8d93f6e48460f34d9e321af250c96ecef1fe4 /ui/src/main/java/com/wireguard/android | |
parent | b9fd3d37f24b8def4fe35e005672454912a5024a (diff) |
ui: Replace ErrorMessages getter with indexing operator
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
Diffstat (limited to 'ui/src/main/java/com/wireguard/android')
8 files changed, 12 insertions, 12 deletions
diff --git a/ui/src/main/java/com/wireguard/android/activity/LogViewerActivity.kt b/ui/src/main/java/com/wireguard/android/activity/LogViewerActivity.kt index 6e1bde99..78efb152 100644 --- a/ui/src/main/java/com/wireguard/android/activity/LogViewerActivity.kt +++ b/ui/src/main/java/com/wireguard/android/activity/LogViewerActivity.kt @@ -185,7 +185,7 @@ class LogViewerActivity : AppCompatActivity() { saveButton?.isEnabled = true Snackbar.make(findViewById(android.R.id.content), if (exception == null) getString(R.string.log_export_success, outputFile?.fileName) - else getString(R.string.log_export_error, ErrorMessages.get(exception)), + else getString(R.string.log_export_error, ErrorMessages[exception]), if (exception == null) Snackbar.LENGTH_SHORT else Snackbar.LENGTH_LONG) .setAnchorView(binding.shareFab) .show() diff --git a/ui/src/main/java/com/wireguard/android/activity/TunnelToggleActivity.kt b/ui/src/main/java/com/wireguard/android/activity/TunnelToggleActivity.kt index e53ff5d3..4befee03 100644 --- a/ui/src/main/java/com/wireguard/android/activity/TunnelToggleActivity.kt +++ b/ui/src/main/java/com/wireguard/android/activity/TunnelToggleActivity.kt @@ -32,7 +32,7 @@ class TunnelToggleActivity : AppCompatActivity() { private fun onToggleFinished(throwable: Throwable?) { if (throwable == null) return - val error = ErrorMessages.get(throwable) + val error = ErrorMessages[throwable] val message = getString(R.string.toggle_error, error) Log.e(TAG, message, throwable) Toast.makeText(this, message, Toast.LENGTH_LONG).show() diff --git a/ui/src/main/java/com/wireguard/android/fragment/AppListDialogFragment.kt b/ui/src/main/java/com/wireguard/android/fragment/AppListDialogFragment.kt index 3bab3648..20f09354 100644 --- a/ui/src/main/java/com/wireguard/android/fragment/AppListDialogFragment.kt +++ b/ui/src/main/java/com/wireguard/android/fragment/AppListDialogFragment.kt @@ -42,7 +42,7 @@ class AppListDialogFragment : DialogFragment() { appData.clear() appData.addAll(data) } else { - val error = ErrorMessages.get(throwable) + val error = ErrorMessages[throwable] val message = activity.getString(R.string.error_fetching_apps, error) Toast.makeText(activity, message, Toast.LENGTH_LONG).show() dismissAllowingStateLoss() diff --git a/ui/src/main/java/com/wireguard/android/fragment/BaseFragment.kt b/ui/src/main/java/com/wireguard/android/fragment/BaseFragment.kt index 0f7c5802..d072bc69 100644 --- a/ui/src/main/java/com/wireguard/android/fragment/BaseFragment.kt +++ b/ui/src/main/java/com/wireguard/android/fragment/BaseFragment.kt @@ -87,7 +87,7 @@ abstract class BaseFragment : Fragment(), OnSelectedTunnelChangedListener { private fun setTunnelStateWithPermissionsResult(tunnel: ObservableTunnel, checked: Boolean) { tunnel.setStateAsync(Tunnel.State.of(checked)).whenComplete { _, throwable -> if (throwable == null) return@whenComplete - val error = ErrorMessages.get(throwable) + val error = ErrorMessages[throwable] val messageResId = if (checked) R.string.error_up else R.string.error_down val message = requireContext().getString(messageResId, error) val view = view diff --git a/ui/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.kt b/ui/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.kt index 9a92b7cb..894c0e05 100644 --- a/ui/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.kt +++ b/ui/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.kt @@ -46,7 +46,7 @@ class TunnelEditorFragment : BaseFragment(), AppExclusionListener { Toast.makeText(requireContext(), message, Toast.LENGTH_SHORT).show() onFinished() } else { - val error = ErrorMessages.get(throwable) + val error = ErrorMessages[throwable] message = getString(R.string.config_save_error, savedTunnel.name, error) Log.e(TAG, message, throwable) binding?.let { @@ -114,7 +114,7 @@ class TunnelEditorFragment : BaseFragment(), AppExclusionListener { val newConfig = try { binding!!.config!!.resolve() } catch (e: Exception) { - val error = ErrorMessages.get(e) + val error = ErrorMessages[e] val tunnelName = if (tunnel == null) binding!!.name else tunnel!!.name val message = getString(R.string.config_save_error, tunnelName, error) Log.e(TAG, message, e) @@ -179,7 +179,7 @@ class TunnelEditorFragment : BaseFragment(), AppExclusionListener { Toast.makeText(requireContext(), message, Toast.LENGTH_SHORT).show() onFinished() } else { - val error = ErrorMessages.get(throwable) + val error = ErrorMessages[throwable] message = getString(R.string.tunnel_create_error, error) Log.e(TAG, message, throwable) binding?.let { @@ -198,7 +198,7 @@ class TunnelEditorFragment : BaseFragment(), AppExclusionListener { Log.d(TAG, "Attempting to save config of renamed tunnel " + tunnel!!.name) renamedTunnel.setConfigAsync(newConfig).whenComplete { _, t -> onConfigSaved(renamedTunnel, t) } } else { - val error = ErrorMessages.get(throwable) + val error = ErrorMessages[throwable] message = getString(R.string.tunnel_rename_error, error) Log.e(TAG, message, throwable) binding?.let { diff --git a/ui/src/main/java/com/wireguard/android/fragment/TunnelListFragment.kt b/ui/src/main/java/com/wireguard/android/fragment/TunnelListFragment.kt index c23699eb..310f2725 100644 --- a/ui/src/main/java/com/wireguard/android/fragment/TunnelListFragment.kt +++ b/ui/src/main/java/com/wireguard/android/fragment/TunnelListFragment.kt @@ -235,7 +235,7 @@ class TunnelListFragment : BaseFragment() { if (throwable == null) { message = resources.getQuantityString(R.plurals.delete_success, count, count) } else { - val error = ErrorMessages.get(throwable) + val error = ErrorMessages[throwable] message = resources.getQuantityString(R.plurals.delete_error, count, count, error) Log.e(TAG, message, throwable) } @@ -245,7 +245,7 @@ class TunnelListFragment : BaseFragment() { private fun onTunnelImportFinished(tunnels: List<ObservableTunnel>, throwables: Collection<Throwable>) { var message = "" for (throwable in throwables) { - val error = ErrorMessages.get(throwable) + val error = ErrorMessages[throwable] message = getString(R.string.import_error, error) Log.e(TAG, message, throwable) } diff --git a/ui/src/main/java/com/wireguard/android/preference/ModuleDownloaderPreference.kt b/ui/src/main/java/com/wireguard/android/preference/ModuleDownloaderPreference.kt index 6ecebb95..055ed449 100644 --- a/ui/src/main/java/com/wireguard/android/preference/ModuleDownloaderPreference.kt +++ b/ui/src/main/java/com/wireguard/android/preference/ModuleDownloaderPreference.kt @@ -34,7 +34,7 @@ class ModuleDownloaderPreference(context: Context, attrs: AttributeSet?) : Prefe when { throwable != null -> { setState(State.FAILURE) - Toast.makeText(context, ErrorMessages.get(throwable), Toast.LENGTH_LONG).show() + Toast.makeText(context, ErrorMessages[throwable], Toast.LENGTH_LONG).show() } result == OsConstants.ENOENT -> setState(State.NOTFOUND) result == OsConstants.EXIT_SUCCESS -> { diff --git a/ui/src/main/java/com/wireguard/android/preference/ZipExporterPreference.kt b/ui/src/main/java/com/wireguard/android/preference/ZipExporterPreference.kt index 0c00a3ef..fa6bd2fa 100644 --- a/ui/src/main/java/com/wireguard/android/preference/ZipExporterPreference.kt +++ b/ui/src/main/java/com/wireguard/android/preference/ZipExporterPreference.kt @@ -63,7 +63,7 @@ class ZipExporterPreference(context: Context, attrs: AttributeSet?) : Preference private fun exportZipComplete(filePath: String?, throwable: Throwable?) { if (throwable != null) { - val error = ErrorMessages.get(throwable) + val error = ErrorMessages[throwable] val message = context.getString(R.string.zip_export_error, error) Log.e(TAG, message, throwable) Snackbar.make( |