1303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung/*
2303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung * Copyright (C) 2014 The Android Open Source Project
3303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung *
4303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung * Licensed under the Apache License, Version 2.0 (the "License");
5303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung * you may not use this file except in compliance with the License.
6303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung * You may obtain a copy of the License at
7303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung *
8303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung *      http://www.apache.org/licenses/LICENSE-2.0
9303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung *
10303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung * Unless required by applicable law or agreed to in writing, software
11303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung * distributed under the License is distributed on an "AS IS" BASIS,
12303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung * See the License for the specific language governing permissions and
14303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung * limitations under the License.
15303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung */
16303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung
17303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chungpackage com.android.systemui.recents;
18303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung
19852975d5377bfe5f4abc9d2a28e301aa2fa99994Dianne Hackbornimport android.app.ActivityManager;
20303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chungimport android.content.Context;
216736905dc0e10689f7c63f6da43b31325caf966aWinson Chungimport android.content.res.Configuration;
22c620bafde865f7599401f5adf0521820ee9d4a9cWinson Chungimport android.content.res.Resources;
23303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chungimport android.graphics.Rect;
2447a3e65acc35cd3061bf3867e8b20753870fd892Winson Chungimport android.provider.Settings;
25303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chungimport android.util.DisplayMetrics;
26918c0723a169cef46b8bf59c06fd3bb8021d0defWinson Chungimport android.view.animation.AnimationUtils;
27918c0723a169cef46b8bf59c06fd3bb8021d0defWinson Chungimport android.view.animation.Interpolator;
2882862573bcf246128782b91ea627285c43133a8dAndrew Flynn
2982862573bcf246128782b91ea627285c43133a8dAndrew Flynnimport com.android.systemui.Prefs;
302f2ca08baa072376b3dfd60506625496aa05903fWinson Chungimport com.android.systemui.R;
31ffa2ec664479bff6b4b61d4c349d9db2cb37ca16Winson Chungimport com.android.systemui.recents.misc.Console;
3256e09b42a0f1670970872bef611a8036904ad6bfJason Monkimport com.android.systemui.recents.misc.SystemServicesProxy;
33303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung
34303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung
35303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung/** A static Recents configuration for the current context
36303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung * NOTE: We should not hold any references to a Context from a static instance */
37303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chungpublic class RecentsConfiguration {
38303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung    static RecentsConfiguration sInstance;
3985cfec811e35025dbde54f4dc09fe0e1337c36b8Winson Chung    static int sPrevConfigurationHashCode;
40303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung
4196d704186621f6310e0e7d39db57caff67baa96cWinson Chung    /** Levels of svelte in increasing severity/austerity. */
4296d704186621f6310e0e7d39db57caff67baa96cWinson Chung    // No svelting.
4396d704186621f6310e0e7d39db57caff67baa96cWinson Chung    public static final int SVELTE_NONE = 0;
4496d704186621f6310e0e7d39db57caff67baa96cWinson Chung    // Limit thumbnail cache to number of visible thumbnails when Recents was loaded, disable
4596d704186621f6310e0e7d39db57caff67baa96cWinson Chung    // caching thumbnails as you scroll.
4696d704186621f6310e0e7d39db57caff67baa96cWinson Chung    public static final int SVELTE_LIMIT_CACHE = 1;
4796d704186621f6310e0e7d39db57caff67baa96cWinson Chung    // Disable the thumbnail cache, load thumbnails asynchronously when the activity loads and
4896d704186621f6310e0e7d39db57caff67baa96cWinson Chung    // evict all thumbnails when hidden.
4996d704186621f6310e0e7d39db57caff67baa96cWinson Chung    public static final int SVELTE_DISABLE_CACHE = 2;
5096d704186621f6310e0e7d39db57caff67baa96cWinson Chung    // Disable all thumbnail loading.
5196d704186621f6310e0e7d39db57caff67baa96cWinson Chung    public static final int SVELTE_DISABLE_LOADING = 3;
5296d704186621f6310e0e7d39db57caff67baa96cWinson Chung
53d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung    /** Interpolators */
54b01ed681fe97ff5e98471c120ff9581a78db13c5Winson Chung    public Interpolator fastOutSlowInInterpolator;
55b01ed681fe97ff5e98471c120ff9581a78db13c5Winson Chung    public Interpolator fastOutLinearInInterpolator;
56b01ed681fe97ff5e98471c120ff9581a78db13c5Winson Chung    public Interpolator linearOutSlowInInterpolator;
57d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung    public Interpolator quintOutInterpolator;
58918c0723a169cef46b8bf59c06fd3bb8021d0defWinson Chung
59d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung    /** Filtering */
60e0e45bc26d02e2c6ec505ea006e7487f3a5bddc5Winson Chung    public int filteringCurrentViewsAnimDuration;
61e0e45bc26d02e2c6ec505ea006e7487f3a5bddc5Winson Chung    public int filteringNewViewsAnimDuration;
62cd23c849afefe58b213d5abb1c581f15d3ad543aWinson Chung
63d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung    /** Insets */
64d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung    public Rect systemInsets = new Rect();
65d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung    public Rect displayRect = new Rect();
66d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung
67d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung    /** Layout */
68d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung    boolean isLandscape;
6927acf761229779e1777d380616846ac07f484ed6Winson Chung    boolean hasTransposedSearchBar;
7027acf761229779e1777d380616846ac07f484ed6Winson Chung    boolean hasTransposedNavBar;
71d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung
72b1f749906f5c27114d02ea0c3f8ce0dcea08fd3fWinson Chung    /** Loading */
73b1f749906f5c27114d02ea0c3f8ce0dcea08fd3fWinson Chung    public int maxNumTasksToLoad;
74b1f749906f5c27114d02ea0c3f8ce0dcea08fd3fWinson Chung
75d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung    /** Search bar */
76d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung    public int searchBarSpaceHeightPx;
77d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung
78d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung    /** Task stack */
79ebfc6981828b0699eef85c58b23a61f2cac41af3Winson Chung    public int taskStackScrollDuration;
801492646b792360945fba6bdcacc6aa7c19c6618eWinson Chung    public int taskStackMaxDim;
81cd23c849afefe58b213d5abb1c581f15d3ad543aWinson Chung    public int taskStackTopPaddingPx;
826ac8bd6198f67b64aea2258bdb5f8ed371b5bec1Winson Chung    public int dismissAllButtonSizePx;
83d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung    public float taskStackWidthPaddingPct;
84ebfc6981828b0699eef85c58b23a61f2cac41af3Winson Chung    public float taskStackOverscrollPct;
85cd23c849afefe58b213d5abb1c581f15d3ad543aWinson Chung
86c041d883c3591670441d4c2da8fd1108dfd28acdWinson Chung    /** Transitions */
87c041d883c3591670441d4c2da8fd1108dfd28acdWinson Chung    public int transitionEnterFromAppDelay;
88c041d883c3591670441d4c2da8fd1108dfd28acdWinson Chung    public int transitionEnterFromHomeDelay;
89c041d883c3591670441d4c2da8fd1108dfd28acdWinson Chung
90d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung    /** Task view animation and styles */
91c041d883c3591670441d4c2da8fd1108dfd28acdWinson Chung    public int taskViewEnterFromAppDuration;
9219d62382d0acafa0ffe8e48ebb4c737031b3e9c6Winson Chung    public int taskViewEnterFromHomeDuration;
9319d62382d0acafa0ffe8e48ebb4c737031b3e9c6Winson Chung    public int taskViewEnterFromHomeStaggerDelay;
94c041d883c3591670441d4c2da8fd1108dfd28acdWinson Chung    public int taskViewExitToAppDuration;
95ad6f276670443ac8f9b73497dae185bb005c3a76Winson Chung    public int taskViewExitToHomeDuration;
969f49df933f01a32d04bdf92d53c943065aa8ddf7Winson Chung    public int taskViewRemoveAnimDuration;
979f49df933f01a32d04bdf92d53c943065aa8ddf7Winson Chung    public int taskViewRemoveAnimTranslationXPx;
9896e3bc1f8d7c199df6fca603d0c5e59d9b70ca1bWinson Chung    public int taskViewTranslationZMinPx;
99012ef36a6c5e9745d112c734aed916cab052558cWinson Chung    public int taskViewTranslationZMaxPx;
1001492646b792360945fba6bdcacc6aa7c19c6618eWinson Chung    public int taskViewRoundedCornerRadiusPx;
101cd23c849afefe58b213d5abb1c581f15d3ad543aWinson Chung    public int taskViewHighlightPx;
1021907cd478209f01a4215d9a3a76294c2c77c9a63Winson Chung    public int taskViewAffiliateGroupEnterOffsetPx;
10360a729c8e93461c9446d0c8cd519b40dec01e8d8Winson Chung    public float taskViewThumbnailAlpha;
104cd23c849afefe58b213d5abb1c581f15d3ad543aWinson Chung
105d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung    /** Task bar colors */
106f5e22e71cb5f8699a4312c797af068f655cbe629Winson Chung    public int taskBarViewDefaultBackgroundColor;
107f5e22e71cb5f8699a4312c797af068f655cbe629Winson Chung    public int taskBarViewLightTextColor;
108f5e22e71cb5f8699a4312c797af068f655cbe629Winson Chung    public int taskBarViewDarkTextColor;
109cd23c849afefe58b213d5abb1c581f15d3ad543aWinson Chung    public int taskBarViewHighlightColor;
110ec396d6399c5c31d697d81e94aff459e9771b0c6Winson Chung    public float taskBarViewAffiliationColorMinAlpha;
111cd23c849afefe58b213d5abb1c581f15d3ad543aWinson Chung
112a433fa9c17772f563163ff7db177d091d6aebd5bWinson Chung    /** Task bar size & animations */
113a433fa9c17772f563163ff7db177d091d6aebd5bWinson Chung    public int taskBarHeight;
114a26fb7822ddf3511796279b847cc216bee9e7f70Winson Chung    public int taskBarDismissDozeDelaySeconds;
115f5e22e71cb5f8699a4312c797af068f655cbe629Winson Chung
116d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung    /** Nav bar scrim */
117521e7dc0a6782371a710ee81bf804f7e97aaa292Winson Chung    public int navBarScrimEnterDuration;
118521e7dc0a6782371a710ee81bf804f7e97aaa292Winson Chung
119d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung    /** Launch states */
120d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung    public boolean launchedWithAltTab;
121969f586533096999f10f5587f901949791154fa2Winson Chung    public boolean launchedWithNoRecentTasks;
122d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung    public boolean launchedFromAppWithThumbnail;
123d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung    public boolean launchedFromHome;
124860e2d86d8c05b03e985e438664069794825ef0fWinson Chung    public boolean launchedFromSearchHome;
125b0a28ea5d381cd3a8477cf7fd82797199c80ca67Winson Chung    public boolean launchedReuseTaskStackViews;
126860e2d86d8c05b03e985e438664069794825ef0fWinson Chung    public boolean launchedHasConfigurationChanged;
1276057c91563402f900dfc7714a46e952d86172e2fWinson Chung    public int launchedToTaskId;
128860e2d86d8c05b03e985e438664069794825ef0fWinson Chung    public int launchedNumVisibleTasks;
129860e2d86d8c05b03e985e438664069794825ef0fWinson Chung    public int launchedNumVisibleThumbnails;
130b44c24fb50845dfbc1f49e78085cf5e01a32067fWinson Chung
131a0e88b5013d708ac6ed6518817d83c64c87ae4b1Winson Chung    /** Misc **/
132e8199c582d826a39e6e47b0d8418834c15242fecSelim Cinek    public boolean useHardwareLayers;
133a0e88b5013d708ac6ed6518817d83c64c87ae4b1Winson Chung    public int altTabKeyDelay;
134cb5570316d55c6fe2ff717fa6b94b14d13980263Jorim Jaggi    public boolean fakeShadows;
135a0e88b5013d708ac6ed6518817d83c64c87ae4b1Winson Chung
13656e09b42a0f1670970872bef611a8036904ad6bfJason Monk    /** Dev options and global settings */
137d16c565a607de754379fe699a4def21bd0e3de2fWinson Chung    public boolean multiStackEnabled;
13856e09b42a0f1670970872bef611a8036904ad6bfJason Monk    public boolean lockToAppEnabled;
13947a3e65acc35cd3061bf3867e8b20753870fd892Winson Chung    public boolean developerOptionsEnabled;
1408eaeb7dc93ed71b768a2ea8d45021cca010e8263Winson Chung    public boolean debugModeEnabled;
14196d704186621f6310e0e7d39db57caff67baa96cWinson Chung    public int svelteLevel;
14247a3e65acc35cd3061bf3867e8b20753870fd892Winson Chung
143303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung    /** Private constructor */
14406795630f62e1e7ad89825db23d7656f8dcd6c5aWinson Chung    private RecentsConfiguration(Context context) {
14506795630f62e1e7ad89825db23d7656f8dcd6c5aWinson Chung        // Properties that don't have to be reloaded with each configuration change can be loaded
14606795630f62e1e7ad89825db23d7656f8dcd6c5aWinson Chung        // here.
14706795630f62e1e7ad89825db23d7656f8dcd6c5aWinson Chung
14806795630f62e1e7ad89825db23d7656f8dcd6c5aWinson Chung        // Interpolators
14906795630f62e1e7ad89825db23d7656f8dcd6c5aWinson Chung        fastOutSlowInInterpolator = AnimationUtils.loadInterpolator(context,
15006795630f62e1e7ad89825db23d7656f8dcd6c5aWinson Chung                com.android.internal.R.interpolator.fast_out_slow_in);
15106795630f62e1e7ad89825db23d7656f8dcd6c5aWinson Chung        fastOutLinearInInterpolator = AnimationUtils.loadInterpolator(context,
15206795630f62e1e7ad89825db23d7656f8dcd6c5aWinson Chung                com.android.internal.R.interpolator.fast_out_linear_in);
15306795630f62e1e7ad89825db23d7656f8dcd6c5aWinson Chung        linearOutSlowInInterpolator = AnimationUtils.loadInterpolator(context,
15406795630f62e1e7ad89825db23d7656f8dcd6c5aWinson Chung                com.android.internal.R.interpolator.linear_out_slow_in);
15506795630f62e1e7ad89825db23d7656f8dcd6c5aWinson Chung        quintOutInterpolator = AnimationUtils.loadInterpolator(context,
15606795630f62e1e7ad89825db23d7656f8dcd6c5aWinson Chung                com.android.internal.R.interpolator.decelerate_quint);
15706795630f62e1e7ad89825db23d7656f8dcd6c5aWinson Chung    }
158303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung
159303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung    /** Updates the configuration to the current context */
16056e09b42a0f1670970872bef611a8036904ad6bfJason Monk    public static RecentsConfiguration reinitialize(Context context, SystemServicesProxy ssp) {
161303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung        if (sInstance == null) {
16206795630f62e1e7ad89825db23d7656f8dcd6c5aWinson Chung            sInstance = new RecentsConfiguration(context);
163303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung        }
16485cfec811e35025dbde54f4dc09fe0e1337c36b8Winson Chung        int configHashCode = context.getResources().getConfiguration().hashCode();
16585cfec811e35025dbde54f4dc09fe0e1337c36b8Winson Chung        if (sPrevConfigurationHashCode != configHashCode) {
16685cfec811e35025dbde54f4dc09fe0e1337c36b8Winson Chung            sInstance.update(context);
16785cfec811e35025dbde54f4dc09fe0e1337c36b8Winson Chung            sPrevConfigurationHashCode = configHashCode;
16885cfec811e35025dbde54f4dc09fe0e1337c36b8Winson Chung        }
16956e09b42a0f1670970872bef611a8036904ad6bfJason Monk        sInstance.updateOnReinitialize(context, ssp);
170303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung        return sInstance;
171303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung    }
172303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung
173303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung    /** Returns the current recents configuration */
174303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung    public static RecentsConfiguration getInstance() {
175303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung        return sInstance;
176303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung    }
177303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung
178303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung    /** Updates the state, given the specified context */
179303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung    void update(Context context) {
180c620bafde865f7599401f5adf0521820ee9d4a9cWinson Chung        Resources res = context.getResources();
181c620bafde865f7599401f5adf0521820ee9d4a9cWinson Chung        DisplayMetrics dm = res.getDisplayMetrics();
182303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung
1838eaeb7dc93ed71b768a2ea8d45021cca010e8263Winson Chung        // Debug mode
18482862573bcf246128782b91ea627285c43133a8dAndrew Flynn        debugModeEnabled = Prefs.getBoolean(context, Prefs.Key.DEBUG_MODE_ENABLED,
18582862573bcf246128782b91ea627285c43133a8dAndrew Flynn                false /* defaultValue */);
1867aceb9a07fd3883c8f301ba93726d55494b0446eWinson Chung        if (debugModeEnabled) {
1877aceb9a07fd3883c8f301ba93726d55494b0446eWinson Chung            Console.Enabled = true;
1887aceb9a07fd3883c8f301ba93726d55494b0446eWinson Chung        }
1898eaeb7dc93ed71b768a2ea8d45021cca010e8263Winson Chung
190242bbb86e8811ad8759790c1b499d0918baece8bWinson Chung        // Layout
191b1f749906f5c27114d02ea0c3f8ce0dcea08fd3fWinson Chung        isLandscape = res.getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
19227acf761229779e1777d380616846ac07f484ed6Winson Chung        hasTransposedSearchBar = res.getBoolean(R.bool.recents_has_transposed_search_bar);
19327acf761229779e1777d380616846ac07f484ed6Winson Chung        hasTransposedNavBar = res.getBoolean(R.bool.recents_has_transposed_nav_bar);
194242bbb86e8811ad8759790c1b499d0918baece8bWinson Chung
195242bbb86e8811ad8759790c1b499d0918baece8bWinson Chung        // Insets
196242bbb86e8811ad8759790c1b499d0918baece8bWinson Chung        displayRect.set(0, 0, dm.widthPixels, dm.heightPixels);
197242bbb86e8811ad8759790c1b499d0918baece8bWinson Chung
198d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung        // Filtering
199e0e45bc26d02e2c6ec505ea006e7487f3a5bddc5Winson Chung        filteringCurrentViewsAnimDuration =
200e0e45bc26d02e2c6ec505ea006e7487f3a5bddc5Winson Chung                res.getInteger(R.integer.recents_filter_animate_current_views_duration);
201e0e45bc26d02e2c6ec505ea006e7487f3a5bddc5Winson Chung        filteringNewViewsAnimDuration =
202e0e45bc26d02e2c6ec505ea006e7487f3a5bddc5Winson Chung                res.getInteger(R.integer.recents_filter_animate_new_views_duration);
203cd23c849afefe58b213d5abb1c581f15d3ad543aWinson Chung
204b1f749906f5c27114d02ea0c3f8ce0dcea08fd3fWinson Chung        // Loading
205852975d5377bfe5f4abc9d2a28e301aa2fa99994Dianne Hackborn        maxNumTasksToLoad = ActivityManager.getMaxRecentTasksStatic();
206b1f749906f5c27114d02ea0c3f8ce0dcea08fd3fWinson Chung
20785cfec811e35025dbde54f4dc09fe0e1337c36b8Winson Chung        // Search Bar
208d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung        searchBarSpaceHeightPx = res.getDimensionPixelSize(R.dimen.recents_search_bar_space_height);
209d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung
210d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung        // Task stack
211ebfc6981828b0699eef85c58b23a61f2cac41af3Winson Chung        taskStackScrollDuration =
212ebfc6981828b0699eef85c58b23a61f2cac41af3Winson Chung                res.getInteger(R.integer.recents_animate_task_stack_scroll_duration);
2136ac8bd6198f67b64aea2258bdb5f8ed371b5bec1Winson Chung        taskStackWidthPaddingPct = res.getFloat(R.dimen.recents_stack_width_padding_percentage);
2146ac8bd6198f67b64aea2258bdb5f8ed371b5bec1Winson Chung        taskStackOverscrollPct = res.getFloat(R.dimen.recents_stack_overscroll_percentage);
215d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung        taskStackMaxDim = res.getInteger(R.integer.recents_max_task_stack_view_dim);
216cd23c849afefe58b213d5abb1c581f15d3ad543aWinson Chung        taskStackTopPaddingPx = res.getDimensionPixelSize(R.dimen.recents_stack_top_padding);
2176ac8bd6198f67b64aea2258bdb5f8ed371b5bec1Winson Chung        dismissAllButtonSizePx = res.getDimensionPixelSize(R.dimen.recents_dismiss_all_button_size);
218cd23c849afefe58b213d5abb1c581f15d3ad543aWinson Chung
219c041d883c3591670441d4c2da8fd1108dfd28acdWinson Chung        // Transition
220c041d883c3591670441d4c2da8fd1108dfd28acdWinson Chung        transitionEnterFromAppDelay =
221c041d883c3591670441d4c2da8fd1108dfd28acdWinson Chung                res.getInteger(R.integer.recents_enter_from_app_transition_duration);
222c041d883c3591670441d4c2da8fd1108dfd28acdWinson Chung        transitionEnterFromHomeDelay =
223c041d883c3591670441d4c2da8fd1108dfd28acdWinson Chung                res.getInteger(R.integer.recents_enter_from_home_transition_duration);
224c041d883c3591670441d4c2da8fd1108dfd28acdWinson Chung
225d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung        // Task view animation and styles
226c041d883c3591670441d4c2da8fd1108dfd28acdWinson Chung        taskViewEnterFromAppDuration =
227c041d883c3591670441d4c2da8fd1108dfd28acdWinson Chung                res.getInteger(R.integer.recents_task_enter_from_app_duration);
22819d62382d0acafa0ffe8e48ebb4c737031b3e9c6Winson Chung        taskViewEnterFromHomeDuration =
229c041d883c3591670441d4c2da8fd1108dfd28acdWinson Chung                res.getInteger(R.integer.recents_task_enter_from_home_duration);
23019d62382d0acafa0ffe8e48ebb4c737031b3e9c6Winson Chung        taskViewEnterFromHomeStaggerDelay =
231c041d883c3591670441d4c2da8fd1108dfd28acdWinson Chung                res.getInteger(R.integer.recents_task_enter_from_home_stagger_delay);
232c041d883c3591670441d4c2da8fd1108dfd28acdWinson Chung        taskViewExitToAppDuration =
233c041d883c3591670441d4c2da8fd1108dfd28acdWinson Chung                res.getInteger(R.integer.recents_task_exit_to_app_duration);
234ad6f276670443ac8f9b73497dae185bb005c3a76Winson Chung        taskViewExitToHomeDuration =
235c041d883c3591670441d4c2da8fd1108dfd28acdWinson Chung                res.getInteger(R.integer.recents_task_exit_to_home_duration);
2369f49df933f01a32d04bdf92d53c943065aa8ddf7Winson Chung        taskViewRemoveAnimDuration =
2379f49df933f01a32d04bdf92d53c943065aa8ddf7Winson Chung                res.getInteger(R.integer.recents_animate_task_view_remove_duration);
2389f49df933f01a32d04bdf92d53c943065aa8ddf7Winson Chung        taskViewRemoveAnimTranslationXPx =
2399f49df933f01a32d04bdf92d53c943065aa8ddf7Winson Chung                res.getDimensionPixelSize(R.dimen.recents_task_view_remove_anim_translation_x);
2401492646b792360945fba6bdcacc6aa7c19c6618eWinson Chung        taskViewRoundedCornerRadiusPx =
2411492646b792360945fba6bdcacc6aa7c19c6618eWinson Chung                res.getDimensionPixelSize(R.dimen.recents_task_view_rounded_corners_radius);
242cd23c849afefe58b213d5abb1c581f15d3ad543aWinson Chung        taskViewHighlightPx = res.getDimensionPixelSize(R.dimen.recents_task_view_highlight);
24396e3bc1f8d7c199df6fca603d0c5e59d9b70ca1bWinson Chung        taskViewTranslationZMinPx = res.getDimensionPixelSize(R.dimen.recents_task_view_z_min);
244012ef36a6c5e9745d112c734aed916cab052558cWinson Chung        taskViewTranslationZMaxPx = res.getDimensionPixelSize(R.dimen.recents_task_view_z_max);
2451907cd478209f01a4215d9a3a76294c2c77c9a63Winson Chung        taskViewAffiliateGroupEnterOffsetPx =
2461907cd478209f01a4215d9a3a76294c2c77c9a63Winson Chung                res.getDimensionPixelSize(R.dimen.recents_task_view_affiliate_group_enter_offset);
2476ac8bd6198f67b64aea2258bdb5f8ed371b5bec1Winson Chung        taskViewThumbnailAlpha = res.getFloat(R.dimen.recents_task_view_thumbnail_alpha);
248cd23c849afefe58b213d5abb1c581f15d3ad543aWinson Chung
249d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung        // Task bar colors
2504a357cd2e55293402d7172766f7f9419815fc1e8Alan Viverette        taskBarViewDefaultBackgroundColor = context.getColor(
2514a357cd2e55293402d7172766f7f9419815fc1e8Alan Viverette                R.color.recents_task_bar_default_background_color);
2524a357cd2e55293402d7172766f7f9419815fc1e8Alan Viverette        taskBarViewLightTextColor = context.getColor(R.color.recents_task_bar_light_text_color);
2534a357cd2e55293402d7172766f7f9419815fc1e8Alan Viverette        taskBarViewDarkTextColor = context.getColor(R.color.recents_task_bar_dark_text_color);
2544a357cd2e55293402d7172766f7f9419815fc1e8Alan Viverette        taskBarViewHighlightColor = context.getColor(R.color.recents_task_bar_highlight_color);
2556ac8bd6198f67b64aea2258bdb5f8ed371b5bec1Winson Chung        taskBarViewAffiliationColorMinAlpha = res.getFloat(
2566ac8bd6198f67b64aea2258bdb5f8ed371b5bec1Winson Chung                R.dimen.recents_task_affiliation_color_min_alpha_percentage);
257cd23c849afefe58b213d5abb1c581f15d3ad543aWinson Chung
258a433fa9c17772f563163ff7db177d091d6aebd5bWinson Chung        // Task bar size & animations
259a433fa9c17772f563163ff7db177d091d6aebd5bWinson Chung        taskBarHeight = res.getDimensionPixelSize(R.dimen.recents_task_bar_height);
260a26fb7822ddf3511796279b847cc216bee9e7f70Winson Chung        taskBarDismissDozeDelaySeconds =
261a26fb7822ddf3511796279b847cc216bee9e7f70Winson Chung                res.getInteger(R.integer.recents_task_bar_dismiss_delay_seconds);
262f7bca430d9356c26d6df222d2c90bc7668262f6bWinson Chung
263d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung        // Nav bar scrim
264521e7dc0a6782371a710ee81bf804f7e97aaa292Winson Chung        navBarScrimEnterDuration =
265521e7dc0a6782371a710ee81bf804f7e97aaa292Winson Chung                res.getInteger(R.integer.recents_nav_bar_scrim_enter_duration);
266a0e88b5013d708ac6ed6518817d83c64c87ae4b1Winson Chung
267a0e88b5013d708ac6ed6518817d83c64c87ae4b1Winson Chung        // Misc
268e8199c582d826a39e6e47b0d8418834c15242fecSelim Cinek        useHardwareLayers = res.getBoolean(R.bool.config_recents_use_hardware_layers);
269a0e88b5013d708ac6ed6518817d83c64c87ae4b1Winson Chung        altTabKeyDelay = res.getInteger(R.integer.recents_alt_tab_key_delay);
270cb5570316d55c6fe2ff717fa6b94b14d13980263Jorim Jaggi        fakeShadows = res.getBoolean(R.bool.config_recents_fake_shadows);
27196d704186621f6310e0e7d39db57caff67baa96cWinson Chung        svelteLevel = res.getInteger(R.integer.recents_svelte_level);
272303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung    }
273303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung
27411ca76a53c60a1898956614315ae929668c523d6Winson Chung    /** Updates the system insets */
275303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung    public void updateSystemInsets(Rect insets) {
276303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung        systemInsets.set(insets);
277303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung    }
278303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung
27956e09b42a0f1670970872bef611a8036904ad6bfJason Monk    /** Updates the states that need to be re-read whenever we re-initialize. */
28056e09b42a0f1670970872bef611a8036904ad6bfJason Monk    void updateOnReinitialize(Context context, SystemServicesProxy ssp) {
28156e09b42a0f1670970872bef611a8036904ad6bfJason Monk        // Check if the developer options are enabled
28256e09b42a0f1670970872bef611a8036904ad6bfJason Monk        developerOptionsEnabled = ssp.getGlobalSetting(context,
28356e09b42a0f1670970872bef611a8036904ad6bfJason Monk                Settings.Global.DEVELOPMENT_SETTINGS_ENABLED) != 0;
28456e09b42a0f1670970872bef611a8036904ad6bfJason Monk        lockToAppEnabled = ssp.getSystemSetting(context,
28556e09b42a0f1670970872bef611a8036904ad6bfJason Monk                Settings.System.LOCK_TO_APP_ENABLED) != 0;
286e0cc2f652bb92acf5105e691b971a9a5e6821c4dWale Ogunwale        multiStackEnabled = "true".equals(ssp.getSystemProperty("persist.sys.debug.multi_window"));
28756e09b42a0f1670970872bef611a8036904ad6bfJason Monk    }
28856e09b42a0f1670970872bef611a8036904ad6bfJason Monk
289b01ed681fe97ff5e98471c120ff9581a78db13c5Winson Chung    /** Called when the configuration has changed, and we want to reset any configuration specific
290b01ed681fe97ff5e98471c120ff9581a78db13c5Winson Chung     * members. */
291b01ed681fe97ff5e98471c120ff9581a78db13c5Winson Chung    public void updateOnConfigurationChange() {
292860e2d86d8c05b03e985e438664069794825ef0fWinson Chung        // Reset this flag on configuration change to ensure that we recreate new task views
293b0a28ea5d381cd3a8477cf7fd82797199c80ca67Winson Chung        launchedReuseTaskStackViews = false;
294860e2d86d8c05b03e985e438664069794825ef0fWinson Chung        // Set this flag to indicate that the configuration has changed since Recents last launched
295860e2d86d8c05b03e985e438664069794825ef0fWinson Chung        launchedHasConfigurationChanged = true;
296b01ed681fe97ff5e98471c120ff9581a78db13c5Winson Chung    }
297b01ed681fe97ff5e98471c120ff9581a78db13c5Winson Chung
29806795630f62e1e7ad89825db23d7656f8dcd6c5aWinson Chung    /** Returns whether the status bar scrim should be animated when shown for the first time. */
29906795630f62e1e7ad89825db23d7656f8dcd6c5aWinson Chung    public boolean shouldAnimateStatusBarScrim() {
30006795630f62e1e7ad89825db23d7656f8dcd6c5aWinson Chung        return launchedFromHome;
30106795630f62e1e7ad89825db23d7656f8dcd6c5aWinson Chung    }
30206795630f62e1e7ad89825db23d7656f8dcd6c5aWinson Chung
30306795630f62e1e7ad89825db23d7656f8dcd6c5aWinson Chung    /** Returns whether the status bar scrim should be visible. */
30406795630f62e1e7ad89825db23d7656f8dcd6c5aWinson Chung    public boolean hasStatusBarScrim() {
30506795630f62e1e7ad89825db23d7656f8dcd6c5aWinson Chung        return !launchedWithNoRecentTasks;
30606795630f62e1e7ad89825db23d7656f8dcd6c5aWinson Chung    }
30706795630f62e1e7ad89825db23d7656f8dcd6c5aWinson Chung
308743d5c95f3a107639c0ff22f099cab2624da3e27Winson Chung    /** Returns whether the nav bar scrim should be animated when shown for the first time. */
309743d5c95f3a107639c0ff22f099cab2624da3e27Winson Chung    public boolean shouldAnimateNavBarScrim() {
310969f586533096999f10f5587f901949791154fa2Winson Chung        return true;
311743d5c95f3a107639c0ff22f099cab2624da3e27Winson Chung    }
312743d5c95f3a107639c0ff22f099cab2624da3e27Winson Chung
313521e7dc0a6782371a710ee81bf804f7e97aaa292Winson Chung    /** Returns whether the nav bar scrim should be visible. */
314521e7dc0a6782371a710ee81bf804f7e97aaa292Winson Chung    public boolean hasNavBarScrim() {
315969f586533096999f10f5587f901949791154fa2Winson Chung        // Only show the scrim if we have recent tasks, and if the nav bar is not transposed
31627acf761229779e1777d380616846ac07f484ed6Winson Chung        return !launchedWithNoRecentTasks && (!hasTransposedNavBar || !isLandscape);
317521e7dc0a6782371a710ee81bf804f7e97aaa292Winson Chung    }
318521e7dc0a6782371a710ee81bf804f7e97aaa292Winson Chung
319f7bca430d9356c26d6df222d2c90bc7668262f6bWinson Chung    /**
320f7bca430d9356c26d6df222d2c90bc7668262f6bWinson Chung     * Returns the task stack bounds in the current orientation. These bounds do not account for
321f7bca430d9356c26d6df222d2c90bc7668262f6bWinson Chung     * the system insets.
322f7bca430d9356c26d6df222d2c90bc7668262f6bWinson Chung     */
323d16c565a607de754379fe699a4def21bd0e3de2fWinson Chung    public void getAvailableTaskStackBounds(int windowWidth, int windowHeight, int topInset,
324af3bb6936786a8c14ac01da3d81d196d17b68b96Winson Chung            int rightInset, Rect searchBarBounds, Rect taskStackBounds) {
32527acf761229779e1777d380616846ac07f484ed6Winson Chung        if (isLandscape && hasTransposedSearchBar) {
3266074c5c15117bb17defb90bdb9fe247d0df47c70Winson Chung            // In landscape, the search bar appears on the left, but we overlay it on top
3276074c5c15117bb17defb90bdb9fe247d0df47c70Winson Chung            taskStackBounds.set(0, topInset, windowWidth - rightInset, windowHeight);
328f7bca430d9356c26d6df222d2c90bc7668262f6bWinson Chung        } else {
329dcfa7976fa836ae90bb4a579892a18a0abf35b3cWinson Chung            // In portrait, the search bar appears on the top (which already has the inset)
330dcfa7976fa836ae90bb4a579892a18a0abf35b3cWinson Chung            taskStackBounds.set(0, searchBarBounds.bottom, windowWidth, windowHeight);
331f7bca430d9356c26d6df222d2c90bc7668262f6bWinson Chung        }
332f7bca430d9356c26d6df222d2c90bc7668262f6bWinson Chung    }
333f7bca430d9356c26d6df222d2c90bc7668262f6bWinson Chung
334f7bca430d9356c26d6df222d2c90bc7668262f6bWinson Chung    /**
335f7bca430d9356c26d6df222d2c90bc7668262f6bWinson Chung     * Returns the search bar bounds in the current orientation.  These bounds do not account for
336f7bca430d9356c26d6df222d2c90bc7668262f6bWinson Chung     * the system insets.
337f7bca430d9356c26d6df222d2c90bc7668262f6bWinson Chung     */
338dcfa7976fa836ae90bb4a579892a18a0abf35b3cWinson Chung    public void getSearchBarBounds(int windowWidth, int windowHeight, int topInset,
339d16c565a607de754379fe699a4def21bd0e3de2fWinson Chung            Rect searchBarSpaceBounds) {
340ecd9b3031c9a322bd69380eae2810d53839e8f64Winson Chung        // Return empty rects if search is not enabled
341dcfa7976fa836ae90bb4a579892a18a0abf35b3cWinson Chung        int searchBarSize = searchBarSpaceHeightPx;
34227acf761229779e1777d380616846ac07f484ed6Winson Chung        if (isLandscape && hasTransposedSearchBar) {
343f7bca430d9356c26d6df222d2c90bc7668262f6bWinson Chung            // In landscape, the search bar appears on the left
344dcfa7976fa836ae90bb4a579892a18a0abf35b3cWinson Chung            searchBarSpaceBounds.set(0, topInset, searchBarSize, windowHeight);
345f7bca430d9356c26d6df222d2c90bc7668262f6bWinson Chung        } else {
346f7bca430d9356c26d6df222d2c90bc7668262f6bWinson Chung            // In portrait, the search bar appears on the top
347dcfa7976fa836ae90bb4a579892a18a0abf35b3cWinson Chung            searchBarSpaceBounds.set(0, topInset, windowWidth, topInset + searchBarSize);
348f7bca430d9356c26d6df222d2c90bc7668262f6bWinson Chung        }
349ecd9b3031c9a322bd69380eae2810d53839e8f64Winson Chung    }
350303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung}
351