为webService添加快捷操作

pull/1194/head
gedoor 3 years ago
parent b99df9aca7
commit 210e1bf51f
  1. 28
      app/src/main/AndroidManifest.xml
  2. 4
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt
  3. 6
      app/src/main/java/io/legado/app/service/WebService.kt
  4. 47
      app/src/main/java/io/legado/app/service/WebTileService.kt
  5. 17
      app/src/main/res/drawable/ic_web_service_phone.xml

@ -34,7 +34,9 @@
android:theme="@style/AppTheme.Light" android:theme="@style/AppTheme.Light"
tools:ignore="AllowBackup,GoogleAppIndexingWarning,UnusedAttribute"> tools:ignore="AllowBackup,GoogleAppIndexingWarning,UnusedAttribute">
<!-- 主入口 --> <!-- 主入口 -->
<activity android:name=".ui.welcome.WelcomeActivity"> <activity
android:name=".ui.welcome.WelcomeActivity"
android:exported="true">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
@ -50,6 +52,7 @@
<activity <activity
android:name=".ui.welcome.Launcher1" android:name=".ui.welcome.Launcher1"
android:enabled="false" android:enabled="false"
android:exported="true"
android:icon="@mipmap/launcher1"> android:icon="@mipmap/launcher1">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
@ -66,6 +69,7 @@
<activity <activity
android:name=".ui.welcome.Launcher2" android:name=".ui.welcome.Launcher2"
android:enabled="false" android:enabled="false"
android:exported="true"
android:icon="@mipmap/launcher2"> android:icon="@mipmap/launcher2">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
@ -82,6 +86,7 @@
<activity <activity
android:name=".ui.welcome.Launcher3" android:name=".ui.welcome.Launcher3"
android:enabled="false" android:enabled="false"
android:exported="true"
android:icon="@mipmap/launcher3"> android:icon="@mipmap/launcher3">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
@ -98,6 +103,7 @@
<activity <activity
android:name=".ui.welcome.Launcher4" android:name=".ui.welcome.Launcher4"
android:enabled="false" android:enabled="false"
android:exported="true"
android:icon="@mipmap/launcher4"> android:icon="@mipmap/launcher4">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
@ -114,6 +120,7 @@
<activity <activity
android:name=".ui.welcome.Launcher5" android:name=".ui.welcome.Launcher5"
android:enabled="false" android:enabled="false"
android:exported="true"
android:icon="@mipmap/launcher5"> android:icon="@mipmap/launcher5">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
@ -130,6 +137,7 @@
<activity <activity
android:name=".ui.welcome.Launcher6" android:name=".ui.welcome.Launcher6"
android:enabled="false" android:enabled="false"
android:exported="true"
android:icon="@mipmap/launcher6"> android:icon="@mipmap/launcher6">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
@ -151,6 +159,7 @@
<activity <activity
android:name=".ui.book.read.ReadBookActivity" android:name=".ui.book.read.ReadBookActivity"
android:configChanges="locale|keyboardHidden|orientation|screenSize|smallestScreenSize|screenLayout" android:configChanges="locale|keyboardHidden|orientation|screenSize|smallestScreenSize|screenLayout"
android:exported="true"
android:launchMode="singleTask"> android:launchMode="singleTask">
<intent-filter> <intent-filter>
<action android:name="com.samsung.android.support.REMOTE_ACTION" /> <action android:name="com.samsung.android.support.REMOTE_ACTION" />
@ -304,6 +313,7 @@
<!-- 文字处理 --> <!-- 文字处理 -->
<activity <activity
android:name=".receiver.SharedReceiverActivity" android:name=".receiver.SharedReceiverActivity"
android:exported="true"
android:label="@string/receiving_shared_label" android:label="@string/receiving_shared_label"
android:theme="@style/AppTheme.Transparent"> android:theme="@style/AppTheme.Transparent">
<intent-filter> <intent-filter>
@ -325,6 +335,7 @@
<activity <activity
android:name=".ui.association.OnLineImportActivity" android:name=".ui.association.OnLineImportActivity"
android:configChanges="locale|keyboardHidden|orientation|screenSize|smallestScreenSize|screenLayout" android:configChanges="locale|keyboardHidden|orientation|screenSize|smallestScreenSize|screenLayout"
android:exported="true"
android:theme="@style/AppTheme.Transparent"> android:theme="@style/AppTheme.Transparent">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.VIEW" /> <action android:name="android.intent.action.VIEW" />
@ -339,6 +350,7 @@
<!-- 打开文件 --> <!-- 打开文件 -->
<activity <activity
android:name=".ui.association.FileAssociationActivity" android:name=".ui.association.FileAssociationActivity"
android:exported="true"
android:launchMode="singleTop" android:launchMode="singleTop"
android:theme="@style/AppTheme.Transparent"> android:theme="@style/AppTheme.Transparent">
<!-- VIEW (Open with) action --> <!-- VIEW (Open with) action -->
@ -388,12 +400,24 @@
<service android:name=".service.CheckSourceService" /> <service android:name=".service.CheckSourceService" />
<service android:name=".service.CacheBookService" /> <service android:name=".service.CacheBookService" />
<service android:name=".service.WebService" /> <service android:name=".service.WebService" />
<service
android:name=".service.WebTileService"
android:label="legado Web Service"
android:icon="@drawable/ic_web_service_noti"
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
android:exported="true">
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE" />
</intent-filter>
</service>
<service android:name=".service.TTSReadAloudService" /> <service android:name=".service.TTSReadAloudService" />
<service android:name=".service.HttpReadAloudService" /> <service android:name=".service.HttpReadAloudService" />
<service android:name=".service.AudioPlayService" /> <service android:name=".service.AudioPlayService" />
<service android:name=".service.DownloadService" /> <service android:name=".service.DownloadService" />
<receiver android:name=".receiver.MediaButtonReceiver"> <receiver
android:name=".receiver.MediaButtonReceiver"
android:exported="true">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MEDIA_BUTTON" /> <action android:name="android.intent.action.MEDIA_BUTTON" />
</intent-filter> </intent-filter>

