Commit ab47b2b2 authored by Ricki Hirner's avatar Ricki Hirner

Debug info: fix onShare

* bump version code to 261
parent 7f301640
Pipeline #42123939 passed with stage
in 10 minutes and 54 seconds
......@@ -18,7 +18,7 @@ android {
defaultConfig {
applicationId "at.bitfire.davdroid"
versionCode 260
versionCode 261
versionName '2.2'
buildConfigField "long", "buildTime", System.currentTimeMillis() + "L"
buildConfigField "boolean", "customCerts", "true"
......
......@@ -99,12 +99,12 @@
</activity>
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="@string/authority_log_provider"
android:authorities="@string/authority_debug_provider"
android:grantUriPermissions="true"
android:exported="false">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/log_paths" />
android:resource="@xml/debug_paths" />
</provider>
<!-- account type "DAVdroid" -->
......
......@@ -93,13 +93,13 @@ object Logger : SharedPreferences.OnSharedPreferenceChangeListener {
.setOngoing(true)
// add "Share" action
val logFileUri = FileProvider.getUriForFile(context, context.getString(R.string.authority_log_provider), logFile)
val logFileUri = FileProvider.getUriForFile(context, context.getString(R.string.authority_debug_provider), logFile)
log.fine("Now logging to file: $logFile -> $logFileUri")
val shareIntent = Intent(Intent.ACTION_SEND)
shareIntent.setDataAndType(logFileUri, "text/plain")
shareIntent.putExtra(Intent.EXTRA_SUBJECT, "DAVx⁵ logs")
shareIntent.putExtra(Intent.EXTRA_STREAM, logFileUri)
shareIntent.type = "text/plain"
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
val shareAction = NotificationCompat.Action.Builder(R.drawable.ic_share_action,
context.getString(R.string.logging_notification_share_log),
......
......@@ -27,6 +27,7 @@ import android.util.Log
import android.view.Menu
import android.view.MenuItem
import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.ShareCompat
import androidx.core.content.ContextCompat
import androidx.core.content.FileProvider
import androidx.core.content.pm.PackageInfoCompat
......@@ -78,29 +79,30 @@ class DebugInfoActivity: AppCompatActivity(), LoaderManager.LoaderCallbacks<Stri
fun onShare(item: MenuItem) {
report?.let {
val sendIntent = Intent()
sendIntent.action = Intent.ACTION_SEND
sendIntent.type = "text/plain"
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "${getString(R.string.app_name)} ${BuildConfig.VERSION_NAME} debug info")
val builder = ShareCompat.IntentBuilder.from(this)
.setSubject("${getString(R.string.app_name)} ${BuildConfig.VERSION_NAME} debug info")
.setType("text/plain")
try {
val debugInfoDir = File(cacheDir, "debug-info")
debugInfoDir.mkdir()
val debugInfoDir = File(filesDir, "debug")
if (!(debugInfoDir.exists() && debugInfoDir.isDirectory) && !debugInfoDir.mkdir())
throw IOException("Couldn't create debug directory")
val reportFile = File(debugInfoDir, "debug.txt")
val reportFile = File(debugInfoDir, "davx5-info.txt")
Logger.log.fine("Writing debug info to ${reportFile.absolutePath}")
val writer = FileWriter(reportFile)
writer.write(it)
writer.close()
sendIntent.putExtra(Intent.EXTRA_STREAM, FileProvider.getUriForFile(this, getString(R.string.authority_log_provider), reportFile))
sendIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
builder.setStream(FileProvider.getUriForFile(this, getString(R.string.authority_debug_provider), reportFile))
} catch(e: IOException) {
// creating an attachment failed, so send it inline
sendIntent.putExtra(Intent.EXTRA_TEXT, it)
val text = "Couldn't create debug info file: " + Log.getStackTraceString(e) + "\n\n$it"
builder.setText(text)
}
val sendIntent = builder.intent
sendIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
startActivity(Intent.createChooser(sendIntent, null))
}
}
......
......@@ -267,7 +267,7 @@
<string name="exception_show_details">Show details</string>
<!-- sync adapters and DebugInfoActivity -->
<string name="authority_log_provider" translatable="false">at.bitfire.davdroid.log</string>
<string name="authority_debug_provider" translatable="false">at.bitfire.davdroid.debug</string>
<string name="debug_info_title">Debug info</string>
<string name="sync_contacts_read_only_address_book">Read-only address book</string>
<plurals name="sync_contacts_local_contact_changes_discarded">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment