Enable one-shot deletes for Android 11+

This commit is contained in:
Vishnu Mohandas 2021-06-29 00:33:53 +05:30
parent dada941088
commit bf210d18ab
5 changed files with 20 additions and 4 deletions

View file

@ -9,3 +9,4 @@ const String SENTRY_DEBUG_DSN =
"https://b31c8af8384a4ce980509b8f592a67eb@errors.ente.io/3";
const String ROADMAP_URL = "https://roadmap.ente.io";
const int MICRO_SECONDS_IN_DAY = 86400000000;
const int ANDROID_11_SDK_INT = 30;

View file

@ -2,10 +2,12 @@ import 'dart:async';
import 'dart:io';
import 'dart:math';
import 'package:device_info/device_info.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:logging/logging.dart';
import 'package:photo_manager/photo_manager.dart';
import 'package:photos/core/constants.dart';
import 'package:photos/core/event_bus.dart';
import 'package:photos/db/files_db.dart';
import 'package:photos/events/collection_updated_event.dart';
@ -144,7 +146,12 @@ Future<bool> deleteLocalFiles(
BuildContext context, List<String> localIDs) async {
final List<String> deletedIDs = [];
if (Platform.isAndroid) {
deletedIDs.addAll(await _deleteLocalFilesInBatches(context, localIDs));
final androidInfo = await DeviceInfoPlugin().androidInfo;
if (androidInfo.version.sdkInt < ANDROID_11_SDK_INT) {
deletedIDs.addAll(await _deleteLocalFilesInBatches(context, localIDs));
} else {
deletedIDs.addAll(await _deleteLocalFilesInOneShot(context, localIDs));
}
} else {
deletedIDs.addAll(await _deleteLocalFilesInOneShot(context, localIDs));
}

View file

@ -165,12 +165,19 @@ packages:
source: hosted
version: "1.0.3"
device_info:
dependency: transitive
dependency: "direct main"
description:
name: device_info
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.2+6"
version: "2.0.2"
device_info_platform_interface:
dependency: transitive
description:
name: device_info_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.1"
dio:
dependency: "direct main"
description:

View file

@ -92,6 +92,7 @@ dependencies:
intl: ^0.17.0
confetti: ^0.5.5
flutter_easyloading: ^3.0.0
device_info: ^2.0.2
dev_dependencies:
flutter_test:

View file

@ -12,7 +12,7 @@ dependencies:
sdk: flutter
package_info_plus: ^1.0.1
device_info: ^0.4.1+4
device_info: ^2.0.2
logging: ^1.0.1
sentry: ^5.0.0
intl: ^0.17.0