fix #84 where account was missing, now it is selected on ecryption
This commit is contained in:
parent
a01276699a
commit
a23b268d9b
4 changed files with 24 additions and 55 deletions
Binary file not shown.
|
@ -9,8 +9,8 @@ android {
|
||||||
applicationId "com.zeapo.pwdstore"
|
applicationId "com.zeapo.pwdstore"
|
||||||
minSdkVersion 15
|
minSdkVersion 15
|
||||||
targetSdkVersion 22
|
targetSdkVersion 22
|
||||||
versionCode 36
|
versionCode 37
|
||||||
versionName "1.2.0.16"
|
versionName "1.2.0.17"
|
||||||
}
|
}
|
||||||
|
|
||||||
compileOptions {
|
compileOptions {
|
||||||
|
|
|
@ -389,7 +389,7 @@ public class PasswordStore extends ActionBarActivity {
|
||||||
switch (requestCode) {
|
switch (requestCode) {
|
||||||
case GitActivity.REQUEST_CLONE:
|
case GitActivity.REQUEST_CLONE:
|
||||||
// if we get here with a RESULT_OK then it's probably OK :)
|
// if we get here with a RESULT_OK then it's probably OK :)
|
||||||
settings.edit().putBoolean("repository_initialized", true).commit();
|
settings.edit().putBoolean("repository_initialized", true).apply();
|
||||||
break;
|
break;
|
||||||
case PgpHandler.REQUEST_CODE_ENCRYPT :
|
case PgpHandler.REQUEST_CODE_ENCRYPT :
|
||||||
Git git = new Git(PasswordRepository.getRepository(new File("")));
|
Git git = new Git(PasswordRepository.getRepository(new File("")));
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
package com.zeapo.pwdstore.crypto;
|
package com.zeapo.pwdstore.crypto;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.content.ClipData;
|
import android.content.ClipData;
|
||||||
import android.content.ClipboardManager;
|
import android.content.ClipboardManager;
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentSender;
|
import android.content.IntentSender;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
@ -52,7 +50,6 @@ public class PgpHandler extends AppCompatActivity implements OpenPgpServiceConne
|
||||||
|
|
||||||
private OpenPgpServiceConnection mServiceConnection;
|
private OpenPgpServiceConnection mServiceConnection;
|
||||||
private String keyIDs = "";
|
private String keyIDs = "";
|
||||||
private String accountName = "";
|
|
||||||
SharedPreferences settings;
|
SharedPreferences settings;
|
||||||
private Activity activity;
|
private Activity activity;
|
||||||
ClipboardManager clipboard;
|
ClipboardManager clipboard;
|
||||||
|
@ -85,7 +82,6 @@ public class PgpHandler extends AppCompatActivity implements OpenPgpServiceConne
|
||||||
// some persistance
|
// some persistance
|
||||||
settings = PreferenceManager.getDefaultSharedPreferences(this);
|
settings = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
String providerPackageName = settings.getString("openpgp_provider_list", "");
|
String providerPackageName = settings.getString("openpgp_provider_list", "");
|
||||||
accountName = settings.getString("openpgp_account_name", "");
|
|
||||||
keyIDs = settings.getString("openpgp_key_ids", "");
|
keyIDs = settings.getString("openpgp_key_ids", "");
|
||||||
|
|
||||||
registered = false;
|
registered = false;
|
||||||
|
@ -444,62 +440,35 @@ public class PgpHandler extends AppCompatActivity implements OpenPgpServiceConne
|
||||||
|
|
||||||
|
|
||||||
public void encrypt(Intent data) {
|
public void encrypt(Intent data) {
|
||||||
accountName = settings.getString("openpgp_account_name", "");
|
data.setAction(OpenPgpApi.ACTION_ENCRYPT);
|
||||||
|
data.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true);
|
||||||
|
|
||||||
if (accountName.isEmpty()) {
|
String name = ((EditText) findViewById(R.id.crypto_password_file_edit)).getText().toString();
|
||||||
new AlertDialog.Builder(this)
|
String pass = ((EditText) findViewById(R.id.crypto_password_edit)).getText().toString();
|
||||||
.setMessage(this.getResources().getString(R.string.account_settings_dialog_text))
|
String extra = ((EditText) findViewById(R.id.crypto_extra_edit)).getText().toString();
|
||||||
.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);
|
if (name.isEmpty()) {
|
||||||
data.putExtra(OpenPgpApi.EXTRA_USER_IDS, new String[]{accountName});
|
showToast(this.getResources().getString(R.string.file_toast_text));
|
||||||
data.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true);
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
String name = ((EditText) findViewById(R.id.crypto_password_file_edit)).getText().toString();
|
if (pass.isEmpty() && extra.isEmpty()) {
|
||||||
String pass = ((EditText) findViewById(R.id.crypto_password_edit)).getText().toString();
|
showToast(this.getResources().getString(R.string.empty_toast_text));
|
||||||
String extra = ((EditText) findViewById(R.id.crypto_extra_edit)).getText().toString();
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (name.isEmpty()) {
|
ByteArrayInputStream is;
|
||||||
showToast(this.getResources().getString(R.string.file_toast_text));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pass.isEmpty() && extra.isEmpty()) {
|
try {
|
||||||
showToast(this.getResources().getString(R.string.empty_toast_text));
|
is = new ByteArrayInputStream((pass + "\n" + extra).getBytes("UTF-8"));
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ByteArrayInputStream is;
|
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||||
|
|
||||||
try {
|
OpenPgpApi api = new OpenPgpApi(this, mServiceConnection.getService());
|
||||||
is = new ByteArrayInputStream((pass + "\n" + extra).getBytes("UTF-8"));
|
api.executeApiAsync(data, is, os, new PgpCallback(true, os, REQUEST_CODE_ENCRYPT));
|
||||||
|
|
||||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
OpenPgpApi api = new OpenPgpApi(this, mServiceConnection.getService());
|
|
||||||
api.executeApiAsync(data, is, os, new PgpCallback(true, os, REQUEST_CODE_ENCRYPT));
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue