Skip to content

Commit

Permalink
Removed vibration on key release
Browse files Browse the repository at this point in the history
  • Loading branch information
Drumber committed Aug 12, 2023
1 parent 8e5f51b commit a9204cb
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 12 deletions.
2 changes: 1 addition & 1 deletion app/src/main/java/org/xbmc/kore/ui/widgets/ControlPad.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ private void setupListeners(Context context) {
buttonInAnim, buttonOutAnim, getContext());

OnTouchListener feedbackTouchListener = (v, event) -> {
UIUtils.handleVibration(context, v, event.getAction());
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
UIUtils.handleVibration(context, v);
buttonInAnim.setFillAfter(true);
v.startAnimation(buttonInAnim);
break;
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/org/xbmc/kore/utils/RepeatListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ public RepeatListener(int initialInterval, int repeatInterval, View.OnClickListe
* @return Wether the event was consumed
*/
public boolean onTouch(View view, MotionEvent motionEvent) {
UIUtils.handleVibration(context, view, motionEvent.getAction());
switch (motionEvent.getAction()) {
case MotionEvent.ACTION_DOWN:
UIUtils.handleVibration(context, view);
repeatHandler.removeCallbacks(handlerRunnable);
if (initialInterval >= 0) {
repeatHandler.postDelayed(handlerRunnable, initialInterval);
Expand Down
12 changes: 2 additions & 10 deletions app/src/main/java/org/xbmc/kore/utils/UIUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.os.Build;
import android.os.Handler;
import android.os.Vibrator;
import android.text.Spannable;
Expand All @@ -39,7 +38,6 @@
import android.util.DisplayMetrics;
import android.view.HapticFeedbackConstants;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewTreeObserver;
import android.view.WindowManager;
Expand Down Expand Up @@ -392,7 +390,7 @@ public static int changeColorAlpha(int color, int alpha)
return (alpha << 24) | (color & 0x00ffffff);
}

public static void handleVibration(Context context, View view, int action) {
public static void handleVibration(Context context, View view) {
if(context == null) return;

Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
Expand All @@ -404,13 +402,7 @@ public static void handleVibration(Context context, View view, int action) {
.getBoolean(Settings.KEY_PREF_VIBRATE_REMOTE_BUTTONS,
Settings.DEFAULT_PREF_VIBRATE_REMOTE_BUTTONS);
if (vibrateOnPress) {
if (action == MotionEvent.ACTION_DOWN) {
view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
} else if ((action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL)
&& Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1
) {
view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY_RELEASE);
}
view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
}
}

Expand Down

0 comments on commit a9204cb

Please sign in to comment.