diff options
| author | Felix Bechstein <f@ub0r.de> | 2017-07-25 15:23:50 +0200 |
|---|---|---|
| committer | Mohamed Zenadi <zeapo@users.noreply.github.com> | 2017-07-25 14:23:50 +0100 |
| commit | 5da9e67545644925902b04a11306289add29c033 (patch) | |
| tree | de8ec31c4fe216157b7680a4defdee86429a4122 /app/src/main/java/com/zeapo/pwdstore/crypto | |
| parent | 5cba6c62d7b4628dfaf482dd883e333f93d323d4 (diff) | |
| download | HardenedPass-5da9e67545644925902b04a11306289add29c033.tar.gz HardenedPass-5da9e67545644925902b04a11306289add29c033.zip | |
Fix lint warnings (#319)
* Fix lint errors/warnings
Fix a lot of lint errors and warnings.
Most things are automatically applied fixes done with android studio:
* externalize strings
* remove unused code / classes / layouts / imports
* migrate some fields to local variables
* Remove dead code from comments
Removed code that is commented out long ago.
* remove unused resources
* colors
* strings
* drawables
* layouts
* menus
Diffstat (limited to 'app/src/main/java/com/zeapo/pwdstore/crypto')
| -rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java | 99 |
1 files changed, 49 insertions, 50 deletions
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 e938fdd4..12f2bcad 100644 --- a/app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java +++ b/app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java @@ -132,7 +132,7 @@ public class PgpHandler extends AppCompatActivity implements OpenPgpServiceConne try { this.mServiceConnection.unbindFromService(); } catch (Exception e) { - + // ignore any errors, we'll stop anyway. } } @@ -273,22 +273,12 @@ public class PgpHandler extends AppCompatActivity implements OpenPgpServiceConne public void handleClick(View view) { switch (view.getId()) { - case R.id.crypto_show_button: - decryptAndVerify(new Intent()); - break; - case R.id.crypto_delete_button: -// deletePassword(); - break; - case R.id.crypto_get_key_ids: - getKeyIds(new Intent()); - break; case R.id.generate_password: DialogFragment df = new pwgenDialogFragment(); df.show(getFragmentManager(), "generator"); default: Log.wtf(Constants.TAG,"This should not happen.... PgpHandler.java#handleClick(View) default reached."); // should not happen - } } @@ -571,7 +561,7 @@ public class PgpHandler extends AppCompatActivity implements OpenPgpServiceConne // get key ids if (result.hasExtra(OpenPgpApi.RESULT_KEY_IDS)) { long[] ids = result.getLongArrayExtra(OpenPgpApi.RESULT_KEY_IDS); - Set<String> keys = new HashSet<String>(); + Set<String> keys = new HashSet<>(); for (long id : ids) keys.add(String.valueOf(id)); // use Long settings.edit().putStringSet("openpgp_key_ids_set", keys).apply(); @@ -734,44 +724,53 @@ public class PgpHandler extends AppCompatActivity implements OpenPgpServiceConne if (operation == null){ return; } - if (operation.equals("DECRYPT")) { - setContentView(R.layout.decrypt_layout); - ((TextView) findViewById(R.id.crypto_password_file)).setText(extra.getString("NAME")); - String path = extra - .getString("FILE_PATH") - .replace(PasswordRepository.getRepositoryDirectory(getApplicationContext()).getAbsolutePath(), ""); - String cat = new File(path).getParentFile().getName(); - - ((TextView) findViewById(R.id.crypto_password_category)).setText(cat + "/"); - decryptAndVerify(new Intent()); - } else if (operation.equals("ENCRYPT")) { - setContentView(R.layout.encrypt_layout); - Typeface monoTypeface = Typeface.createFromAsset(getAssets(), "fonts/sourcecodepro.ttf"); - ((EditText) findViewById(R.id.crypto_password_edit)).setTypeface(monoTypeface); - ((EditText) findViewById(R.id.crypto_extra_edit)).setTypeface(monoTypeface); - String cat = extra.getString("FILE_PATH"); - cat = cat.replace(PasswordRepository.getRepositoryDirectory(getApplicationContext()).getAbsolutePath(), ""); - cat = cat + "/"; - ((TextView) findViewById(R.id.crypto_password_category)).setText(cat); - } else if (operation.equals("GET_KEY_ID")) { - getKeyIds(new Intent()); - -// setContentView(R.layout.key_id); -// if (!keyIDs.isEmpty()) { -// String keys = keyIDs.split(",").length > 1 ? keyIDs : keyIDs.split(",")[0]; -// ((TextView) findViewById(R.id.crypto_key_ids)).setText(keys); -// } - } else if (operation.equals("EDIT")) { - setContentView(R.layout.decrypt_layout); - ((TextView) findViewById(R.id.crypto_password_file)).setText(extra.getString("NAME")); - String cat = new File(extra.getString("FILE_PATH").replace(PasswordRepository.getRepositoryDirectory(getApplicationContext()).getAbsolutePath(), "")) - .getParentFile().getName(); - - ((TextView) findViewById(R.id.crypto_password_category)).setText(cat + "/"); - edit(new Intent()); - } else if (operation.equals("SELECTFOLDER")){ - setContentView(R.layout.select_folder_layout); - selectFolder(getIntent()); + switch (operation) { + case "DECRYPT": { + setContentView(R.layout.decrypt_layout); + ((TextView) findViewById(R.id.crypto_password_file)).setText(extra.getString("NAME")); + String path = extra + .getString("FILE_PATH") + .replace(PasswordRepository.getRepositoryDirectory(getApplicationContext()).getAbsolutePath(), ""); + String cat = new File(path).getParentFile().getName(); + + ((TextView) findViewById(R.id.crypto_password_category)).setText(cat + "/"); + decryptAndVerify(new Intent()); + break; + } + case "ENCRYPT": { + setContentView(R.layout.encrypt_layout); + Typeface monoTypeface = Typeface.createFromAsset(getAssets(), "fonts/sourcecodepro.ttf"); + ((EditText) findViewById(R.id.crypto_password_edit)).setTypeface(monoTypeface); + ((EditText) findViewById(R.id.crypto_extra_edit)).setTypeface(monoTypeface); + String cat = extra.getString("FILE_PATH"); + cat = cat.replace(PasswordRepository.getRepositoryDirectory(getApplicationContext()).getAbsolutePath(), ""); + cat = cat + "/"; + ((TextView) findViewById(R.id.crypto_password_category)).setText(cat); + break; + } + case "GET_KEY_ID": + getKeyIds(new Intent()); + +// setContentView(R.layout.key_id); +// if (!keyIDs.isEmpty()) { +// String keys = keyIDs.split(",").length > 1 ? keyIDs : keyIDs.split(",")[0]; +// ((TextView) findViewById(R.id.crypto_key_ids)).setText(keys); +// } + break; + case "EDIT": { + setContentView(R.layout.decrypt_layout); + ((TextView) findViewById(R.id.crypto_password_file)).setText(extra.getString("NAME")); + String cat = new File(extra.getString("FILE_PATH").replace(PasswordRepository.getRepositoryDirectory(getApplicationContext()).getAbsolutePath(), "")) + .getParentFile().getName(); + + ((TextView) findViewById(R.id.crypto_password_category)).setText(cat + "/"); + edit(new Intent()); + break; + } + case "SELECTFOLDER": + setContentView(R.layout.select_folder_layout); + selectFolder(getIntent()); + break; } } |
