use of com.android.gallery3d.data.Path in project android_packages_apps_Gallery2 by LineageOS.
the class ActionModeHandler method computePanoramaSharingIntent.
// Share intent needs to expand the selection set so we can get URI of
// each media item
private Intent computePanoramaSharingIntent(JobContext jc, int maxItems) {
ArrayList<Path> expandedPaths = mSelectionManager.getSelected(true, maxItems);
if (expandedPaths == null || expandedPaths.size() == 0) {
return new Intent();
}
final ArrayList<Uri> uris = new ArrayList<Uri>();
DataManager manager = mActivity.getDataManager();
final Intent intent = new Intent();
for (Path path : expandedPaths) {
if (jc.isCancelled())
return null;
Uri uri = manager.getContentUri(path);
if (uri != null) {
uris.add(uri);
}
}
final int size = uris.size();
if (size > 0) {
if (size > 1) {
intent.setAction(Intent.ACTION_SEND_MULTIPLE);
intent.setType(GalleryUtils.MIME_TYPE_PANORAMA360);
intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
} else {
intent.setAction(Intent.ACTION_SEND);
intent.setType(GalleryUtils.MIME_TYPE_PANORAMA360);
intent.putExtra(Intent.EXTRA_STREAM, uris.get(0));
}
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
}
return intent;
}
use of com.android.gallery3d.data.Path in project android_packages_apps_Gallery2 by LineageOS.
the class ActionModeHandler method getSelectedMediaObjects.
private ArrayList<MediaObject> getSelectedMediaObjects(JobContext jc) {
ArrayList<Path> unexpandedPaths = mSelectionManager.getSelected(false);
if (unexpandedPaths.isEmpty()) {
// (instead of long press a media object)
return null;
}
ArrayList<MediaObject> selected = new ArrayList<MediaObject>();
DataManager manager = mActivity.getDataManager();
for (Path path : unexpandedPaths) {
if (jc.isCancelled() || !mSelectionManager.inSelectionMode()) {
return null;
}
MediaObject mediaObject = manager.getMediaObject(path);
if (mediaObject != null && mediaObject.isSelectable()) {
selected.add(mediaObject);
}
}
return selected;
}
use of com.android.gallery3d.data.Path in project android_packages_apps_Gallery2 by LineageOS.
the class SelectionManager method getSelected.
public ArrayList<Path> getSelected(boolean expandSet, int maxSelection) {
ArrayList<Path> selected = new ArrayList<Path>();
if (mIsAlbumSet) {
if (mInverseSelection) {
int total = getTotalCount();
for (int i = 0; i < total; i++) {
MediaSet set = mSourceMediaSet.getSubMediaSet(i);
Path id = set.getPath();
if (!mClickedSet.contains(id)) {
if (expandSet) {
if (!expandMediaSet(selected, set, maxSelection)) {
return null;
}
} else {
addPathIfSelectable(selected, id);
if (selected.size() > maxSelection) {
return null;
}
}
}
}
} else {
for (Path id : mClickedSet) {
if (expandSet) {
if (!expandMediaSet(selected, mDataManager.getMediaSet(id), maxSelection)) {
return null;
}
} else {
addPathIfSelectable(selected, id);
if (selected.size() > maxSelection) {
return null;
}
}
}
}
} else {
if (mInverseSelection) {
int total = getTotalCount();
int index = 0;
while (index < total) {
int count = Math.min(total - index, MediaSet.MEDIAITEM_BATCH_FETCH_COUNT);
ArrayList<MediaItem> list = mSourceMediaSet.getMediaItem(index, count);
for (MediaItem item : list) {
Path id = item.getPath();
if (!mClickedSet.contains(id)) {
addPathIfSelectable(selected, id);
if (selected.size() > maxSelection) {
return null;
}
}
}
index += count;
}
} else {
for (Path id : mClickedSet) {
addPathIfSelectable(selected, id);
if (selected.size() > maxSelection) {
return null;
}
}
}
}
return selected;
}
use of com.android.gallery3d.data.Path in project android_packages_apps_Gallery2 by LineageOS.
the class MenuExecutor method getIntentBySingleSelectedPath.
private Intent getIntentBySingleSelectedPath(String action) {
DataManager manager = mActivity.getDataManager();
Path path = getSingleSelectedPath();
if (path == null)
return null;
String mimeType = getMimeType(manager.getMediaType(path));
return new Intent(action).setDataAndType(manager.getContentUri(path), mimeType);
}
use of com.android.gallery3d.data.Path in project android_packages_apps_Gallery2 by LineageOS.
the class GalleryWidgetMigrator method migrateGalleryWidgetsInternal.
private static void migrateGalleryWidgetsInternal(Context context) {
GalleryApp galleryApp = (GalleryApp) context.getApplicationContext();
DataManager manager = galleryApp.getDataManager();
WidgetDatabaseHelper dbHelper = new WidgetDatabaseHelper(context);
// only need to migrate local-album entries of type TYPE_ALBUM
List<Entry> entries = dbHelper.getEntries(WidgetDatabaseHelper.TYPE_ALBUM);
if (entries == null)
return;
// Check each entry's relativePath. If exists, update bucket id using relative
// path combined with external storage path. Otherwise, iterate through old external
// storage paths to find the relative path that matches the old bucket id, and then update
// bucket id and relative path
HashMap<Integer, Entry> localEntries = new HashMap<Integer, Entry>(entries.size());
for (Entry entry : entries) {
Path path = Path.fromString(entry.albumPath);
MediaSet mediaSet = (MediaSet) manager.getMediaObject(path);
if (mediaSet instanceof LocalAlbum) {
if (entry.relativePath != null && entry.relativePath.length() > 0) {
// update entry using relative path + external storage path
updateEntryUsingRelativePath(entry, dbHelper);
} else {
int bucketId = Integer.parseInt(path.getSuffix());
localEntries.put(bucketId, entry);
}
}
}
if (!localEntries.isEmpty())
migrateLocalEntries(context, localEntries, dbHelper);
}
Aggregations