mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-23 22:51:02 +00:00
Prevent crash when storage access framework not installed
This commit is contained in:
parent
d7c4064f0b
commit
d3fc9aadcc
1 changed files with 20 additions and 8 deletions
|
@ -422,6 +422,10 @@ public class FragmentCompose extends FragmentEx {
|
|||
menu.findItem(R.id.menu_attachment).setVisible(!free && working >= 0);
|
||||
menu.findItem(R.id.menu_attachment).setEnabled(etBody.isEnabled());
|
||||
menu.findItem(R.id.menu_addresses).setVisible(!free && working >= 0);
|
||||
|
||||
PackageManager pm = getContext().getPackageManager();
|
||||
menu.findItem(R.id.menu_image).setEnabled(getImageIntent().resolveActivity(pm) != null);
|
||||
menu.findItem(R.id.menu_attachment).setEnabled(getAttachmentIntent().resolveActivity(pm) != null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -488,17 +492,11 @@ public class FragmentCompose extends FragmentEx {
|
|||
}
|
||||
|
||||
private void onMenuImage() {
|
||||
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
|
||||
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||
intent.setType("image/*");
|
||||
startActivityForResult(intent, ActivityCompose.REQUEST_IMAGE);
|
||||
startActivityForResult(getImageIntent(), ActivityCompose.REQUEST_IMAGE);
|
||||
}
|
||||
|
||||
private void onMenuAttachment() {
|
||||
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
|
||||
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||
intent.setType("*/*");
|
||||
startActivityForResult(intent, ActivityCompose.REQUEST_ATTACHMENT);
|
||||
startActivityForResult(getAttachmentIntent(), ActivityCompose.REQUEST_ATTACHMENT);
|
||||
}
|
||||
|
||||
private void onMenuAddresses() {
|
||||
|
@ -522,6 +520,20 @@ public class FragmentCompose extends FragmentEx {
|
|||
}
|
||||
}
|
||||
|
||||
private Intent getImageIntent() {
|
||||
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
|
||||
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||
intent.setType("image/*");
|
||||
return intent;
|
||||
}
|
||||
|
||||
private Intent getAttachmentIntent() {
|
||||
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
|
||||
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||
intent.setType("*/*");
|
||||
return intent;
|
||||
}
|
||||
|
||||
private void handleExit() {
|
||||
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
|
||||
new DialogBuilderLifecycle(getContext(), getViewLifecycleOwner())
|
||||
|
|
Loading…
Reference in a new issue