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

This commit is contained in:
Dianne Hackborn
2012-06-28 17:39:41 -07:00
committed by Android (Google) Code Review
2 changed files with 37 additions and 42 deletions

View File

@@ -128,7 +128,6 @@ public class RemoteViews implements Parcelable, Filter {
private boolean mIsWidgetCollectionChild = false; private boolean mIsWidgetCollectionChild = false;
private static final OnClickHandler DEFAULT_ON_CLICK_HANDLER = new OnClickHandler(); 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 * 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!!!!! * SUBCLASSES MUST BE IMMUTABLE SO CLONE WORKS!!!!!
*/ */
private abstract static class Action implements Parcelable { private abstract static class Action implements Parcelable {
public abstract void apply(RemoteViews owner, View root, public abstract void apply(View root, ViewGroup rootParent,
ViewGroup rootParent) throws ActionException; OnClickHandler handler) throws ActionException;
public int describeContents() { public int describeContents() {
return 0; return 0;
@@ -229,7 +228,7 @@ public class RemoteViews implements Parcelable, Filter {
} }
@Override @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); final View view = root.findViewById(viewId);
if (!(view instanceof AdapterView<?>)) return; if (!(view instanceof AdapterView<?>)) return;
@@ -260,7 +259,7 @@ public class RemoteViews implements Parcelable, Filter {
} }
@Override @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); final View target = root.findViewById(viewId);
if (target == null) return; if (target == null) return;
@@ -272,7 +271,6 @@ public class RemoteViews implements Parcelable, Filter {
if (target == root) { if (target == root) {
target.setTagInternal(com.android.internal.R.id.fillInIntent, fillInIntent); target.setTagInternal(com.android.internal.R.id.fillInIntent, fillInIntent);
} else if (target != null && fillInIntent != null) { } else if (target != null && fillInIntent != null) {
final OnClickHandler clicker = owner.mOnClickHandler;
OnClickListener listener = new OnClickListener() { OnClickListener listener = new OnClickListener() {
public void onClick(View v) { public void onClick(View v) {
// Insure that this view is a child of an AdapterView // 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); rect.bottom = (int) ((pos[1] + v.getHeight()) * appScale + 0.5f);
fillInIntent.setSourceBounds(rect); fillInIntent.setSourceBounds(rect);
clicker.onClickHandler(v, pendingIntent, fillInIntent); handler.onClickHandler(v, pendingIntent, fillInIntent);
} }
}; };
@@ -342,14 +340,13 @@ public class RemoteViews implements Parcelable, Filter {
} }
@Override @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); final View target = root.findViewById(viewId);
if (target == null) return; if (target == null) return;
// If the view isn't an AdapterView, setting a PendingIntent template doesn't make sense // If the view isn't an AdapterView, setting a PendingIntent template doesn't make sense
if (target instanceof AdapterView<?>) { if (target instanceof AdapterView<?>) {
AdapterView<?> av = (AdapterView<?>) target; AdapterView<?> av = (AdapterView<?>) target;
final OnClickHandler clicker = owner.mOnClickHandler;
// The PendingIntent template is stored in the view's tag. // The PendingIntent template is stored in the view's tag.
OnItemClickListener listener = new OnItemClickListener() { OnItemClickListener listener = new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, public void onItemClick(AdapterView<?> parent, View view,
@@ -389,7 +386,7 @@ public class RemoteViews implements Parcelable, Filter {
final Intent intent = new Intent(); final Intent intent = new Intent();
intent.setSourceBounds(rect); intent.setSourceBounds(rect);
clicker.onClickHandler(view, pendingIntentTemplate, fillInIntent); handler.onClickHandler(view, pendingIntentTemplate, fillInIntent);
} }
} }
}; };
@@ -426,7 +423,7 @@ public class RemoteViews implements Parcelable, Filter {
} }
@Override @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); final View target = root.findViewById(viewId);
if (target == null) return; if (target == null) return;
@@ -494,7 +491,7 @@ public class RemoteViews implements Parcelable, Filter {
} }
@Override @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); final View target = root.findViewById(viewId);
if (target == null) return; if (target == null) return;
@@ -515,7 +512,6 @@ public class RemoteViews implements Parcelable, Filter {
if (target != null) { if (target != null) {
// If the pendingIntent is null, we clear the onClickListener // If the pendingIntent is null, we clear the onClickListener
final OnClickHandler clicker = owner.mOnClickHandler;
OnClickListener listener = null; OnClickListener listener = null;
if (pendingIntent != null) { if (pendingIntent != null) {
listener = new OnClickListener() { listener = new OnClickListener() {
@@ -535,7 +531,7 @@ public class RemoteViews implements Parcelable, Filter {
final Intent intent = new Intent(); final Intent intent = new Intent();
intent.setSourceBounds(rect); intent.setSourceBounds(rect);
clicker.onClickHandler(v, pendingIntent, intent); handler.onClickHandler(v, pendingIntent, intent);
} }
}; };
} }
@@ -602,7 +598,7 @@ public class RemoteViews implements Parcelable, Filter {
} }
@Override @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); final View target = root.findViewById(viewId);
if (target == null) return; if (target == null) return;
@@ -662,7 +658,7 @@ public class RemoteViews implements Parcelable, Filter {
} }
@Override @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); final View view = root.findViewById(viewId);
if (view == null) return; if (view == null) return;
@@ -786,11 +782,11 @@ public class RemoteViews implements Parcelable, Filter {
} }
@Override @Override
public void apply(RemoteViews owner, View root, public void apply(View root, ViewGroup rootParent,
ViewGroup rootParent) throws ActionException { OnClickHandler handler) throws ActionException {
ReflectionAction ra = new ReflectionAction(viewId, methodName, ReflectionAction.BITMAP, ReflectionAction ra = new ReflectionAction(viewId, methodName, ReflectionAction.BITMAP,
bitmap); bitmap);
ra.apply(owner, root, rootParent); ra.apply(root, rootParent, handler);
} }
@Override @Override
@@ -1006,7 +1002,7 @@ public class RemoteViews implements Parcelable, Filter {
} }
@Override @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); final View view = root.findViewById(viewId);
if (view == null) return; if (view == null) return;
@@ -1108,13 +1104,13 @@ public class RemoteViews implements Parcelable, Filter {
} }
@Override @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 Context context = root.getContext();
final ViewGroup target = (ViewGroup) root.findViewById(viewId); final ViewGroup target = (ViewGroup) root.findViewById(viewId);
if (target == null) return; if (target == null) return;
if (nestedViews != null) { if (nestedViews != null) {
// Inflate nested views and add as children // Inflate nested views and add as children
target.addView(nestedViews.apply(owner, context, target)); target.addView(nestedViews.apply(context, target, handler));
} else { } else {
// Clear all children when nested views omitted // Clear all children when nested views omitted
target.removeAllViews(); target.removeAllViews();
@@ -1175,7 +1171,7 @@ public class RemoteViews implements Parcelable, Filter {
} }
@Override @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 Context context = root.getContext();
final TextView target = (TextView) root.findViewById(viewId); final TextView target = (TextView) root.findViewById(viewId);
if (target == null) return; if (target == null) return;
@@ -1217,7 +1213,7 @@ public class RemoteViews implements Parcelable, Filter {
} }
@Override @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 Context context = root.getContext();
final TextView target = (TextView) root.findViewById(viewId); final TextView target = (TextView) root.findViewById(viewId);
if (target == null) return; if (target == null) return;
@@ -1261,7 +1257,7 @@ public class RemoteViews implements Parcelable, Filter {
} }
@Override @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 Context context = root.getContext();
final View target = root.findViewById(viewId); final View target = root.findViewById(viewId);
if (target == null) return; if (target == null) return;
@@ -2099,11 +2095,6 @@ public class RemoteViews implements Parcelable, Filter {
return this; return this;
} }
/** @hide */
public void setOnClickHandler(OnClickHandler handler) {
mOnClickHandler = handler;
}
/** /**
* Inflates the view hierarchy represented by this object and applies * Inflates the view hierarchy represented by this object and applies
* all of the actions. * all of the actions.
@@ -2116,10 +2107,11 @@ public class RemoteViews implements Parcelable, Filter {
* @return The inflated view hierarchy * @return The inflated view hierarchy
*/ */
public View apply(Context context, ViewGroup parent) { 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); RemoteViews rvToApply = getRemoteViewsToApply(context);
View result; View result;
@@ -2134,7 +2126,7 @@ public class RemoteViews implements Parcelable, Filter {
result = inflater.inflate(rvToApply.getLayoutId(), parent, false); result = inflater.inflate(rvToApply.getLayoutId(), parent, false);
rvToApply.performApply(owner, result, parent); rvToApply.performApply(result, parent, handler);
return result; return result;
} }
@@ -2148,6 +2140,11 @@ public class RemoteViews implements Parcelable, Filter {
* the {@link #apply(Context,ViewGroup)} call. * the {@link #apply(Context,ViewGroup)} call.
*/ */
public void reapply(Context context, View v) { 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); RemoteViews rvToApply = getRemoteViewsToApply(context);
// In the case that a view has this RemoteViews applied in one orientation, is persisted // 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); 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) { if (mActions != null) {
final int count = mActions.size(); final int count = mActions.size();
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
Action a = mActions.get(i); Action a = mActions.get(i);
a.apply(owner, v, parent); a.apply(v, parent, handler);
} }
} }
} }

