perf(android): R8, bitmap downscaling, edge-to-edge; recover device compat; publish to production
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).
This commit is contained in:
parent
f17ae7751c
commit
071be44851
17 changed files with 232 additions and 21 deletions
|
|
@ -235,8 +235,14 @@ class _CalendarRow extends StatelessWidget {
|
|||
leading: CircleAvatar(
|
||||
radius: 20,
|
||||
backgroundColor: swatch.fill,
|
||||
foregroundImage:
|
||||
entry.photo == null ? null : MemoryImage(entry.photo!),
|
||||
// Decode to the 40px avatar size (× dpr), not the full photo.
|
||||
foregroundImage: entry.photo == null
|
||||
? null
|
||||
: ResizeImage(
|
||||
MemoryImage(entry.photo!),
|
||||
width: (40 * MediaQuery.devicePixelRatioOf(context)).round(),
|
||||
height: (40 * MediaQuery.devicePixelRatioOf(context)).round(),
|
||||
),
|
||||
child: entry.photo == null
|
||||
? Text(
|
||||
entry.label.isEmpty
|
||||
|
|
|
|||
|
|
@ -108,6 +108,10 @@ class _DraftTile extends StatelessWidget {
|
|||
photo,
|
||||
width: 48,
|
||||
height: 48,
|
||||
cacheWidth:
|
||||
(48 * MediaQuery.devicePixelRatioOf(context)).round(),
|
||||
cacheHeight:
|
||||
(48 * MediaQuery.devicePixelRatioOf(context)).round(),
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
|
|
@ -192,6 +196,8 @@ class _NameDraftDialogState extends State<NameDraftDialog> {
|
|||
child: Image.memory(
|
||||
widget.photo!,
|
||||
height: 140,
|
||||
cacheHeight:
|
||||
(140 * MediaQuery.devicePixelRatioOf(context)).round(),
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ class OfferThumbnail extends StatelessWidget {
|
|||
return ClipRRect(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
child: _offerImage(
|
||||
context,
|
||||
url,
|
||||
semanticLabel: semanticLabel,
|
||||
width: size,
|
||||
|
|
@ -63,7 +64,7 @@ class OfferHeroImage extends StatelessWidget {
|
|||
borderRadius: BorderRadius.circular(14),
|
||||
child: AspectRatio(
|
||||
aspectRatio: 4 / 3,
|
||||
child: _offerImage(url, semanticLabel: semanticLabel),
|
||||
child: _offerImage(context, url, semanticLabel: semanticLabel),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
@ -73,6 +74,7 @@ class OfferHeroImage extends StatelessWidget {
|
|||
/// remote URL (via network), always cropping to fill and falling back to a
|
||||
/// neutral placeholder — a broken image must never block the card.
|
||||
Widget _offerImage(
|
||||
BuildContext context,
|
||||
String url, {
|
||||
required String semanticLabel,
|
||||
double? width,
|
||||
|
|
@ -80,10 +82,16 @@ Widget _offerImage(
|
|||
}) {
|
||||
final inline = decodeDataUri(url);
|
||||
if (inline != null) {
|
||||
// For a sized thumbnail, decode down to its on-screen pixels instead of the
|
||||
// photo's full resolution (Play's "bitmap downscaling"). The hero image
|
||||
// passes no width, so it decodes at native size as intended.
|
||||
final dpr = MediaQuery.devicePixelRatioOf(context);
|
||||
return Image.memory(
|
||||
inline,
|
||||
width: width,
|
||||
height: height,
|
||||
cacheWidth: width == null ? null : (width * dpr).round(),
|
||||
cacheHeight: height == null ? null : (height * dpr).round(),
|
||||
fit: BoxFit.cover,
|
||||
semanticLabel: semanticLabel,
|
||||
errorBuilder: (context, _, _) =>
|
||||
|
|
|
|||
|
|
@ -34,7 +34,19 @@ class PeerAvatar extends StatelessWidget {
|
|||
if (pic.startsWith('data:')) {
|
||||
final bytes = decodeDataUri(pic);
|
||||
if (bytes != null) {
|
||||
return CircleAvatar(radius: radius, backgroundImage: MemoryImage(bytes));
|
||||
// Decode the photo down to the avatar's on-screen size (in physical
|
||||
// pixels) instead of full resolution — the "bitmap downscaling" Play
|
||||
// recommends. A tiny disc never needs a multi-megapixel decode.
|
||||
final side = (radius * 2 * MediaQuery.devicePixelRatioOf(context))
|
||||
.round();
|
||||
return CircleAvatar(
|
||||
radius: radius,
|
||||
backgroundImage: ResizeImage(
|
||||
MemoryImage(bytes),
|
||||
width: side,
|
||||
height: side,
|
||||
),
|
||||
);
|
||||
}
|
||||
} else if (pic.startsWith(avatarGlyphPrefix)) {
|
||||
final glyph = avatarGlyphChar(pic.substring(avatarGlyphPrefix.length));
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:image_picker/image_picker.dart';
|
||||
|
||||
import '../i18n/strings.g.dart';
|
||||
import '../services/camera_availability.dart';
|
||||
|
||||
/// Asks the user to take a photo or pick one from the gallery, then returns its
|
||||
/// bytes (or null if cancelled/unavailable). Camera failures — e.g. on desktop,
|
||||
|
|
@ -16,12 +17,15 @@ Future<Uint8List?> pickPhoto(BuildContext context) async {
|
|||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ListTile(
|
||||
key: const Key('photo.source.camera'),
|
||||
leading: const Icon(Icons.photo_camera_outlined),
|
||||
title: Text(t.photo.camera),
|
||||
onTap: () => Navigator.of(sheetContext).pop(ImageSource.camera),
|
||||
),
|
||||
// Only offer the camera when the device actually has one; camera-less
|
||||
// devices (Chromebooks, Automotive, some TVs) fall back to gallery.
|
||||
if (deviceHasCamera)
|
||||
ListTile(
|
||||
key: const Key('photo.source.camera'),
|
||||
leading: const Icon(Icons.photo_camera_outlined),
|
||||
title: Text(t.photo.camera),
|
||||
onTap: () => Navigator.of(sheetContext).pop(ImageSource.camera),
|
||||
),
|
||||
ListTile(
|
||||
key: const Key('photo.source.gallery'),
|
||||
leading: const Icon(Icons.photo_library_outlined),
|
||||
|
|
@ -57,12 +61,15 @@ Future<List<Uint8List>> pickPhotos(BuildContext context) async {
|
|||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ListTile(
|
||||
key: const Key('photos.source.camera'),
|
||||
leading: const Icon(Icons.photo_camera_outlined),
|
||||
title: Text(t.photo.camera),
|
||||
onTap: () => Navigator.of(sheetContext).pop(ImageSource.camera),
|
||||
),
|
||||
// Only offer the camera when the device actually has one; camera-less
|
||||
// devices (Chromebooks, Automotive, some TVs) fall back to gallery.
|
||||
if (deviceHasCamera)
|
||||
ListTile(
|
||||
key: const Key('photos.source.camera'),
|
||||
leading: const Icon(Icons.photo_camera_outlined),
|
||||
title: Text(t.photo.camera),
|
||||
onTap: () => Navigator.of(sheetContext).pop(ImageSource.camera),
|
||||
),
|
||||
ListTile(
|
||||
key: const Key('photos.source.gallery'),
|
||||
leading: const Icon(Icons.photo_library_outlined),
|
||||
|
|
|
|||
|
|
@ -7,12 +7,17 @@ import 'package:zxing_barcode_scanner/zxing_barcode_scanner.dart';
|
|||
import '../data/species_repository.dart';
|
||||
import '../data/variety_repository.dart';
|
||||
import '../i18n/strings.g.dart';
|
||||
import '../services/camera_availability.dart';
|
||||
import '../services/seed_label_scan.dart';
|
||||
|
||||
/// Whether this platform can open the camera scanner. Mobile-only for now
|
||||
/// (pure-ZXing platform views; no Google Play Services) — elsewhere the scan
|
||||
/// button simply isn't offered, same pattern as the OCR capture.
|
||||
bool get qrScanSupported => !kIsWeb && (Platform.isAndroid || Platform.isIOS);
|
||||
/// button simply isn't offered, same pattern as the OCR capture. On Android it
|
||||
/// also requires an actual camera, so camera-less devices (Chromebooks,
|
||||
/// Automotive, some TVs) don't get a scan button that can't open — see
|
||||
/// [deviceHasCamera].
|
||||
bool get qrScanSupported =>
|
||||
!kIsWeb && ((Platform.isAndroid && deviceHasCamera) || Platform.isIOS);
|
||||
|
||||
/// Opens the full-screen camera scanner and returns the first decoded QR
|
||||
/// payload, or null if the person backed out. (Ğ1nkgo's scanner pattern on
|
||||
|
|
|
|||
|
|
@ -199,6 +199,8 @@ class _MoreSection extends StatelessWidget {
|
|||
child: Image.memory(
|
||||
state.photoBytes!,
|
||||
height: 120,
|
||||
cacheHeight:
|
||||
(120 * MediaQuery.devicePixelRatioOf(context)).round(),
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -2244,10 +2244,16 @@ class _PhotoGalleryState extends State<_PhotoGallery> {
|
|||
itemBuilder: (_, i) => GestureDetector(
|
||||
key: Key('photo.thumb.$i'),
|
||||
onTap: () => _openPhotoViewer(context, cubit, i),
|
||||
// Decode to the 140px thumbnail size (× dpr), not full photo
|
||||
// resolution — the full-res decode happens in the viewer.
|
||||
child: Image.memory(
|
||||
photos[i].bytes,
|
||||
width: 140,
|
||||
height: 140,
|
||||
cacheWidth:
|
||||
(140 * MediaQuery.devicePixelRatioOf(context)).round(),
|
||||
cacheHeight:
|
||||
(140 * MediaQuery.devicePixelRatioOf(context)).round(),
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue