Merge pull request #29 from iAmiAdam/String-Bash

Hard coded strings replaced with resources in PasswordStore
This commit is contained in:
Mohamed Zenadi 2014-10-31 14:23:36 +01:00
commit cff7c7e606
3 changed files with 34 additions and 15 deletions

View file

@ -54,7 +54,7 @@ public class PasswordStore extends ActionBarActivity {
super.onResume(); super.onResume();
// create the repository static variable in PasswordRepository // create the repository static variable in PasswordRepository
PasswordRepository.getRepository(new File(getFilesDir() + "/store/.git")); PasswordRepository.getRepository(new File(getFilesDir() + this.getResources().getString(R.string.store_git)));
// re-check that there was no change with the repository state // re-check that there was no change with the repository state
checkLocalRepository(); checkLocalRepository();
@ -112,8 +112,8 @@ public class PasswordStore extends ActionBarActivity {
Log.d("PASS", "Menu item " + id + " pressed"); Log.d("PASS", "Menu item " + id + " pressed");
AlertDialog.Builder initBefore = new AlertDialog.Builder(this) 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.") .setMessage(this.getResources().getString(R.string.creation_dialog_text))
.setPositiveButton("OK", new DialogInterface.OnClickListener() { .setPositiveButton(this.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) {
} }
@ -206,7 +206,7 @@ public class PasswordStore extends ActionBarActivity {
GitAsyncTask tasks = new GitAsyncTask(this, false, false, CommitCommand.class); GitAsyncTask tasks = new GitAsyncTask(this, false, false, CommitCommand.class);
tasks.execute( tasks.execute(
git.add().addFilepattern("."), 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) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@ -221,15 +221,15 @@ public class PasswordStore extends ActionBarActivity {
if (keyId.isEmpty()) if (keyId.isEmpty())
new AlertDialog.Builder(this) new AlertDialog.Builder(this)
.setMessage("You have to select your \"PGP-Key ID\" before initializing the repository") .setMessage(this.getResources().getString(R.string.key_dialog_text))
.setPositiveButton("On my way!", new DialogInterface.OnClickListener() { .setPositiveButton(this.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, GitHandler.REQUEST_INIT); startActivityForResult(intent, GitHandler.REQUEST_INIT);
} }
}) })
.setNegativeButton("Nah... later", new DialogInterface.OnClickListener() { .setNegativeButton(this.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 :(
@ -239,7 +239,7 @@ public class PasswordStore extends ActionBarActivity {
else { else {
new AlertDialog.Builder(this) 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() { .setPositiveButton("ssh-key", new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialogInterface, int i) { public void onClick(DialogInterface dialogInterface, int i) {
@ -369,9 +369,9 @@ public class PasswordStore extends ActionBarActivity {
public void deletePassword(final PasswordRecyclerAdapter adapter, final int position) { public void deletePassword(final PasswordRecyclerAdapter adapter, final int position) {
final PasswordItem item = adapter.getValues().get(position); final PasswordItem item = adapter.getValues().get(position);
new AlertDialog.Builder(this). new AlertDialog.Builder(this).
setMessage("Are you sure you want to delete the password \"" + setMessage(this.getResources().getString(R.string.delete_dialog_text) +
item + "\"") item + "\"")
.setPositiveButton("YES", new DialogInterface.OnClickListener() { .setPositiveButton(this.getResources().getString(R.string.dialog_yes), new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialogInterface, int i) { public void onClick(DialogInterface dialogInterface, int i) {
String path = item.getFile().getAbsolutePath(); String path = item.getFile().getAbsolutePath();
@ -388,7 +388,7 @@ public class PasswordStore extends ActionBarActivity {
); );
} }
}) })
.setNegativeButton("NO", new DialogInterface.OnClickListener() { .setNegativeButton(this.getResources().getString(R.string.dialog_no), new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialogInterface, int i) { public void onClick(DialogInterface dialogInterface, int i) {
@ -440,7 +440,7 @@ public class PasswordStore extends ActionBarActivity {
GitAsyncTask tasks = new GitAsyncTask(this, false, false, CommitCommand.class); GitAsyncTask tasks = new GitAsyncTask(this, false, false, CommitCommand.class);
tasks.execute( tasks.execute(
git.add().addFilepattern("."), 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))
); );
refreshListAdapter(); refreshListAdapter();
break; break;

View file

@ -24,8 +24,8 @@
<item android:id="@+id/refresh" <item android:id="@+id/refresh"
android:title="Refresh list" android:title="Refresh list"
android:showAsAction="never" pwstore:showAsAction="never"
android:icon="@drawable/ico_sync"/> android:icon="@drawable/ic_action_refresh"/>
<item android:id="@+id/user_pref" <item android:id="@+id/user_pref"
android:title="Settings" android:title="Settings"

View file

@ -13,7 +13,20 @@
<string name="dialog_delete">Delete directory</string> <string name="dialog_delete">Delete directory</string>
<string name="dialog_do_not_delete">Cancel</string> <string name="dialog_do_not_delete">Cancel</string>
<string name="title_activity_git_clone">Clone repository</string> <string name="title_activity_git_clone">Clone repository</string>
<!-- Password Store -->
<string name="creation_dialog_text">Please clone or create a new repository below before trying to add a password or any synchronization operation.</string>
<string name="store_git">/store/.git</string>
<string name="key_dialog_text">You have to select your "PGP-Key ID" before initializing the repository</string>
<string name="connection_dialog_text">Which connection method do you prefer?</string>
<string name="delete_dialog_text">Are you sure you want to delete the password /"</string>
<!-- git commits -->
<string name="initialization_commit_text">[ANDROID PwdStore] Initialized store with keyID: </string>
<string name="add_commit_text">[ANDROID PwdStore] Add </string>
<string name="remove_commit_text">[ANDROID PwdStore] Remove </string>
<string name="from_store"> from store.</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>
<string name="clone">Clone existing</string> <string name="clone">Clone existing</string>
@ -43,6 +56,12 @@
<!-- DECRYPT Layout --> <!-- DECRYPT Layout -->
<string name="crypto_category">Category</string> <string name="crypto_category">Category</string>
<string name="action_search">Search</string> <string name="action_search">Search</string>
<!-- Misc -->
<string name="dialog_ok">OK</string>
<string name="dialog_yes">Yes</string>
<string name="dialog_no">No</string>
<string name="dialog_positive">On my way...</string>
<string name="dialog_negative">Nah... later</string>
</resources> </resources>