Skip to content

Commit

Permalink
Fixed device state not reporting correctly in the ui
Browse files Browse the repository at this point in the history
- Fixed beta versions not copying over with the build scripts.
  • Loading branch information
jeroen1602 committed Dec 9, 2023
1 parent dfca00e commit 9681a57
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 20 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Version 1.3.1+11

- (Android) Fixed multiple devices not showing up.
- (Android) Fixed device state not reporting correctly in the ui (only for the second device somehow).

# Version 1.3.0+10 08-12-2023

Expand Down
15 changes: 4 additions & 11 deletions lib/lighthouse_provider/widgets/lighthouse_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -201,16 +201,14 @@ class LighthouseWidget extends StatefulWidget {
required this.selecting,
this.nickname,
this.sleepState = LighthousePowerState.sleep,
super.key})
: statefulDevice = lighthouseDevice is StatefulLighthouseDevice;
super.key});

final LighthouseDevice lighthouseDevice;
final VoidCallback onSelected;
final bool selected;
final String? nickname;
final LighthousePowerState sleepState;
final bool selecting;
final bool statefulDevice;

@override
State<StatefulWidget> createState() {
Expand All @@ -219,22 +217,17 @@ class LighthouseWidget extends StatefulWidget {
}

class LighthouseWidgetState extends State<LighthouseWidget> {
Stream<int>? _powerStateStream;

@override
void initState() {
super.initState();
if (widget.statefulDevice) {
_powerStateStream =
(widget.lighthouseDevice as StatefulLighthouseDevice).powerState;
}
}

@override
Widget build(final BuildContext context) {
if (widget.statefulDevice) {
if (widget.lighthouseDevice is StatefulLighthouseDevice) {
return StreamBuilder<int>(
stream: _powerStateStream,
stream:
(widget.lighthouseDevice as StatefulLighthouseDevice).powerState,
builder: (final BuildContext context,
final AsyncSnapshot<int> powerStateSnapshot) {
final powerStateData = powerStateSnapshot.data ?? 0xFF;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ mixin StatefulLighthouseDevice on LighthouseDevice {
}
} catch (e, s) {
lighthouseLogger.severe(
"Could not get state, maybe the device is already disconnected",
"Could not get state from $name, maybe the device is already disconnected",
e,
s);
await disconnect();
Expand All @@ -138,18 +138,19 @@ mixin StatefulLighthouseDevice on LighthouseDevice {
}
} else {
if (retryCount++ > 5) {
lighthouseLogger.shout("Unable to get power state because the "
"mutex has been locked for a while ($retryCount)."
"\nLocked by: ${transactionMutex.lockTrace?.toString()}");
lighthouseLogger
.shout("Unable to get power state from $name because the "
"mutex has been locked for a while ($retryCount)."
"\nLocked by: ${transactionMutex.lockTrace?.toString()}");
}
}
} else {
lighthouseLogger.info("Cleaning-up old subscription!");
lighthouseLogger.info("Cleaning-up old subscription! For $name");
disconnect();
}
});
powerStateSubscription.onDone(() {
lighthouseLogger.info("Cleaning-up power state subscription!");
lighthouseLogger.info("Cleaning-up power state subscription! For $name");
_powerStateSubscription = null;
});
_powerStateSubscription = powerStateSubscription;
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.3.0+10
version: 1.3.1-beta2+11

environment:
sdk: ">=2.19.0 <3.0.0"
Expand Down
29 changes: 29 additions & 0 deletions scripts/build-release-apks-fat.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash

SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)

cd "$SCRIPT_DIR/../" || exit

flutter build apk --release --no-obfuscate \
--flavor=defaultVersion \
--dart-define=includeGooglePlayInAppPurchases=false \
--dart-define=includeSupportButtons=true \
--dart-define=includeSupportPage=true \
--dart-define=includePaypal=true \
--dart-define=includeGithubSponsor=true \
--target-platform=android-arm,android-arm64,android-x64

EXIT_CODE=$?

if [ $EXIT_CODE != 0 ]; then
echo 'Could not build'
exit $EXIT_CODE
fi

set -e

mkdir -p "$SCRIPT_DIR/../output"

VERSION=$(grep -oP 'version: \K\d+\.\d+\.\d+(-.+)?\+\d+' "${SCRIPT_DIR}/../pubspec.yaml")

cp -vrf "${SCRIPT_DIR}/../build/app/outputs/flutter-apk/app-defaultversion-release.apk" "${SCRIPT_DIR}/../output/lighthouse_pm-${VERSION}.fat.apk"
2 changes: 1 addition & 1 deletion scripts/build-release-apks-github.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ set -e

mkdir -p "$SCRIPT_DIR/../output"

VERSION=$(grep -oP 'version: \K\d+\.\d+\.\d+\+\d+' "${SCRIPT_DIR}/../pubspec.yaml")
VERSION=$(grep -oP 'version: \K\d+\.\d+\.\d+(-.+)?\+\d+' "${SCRIPT_DIR}/../pubspec.yaml")

function copy_result() {
VERSION=$1
Expand Down
2 changes: 1 addition & 1 deletion scripts/build-release-bundle-playstore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ set -e

mkdir -p "$SCRIPT_DIR/../output"

VERSION=$(grep -oP 'version: \K\d+\.\d+\.\d+\+\d+' "${SCRIPT_DIR}/../pubspec.yaml")
VERSION=$(grep -oP 'version: \K\d+\.\d+\.\d+(-.+)?\+\d+' "${SCRIPT_DIR}/../pubspec.yaml")

cp -vrf "${SCRIPT_DIR}/../build/app/outputs/bundle/googlePlayRelease/app-googlePlay-release.aab" "$SCRIPT_DIR/../output/googlePlay-${VERSION}.aab"

0 comments on commit 9681a57

Please sign in to comment.