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:label="HA Client"
android:icon="@mipmap/ic_launcher"
android:networkSecurityConfig="@xml/network_security_config">
android:usesCleartextTraffic="true">
<activity
android:name=".MainActivity"
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) {
_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,10 +78,11 @@ class _ConnectionSettingsPageState extends State<ConnectionSettingsPage> {
@override
Widget build(BuildContext context) {
Widget webViewButton;
if (oauthUrl != null) {
webViewButton = FlatButton(
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,
@ -95,9 +94,6 @@ class _ConnectionSettingsPageState extends State<ConnectionSettingsPage> {
},
child: Text("Login with Home Assistant")
);
} else {
webViewButton = Container(height: 0.0,);
}
return new Scaffold(
appBar: new AppBar(
leading: IconButton(icon: Icon(Icons.arrow_back), onPressed: (){