Java Code Examples for android.view.View.isInTouchMode()

The following are Jave code examples for showing how to use isInTouchMode() of the android.view.View class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: LaunchEnr   File: ShortcutsItemView.java   Source Code and License Vote up 6 votes
@Override
public boolean onLongClick(View v) {
    // Return early if this is not initiated from a touch or not the correct view
    if (!v.isInTouchMode() || !(v.getParent() instanceof DeepShortcutView)) return false;
    // Return early if global dragging is not enabled
    if (!mLauncher.isDraggingEnabled()) return false;
    // Return early if an item is already being dragged (e.g. when long-pressing two shortcuts)
    if (mLauncher.getDragController().isDragging()) return false;

    // Long clicked on a shortcut.
    DeepShortcutView sv = (DeepShortcutView) v.getParent();
    sv.setWillDrawIcon(false);

    // Move the icon to align with the center-top of the touch point
    mIconShift.x = mIconLastTouchPos.x - sv.getIconCenter().x;
    mIconShift.y = mIconLastTouchPos.y - mLauncher.getDeviceProfile().iconSizePx;

    DragView dv = mLauncher.getWorkspace().beginDragShared(sv.getIconView(),
            (PopupContainerWithArrow) getParent(), sv.getFinalInfo(),
            new ShortcutDragPreviewProvider(sv.getIconView(), mIconShift), new DragOptions());
    dv.animateShift(-mIconShift.x, -mIconShift.y);

    // TODO: support dragging from within folder without having to close it
    AbstractFloatingView.closeOpenContainer(mLauncher, AbstractFloatingView.TYPE_FOLDER);
    return false;
}
 
Example 2
Project: FlickLauncher   File: DeepShortcutsContainer.java   Source Code and License Vote up 6 votes
public boolean onLongClick(View v) {
    // Return early if this is not initiated from a touch or not the correct view
    if (!v.isInTouchMode() || !(v.getParent() instanceof DeepShortcutView)) return false;
    // Return if global dragging is not enabled
    if (!mLauncher.isDraggingEnabled()) return false;

    // Long clicked on a shortcut.
    mDeferContainerRemoval = true;
    DeepShortcutView sv = (DeepShortcutView) v.getParent();
    sv.setWillDrawIcon(false);

    // Move the icon to align with the center-top of the touch point
    mIconShift.x = mIconLastTouchPos.x - sv.getIconCenter().x;
    mIconShift.y = mIconLastTouchPos.y - mLauncher.getDeviceProfile().iconSizePx;

    DragView dv = mLauncher.getWorkspace().beginDragShared(
            sv.getBubbleText(), this, sv.getFinalInfo(),
            new ShortcutDragPreviewProvider(sv.getIconView(), mIconShift), new DragOptions());
    dv.animateShift(-mIconShift.x, -mIconShift.y);

    // TODO: support dragging from within folder without having to close it
    mLauncher.closeFolder();
    return false;
}
 
Example 3
Project: FlickLauncher   File: WidgetsContainerView.java   Source Code and License Vote up 6 votes
@Override
public boolean onLongClick(View v) {
    if (LOGD) {
        Log.d(TAG, String.format("onLonglick [v=%s]", v));
    }
    // Return early if this is not initiated from a touch
    if (!v.isInTouchMode()) return false;
    // When we have exited all apps or are in transition, disregard long clicks
    if (!mLauncher.isWidgetsViewVisible() ||
            mLauncher.getWorkspace().isSwitchingState()) return false;
    // Return if global dragging is not enabled
    if (!mLauncher.isDraggingEnabled()) return false;

    boolean status = beginDragging(v);
    if (status && v.getTag() instanceof PendingAddWidgetInfo) {
        WidgetHostViewLoader hostLoader = new WidgetHostViewLoader(mLauncher, v);
        boolean preloadStatus = hostLoader.preloadWidget();
        if (LOGD) {
            Log.d(TAG, String.format("preloading widget [status=%s]", preloadStatus));
        }
        mLauncher.getDragController().addDragListener(hostLoader);
    }
    return status;
}
 
