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

Commit 37432444 authored by Samuel Fufa's avatar Samuel Fufa
Browse files

Initial setup for widgets in Search

LiveSearchManager creates AppWidgetHost when user starts a new search session and destroys it when user returns to home. In addition, it also manages the creation and caching of PlaceholderSearchWidget which can be used to create AppWidgetHostViews.
Bug: 168321831
Test: Manual

Change-Id: I06a893028e55aa6e0702a4f1cd7a2edbb1f61671
parent 984e0d0a
Loading
Loading
Loading
Loading
+5 −0
Original line number Original line Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<com.android.launcher3.views.SearchResultWidget android:layout_height="wrap_content"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:gravity="center"
    android:layout_width="match_parent" />
 No newline at end of file
+1 −1
Original line number Original line Diff line number Diff line
@@ -36,7 +36,7 @@ public class AppWidgetResizeFrame extends AbstractFloatingView implements View.O
    private static final Rect sTmpRect = new Rect();
    private static final Rect sTmpRect = new Rect();


    // Represents the cell size on the grid in the two orientations.
    // Represents the cell size on the grid in the two orientations.
    private static final MainThreadInitializedObject<Point[]> CELL_SIZE =
    public static final MainThreadInitializedObject<Point[]> CELL_SIZE =
            new MainThreadInitializedObject<>(c -> {
            new MainThreadInitializedObject<>(c -> {
                InvariantDeviceProfile inv = LauncherAppState.getIDP(c);
                InvariantDeviceProfile inv = LauncherAppState.getIDP(c);
                return new Point[] {inv.landscapeProfile.getCellSize(),
                return new Point[] {inv.landscapeProfile.getCellSize(),
+10 −0
Original line number Original line Diff line number Diff line
@@ -111,6 +111,7 @@ import com.android.launcher3.allapps.AllAppsContainerView;
import com.android.launcher3.allapps.AllAppsStore;
import com.android.launcher3.allapps.AllAppsStore;
import com.android.launcher3.allapps.AllAppsTransitionController;
import com.android.launcher3.allapps.AllAppsTransitionController;
import com.android.launcher3.allapps.DiscoveryBounce;
import com.android.launcher3.allapps.DiscoveryBounce;
import com.android.launcher3.allapps.search.LiveSearchManager;
import com.android.launcher3.anim.PropertyListBuilder;
import com.android.launcher3.anim.PropertyListBuilder;
import com.android.launcher3.compat.AccessibilityManagerCompat;
import com.android.launcher3.compat.AccessibilityManagerCompat;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.config.FeatureFlags;
@@ -276,6 +277,8 @@ public class Launcher extends StatefulActivity<LauncherState> implements Launche


    private LifecycleRegistry mLifecycleRegistry;
    private LifecycleRegistry mLifecycleRegistry;


    private LiveSearchManager mLiveSearchManager;

    @Thunk
    @Thunk
    Workspace mWorkspace;
    Workspace mWorkspace;
    @Thunk
    @Thunk
@@ -389,6 +392,8 @@ public class Launcher extends StatefulActivity<LauncherState> implements Launche
        mIconCache = app.getIconCache();
        mIconCache = app.getIconCache();
        mAccessibilityDelegate = new LauncherAccessibilityDelegate(this);
        mAccessibilityDelegate = new LauncherAccessibilityDelegate(this);


        mLiveSearchManager = new LiveSearchManager(this);

        mDragController = new DragController(this);
        mDragController = new DragController(this);
        mAllAppsController = new AllAppsTransitionController(this);
        mAllAppsController = new AllAppsTransitionController(this);
        mStateManager = new StateManager<>(this, NORMAL);
        mStateManager = new StateManager<>(this, NORMAL);
@@ -492,6 +497,10 @@ public class Launcher extends StatefulActivity<LauncherState> implements Launche
        return mLifecycleRegistry;
        return mLifecycleRegistry;
    }
    }


    public LiveSearchManager getLiveSearchManager() {
        return mLiveSearchManager;
    }

    protected LauncherOverlayManager getDefaultOverlay() {
    protected LauncherOverlayManager getDefaultOverlay() {
        return new LauncherOverlayManager() { };
        return new LauncherOverlayManager() { };
    }
    }
@@ -1583,6 +1592,7 @@ public class Launcher extends StatefulActivity<LauncherState> implements Launche
        mAppTransitionManager.unregisterRemoteAnimations();
        mAppTransitionManager.unregisterRemoteAnimations();
        mUserChangedCallbackCloseable.close();
        mUserChangedCallbackCloseable.close();
        mLifecycleRegistry.setCurrentState(Lifecycle.State.DESTROYED);
        mLifecycleRegistry.setCurrentState(Lifecycle.State.DESTROYED);
        mLiveSearchManager.stop();
    }
    }


    public LauncherAccessibilityDelegate getAccessibilityDelegate() {
    public LauncherAccessibilityDelegate getAccessibilityDelegate() {
+12 −1
Original line number Original line Diff line number Diff line
@@ -46,6 +46,7 @@ import com.android.launcher3.allapps.search.SearchSectionInfo;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.model.data.AppInfo;
import com.android.launcher3.model.data.AppInfo;
import com.android.launcher3.util.PackageManagerHelper;
import com.android.launcher3.util.PackageManagerHelper;
import com.android.launcher3.views.SearchResultWidget;
import com.android.systemui.plugins.shared.SearchTarget;
import com.android.systemui.plugins.shared.SearchTarget;


import java.util.List;
import java.util.List;
@@ -89,6 +90,8 @@ public class AllAppsGridAdapter extends


    public static final int VIEW_TYPE_SEARCH_ICON = 1 << 14;
    public static final int VIEW_TYPE_SEARCH_ICON = 1 << 14;


    public static final int VIEW_TYPE_SEARCH_WIDGET_LIVE = 1 << 15;

    // Common view type masks
    // Common view type masks
    public static final int VIEW_TYPE_MASK_DIVIDER = VIEW_TYPE_ALL_APPS_DIVIDER;
    public static final int VIEW_TYPE_MASK_DIVIDER = VIEW_TYPE_ALL_APPS_DIVIDER;
    public static final int VIEW_TYPE_MASK_ICON = VIEW_TYPE_ICON | VIEW_TYPE_SEARCH_ICON;
    public static final int VIEW_TYPE_MASK_ICON = VIEW_TYPE_ICON | VIEW_TYPE_SEARCH_ICON;
@@ -181,7 +184,8 @@ public class AllAppsGridAdapter extends
                    || viewType == VIEW_TYPE_SEARCH_THUMBNAIL
                    || viewType == VIEW_TYPE_SEARCH_THUMBNAIL
                    || viewType == VIEW_TYPE_SEARCH_ICON_ROW
                    || viewType == VIEW_TYPE_SEARCH_ICON_ROW
                    || viewType == VIEW_TYPE_SEARCH_ICON
                    || viewType == VIEW_TYPE_SEARCH_ICON
                    || viewType == VIEW_TYPE_SEARCH_SUGGEST;
                    || viewType == VIEW_TYPE_SEARCH_SUGGEST
                    || viewType == VIEW_TYPE_SEARCH_WIDGET_LIVE;
        }
        }
    }
    }


