From f633ef5f4310b6f79087797a2dc215812f841b70 Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Tue, 13 Mar 2018 09:57:05 -0700 Subject: [PATCH] Adding fallback recents activity > Refactoring RecentsView to a common base class > Moving some dependency form Launcher to BaseActivity > Using the Recents view in RecentsActivity Change-Id: Ie0e6741d356291e77420798c140c999121de3a0d --- .../res/layout/fallback_recents_activity.xml | 29 ++++ quickstep/res/layout/overview_panel.xml | 4 +- quickstep/res/layout/task.xml | 6 +- quickstep/res/layout/task_menu.xml | 4 +- .../LauncherAppTransitionManagerImpl.java | 4 +- .../uioverrides/EdgeSwipeController.java | 2 +- .../uioverrides/FastOverviewState.java | 2 +- .../launcher3/uioverrides/OverviewState.java | 2 +- .../uioverrides/OverviewSwipeController.java | 4 +- .../RecentsViewStateController.java | 5 +- .../launcher3/uioverrides/UiFactory.java | 2 +- .../quickstep/FallbackRecentsView.java | 57 ++++++ .../NavBarSwipeInteractionHandler.java | 3 +- .../quickstep/OverviewCommandHelper.java | 9 + .../quickstep/QuickScrubController.java | 16 +- .../android/quickstep/RecentsActivity.java | 31 ++-- .../android/quickstep/RecentsRootView.java | 56 ++++++ .../com/android/quickstep/SimpleTaskView.java | 52 ------ .../android/quickstep/TaskSystemShortcut.java | 3 +- .../quickstep/TouchInteractionService.java | 1 + .../WindowTransformSwipeHandler.java | 2 + .../quickstep/views/LauncherRecentsView.java | 134 ++++++++++++++ .../quickstep/{ => views}/RecentsView.java | 163 +++--------------- .../quickstep/{ => views}/TaskMenuView.java | 4 +- .../{ => views}/TaskThumbnailView.java | 8 +- .../quickstep/{ => views}/TaskView.java | 6 +- src/com/android/launcher3/BaseActivity.java | 15 ++ .../launcher3/InvariantDeviceProfile.java | 8 +- src/com/android/launcher3/Launcher.java | 10 +- 29 files changed, 391 insertions(+), 251 deletions(-) create mode 100644 quickstep/res/layout/fallback_recents_activity.xml create mode 100644 quickstep/src/com/android/quickstep/FallbackRecentsView.java create mode 100644 quickstep/src/com/android/quickstep/RecentsRootView.java delete mode 100644 quickstep/src/com/android/quickstep/SimpleTaskView.java create mode 100644 quickstep/src/com/android/quickstep/views/LauncherRecentsView.java rename quickstep/src/com/android/quickstep/{ => views}/RecentsView.java (80%) rename quickstep/src/com/android/quickstep/{ => views}/TaskMenuView.java (98%) rename quickstep/src/com/android/quickstep/{ => views}/TaskThumbnailView.java (96%) rename quickstep/src/com/android/quickstep/{ => views}/TaskView.java (97%) diff --git a/quickstep/res/layout/fallback_recents_activity.xml b/quickstep/res/layout/fallback_recents_activity.xml new file mode 100644 index 0000000000..c41684455b --- /dev/null +++ b/quickstep/res/layout/fallback_recents_activity.xml @@ -0,0 +1,29 @@ + + + + + + \ No newline at end of file diff --git a/quickstep/res/layout/overview_panel.xml b/quickstep/res/layout/overview_panel.xml index 54190ec66f..54a90cfe84 100644 --- a/quickstep/res/layout/overview_panel.xml +++ b/quickstep/res/layout/overview_panel.xml @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. --> - - \ No newline at end of file + \ No newline at end of file diff --git a/quickstep/res/layout/task.xml b/quickstep/res/layout/task.xml index 91b6aa3361..0ac2b11030 100644 --- a/quickstep/res/layout/task.xml +++ b/quickstep/res/layout/task.xml @@ -13,12 +13,12 @@ See the License for the specific language governing permissions and limitations under the License. --> - - - \ No newline at end of file + \ No newline at end of file diff --git a/quickstep/res/layout/task_menu.xml b/quickstep/res/layout/task_menu.xml index 6e3fb4fbdb..b8466652e5 100644 --- a/quickstep/res/layout/task_menu.xml +++ b/quickstep/res/layout/task_menu.xml @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. --> - - \ No newline at end of file + \ No newline at end of file diff --git a/quickstep/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java b/quickstep/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java index 3b75001eaf..ba0cbfa77d 100644 --- a/quickstep/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java +++ b/quickstep/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java @@ -59,9 +59,9 @@ import com.android.launcher3.shortcuts.DeepShortcutTextView; import com.android.launcher3.shortcuts.DeepShortcutView; import com.android.quickstep.RecentsAnimationInterpolator; import com.android.quickstep.RecentsAnimationInterpolator.TaskWindowBounds; -import com.android.quickstep.RecentsView; -import com.android.quickstep.TaskView; +import com.android.quickstep.views.RecentsView; import com.android.systemui.shared.recents.model.Task; +import com.android.quickstep.views.TaskView; import com.android.systemui.shared.system.ActivityCompat; import com.android.systemui.shared.system.ActivityOptionsCompat; import com.android.systemui.shared.system.RemoteAnimationAdapterCompat; diff --git a/quickstep/src/com/android/launcher3/uioverrides/EdgeSwipeController.java b/quickstep/src/com/android/launcher3/uioverrides/EdgeSwipeController.java index a55edfe4e7..97ac3e6069 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/EdgeSwipeController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/EdgeSwipeController.java @@ -36,7 +36,7 @@ import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch; import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction; import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType; import com.android.launcher3.util.VerticalSwipeController; -import com.android.quickstep.RecentsView; +import com.android.quickstep.views.RecentsView; class EventLogTags { private EventLogTags() { diff --git a/quickstep/src/com/android/launcher3/uioverrides/FastOverviewState.java b/quickstep/src/com/android/launcher3/uioverrides/FastOverviewState.java index 8a5c55af84..9541d0d052 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/FastOverviewState.java +++ b/quickstep/src/com/android/launcher3/uioverrides/FastOverviewState.java @@ -17,7 +17,7 @@ package com.android.launcher3.uioverrides; import com.android.launcher3.Launcher; import com.android.quickstep.QuickScrubController; -import com.android.quickstep.RecentsView; +import com.android.quickstep.views.RecentsView; /** * Extension of overview state used for QuickScrub diff --git a/quickstep/src/com/android/launcher3/uioverrides/OverviewState.java b/quickstep/src/com/android/launcher3/uioverrides/OverviewState.java index a88369d264..abb4ecf4c9 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/OverviewState.java +++ b/quickstep/src/com/android/launcher3/uioverrides/OverviewState.java @@ -26,7 +26,7 @@ import com.android.launcher3.Launcher; import com.android.launcher3.LauncherState; import com.android.launcher3.Workspace; import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType; -import com.android.quickstep.RecentsView; +import com.android.quickstep.views.RecentsView; /** * Definition for overview state diff --git a/quickstep/src/com/android/launcher3/uioverrides/OverviewSwipeController.java b/quickstep/src/com/android/launcher3/uioverrides/OverviewSwipeController.java index eb14d601b7..66f3450759 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/OverviewSwipeController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/OverviewSwipeController.java @@ -43,8 +43,8 @@ import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction; import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch; import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType; import com.android.launcher3.util.TouchController; -import com.android.quickstep.RecentsView; -import com.android.quickstep.TaskView; +import com.android.quickstep.views.RecentsView; +import com.android.quickstep.views.TaskView; /** * Touch controller for swipe interaction in Overview state diff --git a/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java b/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java index 132a0c5199..8b0793451b 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java @@ -32,8 +32,8 @@ import com.android.launcher3.anim.AnimationSuccessListener; import com.android.launcher3.anim.AnimatorSetBuilder; import com.android.launcher3.anim.Interpolators; import com.android.quickstep.AnimatedFloat; -import com.android.quickstep.RecentsView; -import com.android.quickstep.TaskView; +import com.android.quickstep.views.RecentsView; +import com.android.quickstep.views.TaskView; public class RecentsViewStateController implements StateHandler { @@ -50,7 +50,6 @@ public class RecentsViewStateController implements StateHandler { public RecentsViewStateController(Launcher launcher) { mLauncher = launcher; mRecentsView = launcher.getOverviewPanel(); - mRecentsView.setStateController(this); } @Override diff --git a/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java b/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java index 6b67fd434b..9051cfbfc2 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java +++ b/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java @@ -29,7 +29,7 @@ import com.android.launcher3.dragndrop.DragLayer; import com.android.launcher3.util.TouchController; import com.android.quickstep.OverviewInteractionState; import com.android.quickstep.RecentsModel; -import com.android.quickstep.RecentsView; +import com.android.quickstep.views.RecentsView; public class UiFactory { diff --git a/quickstep/src/com/android/quickstep/FallbackRecentsView.java b/quickstep/src/com/android/quickstep/FallbackRecentsView.java new file mode 100644 index 0000000000..22f6e0cc25 --- /dev/null +++ b/quickstep/src/com/android/quickstep/FallbackRecentsView.java @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2018 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.quickstep; + +import android.content.Context; +import android.graphics.Rect; +import android.util.AttributeSet; + +import com.android.launcher3.DeviceProfile; +import com.android.launcher3.Insettable; +import com.android.quickstep.views.RecentsView; + +public class FallbackRecentsView extends RecentsView implements Insettable { + + public FallbackRecentsView(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + public FallbackRecentsView(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + setOverviewStateEnabled(true); + } + + @Override + protected void onAllTasksRemoved() { + mActivity.finish(); + } + + @Override + public void setInsets(Rect insets) { + mInsets.set(insets); + DeviceProfile dp = mActivity.getDeviceProfile(); + Rect padding = getPadding(dp, getContext()); + verticalCenter(padding, dp); + setPadding(padding.left, padding.top, padding.right, padding.bottom); + } + + public static void verticalCenter(Rect padding, DeviceProfile dp) { + Rect insets = dp.getInsets(); + int totalSpace = (padding.top + padding.bottom - insets.top - insets.bottom) / 2; + padding.top = insets.top + totalSpace; + padding.bottom = insets.bottom + totalSpace; + } +} diff --git a/quickstep/src/com/android/quickstep/NavBarSwipeInteractionHandler.java b/quickstep/src/com/android/quickstep/NavBarSwipeInteractionHandler.java index fca844c6be..89c9d1611d 100644 --- a/quickstep/src/com/android/quickstep/NavBarSwipeInteractionHandler.java +++ b/quickstep/src/com/android/quickstep/NavBarSwipeInteractionHandler.java @@ -17,7 +17,6 @@ package com.android.quickstep; import static com.android.quickstep.TouchConsumer.INTERACTION_NORMAL; -import static com.android.quickstep.TouchConsumer.INTERACTION_QUICK_SCRUB; import static com.android.quickstep.TouchConsumer.INTERACTION_QUICK_SWITCH; import static com.android.quickstep.TouchConsumer.isInteractionQuick; @@ -51,6 +50,8 @@ import com.android.launcher3.anim.Interpolators; import com.android.launcher3.util.Preconditions; import com.android.launcher3.util.TraceHelper; import com.android.quickstep.TouchConsumer.InteractionType; +import com.android.quickstep.views.RecentsView; +import com.android.quickstep.views.TaskView; import com.android.systemui.shared.recents.model.RecentsTaskLoadPlan; import com.android.systemui.shared.recents.model.Task; import com.android.systemui.shared.system.ActivityManagerWrapper; diff --git a/quickstep/src/com/android/quickstep/OverviewCommandHelper.java b/quickstep/src/com/android/quickstep/OverviewCommandHelper.java index b60d1e2ddc..031624aaca 100644 --- a/quickstep/src/com/android/quickstep/OverviewCommandHelper.java +++ b/quickstep/src/com/android/quickstep/OverviewCommandHelper.java @@ -16,6 +16,7 @@ package com.android.quickstep; import static com.android.launcher3.LauncherState.OVERVIEW; +import static com.android.quickstep.TouchInteractionService.DEBUG_SHOW_OVERVIEW_BUTTON; import android.annotation.TargetApi; import android.app.ActivityManager.RecentTaskInfo; @@ -40,6 +41,8 @@ import com.android.systemui.shared.system.ActivityManagerWrapper; @TargetApi(Build.VERSION_CODES.P) public class OverviewCommandHelper extends InternalStateHandler { + private static final boolean DEBUG_START_FALLBACK_ACTIVITY = DEBUG_SHOW_OVERVIEW_BUTTON; + private final Context mContext; private final ActivityManagerWrapper mAM; @@ -63,6 +66,12 @@ public class OverviewCommandHelper extends InternalStateHandler { } public void onOverviewToggle() { + if (DEBUG_START_FALLBACK_ACTIVITY) { + mContext.startActivity(new Intent(mContext, RecentsActivity.class) + .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK)); + return; + } + long elapsedTime = SystemClock.elapsedRealtime() - mLastToggleTime; mLastToggleTime = SystemClock.elapsedRealtime(); diff --git a/quickstep/src/com/android/quickstep/QuickScrubController.java b/quickstep/src/com/android/quickstep/QuickScrubController.java index 0ccd7f22fc..a154b291e2 100644 --- a/quickstep/src/com/android/quickstep/QuickScrubController.java +++ b/quickstep/src/com/android/quickstep/QuickScrubController.java @@ -19,12 +19,14 @@ package com.android.quickstep; import android.view.HapticFeedbackConstants; import com.android.launcher3.Alarm; -import com.android.launcher3.Launcher; +import com.android.launcher3.BaseActivity; import com.android.launcher3.OnAlarmListener; import com.android.launcher3.Utilities; import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch; import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType; import com.android.launcher3.userevent.nano.LauncherLogProto.ControlType; +import com.android.quickstep.views.RecentsView; +import com.android.quickstep.views.TaskView; /** * Responds to quick scrub callbacks to page through and launch recent tasks. @@ -45,7 +47,7 @@ public class QuickScrubController implements OnAlarmListener { private final Alarm mAutoAdvanceAlarm; private final RecentsView mRecentsView; - private final Launcher mLauncher; + private final BaseActivity mActivity; private boolean mInQuickScrub; private int mQuickScrubSection; @@ -54,8 +56,8 @@ public class QuickScrubController implements OnAlarmListener { private boolean mQuickSwitched; private boolean mFinishedTransitionToQuickScrub; - public QuickScrubController(Launcher launcher, RecentsView recentsView) { - mLauncher = launcher; + public QuickScrubController(BaseActivity activity, RecentsView recentsView) { + mActivity = activity; mRecentsView = recentsView; if (ENABLE_AUTO_ADVANCE) { mAutoAdvanceAlarm = new Alarm(); @@ -72,7 +74,7 @@ public class QuickScrubController implements OnAlarmListener { mFinishedTransitionToQuickScrub = false; snapToNextTaskIfAvailable(); - mLauncher.getUserEventDispatcher().resetActionDurationMillis(); + mActivity.getUserEventDispatcher().resetActionDurationMillis(); } public void onQuickScrubEnd() { @@ -93,7 +95,7 @@ public class QuickScrubController implements OnAlarmListener { // No page move needed, just launch it launchTaskRunnable.run(); } - mLauncher.getUserEventDispatcher().logActionOnControl(Touch.DRAGDROP, + mActivity.getUserEventDispatcher().logActionOnControl(Touch.DRAGDROP, ControlType.QUICK_SCRUB_BUTTON, null, mStartedFromHome ? ContainerType.WORKSPACE : ContainerType.APP); } @@ -134,7 +136,7 @@ public class QuickScrubController implements OnAlarmListener { private void quickSwitchIfReady() { if (mQuickSwitched && mFinishedTransitionToQuickScrub) { onQuickScrubEnd(); - mLauncher.getUserEventDispatcher().logActionOnControl(Touch.FLING, + mActivity.getUserEventDispatcher().logActionOnControl(Touch.FLING, ControlType.QUICK_SCRUB_BUTTON, null, mStartedFromHome ? ContainerType.WORKSPACE : ContainerType.APP); } diff --git a/quickstep/src/com/android/quickstep/RecentsActivity.java b/quickstep/src/com/android/quickstep/RecentsActivity.java index f92d773bd6..598c34de0e 100644 --- a/quickstep/src/com/android/quickstep/RecentsActivity.java +++ b/quickstep/src/com/android/quickstep/RecentsActivity.java @@ -15,34 +15,29 @@ */ package com.android.quickstep; -import android.app.ListActivity; import android.os.Bundle; -import android.os.UserHandle; -import android.support.annotation.Nullable; -import android.widget.ArrayAdapter; -import com.android.systemui.shared.recents.model.RecentsTaskLoadPlan; -import com.android.systemui.shared.recents.model.RecentsTaskLoadPlan.PreloadOptions; -import com.android.systemui.shared.recents.model.RecentsTaskLoader; -import com.android.systemui.shared.recents.model.Task; +import com.android.launcher3.BaseActivity; +import com.android.launcher3.InvariantDeviceProfile; +import com.android.launcher3.LauncherAppState; +import com.android.launcher3.R; /** * A simple activity to show the recently launched tasks */ -public class RecentsActivity extends ListActivity { - - private ArrayAdapter mAdapter; +public class RecentsActivity extends BaseActivity { @Override - protected void onCreate(@Nullable Bundle savedInstanceState) { + protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - RecentsTaskLoadPlan plan = new RecentsTaskLoadPlan(this); - plan.preloadPlan(new PreloadOptions(), new RecentsTaskLoader(this, 1, 1, 0), -1, - UserHandle.myUserId()); + // In case we are reusing IDP, create a copy so that we dont conflict with Launcher + // activity. + LauncherAppState appState = LauncherAppState.getInstanceNoCreate(); + setDeviceProfile(appState != null + ? appState.getInvariantDeviceProfile().getDeviceProfile(this).copy(this) + : new InvariantDeviceProfile(this).getDeviceProfile(this)); - mAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1); - mAdapter.addAll(plan.getTaskStack().getTasks()); - setListAdapter(mAdapter); + setContentView(R.layout.fallback_recents_activity); } } diff --git a/quickstep/src/com/android/quickstep/RecentsRootView.java b/quickstep/src/com/android/quickstep/RecentsRootView.java new file mode 100644 index 0000000000..3c69dbfd64 --- /dev/null +++ b/quickstep/src/com/android/quickstep/RecentsRootView.java @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2018 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.quickstep; + +import android.annotation.TargetApi; +import android.content.Context; +import android.graphics.Rect; +import android.util.AttributeSet; + +import com.android.launcher3.BaseActivity; +import com.android.launcher3.InsettableFrameLayout; +import com.android.launcher3.R; +import com.android.launcher3.util.Themes; + +public class RecentsRootView extends InsettableFrameLayout { + + private final BaseActivity mActivity; + + public RecentsRootView(Context context, AttributeSet attrs) { + super(context, attrs); + mActivity = BaseActivity.fromContext(context); + } + + @TargetApi(23) + @Override + protected boolean fitSystemWindows(Rect insets) { + // Update device profile before notifying the children. + mActivity.getDeviceProfile().updateInsets(insets); + setInsets(insets); + return true; // I'll take it from here + } + + @Override + public void setInsets(Rect insets) { + // If the insets haven't changed, this is a no-op. Avoid unnecessary layout caused by + // modifying child layout params. + if (!insets.equals(mInsets)) { + super.setInsets(insets); + } + setBackground(insets.top == 0 ? null + : Themes.getAttrDrawable(getContext(), R.attr.workspaceStatusBarScrim)); + } +} \ No newline at end of file diff --git a/quickstep/src/com/android/quickstep/SimpleTaskView.java b/quickstep/src/com/android/quickstep/SimpleTaskView.java deleted file mode 100644 index 8425fa3ba4..0000000000 --- a/quickstep/src/com/android/quickstep/SimpleTaskView.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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.quickstep; - -import android.content.Context; -import android.graphics.Point; -import android.util.AttributeSet; -import android.view.View; -import android.view.WindowManager; - -/** - * A simple view which keeps its size proportional to the display size - */ -public class SimpleTaskView extends View { - - private static final Point sTempPoint = new Point(); - - public SimpleTaskView(Context context) { - super(context); - } - - public SimpleTaskView(Context context, AttributeSet attrs) { - super(context, attrs); - } - - public SimpleTaskView(Context context, AttributeSet attrs, int defStyleAttr) { - super(context, attrs, defStyleAttr); - } - - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - int height = MeasureSpec.getSize(heightMeasureSpec); - getContext().getSystemService(WindowManager.class) - .getDefaultDisplay().getRealSize(sTempPoint); - - int width = (int) ((float) height * sTempPoint.x / sTempPoint.y); - setMeasuredDimension(width, height); - } -} diff --git a/quickstep/src/com/android/quickstep/TaskSystemShortcut.java b/quickstep/src/com/android/quickstep/TaskSystemShortcut.java index fb14fb8074..eebfb91654 100644 --- a/quickstep/src/com/android/quickstep/TaskSystemShortcut.java +++ b/quickstep/src/com/android/quickstep/TaskSystemShortcut.java @@ -16,7 +16,6 @@ package com.android.quickstep; -import android.app.ActivityOptions; import android.content.ComponentName; import android.content.Intent; import android.graphics.Bitmap; @@ -37,6 +36,8 @@ import com.android.launcher3.R; import com.android.launcher3.ShortcutInfo; import com.android.launcher3.popup.SystemShortcut; import com.android.launcher3.util.InstantAppResolver; +import com.android.quickstep.views.RecentsView; +import com.android.quickstep.views.TaskView; import com.android.systemui.shared.recents.ISystemUiProxy; import com.android.systemui.shared.recents.model.Task; import com.android.systemui.shared.recents.view.AppTransitionAnimationSpecCompat; diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java index 04740d98a5..a522ef184e 100644 --- a/quickstep/src/com/android/quickstep/TouchInteractionService.java +++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java @@ -49,6 +49,7 @@ import com.android.launcher3.MainThreadExecutor; import com.android.launcher3.R; import com.android.launcher3.uioverrides.UiFactory; import com.android.launcher3.util.TraceHelper; +import com.android.quickstep.views.RecentsView; import com.android.systemui.shared.recents.IOverviewProxy; import com.android.systemui.shared.recents.ISystemUiProxy; import com.android.systemui.shared.system.ActivityManagerWrapper; diff --git a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java index 0d308a0c95..af09842790 100644 --- a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java +++ b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java @@ -71,6 +71,8 @@ import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType; import com.android.launcher3.util.TraceHelper; import com.android.launcher3.util.ViewOnDrawExecutor; import com.android.quickstep.TouchConsumer.InteractionType; +import com.android.quickstep.views.RecentsView; +import com.android.quickstep.views.TaskView; import com.android.systemui.shared.recents.model.ThumbnailData; import com.android.systemui.shared.recents.utilities.RectFEvaluator; import com.android.systemui.shared.system.InputConsumerController; diff --git a/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java b/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java new file mode 100644 index 0000000000..7989e845ca --- /dev/null +++ b/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java @@ -0,0 +1,134 @@ +/* + * Copyright (C) 2018 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.quickstep.views; + +import static com.android.launcher3.LauncherState.NORMAL; + +import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.BitmapShader; +import android.graphics.Canvas; +import android.graphics.Matrix; +import android.graphics.Paint; +import android.graphics.PorterDuff.Mode; +import android.graphics.PorterDuffXfermode; +import android.graphics.Rect; +import android.graphics.Shader; +import android.graphics.Shader.TileMode; +import android.graphics.drawable.BitmapDrawable; +import android.graphics.drawable.Drawable; +import android.util.AttributeSet; +import android.widget.FrameLayout; + +import com.android.launcher3.DeviceProfile; +import com.android.launcher3.Insettable; +import com.android.launcher3.Launcher; +import com.android.launcher3.R; + +/** + * {@link RecentsView} used in Launcher activity + */ +public class LauncherRecentsView extends RecentsView implements Insettable { + + private Bitmap mScrim; + private Paint mFadePaint; + private Shader mFadeShader; + private Matrix mFadeMatrix; + private boolean mScrimOnLeft; + + public LauncherRecentsView(Context context) { + this(context, null); + } + + public LauncherRecentsView(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + public LauncherRecentsView(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + } + + @Override + public void setInsets(Rect insets) { + mInsets.set(insets); + DeviceProfile dp = mActivity.getDeviceProfile(); + Rect padding = getPadding(dp, getContext()); + FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) getLayoutParams(); + lp.bottomMargin = padding.bottom; + setLayoutParams(lp); + + setPadding(padding.left, padding.top, padding.right, 0); + + if (dp.isVerticalBarLayout()) { + boolean wasScrimOnLeft = mScrimOnLeft; + mScrimOnLeft = dp.isSeascape(); + + if (mScrim == null || wasScrimOnLeft != mScrimOnLeft) { + Drawable scrim = getContext().getDrawable(mScrimOnLeft + ? R.drawable.recents_horizontal_scrim_left + : R.drawable.recents_horizontal_scrim_right); + if (scrim instanceof BitmapDrawable) { + mScrim = ((BitmapDrawable) scrim).getBitmap(); + mFadePaint = new Paint(); + mFadePaint.setXfermode(new PorterDuffXfermode(Mode.DST_IN)); + mFadeShader = new BitmapShader(mScrim, TileMode.CLAMP, TileMode.REPEAT); + mFadeMatrix = new Matrix(); + } else { + mScrim = null; + } + } + } else { + mScrim = null; + mFadePaint = null; + mFadeShader = null; + mFadeMatrix = null; + } + } + + @Override + public void draw(Canvas canvas) { + if (mScrim == null) { + super.draw(canvas); + return; + } + + final int flags = Canvas.HAS_ALPHA_LAYER_SAVE_FLAG; + + int length = mScrim.getWidth(); + int height = getHeight(); + int saveCount = canvas.getSaveCount(); + + int scrimLeft; + if (mScrimOnLeft) { + scrimLeft = getScrollX(); + } else { + scrimLeft = getScrollX() + getWidth() - length; + } + canvas.saveLayer(scrimLeft, 0, scrimLeft + length, height, null, flags); + super.draw(canvas); + + mFadeMatrix.setTranslate(scrimLeft, 0); + mFadeShader.setLocalMatrix(mFadeMatrix); + mFadePaint.setShader(mFadeShader); + canvas.drawRect(scrimLeft, 0, scrimLeft + length, height, mFadePaint); + canvas.restoreToCount(saveCount); + } + + @Override + protected void onAllTasksRemoved() { + mActivity.getStateManager().goToState(NORMAL); + } +} diff --git a/quickstep/src/com/android/quickstep/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java similarity index 80% rename from quickstep/src/com/android/quickstep/RecentsView.java rename to quickstep/src/com/android/quickstep/views/RecentsView.java index 52d95e5d68..fb0a757f66 100644 --- a/quickstep/src/com/android/quickstep/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -14,42 +14,27 @@ * limitations under the License. */ -package com.android.quickstep; - -import static com.android.launcher3.LauncherState.NORMAL; +package com.android.quickstep.views; import android.animation.LayoutTransition; import android.animation.LayoutTransition.TransitionListener; import android.content.Context; import android.content.SharedPreferences; import android.content.SharedPreferences.OnSharedPreferenceChangeListener; -import android.content.res.Resources; -import android.graphics.Bitmap; -import android.graphics.BitmapShader; -import android.graphics.Canvas; -import android.graphics.Matrix; -import android.graphics.Paint; -import android.graphics.PorterDuff.Mode; -import android.graphics.PorterDuffXfermode; import android.graphics.Rect; -import android.graphics.Shader; -import android.graphics.Shader.TileMode; -import android.graphics.drawable.BitmapDrawable; -import android.graphics.drawable.Drawable; import android.util.AttributeSet; import android.util.SparseBooleanArray; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.FrameLayout; +import com.android.launcher3.BaseActivity; import com.android.launcher3.DeviceProfile; -import com.android.launcher3.Insettable; -import com.android.launcher3.Launcher; import com.android.launcher3.PagedView; import com.android.launcher3.R; import com.android.launcher3.Utilities; -import com.android.launcher3.uioverrides.RecentsViewStateController; +import com.android.quickstep.QuickScrubController; +import com.android.quickstep.RecentsModel; import com.android.systemui.shared.recents.model.RecentsTaskLoadPlan; import com.android.systemui.shared.recents.model.RecentsTaskLoader; import com.android.systemui.shared.recents.model.Task; @@ -64,26 +49,26 @@ import java.util.ArrayList; /** * A list of recent tasks. */ -public class RecentsView extends PagedView implements Insettable, OnSharedPreferenceChangeListener { - - private static final Rect sTempStableInsets = new Rect(); +public abstract class RecentsView + extends PagedView implements OnSharedPreferenceChangeListener { private static final String PREF_FLIP_RECENTS = "pref_flip_recents"; - private final Launcher mLauncher; - private QuickScrubController mQuickScrubController; - private final ScrollState mScrollState = new ScrollState(); - private boolean mOverviewStateEnabled; - private boolean mTaskStackListenerRegistered; - private LayoutTransition mLayoutTransition; - private Runnable mNextPageSwitchRunnable; + private static final Rect sTempStableInsets = new Rect(); - private float mFastFlingVelocity; + protected final T mActivity; + private final QuickScrubController mQuickScrubController; + private final float mFastFlingVelocity; + private final RecentsModel mModel; + + private final ScrollState mScrollState = new ScrollState(); + // Keeps track of the previously known visible tasks for purposes of loading/unloading task data + private final SparseBooleanArray mHasVisibleTaskData = new SparseBooleanArray(); /** * TODO: Call reloadIdNeeded in onTaskStackChanged. */ - private TaskStackChangeListener mTaskStackListener = new TaskStackChangeListener() { + private final TaskStackChangeListener mTaskStackListener = new TaskStackChangeListener() { @Override public void onTaskSnapshotChanged(int taskId, ThumbnailData snapshot) { for (int i = 0; i < getChildCount(); i++) { @@ -96,32 +81,17 @@ public class RecentsView extends PagedView implements Insettable, OnSharedPrefer } }; - private RecentsViewStateController mStateController; - - private final RecentsModel mModel; private int mLoadPlanId = -1; // Only valid until the launcher state changes to NORMAL private int mRunningTaskId = -1; - private Bitmap mScrim; - private Paint mFadePaint; - private Shader mFadeShader; - private Matrix mFadeMatrix; - private boolean mScrimOnLeft; - private boolean mFirstTaskIconScaledDown = false; - // Keeps track of the previously known visible tasks for purposes of loading/unloading task data - private SparseBooleanArray mHasVisibleTaskData = new SparseBooleanArray(); - - public RecentsView(Context context) { - this(context, null); - } - - public RecentsView(Context context, AttributeSet attrs) { - this(context, attrs, 0); - } + private boolean mOverviewStateEnabled; + private boolean mTaskStackListenerRegistered; + private LayoutTransition mLayoutTransition; + private Runnable mNextPageSwitchRunnable; public RecentsView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); @@ -130,8 +100,10 @@ public class RecentsView extends PagedView implements Insettable, OnSharedPrefer setupLayoutTransition(); setClipToOutline(true); - mLauncher = Launcher.getLauncher(context); - mQuickScrubController = new QuickScrubController(mLauncher, this); + mFastFlingVelocity = getResources() + .getDimensionPixelSize(R.dimen.recents_fast_fling_velocity); + mActivity = (T) BaseActivity.fromContext(context); + mQuickScrubController = new QuickScrubController(mActivity, this); mModel = RecentsModel.getInstance(context); onSharedPreferenceChanged(Utilities.getPrefs(context), PREF_FLIP_RECENTS); @@ -191,13 +163,6 @@ public class RecentsView extends PagedView implements Insettable, OnSharedPrefer setLayoutTransition(mLayoutTransition); } - @Override - protected void onFinishInflate() { - super.onFinishInflate(); - Resources res = getResources(); - mFastFlingVelocity = res.getDimensionPixelSize(R.dimen.recents_fast_fling_velocity); - } - @Override protected void onWindowVisibilityChanged(int visibility) { super.onWindowVisibilityChanged(visibility); @@ -232,43 +197,6 @@ public class RecentsView extends PagedView implements Insettable, OnSharedPrefer } } - @Override - public void setInsets(Rect insets) { - mInsets.set(insets); - DeviceProfile dp = Launcher.getLauncher(getContext()).getDeviceProfile(); - Rect padding = getPadding(dp, getContext()); - FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) getLayoutParams(); - lp.bottomMargin = padding.bottom; - setLayoutParams(lp); - - setPadding(padding.left, padding.top, padding.right, 0); - - if (dp.isVerticalBarLayout()) { - boolean wasScrimOnLeft = mScrimOnLeft; - mScrimOnLeft = dp.isSeascape(); - - if (mScrim == null || wasScrimOnLeft != mScrimOnLeft) { - Drawable scrim = getContext().getDrawable(mScrimOnLeft - ? R.drawable.recents_horizontal_scrim_left - : R.drawable.recents_horizontal_scrim_right); - if (scrim instanceof BitmapDrawable) { - mScrim = ((BitmapDrawable) scrim).getBitmap(); - mFadePaint = new Paint(); - mFadePaint.setXfermode(new PorterDuffXfermode(Mode.DST_IN)); - mFadeShader = new BitmapShader(mScrim, TileMode.CLAMP, TileMode.REPEAT); - mFadeMatrix = new Matrix(); - } else { - mScrim = null; - } - } - } else { - mScrim = null; - mFadePaint = null; - mFadeShader = null; - mFadeMatrix = null; - } - } - public boolean isTaskViewVisible(TaskView tv) { // For now, just check if it's the active task or an adjacent task return Math.abs(indexOfChild(tv) - getNextPage()) <= 1; @@ -284,14 +212,6 @@ public class RecentsView extends PagedView implements Insettable, OnSharedPrefer return null; } - public void setStateController(RecentsViewStateController stateController) { - mStateController = stateController; - } - - public RecentsViewStateController getStateController() { - return mStateController; - } - public void setOverviewStateEnabled(boolean enabled) { mOverviewStateEnabled = enabled; updateTaskStackListenerState(); @@ -374,7 +294,7 @@ public class RecentsView extends PagedView implements Insettable, OnSharedPrefer } } - private static Rect getPadding(DeviceProfile profile, Context context) { + protected static Rect getPadding(DeviceProfile profile, Context context) { WindowManagerWrapper.getInstance().getStableInsets(sTempStableInsets); Rect padding = new Rect(profile.workspacePadding); @@ -516,10 +436,12 @@ public class RecentsView extends PagedView implements Insettable, OnSharedPrefer ActivityManagerWrapper.getInstance().removeTask(taskView.getTask().key.id); removeView(taskView); if (getChildCount() == 0) { - mLauncher.getStateManager().goToState(NORMAL); + onAllTasksRemoved(); } } + protected abstract void onAllTasksRemoved(); + public void reset() { unloadVisibleTaskData(); mRunningTaskId = -1; @@ -591,35 +513,6 @@ public class RecentsView extends PagedView implements Insettable, OnSharedPrefer } } - @Override - public void draw(Canvas canvas) { - if (mScrim == null) { - super.draw(canvas); - return; - } - - final int flags = Canvas.HAS_ALPHA_LAYER_SAVE_FLAG; - - int length = mScrim.getWidth(); - int height = getHeight(); - int saveCount = canvas.getSaveCount(); - - int scrimLeft; - if (mScrimOnLeft) { - scrimLeft = getScrollX(); - } else { - scrimLeft = getScrollX() + getWidth() - length; - } - canvas.saveLayer(scrimLeft, 0, scrimLeft + length, height, null, flags); - super.draw(canvas); - - mFadeMatrix.setTranslate(scrimLeft, 0); - mFadeShader.setLocalMatrix(mFadeMatrix); - mFadePaint.setShader(mFadeShader); - canvas.drawRect(scrimLeft, 0, scrimLeft + length, height, mFadePaint); - canvas.restoreToCount(saveCount); - } - public interface PageCallbacks { /** diff --git a/quickstep/src/com/android/quickstep/TaskMenuView.java b/quickstep/src/com/android/quickstep/views/TaskMenuView.java similarity index 98% rename from quickstep/src/com/android/quickstep/TaskMenuView.java rename to quickstep/src/com/android/quickstep/views/TaskMenuView.java index 6bbcb37395..94f440dcd8 100644 --- a/quickstep/src/com/android/quickstep/TaskMenuView.java +++ b/quickstep/src/com/android/quickstep/views/TaskMenuView.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.quickstep; +package com.android.quickstep.views; import android.animation.Animator; import android.animation.AnimatorSet; @@ -40,6 +40,8 @@ import com.android.launcher3.anim.AnimationSuccessListener; import com.android.launcher3.anim.RoundedRectRevealOutlineProvider; import com.android.launcher3.dragndrop.DragLayer; import com.android.launcher3.shortcuts.DeepShortcutView; +import com.android.quickstep.TaskSystemShortcut; +import com.android.quickstep.TaskUtils; /** * Contains options for a recent task when long-pressing its icon. diff --git a/quickstep/src/com/android/quickstep/TaskThumbnailView.java b/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java similarity index 96% rename from quickstep/src/com/android/quickstep/TaskThumbnailView.java rename to quickstep/src/com/android/quickstep/views/TaskThumbnailView.java index 2cdd4e98d0..87bb53bb61 100644 --- a/quickstep/src/com/android/quickstep/TaskThumbnailView.java +++ b/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.quickstep; +package com.android.quickstep.views; import android.content.Context; import android.content.res.Configuration; @@ -33,9 +33,10 @@ import android.graphics.Shader; import android.util.AttributeSet; import android.view.View; +import com.android.launcher3.BaseActivity; import com.android.launcher3.DeviceProfile; -import com.android.launcher3.Launcher; import com.android.launcher3.R; +import com.android.quickstep.TaskOverlayFactory; import com.android.quickstep.TaskOverlayFactory.TaskOverlay; import com.android.systemui.shared.recents.model.Task; import com.android.systemui.shared.recents.model.ThumbnailData; @@ -152,7 +153,8 @@ public class TaskThumbnailView extends View { } else { final Configuration configuration = getContext().getApplicationContext().getResources().getConfiguration(); - final DeviceProfile profile = Launcher.getLauncher(getContext()).getDeviceProfile(); + final DeviceProfile profile = BaseActivity.fromContext(getContext()) + .getDeviceProfile(); if (configuration.orientation == mThumbnailData.orientation) { // If we are in the same orientation as the screenshot, just scale it to the // width of the task view diff --git a/quickstep/src/com/android/quickstep/TaskView.java b/quickstep/src/com/android/quickstep/views/TaskView.java similarity index 97% rename from quickstep/src/com/android/quickstep/TaskView.java rename to quickstep/src/com/android/quickstep/views/TaskView.java index e0b03b8fcf..4d734a2b6f 100644 --- a/quickstep/src/com/android/quickstep/TaskView.java +++ b/quickstep/src/com/android/quickstep/views/TaskView.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.quickstep; +package com.android.quickstep.views; import android.animation.TimeInterpolator; import android.app.ActivityOptions; @@ -30,8 +30,8 @@ import android.widget.ImageView; import com.android.launcher3.Launcher; import com.android.launcher3.R; -import com.android.quickstep.RecentsView.PageCallbacks; -import com.android.quickstep.RecentsView.ScrollState; +import com.android.quickstep.views.RecentsView.PageCallbacks; +import com.android.quickstep.views.RecentsView.ScrollState; import com.android.systemui.shared.recents.model.Task; import com.android.systemui.shared.recents.model.Task.TaskCallbacks; import com.android.systemui.shared.recents.model.ThumbnailData; diff --git a/src/com/android/launcher3/BaseActivity.java b/src/com/android/launcher3/BaseActivity.java index 12db3b69db..77a430bb33 100644 --- a/src/com/android/launcher3/BaseActivity.java +++ b/src/com/android/launcher3/BaseActivity.java @@ -20,6 +20,8 @@ import android.app.Activity; import android.content.Context; import android.content.ContextWrapper; import android.content.Intent; +import android.graphics.Point; +import android.view.Display; import android.view.View.AccessibilityDelegate; import com.android.launcher3.DeviceProfile.OnDeviceProfileChangeListener; @@ -102,4 +104,17 @@ public abstract class BaseActivity extends Activity { mDPChangeListeners.get(i).onDeviceProfileChanged(mDeviceProfile); } } + + /** + * Sets the device profile, adjusting it accordingly in case of multi-window + */ + protected void setDeviceProfile(DeviceProfile dp) { + mDeviceProfile = dp; + if (isInMultiWindowModeCompat()) { + Display display = getWindowManager().getDefaultDisplay(); + Point mwSize = new Point(); + display.getSize(mwSize); + mDeviceProfile = mDeviceProfile.getMultiWindowProfile(this, mwSize); + } + } } diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java index e4609119f2..f63cce58d2 100644 --- a/src/com/android/launcher3/InvariantDeviceProfile.java +++ b/src/com/android/launcher3/InvariantDeviceProfile.java @@ -22,6 +22,7 @@ import android.content.res.Configuration; import android.content.res.TypedArray; import android.content.res.XmlResourceParser; import android.graphics.Point; +import android.support.annotation.VisibleForTesting; import android.util.DisplayMetrics; import android.util.Xml; import android.view.Display; @@ -88,17 +89,18 @@ public class InvariantDeviceProfile { public Point defaultWallpaperSize; + @VisibleForTesting public InvariantDeviceProfile() { } - public InvariantDeviceProfile(InvariantDeviceProfile p) { + private InvariantDeviceProfile(InvariantDeviceProfile p) { this(p.name, p.minWidthDps, p.minHeightDps, p.numRows, p.numColumns, p.numFolderRows, p.numFolderColumns, p.iconSize, p.landscapeIconSize, p.iconTextSize, p.numHotseatIcons, p.defaultLayoutId, p.demoModeLayoutId); } - InvariantDeviceProfile(String n, float w, float h, int r, int c, int fr, int fc, + private InvariantDeviceProfile(String n, float w, float h, int r, int c, int fr, int fc, float is, float lis, float its, int hs, int dlId, int dmlId) { name = n; minWidthDps = w; @@ -116,7 +118,7 @@ public class InvariantDeviceProfile { } @TargetApi(23) - InvariantDeviceProfile(Context context) { + public InvariantDeviceProfile(Context context) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); DisplayMetrics dm = new DisplayMetrics(); diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index b4f9409d53..0bbb90c452 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -47,7 +47,6 @@ import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.content.res.Configuration; import android.database.sqlite.SQLiteDatabase; -import android.graphics.Point; import android.graphics.Rect; import android.os.AsyncTask; import android.os.Build; @@ -62,7 +61,6 @@ import android.text.method.TextKeyListener; import android.util.Log; import android.util.SparseArray; import android.view.ActionMode; -import android.view.Display; import android.view.KeyEvent; import android.view.KeyboardShortcutGroup; import android.view.KeyboardShortcutInfo; @@ -401,13 +399,7 @@ public class Launcher extends BaseActivity implements LauncherExterns, LauncherM private void initDeviceProfile(InvariantDeviceProfile idp) { // Load configuration-specific DeviceProfile - mDeviceProfile = idp.getDeviceProfile(this); - if (isInMultiWindowModeCompat()) { - Display display = getWindowManager().getDefaultDisplay(); - Point mwSize = new Point(); - display.getSize(mwSize); - mDeviceProfile = mDeviceProfile.getMultiWindowProfile(this, mwSize); - } + setDeviceProfile(idp.getDeviceProfile(this)); mModelWriter = mModel.getWriter(mDeviceProfile.isVerticalBarLayout(), true); }