Skip to content

Commit 0257111

Browse files
Show OAuth info dialog for cloud services
Introduces a reusable Utils.showQAuthDialog method to display an informational dialog about the OAuth relay server for Google Drive, Huawei Cloud, and Box services. The dialog is now shown on relevant backup service screens and can be forced or suppressed based on user acknowledgment. Also updates icons, improves logging, and refines localization for the dialog message. Minor UI and code cleanups included.
1 parent 1b618bc commit 0257111

18 files changed

+64
-30
lines changed

lib/Screens/Backup/aliyundrive_service_screen.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import '../../Database/cloud_service_config_dao.dart';
2525
import '../../TokenUtils/Cloud/aliyundrive_cloud_service.dart';
2626
import '../../TokenUtils/export_token_util.dart';
2727
import '../../TokenUtils/import_token_util.dart';
28+
import '../../Utils/utils.dart';
2829
import '../../Widgets/BottomSheet/Backups/aliyundrive_backups_bottom_sheet.dart';
2930
import '../../generated/l10n.dart';
3031

@@ -61,6 +62,8 @@ class _AliyunDriveServiceScreenState extends State<AliyunDriveServiceScreen>
6162
void initState() {
6263
super.initState();
6364
loadConfig();
65+
WidgetsBinding.instance
66+
.addPostFrameCallback((_) => Utils.showQAuthDialog(context));
6467
}
6568

