RecentsConfiguration.java revision a0e88b5013d708ac6ed6518817d83c64c87ae4b1
10792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang/*
20792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang * Copyright (C) 2014 The Android Open Source Project
30792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang *
40792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang * Licensed under the Apache License, Version 2.0 (the "License");
50792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang * you may not use this file except in compliance with the License.
60792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang * You may obtain a copy of the License at
70792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang *
80792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang *      http://www.apache.org/licenses/LICENSE-2.0
90792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang *
100792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang * Unless required by applicable law or agreed to in writing, software
110792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang * distributed under the License is distributed on an "AS IS" BASIS,
120792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
130792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang * See the License for the specific language governing permissions and
140792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang * limitations under the License.
150792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang */
160792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang
170792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jangpackage com.android.systemui.recents;
180792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang
19ed0864557b3340ab7db00e2dc95b29c4b8bb485dJinsuk Kimimport android.content.Context;
20ed0864557b3340ab7db00e2dc95b29c4b8bb485dJinsuk Kimimport android.content.SharedPreferences;
215008486b09c588bf3409b70d9ee29225e8593c64Jinsuk Kimimport android.content.res.Configuration;
225008486b09c588bf3409b70d9ee29225e8593c64Jinsuk Kimimport android.content.res.Resources;
235008486b09c588bf3409b70d9ee29225e8593c64Jinsuk Kimimport android.graphics.Rect;
245008486b09c588bf3409b70d9ee29225e8593c64Jinsuk Kimimport android.provider.Settings;
255008486b09c588bf3409b70d9ee29225e8593c64Jinsuk Kimimport android.util.DisplayMetrics;
265008486b09c588bf3409b70d9ee29225e8593c64Jinsuk Kimimport android.util.TypedValue;
275008486b09c588bf3409b70d9ee29225e8593c64Jinsuk Kimimport android.view.animation.AnimationUtils;
285008486b09c588bf3409b70d9ee29225e8593c64Jinsuk Kimimport android.view.animation.Interpolator;
295008486b09c588bf3409b70d9ee29225e8593c64Jinsuk Kimimport com.android.systemui.R;
300792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jangimport com.android.systemui.recents.misc.Console;
3138db629d897e9d7c8e31ce0a7e985981e3e12996Yuncheol Heoimport com.android.systemui.recents.misc.SystemServicesProxy;
327ecfbaed6e902aea151bc1919cf7771bbd868fc4Jinsuk Kim
330792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang
3438db629d897e9d7c8e31ce0a7e985981e3e12996Yuncheol Heo/** A static Recents configuration for the current context
3538db629d897e9d7c8e31ce0a7e985981e3e12996Yuncheol Heo * NOTE: We should not hold any references to a Context from a static instance */
365008486b09c588bf3409b70d9ee29225e8593c64Jinsuk Kimpublic class RecentsConfiguration {
37c0c20d0522d7756d80f011e7a54bf3b51c78df41Jinsuk Kim    static RecentsConfiguration sInstance;
387d9acc7a3eddb3e57c0b8312c3baf7ebb4f529d9Yuncheol Heo    static int sPrevConfigurationHashCode;
3960cffce420db4c3395f86d3b9bb36003adf26f5dJungshik Jang
400340bbc89f8162f9c2a298c98b03bfcdd1bc6e87Jinsuk Kim    /** Animations */
41d643f764f72efc1e7aa67392bf9ac40720ae14c3Jungshik Jang    public float animationPxMovementPerSecond;
42d643f764f72efc1e7aa67392bf9ac40720ae14c3Jungshik Jang
436d97f5b91c6c82f28a2a3a5d3b922f0e5844e733Jinsuk Kim    /** Interpolators */
44d643f764f72efc1e7aa67392bf9ac40720ae14c3Jungshik Jang    public Interpolator fastOutSlowInInterpolator;
459c37e1f53ea4734bfe5ae156dc5399ce5f2c7cccJinsuk Kim    public Interpolator fastOutLinearInInterpolator;
46b3fbf9dbe8d41d91efbac2118b676af74592257bJinsuk Kim    public Interpolator linearOutSlowInInterpolator;
4712e5dcefe136b58562f39604e6a8460ac92cb895Jungshik Jang    public Interpolator quintOutInterpolator;
48ea67c183fe5511ad99aeaae1a32b5245bd020e36Jungshik Jang
49119160a68195bcb2f5bdf4a269807e01228eca97Jinsuk Kim    /** Filtering */
50a858d221ff86c497e745222ea15bab141e337636Jungshik Jang    public int filteringCurrentViewsAnimDuration;
515008486b09c588bf3409b70d9ee29225e8593c64Jinsuk Kim    public int filteringNewViewsAnimDuration;
5242c9800f4f3acef10d19dca39e8b739546407c04Jungshik Jang
5367ea521d14f366fe5aac09e512865d31bfa0ee53Jungshik Jang    /** Insets */
540792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang    public Rect systemInsets = new Rect();
5578d695d8ba532214b02e7f18e0ccf89cf099163dJinsuk Kim    public Rect displayRect = new Rect();
56e9c77c88ea34a66f83a94f960547275c0ff6bd07Jungshik Jang
5738db629d897e9d7c8e31ce0a7e985981e3e12996Yuncheol Heo    /** Layout */
5878d695d8ba532214b02e7f18e0ccf89cf099163dJinsuk Kim    boolean isLandscape;
5938db629d897e9d7c8e31ce0a7e985981e3e12996Yuncheol Heo    boolean transposeRecentsLayoutWithOrientation;
607d9acc7a3eddb3e57c0b8312c3baf7ebb4f529d9Yuncheol Heo
615008486b09c588bf3409b70d9ee29225e8593c64Jinsuk Kim    /** Loading */
627ecfbaed6e902aea151bc1919cf7771bbd868fc4Jinsuk Kim    public int maxNumTasksToLoad;
637d9acc7a3eddb3e57c0b8312c3baf7ebb4f529d9Yuncheol Heo
642b152015ff94f20b9ec3ef284fb83105f8b3c831Jinsuk Kim    /** Search bar */
650792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang    int searchBarAppWidgetId = -1;
663ee65720e91c7f92ad5a034d7052122a606aa8d5Jungshik Jang    public int searchBarSpaceHeightPx;
678b308d93c8fdcc7304b33d9b445ae3807eae97c8Jungshik Jang
6878d695d8ba532214b02e7f18e0ccf89cf099163dJinsuk Kim    /** Task stack */
694893c7efde52411ad051ef5c20251439f4098eacJinsuk Kim    public int taskStackMaxDim;
70959d2db12c7c6a06465af1251bc4cece580a72a3Terry Heo    public int taskStackTopPaddingPx;
710792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang    public float taskStackWidthPaddingPct;
72a5b7414970c85217e88015e78ecbc5ba093dead3Jungshik Jang
733ee65720e91c7f92ad5a034d7052122a606aa8d5Jungshik Jang    /** Task view animation and styles */
747e74206693f4ee93afb902d5b3446e2384f2a13dJinsuk Kim    public int taskViewEnterFromHomeDuration;
754fc1d105fc279bf7df6c876e160672866bdad8e7Jungshik Jang    public int taskViewEnterFromHomeDelay;
760792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang    public int taskViewExitToHomeDuration;
77b6591b8e5399099dc6b7693e0fc719b613aba89cJungshik Jang    public int taskViewRemoveAnimDuration;
78b6591b8e5399099dc6b7693e0fc719b613aba89cJungshik Jang    public int taskViewRemoveAnimTranslationXPx;
79959d2db12c7c6a06465af1251bc4cece580a72a3Terry Heo    public int taskViewTranslationZMinPx;
80959d2db12c7c6a06465af1251bc4cece580a72a3Terry Heo    public int taskViewTranslationZMaxPx;
8178d695d8ba532214b02e7f18e0ccf89cf099163dJinsuk Kim    public int taskViewRoundedCornerRadiusPx;
82f4eb72d53b4c5bc2286841006ad473ad4448bcf8Jinsuk Kim    public int taskViewHighlightPx;
830340bbc89f8162f9c2a298c98b03bfcdd1bc6e87Jinsuk Kim    public int taskViewAffiliateGroupEnterOffsetPx;
8402bb4265ac41e1974ec7d4793e6c2a0ed2adc3c4Jungshik Jang
851ca0a43251a31bb1b4253dc404316cc4b840f497Terry Heo    /** Task bar colors */
86a1fa91fe263c483cf13066e2847a440de2cd52a5Jungshik Jang    public int taskBarViewDefaultBackgroundColor;
870792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang    public int taskBarViewLightTextColor;
880792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang    public int taskBarViewDarkTextColor;
890792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang    public int taskBarViewHighlightColor;
900792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang    public float taskBarViewAffiliationColorMinAlpha;
910792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang
920792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang    /** Task bar size & animations */
935fe3a6cbfc50a8faf9cf051f1f09a7eb1ef6b7eeJinsuk Kim    public int taskBarHeight;
945fe3a6cbfc50a8faf9cf051f1f09a7eb1ef6b7eeJinsuk Kim    public int taskBarEnterAnimDuration;
950792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang    public int taskBarEnterAnimDelay;
96c7eba0f1db8928ca779933a564a06989e22a8532Jinsuk Kim    public int taskBarExitAnimDuration;
9778d695d8ba532214b02e7f18e0ccf89cf099163dJinsuk Kim    public int taskBarDismissDozeDelaySeconds;
98fc44e4e03c5f6486efb7457965dcf7eaf36bc971Yuncheol Heo
99fc44e4e03c5f6486efb7457965dcf7eaf36bc971Yuncheol Heo    /** Lock to app */
100fc44e4e03c5f6486efb7457965dcf7eaf36bc971Yuncheol Heo    public int taskViewLockToAppButtonHeight;
101fc44e4e03c5f6486efb7457965dcf7eaf36bc971Yuncheol Heo    public int taskViewLockToAppShortAnimDuration;
102fc44e4e03c5f6486efb7457965dcf7eaf36bc971Yuncheol Heo    public int taskViewLockToAppLongAnimDuration;
103b502186ab34a4de40f1d98591a0c5d8b4eac76e2Yuncheol Heo
104fc44e4e03c5f6486efb7457965dcf7eaf36bc971Yuncheol Heo    /** Nav bar scrim */
105d643f764f72efc1e7aa67392bf9ac40720ae14c3Jungshik Jang    public int navBarScrimEnterDuration;
106d643f764f72efc1e7aa67392bf9ac40720ae14c3Jungshik Jang
107d643f764f72efc1e7aa67392bf9ac40720ae14c3Jungshik Jang    /** Launch states */
108d643f764f72efc1e7aa67392bf9ac40720ae14c3Jungshik Jang    public boolean launchedWithAltTab;
109d643f764f72efc1e7aa67392bf9ac40720ae14c3Jungshik Jang    public boolean launchedWithNoRecentTasks;
110d643f764f72efc1e7aa67392bf9ac40720ae14c3Jungshik Jang    public boolean launchedFromAppWithThumbnail;
111d643f764f72efc1e7aa67392bf9ac40720ae14c3Jungshik Jang    public boolean launchedFromAppWithScreenshot;
112ece603b7955938d6001c376f351ca0a2219330acYuncheol Heo    public boolean launchedFromHome;
1134fc1d105fc279bf7df6c876e160672866bdad8e7Jungshik Jang    public int launchedToTaskId;
1144fc1d105fc279bf7df6c876e160672866bdad8e7Jungshik Jang
1154fc1d105fc279bf7df6c876e160672866bdad8e7Jungshik Jang    /** Misc **/
1164fc1d105fc279bf7df6c876e160672866bdad8e7Jungshik Jang    public int altTabKeyDelay;
1174fc1d105fc279bf7df6c876e160672866bdad8e7Jungshik Jang
118d643f764f72efc1e7aa67392bf9ac40720ae14c3Jungshik Jang    /** Dev options and global settings */
119d643f764f72efc1e7aa67392bf9ac40720ae14c3Jungshik Jang    public boolean lockToAppEnabled;
120d643f764f72efc1e7aa67392bf9ac40720ae14c3Jungshik Jang    public boolean developerOptionsEnabled;
121d643f764f72efc1e7aa67392bf9ac40720ae14c3Jungshik Jang    public boolean debugModeEnabled;
12202bb4265ac41e1974ec7d4793e6c2a0ed2adc3c4Jungshik Jang
12302bb4265ac41e1974ec7d4793e6c2a0ed2adc3c4Jungshik Jang    /** Private constructor */
12402bb4265ac41e1974ec7d4793e6c2a0ed2adc3c4Jungshik Jang    private RecentsConfiguration(Context context) {
12502bb4265ac41e1974ec7d4793e6c2a0ed2adc3c4Jungshik Jang        // Properties that don't have to be reloaded with each configuration change can be loaded
12602bb4265ac41e1974ec7d4793e6c2a0ed2adc3c4Jungshik Jang        // here.
12702bb4265ac41e1974ec7d4793e6c2a0ed2adc3c4Jungshik Jang
12802bb4265ac41e1974ec7d4793e6c2a0ed2adc3c4Jungshik Jang        // Interpolators
12902bb4265ac41e1974ec7d4793e6c2a0ed2adc3c4Jungshik Jang        fastOutSlowInInterpolator = AnimationUtils.loadInterpolator(context,
13002bb4265ac41e1974ec7d4793e6c2a0ed2adc3c4Jungshik Jang                com.android.internal.R.interpolator.fast_out_slow_in);
13102bb4265ac41e1974ec7d4793e6c2a0ed2adc3c4Jungshik Jang        fastOutLinearInInterpolator = AnimationUtils.loadInterpolator(context,
13202bb4265ac41e1974ec7d4793e6c2a0ed2adc3c4Jungshik Jang                com.android.internal.R.interpolator.fast_out_linear_in);
13302bb4265ac41e1974ec7d4793e6c2a0ed2adc3c4Jungshik Jang        linearOutSlowInInterpolator = AnimationUtils.loadInterpolator(context,
1341ca0a43251a31bb1b4253dc404316cc4b840f497Terry Heo                com.android.internal.R.interpolator.linear_out_slow_in);
135f67113f7abd536cc3eb888344bf925762aa5278eJungshik Jang        quintOutInterpolator = AnimationUtils.loadInterpolator(context,
13638db629d897e9d7c8e31ce0a7e985981e3e12996Yuncheol Heo                com.android.internal.R.interpolator.decelerate_quint);
13738db629d897e9d7c8e31ce0a7e985981e3e12996Yuncheol Heo    }
138f67113f7abd536cc3eb888344bf925762aa5278eJungshik Jang
13938db629d897e9d7c8e31ce0a7e985981e3e12996Yuncheol Heo    /** Updates the configuration to the current context */
14038db629d897e9d7c8e31ce0a7e985981e3e12996Yuncheol Heo    public static RecentsConfiguration reinitialize(Context context, SystemServicesProxy ssp) {
14138db629d897e9d7c8e31ce0a7e985981e3e12996Yuncheol Heo        if (sInstance == null) {
14238db629d897e9d7c8e31ce0a7e985981e3e12996Yuncheol Heo            sInstance = new RecentsConfiguration(context);
14338db629d897e9d7c8e31ce0a7e985981e3e12996Yuncheol Heo        }
14438db629d897e9d7c8e31ce0a7e985981e3e12996Yuncheol Heo        int configHashCode = context.getResources().getConfiguration().hashCode();
14538db629d897e9d7c8e31ce0a7e985981e3e12996Yuncheol Heo        if (sPrevConfigurationHashCode != configHashCode) {
14638db629d897e9d7c8e31ce0a7e985981e3e12996Yuncheol Heo            sInstance.update(context);
14738db629d897e9d7c8e31ce0a7e985981e3e12996Yuncheol Heo            sPrevConfigurationHashCode = configHashCode;
14838db629d897e9d7c8e31ce0a7e985981e3e12996Yuncheol Heo        }
14938db629d897e9d7c8e31ce0a7e985981e3e12996Yuncheol Heo        sInstance.updateOnReinitialize(context, ssp);
1501ca0a43251a31bb1b4253dc404316cc4b840f497Terry Heo        return sInstance;
1515fe3a6cbfc50a8faf9cf051f1f09a7eb1ef6b7eeJinsuk Kim    }
1521ca0a43251a31bb1b4253dc404316cc4b840f497Terry Heo
1531ca0a43251a31bb1b4253dc404316cc4b840f497Terry Heo    /** Returns the current recents configuration */
1541ca0a43251a31bb1b4253dc404316cc4b840f497Terry Heo    public static RecentsConfiguration getInstance() {
1551ca0a43251a31bb1b4253dc404316cc4b840f497Terry Heo        return sInstance;
15638db629d897e9d7c8e31ce0a7e985981e3e12996Yuncheol Heo    }
15738db629d897e9d7c8e31ce0a7e985981e3e12996Yuncheol Heo
1585fe3a6cbfc50a8faf9cf051f1f09a7eb1ef6b7eeJinsuk Kim    /** Updates the state, given the specified context */
1595fe3a6cbfc50a8faf9cf051f1f09a7eb1ef6b7eeJinsuk Kim    void update(Context context) {
1605fe3a6cbfc50a8faf9cf051f1f09a7eb1ef6b7eeJinsuk Kim        SharedPreferences settings = context.getSharedPreferences(context.getPackageName(), 0);
1615fe3a6cbfc50a8faf9cf051f1f09a7eb1ef6b7eeJinsuk Kim        Resources res = context.getResources();
1625fe3a6cbfc50a8faf9cf051f1f09a7eb1ef6b7eeJinsuk Kim        DisplayMetrics dm = res.getDisplayMetrics();
1635fe3a6cbfc50a8faf9cf051f1f09a7eb1ef6b7eeJinsuk Kim
1645fe3a6cbfc50a8faf9cf051f1f09a7eb1ef6b7eeJinsuk Kim        // Debug mode
1655fe3a6cbfc50a8faf9cf051f1f09a7eb1ef6b7eeJinsuk Kim        debugModeEnabled = settings.getBoolean(Constants.Values.App.Key_DebugModeEnabled, false);
1665fe3a6cbfc50a8faf9cf051f1f09a7eb1ef6b7eeJinsuk Kim        if (debugModeEnabled) {
1675fe3a6cbfc50a8faf9cf051f1f09a7eb1ef6b7eeJinsuk Kim            Console.Enabled = true;
1685fe3a6cbfc50a8faf9cf051f1f09a7eb1ef6b7eeJinsuk Kim        }
1695fe3a6cbfc50a8faf9cf051f1f09a7eb1ef6b7eeJinsuk Kim
17038db629d897e9d7c8e31ce0a7e985981e3e12996Yuncheol Heo        // Layout
17138db629d897e9d7c8e31ce0a7e985981e3e12996Yuncheol Heo        isLandscape = res.getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
1720792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang        transposeRecentsLayoutWithOrientation =
1730792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang                res.getBoolean(R.bool.recents_transpose_layout_with_orientation);
1740792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang
1750792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang        // Insets
1760792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang        displayRect.set(0, 0, dm.widthPixels, dm.heightPixels);
17778d695d8ba532214b02e7f18e0ccf89cf099163dJinsuk Kim
17878d695d8ba532214b02e7f18e0ccf89cf099163dJinsuk Kim        // Animations
17978d695d8ba532214b02e7f18e0ccf89cf099163dJinsuk Kim        animationPxMovementPerSecond =
1800340bbc89f8162f9c2a298c98b03bfcdd1bc6e87Jinsuk Kim                res.getDimensionPixelSize(R.dimen.recents_animation_movement_in_dps_per_second);
1810340bbc89f8162f9c2a298c98b03bfcdd1bc6e87Jinsuk Kim
18278d695d8ba532214b02e7f18e0ccf89cf099163dJinsuk Kim        // Filtering
18378d695d8ba532214b02e7f18e0ccf89cf099163dJinsuk Kim        filteringCurrentViewsAnimDuration =
1844893c7efde52411ad051ef5c20251439f4098eacJinsuk Kim                res.getInteger(R.integer.recents_filter_animate_current_views_duration);
18578d695d8ba532214b02e7f18e0ccf89cf099163dJinsuk Kim        filteringNewViewsAnimDuration =
18678d695d8ba532214b02e7f18e0ccf89cf099163dJinsuk Kim                res.getInteger(R.integer.recents_filter_animate_new_views_duration);
18778d695d8ba532214b02e7f18e0ccf89cf099163dJinsuk Kim
188f424932cfb1b16b01a37500d09e295912700a51dJungshik Jang        // Loading
1894893c7efde52411ad051ef5c20251439f4098eacJinsuk Kim        maxNumTasksToLoad = res.getInteger(R.integer.recents_max_num_tasks_to_load);
1906d97f5b91c6c82f28a2a3a5d3b922f0e5844e733Jinsuk Kim
1916d97f5b91c6c82f28a2a3a5d3b922f0e5844e733Jinsuk Kim        // Search Bar
1926d97f5b91c6c82f28a2a3a5d3b922f0e5844e733Jinsuk Kim        searchBarSpaceHeightPx = res.getDimensionPixelSize(R.dimen.recents_search_bar_space_height);
193f424932cfb1b16b01a37500d09e295912700a51dJungshik Jang        searchBarAppWidgetId = settings.getInt(Constants.Values.App.Key_SearchAppWidgetId, -1);
194119160a68195bcb2f5bdf4a269807e01228eca97Jinsuk Kim
195119160a68195bcb2f5bdf4a269807e01228eca97Jinsuk Kim        // Task stack
196119160a68195bcb2f5bdf4a269807e01228eca97Jinsuk Kim        TypedValue widthPaddingPctValue = new TypedValue();
197119160a68195bcb2f5bdf4a269807e01228eca97Jinsuk Kim        res.getValue(R.dimen.recents_stack_width_padding_percentage, widthPaddingPctValue, true);
1989c37e1f53ea4734bfe5ae156dc5399ce5f2c7cccJinsuk Kim        taskStackWidthPaddingPct = widthPaddingPctValue.getFloat();
1999c37e1f53ea4734bfe5ae156dc5399ce5f2c7cccJinsuk Kim        taskStackMaxDim = res.getInteger(R.integer.recents_max_task_stack_view_dim);
2009c37e1f53ea4734bfe5ae156dc5399ce5f2c7cccJinsuk Kim        taskStackTopPaddingPx = res.getDimensionPixelSize(R.dimen.recents_stack_top_padding);
201b6591b8e5399099dc6b7693e0fc719b613aba89cJungshik Jang
20212e5dcefe136b58562f39604e6a8460ac92cb895Jungshik Jang        // Task view animation and styles
203b6591b8e5399099dc6b7693e0fc719b613aba89cJungshik Jang        taskViewEnterFromHomeDuration =
20492b77cf9cbf512e7141cad6fef5a38d0682dde43Jinsuk Kim                res.getInteger(R.integer.recents_animate_task_enter_from_home_duration);
20592b77cf9cbf512e7141cad6fef5a38d0682dde43Jinsuk Kim        taskViewEnterFromHomeDelay =
20692b77cf9cbf512e7141cad6fef5a38d0682dde43Jinsuk Kim                res.getInteger(R.integer.recents_animate_task_enter_from_home_delay);
20792b77cf9cbf512e7141cad6fef5a38d0682dde43Jinsuk Kim        taskViewExitToHomeDuration =
20892b77cf9cbf512e7141cad6fef5a38d0682dde43Jinsuk Kim                res.getInteger(R.integer.recents_animate_task_exit_to_home_duration);
2094d43d93743222311c6377d4904c19ccb93699d3bJinsuk Kim        taskViewRemoveAnimDuration =
2104d43d93743222311c6377d4904c19ccb93699d3bJinsuk Kim                res.getInteger(R.integer.recents_animate_task_view_remove_duration);
2114d43d93743222311c6377d4904c19ccb93699d3bJinsuk Kim        taskViewRemoveAnimTranslationXPx =
2124d43d93743222311c6377d4904c19ccb93699d3bJinsuk Kim                res.getDimensionPixelSize(R.dimen.recents_task_view_remove_anim_translation_x);
2134d43d93743222311c6377d4904c19ccb93699d3bJinsuk Kim        taskViewRoundedCornerRadiusPx =
2144d43d93743222311c6377d4904c19ccb93699d3bJinsuk Kim                res.getDimensionPixelSize(R.dimen.recents_task_view_rounded_corners_radius);
215ea67c183fe5511ad99aeaae1a32b5245bd020e36Jungshik Jang        taskViewHighlightPx = res.getDimensionPixelSize(R.dimen.recents_task_view_highlight);
216ea67c183fe5511ad99aeaae1a32b5245bd020e36Jungshik Jang        taskViewTranslationZMinPx = res.getDimensionPixelSize(R.dimen.recents_task_view_z_min);
217ea67c183fe5511ad99aeaae1a32b5245bd020e36Jungshik Jang        taskViewTranslationZMaxPx = res.getDimensionPixelSize(R.dimen.recents_task_view_z_max);
218ea67c183fe5511ad99aeaae1a32b5245bd020e36Jungshik Jang        taskViewAffiliateGroupEnterOffsetPx =
2194893c7efde52411ad051ef5c20251439f4098eacJinsuk Kim                res.getDimensionPixelSize(R.dimen.recents_task_view_affiliate_group_enter_offset);
2200340bbc89f8162f9c2a298c98b03bfcdd1bc6e87Jinsuk Kim
2210340bbc89f8162f9c2a298c98b03bfcdd1bc6e87Jinsuk Kim        // Task bar colors
2225008486b09c588bf3409b70d9ee29225e8593c64Jinsuk Kim        taskBarViewDefaultBackgroundColor =
2235008486b09c588bf3409b70d9ee29225e8593c64Jinsuk Kim                res.getColor(R.color.recents_task_bar_default_background_color);
224f424932cfb1b16b01a37500d09e295912700a51dJungshik Jang        taskBarViewLightTextColor =
225f424932cfb1b16b01a37500d09e295912700a51dJungshik Jang                res.getColor(R.color.recents_task_bar_light_text_color);
226f424932cfb1b16b01a37500d09e295912700a51dJungshik Jang        taskBarViewDarkTextColor =
2270792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang                res.getColor(R.color.recents_task_bar_dark_text_color);
2280792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang        taskBarViewHighlightColor =
2290792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang                res.getColor(R.color.recents_task_bar_highlight_color);
2300340bbc89f8162f9c2a298c98b03bfcdd1bc6e87Jinsuk Kim        TypedValue affMinAlphaPctValue = new TypedValue();
2310340bbc89f8162f9c2a298c98b03bfcdd1bc6e87Jinsuk Kim        res.getValue(R.dimen.recents_task_affiliation_color_min_alpha_percentage, affMinAlphaPctValue, true);
2320340bbc89f8162f9c2a298c98b03bfcdd1bc6e87Jinsuk Kim        taskBarViewAffiliationColorMinAlpha = affMinAlphaPctValue.getFloat();
2330340bbc89f8162f9c2a298c98b03bfcdd1bc6e87Jinsuk Kim
2342b152015ff94f20b9ec3ef284fb83105f8b3c831Jinsuk Kim        // Task bar size & animations
23530c74d9ba60a7208a587ecd6dcdfef1cfbd7fce7Jinsuk Kim        taskBarHeight = res.getDimensionPixelSize(R.dimen.recents_task_bar_height);
2362b152015ff94f20b9ec3ef284fb83105f8b3c831Jinsuk Kim        taskBarEnterAnimDuration =
2372b152015ff94f20b9ec3ef284fb83105f8b3c831Jinsuk Kim                res.getInteger(R.integer.recents_animate_task_bar_enter_duration);
23830c74d9ba60a7208a587ecd6dcdfef1cfbd7fce7Jinsuk Kim        taskBarEnterAnimDelay =
2392b152015ff94f20b9ec3ef284fb83105f8b3c831Jinsuk Kim                res.getInteger(R.integer.recents_animate_task_bar_enter_delay);
240e9f6ed3b11fb8ebae5e73db1e4736b86cae272d9Jinsuk Kim        taskBarExitAnimDuration =
241e9f6ed3b11fb8ebae5e73db1e4736b86cae272d9Jinsuk Kim                res.getInteger(R.integer.recents_animate_task_bar_exit_duration);
242e9f6ed3b11fb8ebae5e73db1e4736b86cae272d9Jinsuk Kim        taskBarDismissDozeDelaySeconds =
24375a77e7d6cbfc287c6126efd28b338b48b7ea70cYuncheol Heo                res.getInteger(R.integer.recents_task_bar_dismiss_delay_seconds);
24475a77e7d6cbfc287c6126efd28b338b48b7ea70cYuncheol Heo
24538db629d897e9d7c8e31ce0a7e985981e3e12996Yuncheol Heo        // Lock to app
246c0c20d0522d7756d80f011e7a54bf3b51c78df41Jinsuk Kim        taskViewLockToAppButtonHeight =
24738db629d897e9d7c8e31ce0a7e985981e3e12996Yuncheol Heo                res.getDimensionPixelSize(R.dimen.recents_task_view_lock_to_app_button_height);
24838db629d897e9d7c8e31ce0a7e985981e3e12996Yuncheol Heo        taskViewLockToAppShortAnimDuration =
2491ca0a43251a31bb1b4253dc404316cc4b840f497Terry Heo                res.getInteger(R.integer.recents_animate_lock_to_app_button_short_duration);
2501ca0a43251a31bb1b4253dc404316cc4b840f497Terry Heo        taskViewLockToAppLongAnimDuration =
2511ca0a43251a31bb1b4253dc404316cc4b840f497Terry Heo                res.getInteger(R.integer.recents_animate_lock_to_app_button_long_duration);
25238db629d897e9d7c8e31ce0a7e985981e3e12996Yuncheol Heo
25338db629d897e9d7c8e31ce0a7e985981e3e12996Yuncheol Heo        // Nav bar scrim
254fc44e4e03c5f6486efb7457965dcf7eaf36bc971Yuncheol Heo        navBarScrimEnterDuration =
255fc44e4e03c5f6486efb7457965dcf7eaf36bc971Yuncheol Heo                res.getInteger(R.integer.recents_nav_bar_scrim_enter_duration);
256fc44e4e03c5f6486efb7457965dcf7eaf36bc971Yuncheol Heo
257867b4e0c55b4b1e432a3585fc945a999f066ef81Jungshik Jang        // Misc
258867b4e0c55b4b1e432a3585fc945a999f066ef81Jungshik Jang        altTabKeyDelay = res.getInteger(R.integer.recents_alt_tab_key_delay);
259867b4e0c55b4b1e432a3585fc945a999f066ef81Jungshik Jang    }
260f286b4d86b4b2ac91edb88d0336810e46d9a16ceJinsuk Kim
261f286b4d86b4b2ac91edb88d0336810e46d9a16ceJinsuk Kim    /** Updates the system insets */
262f286b4d86b4b2ac91edb88d0336810e46d9a16ceJinsuk Kim    public void updateSystemInsets(Rect insets) {
263f286b4d86b4b2ac91edb88d0336810e46d9a16ceJinsuk Kim        systemInsets.set(insets);
264b3fbf9dbe8d41d91efbac2118b676af74592257bJinsuk Kim    }
265f286b4d86b4b2ac91edb88d0336810e46d9a16ceJinsuk Kim
266b3fbf9dbe8d41d91efbac2118b676af74592257bJinsuk Kim    /** Updates the search bar app widget */
267b3fbf9dbe8d41d91efbac2118b676af74592257bJinsuk Kim    public void updateSearchBarAppWidgetId(Context context, int appWidgetId) {
268f286b4d86b4b2ac91edb88d0336810e46d9a16ceJinsuk Kim        searchBarAppWidgetId = appWidgetId;
269f286b4d86b4b2ac91edb88d0336810e46d9a16ceJinsuk Kim        SharedPreferences settings = context.getSharedPreferences(context.getPackageName(), 0);
270f286b4d86b4b2ac91edb88d0336810e46d9a16ceJinsuk Kim        settings.edit().putInt(Constants.Values.App.Key_SearchAppWidgetId,
271f286b4d86b4b2ac91edb88d0336810e46d9a16ceJinsuk Kim                appWidgetId).apply();
272f286b4d86b4b2ac91edb88d0336810e46d9a16ceJinsuk Kim    }
273781041239f2931ca16c902fb371cd041b057c918Jinsuk Kim
274f286b4d86b4b2ac91edb88d0336810e46d9a16ceJinsuk Kim    /** Updates the states that need to be re-read whenever we re-initialize. */
275f286b4d86b4b2ac91edb88d0336810e46d9a16ceJinsuk Kim    void updateOnReinitialize(Context context, SystemServicesProxy ssp) {
276f286b4d86b4b2ac91edb88d0336810e46d9a16ceJinsuk Kim        // Check if the developer options are enabled
277e9f6ed3b11fb8ebae5e73db1e4736b86cae272d9Jinsuk Kim        developerOptionsEnabled = ssp.getGlobalSetting(context,
278e9f6ed3b11fb8ebae5e73db1e4736b86cae272d9Jinsuk Kim                Settings.Global.DEVELOPMENT_SETTINGS_ENABLED) != 0;
279e9f6ed3b11fb8ebae5e73db1e4736b86cae272d9Jinsuk Kim        lockToAppEnabled = ssp.getSystemSetting(context,
280e9f6ed3b11fb8ebae5e73db1e4736b86cae272d9Jinsuk Kim                Settings.System.LOCK_TO_APP_ENABLED) != 0;
2810792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang    }
2820792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang
2837d9acc7a3eddb3e57c0b8312c3baf7ebb4f529d9Yuncheol Heo    /** Called when the configuration has changed, and we want to reset any configuration specific
2845008486b09c588bf3409b70d9ee29225e8593c64Jinsuk Kim     * members. */
2850792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang    public void updateOnConfigurationChange() {
2860792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang        launchedWithAltTab = false;
2877d9acc7a3eddb3e57c0b8312c3baf7ebb4f529d9Yuncheol Heo        launchedWithNoRecentTasks = false;
2887d9acc7a3eddb3e57c0b8312c3baf7ebb4f529d9Yuncheol Heo        launchedFromAppWithThumbnail = false;
2897d9acc7a3eddb3e57c0b8312c3baf7ebb4f529d9Yuncheol Heo        launchedFromAppWithScreenshot = false;
2907d9acc7a3eddb3e57c0b8312c3baf7ebb4f529d9Yuncheol Heo        launchedFromHome = false;
2917d9acc7a3eddb3e57c0b8312c3baf7ebb4f529d9Yuncheol Heo        launchedToTaskId = -1;
2927d9acc7a3eddb3e57c0b8312c3baf7ebb4f529d9Yuncheol Heo    }
2937d9acc7a3eddb3e57c0b8312c3baf7ebb4f529d9Yuncheol Heo
2947d9acc7a3eddb3e57c0b8312c3baf7ebb4f529d9Yuncheol Heo    /** Returns whether the search bar app widget exists. */
2957d9acc7a3eddb3e57c0b8312c3baf7ebb4f529d9Yuncheol Heo    public boolean hasSearchBarAppWidget() {
2967d9acc7a3eddb3e57c0b8312c3baf7ebb4f529d9Yuncheol Heo        return searchBarAppWidgetId >= 0;
2977d9acc7a3eddb3e57c0b8312c3baf7ebb4f529d9Yuncheol Heo    }
2987d9acc7a3eddb3e57c0b8312c3baf7ebb4f529d9Yuncheol Heo
2997d9acc7a3eddb3e57c0b8312c3baf7ebb4f529d9Yuncheol Heo    /** Returns whether the status bar scrim should be animated when shown for the first time. */
3007d9acc7a3eddb3e57c0b8312c3baf7ebb4f529d9Yuncheol Heo    public boolean shouldAnimateStatusBarScrim() {
3010792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang        return launchedFromHome;
3020792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang    }
3032f51aec689226e259d08bf04d838251f249572e3Jungshik Jang
304c0c20d0522d7756d80f011e7a54bf3b51c78df41Jinsuk Kim    /** Returns whether the status bar scrim should be visible. */
3057ecfbaed6e902aea151bc1919cf7771bbd868fc4Jinsuk Kim    public boolean hasStatusBarScrim() {
3067ecfbaed6e902aea151bc1919cf7771bbd868fc4Jinsuk Kim        return !launchedWithNoRecentTasks;
30708a1be81d7b597f858164fee6a4934264259b3aeYuncheol Heo    }
3088b308d93c8fdcc7304b33d9b445ae3807eae97c8Jungshik Jang
309a9f10629f4bc1a82761917645ff4d2b6d42e47b3Jungshik Jang    /** Returns whether the nav bar scrim should be animated when shown for the first time. */
3103ee65720e91c7f92ad5a034d7052122a606aa8d5Jungshik Jang    public boolean shouldAnimateNavBarScrim() {
311347a60449981fc934e5a84122df87c1447665548Yuncheol Heo        return true;
3125008486b09c588bf3409b70d9ee29225e8593c64Jinsuk Kim    }
313347a60449981fc934e5a84122df87c1447665548Yuncheol Heo
314a9f10629f4bc1a82761917645ff4d2b6d42e47b3Jungshik Jang    /** Returns whether the nav bar scrim should be visible. */
315a9f10629f4bc1a82761917645ff4d2b6d42e47b3Jungshik Jang    public boolean hasNavBarScrim() {
316fc44e4e03c5f6486efb7457965dcf7eaf36bc971Yuncheol Heo        // Only show the scrim if we have recent tasks, and if the nav bar is not transposed
317a9f10629f4bc1a82761917645ff4d2b6d42e47b3Jungshik Jang        return !launchedWithNoRecentTasks &&
318a8a5e50c6f9ba3ae0ff59eda76354e93515d6f8fJinsuk Kim                (!transposeRecentsLayoutWithOrientation || !isLandscape);
3190792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang    }
32008f1ab02d6de42756825a2dfa7027137ff959bd8Jinsuk Kim
3210792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang    /** Returns whether the current layout is horizontal. */
3220792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang    public boolean hasHorizontalLayout() {
323781041239f2931ca16c902fb371cd041b057c918Jinsuk Kim        return isLandscape && transposeRecentsLayoutWithOrientation;
324f286b4d86b4b2ac91edb88d0336810e46d9a16ceJinsuk Kim    }
3250792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang
3260792d37385e60aa8d73f8df174d0a32f4f618bc4Jungshik Jang    /**
327ed0864557b3340ab7db00e2dc95b29c4b8bb485dJinsuk Kim     * Returns the task stack bounds in the current orientation. These bounds do not account for
328f286b4d86b4b2ac91edb88d0336810e46d9a16ceJinsuk Kim     * the system insets.
329f286b4d86b4b2ac91edb88d0336810e46d9a16ceJinsuk Kim     */
33075a77e7d6cbfc287c6126efd28b338b48b7ea70cYuncheol Heo    public void getTaskStackBounds(int windowWidth, int windowHeight, int topInset, int rightInset,
3318692fc68a413c7aca75f094bb02bcbabcc277c73Jinsuk Kim                                   Rect taskStackBounds) {
33263a2e0696ce2a04fbe0f1f00cfe9c93189f944daYuncheol Heo        Rect searchBarBounds = new Rect();
333f286b4d86b4b2ac91edb88d0336810e46d9a16ceJinsuk Kim        getSearchBarBounds(windowWidth, windowHeight, topInset, searchBarBounds);
3340608b9328b1c2f804ffb2d4165c34383d34bde2aYuncheol Heo        if (isLandscape && transposeRecentsLayoutWithOrientation) {
33538db629d897e9d7c8e31ce0a7e985981e3e12996Yuncheol Heo            // In landscape, the search bar appears on the left
33638db629d897e9d7c8e31ce0a7e985981e3e12996Yuncheol Heo            taskStackBounds.set(searchBarBounds.right, topInset, windowWidth - rightInset, windowHeight);
33738db629d897e9d7c8e31ce0a7e985981e3e12996Yuncheol Heo        } else {
3381ca0a43251a31bb1b4253dc404316cc4b840f497Terry Heo            // In portrait, the search bar appears on the top (which already has the inset)
3391ca0a43251a31bb1b4253dc404316cc4b840f497Terry Heo            taskStackBounds.set(0, searchBarBounds.bottom, windowWidth, windowHeight);
3400608b9328b1c2f804ffb2d4165c34383d34bde2aYuncheol Heo        }
3410608b9328b1c2f804ffb2d4165c34383d34bde2aYuncheol Heo    }
3420608b9328b1c2f804ffb2d4165c34383d34bde2aYuncheol Heo
34338db629d897e9d7c8e31ce0a7e985981e3e12996Yuncheol Heo    /**
3447ecfbaed6e902aea151bc1919cf7771bbd868fc4Jinsuk Kim     * Returns the search bar bounds in the current orientation.  These bounds do not account for
34538db629d897e9d7c8e31ce0a7e985981e3e12996Yuncheol Heo     * the system insets.
34625c20298ad04e0e591e0cfdc0bb9d01a985433abYuncheol Heo     */
34725c20298ad04e0e591e0cfdc0bb9d01a985433abYuncheol Heo    public void getSearchBarBounds(int windowWidth, int windowHeight, int topInset,
34825c20298ad04e0e591e0cfdc0bb9d01a985433abYuncheol Heo                                   Rect searchBarSpaceBounds) {
3490608b9328b1c2f804ffb2d4165c34383d34bde2aYuncheol Heo        // Return empty rects if search is not enabled
350fc44e4e03c5f6486efb7457965dcf7eaf36bc971Yuncheol Heo        int searchBarSize = searchBarSpaceHeightPx;
351fc44e4e03c5f6486efb7457965dcf7eaf36bc971Yuncheol Heo        if (!Constants.DebugFlags.App.EnableSearchLayout || !hasSearchBarAppWidget()) {
352fc44e4e03c5f6486efb7457965dcf7eaf36bc971Yuncheol Heo            searchBarSize = 0;
353fc44e4e03c5f6486efb7457965dcf7eaf36bc971Yuncheol Heo        }
354fc44e4e03c5f6486efb7457965dcf7eaf36bc971Yuncheol Heo
35525c20298ad04e0e591e0cfdc0bb9d01a985433abYuncheol Heo        if (isLandscape && transposeRecentsLayoutWithOrientation) {
3565008486b09c588bf3409b70d9ee29225e8593c64Jinsuk Kim            // In landscape, the search bar appears on the left
3570608b9328b1c2f804ffb2d4165c34383d34bde2aYuncheol Heo            searchBarSpaceBounds.set(0, topInset, searchBarSize, windowHeight);
3580608b9328b1c2f804ffb2d4165c34383d34bde2aYuncheol Heo        } else {
3590608b9328b1c2f804ffb2d4165c34383d34bde2aYuncheol Heo            // In portrait, the search bar appears on the top
3600608b9328b1c2f804ffb2d4165c34383d34bde2aYuncheol Heo            searchBarSpaceBounds.set(0, topInset, windowWidth, topInset + searchBarSize);
3610608b9328b1c2f804ffb2d4165c34383d34bde2aYuncheol Heo        }
3620608b9328b1c2f804ffb2d4165c34383d34bde2aYuncheol Heo    }
3630608b9328b1c2f804ffb2d4165c34383d34bde2aYuncheol Heo}
3640608b9328b1c2f804ffb2d4165c34383d34bde2aYuncheol Heo