mirror of
https://github.com/zontreck/NBTEditor
synced 2024-11-21 05:25:54 -07:00
Start trying to fix permission errors on Android
This commit is contained in:
parent
e62fc5cf91
commit
9055c8cb0a
8 changed files with 94 additions and 7 deletions
|
@ -1 +1 @@
|
|||
const VERSION = "1.0722.24+1506";
|
||||
const VERSION = "1.0724.24+0706";
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
@ -12,6 +13,7 @@ import 'package:nbteditor/Consts2.dart';
|
|||
import 'package:nbteditor/SessionData.dart';
|
||||
import 'package:nbteditor/tags/CompoundTag.dart';
|
||||
import 'package:nbteditor/tags/Tag.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
|
||||
class Editor extends StatefulWidget {
|
||||
const Editor({super.key});
|
||||
|
@ -127,7 +129,7 @@ class EditorState extends State<Editor> {
|
|||
title: const Text("S A V E N B T"),
|
||||
subtitle: const Text("Save to NBT"),
|
||||
leading: const Image(
|
||||
image: AssetImage("Icons/PNG/nbteditor.png"),
|
||||
image: AssetImage("Icons/PNG/Compound.png"),
|
||||
),
|
||||
onTap: () async {
|
||||
var result = await showDialog(
|
||||
|
@ -161,8 +163,7 @@ class EditorState extends State<Editor> {
|
|||
}
|
||||
// Prompt for where to save
|
||||
print("Begin picking file to save to");
|
||||
var params = SaveFileDialogParams(data: u8l);
|
||||
var filePath = await FlutterFileDialog.saveFile(params: params);
|
||||
var filePath = await FlutterFileDialog.saveFile();
|
||||
|
||||
if (filePath == null) {
|
||||
print("No file selected");
|
||||
|
|
|
@ -2,6 +2,8 @@ import 'package:flutter/material.dart';
|
|||
import 'package:nbteditor/Editor.dart';
|
||||
import 'package:nbteditor/pages/AddPage.dart';
|
||||
import 'package:nbteditor/pages/SNBTEditor.dart';
|
||||
import 'package:nbteditor/pages/permsrequired.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
|
||||
void main() {
|
||||
runApp(const MainApp());
|
||||
|
@ -15,10 +17,45 @@ class MainApp extends StatelessWidget {
|
|||
return MaterialApp(
|
||||
theme: ThemeData.dark(),
|
||||
routes: {
|
||||
"/": (context) => const Editor(),
|
||||
"/": (context) => StartPage(),
|
||||
"/edit": (context) => const Editor(),
|
||||
"/add": (context) => const AddPage(),
|
||||
"/snbt": (context) => const SnbtEdit(),
|
||||
"/perms": (context) => PermissionsRequiredPage()
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class StartPage extends StatefulWidget {
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
return StartPageState();
|
||||
}
|
||||
}
|
||||
|
||||
class StartPageState extends State<StartPage> {
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
checkPermissions();
|
||||
}
|
||||
|
||||
Future<void> checkPermissions() async {
|
||||
if (await Permission.manageExternalStorage.isDenied) {
|
||||
await Future.delayed(Duration(seconds: 5), () {
|
||||
Navigator.pushReplacementNamed(context, "/perms");
|
||||
});
|
||||
} else {
|
||||
Navigator.pushReplacementNamed(context, "/edit");
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: Column(
|
||||
children: [Image(image: AssetImage("Icons/PNG/nbteditor.png"))],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
44
lib/pages/permsrequired.dart
Normal file
44
lib/pages/permsrequired.dart
Normal file
|
@ -0,0 +1,44 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:nbteditor/Constants.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
|
||||
class PermissionsRequiredPage extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text("NBT Editor - Permissions Denied"),
|
||||
backgroundColor: Constants.TITLEBAR_COLOR,
|
||||
),
|
||||
body: Padding(
|
||||
padding: EdgeInsets.all(8),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
ListTile(
|
||||
title: Text(
|
||||
"We require only one permission, it is being denied by your device. Please grant file permissions to be able to open or save files."),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
if (await Permission.manageExternalStorage.isDenied) {
|
||||
var stat =
|
||||
await Permission.manageExternalStorage.request();
|
||||
if (stat.isPermanentlyDenied) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||
content: Text(
|
||||
"The storage permission is reporting it is permanently denied. Please open settings and allow that permission.")));
|
||||
} else if (stat.isGranted) {
|
||||
Future.delayed(Duration(seconds: 5), () {
|
||||
Navigator.pushReplacementNamed(context, "/edit");
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
child: Text("GRANT"))
|
||||
],
|
||||
),
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
name: nbteditor
|
||||
description: A Minecraft NBT Editor written in Flutter
|
||||
publish_to: 'none'
|
||||
version: 1.0722.24+1907
|
||||
version: 1.0724.24+0706
|
||||
|
||||
|
||||
environment:
|
||||
|
@ -17,6 +17,7 @@ dependencies:
|
|||
libac_dart:
|
||||
hosted: https://git.zontreck.com/api/packages/AriasCreations/pub/
|
||||
version: 1.2.072224+1906
|
||||
permission_handler: ^11.3.1
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
|
|
@ -6,9 +6,12 @@
|
|||
|
||||
#include "generated_plugin_registrant.h"
|
||||
|
||||
#include <permission_handler_windows/permission_handler_windows_plugin.h>
|
||||
#include <url_launcher_windows/url_launcher_windows.h>
|
||||
|
||||
void RegisterPlugins(flutter::PluginRegistry* registry) {
|
||||
PermissionHandlerWindowsPluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin"));
|
||||
UrlLauncherWindowsRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("UrlLauncherWindows"));
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#
|
||||
|
||||
list(APPEND FLUTTER_PLUGIN_LIST
|
||||
permission_handler_windows
|
||||
url_launcher_windows
|
||||
)
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
|
||||
|
||||
#define MyAppName "NBT Editor"
|
||||
#define MyAppVersion "1.0722.24.1506"
|
||||
#define MyAppVersion "1.0724.24+0706"
|
||||
#define MyAppPublisher "Piccari Creations"
|
||||
#define MyAppURL "https://zontreck.com"
|
||||
#define MyAppExeName "nbteditor.exe"
|
||||
|
|
Loading…
Reference in a new issue