import android.content.ActivityNotFoundException;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
-import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
}
// Display restrictions
+ Bundle extras = getIntent().getExtras();
Map<DisplayRestrictions, Object> restrictions = new HashMap<DisplayRestrictions, Object>();
//- Mime/Type restriction
String mimeType = getIntent().getType();
mimeType = MimeTypeHelper.ALL_MIME_TYPES;
}
restrictions.put(DisplayRestrictions.MIME_TYPE_RESTRICTION, mimeType);
+ } else {
+ String[] mimeTypes = getIntent().getStringArrayExtra(Intent.EXTRA_MIME_TYPES);
+ if (mimeTypes != null && mimeTypes.length > 0) {
+ restrictions.put(DisplayRestrictions.MIME_TYPE_RESTRICTION, mimeTypes);
+ }
}
// Other restrictions
- Bundle extras = getIntent().getExtras();
Log.d(TAG, "PickerActivity. extras: " + String.valueOf(extras)); //$NON-NLS-1$
if (extras != null) {
//-- File size
*/
CATEGORY_TYPE_RESTRICTION,
/**
- * Restriction for display only files with the mime/type.
+ * Restriction for display only files with these mime/types (this restriction
+ * accepts a String or String[] as parameter).
*/
MIME_TYPE_RESTRICTION,
/**
break;
case MIME_TYPE_RESTRICTION:
+ String[] mimeTypes = null;
if (value instanceof String) {
- String mimeType = (String)value;
- if (mimeType.compareTo(MimeTypeHelper.ALL_MIME_TYPES) != 0) {
+ mimeTypes = new String[] {(String) value};
+ } else if (value instanceof String[]) {
+ mimeTypes = (String[]) value;
+ }
+ if (mimeTypes != null) {
+ boolean matches = false;
+ for (String mimeType : mimeTypes) {
+ if (mimeType.compareTo(MimeTypeHelper.ALL_MIME_TYPES) == 0) {
+ matches = true;
+ break;
+ }
// NOTE: We don't need the context here, because mime-type
// database should be loaded prior to this call
- if (!MimeTypeHelper.matchesMimeType(null, fso, mimeType)) {
- return false;
+ if (MimeTypeHelper.matchesMimeType(null, fso, mimeType)) {
+ matches = true;
+ break;
}
}
+ if (!matches) {
+ return false;
+ }
}
break;