Device compatibility (regression fix): - The CAMERA permission (from zxing_barcode_scanner / image_picker) implicitly required android.hardware.camera, excluding camera-less devices — Play showed Automotive -96%, Chromebook -86%, TV -25%. Declare camera & location uses-feature required="false" to keep those devices supported. - Detect a real camera at runtime (PackageManager.FEATURE_CAMERA_ANY via the existing MethodChannel), cache it at bootstrap, and hide the QR scan button and the camera photo-source option when absent, so no broken actions are offered. Play "app optimization" recommendations: - Enable R8 (isMinifyEnabled + isShrinkResources) with keep rules for the OCR (tesseract4android), SQLCipher and notifications JNI/reflection code. - Bitmap downscaling: cacheWidth/cacheHeight (and ResizeImage for avatars) on list thumbnails and avatars so photos decode to on-screen size, not full res. - Edge-to-edge: opt in with transparent system bars in main(). Release flow: - Tagged builds now publish to the production track at 100% (was internal); add a manual deploy_internal lane as a QA safety net. - Document country/region availability as a Play Console setting (not in-repo).
35 lines
1.6 KiB
Dart
35 lines
1.6 KiB
Dart
import 'package:flutter/foundation.dart';
|
|
import 'package:flutter/services.dart';
|
|
|
|
/// Whether this device has any camera. Resolved once at startup (via the native
|
|
/// channel, `PackageManager.FEATURE_CAMERA_ANY`) and cached so `build()` methods
|
|
/// can read it synchronously — the QR scan button ([qrScanSupported]) and the
|
|
/// photo-source sheet hide their camera options when it is false.
|
|
///
|
|
/// Defaults to `true` so a normal phone never loses camera UI over a transient
|
|
/// channel error; only genuinely camera-less devices (Chromebooks, Android
|
|
/// Automotive, some TVs — kept installable by the `uses-feature required=false`
|
|
/// in AndroidManifest) flip it to false. Non-Android platforms keep the default
|
|
/// (iOS devices have a camera; desktop/web gate camera UI elsewhere).
|
|
bool _deviceHasCamera = true;
|
|
|
|
bool get deviceHasCamera => _deviceHasCamera;
|
|
|
|
@visibleForTesting
|
|
set deviceHasCamera(bool value) => _deviceHasCamera = value;
|
|
|
|
const _channel = MethodChannel('org.comunes.tane/coarse_location');
|
|
|
|
/// Queries the native camera-presence check and caches it. Called once during
|
|
/// bootstrap, before the first real frame, so synchronous readers see the right
|
|
/// value. Android-only; elsewhere the default stands. Never throws — a channel
|
|
/// error leaves the safe default in place.
|
|
Future<void> initCameraAvailability() async {
|
|
if (defaultTargetPlatform != TargetPlatform.android) return;
|
|
try {
|
|
final has = await _channel.invokeMethod<bool>('hasCamera');
|
|
if (has != null) _deviceHasCamera = has;
|
|
} catch (_) {
|
|
// Keep the default; a normal phone shouldn't lose camera UI over this.
|
|
}
|
|
}
|