Search in sources :

Example 1 with LocalColorExtractor

use of com.android.launcher3.widget.LocalColorExtractor 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 2 with LocalColorExtractor

use of com.android.launcher3.widget.LocalColorExtractor in project android_packages_apps_Launcher3 by ArrowOS.

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 3 with LocalColorExtractor

use of com.android.launcher3.widget.LocalColorExtractor in project android_packages_apps_404Launcher by P-404.

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 4 with LocalColorExtractor

use of com.android.launcher3.widget.LocalColorExtractor in project android_packages_apps_Launcher3 by ProtonAOSP.

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)

Aggregations

AnimatorSet (android.animation.AnimatorSet)4 Rect (android.graphics.Rect)4 View (android.view.View)4 ViewGroup (android.view.ViewGroup)4 AbstractFloatingView (com.android.launcher3.AbstractFloatingView)4 Workspace (com.android.launcher3.Workspace)4 DragLayer (com.android.launcher3.dragndrop.DragLayer)4 DeepShortcutView (com.android.launcher3.shortcuts.DeepShortcutView)4 BaseDragLayer (com.android.launcher3.views.BaseDragLayer)4 LocalColorExtractor (com.android.launcher3.widget.LocalColorExtractor)4