mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-08 16:07:52 -06:00
Changed file directories, added clear storage setting, updated readme w/ Google Play reference
This commit is contained in:
@@ -28,6 +28,11 @@
|
||||
An (almost) fully fledged mobile paperless client.
|
||||
<br />
|
||||
<br />
|
||||
<p>
|
||||
<a href="https://play.google.com/store/apps/details?id=de.astubenbord.paperless_mobile">
|
||||
<img src="resources/get_it_on_google_play_en.svg" width="140px">
|
||||
</a>
|
||||
</p>
|
||||
<!--<a href="https://github.com/astubenbord/paperless-mobile">View Demo</a>
|
||||
·-->
|
||||
<a href="https://github.com/astubenbord/paperless-mobile/issues">Report Bug</a>
|
||||
|
||||
@@ -25,7 +25,8 @@ class GlobalErrorCubit extends Cubit<GlobalErrorState> {
|
||||
|
||||
bool _canEmitNewError() {
|
||||
if (state.errorTimestamp != null) {
|
||||
return DateTime.now().difference(state.errorTimestamp!).inSeconds >= 5;
|
||||
return DateTime.now().difference(state.errorTimestamp!) >=
|
||||
_waitBeforeNextErrorDuration;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -35,8 +35,12 @@ class TimeoutClient implements BaseClient {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Response> delete(Uri url,
|
||||
{Map<String, String>? headers, Object? body, Encoding? encoding}) async {
|
||||
Future<Response> delete(
|
||||
Uri url, {
|
||||
Map<String, String>? headers,
|
||||
Object? body,
|
||||
Encoding? encoding,
|
||||
}) async {
|
||||
await _handleOfflineState();
|
||||
return _handle400Error(
|
||||
await getIt<BaseClient>()
|
||||
@@ -50,7 +54,10 @@ class TimeoutClient implements BaseClient {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Response> get(Uri url, {Map<String, String>? headers}) async {
|
||||
Future<Response> get(
|
||||
Uri url, {
|
||||
Map<String, String>? headers,
|
||||
}) async {
|
||||
await _handleOfflineState();
|
||||
return _handle400Error(
|
||||
await getIt<BaseClient>().get(url, headers: headers).timeout(
|
||||
@@ -62,7 +69,10 @@ class TimeoutClient implements BaseClient {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Response> head(Uri url, {Map<String, String>? headers}) async {
|
||||
Future<Response> head(
|
||||
Uri url, {
|
||||
Map<String, String>? headers,
|
||||
}) async {
|
||||
await _handleOfflineState();
|
||||
return _handle400Error(
|
||||
await getIt<BaseClient>().head(url, headers: headers).timeout(
|
||||
@@ -74,8 +84,12 @@ class TimeoutClient implements BaseClient {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Response> patch(Uri url,
|
||||
{Map<String, String>? headers, Object? body, Encoding? encoding}) async {
|
||||
Future<Response> patch(
|
||||
Uri url, {
|
||||
Map<String, String>? headers,
|
||||
Object? body,
|
||||
Encoding? encoding,
|
||||
}) async {
|
||||
await _handleOfflineState();
|
||||
return _handle400Error(
|
||||
await getIt<BaseClient>()
|
||||
@@ -89,8 +103,12 @@ class TimeoutClient implements BaseClient {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Response> post(Uri url,
|
||||
{Map<String, String>? headers, Object? body, Encoding? encoding}) async {
|
||||
Future<Response> post(
|
||||
Uri url, {
|
||||
Map<String, String>? headers,
|
||||
Object? body,
|
||||
Encoding? encoding,
|
||||
}) async {
|
||||
await _handleOfflineState();
|
||||
return _handle400Error(
|
||||
await getIt<BaseClient>()
|
||||
@@ -104,8 +122,12 @@ class TimeoutClient implements BaseClient {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Response> put(Uri url,
|
||||
{Map<String, String>? headers, Object? body, Encoding? encoding}) async {
|
||||
Future<Response> put(
|
||||
Uri url, {
|
||||
Map<String, String>? headers,
|
||||
Object? body,
|
||||
Encoding? encoding,
|
||||
}) async {
|
||||
await _handleOfflineState();
|
||||
return _handle400Error(
|
||||
await getIt<BaseClient>()
|
||||
@@ -119,7 +141,10 @@ class TimeoutClient implements BaseClient {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String> read(Uri url, {Map<String, String>? headers}) async {
|
||||
Future<String> read(
|
||||
Uri url, {
|
||||
Map<String, String>? headers,
|
||||
}) async {
|
||||
await _handleOfflineState();
|
||||
return getIt<BaseClient>().read(url, headers: headers).timeout(
|
||||
requestTimeout,
|
||||
@@ -129,7 +154,10 @@ class TimeoutClient implements BaseClient {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Uint8List> readBytes(Uri url, {Map<String, String>? headers}) async {
|
||||
Future<Uint8List> readBytes(
|
||||
Uri url, {
|
||||
Map<String, String>? headers,
|
||||
}) async {
|
||||
await _handleOfflineState();
|
||||
return getIt<BaseClient>().readBytes(url, headers: headers).timeout(
|
||||
requestTimeout,
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
class ErrorMessage implements Exception {
|
||||
final ErrorCode code;
|
||||
final String? details;
|
||||
final StackTrace? stackTrace;
|
||||
final int? httpStatusCode;
|
||||
|
||||
const ErrorMessage(this.code, {this.stackTrace, this.httpStatusCode});
|
||||
const ErrorMessage(this.code,
|
||||
{this.details, this.stackTrace, this.httpStatusCode});
|
||||
|
||||
factory ErrorMessage.unknown() {
|
||||
return const ErrorMessage(ErrorCode.unknown);
|
||||
|
||||
95
lib/core/service/file_service.dart
Normal file
95
lib/core/service/file_service.dart
Normal file
@@ -0,0 +1,95 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:paperless_mobile/core/model/error_message.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
|
||||
class FileService {
|
||||
static Future<File> saveToFile(
|
||||
Uint8List bytes,
|
||||
String filename,
|
||||
) async {
|
||||
final dir = await documentsDirectory;
|
||||
if (dir == null) {
|
||||
throw ErrorMessage.unknown(); //TODO: better handling
|
||||
}
|
||||
File file = File("${dir.path}/$filename");
|
||||
return file..writeAsBytes(bytes);
|
||||
}
|
||||
|
||||
static Future<Directory?> getDirectory(PaperlessDirectoryType type) {
|
||||
switch (type) {
|
||||
case PaperlessDirectoryType.documents:
|
||||
return documentsDirectory;
|
||||
case PaperlessDirectoryType.temporary:
|
||||
return temporaryDirectory;
|
||||
case PaperlessDirectoryType.scans:
|
||||
return scanDirectory;
|
||||
case PaperlessDirectoryType.download:
|
||||
return downloadsDirectory;
|
||||
}
|
||||
}
|
||||
|
||||
static Future<File> allocateTemporaryFile(
|
||||
PaperlessDirectoryType type, {
|
||||
required String extension,
|
||||
String? fileName,
|
||||
}) async {
|
||||
final dir = await getDirectory(type);
|
||||
final _fileName = (fileName ?? const Uuid().v1()) + '.$extension';
|
||||
return File('${dir?.path}/$_fileName');
|
||||
}
|
||||
|
||||
static Future<Directory> get temporaryDirectory => getTemporaryDirectory();
|
||||
|
||||
static Future<Directory?> get documentsDirectory async {
|
||||
if (Platform.isAndroid) {
|
||||
return (await getExternalStorageDirectories(
|
||||
type: StorageDirectory.documents,
|
||||
))!
|
||||
.first;
|
||||
} else if (Platform.isIOS) {
|
||||
return getApplicationDocumentsDirectory();
|
||||
} else {
|
||||
throw UnsupportedError("Platform not supported.");
|
||||
}
|
||||
}
|
||||
|
||||
static Future<Directory?> get downloadsDirectory async {
|
||||
if (Platform.isAndroid) {
|
||||
return (await getExternalStorageDirectories(
|
||||
type: StorageDirectory.downloads))!
|
||||
.first;
|
||||
} else if (Platform.isIOS) {
|
||||
return getApplicationDocumentsDirectory();
|
||||
} else {
|
||||
throw UnsupportedError("Platform not supported.");
|
||||
}
|
||||
}
|
||||
|
||||
static Future<Directory?> get scanDirectory async {
|
||||
if (Platform.isAndroid) {
|
||||
return (await getExternalStorageDirectories(type: StorageDirectory.dcim))!
|
||||
.first;
|
||||
} else if (Platform.isIOS) {
|
||||
return getApplicationDocumentsDirectory();
|
||||
} else {
|
||||
throw UnsupportedError("Platform not supported.");
|
||||
}
|
||||
}
|
||||
|
||||
static Future<void> clearUserData() async {
|
||||
final scanDir = await scanDirectory;
|
||||
final tempDir = await temporaryDirectory;
|
||||
scanDir?.delete(recursive: true);
|
||||
tempDir.delete(recursive: true);
|
||||
}
|
||||
}
|
||||
|
||||
enum PaperlessDirectoryType {
|
||||
documents,
|
||||
temporary,
|
||||
scans,
|
||||
download;
|
||||
}
|
||||
@@ -54,16 +54,3 @@ Future<List<T>> getCollection<T>(
|
||||
}
|
||||
return Future.error(errorCode);
|
||||
}
|
||||
|
||||
class FileUtils {
|
||||
static Future<File> saveToFile(
|
||||
Uint8List bytes,
|
||||
String filename, {
|
||||
StorageDirectory directoryType = StorageDirectory.documents,
|
||||
}) async {
|
||||
final dir = (await getExternalStorageDirectories(type: directoryType));
|
||||
File file = File("$dir/$filename");
|
||||
file.writeAsBytesSync(bytes);
|
||||
return file;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,16 +37,9 @@ class _HomePageState extends State<HomePage> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocListener<GlobalErrorCubit, GlobalErrorState>(
|
||||
listener: (context, state) {
|
||||
if (state.hasError) {
|
||||
showSnackBar(context, translateError(context, state.error!.code));
|
||||
}
|
||||
},
|
||||
child: BlocConsumer<ConnectivityCubit, ConnectivityState>(
|
||||
return BlocConsumer<ConnectivityCubit, ConnectivityState>(
|
||||
//Only re-initialize data if the connectivity changed from not connected to connected
|
||||
listenWhen: (previous, current) =>
|
||||
current == ConnectivityState.connected,
|
||||
listenWhen: (previous, current) => current == ConnectivityState.connected,
|
||||
listener: (context, state) {
|
||||
initializeLabelData(context);
|
||||
},
|
||||
@@ -77,7 +70,6 @@ class _HomePageState extends State<HomePage> {
|
||||
][_currentIndex],
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ class Tag extends Label {
|
||||
static const colorKey = 'color';
|
||||
static const isInboxTagKey = 'is_inbox_tag';
|
||||
static const textColorKey = 'text_color';
|
||||
static const legacyColourKey = 'colour';
|
||||
|
||||
final Color? color;
|
||||
final Color? textColor;
|
||||
@@ -31,11 +32,23 @@ class Tag extends Label {
|
||||
Tag.fromJson(JSON json)
|
||||
: isInboxTag = json[isInboxTagKey],
|
||||
textColor = Color(_colorStringToInt(json[textColorKey]) ?? 0),
|
||||
color = (json[colorKey] is Color)
|
||||
? json[colorKey]
|
||||
: Color(_colorStringToInt(json[colorKey]) ?? 0),
|
||||
color = _parseColorFromJson(json),
|
||||
super.fromJson(json);
|
||||
|
||||
///
|
||||
/// The `color` field of the json object can either be of type [Color] or a hex [String].
|
||||
/// Since API version 2, the old attribute `colour` has been replaced with `color`.
|
||||
///
|
||||
static Color _parseColorFromJson(JSON json) {
|
||||
if (json.containsKey(legacyColourKey)) {
|
||||
return Color(_colorStringToInt(json[legacyColourKey]) ?? 0);
|
||||
}
|
||||
if (json[colorKey] is Color) {
|
||||
return json[colorKey];
|
||||
}
|
||||
return Color(_colorStringToInt(json[colorKey]) ?? 0);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return name;
|
||||
|
||||
@@ -79,6 +79,17 @@ class AuthenticationCubit extends Cubit<AuthenticationState> {
|
||||
errorCubit.add(error);
|
||||
}
|
||||
throw error;
|
||||
} on SocketException catch (err) {
|
||||
late ErrorMessage error;
|
||||
if (err.message.contains("connection timed out")) {
|
||||
error = const ErrorMessage(ErrorCode.requestTimedOut);
|
||||
} else {
|
||||
error = ErrorMessage.unknown();
|
||||
}
|
||||
if (propagateEventOnError) {
|
||||
errorCubit.add(error);
|
||||
}
|
||||
rethrow;
|
||||
} on ErrorMessage catch (error) {
|
||||
if (propagateEventOnError) {
|
||||
errorCubit.add(error);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import 'dart:developer';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:paperless_mobile/core/model/error_message.dart';
|
||||
@@ -27,7 +29,11 @@ class DocumentScannerCubit extends Cubit<List<File>> {
|
||||
void reset() {
|
||||
for (final doc in state) {
|
||||
doc.deleteSync();
|
||||
if (kDebugMode) {
|
||||
log('[ScannerCubit]: Removed ${doc.path}');
|
||||
}
|
||||
}
|
||||
|
||||
imageCache.clear();
|
||||
emit(initialState);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'dart:developer' as dev;
|
||||
import 'dart:io';
|
||||
import 'dart:math';
|
||||
|
||||
@@ -7,8 +8,10 @@ import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:mime/mime.dart';
|
||||
import 'package:paperless_mobile/core/bloc/global_error_cubit.dart';
|
||||
import 'package:paperless_mobile/core/bloc/label_bloc_provider.dart';
|
||||
import 'package:paperless_mobile/core/model/error_message.dart';
|
||||
import 'package:paperless_mobile/core/service/file_service.dart';
|
||||
import 'package:paperless_mobile/di_initializer.dart';
|
||||
import 'package:paperless_mobile/features/documents/bloc/documents_cubit.dart';
|
||||
import 'package:paperless_mobile/features/home/view/widget/info_drawer.dart';
|
||||
@@ -16,7 +19,6 @@ import 'package:paperless_mobile/features/scan/bloc/document_scanner_cubit.dart'
|
||||
import 'package:paperless_mobile/features/scan/view/document_upload_page.dart';
|
||||
import 'package:paperless_mobile/features/scan/view/widgets/grid_image_item_widget.dart';
|
||||
import 'package:paperless_mobile/generated/l10n.dart';
|
||||
import 'package:paperless_mobile/util.dart';
|
||||
import 'package:pdf/pdf.dart';
|
||||
import 'package:pdf/widgets.dart' as pw;
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
@@ -38,8 +40,10 @@ class _ScannerPageState extends State<ScannerPage>
|
||||
'jpg',
|
||||
'jpeg'
|
||||
];
|
||||
|
||||
late final AnimationController _fabPulsingController;
|
||||
late final Animation _animation;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@@ -47,9 +51,7 @@ class _ScannerPageState extends State<ScannerPage>
|
||||
AnimationController(vsync: this, duration: const Duration(seconds: 1))
|
||||
..repeat(reverse: true);
|
||||
_animation = Tween(begin: 1.0, end: 1.2).animate(_fabPulsingController)
|
||||
..addListener(() {
|
||||
setState(() {});
|
||||
});
|
||||
..addListener(() => setState((() {})));
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -101,7 +103,9 @@ class _ScannerPageState extends State<ScannerPage>
|
||||
BlocBuilder<DocumentScannerCubit, List<File>>(
|
||||
builder: (context, state) {
|
||||
return IconButton(
|
||||
onPressed: state.isEmpty ? null : () => _export(context),
|
||||
onPressed: state.isEmpty
|
||||
? null
|
||||
: () => _onPrepareDocumentUpload(context),
|
||||
icon: const Icon(Icons.done),
|
||||
tooltip: S.of(context).documentScannerPageUploadButtonTooltip,
|
||||
);
|
||||
@@ -113,17 +117,31 @@ class _ScannerPageState extends State<ScannerPage>
|
||||
|
||||
void _openDocumentScanner(BuildContext context) async {
|
||||
await _requestCameraPermissions();
|
||||
final imagePath = await EdgeDetection.detectEdge;
|
||||
if (imagePath == null) {
|
||||
final file = await FileService.allocateTemporaryFile(
|
||||
PaperlessDirectoryType.scans,
|
||||
extension: 'jpeg',
|
||||
);
|
||||
if (kDebugMode) {
|
||||
dev.log('[ScannerPage] Created temporary file: ${file.path}');
|
||||
}
|
||||
final success = await EdgeDetection.detectEdge(file.path);
|
||||
if (!success) {
|
||||
if (kDebugMode) {
|
||||
dev.log(
|
||||
'[ScannerPage] Scan either not successful or canceled by user.');
|
||||
}
|
||||
return;
|
||||
}
|
||||
final file = File(imagePath);
|
||||
if (kDebugMode) {
|
||||
dev.log('[ScannerPage] Wrote image to temporary file: ${file.path}');
|
||||
}
|
||||
BlocProvider.of<DocumentScannerCubit>(context).addScan(file);
|
||||
}
|
||||
|
||||
void _export(BuildContext context) async {
|
||||
void _onPrepareDocumentUpload(BuildContext context) async {
|
||||
final doc = _buildDocumentFromImageFiles(
|
||||
BlocProvider.of<DocumentScannerCubit>(context).state);
|
||||
BlocProvider.of<DocumentScannerCubit>(context).state,
|
||||
);
|
||||
final bytes = await doc.save();
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
@@ -202,7 +220,7 @@ class _ScannerPageState extends State<ScannerPage>
|
||||
Future<void> _requestCameraPermissions() async {
|
||||
final hasPermission = await Permission.camera.isGranted;
|
||||
if (!hasPermission) {
|
||||
Permission.camera.request();
|
||||
await Permission.camera.request();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,7 +232,11 @@ class _ScannerPageState extends State<ScannerPage>
|
||||
);
|
||||
if (result?.files.single.path != null) {
|
||||
File file = File(result!.files.single.path!);
|
||||
|
||||
if (!_supportedExtensions.contains(file.path.split('.').last)) {
|
||||
return getIt<GlobalErrorCubit>().add(
|
||||
const ErrorMessage(ErrorCode.unsupportedFileFormat),
|
||||
);
|
||||
}
|
||||
final mimeType = lookupMimeType(file.path) ?? '';
|
||||
late Uint8List fileBytes;
|
||||
if (mimeType.startsWith('image')) {
|
||||
|
||||
21
lib/features/settings/view/pages/storage_settings_page.dart
Normal file
21
lib/features/settings/view/pages/storage_settings_page.dart
Normal file
@@ -0,0 +1,21 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:paperless_mobile/features/settings/view/widgets/clear_storage_setting.dart';
|
||||
import 'package:paperless_mobile/generated/l10n.dart';
|
||||
|
||||
class StorageSettingsPage extends StatelessWidget {
|
||||
const StorageSettingsPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(S.of(context).settingsPageStorageSettingsLabel),
|
||||
),
|
||||
body: ListView(
|
||||
children: const [
|
||||
ClearStorageSetting(),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -3,16 +3,12 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:paperless_mobile/features/settings/bloc/application_settings_cubit.dart';
|
||||
import 'package:paperless_mobile/features/settings/view/pages/application_settings_page.dart';
|
||||
import 'package:paperless_mobile/features/settings/view/pages/security_settings_page.dart';
|
||||
import 'package:paperless_mobile/features/settings/view/pages/storage_settings_page.dart';
|
||||
import 'package:paperless_mobile/generated/l10n.dart';
|
||||
|
||||
class SettingsPage extends StatefulWidget {
|
||||
class SettingsPage extends StatelessWidget {
|
||||
const SettingsPage({super.key});
|
||||
|
||||
@override
|
||||
State<SettingsPage> createState() => _SettingsPageState();
|
||||
}
|
||||
|
||||
class _SettingsPageState extends State<SettingsPage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@@ -25,20 +21,26 @@ class _SettingsPageState extends State<SettingsPage> {
|
||||
title: Text(S.of(context).settingsPageApplicationSettingsLabel),
|
||||
subtitle: Text(
|
||||
S.of(context).settingsPageApplicationSettingsDescriptionText),
|
||||
onTap: () => _goto(const ApplicationSettingsPage()),
|
||||
onTap: () => _goto(const ApplicationSettingsPage(), context),
|
||||
),
|
||||
ListTile(
|
||||
title: Text(S.of(context).settingsPageSecuritySettingsLabel),
|
||||
subtitle:
|
||||
Text(S.of(context).settingsPageSecuritySettingsDescriptionText),
|
||||
onTap: () => _goto(const SecuritySettingsPage()),
|
||||
onTap: () => _goto(const SecuritySettingsPage(), context),
|
||||
),
|
||||
ListTile(
|
||||
title: Text(S.of(context).settingsPageStorageSettingsLabel),
|
||||
subtitle:
|
||||
Text(S.of(context).settingsPageStorageSettingsDescriptionText),
|
||||
onTap: () => _goto(const StorageSettingsPage(), context),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _goto(Widget page) {
|
||||
void _goto(Widget page, BuildContext context) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_cache_manager/flutter_cache_manager.dart' as cm;
|
||||
import 'package:paperless_mobile/core/service/file_service.dart';
|
||||
import 'package:paperless_mobile/di_initializer.dart';
|
||||
|
||||
class ClearStorageSetting extends StatelessWidget {
|
||||
const ClearStorageSetting({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListTile(
|
||||
title: Text("Clear data"),
|
||||
subtitle:
|
||||
Text("Remove downloaded files, scans and clear the cache's content"),
|
||||
onTap: _clearCache,
|
||||
);
|
||||
}
|
||||
|
||||
void _clearCache() async {
|
||||
getIt<cm.CacheManager>().emptyCache();
|
||||
FileService.clearUserData();
|
||||
}
|
||||
}
|
||||
@@ -185,6 +185,7 @@
|
||||
"labelsPageStoragePathEmptyStateDescriptionText": "Es wurden noch keine Speicherpfade angelegt.",
|
||||
"referencedDocumentsReadOnlyHintText": "Dies ist eine schreibgeschützte Ansicht! Dokumente können nicht bearbeitet oder entfernt werden.",
|
||||
"editLabelPageConfirmDeletionDialogTitle": "Löschen bestätigen",
|
||||
"editLabelPageDeletionDialogText": "Dieser Kennzeichner wird von Dokumenten referenziert. Durch das Löschen dieses Kennzeichners werden alle Referenzen entfernt. Fortfahren?"
|
||||
|
||||
"editLabelPageDeletionDialogText": "Dieser Kennzeichner wird von Dokumenten referenziert. Durch das Löschen dieses Kennzeichners werden alle Referenzen entfernt. Fortfahren?",
|
||||
"settingsPageStorageSettingsLabel": "Storage",
|
||||
"settingsPageStorageSettingsDescriptionText": "Manage files and storage space"
|
||||
}
|
||||
@@ -186,5 +186,7 @@
|
||||
"labelsPageStoragePathEmptyStateDescriptionText": "You don't seem to have any storage paths set up.",
|
||||
"referencedDocumentsReadOnlyHintText": "This is a read-only view! You cannot edit or remove documents.",
|
||||
"editLabelPageConfirmDeletionDialogTitle": "Confirm deletion",
|
||||
"editLabelPageDeletionDialogText": "This label contains references to other documents. By deleting this label, all references will be removed. Continue?"
|
||||
"editLabelPageDeletionDialogText": "This label contains references to other documents. By deleting this label, all references will be removed. Continue?",
|
||||
"settingsPageStorageSettingsLabel": "Storage",
|
||||
"settingsPageStorageSettingsDescriptionText": "Manage files and storage space"
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
import 'dart:developer';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:encrypted_shared_preferences/encrypted_shared_preferences.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
@@ -11,6 +13,9 @@ import 'package:paperless_mobile/core/bloc/global_error_cubit.dart';
|
||||
import 'package:paperless_mobile/core/bloc/label_bloc_provider.dart';
|
||||
import 'package:paperless_mobile/core/global/asset_images.dart';
|
||||
import 'package:paperless_mobile/core/global/http_self_signed_certificate_override.dart';
|
||||
import 'package:paperless_mobile/core/logic/error_code_localization_mapper.dart';
|
||||
import 'package:paperless_mobile/core/service/file_service.dart';
|
||||
import 'package:paperless_mobile/core/util.dart';
|
||||
import 'package:paperless_mobile/di_initializer.dart';
|
||||
import 'package:paperless_mobile/features/app_intro/application_intro_slideshow.dart';
|
||||
import 'package:paperless_mobile/features/documents/bloc/documents_cubit.dart';
|
||||
@@ -39,8 +44,10 @@ void main() async {
|
||||
|
||||
configureDependencies();
|
||||
// Remove temporarily downloaded files.
|
||||
(await getTemporaryDirectory()).deleteSync(recursive: true);
|
||||
|
||||
(await FileService.temporaryDirectory).deleteSync(recursive: true);
|
||||
if (kDebugMode) {
|
||||
_printDeviceInformation();
|
||||
}
|
||||
kPackageInfo = await PackageInfo.fromPlatform();
|
||||
// Load application settings and stored authentication data
|
||||
getIt<ConnectivityCubit>().initialize();
|
||||
@@ -50,6 +57,17 @@ void main() async {
|
||||
runApp(const MyApp());
|
||||
}
|
||||
|
||||
void _printDeviceInformation() async {
|
||||
final tempPath = await FileService.temporaryDirectory;
|
||||
log('[DEVICE INFO] Temporary ${tempPath.absolute}');
|
||||
final docsPath = await FileService.documentsDirectory;
|
||||
log('[DEVICE INFO] Documents ${docsPath?.absolute}');
|
||||
final downloadPath = await FileService.downloadsDirectory;
|
||||
log('[DEVICE INFO] Download ${downloadPath?.absolute}');
|
||||
final scanPath = await FileService.scanDirectory;
|
||||
log('[DEVICE INFO] Scan ${scanPath?.absolute}');
|
||||
}
|
||||
|
||||
class MyApp extends StatefulWidget {
|
||||
const MyApp({Key? key}) : super(key: key);
|
||||
|
||||
@@ -190,6 +208,12 @@ class _AuthenticationWrapperState extends State<AuthenticationWrapper> {
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider.value(
|
||||
value: getIt<GlobalErrorCubit>(),
|
||||
child: BlocListener<GlobalErrorCubit, GlobalErrorState>(
|
||||
listener: (context, state) {
|
||||
if (state.hasError) {
|
||||
showSnackBar(context, translateError(context, state.error!.code));
|
||||
}
|
||||
},
|
||||
child: SafeArea(
|
||||
top: true,
|
||||
left: false,
|
||||
@@ -223,6 +247,7 @@ class _AuthenticationWrapperState extends State<AuthenticationWrapper> {
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,12 +13,14 @@ final dateFormat = DateFormat("yyyy-MM-dd");
|
||||
final GlobalKey<ScaffoldState> rootScaffoldKey = GlobalKey<ScaffoldState>();
|
||||
late PackageInfo kPackageInfo;
|
||||
|
||||
void showSnackBar(BuildContext context, String message) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(message)));
|
||||
void showSnackBar(BuildContext context, String message, [String? details]) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(message + (details != null ? ' ($details)' : ''))),
|
||||
);
|
||||
}
|
||||
|
||||
void showError(BuildContext context, ErrorMessage error) {
|
||||
showSnackBar(context, translateError(context, error.code));
|
||||
showSnackBar(context, translateError(context, error.code), error.details);
|
||||
}
|
||||
|
||||
bool isNotNull(dynamic value) {
|
||||
|
||||
12
pubspec.lock
12
pubspec.lock
@@ -354,10 +354,12 @@ packages:
|
||||
edge_detection:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: edge_detection
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.9"
|
||||
path: "."
|
||||
ref: master
|
||||
resolved-ref: "19fbebef99360e9cf0b59c6a90ff7cd26d4d6e7d"
|
||||
url: "https://github.com/sawankumarbundelkhandi/edge_detection"
|
||||
source: git
|
||||
version: "1.1.1"
|
||||
encrypt:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -1465,7 +1467,7 @@ packages:
|
||||
source: hosted
|
||||
version: "3.0.1"
|
||||
uuid:
|
||||
dependency: transitive
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: uuid
|
||||
url: "https://pub.dartlang.org"
|
||||
|
||||
@@ -39,7 +39,10 @@ dependencies:
|
||||
permission_handler: ^9.2.0
|
||||
pdf: ^3.8.1
|
||||
pdfx: ^2.3.0
|
||||
edge_detection: ^1.0.9
|
||||
edge_detection:
|
||||
git:
|
||||
url: https://github.com/sawankumarbundelkhandi/edge_detection
|
||||
ref: master
|
||||
path_provider: ^2.0.10
|
||||
image: ^3.1.3
|
||||
photo_view: ^0.14.0
|
||||
@@ -75,6 +78,7 @@ dependencies:
|
||||
introduction_screen: ^3.0.2
|
||||
mime: ^1.0.2
|
||||
receive_sharing_intent: ^1.4.5
|
||||
uuid: ^3.0.6
|
||||
|
||||
dev_dependencies:
|
||||
integration_test:
|
||||
|
||||
1
resources/get_it_on_google_play_en.svg
Normal file
1
resources/get_it_on_google_play_en.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 4.9 KiB |
Reference in New Issue
Block a user