diff --git a/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeSearchEngineTest.java b/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeSearchEngineTest.java index 7ab6cacf3..ea52539fb 100644 --- a/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeSearchEngineTest.java +++ b/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeSearchEngineTest.java @@ -40,7 +40,7 @@ public class YoutubeSearchEngineTest extends AndroidTestCase { result = engine.search("https://www.youtube.com/results?search_query=bla", 0, "de", new Downloader()); - suggestionReply = engine.suggestionList("hello", new Downloader()); + suggestionReply = engine.suggestionList("hello","de",new Downloader()); } public void testIfNoErrorOccur() { diff --git a/app/src/main/java/org/schabi/newpipe/SuggestionListAdapter.java b/app/src/main/java/org/schabi/newpipe/SuggestionListAdapter.java index 9eb7a4c28..53e824c78 100644 --- a/app/src/main/java/org/schabi/newpipe/SuggestionListAdapter.java +++ b/app/src/main/java/org/schabi/newpipe/SuggestionListAdapter.java @@ -16,20 +16,10 @@ import java.util.ArrayList; */ public class SuggestionListAdapter extends CursorAdapter { - private ArrayList suggestions; private String[] columns = new String[]{"_id", "title"}; public SuggestionListAdapter(Context context) { super(context, null, false); - - } - - public ArrayList getSuggestions() { - return suggestions; - } - - public void setSuggestions(ArrayList suggestions) { - this.suggestions = suggestions; } @Override diff --git a/app/src/main/java/org/schabi/newpipe/VideoItemListActivity.java b/app/src/main/java/org/schabi/newpipe/VideoItemListActivity.java index fcc458cb3..e60c4d176 100644 --- a/app/src/main/java/org/schabi/newpipe/VideoItemListActivity.java +++ b/app/src/main/java/org/schabi/newpipe/VideoItemListActivity.java @@ -2,6 +2,7 @@ package org.schabi.newpipe; import android.content.Context; import android.content.Intent; +import android.content.SharedPreferences; import android.os.Bundle; import android.os.Handler; import android.preference.PreferenceManager; @@ -150,16 +151,21 @@ public class VideoItemListActivity extends AppCompatActivity private final SearchEngine engine; private final String query; final Handler h = new Handler(); - + private Context context; private SuggestionSearchRunnable(SearchEngine engine, String query) { this.engine = engine; this.query = query; + context = VideoItemListActivity.this; } @Override public void run() { try { - ArrayListsuggestions = engine.suggestionList(query,new Downloader()); + SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); + String searchLanguageKey = context.getString(R.string.search_language_key); + String searchLanguage = sp.getString(searchLanguageKey, + getString(R.string.default_language_value)); + ArrayListsuggestions = engine.suggestionList(query,searchLanguage,new Downloader()); h.post(new SuggestionResultRunnable(suggestions)); } catch (ExtractionException e) { e.printStackTrace(); diff --git a/app/src/main/java/org/schabi/newpipe/extractor/SearchEngine.java b/app/src/main/java/org/schabi/newpipe/extractor/SearchEngine.java index be176d39e..74f3f0f60 100644 --- a/app/src/main/java/org/schabi/newpipe/extractor/SearchEngine.java +++ b/app/src/main/java/org/schabi/newpipe/extractor/SearchEngine.java @@ -33,7 +33,7 @@ public interface SearchEngine { public final List resultList = new Vector<>(); } - ArrayList suggestionList(String query, Downloader dl) + ArrayList suggestionList(String query,String contentCountry, Downloader dl) throws ExtractionException, IOException; //Result search(String query, int page); diff --git a/app/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSearchEngine.java b/app/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSearchEngine.java index fd7528926..4f24fb5bd 100644 --- a/app/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSearchEngine.java +++ b/app/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSearchEngine.java @@ -147,7 +147,7 @@ public class YoutubeSearchEngine implements SearchEngine { } @Override - public ArrayList suggestionList(String query, Downloader dl) + public ArrayList suggestionList(String query,String contentCountry, Downloader dl) throws IOException, ParsingException { ArrayList suggestions = new ArrayList<>(); @@ -160,6 +160,7 @@ public class YoutubeSearchEngine implements SearchEngine { .appendQueryParameter("client", "") .appendQueryParameter("output", "toolbar") .appendQueryParameter("ds", "yt") + .appendQueryParameter("hl",contentCountry) .appendQueryParameter("q", query); String url = builder.build().toString();