Fix CleartextTraffic issue. WIP #338

This commit is contained in:
estevez-dev 2019-03-19 23:20:57 +02:00
parent ccb88884a7
commit 0efef33e53
3 changed files with 17 additions and 27 deletions

View File

@ -16,7 +16,7 @@
android:name="io.flutter.app.FlutterApplication" android:name="io.flutter.app.FlutterApplication"
android:label="HA Client" android:label="HA Client"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:networkSecurityConfig="@xml/network_security_config"> android:usesCleartextTraffic="true">
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
android:launchMode="singleTop" android:launchMode="singleTop"

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">homemade.systems</domain>
</domain-config>
</network-security-config>

View File

@ -51,8 +51,6 @@ class _ConnectionSettingsPageState extends State<ConnectionSettingsPage> {
} catch (e) { } catch (e) {
_useLovelace = _newUseLovelace = true; _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<ConnectionSettingsPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
Widget webViewButton; Widget webViewButton = RaisedButton(
if (oauthUrl != null) { color: Colors.blue[200],
webViewButton = FlatButton( onPressed: () {
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')}";
Navigator.of(context).push(MaterialPageRoute( Logger.d("OAuth url: $oauthUrl");
builder: (context) => WebviewScaffold( Navigator.of(context).push(MaterialPageRoute(
url: oauthUrl, builder: (context) => WebviewScaffold(
appBar: new AppBar( url: oauthUrl,
title: new Text("Login"), appBar: new AppBar(
) title: new Text("Login"),
) )
)); )
}, ));
child: Text("Login with Home Assistant") },
); child: Text("Login with Home Assistant")
} else { );
webViewButton = Container(height: 0.0,);
}
return new Scaffold( return new Scaffold(
appBar: new AppBar( appBar: new AppBar(
leading: IconButton(icon: Icon(Icons.arrow_back), onPressed: (){ leading: IconButton(icon: Icon(Icons.arrow_back), onPressed: (){