@ -440,6 +440,10 @@ class AnalyzeRule(val ruleData: RuleDataInterface) : JsExtensions {
mode = Mode.Json mode = Mode.Json
ruleStr.substring(6) ruleStr.substring(6)
} }
ruleStr.startsWith("//") -> {//XPath特征很明显,无需配置单独的识别标头
mode = Mode.XPath
ruleStr
}
isJSON || ruleStr.startsWith("$.") || ruleStr.startsWith("$[") -> { isJSON || ruleStr.startsWith("$.") || ruleStr.startsWith("$[") -> {
mode = Mode.Json mode = Mode.Json
ruleStr ruleStr

@ -45,6 +45,9 @@ class WebService : BaseService() {
isRun = true isRun = true
notificationContent = getString(R.string.service_starting) notificationContent = getString(R.string.service_starting)
upNotification() upNotification()
startService<WebTileService> {
action = IntentAction.start
}
} }
override fun onDestroy() { override fun onDestroy() {
@ -57,6 +60,9 @@ class WebService : BaseService() {
webSocketServer?.stop() webSocketServer?.stop()
} }
postEvent(EventBus.WEB_SERVICE, "") postEvent(EventBus.WEB_SERVICE, "")
startService<WebTileService> {
action = IntentAction.stop
}
} }
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {

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

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFF"
android:pathData="M14.604,8.901H9.206c-1.046,0-1.898,0.909-1.898,2.025v8.885c0,1.117,0.853,2.024,1.898,2.024h5.397 c1.048,0,1.898-0.908,1.898-2.024v-8.885C16.502,9.81,15.651,8.901,14.604,8.901z M14.99,19.812c0,0.278-0.176,0.513-0.387,0.513 H9.206c-0.21,0-0.388-0.235-0.388-0.513v-8.885c0-0.278,0.178-0.513,0.388-0.513h5.397c0.211,0,0.387,0.235,0.387,0.513V19.812z" />
<path
android:fillColor="#FFFFFF"
android:pathData="M11.997,1.836c-2.017,0-3.953,0.409-5.604,1.181c0,0,0,0-0.001,0C6.186,3.114,5.98,3.216,5.79,3.323 l0.739,1.318c0.158-0.089,0.33-0.174,0.502-0.253L6.93,4.169l0.102,0.218c1.453-0.68,3.17-1.039,4.966-1.04 c1.999,0,3.946,0.461,5.481,1.298l0.723-1.327C16.424,2.349,14.278,1.836,11.997,1.836z" />
<path
android:fillColor="#FFFFFF"
android:pathData="M8.621,5.621l0.723,1.328C9.426,6.906,9.508,6.864,9.59,6.824c1.484-0.691,3.654-0.642,5.053,0.123 l0.727-1.327c-1.824-0.996-4.496-1.062-6.418-0.166l0.314,0.674l-0.32-0.671C8.838,5.508,8.729,5.563,8.621,5.621z" />
</vector>
Loading…
Cancel
Save