mirror of
https://github.com/moparisthebest/k-9
synced 2025-01-30 14:50:14 -05:00
Add support for KitKat's Storage Access Framework
This allows users on KitKat to add multiple attachments at once.
This commit is contained in:
parent
aec1a38578
commit
d419fab789
@ -5,6 +5,7 @@ import android.annotation.TargetApi;
|
|||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.AlertDialog.Builder;
|
import android.app.AlertDialog.Builder;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
|
import android.content.ClipData;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@ -1986,6 +1987,7 @@ public class MessageCompose extends K9Activity implements OnClickListener,
|
|||||||
Toast.makeText(this, R.string.attachment_encryption_unsupported, Toast.LENGTH_LONG).show();
|
Toast.makeText(this, R.string.attachment_encryption_unsupported, Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
Intent i = new Intent(Intent.ACTION_GET_CONTENT);
|
Intent i = new Intent(Intent.ACTION_GET_CONTENT);
|
||||||
|
i.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
|
||||||
i.addCategory(Intent.CATEGORY_OPENABLE);
|
i.addCategory(Intent.CATEGORY_OPENABLE);
|
||||||
i.setType(mime_type);
|
i.setType(mime_type);
|
||||||
mIgnoreOnPause = true;
|
mIgnoreOnPause = true;
|
||||||
@ -2178,7 +2180,7 @@ public class MessageCompose extends K9Activity implements OnClickListener,
|
|||||||
}
|
}
|
||||||
switch (requestCode) {
|
switch (requestCode) {
|
||||||
case ACTIVITY_REQUEST_PICK_ATTACHMENT:
|
case ACTIVITY_REQUEST_PICK_ATTACHMENT:
|
||||||
addAttachment(data.getData());
|
addAttachmentsFromResultIntent(data);
|
||||||
mDraftNeedsSaving = true;
|
mDraftNeedsSaving = true;
|
||||||
break;
|
break;
|
||||||
case CONTACT_PICKER_TO:
|
case CONTACT_PICKER_TO:
|
||||||
@ -2239,6 +2241,27 @@ public class MessageCompose extends K9Activity implements OnClickListener,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
|
||||||
|
private void addAttachmentsFromResultIntent(Intent data) {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||||
|
ClipData clipData = data.getClipData();
|
||||||
|
if (clipData != null) {
|
||||||
|
for (int i = 0, end = clipData.getItemCount(); i < end; i++) {
|
||||||
|
Uri uri = clipData.getItemAt(i).getUri();
|
||||||
|
if (uri != null) {
|
||||||
|
addAttachment(uri);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Uri uri = data.getData();
|
||||||
|
if (uri != null) {
|
||||||
|
addAttachment(uri);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void doLaunchContactPicker(int resultId) {
|
public void doLaunchContactPicker(int resultId) {
|
||||||
mIgnoreOnPause = true;
|
mIgnoreOnPause = true;
|
||||||
startActivityForResult(mContacts.contactPickerIntent(), resultId);
|
startActivityForResult(mContacts.contactPickerIntent(), resultId);
|
||||||
|
Loading…
Reference in New Issue
Block a user