Browse Source

Don't manually encode spaces

master
Anthony Restaino 8 years ago
parent
commit
621ac7a574
  1. 3
      app/src/main/java/acr/browser/lightning/search/DuckSuggestionsTask.java
  2. 3
      app/src/main/java/acr/browser/lightning/search/GoogleSuggestionsTask.java
  3. 2
      app/src/main/java/acr/browser/lightning/search/Suggestions.java

3
app/src/main/java/acr/browser/lightning/search/DuckSuggestionsTask.java

@ -24,7 +24,6 @@ import java.util.ArrayList; @@ -24,7 +24,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;
import java.util.zip.GZIPInputStream;
import javax.net.ssl.HttpsURLConnection;
@ -53,7 +52,6 @@ public final class DuckSuggestionsTask { @@ -53,7 +52,6 @@ public final class DuckSuggestionsTask {
private static final String TAG = RetrieveSuggestionsTask.class.getSimpleName();
private static final Pattern SPACE_PATTERN = Pattern.compile(" ", Pattern.LITERAL);
private static final String ENCODING = "UTF-8";
private static final long INTERVAL_DAY = TimeUnit.DAYS.toMillis(1);
private static final String DEFAULT_LANGUAGE = "en";
@ -91,7 +89,6 @@ public final class DuckSuggestionsTask { @@ -91,7 +89,6 @@ public final class DuckSuggestionsTask {
void run() {
List<HistoryItem> filter = new ArrayList<>(5);
try {
mQuery = SPACE_PATTERN.matcher(mQuery).replaceAll("+");
mQuery = URLEncoder.encode(mQuery, ENCODING);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();

3
app/src/main/java/acr/browser/lightning/search/GoogleSuggestionsTask.java

@ -26,7 +26,6 @@ import java.util.ArrayList; @@ -26,7 +26,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;
import java.util.zip.GZIPInputStream;
import javax.net.ssl.HttpsURLConnection;
@ -39,7 +38,6 @@ public class GoogleSuggestionsTask { @@ -39,7 +38,6 @@ public class GoogleSuggestionsTask {
private static final String TAG = RetrieveSuggestionsTask.class.getSimpleName();
private static final Pattern SPACE_PATTERN = Pattern.compile(" ", Pattern.LITERAL);
private static final String ENCODING = "ISO-8859-1";
private static final long INTERVAL_DAY = TimeUnit.DAYS.toMillis(1);
private static final String DEFAULT_LANGUAGE = "en";
@ -89,7 +87,6 @@ public class GoogleSuggestionsTask { @@ -89,7 +87,6 @@ public class GoogleSuggestionsTask {
void run() {
List<HistoryItem> filter = new ArrayList<>(5);
try {
mQuery = SPACE_PATTERN.matcher(mQuery).replaceAll("+");
mQuery = URLEncoder.encode(mQuery, ENCODING);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();

2
app/src/main/java/acr/browser/lightning/search/Suggestions.java

@ -332,7 +332,7 @@ public class Suggestions extends BaseAdapter implements Filterable { @@ -332,7 +332,7 @@ public class Suggestions extends BaseAdapter implements Filterable {
mSuggestions.clearSuggestions();
return results;
}
String query = constraint.toString().toLowerCase(Locale.getDefault());
String query = constraint.toString().toLowerCase(Locale.getDefault()).trim();
if (mSuggestions.shouldRequestNetwork() && !SuggestionsManager.isRequestInProgress()) {
mSuggestions.getSuggestionsForQuery(query)

Loading…
Cancel
Save