diff options
Diffstat (limited to 'app/src')
3 files changed, 27 insertions, 38 deletions
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 603eb305..3de74357 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(); @@ -359,7 +358,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) { @@ -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,23 +410,22 @@ 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() { - return new File(((PasswordFragment) getFragmentManager().findFragmentByTag("PasswordsList")).getArguments().getString("Path")); + if ((null != plist)) { + return plist.getCurrentDir(); + } + return null; } protected void onActivityResult(int requestCode, int resultCode, @@ -446,7 +442,7 @@ public class PasswordStore extends ActionBarActivity { git.add().addFilepattern("."), git.commit().setMessage(this.getResources().getString(R.string.add_commit_text) + data.getExtras().getString("NAME") + this.getResources().getString(R.string.from_store)) ); - updateListAdapter(); + refreshListAdapter(); break; case GitHandler.REQUEST_INIT: initRepository(getCurrentFocus()); 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..110f71eb 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); } @@ -141,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: @@ -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); |