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

Commit c13700b6 authored by Brian Isganitis's avatar Brian Isganitis Committed by Android (Google) Code Review
Browse files

Merge changes I2ede15d8,I86a0ffc0,I7c5fdbc7

* changes:
  Do not scale down taskbar all apps icons.
  Inflate taskbar all apps in abstract slide-in view.
  Introduce initial A-Z app drawer to taskbar.
parents 5f0dbb68 25b2ac85
Loading
Loading
Loading
Loading
+50 −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.TaskbarAllAppsSlideInView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.android.launcher3.taskbar.TaskbarAllAppsContainerView
        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>
</com.android.launcher3.taskbar.TaskbarAllAppsSlideInView>
+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);
+36 −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;
@@ -153,6 +155,11 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ
        FrameLayout navButtonsView = mDragLayer.findViewById(R.id.navbuttons_view);
        StashedHandleView stashedHandleView = mDragLayer.findViewById(R.id.stashed_handle);

        TaskbarAllAppsSlideInView appsSlideInView =
                (TaskbarAllAppsSlideInView) mLayoutInflater.inflate(R.layout.taskbar_all_apps,
                        mDragLayer, false);
        mAppsView = appsSlideInView.getAppsView();

        Display display = windowContext.getDisplay();
        Context c = display.getDisplayId() == Display.DEFAULT_DISPLAY
                ? windowContext.getApplicationContext()
@@ -189,7 +196,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, appsSlideInView));
    }

    public void init(TaskbarSharedState sharedState) {
@@ -226,6 +234,7 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ
        mDeviceProfile.updateIconSize(1, resources);
        float iconScale = taskbarIconSize / mDeviceProfile.iconSizePx;
        mDeviceProfile.updateIconSize(iconScale, resources);
        mDeviceProfile.updateAllAppsIconSize(1, resources); // Leave all apps unscaled.
    }

    /** Creates LayoutParams for adding a view directly to WindowManager as a new window */
@@ -279,6 +288,11 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ
        return mDragLayer;
    }

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

    @Override
    public DeviceProfile getDeviceProfile() {
        return mDeviceProfile;
@@ -619,11 +633,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,6 +644,8 @@ 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);
        }
@@ -640,6 +653,24 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ
        AbstractFloatingView.closeAllOpenViews(this);
    }

    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);
        }
    }

    /**
     * Called when we detect a long press in the nav region before passing the gesture slop.
     * @return Whether taskbar handled the long press, and thus should cancel the gesture.
+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);
    }
}
+101 −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 static com.android.launcher3.anim.Interpolators.AGGRESSIVE_EASE;

import android.animation.PropertyValuesHolder;
import android.content.Context;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.MotionEvent;

import com.android.launcher3.Insettable;
import com.android.launcher3.R;
import com.android.launcher3.views.AbstractSlideInView;

/** Wrapper for taskbar all apps with slide-in behavior. */
public class TaskbarAllAppsSlideInView extends
        AbstractSlideInView<TaskbarActivityContext> implements Insettable {

    private static final int DEFAULT_OPEN_DURATION = 500;
    private static final int DEFAULT_CLOSE_DURATION = 200;

    private TaskbarAllAppsContainerView mAppsView;

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

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

    /** Opens the all apps view. */
    public void show() {
        if (mIsOpen || mOpenCloseAnimator.isRunning()) {
            return;
        }
        mIsOpen = true;
        attachToContainer();

        mOpenCloseAnimator.setValues(
                PropertyValuesHolder.ofFloat(TRANSLATION_SHIFT, TRANSLATION_SHIFT_OPENED));
        mOpenCloseAnimator.setInterpolator(AGGRESSIVE_EASE);
        mOpenCloseAnimator.setDuration(DEFAULT_OPEN_DURATION).start();
    }

    /** The apps container inside this view. */
    public TaskbarAllAppsContainerView getAppsView() {
        return mAppsView;
    }

    @Override
    protected void handleClose(boolean animate) {
        handleClose(animate, DEFAULT_CLOSE_DURATION);
    }

    @Override
    protected boolean isOfType(int type) {
        return (type & TYPE_TASKBAR_ALL_APPS) != 0;
    }

    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
        mAppsView = findViewById(R.id.apps_view);
        mContent = mAppsView;
    }

    @Override
    protected int getScrimColor(Context context) {
        return context.getColor(R.color.widgets_picker_scrim);
    }

    @Override
    public boolean onControllerInterceptTouchEvent(MotionEvent ev) {
        if (ev.getAction() == MotionEvent.ACTION_DOWN) {
            mNoIntercept = !mAppsView.shouldContainerScroll(ev);
        }
        return super.onControllerInterceptTouchEvent(ev);
    }

    @Override
    public void setInsets(Rect insets) {
        mAppsView.setInsets(insets);
    }
}
Loading