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

Commit

Permalink
Avoid overriding user input. (#599)
Browse files Browse the repository at this point in the history
  • Loading branch information
keianhzo authored and MortimerGoro committed Oct 3, 2018
1 parent fe3a833 commit d8cdd0a
Showing 1 changed file with 17 additions and 17 deletions.
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

0 comments on commit d8cdd0a

Please sign in to comment.