mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-27 19:22:14 -05:00
Merge pull request #1108 from tdjogi010/development
Asks Passphrase for key delete/export in ViewKeyActivity.
This commit is contained in:
commit
443feef27a
@ -89,6 +89,8 @@ public class ViewKeyActivity extends BaseActivity implements
|
|||||||
LoaderManager.LoaderCallbacks<Cursor> {
|
LoaderManager.LoaderCallbacks<Cursor> {
|
||||||
|
|
||||||
static final int REQUEST_QR_FINGERPRINT = 1;
|
static final int REQUEST_QR_FINGERPRINT = 1;
|
||||||
|
static final int REQUEST_DELETE= 2;
|
||||||
|
static final int REQUEST_EXPORT= 3;
|
||||||
|
|
||||||
ExportHelper mExportHelper;
|
ExportHelper mExportHelper;
|
||||||
ProviderHelper mProviderHelper;
|
ProviderHelper mProviderHelper;
|
||||||
@ -298,48 +300,63 @@ public class ViewKeyActivity extends BaseActivity implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
try {
|
switch (item.getItemId()) {
|
||||||
switch (item.getItemId()) {
|
case android.R.id.home: {
|
||||||
case android.R.id.home: {
|
Intent homeIntent = new Intent(this, MainActivity.class);
|
||||||
Intent homeIntent = new Intent(this, MainActivity.class);
|
homeIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||||
homeIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
startActivity(homeIntent);
|
||||||
startActivity(homeIntent);
|
return true;
|
||||||
return true;
|
}
|
||||||
}
|
case R.id.menu_key_view_export_file: {
|
||||||
case R.id.menu_key_view_export_file: {
|
Intent mIntent = new Intent(this,PassphraseDialogActivity.class);
|
||||||
exportToFile(mDataUri, mExportHelper, mProviderHelper);
|
long keyId=0;
|
||||||
return true;
|
try {
|
||||||
}
|
keyId = new ProviderHelper(this)
|
||||||
case R.id.menu_key_view_delete: {
|
.getCachedPublicKeyRing(mDataUri)
|
||||||
deleteKey(mDataUri, mExportHelper);
|
.extractOrGetMasterKeyId();
|
||||||
return true;
|
} catch (PgpKeyNotFoundException e) {
|
||||||
}
|
e.printStackTrace();
|
||||||
case R.id.menu_key_view_advanced: {
|
}
|
||||||
Intent advancedIntent = new Intent(this, ViewKeyAdvActivity.class);
|
mIntent.putExtra(PassphraseDialogActivity.EXTRA_SUBKEY_ID,keyId);
|
||||||
advancedIntent.setData(mDataUri);
|
startActivityForResult(mIntent,REQUEST_EXPORT);
|
||||||
startActivity(advancedIntent);
|
return true;
|
||||||
return true;
|
}
|
||||||
}
|
case R.id.menu_key_view_delete: {
|
||||||
case R.id.menu_key_view_refresh: {
|
Intent mIntent = new Intent(this,PassphraseDialogActivity.class);
|
||||||
try {
|
long keyId=0;
|
||||||
updateFromKeyserver(mDataUri, mProviderHelper);
|
try {
|
||||||
} catch (ProviderHelper.NotFoundException e) {
|
keyId = new ProviderHelper(this)
|
||||||
Notify.showNotify(this, R.string.error_key_not_found, Notify.Style.ERROR);
|
.getCachedPublicKeyRing(mDataUri)
|
||||||
}
|
.extractOrGetMasterKeyId();
|
||||||
return true;
|
} catch (PgpKeyNotFoundException e) {
|
||||||
}
|
e.printStackTrace();
|
||||||
case R.id.menu_key_view_edit: {
|
}
|
||||||
editKey(mDataUri);
|
mIntent.putExtra(PassphraseDialogActivity.EXTRA_SUBKEY_ID,keyId);
|
||||||
return true;
|
startActivityForResult(mIntent,REQUEST_DELETE);
|
||||||
}
|
return true;
|
||||||
case R.id.menu_key_view_certify_fingerprint: {
|
}
|
||||||
certifyFingeprint(mDataUri);
|
case R.id.menu_key_view_advanced: {
|
||||||
return true;
|
Intent advancedIntent = new Intent(this, ViewKeyAdvActivity.class);
|
||||||
}
|
advancedIntent.setData(mDataUri);
|
||||||
|
startActivity(advancedIntent);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case R.id.menu_key_view_refresh: {
|
||||||
|
try {
|
||||||
|
updateFromKeyserver(mDataUri, mProviderHelper);
|
||||||
|
} catch (ProviderHelper.NotFoundException e) {
|
||||||
|
Notify.showNotify(this, R.string.error_key_not_found, Notify.Style.ERROR);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case R.id.menu_key_view_edit: {
|
||||||
|
editKey(mDataUri);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case R.id.menu_key_view_certify_fingerprint: {
|
||||||
|
certifyFingeprint(mDataUri);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
} catch (ProviderHelper.NotFoundException e) {
|
|
||||||
Notify.showNotify(this, R.string.error_key_not_found, Notify.Style.ERROR);
|
|
||||||
Log.e(Constants.TAG, "Key not found", e);
|
|
||||||
}
|
}
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
@ -427,6 +444,12 @@ public class ViewKeyActivity extends BaseActivity implements
|
|||||||
startActivityForResult(intent, 0);
|
startActivityForResult(intent, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onSaveInstanceState(Bundle outState) {
|
||||||
|
//Note:-Done due to the same weird crashes as for commitAllowingStateLoss()
|
||||||
|
//super.onSaveInstanceState(outState);
|
||||||
|
}
|
||||||
|
|
||||||
private void showQrCodeDialog() {
|
private void showQrCodeDialog() {
|
||||||
Intent qrCodeIntent = new Intent(this, QrCodeViewActivity.class);
|
Intent qrCodeIntent = new Intent(this, QrCodeViewActivity.class);
|
||||||
|
|
||||||
@ -500,6 +523,19 @@ public class ViewKeyActivity extends BaseActivity implements
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (requestCode == REQUEST_DELETE && resultCode == Activity.RESULT_OK){
|
||||||
|
deleteKey(mDataUri, mExportHelper);
|
||||||
|
}
|
||||||
|
if (requestCode == REQUEST_EXPORT && resultCode == Activity.RESULT_OK){
|
||||||
|
try {
|
||||||
|
exportToFile(mDataUri, mExportHelper, mProviderHelper);
|
||||||
|
} catch (ProviderHelper.NotFoundException e) {
|
||||||
|
Notify.showNotify(this, R.string.error_key_not_found, Notify.Style.ERROR);
|
||||||
|
Log.e(Constants.TAG, "Key not found", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (data != null && data.hasExtra(OperationResult.EXTRA_RESULT)) {
|
if (data != null && data.hasExtra(OperationResult.EXTRA_RESULT)) {
|
||||||
OperationResult result = data.getParcelableExtra(OperationResult.EXTRA_RESULT);
|
OperationResult result = data.getParcelableExtra(OperationResult.EXTRA_RESULT);
|
||||||
result.createNotify(this).show();
|
result.createNotify(this).show();
|
||||||
|
Loading…
Reference in New Issue
Block a user