From bdf8bbe26f8a4255997a257953b09c12e6083df0 Mon Sep 17 00:00:00 2001 From: rustdesk Date: Wed, 17 Apr 2024 12:48:27 +0800 Subject: [PATCH] custom android --- flutter/lib/common.dart | 21 +++++ .../lib/desktop/pages/desktop_home_page.dart | 17 +--- flutter/lib/mobile/pages/home_page.dart | 2 +- flutter/lib/mobile/pages/settings_page.dart | 78 ++++++++++++------- 4 files changed, 71 insertions(+), 47 deletions(-) diff --git a/flutter/lib/common.dart b/flutter/lib/common.dart index fc5b537e1..a878995c9 100644 --- a/flutter/lib/common.dart +++ b/flutter/lib/common.dart @@ -3106,6 +3106,27 @@ Color? disabledTextColor(BuildContext context, bool enabled) { : Theme.of(context).textTheme.titleLarge?.color?.withOpacity(0.6); } +Widget loadPowered(BuildContext context) { + return MouseRegion( + cursor: SystemMouseCursors.click, + child: GestureDetector( + onTap: () { + launchUrl(Uri.parse('https://rustdesk.com')); + }, + child: Opacity( + opacity: 0.5, + child: Text( + translate("powered_by_me"), + overflow: TextOverflow.clip, + style: Theme.of(context) + .textTheme + .bodySmall + ?.copyWith(fontSize: 9, decoration: TextDecoration.underline), + )), + ), + ).marginOnly(top: 6); +} + // max 300 x 60 Widget loadLogo() { return FutureBuilder( diff --git a/flutter/lib/desktop/pages/desktop_home_page.dart b/flutter/lib/desktop/pages/desktop_home_page.dart index 7395f4708..c2902806f 100644 --- a/flutter/lib/desktop/pages/desktop_home_page.dart +++ b/flutter/lib/desktop/pages/desktop_home_page.dart @@ -115,22 +115,7 @@ class _DesktopHomePageState extends State if (bind.isCustomClient()) Align( alignment: Alignment.center, - child: MouseRegion( - cursor: SystemMouseCursors.click, - child: GestureDetector( - onTap: () { - launchUrl(Uri.parse('https://rustdesk.com')); - }, - child: Opacity( - opacity: 0.5, - child: Text( - translate("powered_by_me"), - overflow: TextOverflow.clip, - style: Theme.of(context).textTheme.bodySmall?.copyWith( - fontSize: 9, decoration: TextDecoration.underline), - )), - ), - ).marginOnly(top: 6), + child: loadPowered(context), ), Align( alignment: Alignment.center, diff --git a/flutter/lib/mobile/pages/home_page.dart b/flutter/lib/mobile/pages/home_page.dart index e75f9998a..0f3e7b20a 100644 --- a/flutter/lib/mobile/pages/home_page.dart +++ b/flutter/lib/mobile/pages/home_page.dart @@ -45,7 +45,7 @@ class HomePageState extends State { void initPages() { _pages.clear(); if (!bind.isIncomingOnly()) _pages.add(ConnectionPage()); - if (isAndroid) { + if (isAndroid && !bind.isOutgoingOnly()) { _pages.addAll([ChatPage(type: ChatPageType.mobileMain), ServerPage()]); } _pages.add(SettingsPage()); diff --git a/flutter/lib/mobile/pages/settings_page.dart b/flutter/lib/mobile/pages/settings_page.dart index f6b217533..e79310650 100644 --- a/flutter/lib/mobile/pages/settings_page.dart +++ b/flutter/lib/mobile/pages/settings_page.dart @@ -27,7 +27,7 @@ class SettingsPage extends StatefulWidget implements PageShape { final icon = Icon(Icons.settings); @override - final appBarActions = [ScanButton()]; + final appBarActions = bind.isDisableSettings() ? [] : [ScanButton()]; @override State createState() => _SettingsState(); @@ -218,6 +218,7 @@ class _SettingsState extends State with WidgetsBindingObserver { @override Widget build(BuildContext context) { Provider.of(context); + final outgoingOnly = bind.isOutgoingOnly(); final List enhancementsTiles = []; final List shareScreenTiles = [ SettingsTile.switchTile( @@ -448,33 +449,36 @@ class _SettingsState extends State with WidgetsBindingObserver { gFFI.invokeMethod(AndroidChannel.kSetStartOnBootOpt, toValue); })); - return SettingsList( + final disabledSettings = bind.isDisableSettings(); + final settings = SettingsList( sections: [ - SettingsSection( - title: Text(translate('Account')), - tiles: [ - SettingsTile( - title: Obx(() => Text(gFFI.userModel.userName.value.isEmpty - ? translate('Login') - : '${translate('Logout')} (${gFFI.userModel.userName.value})')), - leading: Icon(Icons.person), - onPressed: (context) { - if (gFFI.userModel.userName.value.isEmpty) { - loginDialog(); - } else { - logOutConfirmDialog(); - } - }, - ), - ], - ), + if (!bind.isDisableAccount()) + SettingsSection( + title: Text(translate('Account')), + tiles: [ + SettingsTile( + title: Obx(() => Text(gFFI.userModel.userName.value.isEmpty + ? translate('Login') + : '${translate('Logout')} (${gFFI.userModel.userName.value})')), + leading: Icon(Icons.person), + onPressed: (context) { + if (gFFI.userModel.userName.value.isEmpty) { + loginDialog(); + } else { + logOutConfirmDialog(); + } + }, + ), + ], + ), SettingsSection(title: Text(translate("Settings")), tiles: [ - SettingsTile( - title: Text(translate('ID/Relay Server')), - leading: Icon(Icons.cloud), - onPressed: (context) { - showServerSettings(gFFI.dialogManager); - }), + if (!disabledSettings) + SettingsTile( + title: Text(translate('ID/Relay Server')), + leading: Icon(Icons.cloud), + onPressed: (context) { + showServerSettings(gFFI.dialogManager); + }), SettingsTile( title: Text(translate('Language')), leading: Icon(Icons.translate), @@ -494,7 +498,7 @@ class _SettingsState extends State with WidgetsBindingObserver { }, ) ]), - if (isAndroid) + if (isAndroid && !outgoingOnly) SettingsSection( title: Text(translate("Recording")), tiles: [ @@ -523,13 +527,13 @@ class _SettingsState extends State with WidgetsBindingObserver { ), ], ), - if (isAndroid) + if (isAndroid && !disabledSettings && !outgoingOnly) SettingsSection( title: Text(translate("Share Screen")), tiles: shareScreenTiles, ), - defaultDisplaySection(), - if (isAndroid) + if (!bind.isIncomingOnly()) defaultDisplaySection(), + if (isAndroid && !disabledSettings && !outgoingOnly) SettingsSection( title: Text(translate("Enhancements")), tiles: enhancementsTiles, @@ -578,6 +582,20 @@ class _SettingsState extends State with WidgetsBindingObserver { ), ], ); + return Column( + children: [ + if (bind.isCustomClient()) + Align( + alignment: Alignment.center, + child: loadPowered(context), + ), + Align( + alignment: Alignment.center, + child: loadLogo(), + ), + settings + ], + ); } Future canStartOnBoot() async {