Move extension app info button

Aligns with TachiyomiJ2K.
This commit is contained in:
arkon 2021-09-16 17:57:41 -04:00
parent cfd1b4a6c6
commit 33b3be0d0e
7 changed files with 35 additions and 22 deletions

View File

@ -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()
}

View File

@ -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

View File

@ -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<ExtensionDetailsController>() {
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)
}
}

View File

@ -98,11 +98,24 @@
<Button
android:id="@+id/btn_uninstall"
style="@style/Widget.Tachiyomi.Button.OutlinedButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginEnd="4dp"
android:text="@string/ext_uninstall"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@+id/btn_app_info"
app:layout_constraintTop_toBottomOf="@id/pkgname" />
<Button
android:id="@+id/btn_app_info"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginStart="4dp"
android:text="@string/ext_app_info"
app:layout_constraintStart_toEndOf="@+id/btn_uninstall"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/pkgname" />

View File

@ -18,9 +18,4 @@
android:title="@string/action_disable_all"
app:showAsAction="never" />
<item
android:id="@+id/action_open_in_settings"
android:title="@string/action_open_in_settings"
app:showAsAction="never" />
</menu>

View File

@ -83,7 +83,6 @@
<!-- Do not translate "WebView" -->
<string name="action_open_in_web_view">Open in WebView</string>
<string name="action_web_view" translatable="false">WebView</string>
<string name="action_open_in_settings">Open in Settings</string>
<string name="action_migrate">Migrate</string>
<string name="action_display_mode">Display mode</string>
<string name="action_display">Display</string>
@ -257,6 +256,7 @@
<string name="ext_untrusted">Untrusted</string>
<string name="ext_uninstall">Uninstall</string>
<string name="ext_available">Available</string>
<string name="ext_app_info">App info</string>
<string name="untrusted_extension">Untrusted extension</string>
<string name="untrusted_extension_message">This extension was signed with an untrusted certificate and wasn\'t activated.\n\nA malicious extension could read any login credentials stored in Tachiyomi or execute arbitrary code.\n\nBy trusting this certificate you accept these risks.</string>
<string name="obsolete_extension_message">This extension is no longer available.</string>

View File

@ -240,6 +240,8 @@
<item name="rippleColor">@null</item>
</style>
<style name="Widget.Tachiyomi.Button.OutlinedButton" parent="Widget.MaterialComponents.Button.OutlinedButton" />
<!--=================-->
<!--Widgets.TabLayout-->