Fix nullpointer with clipboard

This commit is contained in:
Dominik Schürmann 2014-10-03 02:17:51 +02:00
parent 9a296c012d
commit b9dc21969f
2 changed files with 9 additions and 10 deletions

View File

@ -76,20 +76,19 @@ public class DecryptActivity extends DrawerActivity {
if (Build.VERSION.SDK_INT >= VERSION_CODES.ICE_CREAM_SANDWICH) { if (Build.VERSION.SDK_INT >= VERSION_CODES.ICE_CREAM_SANDWICH) {
// get text from clipboard // get text from clipboard
final String clipboardText = final CharSequence clipboardText = ClipboardReflection.getClipboardText(DecryptActivity.this);
ClipboardReflection.getClipboardText(DecryptActivity.this).toString();
AsyncTask<Void, Void, Boolean> tadaTask = new AsyncTask<Void, Void, Boolean>() { AsyncTask<String, Void, Boolean> tadaTask = new AsyncTask<String, Void, Boolean>() {
@Override @Override
protected Boolean doInBackground(Void... params) { protected Boolean doInBackground(String... clipboardText) {
// see if it looks like a pgp thing // see if it looks like a pgp thing
Matcher matcher = PgpHelper.PGP_MESSAGE.matcher(clipboardText); Matcher matcher = PgpHelper.PGP_MESSAGE.matcher(clipboardText[0]);
boolean animate = matcher.matches(); boolean animate = matcher.matches();
// see if it looks like another pgp thing // see if it looks like another pgp thing
if (!animate) { if (!animate) {
matcher = PgpHelper.PGP_CLEARTEXT_SIGNATURE.matcher(clipboardText); matcher = PgpHelper.PGP_CLEARTEXT_SIGNATURE.matcher(clipboardText[0]);
animate = matcher.matches(); animate = matcher.matches();
} }
return animate; return animate;
@ -107,7 +106,7 @@ public class DecryptActivity extends DrawerActivity {
}; };
if (clipboardText != null) { if (clipboardText != null) {
tadaTask.execute(); tadaTask.execute(clipboardText.toString());
} }
} }
} }

View File

@ -156,11 +156,11 @@ public class DecryptTextActivity extends ActionBarActivity {
} else if (ACTION_DECRYPT_FROM_CLIPBOARD.equals(action)) { } else if (ACTION_DECRYPT_FROM_CLIPBOARD.equals(action)) {
Log.d(Constants.TAG, "ACTION_DECRYPT_FROM_CLIPBOARD"); Log.d(Constants.TAG, "ACTION_DECRYPT_FROM_CLIPBOARD");
String clipboardText = ClipboardReflection.getClipboardText(this).toString(); CharSequence clipboardText = ClipboardReflection.getClipboardText(this);
clipboardText = getPgpContent(clipboardText);
if (clipboardText != null) { if (clipboardText != null) {
loadFragment(savedInstanceState, clipboardText); String text = getPgpContent(clipboardText.toString());
loadFragment(savedInstanceState, text);
} else { } else {
returnInvalidResult(); returnInvalidResult();
} }