Winson | 35f3050 | 2015-09-28 11:24:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.systemui.recents; |
| 18 | |
| 19 | /** |
| 20 | * The launch state of the RecentsActivity. |
| 21 | * |
Winson | 35f3050 | 2015-09-28 11:24:36 -0700 | [diff] [blame] | 22 | * Current Constraints: |
| 23 | * - needed in onStart() before onNewIntent() |
| 24 | * - needs to be reset when Recents is hidden |
| 25 | * - needs to be computed in Recents component |
| 26 | * - needs to be accessible by views |
| 27 | */ |
| 28 | public class RecentsActivityLaunchState { |
| 29 | |
Winson | 35f3050 | 2015-09-28 11:24:36 -0700 | [diff] [blame] | 30 | public boolean launchedWithAltTab; |
Winson | 35f3050 | 2015-09-28 11:24:36 -0700 | [diff] [blame] | 31 | public boolean launchedFromAppWithThumbnail; |
| 32 | public boolean launchedFromHome; |
| 33 | public boolean launchedFromSearchHome; |
| 34 | public boolean launchedReuseTaskStackViews; |
| 35 | public boolean launchedHasConfigurationChanged; |
Winson | b1e71d0 | 2015-11-23 12:40:23 -0800 | [diff] [blame] | 36 | public boolean launchedViaDragGesture; |
Jorim Jaggi | e161f08 | 2016-02-05 14:26:16 -0800 | [diff] [blame] | 37 | public boolean launchedWhileDocking; |
Winson | 35f3050 | 2015-09-28 11:24:36 -0700 | [diff] [blame] | 38 | public int launchedToTaskId; |
| 39 | public int launchedNumVisibleTasks; |
| 40 | public int launchedNumVisibleThumbnails; |
| 41 | |
Jorim Jaggi | e161f08 | 2016-02-05 14:26:16 -0800 | [diff] [blame] | 42 | public void reset() { |
| 43 | launchedFromHome = false; |
| 44 | launchedFromSearchHome = false; |
| 45 | launchedFromAppWithThumbnail = false; |
| 46 | launchedToTaskId = -1; |
| 47 | launchedWithAltTab = false; |
| 48 | launchedHasConfigurationChanged = false; |
| 49 | launchedViaDragGesture = false; |
| 50 | launchedWhileDocking = false; |
| 51 | } |
| 52 | |
Winson | 35f3050 | 2015-09-28 11:24:36 -0700 | [diff] [blame] | 53 | /** Called when the configuration has changed, and we want to reset any configuration specific |
| 54 | * members. */ |
| 55 | public void updateOnConfigurationChange() { |
| 56 | // Reset this flag on configuration change to ensure that we recreate new task views |
| 57 | launchedReuseTaskStackViews = false; |
| 58 | // Set this flag to indicate that the configuration has changed since Recents last launched |
| 59 | launchedHasConfigurationChanged = true; |
Jorim Jaggi | 435b2e4 | 2015-11-24 15:09:30 -0800 | [diff] [blame] | 60 | launchedViaDragGesture = false; |
Jorim Jaggi | e161f08 | 2016-02-05 14:26:16 -0800 | [diff] [blame] | 61 | launchedWhileDocking = false; |
Winson | 35f3050 | 2015-09-28 11:24:36 -0700 | [diff] [blame] | 62 | } |
| 63 | |
Winson | 5da4347 | 2015-11-04 17:39:55 -0800 | [diff] [blame] | 64 | /** |
| 65 | * Returns the task to focus given the current launch state. |
| 66 | */ |
| 67 | public int getInitialFocusTaskIndex(int numTasks) { |
Winson | b61e654 | 2016-02-04 14:37:18 -0800 | [diff] [blame] | 68 | RecentsDebugFlags debugFlags = Recents.getDebugFlags(); |
Winson | 4b9cded | 2016-01-26 16:26:47 -0800 | [diff] [blame] | 69 | if (launchedFromAppWithThumbnail) { |
Winson | b61e654 | 2016-02-04 14:37:18 -0800 | [diff] [blame] | 70 | if (debugFlags.isFastToggleRecentsEnabled()) { |
| 71 | // If fast toggling, focus the front most task so that the next tap will focus the |
| 72 | // N-1 task |
| 73 | return numTasks - 1; |
| 74 | } |
| 75 | |
Winson | 4b9cded | 2016-01-26 16:26:47 -0800 | [diff] [blame] | 76 | // If coming from another app, focus the next task |
| 77 | return numTasks - 2; |
Winson Chung | ead5c0f | 2015-12-14 11:18:57 -0500 | [diff] [blame] | 78 | } else { |
Winson | b61e654 | 2016-02-04 14:37:18 -0800 | [diff] [blame] | 79 | if (debugFlags.isFastToggleRecentsEnabled()) { |
| 80 | // If fast toggling, defer focusing until the next tap (which will automatically |
| 81 | // focus the front most task) |
| 82 | return -1; |
| 83 | } |
| 84 | |
Winson | 4b9cded | 2016-01-26 16:26:47 -0800 | [diff] [blame] | 85 | // If coming from home, focus the first task |
| 86 | return numTasks - 1; |
Winson | 5da4347 | 2015-11-04 17:39:55 -0800 | [diff] [blame] | 87 | } |
Winson | 5da4347 | 2015-11-04 17:39:55 -0800 | [diff] [blame] | 88 | } |
Winson | 35f3050 | 2015-09-28 11:24:36 -0700 | [diff] [blame] | 89 | } |