mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
new: auto request noti perm
This commit is contained in:
13
lib/core/utils/platform/perm.dart
Normal file
13
lib/core/utils/platform/perm.dart
Normal file
@@ -0,0 +1,13 @@
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
|
||||
abstract final class PermUtils {
|
||||
static Future<bool> request(Permission permission) async {
|
||||
final status = await permission.status;
|
||||
if (status.isGranted) {
|
||||
return true;
|
||||
} else {
|
||||
final result = await permission.request();
|
||||
return result.isGranted;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -263,5 +263,8 @@ class SettingStore extends PersistentStore {
|
||||
/// Version of store db
|
||||
late final storeVersion = property('storeVersion', 0);
|
||||
|
||||
/// Have notified user for notificaiton permission or not
|
||||
late final noNotiPerm = property('noNotiPerm', false);
|
||||
|
||||
// ------END------
|
||||
}
|
||||
|
||||
@@ -164,6 +164,7 @@
|
||||
"newContainer": "Neuer Container",
|
||||
"noClient": "Kein Client",
|
||||
"noInterface": "Kein Interface",
|
||||
"noNotiPerm": "Keine Benachrichtigungsrechte, möglicherweise keine Fortschrittsanzeige beim Herunterladen von App-Updates.",
|
||||
"noOptions": "Keine Optionen verfügbar",
|
||||
"noResult": "Kein Ergebnis",
|
||||
"noSavedPrivateKey": "Keine gespeicherten Private Keys",
|
||||
|
||||
@@ -164,6 +164,7 @@
|
||||
"newContainer": "New container",
|
||||
"noClient": "No client",
|
||||
"noInterface": "No interface",
|
||||
"noNotiPerm": "No notification permissions, possibly no progress indication when downloading app updates.",
|
||||
"noOptions": "No options",
|
||||
"noResult": "No result",
|
||||
"noSavedPrivateKey": "No saved private keys.",
|
||||
|
||||
@@ -164,6 +164,7 @@
|
||||
"newContainer": "Crear contenedor nuevo",
|
||||
"noClient": "No hay conexión SSH",
|
||||
"noInterface": "No hay interfaz disponible",
|
||||
"noNotiPerm": "Sin permisos de notificación, posiblemente sin indicación de progreso al descargar actualizaciones de la aplicación.",
|
||||
"noOptions": "Sin opciones disponibles",
|
||||
"noResult": "Sin resultados",
|
||||
"noSavedPrivateKey": "No hay llaves privadas guardadas.",
|
||||
|
||||
@@ -164,6 +164,7 @@
|
||||
"newContainer": "Nouveau conteneur",
|
||||
"noClient": "Aucun client",
|
||||
"noInterface": "Aucune interface",
|
||||
"noNotiPerm": "Pas de permissions de notification, il est possible qu'il n'y ait pas de notification de progression lors du téléchargement des mises à jour des applications.",
|
||||
"noOptions": "Aucune option",
|
||||
"noResult": "Aucun résultat",
|
||||
"noSavedPrivateKey": "Aucune clé privée enregistrée.",
|
||||
|
||||
@@ -164,6 +164,7 @@
|
||||
"newContainer": "Wadah baru",
|
||||
"noClient": "Tidak ada klien",
|
||||
"noInterface": "Tidak ada antarmuka",
|
||||
"noNotiPerm": "Tidak ada izin notifikasi, mungkin tidak ada indikasi kemajuan saat mengunduh pembaruan aplikasi.",
|
||||
"noOptions": "Tidak ada opsi",
|
||||
"noResult": "Tidak ada hasil",
|
||||
"noSavedPrivateKey": "Tidak ada kunci pribadi yang disimpan.",
|
||||
|
||||
@@ -164,6 +164,7 @@
|
||||
"newContainer": "新しいコンテナを作成",
|
||||
"noClient": "SSH接続がありません",
|
||||
"noInterface": "使用可能なインターフェースがありません",
|
||||
"noNotiPerm": "通知の権限がないため、アプリの更新のダウンロード中に進行状況が表示されない場合があります。",
|
||||
"noOptions": "選択肢がありません",
|
||||
"noResult": "結果なし",
|
||||
"noSavedPrivateKey": "保存されたプライベートキーがありません。",
|
||||
|
||||
@@ -164,6 +164,7 @@
|
||||
"newContainer": "Novo contêiner",
|
||||
"noClient": "Sem conexão SSH",
|
||||
"noInterface": "Sem interface disponível",
|
||||
"noNotiPerm": "Sem permissão de notificação, possivelmente sem indicação de progresso ao baixar atualizações de aplicativos.",
|
||||
"noOptions": "Sem opções",
|
||||
"noResult": "Sem resultados",
|
||||
"noSavedPrivateKey": "Nenhuma chave privada salva.",
|
||||
|
||||
@@ -164,6 +164,7 @@
|
||||
"newContainer": "создать контейнер",
|
||||
"noClient": "нет SSH соединения",
|
||||
"noInterface": "нет доступных интерфейсов",
|
||||
"noNotiPerm": "Нет разрешения на уведомления, возможно отсутствие индикации прогресса при загрузке обновлений приложений.",
|
||||
"noOptions": "нет доступных опций",
|
||||
"noResult": "нет результатов",
|
||||
"noSavedPrivateKey": "Нет сохраненных приватных ключей.",
|
||||
|
||||
@@ -164,6 +164,7 @@
|
||||
"newContainer": "新建容器",
|
||||
"noClient": "没有SSH连接",
|
||||
"noInterface": "没有可用的接口",
|
||||
"noNotiPerm": "无通知权限,可能下载App更新时无进度提示。",
|
||||
"noOptions": "无可选项",
|
||||
"noResult": "无结果",
|
||||
"noSavedPrivateKey": "没有已保存的私钥。",
|
||||
|
||||
@@ -164,6 +164,7 @@
|
||||
"newContainer": "新建容器",
|
||||
"noClient": "沒有SSH連接",
|
||||
"noInterface": "沒有可用的接口",
|
||||
"noNotiPerm": "無通知權限,可能在下載應用程式更新時沒有進度提示。",
|
||||
"noOptions": "無可選項",
|
||||
"noResult": "無結果",
|
||||
"noSavedPrivateKey": "沒有已保存的私鑰。",
|
||||
|
||||
@@ -4,14 +4,17 @@ import 'package:after_layout/after_layout.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:toolbox/core/channel/bg_run.dart';
|
||||
import 'package:toolbox/core/channel/home_widget.dart';
|
||||
import 'package:toolbox/core/extension/context/common.dart';
|
||||
import 'package:toolbox/core/extension/context/dialog.dart';
|
||||
import 'package:toolbox/core/extension/context/locale.dart';
|
||||
import 'package:toolbox/core/persistant_store.dart';
|
||||
import 'package:toolbox/core/update.dart';
|
||||
import 'package:toolbox/core/utils/platform/auth.dart';
|
||||
import 'package:toolbox/core/utils/platform/base.dart';
|
||||
import 'package:toolbox/core/utils/platform/perm.dart';
|
||||
import 'package:toolbox/data/res/github_id.dart';
|
||||
import 'package:toolbox/data/res/logger.dart';
|
||||
import 'package:toolbox/data/res/provider.dart';
|
||||
@@ -315,6 +318,26 @@ ${GithubIds.participants.map((e) => '[$e](${e.url})').join(' ')}
|
||||
// Auth required for first launch
|
||||
BioAuth.go();
|
||||
|
||||
PermUtils.request(Permission.notification).then((suc) {
|
||||
if (!suc) {
|
||||
final noNotiPerm = Stores.setting.noNotiPerm;
|
||||
if (noNotiPerm.fetch()) return;
|
||||
context.showRoundDialog(
|
||||
title: Text(l10n.error),
|
||||
child: Text(l10n.noNotiPerm),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
noNotiPerm.put(true);
|
||||
context.pop();
|
||||
},
|
||||
child: Text(l10n.ok),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
if (Stores.setting.autoCheckAppUpdate.fetch()) {
|
||||
doUpdate(context);
|
||||
}
|
||||
|
||||
48
pubspec.lock
48
pubspec.lock
@@ -815,6 +815,54 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.11.1"
|
||||
permission_handler:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: permission_handler
|
||||
sha256: "18bf33f7fefbd812f37e72091a15575e72d5318854877e0e4035a24ac1113ecb"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "11.3.1"
|
||||
permission_handler_android:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: permission_handler_android
|
||||
sha256: "1acac6bae58144b442f11e66621c062aead9c99841093c38f5bcdcc24c1c3474"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "12.0.5"
|
||||
permission_handler_apple:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: permission_handler_apple
|
||||
sha256: e9ad66020b89ff1b63908f247c2c6f931c6e62699b756ef8b3c4569350cd8662
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "9.4.4"
|
||||
permission_handler_html:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: permission_handler_html
|
||||
sha256: "54bf176b90f6eddd4ece307e2c06cf977fb3973719c35a93b85cc7093eb6070d"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.1.1"
|
||||
permission_handler_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: permission_handler_platform_interface
|
||||
sha256: "48d4fcf201a1dad93ee869ab0d4101d084f49136ec82a8a06ed9cfeacab9fd20"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.2.1"
|
||||
permission_handler_windows:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: permission_handler_windows
|
||||
sha256: "1a790728016f79a41216d88672dbc5df30e686e811ad4e698bfc51f76ad91f1e"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.2.1"
|
||||
petitparser:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
@@ -73,6 +73,7 @@ dependencies:
|
||||
url: https://github.com/lollipopkit/dart_computer
|
||||
flutter_background_service: ^5.0.5
|
||||
icons_plus: ^5.0.0
|
||||
permission_handler: ^11.3.1
|
||||
|
||||
dev_dependencies:
|
||||
flutter_native_splash: ^2.1.6
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include <dynamic_color/dynamic_color_plugin_c_api.h>
|
||||
#include <local_auth_windows/local_auth_plugin.h>
|
||||
#include <permission_handler_windows/permission_handler_windows_plugin.h>
|
||||
#include <screen_retriever/screen_retriever_plugin.h>
|
||||
#include <share_plus/share_plus_windows_plugin_c_api.h>
|
||||
#include <url_launcher_windows/url_launcher_windows.h>
|
||||
@@ -18,6 +19,8 @@ void RegisterPlugins(flutter::PluginRegistry* registry) {
|
||||
registry->GetRegistrarForPlugin("DynamicColorPluginCApi"));
|
||||
LocalAuthPluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("LocalAuthPlugin"));
|
||||
PermissionHandlerWindowsPluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin"));
|
||||
ScreenRetrieverPluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("ScreenRetrieverPlugin"));
|
||||
SharePlusWindowsPluginCApiRegisterWithRegistrar(
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
list(APPEND FLUTTER_PLUGIN_LIST
|
||||
dynamic_color
|
||||
local_auth_windows
|
||||
permission_handler_windows
|
||||
screen_retriever
|
||||
share_plus
|
||||
url_launcher_windows
|
||||
|
||||
Reference in New Issue
Block a user