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

Commit 87b5eb68 authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Exposing some private methods to easily customize arrow popup

Change-Id: I6f6dc0604a616f26c0879732a0237767ddbfdccc
parent 17b7d365
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.quickstep.views;

import static android.widget.Toast.LENGTH_SHORT;

import static com.android.launcher3.BaseActivity.fromContext;
import static com.android.launcher3.anim.Interpolators.FAST_OUT_SLOW_IN;
import static com.android.launcher3.anim.Interpolators.LINEAR;

@@ -133,7 +134,7 @@ public class TaskView extends FrameLayout implements TaskCallbacks, PageCallback
                return;
            }
            launchTask(true /* animate */);
            BaseActivity.fromContext(context).getUserEventDispatcher().logTaskLaunchOrDismiss(
            fromContext(context).getUserEventDispatcher().logTaskLaunchOrDismiss(
                    Touch.TAP, Direction.NONE, getRecentsView().indexOfChild(this),
                    TaskUtils.getLaunchComponentKeyForTask(getTask().key));
        });
@@ -185,7 +186,7 @@ public class TaskView extends FrameLayout implements TaskCallbacks, PageCallback
        if (mTask != null) {
            final ActivityOptions opts;
            if (animate) {
                opts = BaseDraggingActivity.fromContext(getContext())
                opts = ((BaseDraggingActivity) fromContext(getContext()))
                        .getActivityLaunchOptions(this);
            } else {
                opts = ActivityOptions.makeCustomAnimation(getContext(), 0, 0);
@@ -335,7 +336,7 @@ public class TaskView extends FrameLayout implements TaskCallbacks, PageCallback
                        getContext().getText(R.string.accessibility_close_task)));

        final Context context = getContext();
        final BaseDraggingActivity activity = BaseDraggingActivity.fromContext(context);
        final BaseDraggingActivity activity = fromContext(context);
        for (TaskSystemShortcut menuOption : TaskMenuView.MENU_OPTIONS) {
            OnClickListener onClickListener = menuOption.getOnClickListener(activity, this);
            if (onClickListener != null) {
@@ -363,7 +364,7 @@ public class TaskView extends FrameLayout implements TaskCallbacks, PageCallback
        for (TaskSystemShortcut menuOption : TaskMenuView.MENU_OPTIONS) {
            if (action == menuOption.labelResId) {
                OnClickListener onClickListener = menuOption.getOnClickListener(
                        BaseDraggingActivity.fromContext(getContext()), this);
                        fromContext(getContext()), this);
                if (onClickListener != null) {
                    onClickListener.onClick(this);
                }
+9 −8
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import android.widget.LinearLayout;

import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
import com.android.launcher3.util.TouchController;
import com.android.launcher3.views.ActivityContext;
import com.android.launcher3.views.BaseDragLayer;

import java.lang.annotation.Retention;
@@ -151,7 +152,7 @@ public abstract class AbstractFloatingView extends LinearLayout implements Touch
        if (mIsOpen) {
            sendAccessibilityEvent(TYPE_VIEW_FOCUSED);
        }
        BaseDraggingActivity.fromContext(getContext()).getDragLayer()
        ActivityContext.lookupContext(getContext()).getDragLayer()
                .sendAccessibilityEvent(TYPE_WINDOW_CONTENT_CHANGED);
    }

@@ -160,7 +161,7 @@ public abstract class AbstractFloatingView extends LinearLayout implements Touch
    }

    protected static <T extends AbstractFloatingView> T getOpenView(
            BaseDraggingActivity activity, @FloatingViewType int type) {
            ActivityContext activity, @FloatingViewType int type) {
        BaseDragLayer dragLayer = activity.getDragLayer();
        // Iterate in reverse order. AbstractFloatingView is added later to the dragLayer,
        // and will be one of the last views.
@@ -176,7 +177,7 @@ public abstract class AbstractFloatingView extends LinearLayout implements Touch
        return null;
    }

    public static void closeOpenContainer(BaseDraggingActivity activity,
    public static void closeOpenContainer(ActivityContext activity,
            @FloatingViewType int type) {
        AbstractFloatingView view = getOpenView(activity, type);
        if (view != null) {
@@ -184,7 +185,7 @@ public abstract class AbstractFloatingView extends LinearLayout implements Touch
        }
    }

    public static void closeOpenViews(BaseDraggingActivity activity, boolean animate,
    public static void closeOpenViews(ActivityContext activity, boolean animate,
            @FloatingViewType int type) {
        BaseDragLayer dragLayer = activity.getDragLayer();
        // Iterate in reverse order. AbstractFloatingView is added later to the dragLayer,
@@ -200,20 +201,20 @@ public abstract class AbstractFloatingView extends LinearLayout implements Touch
        }
    }

    public static void closeAllOpenViews(BaseDraggingActivity activity, boolean animate) {
    public static void closeAllOpenViews(ActivityContext activity, boolean animate) {
        closeOpenViews(activity, animate, TYPE_ALL);
        activity.finishAutoCancelActionMode();
    }

    public static void closeAllOpenViews(BaseDraggingActivity activity) {
    public static void closeAllOpenViews(ActivityContext activity) {
        closeAllOpenViews(activity, true);
    }

    public static AbstractFloatingView getTopOpenView(BaseDraggingActivity activity) {
    public static AbstractFloatingView getTopOpenView(ActivityContext activity) {
        return getTopOpenViewWithType(activity, TYPE_ALL);
    }

    public static AbstractFloatingView getTopOpenViewWithType(BaseDraggingActivity activity,
    public static AbstractFloatingView getTopOpenViewWithType(ActivityContext activity,
            @FloatingViewType int type) {
        return getOpenView(activity, type);
    }
+11 −7
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.content.ContextWrapper;
import android.content.Intent;
import android.content.res.Configuration;
import android.support.annotation.IntDef;
import android.view.ContextThemeWrapper;
import android.view.View.AccessibilityDelegate;

import com.android.launcher3.DeviceProfile.OnDeviceProfileChangeListener;
@@ -116,13 +117,6 @@ public abstract class BaseActivity extends Activity implements UserEventDelegate
        return Utilities.ATLEAST_NOUGAT && isInMultiWindowMode();
    }

    public static BaseActivity fromContext(Context context) {
        if (context instanceof BaseActivity) {
            return (BaseActivity) context;
        }
        return ((BaseActivity) ((ContextWrapper) context).getBaseContext());
    }

    public SystemUiController getSystemUiController() {
        if (mSystemUiController == null) {
            mSystemUiController = new SystemUiController(getWindow());
@@ -259,4 +253,14 @@ public abstract class BaseActivity extends Activity implements UserEventDelegate
        writer.println(" mActivityFlags: " + mActivityFlags);
        writer.println(" mForceInvisible: " + mForceInvisible);
    }

    public static <T extends BaseActivity> T fromContext(Context context) {
        if (context instanceof BaseActivity) {
            return (T) context;
        } else if (context instanceof ContextThemeWrapper) {
            return fromContext(((ContextWrapper) context).getBaseContext());
        } else {
            throw new IllegalArgumentException("Cannot find BaseActivity in parent tree");
        }
    }
}
+4 −12
Original line number Diff line number Diff line
@@ -18,8 +18,6 @@ package com.android.launcher3;

import android.app.ActivityOptions;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.Intent;
import android.graphics.Rect;
import android.os.Bundle;
@@ -28,23 +26,23 @@ import android.os.StrictMode;
import android.os.UserHandle;
import android.util.Log;
import android.view.ActionMode;
import android.view.Surface;
import android.view.View;
import android.widget.Toast;

import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.badge.BadgeInfo;
import com.android.launcher3.compat.LauncherAppsCompat;
import com.android.launcher3.shortcuts.DeepShortcutManager;
import com.android.launcher3.uioverrides.DisplayRotationListener;
import com.android.launcher3.uioverrides.WallpaperColorInfo;
import com.android.launcher3.shortcuts.DeepShortcutManager;
import com.android.launcher3.views.BaseDragLayer;
import com.android.launcher3.views.ActivityContext;

/**
 * Extension of BaseActivity allowing support for drag-n-drop
 */
public abstract class BaseDraggingActivity extends BaseActivity
        implements WallpaperColorInfo.OnChangeListener {
        implements WallpaperColorInfo.OnChangeListener, ActivityContext {

    private static final String TAG = "BaseDraggingActivity";

@@ -110,6 +108,7 @@ public abstract class BaseDraggingActivity extends BaseActivity
        mCurrentActionMode = null;
    }

    @Override
    public boolean finishAutoCancelActionMode() {
        if (mCurrentActionMode != null && AUTO_CANCEL_ACTION_MODE == mCurrentActionMode.getTag()) {
            mCurrentActionMode.finish();
@@ -128,13 +127,6 @@ public abstract class BaseDraggingActivity extends BaseActivity

    public abstract void invalidateParent(ItemInfo info);

    public static BaseDraggingActivity fromContext(Context context) {
        if (context instanceof BaseDraggingActivity) {
            return (BaseDraggingActivity) context;
        }
        return ((BaseDraggingActivity) ((ContextWrapper) context).getBaseContext());
    }

    public Rect getViewBounds(View v) {
        int[] pos = new int[2];
        v.getLocationOnScreen(pos);
+1 −4
Original line number Diff line number Diff line
@@ -2405,10 +2405,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
    }

    public static Launcher getLauncher(Context context) {
        if (context instanceof Launcher) {
            return (Launcher) context;
        }
        return ((Launcher) ((ContextWrapper) context).getBaseContext());
        return (Launcher) fromContext(context);
    }

    /**
Loading