Merge pull request #34 from gotify/cleartext-traffic

Allow cleartext traffic
This commit is contained in:
Jannis Mattheis
2018-12-22 17:15:37 +01:00
committed by GitHub
3 changed files with 19 additions and 1 deletions

View File

@@ -13,6 +13,7 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher"
android:supportsRtl="true"
android:usesCleartextTraffic="true"
android:theme="@style/AppTheme">
<activity
android:name=".init.InitializationActivity"

View File

@@ -102,11 +102,16 @@ public class LoginActivity extends AppCompatActivity {
@OnClick(R.id.checkurl)
public void doCheckUrl() {
String url = urlField.getText().toString();
if (HttpUrl.parse(url) == null) {
HttpUrl parsedUrl = HttpUrl.parse(url);
if (parsedUrl == null) {
Utils.showSnackBar(LoginActivity.this, "Invalid URL (include http:// or https://)");
return;
}
if ("http".equals(parsedUrl.scheme())) {
showHttpWarning();
}
checkUrlProgress.setVisibility(View.VISIBLE);
checkUrlButton.setVisibility(View.GONE);
@@ -117,6 +122,15 @@ public class LoginActivity extends AppCompatActivity {
.enqueue(callInUI(this, onValidUrl(fixedUrl), onInvalidUrl(fixedUrl)));
}
public void showHttpWarning() {
new AlertDialog.Builder(this)
.setTitle(R.string.warning)
.setCancelable(true)
.setMessage(R.string.http_warning)
.setPositiveButton(R.string.i_understand, (a, b) -> {})
.show();
}
@OnClick(R.id.open_logs)
public void openLogs() {
startActivity(new Intent(this, LogsActivity.class));

View File

@@ -54,4 +54,7 @@
<string name="done">Done</string>
<string name="no_certificate_selected">No certificate selected</string>
<string name="remove_ca_certificate">Remove CA Certificate</string>
<string name="warning">Warning</string>
<string name="http_warning">Using http is insecure and it\'s recommend to use https instead. Use your favorite search engine to get more information about this topic.</string>
<string name="i_understand">I Understand</string>
</resources>