浏览代码

Add shortcut to open extension package in system settings

arkon 4 年之前
父节点
当前提交
ce22b2c29a

+ 11 - 0
app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/details/ExtensionDetailsController.kt

@@ -2,7 +2,10 @@ 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
@@ -180,6 +183,7 @@ class ExtensionDetailsController(bundle: Bundle? = null) :
         when (item.itemId) {
             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)
     }
@@ -204,6 +208,13 @@ class ExtensionDetailsController(bundle: Bundle? = null) :
         )
     }
 
+    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()
     }

+ 5 - 0
app/src/main/res/menu/extension_details.xml

@@ -11,4 +11,9 @@
         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>

+ 1 - 0
app/src/main/res/values/strings.xml

@@ -81,6 +81,7 @@
     <string name="action_move">Move</string>
     <string name="action_open_in_browser">Open in browser</string>
     <string name="action_open_in_web_view">Open in 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>