RecentsConfiguration.java revision cb5570316d55c6fe2ff717fa6b94b14d13980263
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; 21f7bca430d9356c26d6df222d2c90bc7668262f6bWinson Chungimport android.content.SharedPreferences; 226736905dc0e10689f7c63f6da43b31325caf966aWinson Chungimport android.content.res.Configuration; 23c620bafde865f7599401f5adf0521820ee9d4a9cWinson Chungimport android.content.res.Resources; 24303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chungimport android.graphics.Rect; 2547a3e65acc35cd3061bf3867e8b20753870fd892Winson Chungimport android.provider.Settings; 26303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chungimport android.util.DisplayMetrics; 27303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chungimport android.util.TypedValue; 28918c0723a169cef46b8bf59c06fd3bb8021d0defWinson Chungimport android.view.animation.AnimationUtils; 29918c0723a169cef46b8bf59c06fd3bb8021d0defWinson Chungimport android.view.animation.Interpolator; 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 41d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung /** Animations */ 4200350bb3a03e15cbde74db9a07ab98eb08b4e4dfWinson Chung public float animationPxMovementPerSecond; 432f2ca08baa072376b3dfd60506625496aa05903fWinson Chung 44d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung /** Interpolators */ 45b01ed681fe97ff5e98471c120ff9581a78db13c5Winson Chung public Interpolator fastOutSlowInInterpolator; 46b01ed681fe97ff5e98471c120ff9581a78db13c5Winson Chung public Interpolator fastOutLinearInInterpolator; 47b01ed681fe97ff5e98471c120ff9581a78db13c5Winson Chung public Interpolator linearOutSlowInInterpolator; 48d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung public Interpolator quintOutInterpolator; 49918c0723a169cef46b8bf59c06fd3bb8021d0defWinson Chung 50d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung /** Filtering */ 51e0e45bc26d02e2c6ec505ea006e7487f3a5bddc5Winson Chung public int filteringCurrentViewsAnimDuration; 52e0e45bc26d02e2c6ec505ea006e7487f3a5bddc5Winson Chung public int filteringNewViewsAnimDuration; 53cd23c849afefe58b213d5abb1c581f15d3ad543aWinson Chung 54d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung /** Insets */ 55d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung public Rect systemInsets = new Rect(); 56d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung public Rect displayRect = new Rect(); 57d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung 58d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung /** Layout */ 59d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung boolean isLandscape; 6027acf761229779e1777d380616846ac07f484ed6Winson Chung boolean hasTransposedSearchBar; 6127acf761229779e1777d380616846ac07f484ed6Winson Chung boolean hasTransposedNavBar; 62d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung 63b1f749906f5c27114d02ea0c3f8ce0dcea08fd3fWinson Chung /** Loading */ 64b1f749906f5c27114d02ea0c3f8ce0dcea08fd3fWinson Chung public int maxNumTasksToLoad; 65b1f749906f5c27114d02ea0c3f8ce0dcea08fd3fWinson Chung 66d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung /** Search bar */ 67d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung int searchBarAppWidgetId = -1; 68d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung public int searchBarSpaceHeightPx; 69d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung 70d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung /** Task stack */ 71ebfc6981828b0699eef85c58b23a61f2cac41af3Winson Chung public int taskStackScrollDuration; 721492646b792360945fba6bdcacc6aa7c19c6618eWinson Chung public int taskStackMaxDim; 73cd23c849afefe58b213d5abb1c581f15d3ad543aWinson Chung public int taskStackTopPaddingPx; 74d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung public float taskStackWidthPaddingPct; 75ebfc6981828b0699eef85c58b23a61f2cac41af3Winson Chung public float taskStackOverscrollPct; 76cd23c849afefe58b213d5abb1c581f15d3ad543aWinson Chung 77d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung /** Task view animation and styles */ 78d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung public int taskViewEnterFromHomeDelay; 7919d62382d0acafa0ffe8e48ebb4c737031b3e9c6Winson Chung public int taskViewEnterFromHomeDuration; 8019d62382d0acafa0ffe8e48ebb4c737031b3e9c6Winson Chung public int taskViewEnterFromHomeStaggerDelay; 81ad6f276670443ac8f9b73497dae185bb005c3a76Winson Chung public int taskViewExitToHomeDuration; 829f49df933f01a32d04bdf92d53c943065aa8ddf7Winson Chung public int taskViewRemoveAnimDuration; 839f49df933f01a32d04bdf92d53c943065aa8ddf7Winson Chung public int taskViewRemoveAnimTranslationXPx; 8496e3bc1f8d7c199df6fca603d0c5e59d9b70ca1bWinson Chung public int taskViewTranslationZMinPx; 85012ef36a6c5e9745d112c734aed916cab052558cWinson Chung public int taskViewTranslationZMaxPx; 861492646b792360945fba6bdcacc6aa7c19c6618eWinson Chung public int taskViewRoundedCornerRadiusPx; 87cd23c849afefe58b213d5abb1c581f15d3ad543aWinson Chung public int taskViewHighlightPx; 881907cd478209f01a4215d9a3a76294c2c77c9a63Winson Chung public int taskViewAffiliateGroupEnterOffsetPx; 8960a729c8e93461c9446d0c8cd519b40dec01e8d8Winson Chung public float taskViewThumbnailAlpha; 90cd23c849afefe58b213d5abb1c581f15d3ad543aWinson Chung 91d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung /** Task bar colors */ 92f5e22e71cb5f8699a4312c797af068f655cbe629Winson Chung public int taskBarViewDefaultBackgroundColor; 93f5e22e71cb5f8699a4312c797af068f655cbe629Winson Chung public int taskBarViewLightTextColor; 94f5e22e71cb5f8699a4312c797af068f655cbe629Winson Chung public int taskBarViewDarkTextColor; 95cd23c849afefe58b213d5abb1c581f15d3ad543aWinson Chung public int taskBarViewHighlightColor; 96ec396d6399c5c31d697d81e94aff459e9771b0c6Winson Chung public float taskBarViewAffiliationColorMinAlpha; 97cd23c849afefe58b213d5abb1c581f15d3ad543aWinson Chung 98a433fa9c17772f563163ff7db177d091d6aebd5bWinson Chung /** Task bar size & animations */ 99a433fa9c17772f563163ff7db177d091d6aebd5bWinson Chung public int taskBarHeight; 100cd23c849afefe58b213d5abb1c581f15d3ad543aWinson Chung public int taskBarEnterAnimDuration; 101521e7dc0a6782371a710ee81bf804f7e97aaa292Winson Chung public int taskBarEnterAnimDelay; 102cd23c849afefe58b213d5abb1c581f15d3ad543aWinson Chung public int taskBarExitAnimDuration; 103a26fb7822ddf3511796279b847cc216bee9e7f70Winson Chung public int taskBarDismissDozeDelaySeconds; 104f5e22e71cb5f8699a4312c797af068f655cbe629Winson Chung 1051f24c7e37bc794057a156a730c7e4b53b01212edWinson Chung /** Lock to app */ 1061f24c7e37bc794057a156a730c7e4b53b01212edWinson Chung public int taskViewLockToAppButtonHeight; 1071f24c7e37bc794057a156a730c7e4b53b01212edWinson Chung public int taskViewLockToAppShortAnimDuration; 1081f24c7e37bc794057a156a730c7e4b53b01212edWinson Chung public int taskViewLockToAppLongAnimDuration; 1091f24c7e37bc794057a156a730c7e4b53b01212edWinson Chung 110d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung /** Nav bar scrim */ 111521e7dc0a6782371a710ee81bf804f7e97aaa292Winson Chung public int navBarScrimEnterDuration; 112521e7dc0a6782371a710ee81bf804f7e97aaa292Winson Chung 113d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung /** Launch states */ 114d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung public boolean launchedWithAltTab; 115969f586533096999f10f5587f901949791154fa2Winson Chung public boolean launchedWithNoRecentTasks; 116d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung public boolean launchedFromAppWithThumbnail; 117d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung public boolean launchedFromAppWithScreenshot; 118d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung public boolean launchedFromHome; 1196057c91563402f900dfc7714a46e952d86172e2fWinson Chung public int launchedToTaskId; 120b44c24fb50845dfbc1f49e78085cf5e01a32067fWinson Chung 121a0e88b5013d708ac6ed6518817d83c64c87ae4b1Winson Chung /** Misc **/ 122e8199c582d826a39e6e47b0d8418834c15242fecSelim Cinek public boolean useHardwareLayers; 123a0e88b5013d708ac6ed6518817d83c64c87ae4b1Winson Chung public int altTabKeyDelay; 124cb5570316d55c6fe2ff717fa6b94b14d13980263Jorim Jaggi public boolean fakeShadows; 125a0e88b5013d708ac6ed6518817d83c64c87ae4b1Winson Chung 12656e09b42a0f1670970872bef611a8036904ad6bfJason Monk /** Dev options and global settings */ 12756e09b42a0f1670970872bef611a8036904ad6bfJason Monk public boolean lockToAppEnabled; 12847a3e65acc35cd3061bf3867e8b20753870fd892Winson Chung public boolean developerOptionsEnabled; 1298eaeb7dc93ed71b768a2ea8d45021cca010e8263Winson Chung public boolean debugModeEnabled; 13047a3e65acc35cd3061bf3867e8b20753870fd892Winson Chung 131303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung /** Private constructor */ 13206795630f62e1e7ad89825db23d7656f8dcd6c5aWinson Chung private RecentsConfiguration(Context context) { 13306795630f62e1e7ad89825db23d7656f8dcd6c5aWinson Chung // Properties that don't have to be reloaded with each configuration change can be loaded 13406795630f62e1e7ad89825db23d7656f8dcd6c5aWinson Chung // here. 13506795630f62e1e7ad89825db23d7656f8dcd6c5aWinson Chung 13606795630f62e1e7ad89825db23d7656f8dcd6c5aWinson Chung // Interpolators 13706795630f62e1e7ad89825db23d7656f8dcd6c5aWinson Chung fastOutSlowInInterpolator = AnimationUtils.loadInterpolator(context, 13806795630f62e1e7ad89825db23d7656f8dcd6c5aWinson Chung com.android.internal.R.interpolator.fast_out_slow_in); 13906795630f62e1e7ad89825db23d7656f8dcd6c5aWinson Chung fastOutLinearInInterpolator = AnimationUtils.loadInterpolator(context, 14006795630f62e1e7ad89825db23d7656f8dcd6c5aWinson Chung com.android.internal.R.interpolator.fast_out_linear_in); 14106795630f62e1e7ad89825db23d7656f8dcd6c5aWinson Chung linearOutSlowInInterpolator = AnimationUtils.loadInterpolator(context, 14206795630f62e1e7ad89825db23d7656f8dcd6c5aWinson Chung com.android.internal.R.interpolator.linear_out_slow_in); 14306795630f62e1e7ad89825db23d7656f8dcd6c5aWinson Chung quintOutInterpolator = AnimationUtils.loadInterpolator(context, 14406795630f62e1e7ad89825db23d7656f8dcd6c5aWinson Chung com.android.internal.R.interpolator.decelerate_quint); 14506795630f62e1e7ad89825db23d7656f8dcd6c5aWinson Chung } 146303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung 147303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung /** Updates the configuration to the current context */ 14856e09b42a0f1670970872bef611a8036904ad6bfJason Monk public static RecentsConfiguration reinitialize(Context context, SystemServicesProxy ssp) { 149303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung if (sInstance == null) { 15006795630f62e1e7ad89825db23d7656f8dcd6c5aWinson Chung sInstance = new RecentsConfiguration(context); 151303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung } 15285cfec811e35025dbde54f4dc09fe0e1337c36b8Winson Chung int configHashCode = context.getResources().getConfiguration().hashCode(); 15385cfec811e35025dbde54f4dc09fe0e1337c36b8Winson Chung if (sPrevConfigurationHashCode != configHashCode) { 15485cfec811e35025dbde54f4dc09fe0e1337c36b8Winson Chung sInstance.update(context); 15585cfec811e35025dbde54f4dc09fe0e1337c36b8Winson Chung sPrevConfigurationHashCode = configHashCode; 15685cfec811e35025dbde54f4dc09fe0e1337c36b8Winson Chung } 15756e09b42a0f1670970872bef611a8036904ad6bfJason Monk sInstance.updateOnReinitialize(context, ssp); 158303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung return sInstance; 159303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung } 160303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung 161303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung /** Returns the current recents configuration */ 162303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung public static RecentsConfiguration getInstance() { 163303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung return sInstance; 164303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung } 165303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung 166303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung /** Updates the state, given the specified context */ 167303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung void update(Context context) { 1688eaeb7dc93ed71b768a2ea8d45021cca010e8263Winson Chung SharedPreferences settings = context.getSharedPreferences(context.getPackageName(), 0); 169c620bafde865f7599401f5adf0521820ee9d4a9cWinson Chung Resources res = context.getResources(); 170c620bafde865f7599401f5adf0521820ee9d4a9cWinson Chung DisplayMetrics dm = res.getDisplayMetrics(); 171303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung 1728eaeb7dc93ed71b768a2ea8d45021cca010e8263Winson Chung // Debug mode 1738eaeb7dc93ed71b768a2ea8d45021cca010e8263Winson Chung debugModeEnabled = settings.getBoolean(Constants.Values.App.Key_DebugModeEnabled, false); 1747aceb9a07fd3883c8f301ba93726d55494b0446eWinson Chung if (debugModeEnabled) { 1757aceb9a07fd3883c8f301ba93726d55494b0446eWinson Chung Console.Enabled = true; 1767aceb9a07fd3883c8f301ba93726d55494b0446eWinson Chung } 1778eaeb7dc93ed71b768a2ea8d45021cca010e8263Winson Chung 178242bbb86e8811ad8759790c1b499d0918baece8bWinson Chung // Layout 179b1f749906f5c27114d02ea0c3f8ce0dcea08fd3fWinson Chung isLandscape = res.getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE; 18027acf761229779e1777d380616846ac07f484ed6Winson Chung hasTransposedSearchBar = res.getBoolean(R.bool.recents_has_transposed_search_bar); 18127acf761229779e1777d380616846ac07f484ed6Winson Chung hasTransposedNavBar = res.getBoolean(R.bool.recents_has_transposed_nav_bar); 182242bbb86e8811ad8759790c1b499d0918baece8bWinson Chung 183242bbb86e8811ad8759790c1b499d0918baece8bWinson Chung // Insets 184242bbb86e8811ad8759790c1b499d0918baece8bWinson Chung displayRect.set(0, 0, dm.widthPixels, dm.heightPixels); 185242bbb86e8811ad8759790c1b499d0918baece8bWinson Chung 186d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung // Animations 18700350bb3a03e15cbde74db9a07ab98eb08b4e4dfWinson Chung animationPxMovementPerSecond = 1882f2ca08baa072376b3dfd60506625496aa05903fWinson Chung res.getDimensionPixelSize(R.dimen.recents_animation_movement_in_dps_per_second); 189d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung 190d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung // Filtering 191e0e45bc26d02e2c6ec505ea006e7487f3a5bddc5Winson Chung filteringCurrentViewsAnimDuration = 192e0e45bc26d02e2c6ec505ea006e7487f3a5bddc5Winson Chung res.getInteger(R.integer.recents_filter_animate_current_views_duration); 193e0e45bc26d02e2c6ec505ea006e7487f3a5bddc5Winson Chung filteringNewViewsAnimDuration = 194e0e45bc26d02e2c6ec505ea006e7487f3a5bddc5Winson Chung res.getInteger(R.integer.recents_filter_animate_new_views_duration); 195cd23c849afefe58b213d5abb1c581f15d3ad543aWinson Chung 196b1f749906f5c27114d02ea0c3f8ce0dcea08fd3fWinson Chung // Loading 197852975d5377bfe5f4abc9d2a28e301aa2fa99994Dianne Hackborn maxNumTasksToLoad = ActivityManager.getMaxRecentTasksStatic(); 198b1f749906f5c27114d02ea0c3f8ce0dcea08fd3fWinson Chung 19985cfec811e35025dbde54f4dc09fe0e1337c36b8Winson Chung // Search Bar 200d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung searchBarSpaceHeightPx = res.getDimensionPixelSize(R.dimen.recents_search_bar_space_height); 201d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung searchBarAppWidgetId = settings.getInt(Constants.Values.App.Key_SearchAppWidgetId, -1); 202d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung 203d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung // Task stack 204ebfc6981828b0699eef85c58b23a61f2cac41af3Winson Chung taskStackScrollDuration = 205ebfc6981828b0699eef85c58b23a61f2cac41af3Winson Chung res.getInteger(R.integer.recents_animate_task_stack_scroll_duration); 206cd23c849afefe58b213d5abb1c581f15d3ad543aWinson Chung TypedValue widthPaddingPctValue = new TypedValue(); 207cd23c849afefe58b213d5abb1c581f15d3ad543aWinson Chung res.getValue(R.dimen.recents_stack_width_padding_percentage, widthPaddingPctValue, true); 208cd23c849afefe58b213d5abb1c581f15d3ad543aWinson Chung taskStackWidthPaddingPct = widthPaddingPctValue.getFloat(); 209ebfc6981828b0699eef85c58b23a61f2cac41af3Winson Chung TypedValue stackOverscrollPctValue = new TypedValue(); 210ebfc6981828b0699eef85c58b23a61f2cac41af3Winson Chung res.getValue(R.dimen.recents_stack_overscroll_percentage, stackOverscrollPctValue, true); 211ebfc6981828b0699eef85c58b23a61f2cac41af3Winson Chung taskStackOverscrollPct = stackOverscrollPctValue.getFloat(); 212d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung taskStackMaxDim = res.getInteger(R.integer.recents_max_task_stack_view_dim); 213cd23c849afefe58b213d5abb1c581f15d3ad543aWinson Chung taskStackTopPaddingPx = res.getDimensionPixelSize(R.dimen.recents_stack_top_padding); 214cd23c849afefe58b213d5abb1c581f15d3ad543aWinson Chung 215d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung // Task view animation and styles 216d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung taskViewEnterFromHomeDelay = 217d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung res.getInteger(R.integer.recents_animate_task_enter_from_home_delay); 21819d62382d0acafa0ffe8e48ebb4c737031b3e9c6Winson Chung taskViewEnterFromHomeDuration = 21919d62382d0acafa0ffe8e48ebb4c737031b3e9c6Winson Chung res.getInteger(R.integer.recents_animate_task_enter_from_home_duration); 22019d62382d0acafa0ffe8e48ebb4c737031b3e9c6Winson Chung taskViewEnterFromHomeStaggerDelay = 22119d62382d0acafa0ffe8e48ebb4c737031b3e9c6Winson Chung res.getInteger(R.integer.recents_animate_task_enter_from_home_stagger_delay); 222ad6f276670443ac8f9b73497dae185bb005c3a76Winson Chung taskViewExitToHomeDuration = 223ad6f276670443ac8f9b73497dae185bb005c3a76Winson Chung res.getInteger(R.integer.recents_animate_task_exit_to_home_duration); 2249f49df933f01a32d04bdf92d53c943065aa8ddf7Winson Chung taskViewRemoveAnimDuration = 2259f49df933f01a32d04bdf92d53c943065aa8ddf7Winson Chung res.getInteger(R.integer.recents_animate_task_view_remove_duration); 2269f49df933f01a32d04bdf92d53c943065aa8ddf7Winson Chung taskViewRemoveAnimTranslationXPx = 2279f49df933f01a32d04bdf92d53c943065aa8ddf7Winson Chung res.getDimensionPixelSize(R.dimen.recents_task_view_remove_anim_translation_x); 2281492646b792360945fba6bdcacc6aa7c19c6618eWinson Chung taskViewRoundedCornerRadiusPx = 2291492646b792360945fba6bdcacc6aa7c19c6618eWinson Chung res.getDimensionPixelSize(R.dimen.recents_task_view_rounded_corners_radius); 230cd23c849afefe58b213d5abb1c581f15d3ad543aWinson Chung taskViewHighlightPx = res.getDimensionPixelSize(R.dimen.recents_task_view_highlight); 23196e3bc1f8d7c199df6fca603d0c5e59d9b70ca1bWinson Chung taskViewTranslationZMinPx = res.getDimensionPixelSize(R.dimen.recents_task_view_z_min); 232012ef36a6c5e9745d112c734aed916cab052558cWinson Chung taskViewTranslationZMaxPx = res.getDimensionPixelSize(R.dimen.recents_task_view_z_max); 2331907cd478209f01a4215d9a3a76294c2c77c9a63Winson Chung taskViewAffiliateGroupEnterOffsetPx = 2341907cd478209f01a4215d9a3a76294c2c77c9a63Winson Chung res.getDimensionPixelSize(R.dimen.recents_task_view_affiliate_group_enter_offset); 23560a729c8e93461c9446d0c8cd519b40dec01e8d8Winson Chung TypedValue thumbnailAlphaValue = new TypedValue(); 23660a729c8e93461c9446d0c8cd519b40dec01e8d8Winson Chung res.getValue(R.dimen.recents_task_view_thumbnail_alpha, thumbnailAlphaValue, true); 23760a729c8e93461c9446d0c8cd519b40dec01e8d8Winson Chung taskViewThumbnailAlpha = thumbnailAlphaValue.getFloat(); 238cd23c849afefe58b213d5abb1c581f15d3ad543aWinson Chung 239d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung // Task bar colors 240f5e22e71cb5f8699a4312c797af068f655cbe629Winson Chung taskBarViewDefaultBackgroundColor = 241f5e22e71cb5f8699a4312c797af068f655cbe629Winson Chung res.getColor(R.color.recents_task_bar_default_background_color); 242f5e22e71cb5f8699a4312c797af068f655cbe629Winson Chung taskBarViewLightTextColor = 243f5e22e71cb5f8699a4312c797af068f655cbe629Winson Chung res.getColor(R.color.recents_task_bar_light_text_color); 244f5e22e71cb5f8699a4312c797af068f655cbe629Winson Chung taskBarViewDarkTextColor = 245f5e22e71cb5f8699a4312c797af068f655cbe629Winson Chung res.getColor(R.color.recents_task_bar_dark_text_color); 246cd23c849afefe58b213d5abb1c581f15d3ad543aWinson Chung taskBarViewHighlightColor = 247cd23c849afefe58b213d5abb1c581f15d3ad543aWinson Chung res.getColor(R.color.recents_task_bar_highlight_color); 248ec396d6399c5c31d697d81e94aff459e9771b0c6Winson Chung TypedValue affMinAlphaPctValue = new TypedValue(); 249ec396d6399c5c31d697d81e94aff459e9771b0c6Winson Chung res.getValue(R.dimen.recents_task_affiliation_color_min_alpha_percentage, affMinAlphaPctValue, true); 250ec396d6399c5c31d697d81e94aff459e9771b0c6Winson Chung taskBarViewAffiliationColorMinAlpha = affMinAlphaPctValue.getFloat(); 251cd23c849afefe58b213d5abb1c581f15d3ad543aWinson Chung 252a433fa9c17772f563163ff7db177d091d6aebd5bWinson Chung // Task bar size & animations 253a433fa9c17772f563163ff7db177d091d6aebd5bWinson Chung taskBarHeight = res.getDimensionPixelSize(R.dimen.recents_task_bar_height); 254cd23c849afefe58b213d5abb1c581f15d3ad543aWinson Chung taskBarEnterAnimDuration = 255cd23c849afefe58b213d5abb1c581f15d3ad543aWinson Chung res.getInteger(R.integer.recents_animate_task_bar_enter_duration); 256521e7dc0a6782371a710ee81bf804f7e97aaa292Winson Chung taskBarEnterAnimDelay = 257521e7dc0a6782371a710ee81bf804f7e97aaa292Winson Chung res.getInteger(R.integer.recents_animate_task_bar_enter_delay); 258cd23c849afefe58b213d5abb1c581f15d3ad543aWinson Chung taskBarExitAnimDuration = 259cd23c849afefe58b213d5abb1c581f15d3ad543aWinson Chung res.getInteger(R.integer.recents_animate_task_bar_exit_duration); 260a26fb7822ddf3511796279b847cc216bee9e7f70Winson Chung taskBarDismissDozeDelaySeconds = 261a26fb7822ddf3511796279b847cc216bee9e7f70Winson Chung res.getInteger(R.integer.recents_task_bar_dismiss_delay_seconds); 262f7bca430d9356c26d6df222d2c90bc7668262f6bWinson Chung 2631f24c7e37bc794057a156a730c7e4b53b01212edWinson Chung // Lock to app 2641f24c7e37bc794057a156a730c7e4b53b01212edWinson Chung taskViewLockToAppButtonHeight = 2651f24c7e37bc794057a156a730c7e4b53b01212edWinson Chung res.getDimensionPixelSize(R.dimen.recents_task_view_lock_to_app_button_height); 2661f24c7e37bc794057a156a730c7e4b53b01212edWinson Chung taskViewLockToAppShortAnimDuration = 2671f24c7e37bc794057a156a730c7e4b53b01212edWinson Chung res.getInteger(R.integer.recents_animate_lock_to_app_button_short_duration); 2681f24c7e37bc794057a156a730c7e4b53b01212edWinson Chung taskViewLockToAppLongAnimDuration = 2691f24c7e37bc794057a156a730c7e4b53b01212edWinson Chung res.getInteger(R.integer.recents_animate_lock_to_app_button_long_duration); 2701f24c7e37bc794057a156a730c7e4b53b01212edWinson Chung 271d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung // Nav bar scrim 272521e7dc0a6782371a710ee81bf804f7e97aaa292Winson Chung navBarScrimEnterDuration = 273521e7dc0a6782371a710ee81bf804f7e97aaa292Winson Chung res.getInteger(R.integer.recents_nav_bar_scrim_enter_duration); 274a0e88b5013d708ac6ed6518817d83c64c87ae4b1Winson Chung 275a0e88b5013d708ac6ed6518817d83c64c87ae4b1Winson Chung // Misc 276e8199c582d826a39e6e47b0d8418834c15242fecSelim Cinek useHardwareLayers = res.getBoolean(R.bool.config_recents_use_hardware_layers); 277a0e88b5013d708ac6ed6518817d83c64c87ae4b1Winson Chung altTabKeyDelay = res.getInteger(R.integer.recents_alt_tab_key_delay); 278cb5570316d55c6fe2ff717fa6b94b14d13980263Jorim Jaggi fakeShadows = res.getBoolean(R.bool.config_recents_fake_shadows); 279303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung } 280303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung 28111ca76a53c60a1898956614315ae929668c523d6Winson Chung /** Updates the system insets */ 282303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung public void updateSystemInsets(Rect insets) { 283303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung systemInsets.set(insets); 284303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung } 285303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung 286f7bca430d9356c26d6df222d2c90bc7668262f6bWinson Chung /** Updates the search bar app widget */ 287f7bca430d9356c26d6df222d2c90bc7668262f6bWinson Chung public void updateSearchBarAppWidgetId(Context context, int appWidgetId) { 288f7bca430d9356c26d6df222d2c90bc7668262f6bWinson Chung searchBarAppWidgetId = appWidgetId; 289f7bca430d9356c26d6df222d2c90bc7668262f6bWinson Chung SharedPreferences settings = context.getSharedPreferences(context.getPackageName(), 0); 290f7bca430d9356c26d6df222d2c90bc7668262f6bWinson Chung settings.edit().putInt(Constants.Values.App.Key_SearchAppWidgetId, 291f7bca430d9356c26d6df222d2c90bc7668262f6bWinson Chung appWidgetId).apply(); 292f7bca430d9356c26d6df222d2c90bc7668262f6bWinson Chung } 293f7bca430d9356c26d6df222d2c90bc7668262f6bWinson Chung 29456e09b42a0f1670970872bef611a8036904ad6bfJason Monk /** Updates the states that need to be re-read whenever we re-initialize. */ 29556e09b42a0f1670970872bef611a8036904ad6bfJason Monk void updateOnReinitialize(Context context, SystemServicesProxy ssp) { 29656e09b42a0f1670970872bef611a8036904ad6bfJason Monk // Check if the developer options are enabled 29756e09b42a0f1670970872bef611a8036904ad6bfJason Monk developerOptionsEnabled = ssp.getGlobalSetting(context, 29856e09b42a0f1670970872bef611a8036904ad6bfJason Monk Settings.Global.DEVELOPMENT_SETTINGS_ENABLED) != 0; 29956e09b42a0f1670970872bef611a8036904ad6bfJason Monk lockToAppEnabled = ssp.getSystemSetting(context, 30056e09b42a0f1670970872bef611a8036904ad6bfJason Monk Settings.System.LOCK_TO_APP_ENABLED) != 0; 30156e09b42a0f1670970872bef611a8036904ad6bfJason Monk } 30256e09b42a0f1670970872bef611a8036904ad6bfJason Monk 303b01ed681fe97ff5e98471c120ff9581a78db13c5Winson Chung /** Called when the configuration has changed, and we want to reset any configuration specific 304b01ed681fe97ff5e98471c120ff9581a78db13c5Winson Chung * members. */ 305b01ed681fe97ff5e98471c120ff9581a78db13c5Winson Chung public void updateOnConfigurationChange() { 306d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung launchedWithAltTab = false; 307969f586533096999f10f5587f901949791154fa2Winson Chung launchedWithNoRecentTasks = false; 308d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung launchedFromAppWithThumbnail = false; 309d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung launchedFromAppWithScreenshot = false; 310d42a6cfe2bf632222617450a1ed340268e82f06cWinson Chung launchedFromHome = false; 3116057c91563402f900dfc7714a46e952d86172e2fWinson Chung launchedToTaskId = -1; 312b01ed681fe97ff5e98471c120ff9581a78db13c5Winson Chung } 313b01ed681fe97ff5e98471c120ff9581a78db13c5Winson Chung 314521e7dc0a6782371a710ee81bf804f7e97aaa292Winson Chung /** Returns whether the search bar app widget exists. */ 315f7bca430d9356c26d6df222d2c90bc7668262f6bWinson Chung public boolean hasSearchBarAppWidget() { 316f7bca430d9356c26d6df222d2c90bc7668262f6bWinson Chung return searchBarAppWidgetId >= 0; 317f7bca430d9356c26d6df222d2c90bc7668262f6bWinson Chung } 318f7bca430d9356c26d6df222d2c90bc7668262f6bWinson Chung 31906795630f62e1e7ad89825db23d7656f8dcd6c5aWinson Chung /** Returns whether the status bar scrim should be animated when shown for the first time. */ 32006795630f62e1e7ad89825db23d7656f8dcd6c5aWinson Chung public boolean shouldAnimateStatusBarScrim() { 32106795630f62e1e7ad89825db23d7656f8dcd6c5aWinson Chung return launchedFromHome; 32206795630f62e1e7ad89825db23d7656f8dcd6c5aWinson Chung } 32306795630f62e1e7ad89825db23d7656f8dcd6c5aWinson Chung 32406795630f62e1e7ad89825db23d7656f8dcd6c5aWinson Chung /** Returns whether the status bar scrim should be visible. */ 32506795630f62e1e7ad89825db23d7656f8dcd6c5aWinson Chung public boolean hasStatusBarScrim() { 32606795630f62e1e7ad89825db23d7656f8dcd6c5aWinson Chung return !launchedWithNoRecentTasks; 32706795630f62e1e7ad89825db23d7656f8dcd6c5aWinson Chung } 32806795630f62e1e7ad89825db23d7656f8dcd6c5aWinson Chung 329743d5c95f3a107639c0ff22f099cab2624da3e27Winson Chung /** Returns whether the nav bar scrim should be animated when shown for the first time. */ 330743d5c95f3a107639c0ff22f099cab2624da3e27Winson Chung public boolean shouldAnimateNavBarScrim() { 331969f586533096999f10f5587f901949791154fa2Winson Chung return true; 332743d5c95f3a107639c0ff22f099cab2624da3e27Winson Chung } 333743d5c95f3a107639c0ff22f099cab2624da3e27Winson Chung 334521e7dc0a6782371a710ee81bf804f7e97aaa292Winson Chung /** Returns whether the nav bar scrim should be visible. */ 335521e7dc0a6782371a710ee81bf804f7e97aaa292Winson Chung public boolean hasNavBarScrim() { 336969f586533096999f10f5587f901949791154fa2Winson Chung // Only show the scrim if we have recent tasks, and if the nav bar is not transposed 33727acf761229779e1777d380616846ac07f484ed6Winson Chung return !launchedWithNoRecentTasks && (!hasTransposedNavBar || !isLandscape); 338521e7dc0a6782371a710ee81bf804f7e97aaa292Winson Chung } 339521e7dc0a6782371a710ee81bf804f7e97aaa292Winson Chung 340480dd72daf927283997bdb4060091299add66832Winson Chung /** Returns whether the current layout is horizontal. */ 341480dd72daf927283997bdb4060091299add66832Winson Chung public boolean hasHorizontalLayout() { 34227acf761229779e1777d380616846ac07f484ed6Winson Chung return isLandscape && hasTransposedSearchBar; 343480dd72daf927283997bdb4060091299add66832Winson Chung } 344480dd72daf927283997bdb4060091299add66832Winson Chung 345f7bca430d9356c26d6df222d2c90bc7668262f6bWinson Chung /** 346f7bca430d9356c26d6df222d2c90bc7668262f6bWinson Chung * Returns the task stack bounds in the current orientation. These bounds do not account for 347f7bca430d9356c26d6df222d2c90bc7668262f6bWinson Chung * the system insets. 348f7bca430d9356c26d6df222d2c90bc7668262f6bWinson Chung */ 349dcfa7976fa836ae90bb4a579892a18a0abf35b3cWinson Chung public void getTaskStackBounds(int windowWidth, int windowHeight, int topInset, int rightInset, 350dcfa7976fa836ae90bb4a579892a18a0abf35b3cWinson Chung Rect taskStackBounds) { 351dcfa7976fa836ae90bb4a579892a18a0abf35b3cWinson Chung Rect searchBarBounds = new Rect(); 352dcfa7976fa836ae90bb4a579892a18a0abf35b3cWinson Chung getSearchBarBounds(windowWidth, windowHeight, topInset, searchBarBounds); 35327acf761229779e1777d380616846ac07f484ed6Winson Chung if (isLandscape && hasTransposedSearchBar) { 3546074c5c15117bb17defb90bdb9fe247d0df47c70Winson Chung // In landscape, the search bar appears on the left, but we overlay it on top 3556074c5c15117bb17defb90bdb9fe247d0df47c70Winson Chung taskStackBounds.set(0, topInset, windowWidth - rightInset, windowHeight); 356f7bca430d9356c26d6df222d2c90bc7668262f6bWinson Chung } else { 357dcfa7976fa836ae90bb4a579892a18a0abf35b3cWinson Chung // In portrait, the search bar appears on the top (which already has the inset) 358dcfa7976fa836ae90bb4a579892a18a0abf35b3cWinson Chung taskStackBounds.set(0, searchBarBounds.bottom, windowWidth, windowHeight); 359f7bca430d9356c26d6df222d2c90bc7668262f6bWinson Chung } 360f7bca430d9356c26d6df222d2c90bc7668262f6bWinson Chung } 361f7bca430d9356c26d6df222d2c90bc7668262f6bWinson Chung 362f7bca430d9356c26d6df222d2c90bc7668262f6bWinson Chung /** 363f7bca430d9356c26d6df222d2c90bc7668262f6bWinson Chung * Returns the search bar bounds in the current orientation. These bounds do not account for 364f7bca430d9356c26d6df222d2c90bc7668262f6bWinson Chung * the system insets. 365f7bca430d9356c26d6df222d2c90bc7668262f6bWinson Chung */ 366dcfa7976fa836ae90bb4a579892a18a0abf35b3cWinson Chung public void getSearchBarBounds(int windowWidth, int windowHeight, int topInset, 367dcfa7976fa836ae90bb4a579892a18a0abf35b3cWinson Chung Rect searchBarSpaceBounds) { 368ecd9b3031c9a322bd69380eae2810d53839e8f64Winson Chung // Return empty rects if search is not enabled 369dcfa7976fa836ae90bb4a579892a18a0abf35b3cWinson Chung int searchBarSize = searchBarSpaceHeightPx; 370dcfa7976fa836ae90bb4a579892a18a0abf35b3cWinson Chung if (!Constants.DebugFlags.App.EnableSearchLayout || !hasSearchBarAppWidget()) { 371dcfa7976fa836ae90bb4a579892a18a0abf35b3cWinson Chung searchBarSize = 0; 372ecd9b3031c9a322bd69380eae2810d53839e8f64Winson Chung } 373ecd9b3031c9a322bd69380eae2810d53839e8f64Winson Chung 37427acf761229779e1777d380616846ac07f484ed6Winson Chung if (isLandscape && hasTransposedSearchBar) { 375f7bca430d9356c26d6df222d2c90bc7668262f6bWinson Chung // In landscape, the search bar appears on the left 376dcfa7976fa836ae90bb4a579892a18a0abf35b3cWinson Chung searchBarSpaceBounds.set(0, topInset, searchBarSize, windowHeight); 377f7bca430d9356c26d6df222d2c90bc7668262f6bWinson Chung } else { 378f7bca430d9356c26d6df222d2c90bc7668262f6bWinson Chung // In portrait, the search bar appears on the top 379dcfa7976fa836ae90bb4a579892a18a0abf35b3cWinson Chung searchBarSpaceBounds.set(0, topInset, windowWidth, topInset + searchBarSize); 380f7bca430d9356c26d6df222d2c90bc7668262f6bWinson Chung } 381ecd9b3031c9a322bd69380eae2810d53839e8f64Winson Chung } 382303e1ff1fec8b240b587bb18b981247a99833aa8Winson Chung} 383