Search in sources :

Example 1 with UserEventDispatcher

use of com.android.launcher3.logging.UserEventDispatcher in project android_packages_apps_Trebuchet by LineageOS.

the class Launcher method onNewIntent.

@Override
protected void onNewIntent(Intent intent) {
    if (Utilities.IS_RUNNING_IN_TEST_HARNESS) {
        Log.d(TestProtocol.PERMANENT_DIAG_TAG, "Launcher.onNewIntent: " + intent);
    }
    Object traceToken = TraceHelper.INSTANCE.beginSection(ON_NEW_INTENT_EVT);
    super.onNewIntent(intent);
    boolean alreadyOnHome = hasWindowFocus() && ((intent.getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
    // Check this condition before handling isActionMain, as this will get reset.
    boolean shouldMoveToDefaultScreen = alreadyOnHome && isInState(NORMAL) && AbstractFloatingView.getTopOpenView(this) == null;
    boolean isActionMain = Intent.ACTION_MAIN.equals(intent.getAction());
    boolean internalStateHandled = ACTIVITY_TRACKER.handleNewIntent(this, intent);
    if (isActionMain) {
        if (!internalStateHandled) {
            // In all these cases, only animate if we're already on home
            closeOpenViews(isStarted());
            if (!isInState(NORMAL)) {
                // Only change state, if not already the same. This prevents cancelling any
                // animations running as part of resume
                mStateManager.goToState(NORMAL, mStateManager.shouldAnimateStateChange(), this::handlePendingActivityRequest);
            }
            // Reset the apps view
            if (!alreadyOnHome) {
                mAppsView.reset(isStarted());
            }
            if (shouldMoveToDefaultScreen && !mWorkspace.isHandlingTouch()) {
                mWorkspace.post(mWorkspace::moveToDefaultScreen);
            }
        }
        // Handle HOME_INTENT
        UserEventDispatcher ued = getUserEventDispatcher();
        Target target = newContainerTarget(mStateManager.getState().containerType);
        target.pageIndex = mWorkspace.getCurrentPage();
        ued.logActionCommand(Action.Command.HOME_INTENT, target, newContainerTarget(ContainerType.WORKSPACE));
        hideKeyboard();
        if (mLauncherCallbacks != null) {
            mLauncherCallbacks.onHomeIntent(internalStateHandled);
        }
        mOverlayManager.hideOverlay(isStarted() && !isForceInvisible());
        handleGestureContract(intent);
    } else if (Intent.ACTION_ALL_APPS.equals(intent.getAction())) {
        getStateManager().goToState(ALL_APPS, alreadyOnHome);
    }
    TraceHelper.INSTANCE.endSection(traceToken);
}
Also used : UserEventDispatcher(com.android.launcher3.logging.UserEventDispatcher) Target(com.android.launcher3.userevent.nano.LauncherLogProto.Target) LoggerUtils.newContainerTarget(com.android.launcher3.logging.LoggerUtils.newContainerTarget) DragObject(com.android.launcher3.DropTarget.DragObject)

Example 2 with UserEventDispatcher

use of com.android.launcher3.logging.UserEventDispatcher in project Neo-Launcher by NeoApplications.

the class Launcher method onNewIntent.

@Override
protected void onNewIntent(Intent intent) {
    TraceHelper.beginSection("NEW_INTENT");
    super.onNewIntent(intent);
    boolean alreadyOnHome = hasWindowFocus() && ((intent.getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
    // Check this condition before handling isActionMain, as this will get reset.
    boolean shouldMoveToDefaultScreen = alreadyOnHome && isInState(NORMAL) && AbstractFloatingView.getTopOpenView(this) == null;
    boolean isActionMain = Intent.ACTION_MAIN.equals(intent.getAction());
    boolean internalStateHandled = InternalStateHandler.handleNewIntent(this, intent, isStarted());
    boolean handled = false;
    if (isActionMain) {
        if (!internalStateHandled) {
            // In all these cases, only animate if we're already on home
            AbstractFloatingView.closeAllOpenViews(this, isStarted());
            if (!isInState(NORMAL)) {
                // Only change state, if not already the same. This prevents cancelling any
                // animations running as part of resume
                mStateManager.goToState(NORMAL);
            }
            // Reset the apps view
            if (!alreadyOnHome) {
                mAppsView.reset(isStarted());
                handled = true;
            }
            if (shouldMoveToDefaultScreen && !mWorkspace.isHandlingTouch()) {
                mWorkspace.post(mWorkspace::moveToDefaultScreen);
                handled = true;
            }
            if (!handled && this instanceof OmegaLauncher) {
                ((OmegaLauncher) this).getGestureController().onPressHome();
            }
        }
        // Handle HOME_INTENT
        UserEventDispatcher ued = getUserEventDispatcher();
        Target target = newContainerTarget(mStateManager.getState().containerType);
        target.pageIndex = mWorkspace.getCurrentPage();
        ued.logActionCommand(Action.Command.HOME_INTENT, target, newContainerTarget(ContainerType.WORKSPACE));
        final View v = getWindow().peekDecorView();
        if (v != null && v.getWindowToken() != null) {
            UiThreadHelper.hideKeyboardAsync(this, v.getWindowToken());
        }
        if (mLauncherCallbacks != null) {
            mLauncherCallbacks.onHomeIntent(internalStateHandled);
        }
    }
    TraceHelper.endSection("NEW_INTENT");
}
Also used : UserEventDispatcher(com.android.launcher3.logging.UserEventDispatcher) OmegaLauncher(com.saggitt.omega.OmegaLauncher) Target(com.android.launcher3.userevent.nano.LauncherLogProto.Target) LoggerUtils.newTarget(com.android.launcher3.logging.LoggerUtils.newTarget) LoggerUtils.newContainerTarget(com.android.launcher3.logging.LoggerUtils.newContainerTarget) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) AppWidgetHostView(android.appwidget.AppWidgetHostView) OptionsPopupView(com.android.launcher3.views.OptionsPopupView) View(android.view.View) PendingAppWidgetHostView(com.android.launcher3.widget.PendingAppWidgetHostView) AllAppsContainerView(com.android.launcher3.allapps.AllAppsContainerView) ScrimView(com.android.launcher3.views.ScrimView) DragView(com.android.launcher3.dragndrop.DragView)

Example 3 with UserEventDispatcher

use of com.android.launcher3.logging.UserEventDispatcher in project Neo-Launcher by NeoApplications.

the class Launcher method onBackPressed.

@Override
public void onBackPressed() {
    if (finishAutoCancelActionMode()) {
        return;
    }
    if (mLauncherCallbacks != null && mLauncherCallbacks.handleBackPressed()) {
        return;
    }
    if (mDragController.isDragging()) {
        mDragController.cancelDrag();
        return;
    }
    // Note: There should be at most one log per method call. This is enforced implicitly
    // by using if-else statements.
    UserEventDispatcher ued = getUserEventDispatcher();
    AbstractFloatingView topView = AbstractFloatingView.getTopOpenView(this);
    if (topView != null && topView.onBackPressed()) {
    // Handled by the floating view.
    } else {
        mStateManager.getState().onBackPressed(this);
    }
}
Also used : UserEventDispatcher(com.android.launcher3.logging.UserEventDispatcher)

Aggregations

UserEventDispatcher (com.android.launcher3.logging.UserEventDispatcher)3 LoggerUtils.newContainerTarget (com.android.launcher3.logging.LoggerUtils.newContainerTarget)2 Target (com.android.launcher3.userevent.nano.LauncherLogProto.Target)2 AppWidgetHostView (android.appwidget.AppWidgetHostView)1 View (android.view.View)1 DragObject (com.android.launcher3.DropTarget.DragObject)1 AllAppsContainerView (com.android.launcher3.allapps.AllAppsContainerView)1 DragView (com.android.launcher3.dragndrop.DragView)1 LoggerUtils.newTarget (com.android.launcher3.logging.LoggerUtils.newTarget)1 OptionsPopupView (com.android.launcher3.views.OptionsPopupView)1 ScrimView (com.android.launcher3.views.ScrimView)1 LauncherAppWidgetHostView (com.android.launcher3.widget.LauncherAppWidgetHostView)1 PendingAppWidgetHostView (com.android.launcher3.widget.PendingAppWidgetHostView)1 OmegaLauncher (com.saggitt.omega.OmegaLauncher)1