Update Android icons and enter action
@@ -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>
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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())
|
||||
|
||||
BIN
android/app/src/main/res/drawable-nodpi/app_icon_source.png
Normal file
|
After Width: | Height: | Size: 106 KiB |
BIN
android/app/src/main/res/drawable-nodpi/ic_quick_send_tile.png
Normal file
|
After Width: | Height: | Size: 86 KiB |
|
Before Width: | Height: | Size: 544 B After Width: | Height: | Size: 6.0 KiB |
|
Before Width: | Height: | Size: 442 B After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 721 B After Width: | Height: | Size: 9.5 KiB |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 34 KiB |
@@ -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;
|
||||
|
||||