summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/gallery3d/ui')
-rw-r--r--src/com/android/gallery3d/ui/AbstractSlotRenderer.java16
-rw-r--r--src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java14
-rw-r--r--src/com/android/gallery3d/ui/AlbumSetSlotRenderer.java5
-rw-r--r--src/com/android/gallery3d/ui/AlbumSlidingWindow.java13
-rw-r--r--src/com/android/gallery3d/ui/AlbumSlotRenderer.java3
-rw-r--r--src/com/android/gallery3d/ui/MenuExecutor.java36
6 files changed, 85 insertions, 2 deletions
diff --git a/src/com/android/gallery3d/ui/AbstractSlotRenderer.java b/src/com/android/gallery3d/ui/AbstractSlotRenderer.java
index 729439dc3..63bcbea5d 100644
--- a/src/com/android/gallery3d/ui/AbstractSlotRenderer.java
+++ b/src/com/android/gallery3d/ui/AbstractSlotRenderer.java
@@ -20,6 +20,7 @@ import android.content.Context;
import android.graphics.Rect;
import com.android.gallery3d.R;
+import com.android.gallery3d.data.MediaObject;
import com.android.gallery3d.glrenderer.FadeOutTexture;
import com.android.gallery3d.glrenderer.GLCanvas;
import com.android.gallery3d.glrenderer.NinePatchTexture;
@@ -33,6 +34,7 @@ public abstract class AbstractSlotRenderer implements SlotView.SlotRenderer {
private final ResourceTexture mPanoramaIcon;
private final NinePatchTexture mFramePressed;
private final NinePatchTexture mFrameSelected;
+ private final ResourceTexture mDrmIcon;
private FadeOutTexture mFramePressedUp;
protected AbstractSlotRenderer(Context context) {
@@ -41,6 +43,7 @@ public abstract class AbstractSlotRenderer implements SlotView.SlotRenderer {
mPanoramaIcon = new ResourceTexture(context, R.drawable.ic_360pano_holo_light);
mFramePressed = new NinePatchTexture(context, R.drawable.grid_pressed);
mFrameSelected = new NinePatchTexture(context, R.drawable.grid_selected);
+ mDrmIcon = new ResourceTexture(context, R.drawable.drm_image);
}
protected void drawContent(GLCanvas canvas,
@@ -79,6 +82,19 @@ public abstract class AbstractSlotRenderer implements SlotView.SlotRenderer {
mVideoPlayIcon.draw(canvas, (width - s) / 2, (height - s) / 2, s, s);
}
+ protected void drawDrmOverlay(GLCanvas canvas, int width, int height, int Drm_mediaType) {
+ // Scale the video overlay to the height of the thumbnail and put it on the left side.
+ if (Drm_mediaType == MediaObject.MEDIA_TYPE_DRM_VIDEO) {
+ ResourceTexture v = mVideoOverlay;
+ float scale = (float) height / v.getHeight();
+ int w = Math.round(scale * v.getWidth());
+ int h = Math.round(scale * v.getHeight());
+ v.draw(canvas, 0, 0, w, h);
+ }
+ int side = Math.min(width, height) / 6;
+ mDrmIcon.draw(canvas, (width - side) / 2, (height - side) / 2, side, side);
+ }
+
protected void drawPanoramaIcon(GLCanvas canvas, int width, int height) {
int iconSize = Math.min(width, height) / 6;
mPanoramaIcon.draw(canvas, (width - iconSize) / 2, (height - iconSize) / 2,
diff --git a/src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java b/src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java
index 8149df4b3..641115138 100644
--- a/src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java
+++ b/src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java
@@ -24,6 +24,7 @@ import com.android.gallery3d.app.AbstractGalleryActivity;
import com.android.gallery3d.app.AlbumSetDataLoader;
import com.android.gallery3d.common.Utils;
import com.android.gallery3d.data.DataSourceType;
+import com.android.gallery3d.data.LocalMediaItem;
import com.android.gallery3d.data.MediaItem;
import com.android.gallery3d.data.MediaObject;
import com.android.gallery3d.data.MediaSet;
@@ -80,6 +81,7 @@ public class AlbumSetSlidingWindow implements AlbumSetDataLoader.DataListener {
public Path setPath;
public String title;
public int totalCount;
+ public int mediaType;
public int sourceType;
public int cacheFlag;
public int cacheStatus;
@@ -275,6 +277,18 @@ public class AlbumSetSlidingWindow implements AlbumSetDataLoader.DataListener {
if (getDataVersion(cover) != entry.coverDataVersion) {
entry.coverDataVersion = getDataVersion(cover);
entry.rotation = (cover == null) ? 0 : cover.getRotation();
+
+ if (cover instanceof LocalMediaItem) {
+ String filePath = ((LocalMediaItem) cover).filePath;
+ if (filePath != null && (filePath.endsWith(".dcf") || filePath.endsWith(".dm"))) {
+ if (entry.mediaType == MediaObject.MEDIA_TYPE_IMAGE) {
+ entry.mediaType = MediaObject.MEDIA_TYPE_DRM_IMAGE;
+ } else if (entry.mediaType == MediaObject.MEDIA_TYPE_VIDEO) {
+ entry.mediaType = MediaObject.MEDIA_TYPE_DRM_VIDEO;
+ }
+ }
+ }
+
if (entry.coverLoader != null) {
entry.coverLoader.recycle();
entry.coverLoader = null;
diff --git a/src/com/android/gallery3d/ui/AlbumSetSlotRenderer.java b/src/com/android/gallery3d/ui/AlbumSetSlotRenderer.java
index 5332ef89a..37f9b4339 100644
--- a/src/com/android/gallery3d/ui/AlbumSetSlotRenderer.java
+++ b/src/com/android/gallery3d/ui/AlbumSetSlotRenderer.java
@@ -183,7 +183,10 @@ public class AlbumSetSlotRenderer extends AbstractSlotRenderer {
((FadeInTexture) content).isAnimating()) {
renderRequestFlags |= SlotView.RENDER_MORE_FRAME;
}
-
+ if ((entry.mediaType == MediaObject.MEDIA_TYPE_DRM_VIDEO)
+ || (entry.mediaType == MediaObject.MEDIA_TYPE_DRM_IMAGE)) {
+ drawDrmOverlay(canvas, width, height, entry.mediaType);
+ }
return renderRequestFlags;
}
diff --git a/src/com/android/gallery3d/ui/AlbumSlidingWindow.java b/src/com/android/gallery3d/ui/AlbumSlidingWindow.java
index fec7d1e92..a534c6add 100644
--- a/src/com/android/gallery3d/ui/AlbumSlidingWindow.java
+++ b/src/com/android/gallery3d/ui/AlbumSlidingWindow.java
@@ -24,6 +24,7 @@ import com.android.gallery3d.app.AlbumDataLoader;
import com.android.gallery3d.common.Utils;
import com.android.gallery3d.data.MediaItem;
import com.android.gallery3d.data.MediaObject;
+import com.android.gallery3d.data.LocalMediaItem;
import com.android.gallery3d.data.MediaObject.PanoramaSupportCallback;
import com.android.gallery3d.data.Path;
import com.android.gallery3d.glrenderer.Texture;
@@ -267,6 +268,18 @@ public class AlbumSlidingWindow implements AlbumDataLoader.DataListener {
entry.mediaType = (item == null)
? MediaItem.MEDIA_TYPE_UNKNOWN
: entry.item.getMediaType();
+
+ if (item instanceof LocalMediaItem) {
+ String filePath = ((LocalMediaItem)item).filePath;
+ if (filePath != null && (filePath.endsWith(".dcf") || filePath.endsWith(".dm"))) {
+ if (entry.mediaType == MediaObject.MEDIA_TYPE_IMAGE) {
+ entry.mediaType = MediaObject.MEDIA_TYPE_DRM_IMAGE;
+ } else if (entry.mediaType == MediaObject.MEDIA_TYPE_VIDEO) {
+ entry.mediaType = MediaObject.MEDIA_TYPE_DRM_VIDEO;
+ }
+ }
+ }
+
entry.path = (item == null) ? null : item.getPath();
entry.rotation = (item == null) ? 0 : item.getRotation();
entry.contentLoader = new ThumbnailLoader(slotIndex, entry.item);
diff --git a/src/com/android/gallery3d/ui/AlbumSlotRenderer.java b/src/com/android/gallery3d/ui/AlbumSlotRenderer.java
index dc6c89b0e..7f97693e3 100644
--- a/src/com/android/gallery3d/ui/AlbumSlotRenderer.java
+++ b/src/com/android/gallery3d/ui/AlbumSlotRenderer.java
@@ -125,6 +125,9 @@ public class AlbumSlotRenderer extends AbstractSlotRenderer {
if (entry.mediaType == MediaObject.MEDIA_TYPE_VIDEO) {
drawVideoOverlay(canvas, width, height);
+ } else if ((entry.mediaType == MediaObject.MEDIA_TYPE_DRM_VIDEO)
+ || (entry.mediaType == MediaObject.MEDIA_TYPE_DRM_IMAGE)) {
+ drawDrmOverlay(canvas, width, height, entry.mediaType);
}
if (entry.isPanorama) {
diff --git a/src/com/android/gallery3d/ui/MenuExecutor.java b/src/com/android/gallery3d/ui/MenuExecutor.java
index 1ace71829..00a1459b0 100644
--- a/src/com/android/gallery3d/ui/MenuExecutor.java
+++ b/src/com/android/gallery3d/ui/MenuExecutor.java
@@ -24,8 +24,11 @@ import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
+import android.database.Cursor;
+import android.net.Uri;
import android.os.Handler;
import android.os.Message;
+import android.provider.MediaStore.Video.VideoColumns;
import android.support.v4.print.PrintHelper;
import android.view.Menu;
import android.view.MenuItem;
@@ -179,7 +182,7 @@ public class MenuExecutor {
boolean supportInfo = (supported & MediaObject.SUPPORT_INFO) != 0;
boolean supportPrint = (supported & MediaObject.SUPPORT_PRINT) != 0;
supportPrint &= PrintHelper.systemSupportsPrint();
-
+ boolean supportDrmInfo = (supported & MediaObject.SUPPORT_DRM_INFO) != 0;
setMenuItemVisible(menu, R.id.action_delete, supportDelete);
setMenuItemVisible(menu, R.id.action_rotate_ccw, supportRotate);
setMenuItemVisible(menu, R.id.action_rotate_cw, supportRotate);
@@ -195,6 +198,7 @@ public class MenuExecutor {
// setMenuItemVisible(menu, R.id.action_simple_edit, supportEdit);
setMenuItemVisible(menu, R.id.action_details, supportInfo);
setMenuItemVisible(menu, R.id.print, supportPrint);
+ setMenuItemVisible(menu, R.id.action_drm_info, supportDrmInfo);
}
public static void updateMenuForPanorama(Menu menu, boolean shareAsPanorama360,
@@ -271,6 +275,36 @@ public class MenuExecutor {
case R.id.action_show_on_map:
title = R.string.show_on_map;
break;
+ case R.id.action_drm_info:
+ DataManager manager = mActivity.getDataManager();
+ Path path = getSingleSelectedPath();
+ Uri uri = manager.getContentUri(path);
+ Log.d(TAG, "onMenuClicked:" + uri);
+ String filepath = null;
+ String scheme = uri.getScheme();
+ if ("file".equals(scheme)) {
+ filepath = uri.getPath();
+ } else {
+ Cursor cursor = null;
+ try {
+ cursor = mActivity.getAndroidContext().getContentResolver().query(uri,
+ new String[] {VideoColumns.DATA}, null, null, null);
+ if (cursor != null && cursor.moveToNext()) {
+ filepath = cursor.getString(0);
+ }
+ } catch (Throwable t) {
+ Log.w(TAG, "cannot get path from: " + uri);
+ } finally {
+ if (cursor != null) cursor.close();
+ }
+ }
+ Intent drmintent = new Intent("android.drmservice.intent.action.SHOW_PROPERTIES");
+ filepath = filepath.replace("/storage/emulated/0", "/storage/emulated/legacy");
+ drmintent.putExtra("DRM_FILE_PATH", filepath);
+ drmintent.putExtra("DRM_TYPE", "OMAV1");
+ mActivity.getAndroidContext().sendBroadcast(drmintent);
+ title = R.string.drm_license_info;
+ break;
default:
return;
}