Skip to content

Commit 57b8468

Browse files
committed
fix: use share chooser instead of mailto selector for log sharing
mailto failed to attach the logfile for some email clients (e.g. thunderbird, while gmail worked fine). Replace it with Intent.createChooser() with a plain ACTION_SEND_MULTIPLE + */* type instead, so any app can handle attachments. This also fixes that thunderbird can handle the logfile. Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
1 parent c2ff70f commit 57b8468

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

‎app/src/main/java/com/nextcloud/talk/errorhandling/ShareLogsUtils.kt‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66
*/
77
package com.nextcloud.talk.errorhandling
88

9+
import android.content.ActivityNotFoundException
910
import android.content.Context
1011
import android.content.Intent
1112
import android.net.Uri
13+
import android.widget.Toast
1214
import androidx.core.content.FileProvider
13-
import androidx.core.net.toUri
1415
import com.nextcloud.talk.BuildConfig
1516
import com.nextcloud.talk.R
1617
import com.nextcloud.talk.dagger.modules.UtilsModule
@@ -45,7 +46,7 @@ fun shareLogsAndDiagnosis(context: Context, subject: String, diagnosisText: Stri
4546
}
4647

4748
val intent = Intent(Intent.ACTION_SEND_MULTIPLE).apply {
48-
selector = Intent(Intent.ACTION_SENDTO, "mailto:".toUri())
49+
type = "*/*"
4950
putExtra(Intent.EXTRA_EMAIL, arrayOf(context.getString(R.string.nc_report_email)))
5051
putExtra(Intent.EXTRA_SUBJECT, subject)
5152
putExtra(Intent.EXTRA_TEXT, body)
@@ -54,7 +55,11 @@ fun shareLogsAndDiagnosis(context: Context, subject: String, diagnosisText: Stri
5455
}
5556
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
5657
}
57-
context.startActivity(intent)
58+
try {
59+
context.startActivity(Intent.createChooser(intent, subject))
60+
} catch (_: ActivityNotFoundException) {
61+
Toast.makeText(context, R.string.nc_logs_share_no_app_found, Toast.LENGTH_LONG).show()
62+
}
5863
}
5964

6065
fun saveLogsAsZip(context: Context, outputStream: OutputStream, diagnosisText: String) {

‎app/src/main/res/values/strings.xml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ How to translate with transifex:
239239
<string name="nc_logs_overflow_warning">Warning: some log entries were lost due to queue overflow.</string>
240240
<string name="nc_logs_share_latest_crash">Latest crash</string>
241241
<string name="nc_logs_share_diagnosis">Diagnosis report</string>
242+
<string name="nc_logs_share_no_app_found">No app found to send the report.</string>
242243
<string name="nc_logs_download_zip">Download as ZIP</string>
243244
<string name="nc_logs_logging_enabled">Logging enabled</string>
244245
<string name="nc_logs_logging_disabled_note">Logging is disabled. No logs are written to disk.</string>

0 commit comments

Comments
 (0)