blob: e49649502d3537133f6775db0e326eaf27e76403 [file] [log] [blame]
Sunny Goyal27835952017-01-13 12:15:53 -08001/*
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
17package com.android.launcher3;
18
19import android.app.Activity;
20import android.content.Context;
21import android.content.ContextWrapper;
Sunny Goyal64a75aa2017-07-03 13:50:52 -070022import android.content.Intent;
Sunny Goyal27835952017-01-13 12:15:53 -080023import android.view.View.AccessibilityDelegate;
24
Sunny Goyala535ae42017-02-27 10:07:13 -080025import com.android.launcher3.logging.UserEventDispatcher;
Sunny Goyal8392c822017-06-20 10:03:56 -070026import com.android.launcher3.util.SystemUiController;
Sunny Goyala535ae42017-02-27 10:07:13 -080027
Sunny Goyal27835952017-01-13 12:15:53 -080028public abstract class BaseActivity extends Activity {
29
30 protected DeviceProfile mDeviceProfile;
Sunny Goyala535ae42017-02-27 10:07:13 -080031 protected UserEventDispatcher mUserEventDispatcher;
Sunny Goyal8392c822017-06-20 10:03:56 -070032 protected SystemUiController mSystemUiController;
Sunny Goyal27835952017-01-13 12:15:53 -080033
34 public DeviceProfile getDeviceProfile() {
35 return mDeviceProfile;
36 }
37
38 public AccessibilityDelegate getAccessibilityDelegate() {
39 return null;
40 }
41
Sunny Goyala535ae42017-02-27 10:07:13 -080042 public final UserEventDispatcher getUserEventDispatcher() {
43 if (mUserEventDispatcher == null) {
Jon Mirandafe964322017-03-22 10:25:17 -070044 mUserEventDispatcher = UserEventDispatcher.newInstance(this,
Hyunyoung Songd5a9b572017-05-16 11:04:26 -070045 mDeviceProfile.isLandscape, isInMultiWindowModeCompat());
Sunny Goyala535ae42017-02-27 10:07:13 -080046 }
47 return mUserEventDispatcher;
48 }
49
Jon Mirandafe964322017-03-22 10:25:17 -070050 public boolean isInMultiWindowModeCompat() {
51 return Utilities.ATLEAST_NOUGAT && isInMultiWindowMode();
52 }
53
Sunny Goyal27835952017-01-13 12:15:53 -080054 public static BaseActivity fromContext(Context context) {
55 if (context instanceof BaseActivity) {
56 return (BaseActivity) context;
57 }
58 return ((BaseActivity) ((ContextWrapper) context).getBaseContext());
59 }
Sunny Goyal8392c822017-06-20 10:03:56 -070060
61 public SystemUiController getSystemUiController() {
62 if (mSystemUiController == null) {
63 mSystemUiController = new SystemUiController(getWindow());
64 }
65 return mSystemUiController;
66 }
Sunny Goyal64a75aa2017-07-03 13:50:52 -070067
68 @Override
69 public void onActivityResult(int requestCode, int resultCode, Intent data) {
70 super.onActivityResult(requestCode, resultCode, data);
71 }
Sunny Goyal27835952017-01-13 12:15:53 -080072}