• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2008 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.statusbar.policy;
18 
19 import android.app.ActivityManager;
20 import android.content.Context;
21 import android.content.res.TypedArray;
22 import android.os.RemoteException;
23 import android.util.AttributeSet;
24 import android.util.Slog;
25 import android.view.View;
26 import android.widget.ImageView;
27 
28 import com.android.systemui.R;
29 
30 public class CompatModeButton extends ImageView {
31     private static final boolean DEBUG = false;
32     private static final String TAG = "StatusBar.CompatModeButton";
33 
34     private ActivityManager mAM;
35 
CompatModeButton(Context context, AttributeSet attrs)36     public CompatModeButton(Context context, AttributeSet attrs) {
37         this(context, attrs, 0);
38     }
39 
CompatModeButton(Context context, AttributeSet attrs, int defStyle)40     public CompatModeButton(Context context, AttributeSet attrs, int defStyle) {
41         super(context, attrs);
42 
43         setClickable(true);
44 
45         mAM = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
46 
47         refresh();
48     }
49 
refresh()50     public void refresh() {
51         int mode = mAM.getFrontActivityScreenCompatMode();
52         final boolean vis = (mode != ActivityManager.COMPAT_MODE_NEVER
53                           && mode != ActivityManager.COMPAT_MODE_ALWAYS);
54         if (DEBUG) Slog.d(TAG, "compat mode is " + mode + "; icon will " + (vis ? "show" : "hide"));
55         setVisibility(vis ? View.VISIBLE : View.GONE);
56     }
57 }
58