Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5b15392c authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Simplifying writeToParcel for various actions

> Using helper methods when writing and reading typed objects
> Moving the tag write outside the action, as it is read outside
  the action as well
> Removing usused tags

Test: am instrument -w -e class android.widget.RemoteViewsTest com.android.frameworks.coretests/android.support.test.runner.AndroidJUnitRunner
Bug: 65574108
Change-Id: Iaf51cae6ef9f82b70dc1f19c2f019af40c4424a2
parent 8672d813
Loading
Loading
Loading
Loading
+1 −3
Original line number Original line Diff line number Diff line
@@ -5022,8 +5022,6 @@ android.widget.RemoteViews$AsyncApplyTask
android.widget.RemoteViews$BitmapCache
android.widget.RemoteViews$BitmapCache
android.widget.RemoteViews$BitmapReflectionAction
android.widget.RemoteViews$BitmapReflectionAction
android.widget.RemoteViews$LayoutParamAction
android.widget.RemoteViews$LayoutParamAction
android.widget.RemoteViews$MemoryUsageCounter
android.widget.RemoteViews$MutablePair
android.widget.RemoteViews$OnClickHandler
android.widget.RemoteViews$OnClickHandler
android.widget.RemoteViews$OnViewAppliedListener
android.widget.RemoteViews$OnViewAppliedListener
android.widget.RemoteViews$ReflectionAction
android.widget.RemoteViews$ReflectionAction
@@ -5031,7 +5029,7 @@ android.widget.RemoteViews$RemoteView
android.widget.RemoteViews$RemoteViewsContextWrapper
android.widget.RemoteViews$RemoteViewsContextWrapper
android.widget.RemoteViews$RunnableAction
android.widget.RemoteViews$RunnableAction
android.widget.RemoteViews$RuntimeAction
android.widget.RemoteViews$RuntimeAction
android.widget.RemoteViews$SetDrawableParameters
android.widget.RemoteViews$SetDrawableTint
android.widget.RemoteViews$SetOnClickPendingIntent
android.widget.RemoteViews$SetOnClickPendingIntent
android.widget.RemoteViews$SetOnClickPendingIntent$1
android.widget.RemoteViews$SetOnClickPendingIntent$1
android.widget.RemoteViews$ViewGroupAction
android.widget.RemoteViews$ViewGroupAction
+1 −3
Original line number Original line Diff line number Diff line
@@ -2723,13 +2723,11 @@ android.widget.RemoteViews$3
android.widget.RemoteViews$Action
android.widget.RemoteViews$Action
android.widget.RemoteViews$BitmapCache
android.widget.RemoteViews$BitmapCache
android.widget.RemoteViews$LayoutParamAction
android.widget.RemoteViews$LayoutParamAction
android.widget.RemoteViews$MemoryUsageCounter
android.widget.RemoteViews$MutablePair
android.widget.RemoteViews$OnClickHandler
android.widget.RemoteViews$OnClickHandler
android.widget.RemoteViews$ReflectionAction
android.widget.RemoteViews$ReflectionAction
android.widget.RemoteViews$RemoteView
android.widget.RemoteViews$RemoteView
android.widget.RemoteViews$RuntimeAction
android.widget.RemoteViews$RuntimeAction
android.widget.RemoteViews$SetDrawableParameters
android.widget.RemoteViews$SetDrawableTint
android.widget.RemoteViewsAdapter$RemoteAdapterConnectionCallback
android.widget.RemoteViewsAdapter$RemoteAdapterConnectionCallback
android.widget.RtlSpacingHelper
android.widget.RtlSpacingHelper
android.widget.ScrollBarDrawable
android.widget.ScrollBarDrawable
+17 −22
Original line number Original line Diff line number Diff line
@@ -3839,8 +3839,8 @@ public class Notification implements Parcelable
                contentView.setImageViewBitmap(R.id.profile_badge, profileBadge);
                contentView.setImageViewBitmap(R.id.profile_badge, profileBadge);
                contentView.setViewVisibility(R.id.profile_badge, View.VISIBLE);
                contentView.setViewVisibility(R.id.profile_badge, View.VISIBLE);
                if (isColorized()) {
                if (isColorized()) {
                    contentView.setDrawableParameters(R.id.profile_badge, false, -1,
                    contentView.setDrawableTint(R.id.profile_badge, false,
                            getPrimaryTextColor(), PorterDuff.Mode.SRC_ATOP, -1);
                            getPrimaryTextColor(), PorterDuff.Mode.SRC_ATOP);
                }
                }
            }
            }
        }
        }
