diff options
Diffstat (limited to 'app/src/main/java/com/zeapo/pwdstore/crypto')
| -rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java | 73 |
1 files changed, 21 insertions, 52 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 2e676b46..3e94344d 100644 --- a/app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java +++ b/app/src/main/java/com/zeapo/pwdstore/crypto/PgpHandler.java @@ -1,11 +1,9 @@ package com.zeapo.pwdstore.crypto; import android.app.Activity; -import android.app.AlertDialog; import android.app.PendingIntent; import android.content.ClipData; import android.content.ClipboardManager; -import android.content.DialogInterface; import android.content.Intent; import android.content.IntentSender; import android.content.SharedPreferences; @@ -52,7 +50,6 @@ public class PgpHandler extends AppCompatActivity implements OpenPgpServiceConne private OpenPgpServiceConnection mServiceConnection; private String keyIDs = ""; - private String accountName = ""; SharedPreferences settings; private Activity activity; ClipboardManager clipboard; @@ -85,7 +82,6 @@ public class PgpHandler extends AppCompatActivity implements OpenPgpServiceConne // some persistance settings = PreferenceManager.getDefaultSharedPreferences(this); String providerPackageName = settings.getString("openpgp_provider_list", ""); - accountName = settings.getString("openpgp_account_name", ""); keyIDs = settings.getString("openpgp_key_ids", ""); registered = false; @@ -444,62 +440,35 @@ public class PgpHandler extends AppCompatActivity implements OpenPgpServiceConne public void encrypt(Intent data) { - accountName = settings.getString("openpgp_account_name", ""); - - if (accountName.isEmpty()) { - new AlertDialog.Builder(this) - .setMessage(this.getResources().getString(R.string.account_settings_dialog_text)) - .setTitle(this.getResources().getString(R.string.account_settings_dialog_title)) - .setPositiveButton(this.getResources().getString(R.string.dialog_ok), new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int id) { - try { - Intent intent = new Intent(getApplicationContext(), UserPreference.class); - startActivity(intent); - } catch (Exception e) { - System.out.println("Exception caught :("); - e.printStackTrace(); - } - } - }).setNegativeButton(this.getResources().getString(R.string.dialog_no), new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int id) { - // Do nothing... - } - }).show(); - } else { - - data.setAction(OpenPgpApi.ACTION_ENCRYPT); - data.putExtra(OpenPgpApi.EXTRA_USER_IDS, new String[]{accountName}); - data.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true); + data.setAction(OpenPgpApi.ACTION_ENCRYPT); + data.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true); - String name = ((EditText) findViewById(R.id.crypto_password_file_edit)).getText().toString(); - String pass = ((EditText) findViewById(R.id.crypto_password_edit)).getText().toString(); - String extra = ((EditText) findViewById(R.id.crypto_extra_edit)).getText().toString(); + String name = ((EditText) findViewById(R.id.crypto_password_file_edit)).getText().toString(); + String pass = ((EditText) findViewById(R.id.crypto_password_edit)).getText().toString(); + String extra = ((EditText) findViewById(R.id.crypto_extra_edit)).getText().toString(); - if (name.isEmpty()) { - showToast(this.getResources().getString(R.string.file_toast_text)); - return; - } + if (name.isEmpty()) { + showToast(this.getResources().getString(R.string.file_toast_text)); + return; + } - if (pass.isEmpty() && extra.isEmpty()) { - showToast(this.getResources().getString(R.string.empty_toast_text)); - return; - } + if (pass.isEmpty() && extra.isEmpty()) { + showToast(this.getResources().getString(R.string.empty_toast_text)); + return; + } - ByteArrayInputStream is; + ByteArrayInputStream is; - try { - is = new ByteArrayInputStream((pass + "\n" + extra).getBytes("UTF-8")); + try { + is = new ByteArrayInputStream((pass + "\n" + extra).getBytes("UTF-8")); - ByteArrayOutputStream os = new ByteArrayOutputStream(); + ByteArrayOutputStream os = new ByteArrayOutputStream(); - OpenPgpApi api = new OpenPgpApi(this, mServiceConnection.getService()); - api.executeApiAsync(data, is, os, new PgpCallback(true, os, REQUEST_CODE_ENCRYPT)); + OpenPgpApi api = new OpenPgpApi(this, mServiceConnection.getService()); + api.executeApiAsync(data, is, os, new PgpCallback(true, os, REQUEST_CODE_ENCRYPT)); - } catch (Exception e) { - e.printStackTrace(); - } + } catch (Exception e) { + e.printStackTrace(); } } |
