use of com.android.gallery3d.data.DataManager in project android_packages_apps_Gallery2 by LineageOS.
the class GalleryActivity method startViewAction.
private void startViewAction(Intent intent) {
Boolean slideshow = intent.getBooleanExtra(EXTRA_SLIDESHOW, false);
if (slideshow) {
getActionBar().hide();
DataManager manager = getDataManager();
Path path = manager.findPathByUri(intent.getData(), intent.getType());
if (path == null || manager.getMediaObject(path) instanceof MediaItem) {
path = Path.fromString(manager.getTopSetPath(DataManager.INCLUDE_IMAGE));
}
Bundle data = new Bundle();
data.putString(SlideshowPage.KEY_SET_PATH, path.toString());
data.putBoolean(SlideshowPage.KEY_RANDOM_ORDER, true);
data.putBoolean(SlideshowPage.KEY_REPEAT, true);
if (intent.getBooleanExtra(EXTRA_DREAM, false)) {
data.putBoolean(SlideshowPage.KEY_DREAM, true);
}
getStateManager().startState(SlideshowPage.class, data);
} else {
Bundle data = new Bundle();
DataManager dm = getDataManager();
Uri uri = intent.getData();
String contentType = getContentType(intent);
if (contentType == null) {
Toast.makeText(this, R.string.no_such_item, Toast.LENGTH_LONG).show();
finish();
return;
}
if (uri == null) {
int typeBits = GalleryUtils.determineTypeBits(this, intent);
data.putInt(KEY_TYPE_BITS, typeBits);
data.putString(AlbumSetPage.KEY_MEDIA_PATH, getDataManager().getTopSetPath(typeBits));
getStateManager().startState(AlbumSetPage.class, data);
} else if (contentType.startsWith(ContentResolver.CURSOR_DIR_BASE_TYPE)) {
int mediaType = intent.getIntExtra(KEY_MEDIA_TYPES, 0);
if (mediaType != 0) {
uri = uri.buildUpon().appendQueryParameter(KEY_MEDIA_TYPES, String.valueOf(mediaType)).build();
}
Path setPath = dm.findPathByUri(uri, null);
MediaSet mediaSet = null;
if (setPath != null) {
mediaSet = (MediaSet) dm.getMediaObject(setPath);
}
if (mediaSet != null) {
if (mediaSet.isLeafAlbum()) {
data.putString(AlbumPage.KEY_MEDIA_PATH, setPath.toString());
data.putString(AlbumPage.KEY_PARENT_MEDIA_PATH, dm.getTopSetPath(DataManager.INCLUDE_ALL));
getStateManager().startState(AlbumPage.class, data);
} else {
data.putString(AlbumSetPage.KEY_MEDIA_PATH, setPath.toString());
getStateManager().startState(AlbumSetPage.class, data);
}
} else {
startTimelinePage();
}
} else {
Path itemPath = dm.findPathByUri(uri, contentType);
Path albumPath = dm.getDefaultSetOf(itemPath);
data.putString(PhotoPage.KEY_MEDIA_ITEM_PATH, itemPath.toString());
if (!intent.getBooleanExtra(KEY_FROM_SNAPCAM, false)) {
data.putBoolean(PhotoPage.KEY_READONLY, true);
} else {
int hintIndex = 0;
if (View.LAYOUT_DIRECTION_RTL == TextUtils.getLayoutDirectionFromLocale(Locale.getDefault())) {
hintIndex = intent.getIntExtra(KEY_TOTAL_NUMBER, 1) - 1;
}
data.putInt(PhotoPage.KEY_INDEX_HINT, hintIndex);
}
// TODO: Make the parameter "SingleItemOnly" public so other
// activities can reference it.
boolean singleItemOnly = (albumPath == null) || intent.getBooleanExtra("SingleItemOnly", false);
if (!singleItemOnly) {
data.putString(PhotoPage.KEY_MEDIA_SET_PATH, albumPath.toString());
}
data.putBoolean("SingleItemOnly", singleItemOnly);
// set the cover View to black
View cover = findViewById(R.id.gl_root_cover);
cover.setBackgroundColor(Color.BLACK);
getStateManager().startState(SinglePhotoPage.class, data);
}
}
}
use of com.android.gallery3d.data.DataManager in project android_packages_apps_Gallery2 by LineageOS.
the class AlbumPage method onGetContent.
private void onGetContent(final MediaItem item) {
DataManager dm = mActivity.getDataManager();
Activity activity = mActivity;
if (mData.getString(GalleryActivity.EXTRA_CROP) != null) {
Uri uri = dm.getContentUri(item.getPath());
Intent intent = new Intent(CropActivity.CROP_ACTION, uri).addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT).putExtras(getData());
if (mData.getParcelable(MediaStore.EXTRA_OUTPUT) == null) {
intent.putExtra(CropExtras.KEY_RETURN_DATA, true);
}
activity.startActivity(intent);
activity.finish();
} else {
Intent intent = new Intent(null, item.getContentUri()).addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
activity.setResult(Activity.RESULT_OK, intent);
activity.finish();
}
}
use of com.android.gallery3d.data.DataManager in project android_packages_apps_Gallery2 by LineageOS.
the class TimeLinePage method onGetContent.
private void onGetContent(final MediaItem item) {
DataManager dm = mActivity.getDataManager();
Activity activity = mActivity;
if (mData.getString(GalleryActivity.EXTRA_CROP) != null) {
Uri uri = dm.getContentUri(item.getPath());
Intent intent = new Intent(CropActivity.CROP_ACTION, uri).addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT).putExtras(getData());
if (mData.getParcelable(MediaStore.EXTRA_OUTPUT) == null) {
intent.putExtra(CropExtras.KEY_RETURN_DATA, true);
}
activity.startActivity(intent);
activity.finish();
} else {
Intent intent = new Intent(null, item.getContentUri()).addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
activity.setResult(Activity.RESULT_OK, intent);
activity.finish();
}
}
use of com.android.gallery3d.data.DataManager in project android_packages_apps_Gallery2 by LineageOS.
the class ActionModeHandler method computeSharingIntent.
private Intent computeSharingIntent(JobContext jc, int maxItems) {
ArrayList<Path> expandedPaths = mSelectionManager.getSelected(true, maxItems);
if (expandedPaths == null || expandedPaths.size() == 0) {
setNfcBeamPushUris(null);
return new Intent();
}
final ArrayList<Uri> uris = new ArrayList<Uri>();
DataManager manager = mActivity.getDataManager();
int type = 0;
final Intent intent = new Intent();
for (Path path : expandedPaths) {
if (jc.isCancelled())
return null;
int support = manager.getSupportedOperations(path);
type |= manager.getMediaType(path);
if ((support & MediaObject.SUPPORT_SHARE) != 0) {
Uri uri = manager.getContentUri(path);
if (uri != null) {
uris.add(uri);
}
}
}
final int size = uris.size();
if (size > 0) {
final String mimeType = MenuExecutor.getMimeType(type);
if (size > 1) {
intent.setAction(Intent.ACTION_SEND_MULTIPLE).setType(mimeType);
intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
} else {
intent.setAction(Intent.ACTION_SEND).setType(mimeType);
intent.putExtra(Intent.EXTRA_STREAM, uris.get(0));
}
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
setNfcBeamPushUris(uris.toArray(new Uri[uris.size()]));
} else {
setNfcBeamPushUris(null);
}
return intent;
}
use of com.android.gallery3d.data.DataManager in project android_packages_apps_Gallery2 by LineageOS.
the class WidgetConfigure method setChoosenAlbum.
private void setChoosenAlbum(Intent data) {
String albumPath = data.getStringExtra(AlbumPicker.KEY_ALBUM_PATH);
WidgetDatabaseHelper helper = new WidgetDatabaseHelper(this);
try {
String relativePath = null;
GalleryApp galleryApp = (GalleryApp) getApplicationContext();
DataManager manager = galleryApp.getDataManager();
Path path = Path.fromString(albumPath);
MediaSet mediaSet = (MediaSet) manager.getMediaObject(path);
if (mediaSet instanceof LocalAlbum) {
int bucketId = Integer.parseInt(path.getSuffix());
// If the chosen album is a local album, find relative path
// Otherwise, leave the relative path field empty
relativePath = LocalAlbum.getRelativePath(bucketId);
Log.i(TAG, "Setting widget, album path: " + albumPath + ", relative path: " + relativePath);
}
helper.setWidget(mAppWidgetId, WidgetDatabaseHelper.TYPE_ALBUM, albumPath, relativePath);
updateWidgetAndFinish(helper.getEntry(mAppWidgetId));
} finally {
helper.close();
}
}
Aggregations