List of usage examples for android.view HapticFeedbackConstants LONG_PRESS
int LONG_PRESS
To view the source code for android.view HapticFeedbackConstants LONG_PRESS.
Click Source Link
From source file:com.klinker.android.launcher.launcher3.Launcher.java
public boolean onLongClick(View v) { lockLauncherDrawer(true);// www . ja va 2s .c o m if (!isDraggingEnabled()) return false; if (isWorkspaceLocked()) return false; if (mState != State.WORKSPACE) return false; if (v == mAllAppsButton) { onLongClickAllAppsButton(v); return true; } if (v instanceof Workspace) { if (!mWorkspace.isInOverviewMode()) { if (!mWorkspace.isTouchActive()) { showOverviewMode(true); mWorkspace.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS, HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING); return true; } else { return false; } } else { return false; } } CellLayout.CellInfo longClickCellInfo = null; View itemUnderLongClick = null; if (v.getTag() instanceof ItemInfo) { ItemInfo info = (ItemInfo) v.getTag(); longClickCellInfo = new CellLayout.CellInfo(v, info); itemUnderLongClick = longClickCellInfo.cell; resetAddInfo(); } // The hotseat touch handling does not go through Workspace, and we always allow long press // on hotseat items. final boolean inHotseat = isHotseatLayout(v); if (!mDragController.isDragging()) { if (itemUnderLongClick == null) { // User long pressed on empty space mWorkspace.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS, HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING); if (mWorkspace.isInOverviewMode()) { mWorkspace.startReordering(v); } else { showOverviewMode(true); } } else { final boolean isAllAppsButton = inHotseat && isAllAppsButtonRank( mHotseat.getOrderInHotseat(longClickCellInfo.cellX, longClickCellInfo.cellY)); if (!(itemUnderLongClick instanceof Folder || isAllAppsButton)) { // User long pressed on an item mWorkspace.startDrag(longClickCellInfo); } } } return true; }
From source file:g7.bluesky.launcher3.Launcher.java
public boolean onLongClick(View v) { if (!isDraggingEnabled()) return false; if (isWorkspaceLocked()) return false; if (mState != State.WORKSPACE) return false; if (LOGD)/*from w w w . j ava 2 s . c om*/ Log.d(TAG, "onLongClick"); if (v instanceof Workspace) { if (!mWorkspace.isInOverviewMode()) { if (mWorkspace.enterOverviewMode()) { mWorkspace.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS, HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING); return true; } else { return false; } } else { return false; } } CellLayout.CellInfo longClickCellInfo = null; View itemUnderLongClick = null; if (v.getTag() instanceof ItemInfo) { ItemInfo info = (ItemInfo) v.getTag(); longClickCellInfo = new CellLayout.CellInfo(v, info); ; itemUnderLongClick = longClickCellInfo.cell; resetAddInfo(); } // The hotseat touch handling does not go through Workspace, and we always allow long press // on hotseat items. final boolean inHotseat = isHotseatLayout(v); boolean allowLongPress = inHotseat || mWorkspace.allowLongPress(); if (allowLongPress && !mDragController.isDragging()) { if (itemUnderLongClick == null) { // User long pressed on empty space mWorkspace.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS, HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING); if (mWorkspace.isInOverviewMode()) { mWorkspace.startReordering(v); } else { mWorkspace.enterOverviewMode(); } } else { final boolean isAllAppsButton = inHotseat && isAllAppsButtonRank( mHotseat.getOrderInHotseat(longClickCellInfo.cellX, longClickCellInfo.cellY)); if (!(itemUnderLongClick instanceof Folder || isAllAppsButton)) { // User long pressed on an item mWorkspace.startDrag(longClickCellInfo); } } } return true; }
From source file:com.android.launcher3.Launcher.java
@Override public boolean onLongClick(View v) { if (!isDraggingEnabled()) return false; if (isWorkspaceLocked()) return false; if (mState != State.WORKSPACE) return false; if (creation != null) creation.clearAllLayout();//w w w. jav a 2 s . c om if ((FeatureFlags.LAUNCHER3_ALL_APPS_PULL_UP && v instanceof PageIndicator) || (v == mAllAppsButton && mAllAppsButton != null)) { onLongClickAllAppsButton(v); return true; } if (v instanceof Workspace) { if (!mWorkspace.isInOverviewMode()) { if (!mWorkspace.isTouchActive()) { showOverviewMode(true); mWorkspace.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS, HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING); return true; } else { return false; } } else { return false; } } CellLayout.CellInfo longClickCellInfo = null; View itemUnderLongClick = null; if (v.getTag() instanceof ItemInfo) { ItemInfo info = (ItemInfo) v.getTag(); longClickCellInfo = new CellLayout.CellInfo(v, info); itemUnderLongClick = longClickCellInfo.cell; mPendingRequestArgs = null; } // The hotseat touch handling does not go through Workspace, and we always allow long press // on hotseat items. if (!mDragController.isDragging()) { if (itemUnderLongClick == null) { // User long pressed on empty space mWorkspace.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS, HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING); if (mWorkspace.isInOverviewMode()) { mWorkspace.startReordering(v); } else { showOverviewMode(true); } } else { final boolean isAllAppsButton = !FeatureFlags.NO_ALL_APPS_ICON && isHotseatLayout(v) && mDeviceProfile.inv.isAllAppsButtonRank( mHotseat.getOrderInHotseat(longClickCellInfo.cellX, longClickCellInfo.cellY)); if (!(itemUnderLongClick instanceof Folder || isAllAppsButton)) { // User long pressed on an item DragOptions dragOptions = new DragOptions(); if (itemUnderLongClick instanceof BubbleTextView) { BubbleTextView icon = (BubbleTextView) itemUnderLongClick; if (icon.hasDeepShortcuts()) { DeepShortcutsContainer dsc = DeepShortcutsContainer.showForIcon(icon); if (dsc != null) { dragOptions.deferDragCondition = dsc.createDeferDragCondition(null); } } } int positionInGrid = mHotseat.getOrderInHotseat(longClickCellInfo.cellX, longClickCellInfo.cellY); List<Shortcuts> shortcutses = new ArrayList<Shortcuts>(); if (creation != null) creation.clearAllLayout(); mWorkspace.startDrag(longClickCellInfo, dragOptions); //Get selected app info final Object tag = v.getTag(); final ShortcutInfo shortcut; try { shortcut = (ShortcutInfo) tag; Drawable icon; if (Utilities.loadBitmapPref(Launcher.getLauncherActivity(), shortcut.getTargetComponent().getPackageName()) != null) { icon = new BitmapDrawable(activity.getResources(), Utilities.loadBitmapPref(activity, shortcut.getTargetComponent().getPackageName())); } else { icon = new BitmapDrawable(activity.getResources(), shortcut.getIcon(new IconCache(Launcher.this, getDeviceProfile().inv))); } shortcutses = ShortcutsManager.getShortcutsBasedOnTag(Launcher.this.getApplicationContext(), Launcher.this, shortcut, icon); ShortcutsBuilder builder = new ShortcutsBuilder.Builder(this, masterLayout) .launcher3Shortcuts(gridSize, positionInGrid, (int) v.getY(), v.getBottom(), Hotseat.isHotseatTouched, Utilities.getDockSizeDefaultValue(getApplicationContext())) .setOptionLayoutStyle(StyleOption.NONE).setPackageImage(icon) .setShortcutsList(shortcutses).build(); creation = new ShortcutsCreation(builder); creation.init(); Hotseat.isHotseatTouched = false; } catch (ClassCastException e) { Log.e(TAG, "Clicked on Folder/Widget!"); positionInGrid = mHotseat.getOrderInHotseat(longClickCellInfo.cellX, longClickCellInfo.cellY); try { //Get selected folder info final View f = v; final Object tagF = v.getTag(); final FolderInfo folder; folder = (FolderInfo) tagF; shortcutses = new ArrayList<Shortcuts>(); shortcutses.add(new Shortcuts(R.drawable.ic_folder_open_black_24dp, getString(R.string.folder_open), new OnClickListener() { @Override public void onClick(View view) { if (f instanceof FolderIcon) { onClickFolderIcon(f); creation.clearAllLayout(); } } })); shortcutses.add(new Shortcuts(R.drawable.ic_title_black_24dp, getString(R.string.folder_rename), new OnClickListener() { @Override public void onClick(View view) { if (f instanceof FolderIcon) { AlertDialog.Builder alert = new AlertDialog.Builder( new ContextThemeWrapper(Launcher.this, R.style.AlertDialogCustom)); LinearLayout layout = new LinearLayout(getApplicationContext()); layout.setOrientation(LinearLayout.VERTICAL); layout.setPadding(100, 50, 100, 100); final EditText titleBox = new EditText(Launcher.this); titleBox.getBackground().mutate() .setColorFilter( ContextCompat.getColor(getApplicationContext(), R.color.colorPrimary), PorterDuff.Mode.SRC_ATOP); alert.setMessage(getString(R.string.folder_title)); alert.setTitle(getString(R.string.folder_enter_title)); layout.addView(titleBox); alert.setView(layout); alert.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { folder.setTitle(titleBox.getText().toString()); LauncherModel.updateItemInDatabase( Launcher.getLauncherActivity(), folder); } }); alert.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { creation.clearAllLayout(); } }); alert.show(); creation.clearAllLayout(); } } })); ShortcutsBuilder builder = new ShortcutsBuilder.Builder(this, masterLayout) .launcher3Shortcuts(gridSize, positionInGrid, (int) v.getY(), v.getBottom(), Hotseat.isHotseatTouched, Utilities.getDockSizeDefaultValue(getApplicationContext())) .setOptionLayoutStyle(0) .setPackageImage( ContextCompat.getDrawable(Launcher.this, R.mipmap.ic_launcher_home)) .setShortcutsList(shortcutses).build(); creation = new ShortcutsCreation(builder); creation.init(); } catch (ClassCastException ee) { } } } } } return true; }
From source file:com.aliasapps.seq.scroller.TwoWayView.java
private boolean performLongPress(final View child, final int longPressPosition, final long longPressId) { // CHOICE_MODE_MULTIPLE_MODAL takes over long press. boolean handled = false; OnItemLongClickListener listener = getOnItemLongClickListener(); if (listener != null) { handled = listener.onItemLongClick(TwoWayView.this, child, longPressPosition, longPressId); }/*w w w . j av a 2 s . co m*/ if (!handled) { mContextMenuInfo = createContextMenuInfo(child, longPressPosition, longPressId); handled = super.showContextMenuForChild(TwoWayView.this); } if (handled) { performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); } return handled; }
From source file:com.runmit.sweedee.view.DirectListView.java
private boolean performLongPress(final View child, final int longPressPosition, final long longPressId) { // CHOICE_MODE_MULTIPLE_MODAL takes over long press. boolean handled = false; OnItemLongClickListener listener = getOnItemLongClickListener(); if (listener != null) { handled = listener.onItemLongClick(DirectListView.this, child, longPressPosition, longPressId); }/* w w w . j a v a 2 s . c om*/ if (!handled) { mContextMenuInfo = createContextMenuInfo(child, longPressPosition, longPressId); handled = super.showContextMenuForChild(DirectListView.this); } if (handled) { performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); } return handled; }
From source file:com.ruyigu.freeart.ui.widget.HorizontalListView.java
private boolean performLongPress(final View child, final int longPressPosition, final long longPressId) { // CHOICE_MODE_MULTIPLE_MODAL takes over long press. boolean handled = false; OnItemLongClickListener listener = getOnItemLongClickListener(); if (listener != null) { handled = listener.onItemLongClick(HorizontalListView.this, child, longPressPosition, longPressId); }/* www . j a va2 s. c o m*/ if (!handled) { mContextMenuInfo = createContextMenuInfo(child, longPressPosition, longPressId); handled = super.showContextMenuForChild(HorizontalListView.this); } if (handled) { performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); } return handled; }
From source file:com.artifex.mupdf.view.ThumbnailViews.java
private boolean performLongPress(final View child, final int longPressPosition, final long longPressId) { // CHOICE_MODE_MULTIPLE_MODAL takes over long press. boolean handled = false; OnItemLongClickListener listener = getOnItemLongClickListener(); if (listener != null) { handled = listener.onItemLongClick(ThumbnailViews.this, child, longPressPosition, longPressId); }// www. j av a2 s . c om if (!handled) { mContextMenuInfo = createContextMenuInfo(child, longPressPosition, longPressId); handled = super.showContextMenuForChild(ThumbnailViews.this); } if (handled) { performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); } return handled; }