Search in sources :

Example 61 with Launcher

use of com.android.launcher3.Launcher in project android_packages_apps_Launcher3 by AOSPA.

the class SecondaryDisplayLauncher method onNewIntent.

@Override
public void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    if (Intent.ACTION_MAIN.equals(intent.getAction())) {
        // Hide keyboard.
        final View v = getWindow().peekDecorView();
        if (v != null && v.getWindowToken() != null) {
            getSystemService(InputMethodManager.class).hideSoftInputFromWindow(v.getWindowToken(), 0);
        }
    }
    // A new intent will bring the launcher to top. Hide the app drawer to reset the state.
    showAppDrawer(false);
}
Also used : InputMethodManager(android.view.inputmethod.InputMethodManager) View(android.view.View) AbstractFloatingView(com.android.launcher3.AbstractFloatingView) AllAppsContainerView(com.android.launcher3.allapps.AllAppsContainerView)

Example 62 with Launcher

use of com.android.launcher3.Launcher in project android_packages_apps_Launcher3 by AOSPA.

the class PopupContainerWithArrow method configureForLauncher.

private void configureForLauncher(Launcher launcher) {
    addOnAttachStateChangeListener(new LiveUpdateHandler(launcher));
    mPopupItemDragHandler = new LauncherPopupItemDragHandler(launcher, this);
    mAccessibilityDelegate = new ShortcutMenuAccessibilityDelegate(launcher);
    launcher.getDragController().addDragListener(this);
    addPreDrawForColorExtraction(launcher);
}
Also used : ShortcutMenuAccessibilityDelegate(com.android.launcher3.accessibility.ShortcutMenuAccessibilityDelegate)

Example 63 with Launcher

use of com.android.launcher3.Launcher in project android_packages_apps_Launcher3 by AOSPA.

the class ShortcutDragPreviewProvider method getScaleAndPosition.

@Override
public float getScaleAndPosition(Drawable preview, int[] outPos) {
    Launcher launcher = Launcher.getLauncher(mView.getContext());
    int iconSize = getDrawableBounds(mView.getBackground()).width();
    float scale = launcher.getDragLayer().getLocationInDragLayer(mView, outPos);
    int iconLeft = mView.getPaddingStart();
    if (Utilities.isRtl(mView.getResources())) {
        iconLeft = mView.getWidth() - iconSize - iconLeft;
    }
    outPos[0] += Math.round(scale * iconLeft + (scale * iconSize - preview.getIntrinsicWidth()) / 2 + mPositionShift.x);
    outPos[1] += Math.round((scale * mView.getHeight() - preview.getIntrinsicHeight()) / 2 + mPositionShift.y);
    float size = launcher.getDeviceProfile().iconSizePx;
    return scale * iconSize / size;
}
Also used : Launcher(com.android.launcher3.Launcher) Point(android.graphics.Point)

Example 64 with Launcher

use of com.android.launcher3.Launcher in project android_packages_apps_Launcher3 by AOSPA.

the class ArrowPopup method initColorExtractionLocations.

