Search in sources :

Example 6 with Background

use of com.android.launcher3.tapl.Background in project android_packages_apps_Launcher3 by crdroidandroid.

the class TouchInteractionService method onConfigurationChanged.

@Override
public void onConfigurationChanged(Configuration newConfig) {
    if (!mDeviceState.isUserUnlocked()) {
        return;
    }
    final BaseActivityInterface activityInterface = mOverviewComponentObserver.getActivityInterface();
    final BaseDraggingActivity activity = activityInterface.getCreatedActivity();
    if (activity == null || activity.isStarted()) {
        // We only care about the existing background activity.
        return;
    }
    if (mOverviewComponentObserver.canHandleConfigChanges(activity.getComponentName(), activity.getResources().getConfiguration().diff(newConfig))) {
        // Since navBar gestural height are different between portrait and landscape,
        // can handle orientation changes and refresh navigation gestural region through
        // onOneHandedModeChanged()
        int newGesturalHeight = ResourceUtils.getNavbarSize(ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE, getApplicationContext().getResources());
        mDeviceState.onOneHandedModeChanged(newGesturalHeight);
        return;
    }
    preloadOverview(false);
}
Also used : BaseDraggingActivity(com.android.launcher3.BaseDraggingActivity) Point(android.graphics.Point)

Example 7 with Background

use of com.android.launcher3.tapl.Background in project android_packages_apps_Launcher3 by crdroidandroid.

the class TaskbarView method delegateTouchIfNecessary.

/**
 * User touched the Taskbar background. Determine whether the touch is close enough to a view
 * that we should forward the touches to it.
 * @return Whether a delegate view was chosen and it handled the touch event.
 */
private boolean delegateTouchIfNecessary(MotionEvent event) {
    final float x = event.getX();
    final float y = event.getY();
    if (mDelegateView == null && event.getAction() == MotionEvent.ACTION_DOWN) {
        View delegateView = findDelegateView(x, y);
        if (delegateView != null) {
            mDelegateTargeted = true;
            mDelegateView = delegateView;
            mDelegateSlopBounds.set(mTempDelegateBounds);
            mDelegateSlopBounds.inset(-mTouchSlop, -mTouchSlop);
        }
    }
    boolean sendToDelegate = mDelegateTargeted;
    boolean inBounds = true;
    switch(event.getAction()) {
        case MotionEvent.ACTION_MOVE:
            inBounds = mDelegateSlopBounds.contains(x, y);
            break;
        case MotionEvent.ACTION_UP:
        case MotionEvent.ACTION_CANCEL:
            mDelegateTargeted = false;
            break;
    }
    boolean handled = false;
    if (sendToDelegate) {
        if (inBounds) {
            // Offset event coordinates to be inside the target view
            event.setLocation(mDelegateView.getWidth() / 2f, mDelegateView.getHeight() / 2f);
        } else {
            // Offset event coordinates to be outside the target view (in case it does
            // something like tracking pressed state)
            event.setLocation(-mTouchSlop * 2, -mTouchSlop * 2);
        }
        handled = mDelegateView.dispatchTouchEvent(event);
        // Cleanup if this was the last event to send to the delegate.
        if (!mDelegateTargeted) {
            mDelegateView = null;
        }
    }
    return handled;
}
Also used : BubbleTextView(com.android.launcher3.BubbleTextView) View(android.view.View) AbstractFloatingView(com.android.launcher3.AbstractFloatingView)

Example 8 with Background

use of com.android.launcher3.tapl.Background in project android_packages_apps_Launcher3 by crdroidandroid.

the class PopupContainerWithArrow method initializeSystemShortcut.

private void initializeSystemShortcut(int resId, ViewGroup container, SystemShortcut info) {
    View view = inflateAndAdd(resId, container, getInsertIndexForSystemShortcut(container, info));
    if (view instanceof DeepShortcutView) {
        // Expanded system shortcut, with both icon and text shown on white background.
        final DeepShortcutView shortcutView = (DeepShortcutView) view;
        info.setIconAndLabelFor(shortcutView.getIconView(), shortcutView.getBubbleText());
    } else if (view instanceof ImageView) {
        // Only the system shortcut icon shows on a gray background header.
        info.setIconAndContentDescriptionFor((ImageView) view);
        view.setTooltipText(view.getContentDescription());
    }
    view.setTag(info);
    view.setOnClickListener(info);
}
Also used : ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) DraggableView(com.android.launcher3.dragndrop.DraggableView) BubbleTextView(com.android.launcher3.BubbleTextView) View(android.view.View) DeepShortcutView(com.android.launcher3.shortcuts.DeepShortcutView) AbstractFloatingView(com.android.launcher3.AbstractFloatingView) DragView(com.android.launcher3.dragndrop.DragView) DeepShortcutView(com.android.launcher3.shortcuts.DeepShortcutView)

Example 9 with Background

use of com.android.launcher3.tapl.Background in project android_packages_apps_Launcher3 by crdroidandroid.

the class ModelWriter method addItemToDatabase.

/**
 * Add an item to the database in a specified container. Sets the container, screen, cellX and
 * cellY fields of the item. Also assigns an ID to the item.
 */
