Merge branch 'krille/fix-qr-code-scanner' into 'main'

chore: Follow up fix qr code scanner

See merge request famedly/fluffychat!758
This commit is contained in:
Krille Fear 2022-02-20 11:37:01 +00:00
commit ace5afa093
3 changed files with 16 additions and 17 deletions

View File

@ -1,8 +1,6 @@
image: image:
name: cirrusci/flutter name: cirrusci/flutter:2.10.1
variables:
GIT_SUBMODULE_STRATEGY: recursive
.shared_windows_runners: .shared_windows_runners:
tags: tags:

View File

@ -8,7 +8,6 @@ import 'package:permission_handler/permission_handler.dart';
import 'package:fluffychat/pages/new_private_chat/new_private_chat_view.dart'; import 'package:fluffychat/pages/new_private_chat/new_private_chat_view.dart';
import 'package:fluffychat/pages/new_private_chat/qr_scanner_modal.dart'; import 'package:fluffychat/pages/new_private_chat/qr_scanner_modal.dart';
import 'package:fluffychat/utils/fluffy_share.dart'; import 'package:fluffychat/utils/fluffy_share.dart';
import 'package:fluffychat/utils/platform_infos.dart';
import 'package:fluffychat/utils/url_launcher.dart'; import 'package:fluffychat/utils/url_launcher.dart';
import 'package:fluffychat/widgets/matrix.dart'; import 'package:fluffychat/widgets/matrix.dart';
@ -25,10 +24,9 @@ class NewPrivateChatController extends State<NewPrivateChat> {
final formKey = GlobalKey<FormState>(); final formKey = GlobalKey<FormState>();
bool loading = false; bool loading = false;
bool _hideFab = true; bool _hideFab = false;
bool _qrUnsupported = true;
bool get hideFab => !_qrUnsupported && _hideFab; bool get hideFab => _hideFab;
static const Set<String> supportedSigils = {'@', '!', '#'}; static const Set<String> supportedSigils = {'@', '!', '#'};
@ -43,7 +41,6 @@ class NewPrivateChatController extends State<NewPrivateChat> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_checkQrSupported();
textFieldFocus.addListener(setHideFab); textFieldFocus.addListener(setHideFab);
} }
@ -79,6 +76,17 @@ class NewPrivateChatController extends State<NewPrivateChat> {
); );
void openScannerAction() async { void openScannerAction() async {
final info = await DeviceInfoPlugin().androidInfo;
if ((info.version.sdkInt ?? 16) < 21) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
L10n.of(context)!.unsupportedAndroidVersionLong,
),
),
);
return;
}
await Permission.camera.request(); await Permission.camera.request();
await showModalBottomSheet( await showModalBottomSheet(
context: context, context: context,
@ -90,13 +98,4 @@ class NewPrivateChatController extends State<NewPrivateChat> {
@override @override
Widget build(BuildContext context) => NewPrivateChatView(this); Widget build(BuildContext context) => NewPrivateChatView(this);
// checks whether Android < 21 in order to support Android KitKat
void _checkQrSupported() {
if (!PlatformInfos.isAndroid) _qrUnsupported = false;
DeviceInfoPlugin().androidInfo.then(
(info) =>
setState(() => _qrUnsupported = (info.version.sdkInt ?? 16) < 21),
);
}
} }

View File

@ -10,6 +10,7 @@ import assets_audio_player_web
import audioplayers import audioplayers
import connectivity_plus_macos import connectivity_plus_macos
import desktop_drop import desktop_drop
import desktop_lifecycle
import device_info_plus_macos import device_info_plus_macos
import emoji_picker_flutter import emoji_picker_flutter
import file_selector_macos import file_selector_macos
@ -33,6 +34,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
AudioplayersPlugin.register(with: registry.registrar(forPlugin: "AudioplayersPlugin")) AudioplayersPlugin.register(with: registry.registrar(forPlugin: "AudioplayersPlugin"))
ConnectivityPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlugin")) ConnectivityPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlugin"))
DesktopDropPlugin.register(with: registry.registrar(forPlugin: "DesktopDropPlugin")) DesktopDropPlugin.register(with: registry.registrar(forPlugin: "DesktopDropPlugin"))
DesktopLifecyclePlugin.register(with: registry.registrar(forPlugin: "DesktopLifecyclePlugin"))
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin")) DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
EmojiPickerFlutterPlugin.register(with: registry.registrar(forPlugin: "EmojiPickerFlutterPlugin")) EmojiPickerFlutterPlugin.register(with: registry.registrar(forPlugin: "EmojiPickerFlutterPlugin"))
FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin")) FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))