summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2017-03-03 20:10:29 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2017-03-03 20:10:29 +0000
commit4ff3457e77915b596cfa896a4f98283ace2314de (patch)
treed92703a640c24e2716029dcc8f890c76f59ba1c9 /src
parent12584781e436f3e113bbdc41b1be99bf2341ac87 (diff)
parenta535ae423bdb3272095e8d83b4c9deff342227b1 (diff)
downloadandroid_packages_apps_Trebuchet-4ff3457e77915b596cfa896a4f98283ace2314de.tar.gz
android_packages_apps_Trebuchet-4ff3457e77915b596cfa896a4f98283ace2314de.tar.bz2
android_packages_apps_Trebuchet-4ff3457e77915b596cfa896a4f98283ace2314de.zip
Merge "Moving Event dispatcher definition from LAuncher to BaseActivity so that it can be used in other activities as well." into ub-launcher3-dorval
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher3/BaseActivity.java10
-rw-r--r--src/com/android/launcher3/Launcher.java26
-rw-r--r--src/com/android/launcher3/LauncherCallbacks.java1
-rw-r--r--src/com/android/launcher3/logging/UserEventDispatcher.java15
-rw-r--r--src/com/android/launcher3/testing/LauncherExtension.java3
5 files changed, 28 insertions, 27 deletions
diff --git a/src/com/android/launcher3/BaseActivity.java b/src/com/android/launcher3/BaseActivity.java
index 9f4f1f9c4..e1a3ad0d6 100644
--- a/src/com/android/launcher3/BaseActivity.java
+++ b/src/com/android/launcher3/BaseActivity.java
@@ -21,9 +21,12 @@ import android.content.Context;
import android.content.ContextWrapper;
import android.view.View.AccessibilityDelegate;
+import com.android.launcher3.logging.UserEventDispatcher;
+
public abstract class BaseActivity extends Activity {
protected DeviceProfile mDeviceProfile;
+ protected UserEventDispatcher mUserEventDispatcher;
public DeviceProfile getDeviceProfile() {
return mDeviceProfile;
@@ -33,6 +36,13 @@ public abstract class BaseActivity extends Activity {
return null;
}
+ public final UserEventDispatcher getUserEventDispatcher() {
+ if (mUserEventDispatcher == null) {
+ mUserEventDispatcher = UserEventDispatcher.get(this);
+ }
+ return mUserEventDispatcher;
+ }
+
public static BaseActivity fromContext(Context context) {
if (context instanceof BaseActivity) {
return (BaseActivity) context;
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 624ea4a54..74e6bfc84 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -85,9 +85,6 @@ import com.android.launcher3.allapps.AllAppsContainerView;
import com.android.launcher3.allapps.AllAppsTransitionController;
import com.android.launcher3.allapps.DefaultAppSearchController;
import com.android.launcher3.anim.AnimationLayerSet;
-import com.android.launcher3.model.ModelWriter;
-import com.android.launcher3.notification.NotificationListener;
-import com.android.launcher3.popup.PopupDataProvider;
import com.android.launcher3.compat.AppWidgetManagerCompat;
import com.android.launcher3.compat.LauncherAppsCompat;
import com.android.launcher3.compat.PinItemRequestCompat;
@@ -106,10 +103,13 @@ import com.android.launcher3.keyboard.CustomActionsPopup;
import com.android.launcher3.keyboard.ViewGroupFocusHelper;
import com.android.launcher3.logging.FileLog;
import com.android.launcher3.logging.UserEventDispatcher;
+import com.android.launcher3.model.ModelWriter;
import com.android.launcher3.model.PackageItemInfo;
import com.android.launcher3.model.WidgetItem;
+import com.android.launcher3.notification.NotificationListener;
import com.android.launcher3.pageindicators.PageIndicator;
import com.android.launcher3.popup.PopupContainerWithArrow;
+import com.android.launcher3.popup.PopupDataProvider;
import com.android.launcher3.shortcuts.DeepShortcutManager;
import com.android.launcher3.shortcuts.ShortcutKey;
import com.android.launcher3.userevent.nano.LauncherLogProto;
@@ -119,7 +119,6 @@ import com.android.launcher3.userevent.nano.LauncherLogProto.ControlType;
import com.android.launcher3.util.ActivityResultInfo;
import com.android.launcher3.util.ComponentKey;
import com.android.launcher3.util.ItemInfoMatcher;
-import com.android.launcher3.util.LogConfig;
import com.android.launcher3.util.MultiHashMap;
import com.android.launcher3.util.PackageManagerHelper;
import com.android.launcher3.util.PackageUserKey;
@@ -315,8 +314,6 @@ public class Launcher extends BaseActivity
*/
private PendingRequestArgs mPendingRequestArgs;
- private UserEventDispatcher mUserEventDispatcher;
-
private float mLastDispatchTouchEventX = 0.0f;
public ViewGroupFocusHelper mFocusHandler;
@@ -627,23 +624,6 @@ public class Launcher extends BaseActivity
}
}
- public UserEventDispatcher getUserEventDispatcher() {
- if (mLauncherCallbacks != null) {
- UserEventDispatcher dispatcher = mLauncherCallbacks.getUserEventDispatcher();
- if (dispatcher != null) {
- return dispatcher;
- }
- }
-
- // Logger object is a singleton and does not have to be coupled with the foreground
- // activity. Since most user event logging is done on the UI, the object is retrieved
- // from the callback for convenience.
- if (mUserEventDispatcher == null) {
- mUserEventDispatcher = new UserEventDispatcher();
- }
- return mUserEventDispatcher;
- }
-
public boolean isDraggingEnabled() {
// We prevent dragging when we are loading the workspace as it is possible to pick up a view
// that is subsequently removed from the workspace in startBinding().
diff --git a/src/com/android/launcher3/LauncherCallbacks.java b/src/com/android/launcher3/LauncherCallbacks.java
index 6394b9052..2bac11f97 100644
--- a/src/com/android/launcher3/LauncherCallbacks.java
+++ b/src/com/android/launcher3/LauncherCallbacks.java
@@ -92,7 +92,6 @@ public interface LauncherCallbacks {
/*
* Extensions points for adding / replacing some other aspects of the Launcher experience.
*/
- public UserEventDispatcher getUserEventDispatcher();
public boolean shouldMoveToDefaultScreenOnHomeIntent();
public boolean hasSettings();
public AllAppsSearchBarController getAllAppsSearchBarController();
diff --git a/src/com/android/launcher3/logging/UserEventDispatcher.java b/src/com/android/launcher3/logging/UserEventDispatcher.java
index 5f45c6176..90e453117 100644
--- a/src/com/android/launcher3/logging/UserEventDispatcher.java
+++ b/src/com/android/launcher3/logging/UserEventDispatcher.java
@@ -18,6 +18,7 @@ package com.android.launcher3.logging;
import android.app.PendingIntent;
import android.content.ComponentName;
+import android.content.Context;
import android.content.Intent;
import android.os.SystemClock;
import android.util.Log;
@@ -26,6 +27,7 @@ import android.view.ViewParent;
import com.android.launcher3.DropTarget;
import com.android.launcher3.ItemInfo;
+import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.config.ProviderConfig;
import com.android.launcher3.userevent.nano.LauncherLogProto;
@@ -61,6 +63,19 @@ public class UserEventDispatcher {
private static final boolean IS_VERBOSE =
ProviderConfig.IS_DOGFOOD_BUILD && Utilities.isPropertyEnabled(LogConfig.USEREVENT);
+ private static UserEventDispatcher sInstance;
+ private static final Object LOCK = new Object();
+
+ public static UserEventDispatcher get(Context context) {
+ synchronized (LOCK) {
+ if (sInstance == null) {
+ sInstance = Utilities.getOverrideObject(UserEventDispatcher.class,
+ context.getApplicationContext(), R.string.user_event_dispatcher_class);
+ }
+ return sInstance;
+ }
+ }
+
/**
* Implemented by containers to provide a container source for a given child.
*/
diff --git a/src/com/android/launcher3/testing/LauncherExtension.java b/src/com/android/launcher3/testing/LauncherExtension.java
index 6797c7ba3..aedca8db4 100644
--- a/src/com/android/launcher3/testing/LauncherExtension.java
+++ b/src/com/android/launcher3/testing/LauncherExtension.java
@@ -180,9 +180,6 @@ public class LauncherExtension extends Launcher {
}
@Override
- public UserEventDispatcher getUserEventDispatcher() { return null; }
-
- @Override
public View getQsbBar() {
return null;
}