feat: redesign and lots of progress
This commit is contained in:
44
lib/util/bluetooth_settings.dart
Normal file
44
lib/util/bluetooth_settings.dart
Normal file
@ -0,0 +1,44 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
const MethodChannel _settingsChannel = MethodChannel('abawo/settings');
|
||||
|
||||
Future<bool> openBluetoothSettings() async {
|
||||
if (!Platform.isAndroid) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
return await _settingsChannel.invokeMethod<bool>('openBluetoothSettings') ??
|
||||
false;
|
||||
} on PlatformException {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> showBluetoothPairingRecoveryDialog(BuildContext context) {
|
||||
return showDialog<void>(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: const Text('Bluetooth pairing may be broken'),
|
||||
content: const Text(
|
||||
'The connection opened, then broke while reading the device. This is probably a pairing problem.\n\nOpen Bluetooth settings, remove/forget this device, then come back and connect again.',
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: const Text('Not now'),
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: () async {
|
||||
Navigator.of(context).pop();
|
||||
await openBluetoothSettings();
|
||||
},
|
||||
child: const Text('Open Bluetooth settings'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
@ -22,6 +22,10 @@ bool isConnectableAbawoDeviceGuid(Uuid guid) {
|
||||
return isAbawoUniversalShiftersDeviceGuid(guid);
|
||||
}
|
||||
|
||||
bool hasConnectableAbawoDeviceGuid(List<Uuid> guid) => guid
|
||||
.map((id) => isConnectableAbawoDeviceGuid(id))
|
||||
.fold(false, (v, e) => v || e);
|
||||
|
||||
bool isAbawoDeviceIdent(List<int> manuData) {
|
||||
if (manuData.length < abawoManuIdentData.length) return false;
|
||||
for (int i = 0; i < abawoManuIdentData.length; i++) {
|
||||
|
||||
Reference in New Issue
Block a user