Example 4
Project: SimpleUILauncher   File: DeepShortcutsContainer.java   Source Code and License Vote up 6 votes
public boolean onLongClick(View v) {
    // Return early if this is not initiated from a touch or not the correct view
    if (!v.isInTouchMode() || !(v.getParent() instanceof DeepShortcutView)) return false;
    // Return if global dragging is not enabled
    if (!mLauncher.isDraggingEnabled()) return false;

    // Long clicked on a shortcut.
    mDeferContainerRemoval = true;
    DeepShortcutView sv = (DeepShortcutView) v.getParent();
    sv.setWillDrawIcon(false);

    // Move the icon to align with the center-top of the touch point
    mIconShift.x = mIconLastTouchPos.x - sv.getIconCenter().x;
    mIconShift.y = mIconLastTouchPos.y - mLauncher.getDeviceProfile().iconSizePx;

    DragView dv = mLauncher.getWorkspace().beginDragShared(
            sv.getBubbleText(), this, sv.getFinalInfo(),
            new ShortcutDragPreviewProvider(sv.getIconView(), mIconShift), new DragOptions());
    dv.animateShift(-mIconShift.x, -mIconShift.y);

    // TODO: support dragging from within folder without having to close it
    mLauncher.closeFolder();
    return false;
}
 
Example 5
Project: SimpleUILauncher   File: WidgetsContainerView.java   Source Code and License Vote up 6 votes
@Override
public boolean onLongClick(View v) {
    if (LOGD) {
        Log.d(TAG, String.format("onLonglick [v=%s]", v));
    }
    // Return early if this is not initiated from a touch
    if (!v.isInTouchMode()) return false;
    // When we have exited all apps or are in transition, disregard long clicks
    if (!mLauncher.isWidgetsViewVisible() ||
            mLauncher.getWorkspace().isSwitchingState()) return false;
    // Return if global dragging is not enabled
    if (!mLauncher.isDraggingEnabled()) return false;

    boolean status = beginDragging(v);
    if (status && v.getTag() instanceof PendingAddWidgetInfo) {
        WidgetHostViewLoader hostLoader = new WidgetHostViewLoader(mLauncher, v);
        boolean preloadStatus = hostLoader.preloadWidget();
        if (LOGD) {
            Log.d(TAG, String.format("preloading widget [status=%s]", preloadStatus));
        }
        mLauncher.getDragController().addDragListener(hostLoader);
    }
    return status;
}
 
Example 6
Project: LaunchEnr   File: AllAppsContainerView.java   Source Code and License Vote up 5 votes
@Override
public boolean onLongClick(final View v) {
    // Return early if this is not initiated from a touch
    if (!v.isInTouchMode()) return false;
    // When we have exited all apps or are in transition, disregard long clicks

    if (!mLauncher.isAppsViewVisible() ||
            mLauncher.getWorkspace().isSwitchingState()) return false;
    // Return if global dragging is not enabled or we are already dragging
    if (!mLauncher.isDraggingEnabled()) return false;
    if (mLauncher.getDragController().isDragging()) return false;

    // Start the drag
    final DragController dragController = mLauncher.getDragController();
    dragController.addDragListener(new DragController.DragListener() {
        @Override
        public void onDragStart(DropTarget.DragObject dragObject, DragOptions options) {
            v.setVisibility(INVISIBLE);
        }

        @Override
        public void onDragEnd() {
            v.setVisibility(VISIBLE);
            dragController.removeDragListener(this);
        }
    });
    mLauncher.getWorkspace().beginDragShared(v, this, new DragOptions());
    return false;
}
 
Example 7
Project: LaunchEnr   File: Folder.java   Source Code and License Vote up 5 votes
public boolean startDrag(View v, DragOptions options) {
    Object tag = v.getTag();
    if (tag instanceof ShortcutInfo) {
        ShortcutInfo item = (ShortcutInfo) tag;
        if (!v.isInTouchMode()) {
            return false;
        }

        mEmptyCellRank = item.rank;
        mCurrentDragView = v;

        mDragController.addDragListener(this);
        if (options.isAccessibleDrag) {
            mDragController.addDragListener(new AccessibleDragListenerAdapter(
                    mContent, CellLayout.FOLDER_ACCESSIBILITY_DRAG) {

                @Override
                protected void enableAccessibleDrag(boolean enable) {
                    super.enableAccessibleDrag(enable);
                    mFooter.setImportantForAccessibility(enable
                            ? IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
                            : IMPORTANT_FOR_ACCESSIBILITY_AUTO);
                }
            });
        }

        mLauncher.getWorkspace().beginDragShared(v, this, options);
    }
    return true;
}
 
