summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorParamananda <parama@codeaurora.org>2015-03-24 12:34:23 (GMT)
committerRicardo Cerqueira <ricardo@cyngn.com>2015-09-15 20:31:49 (GMT)
commit4f3e49619d3954056f899660cc764f3773d92141 (patch)
tree402b271e793996d4ca002b3512e57512b8fb0c85
parentf5b491b181839286f58d640ae690f1860ef19e8c (diff)
downloadandroid_packages_apps_Gallery2-4f3e49619d3954056f899660cc764f3773d92141.zip
android_packages_apps_Gallery2-4f3e49619d3954056f899660cc764f3773d92141.tar.gz
android_packages_apps_Gallery2-4f3e49619d3954056f899660cc764f3773d92141.tar.bz2
Gallery2 : Drm lock icon added on Photo widget for drm content
CRs-fixed : 804180 Change-Id: I11c969f0156dba6db75c924a568eaa0733395208
-rw-r--r--res/layout/appwidget_drm_empty_item.xml48
-rw-r--r--src/com/android/gallery3d/gadget/PhotoAppWidgetProvider.java2
-rw-r--r--src/com/android/gallery3d/gadget/WidgetClickHandler.java2
-rw-r--r--src/com/android/gallery3d/gadget/WidgetService.java35
4 files changed, 83 insertions, 4 deletions
diff --git a/res/layout/appwidget_drm_empty_item.xml b/res/layout/appwidget_drm_empty_item.xml
new file mode 100644
index 0000000..8261dbe
--- /dev/null
+++ b/res/layout/appwidget_drm_empty_item.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (c) 2015, The Linux Foundation. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of The Linux Foundation nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+-->
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:background="@drawable/appwidget_photo_border" >
+
+ <RelativeLayout
+ android:layout_width="@dimen/stack_photo_width"
+ android:layout_height="@dimen/stack_photo_height"
+ android:background="@android:color/darker_gray" >
+
+ <ImageView
+ android:id="@+id/drm_icon"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_centerInParent="true"
+ android:background="@drawable/drm_image" />
+ </RelativeLayout>
+s
+</FrameLayout> \ No newline at end of file
diff --git a/src/com/android/gallery3d/gadget/PhotoAppWidgetProvider.java b/src/com/android/gallery3d/gadget/PhotoAppWidgetProvider.java
index 1dfbe3f..58466bf 100644
--- a/src/com/android/gallery3d/gadget/PhotoAppWidgetProvider.java
+++ b/src/com/android/gallery3d/gadget/PhotoAppWidgetProvider.java
@@ -106,7 +106,7 @@ public class PhotoAppWidgetProvider extends AppWidgetProvider {
context.getPackageName(), R.layout.photo_frame);
try {
byte[] data = entry.imageData;
- Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length, false);
+ Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
views.setImageViewBitmap(R.id.photo, bitmap);
} catch (Throwable t) {
Log.w(TAG, "cannot load widget image: " + appWidgetId, t);
diff --git a/src/com/android/gallery3d/gadget/WidgetClickHandler.java b/src/com/android/gallery3d/gadget/WidgetClickHandler.java
index 642f3d6..e5b0a37 100644
--- a/src/com/android/gallery3d/gadget/WidgetClickHandler.java
+++ b/src/com/android/gallery3d/gadget/WidgetClickHandler.java
@@ -57,8 +57,6 @@ public class WidgetClickHandler extends Activity {
Intent intent;
if (isValidDataUri(uri)) {
intent = new Intent(Intent.ACTION_VIEW, uri);
- intent.putExtra("WidgetClick", true);
-
// Used for checking whether it is from widget
intent.putExtra(PhotoPage.KEY_IS_FROM_WIDGET, true);
if (tediousBack) {
diff --git a/src/com/android/gallery3d/gadget/WidgetService.java b/src/com/android/gallery3d/gadget/WidgetService.java
index 8544337..7b16f8b 100644
--- a/src/com/android/gallery3d/gadget/WidgetService.java
+++ b/src/com/android/gallery3d/gadget/WidgetService.java
@@ -19,8 +19,10 @@ package com.android.gallery3d.gadget;
import android.annotation.TargetApi;
import android.appwidget.AppWidgetManager;
import android.content.Intent;
+import android.drm.DrmHelper;
import android.graphics.Bitmap;
import android.net.Uri;
+import android.view.View;
import android.widget.RemoteViews;
import android.widget.RemoteViewsService;
@@ -121,7 +123,31 @@ public class WidgetService extends RemoteViewsService {
return null;
}
Bitmap bitmap = mSource.getImage(position);
- if (bitmap == null) return getLoadingView();
+
+ boolean isDrm = false;
+ if (DrmHelper.isDrmFile(DrmHelper.getFilePath(
+ mApp.getAndroidContext(), mSource.getContentUri(position)))) {
+ isDrm = true;
+ }
+
+ if (isDrm) {
+ if (bitmap == null) {
+ RemoteViews rv = new RemoteViews(mApp.getAndroidContext()
+ .getPackageName(),
+ R.layout.appwidget_drm_empty_item);
+ rv.setOnClickFillInIntent(
+ R.id.appwidget_photo_item,
+ new Intent().setFlags(
+ Intent.FLAG_ACTIVITY_CLEAR_TOP).setData(
+ mSource.getContentUri(position)));
+ return rv;
+ }
+ } else {
+ if (bitmap == null) {
+ return getLoadingView();
+ }
+ }
+
RemoteViews views = new RemoteViews(
mApp.getAndroidContext().getPackageName(),
R.layout.appwidget_photo_item);
@@ -129,6 +155,13 @@ public class WidgetService extends RemoteViewsService {
views.setOnClickFillInIntent(R.id.appwidget_photo_item, new Intent()
.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
.setData(mSource.getContentUri(position)));
+
+ if (isDrm) {
+ views.setViewVisibility(R.id.drm_icon, View.VISIBLE);
+ } else {
+ views.setViewVisibility(R.id.drm_icon, View.GONE);
+ }
+
return views;
}