Search in sources :

Example 6 with DataManager

use of com.android.gallery3d.data.DataManager in project android_packages_apps_Gallery2 by LineageOS.

the class PhotoPage method onItemSelected.

@Override
protected boolean onItemSelected(MenuItem item) {
    if (mModel == null)
        return true;
    refreshHidingMessage();
    MediaItem current = mModel.getMediaItem(0);
    // menu when transitioning from filmstrip to camera
    if (current instanceof SnailItem)
        return true;
    // after PhotoPage being refactored.
    if (current == null) {
        // item is not ready, ignore
        return true;
    }
    int currentIndex = mModel.getCurrentIndex();
    // If RTL, the current index need be revised.
    if (View.LAYOUT_DIRECTION_RTL == TextUtils.getLayoutDirectionFromLocale(Locale.getDefault())) {
        currentIndex = mMediaSet.getMediaItemCount() - currentIndex - 1;
    }
    Path path = current.getPath();
    DataManager manager = mActivity.getDataManager();
    int action = item.getItemId();
    String confirmMsg = null;
    switch(action) {
        case android.R.id.home:
            {
                onUpPressed();
                return true;
            }
        case R.id.action_slideshow:
            {
                Bundle data = new Bundle();
                data.putString(SlideshowPage.KEY_SET_PATH, mMediaSet.getPath().toString());
                data.putString(SlideshowPage.KEY_ITEM_PATH, path.toString());
                data.putInt(SlideshowPage.KEY_PHOTO_INDEX, currentIndex);
                data.putBoolean(SlideshowPage.KEY_REPEAT, true);
                mActivity.getStateManager().startStateForResult(SlideshowPage.class, REQUEST_SLIDESHOW, data);
                return true;
            }
        /*case R.id.action_crop: {
                Activity activity = mActivity;
                Intent intent = new Intent(CropActivity.CROP_ACTION);
                intent.setClass(activity, CropActivity.class);
                intent.setDataAndType(manager.getContentUri(path), current.getMimeType())
                    .setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
                activity.startActivityForResult(intent, PicasaSource.isPicasaImage(current)
                        ? REQUEST_CROP_PICASA
                        : REQUEST_CROP);
                return true;
            }*/
        case R.id.action_trim:
            {
                Intent intent = new Intent(mActivity, TrimVideo.class);
                intent.setData(manager.getContentUri(path));
                // We need the file path to wrap this into a RandomAccessFile.
                String str = current.getMimeType();
                if ("video/mp4".equals(str) || "video/mpeg4".equals(str) || "video/3gpp".equals(str) || "video/3gpp2".equals(str)) {
                    intent.putExtra(KEY_MEDIA_ITEM_PATH, current.getFilePath());
                    mActivity.startActivityForResult(intent, REQUEST_TRIM);
                } else {
                    Toast.makeText(mActivity, mActivity.getString(R.string.can_not_trim), Toast.LENGTH_SHORT).show();
                }
                return true;
            }
        case R.id.action_mute:
            {
                MuteVideo muteVideo = new MuteVideo(current.getFilePath(), manager.getContentUri(path), mActivity);
                muteVideo.muteInBackground();
                return true;
            }
        case R.id.action_edit:
            {
                launchPhotoEditor();
                return true;
            }
        /*case R.id.action_simple_edit: {
                launchSimpleEditor();
                return true;
            }*/
        case R.id.action_details:
            {
                if (mShowDetails) {
                    hideDetails();
                } else {
                    showDetails();
                }
                return true;
            }
        case R.id.print:
            {
                try {
                    mActivity.printSelectedImage(manager.getContentUri(path));
                } catch (SecurityException e) {
                    e.printStackTrace();
                    mActivity.finish();
                }
                return true;
            }
        case R.id.action_delete:
            confirmMsg = mActivity.getResources().getQuantityString(R.plurals.delete_selection, 1);
        case R.id.action_setas:
        // case R.id.action_rotate_cw:
        case R.id.action_show_on_map:
            mSelectionManager.deSelectAll();
            mSelectionManager.toggle(path);
            mMenuExecutor.onMenuClicked(item, confirmMsg, mConfirmDialogListener);
            return true;
        // return true;
        default:
            return false;
    }
}
Also used : Path(com.android.gallery3d.data.Path) SnailItem(com.android.gallery3d.data.SnailItem) MediaItem(com.android.gallery3d.data.MediaItem) Bundle(android.os.Bundle) DataManager(com.android.gallery3d.data.DataManager) Intent(android.content.Intent)

Example 7 with DataManager

use of com.android.gallery3d.data.DataManager in project android_packages_apps_Gallery2 by LineageOS.

the class GalleryAppImpl method getDataManager.

@Override
public synchronized DataManager getDataManager() {
    if (mDataManager == null) {
        mDataManager = new DataManager(this);
        mDataManager.initializeSourceMap();
    }
    return mDataManager;
}
Also used : DataManager(com.android.gallery3d.data.DataManager)

Example 8 with DataManager

use of com.android.gallery3d.data.DataManager 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 9 with DataManager

use of com.android.gallery3d.data.DataManager 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 10 with DataManager

use of com.android.gallery3d.data.DataManager 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)

Aggregations

DataManager (com.android.gallery3d.data.DataManager)11 Path (com.android.gallery3d.data.Path)8 Intent (android.content.Intent)6 Uri (android.net.Uri)5 MediaSet (com.android.gallery3d.data.MediaSet)3 ArrayList (java.util.ArrayList)3 Activity (android.app.Activity)2 Bundle (android.os.Bundle)2 GalleryApp (com.android.gallery3d.app.GalleryApp)2 LocalAlbum (com.android.gallery3d.data.LocalAlbum)2 MediaItem (com.android.gallery3d.data.MediaItem)2 CropActivity (com.android.gallery3d.filtershow.crop.CropActivity)2 BottomNavigationView (android.support.design.widget.BottomNavigationView)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 ImageView (android.widget.ImageView)1 ListView (android.widget.ListView)1 TextView (android.widget.TextView)1 MediaObject (com.android.gallery3d.data.MediaObject)1 SnailItem (com.android.gallery3d.data.SnailItem)1