Example 8
Project: LaunchEnr   File: Workspace.java   Source Code and License Vote up 5 votes
public void startDrag(CellLayout.CellInfo cellInfo, DragOptions options) {
    View child = cellInfo.cell;

    // Make sure the drag was started by a long press as opposed to a long click.
    if (!child.isInTouchMode()) {
        return;
    }

    mDragInfo = cellInfo;
    child.setVisibility(INVISIBLE);

    if (options.isAccessibleDrag) {
        mDragController.addDragListener(new AccessibleDragListenerAdapter(
                this, CellLayout.WORKSPACE_ACCESSIBILITY_DRAG) {
            @Override
            protected void enableAccessibleDrag(boolean enable) {
                super.enableAccessibleDrag(enable);
                setEnableForLayout(mLauncher.getHotseat().getLayout(),enable);

                // We need to allow our individual children to become click handlers in this
                // case, so temporarily unset the click handlers.
                setOnClickListener(enable ? null : mLauncher);
            }
        });
    }

    beginDragShared(child, this, options);
}
 
Example 9
Project: LaunchEnr   File: WidgetsContainerView.java   Source Code and License Vote up 5 votes
public boolean handleLongClick(View v) {
    // Return early if this is not initiated from a touch
    if (!v.isInTouchMode()) return false;
    // When we  are in transition, disregard long clicks
    if (mLauncher.getWorkspace().isSwitchingState()) return false;
    // Return if global dragging is not enabled
    if (!mLauncher.isDraggingEnabled()) return false;

    return beginDragging(v);
}
 
Example 10
Project: FlickLauncher   File: AllAppsContainerView.java   Source Code and License Vote up 5 votes
@Override
public boolean onLongClick(View v) {
    // Return early if this is not initiated from a touch
    if (!v.isInTouchMode()) return false;
    // When we have exited all apps or are in transition, disregard long clicks

    if (!mLauncher.isAppsViewVisible() ||
            mLauncher.getWorkspace().isSwitchingState()) return false;
    // Return if global dragging is not enabled or we are already dragging
    if (!mLauncher.isDraggingEnabled()) return false;
    if (mLauncher.getDragController().isDragging()) return false;

    // Start the drag
    DragOptions dragOptions = new DragOptions();
    if (v instanceof BubbleTextView) {
        final BubbleTextView icon = (BubbleTextView) v;
        if (icon.hasDeepShortcuts()) {
            DeepShortcutsContainer dsc = DeepShortcutsContainer.showForIcon(icon);
            if (dsc != null) {
                dragOptions.deferDragCondition = dsc.createDeferDragCondition(new Runnable() {
                    @Override
                    public void run() {
                        icon.setVisibility(VISIBLE);
                    }
                });
            }
        }
    }
    mLauncher.getWorkspace().beginDragShared(v, this, dragOptions);
    if (FeatureFlags.LAUNCHER3_LEGACY_WORKSPACE_DND) {
        // Enter spring loaded mode (the new workspace does this in
        // onDragStart(), so we don't want to do it here)
        mLauncher.enterSpringLoadedDragMode();
    }

    return false;
}
 
Example 11
Project: FlickLauncher   File: Folder.java   Source Code and License Vote up 5 votes
public boolean startDrag(View v, DragOptions options) {
    Object tag = v.getTag();
    if (tag instanceof ShortcutInfo) {
        ShortcutInfo item = (ShortcutInfo) tag;
        if (!v.isInTouchMode()) {
            return false;
        }

        mEmptyCellRank = item.rank;
        mCurrentDragView = v;

        mDragController.addDragListener(this);
        if (options.isAccessibleDrag) {
            mDragController.addDragListener(new AccessibileDragListenerAdapter(
                    mContent, CellLayout.FOLDER_ACCESSIBILITY_DRAG) {

                @Override
                protected void enableAccessibleDrag(boolean enable) {
                    super.enableAccessibleDrag(enable);
                    mFooter.setImportantForAccessibility(enable
                            ? IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
                            : IMPORTANT_FOR_ACCESSIBILITY_AUTO);
                }
            });
        }

        mLauncher.getWorkspace().beginDragShared(v, this, options);
    }
    return true;
}
 
