Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Background image upload #2433

Merged
merged 132 commits into from
Sep 1, 2022
Merged
Show file tree
Hide file tree
Changes from 130 commits
Commits
Show all changes
132 commits
Select commit Hold shift + click to select a range
ae2c27b
work manager used for bg schedule
AshAman999 Jun 24, 2022
a0fc5ff
Merge branch 'develop' into background-image-upload
AshAman999 Jun 26, 2022
624f196
removed swith case
AshAman999 Jun 26, 2022
891cb5a
Merge branch 'develop' into background-image-upload
AshAman999 Jun 27, 2022
16f1a90
remove unwanted contrains and randomize the taskid
AshAman999 Jun 27, 2022
2777d85
Merge branch 'develop' into background-image-upload
AshAman999 Jun 27, 2022
885fddf
added translations
AshAman999 Jun 27, 2022
a068bf5
Merge branch 'develop' into background-image-upload
AshAman999 Jun 28, 2022
9b0972f
Merge branch 'develop' into background-image-upload
AshAman999 Jun 28, 2022
69e5605
new product image upload working
AshAman999 Jun 28, 2022
b13cd93
removed debug for work manager
AshAman999 Jun 28, 2022
8fc449c
Merge branch 'develop' of https://github.com/openfoodfacts/smooth-app…
AshAman999 Jun 29, 2022
ea96e3a
delete photo when uploaded
AshAman999 Jun 29, 2022
982cfbb
Merge branch 'develop' of https://github.com/openfoodfacts/smooth-app…
AshAman999 Jun 29, 2022
9ee8ff9
use await keywords while initializing
AshAman999 Jun 29, 2022
edf420b
Merge branch 'develop' into background-image-upload
monsieurtanuki Jun 30, 2022
fa037e7
Merge branch 'develop' of https://github.com/openfoodfacts/smooth-app…
AshAman999 Jun 30, 2022
8009449
refactor the code
AshAman999 Jun 30, 2022
f198411
Merge branch 'develop' of https://github.com/openfoodfacts/smooth-app…
AshAman999 Jun 30, 2022
514017a
fix show image after queed
AshAman999 Jul 2, 2022
6ba1425
Merge branch 'develop' into background-image-upload
AshAman999 Jul 2, 2022
6838ae7
serialize and deserialze input data seperately
AshAman999 Jul 3, 2022
3ed2fc3
add an instant product in the loacl db to
AshAman999 Jul 3, 2022
854bda8
added smooth random class
AshAman999 Jul 3, 2022
91de167
use smooth random to generate 8 digits
AshAman999 Jul 3, 2022
d4fc18d
remove unneccesary await
AshAman999 Jul 3, 2022
4e2bf81
Merge branch 'develop' of https://github.com/openfoodfacts/smooth-app…
AshAman999 Jul 3, 2022
0dcbf0c
Merge branch 'develop' into background-image-upload
AshAman999 Jul 4, 2022
51a7477
Merge branch 'develop' of https://github.com/openfoodfacts/smooth-app…
AshAman999 Jul 6, 2022
c141b98
Merge branch 'develop' of https://github.com/openfoodfacts/smooth-app…
AshAman999 Jul 6, 2022
69fdf1c
Merge branch 'develop' into background-image-upload
AshAman999 Jul 8, 2022
f5e9c25
update the local db with a product if not yet
AshAman999 Jul 8, 2022
2f49520
update local databse after sucessful
AshAman999 Jul 8, 2022
655e2c2
don't refresh automatically after upload queed
AshAman999 Jul 8, 2022
12cd639
supply language code to work manager
AshAman999 Jul 8, 2022
b8b93b8
Merge branch 'develop' of https://github.com/openfoodfacts/smooth-app…
AshAman999 Jul 8, 2022
18f3467
Merge branch 'develop' of https://github.com/openfoodfacts/smooth-app…
AshAman999 Jul 11, 2022
996cc17
import app localizations
AshAman999 Jul 11, 2022
b2cee71
Merge branch 'develop' of https://github.com/openfoodfacts/smooth-app…
AshAman999 Jul 11, 2022
869686b
small refactoring
AshAman999 Jul 11, 2022
6d04195
Merge branch 'develop' of https://github.com/openfoodfacts/smooth-app…
AshAman999 Jul 11, 2022
d2ee6ff
refactor the code for work manager
AshAman999 Jul 13, 2022
661320e
iOS Config for WorkManager
g123k Jul 13, 2022
1cae159
Merge branch 'background-image-upload' of https://github.com/AshAman9…
AshAman999 Jul 13, 2022
a948e02
formatting
AshAman999 Jul 13, 2022
a7b26cf
Merge branch 'develop' of https://github.com/openfoodfacts/smooth-app…
AshAman999 Jul 13, 2022
ca7280f
suggestion by tolemon
AshAman999 Jul 13, 2022
906525f
suggestion by tolemon
AshAman999 Jul 13, 2022
d09957f
suggestion by tolemon
AshAman999 Jul 13, 2022
0c5e031
small fix
AshAman999 Jul 13, 2022
b0a1944
add swith case to the workmanager
AshAman999 Jul 13, 2022
871fbd8
efficient switch case
AshAman999 Jul 13, 2022
60ed804
Update packages/smooth_app/lib/l10n/app_en.arb
AshAman999 Jul 13, 2022
598930e
minor fix
AshAman999 Jul 14, 2022
f457c0e
Basic Input details add are now run in background
AshAman999 Jul 14, 2022
6ea112a
basic details are now updated immediatly
AshAman999 Jul 14, 2022
fdfd3d4
nutrient edit task are now background
AshAman999 Jul 15, 2022
2a62351
menu screen for background tasks and
AshAman999 Jul 17, 2022
b6a1241
Merge branch 'develop' into background-image-upload
AshAman999 Jul 18, 2022
732ef60
button for retry now works in the bg tasks screen
AshAman999 Jul 18, 2022
ecd0e69
formatting
AshAman999 Jul 18, 2022
a3da277
genaralised function for non image tasks
AshAman999 Jul 18, 2022
fed27f8
should retry set default to false
AshAman999 Jul 18, 2022
8aa6032
Merge branch 'develop' of https://github.com/openfoodfacts/smooth-app…
AshAman999 Jul 18, 2022
f09f3cb
better mechanism for retries and refactor
AshAman999 Jul 19, 2022
200fd21
Merge branch 'develop' of https://github.com/openfoodfacts/smooth-app…
AshAman999 Jul 19, 2022
1fb3bcf
Merge branch 'develop' into background-image-upload
teolemon Jul 19, 2022
cdae696
refactor and consts duration of 3s for snackbars
AshAman999 Jul 19, 2022
17f0007
now language country and user are properly dropped
AshAman999 Jul 19, 2022
0297077
Merge branch 'background-image-upload' of https://github.com/AshAman9…
AshAman999 Jul 19, 2022
be94b12
Merge branch 'develop' of https://github.com/openfoodfacts/smooth-app…
AshAman999 Jul 19, 2022
3eca6f7
Update packages/smooth_app/ios/Runner/Info.plist
teolemon Jul 20, 2022
e83c7b5
Update packages/smooth_app/ios/Runner/AppDelegate.swift
teolemon Jul 20, 2022
64142d4
Merge branch 'develop' of https://github.com/openfoodfacts/smooth-app…
AshAman999 Aug 7, 2022
cdcfd65
Error messages fixed
AshAman999 Aug 7, 2022
ac2c169
custom workmanager dependencies added
AshAman999 Aug 8, 2022
44a0b29
migrated basic detail task from work manager to
AshAman999 Aug 8, 2022
81e28cb
chanages to do the product edit changes in bg
AshAman999 Aug 8, 2022
c4b3a3e
dart format
AshAman999 Aug 8, 2022
3d6115a
cleaned the function calls when doing bg task
AshAman999 Aug 8, 2022
e615db7
Merge branch 'develop' of https://github.com/openfoodfacts/smooth-app…
AshAman999 Aug 9, 2022
8cc45b5
Merge branch 'develop' of https://github.com/openfoodfacts/smooth-app…
AshAman999 Aug 9, 2022
67502b0
dao_task edited
AshAman999 Aug 9, 2022
ae1f4fa
unnecessary methods removed
AshAman999 Aug 9, 2022
e5565d6
use int as id instead of string
AshAman999 Aug 9, 2022
99c1df7
added comments and made fields final
AshAman999 Aug 9, 2022
38fe023
used const variable instead of hardcoded ones
AshAman999 Aug 9, 2022
42b0237
Merge branch 'develop' of https://github.com/openfoodfacts/smooth-app…
AshAman999 Aug 10, 2022
eec46f2
get pending tasks from taskManager class
AshAman999 Aug 10, 2022
a4bf4d1
refactor
AshAman999 Aug 10, 2022
ed5a6cc
handled exceptions
AshAman999 Aug 11, 2022
7236da1
string instead of int
AshAman999 Aug 11, 2022
36b6b08
Merge branch 'develop' of https://github.com/openfoodfacts/smooth-app…
AshAman999 Aug 11, 2022
bd61d94
Merge branch 'develop' of https://github.com/openfoodfacts/smooth-app…
AshAman999 Aug 13, 2022
5441238
remove unused plugin
AshAman999 Aug 13, 2022
078c187
Merge branch 'develop' of https://github.com/openfoodfacts/smooth-app…
AshAman999 Aug 16, 2022
c80d70c
Merge branch 'develop' of https://github.com/openfoodfacts/smooth-app…
AshAman999 Aug 17, 2022
252cb77
Merge branch 'develop' of https://github.com/openfoodfacts/smooth-app…
AshAman999 Aug 18, 2022
a1aef3a
removed unnessary files
AshAman999 Aug 18, 2022
a1d5959
Merge branch 'develop' of https://github.com/openfoodfacts/smooth-app…
AshAman999 Aug 19, 2022
4f81081
Merge branch 'develop' of https://github.com/openfoodfacts/smooth-app…
AshAman999 Aug 20, 2022
093971e
update to localdatabase working without islotes
AshAman999 Aug 20, 2022
36c7877
suggestions left as comments on PR
AshAman999 Aug 22, 2022
4531785
Merge branch 'develop' of https://github.com/openfoodfacts/smooth-app…
AshAman999 Aug 22, 2022
5015bc7
deleted unncessary Random class
AshAman999 Aug 22, 2022
3bfc7be
Merge branch 'develop' of https://github.com/openfoodfacts/smooth-app…
AshAman999 Aug 22, 2022
80152b1
doc added
AshAman999 Aug 22, 2022
e44fc44
Remove WorkManager iOS code
g123k Aug 23, 2022
f7ac588
reset publock
AshAman999 Aug 23, 2022
90b50aa
reset publock
AshAman999 Aug 23, 2022
d9b5610
Merge branch 'develop' into background-image-upload
AshAman999 Aug 23, 2022
910e025
remove harcoded color
AshAman999 Aug 23, 2022
77cf5bc
used duration constant class instead of harcoded
AshAman999 Aug 23, 2022
5389bcf
make methods to generate taskId
AshAman999 Aug 23, 2022
4c848ff
dart frmt
AshAman999 Aug 23, 2022
315ec38
changes as per the code review
AshAman999 Aug 23, 2022
764378d
Merge branch 'develop' of https://github.com/AshAman999/smooth-app in…
AshAman999 Aug 25, 2022
839c951
string buffer , var documentation and rename
AshAman999 Aug 25, 2022
5e7042b
Merge branch 'develop' of https://github.com/AshAman999/smooth-app in…
AshAman999 Aug 27, 2022
d3e33f9
error fix
AshAman999 Aug 27, 2022
84df712
Merge branch 'develop' into background-image-upload
AshAman999 Aug 27, 2022
17174b9
refactor and spelling corrections
AshAman999 Aug 28, 2022
4df7932
Merge branch 'develop' of https://github.com/AshAman999/smooth-app in…
AshAman999 Aug 28, 2022
0178c99
/// instead of //
AshAman999 Aug 28, 2022
a96dab4
dart ff formater
AshAman999 Aug 28, 2022
6b9d0bf
Merge branch 'develop' of https://github.com/openfoodfacts/smooth-app…
AshAman999 Aug 29, 2022
a54b234
more refactorings
AshAman999 Aug 30, 2022
7cee993
Merge branch 'develop' of https://github.com/openfoodfacts/smooth-app…
AshAman999 Aug 30, 2022
20e3c7c
Merge branch 'develop' of https://github.com/openfoodfacts/smooth-app…
AshAman999 Aug 30, 2022
76d0acb
Update background_task_helper.dart
g123k Aug 31, 2022
ba788a9
Merge branch 'develop' into background-image-upload
AshAman999 Aug 31, 2022
eba8d96
dart ff fix
AshAman999 Aug 31, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/smooth_app/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -566,4 +566,4 @@
/* End XCConfigurationList section */
};
rootObject = 97C146E61CF9000F007C117D /* Project object */;
}
}
106 changes: 53 additions & 53 deletions packages/smooth_app/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
@@ -1,59 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
<string>OpenFoodFacts</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>OpenFoodFacts</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>$(FLUTTER_BUILD_NAME)</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>$(FLUTTER_BUILD_NUMBER)</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>UIStatusBarHidden</key>
<false/>
<key>NSPhotoLibraryUsageDescription</key>
<string>This app needs to access photo library for product photos uploads</string>
<key>NSCameraUsageDescription</key>
<string>This app needs Camera Usage for scanning barcodes and cropping photos</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>https</string>
<string>http</string>
<string>mailto</string>
</array>
<key>UIRequiresFullScreen</key>
<true/>
<key>CADisableMinimumFrameDurationOnPhone</key>
<dict>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
<string>OpenFoodFacts</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>OpenFoodFacts</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>$(FLUTTER_BUILD_NAME)</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>$(FLUTTER_BUILD_NUMBER)</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>https</string>
<string>http</string>
<string>mailto</string>
</array>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSCameraUsageDescription</key>
<string>This app needs Camera Usage for scanning barcodes and cropping photos</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>This app needs to access photo library for product photos uploads</string>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiresFullScreen</key>
<true/>
<key>UIStatusBarHidden</key>
<false/>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
</dict>
</plist>
23 changes: 2 additions & 21 deletions packages/smooth_app/lib/cards/data_cards/image_upload_card.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:openfoodfacts/openfoodfacts.dart';
Expand Down Expand Up @@ -46,35 +45,17 @@ class _ImageUploadCardState extends State<ImageUploadCard> {
if (!mounted) {
return;
}
final bool isUploaded = await uploadCapturedPicture(
await uploadCapturedPicture(
AshAman999 marked this conversation as resolved.
Show resolved Hide resolved
context,
barcode: widget.product
.barcode!, //Probably throws an error, but this is not a big problem when we got a product without a barcode
imageField: widget.productImageData.imageField,
imageUri: croppedImageFile.uri,
);
croppedImageFile.delete();

if (!mounted) {
g123k marked this conversation as resolved.
Show resolved Hide resolved
return;
}
if (isUploaded) {
if (widget.productImageData.imageField == ImageField.OTHER) {
final AppLocalizations appLocalizations =
AppLocalizations.of(context);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(appLocalizations.other_photo_uploaded),
duration: const Duration(seconds: 3),
action: SnackBarAction(
label: appLocalizations.more_photos,
onPressed: _getImage,
),
),
);
} else {
await widget.onUpload(context);
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:smooth_app/data_models/product_list.dart';
import 'package:smooth_app/database/dao_product.dart';
import 'package:smooth_app/database/dao_product_list.dart';
import 'package:smooth_app/database/local_database.dart';
import 'package:smooth_app/generic_lib/duration_constants.dart';
import 'package:smooth_app/helpers/analytics_helper.dart';
import 'package:smooth_app/query/barcode_product_query.dart';
import 'package:smooth_app/services/smooth_services.dart';
Expand Down Expand Up @@ -170,7 +171,7 @@ class ContinuousScanModel with ChangeNotifier {
try {
// We try to load the fresh copy of product from the server
final FetchedProduct fetchedProduct =
await _queryBarcode(barcode).timeout(const Duration(seconds: 5));
await _queryBarcode(barcode).timeout(SnackBarDuration.long);
if (fetchedProduct.product != null) {
_addProduct(barcode, ScannedProductState.CACHED);
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dart:convert';
import 'package:openfoodfacts/openfoodfacts.dart';
import 'package:smooth_app/data_models/abstract_onboarding_data.dart';
import 'package:smooth_app/database/local_database.dart';
import 'package:smooth_app/generic_lib/duration_constants.dart';
import 'package:smooth_app/query/product_query.dart';

/// Helper around a product we download, store and reuse at onboarding.
Expand Down Expand Up @@ -42,7 +43,7 @@ class OnboardingDataProduct extends AbstractOnboardingData<Product> {
language: ProductQuery.getLanguage(),
country: ProductQuery.getCountry(),
),
).timeout(const Duration(seconds: 5));
).timeout(SnackBarDuration.long);

@override
String getAssetPath() => assetPath;
Expand Down
3 changes: 2 additions & 1 deletion packages/smooth_app/lib/data_models/onboarding_loader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:smooth_app/data_models/onboarding_data_product.dart';
import 'package:smooth_app/database/local_database.dart';
import 'package:smooth_app/generic_lib/duration_constants.dart';
import 'package:smooth_app/generic_lib/loading_dialog.dart';
import 'package:smooth_app/pages/onboarding/onboarding_flow_navigator.dart';

Expand Down Expand Up @@ -33,7 +34,7 @@ class OnboardingLoader {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(appLocalizations.onboarding_welcome_loading_error),
duration: const Duration(seconds: 2),
duration: SnackBarDuration.short,
behavior: SnackBarBehavior.floating,
elevation: 0,
),
Expand Down
9 changes: 9 additions & 0 deletions packages/smooth_app/lib/generic_lib/duration_constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,12 @@ class SmoothAnimationsDuration {
static const Duration medium = Duration(milliseconds: 400);
static const Duration long = Duration(milliseconds: 500);
}

class SnackBarDuration {
const SnackBarDuration._();

static const Duration brief = Duration(seconds: 1);
static const Duration short = Duration(seconds: 2);
static const Duration medium = Duration(seconds: 3);
static const Duration long = Duration(seconds: 5);
}
Loading