mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-23 18:02:15 -05:00
Extract intent creation code to method
This commit is contained in:
parent
6cb3c991db
commit
11a9eff109
@ -240,11 +240,7 @@ public class AttachmentView extends FrameLayout implements OnClickListener, OnLo
|
|||||||
|
|
||||||
public void showFile() {
|
public void showFile() {
|
||||||
Uri uri = AttachmentProvider.getAttachmentUriForViewing(account, part.getAttachmentId());
|
Uri uri = AttachmentProvider.getAttachmentUriForViewing(account, part.getAttachmentId());
|
||||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
Intent intent = createViewIntentForContentUri(contentType, uri);
|
||||||
// We explicitly set the content type in addition to the URI because some attachment viewers
|
|
||||||
// (such as Polaris office 3.0.x) choke on documents without a MIME type.
|
|
||||||
intent.setDataAndType(uri, contentType);
|
|
||||||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
@ -256,6 +252,14 @@ public class AttachmentView extends FrameLayout implements OnClickListener, OnLo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Intent createViewIntentForContentUri(String mimeType, Uri uri) {
|
||||||
|
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||||
|
intent.setDataAndType(uri, mimeType);
|
||||||
|
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
|
||||||
|
|
||||||
|
return intent;
|
||||||
|
}
|
||||||
|
|
||||||
private void displayAttachmentSavedMessage(final String filename) {
|
private void displayAttachmentSavedMessage(final String filename) {
|
||||||
String message = context.getString(R.string.message_view_status_attachment_saved, filename);
|
String message = context.getString(R.string.message_view_status_attachment_saved, filename);
|
||||||
displayMessageToUser(message);
|
displayMessageToUser(message);
|
||||||
|
Loading…
Reference in New Issue
Block a user