blob: 68df1d5bd3222e014de33092d38557322e534732 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
/*
* Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.systemui.recents;
import android.app.ActivityManager;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.SystemProperties;
import com.android.systemui.R;
import com.android.systemui.recents.misc.SystemServicesProxy;
import com.android.systemui.recents.views.DockState;
import com.android.systemui.shared.recents.model.TaskStack;
/**
* Represents the dock regions for each orientation.
*/
class DockRegion {
public static DockState[] PHONE_LANDSCAPE = {
// We only allow docking to the left in landscape for now on small devices
DockState.LEFT
};
public static DockState[] PHONE_PORTRAIT = {
// We only allow docking to the top for now on small devices
DockState.TOP
};
public static DockState[] TABLET_LANDSCAPE = {
DockState.LEFT,
DockState.RIGHT
};
public static DockState[] TABLET_PORTRAIT = PHONE_PORTRAIT;
}
/**
* Application resources that can be retrieved from the application context and are not specifically
* tied to the current activity.
*/
public class RecentsConfiguration {
private static final int LARGE_SCREEN_MIN_DP = 600;
private static final int XLARGE_SCREEN_MIN_DP = 720;
// Launch states
public RecentsActivityLaunchState mLaunchState = new RecentsActivityLaunchState();
// Since the positions in Recents has to be calculated globally (before the RecentsActivity
// starts), we need to calculate some resource values ourselves, instead of relying on framework
// resources.
public final boolean isLargeScreen;
public final boolean isXLargeScreen;
public final int smallestWidth;
/** Misc **/
public boolean fakeShadows;
public int svelteLevel;
// Whether this product supports Grid-based Recents. If this is field is set to true, then
// Recents will layout task views in a grid mode when there's enough space in the screen.
public boolean isGridEnabled;
// Support for Android Recents for low ram devices. If this field is set to true, then Recents
// will use the alternative layout.
public boolean isLowRamDevice;
// Enable drag and drop split from Recents. Disabled for low ram devices.
public boolean dragToSplitEnabled;
private final Context mAppContext;
public RecentsConfiguration(Context context) {
// Load only resources that can not change after the first load either through developer
// settings or via multi window
SystemServicesProxy ssp = Recents.getSystemServices();
mAppContext = context.getApplicationContext();
Resources res = mAppContext.getResources();
fakeShadows = res.getBoolean(R.bool.config_recents_fake_shadows);
svelteLevel = res.getInteger(R.integer.recents_svelte_level);
isGridEnabled = SystemProperties.getBoolean("ro.recents.grid", false);
isLowRamDevice = ActivityManager.isLowRamDeviceStatic();
dragToSplitEnabled = !isLowRamDevice;
float screenDensity = context.getResources().getDisplayMetrics().density;
smallestWidth = ssp.getDeviceSmallestWidth();
isLargeScreen = smallestWidth >= (int) (screenDensity * LARGE_SCREEN_MIN_DP);
isXLargeScreen = smallestWidth >= (int) (screenDensity * XLARGE_SCREEN_MIN_DP);
}
/**
* Returns the activity launch state.
* TODO: This will be refactored out of RecentsConfiguration.
*/
public RecentsActivityLaunchState getLaunchState() {
return mLaunchState;
}
/**
* Returns the preferred dock states for the current orientation.
* @return a list of dock states for device and its orientation
*/
public DockState[] getDockStatesForCurrentOrientation() {
boolean isLandscape = mAppContext.getResources().getConfiguration().orientation ==
Configuration.ORIENTATION_LANDSCAPE;
RecentsConfiguration config = Recents.getConfiguration();
if (config.isLargeScreen) {
return isLandscape ? DockRegion.TABLET_LANDSCAPE : DockRegion.TABLET_PORTRAIT;
} else {
return isLandscape ? DockRegion.PHONE_LANDSCAPE : DockRegion.PHONE_PORTRAIT;
}
}
}
|