}
// This is a hack before we find a solution to pass a permission to other
- // applications. See bug #1735149.
- // Checks if the URI starts with "content://mms".
- public static boolean isMMSUri(Uri uri) {
- return (uri != null) &&
- uri.getScheme().equals("content") &&
- uri.getAuthority().equals("mms");
+ // applications. See bug #1735149, #1836138.
+ // Checks if the URI is on our whitelist:
+ // content://media/... (MediaProvider)
+ // file:///sdcard/... (Browser download)
+ public static boolean isWhiteListUri(Uri uri) {
+ if (uri == null) return false;
+
+ String scheme = uri.getScheme();
+ String authority = uri.getAuthority();
+
+ if (scheme.equals("content") && authority.equals("media")) {
+ return true;
+ }
+
+ if (scheme.equals("file")) {
+ List<String> p = uri.getPathSegments();
+
+ if (p.size() >= 1 && p.get(0).equals("sdcard")) {
+ return true;
+ }
+ }
+
+ return false;
}
public static void enableShareMenuItem(Menu menu, boolean enabled) {
}
Uri uri = mAllImages.getImageAt(mCurrentPosition).fullSizeImageUri();
- MenuHelper.enableShareMenuItem(menu, !MenuHelper.isMMSUri(uri));
+ MenuHelper.enableShareMenuItem(menu, MenuHelper.isWhiteListUri(uri));
return true;
}
break;
case R.id.btn_share: {
IImage image = mAllImages.getImageAt(mCurrentPosition);
- if (MenuHelper.isMMSUri(image.fullSizeImageUri())) {
+ if (!MenuHelper.isWhiteListUri(image.fullSizeImageUri())) {
return;
}
startShareMediaActivity(image);
}
Uri uri = mAllImages.getImageAt(mCurrentPosition).fullSizeImageUri();
- MenuHelper.enableShareMenuItem(menu, !MenuHelper.isMMSUri(uri));
+ MenuHelper.enableShareMenuItem(menu, MenuHelper.isWhiteListUri(uri));
return true;
}
return;
}
- // We don't show action icons for MMS uri because we don't have
- // delete and share action icons for MMS. It is obvious that we don't
- // need the "delete" action, but for the share part, although we get
- // read permission (for the image) from the MMS application, we cannot
- // pass the permission to other activities due to the current framework
- // design.
- if (MenuHelper.isMMSUri(uri)) {
+ // We only show action icons for URIs that we know we can share and
+ // delete. Although we get read permission (for the images) from
+ // applications like MMS, we cannot pass the permission to other
+ // activities due to the current framework design.
+ if (!MenuHelper.isWhiteListUri(uri)) {
mShowActionIcons = false;
}
break;
case R.id.share: {
IImage image = mAllImages.getImageAt(mCurrentPosition);
- if (MenuHelper.isMMSUri(image.fullSizeImageUri())) {
+ if (!MenuHelper.isWhiteListUri(image.fullSizeImageUri())) {
return;
}
startShareMediaActivity(image);