Adding an empty page in Recents view corresponding to workspace

The page is aligned to the workspace card and shows a widgets button
in the empty region

Change-Id: I479c47a2fbac4b3ef1aaf833d9fe82b5d7e10ddc
This commit is contained in:
Sunny Goyal
2017-12-15 13:05:42 -08:00
parent 9558a884dd
commit e15e2a8267
16 changed files with 424 additions and 75 deletions

View File

@@ -22,6 +22,7 @@ import android.view.View;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
import com.android.launcher3.Utilities;
import com.android.launcher3.Workspace;
import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
import com.android.quickstep.RecentsView;
@@ -31,8 +32,9 @@ import com.android.quickstep.RecentsView;
*/
public class OverviewState extends LauncherState {
private static final int STATE_FLAGS = FLAG_SHOW_SCRIM
| FLAG_WORKSPACE_ICONS_CAN_BE_DRAGGED;
public static final float WORKSPACE_SCALE_ON_SCROLL = 0.9f;
private static final int STATE_FLAGS = FLAG_SHOW_SCRIM | FLAG_WORKSPACE_ICONS_CAN_BE_DRAGGED;
public OverviewState(int id) {
super(id, ContainerType.WORKSPACE, OVERVIEW_TRANSITION_MS, 1f, STATE_FLAGS);
@@ -42,18 +44,15 @@ public class OverviewState extends LauncherState {
public float[] getWorkspaceScaleAndTranslation(Launcher launcher) {
Rect pageRect = new Rect();
RecentsView.getPageRect(launcher, pageRect);
Workspace ws = launcher.getWorkspace();
float childWidth = ws.getNormalChildWidth();
if (childWidth <= 0 || pageRect.isEmpty()) {
if (launcher.getWorkspace().getNormalChildWidth() <= 0 || pageRect.isEmpty()) {
return super.getWorkspaceScaleAndTranslation(launcher);
}
Rect insets = launcher.getDragLayer().getInsets();
float scale = pageRect.width() / childWidth;
float halfHeight = ws.getHeight() / 2;
float childTop = halfHeight - scale * (halfHeight - ws.getPaddingTop() - insets.top);
return new float[] {scale, pageRect.top - childTop};
RecentsView rv = launcher.getOverviewPanel();
if (rv.getCurrentPage() >= rv.getFirstTaskIndex()) {
Utilities.scaleRectAboutCenter(pageRect, WORKSPACE_SCALE_ON_SCROLL);
}
return getScaleAndTranslationForPageRect(launcher, pageRect);
}
@Override
@@ -77,4 +76,16 @@ public class OverviewState extends LauncherState {
public View getFinalFocus(Launcher launcher) {
return launcher.getOverviewPanel();
}
public static float[] getScaleAndTranslationForPageRect(Launcher launcher, Rect pageRect) {
Workspace ws = launcher.getWorkspace();
float childWidth = ws.getNormalChildWidth();
Rect insets = launcher.getDragLayer().getInsets();
float scale = pageRect.width() / childWidth;
float halfHeight = ws.getHeight() / 2;
float childTop = halfHeight - scale * (halfHeight - ws.getPaddingTop() - insets.top);
return new float[] {scale, pageRect.top - childTop};
}
}