Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2afc19ec authored by Niedermann IT-Dienstleistungen's avatar Niedermann IT-Dienstleistungen
Browse files

#398 Check the URL (and draw the check) only on blur

Checking the URL on every text change can lead to privacy issues (e.g. if a subdomain is also an existing domain and a request is done to this domain).
parent ba19a6b6
Loading
Loading
Loading
Loading
+25 −9
Original line number Diff line number Diff line
@@ -76,6 +76,13 @@ public class SettingsActivity extends AppCompatActivity {
            }
        }

        field_url.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                new URLValidatorAsyncTask().execute(getNormalizedUrl());
            }
        });

        field_url.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
@@ -83,15 +90,7 @@ public class SettingsActivity extends AppCompatActivity {

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                String url = field_url.getText().toString().trim();

                if (!url.endsWith("/")) {
                    url += "/";
                }
                if (!url.startsWith("http://") && !url.startsWith("https://")) {
                    url = "https://" + url;
                }
                new URLValidatorAsyncTask().execute(url);
                String url = getNormalizedUrl();

                if (NotesClientUtil.isHttp(url)) {
                    urlWarnHttp.setVisibility(View.VISIBLE);
@@ -202,6 +201,23 @@ public class SettingsActivity extends AppCompatActivity {
        }
    }

    /**
     * Takes care about protocol and a slash at the end.
     * @return normalized Url
     */
    private String getNormalizedUrl() {
        String url = field_url.getText().toString().trim();

        if (!url.endsWith("/")) {
            url += "/";
        }
        if (!url.startsWith("http://") && !url.startsWith("https://")) {
            url = "https://" + url;
        }

        return url;
    }

    /************************************ Async Tasks ************************************/

    /**