Skip to content

Commit

Permalink
Fixed visual bug for updating whether device is being scanned or conn…
Browse files Browse the repository at this point in the history
…ected
  • Loading branch information
nandanav committed Oct 14, 2023
2 parents 17783a0 + 8fa294f commit d2fb7e6
Show file tree
Hide file tree
Showing 62 changed files with 626 additions and 49 deletions.
2 changes: 1 addition & 1 deletion app/watt_wizard/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ android {
applicationId "com.example.watt_wizard"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion flutter.minSdkVersion
minSdkVersion 21
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
Expand Down
56 changes: 28 additions & 28 deletions app/watt_wizard/android/app/google-services.json
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
{
"project_info": {
"project_number": "192909855910",
"project_id": "hackgt2023",
"storage_bucket": "hackgt2023.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:192909855910:android:a3092489a70c4c20873867",
"android_client_info": {
"package_name": "com.example.watt_wizard"
}
},
"oauth_client": [],
"api_key": [
{
"current_key": "AIzaSyATxM_RUX_OreCB3ftyZaI2ByYNNZTRqm4"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": []
}
}
}
],
"configuration_version": "1"
}
"project_info": {
"project_number": "192909855910",
"project_id": "hackgt2023",
"storage_bucket": "hackgt2023.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:192909855910:android:a3092489a70c4c20873867",
"android_client_info": {
"package_name": "com.example.watt_wizard"
}
},
"oauth_client": [],
"api_key": [
{
"current_key": "AIzaSyATxM_RUX_OreCB3ftyZaI2ByYNNZTRqm4"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": []
}
}
}
],
"configuration_version": "1"
}
18 changes: 17 additions & 1 deletion app/watt_wizard/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Tell Google Play Store that your app uses Bluetooth LE
Set android:required="true" if bluetooth is necessary -->
<uses-feature android:name="android.hardware.bluetooth_le" android:required="false" />

<!-- New Bluetooth permissions in Android 12
https://developer.android.com/about/versions/12/features/bluetooth-permissions -->
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />

<!-- legacy for Android 11 or lower -->
<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" android:maxSdkVersion="30"/>

<!-- legacy for Android 9 or lower -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" android:maxSdkVersion="28" />
<application
android:label="watt_wizard"
android:name="${applicationName}"
android:icon="@mipmap/launcher_icon">
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:exported="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
<item android:drawable="?android:colorBackground" />

<!-- You can insert your own image assets here -->
<!-- <item>
<item>
<bitmap
android:gravity="center"
android:src="@mipmap/launch_image" />
</item> -->
android:src="@mipmap/ic_launcher" />
</item>
</layer-list>
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
<item android:drawable="@android:color/white" />

<!-- You can insert your own image assets here -->
<!-- <item>
<item>
<bitmap
android:gravity="center"
android:src="@mipmap/launch_image" />
</item> -->
android:src="@mipmap/ic_launcher" />
</item>
</layer-list>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@mipmap/ic_launcher_adaptive_back"/>
<foreground android:drawable="@mipmap/ic_launcher_adaptive_fore"/>
</adaptive-icon>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file added app/watt_wizard/assets/icon/android_round.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed app/watt_wizard/assets/icon/icon.png
Binary file not shown.
Binary file added app/watt_wizard/assets/icon/ios_square.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions app/watt_wizard/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ PODS:
- FirebaseCoreInternal (10.16.0):
- "GoogleUtilities/NSData+zlib (~> 7.8)"
- Flutter (1.0.0)
- flutter_blue_plus (0.0.1):
- Flutter
- GoogleUtilities/AppDelegateSwizzler (7.11.5):
- GoogleUtilities/Environment
- GoogleUtilities/Logger
Expand All @@ -49,6 +51,7 @@ DEPENDENCIES:
- firebase_auth (from `.symlinks/plugins/firebase_auth/ios`)
- firebase_core (from `.symlinks/plugins/firebase_core/ios`)
- Flutter (from `Flutter`)
- flutter_blue_plus (from `.symlinks/plugins/flutter_blue_plus/ios`)

