Update crash activity
This commit is contained in:
@@ -56,7 +56,7 @@
|
||||
<activity
|
||||
android:name=".ui.utils.CrashActivity"
|
||||
android:label="@string/error_occurred"
|
||||
android:theme="@android:style/Theme.DeviceDefault.Dialog"
|
||||
android:theme="@android:style/Theme.DeviceDefault"
|
||||
android:windowSoftInputMode="stateAlwaysHidden" />
|
||||
<activity
|
||||
android:name="org.koitharu.kotatsu.ui.list.favourites.categories.CategoriesActivity"
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
package org.koitharu.kotatsu.ui.utils
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.ActivityNotFoundException
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import kotlinx.android.synthetic.main.activity_crash.*
|
||||
import org.koitharu.kotatsu.R
|
||||
import org.koitharu.kotatsu.ui.list.MainActivity
|
||||
import org.koitharu.kotatsu.utils.ShareHelper
|
||||
|
||||
class CrashActivity : Activity(), View.OnClickListener {
|
||||
|
||||
@@ -16,10 +21,26 @@ class CrashActivity : Activity(), View.OnClickListener {
|
||||
textView.text = intent.getStringExtra(Intent.EXTRA_TEXT)
|
||||
button_close.setOnClickListener(this)
|
||||
button_restart.setOnClickListener(this)
|
||||
button_report.setOnClickListener(this)
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
|
||||
menuInflater.inflate(R.menu.opt_crash, menu)
|
||||
return super.onCreateOptionsMenu(menu)
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
R.id.action_share -> {
|
||||
ShareHelper.shareText(this, textView.text?.toString() ?: return false)
|
||||
}
|
||||
else -> return super.onOptionsItemSelected(item)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onClick(v: View) {
|
||||
when(v.id) {
|
||||
when (v.id) {
|
||||
R.id.button_close -> {
|
||||
finish()
|
||||
}
|
||||
@@ -29,6 +50,14 @@ class CrashActivity : Activity(), View.OnClickListener {
|
||||
startActivity(intent)
|
||||
finish()
|
||||
}
|
||||
R.id.button_report -> {
|
||||
val intent = Intent(Intent.ACTION_VIEW)
|
||||
intent.data = Uri.parse("https://github.com/nv95/Kotatsu/issues")
|
||||
try {
|
||||
startActivity(Intent.createChooser(intent, getString(R.string.report_github)))
|
||||
} catch (_: ActivityNotFoundException) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,6 @@ import java.io.File
|
||||
|
||||
object ShareHelper {
|
||||
|
||||
@JvmStatic
|
||||
fun shareMangaLink(context: Context, manga: Manga) {
|
||||
val intent = Intent(Intent.ACTION_SEND)
|
||||
intent.type = "text/plain"
|
||||
@@ -25,7 +24,6 @@ object ShareHelper {
|
||||
context.startActivity(shareIntent)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun shareCbz(context: Context, file: File) {
|
||||
val uri = FileProvider.getUriForFile(context, "${BuildConfig.APPLICATION_ID}.files", file)
|
||||
val intent = Intent(Intent.ACTION_SEND)
|
||||
@@ -36,7 +34,6 @@ object ShareHelper {
|
||||
context.startActivity(shareIntent)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun shareImage(context: Context, uri: Uri) {
|
||||
val intent = Intent(Intent.ACTION_SEND)
|
||||
intent.setDataAndType(uri, context.contentResolver.getType(uri))
|
||||
@@ -44,4 +41,12 @@ object ShareHelper {
|
||||
val shareIntent = Intent.createChooser(intent, context.getString(R.string.share_image))
|
||||
context.startActivity(shareIntent)
|
||||
}
|
||||
|
||||
fun shareText(context: Context, text: String) {
|
||||
val intent = Intent(Intent.ACTION_SEND)
|
||||
intent.type = "text/plain"
|
||||
intent.putExtra(Intent.EXTRA_TEXT, text)
|
||||
val shareIntent = Intent.createChooser(intent, context.getString(R.string.share))
|
||||
context.startActivity(shareIntent)
|
||||
}
|
||||
}
|
||||
@@ -1,45 +1,59 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout
|
||||
<LinearLayout
|
||||
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">
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="2dp"
|
||||
android:paddingEnd="2dp"
|
||||
android:padding="4dp"
|
||||
android:textIsSelectable="true" />
|
||||
</ScrollView>
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_close"
|
||||
style="@android:style/Widget.DeviceDefault.Button.Borderless"
|
||||
android:layout_width="wrap_content"
|
||||
android:id="@+id/button_report"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_toStartOf="@id/button_restart"
|
||||
android:text="@string/close" />
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:layout_marginBottom="2dp"
|
||||
android:drawableEnd="@android:drawable/ic_menu_set_as"
|
||||
android:text="@string/report_github" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_restart"
|
||||
style="@android:style/Widget.DeviceDefault.Button.Borderless"
|
||||
android:layout_width="wrap_content"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:text="@string/restart" />
|
||||
android:orientation="horizontal"
|
||||
android:weightSum="2">
|
||||
|
||||
</RelativeLayout>
|
||||
<Button
|
||||
android:id="@+id/button_close"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_marginEnd="2dp"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/close" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_restart"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="2dp"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/restart" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
12
app/src/main/res/menu/opt_crash.xml
Normal file
12
app/src/main/res/menu/opt_crash.xml
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<item
|
||||
android:id="@+id/action_share"
|
||||
android:icon="@android:drawable/ic_menu_share"
|
||||
android:showAsAction="ifRoom"
|
||||
android:title="@string/share"
|
||||
tools:ignore="AppCompatResource" />
|
||||
</menu>
|
||||
@@ -164,4 +164,5 @@
|
||||
<string name="prefer_rtl_reader">Prefer Right to left reader</string>
|
||||
<string name="prefer_rtl_reader_summary">You can set up the reading mode for each manga separately</string>
|
||||
<string name="create_category">New category</string>
|
||||
<string name="report_github">Create issue on GitHub</string>
|
||||
</resources>
|
||||
Reference in New Issue
Block a user