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

Commit 4edf1da6 authored by Brian Isganitis's avatar Brian Isganitis
Browse files

Introduce initial A-Z app drawer to taskbar.

Invoking the drawer is currently hooked up to tapping empty space on the
taskbar. Apps can be launched, and drag-n-drop split screen works. The
drawer can only be dismissed by acting on an app icon or tapping the
taskbar again.

Test: Manual
Bug: 204696617
Change-Id: I7c5fdbc7d54d8209f6f15ef80bfeb5e9b80cf647
parent 65ffe192
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -82,4 +82,8 @@
        android:clipToOutline="true"
        android:layout_gravity="bottom"/>

    <include
        layout="@layout/taskbar_all_apps"
        android:visibility="gone" />

</com.android.launcher3.taskbar.TaskbarDragLayer>
 No newline at end of file
+44 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
     Copyright (C) 2022 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<com.android.launcher3.taskbar.TaskbarAllAppsContainerView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/apps_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:clipChildren="true"
    android:clipToPadding="false"
    android:focusable="false"
    android:saveEnabled="false"
    android:theme="?attr/allAppsTheme">

    <include
        layout="@layout/all_apps_rv_layout"
        android:visibility="gone" />

    <com.android.launcher3.allapps.FloatingHeaderView
        android:id="@+id/all_apps_header"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/search_container_all_apps"
        android:clipToPadding="false"
        android:paddingTop="@dimen/all_apps_header_top_padding"
        android:orientation="vertical">

        <include layout="@layout/all_apps_personal_work_tabs" />
    </com.android.launcher3.allapps.FloatingHeaderView>

    <include layout="@layout/all_apps_fast_scroller" />
</com.android.launcher3.taskbar.TaskbarAllAppsContainerView>
+2 −2
Original line number Diff line number Diff line
@@ -37,8 +37,8 @@ import com.android.launcher3.Utilities;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.logging.InstanceId;
import com.android.launcher3.logging.InstanceIdSequence;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.model.data.ItemInfoWithIcon;
import com.android.launcher3.model.data.WorkspaceItemInfo;
import com.android.launcher3.util.OnboardingPrefs;
import com.android.quickstep.AnimatedFloat;
import com.android.quickstep.RecentsAnimationCallbacks;
@@ -238,7 +238,7 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
    }

    @Override
    public void onTaskbarIconLaunched(WorkspaceItemInfo item) {
    public void onTaskbarIconLaunched(ItemInfo item) {
        InstanceId instanceId = new InstanceIdSequence().newInstanceId();
        mLauncher.logAppLaunch(mControllers.taskbarActivityContext.getStatsLogManager(), item,
                instanceId);
+32 −5
Original line number Diff line number Diff line
@@ -64,6 +64,7 @@ import com.android.launcher3.dot.DotInfo;
import com.android.launcher3.folder.Folder;
import com.android.launcher3.folder.FolderIcon;
import com.android.launcher3.logger.LauncherAtom;
import com.android.launcher3.model.data.AppInfo;
import com.android.launcher3.model.data.FolderInfo;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.model.data.WorkspaceItemInfo;
@@ -100,6 +101,7 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ

    private final LayoutInflater mLayoutInflater;
    private final TaskbarDragLayer mDragLayer;
    private final TaskbarAllAppsContainerView mAppsView;
    private final TaskbarControllers mControllers;

    private DeviceProfile mDeviceProfile;
@@ -152,6 +154,7 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ
        TaskbarScrimView taskbarScrimView = mDragLayer.findViewById(R.id.taskbar_scrim);
        FrameLayout navButtonsView = mDragLayer.findViewById(R.id.navbuttons_view);
        StashedHandleView stashedHandleView = mDragLayer.findViewById(R.id.stashed_handle);
        mAppsView = mDragLayer.findViewById(R.id.apps_view);

        Display display = windowContext.getDisplay();
        Context c = display.getDisplayId() == Display.DEFAULT_DISPLAY
@@ -189,7 +192,8 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ
                new TaskbarEduController(this),
                new TaskbarAutohideSuspendController(this),
                new TaskbarPopupController(this),
                new TaskbarForceVisibleImmersiveController(this));
                new TaskbarForceVisibleImmersiveController(this),
                new TaskbarAllAppsViewController(this, mAppsView));
    }

    public void init(TaskbarSharedState sharedState) {
@@ -279,6 +283,11 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ
        return mDragLayer;
    }

    @Override
    public TaskbarAllAppsContainerView getAppsView() {
        return mAppsView;
    }

    @Override
    public DeviceProfile getDeviceProfile() {
        return mDeviceProfile;
@@ -619,11 +628,8 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ
                        String packageName = intent.getPackage();
                        getSystemService(LauncherApps.class)
                                .startShortcut(packageName, id, null, null, info.user);
                    } else if (info.user.equals(Process.myUserHandle())) {
                        startActivity(intent);
                    } else {
                        getSystemService(LauncherApps.class).startMainActivity(
                                intent.getComponent(), info.user, intent.getSourceBounds(), null);
                        startItemInfoActivity(info);
                    }

                    mControllers.uiController.onTaskbarIconLaunched(info);
