Crash info dialog
This commit is contained in:
@@ -46,16 +46,21 @@
|
||||
<activity
|
||||
android:name=".ui.reader.SimpleSettingsActivity"
|
||||
android:label="@string/settings" />
|
||||
<activity android:name=".ui.browser.BrowserActivity" />
|
||||
|
||||
<activity
|
||||
android:name=".ui.browser.BrowserActivity"
|
||||
android:launchMode="singleInstance" />
|
||||
android:name=".ui.utils.CrashActivity"
|
||||
android:theme="@android:style/Theme.DeviceDefault.Dialog"
|
||||
android:label="@string/error_occurred"
|
||||
android:windowSoftInputMode="stateAlwaysHidden" />
|
||||
|
||||
<service
|
||||
android:name=".ui.download.DownloadService"
|
||||
android:foregroundServiceType="dataSync" />
|
||||
<service android:name=".ui.settings.AppUpdateService" />
|
||||
|
||||
<service android:name=".ui.tracker.TrackerJobService"
|
||||
<service
|
||||
android:name=".ui.tracker.TrackerJobService"
|
||||
android:exported="true"
|
||||
android:permission="android.permission.BIND_JOB_SERVICE" />
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.koitharu.kotatsu.core.parser.UserAgentInterceptor
|
||||
import org.koitharu.kotatsu.core.prefs.AppSettings
|
||||
import org.koitharu.kotatsu.domain.MangaLoaderContext
|
||||
import org.koitharu.kotatsu.ui.tracker.TrackerJobService
|
||||
import org.koitharu.kotatsu.ui.utils.AppCrashHandler
|
||||
import org.koitharu.kotatsu.utils.CacheUtils
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
@@ -43,9 +44,7 @@ class KotatsuApp : Application() {
|
||||
super.onCreate()
|
||||
initKoin()
|
||||
initCoil()
|
||||
if (BuildConfig.DEBUG) {
|
||||
initErrorHandler()
|
||||
}
|
||||
Thread.setDefaultUncaughtExceptionHandler(AppCrashHandler(applicationContext))
|
||||
TrackerJobService.setup(this)
|
||||
AppCompatDelegate.setDefaultNightMode(AppSettings(this).theme)
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ import moxy.MvpAppCompatActivity
|
||||
import org.koin.core.KoinComponent
|
||||
import org.koitharu.kotatsu.BuildConfig
|
||||
import org.koitharu.kotatsu.R
|
||||
import org.koitharu.kotatsu.ui.common.dialog.StorageSelectDialog
|
||||
|
||||
abstract class BaseActivity : MvpAppCompatActivity(), KoinComponent {
|
||||
|
||||
@@ -70,7 +69,7 @@ abstract class BaseActivity : MvpAppCompatActivity(), KoinComponent {
|
||||
return true
|
||||
}
|
||||
if (BuildConfig.DEBUG && keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
|
||||
StorageSelectDialog.Builder(this).create().show()
|
||||
throw StackOverflowError("test")
|
||||
return true
|
||||
}
|
||||
return super.onKeyDown(keyCode, event)
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package org.koitharu.kotatsu.ui.utils
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import java.io.PrintWriter
|
||||
import java.io.StringWriter
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
class AppCrashHandler(private val applicationContext: Context) : Thread.UncaughtExceptionHandler {
|
||||
|
||||
override fun uncaughtException(t: Thread, e: Throwable) {
|
||||
val crashInfo = buildString {
|
||||
val writer = StringWriter()
|
||||
e.printStackTrace(PrintWriter(writer))
|
||||
append(writer.toString().trimIndent())
|
||||
}
|
||||
val intent = Intent(applicationContext, CrashActivity::class.java)
|
||||
intent.putExtra(Intent.EXTRA_TEXT, crashInfo)
|
||||
intent.flags = (Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
try {
|
||||
applicationContext.startActivity(intent)
|
||||
} catch (e: Throwable) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
exitProcess(1)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package org.koitharu.kotatsu.ui.utils
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import kotlinx.android.synthetic.main.activity_crash.*
|
||||
import org.koitharu.kotatsu.R
|
||||
import org.koitharu.kotatsu.ui.main.MainActivity
|
||||
|
||||
class CrashActivity : Activity(), View.OnClickListener {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_crash)
|
||||
textView.text = intent.getStringExtra(Intent.EXTRA_TEXT)
|
||||
button_close.setOnClickListener(this)
|
||||
button_restart.setOnClickListener(this)
|
||||
}
|
||||
|
||||
override fun onClick(v: View) {
|
||||
when(v.id) {
|
||||
R.id.button_close -> {
|
||||
finish()
|
||||
}
|
||||
R.id.button_restart -> {
|
||||
val intent = Intent(applicationContext, MainActivity::class.java)
|
||||
intent.flags = (Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
startActivity(intent)
|
||||
finish()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
45
app/src/main/res/layout/activity_crash.xml
Normal file
45
app/src/main/res/layout/activity_crash.xml
Normal file
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_above="@id/button_close"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginTop="2dp"
|
||||
android:layout_marginBottom="2dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="2dp"
|
||||
android:paddingEnd="2dp"
|
||||
android:textIsSelectable="true" />
|
||||
</ScrollView>
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_close"
|
||||
style="@android:style/Widget.DeviceDefault.Button.Borderless"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_toStartOf="@id/button_restart"
|
||||
android:text="@string/close" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_restart"
|
||||
style="@android:style/Widget.DeviceDefault.Button.Borderless"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:text="@string/restart" />
|
||||
|
||||
</RelativeLayout>
|
||||
@@ -117,4 +117,5 @@
|
||||
<string name="show_notification_new_chapters">Уведомлять об обновлении манги, которую Вы читаете</string>
|
||||
<string name="download">Загрузить</string>
|
||||
<string name="read_from_start">Читать с начала</string>
|
||||
<string name="restart">Перезапустить</string>
|
||||
</resources>
|
||||
@@ -118,4 +118,5 @@
|
||||
<string name="show_notification_new_chapters">Notify about updates of manga you are reading</string>
|
||||
<string name="download">Download</string>
|
||||
<string name="read_from_start">Read from start</string>
|
||||
<string name="restart">Restart</string>
|
||||
</resources>
|
||||
Reference in New Issue
Block a user