From 1f530aeb3c8d6df68f5c927b994d60171c1bca6b Mon Sep 17 00:00:00 2001 From: Manuel Martin Date: Tue, 2 Oct 2018 17:28:22 +0200 Subject: [PATCH] Avoid overriding user input. --- .../vrbrowser/ui/NavigationURLBar.java | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/NavigationURLBar.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/NavigationURLBar.java index fabf3bc00..d4732c582 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/NavigationURLBar.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/NavigationURLBar.java @@ -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); }