This commit is contained in:
Dominik Schürmann 2014-02-04 19:55:40 +01:00
parent d090d4d332
commit a56219a027
2 changed files with 62 additions and 58 deletions

View File

@ -61,7 +61,7 @@ public class KeychainIntentServiceHandler extends Handler {
} }
public void showProgressDialog(FragmentActivity activity) { public void showProgressDialog(FragmentActivity activity) {
// TODO: THis is a hack!, see http://stackoverflow.com/questions/10114324/show-dialogfragment-from-onactivityresult // TODO: This is a hack!, see http://stackoverflow.com/questions/10114324/show-dialogfragment-from-onactivityresult
final FragmentManager manager = activity.getSupportFragmentManager(); final FragmentManager manager = activity.getSupportFragmentManager();
Handler handler = new Handler(); Handler handler = new Handler();
handler.post(new Runnable() { handler.post(new Runnable() {

View File

@ -271,14 +271,14 @@ public class DecryptActivity extends DrawerActivity {
if (mDecryptImmediately if (mDecryptImmediately
|| (mSource.getCurrentView().getId() == R.id.sourceMessage && (mMessage.getText() || (mSource.getCurrentView().getId() == R.id.sourceMessage && (mMessage.getText()
.length() > 0 || mContentUri != null))) { .length() > 0 || mContentUri != null))) {
decryptClicked(); decryptClicked();
} }
} }
/** /**
* Handles all actions with this intent * Handles all actions with this intent
* *
* @param intent * @param intent
*/ */
private void handleActions(Intent intent) { private void handleActions(Intent intent) {
@ -383,21 +383,21 @@ public class DecryptActivity extends DrawerActivity {
private void updateSource() { private void updateSource() {
switch (mSource.getCurrentView().getId()) { switch (mSource.getCurrentView().getId()) {
case R.id.sourceFile: { case R.id.sourceFile: {
mSourceLabel.setText(R.string.label_file); mSourceLabel.setText(R.string.label_file);
mDecryptButton.setText(getString(R.string.btn_decrypt)); mDecryptButton.setText(getString(R.string.btn_decrypt));
break; break;
} }
case R.id.sourceMessage: { case R.id.sourceMessage: {
mSourceLabel.setText(R.string.label_message); mSourceLabel.setText(R.string.label_message);
mDecryptButton.setText(getString(R.string.btn_decrypt)); mDecryptButton.setText(getString(R.string.btn_decrypt));
break; break;
} }
default: { default: {
break; break;
} }
} }
} }
@ -535,7 +535,7 @@ public class DecryptActivity extends DrawerActivity {
try { try {
if (inStream.markSupported()) { if (inStream.markSupported()) {
inStream.mark(200); // should probably set this to the max size of two pgpF inStream.mark(200); // should probably set this to the max size of two pgpF
// objects, if it even needs to be anything other than 0. // objects, if it even needs to be anything other than 0.
} }
mSecretKeyId = PgpHelper.getDecryptionKeyId(this, inStream); mSecretKeyId = PgpHelper.getDecryptionKeyId(this, inStream);
if (mSecretKeyId == Id.key.none) { if (mSecretKeyId == Id.key.none) {
@ -567,7 +567,7 @@ public class DecryptActivity extends DrawerActivity {
data = "\n\n" + data; data = "\n\n" + data;
intent.putExtra(EncryptActivity.EXTRA_TEXT, data); intent.putExtra(EncryptActivity.EXTRA_TEXT, data);
intent.putExtra(EncryptActivity.EXTRA_SIGNATURE_KEY_ID, mSecretKeyId); intent.putExtra(EncryptActivity.EXTRA_SIGNATURE_KEY_ID, mSecretKeyId);
intent.putExtra(EncryptActivity.EXTRA_ENCRYPTION_KEY_IDS, new long[] { mSignatureKeyId }); intent.putExtra(EncryptActivity.EXTRA_ENCRYPTION_KEY_IDS, new long[]{mSignatureKeyId});
startActivity(intent); startActivity(intent);
} }
@ -665,26 +665,26 @@ public class DecryptActivity extends DrawerActivity {
} }
switch (mDecryptTarget) { switch (mDecryptTarget) {
case Id.target.message: case Id.target.message:
String decryptedMessage = returnData String decryptedMessage = returnData
.getString(KeychainIntentService.RESULT_DECRYPTED_STRING); .getString(KeychainIntentService.RESULT_DECRYPTED_STRING);
mMessage.setText(decryptedMessage); mMessage.setText(decryptedMessage);
mMessage.setHorizontallyScrolling(false); mMessage.setHorizontallyScrolling(false);
break; break;
case Id.target.file: case Id.target.file:
if (mDeleteAfter.isChecked()) { if (mDeleteAfter.isChecked()) {
// Create and show dialog to delete original file // Create and show dialog to delete original file
DeleteFileDialogFragment deleteFileDialog = DeleteFileDialogFragment DeleteFileDialogFragment deleteFileDialog = DeleteFileDialogFragment
.newInstance(mInputFilename); .newInstance(mInputFilename);
deleteFileDialog.show(getSupportFragmentManager(), "deleteDialog"); deleteFileDialog.show(getSupportFragmentManager(), "deleteDialog");
} }
break; break;
default: default:
// shouldn't happen // shouldn't happen
break; break;
} }
@ -722,7 +722,9 @@ public class DecryptActivity extends DrawerActivity {
mSignatureLayout.setVisibility(View.VISIBLE); mSignatureLayout.setVisibility(View.VISIBLE);
} }
} }
}; }
;
}; };
// Create a new Messenger for the communication back // Create a new Messenger for the communication back
@ -739,34 +741,36 @@ public class DecryptActivity extends DrawerActivity {
@Override @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) { protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) { switch (requestCode) {
case RESULT_CODE_FILE: { case RESULT_CODE_FILE: {
if (resultCode == RESULT_OK && data != null) { if (resultCode == RESULT_OK && data != null) {
try { try {
String path = FileHelper.getPath(this, data.getData()); String path = FileHelper.getPath(this, data.getData());
Log.d(Constants.TAG, "path=" + path); Log.d(Constants.TAG, "path=" + path);
mFilename.setText(path); mFilename.setText(path);
} catch (NullPointerException e) { } catch (NullPointerException e) {
Log.e(Constants.TAG, "Nullpointer while retrieving path!"); Log.e(Constants.TAG, "Nullpointer while retrieving path!");
}
} }
return;
} }
return;
}
// this request is returned after LookupUnknownKeyDialogFragment started // this request is returned after LookupUnknownKeyDialogFragment started
// ImportKeysActivity and user looked uo key // ImportKeysActivity and user looked uo key
case RESULT_CODE_LOOKUP_KEY: { case RESULT_CODE_LOOKUP_KEY: {
Log.d(Constants.TAG, "Returning from Lookup Key..."); Log.d(Constants.TAG, "Returning from Lookup Key...");
// decrypt again if (resultCode == RESULT_OK) {
decryptStart(); // decrypt again
return; decryptStart();
} }
return;
}
default: { default: {
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);
break; break;
} }
} }
} }