Loading core/java/android/appwidget/AppWidgetHost.java +18 −6 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import android.os.ServiceManager; import android.util.DisplayMetrics; import android.util.TypedValue; import android.widget.RemoteViews; import android.widget.RemoteViews.OnClickHandler; import com.android.internal.appwidget.IAppWidgetHost; import com.android.internal.appwidget.IAppWidgetService; Loading Loading @@ -111,10 +112,19 @@ public class AppWidgetHost { int mHostId; Callbacks mCallbacks = new Callbacks(); final HashMap<Integer,AppWidgetHostView> mViews = new HashMap<Integer, AppWidgetHostView>(); private OnClickHandler mOnClickHandler; public AppWidgetHost(Context context, int hostId) { this(context, hostId, null); } /** * @hide */ public AppWidgetHost(Context context, int hostId, OnClickHandler handler) { mContext = context; mHostId = hostId; mOnClickHandler = handler; mHandler = new UpdateHandler(context.getMainLooper()); mDisplayMetrics = context.getResources().getDisplayMetrics(); synchronized (sServiceLock) { Loading Loading @@ -235,6 +245,7 @@ public class AppWidgetHost { public final AppWidgetHostView createView(Context context, int appWidgetId, AppWidgetProviderInfo appWidget) { AppWidgetHostView view = onCreateView(context, appWidgetId, appWidget); view.setOnClickHandler(mOnClickHandler); view.setAppWidget(appWidgetId, appWidget); synchronized (mViews) { mViews.put(appWidgetId, view); Loading @@ -246,6 +257,7 @@ public class AppWidgetHost { throw new RuntimeException("system server dead?", e); } view.updateAppWidget(views); return view; } Loading @@ -255,7 +267,7 @@ public class AppWidgetHost { */ protected AppWidgetHostView onCreateView(Context context, int appWidgetId, AppWidgetProviderInfo appWidget) { return new AppWidgetHostView(context); return new AppWidgetHostView(context, mOnClickHandler); } /** Loading core/java/android/appwidget/AppWidgetHostView.java +39 −17 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ import android.widget.AdapterView; import android.widget.BaseAdapter; import android.widget.FrameLayout; import android.widget.RemoteViews; import android.widget.RemoteViews.OnClickHandler; import android.widget.RemoteViewsAdapter.RemoteAdapterConnectionCallback; import android.widget.TextView; Loading Loading @@ -83,6 +84,7 @@ public class AppWidgetHostView extends FrameLayout { long mFadeStartTime = -1; Bitmap mOld; Paint mOldPaint = new Paint(); private OnClickHandler mOnClickHandler; /** * Create a host view. Uses default fade animations. Loading @@ -91,6 +93,14 @@ public class AppWidgetHostView extends FrameLayout { this(context, android.R.anim.fade_in, android.R.anim.fade_out); } /** * @hide */ public AppWidgetHostView(Context context, OnClickHandler handler) { this(context, android.R.anim.fade_in, android.R.anim.fade_out); mOnClickHandler = handler; } /** * Create a host view. Uses specified animations when pushing * {@link #updateAppWidget(RemoteViews)}. Loading @@ -108,6 +118,17 @@ public class AppWidgetHostView extends FrameLayout { setIsRootNamespace(true); } /** * Pass the given handler to RemoteViews when updating this widget. Unless this * is done immediatly after construction, a call to {@link #updateAppWidget(RemoteViews)} * should be made. * @param handler * @hide */ public void setOnClickHandler(OnClickHandler handler) { mOnClickHandler = handler; } /** * Set the AppWidget that will be displayed by this view. This method also adds default padding * to widgets, as described in {@link #getDefaultPaddingForWidget(Context, ComponentName, Rect)} Loading Loading @@ -281,6 +302,7 @@ public class AppWidgetHostView extends FrameLayout { * AppWidget provider. Will animate into these new views as needed */ public void updateAppWidget(RemoteViews remoteViews) { if (LOGD) Log.d(TAG, "updateAppWidget called mOld=" + mOld); boolean recycled = false; Loading Loading @@ -324,7 +346,7 @@ public class AppWidgetHostView extends FrameLayout { // layout matches, try recycling it if (content == null && layoutId == mLayoutId) { try { remoteViews.reapply(mContext, mView); remoteViews.reapply(mContext, mView, mOnClickHandler); content = mView; recycled = true; if (LOGD) Log.d(TAG, "was able to recycled existing layout"); Loading @@ -336,7 +358,7 @@ public class AppWidgetHostView extends FrameLayout { // Try normal RemoteView inflation if (content == null) { try { content = remoteViews.apply(mContext, this); content = remoteViews.apply(mContext, this, mOnClickHandler); if (LOGD) Log.d(TAG, "had to inflate new layout"); } catch (RuntimeException e) { exception = e; Loading core/java/android/widget/RemoteViews.java +44 −47 Original line number Diff line number Diff line Loading @@ -1671,11 +1671,7 @@ public class RemoteViews implements Parcelable, Filter { * layout direction), or 0 * @param top The id of a drawable to place above the text, or 0 * @param end The id of a drawable to place after the text, or 0 <<<<<<< HEAD * @param bottom The id of a drawable to place below the text, or 0 ======= * @param bottom The id of a drawable to place below the text, or 0 >>>>>>> 0a43f67e */ public void setTextViewCompoundDrawablesRelative(int viewId, int start, int top, int end, int bottom) { addAction(new TextViewDrawableAction(viewId, true, start, top, end, bottom)); Loading Loading @@ -2114,7 +2110,7 @@ public class RemoteViews implements Parcelable, Filter { * @return The inflated view hierarchy */ public View apply(Context context, ViewGroup parent) { return apply(context, parent, DEFAULT_ON_CLICK_HANDLER); return apply(context, parent, null); } /** @hide */ Loading Loading @@ -2147,7 +2143,7 @@ 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); reapply(context, v, null); } /** @hide */ Loading @@ -2170,6 +2166,7 @@ public class RemoteViews implements Parcelable, Filter { private void performApply(View v, ViewGroup parent, OnClickHandler handler) { if (mActions != null) { handler = handler == null ? DEFAULT_ON_CLICK_HANDLER : handler; final int count = mActions.size(); for (int i = 0; i < count; i++) { Action a = mActions.get(i); Loading Loading
core/java/android/appwidget/AppWidgetHost.java +18 −6 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import android.os.ServiceManager; import android.util.DisplayMetrics; import android.util.TypedValue; import android.widget.RemoteViews; import android.widget.RemoteViews.OnClickHandler; import com.android.internal.appwidget.IAppWidgetHost; import com.android.internal.appwidget.IAppWidgetService; Loading Loading @@ -111,10 +112,19 @@ public class AppWidgetHost { int mHostId; Callbacks mCallbacks = new Callbacks(); final HashMap<Integer,AppWidgetHostView> mViews = new HashMap<Integer, AppWidgetHostView>(); private OnClickHandler mOnClickHandler; public AppWidgetHost(Context context, int hostId) { this(context, hostId, null); } /** * @hide */ public AppWidgetHost(Context context, int hostId, OnClickHandler handler) { mContext = context; mHostId = hostId; mOnClickHandler = handler; mHandler = new UpdateHandler(context.getMainLooper()); mDisplayMetrics = context.getResources().getDisplayMetrics(); synchronized (sServiceLock) { Loading Loading @@ -235,6 +245,7 @@ public class AppWidgetHost { public final AppWidgetHostView createView(Context context, int appWidgetId, AppWidgetProviderInfo appWidget) { AppWidgetHostView view = onCreateView(context, appWidgetId, appWidget); view.setOnClickHandler(mOnClickHandler); view.setAppWidget(appWidgetId, appWidget); synchronized (mViews) { mViews.put(appWidgetId, view); Loading @@ -246,6 +257,7 @@ public class AppWidgetHost { throw new RuntimeException("system server dead?", e); } view.updateAppWidget(views); return view; } Loading @@ -255,7 +267,7 @@ public class AppWidgetHost { */ protected AppWidgetHostView onCreateView(Context context, int appWidgetId, AppWidgetProviderInfo appWidget) { return new AppWidgetHostView(context); return new AppWidgetHostView(context, mOnClickHandler); } /** Loading
core/java/android/appwidget/AppWidgetHostView.java +39 −17 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ import android.widget.AdapterView; import android.widget.BaseAdapter; import android.widget.FrameLayout; import android.widget.RemoteViews; import android.widget.RemoteViews.OnClickHandler; import android.widget.RemoteViewsAdapter.RemoteAdapterConnectionCallback; import android.widget.TextView; Loading Loading @@ -83,6 +84,7 @@ public class AppWidgetHostView extends FrameLayout { long mFadeStartTime = -1; Bitmap mOld; Paint mOldPaint = new Paint(); private OnClickHandler mOnClickHandler; /** * Create a host view. Uses default fade animations. Loading @@ -91,6 +93,14 @@ public class AppWidgetHostView extends FrameLayout { this(context, android.R.anim.fade_in, android.R.anim.fade_out); } /** * @hide */ public AppWidgetHostView(Context context, OnClickHandler handler) { this(context, android.R.anim.fade_in, android.R.anim.fade_out); mOnClickHandler = handler; } /** * Create a host view. Uses specified animations when pushing * {@link #updateAppWidget(RemoteViews)}. Loading @@ -108,6 +118,17 @@ public class AppWidgetHostView extends FrameLayout { setIsRootNamespace(true); } /** * Pass the given handler to RemoteViews when updating this widget. Unless this * is done immediatly after construction, a call to {@link #updateAppWidget(RemoteViews)} * should be made. * @param handler * @hide */ public void setOnClickHandler(OnClickHandler handler) { mOnClickHandler = handler; } /** * Set the AppWidget that will be displayed by this view. This method also adds default padding * to widgets, as described in {@link #getDefaultPaddingForWidget(Context, ComponentName, Rect)} Loading Loading @@ -281,6 +302,7 @@ public class AppWidgetHostView extends FrameLayout { * AppWidget provider. Will animate into these new views as needed */ public void updateAppWidget(RemoteViews remoteViews) { if (LOGD) Log.d(TAG, "updateAppWidget called mOld=" + mOld); boolean recycled = false; Loading Loading @@ -324,7 +346,7 @@ public class AppWidgetHostView extends FrameLayout { // layout matches, try recycling it if (content == null && layoutId == mLayoutId) { try { remoteViews.reapply(mContext, mView); remoteViews.reapply(mContext, mView, mOnClickHandler); content = mView; recycled = true; if (LOGD) Log.d(TAG, "was able to recycled existing layout"); Loading @@ -336,7 +358,7 @@ public class AppWidgetHostView extends FrameLayout { // Try normal RemoteView inflation if (content == null) { try { content = remoteViews.apply(mContext, this); content = remoteViews.apply(mContext, this, mOnClickHandler); if (LOGD) Log.d(TAG, "had to inflate new layout"); } catch (RuntimeException e) { exception = e; Loading
core/java/android/widget/RemoteViews.java +44 −47 Original line number Diff line number Diff line Loading @@ -1671,11 +1671,7 @@ public class RemoteViews implements Parcelable, Filter { * layout direction), or 0 * @param top The id of a drawable to place above the text, or 0 * @param end The id of a drawable to place after the text, or 0 <<<<<<< HEAD * @param bottom The id of a drawable to place below the text, or 0 ======= * @param bottom The id of a drawable to place below the text, or 0 >>>>>>> 0a43f67e */ public void setTextViewCompoundDrawablesRelative(int viewId, int start, int top, int end, int bottom) { addAction(new TextViewDrawableAction(viewId, true, start, top, end, bottom)); Loading Loading @@ -2114,7 +2110,7 @@ public class RemoteViews implements Parcelable, Filter { * @return The inflated view hierarchy */ public View apply(Context context, ViewGroup parent) { return apply(context, parent, DEFAULT_ON_CLICK_HANDLER); return apply(context, parent, null); } /** @hide */ Loading Loading @@ -2147,7 +2143,7 @@ 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); reapply(context, v, null); } /** @hide */ Loading @@ -2170,6 +2166,7 @@ public class RemoteViews implements Parcelable, Filter { private void performApply(View v, ViewGroup parent, OnClickHandler handler) { if (mActions != null) { handler = handler == null ? DEFAULT_ON_CLICK_HANDLER : handler; final int count = mActions.size(); for (int i = 0; i < count; i++) { Action a = mActions.get(i); Loading