-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
105 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package li.songe.gkd.debug | ||
|
||
import android.service.quicksettings.Tile | ||
import android.service.quicksettings.TileService | ||
import kotlinx.coroutines.MainScope | ||
import kotlinx.coroutines.cancel | ||
import kotlinx.coroutines.flow.MutableStateFlow | ||
import kotlinx.coroutines.flow.combine | ||
import kotlinx.coroutines.launch | ||
|
||
class HttpTileService : TileService() { | ||
val scope = MainScope() | ||
private val listeningFlow = MutableStateFlow(false) | ||
override fun onCreate() { | ||
super.onCreate() | ||
scope.launch { | ||
combine( | ||
HttpService.isRunning, | ||
listeningFlow | ||
) { v1, v2 -> v1 to v2 }.collect { (httpRunning, listening) -> | ||
if (listening) { | ||
qsTile.state = if (httpRunning) Tile.STATE_ACTIVE else Tile.STATE_INACTIVE | ||
qsTile.updateTile() | ||
} | ||
} | ||
} | ||
} | ||
|
||
override fun onStartListening() { | ||
super.onStartListening() | ||
listeningFlow.value = true | ||
} | ||
|
||
override fun onStopListening() { | ||
super.onStopListening() | ||
listeningFlow.value = false | ||
} | ||
|
||
override fun onClick() { | ||
super.onClick() | ||
if (HttpService.isRunning.value) { | ||
HttpService.stop() | ||
} else { | ||
HttpService.start() | ||
} | ||
} | ||
|
||
override fun onDestroy() { | ||
super.onDestroy() | ||
scope.cancel() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:viewportWidth="960" | ||
android:viewportHeight="960"> | ||
<path | ||
android:fillColor="#FFF" | ||
android:pathData="M40,600v-240h60v80h80v-80h60v240h-60v-100h-80v100L40,600ZM340,600v-180h-60v-60h180v60h-60v180h-60ZM560,600v-180h-60v-60h180v60h-60v180h-60ZM720,600v-240h140q24,0 42,18t18,42v40q0,24 -18,42t-42,18h-80v80h-60ZM780,460h80v-40h-80v40Z" /> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<string name="app_name">GKD</string> | ||
<string name="ab_desc">基于高级选择器+订阅规则的屏幕自定义点击服务\n\n通过自定义选择器和订阅规则,能帮助你实现点击任意位置控件,自定义快捷操作等高级功能</string> | ||
<string name="capture_label">捕获快照</string> | ||
<string name="import_desc">GKD-导入数据</string> | ||
</resources> | ||
<string name="a11y_desc">基于高级选择器+订阅规则的屏幕自定义点击服务\n\n通过自定义选择器和订阅规则,能帮助你实现点击任意位置控件,自定义快捷操作等高级功能</string> | ||
<string name="import_data">导入数据</string> | ||
<string name="capture_snapshot">捕获快照</string> | ||
<string name="http_server">HTTP服务</string> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters