From 27e2fd3caf8583e7946f36c8a71380812eb60e58 Mon Sep 17 00:00:00 2001 From: Codel1417 Date: Thu, 11 Jul 2024 01:04:41 -0400 Subject: [PATCH] Changes for opening bluetooth settings --- CHANGELOG.md | 2 + lib/Frontend/pages/home.dart | 10 +- lib/Frontend/pages/intro.dart | 326 +++++++++--------- .../translation_string_definitions.dart | 5 +- 4 files changed, 166 insertions(+), 177 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 906b05cb..a774b00e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ - Improve indicating when an action card controls multiple gear - Fix opening links on IOS +- Support more android devices +- Fix connecting to gear on older android versions ### V 1.0.5 diff --git a/lib/Frontend/pages/home.dart b/lib/Frontend/pages/home.dart index 91a94986..d674f991 100644 --- a/lib/Frontend/pages/home.dart +++ b/lib/Frontend/pages/home.dart @@ -113,10 +113,10 @@ class _HomeState extends ConsumerState { child: Column( mainAxisSize: MainAxisSize.min, children: [ - const ListTile( - leading: Icon(Icons.bluetooth_disabled), - title: Text('Bluetooth is Unavailable'), - subtitle: Text('Bluetooth is required to connect to Gear'), + ListTile( + leading: const Icon(Icons.bluetooth_disabled), + title: Text(actionsNoBluetooth()), + subtitle: Text(actionsNoBluetoothDescription()), ), Row( mainAxisAlignment: MainAxisAlignment.end, @@ -125,7 +125,7 @@ class _HomeState extends ConsumerState { onPressed: () async { AppSettings.openAppSettings(type: AppSettingsType.bluetooth); }, - child: const Text('Open Settings'), + child: Text(onboardingBluetoothEnableButtonLabel()), ), const SizedBox(width: 8), ], diff --git a/lib/Frontend/pages/intro.dart b/lib/Frontend/pages/intro.dart index f8aa1490..5333904c 100644 --- a/lib/Frontend/pages/intro.dart +++ b/lib/Frontend/pages/intro.dart @@ -1,6 +1,5 @@ import 'dart:async'; -import 'package:app_settings/app_settings.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; @@ -62,185 +61,170 @@ class OnBoardingPageState extends ConsumerState { bodyFlex: 5, safeArea: 0, ); - return ValueListenableBuilder( - valueListenable: isBluetoothEnabled, - builder: (BuildContext context, bool bluetoothEnabled, Widget? child) { - return IntroductionScreen( - key: introKey, - canProgress: (page) { - if (page == 2 && !bluetoothAccepted && bluetoothEnabled) { - return false; - } else if (page == 1 && !privacyAccepted) { - return false; - } - return true; - }, - globalBackgroundColor: Theme.of(context).canvasColor, - allowImplicitScrolling: true, - globalHeader: Align( - alignment: Alignment.topRight, - child: SafeArea( - child: Padding( - padding: const EdgeInsets.only(top: 16, right: 16), - child: InkWell( - child: _buildImage(Assets.tCLogoTransparentNoText.path, 60), - onLongPress: () async { - _introLogger.info("Open Logs"); - const LogsRoute().push(context); - }, - ), - ), + return IntroductionScreen( + key: introKey, + canProgress: (page) { + if (page == 2 && !bluetoothAccepted) { + return false; + } else if (page == 1 && !privacyAccepted) { + return false; + } + return true; + }, + globalBackgroundColor: Theme.of(context).canvasColor, + allowImplicitScrolling: true, + globalHeader: Align( + alignment: Alignment.topRight, + child: SafeArea( + child: Padding( + padding: const EdgeInsets.only(top: 16, right: 16), + child: InkWell( + child: _buildImage(Assets.tCLogoTransparentNoText.path, 60), + onLongPress: () async { + _introLogger.info("Open Logs"); + const LogsRoute().push(context); + }, ), ), - pages: [ - PageViewModel( - title: homeWelcomeMessageTitle(), - body: homeWelcomeMessage(), - image: Builder( - builder: (context) { - if (Theme.of(context).colorScheme.brightness == Brightness.light) { - return _buildImage(Assets.splashLightTransparent.path, MediaQuery.of(context).size.width); - } else { - return _buildImage(Assets.splashDarkTransparent.path, MediaQuery.of(context).size.width); - } - }, - ), - decoration: pageDecoration, - ), - PageViewModel( - title: morePrivacyPolicyLinkTitle(), - body: onboardingPrivacyPolicyDescription(), - image: LottieLazyLoad( - asset: Assets.tailcostickers.tailCoStickersFile144834359, - width: MediaQuery.of(context).size.width, - ), - footer: ButtonBar( - alignment: MainAxisAlignment.center, - children: [ - ElevatedButton( - onPressed: () async { - MarkdownViewerRoute( - $extra: MarkdownInfo( - content: await rootBundle.loadString(Assets.privacy), - title: morePrivacyPolicyLinkTitle(), - ), - ).push(context); - }, - child: Text( - onboardingPrivacyPolicyViewButtonLabel(), - ), - ), - FilledButton( - onPressed: privacyAccepted - ? null - : () async { - setState(() { - _introLogger.info("Accepted Privacy Policy"); - privacyAccepted = true; - HiveProxy - ..put(settings, allowErrorReporting, true) - ..put(settings, allowAnalytics, true); - introKey.currentState?.next(); - }); - }, - child: Text( - onboardingPrivacyPolicyAcceptButtonLabel(), - ), - ), - ], - ), - decoration: pageDecoration, - ), - PageViewModel( - title: onboardingBluetoothTitle(), - body: onboardingBluetoothDescription(), - image: LottieLazyLoad( - asset: Assets.tailcostickers.tailCoStickersFile144834357, - width: MediaQuery.of(context).size.width, - ), - footer: ButtonBar( - alignment: MainAxisAlignment.center, - children: [ - FilledButton( - onPressed: bluetoothEnabled - ? null - : () async { - AppSettings.openAppSettings(type: AppSettingsType.bluetooth); - }, - child: Text( - onboardingBluetoothEnableButtonLabel(), - ), - ), - FilledButton( - onPressed: bluetoothAccepted - ? null - : () async { - if (await getBluetoothPermission(_introLogger)) { - setState( - () { - // Start FlutterBluePlus - if (!ref.exists(initFlutterBluePlusProvider)) { - ref.read(initFlutterBluePlusProvider); - } - bluetoothAccepted = true; - }, - ); - introKey.currentState?.next(); - } - }, - child: Text( - onboardingBluetoothRequestButtonLabel(), + ), + ), + pages: [ + PageViewModel( + title: homeWelcomeMessageTitle(), + body: homeWelcomeMessage(), + image: Builder( + builder: (context) { + if (Theme.of(context).colorScheme.brightness == Brightness.light) { + return _buildImage(Assets.splashLightTransparent.path, MediaQuery.of(context).size.width); + } else { + return _buildImage(Assets.splashDarkTransparent.path, MediaQuery.of(context).size.width); + } + }, + ), + decoration: pageDecoration, + ), + PageViewModel( + title: morePrivacyPolicyLinkTitle(), + body: onboardingPrivacyPolicyDescription(), + image: LottieLazyLoad( + asset: Assets.tailcostickers.tailCoStickersFile144834359, + width: MediaQuery.of(context).size.width, + ), + footer: ButtonBar( + alignment: MainAxisAlignment.center, + children: [ + ElevatedButton( + onPressed: () async { + MarkdownViewerRoute( + $extra: MarkdownInfo( + content: await rootBundle.loadString(Assets.privacy), + title: morePrivacyPolicyLinkTitle(), ), - ), - ], + ).push(context); + }, + child: Text( + onboardingPrivacyPolicyViewButtonLabel(), + ), ), - decoration: pageDecoration, - ), - PageViewModel( - title: onboardingCompletedTitle(), - body: "", - image: LottieLazyLoad( - asset: Assets.tailcostickers.tailCoStickersFile144834338, - width: MediaQuery.of(context).size.width, + FilledButton( + onPressed: privacyAccepted + ? null + : () async { + setState(() { + _introLogger.info("Accepted Privacy Policy"); + privacyAccepted = true; + HiveProxy + ..put(settings, allowErrorReporting, true) + ..put(settings, allowAnalytics, true); + introKey.currentState?.next(); + }); + }, + child: Text( + onboardingPrivacyPolicyAcceptButtonLabel(), + ), ), - decoration: pageDecoration.copyWith( - bodyFlex: 2, - imageFlex: 4, - bodyAlignment: Alignment.bottomCenter, - imageAlignment: Alignment.topCenter, - imagePadding: const EdgeInsets.symmetric(vertical: 32), - contentMargin: const EdgeInsets.only(top: 32), + ], + ), + decoration: pageDecoration, + ), + PageViewModel( + title: onboardingBluetoothTitle(), + body: onboardingBluetoothDescription(), + image: LottieLazyLoad( + asset: Assets.tailcostickers.tailCoStickersFile144834357, + width: MediaQuery.of(context).size.width, + ), + footer: ButtonBar( + alignment: MainAxisAlignment.center, + children: [ + FilledButton( + onPressed: bluetoothAccepted + ? null + : () async { + if (await getBluetoothPermission(_introLogger)) { + setState( + () { + // Start FlutterBluePlus + if (!ref.exists(initFlutterBluePlusProvider)) { + ref.read(initFlutterBluePlusProvider); + } + bluetoothAccepted = true; + }, + ); + introKey.currentState?.next(); + } + }, + child: Text( + onboardingBluetoothRequestButtonLabel(), + ), ), - reverse: true, - ), - ], - onDone: () => _onIntroEnd(context), - onSkip: () => _onIntroEnd(context), - // You can override onSkip callback - //rtl: true, // Display as right-to-left - back: const Icon(Icons.arrow_back), - next: const Icon( - Icons.arrow_forward, - key: Key('nextPage'), + ], ), - done: FilledButton( - onPressed: () { - _onIntroEnd(context); - }, - child: Text(onboardingDoneButtonLabel(), style: const TextStyle(fontWeight: FontWeight.w600)), + decoration: pageDecoration, + ), + PageViewModel( + title: onboardingCompletedTitle(), + body: "", + image: LottieLazyLoad( + asset: Assets.tailcostickers.tailCoStickersFile144834338, + width: MediaQuery.of(context).size.width, ), - dotsFlex: 1, - controlsPadding: const EdgeInsets.symmetric(vertical: 32), - dotsDecorator: DotsDecorator( - size: const Size.square(10.0), - activeSize: const Size(40.0, 10.0), - activeColor: Theme.of(context).colorScheme.primary, - color: Theme.of(context).colorScheme.tertiary, - spacing: const EdgeInsets.symmetric(horizontal: 3.0), - activeShape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(50.0)), + decoration: pageDecoration.copyWith( + bodyFlex: 2, + imageFlex: 4, + bodyAlignment: Alignment.bottomCenter, + imageAlignment: Alignment.topCenter, + imagePadding: const EdgeInsets.symmetric(vertical: 32), + contentMargin: const EdgeInsets.only(top: 32), ), - ); - }, + reverse: true, + ), + ], + onDone: () => _onIntroEnd(context), + onSkip: () => _onIntroEnd(context), + // You can override onSkip callback + //rtl: true, // Display as right-to-left + back: const Icon(Icons.arrow_back), + next: const Icon( + Icons.arrow_forward, + key: Key('nextPage'), + ), + done: FilledButton( + onPressed: () { + _onIntroEnd(context); + }, + child: Text(onboardingDoneButtonLabel(), style: const TextStyle(fontWeight: FontWeight.w600)), + ), + dotsFlex: 1, + controlsPadding: const EdgeInsets.symmetric(vertical: 32), + dotsDecorator: DotsDecorator( + size: const Size.square(10.0), + activeSize: const Size(40.0, 10.0), + activeColor: Theme.of(context).colorScheme.primary, + color: Theme.of(context).colorScheme.tertiary, + spacing: const EdgeInsets.symmetric(horizontal: 3.0), + activeShape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(50.0)), + ), ); } } diff --git a/lib/Frontend/translation_string_definitions.dart b/lib/Frontend/translation_string_definitions.dart index f8089d78..b95aafe7 100644 --- a/lib/Frontend/translation_string_definitions.dart +++ b/lib/Frontend/translation_string_definitions.dart @@ -105,6 +105,9 @@ String sequenceEditListDelayLabel(int howMany) => Intl.message( //Actions Page String actionsNoBluetooth() => Intl.message('Bluetooth is unavailable', name: 'actionsNoBluetooth', desc: 'Label on the actions page when bluetooth is unavailable'); +String actionsNoBluetoothDescription() => + Intl.message('Bluetooth is required to connect to Gear. Please turn on bluetooth in settings. Do not connect to gear while in your devices bluetooth settings.', name: 'actionsNoBluetoothDescription', desc: 'description on the actions page when bluetooth is unavailable'); + String actionsCategoryCalm() => Intl.message('Calm and Relaxed', name: 'actionsCategoryCalm', desc: 'calm action group label'); String actionsCategoryFast() => Intl.message('Fast and Excited', name: 'actionsCategoryFast', desc: 'fast action group label'); @@ -310,7 +313,7 @@ String onboardingBluetoothDescription() => Intl.message("Bluetooth permission is String onboardingBluetoothRequestButtonLabel() => Intl.message("Grant Permission", name: 'onboardingBluetoothRequestButtonLabel', desc: 'Label for the button to request bluetooth permission on the onboarding screen'); -String onboardingBluetoothEnableButtonLabel() => Intl.message("Turn On Bluetooth", name: 'onboardingBluetoothEnableButtonLabel', desc: 'Label for the button to open bluetooth settings on the onboarding screen'); +String onboardingBluetoothEnableButtonLabel() => Intl.message("Open Settings to turn On Bluetooth", name: 'onboardingBluetoothEnableButtonLabel', desc: 'Label for the button to open bluetooth settings on the onboarding screen'); String onboardingDoneButtonLabel() => Intl.message("Done", name: 'onboardingDoneButtonLabel', desc: 'Label for the button to close the onboarding screen');