fix: use binding in CrashActivity.kt
This commit is contained in:
parent
e9551be62d
commit
d5be21882e
4 changed files with 32 additions and 18 deletions
|
@ -3,34 +3,45 @@ 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 android.view.ViewGroup
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.FileProvider
|
||||
import androidx.core.view.updateLayoutParams
|
||||
import ani.dantotsu.R
|
||||
import ani.dantotsu.databinding.ActivityCrashBinding
|
||||
import ani.dantotsu.initActivity
|
||||
import ani.dantotsu.navBarHeight
|
||||
import ani.dantotsu.statusBarHeight
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
import eu.kanade.tachiyomi.util.system.copyToClipboard
|
||||
import java.io.File
|
||||
|
||||
|
||||
class CrashActivity : AppCompatActivity() {
|
||||
private lateinit var binding: ActivityCrashBinding
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_crash)
|
||||
ThemeManager(this).applyTheme()
|
||||
initActivity(this)
|
||||
binding = ActivityCrashBinding.inflate(layoutInflater)
|
||||
|
||||
setContentView(binding.root)
|
||||
binding.root.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||
topMargin = statusBarHeight
|
||||
bottomMargin = navBarHeight
|
||||
}
|
||||
val stackTrace = intent.getStringExtra("stackTrace") ?: "No stack trace available"
|
||||
val reportView = findViewById<EditText>(R.id.crashReportView)
|
||||
reportView.setText(stackTrace)
|
||||
reportView.setOnKeyListener(View.OnKeyListener { _, _, _ ->
|
||||
|
||||
binding.crashReportView.setText(stackTrace)
|
||||
binding.crashReportView.setOnKeyListener(View.OnKeyListener { _, _, _ ->
|
||||
true // Blocks input from hardware keyboards.
|
||||
})
|
||||
|
||||
val copyButton = findViewById<Button>(R.id.copyButton)
|
||||
copyButton.setOnClickListener {
|
||||
binding.copyButton.setOnClickListener {
|
||||
copyToClipboard("Crash log", stackTrace)
|
||||
}
|
||||
|
||||
val shareAsTextFileButton = findViewById<Button>(R.id.shareAsTextFileButton)
|
||||
shareAsTextFileButton.setOnClickListener {
|
||||
binding.shareAsTextFileButton.setOnClickListener {
|
||||
shareAsTextFile(stackTrace)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,17 +27,18 @@
|
|||
android:textSize="64sp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="200dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/poppins_bold"
|
||||
android:text="@string/app_died"
|
||||
android:textAlignment="center"
|
||||
android:textColor="?attr/colorPrimary"
|
||||
android:textSize="32sp" />
|
||||
android:textSize="24sp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="200dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="32dp"
|
||||
android:fontFamily="@font/poppins"
|
||||
android:text="@string/an_unexpected_error_occurred"
|
||||
android:textAlignment="center"
|
||||
|
@ -55,7 +56,8 @@
|
|||
android:padding="16dp"
|
||||
android:textColor="?attr/colorOnBackground"
|
||||
android:textIsSelectable="true"
|
||||
android:textSize="12sp" />
|
||||
android:textSize="12sp"
|
||||
tools:ignore="LabelFor" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
@ -66,7 +68,7 @@
|
|||
android:orientation="horizontal"
|
||||
android:layout_gravity="bottom|center_horizontal"
|
||||
android:gravity="center_horizontal"
|
||||
android:layout_marginBottom="48dp"
|
||||
android:layout_marginBottom="24dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent">
|
||||
|
|
|
@ -25,8 +25,8 @@
|
|||
android:id="@+id/listTitle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_marginStart="24dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginStart="32dp"
|
||||
android:ellipsize="end"
|
||||
android:fontFamily="@font/poppins_bold"
|
||||
android:gravity="center|start"
|
||||
|
@ -35,6 +35,7 @@
|
|||
android:textColor="?attr/colorOnBackground"
|
||||
android:textSize="16sp"
|
||||
tools:text="@string/app_name" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/mediaList"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -53,7 +54,7 @@
|
|||
android:layout_gravity="end"
|
||||
android:alpha="0.33"
|
||||
android:padding="8dp"
|
||||
android:layout_marginEnd="12dp"
|
||||
android:layout_marginEnd="24dp"
|
||||
app:srcCompat="@drawable/ic_round_grid_view_24"
|
||||
app:tint="?attr/colorOnBackground"
|
||||
tools:ignore="ContentDescription,ImageContrastCheck" />
|
||||
|
|
|
@ -212,7 +212,7 @@
|
|||
android:padding="8dp"
|
||||
android:src="@drawable/arrow_mark"
|
||||
android:textSize="16sp"
|
||||
|
||||
android:visibility="gone"
|
||||
tools:ignore="ContentDescription" />
|
||||
</LinearLayout>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue