Loading core/java/android/widget/RemoteViews.java +10 −0 Original line number Diff line number Diff line Loading @@ -3423,6 +3423,12 @@ public class RemoteViews implements Parcelable, Filter { * @hide */ public interface OnViewAppliedListener { /** * Callback when the RemoteView has finished inflating, * but no actions have been applied yet. */ default void onViewInflated(View v) {}; void onViewApplied(View v); void onError(Exception e); Loading Loading @@ -3519,6 +3525,10 @@ public class RemoteViews implements Parcelable, Filter { @Override protected void onPostExecute(ViewTree viewTree) { if (mError == null) { if (mListener != null) { mListener.onViewInflated(viewTree.mRoot); } try { if (mActions != null) { OnClickHandler handler = mHandler == null Loading core/java/com/android/internal/widget/ImageMessageConsumer.java 0 → 100644 +28 −0 Original line number Diff line number Diff line /* * Copyright (C) 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.internal.widget; /** * An interface for the class who will use the {@link ImageResolver} to resolve images. */ public interface ImageMessageConsumer { /** * Set the custom {@link ImageResolver} other than {@link LocalImageResolver}. * @param resolver An image resolver that has custom implementation. */ void setImageResolver(ImageResolver resolver); } core/java/com/android/internal/widget/ImageResolver.java 0 → 100644 +32 −0 Original line number Diff line number Diff line /* * Copyright (C) 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.internal.widget; import android.graphics.drawable.Drawable; import android.net.Uri; /** * An interface for image resolvers that have custom implementations like cache mechanisms. */ public interface ImageResolver { /** * Load an image from specified uri. * @param uri Uri of the target image. * @return Target image in Drawable. */ Drawable loadImage(Uri uri); } core/java/com/android/internal/widget/LocalImageResolver.java +0 −1 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ package com.android.internal.widget; import android.annotation.Nullable; import android.app.Notification; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; Loading core/java/com/android/internal/widget/MessagingImageMessage.java +14 −2 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import android.content.Context; import android.graphics.Canvas; import android.graphics.Path; import android.graphics.drawable.Drawable; import android.net.Uri; import android.util.AttributeSet; import android.util.Log; import android.util.Pools; Loading Loading @@ -57,6 +58,7 @@ public class MessagingImageMessage extends ImageView implements MessagingMessage private int mActualWidth; private int mActualHeight; private boolean mIsIsolated; private ImageResolver mImageResolver; public MessagingImageMessage(@NonNull Context context) { this(context, null); Loading Loading @@ -96,11 +98,16 @@ public class MessagingImageMessage extends ImageView implements MessagingMessage MessagingMessage.super.setMessage(message); Drawable drawable; try { drawable = LocalImageResolver.resolveImage(message.getDataUri(), getContext()); Uri uri = message.getDataUri(); drawable = mImageResolver != null ? mImageResolver.loadImage(uri) : LocalImageResolver.resolveImage(uri, getContext()); } catch (IOException | SecurityException e) { e.printStackTrace(); return false; } if (drawable == null) { return false; } int intrinsicHeight = drawable.getIntrinsicHeight(); if (intrinsicHeight == 0) { Log.w(TAG, "Drawable with 0 intrinsic height was returned"); Loading @@ -114,7 +121,7 @@ public class MessagingImageMessage extends ImageView implements MessagingMessage } static MessagingMessage createMessage(MessagingLayout layout, Notification.MessagingStyle.Message m) { Notification.MessagingStyle.Message m, ImageResolver resolver) { MessagingLinearLayout messagingLinearLayout = layout.getMessagingLinearLayout(); MessagingImageMessage createdMessage = sInstancePool.acquire(); if (createdMessage == null) { Loading @@ -125,6 +132,7 @@ public class MessagingImageMessage extends ImageView implements MessagingMessage false); createdMessage.addOnLayoutChangeListener(MessagingLayout.MESSAGING_PROPERTY_ANIMATOR); } createdMessage.setImageResolver(resolver); boolean created = createdMessage.setMessage(m); if (!created) { createdMessage.recycle(); Loading @@ -133,6 +141,10 @@ public class MessagingImageMessage extends ImageView implements MessagingMessage return createdMessage; } private void setImageResolver(ImageResolver resolver) { mImageResolver = resolver; } @Override protected void onDraw(Canvas canvas) { canvas.save(); Loading Loading
core/java/android/widget/RemoteViews.java +10 −0 Original line number Diff line number Diff line Loading @@ -3423,6 +3423,12 @@ public class RemoteViews implements Parcelable, Filter { * @hide */ public interface OnViewAppliedListener { /** * Callback when the RemoteView has finished inflating, * but no actions have been applied yet. */ default void onViewInflated(View v) {}; void onViewApplied(View v); void onError(Exception e); Loading Loading @@ -3519,6 +3525,10 @@ public class RemoteViews implements Parcelable, Filter { @Override protected void onPostExecute(ViewTree viewTree) { if (mError == null) { if (mListener != null) { mListener.onViewInflated(viewTree.mRoot); } try { if (mActions != null) { OnClickHandler handler = mHandler == null Loading
core/java/com/android/internal/widget/ImageMessageConsumer.java 0 → 100644 +28 −0 Original line number Diff line number Diff line /* * Copyright (C) 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.internal.widget; /** * An interface for the class who will use the {@link ImageResolver} to resolve images. */ public interface ImageMessageConsumer { /** * Set the custom {@link ImageResolver} other than {@link LocalImageResolver}. * @param resolver An image resolver that has custom implementation. */ void setImageResolver(ImageResolver resolver); }
core/java/com/android/internal/widget/ImageResolver.java 0 → 100644 +32 −0 Original line number Diff line number Diff line /* * Copyright (C) 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.internal.widget; import android.graphics.drawable.Drawable; import android.net.Uri; /** * An interface for image resolvers that have custom implementations like cache mechanisms. */ public interface ImageResolver { /** * Load an image from specified uri. * @param uri Uri of the target image. * @return Target image in Drawable. */ Drawable loadImage(Uri uri); }
core/java/com/android/internal/widget/LocalImageResolver.java +0 −1 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ package com.android.internal.widget; import android.annotation.Nullable; import android.app.Notification; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; Loading
core/java/com/android/internal/widget/MessagingImageMessage.java +14 −2 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import android.content.Context; import android.graphics.Canvas; import android.graphics.Path; import android.graphics.drawable.Drawable; import android.net.Uri; import android.util.AttributeSet; import android.util.Log; import android.util.Pools; Loading Loading @@ -57,6 +58,7 @@ public class MessagingImageMessage extends ImageView implements MessagingMessage private int mActualWidth; private int mActualHeight; private boolean mIsIsolated; private ImageResolver mImageResolver; public MessagingImageMessage(@NonNull Context context) { this(context, null); Loading Loading @@ -96,11 +98,16 @@ public class MessagingImageMessage extends ImageView implements MessagingMessage MessagingMessage.super.setMessage(message); Drawable drawable; try { drawable = LocalImageResolver.resolveImage(message.getDataUri(), getContext()); Uri uri = message.getDataUri(); drawable = mImageResolver != null ? mImageResolver.loadImage(uri) : LocalImageResolver.resolveImage(uri, getContext()); } catch (IOException | SecurityException e) { e.printStackTrace(); return false; } if (drawable == null) { return false; } int intrinsicHeight = drawable.getIntrinsicHeight(); if (intrinsicHeight == 0) { Log.w(TAG, "Drawable with 0 intrinsic height was returned"); Loading @@ -114,7 +121,7 @@ public class MessagingImageMessage extends ImageView implements MessagingMessage } static MessagingMessage createMessage(MessagingLayout layout, Notification.MessagingStyle.Message m) { Notification.MessagingStyle.Message m, ImageResolver resolver) { MessagingLinearLayout messagingLinearLayout = layout.getMessagingLinearLayout(); MessagingImageMessage createdMessage = sInstancePool.acquire(); if (createdMessage == null) { Loading @@ -125,6 +132,7 @@ public class MessagingImageMessage extends ImageView implements MessagingMessage false); createdMessage.addOnLayoutChangeListener(MessagingLayout.MESSAGING_PROPERTY_ANIMATOR); } createdMessage.setImageResolver(resolver); boolean created = createdMessage.setMessage(m); if (!created) { createdMessage.recycle(); Loading @@ -133,6 +141,10 @@ public class MessagingImageMessage extends ImageView implements MessagingMessage return createdMessage; } private void setImageResolver(ImageResolver resolver) { mImageResolver = resolver; } @Override protected void onDraw(Canvas canvas) { canvas.save(); Loading