Search in sources :

Example 56 with Widget

use of com.android.launcher3.tapl.Widget in project android_packages_apps_Launcher3 by AOSPA.

the class WidgetsBottomSheet method onWidgetsBound.

@Override
public void onWidgetsBound() {
    List<WidgetItem> widgets = mActivityContext.getPopupDataProvider().getWidgetsForPackageUser(new PackageUserKey(mOriginalItemInfo.getTargetComponent().getPackageName(), mOriginalItemInfo.user));
    TableLayout widgetsTable = findViewById(R.id.widgets_table);
    widgetsTable.removeAllViews();
    WidgetsTableUtils.groupWidgetItemsIntoTableWithReordering(widgets, mMaxHorizontalSpan).forEach(row -> {
        TableRow tableRow = new TableRow(getContext());
        tableRow.setGravity(Gravity.TOP);
        row.forEach(widgetItem -> {
            WidgetCell widget = addItemCell(tableRow);
            widget.applyFromCellItem(widgetItem);
        });
        widgetsTable.addView(tableRow);
    });
}
Also used : TableRow(android.widget.TableRow) WidgetItem(com.android.launcher3.model.WidgetItem) PackageUserKey(com.android.launcher3.util.PackageUserKey) TableLayout(android.widget.TableLayout)

Example 57 with Widget

use of com.android.launcher3.tapl.Widget in project android_packages_apps_Launcher3 by AOSPA.

the class WidgetsListAdapter method setWidgets.

/**
 * Updates the widget list based on {@code tempEntries}.
 */
public void setWidgets(List<WidgetsListBaseEntry> tempEntries) {
    mAllEntries.clear();
    mAllEntries.add(new WidgetListSpaceEntry());
    tempEntries.stream().sorted(mRowComparator).forEach(mAllEntries::add);
    if (shouldClearVisibleEntries()) {
        mVisibleEntries.clear();
    }
    updateVisibleEntries();
}
Also used : WidgetListSpaceEntry(com.android.launcher3.widget.model.WidgetListSpaceEntry)

Example 58 with Widget

use of com.android.launcher3.tapl.Widget in project android_packages_apps_Launcher3 by AOSPA.

the class WidgetsFullSheet method setUpEducationViewsIfNeeded.

private void setUpEducationViewsIfNeeded() {
    if (!hasSeenEducationDialog()) {
        postDelayed(() -> {
            WidgetsEduView eduDialog = showEducationDialog();
            eduDialog.addOnCloseListener(() -> {
                if (!hasSeenEducationTip()) {
                    addOnLayoutChangeListener(mLayoutChangeListenerToShowTips);
                    // Call #requestLayout() to trigger layout change listener in order to show
                    // arrow tip immediately if there is a widget to show it on.
                    requestLayout();
                }
            });
        }, EDUCATION_DIALOG_DELAY_MS);
    } else if (!hasSeenEducationTip()) {
        addOnLayoutChangeListener(mLayoutChangeListenerToShowTips);
    }
}
Also used : WidgetsEduView(com.android.launcher3.views.WidgetsEduView)

Example 59 with Widget

use of com.android.launcher3.tapl.Widget in project android_packages_apps_Launcher3 by AOSPA.

the class WidgetsListTableViewHolderBinder method bindViewHolder.

@Override
public void bindViewHolder(WidgetsRowViewHolder holder, WidgetsListContentEntry entry, @ListPosition int position, List<Object> payloads) {
    for (Object payload : payloads) {
        Pair<WidgetItem, Bitmap> pair = (Pair) payload;
        holder.previewCache.put(pair.first, pair.second);
    }
    WidgetsListTableView table = holder.tableContainer;
    if (DEBUG) {
        Log.d(TAG, String.format("onBindViewHolder [widget#=%d, table.getChildCount=%d]", entry.mWidgets.size(), table.getChildCount()));
    }
    table.setListDrawableState(((position & POSITION_LAST) != 0) ? LAST : MIDDLE);
    List<ArrayList<WidgetItem>> widgetItemsTable = WidgetsTableUtils.groupWidgetItemsIntoTableWithReordering(entry.mWidgets, entry.getMaxSpanSizeInCells());
    recycleTableBeforeBinding(table, widgetItemsTable);
    // Bind the widget items.
    for (int i = 0; i < widgetItemsTable.size(); i++) {
        List<WidgetItem> widgetItemsPerRow = widgetItemsTable.get(i);
        for (int j = 0; j < widgetItemsPerRow.size(); j++) {
            TableRow row = (TableRow) table.getChildAt(i);
            row.setVisibility(View.VISIBLE);
            WidgetCell widget = (WidgetCell) row.getChildAt(j);
            widget.clear();
            WidgetItem widgetItem = widgetItemsPerRow.get(j);
            widget.setVisibility(View.VISIBLE);
            // When preview loads, notify adapter to rebind the item and possibly animate
            widget.applyFromCellItem(widgetItem, 1f, bitmap -> {
                if (holder.getBindingAdapter() != null) {
                    holder.getBindingAdapter().notifyItemChanged(holder.getBindingAdapterPosition(), Pair.create(widgetItem, bitmap));
                }
            }, holder.previewCache.get(widgetItem));
        }
    }
}
Also used : Bitmap(android.graphics.Bitmap) TableRow(android.widget.TableRow) ArrayList(java.util.ArrayList) WidgetItem(com.android.launcher3.model.WidgetItem) WidgetCell(com.android.launcher3.widget.WidgetCell) Pair(android.util.Pair)

Example 60 with Widget

use of com.android.launcher3.tapl.Widget in project android_packages_apps_Launcher3 by AOSPA.

the class WidgetsListTableViewHolderBinder method unbindViewHolder.

@Override
public void unbindViewHolder(WidgetsRowViewHolder holder) {
    int numOfRows = holder.tableContainer.getChildCount();
    holder.previewCache.clear();
    for (int i = 0; i < numOfRows; i++) {
        TableRow tableRow = (TableRow) holder.tableContainer.getChildAt(i);
        int numOfCols = tableRow.getChildCount();
        for (int j = 0; j < numOfCols; j++) {
            WidgetCell widget = (WidgetCell) tableRow.getChildAt(j);
            widget.clear();
        }
    }
}
Also used : TableRow(android.widget.TableRow) WidgetCell(com.android.launcher3.widget.WidgetCell)

Aggregations

LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)105 Test (org.junit.Test)87 LauncherAppWidgetProviderInfo (com.android.launcher3.widget.LauncherAppWidgetProviderInfo)71 LauncherAppWidgetHostView (com.android.launcher3.widget.LauncherAppWidgetHostView)66 Point (android.graphics.Point)62 ArrayList (java.util.ArrayList)60 AppWidgetProviderInfo (android.appwidget.AppWidgetProviderInfo)56 View (android.view.View)55 LargeTest (androidx.test.filters.LargeTest)55 ComponentName (android.content.ComponentName)53 AppWidgetHostView (android.appwidget.AppWidgetHostView)52 Bundle (android.os.Bundle)50 WidgetItem (com.android.launcher3.model.WidgetItem)49 AbstractLauncherUiTest (com.android.launcher3.ui.AbstractLauncherUiTest)49 PendingAppWidgetHostView (com.android.launcher3.widget.PendingAppWidgetHostView)47 ItemInfo (com.android.launcher3.model.data.ItemInfo)44 PackageUserKey (com.android.launcher3.util.PackageUserKey)41 PendingAddWidgetInfo (com.android.launcher3.widget.PendingAddWidgetInfo)41 Context (android.content.Context)31 WidgetManagerHelper (com.android.launcher3.widget.WidgetManagerHelper)31