Merge pull request #30 from iAmiAdam/String-Bash

Hard coded strings replaced in resources
This commit is contained in:
Mohamed Zenadi 2014-10-31 16:10:42 +01:00
commit 22c6228e36
4 changed files with 61 additions and 33 deletions

View File

@ -30,7 +30,7 @@ public class GitAsyncTask extends AsyncTask<GitCommand, Integer, String> {
} }
protected void onPreExecute() { 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.setCancelable(false);
this.dialog.show(); this.dialog.show();
} }
@ -54,9 +54,9 @@ public class GitAsyncTask extends AsyncTask<GitCommand, Integer, String> {
if (!result.isEmpty()) { if (!result.isEmpty()) {
new AlertDialog.Builder(activity). new AlertDialog.Builder(activity).
setTitle("Internal exception occurred"). setTitle(activity.getResources().getString(R.string.jgit_error_dialog_title)).
setMessage("Message from jgit:\n" + result). setMessage(activity.getResources().getString(R.string.jgit_error_dialog_text) + result).
setPositiveButton("OK", new DialogInterface.OnClickListener() { setPositiveButton(activity.getResources().getString(R.string.dialog_ok), new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialogInterface, int i) { public void onClick(DialogInterface dialogInterface, int i) {
if (operation.equals(CloneCommand.class)) { if (operation.equals(CloneCommand.class)) {

View File

@ -113,9 +113,9 @@ public class GitHandler extends ActionBarActivity {
} else { } else {
((EditText)findViewById(R.id.clone_uri)).setHint("hostname/path"); ((EditText)findViewById(R.id.clone_uri)).setHint("hostname/path");
new AlertDialog.Builder(activity). 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). setCancelable(true).
setPositiveButton("OK", new DialogInterface.OnClickListener() { setPositiveButton(activity.getResources().getString(R.string.dialog_ok), new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialogInterface, int i) { public void onClick(DialogInterface dialogInterface, int i) {
@ -444,8 +444,8 @@ public class GitHandler extends ActionBarActivity {
// did he forget the username? // did he forget the username?
if (!hostname.matches("^.+@.+")) { if (!hostname.matches("^.+@.+")) {
new AlertDialog.Builder(this). new AlertDialog.Builder(this).
setMessage("Did you forget to specify a username?"). setMessage(activity.getResources().getString(R.string.forget_username_dialog_text)).
setPositiveButton("Oups...", new DialogInterface.OnClickListener() { setPositiveButton(activity.getResources().getString(R.string.dialog_oops), new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialogInterface, int i) { 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_server", "").isEmpty() ||
settings.getString("git_remote_location", "").isEmpty() ) settings.getString("git_remote_location", "").isEmpty() )
new AlertDialog.Builder(this) new AlertDialog.Builder(this)
.setMessage("You have to set the information about the server before synchronizing with the server") .setMessage(activity.getResources().getString(R.string.set_information_dialog_text))
.setPositiveButton("On my way!", new DialogInterface.OnClickListener() { .setPositiveButton(activity.getResources().getString(R.string.dialog_positive), new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialogInterface, int i) { public void onClick(DialogInterface dialogInterface, int i) {
Intent intent = new Intent(activity, UserPreference.class); Intent intent = new Intent(activity, UserPreference.class);
startActivityForResult(intent, REQUEST_PULL); startActivityForResult(intent, REQUEST_PULL);
} }
}) })
.setNegativeButton("Nah... later", new DialogInterface.OnClickListener() { .setNegativeButton(activity.getResources().getString(R.string.dialog_negative), new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialogInterface, int i) { public void onClick(DialogInterface dialogInterface, int i) {
// do nothing :( // do nothing :(
@ -643,9 +643,9 @@ public class GitHandler extends ActionBarActivity {
final File sshKey = new File(getFilesDir() + "/.ssh_key"); final File sshKey = new File(getFilesDir() + "/.ssh_key");
if (!sshKey.exists()) { if (!sshKey.exists()) {
new AlertDialog.Builder(this) new AlertDialog.Builder(this)
.setMessage("Please import your SSH key file in the preferences") .setMessage(activity.getResources().getString(R.string.ssh_preferences_dialog_text))
.setTitle("No SSH key") .setTitle(activity.getResources().getString(R.string.ssh_preferences_dialog_title))
.setPositiveButton("OK", new DialogInterface.OnClickListener() { .setPositiveButton(activity.getResources().getString(R.string.dialog_ok), new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int id) { public void onClick(DialogInterface dialog, int id) {
try { try {
@ -657,7 +657,7 @@ public class GitHandler extends ActionBarActivity {
e.printStackTrace(); e.printStackTrace();
} }
} }
}).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { }).setNegativeButton(activity.getResources().getString(R.string.dialog_cancel), new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int id) { public void onClick(DialogInterface dialog, int id) {
// Do nothing... // Do nothing...
@ -670,10 +670,10 @@ public class GitHandler extends ActionBarActivity {
passphrase.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); passphrase.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
new AlertDialog.Builder(activity) new AlertDialog.Builder(activity)
.setTitle("Authenticate") .setTitle(activity.getResources().getString(R.string.passphrase_dialog_title))
.setMessage("Please provide the passphrase for your SSH key. Leave it empty if there is no passphrase.") .setMessage(activity.getResources().getString(R.string.passphrase_dialog_text))
.setView(passphrase) .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) { public void onClick(DialogInterface dialog, int whichButton) {
SshSessionFactory.setInstance(new GitConfigSessionFactory()); 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) { public void onClick(DialogInterface dialog, int whichButton) {
// Do nothing. // Do nothing.
} }
@ -707,10 +707,10 @@ public class GitHandler extends ActionBarActivity {
password.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); password.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
new AlertDialog.Builder(activity) new AlertDialog.Builder(activity)
.setTitle("Authenticate") .setTitle(activity.getResources().getString(R.string.passphrase_dialog_title))
.setMessage("Please provide the password for this repository") .setMessage(activity.getResources().getString(R.string.password_dialog_text))
.setView(password) .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) { public void onClick(DialogInterface dialog, int whichButton) {
SshSessionFactory.setInstance(new GitConfigSessionFactory()); 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) { public void onClick(DialogInterface dialog, int whichButton) {
// Do nothing. // Do nothing.
} }

View File

@ -89,7 +89,7 @@ public class PgpHandler extends ActionBarActivity implements OpenPgpServiceConne
registered = false; registered = false;
if (TextUtils.isEmpty(providerPackageName)) { 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); Intent intent = new Intent(this, UserPreference.class);
startActivity(intent); startActivity(intent);
// a small hack to avoid eternal loop later, have to be solved via a startactivityforresult() // a small hack to avoid eternal loop later, have to be solved via a startactivityforresult()
@ -145,9 +145,9 @@ public class PgpHandler extends ActionBarActivity implements OpenPgpServiceConne
public void copyToClipBoard() { public void copyToClipBoard() {
ClipData clip = ClipData.newPlainText("pgp_handler_result_pm", ((TextView) findViewById(R.id.crypto_password_show)).getText()); ClipData clip = ClipData.newPlainText("pgp_handler_result_pm", ((TextView) findViewById(R.id.crypto_password_show)).getText());
clipboard.setPrimaryClip(clip); 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")) + 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) { public void handleClick(View view) {
@ -409,7 +409,7 @@ public class PgpHandler extends ActionBarActivity implements OpenPgpServiceConne
public void getKeyIds(Intent data) { public void getKeyIds(Intent data) {
accountName = settings.getString("openpgp_account_name", ""); accountName = settings.getString("openpgp_account_name", "");
if (accountName.isEmpty()) 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.setAction(OpenPgpApi.ACTION_GET_KEY_IDS);
data.putExtra(OpenPgpApi.EXTRA_USER_IDS, new String[]{accountName.isEmpty() ? "default" : accountName}); data.putExtra(OpenPgpApi.EXTRA_USER_IDS, new String[]{accountName.isEmpty() ? "default" : accountName});
@ -441,9 +441,9 @@ public class PgpHandler extends ActionBarActivity implements OpenPgpServiceConne
if (accountName.isEmpty()) { if (accountName.isEmpty()) {
new AlertDialog.Builder(this) new AlertDialog.Builder(this)
.setMessage("Please set your OpenKeychain account (email) in the preferences") .setMessage(this.getResources().getString(R.string.account_settings_dialog_text))
.setTitle("Account name empty!") .setTitle(this.getResources().getString(R.string.account_settings_dialog_title))
.setPositiveButton("OK", new DialogInterface.OnClickListener() { .setPositiveButton(this.getResources().getString(R.string.dialog_ok), new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int id) { public void onClick(DialogInterface dialog, int id) {
try { try {
@ -454,7 +454,7 @@ public class PgpHandler extends ActionBarActivity implements OpenPgpServiceConne
e.printStackTrace(); e.printStackTrace();
} }
} }
}).setNegativeButton("No thanks", new DialogInterface.OnClickListener() { }).setNegativeButton(this.getResources().getString(R.string.dialog_no), new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int id) { public void onClick(DialogInterface dialog, int id) {
// Do nothing... // Do nothing...
@ -471,12 +471,12 @@ public class PgpHandler extends ActionBarActivity implements OpenPgpServiceConne
String extra = ((EditText) findViewById(R.id.crypto_extra_edit)).getText().toString(); String extra = ((EditText) findViewById(R.id.crypto_extra_edit)).getText().toString();
if (name.isEmpty()) { if (name.isEmpty()) {
showToast("Please provide a file name"); showToast(this.getResources().getString(R.string.file_toast_text));
return; return;
} }
if (pass.isEmpty() && extra.isEmpty()) { 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; return;
} }

View File

@ -26,6 +26,32 @@
<string name="add_commit_text">[ANDROID PwdStore] Add </string> <string name="add_commit_text">[ANDROID PwdStore] Add </string>
<string name="remove_commit_text">[ANDROID PwdStore] Remove </string> <string name="remove_commit_text">[ANDROID PwdStore] Remove </string>
<string name="from_store"> from store.</string> <string name="from_store"> from store.</string>
<!-- PGPHandler -->
<string name="provider_toast_text">No OpenPGP Provider selected!</string>
<string name="okc_progress_text">Waiting for OpenKeychain...</string>
<string name="clipboard_beginning_toast_text">Password copied to clipboard, you have </string>
<string name="clipboard_ending_toast_text"> seconds to paste it somewhere.</string>
<string name="name_settings_toast_text">Please set your account name in settings whenever you can</string>
<string name="account_settings_dialog_text">Please set your OpenKeychain account (email) in the preferences</string>
<string name="account_settings_dialog_title">Account name empty!</string>
<string name="file_toast_text">Please provide a file name</string>
<string name="empty_toast_text">You cannot use an empty password or empty extra content</string>
<!-- Git Async Task -->
<string name="running_dialog_text">Running command...</string>
<string name="jgit_error_dialog_title">Internal exception occurred</string>
<string name="jgit_error_dialog_text">Message from jgit: /n</string>
<!-- Git Handler -->
<string name="read_only_dialog_text">You are about to use a read-only repository, you will not be able to push to it</string>
<string name="forget_username_dialog_text">Did you forget to specify a username?</string>
<string name="set_information_dialog_text">You have to set the information about the server before synchronizing with the server</string>
<string name="ssh_preferences_dialog_text">Please import your SSH key file in the preferences</string>
<string name="ssh_preferences_dialog_title">No SSH key</string>
<string name="passphrase_dialog_title">Authenticate</string>
<string name="passphrase_dialog_text">Please provide the passphrase for your SSH key. Leave it empty if there is no passphrase.</string>
<string name="password_dialog_text">Please provide the password for this repository</string>
<!-- Clone fragment --> <!-- Clone fragment -->
<string name="clone_fragment_text">Welcome to Password Store\n\n In this screen you can either create a new repository or clone your git repository onto your device.</string> <string name="clone_fragment_text">Welcome to Password Store\n\n In this screen you can either create a new repository or clone your git repository onto your device.</string>
@ -63,5 +89,7 @@
<string name="dialog_no">No</string> <string name="dialog_no">No</string>
<string name="dialog_positive">On my way...</string> <string name="dialog_positive">On my way...</string>
<string name="dialog_negative">Nah... later</string> <string name="dialog_negative">Nah... later</string>
<string name="dialog_oops">Oops...</string>
<string name="dialog_cancel">Cancel</string>
</resources> </resources>