Update crash activity
This commit is contained in:
@@ -56,7 +56,7 @@
|
|||||||
<activity
|
<activity
|
||||||
android:name=".ui.utils.CrashActivity"
|
android:name=".ui.utils.CrashActivity"
|
||||||
android:label="@string/error_occurred"
|
android:label="@string/error_occurred"
|
||||||
android:theme="@android:style/Theme.DeviceDefault.Dialog"
|
android:theme="@android:style/Theme.DeviceDefault"
|
||||||
android:windowSoftInputMode="stateAlwaysHidden" />
|
android:windowSoftInputMode="stateAlwaysHidden" />
|
||||||
<activity
|
<activity
|
||||||
android:name="org.koitharu.kotatsu.ui.list.favourites.categories.CategoriesActivity"
|
android:name="org.koitharu.kotatsu.ui.list.favourites.categories.CategoriesActivity"
|
||||||
|
|||||||
@@ -1,12 +1,17 @@
|
|||||||
package org.koitharu.kotatsu.ui.utils
|
package org.koitharu.kotatsu.ui.utils
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
|
import android.content.ActivityNotFoundException
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.view.Menu
|
||||||
|
import android.view.MenuItem
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import kotlinx.android.synthetic.main.activity_crash.*
|
import kotlinx.android.synthetic.main.activity_crash.*
|
||||||
import org.koitharu.kotatsu.R
|
import org.koitharu.kotatsu.R
|
||||||
import org.koitharu.kotatsu.ui.list.MainActivity
|
import org.koitharu.kotatsu.ui.list.MainActivity
|
||||||
|
import org.koitharu.kotatsu.utils.ShareHelper
|
||||||
|
|
||||||
class CrashActivity : Activity(), View.OnClickListener {
|
class CrashActivity : Activity(), View.OnClickListener {
|
||||||
|
|
||||||
@@ -16,10 +21,26 @@ class CrashActivity : Activity(), View.OnClickListener {
|
|||||||
textView.text = intent.getStringExtra(Intent.EXTRA_TEXT)
|
textView.text = intent.getStringExtra(Intent.EXTRA_TEXT)
|
||||||
button_close.setOnClickListener(this)
|
button_close.setOnClickListener(this)
|
||||||
button_restart.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) {
|
override fun onClick(v: View) {
|
||||||
when(v.id) {
|
when (v.id) {
|
||||||
R.id.button_close -> {
|
R.id.button_close -> {
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
@@ -29,6 +50,14 @@ class CrashActivity : Activity(), View.OnClickListener {
|
|||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
finish()
|
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 {
|
object ShareHelper {
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun shareMangaLink(context: Context, manga: Manga) {
|
fun shareMangaLink(context: Context, manga: Manga) {
|
||||||
val intent = Intent(Intent.ACTION_SEND)
|
val intent = Intent(Intent.ACTION_SEND)
|
||||||
intent.type = "text/plain"
|
intent.type = "text/plain"
|
||||||
@@ -25,7 +24,6 @@ object ShareHelper {
|
|||||||
context.startActivity(shareIntent)
|
context.startActivity(shareIntent)
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun shareCbz(context: Context, file: File) {
|
fun shareCbz(context: Context, file: File) {
|
||||||
val uri = FileProvider.getUriForFile(context, "${BuildConfig.APPLICATION_ID}.files", file)
|
val uri = FileProvider.getUriForFile(context, "${BuildConfig.APPLICATION_ID}.files", file)
|
||||||
val intent = Intent(Intent.ACTION_SEND)
|
val intent = Intent(Intent.ACTION_SEND)
|
||||||
@@ -36,7 +34,6 @@ object ShareHelper {
|
|||||||
context.startActivity(shareIntent)
|
context.startActivity(shareIntent)
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
|
||||||
fun shareImage(context: Context, uri: Uri) {
|
fun shareImage(context: Context, uri: Uri) {
|
||||||
val intent = Intent(Intent.ACTION_SEND)
|
val intent = Intent(Intent.ACTION_SEND)
|
||||||
intent.setDataAndType(uri, context.contentResolver.getType(uri))
|
intent.setDataAndType(uri, context.contentResolver.getType(uri))
|
||||||
@@ -44,4 +41,12 @@ object ShareHelper {
|
|||||||
val shareIntent = Intent.createChooser(intent, context.getString(R.string.share_image))
|
val shareIntent = Intent.createChooser(intent, context.getString(R.string.share_image))
|
||||||
context.startActivity(shareIntent)
|
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"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout
|
<LinearLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<ScrollView
|
<ScrollView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="0dp"
|
||||||
android:layout_above="@id/button_close"
|
android:layout_weight="1">
|
||||||
android:layout_alignParentStart="true"
|
|
||||||
android:layout_alignParentTop="true"
|
|
||||||
android:layout_alignParentEnd="true"
|
|
||||||
android:layout_marginTop="2dp"
|
|
||||||
android:layout_marginBottom="2dp">
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/textView"
|
android:id="@+id/textView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingStart="2dp"
|
android:padding="4dp"
|
||||||
android:paddingEnd="2dp"
|
|
||||||
android:textIsSelectable="true" />
|
android:textIsSelectable="true" />
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/button_close"
|
android:id="@+id/button_report"
|
||||||
style="@android:style/Widget.DeviceDefault.Button.Borderless"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentBottom="true"
|
android:layout_marginStart="4dp"
|
||||||
android:layout_toStartOf="@id/button_restart"
|
android:layout_marginEnd="4dp"
|
||||||
android:text="@string/close" />
|
android:layout_marginBottom="2dp"
|
||||||
|
android:drawableEnd="@android:drawable/ic_menu_set_as"
|
||||||
|
android:text="@string/report_github" />
|
||||||
|
|
||||||
<Button
|
<LinearLayout
|
||||||
android:id="@+id/button_restart"
|
android:layout_width="match_parent"
|
||||||
style="@android:style/Widget.DeviceDefault.Button.Borderless"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentEnd="true"
|
android:orientation="horizontal"
|
||||||
android:layout_alignParentBottom="true"
|
android:weightSum="2">
|
||||||
android:text="@string/restart" />
|
|
||||||
|
|
||||||
</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">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="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="create_category">New category</string>
|
||||||
|
<string name="report_github">Create issue on GitHub</string>
|
||||||
</resources>
|
</resources>
|
||||||
Reference in New Issue
Block a user