• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 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.launcher3;
18 
19 import android.app.Activity;
20 import android.content.Context;
21 import android.content.ContextWrapper;
22 import android.content.Intent;
23 import android.view.View.AccessibilityDelegate;
24 
25 import com.android.launcher3.logging.UserEventDispatcher;
26 import com.android.launcher3.util.SystemUiController;
27 
28 public abstract class BaseActivity extends Activity {
29 
30     protected DeviceProfile mDeviceProfile;
31     protected UserEventDispatcher mUserEventDispatcher;
32     protected SystemUiController mSystemUiController;
33 
getDeviceProfile()34     public DeviceProfile getDeviceProfile() {
35         return mDeviceProfile;
36     }
37 
getAccessibilityDelegate()38     public AccessibilityDelegate getAccessibilityDelegate() {
39         return null;
40     }
41 
getUserEventDispatcher()42     public final UserEventDispatcher getUserEventDispatcher() {
43         if (mUserEventDispatcher == null) {
44             mUserEventDispatcher = UserEventDispatcher.newInstance(this,
45                     mDeviceProfile.isLandscape, isInMultiWindowModeCompat());
46         }
47         return mUserEventDispatcher;
48     }
49 
isInMultiWindowModeCompat()50     public boolean isInMultiWindowModeCompat() {
51         return Utilities.ATLEAST_NOUGAT && isInMultiWindowMode();
52     }
53 
fromContext(Context context)54     public static BaseActivity fromContext(Context context) {
55         if (context instanceof BaseActivity) {
56             return (BaseActivity) context;
57         }
58         return ((BaseActivity) ((ContextWrapper) context).getBaseContext());
59     }
60 
getSystemUiController()61     public SystemUiController getSystemUiController() {
62         if (mSystemUiController == null) {
63             mSystemUiController = new SystemUiController(getWindow());
64         }
65         return mSystemUiController;
66     }
67 
68     @Override
onActivityResult(int requestCode, int resultCode, Intent data)69     public void onActivityResult(int requestCode, int resultCode, Intent data) {
70         super.onActivityResult(requestCode, resultCode, data);
71     }
72 }
73