Update Android icons and enter action

This commit is contained in:
Misaka
2026-05-16 22:00:02 +08:00
parent fe5cb9af37
commit 7cd6fbd1f2
11 changed files with 33 additions and 7 deletions

View File

@@ -47,7 +47,7 @@
<service
android:name=".QuickSendTileService"
android:exported="true"
android:icon="@mipmap/ic_launcher"
android:icon="@drawable/ic_quick_send_tile"
android:label="文本同步"
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
<intent-filter>

View File

@@ -221,9 +221,27 @@ class ConnectionService : Service() {
return false
}
return sendAction(socket, "replaceAll", text)
}
fun sendEnter(): Boolean {
Log.d("WTS", "ConnectionService.sendEnter connected=${state.connected}")
val socket = currentSocket ?: return false
if (!state.connected) {
return false
}
return sendAction(socket, "enter", null)
}
private fun sendAction(socket: WebSocket, action: String, text: String?): Boolean {
val payload = JSONObject()
.put("action", "replaceAll")
.put("text", text)
.put("action", action)
.apply {
if (text != null) {
put("text", text)
}
}
.toString()
return socket.send(payload)
}

View File

@@ -45,6 +45,10 @@ class MainActivity : FlutterActivity() {
Log.d(tag, "MethodChannel sendText length=${text.length}")
result.success(ConnectionService.sendText(text))
}
"sendEnter" -> {
Log.d(tag, "MethodChannel sendEnter")
result.success(ConnectionService.sendEnter())
}
"getState" -> {
Log.d(tag, "MethodChannel getState")
result.success(ConnectionService.stateMap())

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 544 B

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 442 B

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 721 B

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 34 KiB

View File

@@ -123,6 +123,11 @@ class NativeConnectionApi {
return result ?? false;
}
Future<bool> sendEnter() async {
final result = await _methodChannel.invokeMethod<bool>('sendEnter');
return result ?? false;
}
Future<List<DiscoveredDevice>> startDiscovery() async {
try {
final result = await _methodChannel.invokeListMethod<dynamic>(
@@ -341,15 +346,14 @@ class _InputSyncPageState extends State<InputSyncPage>
}
final draft = inputController.text;
final textToSend = appendEnter ? '$draft\n' : draft;
setState(() {
sendButtonState = SendButtonState.sending;
});
try {
final sent = await api.sendText(textToSend);
if (!sent) {
final sent = await api.sendText(draft);
final enterSent = !sent || !appendEnter ? true : await api.sendEnter();
if (!sent || !enterSent) {
_showToast('发送失败,连接已断开');
setState(() {
sendButtonState = SendButtonState.idle;