[Android] Add the new remote access feedback API
Nicolas Pomepuy
git at videolan.org
Thu Apr 24 14:06:53 UTC 2025
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Thu Apr 10 06:46:46 2025 +0200| [56fed5991656f4f9282b941fb923b54a7840ee0c] | committer: Nicolas Pomepuy
Add the new remote access feedback API
> https://code.videolan.org/videolan/vlc-android/commit/56fed5991656f4f9282b941fb923b54a7840ee0c
---
.../vlc/remoteaccessserver/RemoteAccessRouting.kt | 46 ++++++++++++++++++++++
.../vlc/remoteaccessserver/RemoteAccessServer.kt | 1 +
.../vlc/remoteaccessserver/TranslationMapping.kt | 20 +++++++++-
.../resources/src/main/res/values/strings.xml | 6 +++
4 files changed, 72 insertions(+), 1 deletion(-)
diff --git a/application/remote-access-server/src/main/java/org/videolan/vlc/remoteaccessserver/RemoteAccessRouting.kt b/application/remote-access-server/src/main/java/org/videolan/vlc/remoteaccessserver/RemoteAccessRouting.kt
index b8d6401b21..348cf61a6d 100644
--- a/application/remote-access-server/src/main/java/org/videolan/vlc/remoteaccessserver/RemoteAccessRouting.kt
+++ b/application/remote-access-server/src/main/java/org/videolan/vlc/remoteaccessserver/RemoteAccessRouting.kt
@@ -107,6 +107,7 @@ import org.videolan.vlc.BuildConfig
import org.videolan.vlc.gui.dialogs.getPlaylistByName
import org.videolan.vlc.gui.helpers.AudioUtil
import org.videolan.vlc.gui.helpers.BitmapUtil
+import org.videolan.vlc.gui.helpers.FeedbackUtil
import org.videolan.vlc.gui.helpers.VectorDrawableUtil
import org.videolan.vlc.gui.helpers.getBitmapFromDrawable
import org.videolan.vlc.gui.helpers.getColoredBitmapFromColor
@@ -266,6 +267,51 @@ fun Route.setupRouting(appContext: Context, scope: CoroutineScope) {
call.respondJson(convertToJson(logs))
}
+ // Prepare the feedback data
+ post("/feedback-form") {
+ verifyLogin(settings)
+
+ val formParameters = try {
+ call.receiveParameters()
+ } catch (e: Exception) {
+ Log.w(this::class.java.simpleName, "Failed to parse form parameters. ${e.message}", e)
+ call.respond(HttpStatusCode.BadRequest)
+ return at post
+ }
+
+ val feedbackType = formParameters.get("type")?.toInt() ?: 0
+ val includeML = formParameters.get("includeML") == "true"
+ val includeLogs = formParameters.get("includeLogs") == "true"
+ val subject = formParameters.get("subject") ?: ""
+ val message = formParameters.get("message") ?: ""
+
+ if ((includeLogs || includeML) && !settings.getBoolean(REMOTE_ACCESS_LOGS, false)) {
+ call.respond(HttpStatusCode.Forbidden)
+ return at post
+ }
+
+ var zipFile: String? = null
+
+
+ if (includeML) {
+ val externalPath = RemoteAccessServer.getInstance(appContext).downloadFolder
+ File(externalPath).mkdirs()
+ val dbPath = "$externalPath/${Medialibrary.VLC_MEDIA_DB_NAME}"
+ val dbZipPath = "$externalPath/db.zip"
+ val db = File(appContext.getDir("db", Context.MODE_PRIVATE).toString() + Medialibrary.VLC_MEDIA_DB_NAME)
+ val dbFile = File(dbPath)
+ FileUtils.copyFile(db, dbFile)
+ FileUtils.zip(arrayOf(dbPath), dbZipPath)
+ FileUtils.deleteFile(dbFile)
+ zipFile = "db.zip"
+ }
+
+ val completeMessage = "$message\r\n\r\n${FeedbackUtil.generateUsefulInfo(appContext)}"
+
+ val result = RemoteAccessServer.FeedbackResult(FeedbackUtil.SupportType.SUPPORT_EMAIL.email, FeedbackUtil.generateSubject(subject, feedbackType), completeMessage, zipFile)
+
+ call.respondJson(convertToJson(result))
+ }
// Get the translation string list
get("/translation") {
call.respondJson(convertToJson(TranslationMapping.generateTranslations(appContext.getContextWithLocale(AppContextProvider.locale))))
diff --git a/application/remote-access-server/src/main/java/org/videolan/vlc/remoteaccessserver/RemoteAccessServer.kt b/application/remote-access-server/src/main/java/org/videolan/vlc/remoteaccessserver/RemoteAccessServer.kt
index 609087140d..f575d71289 100644
--- a/application/remote-access-server/src/main/java/org/videolan/vlc/remoteaccessserver/RemoteAccessServer.kt
+++ b/application/remote-access-server/src/main/java/org/videolan/vlc/remoteaccessserver/RemoteAccessServer.kt
@@ -930,6 +930,7 @@ class RemoteAccessServer(private val context: Context) : PlaybackService.Callbac
data class ArtistResult(val albums: List<PlayQueueItem>, val tracks: List<PlayQueueItem>, val name: String)
data class AlbumResult(val tracks: List<PlayQueueItem>, val name: String)
data class PlaylistResult(val tracks: List<PlayQueueItem>, val name: String)
+ data class FeedbackResult(val mail: String, val subject: String, val message: String, val file: String?)
fun getSecureUrl(call: ApplicationCall) = "https://${call.request.host()}:${engine.environment.connectors.first { it.type.name == "HTTPS" }.port}"
diff --git a/application/remote-access-server/src/main/java/org/videolan/vlc/remoteaccessserver/TranslationMapping.kt b/application/remote-access-server/src/main/java/org/videolan/vlc/remoteaccessserver/TranslationMapping.kt
index a1c0e81763..cdf038f239 100644
--- a/application/remote-access-server/src/main/java/org/videolan/vlc/remoteaccessserver/TranslationMapping.kt
+++ b/application/remote-access-server/src/main/java/org/videolan/vlc/remoteaccessserver/TranslationMapping.kt
@@ -74,6 +74,7 @@ object TranslationMapping {
DIRECTORY_EMPTY(R.string.empty_directory),
FORBIDDEN(R.string.ra_forbidden),
PLAYBACK_CONTROL_FORBIDDEN(R.string.ra_playback_forbidden),
+ LOGS_CONTROL_FORBIDDEN(R.string.ra_logs_forbidden),
SEND(R.string.send),
NEW_CODE(R.string.ra_new_code),
CODE_REQUEST_EXPLANATION(R.string.ra_code_requested_explanation),
@@ -142,6 +143,23 @@ object TranslationMapping {
RESUME(R.string.resume),
CONFIRM_RESUME(R.string.confirm_resume),
APPLY_PLAYQUEUE(R.string.apply_playqueue),
- NO(R.string.no)
+ NO(R.string.no),
+ FEEDBACK(R.string.send_feedback),
+ FEEDBACK_SUBTITLE(R.string.email_support),
+ FEEDBACK_TYPE(R.string.feedback_type),
+ FEEDBACK_HELP(R.string.get_help),
+ FEEDBACK_FEATURE(R.string.send_feedback_request),
+ FEEDBACK_BUG(R.string.report_a_bug),
+ FEEDBACK_CRASH(R.string.report_crash),
+ FEEDBACK_SUBJECT(R.string.subject),
+ FEEDBACK_MESSAGE(R.string.body),
+ FEEDBACK_MEDIALIBRARY(R.string.include_medialib),
+ FEEDBACK_LOGS(R.string.include_logs),
+ FEEDBACK_GENERATE(R.string.remote_access_feedback_generate),
+ FEEDBACK_GENERATING_LOGS(R.string.please_wait),
+ FEEDBACK_GENERATED_TITLE(R.string.remote_access_feedback_generated),
+ FEEDBACK_GENERATED_EXPLANATION(R.string.remote_access_feedback_generated_explanation),
+ FEEDBACK_GENERATED_FILE_EXPLANATION(R.string.remote_access_feedback_file_explanation),
+ COPIED(R.string.generic_copied_to_clipboard),
}
}
\ No newline at end of file
diff --git a/application/resources/src/main/res/values/strings.xml b/application/resources/src/main/res/values/strings.xml
index bedd1553c0..217e4a2e31 100644
--- a/application/resources/src/main/res/values/strings.xml
+++ b/application/resources/src/main/res/values/strings.xml
@@ -1304,6 +1304,7 @@
<string name="ra_prepare_download">Preparing your download</string>
<string name="ra_forbidden">Content disabled in the settings</string>
<string name="ra_playback_forbidden">Playback control disabled in the settings</string>
+ <string name="ra_logs_forbidden">Logs sharing disabled in the settings</string>
<string name="ra_code_requested_explanation">To protect your server, the access is protected.\nPlease enter the code displayed in your notifications</string>
<string name="ra_ssl_explanation_title">Unsecure connection</string>
<string name="ra_ssl_explanation">Your connection is not secure.</string>
@@ -1395,4 +1396,9 @@
<string name="generating_logs">Generating logs. Please wait.</string>
<string name="default_playback_action">Playback action</string>
<string name="files">Files</string>
+ <string name="remote_access_feedback_generate">Generate report</string>
+ <string name="remote_access_feedback_generated">Your feedback report has been generated</string>
+ <string name="remote_access_feedback_generated_explanation">Tap the button below to send it using your default email client. If you encounter any issues, you can copy paste the fields below and send the email yourself.</string>
+ <string name="remote_access_feedback_file_explanation">You just downloaded the needed file. Please remember to attach it to your email.</string>
+ <string name="generic_copied_to_clipboard">Copied to clipboard</string>
</resources>
More information about the Android
mailing list