Example 12
Project: FlickLauncher   File: Workspace.java   Source Code and License Vote up 5 votes
public void startDrag(CellLayout.CellInfo cellInfo, DragOptions options) {
    View child = cellInfo.cell;

    // Make sure the drag was started by a long press as opposed to a long click.
    if (!child.isInTouchMode()) {
        return;
    }

    mDragInfo = cellInfo;
    child.setVisibility(INVISIBLE);
    CellLayout layout = (CellLayout) child.getParent().getParent();
    layout.prepareChildForDrag(child);

    if (options.isAccessibleDrag) {
        mDragController.addDragListener(new AccessibileDragListenerAdapter(
                this, CellLayout.WORKSPACE_ACCESSIBILITY_DRAG) {
            @Override
            protected void enableAccessibleDrag(boolean enable) {
                super.enableAccessibleDrag(enable);
                setEnableForLayout(mLauncher.getHotseat().getLayout(),enable);

                // We need to allow our individual children to become click handlers in this
                // case, so temporarily unset the click handlers.
                setOnClickListener(enable ? null : mLauncher);
            }
        });
    }

    beginDragShared(child, this, options);
}
 
Example 13
Project: SimpleUILauncher   File: AllAppsContainerView.java   Source Code and License Vote up 5 votes
@Override
public boolean onLongClick(View v) {
    // Return early if this is not initiated from a touch
    if (!v.isInTouchMode()) return false;
    // When we have exited all apps or are in transition, disregard long clicks

    if (!mLauncher.isAppsViewVisible() ||
            mLauncher.getWorkspace().isSwitchingState()) return false;
    // Return if global dragging is not enabled or we are already dragging
    if (!mLauncher.isDraggingEnabled()) return false;
    if (mLauncher.getDragController().isDragging()) return false;

    // Start the drag
    DragOptions dragOptions = new DragOptions();
    if (v instanceof BubbleTextView) {
        final BubbleTextView icon = (BubbleTextView) v;
        if (icon.hasDeepShortcuts()) {
            DeepShortcutsContainer dsc = DeepShortcutsContainer.showForIcon(icon);
            if (dsc != null) {
                dragOptions.deferDragCondition = dsc.createDeferDragCondition(new Runnable() {
                    @Override
                    public void run() {
                        icon.setVisibility(VISIBLE);
                    }
                });
            }
        }
    }
    mLauncher.getWorkspace().beginDragShared(v, this, dragOptions);
    if (FeatureFlags.LAUNCHER3_LEGACY_WORKSPACE_DND) {
        // Enter spring loaded mode (the new workspace does this in
        // onDragStart(), so we don't want to do it here)
        mLauncher.enterSpringLoadedDragMode();
    }

    return false;
}
 
Example 14
Project: SimpleUILauncher   File: Folder.java   Source Code and License Vote up 5 votes
public boolean startDrag(View v, DragOptions options) {
    Object tag = v.getTag();
    if (tag instanceof ShortcutInfo) {
        ShortcutInfo item = (ShortcutInfo) tag;
        if (!v.isInTouchMode()) {
            return false;
        }

        mEmptyCellRank = item.rank;
        mCurrentDragView = v;

        mDragController.addDragListener(this);
        if (options.isAccessibleDrag) {
            mDragController.addDragListener(new AccessibileDragListenerAdapter(
                    mContent, CellLayout.FOLDER_ACCESSIBILITY_DRAG) {

                @Override
                protected void enableAccessibleDrag(boolean enable) {
                    super.enableAccessibleDrag(enable);
                    mFooter.setImportantForAccessibility(enable
                            ? IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
                            : IMPORTANT_FOR_ACCESSIBILITY_AUTO);
                }
            });
        }

        mLauncher.getWorkspace().beginDragShared(v, this, options);
    }
    return true;
}
 
Example 15
Project: SimpleUILauncher   File: Workspace.java   Source Code and License Vote up 5 votes
public void startDrag(CellLayout.CellInfo cellInfo, DragOptions options) {
    View child = cellInfo.cell;

    // Make sure the drag was started by a long press as opposed to a long click.
    if (!child.isInTouchMode()) {
        return;
    }

    mDragInfo = cellInfo;
    child.setVisibility(INVISIBLE);
    CellLayout layout = (CellLayout) child.getParent().getParent();
    layout.prepareChildForDrag(child);

    if (options.isAccessibleDrag) {
        mDragController.addDragListener(new AccessibileDragListenerAdapter(
                this, CellLayout.WORKSPACE_ACCESSIBILITY_DRAG) {
            @Override
            protected void enableAccessibleDrag(boolean enable) {
                super.enableAccessibleDrag(enable);
                setEnableForLayout(mLauncher.getHotseat().getLayout(),enable);

                // We need to allow our individual children to become click handlers in this
                // case, so temporarily unset the click handlers.
                setOnClickListener(enable ? null : mLauncher);
            }
        });
    }

    beginDragShared(child, this, options);
}