Loading res/layout/appwidget_drm_empty_item.xml 0 → 100644 +48 −0 Original line number Diff line number Diff line <?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 src/com/android/gallery3d/gadget/PhotoAppWidgetProvider.java +1 −1 Original line number Diff line number Diff line Loading @@ -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); Loading src/com/android/gallery3d/gadget/WidgetClickHandler.java +0 −2 Original line number Diff line number Diff line Loading @@ -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) { Loading src/com/android/gallery3d/gadget/WidgetService.java +34 −1 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -117,7 +119,31 @@ public class WidgetService extends RemoteViewsService { @Override public RemoteViews getViewAt(int position) { 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); Loading @@ -125,6 +151,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; } Loading Loading
res/layout/appwidget_drm_empty_item.xml 0 → 100644 +48 −0 Original line number Diff line number Diff line <?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
src/com/android/gallery3d/gadget/PhotoAppWidgetProvider.java +1 −1 Original line number Diff line number Diff line Loading @@ -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); Loading
src/com/android/gallery3d/gadget/WidgetClickHandler.java +0 −2 Original line number Diff line number Diff line Loading @@ -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) { Loading
src/com/android/gallery3d/gadget/WidgetService.java +34 −1 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -117,7 +119,31 @@ public class WidgetService extends RemoteViewsService { @Override public RemoteViews getViewAt(int position) { 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); Loading @@ -125,6 +151,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; } Loading