use of android.appwidget.AppWidgetProviderInfo in project Launcher3 by chislon.
the class AppsCustomizePagedView method dumpAppWidgetProviderInfoList.
private void dumpAppWidgetProviderInfoList(String tag, String label, ArrayList<Object> list) {
Log.d(tag, label + " size=" + list.size());
for (Object i : list) {
if (i instanceof AppWidgetProviderInfo) {
AppWidgetProviderInfo info = (AppWidgetProviderInfo) i;
Log.d(tag, " label=\"" + info.label + "\" previewImage=" + info.previewImage + " resizeMode=" + info.resizeMode + " configure=" + info.configure + " initialLayout=" + info.initialLayout + " minWidth=" + info.minWidth + " minHeight=" + info.minHeight);
} else if (i instanceof ResolveInfo) {
ResolveInfo info = (ResolveInfo) i;
Log.d(tag, " label=\"" + info.loadLabel(mPackageManager) + "\" icon=" + info.icon);
}
}
}
use of android.appwidget.AppWidgetProviderInfo in project Launcher3 by chislon.
the class LauncherTransitionable method bindAppWidget.
/**
* Add the views for a widget to the workspace.
*
* Implementation of the method from LauncherModel.Callbacks.
*/
public void bindAppWidget(final LauncherAppWidgetInfo item) {
Runnable r = new Runnable() {
public void run() {
bindAppWidget(item);
}
};
if (waitUntilResume(r)) {
return;
}
final long start = DEBUG_WIDGETS ? SystemClock.uptimeMillis() : 0;
if (DEBUG_WIDGETS) {
Log.d(TAG, "bindAppWidget: " + item);
}
final Workspace workspace = mWorkspace;
final int appWidgetId = item.appWidgetId;
final AppWidgetProviderInfo appWidgetInfo = mAppWidgetManager.getAppWidgetInfo(appWidgetId);
if (DEBUG_WIDGETS) {
Log.d(TAG, "bindAppWidget: id=" + item.appWidgetId + " belongs to component " + appWidgetInfo.provider);
}
item.hostView = mAppWidgetHost.createView(this, appWidgetId, appWidgetInfo);
item.hostView.setTag(item);
item.onBindAppWidget(this);
workspace.addInScreen(item.hostView, item.container, item.screenId, item.cellX, item.cellY, item.spanX, item.spanY, false);
addWidgetToAutoAdvanceIfNeeded(item.hostView, appWidgetInfo);
workspace.requestLayout();
if (DEBUG_WIDGETS) {
Log.d(TAG, "bound widget id=" + item.appWidgetId + " in " + (SystemClock.uptimeMillis() - start) + "ms");
}
}
use of android.appwidget.AppWidgetProviderInfo in project Launcher3 by chislon.
the class LauncherBackupHelper method packWidget.
/**
* Serialize a widget for persistence, including a checksum wrapper.
*/
private byte[] packWidget(int dpi, WidgetPreviewLoader previewLoader, IconCache iconCache, ComponentName provider) {
final AppWidgetProviderInfo info = findAppWidgetProviderInfo(provider);
Widget widget = new Widget();
widget.provider = provider.flattenToShortString();
widget.label = info.label;
widget.configure = info.configure != null;
if (info.icon != 0) {
widget.icon = new Resource();
Drawable fullResIcon = iconCache.getFullResIcon(provider.getPackageName(), info.icon);
Bitmap icon = Utilities.createIconBitmap(fullResIcon, mContext);
ByteArrayOutputStream os = new ByteArrayOutputStream();
if (icon.compress(IMAGE_FORMAT, IMAGE_COMPRESSION_QUALITY, os)) {
widget.icon.data = os.toByteArray();
widget.icon.dpi = dpi;
}
}
if (info.previewImage != 0) {
widget.preview = new Resource();
Bitmap preview = previewLoader.generateWidgetPreview(info, null);
ByteArrayOutputStream os = new ByteArrayOutputStream();
if (preview.compress(IMAGE_FORMAT, IMAGE_COMPRESSION_QUALITY, os)) {
widget.preview.data = os.toByteArray();
widget.preview.dpi = dpi;
}
}
return writeCheckedBytes(widget);
}
use of android.appwidget.AppWidgetProviderInfo in project Launcher3 by chislon.
the class LauncherBackupHelper method findAppWidgetProviderInfo.
private AppWidgetProviderInfo findAppWidgetProviderInfo(ComponentName component) {
if (mWidgetMap == null) {
List<AppWidgetProviderInfo> widgets = AppWidgetManager.getInstance(mContext).getInstalledProviders();
mWidgetMap = new HashMap<ComponentName, AppWidgetProviderInfo>(widgets.size());
for (AppWidgetProviderInfo info : widgets) {
mWidgetMap.put(info.provider, info);
}
}
return mWidgetMap.get(component);
}
use of android.appwidget.AppWidgetProviderInfo in project Launcher3 by chislon.
the class AppsCustomizePagedView method onPackagesUpdated.
public void onPackagesUpdated(ArrayList<Object> widgetsAndShortcuts) {
LauncherAppState app = LauncherAppState.getInstance();
DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
// Get the list of widgets and shortcuts
mWidgets.clear();
for (Object o : widgetsAndShortcuts) {
if (o instanceof AppWidgetProviderInfo) {
AppWidgetProviderInfo widget = (AppWidgetProviderInfo) o;
if (!app.shouldShowAppOrWidgetProvider(widget.provider)) {
continue;
}
widget.label = widget.label.trim();
if (widget.minWidth > 0 && widget.minHeight > 0) {
// Ensure that all widgets we show can be added on a workspace of this size
int[] spanXY = Launcher.getSpanForWidget(mLauncher, widget);
int[] minSpanXY = Launcher.getMinSpanForWidget(mLauncher, widget);
int minSpanX = Math.min(spanXY[0], minSpanXY[0]);
int minSpanY = Math.min(spanXY[1], minSpanXY[1]);
if (minSpanX <= (int) grid.numColumns && minSpanY <= (int) grid.numRows) {
mWidgets.add(widget);
} else {
Log.e(TAG, "Widget " + widget.provider + " can not fit on this device (" + widget.minWidth + ", " + widget.minHeight + ")");
}
} else {
Log.e(TAG, "Widget " + widget.provider + " has invalid dimensions (" + widget.minWidth + ", " + widget.minHeight + ")");
}
} else {
// just add shortcuts
mWidgets.add(o);
}
}
updatePageCountsAndInvalidateData();
}
Aggregations