Skip to content

Commit

Permalink
Merge branch 'develop' into refactor/backgroundTasks
Browse files Browse the repository at this point in the history
  • Loading branch information
monsieurtanuki authored Sep 10, 2022
2 parents 42c4beb + d2f8077 commit d2d614c
Show file tree
Hide file tree
Showing 147 changed files with 2,561 additions and 230 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
uses: actions/checkout@v3

- name: Setup Java JDK
uses: actions/setup-java@v3.4.1
uses: actions/setup-java@v3.5.0
with:
distribution: 'zulu'
java-version: ${{ env.JAVA_VERSION }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
ruby-version: ${{ env.RUBY_VERSION }}

- name: Setup Java JDK
uses: actions/setup-java@v3.4.1
uses: actions/setup-java@v3.5.0
with:
distribution: 'zulu'
java-version: ${{ env.JAVA_VERSION }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/postsubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
uses: actions/checkout@v3

- name: Setup Java JDK
uses: actions/setup-java@v3.4.1
uses: actions/setup-java@v3.5.0
with:
distribution: 'zulu'
java-version: 11
Expand Down
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# Changelog

## [3.16.0](https://github.com/openfoodfacts/smooth-app/compare/v3.15.0...v3.16.0) (2022-09-10)


### Features

* Helper for haptic feedback + improved delete product button ([#2957](https://github.com/openfoodfacts/smooth-app/issues/2957)) ([1073972](https://github.com/openfoodfacts/smooth-app/commit/10739723cedf55775e846b05d65db455d89d1d13))


### Bug Fixes

* miniature of ingredients blocks the text ([#2964](https://github.com/openfoodfacts/smooth-app/issues/2964)) ([c30e109](https://github.com/openfoodfacts/smooth-app/commit/c30e109372440ed9ef695525f061efb5f5951465))


### Miscellaneous

* New Crowdin translations ([#2981](https://github.com/openfoodfacts/smooth-app/issues/2981)) ([8f1cd29](https://github.com/openfoodfacts/smooth-app/commit/8f1cd2972f7cd6b3da651042ec673e4fa439ae47))
* New Crowdin translations ([#2990](https://github.com/openfoodfacts/smooth-app/issues/2990)) ([16b0434](https://github.com/openfoodfacts/smooth-app/commit/16b0434a823cb5999bc4b28ad0678497f22c7c58))

## [3.15.0](https://github.com/openfoodfacts/smooth-app/compare/v3.14.0...v3.15.0) (2022-09-07)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:provider/provider.dart';
import 'package:smooth_app/data_models/continuous_scan_model.dart';
import 'package:smooth_app/generic_lib/design_constants.dart';
import 'package:smooth_app/helpers/extension_on_text_helper.dart';
import 'package:smooth_app/helpers/haptic_feedback_helper.dart';
import 'package:smooth_app/helpers/product_cards_helper.dart';
import 'package:smooth_app/pages/product/add_basic_details_page.dart';

Expand All @@ -29,14 +30,27 @@ class ProductTitleCard extends StatelessWidget {
final Widget trailingWidget;
final String brands = product.brands ?? appLocalizations.unknownBrand;
final String quantity = product.quantity ?? '';

if (isRemovable && !isSelectable) {
final ContinuousScanModel model = context.watch<ContinuousScanModel>();
subtitleText = '$brands${quantity == '' ? '' : ', $quantity'}';
trailingWidget = InkWell(
onTap: () async => model.removeBarcode(product.barcode!),
child: const Icon(
Icons.clear_rounded,
size: MINIMUM_TOUCH_SIZE,
customBorder: const CircleBorder(),
onTap: () async {
await model.removeBarcode(product.barcode!);

// Vibrate twice
SmoothHapticFeedback.confirm();
},
child: Tooltip(
message: appLocalizations.product_card_remove_product_tooltip,
child: const Padding(
padding: EdgeInsets.all(SMALL_SPACE),
child: Icon(
Icons.clear_rounded,
size: DEFAULT_ICON_SIZE,
),
),
),
);
} else {
Expand Down
11 changes: 11 additions & 0 deletions packages/smooth_app/lib/data_models/user_preferences.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ class UserPreferences extends ChangeNotifier {
// Play sound when decoding a barcode
static const String _TAG_PLAY_CAMERA_SCAN_SOUND = 'camera_scan_sound';

/// Vibrations / haptic feedback
static const String _TAG_HAPTIC_FEEDBACK_IN_APP = 'haptic_feedback_enabled';

/// Attribute group that is not collapsed
static const String _TAG_ACTIVE_ATTRIBUTE_GROUP = 'activeAttributeGroup';

Expand Down Expand Up @@ -183,6 +186,14 @@ class UserPreferences extends ChangeNotifier {
bool get playCameraSound =>
_sharedPreferences.getBool(_TAG_PLAY_CAMERA_SCAN_SOUND) ?? false;

Future<void> setHapticFeedbackEnabled(bool enabled) async {
await _sharedPreferences.setBool(_TAG_HAPTIC_FEEDBACK_IN_APP, enabled);
notifyListeners();
}

bool get hapticFeedbackEnabled =>
_sharedPreferences.getBool(_TAG_HAPTIC_FEEDBACK_IN_APP) ?? true;

Future<void> setDevMode(final int value) async {
await _sharedPreferences.setInt(_TAG_DEV_MODE, value);
notifyListeners();
Expand Down
34 changes: 34 additions & 0 deletions packages/smooth_app/lib/database/dao_product.dart
Original file line number Diff line number Diff line change
Expand Up @@ -203,4 +203,38 @@ class DaoProduct extends AbstractSqlDao
debugPrint('$barcode;$asZipped;$asString;$factor');
}
}

/// Get the total number of products in the database
Future<int> getTotalNoOfProducts() async {
return Sqflite.firstIntValue(
await localDatabase.database.rawQuery(
'select count(*) from $_TABLE_PRODUCT',
),
) ??
0;
}

/// Get the estimated total size of the database in MegaBytes
Future<double> getEstimatedTotalSizeInMB() async {
// We get the estimated size of the database in bytes
// by summing the size of the gzipped json column and
// the size of the barcode column and last update column
final int? estimatedDataSize = Sqflite.firstIntValue(
await localDatabase.database.rawQuery('''
select sum(length($_TABLE_PRODUCT_COLUMN_BARCODE)) +
sum(length($_TABLE_PRODUCT_COLUMN_LAST_UPDATE)) +
sum(length($_TABLE_PRODUCT_COLUMN_GZIPPED_JSON))
from $_TABLE_PRODUCT
'''),
);
return double.parse(
((estimatedDataSize ?? 0) / ~1024 / ~1024).toStringAsFixed(2),
);
}

/// Delete all products from the database
Future<int> deleteAll() async {
// We return the number of rows deleted ie the number of products deleted
return localDatabase.database.delete(_TABLE_PRODUCT);
}
}
57 changes: 57 additions & 0 deletions packages/smooth_app/lib/helpers/haptic_feedback_helper.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import 'package:flutter/services.dart';
import 'package:smooth_app/data_models/user_preferences.dart';

/// Haptic feedback/vibrations in the app
/// Managed by a preference in the user's preferences
class SmoothHapticFeedback {
const SmoothHapticFeedback._();

/// Will vibrate smoothly twice
static Future<void> confirm() async {
if (!(await _areHapticFeedbackEnabled())) {
return;
}

await HapticFeedback.lightImpact();
return Future<void>.delayed(const Duration(milliseconds: 50), () {
HapticFeedback.lightImpact();
});
}

/// Discrete vibration
static Future<void> click() async {
if (!(await _areHapticFeedbackEnabled())) {
return;
}

return HapticFeedback.selectionClick();
}

/// According to the doc: "a collision impact with a light mass"
static Future<void> lightNotification() async {
if (!(await _areHapticFeedbackEnabled())) {
return;
}

return HapticFeedback.lightImpact();
}

/// Will vibrate heavily twice
static Future<void> error() async {
if (!(await _areHapticFeedbackEnabled())) {
return;
}

await HapticFeedback.heavyImpact();
return Future<void>.delayed(const Duration(milliseconds: 50), () {
HapticFeedback.heavyImpact();
});
}

static Future<bool> _areHapticFeedbackEnabled() async {
return UserPreferences.getUserPreferences()
.then((UserPreferences userPreferences) {
return userPreferences.hapticFeedbackEnabled;
});
}
}
16 changes: 15 additions & 1 deletion packages/smooth_app/lib/l10n/app_aa.arb
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,8 @@
"settings_app_app": "Application",
"settings_app_data": "Privacy & monitoring",
"settings_app_camera": "Camera",
"settings_app_products": "Products",
"settings_app_miscellaneous": "Miscellaneous",
"@camera_settings_title": {
"description": "Name of the camera section in the settings"
},
Expand Down Expand Up @@ -974,6 +976,14 @@
"@camera_alternative_mode_confirm_dialog_button": {
"description": "Button for the dialog to confirm the user has understood"
},
"app_haptic_feedback_title": "Vibration & Haptics",
"@app_haptic_feedback_title": {
"description": "Title for the Haptic feedback toggle"
},
"app_haptic_feedback_subtitle": "Vibrations after executing some actions (barcode decoded, product removed…).",
"@app_haptic_feedback_subtitle": {
"description": "SubTitle for the Haptic feedback toggle"
},
"crash_reporting_toggle_title": "Crash reporting",
"@crash_reporting_toggle_title": {
"description": "Title for the Crash reporting toggle"
Expand Down Expand Up @@ -1672,5 +1682,9 @@
"description": "Content for the dialog when no email client is installed on the device"
},
"all_images": "All Images",
"selected_images": "Selected Images"
"selected_images": "Selected Images",
"product_card_remove_product_tooltip": "Remove product",
"@product_card_remove_product_tooltip": {
"description": "Tooltip (message visible with a long-press) on a product item in the carousel"
}
}
16 changes: 15 additions & 1 deletion packages/smooth_app/lib/l10n/app_af.arb
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,8 @@
"settings_app_app": "Application",
"settings_app_data": "Privacy & monitoring",
"settings_app_camera": "Camera",
"settings_app_products": "Products",
"settings_app_miscellaneous": "Miscellaneous",
"@camera_settings_title": {
"description": "Name of the camera section in the settings"
},
Expand Down Expand Up @@ -974,6 +976,14 @@
"@camera_alternative_mode_confirm_dialog_button": {
"description": "Button for the dialog to confirm the user has understood"
},
"app_haptic_feedback_title": "Vibration & Haptics",
"@app_haptic_feedback_title": {
"description": "Title for the Haptic feedback toggle"
},
"app_haptic_feedback_subtitle": "Vibrations after executing some actions (barcode decoded, product removed…).",
"@app_haptic_feedback_subtitle": {
"description": "SubTitle for the Haptic feedback toggle"
},
"crash_reporting_toggle_title": "Crash reporting",
"@crash_reporting_toggle_title": {
"description": "Title for the Crash reporting toggle"
Expand Down Expand Up @@ -1672,5 +1682,9 @@
"description": "Content for the dialog when no email client is installed on the device"
},
"all_images": "All Images",
"selected_images": "Selected Images"
"selected_images": "Selected Images",
"product_card_remove_product_tooltip": "Remove product",
"@product_card_remove_product_tooltip": {
"description": "Tooltip (message visible with a long-press) on a product item in the carousel"
}
}
16 changes: 15 additions & 1 deletion packages/smooth_app/lib/l10n/app_ak.arb
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,8 @@
"settings_app_app": "Application",
"settings_app_data": "Privacy & monitoring",
"settings_app_camera": "Camera",
"settings_app_products": "Products",
"settings_app_miscellaneous": "Miscellaneous",
"@camera_settings_title": {
"description": "Name of the camera section in the settings"
},
Expand Down Expand Up @@ -974,6 +976,14 @@
"@camera_alternative_mode_confirm_dialog_button": {
"description": "Button for the dialog to confirm the user has understood"
},
"app_haptic_feedback_title": "Vibration & Haptics",
"@app_haptic_feedback_title": {
"description": "Title for the Haptic feedback toggle"
},
"app_haptic_feedback_subtitle": "Vibrations after executing some actions (barcode decoded, product removed…).",
"@app_haptic_feedback_subtitle": {
"description": "SubTitle for the Haptic feedback toggle"
},
"crash_reporting_toggle_title": "Crash reporting",
"@crash_reporting_toggle_title": {
"description": "Title for the Crash reporting toggle"
Expand Down Expand Up @@ -1672,5 +1682,9 @@
"description": "Content for the dialog when no email client is installed on the device"
},
"all_images": "All Images",
"selected_images": "Selected Images"
"selected_images": "Selected Images",
"product_card_remove_product_tooltip": "Remove product",
"@product_card_remove_product_tooltip": {
"description": "Tooltip (message visible with a long-press) on a product item in the carousel"
}
}
16 changes: 15 additions & 1 deletion packages/smooth_app/lib/l10n/app_am.arb
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,8 @@
"settings_app_app": "Application",
"settings_app_data": "Privacy & monitoring",
"settings_app_camera": "Camera",
"settings_app_products": "Products",
"settings_app_miscellaneous": "Miscellaneous",
"@camera_settings_title": {
"description": "Name of the camera section in the settings"
},
Expand Down Expand Up @@ -974,6 +976,14 @@
"@camera_alternative_mode_confirm_dialog_button": {
"description": "Button for the dialog to confirm the user has understood"
},
"app_haptic_feedback_title": "Vibration & Haptics",
"@app_haptic_feedback_title": {
"description": "Title for the Haptic feedback toggle"
},
"app_haptic_feedback_subtitle": "Vibrations after executing some actions (barcode decoded, product removed…).",
"@app_haptic_feedback_subtitle": {
"description": "SubTitle for the Haptic feedback toggle"
},
"crash_reporting_toggle_title": "Crash reporting",
"@crash_reporting_toggle_title": {
"description": "Title for the Crash reporting toggle"
Expand Down Expand Up @@ -1672,5 +1682,9 @@
"description": "Content for the dialog when no email client is installed on the device"
},
"all_images": "All Images",
"selected_images": "Selected Images"
"selected_images": "Selected Images",
"product_card_remove_product_tooltip": "Remove product",
"@product_card_remove_product_tooltip": {
"description": "Tooltip (message visible with a long-press) on a product item in the carousel"
}
}
16 changes: 15 additions & 1 deletion packages/smooth_app/lib/l10n/app_ar.arb
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,8 @@
"settings_app_app": "Application",
"settings_app_data": "Privacy & monitoring",
"settings_app_camera": "Camera",
"settings_app_products": "المنتجات",
"settings_app_miscellaneous": "Miscellaneous",
"@camera_settings_title": {
"description": "Name of the camera section in the settings"
},
Expand Down Expand Up @@ -974,6 +976,14 @@
"@camera_alternative_mode_confirm_dialog_button": {
"description": "Button for the dialog to confirm the user has understood"
},
"app_haptic_feedback_title": "Vibration & Haptics",
"@app_haptic_feedback_title": {
"description": "Title for the Haptic feedback toggle"
},
"app_haptic_feedback_subtitle": "Vibrations after executing some actions (barcode decoded, product removed…).",
"@app_haptic_feedback_subtitle": {
"description": "SubTitle for the Haptic feedback toggle"
},
"crash_reporting_toggle_title": "Crash reporting",
"@crash_reporting_toggle_title": {
"description": "Title for the Crash reporting toggle"
Expand Down Expand Up @@ -1672,5 +1682,9 @@
"description": "Content for the dialog when no email client is installed on the device"
},
"all_images": "All Images",
"selected_images": "Selected Images"
"selected_images": "Selected Images",
"product_card_remove_product_tooltip": "Remove product",
"@product_card_remove_product_tooltip": {
"description": "Tooltip (message visible with a long-press) on a product item in the carousel"
}
}
Loading

0 comments on commit d2d614c

Please sign in to comment.