From git at videolan.org Mon Aug 5 09:34:59 2024 From: git at videolan.org (=?UTF-8?Q?Nicolas_Pomepuy?=) Date: Mon, 5 Aug 2024 11:34:59 +0200 (CEST) Subject: [Android] =?utf-8?q?Add_a_file_picker_to_the_settings_restoratio?= =?utf-8?q?n?= Message-ID: <20240805093459.0C98882E030@gitlab> vlc-android | branch: master | Nicolas Pomepuy | Thu Aug 1 09:51:43 2024 +0200| [dd503a38f27d564b4b648b6f7634f5df8a08bf2a] | committer: Nicolas Pomepuy Add a file picker to the settings restoration > https://code.videolan.org/videolan/vlc-android/commit/dd503a38f27d564b4b648b6f7634f5df8a08bf2a --- .../ui/preferences/PreferencesAdvanced.kt | 31 +++++++++++-- .../src/org/videolan/vlc/gui/helpers/UiTools.kt | 5 +- .../vlc/gui/preferences/PreferencesAdvanced.kt | 32 +++++++++++-- .../vlc/gui/preferences/search/PreferenceParser.kt | 54 ++++++++++------------ .../videolan/vlc/providers/FilePickerProvider.kt | 5 +- .../src/org/videolan/vlc/util/FileUtils.kt | 8 ++++ 6 files changed, 93 insertions(+), 42 deletions(-) Diff: https://code.videolan.org/videolan/vlc-android/commit/dd503a38f27d564b4b648b6f7634f5df8a08bf2a From git at videolan.org Mon Aug 5 09:34:58 2024 From: git at videolan.org (=?UTF-8?Q?Nicolas_Pomepuy?=) Date: Mon, 5 Aug 2024 11:34:58 +0200 (CEST) Subject: [Android] =?utf-8?q?Import_and_restore_app=27s_settings?= Message-ID: <20240805093458.F198E82E00D@gitlab> vlc-android | branch: master | Nicolas Pomepuy | Tue Jul 30 09:51:44 2024 +0200| [cde7543371685cc4956bd20ce47b5b2dd847a240] | committer: Nicolas Pomepuy Import and restore app's settings > https://code.videolan.org/videolan/vlc-android/commit/cde7543371685cc4956bd20ce47b5b2dd847a240 --- .../main/java/org/videolan/resources/Constants.kt | 3 +- .../resources/src/main/res/values/strings.xml | 6 ++ .../ui/preferences/PreferencesAdvanced.kt | 19 ++++ .../vlc-android/res/xml/preferences_adv.xml | 14 ++- .../vlc/gui/preferences/PreferencesActivity.kt | 2 +- .../vlc/gui/preferences/PreferencesAdvanced.kt | 19 ++++ .../vlc/gui/preferences/search/PreferenceParser.kt | 116 ++++++++++++++++++++- 7 files changed, 173 insertions(+), 6 deletions(-) Diff: https://code.videolan.org/videolan/vlc-android/commit/cde7543371685cc4956bd20ce47b5b2dd847a240 From git at videolan.org Mon Aug 5 09:34:58 2024 From: git at videolan.org (=?UTF-8?Q?Nicolas_Pomepuy?=) Date: Mon, 5 Aug 2024 11:34:58 +0200 (CEST) Subject: [Android] =?utf-8?q?Create_a_new_application_data_section_in_the?= =?utf-8?q?_advanced_settings?= Message-ID: <20240805093458.E7F1482E00C@gitlab> vlc-android | branch: master | Nicolas Pomepuy | Mon Jul 29 14:50:10 2024 +0200| [9d9bc1557ea693ddee74d5655e8cda1cad995f94] | committer: Nicolas Pomepuy Create a new application data section in the advanced settings > https://code.videolan.org/videolan/vlc-android/commit/9d9bc1557ea693ddee74d5655e8cda1cad995f94 --- .../resources/src/main/res/values/strings.xml | 1 + .../vlc-android/res/xml/preferences_adv.xml | 55 ++++++++++++---------- 2 files changed, 30 insertions(+), 26 deletions(-) diff --git a/application/resources/src/main/res/values/strings.xml b/application/resources/src/main/res/values/strings.xml index e9585d72fb..b05a1ff5fb 100644 --- a/application/resources/src/main/res/values/strings.xml +++ b/application/resources/src/main/res/values/strings.xml @@ -1274,4 +1274,5 @@ Device Connected device Device model + Application data diff --git a/application/vlc-android/res/xml/preferences_adv.xml b/application/vlc-android/res/xml/preferences_adv.xml index fed5d1d7d3..26f58d6663 100644 --- a/application/vlc-android/res/xml/preferences_adv.xml +++ b/application/vlc-android/res/xml/preferences_adv.xml @@ -33,39 +33,42 @@ android:singleLine="false" android:title="@string/http_user_agent"/> - - - - - - - - + + + + + + + + + + + vlc-android | branch: master | Nicolas Pomepuy | Tue Jul 30 11:26:45 2024 +0200| [ea23a14b734bb7a832da8929bd1c7d0a402a8f95] | committer: Nicolas Pomepuy Prevent vlc options to be exported/restored > https://code.videolan.org/videolan/vlc-android/commit/ea23a14b734bb7a832da8929bd1c7d0a402a8f95 --- .../src/org/videolan/vlc/gui/preferences/search/PreferenceParser.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/application/vlc-android/src/org/videolan/vlc/gui/preferences/search/PreferenceParser.kt b/application/vlc-android/src/org/videolan/vlc/gui/preferences/search/PreferenceParser.kt index 0fed427890..599fada8fa 100644 --- a/application/vlc-android/src/org/videolan/vlc/gui/preferences/search/PreferenceParser.kt +++ b/application/vlc-android/src/org/videolan/vlc/gui/preferences/search/PreferenceParser.kt @@ -86,7 +86,7 @@ object PreferenceParser { val changedSettings = ArrayList>() allPrefs.forEach { pref -> allSettings.forEach { setting -> - if (pref.key == setting.key) { + if (pref.key == setting.key && pref.key != "custom_libvlc_options") { setting.value?.let { if (!isSame(it, pref.defaultValue)) changedSettings.add(Pair(pref.key, it)) } @@ -272,7 +272,7 @@ object PreferenceParser { val allPrefs = parsePreferences(activity, parseUIPrefs = true) savedSettings?.forEach { entry -> allPrefs.forEach { - if (it.key == entry.key) { + if (it.key == entry.key && it.key != "custom_libvlc_options") { Log.i("PrefParser", "Restored: ${entry.key} -> ${entry.value}") newPrefs.putSingle(entry.key, if (entry.value is Double) (entry.value as Double).toInt() else entry.value) } From git at videolan.org Mon Aug 5 09:48:48 2024 From: git at videolan.org (=?UTF-8?Q?Nicolas_Pomepuy?=) Date: Mon, 5 Aug 2024 11:48:48 +0200 (CEST) Subject: [Android] =?utf-8?q?Remote_access=3A_fix_the_track=27s_artist_wh?= =?utf-8?q?en_it=27s_unknown?= Message-ID: <20240805094848.170D182E00C@gitlab> vlc-android | branch: master | Nicolas Pomepuy | Fri Aug 2 08:38:17 2024 +0200| [5125b72ce30768b835151e4f67c679fed91bc347] | committer: Duncan McNamara Remote access: fix the track's artist when it's unknown > https://code.videolan.org/videolan/vlc-android/commit/5125b72ce30768b835151e4f67c679fed91bc347 --- .../src/main/java/org/videolan/vlc/webserver/RemoteAccessRouting.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/webserver/src/main/java/org/videolan/vlc/webserver/RemoteAccessRouting.kt b/application/webserver/src/main/java/org/videolan/vlc/webserver/RemoteAccessRouting.kt index 179eed10dc..0b7ef52eba 100644 --- a/application/webserver/src/main/java/org/videolan/vlc/webserver/RemoteAccessRouting.kt +++ b/application/webserver/src/main/java/org/videolan/vlc/webserver/RemoteAccessRouting.kt @@ -481,7 +481,7 @@ fun Route.setupRouting(appContext: Context, scope: CoroutineScope) { val list = ArrayList() tracks.forEach { track -> - list.add(track.toPlayQueueItem()) + list.add(track.toPlayQueueItem(defaultArtist = appContext.getString(R.string.unknown_artist))) } val gson = Gson() call.respondText(gson.toJson(list)) From git at videolan.org Mon Aug 5 09:48:48 2024 From: git at videolan.org (=?UTF-8?Q?Nicolas_Pomepuy?=) Date: Mon, 5 Aug 2024 11:48:48 +0200 (CEST) Subject: [Android] =?utf-8?q?Remote_access=3A_fix_the_track=27s_artist_wh?= =?utf-8?q?en_it=27s_unknown_in_playlists?= Message-ID: <20240805094848.1E48582E00D@gitlab> vlc-android | branch: master | Nicolas Pomepuy | Fri Aug 2 09:23:44 2024 +0200| [22135a46f67d1d2df1828d280261cf187daf8907] | committer: Duncan McNamara Remote access: fix the track's artist when it's unknown in playlists > https://code.videolan.org/videolan/vlc-android/commit/22135a46f67d1d2df1828d280261cf187daf8907 --- .../src/main/java/org/videolan/vlc/webserver/RemoteAccessRouting.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/webserver/src/main/java/org/videolan/vlc/webserver/RemoteAccessRouting.kt b/application/webserver/src/main/java/org/videolan/vlc/webserver/RemoteAccessRouting.kt index 0b7ef52eba..5071a5682d 100644 --- a/application/webserver/src/main/java/org/videolan/vlc/webserver/RemoteAccessRouting.kt +++ b/application/webserver/src/main/java/org/videolan/vlc/webserver/RemoteAccessRouting.kt @@ -553,7 +553,7 @@ fun Route.setupRouting(appContext: Context, scope: CoroutineScope) { val list = ArrayList() playlist.tracks.forEach { track -> - list.add(track.toPlayQueueItem().apply { + list.add(track.toPlayQueueItem(defaultArtist = if (track.type == MediaWrapper.TYPE_AUDIO) appContext.getString(R.string.unknown_artist) else "").apply { if (track.type == MediaWrapper.TYPE_VIDEO) fileType = "video" }) } From git at videolan.org Mon Aug 5 12:04:32 2024 From: git at videolan.org (=?UTF-8?Q?Duncan_McNamara?=) Date: Mon, 5 Aug 2024 14:04:32 +0200 (CEST) Subject: [Android] =?utf-8?q?OrientationDelegate=3A_close_when_touch_out?= Message-ID: <20240805120432.600E982E00C@gitlab> vlc-android | branch: master | Duncan McNamara | Thu Jul 11 16:56:37 2024 +0200| [45979251ecc124da217164db7e4d315424257178] | committer: Nicolas Pomepuy OrientationDelegate: close when touch out Touching the screen outside of the delegate should close it, like the ResizeDelegate. > https://code.videolan.org/videolan/vlc-android/commit/45979251ecc124da217164db7e4d315424257178 --- .../src/org/videolan/vlc/gui/video/VideoPlayerOrientationDelegate.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerOrientationDelegate.kt b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerOrientationDelegate.kt index 053aa270ce..cd0d11f34b 100644 --- a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerOrientationDelegate.kt +++ b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerOrientationDelegate.kt @@ -86,6 +86,7 @@ class VideoPlayerOrientationDelegate(private val player: VideoPlayerActivity) { hideOrientationOverlay() } orientationList.adapter = orientationAdapter + orientationMainView.setOnClickListener { hideOrientationOverlay() } } } From git at videolan.org Mon Aug 5 12:13:44 2024 From: git at videolan.org (=?UTF-8?Q?Duncan_McNamara?=) Date: Mon, 5 Aug 2024 14:13:44 +0200 (CEST) Subject: [Android] =?utf-8?q?SafeMode=3A_add_videoplayer_lock_to_pin_lock?= Message-ID: <20240805121344.6C58682E00C@gitlab> vlc-android | branch: master | Duncan McNamara | Fri Jul 19 16:54:59 2024 +0200| [7d46b230413a1a227066a87923a9644f0768ce4a] | committer: Nicolas Pomepuy SafeMode: add videoplayer lock to pin lock Unlocking the video player should be protected by pin when safe mode is enabled. A kid with lock enabled wouldn't be able to leave the videoplayer. > https://code.videolan.org/videolan/vlc-android/commit/7d46b230413a1a227066a87923a9644f0768ce4a --- .../videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt index b5cf619549..5dda6864de 100644 --- a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt +++ b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt @@ -51,12 +51,16 @@ import androidx.core.net.toUri import androidx.core.view.children import androidx.databinding.DataBindingUtil import androidx.lifecycle.ViewModelProvider +import androidx.lifecycle.lifecycleScope import androidx.recyclerview.widget.ItemTouchHelper import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat import androidx.window.layout.FoldingFeature import com.google.android.material.textfield.TextInputLayout +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.launch +import kotlinx.coroutines.withContext import org.videolan.libvlc.util.AndroidUtil import org.videolan.medialibrary.interfaces.media.MediaWrapper import org.videolan.medialibrary.media.MediaWrapperImpl @@ -71,6 +75,7 @@ import org.videolan.vlc.gui.browser.KEY_MEDIA import org.videolan.vlc.gui.dialogs.VideoTracksDialog import org.videolan.vlc.gui.helpers.* import org.videolan.vlc.gui.helpers.UiTools.showVideoTrack +import org.videolan.vlc.gui.helpers.hf.checkPIN import org.videolan.vlc.gui.view.PlayerProgress import org.videolan.vlc.media.MediaUtils import org.videolan.vlc.util.* @@ -623,7 +628,15 @@ class VideoPlayerOverlayDelegate (private val player: VideoPlayerActivity) { hudBinding.orientationToggle.setOnLongClickListener(if (enabled) player else null) hudBinding.swipeToUnlock.setOnStartTouchingListener { showOverlayTimeout(VideoPlayerActivity.OVERLAY_INFINITE) } hudBinding.swipeToUnlock.setOnStopTouchingListener { showOverlayTimeout(Settings.videoHudDelay * 1000) } - hudBinding.swipeToUnlock.setOnUnlockListener { player.toggleLock() } + hudBinding.swipeToUnlock.setOnUnlockListener { + player.lifecycleScope.launch(Dispatchers.IO) { + if (!player.checkPIN()) + player.isLocked = false + withContext(Dispatchers.Main) { + player.toggleLock() + } + } + } } if (::hudRightBinding.isInitialized){ hudRightBinding.playerOverlayNavmenu.setOnClickListener(if (enabled) player else null) From git at videolan.org Mon Aug 5 12:21:23 2024 From: git at videolan.org (=?UTF-8?Q?Duncan_McNamara?=) Date: Mon, 5 Aug 2024 14:21:23 +0200 (CEST) Subject: [Android] =?utf-8?q?SafeMode=3A_remove_relock_button_when_disabl?= =?utf-8?q?ed?= Message-ID: <20240805122123.156E582E00C@gitlab> vlc-android | branch: master | Duncan McNamara | Fri Jul 19 15:24:14 2024 +0200| [4c9e2e274873cb5ebba096ce0d06f4ab42a38520] | committer: Nicolas Pomepuy SafeMode: remove relock button when disabled If the safe mode is unlocked, and then in the settings, disabled, the "re-lock" button would still stay visible. This removes it, if the setting is changed. > https://code.videolan.org/videolan/vlc-android/commit/4c9e2e274873cb5ebba096ce0d06f4ab42a38520 --- application/vlc-android/src/org/videolan/vlc/gui/BaseActivity.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/vlc-android/src/org/videolan/vlc/gui/BaseActivity.kt b/application/vlc-android/src/org/videolan/vlc/gui/BaseActivity.kt index 601bc407ab..c15ad4fddf 100644 --- a/application/vlc-android/src/org/videolan/vlc/gui/BaseActivity.kt +++ b/application/vlc-android/src/org/videolan/vlc/gui/BaseActivity.kt @@ -98,7 +98,7 @@ abstract class BaseActivity : AppCompatActivity() { override fun onPrepareOptionsMenu(menu: Menu?): Boolean { val relockItem = menu?.findItem(R.id.pin_relocked) if (relockItem != null) { - relockItem.isVisible = PinCodeDelegate.pinUnlocked.value == true + relockItem.isVisible = Settings.safeMode && PinCodeDelegate.pinUnlocked.value == true } val unlockItem = menu?.findItem(R.id.pin_unlock) if (unlockItem != null) { From git at videolan.org Mon Aug 5 12:28:59 2024 From: git at videolan.org (=?UTF-8?Q?Nicolas_Pomepuy?=) Date: Mon, 5 Aug 2024 14:28:59 +0200 (CEST) Subject: [Android] =?utf-8?q?Make_the_nightly_auto_update_an_opt-in_featu?= =?utf-8?q?re?= Message-ID: <20240805122859.60A0482E00C@gitlab> vlc-android | branch: master | Nicolas Pomepuy | Tue Jul 30 14:37:35 2024 +0200| [0f89dade09565df9ff1b8650d57483cf8056d0c3] | committer: Duncan McNamara Make the nightly auto update an opt-in feature Fixes #3076 > https://code.videolan.org/videolan/vlc-android/commit/0f89dade09565df9ff1b8650d57483cf8056d0c3 --- application/resources/src/main/res/values/strings.xml | 2 ++ .../vlc-android/src/org/videolan/vlc/gui/MainActivity.kt | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/application/resources/src/main/res/values/strings.xml b/application/resources/src/main/res/values/strings.xml index 07da889945..0f54e94fec 100644 --- a/application/resources/src/main/res/values/strings.xml +++ b/application/resources/src/main/res/values/strings.xml @@ -626,6 +626,8 @@ Install the nightly version Nightly builds are experimental versions updated everyday.\n\nExpect new features but also new bugs! Found version: %2$s - %1$s + You are running a nightly version. Would you like to periodically look for updates? + Auto update diff --git a/application/vlc-android/src/org/videolan/vlc/gui/MainActivity.kt b/application/vlc-android/src/org/videolan/vlc/gui/MainActivity.kt index d577d34a82..b091f59841 100644 --- a/application/vlc-android/src/org/videolan/vlc/gui/MainActivity.kt +++ b/application/vlc-android/src/org/videolan/vlc/gui/MainActivity.kt @@ -23,6 +23,7 @@ package org.videolan.vlc.gui import android.annotation.SuppressLint import android.annotation.TargetApi import android.app.Activity +import android.app.AlertDialog import android.content.Intent import android.os.Build import android.os.Bundle @@ -123,8 +124,20 @@ class MainActivity : ContentActivity(), } lifecycleScope.launch { + if (!BuildConfig.DEBUG) return at launch AutoUpdate.clean(this at MainActivity.application) if (!settings.getBoolean(KEY_SHOW_UPDATE, true)) return at launch + if (!settings.contains(KEY_SHOW_UPDATE)) { + AlertDialog.Builder(this at MainActivity) + .setTitle(resources.getString(R.string.update_nightly)) + .setMessage(resources.getString(R.string.update_nightly_alert)) + .setPositiveButton(R.string.yes){ _, _ -> + settings.putSingle(KEY_SHOW_UPDATE, true) + } + .setNegativeButton(R.string.no, null) + .show() + return at launch + } AutoUpdate.checkUpdate(this at MainActivity.application) {url, date -> val updateDialog = UpdateDialog().apply { arguments = bundleOf(UPDATE_URL to url, UPDATE_DATE to date.time) From git at videolan.org Mon Aug 5 12:28:59 2024 From: git at videolan.org (=?UTF-8?Q?Nicolas_Pomepuy?=) Date: Mon, 5 Aug 2024 14:28:59 +0200 (CEST) Subject: [Android] =?utf-8?q?Add_a_dedicated_setting_for_the_nightly_auto?= =?utf-8?q?_update_opt-in?= Message-ID: <20240805122859.68C5A82E00D@gitlab> vlc-android | branch: master | Nicolas Pomepuy | Mon Aug 5 11:38:18 2024 +0200| [60da867fe353437c6ac50209c3ac473e97c65757] | committer: Duncan McNamara Add a dedicated setting for the nightly auto update opt-in > https://code.videolan.org/videolan/vlc-android/commit/60da867fe353437c6ac50209c3ac473e97c65757 --- application/resources/src/main/res/values/strings.xml | 1 + .../org/videolan/television/ui/preferences/PreferencesAdvanced.kt | 2 ++ application/vlc-android/res/xml/preferences_adv.xml | 7 +++++++ .../src/org/videolan/vlc/gui/preferences/PreferencesAdvanced.kt | 2 ++ 4 files changed, 12 insertions(+) diff --git a/application/resources/src/main/res/values/strings.xml b/application/resources/src/main/res/values/strings.xml index 0f54e94fec..133370a883 100644 --- a/application/resources/src/main/res/values/strings.xml +++ b/application/resources/src/main/res/values/strings.xml @@ -628,6 +628,7 @@ Found version: %2$s - %1$s You are running a nightly version. Would you like to periodically look for updates? Auto update + Search for nightly update periodically diff --git a/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesAdvanced.kt b/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesAdvanced.kt index 54444b3964..baabb788db 100644 --- a/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesAdvanced.kt +++ b/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesAdvanced.kt @@ -66,6 +66,7 @@ import org.videolan.tools.BitmapCache import org.videolan.tools.DAV1D_THREAD_NUMBER import org.videolan.tools.Settings import org.videolan.tools.putSingle +import org.videolan.vlc.BuildConfig import org.videolan.vlc.MediaParsingService import org.videolan.vlc.R import org.videolan.vlc.gui.DebugLogActivity @@ -118,6 +119,7 @@ class PreferencesAdvanced : BasePreferenceFragment(), SharedPreferences.OnShared } return } + if (!BuildConfig.DEBUG) findPreference("show_update")?.isVisible = false super.onDisplayPreferenceDialog(preference) } diff --git a/application/vlc-android/res/xml/preferences_adv.xml b/application/vlc-android/res/xml/preferences_adv.xml index f298a28cf0..8882f94b02 100644 --- a/application/vlc-android/res/xml/preferences_adv.xml +++ b/application/vlc-android/res/xml/preferences_adv.xml @@ -132,6 +132,13 @@ android:key="nightly_install" android:title="@string/install_nightly"/> + + (InputFilter.LengthFilter(5)) it.setSelection(it.editableText.length) } + if (!BuildConfig.DEBUG) findPreference("show_update")?.isVisible = false } override fun onStart() { From git at videolan.org Mon Aug 5 12:28:59 2024 From: git at videolan.org (=?UTF-8?Q?Nicolas_Pomepuy?=) Date: Mon, 5 Aug 2024 14:28:59 +0200 (CEST) Subject: [Android] =?utf-8?q?Fix_the_logo_animation?= Message-ID: <20240805122859.6FFCD82E02D@gitlab> vlc-android | branch: master | Nicolas Pomepuy | Mon Aug 5 11:45:18 2024 +0200| [b6f375160eaa647f6212448a0819c5327c793bea] | committer: Duncan McNamara Fix the logo animation > https://code.videolan.org/videolan/vlc-android/commit/b6f375160eaa647f6212448a0819c5327c793bea --- .../src/org/videolan/vlc/gui/helpers/UiTools.kt | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/application/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.kt b/application/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.kt index fb93f16cec..5a13d3817f 100644 --- a/application/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.kt +++ b/application/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.kt @@ -41,6 +41,7 @@ import android.os.Handler import android.os.Looper import android.renderscript.* import android.text.TextUtils +import android.util.Log import android.view.* import android.view.animation.* import android.view.inputmethod.InputMethodManager @@ -83,6 +84,7 @@ import org.videolan.medialibrary.media.MediaLibraryItem import org.videolan.resources.* import org.videolan.resources.util.launchForeground import org.videolan.tools.* +import org.videolan.vlc.BuildConfig import org.videolan.vlc.BuildConfig.VLC_VERSION_NAME import org.videolan.vlc.MediaParsingService import org.videolan.vlc.R @@ -102,9 +104,11 @@ import org.videolan.vlc.util.LifecycleAwareScheduler import org.videolan.vlc.util.SchedulerCallback import org.videolan.vlc.util.ThumbnailsProvider import org.videolan.vlc.util.openLinkIfPossible +import java.security.SecureRandom import kotlin.math.min object UiTools { + private var logoAnimationRunning: Boolean = false var currentNightMode: Int = 0 private const val TAG = "VLC/UiTools" private var DEFAULT_COVER_VIDEO_DRAWABLE: BitmapDrawable? = null @@ -394,9 +398,12 @@ object UiTools { val logo = v.findViewById(R.id.logo) val konfettiView = v.findViewById(R.id.konfetti) logo.setOnClickListener { - logo.animate().rotationBy(360F).translationY(-24.dp.toFloat()).setDuration(600).setInterpolator(AccelerateDecelerateInterpolator()).withEndAction { + if (logoAnimationRunning) return at setOnClickListener + logoAnimationRunning = true + val iter = SecureRandom().nextInt(4) + 1 + logo.animate().rotationBy(360F * iter).translationY(-24.dp.toFloat()).setDuration(600 + (100L * iter)).setInterpolator(AccelerateDecelerateInterpolator()).withEndAction { logo.animate().translationY(0F).setStartDelay(75).setDuration(300).setInterpolator(OvershootInterpolator(3.0F)).withEndAction { - + logoAnimationRunning = false } konfettiView.build() .addColors(ContextCompat.getColor(activity, R.color.orange200), ContextCompat.getColor(activity, R.color.orange800), ContextCompat.getColor(activity, R.color.orange500)) @@ -409,7 +416,7 @@ object UiTools { .setPosition(logo.x + logo.width - 12.dp, logo.x + logo.width - 12.dp, logo.y + logo.height - 24.dp, logo.y + logo.height + 24.dp) .setRotationEnabled(false) .setDelay(275) - .burst(35) + .burst(iter * 30) konfettiView.build() .addColors(ContextCompat.getColor(activity, R.color.orange200), ContextCompat.getColor(activity, R.color.orange800), ContextCompat.getColor(activity, R.color.orange500)) .setDirection(180.0, 225.0) @@ -421,7 +428,7 @@ object UiTools { .setPosition(logo.x + 12.dp, logo.x + 12.dp, logo.y + logo.height - 24.dp, logo.y + logo.height + 24.dp) .setRotationEnabled(false) .setDelay(275) - .burst(35) + .burst(iter * 30) } } From git at videolan.org Tue Aug 6 06:46:13 2024 From: git at videolan.org (=?UTF-8?Q?Nicolas_Pomepuy?=) Date: Tue, 6 Aug 2024 08:46:13 +0200 (CEST) Subject: [Android] =?utf-8?q?Bump_the_Remote_access_hash?= Message-ID: <20240806064613.6B68B82E019@gitlab> vlc-android | branch: master | Nicolas Pomepuy | Mon Aug 5 14:58:30 2024 +0200| [62ac033e967813a757ee073244c1c76aa6cd1577] | committer: Nicolas Pomepuy Bump the Remote access hash > https://code.videolan.org/videolan/vlc-android/commit/62ac033e967813a757ee073244c1c76aa6cd1577 --- buildsystem/compile-remoteaccess.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildsystem/compile-remoteaccess.sh b/buildsystem/compile-remoteaccess.sh index a2452736ed..c0775f52f9 100755 --- a/buildsystem/compile-remoteaccess.sh +++ b/buildsystem/compile-remoteaccess.sh @@ -57,7 +57,7 @@ done ############################## diagnostic "Setting up the Remote Access project" - REMOTE_ACCESS_TESTED_HASH=28d9ae472bf7d0447970d8f19d3e8e5dc922d215 + REMOTE_ACCESS_TESTED_HASH=cad3379a2aa628a47a92a10b4a48a47c60310f93 REMOTE_ACCESS_REPOSITORY=https://code.videolan.org/videolan/remoteaccess : ${VLC_REMOTE_ACCESS_PATH:="$(pwd -P)/remoteaccess"} From git at videolan.org Wed Aug 7 13:41:51 2024 From: git at videolan.org (=?UTF-8?Q?Nicolas_Pomepuy?=) Date: Wed, 7 Aug 2024 15:41:51 +0200 (CEST) Subject: [Android] =?utf-8?q?Fix_soundfont_picker_not_working_on_TV?= Message-ID: <20240807134151.43FE482E010@gitlab> vlc-android | branch: master | Nicolas Pomepuy | Thu Aug 1 14:48:51 2024 +0200| [f20c417b644bb814f5b797a4aeeff1e5dcbc8838] | committer: Duncan McNamara Fix soundfont picker not working on TV > https://code.videolan.org/videolan/vlc-android/commit/f20c417b644bb814f5b797a4aeeff1e5dcbc8838 --- .../ui/preferences/BasePreferenceFragment.kt | 12 ++++++ .../ui/preferences/PreferencesAdvanced.kt | 6 --- .../television/ui/preferences/PreferencesAudio.kt | 43 +++++++++++++++++++++- 3 files changed, 54 insertions(+), 7 deletions(-) diff --git a/application/television/src/main/java/org/videolan/television/ui/preferences/BasePreferenceFragment.kt b/application/television/src/main/java/org/videolan/television/ui/preferences/BasePreferenceFragment.kt index f70fa49bc3..f8e60fefaa 100644 --- a/application/television/src/main/java/org/videolan/television/ui/preferences/BasePreferenceFragment.kt +++ b/application/television/src/main/java/org/videolan/television/ui/preferences/BasePreferenceFragment.kt @@ -24,14 +24,17 @@ package org.videolan.television.ui.preferences import android.app.Fragment +import android.content.Intent import android.os.Bundle import androidx.leanback.preference.LeanbackPreferenceFragment import androidx.preference.EditTextPreference import androidx.preference.Preference import androidx.preference.PreferenceDialogFragment +import org.videolan.television.ui.dialogs.ConfirmationTvActivity import org.videolan.vlc.R +const val RESTART_CODE = 10001 abstract class BasePreferenceFragment : LeanbackPreferenceFragment() { protected abstract fun getXml(): Int @@ -56,6 +59,15 @@ abstract class BasePreferenceFragment : LeanbackPreferenceFragment() { } else null } + override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { + super.onActivityResult(requestCode, resultCode, data) + if (requestCode == RESTART_CODE) { + if (resultCode == ConfirmationTvActivity.ACTION_ID_POSITIVE) { + android.os.Process.killProcess(android.os.Process.myPid()) + } + } + } + companion object { private const val DIALOG_FRAGMENT_TAG = "androidx.preference.PreferenceFragment.DIALOG" } diff --git a/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesAdvanced.kt b/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesAdvanced.kt index ca5766b028..dbdc910cc3 100644 --- a/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesAdvanced.kt +++ b/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesAdvanced.kt @@ -93,7 +93,6 @@ import java.io.File import java.io.IOException private const val FILE_PICKER_RESULT_CODE = 10000 -private const val RESTART_CODE = 10001 @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) class PreferencesAdvanced : BasePreferenceFragment(), SharedPreferences.OnSharedPreferenceChangeListener, CoroutineScope by MainScope() { override fun getXml(): Int { @@ -309,11 +308,6 @@ class PreferencesAdvanced : BasePreferenceFragment(), SharedPreferences.OnShared override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { super.onActivityResult(requestCode, resultCode, data) - if (requestCode == RESTART_CODE) { - if (resultCode == ConfirmationTvActivity.ACTION_ID_POSITIVE) { - android.os.Process.killProcess(android.os.Process.myPid()) - } - } if (data == null) return if (requestCode == FILE_PICKER_RESULT_CODE) { if (data.hasExtra(EXTRA_MRL)) { diff --git a/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesAudio.kt b/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesAudio.kt index 137e132745..cf59a61d60 100644 --- a/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesAudio.kt +++ b/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesAudio.kt @@ -23,7 +23,9 @@ package org.videolan.television.ui.preferences import android.annotation.TargetApi +import android.content.Intent import android.content.SharedPreferences +import android.net.Uri import android.os.Build import android.os.Bundle import android.text.InputFilter @@ -49,14 +51,21 @@ import org.videolan.tools.Settings import org.videolan.tools.putSingle import org.videolan.vlc.BuildConfig import org.videolan.vlc.R +import org.videolan.vlc.gui.browser.EXTRA_MRL +import org.videolan.vlc.gui.browser.FilePickerActivity +import org.videolan.vlc.gui.browser.KEY_PICKER_TYPE +import org.videolan.vlc.gui.helpers.UiTools import org.videolan.vlc.gui.helpers.restartMediaPlayer import org.videolan.vlc.isVLC4 +import org.videolan.vlc.media.MediaUtils +import org.videolan.vlc.providers.PickerType import org.videolan.vlc.util.LocaleUtil import java.text.DecimalFormat import java.text.DecimalFormatSymbols -import java.util.* +import java.util.Locale private const val TAG = "VLC/PreferencesAudio" +private const val FILE_PICKER_RESULT_CODE = 10000 @Suppress("DEPRECATION") @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) @@ -169,6 +178,38 @@ class PreferencesAudio : BasePreferenceFragment(), SharedPreferences.OnSharedPre } } + override fun onPreferenceTreeClick(preference: Preference): Boolean { + if (preference.key == null) return false + when (preference.key) { + "soundfont" -> { + val filePickerIntent = Intent(activity, FilePickerActivity::class.java) + filePickerIntent.putExtra(KEY_PICKER_TYPE, PickerType.SOUNDFONT.ordinal) + startActivityForResult( + filePickerIntent, + FILE_PICKER_RESULT_CODE + ) + } + } + + return super.onPreferenceTreeClick(preference) + } + + override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { + super.onActivityResult(requestCode, resultCode, data) + if (data == null) return + if (requestCode == FILE_PICKER_RESULT_CODE) { + if (data.hasExtra(EXTRA_MRL)) { + launch { + MediaUtils.useAsSoundFont(activity, Uri.parse(data.getStringExtra( + EXTRA_MRL + ))) + VLCInstance.restart() + } + UiTools.restartDialog(activity!!, true, RESTART_CODE, this) + } + } + } + private suspend fun restartLibVLC() { VLCInstance.restart() restartMediaPlayer() From git at videolan.org Wed Aug 7 13:41:51 2024 From: git at videolan.org (=?UTF-8?Q?Nicolas_Pomepuy?=) Date: Wed, 7 Aug 2024 15:41:51 +0200 (CEST) Subject: [Android] =?utf-8?q?Use_a_proper_confirmation_UI_for_TV_settings?= Message-ID: <20240807134151.3A95182E00F@gitlab> vlc-android | branch: master | Nicolas Pomepuy | Thu Aug 1 14:09:35 2024 +0200| [b08e97af98193c16414523b4e23775e33da9b949] | committer: Duncan McNamara Use a proper confirmation UI for TV settings > https://code.videolan.org/videolan/vlc-android/commit/b08e97af98193c16414523b4e23775e33da9b949 --- .../main/java/org/videolan/resources/Constants.kt | 1 + .../ui/preferences/PreferencesAdvanced.kt | 22 +++++++++---- .../src/org/videolan/vlc/gui/helpers/UiTools.kt | 37 +++++++++++++++++++--- 3 files changed, 48 insertions(+), 12 deletions(-) diff --git a/application/resources/src/main/java/org/videolan/resources/Constants.kt b/application/resources/src/main/java/org/videolan/resources/Constants.kt index 394cc0b76c..91dc6c0ef1 100644 --- a/application/resources/src/main/java/org/videolan/resources/Constants.kt +++ b/application/resources/src/main/java/org/videolan/resources/Constants.kt @@ -235,6 +235,7 @@ const val COMPATERROR_ACTIVITY = "org.videolan.vlc.gui.CompatErrorActivity" const val TV_SEARCH_ACTIVITY = "org.videolan.television.ui.SearchActivity" const val MOBILE_SEARCH_ACTIVITY = "org.videolan.vlc.gui.SearchActivity" const val TV_MAIN_ACTIVITY = "org.videolan.television.ui.MainTvActivity" +const val TV_CONFIRMATION_ACTIVITY = "org.videolan.television.ui.dialogs.ConfirmationTvActivity" const val MOBILE_MAIN_ACTIVITY = "org.videolan.vlc.gui.MainActivity" const val MOVIEPEDIA_ACTIVITY = "org.videolan.moviepedia.ui.MoviepediaActivity" const val TV_AUDIOPLAYER_ACTIVITY = "org.videolan.television.ui.audioplayer.AudioPlayerActivity" diff --git a/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesAdvanced.kt b/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesAdvanced.kt index baabb788db..ca5766b028 100644 --- a/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesAdvanced.kt +++ b/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesAdvanced.kt @@ -62,6 +62,7 @@ import org.videolan.resources.KEY_MEDIA_LAST_PLAYLIST_RESUME import org.videolan.resources.ROOM_DATABASE import org.videolan.resources.SCHEME_PACKAGE import org.videolan.resources.VLCInstance +import org.videolan.television.ui.dialogs.ConfirmationTvActivity import org.videolan.tools.BitmapCache import org.videolan.tools.DAV1D_THREAD_NUMBER import org.videolan.tools.Settings @@ -92,6 +93,7 @@ import java.io.File import java.io.IOException private const val FILE_PICKER_RESULT_CODE = 10000 +private const val RESTART_CODE = 10001 @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) class PreferencesAdvanced : BasePreferenceFragment(), SharedPreferences.OnSharedPreferenceChangeListener, CoroutineScope by MainScope() { override fun getXml(): Int { @@ -307,18 +309,24 @@ class PreferencesAdvanced : BasePreferenceFragment(), SharedPreferences.OnShared override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { super.onActivityResult(requestCode, resultCode, data) + if (requestCode == RESTART_CODE) { + if (resultCode == ConfirmationTvActivity.ACTION_ID_POSITIVE) { + android.os.Process.killProcess(android.os.Process.myPid()) + } + } if (data == null) return if (requestCode == FILE_PICKER_RESULT_CODE) { if (data.hasExtra(EXTRA_MRL)) { launch { - launch { - PreferenceParser.restoreSettings(activity, Uri.parse(data.getStringExtra( - EXTRA_MRL - ))) - } - VLCInstance.restart() + PreferenceParser.restoreSettings( + activity, Uri.parse( + data.getStringExtra( + EXTRA_MRL + ) + ) + ) } - UiTools.restartDialog(activity!!, true) + UiTools.restartDialog(activity!!, true, RESTART_CODE, this) } } } diff --git a/application/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.kt b/application/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.kt index 5a13d3817f..f07c3d83f5 100644 --- a/application/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.kt +++ b/application/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.kt @@ -64,6 +64,7 @@ import androidx.core.net.toUri import androidx.core.os.bundleOf import androidx.core.view.MenuItemCompat import androidx.databinding.BindingAdapter +import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentActivity import androidx.lifecycle.Lifecycle import androidx.lifecycle.findViewTreeLifecycleOwner @@ -811,11 +812,37 @@ object UiTools { } - fun restartDialog(context: Context, fromLeanback:Boolean = false) { - val builder = if (fromLeanback) AlertDialog.Builder(context, R.style.Theme_AppCompat) else AlertDialog.Builder(context) - builder - .setTitle(context.resources.getString(R.string.restart_vlc)) - .setMessage(context.resources.getString(R.string.restart_message)) + fun restartDialog( + activity: Activity, + fromLeanback: Boolean = false, + leanbackResultCode: Int = 0, + leanbackCaller: Any? = null + ) { + + if (fromLeanback) { + val intent = Intent(Intent.ACTION_VIEW).setClassName(activity, TV_CONFIRMATION_ACTIVITY) + + intent.putExtra( + "confirmation_dialog_title", + activity.getString(R.string.restart_vlc) + ) + intent.putExtra( + "confirmation_dialog_text", + activity.getString(R.string.restart_message) + ) + when (leanbackCaller) { + is Activity -> leanbackCaller.startActivityForResult(intent, leanbackResultCode) + is Fragment -> leanbackCaller.startActivityForResult(intent, leanbackResultCode) + is android.app.Fragment -> leanbackCaller.startActivityForResult(intent, leanbackResultCode) + else -> throw IllegalStateException("Invalid caller") + } + + return + } + + AlertDialog.Builder(activity) + .setTitle(activity.resources.getString(R.string.restart_vlc)) + .setMessage(activity.resources.getString(R.string.restart_message)) .setPositiveButton(R.string.restart_message_OK) { _, _ -> android.os.Process.killProcess(android.os.Process.myPid()) } .setNegativeButton(R.string.restart_message_Later, null) .create() From git at videolan.org Fri Aug 9 09:26:01 2024 From: git at videolan.org (=?UTF-8?Q?Nicolas_Pomepuy?=) Date: Fri, 9 Aug 2024 11:26:01 +0200 (CEST) Subject: [Android] =?utf-8?q?Fix_auto_update_denial?= Message-ID: <20240809092602.7C90F82E00C@gitlab> vlc-android | branch: master | Nicolas Pomepuy | Fri Aug 9 07:30:39 2024 +0200| [de2fb6bf784efaf6130bc045175d8baec85c022a] | committer: Nicolas Pomepuy Fix auto update denial > https://code.videolan.org/videolan/vlc-android/commit/de2fb6bf784efaf6130bc045175d8baec85c022a --- application/vlc-android/src/org/videolan/vlc/gui/MainActivity.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/application/vlc-android/src/org/videolan/vlc/gui/MainActivity.kt b/application/vlc-android/src/org/videolan/vlc/gui/MainActivity.kt index b091f59841..8aa47b292b 100644 --- a/application/vlc-android/src/org/videolan/vlc/gui/MainActivity.kt +++ b/application/vlc-android/src/org/videolan/vlc/gui/MainActivity.kt @@ -134,7 +134,9 @@ class MainActivity : ContentActivity(), .setPositiveButton(R.string.yes){ _, _ -> settings.putSingle(KEY_SHOW_UPDATE, true) } - .setNegativeButton(R.string.no, null) + .setNegativeButton(R.string.no){ _, _ -> + settings.putSingle(KEY_SHOW_UPDATE, false) + } .show() return at launch } From git at videolan.org Tue Aug 13 08:29:09 2024 From: git at videolan.org (=?UTF-8?Q?Duncan_McNamara?=) Date: Tue, 13 Aug 2024 10:29:09 +0200 (CEST) Subject: [Android] =?utf-8?q?PiP=3A_set_isInPipMode_to_false_in_onStop?= Message-ID: <20240813082909.D5E6982E002@gitlab> vlc-android | branch: master | Duncan McNamara | Mon Aug 12 15:59:39 2024 +0200| [9fa78fb6d8e40fa77322912857a73b760f3f5416] | committer: Nicolas Pomepuy PiP: set isInPipMode to false in onStop Pressing the stop / cross button on pip to stop the PiP player will stop PiP but not set the liveData value to false. This causes StartActivity to restart the video player when re-opening the app after killing the pip player, and can cause the HUD not to show > https://code.videolan.org/videolan/vlc-android/commit/9fa78fb6d8e40fa77322912857a73b760f3f5416 --- .../vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt index 6c2a8d041a..705a5ca125 100644 --- a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt +++ b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt @@ -917,6 +917,7 @@ open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback, cleanUI() stopPlayback() service?.playlistManager?.videoStatsOn?.postValue(false) + service?.isInPiPMode?.value = false if (savedTime != -1L) settings.putSingle(VIDEO_RESUME_TIME, savedTime) From git at videolan.org Tue Aug 13 16:56:02 2024 From: git at videolan.org (=?UTF-8?Q?Nicolas_Pomepuy?=) Date: Tue, 13 Aug 2024 18:56:02 +0200 (CEST) Subject: [Android] =?utf-8?q?Remote_access=3A_send_a_403_error_for_long_p?= =?utf-8?q?olling_when_playback_control_is_disabled?= Message-ID: <20240813165602.5FF1F82E028@gitlab> vlc-android | branch: master | Nicolas Pomepuy | Mon Aug 5 09:19:47 2024 +0200| [a0730ac6bb34a50e4bb9a44d98d82e1fa89b6246] | committer: Duncan McNamara Remote access: send a 403 error for long polling when playback control is disabled > https://code.videolan.org/videolan/vlc-android/commit/a0730ac6bb34a50e4bb9a44d98d82e1fa89b6246 --- .../videolan/vlc/webserver/RemoteAccessRouting.kt | 8 +++- .../webserver/websockets/RemoteAccessWebSockets.kt | 53 ++++++++++++++-------- 2 files changed, 39 insertions(+), 22 deletions(-) diff --git a/application/webserver/src/main/java/org/videolan/vlc/webserver/RemoteAccessRouting.kt b/application/webserver/src/main/java/org/videolan/vlc/webserver/RemoteAccessRouting.kt index de85cbc2c5..d345637507 100644 --- a/application/webserver/src/main/java/org/videolan/vlc/webserver/RemoteAccessRouting.kt +++ b/application/webserver/src/main/java/org/videolan/vlc/webserver/RemoteAccessRouting.kt @@ -442,7 +442,8 @@ fun Route.setupRouting(appContext: Context, scope: CoroutineScope) { get("/longpolling") { //Empty the queue if needed if (RemoteAccessWebSockets.messageQueue.isNotEmpty()) { - call.respondText(Gson().toJson(RemoteAccessWebSockets.messageQueue)) + val queue = RemoteAccessWebSockets.messageQueue.toArray() + call.respondText(Gson().toJson(queue)) RemoteAccessWebSockets.messageQueue.clear() return at get } @@ -465,7 +466,10 @@ fun Route.setupRouting(appContext: Context, scope: CoroutineScope) { call.request.queryParameters["message"]?.let { message -> val id = call.request.queryParameters["id"]?.toInt() val authTicket = call.request.queryParameters["authTicket"] - RemoteAccessWebSockets.manageIncomingMessages(WSIncomingMessage(message, id, authTicket), settings, RemoteAccessServer.getInstance(appContext).service, appContext) + if (!RemoteAccessWebSockets.manageIncomingMessages(WSIncomingMessage(message, id, authTicket), settings, RemoteAccessServer.getInstance(appContext).service, appContext)) { + call.respond(HttpStatusCode.Forbidden) + return at get + } } call.respond(HttpStatusCode.OK) } diff --git a/application/webserver/src/main/java/org/videolan/vlc/webserver/websockets/RemoteAccessWebSockets.kt b/application/webserver/src/main/java/org/videolan/vlc/webserver/websockets/RemoteAccessWebSockets.kt index bc0dbf7336..5a57c9232d 100644 --- a/application/webserver/src/main/java/org/videolan/vlc/webserver/websockets/RemoteAccessWebSockets.kt +++ b/application/webserver/src/main/java/org/videolan/vlc/webserver/websockets/RemoteAccessWebSockets.kt @@ -80,25 +80,34 @@ object RemoteAccessWebSockets { } } + /** + * Manage incoming messages from the client, either from websockets or long polling + * + * @param incomingMessage the incoming message + * @param settings the shared preferences + * @param service the playback service + * @param context the context + * @return true if the message has been handled, false if playback control is not allowed + */ fun manageIncomingMessages( incomingMessage: WSIncomingMessage, settings: SharedPreferences, service: PlaybackService?, context: Context, - ) { + ):Boolean { when (incomingMessage.message) { "hello" -> {} - "play" -> if (playbackControlAllowedOrSend(settings)) service?.play() - "pause" -> if (playbackControlAllowedOrSend(settings)) service?.pause() - "previous" -> if (playbackControlAllowedOrSend(settings)) service?.previous(false) - "next" -> if (playbackControlAllowedOrSend(settings)) service?.next() + "play" -> if (playbackControlAllowedOrSend(settings)) service?.play() else return false + "pause" -> if (playbackControlAllowedOrSend(settings)) service?.pause() else return false + "previous" -> if (playbackControlAllowedOrSend(settings)) service?.previous(false) else return false + "next" -> if (playbackControlAllowedOrSend(settings)) service?.next() else return false "previous10" -> if (playbackControlAllowedOrSend(settings)) service?.let { it.seek( (it.getTime() - 10000).coerceAtLeast( 0 ), fromUser = true ) - } + } else return false "next10" -> if (playbackControlAllowedOrSend(settings)) service?.let { it.seek( @@ -106,9 +115,9 @@ object RemoteAccessWebSockets { it.length ), fromUser = true ) - } + } else return false - "shuffle" -> if (playbackControlAllowedOrSend(settings)) service?.shuffle() + "shuffle" -> if (playbackControlAllowedOrSend(settings)) service?.shuffle() else return false "repeat" -> if (playbackControlAllowedOrSend(settings)) service?.let { when (it.repeatType) { PlaybackStateCompat.REPEAT_MODE_NONE -> { @@ -125,7 +134,7 @@ object RemoteAccessWebSockets { it.repeatType = PlaybackStateCompat.REPEAT_MODE_NONE } } - } + } else return false "get-volume" -> { AppScope.launch { @@ -151,23 +160,23 @@ object RemoteAccessWebSockets { AudioManager.FLAG_SHOW_UI ) - } + } else return false } "set-progress" -> { if (playbackControlAllowedOrSend(settings)) incomingMessage.id?.let { service?.setTime(it.toLong()) - } + } else return false } "play-media" -> { - if (playbackControlAllowedOrSend(settings)) service?.playIndex(incomingMessage.id!!) + if (playbackControlAllowedOrSend(settings)) service?.playIndex(incomingMessage.id!!) else return false } "delete-media" -> { - if (playbackControlAllowedOrSend(settings)) service?.remove(incomingMessage.id!!) + if (playbackControlAllowedOrSend(settings)) service?.remove(incomingMessage.id!!) else return false } @@ -178,7 +187,7 @@ object RemoteAccessWebSockets { ?: 0) - 1 ) service?.moveItem(index, index + 2) - } + } else return false } @@ -187,16 +196,20 @@ object RemoteAccessWebSockets { val index = incomingMessage.id!! if (index > 0) service?.moveItem(index, index - 1) - } + } else return false } - else -> Log.w( - TAG, - "Unrecognized message", - IllegalStateException("Unrecognized message: $incomingMessage") - ) + else -> { + Log.w( + TAG, + "Unrecognized message", + IllegalStateException("Unrecognized message: $incomingMessage") + ) + return false + } } + return true } /** From git at videolan.org Tue Aug 13 16:56:02 2024 From: git at videolan.org (=?UTF-8?Q?Nicolas_Pomepuy?=) Date: Tue, 13 Aug 2024 18:56:02 +0200 (CEST) Subject: [Android] =?utf-8?q?Remote_access=3A_implement_the_long_polling?= Message-ID: <20240813165602.59BC982E002@gitlab> vlc-android | branch: master | Nicolas Pomepuy | Fri Aug 2 13:45:07 2024 +0200| [e74e5adced941843fbda28ce316c8f63e9260f13] | committer: Duncan McNamara Remote access: implement the long polling > https://code.videolan.org/videolan/vlc-android/commit/e74e5adced941843fbda28ce316c8f63e9260f13 --- .../videolan/vlc/webserver/RemoteAccessRouting.kt | 39 +++- .../videolan/vlc/webserver/RemoteAccessServer.kt | 25 ++- .../webserver/websockets/RemoteAccessWebSockets.kt | 219 +++++++++++++-------- 3 files changed, 187 insertions(+), 96 deletions(-) Diff: https://code.videolan.org/videolan/vlc-android/commit/e74e5adced941843fbda28ce316c8f63e9260f13 From git at videolan.org Tue Aug 13 16:56:02 2024 From: git at videolan.org (=?UTF-8?Q?Nicolas_Pomepuy?=) Date: Tue, 13 Aug 2024 18:56:02 +0200 (CEST) Subject: [Android] =?utf-8?q?Add_a_3_second_timeout_to_the_long_polling_t?= =?utf-8?q?o_avoid_blocking_other_queries?= Message-ID: <20240813165602.6671982E02B@gitlab> vlc-android | branch: master | Nicolas Pomepuy | Tue Aug 13 14:43:56 2024 +0200| [eb0bdbbe7c84311688987a91740a9602ea8d9563] | committer: Duncan McNamara Add a 3 second timeout to the long polling to avoid blocking other queries > https://code.videolan.org/videolan/vlc-android/commit/eb0bdbbe7c84311688987a91740a9602ea8d9563 --- .../src/main/java/org/videolan/vlc/webserver/RemoteAccessRouting.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/application/webserver/src/main/java/org/videolan/vlc/webserver/RemoteAccessRouting.kt b/application/webserver/src/main/java/org/videolan/vlc/webserver/RemoteAccessRouting.kt index d345637507..cd8fdadbf8 100644 --- a/application/webserver/src/main/java/org/videolan/vlc/webserver/RemoteAccessRouting.kt +++ b/application/webserver/src/main/java/org/videolan/vlc/webserver/RemoteAccessRouting.kt @@ -59,6 +59,7 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import kotlinx.coroutines.withContext +import kotlinx.coroutines.withTimeout import org.json.JSONArray import org.json.JSONObject import org.videolan.medialibrary.MLServiceLocator @@ -448,7 +449,8 @@ fun Route.setupRouting(appContext: Context, scope: CoroutineScope) { return at get } //block the request until a message is received - val message = RemoteAccessWebSockets.onPlaybackEventChannel.receive() + // The 3 second timeout is to avoid blocking forever + val message = withTimeout(3000) { RemoteAccessWebSockets.onPlaybackEventChannel.receive() } if (message.contains("\"type\":\"browser-description\"")) { call.respondText("[$message]") return at get From git at videolan.org Wed Aug 14 05:54:41 2024 From: git at videolan.org (=?UTF-8?Q?Nicolas_Pomepuy?=) Date: Wed, 14 Aug 2024 07:54:41 +0200 (CEST) Subject: [Android] =?utf-8?q?Bump_the_remote_access_hash?= Message-ID: <20240814055441.5175C82E002@gitlab> vlc-android | branch: master | Nicolas Pomepuy | Wed Aug 14 07:32:48 2024 +0200| [9c746d96ecde325b9477363e6d1e00bd940bceef] | committer: Nicolas Pomepuy Bump the remote access hash To fix some vulnerability issues > https://code.videolan.org/videolan/vlc-android/commit/9c746d96ecde325b9477363e6d1e00bd940bceef --- buildsystem/compile-remoteaccess.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildsystem/compile-remoteaccess.sh b/buildsystem/compile-remoteaccess.sh index c0775f52f9..1082d82b99 100755 --- a/buildsystem/compile-remoteaccess.sh +++ b/buildsystem/compile-remoteaccess.sh @@ -57,7 +57,7 @@ done ############################## diagnostic "Setting up the Remote Access project" - REMOTE_ACCESS_TESTED_HASH=cad3379a2aa628a47a92a10b4a48a47c60310f93 + REMOTE_ACCESS_TESTED_HASH=c65766195742cd2f861bab4c5bffc09d01f037cb REMOTE_ACCESS_REPOSITORY=https://code.videolan.org/videolan/remoteaccess : ${VLC_REMOTE_ACCESS_PATH:="$(pwd -P)/remoteaccess"}