Add share menu item in reader
Closes #9510 (cherry picked from commit 841f80f935225bdb7ee7e400d2b2aa8176c5e4c5) # Conflicts: # app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt # app/src/main/res/menu/reader.xml
This commit is contained in:
parent
40353c6dc9
commit
805a88df25
@ -377,16 +377,16 @@ class ReaderActivity : BaseActivity() {
|
||||
assistUrl?.let { outContent.webUri = it.toUri() }
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the options menu of the toolbar is being created. It adds our custom menu.
|
||||
*/
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
menuInflater.inflate(R.menu.reader, menu)
|
||||
|
||||
/*val isChapterBookmarked = viewModel.getCurrentChapter()?.chapter?.bookmark ?: false
|
||||
menu.findItem(R.id.action_bookmark).isVisible = !isChapterBookmarked
|
||||
menu.findItem(R.id.action_remove_bookmark).isVisible = isChapterBookmarked
|
||||
menu.findItem(R.id.action_open_in_web_view).isVisible = viewModel.getSource() is HttpSource*/
|
||||
|
||||
val isHttpSource = viewModel.getSource() is HttpSource
|
||||
menu.findItem(R.id.action_open_in_web_view).isVisible = isHttpSource
|
||||
menu.findItem(R.id.action_share).isVisible = isHttpSource*/
|
||||
|
||||
return true
|
||||
}
|
||||
@ -398,7 +398,7 @@ class ReaderActivity : BaseActivity() {
|
||||
/*override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
R.id.action_open_in_web_view -> {
|
||||
openChapterInWebview()
|
||||
openChapterInWebView()
|
||||
}
|
||||
R.id.action_bookmark -> {
|
||||
viewModel.bookmarkCurrentChapter(true)
|
||||
@ -408,6 +408,12 @@ class ReaderActivity : BaseActivity() {
|
||||
viewModel.bookmarkCurrentChapter(false)
|
||||
invalidateOptionsMenu()
|
||||
}
|
||||
R.id.action_share -> {
|
||||
assistUrl?.let {
|
||||
val intent = it.toUri().toShareIntent(this, type = "text/plain")
|
||||
startActivity(Intent.createChooser(intent, getString(R.string.action_share)))
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.onOptionsItemSelected(item)
|
||||
}*/
|
||||
@ -701,7 +707,7 @@ class ReaderActivity : BaseActivity() {
|
||||
setTooltip(R.string.action_open_in_web_view)
|
||||
|
||||
setOnClickListener {
|
||||
openChapterInWebview()
|
||||
openChapterInWebView()
|
||||
}
|
||||
}
|
||||
|
||||
@ -713,6 +719,17 @@ class ReaderActivity : BaseActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
with(binding.actionShare) {
|
||||
setTooltip(R.string.action_share)
|
||||
|
||||
setOnClickListener {
|
||||
assistUrl?.let {
|
||||
val intent = it.toUri().toShareIntent(this@ReaderActivity, type = "text/plain")
|
||||
startActivity(Intent.createChooser(intent, getString(R.string.action_share)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
with(binding.doublePage) {
|
||||
setTooltip(R.string.page_layout)
|
||||
|
||||
@ -915,6 +932,8 @@ class ReaderActivity : BaseActivity() {
|
||||
}
|
||||
actionWebView.isVisible =
|
||||
ReaderBottomButton.WebView.isIn(enabledButtons) && viewModel.getSource() is HttpSource
|
||||
actionShare.isVisible =
|
||||
ReaderBottomButton.Share.isIn(enabledButtons) && viewModel.getSource() is HttpSource
|
||||
actionChapterList.isVisible =
|
||||
ReaderBottomButton.ViewChapters.isIn(enabledButtons)
|
||||
shiftPageButton.isVisible = (viewer as? PagerViewer)?.config?.doublePages ?: false
|
||||
@ -1160,14 +1179,12 @@ class ReaderActivity : BaseActivity() {
|
||||
startPostponedEnterTransition()
|
||||
}
|
||||
|
||||
private fun openChapterInWebview() {
|
||||
private fun openChapterInWebView() {
|
||||
val manga = viewModel.manga ?: return
|
||||
val source = viewModel.getSource() ?: return
|
||||
lifecycleScope.launchIO {
|
||||
viewModel.getChapterUrl()?.let { url ->
|
||||
val intent = WebViewActivity.newIntent(this@ReaderActivity, url, source.id, manga.title)
|
||||
withUIContext { startActivity(intent) }
|
||||
}
|
||||
assistUrl?.let {
|
||||
val intent = WebViewActivity.newIntent(this@ReaderActivity, it, source.id, manga.title)
|
||||
startActivity(intent)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ import eu.kanade.tachiyomi.R
|
||||
enum class ReaderBottomButton(val value: String, @StringRes val stringRes: Int) {
|
||||
ViewChapters("vc", R.string.action_view_chapters),
|
||||
WebView("wb", R.string.action_open_in_web_view),
|
||||
Share("sh", R.string.action_share),
|
||||
ReadingMode("rm", R.string.viewer),
|
||||
Rotation("rot", R.string.rotation_type),
|
||||
CropBordersPager("cbp", R.string.pref_crop_borders_pager),
|
||||
|
@ -229,7 +229,7 @@
|
||||
android:layout_marginBottom="16dp"
|
||||
android:layoutDirection="ltr" />
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
<LinearLayout
|
||||
android:id="@+id/toolbar_bottom"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
@ -241,13 +241,10 @@
|
||||
android:id="@+id/action_chapter_list"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:contentDescription="@string/custom_filter"
|
||||
android:contentDescription="@string/chapters"
|
||||
android:padding="@dimen/screen_edge_margin"
|
||||
app:layout_constraintEnd_toStartOf="@+id/action_web_view"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintHorizontal_chainStyle="spread"
|
||||
app:srcCompat="@drawable/ic_format_list_numbered_24dp"
|
||||
app:tint="?attr/colorOnSurface" />
|
||||
|
||||
@ -256,15 +253,23 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:contentDescription="@string/custom_filter"
|
||||
android:contentDescription="@string/action_open_in_web_view"
|
||||
android:padding="@dimen/screen_edge_margin"
|
||||
app:layout_constraintEnd_toStartOf="@id/action_reading_mode"
|
||||
app:layout_constraintStart_toEndOf="@+id/action_chapter_list"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintHorizontal_chainStyle="spread"
|
||||
android:layout_weight="1"
|
||||
app:srcCompat="@drawable/ic_webview_24dp"
|
||||
app:tint="?attr/colorOnSurface" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/action_share"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:contentDescription="@string/action_share"
|
||||
android:padding="@dimen/screen_edge_margin"
|
||||
android:layout_weight="1"
|
||||
app:srcCompat="@drawable/ic_share_24dp"
|
||||
app:tint="?attr/colorOnSurface" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/action_reading_mode"
|
||||
android:layout_width="wrap_content"
|
||||
@ -272,10 +277,7 @@
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:contentDescription="@string/viewer"
|
||||
android:padding="@dimen/screen_edge_margin"
|
||||
app:layout_constraintEnd_toStartOf="@id/action_crop_borders"
|
||||
app:layout_constraintStart_toEndOf="@+id/action_web_view"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintHorizontal_chainStyle="spread"
|
||||
android:layout_weight="1"
|
||||
app:srcCompat="@drawable/ic_reader_default_24dp"
|
||||
app:tint="?attr/colorOnSurface" />
|
||||
|
||||
@ -286,10 +288,7 @@
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:contentDescription="@string/pref_crop_borders"
|
||||
android:padding="@dimen/screen_edge_margin"
|
||||
app:layout_constraintEnd_toStartOf="@id/action_rotation"
|
||||
app:layout_constraintStart_toEndOf="@+id/action_reading_mode"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintHorizontal_chainStyle="spread"
|
||||
android:layout_weight="1"
|
||||
app:srcCompat="@drawable/ic_crop_24dp"
|
||||
app:tint="?attr/colorOnSurface" />
|
||||
|
||||
@ -300,10 +299,7 @@
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:contentDescription="@string/pref_rotation_type"
|
||||
android:padding="@dimen/screen_edge_margin"
|
||||
app:layout_constraintEnd_toStartOf="@id/double_page"
|
||||
app:layout_constraintStart_toEndOf="@+id/action_crop_borders"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintHorizontal_chainStyle="spread"
|
||||
android:layout_weight="1"
|
||||
app:srcCompat="@drawable/ic_screen_rotation_24dp"
|
||||
app:tint="?attr/colorOnSurface" />
|
||||
|
||||
@ -314,10 +310,7 @@
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:contentDescription="@string/page_layout"
|
||||
android:padding="@dimen/screen_edge_margin"
|
||||
app:layout_constraintEnd_toStartOf="@id/shift_page_button"
|
||||
app:layout_constraintStart_toEndOf="@+id/action_rotation"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintHorizontal_chainStyle="spread"
|
||||
android:layout_weight="1"
|
||||
app:srcCompat="@drawable/ic_book_open_variant_24dp"
|
||||
app:tint="?attr/colorOnSurface" />
|
||||
|
||||
@ -328,10 +321,7 @@
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:contentDescription="@string/shift_double_pages"
|
||||
android:padding="@dimen/screen_edge_margin"
|
||||
app:layout_constraintEnd_toStartOf="@id/action_settings"
|
||||
app:layout_constraintStart_toEndOf="@+id/double_page"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintHorizontal_chainStyle="spread"
|
||||
android:layout_weight="1"
|
||||
app:srcCompat="@drawable/ic_page_next_outline_24dp"
|
||||
app:tint="?attr/colorOnSurface" />
|
||||
|
||||
@ -342,14 +332,11 @@
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:contentDescription="@string/action_settings"
|
||||
android:padding="@dimen/screen_edge_margin"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/shift_page_button"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintHorizontal_chainStyle="spread"
|
||||
android:layout_weight="1"
|
||||
app:srcCompat="@drawable/ic_settings_24dp"
|
||||
app:tint="?attr/colorOnSurface" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
@ -18,9 +18,12 @@
|
||||
|
||||
<item
|
||||
android:id="@+id/action_open_in_web_view"
|
||||
android:icon="@drawable/ic_webview_24dp"
|
||||
android:title="@string/action_open_in_web_view"
|
||||
app:iconTint="?attr/colorOnSurface"
|
||||
app:showAsAction="ifRoom" />-->
|
||||
app:showAsAction="never" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_share"
|
||||
android:title="@string/action_share"
|
||||
app:showAsAction="never" />-->
|
||||
|
||||
</menu>
|
||||
|
Loading…
x
Reference in New Issue
Block a user