mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-22 13:21:49 +01:00
Added option to share your favorite manga (#477)
This commit is contained in:
parent
9f20e40257
commit
596a24fce8
@ -192,7 +192,7 @@ abstract class OnlineSource(context: Context) : Source {
|
||||
*
|
||||
* @param manga the manga to be updated.
|
||||
*/
|
||||
open protected fun mangaDetailsRequest(manga: Manga): Request {
|
||||
open fun mangaDetailsRequest(manga: Manga): Request {
|
||||
return GET(baseUrl + manga.url, headers)
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package eu.kanade.tachiyomi.ui.manga.info
|
||||
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.support.customtabs.CustomTabsIntent
|
||||
@ -59,6 +60,7 @@ class MangaInfoFragment : BaseRxFragment<MangaInfoPresenter>() {
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
R.id.action_open_in_browser -> openInBrowser()
|
||||
R.id.action_share -> shareManga()
|
||||
else -> return super.onOptionsItemSelected(item)
|
||||
}
|
||||
return true
|
||||
@ -158,6 +160,24 @@ class MangaInfoFragment : BaseRxFragment<MangaInfoPresenter>() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to run Intent with [Intent.ACTION_SEND], which show share dialog.
|
||||
*/
|
||||
private fun shareManga() {
|
||||
val source = presenter.source as? OnlineSource ?: return
|
||||
try {
|
||||
val url = source.mangaDetailsRequest(presenter.manga).url().toString()
|
||||
val sharingIntent = Intent(Intent.ACTION_SEND).apply {
|
||||
type = "text/plain"
|
||||
putExtra(android.content.Intent.EXTRA_SUBJECT, presenter.manga.title)
|
||||
putExtra(android.content.Intent.EXTRA_TEXT, resources.getString(R.string.share_text, presenter.manga.title, url))
|
||||
}
|
||||
startActivity(Intent.createChooser(sharingIntent, resources.getText(R.string.share_subject)))
|
||||
} catch (e: Exception) {
|
||||
context.toast(e.message)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update FAB with correct drawable.
|
||||
*
|
||||
|
@ -128,5 +128,4 @@ class MangaInfoPresenter : BasePresenter<MangaInfoFragment>() {
|
||||
private fun refreshManga() {
|
||||
start(GET_MANGA)
|
||||
}
|
||||
|
||||
}
|
||||
|
9
app/src/main/res/drawable/ic_share_white_24dp.xml
Normal file
9
app/src/main/res/drawable/ic_share_white_24dp.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportHeight="24.0"
|
||||
android:viewportWidth="24.0">
|
||||
<path
|
||||
android:fillColor="#FFFFFFFF"
|
||||
android:pathData="M18,16.08c-0.76,0 -1.44,0.3 -1.96,0.77L8.91,12.7c0.05,-0.23 0.09,-0.46 0.09,-0.7s-0.04,-0.47 -0.09,-0.7l7.05,-4.11c0.54,0.5 1.25,0.81 2.04,0.81 1.66,0 3,-1.34 3,-3s-1.34,-3 -3,-3 -3,1.34 -3,3c0,0.24 0.04,0.47 0.09,0.7L8.04,9.81C7.5,9.31 6.79,9 6,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3c0.79,0 1.5,-0.31 2.04,-0.81l7.12,4.16c-0.05,0.21 -0.08,0.43 -0.08,0.65 0,1.61 1.31,2.92 2.92,2.92 1.61,0 2.92,-1.31 2.92,-2.92s-1.31,-2.92 -2.92,-2.92z" />
|
||||
</vector>
|
@ -2,6 +2,12 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item
|
||||
android:id="@+id/action_share"
|
||||
android:icon="@drawable/ic_share_white_24dp"
|
||||
android:title="@string/action_share"
|
||||
app:showAsAction="ifRoom" />
|
||||
|
||||
<item android:id="@+id/action_open_in_browser"
|
||||
android:title="@string/action_open_in_browser"
|
||||
app:showAsAction="never"/>
|
||||
|
@ -56,6 +56,7 @@
|
||||
<string name="action_cancel">Cancel</string>
|
||||
<string name="action_sort">Sort</string>
|
||||
<string name="action_install">Install</string>
|
||||
<string name="action_share">Share</string>
|
||||
|
||||
<!-- Operations -->
|
||||
<string name="deleting">Deleting…</string>
|
||||
@ -222,6 +223,8 @@
|
||||
<string name="manga_info_status_label">Status</string>
|
||||
<string name="manga_info_source_label">Source</string>
|
||||
<string name="manga_info_genres_label">Genres</string>
|
||||
<string name="share_subject">Share…</string>
|
||||
<string name="share_text">Check out %1$s! at %2$s</string>
|
||||
|
||||
<!-- Manga chapters fragment -->
|
||||
<string name="manga_chapters_tab">Chapters</string>
|
||||
|
Loading…
Reference in New Issue
Block a user