|
|
@ -367,6 +367,14 @@ public class FragmentCompose extends FragmentEx { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onResume() { |
|
|
|
super.onResume(); |
|
|
|
|
|
|
|
if (!pgpService.isBound()) |
|
|
|
pgpService.bindToService(); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onPause() { |
|
|
|
if (autosave) |
|
|
@ -488,30 +496,42 @@ public class FragmentCompose extends FragmentEx { |
|
|
|
} |
|
|
|
|
|
|
|
private void onEncrypt() { |
|
|
|
if (Helper.isPro(getContext())) |
|
|
|
try { |
|
|
|
String to = etTo.getText().toString(); |
|
|
|
InternetAddress ato[] = (TextUtils.isEmpty(to) ? new InternetAddress[0] : InternetAddress.parse(to)); |
|
|
|
if (ato.length == 0) |
|
|
|
throw new IllegalArgumentException(getString(R.string.title_to_missing)); |
|
|
|
|
|
|
|
String[] tos = new String[ato.length]; |
|
|
|
for (int i = 0; i < ato.length; i++) |
|
|
|
tos[i] = ato[i].getAddress(); |
|
|
|
|
|
|
|
Intent data = new Intent(); |
|
|
|
data.setAction(OpenPgpApi.ACTION_SIGN_AND_ENCRYPT); |
|
|
|
data.putExtra(OpenPgpApi.EXTRA_USER_IDS, tos); |
|
|
|
data.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true); |
|
|
|
|
|
|
|
encrypt(data); |
|
|
|
} catch (Throwable ex) { |
|
|
|
if (ex instanceof IllegalArgumentException) |
|
|
|
Snackbar.make(view, ex.getMessage(), Snackbar.LENGTH_LONG).show(); |
|
|
|
else |
|
|
|
Helper.unexpectedError(getContext(), ex); |
|
|
|
if (Helper.isPro(getContext())) { |
|
|
|
if (pgpService.isBound()) |
|
|
|
try { |
|
|
|
String to = etTo.getText().toString(); |
|
|
|
InternetAddress ato[] = (TextUtils.isEmpty(to) ? new InternetAddress[0] : InternetAddress.parse(to)); |
|
|
|
if (ato.length == 0) |
|
|
|
throw new IllegalArgumentException(getString(R.string.title_to_missing)); |
|
|
|
|
|
|
|
String[] tos = new String[ato.length]; |
|
|
|
for (int i = 0; i < ato.length; i++) |
|
|
|
tos[i] = ato[i].getAddress(); |
|
|
|
|
|
|
|
Intent data = new Intent(); |
|
|
|
data.setAction(OpenPgpApi.ACTION_SIGN_AND_ENCRYPT); |
|
|
|
data.putExtra(OpenPgpApi.EXTRA_USER_IDS, tos); |
|
|
|
data.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true); |
|
|
|
|
|
|
|
encrypt(data); |
|
|
|
} catch (Throwable ex) { |
|
|
|
if (ex instanceof IllegalArgumentException) |
|
|
|
Snackbar.make(view, ex.getMessage(), Snackbar.LENGTH_LONG).show(); |
|
|
|
else |
|
|
|
Helper.unexpectedError(getContext(), ex); |
|
|
|
} |
|
|
|
else { |
|
|
|
Snackbar snackbar = Snackbar.make(view, R.string.title_no_openpgp, Snackbar.LENGTH_LONG); |
|
|
|
if (Helper.getIntentOpenKeychain().resolveActivity(getContext().getPackageManager()) != null) |
|
|
|
snackbar.setAction(R.string.title_fix, new View.OnClickListener() { |
|
|
|
@Override |
|
|
|
public void onClick(View v) { |
|
|
|
startActivity(Helper.getIntentOpenKeychain()); |
|
|
|
} |
|
|
|
}); |
|
|
|
snackbar.show(); |
|
|
|
} |
|
|
|
else { |
|
|
|
} else { |
|
|
|
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction(); |
|
|
|
fragmentTransaction.replace(R.id.content_frame, new FragmentPro()).addToBackStack("pro"); |
|
|
|
fragmentTransaction.commit(); |
|
|
@ -530,9 +550,6 @@ public class FragmentCompose extends FragmentEx { |
|
|
|
long id = args.getLong("id"); |
|
|
|
Intent data = args.getParcelable("data"); |
|
|
|
|
|
|
|
if (!pgpService.isBound()) |
|
|
|
throw new IllegalArgumentException(getString(R.string.title_no_openpgp)); |
|
|
|
|
|
|
|
DB db = DB.getInstance(context); |
|
|
|
|
|
|
|
// Get attachments |
|
|
|