[Android] Remove custom actions
Geoffrey Métais
git at videolan.org
Mon May 7 17:14:54 CEST 2018
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon May 7 16:25:18 2018 +0200| [760074d7001528271972952262932f427beebaee] | committer: Geoffrey Métais
Remove custom actions
Double press on play/pause is handled by library.
Long press is no longer valid, it triggers Assistant.
> https://code.videolan.org/videolan/vlc-android/commit/760074d7001528271972952262932f427beebaee
---
vlc-android/res/xml/preferences_audio.xml | 5 --
.../src/org/videolan/vlc/MediaSessionCallback.kt | 60 +---------------------
.../src/org/videolan/vlc/PlaybackService.kt | 2 -
.../vlc/gui/tv/preferences/PreferencesAudio.java | 1 -
4 files changed, 1 insertion(+), 67 deletions(-)
diff --git a/vlc-android/res/xml/preferences_audio.xml b/vlc-android/res/xml/preferences_audio.xml
index 338fd9790..8ebf49a79 100644
--- a/vlc-android/res/xml/preferences_audio.xml
+++ b/vlc-android/res/xml/preferences_audio.xml
@@ -34,11 +34,6 @@
<PreferenceCategory
android:title="@string/headset_prefs_category"
android:key="headset_prefs_category">
- <CheckBoxPreference
- android:defaultValue="true"
- android:key="enable_headset_actions"
- android:summary="@string/enable_headset_actions_summary"
- android:title="@string/enable_headset_actions_title" />
<CheckBoxPreference
android:defaultValue="true"
android:key="enable_headset_detection"
diff --git a/vlc-android/src/org/videolan/vlc/MediaSessionCallback.kt b/vlc-android/src/org/videolan/vlc/MediaSessionCallback.kt
index 7a5d8b81b..767c84d2e 100644
--- a/vlc-android/src/org/videolan/vlc/MediaSessionCallback.kt
+++ b/vlc-android/src/org/videolan/vlc/MediaSessionCallback.kt
@@ -1,14 +1,10 @@
package org.videolan.vlc
-import android.content.Intent
import android.net.Uri
import android.os.Bundle
-import android.os.SystemClock
import android.support.v4.media.session.MediaSessionCompat
import android.support.v4.media.session.PlaybackStateCompat
-import android.view.KeyEvent
import kotlinx.coroutines.experimental.launch
-import org.videolan.libvlc.util.AndroidUtil
import org.videolan.medialibrary.Tools
import org.videolan.medialibrary.media.MediaLibraryItem
import org.videolan.medialibrary.media.MediaWrapper
@@ -20,64 +16,10 @@ import org.videolan.vlc.util.VoiceSearchParams
import org.videolan.vlc.util.registerMedialibrary
internal class MediaSessionCallback(private val playbackService: PlaybackService) : MediaSessionCompat.Callback() {
- private var mHeadsetDownTime = 0L
- private var mHeadsetUpTime = 0L
-
- override fun onMediaButtonEvent(mediaButtonEvent: Intent): Boolean {
- if (!playbackService.settings.getBoolean("enable_headset_actions", true) || VLCApplication.showTvUi()) return false
- val event = mediaButtonEvent.getParcelableExtra<KeyEvent>(Intent.EXTRA_KEY_EVENT)
- if (event != null && !playbackService.isVideoPlaying) {
- val keyCode = event.keyCode
- if (keyCode == KeyEvent.KEYCODE_MEDIA_PLAY || keyCode == KeyEvent.KEYCODE_MEDIA_PAUSE
- || keyCode == KeyEvent.KEYCODE_HEADSETHOOK || keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE) {
- val time = SystemClock.uptimeMillis()
- when (event.action) {
- KeyEvent.ACTION_DOWN -> {
- if (event.repeatCount <= 0) mHeadsetDownTime = time
- if (!playbackService.hasMedia()) {
- PlaybackService.loadLastAudio(playbackService)
- return true
- }
- }
- KeyEvent.ACTION_UP -> if (AndroidDevices.hasTsp) { //no backward/forward on TV
- when {
- time - mHeadsetDownTime >= PlaybackService.DELAY_LONG_CLICK -> { // long click
- mHeadsetUpTime = time
- playbackService.previous(false)
- return true
- }
- time - mHeadsetUpTime <= PlaybackService.DELAY_DOUBLE_CLICK -> { // double click
- mHeadsetUpTime = time
- playbackService.next()
- return true
- }
- else -> {
- mHeadsetUpTime = time
- return false
- }
- }
- }
- }
- return false
- } else if (!AndroidUtil.isLolliPopOrLater) {
- when (keyCode) {
- KeyEvent.KEYCODE_MEDIA_NEXT -> {
- onSkipToNext()
- return true
- }
- KeyEvent.KEYCODE_MEDIA_PREVIOUS -> {
- onSkipToPrevious()
- return true
- }
- }
- }
- }
- return false
- }
override fun onPlay() {
if (playbackService.hasMedia()) playbackService.play()
- else PlaybackService.loadLastAudio(playbackService)
+ else if (!AndroidDevices.isAndroidTv) PlaybackService.loadLastAudio(playbackService)
}
override fun onCustomAction(action: String?, extras: Bundle?) {
diff --git a/vlc-android/src/org/videolan/vlc/PlaybackService.kt b/vlc-android/src/org/videolan/vlc/PlaybackService.kt
index 681893776..415fa3374 100644
--- a/vlc-android/src/org/videolan/vlc/PlaybackService.kt
+++ b/vlc-android/src/org/videolan/vlc/PlaybackService.kt
@@ -1305,8 +1305,6 @@ class PlaybackService : MediaBrowserServiceCompat() {
private const val SHOW_TOAST = 1
private const val END_MEDIASESSION = 2
- internal const val DELAY_DOUBLE_CLICK = 800L
- internal const val DELAY_LONG_CLICK = 1000L
fun getService(iBinder: IBinder): PlaybackService? {
val binder = iBinder as LocalBinder
return binder.service
diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/preferences/PreferencesAudio.java b/vlc-android/src/org/videolan/vlc/gui/tv/preferences/PreferencesAudio.java
index cea384f1a..7c35551e5 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/preferences/PreferencesAudio.java
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/preferences/PreferencesAudio.java
@@ -54,7 +54,6 @@ public class PreferencesAudio extends BasePreferenceFragment implements SharedPr
findPreference("enable_play_on_headset_insertion").setVisible(false);
findPreference("headset_prefs_category").setVisible(false);
findPreference("lockscreen_cover").setVisible(false);
- findPreference("enable_headset_actions").setVisible(false);
findPreference("audio_ducking").setVisible(!AndroidUtil.isOOrLater);
final HWDecoderUtil.AudioOutput aout = HWDecoderUtil.getAudioOutputFromDevice();
More information about the Android
mailing list