mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-23 04:11:48 +01:00
Bunch of crash fixes
This commit is contained in:
parent
6cd34614f6
commit
ce0090f0ca
@ -35,6 +35,7 @@ import eu.kanade.tachiyomi.util.view.visible
|
|||||||
import kotlinx.coroutines.flow.launchIn
|
import kotlinx.coroutines.flow.launchIn
|
||||||
import kotlinx.coroutines.flow.onEach
|
import kotlinx.coroutines.flow.onEach
|
||||||
import reactivecircus.flowbinding.android.view.clicks
|
import reactivecircus.flowbinding.android.view.clicks
|
||||||
|
import timber.log.Timber
|
||||||
|
|
||||||
@SuppressLint("RestrictedApi")
|
@SuppressLint("RestrictedApi")
|
||||||
class ExtensionDetailsController(bundle: Bundle? = null) :
|
class ExtensionDetailsController(bundle: Bundle? = null) :
|
||||||
@ -97,7 +98,11 @@ class ExtensionDetailsController(bundle: Bundle? = null) :
|
|||||||
|
|
||||||
for (source in extension.sources) {
|
for (source in extension.sources) {
|
||||||
if (source is ConfigurableSource) {
|
if (source is ConfigurableSource) {
|
||||||
addPreferencesForSource(screen, source, multiSource)
|
try {
|
||||||
|
addPreferencesForSource(screen, source, multiSource)
|
||||||
|
} catch (e: AbstractMethodError) {
|
||||||
|
Timber.e("Source did not implement [addPreferencesForSource]: ${source.name}")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,10 +113,14 @@ class SourceController :
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onItemClick(view: View, position: Int): Boolean {
|
override fun onItemClick(view: View, position: Int): Boolean {
|
||||||
val item = adapter?.getItem(position) as? SourceItem ?: return false
|
onItemClick(position)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun onItemClick(position: Int) {
|
||||||
|
val item = adapter?.getItem(position) as? SourceItem ?: return
|
||||||
val source = item.source
|
val source = item.source
|
||||||
openCatalogue(source, BrowseSourceController(source))
|
openCatalogue(source, BrowseSourceController(source))
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onItemLongClick(position: Int) {
|
override fun onItemLongClick(position: Int) {
|
||||||
@ -165,7 +169,7 @@ class SourceController :
|
|||||||
* Called when browse is clicked in [SourceAdapter]
|
* Called when browse is clicked in [SourceAdapter]
|
||||||
*/
|
*/
|
||||||
override fun onBrowseClick(position: Int) {
|
override fun onBrowseClick(position: Int) {
|
||||||
onItemClick(view!!, position)
|
onItemClick(position)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -41,8 +41,8 @@ import uy.kohesive.injekt.api.get
|
|||||||
* Presenter of [BrowseSourceController].
|
* Presenter of [BrowseSourceController].
|
||||||
*/
|
*/
|
||||||
open class BrowseSourcePresenter(
|
open class BrowseSourcePresenter(
|
||||||
sourceId: Long,
|
private val sourceId: Long,
|
||||||
sourceManager: SourceManager = Injekt.get(),
|
private val sourceManager: SourceManager = Injekt.get(),
|
||||||
private val db: DatabaseHelper = Injekt.get(),
|
private val db: DatabaseHelper = Injekt.get(),
|
||||||
private val prefs: PreferencesHelper = Injekt.get(),
|
private val prefs: PreferencesHelper = Injekt.get(),
|
||||||
private val coverCache: CoverCache = Injekt.get()
|
private val coverCache: CoverCache = Injekt.get()
|
||||||
@ -51,7 +51,7 @@ open class BrowseSourcePresenter(
|
|||||||
/**
|
/**
|
||||||
* Selected source.
|
* Selected source.
|
||||||
*/
|
*/
|
||||||
val source = sourceManager.get(sourceId) as CatalogueSource
|
lateinit var source: CatalogueSource
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Query from the view.
|
* Query from the view.
|
||||||
@ -109,6 +109,8 @@ open class BrowseSourcePresenter(
|
|||||||
override fun onCreate(savedState: Bundle?) {
|
override fun onCreate(savedState: Bundle?) {
|
||||||
super.onCreate(savedState)
|
super.onCreate(savedState)
|
||||||
|
|
||||||
|
source = sourceManager.get(sourceId) as? CatalogueSource ?: return
|
||||||
|
|
||||||
sourceFilters = source.getFilterList()
|
sourceFilters = source.getFilterList()
|
||||||
|
|
||||||
if (savedState != null) {
|
if (savedState != null) {
|
||||||
|
@ -302,13 +302,13 @@ class DownloadController :
|
|||||||
override fun onMenuItemClick(position: Int, menuItem: MenuItem) {
|
override fun onMenuItemClick(position: Int, menuItem: MenuItem) {
|
||||||
when (menuItem.itemId) {
|
when (menuItem.itemId) {
|
||||||
R.id.move_to_top, R.id.move_to_bottom -> {
|
R.id.move_to_top, R.id.move_to_bottom -> {
|
||||||
|
val download = adapter?.getItem(position) ?: return
|
||||||
val items = adapter?.currentItems?.toMutableList() ?: return
|
val items = adapter?.currentItems?.toMutableList() ?: return
|
||||||
val item = items[position]
|
items.remove(download)
|
||||||
items.remove(item)
|
|
||||||
if (menuItem.itemId == R.id.move_to_top) {
|
if (menuItem.itemId == R.id.move_to_top) {
|
||||||
items.add(0, item)
|
items.add(0, download)
|
||||||
} else {
|
} else {
|
||||||
items.add(item)
|
items.add(download)
|
||||||
}
|
}
|
||||||
|
|
||||||
val adapter = adapter ?: return
|
val adapter = adapter ?: return
|
||||||
|
@ -318,7 +318,7 @@ class LibraryController(
|
|||||||
binding.actionToolbar.show(
|
binding.actionToolbar.show(
|
||||||
actionMode!!,
|
actionMode!!,
|
||||||
R.menu.library_selection
|
R.menu.library_selection
|
||||||
) { onActionItemClicked(actionMode!!, it!!) }
|
) { onActionItemClicked(it!!) }
|
||||||
(activity as? MainActivity)?.showBottomNav(visible = false, collapse = true)
|
(activity as? MainActivity)?.showBottomNav(visible = false, collapse = true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -419,6 +419,10 @@ class LibraryController(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean {
|
override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean {
|
||||||
|
return onActionItemClicked(item)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun onActionItemClicked(item: MenuItem): Boolean {
|
||||||
when (item.itemId) {
|
when (item.itemId) {
|
||||||
R.id.action_edit_cover -> {
|
R.id.action_edit_cover -> {
|
||||||
changeSelectedCover()
|
changeSelectedCover()
|
||||||
|
@ -264,8 +264,10 @@ class MainActivity : BaseActivity<MainActivityBinding>() {
|
|||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
binding.bottomNav.setOnNavigationItemSelectedListener(null)
|
|
||||||
binding.toolbar.setNavigationOnClickListener(null)
|
// Binding sometimes isn't actually instantiated yet somehow
|
||||||
|
binding?.bottomNav.setOnNavigationItemSelectedListener(null)
|
||||||
|
binding?.toolbar.setNavigationOnClickListener(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBackPressed() {
|
override fun onBackPressed() {
|
||||||
|
@ -86,6 +86,9 @@ class ChaptersController :
|
|||||||
override fun onViewCreated(view: View) {
|
override fun onViewCreated(view: View) {
|
||||||
super.onViewCreated(view)
|
super.onViewCreated(view)
|
||||||
|
|
||||||
|
val ctrl = parentController as MangaController
|
||||||
|
if (ctrl.manga == null || ctrl.source == null) return
|
||||||
|
|
||||||
// Init RecyclerView and adapter
|
// Init RecyclerView and adapter
|
||||||
adapter = ChaptersAdapter(this, view.context)
|
adapter = ChaptersAdapter(this, view.context)
|
||||||
|
|
||||||
@ -379,7 +382,7 @@ class ChaptersController :
|
|||||||
binding.actionToolbar.show(
|
binding.actionToolbar.show(
|
||||||
actionMode!!,
|
actionMode!!,
|
||||||
R.menu.chapter_selection
|
R.menu.chapter_selection
|
||||||
) { onActionItemClicked(actionMode!!, it!!) }
|
) { onActionItemClicked(it!!) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -418,6 +421,10 @@ class ChaptersController :
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean {
|
override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean {
|
||||||
|
return onActionItemClicked(item)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun onActionItemClicked(item: MenuItem): Boolean {
|
||||||
when (item.itemId) {
|
when (item.itemId) {
|
||||||
R.id.action_select_all -> selectAll()
|
R.id.action_select_all -> selectAll()
|
||||||
R.id.action_select_inverse -> selectInverse()
|
R.id.action_select_inverse -> selectInverse()
|
||||||
|
@ -84,6 +84,8 @@ open class Pager(
|
|||||||
override fun onTouchEvent(ev: MotionEvent): Boolean {
|
override fun onTouchEvent(ev: MotionEvent): Boolean {
|
||||||
return try {
|
return try {
|
||||||
super.onTouchEvent(ev)
|
super.onTouchEvent(ev)
|
||||||
|
} catch (e: IndexOutOfBoundsException) {
|
||||||
|
false
|
||||||
} catch (e: IllegalArgumentException) {
|
} catch (e: IllegalArgumentException) {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
@ -179,7 +179,7 @@ class UpdatesController :
|
|||||||
binding.actionToolbar.show(
|
binding.actionToolbar.show(
|
||||||
actionMode!!,
|
actionMode!!,
|
||||||
R.menu.updates_chapter_selection
|
R.menu.updates_chapter_selection
|
||||||
) { onActionItemClicked(actionMode!!, it!!) }
|
) { onActionItemClicked(it!!) }
|
||||||
(activity as? MainActivity)?.showBottomNav(visible = false, collapse = true)
|
(activity as? MainActivity)?.showBottomNav(visible = false, collapse = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -333,6 +333,10 @@ class UpdatesController :
|
|||||||
* @param item item from ActionMode.
|
* @param item item from ActionMode.
|
||||||
*/
|
*/
|
||||||
override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean {
|
override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean {
|
||||||
|
return onActionItemClicked(item)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun onActionItemClicked(item: MenuItem): Boolean {
|
||||||
when (item.itemId) {
|
when (item.itemId) {
|
||||||
R.id.action_select_all -> selectAll()
|
R.id.action_select_all -> selectAll()
|
||||||
R.id.action_select_inverse -> selectInverse()
|
R.id.action_select_inverse -> selectInverse()
|
||||||
|
@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.ui.setting
|
|||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
|
import android.content.ActivityNotFoundException
|
||||||
import android.content.Context.POWER_SERVICE
|
import android.content.Context.POWER_SERVICE
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
@ -97,11 +98,15 @@ class SettingsAdvancedController : SettingsController() {
|
|||||||
val packageName: String = context.packageName
|
val packageName: String = context.packageName
|
||||||
val pm = context.getSystemService(POWER_SERVICE) as PowerManager?
|
val pm = context.getSystemService(POWER_SERVICE) as PowerManager?
|
||||||
if (!pm!!.isIgnoringBatteryOptimizations(packageName)) {
|
if (!pm!!.isIgnoringBatteryOptimizations(packageName)) {
|
||||||
val intent = Intent().apply {
|
try {
|
||||||
action = Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS
|
val intent = Intent().apply {
|
||||||
data = Uri.parse("package:$packageName")
|
action = Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS
|
||||||
|
data = Uri.parse("package:$packageName")
|
||||||
|
}
|
||||||
|
startActivity(intent)
|
||||||
|
} catch (e: ActivityNotFoundException) {
|
||||||
|
context.toast(R.string.battery_optimization_setting_activity_not_found)
|
||||||
}
|
}
|
||||||
startActivity(intent)
|
|
||||||
} else {
|
} else {
|
||||||
context.toast(R.string.battery_optimization_disabled)
|
context.toast(R.string.battery_optimization_disabled)
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ import eu.kanade.tachiyomi.databinding.WebviewActivityBinding
|
|||||||
import eu.kanade.tachiyomi.source.SourceManager
|
import eu.kanade.tachiyomi.source.SourceManager
|
||||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||||
import eu.kanade.tachiyomi.ui.base.activity.BaseActivity
|
import eu.kanade.tachiyomi.ui.base.activity.BaseActivity
|
||||||
|
import eu.kanade.tachiyomi.ui.main.ForceCloseActivity
|
||||||
import eu.kanade.tachiyomi.util.system.WebViewClientCompat
|
import eu.kanade.tachiyomi.util.system.WebViewClientCompat
|
||||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||||
import eu.kanade.tachiyomi.util.system.openInBrowser
|
import eu.kanade.tachiyomi.util.system.openInBrowser
|
||||||
@ -38,8 +39,14 @@ class WebViewActivity : BaseActivity<WebviewActivityBinding>() {
|
|||||||
@SuppressLint("SetJavaScriptEnabled")
|
@SuppressLint("SetJavaScriptEnabled")
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
binding = WebviewActivityBinding.inflate(layoutInflater)
|
|
||||||
setContentView(binding.root)
|
try {
|
||||||
|
binding = WebviewActivityBinding.inflate(layoutInflater)
|
||||||
|
setContentView(binding.root)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
// Potentially throws errors like "Error inflating class android.webkit.WebView"
|
||||||
|
ForceCloseActivity.closeApp(this)
|
||||||
|
}
|
||||||
|
|
||||||
title = intent.extras?.getString(TITLE_KEY)
|
title = intent.extras?.getString(TITLE_KEY)
|
||||||
setSupportActionBar(binding.toolbar)
|
setSupportActionBar(binding.toolbar)
|
||||||
|
@ -356,6 +356,7 @@
|
|||||||
<string name="pref_disable_battery_optimization">Disable battery optimization</string>
|
<string name="pref_disable_battery_optimization">Disable battery optimization</string>
|
||||||
<string name="pref_disable_battery_optimization_summary">Helps with background library updates and backups</string>
|
<string name="pref_disable_battery_optimization_summary">Helps with background library updates and backups</string>
|
||||||
<string name="battery_optimization_disabled">Battery optimization is already disabled</string>
|
<string name="battery_optimization_disabled">Battery optimization is already disabled</string>
|
||||||
|
<string name="battery_optimization_setting_activity_not_found">Couldn\'t open device settings</string>
|
||||||
|
|
||||||
<!-- About section -->
|
<!-- About section -->
|
||||||
<string name="website">Website</string>
|
<string name="website">Website</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user