From 0184b0678dfab2a416b6b1c1ed6aaf469e68f8e9 Mon Sep 17 00:00:00 2001 From: Jay Date: Fri, 22 May 2020 15:07:38 -0400 Subject: [PATCH] Replaced filter button in reader with open manga in webview --- .../tachiyomi/ui/reader/ReaderActivity.kt | 15 ++++++++ .../tachiyomi/ui/reader/ReaderPresenter.kt | 3 ++ .../ui/reader/chapter/ChapterFilterSheet.kt | 37 ------------------- .../ui/reader/chapter/ReaderChapterSheet.kt | 14 +++---- .../main/res/layout/chapter_filter_sheet.xml | 16 -------- .../main/res/layout/chapter_header_item.xml | 8 ++-- .../main/res/layout/reader_chapters_sheet.xml | 8 ++-- 7 files changed, 33 insertions(+), 68 deletions(-) delete mode 100644 app/src/main/java/eu/kanade/tachiyomi/ui/reader/chapter/ChapterFilterSheet.kt delete mode 100644 app/src/main/res/layout/chapter_filter_sheet.xml diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt index 74cf0e1728..21347666de 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt @@ -48,6 +48,7 @@ import eu.kanade.tachiyomi.ui.reader.viewer.pager.L2RPagerViewer import eu.kanade.tachiyomi.ui.reader.viewer.pager.R2LPagerViewer import eu.kanade.tachiyomi.ui.reader.viewer.pager.VerticalPagerViewer import eu.kanade.tachiyomi.ui.reader.viewer.webtoon.WebtoonViewer +import eu.kanade.tachiyomi.ui.webview.WebViewActivity import eu.kanade.tachiyomi.util.storage.getUriCompat import eu.kanade.tachiyomi.util.system.GLUtil import eu.kanade.tachiyomi.util.system.ThemeUtil @@ -745,6 +746,20 @@ class ReaderActivity : BaseRxActivity(), } } + fun openMangaInBrowser() { + val source = presenter.getSource() ?: return + val url = try { + source.mangaDetailsRequest(presenter.manga!!).url.toString() + } catch (e: Exception) { + return + } + + val intent = WebViewActivity.newIntent( + applicationContext, source.id, url, presenter.manga!!.title + ) + startActivity(intent) + } + /** * Class that handles the user preferences of the reader. */ diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt index da223c825a..41ce645e15 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt @@ -17,6 +17,7 @@ import eu.kanade.tachiyomi.data.track.TrackManager import eu.kanade.tachiyomi.source.LocalSource import eu.kanade.tachiyomi.source.SourceManager import eu.kanade.tachiyomi.source.model.Page +import eu.kanade.tachiyomi.source.online.HttpSource import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter import eu.kanade.tachiyomi.ui.reader.chapter.ReaderChapterItem import eu.kanade.tachiyomi.ui.reader.loader.ChapterLoader @@ -452,6 +453,8 @@ class ReaderPresenter( return viewerChaptersRelay.value?.currChapter } + fun getSource() = sourceManager.getOrStub(manga!!.source) as? HttpSource + /** * Returns the viewer position used by this manga or the default one. */ diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/chapter/ChapterFilterSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/chapter/ChapterFilterSheet.kt deleted file mode 100644 index 75c6eda628..0000000000 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/chapter/ChapterFilterSheet.kt +++ /dev/null @@ -1,37 +0,0 @@ -package eu.kanade.tachiyomi.ui.reader.chapter - -import android.view.ViewGroup -import com.google.android.material.bottomsheet.BottomSheetBehavior -import com.google.android.material.bottomsheet.BottomSheetDialog -import eu.kanade.tachiyomi.R -import eu.kanade.tachiyomi.data.database.models.Manga -import eu.kanade.tachiyomi.ui.reader.ReaderActivity -import eu.kanade.tachiyomi.util.view.expand -import eu.kanade.tachiyomi.util.view.setBottomEdge -import eu.kanade.tachiyomi.util.view.setEdgeToEdge -import kotlinx.android.synthetic.main.chapter_filter_layout.* -import kotlinx.android.synthetic.main.chapter_filter_sheet.* -import kotlinx.android.synthetic.main.reader_chapters_sheet.* - -class ChapterFilterSheet(activity: ReaderActivity, manga: Manga) : - BottomSheetDialog(activity, R.style.BottomSheetDialogTheme) { - - init { - val view = activity.layoutInflater.inflate(R.layout.chapter_filter_sheet, null) - setContentView(view) - BottomSheetBehavior.from(view.parent as ViewGroup).expand() - setEdgeToEdge(activity, view) - setBottomEdge(show_bookmark, activity) - - chapter_filter_layout.setCheckboxes(manga) - setOnDismissListener { - activity.presenter.setFilters( - show_read.isChecked, - show_unread.isChecked, - show_download.isChecked, - show_bookmark.isChecked - ) - activity.chapters_bottom_sheet.refreshList() - } - } -} diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/chapter/ReaderChapterSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/chapter/ReaderChapterSheet.kt index ec309b5356..5b65297f82 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/chapter/ReaderChapterSheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/chapter/ReaderChapterSheet.kt @@ -53,8 +53,8 @@ class ReaderChapterSheet @JvmOverloads constructor(context: Context, attrs: Attr } } - filter_button.setOnClickListener { - ChapterFilterSheet(activity, presenter.manga!!).show() + webview_button.setOnClickListener { + activity.openMangaInBrowser() } post { @@ -66,8 +66,8 @@ class ReaderChapterSheet @JvmOverloads constructor(context: Context, attrs: Attr pill.alpha = (1 - max(0f, progress)) * 0.25f val trueProgress = max(progress, 0f) chapters_button.alpha = 1 - trueProgress - filter_button.alpha = trueProgress - filter_button.visibleIf(filter_button.alpha > 0) + webview_button.alpha = trueProgress + webview_button.visibleIf(webview_button.alpha > 0) chapters_button.visInvisIf(chapters_button.alpha > 0) backgroundTintList = ColorStateList.valueOf(lerpColor(primary, fullPrimary, trueProgress)) @@ -87,15 +87,15 @@ class ReaderChapterSheet @JvmOverloads constructor(context: Context, attrs: Attr chapter_recycler.height / 2 - 30.dpToPx ) chapters_button.alpha = 1f - filter_button.alpha = 0f + webview_button.alpha = 0f } if (state == BottomSheetBehavior.STATE_EXPANDED) { chapter_recycler.alpha = 1f chapters_button.alpha = 0f - filter_button.alpha = 1f + webview_button.alpha = 1f if (activity.sheetManageNavColor) activity.window.navigationBarColor = primary } - filter_button.visibleIf(state != BottomSheetBehavior.STATE_COLLAPSED) + webview_button.visibleIf(state != BottomSheetBehavior.STATE_COLLAPSED) chapters_button.visInvisIf(state != BottomSheetBehavior.STATE_EXPANDED) } }) diff --git a/app/src/main/res/layout/chapter_filter_sheet.xml b/app/src/main/res/layout/chapter_filter_sheet.xml deleted file mode 100644 index 89e5bb0eaa..0000000000 --- a/app/src/main/res/layout/chapter_filter_sheet.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/chapter_header_item.xml b/app/src/main/res/layout/chapter_header_item.xml index d9868ea1a2..76f2560cf2 100644 --- a/app/src/main/res/layout/chapter_header_item.xml +++ b/app/src/main/res/layout/chapter_header_item.xml @@ -28,7 +28,7 @@ app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintTop_toTopOf="@id/webview_button" /> \ No newline at end of file diff --git a/app/src/main/res/layout/reader_chapters_sheet.xml b/app/src/main/res/layout/reader_chapters_sheet.xml index 03d513b460..94eaf2ff7d 100644 --- a/app/src/main/res/layout/reader_chapters_sheet.xml +++ b/app/src/main/res/layout/reader_chapters_sheet.xml @@ -46,19 +46,19 @@ app:srcCompat="@drawable/ic_format_list_numbered_24dp" /> + app:srcCompat="@drawable/ic_open_in_webview_24dp" />