@@ -4130,18 +4130,14 @@ public class Notification implements Parcelable


                if (action != null) {
                if (action != null) {
                    int contrastColor = resolveContrastColor();
                    int contrastColor = resolveContrastColor();
                    contentView.setDrawableParameters(R.id.reply_icon_action,
                    contentView.setDrawableTint(R.id.reply_icon_action,
                            true /* targetBackground */,
                            true /* targetBackground */,
                            -1,
                            contrastColor, PorterDuff.Mode.SRC_ATOP);
                            contrastColor,
                            PorterDuff.Mode.SRC_ATOP, -1);
                    int iconColor = NotificationColorUtil.isColorLight(contrastColor)
                    int iconColor = NotificationColorUtil.isColorLight(contrastColor)
                            ? Color.BLACK : Color.WHITE;
                            ? Color.BLACK : Color.WHITE;
                    contentView.setDrawableParameters(R.id.reply_icon_action,
                    contentView.setDrawableTint(R.id.reply_icon_action,
                            false /* targetBackground */,
                            false /* targetBackground */,
                            -1,
                            iconColor, PorterDuff.Mode.SRC_ATOP);
                            iconColor,
                            PorterDuff.Mode.SRC_ATOP, -1);
                    contentView.setOnClickPendingIntent(R.id.right_icon,
                    contentView.setOnClickPendingIntent(R.id.right_icon,
                            action.actionIntent);
                            action.actionIntent);
                    contentView.setOnClickPendingIntent(R.id.reply_icon_action,
                    contentView.setOnClickPendingIntent(R.id.reply_icon_action,
@@ -4185,8 +4181,8 @@ public class Notification implements Parcelable


        private void bindExpandButton(RemoteViews contentView) {
        private void bindExpandButton(RemoteViews contentView) {
            int color = getPrimaryHighlightColor();
            int color = getPrimaryHighlightColor();
            contentView.setDrawableParameters(R.id.expand_button, false, -1, color,
            contentView.setDrawableTint(R.id.expand_button, false, color,
                    PorterDuff.Mode.SRC_ATOP, -1);
                    PorterDuff.Mode.SRC_ATOP);
            contentView.setInt(R.id.notification_header, "setOriginalNotificationColor",
            contentView.setInt(R.id.notification_header, "setOriginalNotificationColor",
                    color);
                    color);
        }
        }
@@ -4293,8 +4289,7 @@ public class Notification implements Parcelable
                mN.mSmallIcon = Icon.createWithResource(mContext, mN.icon);
                mN.mSmallIcon = Icon.createWithResource(mContext, mN.icon);
            }
            }
            contentView.setImageViewIcon(R.id.icon, mN.mSmallIcon);
            contentView.setImageViewIcon(R.id.icon, mN.mSmallIcon);
            contentView.setDrawableParameters(R.id.icon, false /* targetBackground */,
            contentView.setInt(R.id.icon, "setImageLevel", mN.iconLevel);
                    -1 /* alpha */, -1 /* colorFilter */, null /* mode */, mN.iconLevel);
            processSmallIconColor(mN.mSmallIcon, contentView, ambient);
            processSmallIconColor(mN.mSmallIcon, contentView, ambient);
        }
        }


@@ -4684,8 +4679,8 @@ public class Notification implements Parcelable
                    bgColor = mContext.getColor(oddAction ? R.color.notification_action_list
                    bgColor = mContext.getColor(oddAction ? R.color.notification_action_list
                            : R.color.notification_action_list_dark);
                            : R.color.notification_action_list_dark);
                }
                }
                button.setDrawableParameters(R.id.button_holder, true, -1, bgColor,
                button.setDrawableTint(R.id.button_holder, true,
                        PorterDuff.Mode.SRC_ATOP, -1);
                        bgColor, PorterDuff.Mode.SRC_ATOP);
                CharSequence title = action.title;
                CharSequence title = action.title;
                ColorStateList[] outResultColor = null;
                ColorStateList[] outResultColor = null;
                if (isLegacy()) {
                if (isLegacy()) {
@@ -4818,8 +4813,8 @@ public class Notification implements Parcelable
            boolean colorable = !isLegacy() || getColorUtil().isGrayscaleIcon(mContext, smallIcon);
            boolean colorable = !isLegacy() || getColorUtil().isGrayscaleIcon(mContext, smallIcon);
            int color = ambient ? resolveAmbientColor() : getPrimaryHighlightColor();
            int color = ambient ? resolveAmbientColor() : getPrimaryHighlightColor();
            if (colorable) {
            if (colorable) {
                contentView.setDrawableParameters(R.id.icon, false, -1, color,
                contentView.setDrawableTint(R.id.icon, false, color,
                        PorterDuff.Mode.SRC_ATOP, -1);
                        PorterDuff.Mode.SRC_ATOP);


            }
            }
            contentView.setInt(R.id.notification_header, "setOriginalIconColor",
            contentView.setInt(R.id.notification_header, "setOriginalIconColor",
@@ -4835,8 +4830,8 @@ public class Notification implements Parcelable
            if (largeIcon != null && isLegacy()
            if (largeIcon != null && isLegacy()
                    && getColorUtil().isGrayscaleIcon(mContext, largeIcon)) {
                    && getColorUtil().isGrayscaleIcon(mContext, largeIcon)) {
                // resolve color will fall back to the default when legacy
                // resolve color will fall back to the default when legacy
                contentView.setDrawableParameters(R.id.icon, false, -1, resolveContrastColor(),
                contentView.setDrawableTint(R.id.icon, false, resolveContrastColor(),
                        PorterDuff.Mode.SRC_ATOP, -1);
                        PorterDuff.Mode.SRC_ATOP);
            }
            }
        }
        }


@@ -6750,8 +6745,8 @@ public class Notification implements Parcelable
                    : NotificationColorUtil.resolveColor(mBuilder.mContext,
                    : NotificationColorUtil.resolveColor(mBuilder.mContext,
                            Notification.COLOR_DEFAULT);
                            Notification.COLOR_DEFAULT);


            button.setDrawableParameters(R.id.action0, false, -1, tintColor,
            button.setDrawableTint(R.id.action0, false, tintColor,
                    PorterDuff.Mode.SRC_ATOP, -1);
                    PorterDuff.Mode.SRC_ATOP);
            if (!tombstone) {
            if (!tombstone) {
                button.setOnClickPendingIntent(R.id.action0, action.actionIntent);
                button.setOnClickPendingIntent(R.id.action0, action.actionIntent);
            }
            }
+139 −337

File changed.

Preview size limit exceeded, changes collapsed.