6669
loadConfig() async {

lib/Screens/Backup/box_service_screen.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import '../../Database/cloud_service_config_dao.dart';
2626
import '../../TokenUtils/Cloud/box_cloud_service.dart';
2727
import '../../TokenUtils/export_token_util.dart';
2828
import '../../TokenUtils/import_token_util.dart';
29+
import '../../Utils/utils.dart';
2930
import '../../Widgets/BottomSheet/Backups/box_backups_bottom_sheet.dart';
3031
import '../../generated/l10n.dart';
3132

@@ -63,6 +64,8 @@ class _BoxServiceScreenState extends State<BoxServiceScreen>
6364
void initState() {
6465
super.initState();
6566
loadConfig();
67+
WidgetsBinding.instance
68+
.addPostFrameCallback((_) => Utils.showQAuthDialog(context));
6669
}
6770

6871
loadConfig() async {

lib/Screens/Backup/cloud_service_screen.dart

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import 'package:group_button/group_button.dart';
2828
import 'package:lucide_icons/lucide_icons.dart';
2929

3030
import '../../TokenUtils/Cloud/cloud_service.dart';
31+
import '../../Utils/utils.dart';
3132
import '../../generated/l10n.dart';
3233
import '../Setting/base_setting_screen.dart';
3334

@@ -81,7 +82,7 @@ class _CloudServiceScreenState extends State<CloudServiceScreen>
8182
desktopActions: [
8283
ToolButton(
8384
context: context,
84-
icon: LucideIcons.info,
85+
icon: LucideIcons.shieldCheck,
8586
buttonSize: const Size(32, 32),
8687
onPressed: _showServerInfo,
8788
tooltipPosition: TooltipPosition.bottom,
@@ -91,7 +92,7 @@ class _CloudServiceScreenState extends State<CloudServiceScreen>
9192
actions: [
9293
CircleIconButton(
9394
icon: Icon(
94-
LucideIcons.info,
95+
LucideIcons.shieldCheck,
9596
color: ChewieTheme.iconColor,
9697
),
9798
onTap: _showServerInfo,
@@ -101,19 +102,7 @@ class _CloudServiceScreenState extends State<CloudServiceScreen>
101102
}
102103

103104
_showServerInfo() {
104-
DialogBuilder.showConfirmDialog(
105-
context,
106-
title: S.current.cloudOAuthDialogTitle,
107-
message: S.current.cloudOAuthDialogMessage(CloudService.serverEndpoint,
108-
CloudService.serverGithubUrl, CloudService.serverGithubRepoName),
109-
renderHtml: true,
110-
cancelButtonText: S.current.cloudOAuthDialogGoToRepo,
111-
confirmButtonText: S.current.cloudOAuthDialogConfirm,
112-
onTapConfirm: () {},
113-
onTapCancel: () {
114-
UriUtil.openExternal(CloudService.serverGithubUrl);
115-
},
116-
);
105+
Utils.showQAuthDialog(context, true);
117106
}
118107

119108
_buildBody() {

lib/Screens/Backup/googledrive_service_screen.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import '../../Database/cloud_service_config_dao.dart';
2525
import '../../TokenUtils/Cloud/googledrive_cloud_service.dart';
2626
import '../../TokenUtils/export_token_util.dart';
2727
import '../../TokenUtils/import_token_util.dart';
28+
import '../../Utils/utils.dart';
2829
import '../../Widgets/BottomSheet/Backups/googledrive_backups_bottom_sheet.dart';
2930
import '../../generated/l10n.dart';
3031

@@ -63,6 +64,8 @@ class _GoogleDriveServiceScreenState extends State<GoogleDriveServiceScreen>
6364
void initState() {
6465
super.initState();
6566
loadConfig();
67+
WidgetsBinding.instance
68+
.addPostFrameCallback((_) => Utils.showQAuthDialog(context));
6669
}
6770

6871
loadConfig() async {
@@ -133,7 +136,8 @@ class _GoogleDriveServiceScreenState extends State<GoogleDriveServiceScreen>
133136
}
134137
await currentService.checkServer().then((value) async {
135138
if (!value) {
136-
IToast.show(S.current.cloudOAuthUnavailable(CloudService.serverEndpoint));
139+
IToast.show(
140+
S.current.cloudOAuthUnavailable(CloudService.serverEndpoint));
137141
} else {
138142
await currentService.authenticate().then((value) async {
139143
setState(() {

lib/Screens/Backup/huawei_service_screen.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import '../../Database/cloud_service_config_dao.dart';
2525
import '../../TokenUtils/Cloud/huawei_cloud_service.dart';
2626
import '../../TokenUtils/export_token_util.dart';
2727
import '../../TokenUtils/import_token_util.dart';
28+
import '../../Utils/utils.dart';
2829
import '../../Widgets/BottomSheet/Backups/huawei_backups_bottom_sheet.dart';
2930
import '../../generated/l10n.dart';
3031

@@ -62,6 +63,8 @@ class _HuaweiCloudServiceScreenState extends State<HuaweiCloudServiceScreen>
6263
void initState() {
6364
super.initState();
6465
loadConfig();
66+
WidgetsBinding.instance
67+
.addPostFrameCallback((_) => Utils.showQAuthDialog(context));
6568
}
6669

6770
loadConfig() async {

lib/Screens/Lock/pin_verify_screen.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,10 @@ class PinVerifyScreenState extends State<PinVerifyScreen>
122122
windowManager.addListener(this);
123123
super.initState();
124124
WidgetsBinding.instance.addPostFrameCallback((_) {
125-
chewieProvider.loadingWidgetBuilder = (size, forceDark) =>
126-
LottieFiles.load(LottieFiles.getLoadingPath(context), scale: 1.5);
125+
if (mounted) {
126+
chewieProvider.loadingWidgetBuilder = (size, forceDark) =>
127+
LottieFiles.load(LottieFiles.getLoadingPath(context), scale: 1.5);
128+
}
127129
});
128130
Utils.initSimpleTray();
129131
initBiometricAuthentication();
@@ -166,7 +168,7 @@ class PinVerifyScreenState extends State<PinVerifyScreen>
166168
? ResponsiveAppBar(
167169
title: S.current.verifyGestureLock,
168170
showBack: false,
169-
titleLeftMargin: 12,
171+
titleLeftMargin: 15,
170172
actions: const [
171173
BlankIconButton(),
172174
],

lib/Screens/main_screen.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ class MainScreenState extends State<MainScreen>
177177
});
178178
fetchReleases();
179179
WidgetsBinding.instance.addPostFrameCallback((_) async {
180+
IToast.showTop("Initialized");
180181
if (ChewieHiveUtil.getBool(CloudOTPHiveUtil.autoFocusSearchBarKey,
181182
defaultValue: false)) {
182183
ShortcutsUtil.focusSearch();

lib/TokenUtils/Cloud/box_cloud_service.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import 'dart:typed_data';
1717

18+
import 'package:awesome_chewie/awesome_chewie.dart';
1819
import 'package:awesome_cloud/awesome_cloud.dart';
1920
import 'package:http/http.dart' as http;
2021

@@ -61,7 +62,8 @@ class BoxCloudService extends CloudService {
6162
@override
6263
Future<bool> checkServer() async {
6364
try {
64-
final response = await http.head(Uri.parse(_customAuthEndpoint));
65+
final response = await http.head(Uri.parse(CloudService.serverEndpoint));
66+
ILogger.info('Box Cloud service availability response for $_customAuthEndpoint: ${response.statusCode}');
6567
return response.statusCode == 200;
6668
} catch (e) {
6769
return false;

lib/Utils/hive_util.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ class CloudOTPHiveUtil {
8282

8383
//System
8484
static const String oldVersionKey = "oldVersion";
85+
static const String haveShowQAuthDialogKey = "haveShowQAuthDialog";
8586

8687
static initConfig() async {
8788
await ChewieHiveUtil.put(

lib/Utils/utils.dart

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import '../Screens/Setting/about_setting_screen.dart';
3434
import '../Screens/Setting/mobile_setting_navigation_screen.dart';
3535
import '../Screens/Setting/setting_navigation_screen.dart';
3636
import '../Screens/Setting/setting_safe_screen.dart';
37+
import '../TokenUtils/Cloud/cloud_service.dart';
3738
import '../TokenUtils/code_generator.dart';
3839
import 'package:screen_retriever/screen_retriever.dart';
3940
import '../generated/l10n.dart';
@@ -42,6 +43,26 @@ import 'constant.dart';
4243
import 'hive_util.dart';
4344

4445
class Utils {
46+
static showQAuthDialog(BuildContext context, [bool force = false]) {
47+
bool haveShowQAuthDialog = ChewieHiveUtil.getBool(
48+
CloudOTPHiveUtil.haveShowQAuthDialogKey,
49+
defaultValue: false);
50+
if (force || !haveShowQAuthDialog) {
51+
DialogBuilder.showInfoDialog(
52+
context,
53+
title: S.current.cloudOAuthDialogTitle,
54+
message: S.current.cloudOAuthDialogMessage(CloudService.serverEndpoint,
55+
CloudService.serverGithubUrl, CloudService.serverGithubRepoName),
56+
renderHtml: true,
57+
// cancelButtonText: S.current.cloudOAuthDialogGoToRepo,
58+
buttonText: S.current.cloudOAuthDialogConfirm,
59+
onTapDismiss: () {
60+
ChewieHiveUtil.put(CloudOTPHiveUtil.haveShowQAuthDialogKey, true);
61+
},
62+
);
63+
}
64+
}
65+
4566
static Future<Rect> getWindowRect(BuildContext context) async {
4667
Display primaryDisplay = await screenRetriever.getPrimaryDisplay();
4768
return Rect.fromLTWH(

0 commit comments

Comments
 (0)