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;
}
}
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;
}
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;
}
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;
}
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);
}
Aggregations