mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-23 15:21:51 +01:00
Supporting Recents URL sharing
Manga Details and reader will share manga url Browse Source will share source url
This commit is contained in:
parent
89f0ecaeaa
commit
9077140800
@ -3,10 +3,12 @@ package eu.kanade.tachiyomi.ui.main
|
||||
import android.animation.AnimatorSet
|
||||
import android.animation.ValueAnimator
|
||||
import android.app.Dialog
|
||||
import android.app.assist.AssistContent
|
||||
import android.content.Intent
|
||||
import android.graphics.Color
|
||||
import android.graphics.Rect
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
@ -55,6 +57,7 @@ import eu.kanade.tachiyomi.data.updater.UpdateResult
|
||||
import eu.kanade.tachiyomi.data.updater.UpdaterNotifier
|
||||
import eu.kanade.tachiyomi.databinding.MainActivityBinding
|
||||
import eu.kanade.tachiyomi.extension.api.ExtensionGithubApi
|
||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||
import eu.kanade.tachiyomi.ui.base.MaterialMenuSheet
|
||||
import eu.kanade.tachiyomi.ui.base.activity.BaseActivity
|
||||
import eu.kanade.tachiyomi.ui.base.controller.BaseController
|
||||
@ -647,6 +650,25 @@ open class MainActivity : BaseActivity<MainActivityBinding>(), DownloadServiceLi
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onProvideAssistContent(outContent: AssistContent) {
|
||||
super.onProvideAssistContent(outContent)
|
||||
when (val controller = router.backstack.lastOrNull()?.controller) {
|
||||
is MangaDetailsController -> {
|
||||
val source = controller.presenter.source as? HttpSource ?: return
|
||||
val url = try {
|
||||
source.mangaDetailsRequest(controller.presenter.manga).url.toString()
|
||||
} catch (e: Exception) {
|
||||
return
|
||||
}
|
||||
outContent.webUri = Uri.parse(url)
|
||||
}
|
||||
is BrowseSourceController -> {
|
||||
val source = controller.presenter.source as? HttpSource ?: return
|
||||
outContent.webUri = Uri.parse(source.baseUrl)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
overflowDialog?.dismiss()
|
||||
|
@ -1,6 +1,7 @@
|
||||
package eu.kanade.tachiyomi.ui.reader
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.assist.AssistContent
|
||||
import android.content.ClipData
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
@ -9,6 +10,7 @@ import android.content.res.Configuration
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.LayerDrawable
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.KeyEvent
|
||||
@ -41,6 +43,7 @@ import eu.kanade.tachiyomi.data.preference.asImmediateFlowIn
|
||||
import eu.kanade.tachiyomi.data.preference.toggle
|
||||
import eu.kanade.tachiyomi.databinding.ReaderActivityBinding
|
||||
import eu.kanade.tachiyomi.source.model.Page
|
||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||
import eu.kanade.tachiyomi.ui.base.MaterialMenuSheet
|
||||
import eu.kanade.tachiyomi.ui.base.activity.BaseRxActivity
|
||||
import eu.kanade.tachiyomi.ui.main.MainActivity
|
||||
@ -1225,6 +1228,18 @@ class ReaderActivity :
|
||||
startActivity(Intent.createChooser(intent, getString(R.string.share)))
|
||||
}
|
||||
|
||||
override fun onProvideAssistContent(outContent: AssistContent) {
|
||||
super.onProvideAssistContent(outContent)
|
||||
val manga = presenter.manga ?: return
|
||||
val source = presenter.source as? HttpSource ?: return
|
||||
val url = try {
|
||||
source.mangaDetailsRequest(manga).url.toString()
|
||||
} catch (e: Exception) {
|
||||
return
|
||||
}
|
||||
outContent.webUri = Uri.parse(url)
|
||||
}
|
||||
|
||||
/**
|
||||
* Called from the page sheet. It delegates saving the image of the given [page] on external
|
||||
* storage to the presenter.
|
||||
|
@ -20,6 +20,7 @@ import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.data.track.DelayedTrackingUpdateJob
|
||||
import eu.kanade.tachiyomi.data.track.TrackManager
|
||||
import eu.kanade.tachiyomi.source.LocalSource
|
||||
import eu.kanade.tachiyomi.source.Source
|
||||
import eu.kanade.tachiyomi.source.SourceManager
|
||||
import eu.kanade.tachiyomi.source.model.Page
|
||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||
@ -76,6 +77,9 @@ class ReaderPresenter(
|
||||
var manga: Manga? = null
|
||||
private set
|
||||
|
||||
val source: Source?
|
||||
get() = manga?.source?.let { sourceManager.getOrStub(it) }
|
||||
|
||||
/**
|
||||
* The chapter id of the currently loaded chapter. Used to restore from process kill.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user