blob: 2afb09a18f7a07398a2ee4d82ea5fa202d1e51d7 [file] [log] [blame]
Winson Chung303e1ff2014-03-07 15:06:19 -08001/*
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
17package com.android.systemui.recents;
18
19import android.content.Context;
Winson Chungc620baf2014-03-19 17:15:29 -070020import android.content.res.Resources;
Winson Chung303e1ff2014-03-07 15:06:19 -080021import android.graphics.Rect;
Winsonc0d70582016-01-29 10:24:39 -080022
Winson Chung2f2ca082014-04-03 18:05:29 -070023import com.android.systemui.R;
Jason Monk56e09b42014-07-18 10:29:14 -040024import com.android.systemui.recents.misc.SystemServicesProxy;
Winson Chung303e1ff2014-03-07 15:06:19 -080025
Winson35f30502015-09-28 11:24:36 -070026/**
27 * Application resources that can be retrieved from the application context and are not specifically
28 * tied to the current activity.
29 */
Winson Chung303e1ff2014-03-07 15:06:19 -080030public class RecentsConfiguration {
Winson35f30502015-09-28 11:24:36 -070031
32 private static final int LARGE_SCREEN_MIN_DP = 600;
33 private static final int XLARGE_SCREEN_MIN_DP = 720;
34
Winson Chung96d70412014-11-12 14:17:17 -080035 /** 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
Winson35f30502015-09-28 11:24:36 -070047 // Launch states
Winson53ec42c2015-10-28 15:55:35 -070048 public RecentsActivityLaunchState mLaunchState = new RecentsActivityLaunchState();
Winson Chung918c0722014-05-08 15:04:23 -070049
Winson35f30502015-09-28 11:24:36 -070050 // 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
Winson59924fe2016-03-17 14:13:18 -070053 public boolean hasTransposedNavBar;
Winson Chungd42a6cf2014-06-03 16:24:04 -070054
Winson35f30502015-09-28 11:24:36 -070055 // 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 Chungb44c24f2014-04-09 15:17:43 -070061
Winson Chunga0e88b52014-08-11 19:25:42 -070062 /** Misc **/
Jorim Jaggicb557032014-09-16 23:09:24 +020063 public boolean fakeShadows;
Winson35f30502015-09-28 11:24:36 -070064 public int svelteLevel;
Winson Chunga0e88b52014-08-11 19:25:42 -070065
Winson53ec42c2015-10-28 15:55:35 -070066 public RecentsConfiguration(Context context) {
Winson35f30502015-09-28 11:24:36 -070067 // Load only resources that can not change after the first load either through developer
68 // settings or via multi window
Winson53ec42c2015-10-28 15:55:35 -070069 SystemServicesProxy ssp = Recents.getSystemServices();
Winson35f30502015-09-28 11:24:36 -070070 Context appContext = context.getApplicationContext();
71 Resources res = appContext.getResources();
Winson35f30502015-09-28 11:24:36 -070072 fakeShadows = res.getBoolean(R.bool.config_recents_fake_shadows);
73 svelteLevel = res.getInteger(R.integer.recents_svelte_level);
Winson Chung06795632014-06-17 15:53:44 -070074
Winson59924fe2016-03-17 14:13:18 -070075 float screenDensity = context.getResources().getDisplayMetrics().density;
Winson35f30502015-09-28 11:24:36 -070076 smallestWidth = ssp.getDeviceSmallestWidth();
Winson59924fe2016-03-17 14:13:18 -070077 isLargeScreen = smallestWidth >= (int) (screenDensity * LARGE_SCREEN_MIN_DP);
78 isXLargeScreen = smallestWidth >= (int) (screenDensity * XLARGE_SCREEN_MIN_DP);
Winson35f30502015-09-28 11:24:36 -070079 }
80
81 /**
82 * Updates the configuration based on the current state of the system
83 */
Jorim Jaggic6c89a82016-01-28 17:48:21 -080084 void update(Rect systemInsets) {
85 hasTransposedNavBar = systemInsets.right > 0;
Winson Chung06795632014-06-17 15:53:44 -070086 }
Winson Chung303e1ff2014-03-07 15:06:19 -080087
Winson35f30502015-09-28 11:24:36 -070088 /**
89 * Returns the activity launch state.
90 * TODO: This will be refactored out of RecentsConfiguration.
91 */
92 public RecentsActivityLaunchState getLaunchState() {
93 return mLaunchState;
Jason Monk56e09b42014-07-18 10:29:14 -040094 }
95
Winsone7f138c2015-10-22 16:15:21 -070096 /**
97 * Called when the configuration has changed, and we want to reset any configuration specific
98 * members.
99 */
Winson Chungb01ed682014-05-29 14:25:42 -0700100 public void updateOnConfigurationChange() {
Winson35f30502015-09-28 11:24:36 -0700101 mLaunchState.updateOnConfigurationChange();
Winson Chung521e7dc2014-06-02 15:31:56 -0700102 }
Winson Chung303e1ff2014-03-07 15:06:19 -0800103}