Login and mobile app registration improvements
This commit is contained in:
		| @@ -27,11 +27,11 @@ class AuthManager { | |||||||
|           Logger.d("Gottemp token"); |           Logger.d("Gottemp token"); | ||||||
|           String tempToken = json.decode(response)['access_token']; |           String tempToken = json.decode(response)['access_token']; | ||||||
|           Logger.d("Closing webview..."); |           Logger.d("Closing webview..."); | ||||||
|           flutterWebviewPlugin.close(); |           //flutterWebviewPlugin.close(); | ||||||
|           eventBus.fire(StartAuthEvent(oauthUrl, false)); |           eventBus.fire(StartAuthEvent(oauthUrl, false)); | ||||||
|           completer.complete(tempToken); |           completer.complete(tempToken); | ||||||
|         }).catchError((e) { |         }).catchError((e) { | ||||||
|           flutterWebviewPlugin.close(); |           //flutterWebviewPlugin.close(); | ||||||
|           Logger.e("Error getting temp token: ${e.toString()}"); |           Logger.e("Error getting temp token: ${e.toString()}"); | ||||||
|           eventBus.fire(StartAuthEvent(oauthUrl, false)); |           eventBus.fire(StartAuthEvent(oauthUrl, false)); | ||||||
|           completer.completeError(HAError("Error getting temp token")); |           completer.completeError(HAError("Error getting temp token")); | ||||||
|   | |||||||
| @@ -152,7 +152,8 @@ class HomeAssistant { | |||||||
|           eventBus.fire(ShowDialogEvent( |           eventBus.fire(ShowDialogEvent( | ||||||
|             title: "All good", |             title: "All good", | ||||||
|             body: "HA Client integration with your Home Assistant server works fine", |             body: "HA Client integration with your Home Assistant server works fine", | ||||||
|             positiveText: "Nice!" |             positiveText: "Nice!", | ||||||
|  |             negativeText: "Ok" | ||||||
|           )); |           )); | ||||||
|         } |         } | ||||||
|         completer.complete(); |         completer.complete(); | ||||||
|   | |||||||
| @@ -15,7 +15,7 @@ import 'package:http/http.dart' as http; | |||||||
| import 'package:charts_flutter/flutter.dart' as charts; | import 'package:charts_flutter/flutter.dart' as charts; | ||||||
| import 'package:progress_indicators/progress_indicators.dart'; | import 'package:progress_indicators/progress_indicators.dart'; | ||||||
| import 'package:flutter_markdown/flutter_markdown.dart'; | import 'package:flutter_markdown/flutter_markdown.dart'; | ||||||
| import 'package:flutter_svg/flutter_svg.dart'; | //import 'package:flutter_svg/flutter_svg.dart'; | ||||||
| import 'package:flutter_custom_tabs/flutter_custom_tabs.dart'; | import 'package:flutter_custom_tabs/flutter_custom_tabs.dart'; | ||||||
| import 'package:firebase_messaging/firebase_messaging.dart'; | import 'package:firebase_messaging/firebase_messaging.dart'; | ||||||
| import 'package:flutter_webview_plugin/flutter_webview_plugin.dart'; | import 'package:flutter_webview_plugin/flutter_webview_plugin.dart'; | ||||||
| @@ -352,6 +352,8 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver, Ticker | |||||||
|         }); |         }); | ||||||
|         if (event.showButton) { |         if (event.showButton) { | ||||||
|           _showOAuth(); |           _showOAuth(); | ||||||
|  |         } else { | ||||||
|  |           Navigator.of(context).pop(); | ||||||
|         } |         } | ||||||
|       }); |       }); | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -233,7 +233,7 @@ class _ConfigPanelWidgetState extends State<ConfigPanelWidget> { | |||||||
|                 Container(height: Sizes.rowPadding,), |                 Container(height: Sizes.rowPadding,), | ||||||
|                 Text("${HomeAssistant().userName}'s ${Device().model}, ${Device().osName} ${Device().osVersion}"), |                 Text("${HomeAssistant().userName}'s ${Device().model}, ${Device().osName} ${Device().osVersion}"), | ||||||
|                 Container(height: 6.0,), |                 Container(height: 6.0,), | ||||||
|                 Text("Here you can manually check if HA Client integration with your Home Assistant works fine."), |                 Text("Here you can manually check if HA Client integration with your Home Assistant works fine. As mobileApp integration in Home Assistant is still in development, this is not 100% correct check."), | ||||||
|                 Divider(), |                 Divider(), | ||||||
|                 Row( |                 Row( | ||||||
|                   mainAxisSize: MainAxisSize.min, |                   mainAxisSize: MainAxisSize.min, | ||||||
| @@ -241,6 +241,10 @@ class _ConfigPanelWidgetState extends State<ConfigPanelWidget> { | |||||||
|                     FlatButton( |                     FlatButton( | ||||||
|                         onPressed: () => updateRegistration(), |                         onPressed: () => updateRegistration(), | ||||||
|                         child: Text("Check registration", style: TextStyle(color: Colors.blue)) |                         child: Text("Check registration", style: TextStyle(color: Colors.blue)) | ||||||
|  |                     ), | ||||||
|  |                     FlatButton( | ||||||
|  |                         onPressed: () => resetRegistration(), | ||||||
|  |                         child: Text("Reset registration", style: TextStyle(color: Colors.red)) | ||||||
|                     ) |                     ) | ||||||
|                   ], |                   ], | ||||||
|                 ) |                 ) | ||||||
| @@ -276,7 +280,19 @@ class _ConfigPanelWidgetState extends State<ConfigPanelWidget> { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   updateRegistration() { |   updateRegistration() { | ||||||
|     HomeAssistant().checkAppRegistration(); |     HomeAssistant().checkAppRegistration(showOkDialog: true); | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   resetRegistration() { | ||||||
|  |     eventBus.fire(ShowDialogEvent( | ||||||
|  |       title: "Waaaait", | ||||||
|  |       body: "If you don't whant to have duplicate integrations and entities in your HA for your current device, first you need to remove MobileApp integration from Integration settings in HA and restart server.", | ||||||
|  |       positiveText: "Done it already", | ||||||
|  |       negativeText: "Ok, I will", | ||||||
|  |       onPositive: () { | ||||||
|  |         HomeAssistant().checkAppRegistration(showOkDialog: true, forceRegister: true); | ||||||
|  |       }, | ||||||
|  |     )); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   @override |   @override | ||||||
|   | |||||||
							
								
								
									
										59
									
								
								pubspec.lock
									
									
									
									
									
								
							
							
						
						
									
										59
									
								
								pubspec.lock
									
									
									
									
									
								
							| @@ -1,5 +1,5 @@ | |||||||
| # Generated by pub | # Generated by pub | ||||||
| # See https://www.dartlang.org/tools/pub/glossary#lockfile | # See https://dart.dev/tools/pub/glossary#lockfile | ||||||
| packages: | packages: | ||||||
|   archive: |   archive: | ||||||
|     dependency: transitive |     dependency: transitive | ||||||
| @@ -21,7 +21,7 @@ packages: | |||||||
|       name: async |       name: async | ||||||
|       url: "https://pub.dartlang.org" |       url: "https://pub.dartlang.org" | ||||||
|     source: hosted |     source: hosted | ||||||
|     version: "2.1.0" |     version: "2.2.0" | ||||||
|   boolean_selector: |   boolean_selector: | ||||||
|     dependency: transitive |     dependency: transitive | ||||||
|     description: |     description: | ||||||
| @@ -35,7 +35,7 @@ packages: | |||||||
|       name: cached_network_image |       name: cached_network_image | ||||||
|       url: "https://pub.dartlang.org" |       url: "https://pub.dartlang.org" | ||||||
|     source: hosted |     source: hosted | ||||||
|     version: "0.8.0" |     version: "1.1.1" | ||||||
|   charcode: |   charcode: | ||||||
|     dependency: transitive |     dependency: transitive | ||||||
|     description: |     description: | ||||||
| @@ -77,7 +77,7 @@ packages: | |||||||
|       name: crypto |       name: crypto | ||||||
|       url: "https://pub.dartlang.org" |       url: "https://pub.dartlang.org" | ||||||
|     source: hosted |     source: hosted | ||||||
|     version: "2.0.6" |     version: "2.1.1+1" | ||||||
|   date_format: |   date_format: | ||||||
|     dependency: "direct main" |     dependency: "direct main" | ||||||
|     description: |     description: | ||||||
| @@ -117,7 +117,7 @@ packages: | |||||||
|       name: flutter_cache_manager |       name: flutter_cache_manager | ||||||
|       url: "https://pub.dartlang.org" |       url: "https://pub.dartlang.org" | ||||||
|     source: hosted |     source: hosted | ||||||
|     version: "0.3.2" |     version: "1.1.1" | ||||||
|   flutter_custom_tabs: |   flutter_custom_tabs: | ||||||
|     dependency: "direct main" |     dependency: "direct main" | ||||||
|     description: |     description: | ||||||
| @@ -131,7 +131,7 @@ packages: | |||||||
|       name: flutter_launcher_icons |       name: flutter_launcher_icons | ||||||
|       url: "https://pub.dartlang.org" |       url: "https://pub.dartlang.org" | ||||||
|     source: hosted |     source: hosted | ||||||
|     version: "0.7.2" |     version: "0.7.2+1" | ||||||
|   flutter_local_notifications: |   flutter_local_notifications: | ||||||
|     dependency: "direct main" |     dependency: "direct main" | ||||||
|     description: |     description: | ||||||
| @@ -153,13 +153,6 @@ packages: | |||||||
|       url: "https://pub.dartlang.org" |       url: "https://pub.dartlang.org" | ||||||
|     source: hosted |     source: hosted | ||||||
|     version: "3.2.1+1" |     version: "3.2.1+1" | ||||||
|   flutter_svg: |  | ||||||
|     dependency: "direct main" |  | ||||||
|     description: |  | ||||||
|       name: flutter_svg |  | ||||||
|       url: "https://pub.dartlang.org" |  | ||||||
|     source: hosted |  | ||||||
|     version: "0.10.4" |  | ||||||
|   flutter_test: |   flutter_test: | ||||||
|     dependency: "direct dev" |     dependency: "direct dev" | ||||||
|     description: flutter |     description: flutter | ||||||
| @@ -171,7 +164,7 @@ packages: | |||||||
|       name: flutter_webview_plugin |       name: flutter_webview_plugin | ||||||
|       url: "https://pub.dartlang.org" |       url: "https://pub.dartlang.org" | ||||||
|     source: hosted |     source: hosted | ||||||
|     version: "0.3.5" |     version: "0.3.7" | ||||||
|   http: |   http: | ||||||
|     dependency: transitive |     dependency: transitive | ||||||
|     description: |     description: | ||||||
| @@ -235,69 +228,55 @@ packages: | |||||||
|       url: "https://pub.dartlang.org" |       url: "https://pub.dartlang.org" | ||||||
|     source: hosted |     source: hosted | ||||||
|     version: "1.6.2" |     version: "1.6.2" | ||||||
|   path_drawing: |  | ||||||
|     dependency: transitive |  | ||||||
|     description: |  | ||||||
|       name: path_drawing |  | ||||||
|       url: "https://pub.dartlang.org" |  | ||||||
|     source: hosted |  | ||||||
|     version: "0.4.1" |  | ||||||
|   path_parsing: |  | ||||||
|     dependency: transitive |  | ||||||
|     description: |  | ||||||
|       name: path_parsing |  | ||||||
|       url: "https://pub.dartlang.org" |  | ||||||
|     source: hosted |  | ||||||
|     version: "0.1.4" |  | ||||||
|   path_provider: |   path_provider: | ||||||
|     dependency: transitive |     dependency: transitive | ||||||
|     description: |     description: | ||||||
|       name: path_provider |       name: path_provider | ||||||
|       url: "https://pub.dartlang.org" |       url: "https://pub.dartlang.org" | ||||||
|     source: hosted |     source: hosted | ||||||
|     version: "0.5.0+1" |     version: "1.2.0" | ||||||
|   pedantic: |   pedantic: | ||||||
|     dependency: transitive |     dependency: transitive | ||||||
|     description: |     description: | ||||||
|       name: pedantic |       name: pedantic | ||||||
|       url: "https://pub.dartlang.org" |       url: "https://pub.dartlang.org" | ||||||
|     source: hosted |     source: hosted | ||||||
|     version: "1.5.0" |     version: "1.7.0" | ||||||
|   petitparser: |   petitparser: | ||||||
|     dependency: transitive |     dependency: transitive | ||||||
|     description: |     description: | ||||||
|       name: petitparser |       name: petitparser | ||||||
|       url: "https://pub.dartlang.org" |       url: "https://pub.dartlang.org" | ||||||
|     source: hosted |     source: hosted | ||||||
|     version: "2.2.1" |     version: "2.4.0" | ||||||
|   platform: |   platform: | ||||||
|     dependency: transitive |     dependency: transitive | ||||||
|     description: |     description: | ||||||
|       name: platform |       name: platform | ||||||
|       url: "https://pub.dartlang.org" |       url: "https://pub.dartlang.org" | ||||||
|     source: hosted |     source: hosted | ||||||
|     version: "2.2.0" |     version: "2.2.1" | ||||||
|   progress_indicators: |   progress_indicators: | ||||||
|     dependency: "direct main" |     dependency: "direct main" | ||||||
|     description: |     description: | ||||||
|       name: progress_indicators |       name: progress_indicators | ||||||
|       url: "https://pub.dartlang.org" |       url: "https://pub.dartlang.org" | ||||||
|     source: hosted |     source: hosted | ||||||
|     version: "0.1.2" |     version: "0.1.4" | ||||||
|   quiver: |   quiver: | ||||||
|     dependency: transitive |     dependency: transitive | ||||||
|     description: |     description: | ||||||
|       name: quiver |       name: quiver | ||||||
|       url: "https://pub.dartlang.org" |       url: "https://pub.dartlang.org" | ||||||
|     source: hosted |     source: hosted | ||||||
|     version: "2.0.2" |     version: "2.0.3" | ||||||
|   shared_preferences: |   shared_preferences: | ||||||
|     dependency: "direct main" |     dependency: "direct main" | ||||||
|     description: |     description: | ||||||
|       name: shared_preferences |       name: shared_preferences | ||||||
|       url: "https://pub.dartlang.org" |       url: "https://pub.dartlang.org" | ||||||
|     source: hosted |     source: hosted | ||||||
|     version: "0.5.3+1" |     version: "0.5.3+4" | ||||||
|   sky_engine: |   sky_engine: | ||||||
|     dependency: transitive |     dependency: transitive | ||||||
|     description: flutter |     description: flutter | ||||||
| @@ -316,7 +295,7 @@ packages: | |||||||
|       name: sqflite |       name: sqflite | ||||||
|       url: "https://pub.dartlang.org" |       url: "https://pub.dartlang.org" | ||||||
|     source: hosted |     source: hosted | ||||||
|     version: "1.1.5" |     version: "1.1.6+3" | ||||||
|   stack_trace: |   stack_trace: | ||||||
|     dependency: transitive |     dependency: transitive | ||||||
|     description: |     description: | ||||||
| @@ -358,7 +337,7 @@ packages: | |||||||
|       name: test_api |       name: test_api | ||||||
|       url: "https://pub.dartlang.org" |       url: "https://pub.dartlang.org" | ||||||
|     source: hosted |     source: hosted | ||||||
|     version: "0.2.4" |     version: "0.2.5" | ||||||
|   typed_data: |   typed_data: | ||||||
|     dependency: transitive |     dependency: transitive | ||||||
|     description: |     description: | ||||||
| @@ -372,7 +351,7 @@ packages: | |||||||
|       name: url_launcher |       name: url_launcher | ||||||
|       url: "https://pub.dartlang.org" |       url: "https://pub.dartlang.org" | ||||||
|     source: hosted |     source: hosted | ||||||
|     version: "5.0.3" |     version: "5.1.2" | ||||||
|   uuid: |   uuid: | ||||||
|     dependency: transitive |     dependency: transitive | ||||||
|     description: |     description: | ||||||
| @@ -393,7 +372,7 @@ packages: | |||||||
|       name: web_socket_channel |       name: web_socket_channel | ||||||
|       url: "https://pub.dartlang.org" |       url: "https://pub.dartlang.org" | ||||||
|     source: hosted |     source: hosted | ||||||
|     version: "1.0.13" |     version: "1.0.15" | ||||||
|   xml: |   xml: | ||||||
|     dependency: transitive |     dependency: transitive | ||||||
|     description: |     description: | ||||||
| @@ -409,5 +388,5 @@ packages: | |||||||
|     source: hosted |     source: hosted | ||||||
|     version: "2.1.16" |     version: "2.1.16" | ||||||
| sdks: | sdks: | ||||||
|   dart: ">=2.2.0 <3.0.0" |   dart: ">=2.4.0 <3.0.0" | ||||||
|   flutter: ">=1.5.0 <2.0.0" |   flutter: ">=1.5.0 <2.0.0" | ||||||
|   | |||||||
| @@ -18,7 +18,7 @@ dependencies: | |||||||
|   date_format: any |   date_format: any | ||||||
|   charts_flutter: any |   charts_flutter: any | ||||||
|   flutter_markdown: any |   flutter_markdown: any | ||||||
|   flutter_svg: ^0.10.3 | #  flutter_svg: ^0.10.3 | ||||||
|   flutter_custom_tabs: ^0.6.0 |   flutter_custom_tabs: ^0.6.0 | ||||||
|   firebase_messaging: ^4.0.0+1 |   firebase_messaging: ^4.0.0+1 | ||||||
|   flutter_webview_plugin: ^0.3.1 |   flutter_webview_plugin: ^0.3.1 | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user