From 09e7d56ff2920ff2e8a513899a0d27482d5f73b9 Mon Sep 17 00:00:00 2001 From: arkon Date: Thu, 16 Jan 2020 22:13:34 -0500 Subject: [PATCH] Move "Open in browser" option to webview only --- .../browse/BrowseCatalogueController.kt | 19 +++++----------- .../ui/manga/info/MangaInfoController.kt | 15 +------------ .../tachiyomi/ui/webview/WebViewActivity.kt | 5 +++++ app/src/main/res/menu/catalogue_list.xml | 22 ++++++++----------- app/src/main/res/menu/manga_info.xml | 14 +++++------- app/src/main/res/menu/webview.xml | 5 +++++ 6 files changed, 32 insertions(+), 48 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/browse/BrowseCatalogueController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/browse/BrowseCatalogueController.kt index 1391a2321f..2c72322feb 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/browse/BrowseCatalogueController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/browse/BrowseCatalogueController.kt @@ -2,17 +2,17 @@ package eu.kanade.tachiyomi.ui.catalogue.browse import android.content.res.Configuration import android.os.Bundle -import com.google.android.material.snackbar.Snackbar -import androidx.drawerlayout.widget.DrawerLayout -import androidx.appcompat.widget.* import android.view.* +import androidx.appcompat.widget.SearchView import androidx.core.view.GravityCompat +import androidx.drawerlayout.widget.DrawerLayout import androidx.recyclerview.widget.DividerItemDecoration import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import com.afollestad.materialdialogs.MaterialDialog import com.f2prateek.rx.preferences.Preference +import com.google.android.material.snackbar.Snackbar import com.jakewharton.rxbinding.support.v7.widget.queryTextChangeEvents import eu.davidea.flexibleadapter.FlexibleAdapter import eu.davidea.flexibleadapter.items.IFlexible @@ -31,8 +31,9 @@ import eu.kanade.tachiyomi.ui.manga.MangaController import eu.kanade.tachiyomi.ui.webview.WebViewActivity import eu.kanade.tachiyomi.util.* import eu.kanade.tachiyomi.widget.AutofitRecyclerView -import kotlinx.android.synthetic.main.catalogue_controller.* -import kotlinx.android.synthetic.main.main_activity.* +import kotlinx.android.synthetic.main.catalogue_controller.catalogue_view +import kotlinx.android.synthetic.main.catalogue_controller.progress +import kotlinx.android.synthetic.main.main_activity.drawer import rx.Observable import rx.Subscription import rx.android.schedulers.AndroidSchedulers @@ -274,7 +275,6 @@ open class BrowseCatalogueController(bundle: Bundle) : super.onPrepareOptionsMenu(menu) val isHttpSource = presenter.source is HttpSource - menu.findItem(R.id.action_open_in_browser).isVisible = isHttpSource menu.findItem(R.id.action_open_in_web_view).isVisible = isHttpSource } @@ -283,19 +283,12 @@ open class BrowseCatalogueController(bundle: Bundle) : R.id.action_search -> expandActionViewFromInteraction = true R.id.action_display_mode -> swapDisplayMode() R.id.action_set_filter -> navView?.let { activity?.drawer?.openDrawer(GravityCompat.END) } - R.id.action_open_in_browser -> openInBrowser() R.id.action_open_in_web_view -> openInWebView() else -> return super.onOptionsItemSelected(item) } return true } - private fun openInBrowser() { - val source = presenter.source as? HttpSource ?: return - - activity?.openInBrowser(source.baseUrl) - } - private fun openInWebView() { val source = presenter.source as? HttpSource ?: return diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoController.kt index 60112e2d7c..d4c56142ce 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoController.kt @@ -41,7 +41,6 @@ import eu.kanade.tachiyomi.ui.library.LibraryController import eu.kanade.tachiyomi.ui.main.MainActivity import eu.kanade.tachiyomi.ui.manga.MangaController import eu.kanade.tachiyomi.ui.webview.WebViewActivity -import eu.kanade.tachiyomi.util.openInBrowser import eu.kanade.tachiyomi.util.snack import eu.kanade.tachiyomi.util.toast import eu.kanade.tachiyomi.util.truncateCenter @@ -134,13 +133,11 @@ class MangaInfoController : NucleusController(), override fun onOptionsItemSelected(item: MenuItem): Boolean { when (item.itemId) { - R.id.action_open_in_browser -> openInBrowser() R.id.action_open_in_web_view -> openInWebView() R.id.action_share -> shareManga() R.id.action_add_to_home_screen -> addToHomeScreen() - else -> return super.onOptionsItemSelected(item) } - return true + return super.onOptionsItemSelected(item) } /** @@ -278,16 +275,6 @@ class MangaInfoController : NucleusController(), } } - /** - * Open the manga in browser. - */ - private fun openInBrowser() { - val context = view?.context ?: return - val source = presenter.source as? HttpSource ?: return - - context.openInBrowser(source.mangaDetailsRequest(presenter.manga).url.toString()) - } - private fun openInWebView() { val source = presenter.source as? HttpSource ?: return diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/webview/WebViewActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/webview/WebViewActivity.kt index 170fda36ed..06c7bf31c6 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/webview/WebViewActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/webview/WebViewActivity.kt @@ -123,6 +123,7 @@ class WebViewActivity : BaseActivity() { R.id.action_web_forward -> webview.goForward() R.id.action_web_refresh -> refreshPage() R.id.action_web_share -> shareWebpage() + R.id.action_web_browser -> openInBrowser() } return super.onOptionsItemSelected(item) } @@ -144,6 +145,10 @@ class WebViewActivity : BaseActivity() { } } + private fun openInBrowser() { + openInBrowser(webview.url) + } + companion object { private const val SOURCE_KEY = "source_key" private const val URL_KEY = "url_key" diff --git a/app/src/main/res/menu/catalogue_list.xml b/app/src/main/res/menu/catalogue_list.xml index 80d8739fd7..1451609075 100644 --- a/app/src/main/res/menu/catalogue_list.xml +++ b/app/src/main/res/menu/catalogue_list.xml @@ -1,33 +1,29 @@ + xmlns:tools="http://schemas.android.com/tools" + tools:context=".CatalogueListActivity"> + android:title="@string/action_search" + app:actionViewClass="androidx.appcompat.widget.SearchView" + app:showAsAction="collapseActionView|ifRoom" /> + android:title="@string/action_set_filter" + app:showAsAction="ifRoom" /> - - + app:showAsAction="ifRoom" /> + app:showAsAction="never" /> diff --git a/app/src/main/res/menu/manga_info.xml b/app/src/main/res/menu/manga_info.xml index 6a5edad194..e7fcebc39b 100644 --- a/app/src/main/res/menu/manga_info.xml +++ b/app/src/main/res/menu/manga_info.xml @@ -8,16 +8,14 @@ android:title="@string/action_share" app:showAsAction="ifRoom" /> - - - + app:showAsAction="never" /> - + app:showAsAction="never" /> diff --git a/app/src/main/res/menu/webview.xml b/app/src/main/res/menu/webview.xml index 1a7daa2374..f4d9eec4e7 100644 --- a/app/src/main/res/menu/webview.xml +++ b/app/src/main/res/menu/webview.xml @@ -24,4 +24,9 @@ android:title="@string/action_share" app:showAsAction="never" /> + +