From c0fb96a911c7c0464e26b78597e58aa96b19bde9 Mon Sep 17 00:00:00 2001 From: Alexander-- Date: Sat, 16 Nov 2019 13:05:59 +0659 Subject: [PATCH] Release seekbar on any confirmation key, not just DPAD_CENTER --- .../java/org/schabi/newpipe/util/FireTvUtils.java | 13 +++++++++++++ .../org/schabi/newpipe/views/FocusAwareSeekBar.java | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/schabi/newpipe/util/FireTvUtils.java b/app/src/main/java/org/schabi/newpipe/util/FireTvUtils.java index 879b54e1f..2c5090381 100644 --- a/app/src/main/java/org/schabi/newpipe/util/FireTvUtils.java +++ b/app/src/main/java/org/schabi/newpipe/util/FireTvUtils.java @@ -3,6 +3,7 @@ package org.schabi.newpipe.util; import android.annotation.SuppressLint; import android.content.pm.PackageManager; +import android.view.KeyEvent; import org.schabi.newpipe.App; public class FireTvUtils { @@ -15,4 +16,16 @@ public class FireTvUtils { return pm.hasSystemFeature(AMAZON_FEATURE_FIRE_TV) || pm.hasSystemFeature(PackageManager.FEATURE_LEANBACK); } + + public static boolean isConfirmKey(int keyCode) { + switch (keyCode) { + case KeyEvent.KEYCODE_DPAD_CENTER: + case KeyEvent.KEYCODE_ENTER: + case KeyEvent.KEYCODE_SPACE: + case KeyEvent.KEYCODE_NUMPAD_ENTER: + return true; + default: + return false; + } + } } diff --git a/app/src/main/java/org/schabi/newpipe/views/FocusAwareSeekBar.java b/app/src/main/java/org/schabi/newpipe/views/FocusAwareSeekBar.java index 3789ea344..dafd5ae6f 100644 --- a/app/src/main/java/org/schabi/newpipe/views/FocusAwareSeekBar.java +++ b/app/src/main/java/org/schabi/newpipe/views/FocusAwareSeekBar.java @@ -25,6 +25,7 @@ import android.view.ViewTreeObserver; import android.widget.SeekBar; import androidx.appcompat.widget.AppCompatSeekBar; +import org.schabi.newpipe.util.FireTvUtils; /** * SeekBar, adapted for directional navigation. It emulates touch-related callbacks @@ -57,7 +58,7 @@ public final class FocusAwareSeekBar extends AppCompatSeekBar { @Override public boolean onKeyDown(int keyCode, KeyEvent event) { - if (!isInTouchMode() && keyCode == KeyEvent.KEYCODE_DPAD_CENTER) { + if (!isInTouchMode() && FireTvUtils.isConfirmKey(keyCode)) { releaseTrack(); }