diff options
author | Dianne Hackborn <hackbod@google.com> | 2012-06-28 17:45:40 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2012-06-28 17:45:40 -0700 |
commit | acc3da02e84aa541c829ec0650a7dcace16e5df0 (patch) | |
tree | 5a6aaef73778037ff078e5aa03b11a2b306a8fb0 /core/java/android/widget/RemoteViews.java | |
parent | 875e0554c908f600c2fd50d6d1539ceda115df82 (diff) | |
parent | 4be93bbe911c1a4471f81f0e261e9b13d9212c36 (diff) | |
download | frameworks_base-acc3da02e84aa541c829ec0650a7dcace16e5df0.zip frameworks_base-acc3da02e84aa541c829ec0650a7dcace16e5df0.tar.gz frameworks_base-acc3da02e84aa541c829ec0650a7dcace16e5df0.tar.bz2 |
am 4be93bbe: am 074b54fb: Merge "Maybe fix issue #6756472: Share button is not defocusing the shade" into jb-dev
* commit '4be93bbe911c1a4471f81f0e261e9b13d9212c36':
Maybe fix issue #6756472: Share button is not defocusing the shade
Diffstat (limited to 'core/java/android/widget/RemoteViews.java')
-rw-r--r-- | core/java/android/widget/RemoteViews.java | 69 |
1 files changed, 33 insertions, 36 deletions
diff --git a/core/java/android/widget/RemoteViews.java b/core/java/android/widget/RemoteViews.java index 443e7cc..dd05a03 100644 --- a/core/java/android/widget/RemoteViews.java +++ b/core/java/android/widget/RemoteViews.java @@ -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; @@ -2106,11 +2102,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. @@ -2123,10 +2114,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; @@ -2141,7 +2133,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; } @@ -2155,6 +2147,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 @@ -2168,15 +2165,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); } } } |