@@ -633,11 +639,32 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ
                    Log.e(TAG, "Unable to launch. tag=" + info + " intent=" + intent, e);
                }
            }
        } else if (tag instanceof AppInfo) {
            startItemInfoActivity((AppInfo) tag);
        } else {
            Log.e(TAG, "Unknown type clicked: " + tag);
        }

        AbstractFloatingView.closeAllOpenViews(this);
        mControllers.taskbarAllAppsViewController.hide();
    }

    private void startItemInfoActivity(ItemInfo info) {
        Intent intent = new Intent(info.getIntent())
                .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        try {
            if (info.user.equals(Process.myUserHandle())) {
                // TODO(b/216683257): Use startActivityForResult for search results that require it.
                startActivity(intent);
            } else {
                getSystemService(LauncherApps.class).startMainActivity(
                        intent.getComponent(), info.user, intent.getSourceBounds(), null);
            }
        } catch (NullPointerException | ActivityNotFoundException | SecurityException e) {
            Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT)
                    .show();
            Log.e(TAG, "Unable to launch. tag=" + info + " intent=" + intent, e);
        }
    }

    /**
+86 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.android.launcher3.taskbar;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowInsets;

import androidx.recyclerview.widget.RecyclerView;

import com.android.launcher3.allapps.AllAppsGridAdapter;
import com.android.launcher3.allapps.BaseAllAppsContainerView;
import com.android.launcher3.allapps.search.SearchAdapterProvider;

/** All apps container accessible from taskbar. */
public class TaskbarAllAppsContainerView extends BaseAllAppsContainerView<TaskbarActivityContext> {
    public TaskbarAllAppsContainerView(Context context) {
        this(context, null);
    }

    public TaskbarAllAppsContainerView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public TaskbarAllAppsContainerView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected SearchAdapterProvider<?> createMainAdapterProvider() {
        // Task bar all apps does not yet support search, so this implementation is minimal.
        return new SearchAdapterProvider<TaskbarActivityContext>(mActivityContext) {
            @Override
            public boolean launchHighlightedItem() {
                return false;
            }

            @Override
            public View getHighlightedItem() {
                return null;
            }

            @Override
            public RecyclerView.ItemDecoration getDecorator() {
                return null;
            }

            @Override
            public boolean isViewSupported(int viewType) {
                return false;
            }

            @Override
            public void onBindView(AllAppsGridAdapter.ViewHolder holder, int position) { }

            @Override
            public AllAppsGridAdapter.ViewHolder onCreateViewHolder(LayoutInflater layoutInflater,
                    ViewGroup parent, int viewType) {
                return null;
            }
        };
    }

    @Override
    public WindowInsets onApplyWindowInsets(WindowInsets insets) {
        // TODO(b/204696617): Switch to status bar insets once they work.
        setInsets(insets.getInsets(WindowInsets.Type.tappableElement()).toRect());
        return super.onApplyWindowInsets(insets);
    }
}
Loading