Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fe8e4a90 authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Moving some methods from various activities to the base interface

This allows creating some custom views in the absence of
activity context

Bug: 118758696
Change-Id: I23999290e972a2a8cbd725a521a4e0c7c2e5023e
parent 3386fbf6
Loading
Loading
Loading
Loading
+0 −9
Original line number Diff line number Diff line
@@ -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
+4 −5
Original line number Diff line number Diff line
@@ -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) {}
+1 −7
Original line number Diff line number Diff line
@@ -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 extends View> 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);
+5 −4
Original line number Diff line number Diff line
@@ -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();

+6 −0
Original line number Diff line number Diff line
@@ -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),
Loading