new: auto request noti perm

This commit is contained in:
lollipopkit
2024-04-02 18:27:06 -06:00
parent 704a93713f
commit 2f96a090c4
17 changed files with 102 additions and 0 deletions

View 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;
}
}
}

View File

@@ -263,5 +263,8 @@ class SettingStore extends PersistentStore {
/// Version of store db /// Version of store db
late final storeVersion = property('storeVersion', 0); late final storeVersion = property('storeVersion', 0);
/// Have notified user for notificaiton permission or not
late final noNotiPerm = property('noNotiPerm', false);
// ------END------ // ------END------
} }

View File

@@ -164,6 +164,7 @@
"newContainer": "Neuer Container", "newContainer": "Neuer Container",
"noClient": "Kein Client", "noClient": "Kein Client",
"noInterface": "Kein Interface", "noInterface": "Kein Interface",
"noNotiPerm": "Keine Benachrichtigungsrechte, möglicherweise keine Fortschrittsanzeige beim Herunterladen von App-Updates.",
"noOptions": "Keine Optionen verfügbar", "noOptions": "Keine Optionen verfügbar",
"noResult": "Kein Ergebnis", "noResult": "Kein Ergebnis",
"noSavedPrivateKey": "Keine gespeicherten Private Keys", "noSavedPrivateKey": "Keine gespeicherten Private Keys",

View File

@@ -164,6 +164,7 @@
"newContainer": "New container", "newContainer": "New container",
"noClient": "No client", "noClient": "No client",
"noInterface": "No interface", "noInterface": "No interface",
"noNotiPerm": "No notification permissions, possibly no progress indication when downloading app updates.",
"noOptions": "No options", "noOptions": "No options",
"noResult": "No result", "noResult": "No result",
"noSavedPrivateKey": "No saved private keys.", "noSavedPrivateKey": "No saved private keys.",

View File

@@ -164,6 +164,7 @@
"newContainer": "Crear contenedor nuevo", "newContainer": "Crear contenedor nuevo",
"noClient": "No hay conexión SSH", "noClient": "No hay conexión SSH",
"noInterface": "No hay interfaz disponible", "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", "noOptions": "Sin opciones disponibles",
"noResult": "Sin resultados", "noResult": "Sin resultados",
"noSavedPrivateKey": "No hay llaves privadas guardadas.", "noSavedPrivateKey": "No hay llaves privadas guardadas.",

View File

@@ -164,6 +164,7 @@
"newContainer": "Nouveau conteneur", "newContainer": "Nouveau conteneur",
"noClient": "Aucun client", "noClient": "Aucun client",
"noInterface": "Aucune interface", "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", "noOptions": "Aucune option",
"noResult": "Aucun résultat", "noResult": "Aucun résultat",
"noSavedPrivateKey": "Aucune clé privée enregistrée.", "noSavedPrivateKey": "Aucune clé privée enregistrée.",

View File

@@ -164,6 +164,7 @@
"newContainer": "Wadah baru", "newContainer": "Wadah baru",
"noClient": "Tidak ada klien", "noClient": "Tidak ada klien",
"noInterface": "Tidak ada antarmuka", "noInterface": "Tidak ada antarmuka",
"noNotiPerm": "Tidak ada izin notifikasi, mungkin tidak ada indikasi kemajuan saat mengunduh pembaruan aplikasi.",
"noOptions": "Tidak ada opsi", "noOptions": "Tidak ada opsi",
"noResult": "Tidak ada hasil", "noResult": "Tidak ada hasil",
"noSavedPrivateKey": "Tidak ada kunci pribadi yang disimpan.", "noSavedPrivateKey": "Tidak ada kunci pribadi yang disimpan.",

View File

@@ -164,6 +164,7 @@
"newContainer": "新しいコンテナを作成", "newContainer": "新しいコンテナを作成",
"noClient": "SSH接続がありません", "noClient": "SSH接続がありません",
"noInterface": "使用可能なインターフェースがありません", "noInterface": "使用可能なインターフェースがありません",
"noNotiPerm": "通知の権限がないため、アプリの更新のダウンロード中に進行状況が表示されない場合があります。",
"noOptions": "選択肢がありません", "noOptions": "選択肢がありません",
"noResult": "結果なし", "noResult": "結果なし",
"noSavedPrivateKey": "保存されたプライベートキーがありません。", "noSavedPrivateKey": "保存されたプライベートキーがありません。",

View File

@@ -164,6 +164,7 @@
"newContainer": "Novo contêiner", "newContainer": "Novo contêiner",
"noClient": "Sem conexão SSH", "noClient": "Sem conexão SSH",
"noInterface": "Sem interface disponível", "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", "noOptions": "Sem opções",
"noResult": "Sem resultados", "noResult": "Sem resultados",
"noSavedPrivateKey": "Nenhuma chave privada salva.", "noSavedPrivateKey": "Nenhuma chave privada salva.",

View File

