From 12589a053993d67716e57a47047a765bbfd71e12 Mon Sep 17 00:00:00 2001 From: rustdesk Date: Mon, 28 Mar 2022 23:04:37 +0800 Subject: [PATCH 1/3] jniLibs --- android/app/src/main/jniLibs/arm64-v8a/libc++_shared.so | 1 + android/app/src/main/jniLibs/arm64-v8a/libcrypto.so | 1 + android/app/src/main/jniLibs/arm64-v8a/librustdesk.so | 1 + android/app/src/main/jniLibs/arm64-v8a/libssl.so | 1 + 4 files changed, 4 insertions(+) create mode 120000 android/app/src/main/jniLibs/arm64-v8a/libc++_shared.so create mode 120000 android/app/src/main/jniLibs/arm64-v8a/libcrypto.so create mode 120000 android/app/src/main/jniLibs/arm64-v8a/librustdesk.so create mode 120000 android/app/src/main/jniLibs/arm64-v8a/libssl.so diff --git a/android/app/src/main/jniLibs/arm64-v8a/libc++_shared.so b/android/app/src/main/jniLibs/arm64-v8a/libc++_shared.so new file mode 120000 index 000000000..fcc847538 --- /dev/null +++ b/android/app/src/main/jniLibs/arm64-v8a/libc++_shared.so @@ -0,0 +1 @@ +../../../../../../../../.android/libc++_shared.so \ No newline at end of file diff --git a/android/app/src/main/jniLibs/arm64-v8a/libcrypto.so b/android/app/src/main/jniLibs/arm64-v8a/libcrypto.so new file mode 120000 index 000000000..0974e8561 --- /dev/null +++ b/android/app/src/main/jniLibs/arm64-v8a/libcrypto.so @@ -0,0 +1 @@ +../../../../../../../../.android/libcrypto.so \ No newline at end of file diff --git a/android/app/src/main/jniLibs/arm64-v8a/librustdesk.so b/android/app/src/main/jniLibs/arm64-v8a/librustdesk.so new file mode 120000 index 000000000..d614db955 --- /dev/null +++ b/android/app/src/main/jniLibs/arm64-v8a/librustdesk.so @@ -0,0 +1 @@ +../../../../../../../../.android/liblibrustdesk.so \ No newline at end of file diff --git a/android/app/src/main/jniLibs/arm64-v8a/libssl.so b/android/app/src/main/jniLibs/arm64-v8a/libssl.so new file mode 120000 index 000000000..dac4f4a54 --- /dev/null +++ b/android/app/src/main/jniLibs/arm64-v8a/libssl.so @@ -0,0 +1 @@ +../../../../../../../../.android/libssl.so \ No newline at end of file From 91f3048ac284d8b91c4cd065a49247290a814115 Mon Sep 17 00:00:00 2001 From: rustdesk Date: Mon, 4 Apr 2022 01:21:44 +0800 Subject: [PATCH 2/3] no non-english allowed in source code --- .../com/carriez/flutter_hbb/BootReceiver.kt | 3 +- .../com/carriez/flutter_hbb/InputService.kt | 5 +-- .../com/carriez/flutter_hbb/MainActivity.kt | 3 -- .../com/carriez/flutter_hbb/MainService.kt | 36 +++++-------------- .../kotlin/com/carriez/flutter_hbb/common.kt | 3 +- lib/models/chat_model.dart | 3 -- lib/models/file_model.dart | 12 ++----- lib/models/server_model.dart | 11 ------ lib/pages/chat_page.dart | 1 - lib/pages/file_manager_page.dart | 2 -- lib/pages/server_page.dart | 1 - lib/widgets/gestures.dart | 19 +++------- 12 files changed, 19 insertions(+), 80 deletions(-) diff --git a/android/app/src/main/kotlin/com/carriez/flutter_hbb/BootReceiver.kt b/android/app/src/main/kotlin/com/carriez/flutter_hbb/BootReceiver.kt index 6b681aef2..328701567 100644 --- a/android/app/src/main/kotlin/com/carriez/flutter_hbb/BootReceiver.kt +++ b/android/app/src/main/kotlin/com/carriez/flutter_hbb/BootReceiver.kt @@ -6,7 +6,6 @@ import android.content.Intent import android.os.Build import android.widget.Toast -// 开机自启动 此功能暂不开启 class BootReceiver : BroadcastReceiver() { override fun onReceive(context: Context, intent: Intent) { if ("android.intent.action.BOOT_COMPLETED" == intent.action){ @@ -21,4 +20,4 @@ class BootReceiver : BroadcastReceiver() { } } } -} \ No newline at end of file +} diff --git a/android/app/src/main/kotlin/com/carriez/flutter_hbb/InputService.kt b/android/app/src/main/kotlin/com/carriez/flutter_hbb/InputService.kt index 33a2a637e..6a785a161 100644 --- a/android/app/src/main/kotlin/com/carriez/flutter_hbb/InputService.kt +++ b/android/app/src/main/kotlin/com/carriez/flutter_hbb/InputService.kt @@ -29,7 +29,6 @@ class InputService : AccessibilityService() { @RequiresApi(Build.VERSION_CODES.N) fun rustMouseInput(mask: Int, _x: Int, _y: Int) { - // TODO 按键抬起按下时候 x y 都是0 if (!(mask == 9 || mask == 10)) { mouseX = _x * INFO.scale mouseY = _y * INFO.scale @@ -77,12 +76,10 @@ class InputService : AccessibilityService() { dispatchGesture(builder.build(), object : GestureResultCallback() { override fun onCompleted(gestureDescription: GestureDescription) { super.onCompleted(gestureDescription) - Log.d(logTag, "滑动成功") } override fun onCancelled(gestureDescription: GestureDescription) { super.onCancelled(gestureDescription) - Log.d(logTag, "滑动失败 ") } }, null) } @@ -108,4 +105,4 @@ class InputService : AccessibilityService() { override fun onInterrupt() { // TODO("Not yet implemented") } -} \ No newline at end of file +} diff --git a/android/app/src/main/kotlin/com/carriez/flutter_hbb/MainActivity.kt b/android/app/src/main/kotlin/com/carriez/flutter_hbb/MainActivity.kt index 209acddd7..b53ffb69c 100644 --- a/android/app/src/main/kotlin/com/carriez/flutter_hbb/MainActivity.kt +++ b/android/app/src/main/kotlin/com/carriez/flutter_hbb/MainActivity.kt @@ -118,7 +118,6 @@ class MainActivity : FlutterActivity() { startActivityForResult(mIntent, MEDIA_REQUEST_CODE) } - // 在onActivityResult中成功获取到mediaProjection就开始就调用此函数,开始初始化监听服务 private fun initService() { if (mediaProjectionResultIntent == null) { Log.w(logTag, "initService fail,mediaProjectionResultIntent is null") @@ -170,8 +169,6 @@ class MainActivity : FlutterActivity() { } private fun updateMachineInfo() { - // 屏幕尺寸 控制最长边不超过1400 超过则减半并储存缩放比例 实际发送给手机端的尺寸为缩小后的尺寸 - // input控制时再通过缩放比例恢复原始尺寸进行path入参 val dm = DisplayMetrics() @Suppress("DEPRECATION") if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { diff --git a/android/app/src/main/kotlin/com/carriez/flutter_hbb/MainService.kt b/android/app/src/main/kotlin/com/carriez/flutter_hbb/MainService.kt index 861123d1d..8b9c5a6e1 100644 --- a/android/app/src/main/kotlin/com/carriez/flutter_hbb/MainService.kt +++ b/android/app/src/main/kotlin/com/carriez/flutter_hbb/MainService.kt @@ -41,14 +41,14 @@ const val EXTRA_LOGIN_REQ_NOTIFY = "EXTRA_LOGIN_REQ_NOTIFY" const val DEFAULT_NOTIFY_TITLE = "RustDesk" const val DEFAULT_NOTIFY_TEXT = "Service is running" const val DEFAULT_NOTIFY_ID = 1 -const val NOTIFY_ID_OFFSET = 100 // 为每个客户端ID增加这个偏移量,而得到通知栏ID,避免使用0且防止和默认ID冲突 +const val NOTIFY_ID_OFFSET = 100 const val NOTIFY_TYPE_START_CAPTURE = "NOTIFY_TYPE_START_CAPTURE" const val MIME_TYPE = MediaFormat.MIMETYPE_VIDEO_VP9 // video const -const val MAX_SCREEN_SIZE = 1200 // 内置编码器有上限 且实际使用中不需要过高的分辨率 +const val MAX_SCREEN_SIZE = 1200 const val VIDEO_KEY_BIT_RATE = 1024_000 const val VIDEO_KEY_FRAME_RATE = 30 @@ -157,14 +157,13 @@ class MainService : Service() { private val logTag = "LOG_SERVICE" private val useVP9 = false private val binder = LocalBinder() - private var _isReady = false // 是否获取了录屏权限 - private var _isStart = false // 是否正在进行录制 + private var _isReady = false + private var _isStart = false val isReady: Boolean get() = _isReady val isStart: Boolean get() = _isStart - // video 注意 这里imageReader要成为成员变量,防止被回收 https://www.cnblogs.com/yongdaimi/p/11004560.html private var mediaProjection: MediaProjection? = null private var surface: Surface? = null private val sendVP9Thread = Executors.newSingleThreadExecutor() @@ -179,7 +178,7 @@ class MainService : Service() { private var audioData: FloatArray? = null private var minBufferSize = 0 private var isNewData = false - private val audioZeroData: FloatArray = FloatArray(32) // 必须是32位 如果只有8位进行ffi传输时会出错 + private val audioZeroData: FloatArray = FloatArray(32) private var audioRecordStat = false // notification @@ -208,7 +207,6 @@ class MainService : Service() { override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { Log.d("whichService", "this service:${Thread.currentThread()}") - // 只有init的时候通过onStartCommand 且开启前台服务 if (intent?.action == INIT_SERVICE) { Log.d(logTag, "service starting:${startId}:${Thread.currentThread()}") createForegroundNotification() @@ -217,25 +215,20 @@ class MainService : Service() { intent.getParcelableExtra(EXTRA_MP_DATA)?.let { mediaProjection = mMediaProjectionManager.getMediaProjection(Activity.RESULT_OK, it) - Log.d(logTag, "获取mMediaProjection成功$mediaProjection") checkMediaPermission() surface = createSurface() init(this) _isReady = true } ?: let { - Log.d(logTag, "获取mMediaProjection失败!") } // } else if (intent?.action == ACTION_LOGIN_REQ_NOTIFY) { - // 暂时不开启通知从通知栏确认登录 // val notifyLoginRes = intent.getBooleanExtra(EXTRA_LOGIN_REQ_NOTIFY, false) -// Log.d(logTag, "从通知栏点击了:$notifyLoginRes") } return super.onStartCommand(intent, flags, startId) } @SuppressLint("WrongConstant") private fun createSurface(): Surface? { - // 暂时只使用原始数据的情况 return if (useVP9) { // TODO null @@ -246,7 +239,7 @@ class MainService : Service() { INFO.screenWidth, INFO.screenHeight, PixelFormat.RGBA_8888, - 2 // maxImages 至少是2 + 2 ).apply { setOnImageAvailableListener({ imageReader: ImageReader -> try { @@ -292,7 +285,6 @@ class MainService : Service() { startRawVideoRecorder(mediaProjection!!) } - // 音频只支持安卓10以及以上 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { startAudioRecorder() } @@ -363,7 +355,6 @@ class MainService : Service() { @SuppressLint("WrongConstant") private fun startVP9VideoRecorder(mp: MediaProjection) { - //使用内置编码器 createMediaCodec() videoEncoder?.let { surface = it.createInputSurface() @@ -391,7 +382,6 @@ class MainService : Service() { ) { codec.getOutputBuffer(index)?.let { buf -> sendVP9Thread.execute { - // TODO 优化内存使用方式 val byteArray = ByteArray(buf.limit()) buf.get(byteArray) // sendVp9(byteArray) @@ -411,7 +401,7 @@ class MainService : Service() { videoEncoder = MediaCodec.createEncoderByType(MIME_TYPE) val mFormat = MediaFormat.createVideoFormat(MIME_TYPE, INFO.screenWidth, INFO.screenHeight) mFormat.setInteger(MediaFormat.KEY_BIT_RATE, VIDEO_KEY_BIT_RATE) - mFormat.setInteger(MediaFormat.KEY_FRAME_RATE, VIDEO_KEY_FRAME_RATE) // codec的帧率设置无效 + mFormat.setInteger(MediaFormat.KEY_FRAME_RATE, VIDEO_KEY_FRAME_RATE) mFormat.setInteger( MediaFormat.KEY_COLOR_FORMAT, MediaCodecInfo.CodecCapabilities.COLOR_FormatYUV420Flexible @@ -433,7 +423,6 @@ class MainService : Service() { thread { while (audioRecordStat) { val res = audioRecorder!!.read(audioData!!, 0, minBufferSize, READ_BLOCKING) - // 录制float 需要使用对应的read float[] 函数 if (res != AudioRecord.ERROR_INVALID_OPERATION) { isNewData = true } @@ -493,7 +482,6 @@ class MainService : Service() { private fun initNotification() { notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager - // 设置通知渠道 android8开始引入 老版本会被忽略 这个东西的作用相当于为通知分类 给用户选择通知消息的种类 notificationChannel = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { val channelId = "RustDesk" val channelName = "RustDesk Service" @@ -517,7 +505,7 @@ class MainService : Service() { private fun createForegroundNotification() { val intent = Intent(this, MainActivity::class.java).apply { flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED - action = Intent.ACTION_MAIN // 不设置会造成每次都重新启动一个新的Activity + action = Intent.ACTION_MAIN addCategory(Intent.CATEGORY_LAUNCHER) putExtra("type", type) } @@ -539,19 +527,16 @@ class MainService : Service() { .setColor(ContextCompat.getColor(this, R.color.primary)) .setWhen(System.currentTimeMillis()) .build() - // 这里满足前台服务首次启动时5s内设定好通知内容,这里使用startForeground,后续普通调用使用notificationManager即可 startForeground(DEFAULT_NOTIFY_ID, notification) } private fun loginRequestNotification(clientID:Int, type: String, username: String, peerId: String) { - // notificationBuilder 第一次使用时状态已保存,再次生成时只需要调整需要修改的部分 cancelNotification(clientID) val notification = notificationBuilder .setOngoing(false) .setPriority(NotificationCompat.PRIORITY_HIGH) .setContentTitle(translate("Do you accept?")) .setContentText("$type:$username-$peerId") - // 暂时不开启通知栏接受请求 // .setStyle(MediaStyle().setShowActionsInCompactView(0, 1)) // .addAction(R.drawable.check_blue, "check", genLoginRequestPendingIntent(true)) // .addAction(R.drawable.close_red, "close", genLoginRequestPendingIntent(false)) @@ -574,11 +559,6 @@ class MainService : Service() { return clientID + NOTIFY_ID_OFFSET } - /** - * 关闭通知的情况 - * 1.UI端接受或拒绝 - * 2.peer端通过密码建立了连接(在onClientAuthorizedNotification中已处理) 和 peer端手动取消了连接 - */ fun cancelNotification(clientID:Int){ notificationManager.cancel(getClientNotifyID(clientID)) } diff --git a/android/app/src/main/kotlin/com/carriez/flutter_hbb/common.kt b/android/app/src/main/kotlin/com/carriez/flutter_hbb/common.kt index 1b1c5944f..3c01d1480 100644 --- a/android/app/src/main/kotlin/com/carriez/flutter_hbb/common.kt +++ b/android/app/src/main/kotlin/com/carriez/flutter_hbb/common.kt @@ -28,7 +28,7 @@ data class Info( @RequiresApi(Build.VERSION_CODES.LOLLIPOP) fun testVP9Support(): Boolean { - return true // 函数内部永远返回true 暂时只使用原始数据 + return true val res = MediaCodecList(MediaCodecList.ALL_CODECS) .findEncoderForFormat( MediaFormat.createVideoFormat( @@ -46,7 +46,6 @@ fun checkPermissions(context: Context) { .permission(Permission.MANAGE_EXTERNAL_STORAGE) .request { permissions, all -> if (all) { - Log.d("loglog", "获取存储权限成功:$permissions") } } } diff --git a/lib/models/chat_model.dart b/lib/models/chat_model.dart index 0c3aaa798..15c634738 100644 --- a/lib/models/chat_model.dart +++ b/lib/models/chat_model.dart @@ -7,9 +7,6 @@ import 'package:flutter_hbb/pages/chat_page.dart'; import 'model.dart'; class ChatModel with ChangeNotifier { - // -1作为客户端模式的id,客户端模式下此id唯一 - // 其它正整数的id,来自被控服务器模式下的其他客户端的id,每个客户端有不同的id - // 注意 此id和peer_id不同,服务端模式下的id等同于conn的顺序累加id static final clientModeID = -1; final Map> _messages = Map()..[clientModeID] = []; diff --git a/lib/models/file_model.dart b/lib/models/file_model.dart index 1b5f792eb..0af75ec33 100644 --- a/lib/models/file_model.dart +++ b/lib/models/file_model.dart @@ -26,10 +26,6 @@ class FileModel extends ChangeNotifier { var _localOption = DirectoryOption(); var _remoteOption = DirectoryOption(); - /// 每一个选择的文件或文件夹占用一个 _jobId,file_num是文件夹中的单独文件id - /// 如 - /// 发送单独一个文件 file_num = 0; - /// 发送一个文件夹,若文件夹下有3个文件 最后一个文件的 file_num = 2; var _jobId = 0; var _jobProgress = JobProgress(); // from rust update @@ -119,7 +115,6 @@ class FileModel extends ChangeNotifier { _fileFetcher.tryCompleteTask(evt['value'], evt['is_local']); } - // job 类型 复制结束 删除结束 jobDone(Map evt) { if (_jobResultListener.isListening) { _jobResultListener.complete(evt); @@ -250,7 +245,7 @@ class FileModel extends ChangeNotifier { "path": from.path, "to": PathUtil.join(toPath, from.name, isWindows), "show_hidden": showHidden.toString(), - "is_remote": (!(items.isLocal!)).toString() // 指from的位置而不是to的位置 + "is_remote": (!(items.isLocal!)).toString() }; FFI.setByName("send_files", jsonEncode(msg)); }); @@ -282,7 +277,6 @@ class FileModel extends ChangeNotifier { _jobId, item.path, items.isLocal!, true); fd.format(isWindows); EasyLoading.dismiss(); - // 空文件夹 if (fd.entries.isEmpty) { final confirm = await showRemoveDialog(translate("Are you sure you want to delete this empty directory?"), item.name, false); if (confirm == true) { @@ -476,7 +470,7 @@ class FileFetcher { Timer(Duration(seconds: 2), () { tasks.remove(path); - if (c.isCompleted) return; // 计时器加入map + if (c.isCompleted) return; c.completeError("Failed to read dir,timeout"); }); return c.future; @@ -492,7 +486,7 @@ class FileFetcher { Timer(Duration(seconds: 2), () { tasks.remove(id); - if (c.isCompleted) return; // 计时器加入map + if (c.isCompleted) return; c.completeError("Failed to read dir,timeout"); }); return c.future; diff --git a/lib/models/server_model.dart b/lib/models/server_model.dart index 23367e0bd..b99e7eacc 100644 --- a/lib/models/server_model.dart +++ b/lib/models/server_model.dart @@ -372,17 +372,6 @@ showInputWarnAlert() async { DialogManager.register(alertContext); return AlertDialog( title: Text(translate("How to get Android input permission?")), - // content: Text.rich(TextSpan(style: TextStyle(), children: [ - // // [已安装的服务] : [Installed Services] - // // 请在接下来的系统设置页面里,找到并进入[Installed Services]页面,将[RustDesk Input]服务开启。 - // TextSpan(text: "请在接下来的系统设置页\n进入"), - // TextSpan(text: " [服务] ", style: TextStyle(color: MyTheme.accent)), - // TextSpan(text: "配置页面\n将"), - // TextSpan( - // text: " [RustDesk Input] ", - // style: TextStyle(color: MyTheme.accent)), - // TextSpan(text: "服务开启") - // ])), content: Column( mainAxisSize: MainAxisSize.min, children: [ diff --git a/lib/pages/chat_page.dart b/lib/pages/chat_page.dart index ee72d4908..a95799df6 100644 --- a/lib/pages/chat_page.dart +++ b/lib/pages/chat_page.dart @@ -177,7 +177,6 @@ class _ChatWindowOverlayState extends State { } checkScreenSize() { - // TODO 横屏处理 } checkKeyboard() { diff --git a/lib/pages/file_manager_page.dart b/lib/pages/file_manager_page.dart index 256d8708a..2c3e16881 100644 --- a/lib/pages/file_manager_page.dart +++ b/lib/pages/file_manager_page.dart @@ -360,7 +360,6 @@ class _FileManagerPageState extends State { if (model.selectMode) { if (_selectedItems.length == 0 || !isOtherPage) { - // 选择模式 当前选择页面 return BottomSheetBody( leading: Icon(Icons.check), title: translate("Selected"), @@ -377,7 +376,6 @@ class _FileManagerPageState extends State { ) ]); } else { - // 选择模式 复制目标页面 return BottomSheetBody( leading: Icon(Icons.input), title: translate("Paste here?"), diff --git a/lib/pages/server_page.dart b/lib/pages/server_page.dart index 47fe6f360..e716f5d31 100644 --- a/lib/pages/server_page.dart +++ b/lib/pages/server_page.dart @@ -77,7 +77,6 @@ class ServerPage extends StatelessWidget implements PageShape { } void checkService() { - // 检测当前服务状态,若已存在服务则异步更新数据回来 FFI.invokeMethod("check_service"); // jvm } diff --git a/lib/widgets/gestures.dart b/lib/widgets/gestures.dart index cb15813c9..9abd055a2 100644 --- a/lib/widgets/gestures.dart +++ b/lib/widgets/gestures.dart @@ -239,8 +239,8 @@ class HoldTapMoveGestureRecognizer extends GestureRecognizer { bool _isStart = false; - Timer? _firstTapUpTimer; // 第一次点击后的计时 超时未等到第二次操作则reject - Timer? _secondTapDownTimer; // 第二次点击后的计时 期间内有其他的操作则reject 超时则判定成功 drag update + Timer? _firstTapUpTimer; + Timer? _secondTapDownTimer; _TapTracker? _firstTap; _TapTracker? _secondTap; @@ -266,7 +266,6 @@ class HoldTapMoveGestureRecognizer extends GestureRecognizer { @override void addAllowedPointer(PointerDownEvent event) { - // 检测按下事件 if (_firstTap != null) { if (!_firstTap!.isWithinGlobalTolerance(event, kDoubleTapSlop)) { // Ignore out-of-bounds second taps. @@ -285,7 +284,7 @@ class HoldTapMoveGestureRecognizer extends GestureRecognizer { localPosition: event.localPosition))); } } - _trackTap(event); // 捕捉第一次tap + _trackTap(event); } void _trackTap(PointerDownEvent event) { @@ -301,14 +300,12 @@ class HoldTapMoveGestureRecognizer extends GestureRecognizer { tracker.startTrackingPointer(_handleEvent, event.transform); } - // 实际的逻辑应该是第二次down后一段时间没有抬起则表示start 刚好是双击取反 void _handleEvent(PointerEvent event) { final _TapTracker tracker = _trackers[event.pointer]!; if (event is PointerUpEvent) { if (_firstTap == null && _secondTap == null) { _registerFirstTap(tracker); } else { - // 检测到其他的抬起事件则取消 _reject(tracker); } } else if (event is PointerDownEvent) { @@ -316,7 +313,6 @@ class HoldTapMoveGestureRecognizer extends GestureRecognizer { _registerSecondTap(tracker); } } else if (event is PointerMoveEvent) { - // 检测到first tap move 则取消,检测到second tap move且已经通过竞技场则update if (!tracker.isWithinGlobalTolerance(event, kDoubleTapTouchSlop)) { if (_firstTap != null && _firstTap!.pointer == event.pointer) { // first tap move @@ -403,7 +399,6 @@ class HoldTapMoveGestureRecognizer extends GestureRecognizer { GestureBinding.instance!.gestureArena.release(tracker.pointer); } } - // TODO 正确的释放资源 _firstTap = null; _secondTap = null; _clearTrackers(); @@ -420,7 +415,6 @@ class HoldTapMoveGestureRecognizer extends GestureRecognizer { } void _registerSecondTap(_TapTracker tracker) { - // 清除first tap的状态 if (_firstTap != null) { _stopFirstTapUpTimer(); _freezeTracker(_firstTap!); @@ -489,7 +483,7 @@ class DoubleFinerTapGestureRecognizer extends GestureRecognizer { GestureTapDownCallback? onDoubleFinerTap; GestureTapCancelCallback? onDoubleFinerTapCancel; - Timer? _firstTapTimer; // 第一次点击后的计时 超时未等到第二次操作则reject + Timer? _firstTapTimer; _TapTracker? _firstTap; var _isStart = false; @@ -518,7 +512,6 @@ class DoubleFinerTapGestureRecognizer extends GestureRecognizer { @override void addAllowedPointer(PointerDownEvent event) { - // 检测按下事件 debugPrint("addAllowedPointer"); if (_isStart) { // second @@ -536,7 +529,7 @@ class DoubleFinerTapGestureRecognizer extends GestureRecognizer { _isStart = true; _startFirstTapDownTimer(); } - _trackTap(event); // 捕捉tap + _trackTap(event); } void _trackTap(PointerDownEvent event) { @@ -553,7 +546,6 @@ class DoubleFinerTapGestureRecognizer extends GestureRecognizer { _registerTap(tracker); } - // 实际的逻辑应该是第二次down后一段时间没有抬起则表示start 刚好是双击取反 void _handleEvent(PointerEvent event) { final _TapTracker tracker = _trackers[event.pointer]!; if (event is PointerUpEvent) { @@ -608,7 +600,6 @@ class DoubleFinerTapGestureRecognizer extends GestureRecognizer { void _reset() { _stopFirstTapUpTimer(); _firstTap = null; - // TODO 正确的释放资源 _clearTrackers(); } From 71c50e6f1ebd5151555673161ff3d1f4a80369f8 Mon Sep 17 00:00:00 2001 From: rustdesk Date: Mon, 4 Apr 2022 01:38:53 +0800 Subject: [PATCH 3/3] unify menu icon --- lib/models/web_model.dart | 2 +- lib/pages/chat_page.dart | 5 +-- lib/pages/connection_page.dart | 67 +++++++++++++++++--------------- lib/pages/server_page.dart | 71 ++++++++++++++++++---------------- 4 files changed, 75 insertions(+), 70 deletions(-) diff --git a/lib/models/web_model.dart b/lib/models/web_model.dart index 3d651ed1b..8bf3b588a 100644 --- a/lib/models/web_model.dart +++ b/lib/models/web_model.dart @@ -83,7 +83,7 @@ class PlatformFFI { static void setMethodCallHandler(FMethod callback) {} - static Future invokeMethod(String method) async { + static Future invokeMethod(String method, [ dynamic arguments]) async { return true; } } diff --git a/lib/pages/chat_page.dart b/lib/pages/chat_page.dart index a95799df6..74a9e3ff3 100644 --- a/lib/pages/chat_page.dart +++ b/lib/pages/chat_page.dart @@ -22,7 +22,7 @@ class ChatPage extends StatelessWidget implements PageShape { @override final appBarActions = [ PopupMenuButton( - icon: Icon(Icons.list_alt), + icon: Icon(Icons.more_vert), itemBuilder: (context) { final chatModel = FFI.chatModel; final serverModel = FFI.serverModel; @@ -176,8 +176,7 @@ class _ChatWindowOverlayState extends State { }); } - checkScreenSize() { - } + checkScreenSize() {} checkKeyboard() { final bottomHeight = MediaQuery.of(context).viewInsets.bottom; diff --git a/lib/pages/connection_page.dart b/lib/pages/connection_page.dart index c092b7d04..5252d2b1b 100644 --- a/lib/pages/connection_page.dart +++ b/lib/pages/connection_page.dart @@ -286,37 +286,40 @@ class _WebMenuState extends State { Widget build(BuildContext context) { Provider.of(context); final username = getUsername(); - return PopupMenuButton(itemBuilder: (context) { - return [ - PopupMenuItem( - child: Text(translate('ID/Relay Server')), - value: "server", - ), - PopupMenuItem( - child: Text(username == null - ? translate("Login") - : translate("Logout") + ' ($username)'), - value: "login", - ), - PopupMenuItem( - child: Text(translate('About') + ' RustDesk'), - value: "about", - ) - ]; - }, onSelected: (value) { - if (value == 'server') { - showServer(); - } - if (value == 'about') { - showAbout(); - } - if (value == 'login') { - if (username == null) { - showLogin(); - } else { - logout(); - } - } - }); + return PopupMenuButton( + icon: Icon(Icons.more_vert), + itemBuilder: (context) { + return [ + PopupMenuItem( + child: Text(translate('ID/Relay Server')), + value: "server", + ), + PopupMenuItem( + child: Text(username == null + ? translate("Login") + : translate("Logout") + ' ($username)'), + value: "login", + ), + PopupMenuItem( + child: Text(translate('About') + ' RustDesk'), + value: "about", + ) + ]; + }, + onSelected: (value) { + if (value == 'server') { + showServer(); + } + if (value == 'about') { + showAbout(); + } + if (value == 'login') { + if (username == null) { + showLogin(); + } else { + logout(); + } + } + }); } } diff --git a/lib/pages/server_page.dart b/lib/pages/server_page.dart index e716f5d31..a607ec837 100644 --- a/lib/pages/server_page.dart +++ b/lib/pages/server_page.dart @@ -17,41 +17,44 @@ class ServerPage extends StatelessWidget implements PageShape { @override final appBarActions = [ - PopupMenuButton(itemBuilder: (context) { - return [ - PopupMenuItem( - child: Text(translate("Change ID")), - value: "changeID", - enabled: false, - ), - PopupMenuItem( - child: Text(translate("Set your own password")), - value: "changePW", - enabled: FFI.serverModel.isStart, - ), - PopupMenuItem( - child: Text(translate("Refresh random password")), - value: "refreshPW", - enabled: FFI.serverModel.isStart, - ) - ]; - }, onSelected: (value) { - if (value == "changeID") { - // TODO - } else if (value == "changePW") { - updatePasswordDialog(); - } else if (value == "refreshPW") { - () async { - showLoading(translate("Waiting")); - if(await FFI.serverModel.updatePassword("")){ - showSuccess(); - }else{ - showError(); + PopupMenuButton( + icon: Icon(Icons.more_vert), + itemBuilder: (context) { + return [ + PopupMenuItem( + child: Text(translate("Change ID")), + value: "changeID", + enabled: false, + ), + PopupMenuItem( + child: Text(translate("Set your own password")), + value: "changePW", + enabled: FFI.serverModel.isStart, + ), + PopupMenuItem( + child: Text(translate("Refresh random password")), + value: "refreshPW", + enabled: FFI.serverModel.isStart, + ) + ]; + }, + onSelected: (value) { + if (value == "changeID") { + // TODO + } else if (value == "changePW") { + updatePasswordDialog(); + } else if (value == "refreshPW") { + () async { + showLoading(translate("Waiting")); + if (await FFI.serverModel.updatePassword("")) { + showSuccess(); + } else { + showError(); + } + debugPrint("end updatePassword"); + }(); } - debugPrint("end updatePassword"); - }(); - } - }) + }) ]; @override