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

The following examples show how to use android.view.View#performHapticFeedback() . These examples are extracted from open source projects. 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 Project: Twire   File: ChatFragment.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Called from EmoteGridFragments when an Emote in the emotekeyboard has been clicked
 *
 * @param clickedEmote
 */
@Override
public void onEmoteClicked(Emote clickedEmote, View view) {
    view.performHapticFeedback(VIBRATION_FEEDBACK);

    if (clickedEmote != null) {
        int startPosition = mSendText.getSelectionStart();
        String emoteKeyword = clickedEmote.getKeyword();

        if (startPosition != 0 && mSendText.getText().charAt(startPosition - 1) != ' ') {
            emoteKeyword = " " + emoteKeyword;
        }

        mSendText.getText().insert(startPosition, emoteKeyword);

        if (recentEmotesFragment != null) {
            recentEmotesFragment.addEmote(clickedEmote);
        }
    }
}
 
Example 2
boolean performLongPress(final View child,
                         final int longPressPosition, final long longPressId) {
    // CHOICE_MODE_MULTIPLE_MODAL takes over long press.
    if (mChoiceMode == AbsListView.CHOICE_MODE_MULTIPLE_MODAL) {
        if (mChoiceActionMode == null) {
            setItemChecked(longPressPosition, true);
            child.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
        }
        return true;
    }

    boolean handled = false;
    if (mOnItemLongClickListener != null) {
        handled = mOnItemLongClickListener.onItemLongClick(this, child,
                longPressPosition, longPressId);
    }
    if (handled) {
        child.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
    }

    return handled;
}
 
Example 3
Source Project: RemoteControlView   File: Tools.java    License: Apache License 2.0 6 votes vote down vote up
public static void startDrag(View view){
    DraggableInfo tag = (DraggableInfo) view.getTag();
    if (tag == null){
        tag = new DraggableInfo("Text", 0, 0, 1);
    }
    Intent intent = new Intent();
    intent.putExtra("data", tag);
    ClipData dragData = ClipData.newIntent("value", intent);
    View.DragShadowBuilder myShadow = new View.DragShadowBuilder(view);
    // 震动反馈,不需要震动权限
    view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        view.startDragAndDrop(dragData, myShadow, null, 0);
    }else{
        view.startDrag(dragData, myShadow, null, 0);
    }
}
 
Example 4
@Override
public void onKey(final int primaryCode, final int[] keyCodes) {
    final Editable editable;
    final View view;
    if (mIsSixDigit) {
        editable = mPinEntryView.getText();
        view = mPinEntryView;
    } else {
        editable = mPinLongText.getEditableText();
        view = mPinLongText;
    }
    view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
    if (primaryCode >= 0 && primaryCode <= 9)
        editable.append(String.valueOf(primaryCode));
    else if (primaryCode == -2)
        clear();
    else if (primaryCode == -1)
        view.dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL));
}
 
Example 5
/**
 * Called from EmoteGridFragments when an Emote in the emotekeyboard has been clicked
 * @param clickedEmote
 */
@Override
public void onEmoteClicked(Emote clickedEmote, View view) {
	view.performHapticFeedback(VIBRATION_FEEDBACK);

	if (clickedEmote != null) {
		int startPosition = mSendText.getSelectionStart();
		String emoteKeyword = clickedEmote.getKeyword();

		if (startPosition != 0 && mSendText.getText().charAt(startPosition - 1) != ' ') {
			emoteKeyword = " " + emoteKeyword;
		}

		mSendText.getText().insert(startPosition, emoteKeyword);

		if (recentEmotesFragment != null) {
			recentEmotesFragment.addEmote(clickedEmote);
		}
	}
}
 
Example 6
private void growView(@NonNull View view) {
  view.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP);
  view.animate()
      .scaleY(1.5f)
      .scaleX(1.5f)
      .translationY(-selectedVerticalTranslation)
      .setDuration(200)
      .setInterpolator(INTERPOLATOR)
      .start();
}
 
Example 7
Source Project: Twire   File: ChatFragment.java    License: GNU General Public License v3.0 5 votes vote down vote up
private void emoteButtonClicked(View clickedView) {
    clickedView.performHapticFeedback(VIBRATION_FEEDBACK);

    if (hasSoftKeyboardBeenShown) {
        getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING);
    }

    if (!isEmoteKeyboardOpen) {
        if (!hasSoftKeyboardBeenShown) {
            Log.d(LOG_TAG, "SHOW SOFT KEYBOARD");
            hideKeyboardWhenShown = true;
            if (mSendText.requestFocus()) {
                openSoftKeyboard();
            }
        }

        showEmoteKeyboard();

    } else {
        if (isSoftKeyboardOpen) {
            closeSoftKeyboard();
        } else {
            getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING);
            openSoftKeyboard();
        }
    }
}
 
