Java 11 networkSecurityConfig

- upgrading gradle to Java 11
 - fix CleartextTraffic with networkSecurityConfig
 - fix port empty
This commit is contained in:
lionel
2021-10-08 20:09:52 +02:00
parent 54dce31f53
commit cba7fc2555
11 changed files with 37 additions and 26 deletions

View File

@ -21,8 +21,8 @@ android {
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
}

View File

@ -7,12 +7,13 @@
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
android:theme="@style/AppTheme"
android:networkSecurityConfig="@xml/network_security_config">
<!--android:usesCleartextTraffic="true"-->
<provider
android:name="androidx.core.content.FileProvider"

View File

@ -63,13 +63,21 @@ public class Transfer {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
host = prefs.getString("host", null);
port = valueOf(prefs.getString("port", null));
root = prefs.getString("root", null);
local_storage = prefs.getString("local_storage", null);
if(prefs.getBoolean("protocol", false))
protocol = "https";
else
protocol = "http";
String portValue = prefs.getString("port", null);
if(portValue.equals("")){
if(protocol.equals("http"))
port = 80;
else if(protocol.equals("https"))
port = 443;
}
else
port = valueOf(portValue);
}
private URL checkRedirection(URL url) throws IOException {

View File

@ -25,7 +25,7 @@
<string name="server_protocol">Use secure https</string>
<string name="server_host_def">www.netdldata.net</string>
<string name="server_port">Port</string>
<string name="server_port_def">80</string>
<string name="server_port_def"></string>
<string name="server_root">Root</string>
<string name="server_root_def">/transfer</string>

View File

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