2 * Copyright (C) 2009 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package com.android.camera.gallery;
19 import android.content.ContentResolver;
20 import android.database.Cursor;
21 import android.graphics.Bitmap;
22 import android.net.Uri;
23 import android.provider.DrmStore;
26 * Represents an ordered collection of Image objects from the DRM provider.
28 public class DrmImageList extends ImageList implements IImageList {
30 // TODO: get other field from database too ?
31 private static final String[] DRM_IMAGE_PROJECTION = new String[] {
34 DrmStore.Images.MIME_TYPE,
37 private static final int INDEX_ID = 0;
38 private static final int INDEX_DATA_PATH = 1;
39 private static final int INDEX_MIME_TYPE = 2;
41 public DrmImageList(ContentResolver resolver, Uri imageUri, int sort,
43 super(resolver, imageUri, sort, bucketId);
47 protected String sortOrder() {
48 // We have no date information in DrmStore, so we just sort by _id.
53 protected Cursor createCursor() {
54 return mContentResolver.query(
55 mBaseUri, DRM_IMAGE_PROJECTION, null, null, sortOrder());
58 private static class DrmImage extends Image {
60 protected DrmImage(BaseImageList container, ContentResolver cr,
61 long id, int index, Uri uri, String dataPath,
62 long miniThumbMagic, String mimeType, long dateTaken,
63 String title, int rotation) {
64 super(container, cr, id, index, uri, dataPath,
65 mimeType, dateTaken, title, rotation);
69 public int getDegreesRotated() {
74 public boolean isDrm() {
79 public boolean isReadonly() {
84 public Bitmap miniThumbBitmap() {
85 return fullSizeBitmap(IImage.MINI_THUMB_TARGET_SIZE,
86 IImage.MINI_THUMB_MAX_NUM_PIXELS);
90 public Bitmap thumbBitmap(boolean rotateAsNeeded) {
91 return fullSizeBitmap(IImage.THUMBNAIL_TARGET_SIZE,
92 IImage.THUMBNAIL_MAX_NUM_PIXELS);
97 protected BaseImage loadImageFromCursor(Cursor cursor) {
98 long id = cursor.getLong(INDEX_ID);
99 String dataPath = cursor.getString(INDEX_DATA_PATH);
100 String mimeType = cursor.getString(INDEX_MIME_TYPE);
101 return new DrmImage(this, mContentResolver, id, cursor.getPosition(),
102 contentUri(id), dataPath, 0, mimeType, 0, "DrmImage-" + id,