/** * Adds a widget to the widget area on the MainActivity * * @param appWidgetId id of widget to add */ private void addWidgetToLauncher(int appWidgetId) { // only add widgets if in minimal mode (may need launcher restart when turned on) if (prefs.getBoolean("history-hide", true)) { // remove empty list view when using widgets, this would block touches on the widget mainActivity.emptyListView.setVisibility(View.GONE); //add widget to view AppWidgetProviderInfo appWidgetInfo = mAppWidgetManager.getAppWidgetInfo(appWidgetId); if (appWidgetInfo == null) { removeAllWidgets(); return; } AppWidgetHostView hostView = mAppWidgetHost.createView(mainActivity, appWidgetId, appWidgetInfo); hostView.setMinimumHeight(appWidgetInfo.minHeight); hostView.setAppWidget(appWidgetId, appWidgetInfo); if (Build.VERSION.SDK_INT > 15) { hostView.updateAppWidgetSize(null, appWidgetInfo.minWidth, appWidgetInfo.minHeight, appWidgetInfo.minWidth, appWidgetInfo.minHeight); } widgetArea.addView(hostView); } // only one widget allowed so widgetUsed is true now, even if not added to view widgetUsed = true; }
static void updateWidgetSizeRanges(AppWidgetHostView widgetView, Launcher launcher, int spanX, int spanY) { getWidgetSizeRanges(launcher, spanX, spanY, sTmpRect); widgetView.updateAppWidgetSize(null, sTmpRect.left, sTmpRect.top, sTmpRect.right, sTmpRect.bottom); }
static void updateWidgetSizeRanges(AppWidgetHostView widgetView, Launcher launcher, int spanX, int spanY) { getWidgetSizeRanges(launcher, spanX, spanY, sTmpRect); widgetView.updateAppWidgetSize(null, sTmpRect.left, sTmpRect.top, sTmpRect.right, sTmpRect.bottom); }
static void updateWidgetSizeRanges(AppWidgetHostView widgetView, Launcher launcher, int spanX, int spanY) { getWidgetSizeRanges(launcher, spanX, spanY, sTmpRect); widgetView.updateAppWidgetSize(null, sTmpRect.left, sTmpRect.top, sTmpRect.right, sTmpRect.bottom); }
static void updateWidgetSizeRanges(AppWidgetHostView widgetView, Launcher launcher, int spanX, int spanY) { getWidgetSizeRanges(launcher, spanX, spanY, sTmpRect); widgetView.updateAppWidgetSize(null, sTmpRect.left, sTmpRect.top, sTmpRect.right, sTmpRect.bottom); }
static void updateWidgetSizeRanges(AppWidgetHostView widgetView, Launcher launcher, int spanX, int spanY) { getWidgetSizeRanges(launcher, spanX, spanY, mTmpRect); widgetView.updateAppWidgetSize(null, mTmpRect.left, mTmpRect.top, mTmpRect.right, mTmpRect.bottom); }
@Override public void run() { appwid.updateAppWidgetSize(null, wDp, hDpf, wDp, hDpf); if (appwid.getParent()!=null) { appwid.getParent().requestLayout(); } appwid.requestLayout(); appwid.postInvalidate(); } }, 1000);