use of com.android.gallery3d.data.MediaObject in project android_packages_apps_Gallery2 by LineageOS.
the class GalleryProvider method openFile.
@Override
public ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException {
long token = Binder.clearCallingIdentity();
try {
if (mode.contains("w")) {
throw new FileNotFoundException("cannot open file for write");
}
Path path = Path.fromString(uri.getPath());
MediaObject object = mDataManager.getMediaObject(path);
if (object == null) {
throw new FileNotFoundException(uri.toString());
}
if (PicasaSource.isPicasaImage(object)) {
return PicasaSource.openFile(getContext(), object, mode);
} else {
throw new FileNotFoundException("unspported type: " + object);
}
} finally {
Binder.restoreCallingIdentity(token);
}
}
use of com.android.gallery3d.data.MediaObject in project android_packages_apps_Gallery2 by LineageOS.
the class GalleryProvider method queryPicasaItem.
private Cursor queryPicasaItem(MediaObject image, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
if (projection == null)
projection = SUPPORTED_PICASA_COLUMNS;
Object[] columnValues = new Object[projection.length];
double latitude = PicasaSource.getLatitude(image);
double longitude = PicasaSource.getLongitude(image);
boolean isValidLatlong = GalleryUtils.isValidLocation(latitude, longitude);
for (int i = 0, n = projection.length; i < n; ++i) {
String column = projection[i];
if (PicasaColumns.USER_ACCOUNT.equals(column)) {
columnValues[i] = PicasaSource.getUserAccount(getContext(), image);
} else if (PicasaColumns.PICASA_ID.equals(column)) {
columnValues[i] = PicasaSource.getPicasaId(image);
} else if (ImageColumns.DISPLAY_NAME.equals(column)) {
columnValues[i] = PicasaSource.getImageTitle(image);
} else if (ImageColumns.SIZE.equals(column)) {
columnValues[i] = PicasaSource.getImageSize(image);
} else if (ImageColumns.MIME_TYPE.equals(column)) {
columnValues[i] = PicasaSource.getContentType(image);
} else if (ImageColumns.DATE_TAKEN.equals(column)) {
columnValues[i] = PicasaSource.getDateTaken(image);
} else if (ImageColumns.LATITUDE.equals(column)) {
columnValues[i] = isValidLatlong ? latitude : null;
} else if (ImageColumns.LONGITUDE.equals(column)) {
columnValues[i] = isValidLatlong ? longitude : null;
} else if (ImageColumns.ORIENTATION.equals(column)) {
columnValues[i] = PicasaSource.getRotation(image);
} else {
Log.w(TAG, "unsupported column: " + column);
}
}
MatrixCursor cursor = new MatrixCursor(projection);
cursor.addRow(columnValues);
return cursor;
}
use of com.android.gallery3d.data.MediaObject in project android_packages_apps_Gallery2 by LineageOS.
the class ActionModeHandler method computeCanShare.
private boolean computeCanShare(ArrayList<MediaObject> selected, int max) {
int numSelected = selected.size();
boolean ret = computeCanShare(numSelected, max);
if (!ret)
return false;
numSelected = 0;
for (MediaObject mediaObject : selected) {
if (mediaObject instanceof MediaSet) {
numSelected = numSelected + ((MediaSet) mediaObject).getTotalMediaItemCount();
} else {
numSelected = numSelected + 1;
}
ret = computeCanShare(numSelected, max);
if (!ret)
return false;
}
return true;
}
use of com.android.gallery3d.data.MediaObject in project android_packages_apps_Gallery2 by LineageOS.
the class ActionModeHandler method computeMenuOptions.
// Menu options are determined by selection set itself.
// We cannot expand it because MenuExecuter executes it based on
// the selection set instead of the expanded result.
// e.g. LocalImage can be rotated but collections of them (LocalAlbum) can't.
private int computeMenuOptions(ArrayList<MediaObject> selected) {
int operation = MediaObject.SUPPORT_ALL;
int type = 0;
for (MediaObject mediaObject : selected) {
int support = mediaObject.getSupportedOperations();
type |= mediaObject.getMediaType();
operation &= support;
}
switch(selected.size()) {
case 1:
final String mimeType = MenuExecutor.getMimeType(type);
if (!GalleryUtils.isEditorAvailable(mActivity, mimeType)) {
operation &= ~MediaObject.SUPPORT_EDIT;
}
break;
default:
operation = computeMenuOptionsMultiple(operation, selected.size());
}
return operation;
}
use of com.android.gallery3d.data.MediaObject in project android_packages_apps_Gallery2 by LineageOS.
the class GalleryProvider method query.
// TODO: consider concurrent access
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
long token = Binder.clearCallingIdentity();
try {
Path path = Path.fromString(uri.getPath());
MediaObject object = mDataManager.getMediaObject(path);
if (object == null) {
Log.w(TAG, "cannot find: " + uri);
return null;
}
if (PicasaSource.isPicasaImage(object)) {
return queryPicasaItem(object, projection, selection, selectionArgs, sortOrder);
} else {
return null;
}
} finally {
Binder.restoreCallingIdentity(token);
}
}
Aggregations