mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-19 15:31:13 +01:00
Rewrite link intercept activity
Fix compatibility issues between lewd sources and manga info screen
This commit is contained in:
@@ -36,11 +36,11 @@ import eu.kanade.tachiyomi.ui.migration.MigrationController
|
||||
import eu.kanade.tachiyomi.util.inflate
|
||||
import eu.kanade.tachiyomi.util.toast
|
||||
import eu.kanade.tachiyomi.widget.DrawerSwipeCloseListener
|
||||
import exh.FavoritesSyncHelper
|
||||
import exh.metadata.loadAllMetadata
|
||||
import exh.metadata.models.SearchableGalleryMetadata
|
||||
import io.realm.Realm
|
||||
import io.realm.RealmResults
|
||||
import kotlinx.android.synthetic.main.main_activity.*
|
||||
import kotlinx.android.synthetic.main.library_controller.*
|
||||
import kotlinx.android.synthetic.main.main_activity.*
|
||||
import rx.Subscription
|
||||
@@ -133,6 +133,8 @@ class LibraryController(
|
||||
var realm: Realm? = null
|
||||
//Cached metadata
|
||||
var meta: Map<KClass<out SearchableGalleryMetadata>, RealmResults<out SearchableGalleryMetadata>>? = null
|
||||
//Favorites
|
||||
val favorites by lazy { FavoritesSyncHelper(activity!!) }
|
||||
// <-- EH
|
||||
|
||||
init {
|
||||
@@ -403,6 +405,9 @@ class LibraryController(
|
||||
R.id.action_source_migration -> {
|
||||
router.pushController(MigrationController().withFadeTransaction())
|
||||
}
|
||||
R.id.action_download_favorites -> {
|
||||
favorites.guiSyncFavorites { }
|
||||
}
|
||||
else -> return super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ import eu.kanade.tachiyomi.data.glide.GlideApp
|
||||
import eu.kanade.tachiyomi.data.notification.NotificationReceiver
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.source.Source
|
||||
import eu.kanade.tachiyomi.source.SourceManager
|
||||
import eu.kanade.tachiyomi.source.model.SManga
|
||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||
import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
||||
@@ -45,6 +46,8 @@ import eu.kanade.tachiyomi.util.getResourceColor
|
||||
import eu.kanade.tachiyomi.util.snack
|
||||
import eu.kanade.tachiyomi.util.toast
|
||||
import eu.kanade.tachiyomi.util.truncateCenter
|
||||
import exh.EH_SOURCE_ID
|
||||
import exh.EXH_SOURCE_ID
|
||||
import jp.wasabeef.glide.transformations.CropSquareTransformation
|
||||
import jp.wasabeef.glide.transformations.MaskTransformation
|
||||
import kotlinx.android.synthetic.main.manga_info_controller.*
|
||||
@@ -66,6 +69,8 @@ class MangaInfoController : NucleusController<MangaInfoPresenter>(),
|
||||
*/
|
||||
private val preferences: PreferencesHelper by injectLazy()
|
||||
|
||||
private val sourceManager: SourceManager by injectLazy()
|
||||
|
||||
init {
|
||||
setHasOptionsMenu(true)
|
||||
setOptionsMenuHidden(true)
|
||||
@@ -103,22 +108,38 @@ class MangaInfoController : NucleusController<MangaInfoPresenter>(),
|
||||
}
|
||||
|
||||
manga_artist.clicks().subscribeUntilDestroy {
|
||||
performGlobalSearch(manga_artist.text.toString())
|
||||
//EXH Special case E-Hentai/ExHentai to use tag based search
|
||||
var text = manga_artist.text.toString()
|
||||
if(isEHentaiBasedSource())
|
||||
text = wrapTag("artist", text)
|
||||
performGlobalSearch(text)
|
||||
}
|
||||
|
||||
manga_author.longClicks().subscribeUntilDestroy {
|
||||
copyToClipboard(manga_author.text.toString(), manga_author.text.toString())
|
||||
//EXH Special case E-Hentai/ExHentai to ignore author field (unused)
|
||||
if(!isEHentaiBasedSource())
|
||||
copyToClipboard(manga_author.text.toString(), manga_author.text.toString())
|
||||
}
|
||||
|
||||
manga_author.clicks().subscribeUntilDestroy {
|
||||
performGlobalSearch(manga_author.text.toString())
|
||||
//EXH Special case E-Hentai/ExHentai to ignore author field (unused)
|
||||
if(!isEHentaiBasedSource())
|
||||
performGlobalSearch(manga_author.text.toString())
|
||||
}
|
||||
|
||||
manga_summary.longClicks().subscribeUntilDestroy {
|
||||
copyToClipboard(view.context.getString(R.string.description), manga_summary.text.toString())
|
||||
}
|
||||
|
||||
manga_genres_tags.setOnTagClickListener { tag -> performGlobalSearch(tag) }
|
||||
manga_genres_tags.setOnTagClickListener { tag ->
|
||||
//EXH Special case E-Hentai/ExHentai to use tag based search
|
||||
var text = tag
|
||||
if(isEHentaiBasedSource()) {
|
||||
val parsed = parseTag(text)
|
||||
text = wrapTag(parsed.first, parsed.second)
|
||||
}
|
||||
performGlobalSearch(text)
|
||||
}
|
||||
|
||||
manga_cover.longClicks().subscribeUntilDestroy {
|
||||
copyToClipboard(view.context.getString(R.string.title), presenter.manga.title)
|
||||
@@ -491,6 +512,32 @@ class MangaInfoController : NucleusController<MangaInfoPresenter>(),
|
||||
router.pushController(CatalogueSearchController(query).withFadeTransaction())
|
||||
}
|
||||
|
||||
// --> EH
|
||||
private fun wrapTag(namespace: String, tag: String)
|
||||
= if(tag.contains(' '))
|
||||
"$namespace:\"$tag$\""
|
||||
else
|
||||
"$namespace:$tag$"
|
||||
|
||||
private fun parseTag(tag: String) = tag.substringBefore(':').trim() to tag.substringAfter(':').trim()
|
||||
|
||||
private fun isEHentaiBasedSource(): Boolean {
|
||||
val mangaSourceText = manga_source.text
|
||||
|
||||
sourceManager.get(EH_SOURCE_ID)?.let {
|
||||
if(mangaSourceText.startsWith(it.name))
|
||||
return true
|
||||
}
|
||||
|
||||
sourceManager.get(EXH_SOURCE_ID)?.let {
|
||||
if(mangaSourceText.startsWith(it.name))
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
// <-- EH
|
||||
|
||||
/**
|
||||
* Create shortcut using ShortcutManager.
|
||||
*
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.bluelinelabs.conductor.RouterTransaction
|
||||
import com.bluelinelabs.conductor.changehandler.FadeChangeHandler
|
||||
import exh.ui.login.LoginController
|
||||
import rx.android.schedulers.AndroidSchedulers
|
||||
import rx.schedulers.Schedulers
|
||||
|
||||
/**
|
||||
* EH Settings fragment
|
||||
@@ -22,6 +23,7 @@ class SettingsEhController : SettingsController() {
|
||||
defaultValue = false
|
||||
preferences.enableExhentai()
|
||||
.asObservable()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeUntilDestroy {
|
||||
isChecked = it
|
||||
|
||||
Reference in New Issue
Block a user