[go: nahoru, domu]

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
17package com.android.systemui.recents;
18
19import android.content.Context;
20import android.content.res.Resources;
21import android.graphics.Rect;
22
23import com.android.systemui.R;
24import com.android.systemui.recents.misc.SystemServicesProxy;
25
26/**
27 * Application resources that can be retrieved from the application context and are not specifically
28 * tied to the current activity.
29 */
30public class RecentsConfiguration {
31
32    private static final int LARGE_SCREEN_MIN_DP = 600;
33    private static final int XLARGE_SCREEN_MIN_DP = 720;
34
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
47    // Launch states
48    public RecentsActivityLaunchState mLaunchState = new RecentsActivityLaunchState();
49
50    // Since the positions in Recents has to be calculated globally (before the RecentsActivity
51    // starts), we need to calculate some resource values ourselves, instead of relying on framework
52    // resources.
53    public final boolean isLargeScreen;
54    public final boolean isXLargeScreen;
55    public final int smallestWidth;
56
57    /** Misc **/
58    public boolean fakeShadows;
59    public int svelteLevel;
60
61    public RecentsConfiguration(Context context) {
62        // Load only resources that can not change after the first load either through developer
63        // settings or via multi window
64        SystemServicesProxy ssp = Recents.getSystemServices();
65        Context appContext = context.getApplicationContext();
66        Resources res = appContext.getResources();
67        fakeShadows = res.getBoolean(R.bool.config_recents_fake_shadows);
68        svelteLevel = res.getInteger(R.integer.recents_svelte_level);
69
70        float screenDensity = context.getResources().getDisplayMetrics().density;
71        smallestWidth = ssp.getDeviceSmallestWidth();
72        isLargeScreen = smallestWidth >= (int) (screenDensity * LARGE_SCREEN_MIN_DP);
73        isXLargeScreen = smallestWidth >= (int) (screenDensity * XLARGE_SCREEN_MIN_DP);
74    }
75
76    /**
77     * Returns the activity launch state.
78     * TODO: This will be refactored out of RecentsConfiguration.
79     */
80    public RecentsActivityLaunchState getLaunchState() {
81        return mLaunchState;
82    }
83}
84