Example 8
public void performHapticFeedback(final View viewToPerformHapticFeedbackOn) {
    if (!mSettingsValues.mVibrateOn) {
        return;
    }
    if (mSettingsValues.mKeypressVibrationDuration >= 0) {
        vibrate(mSettingsValues.mKeypressVibrationDuration);
        return;
    }
    // Go ahead with the system default
    if (viewToPerformHapticFeedbackOn != null) {
        viewToPerformHapticFeedbackOn.performHapticFeedback(
                HapticFeedbackConstants.KEYBOARD_TAP,
                HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
    }
}
 
Example 9
Source Project: MultiView   File: ItemClickSupport.java    License: Apache License 2.0 5 votes vote down vote up
@Override
boolean performItemLongClick(RecyclerView parent, View view, int position, long id) {
    if (mItemLongClickListener != null) {
        view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
        return mItemLongClickListener.onItemLongClick(parent, view, position, id);
    }

    return false;
}
 
Example 10
Source Project: PhoneProfilesPlus   File: NumberPicker.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onClick(View v) {
    v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
    mError.hideImmediately();
    doOnClick(v);
    updateDeleteButtons();
}
 
Example 11
@Override
boolean performItemLongClick(RecyclerView parent, View view, int position, long id) {
    if (mItemLongClickListener != null) {
        view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
        return mItemLongClickListener.onItemLongClick(parent, view, position, id);
    }

    return false;
}
 
Example 12
Source Project: PlayWidget   File: ItemClickSupport.java    License: MIT License 5 votes vote down vote up
@Override
boolean performItemLongClick(RecyclerView parent, View view, int position, long id) {
    if (mItemLongClickListener != null) {
        view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
        return mItemLongClickListener.onItemLongClick(parent, view, position, id);
    }

    return false;
}
 
Example 13
public void onClick(View sender) {
    onPlay(mStartPos);
    sender.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
}
 
Example 14
Source Project: iBeebo   File: Utility.java    License: GNU General Public License v3.0 4 votes vote down vote up
public static void vibrate(Context context, View view) {
    // Vibrator vibrator = (Vibrator)
    // context.getSystemService(Context.VIBRATOR_SERVICE);
    // vibrator.vibrate(30);
    view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
}
 
Example 15
Source Project: SublimePicker   File: SUtils.java    License: Apache License 2.0 4 votes vote down vote up
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static void vibrateForDatePicker(View view) {
    // Using a different haptic feedback constant
    view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY
                                 /*(5) - HapticFeedbackConstants.CALENDAR_DATE*/);
}
 
Example 16
Source Project: TurboLauncher   File: Launcher.java    License: Apache License 2.0 4 votes vote down vote up
public void onTouchDownAllAppsButton(View v) {
	// Provide the same haptic feedback that the system offers for virtual
	// keys.
	v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
}
 
Example 17
Source Project: iBeebo   File: Utility.java    License: GNU General Public License v3.0 4 votes vote down vote up
public static void vibrate(Context context, View view) {
    // Vibrator vibrator = (Vibrator)
    // context.getSystemService(Context.VIBRATOR_SERVICE);
    // vibrator.vibrate(30);
    view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
}
 
Example 18
/**
 * @see #showWidget(com.achep.acdisplay.ui.components.Widget)
 */
protected void showWidget(@NonNull Widget widget, boolean animate) {
    mHandler.removeMessages(MSG_SHOW_HOME_WIDGET);
    mHasPinnedWidget = false;

    Log.d(TAG, "showing widget " + widget);

    View iconView;

    if (mSelectedWidget != null) {
        iconView = mSelectedWidget.getIconView();
        if (iconView != null) {
            iconView.setSelected(false);
        }

        mSelectedWidget.onViewDetached();
    }

    mSelectedWidget = widget;
    resetSceneContainerParams();
    animate &= isAnimatableAuto();

    SceneCompat scene = findSceneByWidget(mSelectedWidget);
    if (scene == null) scene = mSceneMainClock;
    if (mCurrentScene != scene) {
        goScene(scene, animate);
    } else if (animate) {
        final ViewGroup viewGroup = mSelectedWidget.getView();
        maybeBeginDelayedTransition(viewGroup, mTransitionJit);
    }

    mSelectedWidget.onViewAttached();
    mBackground.dispatchSetBackground(
            mSelectedWidget.getBackground(),
            mSelectedWidget.getBackgroundMask());
    updateStatusClockVisibility(!mSelectedWidget.hasClock() && getConfig().isFullScreen());

    iconView = mSelectedWidget.getIconView();
    if (iconView != null) {
        iconView.setSelected(true);
        iconView.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
    }

    if (!isResumed()) {
        return;
    }

    // Start timeout on main or media widgets, and
    // pause it otherwise.
    if (widget.isHomeWidget()) {
        mTimeout.resume();
    } else {
        mTimeout.setTimeoutDelayed(mTimeoutNormal, true);
        mTimeout.pause();
    }
}
 
Example 19
Source Project: journaldev   File: RecyclerViewAdapter.java    License: MIT License 4 votes vote down vote up
@Override
public boolean onLongClick(View view) {
    listener.onRowLongClicked(getAdapterPosition());
    view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
    return true;
}
 
Example 20
Source Project: TurboLauncher   File: Launcher.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Event handler for the search button
 * 
 * @param v
 *            The view that was clicked.
 */
public void onClickSearchButton(View v) {

	v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
	onSearchRequested();
}