private void initColorExtractionLocations(Launcher launcher) {
    if (mColorExtractors == null) {
        return;
    }
    Workspace workspace = launcher.getWorkspace();
    if (workspace == null) {
        return;
    }
    boolean firstVisibleChild = true;
    int screenId = workspace.getScreenIdForPageIndex(workspace.getCurrentPage());
    DragLayer dragLayer = launcher.getDragLayer();
    final View[] viewAlignedWithArrow = new View[1];
    // Order matters here, since we need the arrow to match the color of its adjacent view.
    for (final View view : getChildrenForColorExtraction()) {
        if (view != null && view.getVisibility() == VISIBLE) {
            Rect pos = new Rect();
            dragLayer.getDescendantRectRelativeToSelf(view, pos);
            if (!pos.isEmpty()) {
                LocalColorExtractor extractor = LocalColorExtractor.newInstance(launcher);
                extractor.setWorkspaceLocation(pos, dragLayer, screenId);
                extractor.setListener(extractedColors -> {
                    AnimatorSet colors = new AnimatorSet();
                    int newColor = getExtractedColor(extractedColors);
                    setChildColor(view, newColor, colors);
                    int numChildren = view instanceof ViewGroup ? ((ViewGroup) view).getChildCount() : 0;
                    for (int i = 0; i < numChildren; ++i) {
                        View childView = ((ViewGroup) view).getChildAt(i);
                        setChildColor(childView, newColor, colors);
                    }
                    if (viewAlignedWithArrow[0] == view) {
                        mArrowColor = newColor;
                        updateArrowColor();
                    }
                    colors.setDuration(150);
                    view.post(colors::start);
                });
                mColorExtractors.add(extractor);
                if (mIsAboveIcon || firstVisibleChild) {
                    viewAlignedWithArrow[0] = view;
                }
                firstVisibleChild = false;
            }
        }
    }
}
Also used : BaseDragLayer(com.android.launcher3.views.BaseDragLayer) DragLayer(com.android.launcher3.dragndrop.DragLayer) Rect(android.graphics.Rect) ViewGroup(android.view.ViewGroup) AnimatorSet(android.animation.AnimatorSet) LocalColorExtractor(com.android.launcher3.widget.LocalColorExtractor) View(android.view.View) DeepShortcutView(com.android.launcher3.shortcuts.DeepShortcutView) AbstractFloatingView(com.android.launcher3.AbstractFloatingView) Workspace(com.android.launcher3.Workspace)

Example 65 with Launcher

use of com.android.launcher3.Launcher in project android_packages_apps_Launcher3 by AOSPA.

the class SpringLoadedState method getWorkspaceScaleAndTranslation.

@Override
public ScaleAndTranslation getWorkspaceScaleAndTranslation(Launcher launcher) {
    DeviceProfile grid = launcher.getDeviceProfile();
    Workspace ws = launcher.getWorkspace();
    if (ws.getChildCount() == 0) {
        return super.getWorkspaceScaleAndTranslation(launcher);
    }
    if (grid.isVerticalBarLayout()) {
        float scale = grid.workspaceSpringLoadShrinkFactor;
        return new ScaleAndTranslation(scale, 0, 0);
    }
    float scale = grid.workspaceSpringLoadShrinkFactor;
    Rect insets = launcher.getDragLayer().getInsets();
    float scaledHeight = scale * ws.getNormalChildHeight();
    float shrunkTop = insets.top + grid.dropTargetBarSizePx;
    float shrunkBottom = ws.getMeasuredHeight() - insets.bottom - grid.workspacePadding.bottom - grid.workspaceSpringLoadedBottomSpace;
    float totalShrunkSpace = shrunkBottom - shrunkTop;
    float desiredCellTop = shrunkTop + (totalShrunkSpace - scaledHeight) / 2;
    float halfHeight = ws.getHeight() / 2;
    float myCenter = ws.getTop() + halfHeight;
    float cellTopFromCenter = halfHeight - ws.getChildAt(0).getTop();
    float actualCellTop = myCenter - cellTopFromCenter * scale;
    return new ScaleAndTranslation(scale, 0, (desiredCellTop - actualCellTop) / scale);
}
Also used : DeviceProfile(com.android.launcher3.DeviceProfile) Rect(android.graphics.Rect) Workspace(com.android.launcher3.Workspace)

Aggregations

Launcher (com.android.launcher3.Launcher)194 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)102 Test (org.junit.Test)102 View (android.view.View)87 LargeTest (androidx.test.filters.LargeTest)83 ItemInfo (com.android.launcher3.model.data.ItemInfo)83 Rect (android.graphics.Rect)80 Point (android.graphics.Point)77 Intent (android.content.Intent)71 ArrayList (java.util.ArrayList)69 DeviceProfile (com.android.launcher3.DeviceProfile)66 BaseQuickstepLauncher (com.android.launcher3.BaseQuickstepLauncher)64 Context (android.content.Context)61 LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)49 RecentsView (com.android.quickstep.views.RecentsView)46 DragLayer (com.android.launcher3.dragndrop.DragLayer)45 ComponentName (android.content.ComponentName)43 FolderInfo (com.android.launcher3.model.data.FolderInfo)42 ViewGroup (android.view.ViewGroup)41 AllApps (com.android.launcher3.tapl.AllApps)40