diff --git a/quickstep/src/com/android/quickstep/RecentsActivity.java b/quickstep/src/com/android/quickstep/RecentsActivity.java index ef735e1ce2..9d01f74477 100644 --- a/quickstep/src/com/android/quickstep/RecentsActivity.java +++ b/quickstep/src/com/android/quickstep/RecentsActivity.java @@ -44,7 +44,6 @@ import com.android.launcher3.ItemInfo; import com.android.launcher3.LauncherAnimationRunner; import com.android.launcher3.R; import com.android.launcher3.anim.Interpolators; -import com.android.launcher3.badge.BadgeInfo; import com.android.launcher3.uioverrides.UiFactory; import com.android.launcher3.util.SystemUiController; import com.android.launcher3.util.Themes; @@ -155,11 +154,6 @@ public class RecentsActivity extends BaseDraggingActivity { return (T) mFallbackRecentsView; } - @Override - public BadgeInfo getBadgeInfoForItem(ItemInfo info) { - return null; - } - @Override public ActivityOptions getActivityLaunchOptions(final View v) { if (!(v instanceof TaskView)) { @@ -210,9 +204,6 @@ public class RecentsActivity extends BaseDraggingActivity { return target; } - @Override - public void invalidateParent(ItemInfo info) { } - @Override protected void onStart() { // Set the alpha to 1 before calling super, as it may get set back to 0 due to diff --git a/src/com/android/launcher3/BaseActivity.java b/src/com/android/launcher3/BaseActivity.java index 77b6010c26..1b953d4aed 100644 --- a/src/com/android/launcher3/BaseActivity.java +++ b/src/com/android/launcher3/BaseActivity.java @@ -36,6 +36,7 @@ import com.android.launcher3.logging.UserEventDispatcher.UserEventDelegate; import com.android.launcher3.uioverrides.UiFactory; import com.android.launcher3.userevent.nano.LauncherLogProto; import com.android.launcher3.util.SystemUiController; +import com.android.launcher3.views.ActivityContext; import java.io.FileDescriptor; import java.io.PrintWriter; @@ -44,7 +45,8 @@ import java.util.ArrayList; import androidx.annotation.IntDef; -public abstract class BaseActivity extends Activity implements UserEventDelegate, LogStateProvider{ +public abstract class BaseActivity extends Activity + implements UserEventDelegate, LogStateProvider, ActivityContext { public static final int INVISIBLE_BY_STATE_HANDLER = 1 << 0; public static final int INVISIBLE_BY_APP_TRANSITIONS = 1 << 1; @@ -100,14 +102,11 @@ public abstract class BaseActivity extends Activity implements UserEventDelegate // animation @InvisibilityFlags private int mForceInvisible; + @Override public DeviceProfile getDeviceProfile() { return mDeviceProfile; } - public AccessibilityDelegate getAccessibilityDelegate() { - return null; - } - public int getCurrentState() { return StatsLogUtils.LAUNCHER_STATE_BACKGROUND; } public void modifyUserEvent(LauncherLogProto.LauncherEvent event) {} diff --git a/src/com/android/launcher3/BaseDraggingActivity.java b/src/com/android/launcher3/BaseDraggingActivity.java index 152dc84d01..25ee61e020 100644 --- a/src/com/android/launcher3/BaseDraggingActivity.java +++ b/src/com/android/launcher3/BaseDraggingActivity.java @@ -44,7 +44,7 @@ import com.android.launcher3.views.ActivityContext; * Extension of BaseActivity allowing support for drag-n-drop */ public abstract class BaseDraggingActivity extends BaseActivity - implements WallpaperColorInfo.OnChangeListener, ActivityContext { + implements WallpaperColorInfo.OnChangeListener { private static final String TAG = "BaseDraggingActivity"; @@ -139,16 +139,10 @@ public abstract class BaseDraggingActivity extends BaseActivity return false; } - public abstract BaseDragLayer getDragLayer(); - public abstract T getOverviewPanel(); public abstract View getRootView(); - public abstract BadgeInfo getBadgeInfoForItem(ItemInfo info); - - public abstract void invalidateParent(ItemInfo info); - public Rect getViewBounds(View v) { int[] pos = new int[2]; v.getLocationOnScreen(pos); diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java index 455fd1866d..f20ded364b 100644 --- a/src/com/android/launcher3/BubbleTextView.java +++ b/src/com/android/launcher3/BubbleTextView.java @@ -42,8 +42,6 @@ import android.view.ViewConfiguration; import android.view.ViewDebug; import android.widget.TextView; -import com.android.launcher3.icons.IconCache.IconLoadRequest; -import com.android.launcher3.icons.IconCache.ItemInfoUpdateReceiver; import com.android.launcher3.Launcher.OnResumeCallback; import com.android.launcher3.badge.BadgeInfo; import com.android.launcher3.badge.BadgeRenderer; @@ -51,7 +49,10 @@ import com.android.launcher3.folder.FolderIcon; import com.android.launcher3.graphics.DrawableFactory; import com.android.launcher3.graphics.IconPalette; import com.android.launcher3.graphics.PreloadIconDrawable; +import com.android.launcher3.icons.IconCache.IconLoadRequest; +import com.android.launcher3.icons.IconCache.ItemInfoUpdateReceiver; import com.android.launcher3.model.PackageItemInfo; +import com.android.launcher3.views.ActivityContext; import java.text.NumberFormat; @@ -96,7 +97,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, } }; - private final BaseDraggingActivity mActivity; + private final ActivityContext mActivity; private Drawable mIcon; private final boolean mCenterVertically; @@ -144,7 +145,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, public BubbleTextView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); - mActivity = BaseDraggingActivity.fromContext(context); + mActivity = ActivityContext.lookupContext(context); DeviceProfile grid = mActivity.getDeviceProfile(); mSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop(); diff --git a/src/com/android/launcher3/dragndrop/AddItemActivity.java b/src/com/android/launcher3/dragndrop/AddItemActivity.java index daf7dc6d99..79819ccadf 100644 --- a/src/com/android/launcher3/dragndrop/AddItemActivity.java +++ b/src/com/android/launcher3/dragndrop/AddItemActivity.java @@ -58,6 +58,7 @@ import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType; import com.android.launcher3.util.InstantAppResolver; import com.android.launcher3.util.LooperExecutor; import com.android.launcher3.util.Provider; +import com.android.launcher3.views.BaseDragLayer; import com.android.launcher3.widget.PendingAddShortcutInfo; import com.android.launcher3.widget.PendingAddWidgetInfo; import com.android.launcher3.widget.WidgetHostViewLoader; @@ -314,6 +315,11 @@ public class AddItemActivity extends BaseActivity implements OnLongClickListener .getInt(STATE_EXTRA_WIDGET_ID, mPendingBindWidgetId); } + @Override + public BaseDragLayer getDragLayer() { + throw new UnsupportedOperationException(); + } + private void logCommand(int command) { getUserEventDispatcher().dispatchUserEvent(newLauncherEvent( newCommandAction(command), diff --git a/src/com/android/launcher3/views/ActivityContext.java b/src/com/android/launcher3/views/ActivityContext.java index 04100af7f2..cee7eee22b 100644 --- a/src/com/android/launcher3/views/ActivityContext.java +++ b/src/com/android/launcher3/views/ActivityContext.java @@ -18,10 +18,15 @@ package com.android.launcher3.views; import android.content.Context; import android.content.ContextWrapper; import android.view.ContextThemeWrapper; +import android.view.View.AccessibilityDelegate; + +import com.android.launcher3.DeviceProfile; +import com.android.launcher3.ItemInfo; +import com.android.launcher3.badge.BadgeInfo; /** - * An interface to be used along with a context. This allows a generic class to depend on Context - * subclass instead of an Activity. + * An interface to be used along with a context for various activities in Launcher. This allows a + * generic class to depend on Context subclass instead of an Activity. */ public interface ActivityContext { @@ -29,8 +34,28 @@ public interface ActivityContext { return false; } + default BadgeInfo getBadgeInfoForItem(ItemInfo info) { + return null; + } + + /** + * For items with tree hierarchy, notifies the activity to invalidate the parent when a root + * is invalidated + * @param info info associated with a root node. + */ + default void invalidateParent(ItemInfo info) { } + + default AccessibilityDelegate getAccessibilityDelegate() { + return null; + } + + /** + * The root view to support drag-and-drop and popup support. + */ BaseDragLayer getDragLayer(); + DeviceProfile getDeviceProfile(); + static ActivityContext lookupContext(Context context) { if (context instanceof ActivityContext) { return (ActivityContext) context;