From 73bf555ba0e46e9b4542002542eec7eada30bbb1 Mon Sep 17 00:00:00 2001 From: Adam Smith Date: Fri, 31 Oct 2014 13:54:38 +0000 Subject: PGPHandler Strings replaced --- .../java/com/zeapo/pwdstore/crypto/PgpHandler.java | 22 +++++++++++----------- app/src/main/res/values/strings.xml | 11 +++++++++++ 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java b/app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java index f2908ebd..850070fd 100644 --- a/app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java +++ b/app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java @@ -91,7 +91,7 @@ public class PgpHandler extends ActionBarActivity implements OpenPgpServiceConne registered = false; if (TextUtils.isEmpty(providerPackageName)) { - Toast.makeText(this, "No OpenPGP Provider selected!", Toast.LENGTH_LONG).show(); + Toast.makeText(this, this.getResources().getString(R.string.provider_toast_text), Toast.LENGTH_LONG).show(); Intent intent = new Intent(this, UserPreference.class); startActivity(intent); // a small hack to avoid eternal loop later, have to be solved via a startactivityforresult() @@ -106,7 +106,7 @@ public class PgpHandler extends ActionBarActivity implements OpenPgpServiceConne mServiceConnection.bindToService(); bindingDialog = new ProgressDialog(this); - bindingDialog.setMessage("Waiting for OpenKeychain..."); + bindingDialog.setMessage(this.getResources().getString(R.string.okc_progress_text)); bindingDialog.setCancelable(false); bindingDialog.show(); @@ -153,9 +153,9 @@ public class PgpHandler extends ActionBarActivity implements OpenPgpServiceConne public void copyToClipBoard() { ClipData clip = ClipData.newPlainText("pgp_handler_result_pm", ((TextView) findViewById(R.id.crypto_password_show)).getText()); clipboard.setPrimaryClip(clip); - showToast("Password copied to clipboard, you have " + showToast(this.getResources().getString(R.string.clipboard_beginning_toast_text) + Integer.parseInt(settings.getString("general_show_time", "45")) - + " seconds to paste it somewhere."); + + this.getResources().getString(R.string.clipboard_ending_toast_text)); } public void handleClick(View view) { @@ -424,7 +424,7 @@ public class PgpHandler extends ActionBarActivity implements OpenPgpServiceConne public void getKeyIds(Intent data) { accountName = settings.getString("openpgp_account_name", ""); if (accountName.isEmpty()) - showToast("Please set your account name in settings whenever you can"); + showToast(this.getResources().getString(R.string.name_settings_toast_text)); data.setAction(OpenPgpApi.ACTION_GET_KEY_IDS); data.putExtra(OpenPgpApi.EXTRA_USER_IDS, new String[]{accountName.isEmpty() ? "default" : accountName}); @@ -456,9 +456,9 @@ public class PgpHandler extends ActionBarActivity implements OpenPgpServiceConne if (accountName.isEmpty()) { new AlertDialog.Builder(this) - .setMessage("Please set your OpenKeychain account (email) in the preferences") - .setTitle("Account name empty!") - .setPositiveButton("OK", new DialogInterface.OnClickListener() { + .setMessage(this.getResources().getString(R.string.account_settings_dialog_text)) + .setTitle(this.getResources().getString(R.string.account_settings_dialog_title)) + .setPositiveButton(this.getResources().getString(R.string.dialog_ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { try { @@ -469,7 +469,7 @@ public class PgpHandler extends ActionBarActivity implements OpenPgpServiceConne e.printStackTrace(); } } - }).setNegativeButton("No thanks", new DialogInterface.OnClickListener() { + }).setNegativeButton(this.getResources().getString(R.string.dialog_no), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { // Do nothing... @@ -486,12 +486,12 @@ public class PgpHandler extends ActionBarActivity implements OpenPgpServiceConne String extra = ((EditText) findViewById(R.id.crypto_extra_edit)).getText().toString(); if (name.isEmpty()) { - showToast("Please provide a file name"); + showToast(this.getResources().getString(R.string.file_toast_text)); return; } if (pass.isEmpty() && extra.isEmpty()) { - showToast("You cannot use an empty password or empty extra content"); + showToast(this.getResources().getString(R.string.empty_toast_text)); return; } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 7fc3cbac..bf3460b1 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -26,6 +26,17 @@ [ANDROID PwdStore] Add [ANDROID PwdStore] Remove from store. + + + No OpenPGP Provider selected! + Waiting for OpenKeychain... + Password copied to clipboard, you have + seconds to paste it somewhere. + Please set your account name in settings whenever you can + Please set your OpenKeychain account (email) in the preferences + Account name empty! + Please provide a file name + You cannot use an empty password or empty extra content Welcome to Password Store\n\n In this screen you can either create a new repository or clone your git repository onto your device. -- cgit v1.2.3 From 7219fedf459e305bb7fbaabee2b4ce833f769ccc Mon Sep 17 00:00:00 2001 From: Adam Smith Date: Fri, 31 Oct 2014 14:13:17 +0000 Subject: Hard coded string in GitAsyncTask replaced with resources --- app/src/main/java/com/zeapo/pwdstore/GitAsyncTask.java | 8 ++++---- app/src/main/res/values/strings.xml | 5 +++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/zeapo/pwdstore/GitAsyncTask.java b/app/src/main/java/com/zeapo/pwdstore/GitAsyncTask.java index c27bd0d4..6d0e745d 100644 --- a/app/src/main/java/com/zeapo/pwdstore/GitAsyncTask.java +++ b/app/src/main/java/com/zeapo/pwdstore/GitAsyncTask.java @@ -30,7 +30,7 @@ public class GitAsyncTask extends AsyncTask { } protected void onPreExecute() { - this.dialog.setMessage("Running command..."); + this.dialog.setMessage(activity.getResources().getString(R.string.running_dialog_text)); this.dialog.setCancelable(false); this.dialog.show(); } @@ -54,9 +54,9 @@ public class GitAsyncTask extends AsyncTask { if (!result.isEmpty()) { new AlertDialog.Builder(activity). - setTitle("Internal exception occurred"). - setMessage("Message from jgit:\n" + result). - setPositiveButton("OK", new DialogInterface.OnClickListener() { + setTitle(activity.getResources().getString(R.string.jgit_error_dialog_title)). + setMessage(activity.getResources().getString(R.string.jgit_error_dialog_text) + result). + setPositiveButton(activity.getResources().getString(R.string.dialog_ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { if (operation.equals(CloneCommand.class)) { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index bf3460b1..3565d79f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -37,6 +37,11 @@ Account name empty! Please provide a file name You cannot use an empty password or empty extra content + + + Running command... + Internal exception occurred + Message from jgit: /n Welcome to Password Store\n\n In this screen you can either create a new repository or clone your git repository onto your device. -- cgit v1.2.3 From 58183ee900a368bd32e6e2bdbaaa37cff8ec6cca Mon Sep 17 00:00:00 2001 From: Adam Smith Date: Fri, 31 Oct 2014 14:28:09 +0000 Subject: Hard coded strings replaced for resources in GitHandler --- .../main/java/com/zeapo/pwdstore/GitHandler.java | 38 +++++++++++----------- app/src/main/res/values/strings.xml | 12 +++++++ 2 files changed, 31 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/com/zeapo/pwdstore/GitHandler.java b/app/src/main/java/com/zeapo/pwdstore/GitHandler.java index 6003cd73..1393d053 100644 --- a/app/src/main/java/com/zeapo/pwdstore/GitHandler.java +++ b/app/src/main/java/com/zeapo/pwdstore/GitHandler.java @@ -113,9 +113,9 @@ public class GitHandler extends ActionBarActivity { } else { ((EditText)findViewById(R.id.clone_uri)).setHint("hostname/path"); new AlertDialog.Builder(activity). - setMessage("You are about to use a read-only repository, you will not be able to push to it"). + setMessage(activity.getResources().getString(R.string.read_only_dialog_text)). setCancelable(true). - setPositiveButton("OK", new DialogInterface.OnClickListener() { + setPositiveButton(activity.getResources().getString(R.string.dialog_ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { @@ -444,8 +444,8 @@ public class GitHandler extends ActionBarActivity { // did he forget the username? if (!hostname.matches("^.+@.+")) { new AlertDialog.Builder(this). - setMessage("Did you forget to specify a username?"). - setPositiveButton("Oups...", new DialogInterface.OnClickListener() { + setMessage(activity.getResources().getString(R.string.forget_username_dialog_text)). + setPositiveButton(activity.getResources().getString(R.string.dialog_oops), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { @@ -530,15 +530,15 @@ public class GitHandler extends ActionBarActivity { settings.getString("git_remote_server", "").isEmpty() || settings.getString("git_remote_location", "").isEmpty() ) new AlertDialog.Builder(this) - .setMessage("You have to set the information about the server before synchronizing with the server") - .setPositiveButton("On my way!", new DialogInterface.OnClickListener() { + .setMessage(activity.getResources().getString(R.string.set_information_dialog_text)) + .setPositiveButton(activity.getResources().getString(R.string.dialog_positive), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { Intent intent = new Intent(activity, UserPreference.class); startActivityForResult(intent, REQUEST_PULL); } }) - .setNegativeButton("Nah... later", new DialogInterface.OnClickListener() { + .setNegativeButton(activity.getResources().getString(R.string.dialog_negative), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { // do nothing :( @@ -643,9 +643,9 @@ public class GitHandler extends ActionBarActivity { final File sshKey = new File(getFilesDir() + "/.ssh_key"); if (!sshKey.exists()) { new AlertDialog.Builder(this) - .setMessage("Please import your SSH key file in the preferences") - .setTitle("No SSH key") - .setPositiveButton("OK", new DialogInterface.OnClickListener() { + .setMessage(activity.getResources().getString(R.string.ssh_preferences_dialog_text)) + .setTitle(activity.getResources().getString(R.string.ssh_preferences_dialog_title)) + .setPositiveButton(activity.getResources().getString(R.string.dialog_ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { try { @@ -657,7 +657,7 @@ public class GitHandler extends ActionBarActivity { e.printStackTrace(); } } - }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { + }).setNegativeButton(activity.getResources().getString(R.string.dialog_cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { // Do nothing... @@ -670,10 +670,10 @@ public class GitHandler extends ActionBarActivity { passphrase.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); new AlertDialog.Builder(activity) - .setTitle("Authenticate") - .setMessage("Please provide the passphrase for your SSH key. Leave it empty if there is no passphrase.") + .setTitle(activity.getResources().getString(R.string.passphrase_dialog_title)) + .setMessage(activity.getResources().getString(R.string.passphrase_dialog_text)) .setView(passphrase) - .setPositiveButton("OK", new DialogInterface.OnClickListener() { + .setPositiveButton(activity.getResources().getString(R.string.dialog_ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { SshSessionFactory.setInstance(new GitConfigSessionFactory()); @@ -693,7 +693,7 @@ public class GitHandler extends ActionBarActivity { } } - }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { + }).setNegativeButton(activity.getResources().getString(R.string.dialog_cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Do nothing. } @@ -707,10 +707,10 @@ public class GitHandler extends ActionBarActivity { password.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); new AlertDialog.Builder(activity) - .setTitle("Authenticate") - .setMessage("Please provide the password for this repository") + .setTitle(activity.getResources().getString(R.string.passphrase_dialog_title)) + .setMessage(activity.getResources().getString(R.string.password_dialog_text)) .setView(password) - .setPositiveButton("OK", new DialogInterface.OnClickListener() { + .setPositiveButton(activity.getResources().getString(R.string.dialog_ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { SshSessionFactory.setInstance(new GitConfigSessionFactory()); @@ -725,7 +725,7 @@ public class GitHandler extends ActionBarActivity { } } - }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { + }).setNegativeButton(activity.getResources().getString(R.string.dialog_cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Do nothing. } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3565d79f..cc4e3e36 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -42,6 +42,16 @@ Running command... Internal exception occurred Message from jgit: /n + + + You are about to use a read-only repository, you will not be able to push to it + Did you forget to specify a username? + You have to set the information about the server before synchronizing with the server + Please import your SSH key file in the preferences + No SSH key + Authenticate + Please provide the passphrase for your SSH key. Leave it empty if there is no passphrase. + Please provide the password for this repository Welcome to Password Store\n\n In this screen you can either create a new repository or clone your git repository onto your device. @@ -79,5 +89,7 @@ No On my way... Nah... later + Oops... + Cancel -- cgit v1.2.3