#77 new: also when backing app

This commit is contained in:
lollipopkit
2023-07-25 12:24:26 +08:00
parent 9e6f386b28
commit 08a4dba659
17 changed files with 103 additions and 23 deletions

View File

@@ -2,8 +2,8 @@
class BuildData {
static const String name = "ServerBox";
static const int build = 380;
static const int build = 387;
static const String engine = "3.10.6";
static const String buildAt = "2023-07-20 18:08:32.806339";
static const int modifications = 14;
static const String buildAt = "2023-07-21 18:06:24.239059";
static const int modifications = 2;
}

View File

@@ -15,3 +15,4 @@ const maxDebugLogLines = 100;
/// Method Channels
const pkgName = 'tech.lolli.toolbox';
const bgRunChannel = MethodChannel('$pkgName/app_retain');
const homeWidgetChannel = MethodChannel('$pkgName/home_widget');

View File

@@ -95,4 +95,7 @@ class SettingStore extends PersistentStore {
StoreProperty<NetViewType> get netViewType =>
property('netViewType', defaultValue: NetViewType.speed);
// Only valid on iOS
StoreProperty<bool> get autoUpdateHomeWidget => property('autoUpdateHomeWidget', defaultValue: isIOS);
}

View File

@@ -10,6 +10,7 @@
"alreadyLastDir": "Bereits im letzten Verzeichnis.",
"attention": "Achtung",
"auto": "System folgen",
"autoUpdateHomeWidget": "Home-Widget automatisch aktualisieren",
"backup": "Backup",
"backupAndRestore": "Backup und Wiederherstellung",
"backupTip": "Das Backup wird nur einfach verschlüsselt.\nBitte bewahre die Datei sicher auf.",
@@ -204,5 +205,6 @@
"versionUpdated": "v1.0.{build} ist bereits die neueste Version",
"viewErr": "Fehler anzeigen",
"waitConnection": "Bitte warte, bis die Verbindung hergestellt wurde.",
"whenOpenApp": "Beim Öffnen der App",
"willTakEeffectImmediately": "Wird sofort angewendet"
}

View File

@@ -10,6 +10,7 @@
"alreadyLastDir": "Already in last directory.",
"attention": "Attention",
"auto": "Auto",
"autoUpdateHomeWidget": "Auto update home widget",
"backup": "Backup",
"backupAndRestore": "Backup and Restore",
"backupTip": "The exported data is simply encrypted. \nPlease keep it safe.",
@@ -204,5 +205,6 @@
"versionUpdated": "Current: v1.0.{build}, is up to date",
"viewErr": "See error",
"waitConnection": "Please wait for the connection to be established.",
"whenOpenApp": "When opening the app",
"willTakEeffectImmediately": "Will take effect immediately"
}

View File

@@ -10,6 +10,7 @@
"alreadyLastDir": "已经是最上层目录了",
"attention": "注意",
"auto": "自动",
"autoUpdateHomeWidget": "自动更新桌面小部件",
"backup": "备份",
"backupAndRestore": "备份和恢复",
"backupTip": "导出的数据仅进行了简单加密,请妥善保管。",
@@ -204,5 +205,6 @@
"versionUpdated": "当前v1.0.{build}, 已是最新版本",
"viewErr": "查看错误",
"waitConnection": "请等待连接建立",
"whenOpenApp": "当打开 App 时",
"willTakEeffectImmediately": "更改将会立即生效"
}

View File

@@ -10,6 +10,7 @@
"alreadyLastDir": "已經是最上層目錄了",
"attention": "注意",
"auto": "自動",
"autoUpdateHomeWidget": "自動更新桌面小部件",
"backup": "備份",
"backupAndRestore": "備份和還原",
"backupTip": "導出的數據僅進行了簡單加密,請妥善保管。",
@@ -204,5 +205,6 @@
"versionUpdated": "當前v1.0.{build}, 已是最新版本",
"viewErr": "查看錯誤",
"waitConnection": "請等待連接建立",
"whenOpenApp": "當打開 App 時",
"willTakEeffectImmediately": "更改將會立即生效"
}

View File

@@ -85,6 +85,7 @@ class _HomePageState extends State<HomePage>
if (!_serverProvider.isAutoRefreshOn) {
_serverProvider.startAutoRefresh();
}
updateHomeWidget();
break;
case AppLifecycleState.paused:
// Keep running in background on Android device
@@ -306,6 +307,7 @@ class _HomePageState extends State<HomePage>
@override
Future<void> afterFirstLayout(BuildContext context) async {
doUpdate(context);
updateHomeWidget();
await GetIt.I.allReady();
await _serverProvider.loadLocalData();
await _serverProvider.refreshData();
@@ -313,4 +315,10 @@ class _HomePageState extends State<HomePage>
Analysis.init();
}
}
void updateHomeWidget() {
if (_setting.autoUpdateHomeWidget.fetch()!) {
homeWidgetChannel.invokeMethod('update');
}
}
}

View File

@@ -145,6 +145,7 @@ class _SettingPageState extends State<SettingPage> {
];
if (isIOS) {
children.add(_buildPushToken());
children.add(_buildAutoUpdateHomeWidget());
}
if (isAndroid) {
children.add(_buildBgRun());
@@ -928,4 +929,12 @@ class _SettingPageState extends State<SettingPage> {
},
);
}
Widget _buildAutoUpdateHomeWidget() {
return ListTile(
title: Text(_s.autoUpdateHomeWidget),
subtitle: Text(_s.whenOpenApp, style: grey),
trailing: buildSwitch(context, _setting.autoUpdateHomeWidget),
);
}
}