From 0efef33e5386ad6089bd15a2ae924ebfbfcd8163 Mon Sep 17 00:00:00 2001 From: estevez-dev Date: Tue, 19 Mar 2019 23:20:57 +0200 Subject: [PATCH] Fix CleartextTraffic issue. WIP #338 --- android/app/src/main/AndroidManifest.xml | 2 +- .../main/res/xml/network_security_config.xml | 6 ---- lib/settings.page.dart | 36 +++++++++---------- 3 files changed, 17 insertions(+), 27 deletions(-) delete mode 100644 android/app/src/main/res/xml/network_security_config.xml diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 49d7f01..46304b4 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -16,7 +16,7 @@ android:name="io.flutter.app.FlutterApplication" android:label="HA Client" android:icon="@mipmap/ic_launcher" - android:networkSecurityConfig="@xml/network_security_config"> + android:usesCleartextTraffic="true"> - - - homemade.systems - - \ No newline at end of file diff --git a/lib/settings.page.dart b/lib/settings.page.dart index 626c845..c70c04e 100644 --- a/lib/settings.page.dart +++ b/lib/settings.page.dart @@ -51,8 +51,6 @@ class _ConnectionSettingsPageState extends State { } catch (e) { _useLovelace = _newUseLovelace = true; } - oauthUrl = "${ _newSocketProtocol == "wss" ? "https" : "http"}://$_newHassioDomain:${_newHassioPort ?? ''}/auth/authorize?client_id=${Uri.encodeComponent('http://ha-client.homemade.systems/')}&redirect_uri=${Uri.encodeComponent('http://ha-client.homemade.systems/service/auth_callback.html')}"; - Logger.d("OAuth url: $oauthUrl"); }); } @@ -80,24 +78,22 @@ class _ConnectionSettingsPageState extends State { @override Widget build(BuildContext context) { - Widget webViewButton; - if (oauthUrl != null) { - webViewButton = FlatButton( - onPressed: () { - Navigator.of(context).push(MaterialPageRoute( - builder: (context) => WebviewScaffold( - url: oauthUrl, - appBar: new AppBar( - title: new Text("Login"), - ) - ) - )); - }, - child: Text("Login with Home Assistant") - ); - } else { - webViewButton = Container(height: 0.0,); - } + Widget webViewButton = RaisedButton( + color: Colors.blue[200], + onPressed: () { + oauthUrl = "${ _newSocketProtocol == "wss" ? "https" : "http"}://$_newHassioDomain:${_newHassioPort ?? ''}/auth/authorize?client_id=${Uri.encodeComponent('http://ha-client.homemade.systems/')}&redirect_uri=${Uri.encodeComponent('http://ha-client.homemade.systems/service/auth_callback.html')}"; + Logger.d("OAuth url: $oauthUrl"); + Navigator.of(context).push(MaterialPageRoute( + builder: (context) => WebviewScaffold( + url: oauthUrl, + appBar: new AppBar( + title: new Text("Login"), + ) + ) + )); + }, + child: Text("Login with Home Assistant") + ); return new Scaffold( appBar: new AppBar( leading: IconButton(icon: Icon(Icons.arrow_back), onPressed: (){