Skip to content

Commit 8c72a2e

Browse files
committed
Merge branch 'dev'
2 parents 3bd5689 + 11e6012 commit 8c72a2e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+561
-477
lines changed

.github/workflows/publish.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
steps:
1717

1818
- name: Checkout the code
19-
uses: actions/checkout@v2
19+
uses: actions/checkout@v3
2020

2121
- name: Install and set Flutter version
2222
uses: subosito/flutter-action@v2
@@ -56,7 +56,7 @@ jobs:
5656
ls ${{ github.workspace }}
5757
- run: echo "🍏 This job's status is ${{ job.status }}."
5858
- name: Checkout the code
59-
uses: actions/checkout@v2
59+
uses: actions/checkout@v3
6060

6161
- name: actions/setup-node@v2
6262
uses: actions/setup-node@v2
@@ -88,7 +88,7 @@ jobs:
8888
steps:
8989

9090
- name: Checkout the code
91-
uses: actions/checkout@v2
91+
uses: actions/checkout@v3
9292

9393
- name: Install and set Flutter version
9494
uses: subosito/flutter-action@v2

CHANGELOG.md

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
## 2.0.0测试版
1+
## 2.0.2
2+
* 修复扫码加入失败的bug
3+
* 顶部显示当前所在的共享房间
4+
* 发现设备优化,不显示已加入的房间
5+
* U持续优化
6+
7+
## 2.0.1
8+
* 支持文件自动下载
9+
* 图片预览支持缩放
10+
11+
## 2.0.0正式版
212
【全部日志】
313
* 整体交互大量重构,感谢UI设计师@柚凛的支持
414
* 新版主页
@@ -16,17 +26,25 @@
1626

1727
**U持续优化**
1828

19-
**调整主页UI布局**
29+
**图片预览支持缩放**
30+
31+
**自动下载功能不会重复下载了**
32+
33+
**文件下载切换界面不会停止下载**
34+
35+
**连续返回两次才退出App,防止误触**
2036

2137
【已知问题】
2238

23-
**目前自动下载功能会重复下载文件,等待后续更新**
39+
**移动 端浏览器加入共享,展示布局异常**
2440

25-
目前还只是一个测试版,目前还只是一个测试版,目前还只是一个测试版,目前还只是一个测试版,目前还只是一个测试版,目前还只是一个测试版,仍有很多不稳定的地方,大家多多体谅。
41+
从这个版本开始作为一个正式版了,开发人力不足,仍有很多不稳定的地方,大家多多体谅。
2642

27-
旧机型、TV,去官网下arm_v7a版本的 http://nightmare.fun/YanTool/resources/SpeedShare/?C=N;O=A
43+
有BUG直接评论区反馈吧,反馈前注意看下有没有人反馈过一样的问题。
2844

29-
测试版的使用bug基本不用提,提了意义也不大,等2.0正式版出了再提。
45+
能简单说清楚就直接描述,不能请按照反馈模板进行反馈。
46+
47+
旧机型、TV,去官网下arm_v7a版本的 http://nightmare.fun/YanTool/resources/SpeedShare/?C=N;O=A
3048

3149
## 1.3.2
3250
* [新增]剪切板共享功能(测试中)

android/app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ android {
3939
}
4040
defaultConfig {
4141
applicationId "com.nightmare.speedshare"
42-
minSdkVersion 20
42+
minSdkVersion 21
4343
targetSdkVersion 28
4444
versionCode flutterVersionCode.toInteger()
4545
versionName flutterVersionName
File renamed without changes.
File renamed without changes.

lib/app/bindings/home_binding.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'package:get/get.dart';
22
import 'package:speed_share/app/controller/controller.dart';
3+
import 'package:speed_share/app/controller/download_controller.dart';
34

45
class HomeBinding extends Bindings {
56
@override
@@ -8,5 +9,6 @@ class HomeBinding extends Bindings {
89
Get.put(OnlineController());
910
Get.put(FileController());
1011
Get.put(DeviceController());
12+
Get.put(DownloadController());
1113
}
1214
}

lib/app/controller/device_controller.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,11 @@ class DeviceController extends GetxController {
3434
@override
3535
void onInit() {
3636
super.onInit();
37-
Log.w('$this init');
3837
}
3938

4039
@override
4140
void onReady() {
4241
super.onReady();
43-
Log.w('$this onReady');
4442
}
4543

4644
void onDeviceConnect(

lib/app/controller/download_controller.dart

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
1+
import 'dart:async';
2+
3+
import 'package:dio/dio.dart';
14
import 'package:get/get.dart';
5+
import 'package:global_repository/global_repository.dart';
6+
import 'package:path/path.dart';
7+
import 'package:speed_share/utils/ext_util.dart';
8+
import 'package:speed_share/utils/path_util.dart';
9+
10+
class DownloadInfo {
11+
double progress = 0;
12+
String speed = '0';
13+
int count = 0;
14+
}
215

316
class DownloadController extends GetxController {
17+
/// key是url,value是进度
18+
Map<String, DownloadInfo> progress = {};
19+
20+
final Dio dio = Dio();
421
@override
522
void onInit() {
623
super.onInit();
@@ -11,6 +28,80 @@ class DownloadController extends GetxController {
1128
super.onReady();
1229
}
1330

31+
double getProgress(String url) {
32+
if (progress.containsKey(url)) {
33+
return progress[url].progress;
34+
}
35+
return 0;
36+
}
37+
38+
DownloadInfo getInfo(String url) {
39+
if (progress.containsKey(url)) {
40+
return progress[url];
41+
}
42+
return DownloadInfo();
43+
}
44+
45+
// 计算网速
46+
Future<void> computeNetSpeed(DownloadInfo info) async {
47+
int tmpCount = 0;
48+
Timer timer;
49+
timer = Timer.periodic(const Duration(milliseconds: 500), (timer) {
50+
int diff = info.count - tmpCount;
51+
tmpCount = info.count;
52+
// Log.e('diff -> $diff');
53+
// 乘以2是因为半秒测的一次
54+
info.speed = FileSizeUtils.getFileSize(diff * 2);
55+
// Log.e('网速 -> $speed');
56+
});
57+
}
58+
1459
@override
1560
void onClose() {}
61+
Future<void> downloadFile(String url, String dir) async {
62+
if (progress.containsKey(url) && progress[url].progress != 0.0) {
63+
showToast('已经在下载中了哦');
64+
return;
65+
}
66+
if (progress.containsKey(url) && progress[url].progress == 1.0) {
67+
showToast('下载完成了哦');
68+
return;
69+
}
70+
DownloadInfo info = DownloadInfo();
71+
progress[url] = info;
72+
String savePath = getSavePath(url, dir);
73+
computeNetSpeed(info);
74+
// Response res = await RangeDownload.downloadWithChunks(
75+
// '$urlPath?download=true', savePath,
76+
// // isRangeDownload: false, //Support normal download
77+
// maxChunk: 4,
78+
// // dio: Dio(),//Optional parameters "dio".Convenient to customize request settings.
79+
// // cancelToken: cancelToken,
80+
// onReceiveProgress: (received, total) {
81+
// count = received;
82+
// fileDownratio = received / total;
83+
// setState(() {});
84+
// if (!isStarted) {
85+
// startTime = DateTime.now();
86+
// isStarted = true;
87+
// }
88+
// },
89+
// );
90+
await dio.download(
91+
'$url?download=true',
92+
savePath,
93+
onReceiveProgress: (count, total) {
94+
info.count = count;
95+
info.progress = count / total;
96+
update();
97+
},
98+
);
99+
update();
100+
}
101+
102+
String getSavePath(String url, String dir) {
103+
String type = url.getType;
104+
String savePath = '$dir/$type/${basename(url)}';
105+
return getSafePath(savePath);
106+
}
16107
}

lib/app/controller/file_controller.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ class FileController extends GetxController {
4646
@override
4747
void onInit() {
4848
super.onInit();
49-
Log.w('$this init');
5049
initFile();
5150
}
5251

@@ -140,6 +139,7 @@ class FileController extends GetxController {
140139
// prefer using rename as it is probably faster
141140
return await sourceFile.rename(newPath);
142141
} on FileSystemException catch (e) {
142+
Log.e('moveFileSafe : $e');
143143
// if rename fails, copy the source file and then delete it
144144
final newFile = await sourceFile.copy(newPath);
145145
await sourceFile.delete();
@@ -175,6 +175,5 @@ class FileController extends GetxController {
175175
@override
176176
void onReady() {
177177
super.onReady();
178-
Log.w('$this onReady');
179178
}
180179
}

lib/app/controller/online_controller.dart

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import 'package:get/get.dart';
22
import 'package:get/get_rx/src/rx_workers/utils/debouncer.dart';
3+
import 'package:signale/signale.dart';
4+
import 'package:speed_share/app/controller/chat_controller.dart';
35

46
class DeviceEntity {
57
DeviceEntity(this.unique, this.address, this.port);
@@ -26,9 +28,10 @@ class DeviceEntity {
2628
@override
2729
int get hashCode => address.hashCode;
2830
}
31+
2932
// 管理UDP发现的设备
3033
class OnlineController extends GetxController {
31-
final list = <DeviceEntity>[].obs;
34+
final list = <DeviceEntity>[];
3235
final Debouncer _debouncer = Debouncer(
3336
delay: const Duration(
3437
seconds: 2,
@@ -66,4 +69,20 @@ class OnlineController extends GetxController {
6669
update();
6770
// Log.w('removeOnlineItem -> $list');
6871
}
72+
// TODO可能出问题,当前连接断开后,就没办法显示在线设备了
73+
List<DeviceEntity> avallist() {
74+
ChatController chatController = Get.find();
75+
if(chatController.chatServerAddress == null){
76+
return list;
77+
}
78+
List<DeviceEntity> tmp = [];
79+
Uri uri = Uri.parse(chatController.chatServerAddress);
80+
// Log.i(uri.host);
81+
for (var element in list) {
82+
if (!element.address.startsWith(uri.host)) {
83+
tmp.add(element);
84+
}
85+
}
86+
return tmp;
87+
}
6988
}

lib/app/controller/setting_controller.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,11 @@ class SettingController extends GetxController {
2828
@override
2929
void onInit() {
3030
super.onInit();
31-
Log.w('$this init');
3231
}
3332

3433
@override
3534
void onReady() {
3635
super.onReady();
37-
Log.w('$this onReady');
3836
}
3937

4038
void clipChange(bool value) {

lib/app/controller/utils/token_util.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ void handleTokenCheck(int port) {
3535
// 发起http get请求,用来校验网络是否互通
3636
// 如果不通,会返回null
3737
Future<String> getToken(String url) async {
38-
Log.i('$url/check_token');
38+
Log.i('访问 $url/check_token 以检测网络是否互通');
3939
Completer lock = Completer();
4040
CancelToken cancelToken = CancelToken();
4141
Response response;
@@ -57,7 +57,6 @@ Future<String> getToken(String url) async {
5757
if (!lock.isCompleted) {
5858
lock.complete(null);
5959
}
60-
Log.w('$url无法访问');
6160
}
6261
return await lock.future;
6362
} // 得到正确的url

lib/app/routes/app_pages.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import 'package:animations/animations.dart';
21
import 'package:flutter/foundation.dart';
32
import 'package:flutter/material.dart';
43
import 'package:flutter/services.dart';
@@ -7,16 +6,14 @@ import 'package:get/get_rx/src/rx_workers/utils/debouncer.dart';
76
import 'package:global_repository/global_repository.dart';
87
import 'package:speed_share/app/bindings/chat_binding.dart';
98
import 'package:speed_share/app/bindings/home_binding.dart';
10-
import 'package:speed_share/app/controller/chat_controller.dart';
119
import 'package:speed_share/themes/theme.dart';
1210
import 'package:speed_share/utils/document/document.dart';
1311
import 'package:speed_share/v2/adapive_entry.dart';
14-
import 'package:speed_share/v2/share_chat_window.dart';
1512
import 'package:file_manager_view/file_manager_view.dart';
1613

1714
part 'app_routes.dart';
1815

19-
Debouncer debouncer = Debouncer(delay: Duration(seconds: 1));
16+
Debouncer debouncer = Debouncer(delay: const Duration(seconds: 1));
2017
int time = 0;
2118

2219
class SpeedPages {

lib/global/global.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ class Global {
9191
localClipdata = clip.text;
9292
Log.i('ClipboardData : ${clip.text}');
9393
stopSendBoardcast();
94-
startSendBoardcast('clip' + clip.text);
94+
startSendBoardcast('clip${clip.text}');
9595
Future.delayed(const Duration(seconds: 3), () {
9696
stopSendBoardcast();
97-
boardcasdMessage.remove('clip' + clip.text);
97+
boardcasdMessage.remove('clip${clip.text}');
9898
multicast.startSendBoardcast(boardcasdMessage);
9999
});
100100
}
@@ -150,11 +150,11 @@ class Global {
150150
final filename = file.name;
151151
if (file.isFile) {
152152
final data = file.content as List<int>;
153-
File wfile = File(RuntimeEnvir.filesPath + '/' + filename);
153+
File wfile = File('${RuntimeEnvir.filesPath}/$filename');
154154
await wfile.create(recursive: true);
155155
await wfile.writeAsBytes(data);
156156
} else {
157-
await Directory(RuntimeEnvir.filesPath + '/' + filename).create(
157+
await Directory('${RuntimeEnvir.filesPath}/$filename').create(
158158
recursive: true,
159159
);
160160
}

lib/main.dart

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'package:flutter/material.dart';
22
import 'package:get/get.dart' hide Response;
33
import 'package:global_repository/global_repository.dart';
4+
import 'package:path_provider/path_provider.dart';
45
import 'package:responsive_framework/responsive_framework.dart';
56
import 'package:settings/settings.dart';
67
import 'package:speed_share/app/controller/chat_controller.dart';
@@ -20,7 +21,12 @@ Future<void> initSetting() async {
2021

2122
Future<void> main() async {
2223
if (!GetPlatform.isWeb && !GetPlatform.isIOS) {
23-
RuntimeEnvir.initEnvirWithPackageName(Config.packageName);
24+
WidgetsFlutterBinding.ensureInitialized();
25+
final dir = (await getApplicationSupportDirectory()).path;
26+
RuntimeEnvir.initEnvirWithPackageName(
27+
Config.packageName,
28+
appSupportDirectory: dir,
29+
);
2430
fm.Server.start();
2531
}
2632
Get.config(

0 commit comments

Comments
 (0)