SPEC REPOS:
trunk:
Expand All @@ -69,6 +72,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/firebase_core/ios"
Flutter:
:path: Flutter
flutter_blue_plus:
:path: ".symlinks/plugins/flutter_blue_plus/ios"

SPEC CHECKSUMS:
Firebase: 66043bd4579e5b73811f96829c694c7af8d67435
Expand All @@ -79,6 +84,7 @@ SPEC CHECKSUMS:
FirebaseCore: 2cec518b43635f96afe7ac3a9c513e47558abd2e
FirebaseCoreInternal: 26233f705cc4531236818a07ac84d20c333e505a
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
flutter_blue_plus: 4837da7d00cf5d441fdd6635b3a57f936778ea96
GoogleUtilities: 13e2c67ede716b8741c7989e26893d151b2b2084
GTMSessionFetcher: e8647203b65cee28c5f73d0f473d096653945e72
PromisesObjC: c50d2056b5253dadbd6c2bea79b0674bd5a52fa4
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions app/watt_wizard/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@
<string>$(FLUTTER_BUILD_NAME)</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>NSBluetoothAlwaysUsageDescription</key>
<string>Need BLE permission</string>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>Need BLE permission</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>Need Location permission</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>Need Location permission</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Need Location permission</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
Expand Down
43 changes: 41 additions & 2 deletions app/watt_wizard/lib/homescreen.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import 'dart:async';
import 'dart:io';

import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
import 'package:watt_wizard/profile.dart';

class HomeScreen extends StatefulWidget {
const HomeScreen({super.key});
Expand All @@ -10,6 +15,9 @@ class HomeScreen extends StatefulWidget {

class _HomeScreenState extends State<HomeScreen> {
late User user;
BluetoothAdapterState _adapterState = BluetoothAdapterState.unknown;
late StreamSubscription<BluetoothAdapterState> _adapterStateStateSubscription;

@override
void initState() {
user = FirebaseAuth.instance.currentUser!;
Expand All @@ -20,11 +28,23 @@ class _HomeScreenState extends State<HomeScreen> {
user = event;
});
}

_adapterStateStateSubscription =
FlutterBluePlus.adapterState.listen((state) {
_adapterState = state;
setState(() {});
});
});

super.initState();
}

@override
void dispose() {
_adapterStateStateSubscription.cancel();
super.dispose();
}

@override
Widget build(BuildContext context) {
return Scaffold(
Expand All @@ -39,8 +59,17 @@ class _HomeScreenState extends State<HomeScreen> {
},
),
title: const Text("Home Screen"),
actions: const <Widget>[
IconButton(onPressed: null, icon: Icon(Icons.account_circle)),
actions: <Widget>[
IconButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
ProfileScreen(username: user.displayName!)),
);
},
icon: const Icon(Icons.account_circle)),
],
),
body: Center(
Expand All @@ -50,6 +79,16 @@ class _HomeScreenState extends State<HomeScreen> {
Text(
"Welcome ${user.displayName}",
),
_adapterState == BluetoothAdapterState.on
? const Spacer()
: FilledButton(
onPressed: () async {
if (Platform.isAndroid) {
await FlutterBluePlus.turnOn();
} else {}
},
child: const Text("Turn Bluetooth On"),
)
],
)),
);
Expand Down
19 changes: 11 additions & 8 deletions app/watt_wizard/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
// if (Platform.isAndroid) {
// await FlutterBluePlus.turnOn();
// }

return MaterialApp(
title: 'Watt Wizard',
theme: ThemeData(
Expand All @@ -29,14 +33,13 @@ class MyApp extends StatelessWidget {

Widget _landingPage() {
return StreamBuilder<User?>(
stream: FirebaseAuth.instance.authStateChanges(),
builder: (BuildContext context, snapshot) {
if(snapshot.hasData) {
return const HomeScreen();
}
return const MyHomePage(title: 'Sign in to Watt Wizard');
}
);
stream: FirebaseAuth.instance.authStateChanges(),
builder: (BuildContext context, snapshot) {
if (snapshot.hasData) {
return const HomeScreen();
}
return const MyHomePage(title: 'Sign in to Watt Wizard');
});
}

class MyHomePage extends StatelessWidget {
Expand Down
Loading

0 comments on commit d2fb7e6

Please sign in to comment.