@@ -164,6 +164,7 @@
"newContainer": "создать контейнер", "newContainer": "создать контейнер",
"noClient": "нет SSH соединения", "noClient": "нет SSH соединения",
"noInterface": "нет доступных интерфейсов", "noInterface": "нет доступных интерфейсов",
"noNotiPerm": "Нет разрешения на уведомления, возможно отсутствие индикации прогресса при загрузке обновлений приложений.",
"noOptions": "нет доступных опций", "noOptions": "нет доступных опций",
"noResult": "нет результатов", "noResult": "нет результатов",
"noSavedPrivateKey": "Нет сохраненных приватных ключей.", "noSavedPrivateKey": "Нет сохраненных приватных ключей.",

View File

@@ -164,6 +164,7 @@
"newContainer": "新建容器", "newContainer": "新建容器",
"noClient": "没有SSH连接", "noClient": "没有SSH连接",
"noInterface": "没有可用的接口", "noInterface": "没有可用的接口",
"noNotiPerm": "无通知权限可能下载App更新时无进度提示。",
"noOptions": "无可选项", "noOptions": "无可选项",
"noResult": "无结果", "noResult": "无结果",
"noSavedPrivateKey": "没有已保存的私钥。", "noSavedPrivateKey": "没有已保存的私钥。",

View File

@@ -164,6 +164,7 @@
"newContainer": "新建容器", "newContainer": "新建容器",
"noClient": "沒有SSH連接", "noClient": "沒有SSH連接",
"noInterface": "沒有可用的接口", "noInterface": "沒有可用的接口",
"noNotiPerm": "無通知權限,可能在下載應用程式更新時沒有進度提示。",
"noOptions": "無可選項", "noOptions": "無可選項",
"noResult": "無結果", "noResult": "無結果",
"noSavedPrivateKey": "沒有已保存的私鑰。", "noSavedPrivateKey": "沒有已保存的私鑰。",

View File

@@ -4,14 +4,17 @@ import 'package:after_layout/after_layout.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:get_it/get_it.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/bg_run.dart';
import 'package:toolbox/core/channel/home_widget.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/dialog.dart';
import 'package:toolbox/core/extension/context/locale.dart'; import 'package:toolbox/core/extension/context/locale.dart';
import 'package:toolbox/core/persistant_store.dart'; import 'package:toolbox/core/persistant_store.dart';
import 'package:toolbox/core/update.dart'; import 'package:toolbox/core/update.dart';
import 'package:toolbox/core/utils/platform/auth.dart'; import 'package:toolbox/core/utils/platform/auth.dart';
import 'package:toolbox/core/utils/platform/base.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/github_id.dart';
import 'package:toolbox/data/res/logger.dart'; import 'package:toolbox/data/res/logger.dart';
import 'package:toolbox/data/res/provider.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 // Auth required for first launch
BioAuth.go(); 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()) { if (Stores.setting.autoCheckAppUpdate.fetch()) {
doUpdate(context); doUpdate(context);
} }

View File

@@ -815,6 +815,54 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.11.1" 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: petitparser:
dependency: transitive dependency: transitive
description: description:

View File

@@ -73,6 +73,7 @@ dependencies:
url: https://github.com/lollipopkit/dart_computer url: https://github.com/lollipopkit/dart_computer
flutter_background_service: ^5.0.5 flutter_background_service: ^5.0.5
icons_plus: ^5.0.0 icons_plus: ^5.0.0
permission_handler: ^11.3.1
dev_dependencies: dev_dependencies:
flutter_native_splash: ^2.1.6 flutter_native_splash: ^2.1.6

View File

@@ -8,6 +8,7 @@
#include <dynamic_color/dynamic_color_plugin_c_api.h> #include <dynamic_color/dynamic_color_plugin_c_api.h>
#include <local_auth_windows/local_auth_plugin.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 <screen_retriever/screen_retriever_plugin.h>
#include <share_plus/share_plus_windows_plugin_c_api.h> #include <share_plus/share_plus_windows_plugin_c_api.h>
#include <url_launcher_windows/url_launcher_windows.h> #include <url_launcher_windows/url_launcher_windows.h>
@@ -18,6 +19,8 @@ void RegisterPlugins(flutter::PluginRegistry* registry) {
registry->GetRegistrarForPlugin("DynamicColorPluginCApi")); registry->GetRegistrarForPlugin("DynamicColorPluginCApi"));
LocalAuthPluginRegisterWithRegistrar( LocalAuthPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("LocalAuthPlugin")); registry->GetRegistrarForPlugin("LocalAuthPlugin"));
PermissionHandlerWindowsPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin"));
ScreenRetrieverPluginRegisterWithRegistrar( ScreenRetrieverPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("ScreenRetrieverPlugin")); registry->GetRegistrarForPlugin("ScreenRetrieverPlugin"));
SharePlusWindowsPluginCApiRegisterWithRegistrar( SharePlusWindowsPluginCApiRegisterWithRegistrar(

View File

@@ -5,6 +5,7 @@
list(APPEND FLUTTER_PLUGIN_LIST list(APPEND FLUTTER_PLUGIN_LIST
dynamic_color dynamic_color
local_auth_windows local_auth_windows
permission_handler_windows
screen_retriever screen_retriever
share_plus share_plus
url_launcher_windows url_launcher_windows