diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 1814eed8a..c2c6e2198 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -34,7 +34,9 @@ android:theme="@style/AppTheme.Light" tools:ignore="AllowBackup,GoogleAppIndexingWarning,UnusedAttribute"> - + @@ -50,6 +52,7 @@ @@ -66,6 +69,7 @@ @@ -82,6 +86,7 @@ @@ -98,6 +103,7 @@ @@ -114,6 +120,7 @@ @@ -130,6 +137,7 @@ @@ -151,6 +159,7 @@ @@ -304,6 +313,7 @@ @@ -325,6 +335,7 @@ @@ -339,6 +350,7 @@ @@ -388,12 +400,24 @@ + + + + + - + diff --git a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt index 007fe1b4e..17803680c 100644 --- a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt +++ b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt @@ -440,6 +440,10 @@ class AnalyzeRule(val ruleData: RuleDataInterface) : JsExtensions { mode = Mode.Json ruleStr.substring(6) } + ruleStr.startsWith("//") -> {//XPath特征很明显,无需配置单独的识别标头 + mode = Mode.XPath + ruleStr + } isJSON || ruleStr.startsWith("$.") || ruleStr.startsWith("$[") -> { mode = Mode.Json ruleStr diff --git a/app/src/main/java/io/legado/app/service/WebService.kt b/app/src/main/java/io/legado/app/service/WebService.kt index 2f9afe931..719f7f6e4 100644 --- a/app/src/main/java/io/legado/app/service/WebService.kt +++ b/app/src/main/java/io/legado/app/service/WebService.kt @@ -45,6 +45,9 @@ class WebService : BaseService() { isRun = true notificationContent = getString(R.string.service_starting) upNotification() + startService { + action = IntentAction.start + } } override fun onDestroy() { @@ -57,6 +60,9 @@ class WebService : BaseService() { webSocketServer?.stop() } postEvent(EventBus.WEB_SERVICE, "") + startService { + action = IntentAction.stop + } } override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { diff --git a/app/src/main/java/io/legado/app/service/WebTileService.kt b/app/src/main/java/io/legado/app/service/WebTileService.kt new file mode 100644 index 000000000..c1a1ccad5 --- /dev/null +++ b/app/src/main/java/io/legado/app/service/WebTileService.kt @@ -0,0 +1,47 @@ +package io.legado.app.service + +import android.content.Intent +import android.os.Build +import android.service.quicksettings.Tile +import android.service.quicksettings.TileService +import androidx.annotation.RequiresApi +import io.legado.app.constant.IntentAction + +@RequiresApi(Build.VERSION_CODES.N) +class WebTileService : TileService() { + + override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { + when (intent?.action) { + IntentAction.start -> { + qsTile.state = Tile.STATE_ACTIVE + qsTile.updateTile() + } + IntentAction.stop -> { + qsTile.state = Tile.STATE_INACTIVE + qsTile.updateTile() + } + } + return super.onStartCommand(intent, flags, startId) + } + + override fun onStartListening() { + super.onStartListening() + if (WebService.isRun) { + qsTile.state = Tile.STATE_ACTIVE + qsTile.updateTile() + } else { + qsTile.state = Tile.STATE_INACTIVE + qsTile.updateTile() + } + } + + override fun onClick() { + super.onClick() + if (WebService.isRun) { + WebService.stop(this) + } else { + WebService.start(this) + } + } + +} \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_web_service_phone.xml b/app/src/main/res/drawable/ic_web_service_phone.xml deleted file mode 100644 index f48dd2c8d..000000000 --- a/app/src/main/res/drawable/ic_web_service_phone.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - \ No newline at end of file