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

The following examples show how to use android.view.View#isInTouchMode() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ShortcutsItemView.java    From LaunchEnr with GNU General Public License v3.0 6 votes vote down vote up
@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
Source File: Folder.java    From Trebuchet with GNU General Public License v3.0 6 votes vote down vote up
private boolean beginDrag(View v, boolean accessible) {
    Object tag = v.getTag();
    if (tag instanceof ShortcutInfo) {
        ShortcutInfo item = (ShortcutInfo) tag;
        if (!v.isInTouchMode()) {
            return false;
        }

        mLauncher.getWorkspace().beginDragShared(v, new Point(), this, accessible);

        mCurrentDragInfo = item;
        mEmptyCellRank = item.rank;
        mCurrentDragView = v;

        mContent.removeItem(mCurrentDragView);
        mInfo.remove(mCurrentDragInfo);
        mDragInProgress = true;
        mItemAddedBackToSelfViaIcon = false;
    }
    return true;
}
 
Example 3
Source File: AllAppsContainerView.java    From Trebuchet with GNU General Public License v3.0 6 votes vote down vote up
@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
    if (!mLauncher.isDraggingEnabled()) return false;

    // Start the drag
    mLauncher.getWorkspace().beginDragShared(v, mIconLastTouchPos, this, false);
    // Enter spring loaded mode
    mLauncher.enterSpringLoadedDragMode();

    return false;
}
 
Example 4
Source File: Workspace.java    From Trebuchet with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void startDrag(CellLayout.CellInfo cellInfo, boolean accessible) {
    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);

    beginDragShared(child, this, accessible);
}
 
Example 5
Source File: WidgetsContainerView.java    From Trebuchet with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean onLongClick(View v) {
    if (DEBUG) {
        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
    Log.d(TAG, String.format("onLonglick dragging enabled?.", v));
    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 (DEBUG) {
            Log.d(TAG, String.format("preloading widget [status=%s]", preloadStatus));
        }
        mLauncher.getDragController().addDragListener(hostLoader);
    }
    return status;
}
 
Example 6
Source File: Folder.java    From TurboLauncher with Apache License 2.0 6 votes vote down vote up
public boolean onLongClick(View v) {
    // Return if global dragging is not enabled
    if (!mLauncher.isDraggingEnabled()) return true;

    Object tag = v.getTag();
    if (tag instanceof ShortcutInfo) {
        ShortcutInfo item = (ShortcutInfo) tag;
        if (!v.isInTouchMode()) {
            return false;
        }

        mLauncher.getWorkspace().onDragStartedWithItem(v);
        mLauncher.getWorkspace().beginDragShared(v, this);

        mCurrentDragInfo = item;
        mEmptyCell[0] = item.cellX;
        mEmptyCell[1] = item.cellY;
        mCurrentDragView = v;

        mContent.removeView(mCurrentDragView);
        mInfo.remove(mCurrentDragInfo);
        mDragInProgress = true;
        mItemAddedBackToSelfViaIcon = false;
    }
    return true;
}
 
Example 7
Source File: Workspace.java    From TurboLauncher with Apache License 2.0 6 votes vote down vote up
void startDrag(CellLayout.CellInfo cellInfo) {
    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);

    child.clearFocus();
    child.setPressed(false);

    final Canvas canvas = new Canvas();

    // The outline is used to visualize where the item will land if dropped
    mDragOutline = createDragOutline(child, canvas, DRAG_BITMAP_PADDING);
    beginDragShared(child, this);
}
 
Example 8
Source File: Folder.java    From LB-Launcher with Apache License 2.0 6 votes vote down vote up
public boolean onLongClick(View v) {
    // Return if global dragging is not enabled
    if (!mLauncher.isDraggingEnabled()) return true;

    Object tag = v.getTag();
    if (tag instanceof ShortcutInfo) {
        ShortcutInfo item = (ShortcutInfo) tag;
        if (!v.isInTouchMode()) {
            return false;
        }

        mLauncher.getWorkspace().beginDragShared(v, this);

        mCurrentDragInfo = item;
        mEmptyCell[0] = item.cellX;
        mEmptyCell[1] = item.cellY;
        mCurrentDragView = v;

        mContent.removeView(mCurrentDragView);
        mInfo.remove(mCurrentDragInfo);
        mDragInProgress = true;
        mItemAddedBackToSelfViaIcon = false;
    }
    return true;
}
 
Example 9
Source File: AllAppsContainerView.java    From LaunchEnr with GNU General Public License v3.0 5 votes vote down vote up
@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 10
Source File: Folder.java    From LaunchEnr with GNU General Public License v3.0 5 votes vote down vote up
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 11
Source File: Workspace.java    From LaunchEnr with GNU General Public License v3.0 5 votes vote down vote up
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 12
Source File: WidgetsContainerView.java    From LaunchEnr with GNU General Public License v3.0 5 votes vote down vote up
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 13
Source File: MainActivity.java    From zapp with MIT License 5 votes vote down vote up
private void onSearchQueryTextFocusChangeListener(View searchView, boolean hasFocus) {
	if (hasFocus && !searchView.isInTouchMode()) {
		searchView.post(() -> {
			InputMethodManager imm = (InputMethodManager) MainActivity.this.getSystemService(Context.INPUT_METHOD_SERVICE);
			imm.showSoftInput(searchView.findFocus(), InputMethodManager.SHOW_FORCED);
		});
	}
}
 
Example 14
Source File: PagedViewWithDraggableItems.java    From TurboLauncher with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onLongClick(View v) {
    // Return early if this is not initiated from a touch
    if (!v.isInTouchMode()) return false;
    // Return early if we are still animating the pages
    if (mNextPage != INVALID_PAGE) return false;
    // When we have exited all apps or are in transition, disregard long clicks
    if (!mLauncher.isAllAppsVisible() ||
            mLauncher.getWorkspace().isSwitchingState()) return false;
    // Return if global dragging is not enabled
    if (!mLauncher.isDraggingEnabled()) return false;

    return beginDragging(v);
}
 
Example 15
Source File: PagedViewWithDraggableItems.java    From LB-Launcher with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onLongClick(View v) {
    // Return early if this is not initiated from a touch
    if (!v.isInTouchMode()) return false;
    // Return early if we are still animating the pages
    if (mNextPage != INVALID_PAGE) return false;
    // When we have exited all apps or are in transition, disregard long clicks
    if (!mLauncher.isAllAppsVisible() ||
            mLauncher.getWorkspace().isSwitchingState()) return false;
    // Return if global dragging is not enabled
    if (!mLauncher.isDraggingEnabled()) return false;

    return beginDragging(v);
}