Search in sources :

Example 1 with DataManager

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);
        }
    }
}
Also used : Path(com.android.gallery3d.data.Path) Bundle(android.os.Bundle) DataManager(com.android.gallery3d.data.DataManager) Uri(android.net.Uri) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) BottomNavigationView(android.support.design.widget.BottomNavigationView) TextView(android.widget.TextView) ListView(android.widget.ListView) MediaItem(com.android.gallery3d.data.MediaItem) MediaSet(com.android.gallery3d.data.MediaSet)

Example 2 with DataManager

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();
    }
}
Also used : CropActivity(com.android.gallery3d.filtershow.crop.CropActivity) Activity(android.app.Activity) DataManager(com.android.gallery3d.data.DataManager) Intent(android.content.Intent) Uri(android.net.Uri)

Example 3 with DataManager

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();
    }
}
Also used : CropActivity(com.android.gallery3d.filtershow.crop.CropActivity) Activity(android.app.Activity) DataManager(com.android.gallery3d.data.DataManager) Intent(android.content.Intent) Uri(android.net.Uri)

Example 4 with DataManager

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;
}
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 5 with DataManager

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

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