From af2c0ab0e1e8f45e821e4fc37752eee4bc6ab1bc Mon Sep 17 00:00:00 2001 From: Adam Smith Date: Thu, 30 Oct 2014 22:11:31 +0000 Subject: Check that the string resources work --- app/src/main/java/com/zeapo/pwdstore/PasswordStore.java | 8 ++++---- app/src/main/res/values/strings.xml | 10 +++++++++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java index 62bf3d4f..18cee1f2 100644 --- a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java +++ b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java @@ -53,7 +53,7 @@ public class PasswordStore extends ActionBarActivity { super.onResume(); // create the repository static variable in PasswordRepository - PasswordRepository.getRepository(new File(getFilesDir() + "/store/.git")); + PasswordRepository.getRepository(new File(getFilesDir() + this.getResources().getString(R.string.git_store))); // re-check that there was no change with the repository state checkLocalRepository(); @@ -111,8 +111,8 @@ public class PasswordStore extends ActionBarActivity { Log.d("PASS", "Menu item " + id + " pressed"); AlertDialog.Builder initBefore = new AlertDialog.Builder(this) - .setMessage("Please clone or create a new repository below before trying to add a password or any synchronization operation.") - .setPositiveButton("OK", new DialogInterface.OnClickListener() { + .setMessage(this.getResources().getString(R.string.creation_alert_text)); + .setPositiveButton(this.getResources().getString(R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { } @@ -205,7 +205,7 @@ public class PasswordStore extends ActionBarActivity { GitAsyncTask tasks = new GitAsyncTask(this, false, false, CommitCommand.class); tasks.execute( git.add().addFilepattern("."), - git.commit().setMessage("[ANDROID PwdStore] Initialized store with keyID: " + keyId) + git.commit().setMessage(R.string.initialization_commit_text + keyId) ); } catch (Exception e) { e.printStackTrace(); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 07c6b3fd..0c44511c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -13,7 +13,12 @@ Delete directory Cancel Clone repository - + + + Please clone or create a new repository below before trying to add a password or any synchronization operation. + [ANDROID PwdStore] Initialized store with keyID: + /store/.git + Welcome to Password Store\n\n In this screen you can either create a new repository or clone your git repository onto your device. Clone existing @@ -43,6 +48,9 @@ Category Search + + + OK -- cgit v1.2.3 From d5e4ddc939abfea29852558a8a85409fef9eaf5a Mon Sep 17 00:00:00 2001 From: Adam Smith Date: Fri, 31 Oct 2014 11:37:52 +0000 Subject: Hard coded strings replaced with resources in PasswordStore --- .../java/com/zeapo/pwdstore/PasswordStore.java | 22 +++++++++++----------- app/src/main/res/menu/pwdstore.xml | 4 ++-- app/src/main/res/values/strings.xml | 19 +++++++++++++++---- 3 files changed, 28 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java index 18cee1f2..603eb305 100644 --- a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java +++ b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java @@ -53,7 +53,7 @@ public class PasswordStore extends ActionBarActivity { super.onResume(); // create the repository static variable in PasswordRepository - PasswordRepository.getRepository(new File(getFilesDir() + this.getResources().getString(R.string.git_store))); + PasswordRepository.getRepository(new File(getFilesDir() + this.getResources().getString(R.string.store_git))); // re-check that there was no change with the repository state checkLocalRepository(); @@ -111,8 +111,8 @@ public class PasswordStore extends ActionBarActivity { Log.d("PASS", "Menu item " + id + " pressed"); AlertDialog.Builder initBefore = new AlertDialog.Builder(this) - .setMessage(this.getResources().getString(R.string.creation_alert_text)); - .setPositiveButton(this.getResources().getString(R.string.ok), new DialogInterface.OnClickListener() { + .setMessage(this.getResources().getString(R.string.creation_dialog_text)) + .setPositiveButton(this.getResources().getString(R.string.dialog_ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { } @@ -220,15 +220,15 @@ public class PasswordStore extends ActionBarActivity { if (keyId.isEmpty()) new AlertDialog.Builder(this) - .setMessage("You have to select your \"PGP-Key ID\" before initializing the repository") - .setPositiveButton("On my way!", new DialogInterface.OnClickListener() { + .setMessage(this.getResources().getString(R.string.key_dialog_text)) + .setPositiveButton(this.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, GitHandler.REQUEST_INIT); } }) - .setNegativeButton("Nah... later", new DialogInterface.OnClickListener() { + .setNegativeButton(this.getResources().getString(R.string.dialog_negative), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { // do nothing :( @@ -238,7 +238,7 @@ public class PasswordStore extends ActionBarActivity { else { new AlertDialog.Builder(this) - .setMessage("Which connection method do you prefer?") + .setMessage(this.getResources().getString(R.string.connection_dialog_text)) .setPositiveButton("ssh-key", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { @@ -370,9 +370,9 @@ public class PasswordStore extends ActionBarActivity { public void deletePassword(final PasswordRecyclerAdapter adapter, final int position) { final PasswordItem item = adapter.getValues().get(position); new AlertDialog.Builder(this). - setMessage("Are you sure you want to delete the password \"" + + setMessage(this.getResources().getString(R.string.delete_dialog_text) + item + "\"") - .setPositiveButton("YES", new DialogInterface.OnClickListener() { + .setPositiveButton(this.getResources().getString(R.string.dialog_yes), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { String path = item.getFile().getAbsolutePath(); @@ -389,7 +389,7 @@ public class PasswordStore extends ActionBarActivity { ); } }) - .setNegativeButton("NO", new DialogInterface.OnClickListener() { + .setNegativeButton(this.getResources().getString(R.string.dialog_no), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { @@ -444,7 +444,7 @@ public class PasswordStore extends ActionBarActivity { GitAsyncTask tasks = new GitAsyncTask(this, false, false, CommitCommand.class); tasks.execute( git.add().addFilepattern("."), - git.commit().setMessage("[ANDROID PwdStore] Add " + data.getExtras().getString("NAME") + " from store.") + git.commit().setMessage(this.getResources().getString(R.string.add_commit_text) + data.getExtras().getString("NAME") + this.getResources().getString(R.string.from_store)) ); updateListAdapter(); break; diff --git a/app/src/main/res/menu/pwdstore.xml b/app/src/main/res/menu/pwdstore.xml index bfb3ad0c..220bd49b 100644 --- a/app/src/main/res/menu/pwdstore.xml +++ b/app/src/main/res/menu/pwdstore.xml @@ -24,8 +24,8 @@ + pwstore:showAsAction="never" + android:icon="@drawable/ic_action_refresh"/> Clone repository - Please clone or create a new repository below before trying to add a password or any synchronization operation. - [ANDROID PwdStore] Initialized store with keyID: + Please clone or create a new repository below before trying to add a password or any synchronization operation. /store/.git + You have to select your "PGP-Key ID" before initializing the repository + Which connection method do you prefer? + Are you sure you want to delete the password /" + + + [ANDROID PwdStore] Initialized store with keyID: + [ANDROID PwdStore] Add + [ANDROID PwdStore] Remove + from store. Welcome to Password Store\n\n In this screen you can either create a new repository or clone your git repository onto your device. @@ -50,7 +58,10 @@ Search - OK - + OK + Yes + No + On my way... + Nah... later -- cgit v1.2.3