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

Commit 074b54fb authored by Dianne Hackborn's avatar Dianne Hackborn Committed by Android (Google) Code Review
Browse files

Merge "Maybe fix issue #6756472: Share button is not defocusing the shade" into jb-dev

parents 50cf26c4 a1940216
Loading
Loading
Loading
Loading
+33 −36
Original line number Diff line number Diff line
@@ -128,7 +128,6 @@ public class RemoteViews implements Parcelable, Filter {
    private boolean mIsWidgetCollectionChild = false;

    private static final OnClickHandler DEFAULT_ON_CLICK_HANDLER = new OnClickHandler();
    private OnClickHandler mOnClickHandler = DEFAULT_ON_CLICK_HANDLER;

    /**
     * This annotation indicates that a subclass of View is alllowed to be used
@@ -185,8 +184,8 @@ public class RemoteViews implements Parcelable, Filter {
     *  SUBCLASSES MUST BE IMMUTABLE SO CLONE WORKS!!!!!
     */
    private abstract static class Action implements Parcelable {
        public abstract void apply(RemoteViews owner, View root,
                ViewGroup rootParent) throws ActionException;
        public abstract void apply(View root, ViewGroup rootParent,
                OnClickHandler handler) throws ActionException;

        public int describeContents() {
            return 0;
@@ -229,7 +228,7 @@ public class RemoteViews implements Parcelable, Filter {
        }

        @Override
        public void apply(RemoteViews owner, View root, ViewGroup rootParent) {
        public void apply(View root, ViewGroup rootParent, OnClickHandler handler) {
            final View view = root.findViewById(viewId);
            if (!(view instanceof AdapterView<?>)) return;

@@ -260,7 +259,7 @@ public class RemoteViews implements Parcelable, Filter {
        }

        @Override
        public void apply(RemoteViews owner, View root, ViewGroup rootParent) {
        public void apply(View root, ViewGroup rootParent, final OnClickHandler handler) {
            final View target = root.findViewById(viewId);
            if (target == null) return;

@@ -272,7 +271,6 @@ public class RemoteViews implements Parcelable, Filter {
            if (target == root) {
                target.setTagInternal(com.android.internal.R.id.fillInIntent, fillInIntent);
            } else if (target != null && fillInIntent != null) {
                final OnClickHandler clicker = owner.mOnClickHandler;
                OnClickListener listener = new OnClickListener() {
                    public void onClick(View v) {
                        // Insure that this view is a child of an AdapterView
@@ -310,7 +308,7 @@ public class RemoteViews implements Parcelable, Filter {
                        rect.bottom = (int) ((pos[1] + v.getHeight()) * appScale + 0.5f);

                        fillInIntent.setSourceBounds(rect);
                        clicker.onClickHandler(v, pendingIntent, fillInIntent);
                        handler.onClickHandler(v, pendingIntent, fillInIntent);
                    }

                };
@@ -342,14 +340,13 @@ public class RemoteViews implements Parcelable, Filter {
        }

        @Override
        public void apply(RemoteViews owner, View root, ViewGroup rootParent) {
        public void apply(View root, ViewGroup rootParent, final OnClickHandler handler) {
            final View target = root.findViewById(viewId);
            if (target == null) return;

            // If the view isn't an AdapterView, setting a PendingIntent template doesn't make sense
            if (target instanceof AdapterView<?>) {
                AdapterView<?> av = (AdapterView<?>) target;
                final OnClickHandler clicker = owner.mOnClickHandler;
                // The PendingIntent template is stored in the view's tag.
                OnItemClickListener listener = new OnItemClickListener() {
                    public void onItemClick(AdapterView<?> parent, View view,
@@ -389,7 +386,7 @@ public class RemoteViews implements Parcelable, Filter {

                            final Intent intent = new Intent();
                            intent.setSourceBounds(rect);
                            clicker.onClickHandler(view, pendingIntentTemplate, fillInIntent);
                            handler.onClickHandler(view, pendingIntentTemplate, fillInIntent);
                        }
                    }
                };
@@ -426,7 +423,7 @@ public class RemoteViews implements Parcelable, Filter {
        }

        @Override
        public void apply(RemoteViews owner, View root, ViewGroup rootParent) {
        public void apply(View root, ViewGroup rootParent, OnClickHandler handler) {
            final View target = root.findViewById(viewId);
            if (target == null) return;

@@ -494,7 +491,7 @@ public class RemoteViews implements Parcelable, Filter {
        }

        @Override
        public void apply(RemoteViews owner, View root, ViewGroup rootParent) {
        public void apply(View root, ViewGroup rootParent, final OnClickHandler handler) {
            final View target = root.findViewById(viewId);
            if (target == null) return;

@@ -515,7 +512,6 @@ public class RemoteViews implements Parcelable, Filter {

            if (target != null) {
                // If the pendingIntent is null, we clear the onClickListener
                final OnClickHandler clicker = owner.mOnClickHandler;
                OnClickListener listener = null;
                if (pendingIntent != null) {
                    listener = new OnClickListener() {
@@ -535,7 +531,7 @@ public class RemoteViews implements Parcelable, Filter {
    
                            final Intent intent = new Intent();
                            intent.setSourceBounds(rect);
                            clicker.onClickHandler(v, pendingIntent, intent);
                            handler.onClickHandler(v, pendingIntent, intent);
                        }
                    };
                }
@@ -602,7 +598,7 @@ public class RemoteViews implements Parcelable, Filter {
        }
        
        @Override
        public void apply(RemoteViews owner, View root, ViewGroup rootParent) {
        public void apply(View root, ViewGroup rootParent, OnClickHandler handler) {
            final View target = root.findViewById(viewId);
            if (target == null) return;
            
@@ -662,7 +658,7 @@ public class RemoteViews implements Parcelable, Filter {
        }

        @Override
        public void apply(RemoteViews owner, View root, ViewGroup rootParent) {
        public void apply(View root, ViewGroup rootParent, OnClickHandler handler) {
            final View view = root.findViewById(viewId);
            if (view == null) return;

@@ -786,11 +782,11 @@ public class RemoteViews implements Parcelable, Filter {
        }

        @Override
        public void apply(RemoteViews owner, View root,
                ViewGroup rootParent) throws ActionException {
        public void apply(View root, ViewGroup rootParent,
                OnClickHandler handler) throws ActionException {
            ReflectionAction ra = new ReflectionAction(viewId, methodName, ReflectionAction.BITMAP,
                    bitmap);
            ra.apply(owner, root, rootParent);
            ra.apply(root, rootParent, handler);
        }

        @Override
@@ -1006,7 +1002,7 @@ public class RemoteViews implements Parcelable, Filter {
        }

        @Override
        public void apply(RemoteViews owner, View root, ViewGroup rootParent) {
        public void apply(View root, ViewGroup rootParent, OnClickHandler handler) {
            final View view = root.findViewById(viewId);
            if (view == null) return;

@@ -1108,13 +1104,13 @@ public class RemoteViews implements Parcelable, Filter {
        }

        @Override
        public void apply(RemoteViews owner, View root, ViewGroup rootParent) {
        public void apply(View root, ViewGroup rootParent, OnClickHandler handler) {
            final Context context = root.getContext();
            final ViewGroup target = (ViewGroup) root.findViewById(viewId);
            if (target == null) return;
            if (nestedViews != null) {
                // Inflate nested views and add as children
                target.addView(nestedViews.apply(owner, context, target));
                target.addView(nestedViews.apply(context, target, handler));
            } else {
                // Clear all children when nested views omitted
                target.removeAllViews();
@@ -1175,7 +1171,7 @@ public class RemoteViews implements Parcelable, Filter {
        }

        @Override
        public void apply(RemoteViews owner, View root, ViewGroup rootParent) {
        public void apply(View root, ViewGroup rootParent, OnClickHandler handler) {
            final Context context = root.getContext();
            final TextView target = (TextView) root.findViewById(viewId);
            if (target == null) return;
@@ -1217,7 +1213,7 @@ public class RemoteViews implements Parcelable, Filter {
        }

        @Override
        public void apply(RemoteViews owner, View root, ViewGroup rootParent) {
        public void apply(View root, ViewGroup rootParent, OnClickHandler handler) {
            final Context context = root.getContext();
            final TextView target = (TextView) root.findViewById(viewId);
            if (target == null) return;
@@ -1261,7 +1257,7 @@ public class RemoteViews implements Parcelable, Filter {
        }

        @Override
        public void apply(RemoteViews owner, View root, ViewGroup rootParent) {
        public void apply(View root, ViewGroup rootParent, OnClickHandler handler) {
            final Context context = root.getContext();
            final View target = root.findViewById(viewId);
            if (target == null) return;
@@ -2099,11 +2095,6 @@ public class RemoteViews implements Parcelable, Filter {
        return this;
    }

    /** @hide */
    public void setOnClickHandler(OnClickHandler handler) {
        mOnClickHandler = handler;
    }

    /**
     * Inflates the view hierarchy represented by this object and applies
     * all of the actions.
@@ -2116,10 +2107,11 @@ public class RemoteViews implements Parcelable, Filter {
     * @return The inflated view hierarchy
     */
    public View apply(Context context, ViewGroup parent) {
        return apply(this, context, parent);
        return apply(context, parent, DEFAULT_ON_CLICK_HANDLER);
    }

    View apply(RemoteViews owner, Context context, ViewGroup parent) {
    /** @hide */
    public View apply(Context context, ViewGroup parent, OnClickHandler handler) {
        RemoteViews rvToApply = getRemoteViewsToApply(context);

        View result;
@@ -2134,7 +2126,7 @@ public class RemoteViews implements Parcelable, Filter {

        result = inflater.inflate(rvToApply.getLayoutId(), parent, false);

        rvToApply.performApply(owner, result, parent);
        rvToApply.performApply(result, parent, handler);

        return result;
    }
@@ -2148,6 +2140,11 @@ public class RemoteViews implements Parcelable, Filter {
     * the {@link #apply(Context,ViewGroup)} call.
     */
    public void reapply(Context context, View v) {
        reapply(context, v, DEFAULT_ON_CLICK_HANDLER);
    }

    /** @hide */
    public void reapply(Context context, View v, OnClickHandler handler) {
        RemoteViews rvToApply = getRemoteViewsToApply(context);

        // In the case that a view has this RemoteViews applied in one orientation, is persisted
@@ -2161,15 +2158,15 @@ public class RemoteViews implements Parcelable, Filter {
        }

        prepareContext(context);
        rvToApply.performApply(this, v, (ViewGroup) v.getParent());
        rvToApply.performApply(v, (ViewGroup) v.getParent(), handler);
    }

    private void performApply(RemoteViews owner, View v, ViewGroup parent) {
    private void performApply(View v, ViewGroup parent, OnClickHandler handler) {
        if (mActions != null) {
            final int count = mActions.size();
            for (int i = 0; i < count; i++) {
                Action a = mActions.get(i);
                a.apply(owner, v, parent);
                a.apply(v, parent, handler);
            }
        }
    }
+4 −6
Original line number Diff line number Diff line
@@ -577,11 +577,9 @@ public abstract class BaseStatusBar extends SystemUI implements
        View expandedLarge = null;
        Exception exception = null;
        try {
            oneU.setOnClickHandler(mOnClickHandler);
            expandedOneU = oneU.apply(mContext, adaptive);
            expandedOneU = oneU.apply(mContext, adaptive, mOnClickHandler);
            if (large != null) {
                large.setOnClickHandler(mOnClickHandler);
                expandedLarge = large.apply(mContext, adaptive);
                expandedLarge = large.apply(mContext, adaptive, mOnClickHandler);
            }
        }
        catch (RuntimeException e) {
@@ -872,9 +870,9 @@ public abstract class BaseStatusBar extends SystemUI implements
            oldEntry.notification = notification;
            try {
                // Reapply the RemoteViews
                contentView.reapply(mContext, oldEntry.expanded);
                contentView.reapply(mContext, oldEntry.expanded, mOnClickHandler);
                if (bigContentView != null && oldEntry.getLargeView() != null) {
                    bigContentView.reapply(mContext, oldEntry.getLargeView());
                    bigContentView.reapply(mContext, oldEntry.getLargeView(), mOnClickHandler);
                }
                // update the contentIntent
                final PendingIntent contentIntent = notification.notification.contentIntent;