feat: share as file option for crash
This commit is contained in:
parent
97ff591b62
commit
3a88656e21
3 changed files with 58 additions and 16 deletions
|
@ -1,12 +1,15 @@
|
|||
package ani.dantotsu.others
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.widget.Button
|
||||
import android.widget.EditText
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.FileProvider
|
||||
import ani.dantotsu.R
|
||||
import eu.kanade.tachiyomi.util.system.copyToClipboard
|
||||
import java.io.File
|
||||
|
||||
|
||||
class CrashActivity : AppCompatActivity() {
|
||||
|
@ -25,5 +28,21 @@ class CrashActivity : AppCompatActivity() {
|
|||
copyButton.setOnClickListener {
|
||||
copyToClipboard("Crash log", stackTrace)
|
||||
}
|
||||
|
||||
val shareAsTextFileButton = findViewById<Button>(R.id.shareAsTextFileButton)
|
||||
shareAsTextFileButton.setOnClickListener {
|
||||
shareAsTextFile(stackTrace)
|
||||
}
|
||||
}
|
||||
|
||||
private fun shareAsTextFile(stackTrace: String) {
|
||||
val file = File(cacheDir, "crash_log.txt")
|
||||
file.writeText(stackTrace)
|
||||
val uri = FileProvider.getUriForFile(this, "${packageName}.provider", file)
|
||||
val intent = Intent(Intent.ACTION_SEND).apply {
|
||||
type = "text/plain"
|
||||
putExtra(Intent.EXTRA_STREAM, uri)
|
||||
}
|
||||
startActivity(Intent.createChooser(intent, getString(R.string.share)))
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue