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

Commit a204de7d authored by Samuel Fufa's avatar Samuel Fufa Committed by Android (Google) Code Review
Browse files

Merge "Initial setup for widgets in Search" into ub-launcher3-master

parents 003859cd 37432444
Loading
Loading
Loading
Loading
+5 −0
Original line number 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 Diff line number Diff line
@@ -36,7 +36,7 @@ public class AppWidgetResizeFrame extends AbstractFloatingView implements View.O
    private static final Rect sTmpRect = new Rect();

    // 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 -> {
                InvariantDeviceProfile inv = LauncherAppState.getIDP(c);
                return new Point[] {inv.landscapeProfile.getCellSize(),
+10 −0
Original line number 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.AllAppsTransitionController;
import com.android.launcher3.allapps.DiscoveryBounce;
import com.android.launcher3.allapps.search.LiveSearchManager;
import com.android.launcher3.anim.PropertyListBuilder;
import com.android.launcher3.compat.AccessibilityManagerCompat;
import com.android.launcher3.config.FeatureFlags;
@@ -276,6 +277,8 @@ public class Launcher extends StatefulActivity<LauncherState> implements Launche

    private LifecycleRegistry mLifecycleRegistry;

    private LiveSearchManager mLiveSearchManager;

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

        mLiveSearchManager = new LiveSearchManager(this);

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

    public LiveSearchManager getLiveSearchManager() {
        return mLiveSearchManager;
    }

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

    public LauncherAccessibilityDelegate getAccessibilityDelegate() {
+12 −1
Original line number 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.model.data.AppInfo;
import com.android.launcher3.util.PackageManagerHelper;
import com.android.launcher3.views.SearchResultWidget;
import com.android.systemui.plugins.shared.SearchTarget;

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_WIDGET_LIVE = 1 << 15;

    // Common view type masks
    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;
@@ -181,7 +184,8 @@ public class AllAppsGridAdapter extends
                    || viewType == VIEW_TYPE_SEARCH_THUMBNAIL
                    || viewType == VIEW_TYPE_SEARCH_ICON_ROW
                    || 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:
                return new ViewHolder(mLayoutInflater.inflate(
                        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:
                throw new RuntimeException("Unexpected view type");
        }
@@ -469,6 +476,7 @@ public class AllAppsGridAdapter extends
            case VIEW_TYPE_SEARCH_PEOPLE:
            case VIEW_TYPE_SEARCH_THUMBNAIL:
            case VIEW_TYPE_SEARCH_SUGGEST:
            case VIEW_TYPE_SEARCH_WIDGET_LIVE:
                SearchAdapterItem item =
                        (SearchAdapterItem) mApps.getAdapterItems().get(position);
                SearchTargetHandler payloadResultView = (SearchTargetHandler) holder.itemView;
@@ -487,6 +495,9 @@ public class AllAppsGridAdapter extends
        if (holder.itemView instanceof AllAppsSectionDecorator.SelfDecoratingView) {
            ((AllAppsSectionDecorator.SelfDecoratingView) holder.itemView).removeDecoration();
        }
        if (holder.itemView instanceof SearchResultWidget) {
            ((SearchResultWidget) holder.itemView).removeListener();
        }
    }

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