Search in sources :

Example 21 with Path

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;
}
Also used : Path(com.android.gallery3d.data.Path) ArrayList(java.util.ArrayList) Intent(android.content.Intent) DataManager(com.android.gallery3d.data.DataManager) Uri(android.net.Uri)

Example 22 with Path

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;
}
Also used : Path(com.android.gallery3d.data.Path) ArrayList(java.util.ArrayList) DataManager(com.android.gallery3d.data.DataManager) MediaObject(com.android.gallery3d.data.MediaObject)

Example 23 with Path

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;
}
Also used : Path(com.android.gallery3d.data.Path) MediaItem(com.android.gallery3d.data.MediaItem) MediaSet(com.android.gallery3d.data.MediaSet) ArrayList(java.util.ArrayList)

Example 24 with Path

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);
}
Also used : Path(com.android.gallery3d.data.Path) DataManager(com.android.gallery3d.data.DataManager) Intent(android.content.Intent)

Example 25 with Path

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);
}
Also used : Path(com.android.gallery3d.data.Path) Entry(com.android.gallery3d.gadget.WidgetDatabaseHelper.Entry) HashMap(java.util.HashMap) WidgetDatabaseHelper(com.android.gallery3d.gadget.WidgetDatabaseHelper) MediaSet(com.android.gallery3d.data.MediaSet) LocalAlbum(com.android.gallery3d.data.LocalAlbum) DataManager(com.android.gallery3d.data.DataManager) GalleryApp(com.android.gallery3d.app.GalleryApp)

Aggregations

Path (com.android.gallery3d.data.Path)25 MediaSet (com.android.gallery3d.data.MediaSet)9 DataManager (com.android.gallery3d.data.DataManager)8 MediaItem (com.android.gallery3d.data.MediaItem)8 Intent (android.content.Intent)6 Uri (android.net.Uri)6 ArrayList (java.util.ArrayList)4 Bundle (android.os.Bundle)3 MediaObject (com.android.gallery3d.data.MediaObject)3 Activity (android.app.Activity)2 View (android.view.View)2 GalleryApp (com.android.gallery3d.app.GalleryApp)2 ClusterAlbum (com.android.gallery3d.data.ClusterAlbum)2 LocalAlbum (com.android.gallery3d.data.LocalAlbum)2 MenuExecutor (com.android.gallery3d.ui.MenuExecutor)2 Message (android.os.Message)1 BottomNavigationView (android.support.design.widget.BottomNavigationView)1 MenuItem (android.view.MenuItem)1 AdapterView (android.widget.AdapterView)1 ImageView (android.widget.ImageView)1