@@ -427,6 +431,9 @@ public class AllAppsGridAdapter extends
            case VIEW_TYPE_SEARCH_SUGGEST:
            case VIEW_TYPE_SEARCH_SUGGEST:
                return new ViewHolder(mLayoutInflater.inflate(
                return new ViewHolder(mLayoutInflater.inflate(
                        R.layout.search_result_suggest, parent, false));
                        R.layout.search_result_suggest, parent, false));
            case VIEW_TYPE_SEARCH_WIDGET_LIVE:
                return new ViewHolder(mLayoutInflater.inflate(
                        R.layout.search_result_widget_live, parent, false));
            default:
            default:
                throw new RuntimeException("Unexpected view type");
                throw new RuntimeException("Unexpected view type");
        }
        }
@@ -469,6 +476,7 @@ public class AllAppsGridAdapter extends
            case VIEW_TYPE_SEARCH_PEOPLE:
            case VIEW_TYPE_SEARCH_PEOPLE:
            case VIEW_TYPE_SEARCH_THUMBNAIL:
            case VIEW_TYPE_SEARCH_THUMBNAIL:
            case VIEW_TYPE_SEARCH_SUGGEST:
            case VIEW_TYPE_SEARCH_SUGGEST:
            case VIEW_TYPE_SEARCH_WIDGET_LIVE:
                SearchAdapterItem item =
                SearchAdapterItem item =
                        (SearchAdapterItem) mApps.getAdapterItems().get(position);
                        (SearchAdapterItem) mApps.getAdapterItems().get(position);
                SearchTargetHandler payloadResultView = (SearchTargetHandler) holder.itemView;
                SearchTargetHandler payloadResultView = (SearchTargetHandler) holder.itemView;
@@ -487,6 +495,9 @@ public class AllAppsGridAdapter extends
        if (holder.itemView instanceof AllAppsSectionDecorator.SelfDecoratingView) {
        if (holder.itemView instanceof AllAppsSectionDecorator.SelfDecoratingView) {
            ((AllAppsSectionDecorator.SelfDecoratingView) holder.itemView).removeDecoration();
            ((AllAppsSectionDecorator.SelfDecoratingView) holder.itemView).removeDecoration();
        }
        }
        if (holder.itemView instanceof SearchResultWidget) {
            ((SearchResultWidget) holder.itemView).removeListener();
        }
    }
    }


    @Override
    @Override
+4 −0
Original line number Original line Diff line number Diff line
@@ -264,11 +264,15 @@ public class AllAppsTransitionController implements StateHandler<LauncherState>,
        if (FeatureFlags.ENABLE_DEVICE_SEARCH.get() && BuildCompat.isAtLeastR()) {
        if (FeatureFlags.ENABLE_DEVICE_SEARCH.get() && BuildCompat.isAtLeastR()) {
            mInsetController.onAnimationEnd(mProgress);
            mInsetController.onAnimationEnd(mProgress);
            if (Float.compare(mProgress, 0f) == 0) {
            if (Float.compare(mProgress, 0f) == 0) {
                mLauncher.getLiveSearchManager().start();
                EditText editText = mAppsView.getSearchUiManager().getEditText();
                EditText editText = mAppsView.getSearchUiManager().getEditText();
                if (editText != null) {
                if (editText != null) {
                    editText.requestFocus();
                    editText.requestFocus();
                }
                }
            }
            }
            else {
                mLauncher.getLiveSearchManager().stop();
            }
            // TODO: should make the controller hide synchronously
            // TODO: should make the controller hide synchronously
        }
        }
    }
    }
Loading