From 6b4b520a3308096468a337ba97b6f73f00edb3c0 Mon Sep 17 00:00:00 2001 From: zeapo Date: Thu, 30 Oct 2014 22:30:33 +0100 Subject: Took off bindingDialog that caused more problems than solved --- .../java/com/zeapo/pwdstore/crypto/PgpHandler.java | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) (limited to 'app') 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..4730a8e6 100644 --- a/app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java +++ b/app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java @@ -58,8 +58,6 @@ public class PgpHandler extends ActionBarActivity implements OpenPgpServiceConne private Activity activity; ClipboardManager clipboard; - - private ProgressDialog bindingDialog; private boolean registered; public static final int REQUEST_CODE_SIGN = 9910; @@ -104,12 +102,6 @@ public class PgpHandler extends ActionBarActivity implements OpenPgpServiceConne mServiceConnection = new OpenPgpServiceConnection( PgpHandler.this, providerPackageName, this); mServiceConnection.bindToService(); - - bindingDialog = new ProgressDialog(this); - bindingDialog.setMessage("Waiting for OpenKeychain..."); - bindingDialog.setCancelable(false); - bindingDialog.show(); - registered = true; getSupportActionBar().setDisplayHomeAsUpEnabled(true); } @@ -295,7 +287,6 @@ public class PgpHandler extends ActionBarActivity implements OpenPgpServiceConne break; } } else if (resultCode == RESULT_CANCELED) { - bindingDialog.dismiss(); setResult(RESULT_CANCELED, data); finish(); } @@ -323,8 +314,6 @@ public class PgpHandler extends ActionBarActivity implements OpenPgpServiceConne Log.d(OpenPgpApi.TAG, "result: " + os.toByteArray().length + " str=" + os.toString("UTF-8")); - bindingDialog.dismiss(); - if (returnToCiphertextField) { findViewById(R.id.crypto_container).setVisibility(View.VISIBLE); @@ -342,7 +331,7 @@ public class PgpHandler extends ActionBarActivity implements OpenPgpServiceConne copyToClipBoard(); } } else { - showToast(os.toString()); + Log.d("PGPHANDLER", "Error message after decrypt : " + os.toString()); } } catch (UnsupportedEncodingException e) { Log.e(Constants.TAG, "UnsupportedEncodingException", e); @@ -406,13 +395,9 @@ public class PgpHandler extends ActionBarActivity implements OpenPgpServiceConne * * Check in open-pgp-lib how their definitions and error code */ - showToast("ERROR"); - OpenPgpError error = result.getParcelableExtra(OpenPgpApi.RESULT_ERROR); handleError(error); - // close the dialog - bindingDialog.dismiss(); break; } @@ -526,15 +511,12 @@ public class PgpHandler extends ActionBarActivity implements OpenPgpServiceConne ((TextView) findViewById(R.id.crypto_password_category)).setText(cat + "/"); decryptAndVerify(new Intent()); } else if (extra.getString("Operation").equals("ENCRYPT")) { - bindingDialog.dismiss(); - setContentView(R.layout.encrypt_layout); String cat = extra.getString("FILE_PATH"); cat = cat.replace(PasswordRepository.getWorkTree().getAbsolutePath(), ""); cat = cat + "/"; ((TextView) findViewById(R.id.crypto_password_category)).setText(cat); } else if (extra.getString("Operation").equals("GET_KEY_ID")) { - bindingDialog.dismiss(); getKeyIds(new Intent()); // setContentView(R.layout.key_id); -- cgit v1.2.3 From 005f0b6b7bc7c8971a28937e542a0adff33d8353 Mon Sep 17 00:00:00 2001 From: zeapo Date: Thu, 30 Oct 2014 22:31:09 +0100 Subject: when returning from an ADD without confirmation we are canceling not confirming --- app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') 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 4730a8e6..110f71eb 100644 --- a/app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java +++ b/app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java @@ -133,7 +133,7 @@ public class PgpHandler extends ActionBarActivity implements OpenPgpServiceConne int id = item.getItemId(); switch (id) { case android.R.id.home: - setResult(RESULT_OK); + setResult(RESULT_CANCELED); finish(); return true; case R.id.copy_password: -- cgit v1.2.3 From 64481bcb45892adac0786eab0674db7261dccf21 Mon Sep 17 00:00:00 2001 From: zeapo Date: Thu, 30 Oct 2014 22:32:19 +0100 Subject: fixes an issue where the password was always added on the root --- app/src/main/java/com/zeapo/pwdstore/PasswordFragment.java | 11 +++++++++++ app/src/main/java/com/zeapo/pwdstore/PasswordStore.java | 9 +++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.java b/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.java index fa97fcc4..2262b7d3 100644 --- a/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.java +++ b/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.java @@ -186,6 +186,17 @@ public class PasswordFragment extends Fragment{ pathStack.pop(); } + /** + * gets the current directory + * @return the current directory + */ + public File getCurrentDir() { + if (pathStack.isEmpty()) + return PasswordRepository.getWorkTree(); + else + return pathStack.peek(); + } + public boolean isNotEmpty() { return !passListStack.isEmpty(); } diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java index 62bf3d4f..f479347f 100644 --- a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java +++ b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java @@ -359,7 +359,7 @@ public class PasswordStore extends ActionBarActivity { try { Intent intent = new Intent(this, PgpHandler.class); intent.putExtra("PGP-ID", FileUtils.readFileToString(PasswordRepository.getFile("/.gpg-id"))); - intent.putExtra("FILE_PATH", this.currentDir.getAbsolutePath()); + intent.putExtra("FILE_PATH", getCurrentDir().getAbsolutePath()); intent.putExtra("Operation", "ENCRYPT"); startActivityForResult(intent, PgpHandler.REQUEST_CODE_ENCRYPT); } catch (Exception e) { @@ -429,7 +429,12 @@ public class PasswordStore extends ActionBarActivity { } private File getCurrentDir() { - return new File(((PasswordFragment) getFragmentManager().findFragmentByTag("PasswordsList")).getArguments().getString("Path")); + PasswordFragment plist; + if (null != + (plist = (PasswordFragment) getFragmentManager().findFragmentByTag("PasswordsList"))) { + return plist.getCurrentDir(); + } + return null; } protected void onActivityResult(int requestCode, int resultCode, -- cgit v1.2.3 From 8c2c4c3b248ae5148a5904398d6ee4fdb72aab17 Mon Sep 17 00:00:00 2001 From: zeapo Date: Thu, 30 Oct 2014 22:33:03 +0100 Subject: refresh the list rather than a full update related to PR #28 --- app/src/main/java/com/zeapo/pwdstore/PasswordStore.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java index f479347f..d3f75565 100644 --- a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java +++ b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java @@ -451,7 +451,7 @@ public class PasswordStore extends ActionBarActivity { git.add().addFilepattern("."), git.commit().setMessage("[ANDROID PwdStore] Add " + data.getExtras().getString("NAME") + " from store.") ); - updateListAdapter(); + refreshListAdapter(); break; case GitHandler.REQUEST_INIT: initRepository(getCurrentFocus()); -- cgit v1.2.3 From f3899041603293acf615d4d4349e6871c971d810 Mon Sep 17 00:00:00 2001 From: zeapo Date: Thu, 30 Oct 2014 22:38:56 +0100 Subject: uniforming passwordfragment instances --- .../java/com/zeapo/pwdstore/PasswordStore.java | 27 ++++++++-------------- 1 file changed, 9 insertions(+), 18 deletions(-) (limited to 'app') diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java index d3f75565..3788dfc1 100644 --- a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java +++ b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java @@ -38,6 +38,7 @@ public class PasswordStore extends ActionBarActivity { private File currentDir; private SharedPreferences settings; private Activity activity; + private PasswordFragment plist; @Override protected void onCreate(Bundle savedInstanceState) { @@ -302,15 +303,15 @@ public class PasswordStore extends ActionBarActivity { if (fragmentManager.findFragmentByTag("PasswordsList") == null) { PasswordRepository.setInitialized(true); - PasswordFragment passFrag = new PasswordFragment(); + plist = new PasswordFragment(); Bundle args = new Bundle(); args.putString("Path", localDir.getAbsolutePath()); - passFrag.setArguments(args); + plist.setArguments(args); fragmentTransaction.addToBackStack("passlist"); - fragmentTransaction.replace(R.id.main_layout, passFrag, "PasswordsList"); + fragmentTransaction.replace(R.id.main_layout, plist, "PasswordsList"); fragmentTransaction.commit(); } } @@ -322,9 +323,7 @@ public class PasswordStore extends ActionBarActivity { @Override public void onBackPressed() { - PasswordFragment plist; - if ((null != (plist = (PasswordFragment) getFragmentManager().findFragmentByTag("PasswordsList"))) && - plist.isNotEmpty()) { + if ((null != plist) && plist.isNotEmpty()) { plist.popBack(); } else { super.onBackPressed(); @@ -402,9 +401,7 @@ public class PasswordStore extends ActionBarActivity { * clears adapter's content and updates it with a fresh list of passwords from the root */ public void updateListAdapter() { - PasswordFragment plist; - if (null != - (plist = (PasswordFragment) getFragmentManager().findFragmentByTag("PasswordsList"))) { + if ((null != plist)) { plist.updateAdapter(); } } @@ -413,25 +410,19 @@ public class PasswordStore extends ActionBarActivity { * Updates the adapter with the current view of passwords */ public void refreshListAdapter() { - PasswordFragment plist; - if (null != - (plist = (PasswordFragment) getFragmentManager().findFragmentByTag("PasswordsList"))) { + if ((null != plist)) { plist.refreshAdapter(); } } public void filterListAdapter(String filter) { - PasswordFragment plist; - if (null != - (plist = (PasswordFragment) getFragmentManager().findFragmentByTag("PasswordsList"))) { + if ((null != plist)) { plist.filterAdapter(filter); } } private File getCurrentDir() { - PasswordFragment plist; - if (null != - (plist = (PasswordFragment) getFragmentManager().findFragmentByTag("PasswordsList"))) { + if ((null != plist)) { return plist.getCurrentDir(); } return null; -- cgit v1.2.3