Skip to content

Commit

Permalink
Added native heic support for Piwigo 14
Browse files Browse the repository at this point in the history
  • Loading branch information
ReightI committed Oct 12, 2023
1 parent 89ee0dc commit 7a7da9d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ if (keystorePropertiesFile.exists()) {
}

android {
compileSdkVersion 33
compileSdkVersion 34

compileOptions {
// Flag to enable support for the new language APIs
Expand All @@ -55,7 +55,7 @@ android {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.piwigo.piwigo_ng"
minSdkVersion 21
targetSdkVersion 33
targetSdkVersion 34
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
Expand Down
3 changes: 3 additions & 0 deletions lib/services/preferences_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ class Preferences {
static const String isAdminKey = 'IS_USER_ADMIN';
static const String uploadChunkSizeKey = 'UPLOAD_FORM_CHUNK_SIZE';
static const String fileTypesKey = 'FILE_TYPES';
static List<String> get getAvailableFileTypes {
return appPreferences.getString(fileTypesKey)?.split(',') ?? [];
}

// ------------ Settings ------------

Expand Down
12 changes: 8 additions & 4 deletions lib/utils/image_actions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,19 @@ Future<List<XFile>?> onPickFiles() async {

Future<List<XFile>?> onPickImages() async {
try {
List<XFile> files = await _picker.pickMultipleMedia(
List<XFile> pickedFiles = await _picker.pickMultipleMedia(
imageQuality: (Preferences.getUploadQuality * 100).round(),
requestFullMetadata: !Preferences.getRemoveMetadata,
);
for (var file in files) {
if (file.name.endsWith('.heic')) {
List<XFile> files = [];
for (var file in pickedFiles) {
if (Preferences.getAvailableFileTypes
.contains(file.name.split('.').last)) {
files.add(file);
} else if (file.name.endsWith('.heic')) {
String? jpgPath = await HeicToJpg.convert(file.path);
if (jpgPath != null) {
files[files.indexWhere((f) => f == file)] = XFile(jpgPath);
files.add(XFile(jpgPath));
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions lib/views/settings/settings_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,7 @@ class _SettingsPageState extends State<SettingsPage> {
],
);
Widget get _supportedFilesSection {
String fileTypes =
appPreferences.getString('FILE_TYPES')?.replaceAll(',', ', ') ?? '';
String fileTypes = Preferences.getAvailableFileTypes.join(', ') ?? '';
return SettingsSection(
color: Colors.transparent,
children: [
Expand Down

0 comments on commit 7a7da9d

Please sign in to comment.