View File

@@ -577,11 +577,9 @@ public abstract class BaseStatusBar extends SystemUI implements
View expandedLarge = null; View expandedLarge = null;
Exception exception = null; Exception exception = null;
try { try {
oneU.setOnClickHandler(mOnClickHandler); expandedOneU = oneU.apply(mContext, adaptive, mOnClickHandler);
expandedOneU = oneU.apply(mContext, adaptive);
if (large != null) { if (large != null) {
large.setOnClickHandler(mOnClickHandler); expandedLarge = large.apply(mContext, adaptive, mOnClickHandler);
expandedLarge = large.apply(mContext, adaptive);
} }
} }
catch (RuntimeException e) { catch (RuntimeException e) {
@@ -872,9 +870,9 @@ public abstract class BaseStatusBar extends SystemUI implements
oldEntry.notification = notification; oldEntry.notification = notification;
try { try {
// Reapply the RemoteViews // Reapply the RemoteViews
contentView.reapply(mContext, oldEntry.expanded); contentView.reapply(mContext, oldEntry.expanded, mOnClickHandler);
if (bigContentView != null && oldEntry.getLargeView() != null) { if (bigContentView != null && oldEntry.getLargeView() != null) {
bigContentView.reapply(mContext, oldEntry.getLargeView()); bigContentView.reapply(mContext, oldEntry.getLargeView(), mOnClickHandler);
} }
// update the contentIntent // update the contentIntent
final PendingIntent contentIntent = notification.notification.contentIntent; final PendingIntent contentIntent = notification.notification.contentIntent;