Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.systemui.recents; |
| 18 | |
| 19 | import android.content.Context; |
Winson Chung | c620baf | 2014-03-19 17:15:29 -0700 | [diff] [blame] | 20 | import android.content.res.Resources; |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 21 | import android.graphics.Rect; |
Winson | c0d7058 | 2016-01-29 10:24:39 -0800 | [diff] [blame] | 22 | |
Winson Chung | 2f2ca08 | 2014-04-03 18:05:29 -0700 | [diff] [blame] | 23 | import com.android.systemui.R; |
Jason Monk | 56e09b4 | 2014-07-18 10:29:14 -0400 | [diff] [blame] | 24 | import com.android.systemui.recents.misc.SystemServicesProxy; |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 25 | |
Winson | 35f3050 | 2015-09-28 11:24:36 -0700 | [diff] [blame] | 26 | /** |
| 27 | * Application resources that can be retrieved from the application context and are not specifically |
| 28 | * tied to the current activity. |
| 29 | */ |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 30 | public class RecentsConfiguration { |
Winson | 35f3050 | 2015-09-28 11:24:36 -0700 | [diff] [blame] | 31 | |
| 32 | private static final int LARGE_SCREEN_MIN_DP = 600; |
| 33 | private static final int XLARGE_SCREEN_MIN_DP = 720; |
| 34 | |
Winson Chung | 96d7041 | 2014-11-12 14:17:17 -0800 | [diff] [blame] | 35 | /** Levels of svelte in increasing severity/austerity. */ |
| 36 | // No svelting. |
| 37 | public static final int SVELTE_NONE = 0; |
| 38 | // Limit thumbnail cache to number of visible thumbnails when Recents was loaded, disable |
| 39 | // caching thumbnails as you scroll. |
| 40 | public static final int SVELTE_LIMIT_CACHE = 1; |
| 41 | // Disable the thumbnail cache, load thumbnails asynchronously when the activity loads and |
| 42 | // evict all thumbnails when hidden. |
| 43 | public static final int SVELTE_DISABLE_CACHE = 2; |
| 44 | // Disable all thumbnail loading. |
| 45 | public static final int SVELTE_DISABLE_LOADING = 3; |
| 46 | |
Winson | 35f3050 | 2015-09-28 11:24:36 -0700 | [diff] [blame] | 47 | // Launch states |
Winson | 53ec42c | 2015-10-28 15:55:35 -0700 | [diff] [blame] | 48 | public RecentsActivityLaunchState mLaunchState = new RecentsActivityLaunchState(); |
Winson Chung | 918c072 | 2014-05-08 15:04:23 -0700 | [diff] [blame] | 49 | |
Winson | 35f3050 | 2015-09-28 11:24:36 -0700 | [diff] [blame] | 50 | // TODO: Values determined by the current context, needs to be refactored into something that is |
| 51 | // agnostic of the activity context, but still calculable from the Recents component for |
| 52 | // the transition into recents |
Winson | 59924fe | 2016-03-17 14:13:18 -0700 | [diff] [blame] | 53 | public boolean hasTransposedNavBar; |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 54 | |
Winson | 35f3050 | 2015-09-28 11:24:36 -0700 | [diff] [blame] | 55 | // Since the positions in Recents has to be calculated globally (before the RecentsActivity |
| 56 | // starts), we need to calculate some resource values ourselves, instead of relying on framework |
| 57 | // resources. |
| 58 | public final boolean isLargeScreen; |
| 59 | public final boolean isXLargeScreen; |
| 60 | public final int smallestWidth; |
Winson Chung | b44c24f | 2014-04-09 15:17:43 -0700 | [diff] [blame] | 61 | |
Winson Chung | a0e88b5 | 2014-08-11 19:25:42 -0700 | [diff] [blame] | 62 | /** Misc **/ |
Jorim Jaggi | cb55703 | 2014-09-16 23:09:24 +0200 | [diff] [blame] | 63 | public boolean fakeShadows; |
Winson | 35f3050 | 2015-09-28 11:24:36 -0700 | [diff] [blame] | 64 | public int svelteLevel; |
Winson Chung | a0e88b5 | 2014-08-11 19:25:42 -0700 | [diff] [blame] | 65 | |
Winson | 53ec42c | 2015-10-28 15:55:35 -0700 | [diff] [blame] | 66 | public RecentsConfiguration(Context context) { |
Winson | 35f3050 | 2015-09-28 11:24:36 -0700 | [diff] [blame] | 67 | // Load only resources that can not change after the first load either through developer |
| 68 | // settings or via multi window |
Winson | 53ec42c | 2015-10-28 15:55:35 -0700 | [diff] [blame] | 69 | SystemServicesProxy ssp = Recents.getSystemServices(); |
Winson | 35f3050 | 2015-09-28 11:24:36 -0700 | [diff] [blame] | 70 | Context appContext = context.getApplicationContext(); |
| 71 | Resources res = appContext.getResources(); |
Winson | 35f3050 | 2015-09-28 11:24:36 -0700 | [diff] [blame] | 72 | fakeShadows = res.getBoolean(R.bool.config_recents_fake_shadows); |
| 73 | svelteLevel = res.getInteger(R.integer.recents_svelte_level); |
Winson Chung | 0679563 | 2014-06-17 15:53:44 -0700 | [diff] [blame] | 74 | |
Winson | 59924fe | 2016-03-17 14:13:18 -0700 | [diff] [blame] | 75 | float screenDensity = context.getResources().getDisplayMetrics().density; |
Winson | 35f3050 | 2015-09-28 11:24:36 -0700 | [diff] [blame] | 76 | smallestWidth = ssp.getDeviceSmallestWidth(); |
Winson | 59924fe | 2016-03-17 14:13:18 -0700 | [diff] [blame] | 77 | isLargeScreen = smallestWidth >= (int) (screenDensity * LARGE_SCREEN_MIN_DP); |
| 78 | isXLargeScreen = smallestWidth >= (int) (screenDensity * XLARGE_SCREEN_MIN_DP); |
Winson | 35f3050 | 2015-09-28 11:24:36 -0700 | [diff] [blame] | 79 | } |
| 80 | |
| 81 | /** |
| 82 | * Updates the configuration based on the current state of the system |
| 83 | */ |
Jorim Jaggi | c6c89a8 | 2016-01-28 17:48:21 -0800 | [diff] [blame] | 84 | void update(Rect systemInsets) { |
| 85 | hasTransposedNavBar = systemInsets.right > 0; |
Winson Chung | 0679563 | 2014-06-17 15:53:44 -0700 | [diff] [blame] | 86 | } |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 87 | |
Winson | 35f3050 | 2015-09-28 11:24:36 -0700 | [diff] [blame] | 88 | /** |
| 89 | * Returns the activity launch state. |
| 90 | * TODO: This will be refactored out of RecentsConfiguration. |
| 91 | */ |
| 92 | public RecentsActivityLaunchState getLaunchState() { |
| 93 | return mLaunchState; |
Jason Monk | 56e09b4 | 2014-07-18 10:29:14 -0400 | [diff] [blame] | 94 | } |
| 95 | |
Winson | e7f138c | 2015-10-22 16:15:21 -0700 | [diff] [blame] | 96 | /** |
| 97 | * Called when the configuration has changed, and we want to reset any configuration specific |
| 98 | * members. |
| 99 | */ |
Winson Chung | b01ed68 | 2014-05-29 14:25:42 -0700 | [diff] [blame] | 100 | public void updateOnConfigurationChange() { |
Winson | 35f3050 | 2015-09-28 11:24:36 -0700 | [diff] [blame] | 101 | mLaunchState.updateOnConfigurationChange(); |
Winson Chung | 521e7dc | 2014-06-02 15:31:56 -0700 | [diff] [blame] | 102 | } |
Winson Chung | 303e1ff | 2014-03-07 15:06:19 -0800 | [diff] [blame] | 103 | } |