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
|
package ani.dantotsu.others
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.Button
|
import android.widget.Button
|
||||||
import android.widget.EditText
|
import android.widget.EditText
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.core.content.FileProvider
|
||||||
import ani.dantotsu.R
|
import ani.dantotsu.R
|
||||||
import eu.kanade.tachiyomi.util.system.copyToClipboard
|
import eu.kanade.tachiyomi.util.system.copyToClipboard
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
|
||||||
class CrashActivity : AppCompatActivity() {
|
class CrashActivity : AppCompatActivity() {
|
||||||
|
@ -25,5 +28,21 @@ class CrashActivity : AppCompatActivity() {
|
||||||
copyButton.setOnClickListener {
|
copyButton.setOnClickListener {
|
||||||
copyToClipboard("Crash log", stackTrace)
|
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)))
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -12,7 +12,7 @@
|
||||||
android:gravity="top|center_horizontal"
|
android:gravity="top|center_horizontal"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:paddingTop="48dp"
|
android:paddingTop="48dp"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/copyButton"
|
app:layout_constraintBottom_toTopOf="@+id/buttonContainer"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
@ -48,29 +48,51 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="16dp"
|
android:layout_margin="16dp"
|
||||||
|
android:focusable="false"
|
||||||
|
android:focusableInTouchMode="false"
|
||||||
android:fontFamily="@font/poppins"
|
android:fontFamily="@font/poppins"
|
||||||
android:inputType="textMultiLine|none"
|
android:inputType="textMultiLine|none"
|
||||||
android:textIsSelectable="true"
|
|
||||||
android:focusable="false"
|
|
||||||
android:textSize="12sp"
|
|
||||||
android:focusableInTouchMode="false"
|
|
||||||
android:padding="16dp"
|
android:padding="16dp"
|
||||||
android:textColor="?attr/colorOnBackground" />
|
android:textColor="?attr/colorOnBackground"
|
||||||
|
android:textIsSelectable="true"
|
||||||
|
android:textSize="12sp" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/buttonContainer"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_gravity="bottom|center_horizontal"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:layout_marginBottom="48dp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/copyButton"
|
android:id="@+id/copyButton"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="64dp"
|
android:layout_height="64dp"
|
||||||
android:layout_gravity="bottom|center_horizontal"
|
android:layout_marginEnd="8dp"
|
||||||
android:layout_margin="64dp"
|
|
||||||
android:fontFamily="@font/poppins_bold"
|
android:fontFamily="@font/poppins_bold"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:text="@string/copy_report"
|
android:text="@string/copy_report"
|
||||||
app:cornerRadius="16dp"
|
app:cornerRadius="16dp"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
tools:ignore="ButtonStyle" />
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent" />
|
<Button
|
||||||
|
android:id="@+id/shareAsTextFileButton"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="64dp"
|
||||||
|
android:layout_marginStart="8dp"
|
||||||
|
android:fontFamily="@font/poppins_bold"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:text="@string/share_as_file"
|
||||||
|
app:cornerRadius="16dp"
|
||||||
|
tools:ignore="ButtonStyle"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -970,4 +970,5 @@ Non quae tempore quo provident laudantium qui illo dolor vel quia dolor et exerc
|
||||||
<string name="app_died">APP DIED</string>
|
<string name="app_died">APP DIED</string>
|
||||||
<string name="an_unexpected_error_occurred">An unexpected error occurred.\nPlease send a crash report to the developer :)</string>
|
<string name="an_unexpected_error_occurred">An unexpected error occurred.\nPlease send a crash report to the developer :)</string>
|
||||||
<string name="copy_report">Copy Report</string>
|
<string name="copy_report">Copy Report</string>
|
||||||
|
<string name="share_as_file">Share as file</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue