Skip to content

Commit 6b90bdc

Browse files
Improve desktop window handling for cloud services
Added platform checks before minimizing and restoring windows in cloud service screens to prevent errors on non-desktop platforms. Also added Linux unsupported message for Huawei Cloud and updated pubspec version to 3.1.2+312.
1 parent d848058 commit 6b90bdc

9 files changed

+67
-57
lines changed

lib/Screens/Backup/aliyundrive_service_screen.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,14 +243,14 @@ class _AliyunDriveServiceScreenState
243243
onPressed: () async {
244244
try {
245245
appProvider.preventLock = true;
246-
windowManager.minimize();
246+
if(ResponsiveUtil.isDesktop()) windowManager.minimize();
247247
await ping();
248248
} catch (e, t) {
249249
ILogger.error("Failed to connect to aliyunDrive", e, t);
250250
IToast.show(appLocalizations.cloudConnectionError);
251251
} finally {
252252
appProvider.preventLock = false;
253-
windowManager.restore();
253+
if(ResponsiveUtil.isDesktop()) windowManager.restore();
254254
}
255255
},
256256
),

lib/Screens/Backup/box_service_screen.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,14 +255,14 @@ class _BoxServiceScreenState extends BaseDynamicState<BoxServiceScreen>
255255
onPressed: () async {
256256
try {
257257
appProvider.preventLock = true;
258-
windowManager.minimize();
258+
if(ResponsiveUtil.isDesktop()) windowManager.minimize();
259259
await ping();
260260
} catch (e, t) {
261261
ILogger.error("Failed to connect to box", e, t);
262262
IToast.show(appLocalizations.cloudConnectionError);
263263
} finally {
264264
appProvider.preventLock = false;
265-
windowManager.restore();
265+
if(ResponsiveUtil.isDesktop()) windowManager.restore();
266266
}
267267
},
268268
),

lib/Screens/Backup/dropbox_service_screen.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,14 +244,14 @@ class _DropboxServiceScreenState extends BaseDynamicState<DropboxServiceScreen>
244244
onPressed: () async {
245245
try {
246246
appProvider.preventLock = true;
247-
windowManager.minimize();
247+
if(ResponsiveUtil.isDesktop()) windowManager.minimize();
248248
await ping();
249249
} catch (e, t) {
250250
ILogger.error("Failed to connect to dropbox", e, t);
251251
IToast.show(appLocalizations.cloudConnectionError);
252252
} finally {
253253
appProvider.preventLock = false;
254-
windowManager.restore();
254+
if(ResponsiveUtil.isDesktop()) windowManager.restore();
255255
}
256256
},
257257
),

lib/Screens/Backup/googledrive_service_screen.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,14 +242,14 @@ class _GoogleDriveServiceScreenState
242242
onPressed: () async {
243243
try {
244244
appProvider.preventLock = true;
245-
windowManager.minimize();
245+
if(ResponsiveUtil.isDesktop()) windowManager.minimize();
246246
await ping();
247247
} catch (e, t) {
248248
ILogger.error("Failed to connect to google drive", e, t);
249249
IToast.show(appLocalizations.cloudConnectionError);
250250
} finally {
251251
appProvider.preventLock = false;
252-
windowManager.restore();
252+
if(ResponsiveUtil.isDesktop()) windowManager.restore();
253253
}
254254
},
255255
),

lib/Screens/Backup/huawei_service_screen.dart

Lines changed: 56 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class _HuaweiCloudServiceScreenState
7272

