use of com.android.launcher3.model.WidgetItem in project android_packages_apps_Launcher3 by crdroidandroid.
the class WidgetsFullSheet method onRecommendedWidgetsBound.
@Override
public void onRecommendedWidgetsBound() {
if (mIsInSearchMode) {
return;
}
List<WidgetItem> recommendedWidgets = mActivityContext.getPopupDataProvider().getRecommendedWidgets();
WidgetsRecommendationTableLayout table = mSearchAndRecommendationViewHolder.mRecommendedWidgetsTable;
if (recommendedWidgets.size() > 0) {
float noWidgetsViewHeight = 0;
if (mIsNoWidgetsViewNeeded) {
// Make sure recommended section leaves enough space for noWidgetsView.
Rect noWidgetsViewTextBounds = new Rect();
mNoWidgetsView.getPaint().getTextBounds(mNoWidgetsView.getText().toString(), /* start= */
0, mNoWidgetsView.getText().length(), noWidgetsViewTextBounds);
noWidgetsViewHeight = noWidgetsViewTextBounds.height();
}
doMeasure(makeMeasureSpec(mActivityContext.getDeviceProfile().availableWidthPx, MeasureSpec.EXACTLY), makeMeasureSpec(mActivityContext.getDeviceProfile().availableHeightPx, MeasureSpec.EXACTLY));
float maxTableHeight = (mContent.getMeasuredHeight() - mTabsHeight - mViewPagerTopPadding - getHeaderViewHeight() - noWidgetsViewHeight) * RECOMMENDATION_TABLE_HEIGHT_RATIO;
List<ArrayList<WidgetItem>> recommendedWidgetsInTable = WidgetsTableUtils.groupWidgetItemsIntoTable(recommendedWidgets, mMaxSpansPerRow);
table.setRecommendedWidgets(recommendedWidgetsInTable, maxTableHeight);
} else {
table.setVisibility(GONE);
}
}
use of com.android.launcher3.model.WidgetItem in project android_packages_apps_Launcher3 by crdroidandroid.
the class WidgetsModel method update.
/**
* @param packageUser If null, all widgets and shortcuts are updated and returned, otherwise
* only widgets and shortcuts associated with the package/user are.
*/
public List<ComponentWithLabelAndIcon> update(LauncherAppState app, @Nullable PackageUserKey packageUser) {
Preconditions.assertWorkerThread();
Context context = app.getContext();
final ArrayList<WidgetItem> widgetsAndShortcuts = new ArrayList<>();
List<ComponentWithLabelAndIcon> updatedItems = new ArrayList<>();
try {
InvariantDeviceProfile idp = app.getInvariantDeviceProfile();
PackageManager pm = app.getContext().getPackageManager();
// Widgets
WidgetManagerHelper widgetManager = new WidgetManagerHelper(context);
for (AppWidgetProviderInfo widgetInfo : widgetManager.getAllProviders(packageUser)) {
LauncherAppWidgetProviderInfo launcherWidgetInfo = LauncherAppWidgetProviderInfo.fromProviderInfo(context, widgetInfo);
widgetsAndShortcuts.add(new WidgetItem(launcherWidgetInfo, idp, app.getIconCache()));
updatedItems.add(launcherWidgetInfo);
}
// Shortcuts
for (ShortcutConfigActivityInfo info : queryList(context, packageUser)) {
widgetsAndShortcuts.add(new WidgetItem(info, app.getIconCache(), pm));
updatedItems.add(info);
}
setWidgetsAndShortcuts(widgetsAndShortcuts, app, packageUser);
} catch (Exception e) {
if (!FeatureFlags.IS_STUDIO_BUILD && Utilities.isBinderSizeError(e)) {
// the returned value may be incomplete and will not be refreshed until the next
// time Launcher starts.
// TODO: after figuring out a repro step, introduce a dirty bit to check when
// onResume is called to refresh the widget provider list.
} else {
throw e;
}
}
app.getWidgetCache().removeObsoletePreviews(widgetsAndShortcuts, packageUser);
return updatedItems;
}
use of com.android.launcher3.model.WidgetItem in project android_packages_apps_Launcher3 by crdroidandroid.
the class CachingWidgetPreviewLoaderTest method loadPreviewIntoCache.
private void loadPreviewIntoCache(WidgetItem widgetItem, Size size, Bitmap bitmap) {
reset(mDelegate);
mLoader.loadPreview(mTestActivity, widgetItem, size, ignored -> {
});
verify(mDelegate).loadPreview(any(), any(), any(), mCallbackCaptor.capture());
WidgetPreviewLoadedCallback loaderCallback = mCallbackCaptor.getValue();
loaderCallback.onPreviewLoaded(bitmap);
}
use of com.android.launcher3.model.WidgetItem in project android_packages_apps_Launcher3 by crdroidandroid.
the class WidgetsDiffReporterTest method createWidgetsContentEntry.
private WidgetsListContentEntry createWidgetsContentEntry(String packageName, String appName, int numOfWidgets) {
List<WidgetItem> widgetItems = generateWidgetItems(packageName, numOfWidgets);
PackageItemInfo pInfo = createPackageItemInfo(packageName, appName, widgetItems.get(0).user);
return new WidgetsListContentEntry(pInfo, /* titleSectionName= */
"", widgetItems);
}
use of com.android.launcher3.model.WidgetItem in project android_packages_apps_Launcher3 by crdroidandroid.
the class WidgetsDiffReporterTest method createWidgetsHeaderEntry.
private WidgetsListHeaderEntry createWidgetsHeaderEntry(String packageName, String appName, int numOfWidgets) {
List<WidgetItem> widgetItems = generateWidgetItems(packageName, numOfWidgets);
PackageItemInfo pInfo = createPackageItemInfo(packageName, appName, widgetItems.get(0).user);
return new WidgetsListHeaderEntry(pInfo, /* titleSectionName= */
"", widgetItems);
}
Aggregations