Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 531fc498 authored by Will Leshner's avatar Will Leshner
Browse files

Handle widget taps in WidgetPickerActivity.

Bug: 307306823
Test: atest Launcher3Tests
Flag: NA
Change-Id: I05cd42eae91447cfe99165096a735f6e04257203
parent 23ef0eda
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -22,7 +22,10 @@ import static android.view.WindowInsets.Type.statusBars;
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
import static com.android.launcher3.util.Executors.MODEL_EXECUTOR;

import android.appwidget.AppWidgetProviderInfo;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.WindowInsetsController;
import android.view.WindowManager;

@@ -32,6 +35,7 @@ import com.android.launcher3.dragndrop.SimpleDragLayer;
import com.android.launcher3.model.WidgetsModel;
import com.android.launcher3.popup.PopupDataProvider;
import com.android.launcher3.widget.BaseWidgetSheet;
import com.android.launcher3.widget.WidgetCell;
import com.android.launcher3.widget.model.WidgetsListBaseEntry;
import com.android.launcher3.widget.picker.WidgetsFullSheet;

@@ -81,6 +85,23 @@ public class WidgetPickerActivity extends BaseActivity {
        return mDragLayer;
    }

    @Override
    public View.OnClickListener getItemOnClickListener() {
        return v -> {
            final AppWidgetProviderInfo info =
                    (v instanceof WidgetCell) ? ((WidgetCell) v).getWidgetItem().widgetInfo : null;
            if (info == null || info.provider == null) {
                return;
            }

            setResult(RESULT_OK, new Intent()
                    .putExtra(Intent.EXTRA_COMPONENT_NAME, info.provider)
                    .putExtra(Intent.EXTRA_USER, info.getProfile()));

            finish();
        };
    }

    private void refreshAndBindWidgets() {
        MODEL_EXECUTOR.execute(() -> {
            LauncherAppState app = LauncherAppState.getInstance(this);
+5 −0
Original line number Diff line number Diff line
@@ -147,6 +147,11 @@ public class WidgetCell extends LinearLayout {
        return mAppWidgetHostViewScale;
    }

    /** Returns the {@link WidgetItem} for this {@link WidgetCell}. */
    public WidgetItem getWidgetItem() {
        return mItem;
    }

    /**
     * Called to clear the view and free attached resources. (e.g., {@link Bitmap}
     */