2021-02-02 17:12:08 -08:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2021 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;
|
|
|
|
|
|
2021-05-20 20:18:47 +00:00
|
|
|
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
|
|
|
|
|
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
|
2021-06-04 15:35:46 -07:00
|
|
|
import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL;
|
2021-05-20 20:18:47 +00:00
|
|
|
|
2021-08-30 14:15:56 -07:00
|
|
|
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_FOLDER_OPEN;
|
2021-09-16 21:28:47 -07:00
|
|
|
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED;
|
|
|
|
|
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_QUICK_SETTINGS_EXPANDED;
|
2021-05-20 20:18:47 +00:00
|
|
|
import static com.android.systemui.shared.system.WindowManagerWrapper.ITYPE_BOTTOM_TAPPABLE_ELEMENT;
|
|
|
|
|
import static com.android.systemui.shared.system.WindowManagerWrapper.ITYPE_EXTRA_NAVIGATION_BAR;
|
|
|
|
|
|
2021-10-21 10:45:20 -07:00
|
|
|
import android.animation.AnimatorSet;
|
2021-05-20 20:18:47 +00:00
|
|
|
import android.app.ActivityOptions;
|
|
|
|
|
import android.content.ActivityNotFoundException;
|
|
|
|
|
import android.content.Context;
|
|
|
|
|
import android.content.Intent;
|
2021-11-26 11:38:28 +00:00
|
|
|
import android.content.pm.ActivityInfo.Config;
|
2021-05-20 20:18:47 +00:00
|
|
|
import android.content.pm.LauncherApps;
|
2021-09-01 17:28:13 -07:00
|
|
|
import android.graphics.Insets;
|
2021-05-20 20:18:47 +00:00
|
|
|
import android.graphics.PixelFormat;
|
2021-02-02 17:12:08 -08:00
|
|
|
import android.graphics.Rect;
|
2021-05-20 20:18:47 +00:00
|
|
|
import android.os.Process;
|
|
|
|
|
import android.os.SystemProperties;
|
2021-10-01 11:31:45 -07:00
|
|
|
import android.provider.Settings;
|
2021-05-20 20:18:47 +00:00
|
|
|
import android.util.Log;
|
|
|
|
|
import android.view.ContextThemeWrapper;
|
|
|
|
|
import android.view.Display;
|
|
|
|
|
import android.view.Gravity;
|
2021-02-02 17:12:08 -08:00
|
|
|
import android.view.LayoutInflater;
|
2021-08-13 17:03:55 -07:00
|
|
|
import android.view.RoundedCorner;
|
2021-05-06 12:11:44 -07:00
|
|
|
import android.view.View;
|
2021-05-20 20:18:47 +00:00
|
|
|
import android.view.WindowManager;
|
2021-06-08 20:03:43 -07:00
|
|
|
import android.widget.FrameLayout;
|
2021-05-20 20:18:47 +00:00
|
|
|
import android.widget.Toast;
|
2021-05-06 12:11:44 -07:00
|
|
|
|
2021-05-20 20:18:47 +00:00
|
|
|
import androidx.annotation.NonNull;
|
2021-08-13 17:03:55 -07:00
|
|
|
import androidx.annotation.Nullable;
|
2021-02-02 17:12:08 -08:00
|
|
|
|
2021-05-20 20:18:47 +00:00
|
|
|
import com.android.launcher3.AbstractFloatingView;
|
2021-02-02 17:12:08 -08:00
|
|
|
import com.android.launcher3.DeviceProfile;
|
2021-05-20 20:18:47 +00:00
|
|
|
import com.android.launcher3.LauncherSettings.Favorites;
|
2021-02-02 17:12:08 -08:00
|
|
|
import com.android.launcher3.R;
|
2021-05-20 20:18:47 +00:00
|
|
|
import com.android.launcher3.folder.Folder;
|
|
|
|
|
import com.android.launcher3.folder.FolderIcon;
|
2021-08-30 14:15:56 -07:00
|
|
|
import com.android.launcher3.logger.LauncherAtom;
|
2021-05-20 20:18:47 +00:00
|
|
|
import com.android.launcher3.model.data.FolderInfo;
|
|
|
|
|
import com.android.launcher3.model.data.WorkspaceItemInfo;
|
|
|
|
|
import com.android.launcher3.touch.ItemClickHandler;
|
|
|
|
|
import com.android.launcher3.util.PackageManagerHelper;
|
2021-10-01 11:31:45 -07:00
|
|
|
import com.android.launcher3.util.SettingsCache;
|
2021-05-20 20:18:47 +00:00
|
|
|
import com.android.launcher3.util.Themes;
|
|
|
|
|
import com.android.launcher3.util.TraceHelper;
|
2021-06-14 11:40:10 -07:00
|
|
|
import com.android.launcher3.util.ViewCache;
|
2021-02-02 17:12:08 -08:00
|
|
|
import com.android.launcher3.views.ActivityContext;
|
2021-05-20 20:18:47 +00:00
|
|
|
import com.android.quickstep.SysUINavigationMode;
|
|
|
|
|
import com.android.quickstep.SysUINavigationMode.Mode;
|
|
|
|
|
import com.android.systemui.shared.recents.model.Task;
|
2021-10-21 15:31:51 +01:00
|
|
|
import com.android.systemui.shared.rotation.RotationButtonController;
|
2021-05-20 20:18:47 +00:00
|
|
|
import com.android.systemui.shared.system.ActivityManagerWrapper;
|
|
|
|
|
import com.android.systemui.shared.system.WindowManagerWrapper;
|
2021-10-13 17:04:16 +01:00
|
|
|
import com.android.systemui.unfold.util.ScopedUnfoldTransitionProgressProvider;
|
2021-02-02 17:12:08 -08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The {@link ActivityContext} with which we inflate Taskbar-related Views. This allows UI elements
|
|
|
|
|
* that are used by both Launcher and Taskbar (such as Folder) to reference a generic
|
|
|
|
|
* ActivityContext and BaseDragLayer instead of the Launcher activity and its DragLayer.
|
|
|
|
|
*/
|
2021-05-20 20:18:47 +00:00
|
|
|
public class TaskbarActivityContext extends ContextThemeWrapper implements ActivityContext {
|
|
|
|
|
|
|
|
|
|
private static final boolean ENABLE_THREE_BUTTON_TASKBAR =
|
|
|
|
|
SystemProperties.getBoolean("persist.debug.taskbar_three_button", false);
|
|
|
|
|
private static final String TAG = "TaskbarActivityContext";
|
|
|
|
|
|
|
|
|
|
private static final String WINDOW_TITLE = "Taskbar";
|
2021-02-02 17:12:08 -08:00
|
|
|
|
|
|
|
|
private final DeviceProfile mDeviceProfile;
|
|
|
|
|
private final LayoutInflater mLayoutInflater;
|
2021-05-21 14:41:30 -07:00
|
|
|
private final TaskbarDragLayer mDragLayer;
|
2021-06-08 20:03:43 -07:00
|
|
|
private final TaskbarControllers mControllers;
|
2021-02-02 17:12:08 -08:00
|
|
|
|
2021-05-20 20:18:47 +00:00
|
|
|
private final WindowManager mWindowManager;
|
2021-08-13 17:03:55 -07:00
|
|
|
private final @Nullable RoundedCorner mLeftCorner, mRightCorner;
|
2021-05-20 20:18:47 +00:00
|
|
|
private WindowManager.LayoutParams mWindowLayoutParams;
|
2021-05-24 15:47:38 -07:00
|
|
|
private boolean mIsFullscreen;
|
|
|
|
|
// The size we should return to when we call setTaskbarWindowFullscreen(false)
|
|
|
|
|
private int mLastRequestedNonFullscreenHeight;
|
2021-05-20 20:18:47 +00:00
|
|
|
|
|
|
|
|
private final SysUINavigationMode.Mode mNavMode;
|
2021-06-14 11:40:10 -07:00
|
|
|
private final ViewCache mViewCache = new ViewCache();
|
2021-05-20 20:18:47 +00:00
|
|
|
|
|
|
|
|
private final boolean mIsSafeModeEnabled;
|
2021-10-01 11:31:45 -07:00
|
|
|
private final boolean mIsUserSetupComplete;
|
2021-06-15 14:49:28 -07:00
|
|
|
private boolean mIsDestroyed = false;
|
2021-10-07 21:54:01 +08:00
|
|
|
// The flag to know if the window is excluded from magnification region computation.
|
|
|
|
|
private boolean mIsExcludeFromMagnificationRegion = false;
|
2021-05-20 20:18:47 +00:00
|
|
|
|
|
|
|
|
public TaskbarActivityContext(Context windowContext, DeviceProfile dp,
|
2021-08-27 14:11:53 +01:00
|
|
|
TaskbarNavButtonController buttonController, ScopedUnfoldTransitionProgressProvider
|
|
|
|
|
unfoldTransitionProgressProvider) {
|
2021-05-20 20:18:47 +00:00
|
|
|
super(windowContext, Themes.getActivityThemeRes(windowContext));
|
|
|
|
|
mDeviceProfile = dp;
|
2021-06-08 20:03:43 -07:00
|
|
|
|
2021-05-20 20:18:47 +00:00
|
|
|
mNavMode = SysUINavigationMode.getMode(windowContext);
|
|
|
|
|
mIsSafeModeEnabled = TraceHelper.allowIpcs("isSafeMode",
|
|
|
|
|
() -> getPackageManager().isSafeMode());
|
2021-10-01 11:31:45 -07:00
|
|
|
mIsUserSetupComplete = SettingsCache.INSTANCE.get(this).getValue(
|
|
|
|
|
Settings.Secure.getUriFor(Settings.Secure.USER_SETUP_COMPLETE), 0);
|
2021-05-20 20:18:47 +00:00
|
|
|
|
2021-02-02 17:12:08 -08:00
|
|
|
float taskbarIconSize = getResources().getDimension(R.dimen.taskbar_icon_size);
|
2021-05-25 14:35:01 -07:00
|
|
|
mDeviceProfile.updateIconSize(1, getResources());
|
2021-03-22 17:19:41 -07:00
|
|
|
float iconScale = taskbarIconSize / mDeviceProfile.iconSizePx;
|
|
|
|
|
mDeviceProfile.updateIconSize(iconScale, getResources());
|
2021-02-02 17:12:08 -08:00
|
|
|
|
|
|
|
|
mLayoutInflater = LayoutInflater.from(this).cloneInContext(this);
|
2021-06-08 20:03:43 -07:00
|
|
|
|
|
|
|
|
// Inflate views.
|
|
|
|
|
mDragLayer = (TaskbarDragLayer) mLayoutInflater.inflate(
|
|
|
|
|
R.layout.taskbar, null, false);
|
|
|
|
|
TaskbarView taskbarView = mDragLayer.findViewById(R.id.taskbar_view);
|
2021-09-24 10:48:01 -07:00
|
|
|
TaskbarScrimView taskbarScrimView = mDragLayer.findViewById(R.id.taskbar_scrim);
|
2021-06-08 20:03:43 -07:00
|
|
|
FrameLayout navButtonsView = mDragLayer.findViewById(R.id.navbuttons_view);
|
2021-08-17 16:07:22 -07:00
|
|
|
StashedHandleView stashedHandleView = mDragLayer.findViewById(R.id.stashed_handle);
|
2021-06-08 20:03:43 -07:00
|
|
|
|
2021-08-27 14:11:53 +01:00
|
|
|
Display display = windowContext.getDisplay();
|
|
|
|
|
Context c = display.getDisplayId() == Display.DEFAULT_DISPLAY
|
|
|
|
|
? windowContext.getApplicationContext()
|
|
|
|
|
: windowContext.getApplicationContext().createDisplayContext(display);
|
|
|
|
|
mWindowManager = c.getSystemService(WindowManager.class);
|
|
|
|
|
mLeftCorner = display.getRoundedCorner(RoundedCorner.POSITION_BOTTOM_LEFT);
|
|
|
|
|
mRightCorner = display.getRoundedCorner(RoundedCorner.POSITION_BOTTOM_RIGHT);
|
|
|
|
|
|
2021-06-08 20:03:43 -07:00
|
|
|
// Construct controllers.
|
|
|
|
|
mControllers = new TaskbarControllers(this,
|
|
|
|
|
new TaskbarDragController(this),
|
|
|
|
|
buttonController,
|
|
|
|
|
new NavbarButtonsViewController(this, navButtonsView),
|
2021-10-21 15:31:51 +01:00
|
|
|
new RotationButtonController(this,
|
2021-11-04 16:53:59 -07:00
|
|
|
c.getColor(R.color.taskbar_nav_icon_light_color),
|
|
|
|
|
c.getColor(R.color.taskbar_nav_icon_dark_color),
|
2021-10-21 15:31:51 +01:00
|
|
|
R.drawable.ic_sysbar_rotate_button_ccw_start_0,
|
|
|
|
|
R.drawable.ic_sysbar_rotate_button_ccw_start_90,
|
|
|
|
|
R.drawable.ic_sysbar_rotate_button_cw_start_0,
|
|
|
|
|
R.drawable.ic_sysbar_rotate_button_cw_start_90,
|
|
|
|
|
() -> getDisplay().getRotation()),
|
2021-06-08 20:03:43 -07:00
|
|
|
new TaskbarDragLayerController(this, mDragLayer),
|
2021-06-04 15:35:46 -07:00
|
|
|
new TaskbarViewController(this, taskbarView),
|
2021-09-24 10:48:01 -07:00
|
|
|
new TaskbarScrimViewController(this, taskbarScrimView),
|
2021-08-27 14:11:53 +01:00
|
|
|
new TaskbarUnfoldAnimationController(unfoldTransitionProgressProvider,
|
|
|
|
|
mWindowManager),
|
2021-06-01 16:54:07 -07:00
|
|
|
new TaskbarKeyguardController(this),
|
|
|
|
|
new StashedHandleViewController(this, stashedHandleView),
|
2021-07-30 16:00:20 -10:00
|
|
|
new TaskbarStashController(this),
|
2021-10-27 14:48:47 -07:00
|
|
|
new TaskbarEduController(this),
|
2021-10-12 12:38:55 -07:00
|
|
|
new TaskbarAutohideSuspendController(this),
|
|
|
|
|
new TaskbarPopupController());
|
2021-05-05 14:04:11 -07:00
|
|
|
}
|
|
|
|
|
|
2021-10-01 11:31:45 -07:00
|
|
|
public void init(TaskbarSharedState sharedState) {
|
2021-08-13 17:03:55 -07:00
|
|
|
mLastRequestedNonFullscreenHeight = getDefaultTaskbarWindowHeight();
|
2021-05-20 20:18:47 +00:00
|
|
|
mWindowLayoutParams = new WindowManager.LayoutParams(
|
|
|
|
|
MATCH_PARENT,
|
2021-05-24 15:47:38 -07:00
|
|
|
mLastRequestedNonFullscreenHeight,
|
2021-06-04 15:35:46 -07:00
|
|
|
TYPE_NAVIGATION_BAR_PANEL,
|
2021-09-16 21:28:47 -07:00
|
|
|
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
|
|
|
|
|
| WindowManager.LayoutParams.FLAG_SLIPPERY,
|
2021-05-20 20:18:47 +00:00
|
|
|
PixelFormat.TRANSLUCENT);
|
|
|
|
|
mWindowLayoutParams.setTitle(WINDOW_TITLE);
|
|
|
|
|
mWindowLayoutParams.packageName = getPackageName();
|
|
|
|
|
mWindowLayoutParams.gravity = Gravity.BOTTOM;
|
|
|
|
|
mWindowLayoutParams.setFitInsetsTypes(0);
|
|
|
|
|
mWindowLayoutParams.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING;
|
|
|
|
|
mWindowLayoutParams.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
|
2021-09-14 15:31:26 -07:00
|
|
|
mWindowLayoutParams.privateFlags =
|
|
|
|
|
WindowManager.LayoutParams.PRIVATE_FLAG_NO_MOVE_ANIMATION;
|
2021-05-20 20:18:47 +00:00
|
|
|
|
|
|
|
|
WindowManagerWrapper wmWrapper = WindowManagerWrapper.getInstance();
|
|
|
|
|
wmWrapper.setProvidesInsetsTypes(
|
|
|
|
|
mWindowLayoutParams,
|
|
|
|
|
new int[] { ITYPE_EXTRA_NAVIGATION_BAR, ITYPE_BOTTOM_TAPPABLE_ELEMENT }
|
|
|
|
|
);
|
2021-09-01 17:28:13 -07:00
|
|
|
// Adjust the frame by the rounded corners (ie. leaving just the bar as the inset) when
|
|
|
|
|
// the IME is showing
|
|
|
|
|
mWindowLayoutParams.providedInternalImeInsets = Insets.of(0,
|
|
|
|
|
getDefaultTaskbarWindowHeight() - mDeviceProfile.taskbarSize, 0, 0);
|
2021-05-20 20:18:47 +00:00
|
|
|
|
2021-06-08 20:03:43 -07:00
|
|
|
// Initialize controllers after all are constructed.
|
2021-10-01 11:31:45 -07:00
|
|
|
mControllers.init(sharedState);
|
2021-10-28 16:39:32 -07:00
|
|
|
updateSysuiStateFlags(sharedState.sysuiStateFlags, true /* fromInit */);
|
2021-06-08 20:03:43 -07:00
|
|
|
|
2021-05-21 14:41:30 -07:00
|
|
|
mWindowManager.addView(mDragLayer, mWindowLayoutParams);
|
2021-05-20 20:18:47 +00:00
|
|
|
}
|
|
|
|
|
|
2021-11-26 11:38:28 +00:00
|
|
|
public void onConfigurationChanged(@Config int configChanges) {
|
|
|
|
|
mControllers.onConfigurationChanged(configChanges);
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-15 13:14:41 -07:00
|
|
|
public boolean isThreeButtonNav() {
|
|
|
|
|
return mNavMode == Mode.THREE_BUTTONS;
|
2021-02-02 17:12:08 -08:00
|
|
|
}
|
|
|
|
|
|
2021-08-13 17:03:55 -07:00
|
|
|
public int getLeftCornerRadius() {
|
|
|
|
|
return mLeftCorner == null ? 0 : mLeftCorner.getRadius();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getRightCornerRadius() {
|
|
|
|
|
return mRightCorner == null ? 0 : mRightCorner.getRadius();
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-22 14:43:58 -07:00
|
|
|
@Override
|
2021-02-02 17:12:08 -08:00
|
|
|
public LayoutInflater getLayoutInflater() {
|
|
|
|
|
return mLayoutInflater;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2021-05-21 14:41:30 -07:00
|
|
|
public TaskbarDragLayer getDragLayer() {
|
|
|
|
|
return mDragLayer;
|
2021-02-02 17:12:08 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public DeviceProfile getDeviceProfile() {
|
|
|
|
|
return mDeviceProfile;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Rect getFolderBoundingBox() {
|
2021-06-08 20:03:43 -07:00
|
|
|
return mControllers.taskbarDragLayerController.getFolderBoundingBox();
|
2021-02-02 17:12:08 -08:00
|
|
|
}
|
2021-05-06 12:11:44 -07:00
|
|
|
|
|
|
|
|
@Override
|
2021-05-24 15:47:38 -07:00
|
|
|
public TaskbarDragController getDragController() {
|
2021-06-08 20:03:43 -07:00
|
|
|
return mControllers.taskbarDragController;
|
2021-05-06 12:11:44 -07:00
|
|
|
}
|
|
|
|
|
|
2021-06-14 11:40:10 -07:00
|
|
|
@Override
|
|
|
|
|
public ViewCache getViewCache() {
|
|
|
|
|
return mViewCache;
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-03 12:47:09 -07:00
|
|
|
@Override
|
|
|
|
|
public boolean supportsIme() {
|
|
|
|
|
// Currently we don't support IME because we have FLAG_NOT_FOCUSABLE. We can remove that
|
|
|
|
|
// flag when opening a floating view that needs IME (such as Folder), but then that means
|
|
|
|
|
// Taskbar will be below IME and thus users can't click the back button.
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-12 12:38:55 -07:00
|
|
|
@Override
|
|
|
|
|
public View.OnClickListener getItemOnClickListener() {
|
|
|
|
|
return this::onTaskbarIconClicked;
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-30 14:15:56 -07:00
|
|
|
/**
|
|
|
|
|
* Change from hotseat/predicted hotseat to taskbar container.
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public void applyOverwritesToLogItem(LauncherAtom.ItemInfo.Builder itemInfoBuilder) {
|
|
|
|
|
if (!itemInfoBuilder.hasContainerInfo()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
LauncherAtom.ContainerInfo oldContainer = itemInfoBuilder.getContainerInfo();
|
|
|
|
|
|
|
|
|
|
if (oldContainer.hasPredictedHotseatContainer()) {
|
|
|
|
|
LauncherAtom.PredictedHotseatContainer predictedHotseat =
|
|
|
|
|
oldContainer.getPredictedHotseatContainer();
|
|
|
|
|
LauncherAtom.TaskBarContainer.Builder taskbarBuilder =
|
|
|
|
|
LauncherAtom.TaskBarContainer.newBuilder();
|
|
|
|
|
|
|
|
|
|
if (predictedHotseat.hasIndex()) {
|
|
|
|
|
taskbarBuilder.setIndex(predictedHotseat.getIndex());
|
|
|
|
|
}
|
|
|
|
|
if (predictedHotseat.hasCardinality()) {
|
|
|
|
|
taskbarBuilder.setCardinality(predictedHotseat.getCardinality());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
itemInfoBuilder.setContainerInfo(LauncherAtom.ContainerInfo.newBuilder()
|
|
|
|
|
.setTaskBarContainer(taskbarBuilder));
|
|
|
|
|
} else if (oldContainer.hasHotseat()) {
|
|
|
|
|
LauncherAtom.HotseatContainer hotseat = oldContainer.getHotseat();
|
|
|
|
|
LauncherAtom.TaskBarContainer.Builder taskbarBuilder =
|
|
|
|
|
LauncherAtom.TaskBarContainer.newBuilder();
|
|
|
|
|
|
|
|
|
|
if (hotseat.hasIndex()) {
|
|
|
|
|
taskbarBuilder.setIndex(hotseat.getIndex());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
itemInfoBuilder.setContainerInfo(LauncherAtom.ContainerInfo.newBuilder()
|
|
|
|
|
.setTaskBarContainer(taskbarBuilder));
|
|
|
|
|
} else if (oldContainer.hasFolder() && oldContainer.getFolder().hasHotseat()) {
|
|
|
|
|
LauncherAtom.FolderContainer.Builder folderBuilder = oldContainer.getFolder()
|
|
|
|
|
.toBuilder();
|
|
|
|
|
LauncherAtom.HotseatContainer hotseat = folderBuilder.getHotseat();
|
|
|
|
|
LauncherAtom.TaskBarContainer.Builder taskbarBuilder =
|
|
|
|
|
LauncherAtom.TaskBarContainer.newBuilder();
|
|
|
|
|
|
|
|
|
|
if (hotseat.hasIndex()) {
|
|
|
|
|
taskbarBuilder.setIndex(hotseat.getIndex());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
folderBuilder.setTaskbar(taskbarBuilder);
|
|
|
|
|
folderBuilder.clearHotseat();
|
|
|
|
|
itemInfoBuilder.setContainerInfo(LauncherAtom.ContainerInfo.newBuilder()
|
|
|
|
|
.setFolder(folderBuilder));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-20 20:18:47 +00:00
|
|
|
/**
|
|
|
|
|
* Sets a new data-source for this taskbar instance
|
|
|
|
|
*/
|
|
|
|
|
public void setUIController(@NonNull TaskbarUIController uiController) {
|
2021-06-08 20:03:43 -07:00
|
|
|
mControllers.uiController.onDestroy();
|
|
|
|
|
mControllers.uiController = uiController;
|
|
|
|
|
mControllers.uiController.init(mControllers);
|
2021-05-20 20:18:47 +00:00
|
|
|
}
|
|
|
|
|
|
2021-10-01 11:31:45 -07:00
|
|
|
/**
|
|
|
|
|
* Sets the flag indicating setup UI is visible
|
|
|
|
|
*/
|
|
|
|
|
public void setSetupUIVisible(boolean isVisible) {
|
|
|
|
|
mControllers.taskbarStashController.setSetupUIVisible(isVisible);
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-20 20:18:47 +00:00
|
|
|
/**
|
|
|
|
|
* Called when this instance of taskbar is no longer needed
|
|
|
|
|
*/
|
|
|
|
|
public void onDestroy() {
|
2021-06-15 14:49:28 -07:00
|
|
|
mIsDestroyed = true;
|
2021-05-20 20:18:47 +00:00
|
|
|
setUIController(TaskbarUIController.DEFAULT);
|
2021-06-08 20:03:43 -07:00
|
|
|
mControllers.onDestroy();
|
2021-05-21 14:41:30 -07:00
|
|
|
mWindowManager.removeViewImmediate(mDragLayer);
|
2021-05-20 20:18:47 +00:00
|
|
|
}
|
|
|
|
|
|
2021-10-28 16:39:32 -07:00
|
|
|
public void updateSysuiStateFlags(int systemUiStateFlags, boolean fromInit) {
|
|
|
|
|
mControllers.navbarButtonsViewController.updateStateForSysuiFlags(systemUiStateFlags,
|
|
|
|
|
fromInit);
|
2021-06-08 20:03:43 -07:00
|
|
|
mControllers.taskbarViewController.setImeIsVisible(
|
|
|
|
|
mControllers.navbarButtonsViewController.isImeVisible());
|
2021-10-21 10:45:20 -07:00
|
|
|
int shadeExpandedFlags = SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED
|
|
|
|
|
| SYSUI_STATE_QUICK_SETTINGS_EXPANDED;
|
2021-10-28 16:39:32 -07:00
|
|
|
onNotificationShadeExpandChanged((systemUiStateFlags & shadeExpandedFlags) != 0, fromInit);
|
2021-08-26 10:18:04 -07:00
|
|
|
mControllers.taskbarViewController.setRecentsButtonDisabled(
|
|
|
|
|
mControllers.navbarButtonsViewController.isRecentsDisabled());
|
2021-09-28 15:09:25 -07:00
|
|
|
mControllers.stashedHandleViewController.setIsHomeButtonDisabled(
|
|
|
|
|
mControllers.navbarButtonsViewController.isHomeDisabled());
|
2021-06-04 15:35:46 -07:00
|
|
|
mControllers.taskbarKeyguardController.updateStateForSysuiFlags(systemUiStateFlags);
|
2021-10-28 16:39:32 -07:00
|
|
|
mControllers.taskbarStashController.updateStateForSysuiFlags(systemUiStateFlags, fromInit);
|
|
|
|
|
mControllers.taskbarScrimViewController.updateStateForSysuiFlags(systemUiStateFlags,
|
|
|
|
|
fromInit);
|
2021-11-24 19:54:07 -08:00
|
|
|
mControllers.navButtonController.updateSysuiFlags(systemUiStateFlags);
|
2021-05-25 14:35:01 -07:00
|
|
|
}
|
|
|
|
|
|
2021-10-21 10:45:20 -07:00
|
|
|
/**
|
|
|
|
|
* Hides the taskbar icons and background when the notication shade is expanded.
|
|
|
|
|
*/
|
2021-10-28 16:39:32 -07:00
|
|
|
private void onNotificationShadeExpandChanged(boolean isExpanded, boolean skipAnim) {
|
2021-10-21 10:45:20 -07:00
|
|
|
float alpha = isExpanded ? 0 : 1;
|
|
|
|
|
AnimatorSet anim = new AnimatorSet();
|
|
|
|
|
anim.play(mControllers.taskbarViewController.getTaskbarIconAlpha().getProperty(
|
|
|
|
|
TaskbarViewController.ALPHA_INDEX_NOTIFICATION_EXPANDED).animateToValue(alpha));
|
|
|
|
|
if (!isThreeButtonNav()) {
|
|
|
|
|
anim.play(mControllers.taskbarDragLayerController.getNotificationShadeBgTaskbar()
|
|
|
|
|
.animateToValue(alpha));
|
|
|
|
|
}
|
|
|
|
|
anim.start();
|
2021-10-28 16:39:32 -07:00
|
|
|
if (skipAnim) {
|
|
|
|
|
anim.end();
|
|
|
|
|
}
|
2021-10-21 10:45:20 -07:00
|
|
|
}
|
|
|
|
|
|
2021-05-25 14:35:01 -07:00
|
|
|
public void onRotationProposal(int rotation, boolean isValid) {
|
2021-06-08 20:03:43 -07:00
|
|
|
mControllers.rotationButtonController.onRotationProposal(rotation, isValid);
|
2021-05-25 14:35:01 -07:00
|
|
|
}
|
|
|
|
|
|
2021-06-04 15:35:46 -07:00
|
|
|
public void disableNavBarElements(int displayId, int state1, int state2, boolean animate) {
|
2021-05-25 14:35:01 -07:00
|
|
|
if (displayId != getDisplayId()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-06-08 20:03:43 -07:00
|
|
|
mControllers.rotationButtonController.onDisable2FlagChanged(state2);
|
2021-05-25 14:35:01 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void onSystemBarAttributesChanged(int displayId, int behavior) {
|
2021-06-08 20:03:43 -07:00
|
|
|
mControllers.rotationButtonController.onBehaviorChanged(displayId, behavior);
|
2021-05-21 14:41:30 -07:00
|
|
|
}
|
|
|
|
|
|
2021-11-04 16:53:59 -07:00
|
|
|
public void onNavButtonsDarkIntensityChanged(float darkIntensity) {
|
|
|
|
|
mControllers.navbarButtonsViewController.getTaskbarNavButtonDarkIntensity()
|
|
|
|
|
.updateValue(darkIntensity);
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-20 20:18:47 +00:00
|
|
|
/**
|
|
|
|
|
* Updates the TaskbarContainer to MATCH_PARENT vs original Taskbar size.
|
|
|
|
|
*/
|
2021-05-24 15:47:38 -07:00
|
|
|
public void setTaskbarWindowFullscreen(boolean fullscreen) {
|
2021-10-27 14:48:47 -07:00
|
|
|
mControllers.taskbarAutohideSuspendController.updateFlag(
|
|
|
|
|
TaskbarAutohideSuspendController.FLAG_AUTOHIDE_SUSPEND_FULLSCREEN, fullscreen);
|
2021-05-24 15:47:38 -07:00
|
|
|
mIsFullscreen = fullscreen;
|
|
|
|
|
setTaskbarWindowHeight(fullscreen ? MATCH_PARENT : mLastRequestedNonFullscreenHeight);
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-13 17:03:55 -07:00
|
|
|
public boolean isTaskbarWindowFullscreen() {
|
|
|
|
|
return mIsFullscreen;
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-24 15:47:38 -07:00
|
|
|
/**
|
2021-08-13 17:03:55 -07:00
|
|
|
* Updates the TaskbarContainer height (pass {@link #getDefaultTaskbarWindowHeight()} to reset).
|
2021-05-24 15:47:38 -07:00
|
|
|
*/
|
|
|
|
|
public void setTaskbarWindowHeight(int height) {
|
2021-06-15 14:49:28 -07:00
|
|
|
if (mWindowLayoutParams.height == height || mIsDestroyed) {
|
2021-05-24 15:47:38 -07:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (height != MATCH_PARENT) {
|
|
|
|
|
mLastRequestedNonFullscreenHeight = height;
|
|
|
|
|
if (mIsFullscreen) {
|
|
|
|
|
// We still need to be fullscreen, so defer any change to our height until we call
|
|
|
|
|
// setTaskbarWindowFullscreen(false). For example, this could happen when dragging
|
|
|
|
|
// from the gesture region, as the drag will cancel the gesture and reset launcher's
|
|
|
|
|
// state, which in turn normally would reset the taskbar window height as well.
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
mWindowLayoutParams.height = height;
|
|
|
|
|
mWindowManager.updateViewLayout(mDragLayer, mWindowLayoutParams);
|
2021-05-20 20:18:47 +00:00
|
|
|
}
|
|
|
|
|
|
2021-08-13 17:03:55 -07:00
|
|
|
/**
|
|
|
|
|
* Returns the default height of the window, including the static corner radii above taskbar.
|
|
|
|
|
*/
|
|
|
|
|
public int getDefaultTaskbarWindowHeight() {
|
|
|
|
|
return mDeviceProfile.taskbarSize + Math.max(getLeftCornerRadius(), getRightCornerRadius());
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-20 20:18:47 +00:00
|
|
|
protected void onTaskbarIconClicked(View view) {
|
|
|
|
|
Object tag = view.getTag();
|
|
|
|
|
if (tag instanceof Task) {
|
|
|
|
|
Task task = (Task) tag;
|
|
|
|
|
ActivityManagerWrapper.getInstance().startActivityFromRecents(task.key,
|
|
|
|
|
ActivityOptions.makeBasic());
|
|
|
|
|
} else if (tag instanceof FolderInfo) {
|
|
|
|
|
FolderIcon folderIcon = (FolderIcon) view;
|
|
|
|
|
Folder folder = folderIcon.getFolder();
|
|
|
|
|
setTaskbarWindowFullscreen(true);
|
|
|
|
|
|
|
|
|
|
getDragLayer().post(() -> {
|
|
|
|
|
folder.animateOpen();
|
2021-08-30 14:15:56 -07:00
|
|
|
getStatsLogManager().logger().withItemInfo(folder.mInfo).log(LAUNCHER_FOLDER_OPEN);
|
2021-05-20 20:18:47 +00:00
|
|
|
|
|
|
|
|
folder.iterateOverItems((itemInfo, itemView) -> {
|
2021-06-08 20:03:43 -07:00
|
|
|
mControllers.taskbarViewController
|
|
|
|
|
.setClickAndLongClickListenersForIcon(itemView);
|
2021-05-20 20:18:47 +00:00
|
|
|
// To play haptic when dragging, like other Taskbar items do.
|
|
|
|
|
itemView.setHapticFeedbackEnabled(true);
|
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
} else if (tag instanceof WorkspaceItemInfo) {
|
|
|
|
|
WorkspaceItemInfo info = (WorkspaceItemInfo) tag;
|
2021-05-25 14:35:01 -07:00
|
|
|
if (info.isDisabled()) {
|
|
|
|
|
ItemClickHandler.handleDisabledItemClicked(info, this);
|
|
|
|
|
} else {
|
2021-05-20 20:18:47 +00:00
|
|
|
Intent intent = new Intent(info.getIntent())
|
|
|
|
|
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
|
|
|
try {
|
|
|
|
|
if (mIsSafeModeEnabled && !PackageManagerHelper.isSystemApp(this, intent)) {
|
|
|
|
|
Toast.makeText(this, R.string.safemode_shortcut_error,
|
|
|
|
|
Toast.LENGTH_SHORT).show();
|
|
|
|
|
} else if (info.isPromise()) {
|
|
|
|
|
intent = new PackageManagerHelper(this)
|
|
|
|
|
.getMarketIntent(info.getTargetPackage())
|
|
|
|
|
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
|
|
|
startActivity(intent);
|
|
|
|
|
|
|
|
|
|
} else if (info.itemType == Favorites.ITEM_TYPE_DEEP_SHORTCUT) {
|
|
|
|
|
String id = info.getDeepShortcutId();
|
|
|
|
|
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);
|
|
|
|
|
}
|
2021-08-30 14:15:56 -07:00
|
|
|
|
|
|
|
|
mControllers.uiController.onTaskbarIconLaunched(info);
|
2021-05-20 20:18:47 +00:00
|
|
|
} 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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
Log.e(TAG, "Unknown type clicked: " + tag);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AbstractFloatingView.closeAllOpenViews(this);
|
|
|
|
|
}
|
2021-07-16 12:15:35 -10:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
public boolean onLongPressToUnstashTaskbar() {
|
|
|
|
|
return mControllers.taskbarStashController.onLongPressToUnstashTaskbar();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Called when we detect a motion down or up/cancel in the nav region while stashed.
|
|
|
|
|
* @param animateForward Whether to animate towards the unstashed hint state or back to stashed.
|
|
|
|
|
*/
|
|
|
|
|
public void startTaskbarUnstashHint(boolean animateForward) {
|
|
|
|
|
mControllers.taskbarStashController.startUnstashHint(animateForward);
|
|
|
|
|
}
|
2021-10-01 11:31:45 -07:00
|
|
|
|
|
|
|
|
protected boolean isUserSetupComplete() {
|
|
|
|
|
return mIsUserSetupComplete;
|
|
|
|
|
}
|
2021-10-07 21:54:01 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Called when we determine the touchable region.
|
|
|
|
|
*
|
|
|
|
|
* @param exclude {@code true} then the magnification region computation will omit the window.
|
|
|
|
|
*/
|
|
|
|
|
public void excludeFromMagnificationRegion(boolean exclude) {
|
|
|
|
|
if (mIsExcludeFromMagnificationRegion == exclude) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mIsExcludeFromMagnificationRegion = exclude;
|
|
|
|
|
if (exclude) {
|
|
|
|
|
mWindowLayoutParams.privateFlags |=
|
|
|
|
|
WindowManager.LayoutParams.PRIVATE_FLAG_EXCLUDE_FROM_SCREEN_MAGNIFICATION;
|
|
|
|
|
} else {
|
|
|
|
|
mWindowLayoutParams.privateFlags &=
|
|
|
|
|
~WindowManager.LayoutParams.PRIVATE_FLAG_EXCLUDE_FROM_SCREEN_MAGNIFICATION;
|
|
|
|
|
}
|
|
|
|
|
mWindowManager.updateViewLayout(mDragLayer, mWindowLayoutParams);
|
|
|
|
|
}
|
2021-02-02 17:12:08 -08:00
|
|
|
}
|