[Android] Refactor the feedback info generation
Nicolas Pomepuy
git at videolan.org
Thu Apr 24 14:06:53 UTC 2025
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Wed Apr 9 14:42:16 2025 +0200| [b2987ef8930325bd5357d514131e707f0325b04b] | committer: Nicolas Pomepuy
Refactor the feedback info generation
> https://code.videolan.org/videolan/vlc-android/commit/b2987ef8930325bd5357d514131e707f0325b04b
---
.../src/org/videolan/vlc/gui/FeedbackActivity.kt | 10 ++--------
.../src/org/videolan/vlc/gui/helpers/FeedbackUtil.kt | 16 ++++++++++++++--
2 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/FeedbackActivity.kt b/application/vlc-android/src/org/videolan/vlc/gui/FeedbackActivity.kt
index 960c4a4a17..2bedf01d7c 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/FeedbackActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/FeedbackActivity.kt
@@ -229,13 +229,6 @@ class FeedbackActivity : BaseActivity(), DebugLogService.Client.Callback {
private fun sendEmail(includeLogs: Boolean = false) {
val feedbackTypePosition = feedbackTypeEntries.indexOf(binding.feedbackTypeEntry.text.toString())
val isCrashFromML = !mlErrorContext.isNullOrEmpty() || !mlErrorMessage.isNullOrEmpty()
- val subjectPrepend = when {
- isCrashFromML -> "[ML Crash]"
- feedbackTypePosition == 0 -> "[Help] "
- feedbackTypePosition == 1 -> "[Feedback/Request] "
- feedbackTypePosition == 2 -> "[Bug] "
- else -> "[Crash] "
- }
val mail = if (BuildConfig.BETA && feedbackTypePosition > 2) FeedbackUtil.SupportType.CRASH_REPORT_EMAIL else FeedbackUtil.SupportType.SUPPORT_EMAIL
lifecycleScope.launch {
val message = if (isCrashFromML)
@@ -253,7 +246,8 @@ class FeedbackActivity : BaseActivity(), DebugLogService.Client.Callback {
mail,
binding.showIncludes && binding.includeMedialibrary.isChecked,
message,
- subjectPrepend + binding.subjectTextInputLayout.editText?.text.toString(),
+ binding.subjectTextInputLayout.editText?.text.toString(),
+ if (isCrashFromML) 100 else feedbackTypePosition,
if (includeLogs) logcatZipPath else null
)
finish()
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/helpers/FeedbackUtil.kt b/application/vlc-android/src/org/videolan/vlc/gui/helpers/FeedbackUtil.kt
index da56fa776d..10823080d3 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/helpers/FeedbackUtil.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/helpers/FeedbackUtil.kt
@@ -53,9 +53,10 @@ object FeedbackUtil {
* @param includeMedialibrary Whether to include the medialibrary database or not
* @param message Message to send
* @param subject Subject of the email
+ * @param feedbackType Type of feedback
* @param logcatZipPath Path to the logcat zip file
*/
- suspend fun sendEmail(activity: FragmentActivity, supportType: SupportType, includeMedialibrary: Boolean, message: String, subject: String, logcatZipPath: String? = null) {
+ suspend fun sendEmail(activity: FragmentActivity, supportType: SupportType, includeMedialibrary: Boolean, message: String, subject: String, feedbackType: Int, logcatZipPath: String? = null) {
val emailIntent = withContext(Dispatchers.IO) {
val emailIntent = Intent(Intent.ACTION_SEND_MULTIPLE)
@@ -87,7 +88,7 @@ object FeedbackUtil {
val htmlBody = HtmlCompat.fromHtml(body, HtmlCompat.FROM_HTML_MODE_LEGACY)
emailIntent.putExtra(Intent.EXTRA_EMAIL, arrayOf(supportType.email))
- emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject)
+ emailIntent.putExtra(Intent.EXTRA_SUBJECT, generateSubject(subject, feedbackType))
emailIntent.putExtra(Intent.EXTRA_TEXT, htmlBody)
emailIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
emailIntent
@@ -95,6 +96,17 @@ object FeedbackUtil {
emailIntent?.let { activity.startActivity(it) }
}
+ fun generateSubject(initialSubject: String, feedbackType: Int): String {
+ val subjectPrepend = when (feedbackType) {
+ 0 -> "[Help] "
+ 1 -> "[Feedback/Request] "
+ 2 -> "[Bug] "
+ 3 -> "[Crash] "
+ else -> "[ML Crash]"
+ }
+ return subjectPrepend + initialSubject
+ }
+
fun generateUsefulInfo(context: Context) = buildString {
append("____________________________\r\n")
append("Useful info\r\n")
More information about the Android
mailing list