Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow cleartext traffic #34

Merged
merged 2 commits into from
Dec 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
16 changes: 15 additions & 1 deletion app/src/main/java/com/github/gotify/login/LoginActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,16 @@ private void invalidateUrl() {
@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);

Expand All @@ -117,6 +122,15 @@ public void doCheckUrl() {
.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));
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>