64896f3098
This means adding the search view to the drag layer, so it can persist and animate across Launcher states (i.e. Home, All Apps, Overview, Overview from App). Some high level things: - LauncherState now has a flag indicating if the floating search bar should be visible, as well as a method indicating how high it should rest when the keyboard is not showing. By default the height is set negative if the flag is not present, so the search bar will rest off screen in that state. - LauncherState also has a new method indicating if the search bar should show as a pill when not focused. Currently this is done in phone portrait mode in all apps and overview. - SearchUiManager now has a method for gestures to hint that the search bar will be focused or unfocused soon, e.g. for the app -> overview case, we hint that it will be focused when crossing the threshold, and unfocused if retracting. This allows the search bar to animate during the gesture and take or release focus after the state change completes. - AllAppsTransitionController lets the apps panel translate in from the bottom of the screen, for example when coming from an app and we don't want to pop it in halfway up the screen. Instead it can slide in gracefully from behind the keyboard and floating search bar. - KeyboardInsetAnimationCallback can now notify listeners of keyboard alpha changes during controlled animations. And StateAnimationConfig has a new animation type to control the keyboard alpha during the all apps transition. - This new ANIM_ALL_APPS_KEYBOARD_FADE is used to pop the keyboard in at the threshold for going from an app to all apps. Note that its position moves linearly before this, so the search bar starts moving up accordingly before the keyboard alpha is non-0. Fix: 266761289 Fix: 268845147 Fix: 267683921 Fix: 265849321 Fix: 266446733 Fix: 269301440 Bug: 275635606 Bug: 259619990 Bug: 261866704 Test: Manual with all the state transitions on phone and tablet (also folding/unfolding foldable). Flag: ENABLE_FLOATING_SEARCH_BAR, ENABLE_ALL_APPS_FROM_OVERVIEW (latter just for the background app interpolator changes). Change-Id: I6f06552e95747348a62260279626cf407bf145b0
218 lines
7.5 KiB
Java
218 lines
7.5 KiB
Java
/*
|
|
* Copyright (C) 2017 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.uioverrides.states;
|
|
|
|
import static com.android.app.animation.Interpolators.DECELERATE_2;
|
|
import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_OVERVIEW;
|
|
|
|
import android.content.Context;
|
|
import android.graphics.Rect;
|
|
import android.os.SystemProperties;
|
|
|
|
import com.android.launcher3.DeviceProfile;
|
|
import com.android.launcher3.Launcher;
|
|
import com.android.launcher3.LauncherState;
|
|
import com.android.launcher3.R;
|
|
import com.android.launcher3.util.DisplayController;
|
|
import com.android.launcher3.util.Themes;
|
|
import com.android.quickstep.util.LayoutUtils;
|
|
import com.android.quickstep.views.RecentsView;
|
|
import com.android.quickstep.views.TaskView;
|
|
|
|
/**
|
|
* Definition for overview state
|
|
*/
|
|
public class OverviewState extends LauncherState {
|
|
|
|
private static final int OVERVIEW_SLIDE_IN_DURATION = 380;
|
|
private static final int OVERVIEW_POP_IN_DURATION = 250;
|
|
private static final int OVERVIEW_EXIT_DURATION = 250;
|
|
|
|
protected static final Rect sTempRect = new Rect();
|
|
|
|
private static final int STATE_FLAGS = FLAG_WORKSPACE_ICONS_CAN_BE_DRAGGED
|
|
| FLAG_DISABLE_RESTORE | FLAG_OVERVIEW_UI | FLAG_WORKSPACE_INACCESSIBLE
|
|
| FLAG_CLOSE_POPUPS;
|
|
|
|
public OverviewState(int id) {
|
|
this(id, STATE_FLAGS);
|
|
}
|
|
|
|
protected OverviewState(int id, int stateFlags) {
|
|
this(id, LAUNCHER_STATE_OVERVIEW, stateFlags);
|
|
}
|
|
|
|
protected OverviewState(int id, int logContainer, int stateFlags) {
|
|
super(id, logContainer, stateFlags);
|
|
}
|
|
|
|
@Override
|
|
public int getTransitionDuration(Context context, boolean isToState) {
|
|
if (isToState) {
|
|
// In gesture modes, overview comes in all the way from the side, so give it more time.
|
|
return DisplayController.getNavigationMode(context).hasGestures
|
|
? OVERVIEW_SLIDE_IN_DURATION
|
|
: OVERVIEW_POP_IN_DURATION;
|
|
} else {
|
|
// When exiting Overview, exit quickly.
|
|
return OVERVIEW_EXIT_DURATION;
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public ScaleAndTranslation getWorkspaceScaleAndTranslation(Launcher launcher) {
|
|
RecentsView recentsView = launcher.getOverviewPanel();
|
|
recentsView.getTaskSize(sTempRect);
|
|
float scale;
|
|
DeviceProfile deviceProfile = launcher.getDeviceProfile();
|
|
if (deviceProfile.isTwoPanels) {
|
|
// In two panel layout, width does not include both panels or space between them, so
|
|
// use height instead. We do not use height for handheld, as cell layout can be
|
|
// shorter than a task and we want the workspace to scale down to task size.
|
|
scale = (float) sTempRect.height() / deviceProfile.getCellLayoutHeight();
|
|
} else {
|
|
scale = (float) sTempRect.width() / deviceProfile.getCellLayoutWidth();
|
|
}
|
|
float parallaxFactor = 0.5f;
|
|
return new ScaleAndTranslation(scale, 0, -getDefaultSwipeHeight(launcher) * parallaxFactor);
|
|
}
|
|
|
|
@Override
|
|
public float[] getOverviewScaleAndOffset(Launcher launcher) {
|
|
return new float[] {NO_SCALE, NO_OFFSET};
|
|
}
|
|
|
|
@Override
|
|
public PageAlphaProvider getWorkspacePageAlphaProvider(Launcher launcher) {
|
|
return new PageAlphaProvider(DECELERATE_2) {
|
|
@Override
|
|
public float getPageAlpha(int pageIndex) {
|
|
return 0;
|
|
}
|
|
};
|
|
}
|
|
|
|
@Override
|
|
public int getVisibleElements(Launcher launcher) {
|
|
int elements = CLEAR_ALL_BUTTON | OVERVIEW_ACTIONS;
|
|
DeviceProfile dp = launcher.getDeviceProfile();
|
|
boolean showFloatingSearch;
|
|
if (dp.isPhone) {
|
|
// Only show search in phone overview in portrait mode.
|
|
showFloatingSearch = !dp.isLandscape;
|
|
} else {
|
|
// Only show search in tablet overview if taskbar is not visible.
|
|
showFloatingSearch = !dp.isTaskbarPresent || isTaskbarStashed(launcher);
|
|
}
|
|
if (showFloatingSearch) {
|
|
elements |= FLOATING_SEARCH_BAR;
|
|
}
|
|
return elements;
|
|
}
|
|
|
|
@Override
|
|
public int getFloatingSearchBarRestingMarginBottom(Launcher launcher) {
|
|
return areElementsVisible(launcher, FLOATING_SEARCH_BAR) ? 0
|
|
: super.getFloatingSearchBarRestingMarginBottom(launcher);
|
|
}
|
|
|
|
@Override
|
|
public boolean shouldFloatingSearchBarUsePillWhenUnfocused(Launcher launcher) {
|
|
DeviceProfile dp = launcher.getDeviceProfile();
|
|
return dp.isPhone && !dp.isLandscape;
|
|
}
|
|
|
|
@Override
|
|
public boolean isTaskbarAlignedWithHotseat(Launcher launcher) {
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public int getWorkspaceScrimColor(Launcher launcher) {
|
|
return Themes.getAttrColor(launcher, R.attr.overviewScrimColor);
|
|
}
|
|
|
|
@Override
|
|
public boolean displayOverviewTasksAsGrid(DeviceProfile deviceProfile) {
|
|
return deviceProfile.isTablet;
|
|
}
|
|
|
|
@Override
|
|
public boolean disallowTaskbarGlobalDrag() {
|
|
// Disable global drag in overview
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public boolean allowTaskbarInitialSplitSelection() {
|
|
// Allow split select from taskbar items in overview
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public String getDescription(Launcher launcher) {
|
|
return launcher.getString(R.string.accessibility_recent_apps);
|
|
}
|
|
|
|
public static float getDefaultSwipeHeight(Launcher launcher) {
|
|
return LayoutUtils.getDefaultSwipeHeight(launcher, launcher.getDeviceProfile());
|
|
}
|
|
|
|
@Override
|
|
protected float getDepthUnchecked(Context context) {
|
|
//TODO revert when b/178661709 is fixed
|
|
return SystemProperties.getBoolean("ro.launcher.depth.overview", true) ? 1 : 0;
|
|
}
|
|
|
|
@Override
|
|
public void onBackPressed(Launcher launcher) {
|
|
RecentsView recentsView = launcher.getOverviewPanel();
|
|
TaskView taskView = recentsView.getRunningTaskView();
|
|
if (taskView != null) {
|
|
if (recentsView.isTaskViewFullyVisible(taskView)) {
|
|
taskView.launchTasks();
|
|
} else {
|
|
recentsView.snapToPage(recentsView.indexOfChild(taskView));
|
|
}
|
|
} else {
|
|
super.onBackPressed(launcher);
|
|
}
|
|
}
|
|
|
|
public static OverviewState newBackgroundState(int id) {
|
|
return new BackgroundAppState(id);
|
|
}
|
|
|
|
public static OverviewState newSwitchState(int id) {
|
|
return new QuickSwitchState(id);
|
|
}
|
|
|
|
/**
|
|
* New Overview substate that represents the overview in modal mode (one task shown on its own)
|
|
*/
|
|
public static OverviewState newModalTaskState(int id) {
|
|
return new OverviewModalTaskState(id);
|
|
}
|
|
|
|
/**
|
|
* New Overview substate representing state where 1 app for split screen has been selected and
|
|
* pinned and user is selecting the second one
|
|
*/
|
|
public static OverviewState newSplitSelectState(int id) {
|
|
return new SplitScreenSelectState(id);
|
|
}
|
|
}
|