summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--android/app/src/main/AndroidManifest.xml78
-rw-r--r--android/build.gradle2
-rw-r--r--lib/config/defaults.dart2
-rw-r--r--lib/main.dart12
-rw-r--r--lib/pages/developer_page.dart76
-rw-r--r--lib/pages/navigation_page.dart6
-rw-r--r--pubspec.yaml2
7 files changed, 128 insertions, 50 deletions
diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index ad55dd7..64bebb8 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -1,54 +1,58 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.example.dhl_schemaplanner">
- <uses-permission android:name="android.permission.USE_FINGERPRINT"/>
+ package="com.example.dhl_schemaplanner">
+ <uses-permission android:name="android.permission.USE_FINGERPRINT" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
- <uses-permission android:name="android.permission.INTERNET"/>
- <uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
- <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
- <application
- android:label="DHL Schema"
- android:icon="@mipmap/ic_launcher">
+ <uses-permission android:name="android.permission.INTERNET" />
+ <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+ <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
+ <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
+ <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
+ <application
+ android:label="DHL Schema"
+ android:icon="@mipmap/ic_launcher">
<service android:name="com.pravera.flutter_foreground_task.service.ForegroundService" />
<meta-data android:name="com.here.sdk.access_key_id" android:value="7AOr--BqzFzBELeBUXypqQ" />
- <meta-data android:name="com.here.sdk.access_key_secret" android:value="27yrhnsn-in-FVLWie-DKmS44XWsyIVIhgkhbdZB5glP9vyY3dIuZDBq23LvH-UwslyRCHt7vkgJtwADxxq-AQ" />
+ <meta-data android:name="com.here.sdk.access_key_secret"
+ android:value="27yrhnsn-in-FVLWie-DKmS44XWsyIVIhgkhbdZB5glP9vyY3dIuZDBq23LvH-UwslyRCHt7vkgJtwADxxq-AQ" />
- <activity
- android:name=".MainActivity"
- android:launchMode="singleTop"
- android:theme="@style/LaunchTheme"
- android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
- android:hardwareAccelerated="true"
- android:windowSoftInputMode="adjustResize">
- <!-- Specifies an Android theme to apply to this Activity as soon as
+ <activity
+ android:name=".MainActivity"
+ android:launchMode="singleTop"
+ android:theme="@style/LaunchTheme"
+ android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
+ android:hardwareAccelerated="true"
+ android:windowSoftInputMode="adjustResize">
+ <!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
- <meta-data
- android:name="io.flutter.embedding.android.NormalTheme"
- android:resource="@style/NormalTheme"
- />
- <!-- Displays an Android View that continues showing the launch screen
+ <meta-data
+ android:name="io.flutter.embedding.android.NormalTheme"
+ android:resource="@style/NormalTheme"
+ />
+ <!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
- <meta-data
- android:name="io.flutter.embedding.android.SplashScreenDrawable"
- android:resource="@drawable/launch_background"
- />
- <intent-filter>
- <action android:name="android.intent.action.MAIN"/>
- <category android:name="android.intent.category.LAUNCHER"/>
- </intent-filter>
- </activity>
- <!-- Don't delete the meta-data below.
+ <meta-data
+ android:name="io.flutter.embedding.android.SplashScreenDrawable"
+ android:resource="@drawable/launch_background"
+ />
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ <!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
- <meta-data
- android:name="flutterEmbedding"
- android:value="2" />
- </application>
-</manifest>
+ <meta-data
+ android:name="flutterEmbedding"
+ android:value="2" />
+ </application>
+</manifest> \ No newline at end of file
diff --git a/android/build.gradle b/android/build.gradle
index b622d73..ca618df 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -24,6 +24,6 @@ subprojects {
project.evaluationDependsOn(':app')
}
-task clean(type: Delete) {
+tasks.register("clean", Delete) {
delete rootProject.buildDir
}
diff --git a/lib/config/defaults.dart b/lib/config/defaults.dart
index 1f62666..f371111 100644
--- a/lib/config/defaults.dart
+++ b/lib/config/defaults.dart
@@ -1,4 +1,4 @@
-String program_version = '0.15 [19/04/2023]';
+String program_version = '1.0 [09/06/2023]';
bool debug_mode = false;
class ShiftType {
diff --git a/lib/main.dart b/lib/main.dart
index ca99946..909b5f1 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -28,16 +28,14 @@ import 'package:here_sdk/core.engine.dart';
import 'package:here_sdk/core.errors.dart';
import 'package:here_sdk/mapview.dart';
-Future<void> main() async {
+void main() {
_initializeHERESDK();
WidgetsFlutterBinding.ensureInitialized();
- await SystemChrome.setPreferredOrientations(
- [DeviceOrientation.portraitUp, DeviceOrientation.portraitDown]);
- configureNotifications();
- runZonedGuarded(() {
+ SystemChrome.setPreferredOrientations(
+ [DeviceOrientation.portraitUp, DeviceOrientation.portraitDown])
+ .then((value) {
+ configureNotifications();
runApp(const MyApp());
- }, (error, stack) {
- // tja..
});
}
diff --git a/lib/pages/developer_page.dart b/lib/pages/developer_page.dart
index daf0838..2b1b54c 100644
--- a/lib/pages/developer_page.dart
+++ b/lib/pages/developer_page.dart
@@ -1,6 +1,10 @@
import 'dart:io';
import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
+import 'package:flutter_archive/flutter_archive.dart';
+import 'package:path_provider/path_provider.dart';
+import 'package:permission_handler/permission_handler.dart';
import 'package:training_planner/config/defaults.dart';
import 'package:training_planner/events/RefreshWeekEvent.dart';
import 'package:training_planner/main.dart';
@@ -69,6 +73,74 @@ class _DeveloperPageState extends State<DeveloperPage> {
});
}
+ Future<String?> getDownloadPath() async {
+ Directory? directory;
+ try {
+ if (Platform.isIOS) {
+ directory = await getApplicationDocumentsDirectory();
+ } else {
+ directory = Directory('/storage/emulated/0/Download');
+ // Put file in global download folder, if for an unknown reason it didn't exist, we fallback
+ // ignore: avoid_slow_async_io
+ if (!await directory.exists())
+ directory = await getExternalStorageDirectory();
+ }
+ } catch (err, stack) {
+ print("Cannot get download folder path");
+ }
+ return directory?.path;
+ }
+
+ File _createZipFile(String fileName) {
+ final zipFilePath = fileName;
+ final zipFile = File(zipFilePath);
+
+ if (zipFile.existsSync()) {
+ print("Deleting existing zip file: ${zipFile.path}");
+ zipFile.deleteSync();
+ }
+ return zipFile;
+ }
+
+ _exportLocalFiles() async {
+ List<String> result = [];
+ Directory dir = await getApplicationDocumentsDirectory();
+ var list = dir.listSync();
+ for (var item in list) {
+ if (item.path.endsWith('.json')) {
+ result.add(item.path);
+ }
+ }
+
+ if (await Permission.storage.request().isGranted) {
+ String? path = await getDownloadPath();
+ if (path != null) {
+ path += '/backup.zip';
+ var zip = _createZipFile(path);
+
+ int onProgressCallCount1 = 0;
+ try {
+ await ZipFile.createFromDirectory(
+ sourceDir: await getApplicationDocumentsDirectory(),
+ zipFile: zip,
+ recurseSubDirs: false,
+ includeBaseDirectory: false,
+ onZipping: (fileName, isDirectory, progress) {
+ ++onProgressCallCount1;
+ print('Zip #1:');
+ print('progress: ${progress.toStringAsFixed(1)}%');
+ print('name: $fileName');
+ print('isDirectory: $isDirectory');
+ return ZipFileOperation.includeItem;
+ },
+ );
+ } on PlatformException catch (e) {
+ print(e);
+ }
+ }
+ }
+ }
+
@override
Widget build(BuildContext context) {
return Scaffold(
@@ -86,7 +158,9 @@ class _DeveloperPageState extends State<DeveloperPage> {
Text('Bestanden: ' + file_count.toString()),
ElevatedButton(
onPressed: _toggleDebugMode,
- child: Text('Test Modus: ' + debug_mode.toString()))
+ child: Text('Test Modus: ' + debug_mode.toString())),
+ ElevatedButton(
+ onPressed: _exportLocalFiles, child: Text('Export'))
/*
TextButton(
onPressed: () {
diff --git a/lib/pages/navigation_page.dart b/lib/pages/navigation_page.dart
index 9cf7277..9fcc9ae 100644
--- a/lib/pages/navigation_page.dart
+++ b/lib/pages/navigation_page.dart
@@ -67,7 +67,7 @@ class _NavigationPageState extends State<NavigationPage> {
initState() {
super.initState();
- SystemChrome.setEnabledSystemUIOverlays([]);
+ SystemChrome.setPreferredOrientations([]);
Wakelock.enable();
AutoOrientation.portraitDownMode();
@@ -251,8 +251,8 @@ class _NavigationPageState extends State<NavigationPage> {
taskLoadedEvent?.cancel();
Wakelock.disable();
AutoOrientation.portraitUpMode();
- SystemChrome.setEnabledSystemUIOverlays(
- [SystemUiOverlay.top, SystemUiOverlay.bottom]);
+ SystemChrome.setPreferredOrientations(
+ [DeviceOrientation.portraitUp, DeviceOrientation.portraitDown]);
super.dispose();
}
}
diff --git a/pubspec.yaml b/pubspec.yaml
index 4f5e512..a66e311 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -51,6 +51,8 @@ dependencies:
wakelock: ^0.6.2
flutter_osm_plugin: ^0.53.2
flutter_map: ^3.1.0
+ permission_handler: ^10.3.0
+ flutter_archive: ^5.0.0
dev_dependencies:
flutter_test: