Skip to content

Commit

Permalink
Changed namespace & fixed saving on Android
Browse files Browse the repository at this point in the history
  • Loading branch information
YarosMallorca committed Aug 26, 2024
1 parent 6b5a34c commit 6a9e43f
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 30 deletions.
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ if (flutterVersionName == null) {
}

android {
namespace "com.example.dji_mapper"
namespace "com.yarosfpv.dji_mapper"
compileSdkVersion flutter.compileSdkVersion
ndkVersion flutter.ndkVersion

Expand Down
1 change: 1 addition & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:label="DJI Mapper"
android:name="${applicationName}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.dji_mapper
package com.yarosfpv.dji_mapper

import io.flutter.embedding.android.FlutterActivity

Expand Down
40 changes: 21 additions & 19 deletions lib/layouts/export.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:universal_io/io.dart';
import 'package:dji_mapper/components/popups/dji_load_alert.dart';
import 'package:dji_mapper/components/popups/litchi_load_alert.dart';
import 'package:dji_mapper/main.dart';
import 'package:litchi_waypoint_engine/engine.dart' as litchi;
import 'package:universal_io/io.dart';
import 'package:universal_html/html.dart' as html;
import 'package:archive/archive.dart';
import 'package:dji_waypoint_engine/engine.dart';
Expand Down Expand Up @@ -98,6 +98,7 @@ class ExportBarState extends State<ExportBar> {
type: FileType.custom,
fileName: "output.kmz",
allowedExtensions: ["kmz"],
bytes: zipBytes,
dialogTitle: "Save Mission");

if (outputPath == null) {
Expand All @@ -107,19 +108,19 @@ class ExportBarState extends State<ExportBar> {
}
return;
}
} else {
outputPath = "output.kmz";
}

if (!kIsWeb) {
if (!outputPath.endsWith(".kmz")) {
outputPath += ".kmz";
// File Saver does not save the file on Desktop platforms
if (Platform.isWindows || Platform.isLinux || Platform.isMacOS) {
if (!outputPath.endsWith(".kmz")) {
outputPath += ".kmz";
}
// Save file for non-web platforms
final file = File(outputPath);
await file.writeAsBytes(zipBytes);
}
// Save file for non-web platforms
final file = File(outputPath);
await file.writeAsBytes(zipBytes);
} else {
// Save file for web platform
outputPath = "output.kmz";
final blob = html.Blob([zipBytes], 'application/octet-stream');
final url = html.Url.createObjectUrlFromBlob(blob);
html.AnchorElement(href: url)
Expand Down Expand Up @@ -157,6 +158,7 @@ class ExportBarState extends State<ExportBar> {
type: FileType.custom,
fileName: "litchi_mission.csv",
allowedExtensions: ["csv"],
bytes: Uint8List.fromList(csvContent.codeUnits),
dialogTitle: "Save Mission");

if (outputPath == null) {
Expand All @@ -166,19 +168,19 @@ class ExportBarState extends State<ExportBar> {
}
return;
}
} else {
outputPath = "output.csv";
}

if (!kIsWeb) {
if (!outputPath.endsWith(".csv")) {
outputPath += ".csv";
// File Saver does not save the file on Desktop platforms
if (Platform.isWindows || Platform.isLinux || Platform.isMacOS) {
if (!outputPath.endsWith(".csv")) {
outputPath += ".csv";
}
// Save file for non-web platforms
final file = File(outputPath);
await file.writeAsString(csvContent);
}
// Save file for non-web platforms
final file = File(outputPath);
await file.writeAsString(csvContent);
} else {
// Save file for web platform
outputPath = "output.csv";
final blob = html.Blob([csvContent], 'text/csv');
final url = html.Url.createObjectUrlFromBlob(blob);
html.AnchorElement(href: url)
Expand Down
2 changes: 1 addition & 1 deletion lib/layouts/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class _HomeLayoutState extends State<HomeLayout> with TickerProviderStateMixin {

var children = [
Flexible(
flex: MediaQuery.of(context).size.width < 700 ? 1 : 2,
flex: 2,
child: FlutterMap(
mapController: mapController,
options: MapOptions(
Expand Down
6 changes: 3 additions & 3 deletions macos/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@
CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.example.djiWaypointMapping.RunnerTests;
PRODUCT_BUNDLE_IDENTIFIER = com.yarosfpv.djiWaypointMapping.RunnerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/dji_mapper.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/dji_mapper";
Expand All @@ -492,7 +492,7 @@
CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.example.djiWaypointMapping.RunnerTests;
PRODUCT_BUNDLE_IDENTIFIER = com.yarosfpv.djiWaypointMapping.RunnerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/dji_mapper.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/dji_mapper";
Expand All @@ -507,7 +507,7 @@
CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.example.djiWaypointMapping.RunnerTests;
PRODUCT_BUNDLE_IDENTIFIER = com.yarosfpv.djiWaypointMapping.RunnerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/dji_mapper.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/dji_mapper";
Expand Down
20 changes: 18 additions & 2 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.2.3"
geoxml:
dependency: "direct main"
description:
name: geoxml
sha256: dfcbe7f9d83839958ce3c98af6eb673ac4d24b26ee5e47ffb14858f5dc560cf6
url: "https://pub.dev"
source: hosted
version: "2.6.1"
html:
dependency: transitive
description:
Expand Down Expand Up @@ -518,6 +526,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "6.1.2"
quiver:
dependency: transitive
description:
name: quiver
sha256: b1c1ac5ce6688d77f65f3375a9abb9319b3cb32486bdc7a1e0fdf004d7ba4e47
url: "https://pub.dev"
source: hosted
version: "3.2.1"
shared_preferences:
dependency: "direct main"
description:
Expand Down Expand Up @@ -751,10 +767,10 @@ packages:
dependency: transitive
description:
name: vm_service
sha256: f652077d0bdf60abe4c1f6377448e8655008eef28f128bc023f7b5e8dfeb48fc
sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d"
url: "https://pub.dev"
source: hosted
version: "14.2.4"
version: "14.2.5"
web:
dependency: transitive
description:
Expand Down
3 changes: 2 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ dependencies:
file_picker: ^8.0.6
path: ^1.9.0
universal_html: ^2.2.4
universal_io: ^2.2.2
url_launcher: ^6.3.0
geolocator: ^13.0.1
dio: ^5.6.0
package_info_plus: ^8.0.2
geoxml: ^2.6.1
universal_io: ^2.2.2

dependency_overrides:
geolocator_android: 4.5.4
Expand Down
4 changes: 2 additions & 2 deletions windows/runner/Runner.rc
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ BEGIN
BEGIN
BLOCK "040904e4"
BEGIN
VALUE "CompanyName", "com.example" "\0"
VALUE "CompanyName", "com.yarosfpv" "\0"
VALUE "FileDescription", "dji_waypoint_mapping" "\0"
VALUE "FileVersion", VERSION_AS_STRING "\0"
VALUE "InternalName", "dji_waypoint_mapping" "\0"
VALUE "LegalCopyright", "Copyright (C) 2024 com.example. All rights reserved." "\0"
VALUE "LegalCopyright", "Copyright (C) 2024 com.yarosfpv. All rights reserved." "\0"
VALUE "OriginalFilename", "dji_waypoint_mapping.exe" "\0"
VALUE "ProductName", "dji_waypoint_mapping" "\0"
VALUE "ProductVersion", VERSION_AS_STRING "\0"
Expand Down

0 comments on commit 6a9e43f

Please sign in to comment.