mirror of
https://github.com/android-password-store/Android-Password-Store
synced 2025-08-31 06:15:48 +00:00
added account name settings and made it mandatory for encryption
This commit is contained in:
@@ -23,10 +23,11 @@ TODOs
|
|||||||
=====
|
=====
|
||||||
- Initialize a new pass repository
|
- Initialize a new pass repository
|
||||||
- Pull from/Push to a pass repository
|
- Pull from/Push to a pass repository
|
||||||
- Create a new cateogry
|
- Create a new category
|
||||||
- Multi-select (for password deletion)
|
- Multi-select (for password deletion)
|
||||||
- Multiple password stores (multiple git repositories).
|
- Multiple password stores (multiple git repositories).
|
||||||
- More UI enhancements
|
- More UI enhancements
|
||||||
|
- Clean-up the hard-coded strings
|
||||||
|
|
||||||
Needed
|
Needed
|
||||||
======
|
======
|
||||||
|
@@ -46,6 +46,7 @@ public class PgpHandler extends Activity {
|
|||||||
|
|
||||||
private OpenPgpServiceConnection mServiceConnection;
|
private OpenPgpServiceConnection mServiceConnection;
|
||||||
private String keyIDs = "";
|
private String keyIDs = "";
|
||||||
|
private String accountName = "";
|
||||||
SharedPreferences settings;
|
SharedPreferences settings;
|
||||||
|
|
||||||
public static final int REQUEST_CODE_SIGN = 9910;
|
public static final int REQUEST_CODE_SIGN = 9910;
|
||||||
@@ -80,7 +81,7 @@ public class PgpHandler extends Activity {
|
|||||||
// 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", "");
|
||||||
String accountName = settings.getString("openpgp_account_name", "");
|
accountName = settings.getString("openpgp_account_name", "");
|
||||||
|
|
||||||
if (TextUtils.isEmpty(providerPackageName)) {
|
if (TextUtils.isEmpty(providerPackageName)) {
|
||||||
Toast.makeText(this, "No OpenPGP Provider selected!", Toast.LENGTH_LONG).show();
|
Toast.makeText(this, "No OpenPGP Provider selected!", Toast.LENGTH_LONG).show();
|
||||||
@@ -95,6 +96,7 @@ public class PgpHandler extends Activity {
|
|||||||
|
|
||||||
ActionBar actionBar = getActionBar();
|
ActionBar actionBar = getActionBar();
|
||||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||||
|
Log.i("", accountName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -122,7 +124,7 @@ public class PgpHandler extends Activity {
|
|||||||
|
|
||||||
public void handleClick(View view) {
|
public void handleClick(View view) {
|
||||||
switch (view.getId()) {
|
switch (view.getId()) {
|
||||||
case R.id.crypto_show_button :
|
case R.id.crypto_show_button:
|
||||||
decryptAndVerify(new Intent());
|
decryptAndVerify(new Intent());
|
||||||
break;
|
break;
|
||||||
case R.id.crypto_confirm_add:
|
case R.id.crypto_confirm_add:
|
||||||
@@ -180,7 +182,7 @@ public class PgpHandler extends Activity {
|
|||||||
TextView extraText = (TextView) findViewById(R.id.crypto_extra_show);
|
TextView extraText = (TextView) findViewById(R.id.crypto_extra_show);
|
||||||
|
|
||||||
if (extraText.getText().length() != 0)
|
if (extraText.getText().length() != 0)
|
||||||
((LinearLayout) findViewById(R.id.crypto_extra_show_layout )).setVisibility(View.VISIBLE);
|
((LinearLayout) findViewById(R.id.crypto_extra_show_layout)).setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
this.pb = (ProgressBar) findViewById(R.id.pbLoading);
|
this.pb = (ProgressBar) findViewById(R.id.pbLoading);
|
||||||
this.pb.setMax(SHOW_TIME);
|
this.pb.setMax(SHOW_TIME);
|
||||||
@@ -189,7 +191,8 @@ public class PgpHandler extends Activity {
|
|||||||
@Override
|
@Override
|
||||||
protected Boolean doInBackground(Void... params) {
|
protected Boolean doInBackground(Void... params) {
|
||||||
while (this.count < SHOW_TIME) {
|
while (this.count < SHOW_TIME) {
|
||||||
SystemClock.sleep(1000); this.count++;
|
SystemClock.sleep(1000);
|
||||||
|
this.count++;
|
||||||
publishProgress(this.count);
|
publishProgress(this.count);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -241,7 +244,7 @@ public class PgpHandler extends Activity {
|
|||||||
((TextView) findViewById(R.id.crypto_password_show))
|
((TextView) findViewById(R.id.crypto_password_show))
|
||||||
.setText(passContent[0]);
|
.setText(passContent[0]);
|
||||||
|
|
||||||
String extraContent = os.toString("UTF-8").replaceFirst(".*\n","");
|
String extraContent = os.toString("UTF-8").replaceFirst(".*\n", "");
|
||||||
if (extraContent.length() != 0) {
|
if (extraContent.length() != 0) {
|
||||||
((TextView) findViewById(R.id.crypto_extra_show))
|
((TextView) findViewById(R.id.crypto_extra_show))
|
||||||
.setText(extraContent);
|
.setText(extraContent);
|
||||||
@@ -278,7 +281,6 @@ public class PgpHandler extends Activity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// verify
|
// verify
|
||||||
if (result.hasExtra(OpenPgpApi.RESULT_SIGNATURE)) {
|
if (result.hasExtra(OpenPgpApi.RESULT_SIGNATURE)) {
|
||||||
OpenPgpSignatureResult sigResult
|
OpenPgpSignatureResult sigResult
|
||||||
@@ -338,10 +340,33 @@ public class PgpHandler extends Activity {
|
|||||||
|
|
||||||
|
|
||||||
public void encrypt(Intent data) {
|
public void encrypt(Intent data) {
|
||||||
|
accountName = settings.getString("openpgp_account_name", "");
|
||||||
|
|
||||||
|
if (accountName.isEmpty()) {
|
||||||
|
new AlertDialog.Builder(this)
|
||||||
|
.setMessage("Please set your OpenKeychain account (email) in the preferences")
|
||||||
|
.setTitle("Account name empty!")
|
||||||
|
.setPositiveButton("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("No thanks", new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
|
// Do nothing...
|
||||||
|
}
|
||||||
|
}).show();
|
||||||
|
} else {
|
||||||
|
|
||||||
data.setAction(OpenPgpApi.ACTION_ENCRYPT);
|
data.setAction(OpenPgpApi.ACTION_ENCRYPT);
|
||||||
// TODO add preference so that the user sets his account name
|
data.putExtra(OpenPgpApi.EXTRA_USER_IDS, new String[]{accountName});
|
||||||
data.putExtra(OpenPgpApi.EXTRA_USER_IDS, new String[] {"default"});
|
|
||||||
data.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true);
|
data.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true);
|
||||||
|
|
||||||
String name = ((EditText) findViewById(R.id.crypto_password_file_edit)).getText().toString();
|
String name = ((EditText) findViewById(R.id.crypto_password_file_edit)).getText().toString();
|
||||||
@@ -353,7 +378,7 @@ public class PgpHandler extends Activity {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pass.isEmpty()) {
|
if (pass.isEmpty() || extra.isEmpty()) {
|
||||||
showToast("You cannot use an empty password or empty extra content");
|
showToast("You cannot use an empty password or empty extra content");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -368,9 +393,10 @@ public class PgpHandler extends Activity {
|
|||||||
OpenPgpApi api = new OpenPgpApi(this, mServiceConnection.getService());
|
OpenPgpApi api = new OpenPgpApi(this, mServiceConnection.getService());
|
||||||
api.executeApiAsync(data, is, os, new MyCallback(true, os, REQUEST_CODE_ENCRYPT));
|
api.executeApiAsync(data, is, os, new MyCallback(true, os, REQUEST_CODE_ENCRYPT));
|
||||||
|
|
||||||
}catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -5,5 +5,10 @@
|
|||||||
<org.openintents.openpgp.util.OpenPgpListPreference
|
<org.openintents.openpgp.util.OpenPgpListPreference
|
||||||
android:key="openpgp_provider_list"
|
android:key="openpgp_provider_list"
|
||||||
android:title="Select OpenPGP Provider!" />
|
android:title="Select OpenPGP Provider!" />
|
||||||
|
|
||||||
|
<EditTextPreference android:title="OpenPGP account"
|
||||||
|
android:hint="mail@somewhere.tld"
|
||||||
|
android:key="openpgp_account_name"/>
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
Reference in New Issue
Block a user