mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2026-02-23 08:34:39 +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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user