worldhopper/lib/helpers/eink_detection_helper.dart
Felipe M. 0b57896793 feat: eink-mode (#1)
Co-authored-by: Felipe M. <me@fmartingr.com>
Co-committed-by: Felipe M. <me@fmartingr.com>
2026-02-12 22:25:38 +01:00

42 lines
1.2 KiB
Dart

import 'dart:io';
import 'package:device_info_plus/device_info_plus.dart';
/// Detects whether the current device is a known e-ink device.
class EinkDetectionHelper {
static const _einkManufacturers = {
'onyx', // BOOX
'boyue', // Likebook
'amazon', // Kindle
'kobo',
'rakuten', // Kobo
'pocketbook',
'remarkable',
'tolino',
'bigme',
'dasung',
};
/// Hisense e-ink phone model prefixes (e.g. A5, A7, A9).
static const _hisenseEinkModels = {'a5', 'a7', 'a9'};
/// Returns `true` when the device is a known e-ink device.
/// On non-Android platforms this always returns `false`.
static Future<bool> isEinkDevice() async {
if (!Platform.isAndroid) return false;
final info = await DeviceInfoPlugin().androidInfo;
final manufacturer = info.manufacturer.toLowerCase();
final model = info.model.toLowerCase();
if (_einkManufacturers.contains(manufacturer)) return true;
// Hisense makes both LCD and e-ink phones — match specific model lines.
if (manufacturer == 'hisense') {
for (final prefix in _hisenseEinkModels) {
if (model.contains(prefix)) return true;
}
}
return false;
}
}