Release seekbar on any confirmation key, not just DPAD_CENTER

This commit is contained in:
Alexander-- 2019-11-16 13:05:59 +06:59
parent a1e02f7704
commit c0fb96a911
2 changed files with 15 additions and 1 deletions

View File

@ -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;
}
}
}

View File

@ -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();
}