Fix export logs for droid
This commit is contained in:
parent
cc4008ec6e
commit
361ad64cd6
3 changed files with 40 additions and 3 deletions
|
@ -2,10 +2,12 @@ import 'dart:io';
|
|||
|
||||
import 'package:archive/archive_io.dart';
|
||||
import 'package:email_validator/email_validator.dart';
|
||||
import "package:file_saver/file_saver.dart";
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_email_sender/flutter_email_sender.dart';
|
||||
import "package:intl/intl.dart";
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:open_mail_app/open_mail_app.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
|
@ -75,6 +77,15 @@ Future<void> sendLogs(
|
|||
);
|
||||
},
|
||||
),
|
||||
ButtonWidget(
|
||||
buttonType: ButtonType.secondary,
|
||||
labelText: S.of(context).exportLogs,
|
||||
buttonAction: ButtonAction.third,
|
||||
onTap: () async {
|
||||
final zipFilePath = await getZippedLogsFile(context);
|
||||
await exportLogs(context, zipFilePath);
|
||||
},
|
||||
),
|
||||
ButtonWidget(
|
||||
isInAlert: true,
|
||||
buttonType: ButtonType.secondary,
|
||||
|
@ -159,9 +170,26 @@ Future<void> shareLogs(
|
|||
],
|
||||
);
|
||||
if (result?.action != null && result!.action == ButtonAction.second) {
|
||||
final Size size = MediaQuery.of(context).size;
|
||||
await Share.shareFiles(
|
||||
[zipFilePath],
|
||||
await exportLogs(context, zipFilePath);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> exportLogs(BuildContext context, String zipFilePath) async {
|
||||
final Size size = MediaQuery.of(context).size;
|
||||
if (Platform.isAndroid) {
|
||||
final DateTime now = DateTime.now().toUtc();
|
||||
final String shortMonthName = DateFormat('MMM').format(now); // Short month
|
||||
final String logFileName =
|
||||
'ente-logs-${now.year}-$shortMonthName-${now.day}-${now.hour}-${now.minute}';
|
||||
await FileSaver.instance.saveAs(
|
||||
name: logFileName,
|
||||
filePath: zipFilePath,
|
||||
mimeType: MimeType.zip,
|
||||
ext: 'zip',
|
||||
);
|
||||
} else {
|
||||
await Share.shareXFiles(
|
||||
[XFile(zipFilePath, mimeType: 'application/zip')],
|
||||
sharePositionOrigin: Rect.fromLTWH(0, 0, size.width, size.height / 2),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -492,6 +492,14 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.1.4"
|
||||
file_saver:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: file_saver
|
||||
sha256: "8ffd91ae9f543c5ebbfec71a814ee5aa9e21176d31335133308abf63f4c42e8a"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.2.9"
|
||||
firebase_core:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
|
|
@ -53,6 +53,7 @@ dependencies:
|
|||
expansion_tile_card: ^3.0.0
|
||||
extended_image: ^8.1.1
|
||||
fast_base58: ^0.2.1
|
||||
file_saver: ^0.2.9
|
||||
firebase_core: ^2.13.1
|
||||
firebase_messaging: ^14.6.2
|
||||
fk_user_agent: ^2.0.1
|
||||
|
|
Loading…
Add table
Reference in a new issue