7373
loadConfig() async {
7474
_huaweiCloudCloudServiceConfig =
75-
await CloudServiceConfigDao.getHuaweiCloudConfig();
75+
await CloudServiceConfigDao.getHuaweiCloudConfig();
7676
if (_huaweiCloudCloudServiceConfig != null) {
7777
_sizeController.text = _huaweiCloudCloudServiceConfig!.size;
7878
_accountController.text = _huaweiCloudCloudServiceConfig!.account ?? "";
@@ -91,9 +91,9 @@ class _HuaweiCloudServiceScreenState
9191
}
9292
if (_huaweiCloudCloudService != null) {
9393
_huaweiCloudCloudServiceConfig!.configured =
94-
await _huaweiCloudCloudService!.hasConfigured();
94+
await _huaweiCloudCloudService!.hasConfigured();
9595
_huaweiCloudCloudServiceConfig!.connected =
96-
await _huaweiCloudCloudService!.isConnected();
96+
await _huaweiCloudCloudService!.isConnected();
9797
if (_huaweiCloudCloudServiceConfig!.configured &&
9898
!_huaweiCloudCloudServiceConfig!.connected) {
9999
IToast.showTop(appLocalizations.cloudConnectionError);
@@ -118,14 +118,30 @@ class _HuaweiCloudServiceScreenState
118118
@override
119119
Widget build(BuildContext context) {
120120
super.build(context);
121-
return inited
122-
? _buildBody()
123-
: ItemBuilder.buildLoadingDialog(
124-
context: context,
125-
background: Colors.transparent,
126-
text: appLocalizations.cloudConnecting,
127-
mainAxisAlignment: MainAxisAlignment.start,
128-
topPadding: 100,
121+
return ResponsiveUtil.isLinux()
122+
? _buildUnsupportBody()
123+
: inited
124+
? _buildBody()
125+
: ItemBuilder.buildLoadingDialog(
126+
context: context,
127+
background: Colors.transparent,
128+
text: appLocalizations.cloudConnecting,
129+
mainAxisAlignment: MainAxisAlignment.start,
130+
topPadding: 100,
131+
);
132+
}
133+
134+
_buildUnsupportBody() {
135+
return Center(
136+
child: Column(
137+
mainAxisAlignment: MainAxisAlignment.start,
138+
children: [
139+
const SizedBox(height: 100),
140+
Text(appLocalizations
141+
.cloudTypeNotSupport(appLocalizations.cloudTypeBox)),
142+
const SizedBox(height: 10),
143+
],
144+
),
129145
);
130146
}
131147

@@ -194,7 +210,7 @@ class _HuaweiCloudServiceScreenState
194210
onTap: () {
195211
setState(() {
196212
_huaweiCloudCloudServiceConfig!.enabled =
197-
!_huaweiCloudCloudServiceConfig!.enabled;
213+
!_huaweiCloudCloudServiceConfig!.enabled;
198214
CloudServiceConfigDao.updateConfigEnabled(
199215
_huaweiCloudCloudServiceConfig!,
200216
_huaweiCloudCloudServiceConfig!.enabled);
@@ -236,14 +252,14 @@ class _HuaweiCloudServiceScreenState
236252
onPressed: () async {
237253
try {
238254
appProvider.preventLock = true;
239-
windowManager.minimize();
255+
if(ResponsiveUtil.isDesktop()) windowManager.minimize();
240256
await ping();
241257
} catch (e, t) {
242258
ILogger.error("Failed to connect to huawei cloud", e, t);
243259
IToast.show(appLocalizations.cloudConnectionError);
244260
} finally {
245261
appProvider.preventLock = false;
246-
windowManager.restore();
262+
if(ResponsiveUtil.isDesktop()) windowManager.restore();
247263
}
248264
},
249265
),
@@ -266,7 +282,7 @@ class _HuaweiCloudServiceScreenState
266282
title: appLocalizations.cloudPulling);
267283
try {
268284
List<HuaweiCloudFileInfo>? files =
269-
await _huaweiCloudCloudService!.listBackups();
285+
await _huaweiCloudCloudService!.listBackups();
270286
if (files == null) {
271287
CustomLoadingDialog.dismissLoading();
272288
IToast.show(appLocalizations.cloudPullFailed);
@@ -281,26 +297,24 @@ class _HuaweiCloudServiceScreenState
281297
BottomSheetBuilder.showBottomSheet(
282298
context,
283299
responsive: true,
284-
(dialogContext) =>
285-
HuaweiCloudBackupsBottomSheet(
286-
files: files,
287-
cloudService: _huaweiCloudCloudService!,
288-
onSelected: (selectedFile) async {
289-
var dialog = showProgressDialog(
290-
appLocalizations.cloudPulling,
291-
showProgress: true,
292-
);
293-
Uint8List? res =
300+
(dialogContext) => HuaweiCloudBackupsBottomSheet(
301+
files: files,
302+
cloudService: _huaweiCloudCloudService!,
303+
onSelected: (selectedFile) async {
304+
var dialog = showProgressDialog(
305+
appLocalizations.cloudPulling,
306+
showProgress: true,
307+
);
308+
Uint8List? res =
294309
await _huaweiCloudCloudService!.downloadFile(
295-
selectedFile.id,
296-
onProgress: (c, t) {
297-
dialog.updateProgress(progress: c / t);
298-
},
299-
);
300-
ImportTokenUtil.importFromCloud(
301-
context, res, dialog);
310+
selectedFile.id,
311+
onProgress: (c, t) {
312+
dialog.updateProgress(progress: c / t);
302313
},
303-
),
314+
);
315+
ImportTokenUtil.importFromCloud(context, res, dialog);
316+
},
317+
),
304318
);
305319
} else {
306320
IToast.show(appLocalizations.cloudNoBackupFile);
@@ -340,16 +354,16 @@ class _HuaweiCloudServiceScreenState
340354
title: appLocalizations.cloudLogout,
341355
message: appLocalizations.cloudLogoutMessage,
342356
onTapConfirm: () async {
343-
await _huaweiCloudCloudService!.signOut();
344-
setState(() {
345-
_huaweiCloudCloudServiceConfig!.connected = false;
346-
_huaweiCloudCloudServiceConfig!.account = "";
347-
_huaweiCloudCloudServiceConfig!.totalSize =
348-
_huaweiCloudCloudServiceConfig!.remainingSize =
357+
await _huaweiCloudCloudService!.signOut();
358+
setState(() {
359+
_huaweiCloudCloudServiceConfig!.connected = false;
360+
_huaweiCloudCloudServiceConfig!.account = "";
361+
_huaweiCloudCloudServiceConfig!.totalSize =
362+
_huaweiCloudCloudServiceConfig!.remainingSize =
349363
_huaweiCloudCloudServiceConfig!.usedSize = -1;
350-
updateConfig(_huaweiCloudCloudServiceConfig!);
351-
});
352-
});
364+
updateConfig(_huaweiCloudCloudServiceConfig!);
365+
});
366+
});
353367
},
354368
),
355369
),

lib/Screens/Backup/onedrive_service_screen.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,14 +253,14 @@ class _OneDriveServiceScreenState
253253
onPressed: () async {
254254
try {
255255
appProvider.preventLock = true;
256-
windowManager.minimize();
256+
if(ResponsiveUtil.isDesktop()) windowManager.minimize();
257257
await ping();
258258
} catch (e, t) {
259259
ILogger.error("Failed to connect to onedrive", e, t);
260260
IToast.show(appLocalizations.cloudConnectionError);
261261
} finally {
262262
appProvider.preventLock = false;
263-
windowManager.restore();
263+
if(ResponsiveUtil.isDesktop()) windowManager.restore();
264264
}
265265
},
266266
),

lib/Screens/Backup/s3_service_screen.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,14 +300,12 @@ class _S3CloudServiceScreenState extends BaseDynamicState<S3CloudServiceScreen>
300300
await CloudServiceConfigDao.updateConfig(currentConfig);
301301
_s3CloudService = S3CloudService(_s3CloudServiceConfig!);
302302
appProvider.preventLock = true;
303-
windowManager.minimize();
304303
await ping();
305304
} catch (e, t) {
306305
ILogger.error("Failed to connect to S3 cloud", e, t);
307306
IToast.show(appLocalizations.cloudConnectionError);
308307
} finally {
309308
appProvider.preventLock = false;
310-
windowManager.restore();
311309
}
312310
}
313311
},

lib/Screens/Backup/webdav_service_screen.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,14 +265,12 @@ class _WebDavServiceScreenState extends BaseDynamicState<WebDavServiceScreen>
265265
WebDavCloudService(_webDavCloudServiceConfig!);
266266
try {
267267
appProvider.preventLock = true;
268-
windowManager.minimize();
269268
await ping();
270269
} catch (e, t) {
271270
ILogger.error("Failed to connect to webdav", e, t);
272271
IToast.show(appLocalizations.cloudConnectionError);
273272
} finally {
274273
appProvider.preventLock = false;
275-
windowManager.restore();
276274
}
277275
}
278276
},

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: cloudotp
2-
version: 3.1.1+311
2+
version: 3.1.2+312
33
description: An awesome two-factor authenticator which supports cloud storage and multiple platforms.
44
publish_to: none
55

0 commit comments

Comments
 (0)