From 33b3be0d0ed66f249cc956587feed050ac3d2769 Mon Sep 17 00:00:00 2001 From: arkon Date: Thu, 16 Sep 2021 17:57:41 -0400 Subject: [PATCH] Move extension app info button Aligns with TachiyomiJ2K. --- .../details/ExtensionDetailsController.kt | 13 +------------ .../details/ExtensionDetailsHeaderAdapter.kt | 3 +++ .../details/ExtensionDetailsPresenter.kt | 19 +++++++++++++++---- .../res/layout/extension_detail_header.xml | 13 +++++++++++++ app/src/main/res/menu/extension_details.xml | 5 ----- app/src/main/res/values/strings.xml | 2 +- app/src/main/res/values/styles.xml | 2 ++ 7 files changed, 35 insertions(+), 22 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsController.kt index ea7a6daf10..3814dc9caa 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsController.kt @@ -2,10 +2,7 @@ package eu.kanade.tachiyomi.ui.browse.extension.details import android.annotation.SuppressLint import android.content.Context -import android.content.Intent -import android.net.Uri import android.os.Bundle -import android.provider.Settings import android.util.TypedValue import android.view.LayoutInflater import android.view.Menu @@ -68,7 +65,7 @@ class ExtensionDetailsController(bundle: Bundle? = null) : } override fun createPresenter(): ExtensionDetailsPresenter { - return ExtensionDetailsPresenter(args.getString(PKGNAME_KEY)!!) + return ExtensionDetailsPresenter(this, args.getString(PKGNAME_KEY)!!) } override fun getTitle(): String? { @@ -188,7 +185,6 @@ class ExtensionDetailsController(bundle: Bundle? = null) : R.id.action_history -> openCommitHistory() R.id.action_enable_all -> toggleAllSources(true) R.id.action_disable_all -> toggleAllSources(false) - R.id.action_open_in_settings -> openInSettings() } return super.onOptionsItemSelected(item) } @@ -219,13 +215,6 @@ class ExtensionDetailsController(bundle: Bundle? = null) : openInBrowser(url) } - private fun openInSettings() { - val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS).apply { - data = Uri.fromParts("package", presenter.pkgName, null) - } - startActivity(intent) - } - private fun Source.isEnabled(): Boolean { return id.toString() !in preferences.disabledSources().get() } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsHeaderAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsHeaderAdapter.kt index b65d74ade1..897e05c958 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsHeaderAdapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsHeaderAdapter.kt @@ -44,6 +44,9 @@ class ExtensionDetailsHeaderAdapter(private val presenter: ExtensionDetailsPrese binding.btnUninstall.clicks() .onEach { presenter.uninstallExtension() } .launchIn(presenter.presenterScope) + binding.btnAppInfo.clicks() + .onEach { presenter.openInSettings() } + .launchIn(presenter.presenterScope) if (extension.isObsolete) { binding.warningBanner.isVisible = true diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsPresenter.kt index 149de4b119..9a18a597f8 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsPresenter.kt @@ -1,17 +1,21 @@ package eu.kanade.tachiyomi.ui.browse.extension.details +import android.content.Intent +import android.net.Uri import android.os.Bundle +import android.provider.Settings import eu.kanade.tachiyomi.extension.ExtensionManager import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter import rx.android.schedulers.AndroidSchedulers -import uy.kohesive.injekt.Injekt -import uy.kohesive.injekt.api.get +import uy.kohesive.injekt.injectLazy class ExtensionDetailsPresenter( - val pkgName: String, - private val extensionManager: ExtensionManager = Injekt.get() + private val controller: ExtensionDetailsController, + private val pkgName: String, ) : BasePresenter() { + private val extensionManager: ExtensionManager by injectLazy() + val extension = extensionManager.installedExtensions.find { it.pkgName == pkgName } override fun onCreate(savedState: Bundle?) { @@ -36,4 +40,11 @@ class ExtensionDetailsPresenter( val extension = extension ?: return extensionManager.uninstallExtension(extension.pkgName) } + + fun openInSettings() { + val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS).apply { + data = Uri.fromParts("package", pkgName, null) + } + controller.startActivity(intent) + } } diff --git a/app/src/main/res/layout/extension_detail_header.xml b/app/src/main/res/layout/extension_detail_header.xml index 8abf18b1ec..2dd068866e 100644 --- a/app/src/main/res/layout/extension_detail_header.xml +++ b/app/src/main/res/layout/extension_detail_header.xml @@ -98,11 +98,24 @@