Skip to content

Add warning when bluetooth is off#161

Merged
zjs81 merged 9 commits into
zjs81:mainfrom
ChaoticLeah:enhancement/bluetooth-disabled-warning
Feb 14, 2026
Merged

Add warning when bluetooth is off#161
zjs81 merged 9 commits into
zjs81:mainfrom
ChaoticLeah:enhancement/bluetooth-disabled-warning

Conversation

@ChaoticLeah

@ChaoticLeah ChaoticLeah commented Feb 11, 2026

Copy link
Copy Markdown
Contributor

Tested on linux and android

Linux:
image

Android:
image

What it does:

  • Places a banner up-top if bluetooth is off
  • If bluetooth is turned off while scanning the scan is canceled (and ofc the banner appears)
  • The scan button gets greyed out and does nothing when there is no bluetooth

Someone should probably test IOS

Closes: #156

Copilot AI review requested due to automatic review settings February 11, 2026 21:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds user-facing UI copy and a scanner-screen banner to warn when Bluetooth is not powered on, aligning with Issue #156 (“If bluetooth is off when pairing warn user”).

Changes:

  • Track FlutterBluePlus.adapterState in ScannerScreen and show a “Bluetooth is off” warning banner when not on.
  • Add new English localization strings for the Bluetooth-off banner.
  • Update untranslated.json to reflect missing translations for the new keys across non-English locales.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 7 comments.

File Description
untranslated.json Records untranslated localization keys for multiple locales after adding new scanner strings.
lib/screens/scanner_screen.dart Subscribes to adapter state and conditionally renders a Bluetooth-off warning banner.
lib/l10n/app_en.arb Adds English strings for the new Bluetooth-off banner (and an “Enable Bluetooth” label).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread untranslated.json Outdated
Comment thread lib/screens/scanner_screen.dart
Comment thread lib/l10n/app_en.arb
Comment thread lib/screens/scanner_screen.dart Outdated
Comment thread lib/screens/scanner_screen.dart Outdated
Comment on lines +47 to +54
_bluetoothStateSubscription = FlutterBluePlus.adapterState.listen((state) {
if (mounted) {
setState(() {
_bluetoothState = state;
});
// Cancel scan if Bluetooth turns off while scanning
if (state != BluetoothAdapterState.on &&
connector.state == MeshCoreConnectionState.scanning) {

Copilot AI Feb 11, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The adapter state listener only updates _bluetoothState. Per the PR description, turning Bluetooth off while scanning should cancel the scan, but no call to connector.stopScan() (or equivalent) happens when the adapter transitions away from on. Add logic here to stop an active scan when Bluetooth turns off and ensure connector state/UI stay consistent.

Copilot uses AI. Check for mistakes.

@446564 446564 Feb 12, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an extreme edge case, probably not a high priority. I did find it myself when testing but I don't think the average user is going to turn off ble after opening the app and then wonder what happened.

But it would be a nice to have safety.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be fixed? Not totally sure what the problem is if I didnt fix it but I think I got it

Comment thread lib/l10n/app_en.arb
Comment thread lib/l10n/app_en.arb
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 11, 2026 22:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/screens/scanner_screen.dart
Comment thread lib/screens/scanner_screen.dart
Comment thread untranslated.json Outdated
Comment thread lib/screens/scanner_screen.dart Outdated
@446564

446564 commented Feb 12, 2026

Copy link
Copy Markdown
Collaborator

I'll look closer and test on android tomorrow

@446564 446564 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The biggest thing I can see is the translations issues and the missing use of unawaited, the other things are nice to have though to prevent edge cases.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 12, 2026 19:02
@ChaoticLeah

Copy link
Copy Markdown
Contributor Author

The biggest thing I can see is the translations issues and the missing use of unawaited, the other things are nice to have though to prevent edge cases.

How do we want to do translations?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +83 to +85
// Bluetooth off warning
if (_bluetoothState != BluetoothAdapterState.on)
_bluetoothOffWarning(context),

Copilot AI Feb 12, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The warning banner currently shows for any adapter state other than on (e.g., unknown, turningOn, turningOff), which can incorrectly tell users “Bluetooth is off” during initialization or transitions. Restrict the banner to states that definitively indicate Bluetooth is unavailable (e.g., off/unavailable/unauthorized), or vary the text based on the specific state.

Copilot uses AI. Check for mistakes.
Comment on lines +252 to +263
Text(
context.l10n.scanner_bluetoothOff,
style: const TextStyle(
color: Colors.red,
fontWeight: FontWeight.w600,
fontSize: 14,
),
),
const SizedBox(height: 4),
Text(
context.l10n.scanner_bluetoothOffMessage,
style: TextStyle(

Copilot AI Feb 12, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These new scanner_bluetoothOff* strings are referenced from code, but the checked-in generated localization outputs (lib/l10n/app_localizations*.dart) don’t contain these getters yet. Either regenerate and commit the updated localization Dart files (per the current repo layout), or stop checking the generated localization files into source control so they can’t drift out of sync.

Copilot uses AI. Check for mistakes.
@446564

446564 commented Feb 12, 2026

Copy link
Copy Markdown
Collaborator

The biggest thing I can see is the translations issues and the missing use of unawaited, the other things are nice to have though to prevent edge cases.

How do we want to do translations?

If you run flutter gen-l10n it should create all the getters and setters, everything will be set to default english strings which you could just use g translate to change.

…app theme colors removed FAB overrides because material 3 does this for us, fixed missing translations.
Copilot AI review requested due to automatic review settings February 14, 2026 08:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@zjs81

zjs81 commented Feb 14, 2026

Copy link
Copy Markdown
Owner

@codex review

@zjs81

zjs81 commented Feb 14, 2026

Copy link
Copy Markdown
Owner

I fixed a few things in this PR. The way you do translations is using the translate.py script in the tools folder. It uses a local AI agent to do the translations for us.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 37db955ab2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/screens/scanner_screen.dart Outdated
@zjs81

zjs81 commented Feb 14, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@zjs81 zjs81 merged commit f87d489 into zjs81:main Feb 14, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

If bluetooth is off when pairing warn user

4 participants