Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Avoid overriding user input in URL bar #599

Merged
merged 1 commit into from
Oct 3, 2018
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -136,25 +136,25 @@ else if (aURL.startsWith("data:") && SessionStore.get().isCurrentSessionPrivate(
aURL = "";
else
index = aURL.indexOf("://");
}
mURL.setText(aURL);
if (index > 0) {
SpannableString spannable = new SpannableString(aURL);
ForegroundColorSpan color1 = new ForegroundColorSpan(mURLProtocolColor);
ForegroundColorSpan color2 = new ForegroundColorSpan(mURLWebsiteColor);
spannable.setSpan(color1, 0, index + 3, 0);
spannable.setSpan(color2, index + 3, aURL.length(), 0);
mURL.setText(spannable);
} else {
mURL.setText(aURL);
}

mURL.addTextChangedListener(mURLTextWatcher);
}
// Update the URL bar only if the URL is different than the current one and
// the URL bar is not focused to avoid override user input
if (!mURL.getText().toString().equalsIgnoreCase(aURL) && !mURL.isFocused()) {
mURL.setText(aURL);
if (index > 0) {
SpannableString spannable = new SpannableString(aURL);
ForegroundColorSpan color1 = new ForegroundColorSpan(mURLProtocolColor);
ForegroundColorSpan color2 = new ForegroundColorSpan(mURLWebsiteColor);
spannable.setSpan(color1, 0, index + 3, 0);
spannable.setSpan(color2, index + 3, aURL.length(), 0);
mURL.setText(spannable);

} else {
mURL.setText(aURL);
}
}
}

public void setURLText(String aText) {
mURL.removeTextChangedListener(mURLTextWatcher);
mURL.setText(aText);
mURL.addTextChangedListener(mURLTextWatcher);
}

Expand Down