Skip to content

Commit df4a2d1

Browse files
committed
## 1.2.10
* Android 优化:剪贴板权限检测和请求 * Android 优化:优化初始化逻辑 --- * Android Optimization: Clipboard permission detection and request * Android Optimization: Improved initialization logic
1 parent e36f4c0 commit df4a2d1

6 files changed

Lines changed: 22 additions & 11 deletions

File tree

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
## 1.2.10
2+
* Android 优化:剪贴板权限检测和请求
3+
* Android 优化:优化初始化逻辑
4+
---
5+
* Android Optimization: Clipboard permission detection and request
6+
* Android Optimization: Improved initialization logic
7+
8+
翻译英文
9+
110
## 1.2.9
211
* Android 新增:剪贴板权限的检测和修改方法(需要 Shizuku 或 root)
312
---

README-EN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Add this to your package's `pubspec.yaml` file:
3838

3939
```yaml
4040
dependencies:
41-
clipshare_clipboard_listener: ^1.2.9
41+
clipshare_clipboard_listener: ^1.2.10
4242
```
4343
4444
### Usage

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Shizuku 或 Root)
3535

3636
```yaml
3737
dependencies:
38-
clipshare_clipboard_listener: ^1.2.9
38+
clipshare_clipboard_listener: ^1.2.10
3939
```
4040
4141
### 用法

android/src/main/aidl/top/coclyun/clipshare/clipboard_listener/ICommandRunnerService.aidl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// ILatestWriteClipboardPkgService.aidl
1+
// ICommandRunnerService.aidl
22
package top.coclyun.clipshare.clipboard_listener;
33

44
interface ICommandRunnerService {

android/src/main/kotlin/top/coclyun/clipshare/clipboard_listener/ClipshareClipboardListenerPlugin.kt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,9 @@ class ClipshareClipboardListenerPlugin : FlutterPlugin, MethodCallHandler,
106106
).daemon(false).processNameSuffix("clipshare-listening-service")
107107
Log.d(TAG, "applicationId: ${config.applicationId}")
108108
Shizuku.addRequestPermissionResultListener(this);
109-
currentEnv = getCurrentEnvironment()
110109
instance = this
111110
ClipboardListener.init(this, context)
112-
ClipboardListener.instance.addObserver(this)
113111
channel.setMethodCallHandler(this)
114-
Log.d(TAG, "currentEnv $currentEnv")
115112
initClipboardSourceShizukuService()
116113
}
117114

@@ -156,6 +153,9 @@ class ClipshareClipboardListenerPlugin : FlutterPlugin, MethodCallHandler,
156153
//region Flutter Method Channel Events
157154

158155
private fun onStartListeningCalled(call: MethodCall, result: Result) {
156+
currentEnv = getCurrentEnvironment()
157+
Log.d(TAG, "currentEnv $currentEnv")
158+
ClipboardListener.instance.addObserver(this)
159159
val envStr = call.argument<String>("env")
160160
val wayStr = call.argument<String>("way")
161161
var env: EnvironmentType? = null
@@ -400,8 +400,9 @@ class ClipshareClipboardListenerPlugin : FlutterPlugin, MethodCallHandler,
400400
}
401401

402402
private fun checkClipboardPermission(call: MethodCall, result: Result) {
403-
if (currentEnv != EnvironmentType.root && currentEnv != EnvironmentType.shizuku) {
403+
if (currentEnv != null && currentEnv != EnvironmentType.root && currentEnv != EnvironmentType.shizuku) {
404404
result.success(false)
405+
return
405406
}
406407
commandRunnerScope.launch {
407408
if (commandRunnerService == null) {
@@ -426,12 +427,12 @@ class ClipshareClipboardListenerPlugin : FlutterPlugin, MethodCallHandler,
426427
}
427428

428429
private fun requestClipboardPermission(call: MethodCall, result: Result) {
429-
430-
if (currentEnv != EnvironmentType.root && currentEnv != EnvironmentType.shizuku) {
430+
if (currentEnv != null && currentEnv != EnvironmentType.root && currentEnv != EnvironmentType.shizuku) {
431431
result.success(false)
432+
return
432433
}
433434
commandRunnerScope.launch {
434-
if (currentEnv == EnvironmentType.shizuku && commandRunnerService == null) {
435+
if (commandRunnerService == null) {
435436
initCommandRunnerService()
436437
waitCommandRunnerService()
437438
}
@@ -599,6 +600,7 @@ class ClipshareClipboardListenerPlugin : FlutterPlugin, MethodCallHandler,
599600
}
600601

601602
private fun stopListening() {
603+
ClipboardListener.instance.removeObserver(this)
602604
val serviceIntent = Intent(context, ForegroundService::class.java)
603605
listening = false
604606
stopClipboardSourceService()

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ repository: https://github.com/aa2013/ClipboardListener
44
description: >
55
Supports clipboard monitoring on Windows、Android、Linux、MacOS platforms, with support for text and images.
66
For Android 10+ devices, background clipboard monitoring is supported (requires Shizuku).
7-
version: 1.2.9
7+
version: 1.2.10
88
license: MIT
99
#homepage:
1010

0 commit comments

Comments
 (0)