public void addItemToDatabase(final ItemInfo item, int container, int screenId, int cellX, int cellY) {
    updateItemInfoProps(item, container, screenId, cellX, cellY);
    final ContentResolver cr = mContext.getContentResolver();
    item.id = Settings.call(cr, Settings.METHOD_NEW_ITEM_ID).getInt(Settings.EXTRA_VALUE);
    ModelVerifier verifier = new ModelVerifier();
    final StackTraceElement[] stackTrace = new Throwable().getStackTrace();
    ((Executor) MODEL_EXECUTOR).execute(() -> {
        // Write the item on background thread, as some properties might have been updated in
        // the background.
        final ContentWriter writer = new ContentWriter(mContext);
        item.onAddToDatabase(writer);
        writer.put(Favorites._ID, item.id);
        cr.insert(Favorites.CONTENT_URI, writer.getValues(mContext));
        synchronized (mBgDataModel) {
            checkItemInfoLocked(item.id, item, stackTrace);
            mBgDataModel.addItem(mContext, item, true);
            verifier.verifyModel();
        }
    });
}
Also used : ContentWriter(com.android.launcher3.util.ContentWriter) Executor(java.util.concurrent.Executor) ContentResolver(android.content.ContentResolver)

Example 10 with Background

use of com.android.launcher3.tapl.Background in project android_packages_apps_Launcher3 by crdroidandroid.

the class TaplTestsQuickstep method testOverview.

@Test
@PortraitLandscape
public void testOverview() throws Exception {
    startTestAppsWithCheck();
    // mLauncher.pressHome() also tests an important case of pressing home while in background.
    Overview overview = mLauncher.pressHome().switchToOverview();
    assertTrue("Launcher internal state didn't switch to Overview", isInState(() -> LauncherState.OVERVIEW));
    executeOnLauncher(launcher -> assertTrue("Don't have at least 3 tasks", getTaskCount(launcher) >= 3));
    // Test flinging forward and backward.
    executeOnLauncher(launcher -> assertEquals("Current task in Overview is not 0", 0, getCurrentOverviewPage(launcher)));
    overview.flingForward();
    assertTrue("Launcher internal state is not Overview", isInState(() -> LauncherState.OVERVIEW));
    final Integer currentTaskAfterFlingForward = getFromLauncher(launcher -> getCurrentOverviewPage(launcher));
    executeOnLauncher(launcher -> assertTrue("Current task in Overview is still 0", currentTaskAfterFlingForward > 0));
    overview.flingBackward();
    assertTrue("Launcher internal state is not Overview", isInState(() -> LauncherState.OVERVIEW));
    executeOnLauncher(launcher -> assertTrue("Flinging back in Overview did nothing", getCurrentOverviewPage(launcher) < currentTaskAfterFlingForward));
    // Test opening a task.
    OverviewTask task = mLauncher.pressHome().switchToOverview().getCurrentTask();
    assertNotNull("overview.getCurrentTask() returned null (1)", task);
    assertNotNull("OverviewTask.open returned null", task.open());
    assertTrue("Test activity didn't open from Overview", mDevice.wait(Until.hasObject(By.pkg(getAppPackageName()).text("TestActivity2")), DEFAULT_UI_TIMEOUT));
    executeOnLauncher(launcher -> assertTrue("Launcher activity is the top activity; expecting another activity to be the top " + "one", isInBackground(launcher)));
    // Test dismissing a task.
    overview = mLauncher.pressHome().switchToOverview();
    assertTrue("Launcher internal state didn't switch to Overview", isInState(() -> LauncherState.OVERVIEW));
    final Integer numTasks = getFromLauncher(launcher -> getTaskCount(launcher));
    task = overview.getCurrentTask();
    assertNotNull("overview.getCurrentTask() returned null (2)", task);
    task.dismiss();
    executeOnLauncher(launcher -> assertEquals("Dismissing a task didn't remove 1 task from Overview", numTasks - 1, getTaskCount(launcher)));
    // Test UIDevice.pressHome, once we are in AllApps.
    mDevice.pressHome();
    waitForState("Launcher internal state didn't switch to Home", () -> LauncherState.NORMAL);
    // Test dismissing all tasks.
    mLauncher.getWorkspace().switchToOverview().dismissAllTasks();
    waitForState("Launcher internal state didn't switch to Home", () -> LauncherState.NORMAL);
    executeOnLauncher(launcher -> assertEquals("Still have tasks after dismissing all", 0, getTaskCount(launcher)));
}
Also used : OverviewTask(com.android.launcher3.tapl.OverviewTask) Overview(com.android.launcher3.tapl.Overview) LargeTest(androidx.test.filters.LargeTest) Test(org.junit.Test)

Aggregations

View (android.view.View)48 Point (android.graphics.Point)39 Rect (android.graphics.Rect)39 ItemInfo (com.android.launcher3.model.data.ItemInfo)29 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)29 ObjectAnimator (android.animation.ObjectAnimator)28 Background (com.android.launcher3.tapl.Background)28 DragView (com.android.launcher3.dragndrop.DragView)26 DragLayer (com.android.launcher3.dragndrop.DragLayer)25 Animator (android.animation.Animator)24 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)24 LauncherAppWidgetHostView (com.android.launcher3.widget.LauncherAppWidgetHostView)24 Drawable (android.graphics.drawable.Drawable)23 ArrayList (java.util.ArrayList)23 ViewGroup (android.view.ViewGroup)22 ColorDrawable (android.graphics.drawable.ColorDrawable)21 Handler (android.os.Handler)21 FolderIcon (com.android.launcher3.folder.FolderIcon)21 DeepShortcutView (com.android.launcher3.shortcuts.DeepShortcutView)21 Bitmap (android.graphics.Bitmap)20