openfoodfacts / smooth-app

🤳🥫 The new Open Food Facts mobile application for Android and iOS, crafted with Flutter and Dart
https://world.openfoodfacts.org/open-food-facts-mobile-app?utm_source=off&utf_medium=web&utm_campaign=github-repo
Apache License 2.0
827 stars 277 forks source link

Create a ZXing (MLKit-free) build for F-Droid #1882

Closed g123k closed 1 year ago

g123k commented 2 years ago

What

Part of

Initial message by @g123k

Hi everyone,

Smoothie has two dependencies to manage barcode decoding: google_ml_barcode_scanner (MLKit) and qr_code_scanner (ZXing). For both cases, the engine is embedded in our app. For debug APKs (= non-optimized), even with the Flutter engine, the difference with V1 is huge:

The reason behind this choice seems to be related that we want some builds for Google Play (let's say with MLKit) and for other app stores (FDroid…). Instead of building a single "fat" application, shouldn't we split the app into two versions?

Or maybe is qr_code_scanner still relevant? Is embedding MLKit an "OK" solution for non-Google Play Android stores?

Part of

M123-dev commented 2 years ago

When switching back to ML Kit we left in ZXing for two reasons: 1. Comparing them, I'd say that's done and 2. To allow publishing in stores like fDroid

But first most stores like these from Amazon or Samsung don't really care if we include ML Kit or not. The only one I know of is FDroid. V1 is on there so the initial plan was to also release it there but that's not a priority.

If there is a way to build with only one of them included without splitting the codebase that's a idea if that's not possible we can just remove qr_code_scanner. It's currently not in use and with the current level of abstraction it's easy to add back in if we need it again

g123k commented 2 years ago

@teolemon What’s our déploiement target for V1 and upcoming releases? Only Google Play? Fdroid?

teolemon commented 2 years ago

Only Google Play, but it'd be cool to figure out fdroid after that

g123k commented 2 years ago

Ok, so here is the plan:

Is-it OK for everyone?

monsieurtanuki commented 2 years ago

Is-it OK for everyone?

Understood, though I'm not convinced the energy spent there will be worth the trouble. For the Android app, how many downloads from Google Play and from FDroid?

teolemon commented 2 years ago

We want a fully free version to be available for F-Droid and FOSS (Open Food Facts is about Open Source). In V1, we actually allow users to opt-in into ML Kit, since there are terms and conditions. https://github.com/openfoodfacts/openfoodfacts-androidapp/pull/3836

<string name="preference_choose_scanner_dialog_title"><b>New: Enhanced “MLKit” scanner</b></string>
<string name="preference_choose_scanner_dialog_body">We have included a new option to more reliably scan barcodes. While this scanner works on your device, using machine learning,
        please be aware that it is a proprietary component provided by Google, governed by this privacy policy, and that some limited telemetry might be sent back to Google’s servers
        to improve their software. As noted in the MLKit terms, this won’t include any information about the products you scan and the telemetry is anonymized. Choosing MLKit scanner
        implies that you accept those terms\n<b>Note: You can switch back at any time between the 2 scanners in the Settings.</b>
monsieurtanuki commented 2 years ago

Regarding app size in general as in OP, maybe we could get rid of external packages that we don't use often. For the record, those are all the external packages we use:

% grep -rh ".dart';" * | grep -v "package:smooth_app" | grep -v "package:flutter" | grep -v "package:openfoodfacts" | sort | uniq -c | sort
   1 import 'package:camera_web/camera_web.dart';
   1 import 'package:carousel_slider/carousel_slider.dart';
   1 import 'package:collection/collection.dart';
   1 import 'package:device_preview/device_preview.dart';
   1 import 'package:fwfh_selectable_text/fwfh_selectable_text.dart';
   1 import 'package:hive/hive.dart';
   1 import 'package:http/http.dart';
   1 import 'package:image_cropper/image_cropper.dart';
   1 import 'package:image_cropper_for_web/image_cropper_for_web.dart';
   1 import 'package:image_picker/image_picker.dart';
   1 import 'package:image_picker_for_web/image_picker_for_web.dart';
   1 import 'package:intl/intl.dart';
   1 import 'package:iso_countries/iso_countries.dart';
   1 import 'package:latlong2/latlong.dart';
   1 import 'package:matomo_forever/matomo_forever.dart';
   1 import 'package:modal_bottom_sheet/modal_bottom_sheet.dart';
   1 import 'package:package_info_plus_web/package_info_plus_web.dart';
   1 import 'package:path/path.dart';
   1 import 'package:path_provider/path_provider.dart';
   1 import 'package:percent_indicator/percent_indicator.dart';
   1 import 'package:photo_view/photo_view.dart';
   1 import 'package:photo_view/photo_view_gallery.dart';
   1 import 'package:qr_code_scanner/qr_code_scanner.dart';
   1 import 'package:rxdart/rxdart.dart';
   1 import 'package:sentry_flutter/sentry_flutter_web.dart';
   1 import 'package:shared_preferences/shared_preferences.dart';
   1 import 'package:shared_preferences_web/shared_preferences_web.dart';
   1 import 'package:typed_data/typed_buffers.dart';
   1 import 'package:url_launcher_web/url_launcher_web.dart';
   1 import 'package:uuid/uuid.dart';
   2 import 'package:mailto/mailto.dart';
   2 import 'package:permission_handler/permission_handler.dart';
   2 import 'package:sentry_flutter/sentry_flutter.dart';
   2 import 'package:visibility_detector/visibility_detector.dart';
   4 import 'package:google_ml_barcode_scanner/google_ml_barcode_scanner.dart';
   4 import 'package:package_info_plus/package_info_plus.dart';
   4 import 'package:url_launcher/url_launcher.dart';
   6 import 'package:camera/camera.dart';
   6 import 'package:hive_flutter/hive_flutter.dart';
   8 import 'package:auto_size_text/auto_size_text.dart';
  44 import 'package:provider/provider.dart';
g123k commented 2 years ago

Excellent idea @monsieurtanuki. I have created a dedicated issue.

g123k commented 2 years ago

Good news: the app is working well on Huawei devices (without GMS). The only use case where we will have to use ZXing is for FDroid.

M123-dev commented 2 years ago

Heyy @g123k the new modular pipline is up and running so if we create a different flavour / store listing it's just a matter of passing different values to the workflow to create a differnt app.

g123k commented 2 years ago

ℹ️ This issue will be implemented as part of #3084 (step 3)

g123k commented 2 years ago

A few after the release, we should think about removing the data import feature #3150

teolemon commented 1 year ago

@g123k @M123-dev @monsieurtanuki is that something we can now do ? Unsure why we closed it in the first place

M123-dev commented 1 year ago

We had this before the we switched Scanners, (not automated the release to the store, but the apk uploaded to github releases)

alexgarel commented 1 year ago

I opened a new ticket, because this was is on a related subject, not the core.