switch languageCode to content country
This commit is contained in:
parent
28a9855fd2
commit
33d75fd2fb
7 changed files with 36 additions and 22 deletions
|
@ -143,8 +143,8 @@ public class KioskFragment extends BaseListInfoFragment<KioskInfo> {
|
||||||
public Single<KioskInfo> loadResult(boolean forceReload) {
|
public Single<KioskInfo> loadResult(boolean forceReload) {
|
||||||
String contentCountry = PreferenceManager
|
String contentCountry = PreferenceManager
|
||||||
.getDefaultSharedPreferences(activity)
|
.getDefaultSharedPreferences(activity)
|
||||||
.getString(getString(R.string.search_language_key),
|
.getString(getString(R.string.content_country_key),
|
||||||
getString(R.string.default_language_value));
|
getString(R.string.default_country_value));
|
||||||
return ExtractorHelper.getKioskInfo(serviceId, url, contentCountry, forceReload);
|
return ExtractorHelper.getKioskInfo(serviceId, url, contentCountry, forceReload);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,8 +152,8 @@ public class KioskFragment extends BaseListInfoFragment<KioskInfo> {
|
||||||
public Single<ListExtractor.NextItemsResult> loadMoreItemsLogic() {
|
public Single<ListExtractor.NextItemsResult> loadMoreItemsLogic() {
|
||||||
String contentCountry = PreferenceManager
|
String contentCountry = PreferenceManager
|
||||||
.getDefaultSharedPreferences(activity)
|
.getDefaultSharedPreferences(activity)
|
||||||
.getString(getString(R.string.search_language_key),
|
.getString(getString(R.string.content_country_key),
|
||||||
getString(R.string.default_language_value));
|
getString(R.string.default_country_value));
|
||||||
return ExtractorHelper.getMoreKioskItems(serviceId, url, currentNextItemsUrl, contentCountry);
|
return ExtractorHelper.getMoreKioskItems(serviceId, url, currentNextItemsUrl, contentCountry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -111,7 +111,7 @@ public class SearchFragment extends BaseListFragment<SearchResult, ListExtractor
|
||||||
|
|
||||||
private int currentPage = 0;
|
private int currentPage = 0;
|
||||||
private int currentNextPage = 0;
|
private int currentNextPage = 0;
|
||||||
private String searchLanguage;
|
private String contentCountry;
|
||||||
private boolean isSuggestionsEnabled = true;
|
private boolean isSuggestionsEnabled = true;
|
||||||
private boolean isSearchHistoryEnabled = true;
|
private boolean isSearchHistoryEnabled = true;
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ public class SearchFragment extends BaseListFragment<SearchResult, ListExtractor
|
||||||
|
|
||||||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
|
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
|
||||||
isSuggestionsEnabled = preferences.getBoolean(getString(R.string.show_search_suggestions_key), true);
|
isSuggestionsEnabled = preferences.getBoolean(getString(R.string.show_search_suggestions_key), true);
|
||||||
searchLanguage = preferences.getString(getString(R.string.search_language_key), getString(R.string.default_language_value));
|
contentCountry = preferences.getString(getString(R.string.content_country_key), getString(R.string.default_country_value));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -619,7 +619,7 @@ public class SearchFragment extends BaseListFragment<SearchResult, ListExtractor
|
||||||
return local.materialize();
|
return local.materialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
final Observable<List<SuggestionItem>> network = ExtractorHelper.suggestionsFor(serviceId, query, searchLanguage).toObservable()
|
final Observable<List<SuggestionItem>> network = ExtractorHelper.suggestionsFor(serviceId, query, contentCountry).toObservable()
|
||||||
.map(new Function<List<String>, List<SuggestionItem>>() {
|
.map(new Function<List<String>, List<SuggestionItem>>() {
|
||||||
@Override
|
@Override
|
||||||
public List<SuggestionItem> apply(@io.reactivex.annotations.NonNull List<String> strings) throws Exception {
|
public List<SuggestionItem> apply(@io.reactivex.annotations.NonNull List<String> strings) throws Exception {
|
||||||
|
@ -731,7 +731,7 @@ public class SearchFragment extends BaseListFragment<SearchResult, ListExtractor
|
||||||
super.startLoading(forceLoad);
|
super.startLoading(forceLoad);
|
||||||
if (disposables != null) disposables.clear();
|
if (disposables != null) disposables.clear();
|
||||||
if (searchDisposable != null) searchDisposable.dispose();
|
if (searchDisposable != null) searchDisposable.dispose();
|
||||||
searchDisposable = ExtractorHelper.searchFor(serviceId, searchQuery, currentPage, searchLanguage, filter)
|
searchDisposable = ExtractorHelper.searchFor(serviceId, searchQuery, currentPage, contentCountry, filter)
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(new Consumer<SearchResult>() {
|
.subscribe(new Consumer<SearchResult>() {
|
||||||
|
@ -755,7 +755,7 @@ public class SearchFragment extends BaseListFragment<SearchResult, ListExtractor
|
||||||
showListFooter(true);
|
showListFooter(true);
|
||||||
if (searchDisposable != null) searchDisposable.dispose();
|
if (searchDisposable != null) searchDisposable.dispose();
|
||||||
currentNextPage = currentPage + 1;
|
currentNextPage = currentPage + 1;
|
||||||
searchDisposable = ExtractorHelper.getMoreSearchItems(serviceId, searchQuery, currentNextPage, searchLanguage, filter)
|
searchDisposable = ExtractorHelper.getMoreSearchItems(serviceId, searchQuery, currentNextPage, contentCountry, filter)
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(new Consumer<ListExtractor.NextItemsResult>() {
|
.subscribe(new Consumer<ListExtractor.NextItemsResult>() {
|
||||||
|
|
|
@ -382,7 +382,7 @@ public class ErrorActivity extends AppCompatActivity {
|
||||||
|
|
||||||
private String getContentLangString() {
|
private String getContentLangString() {
|
||||||
return PreferenceManager.getDefaultSharedPreferences(this)
|
return PreferenceManager.getDefaultSharedPreferences(this)
|
||||||
.getString(this.getString(R.string.search_language_key), "none");
|
.getString(this.getString(R.string.content_country_key), "none");
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getOsString() {
|
private String getOsString() {
|
||||||
|
|
|
@ -57,13 +57,13 @@ public final class ExtractorHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Single<SearchResult> searchFor(final int serviceId, final String query, final int pageNumber, final String searchLanguage, final SearchEngine.Filter filter) {
|
public static Single<SearchResult> searchFor(final int serviceId, final String query, final int pageNumber, final String contentCountry, final SearchEngine.Filter filter) {
|
||||||
checkServiceId(serviceId);
|
checkServiceId(serviceId);
|
||||||
return Single.fromCallable(new Callable<SearchResult>() {
|
return Single.fromCallable(new Callable<SearchResult>() {
|
||||||
@Override
|
@Override
|
||||||
public SearchResult call() throws Exception {
|
public SearchResult call() throws Exception {
|
||||||
return SearchResult.getSearchResult(NewPipe.getService(serviceId).getSearchEngine(),
|
return SearchResult.getSearchResult(NewPipe.getService(serviceId).getSearchEngine(),
|
||||||
query, pageNumber, searchLanguage, filter);
|
query, pageNumber, contentCountry, filter);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -79,12 +79,12 @@ public final class ExtractorHelper {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Single<List<String>> suggestionsFor(final int serviceId, final String query, final String searchLanguage) {
|
public static Single<List<String>> suggestionsFor(final int serviceId, final String query, final String contentCountry) {
|
||||||
checkServiceId(serviceId);
|
checkServiceId(serviceId);
|
||||||
return Single.fromCallable(new Callable<List<String>>() {
|
return Single.fromCallable(new Callable<List<String>>() {
|
||||||
@Override
|
@Override
|
||||||
public List<String> call() throws Exception {
|
public List<String> call() throws Exception {
|
||||||
return NewPipe.getService(serviceId).getSuggestionExtractor().suggestionList(query, searchLanguage);
|
return NewPipe.getService(serviceId).getSuggestionExtractor().suggestionList(query, contentCountry);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -143,7 +143,8 @@ public final class ExtractorHelper {
|
||||||
return checkCache(forceLoad, serviceId, url, Single.fromCallable(new Callable<KioskInfo>() {
|
return checkCache(forceLoad, serviceId, url, Single.fromCallable(new Callable<KioskInfo>() {
|
||||||
@Override
|
@Override
|
||||||
public KioskInfo call() throws Exception {
|
public KioskInfo call() throws Exception {
|
||||||
return KioskInfo.getInfo(NewPipe.getService(serviceId), url, toUpperCase(contentCountry));
|
Log.e("---------", contentCountry);
|
||||||
|
return KioskInfo.getInfo(NewPipe.getService(serviceId), url, contentCountry);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
@ -152,7 +153,7 @@ public final class ExtractorHelper {
|
||||||
return Single.fromCallable(new Callable<NextItemsResult>() {
|
return Single.fromCallable(new Callable<NextItemsResult>() {
|
||||||
@Override
|
@Override
|
||||||
public NextItemsResult call() throws Exception {
|
public NextItemsResult call() throws Exception {
|
||||||
return KioskInfo.getMoreItems(NewPipe.getService(serviceId), url, nextStreamsUrl, toUpperCase(contentCountry));
|
return KioskInfo.getMoreItems(NewPipe.getService(serviceId), url, nextStreamsUrl, contentCountry);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,9 @@
|
||||||
<string name="show_next_video_key" translatable="false">show_next_video</string>
|
<string name="show_next_video_key" translatable="false">show_next_video</string>
|
||||||
<string name="show_hold_to_append_key" translatable="false">show_hold_to_append</string>
|
<string name="show_hold_to_append_key" translatable="false">show_hold_to_append</string>
|
||||||
<string name="default_language_value">en</string>
|
<string name="default_language_value">en</string>
|
||||||
|
<string name="default_country_value">GB</string>
|
||||||
<string name="search_language_key" translatable="false">search_language</string>
|
<string name="search_language_key" translatable="false">search_language</string>
|
||||||
|
<string name="content_country_key" translatable="false">content_country</string>
|
||||||
<string name="show_age_restricted_content" translatable="false">show_age_restricted_content</string>
|
<string name="show_age_restricted_content" translatable="false">show_age_restricted_content</string>
|
||||||
<string name="use_tor_key" translatable="false">use_tor</string>
|
<string name="use_tor_key" translatable="false">use_tor</string>
|
||||||
<string name="enable_search_history_key" translatable="false">enable_search_history</string>
|
<string name="enable_search_history_key" translatable="false">enable_search_history</string>
|
||||||
|
@ -518,7 +520,7 @@
|
||||||
<item>Sweden</item>
|
<item>Sweden</item>
|
||||||
<item>Switzerland</item>
|
<item>Switzerland</item>
|
||||||
<item>Syrian ArabRepublic(Syria)</item>
|
<item>Syrian ArabRepublic(Syria)</item>
|
||||||
<item>Taiwan,RepublicofChina</item>
|
<item>Taiwan, Republicof China</item>
|
||||||
<item>Tajikistan</item>
|
<item>Tajikistan</item>
|
||||||
<item>Tanzania</item>
|
<item>Tanzania</item>
|
||||||
<item>Thailand</item>
|
<item>Thailand</item>
|
||||||
|
@ -534,10 +536,10 @@
|
||||||
<item>Tuvalu</item>
|
<item>Tuvalu</item>
|
||||||
<item>Uganda</item>
|
<item>Uganda</item>
|
||||||
<item>Ukraine</item>
|
<item>Ukraine</item>
|
||||||
<item>UnitedArabEmirates</item>
|
<item>United Arab Emirates</item>
|
||||||
<item>UnitedKingdom</item>
|
<item>United Kingdom</item>
|
||||||
<item>USA</item>
|
<item>USA</item>
|
||||||
<item>MinorOutlyingIslands</item>
|
<item>Minor Outlying Islands</item>
|
||||||
<item>Uruguay</item>
|
<item>Uruguay</item>
|
||||||
<item>Uzbekistan</item>
|
<item>Uzbekistan</item>
|
||||||
<item>Vanuatu</item>
|
<item>Vanuatu</item>
|
||||||
|
|
|
@ -83,7 +83,8 @@
|
||||||
<string name="show_hold_to_append_title">Show Hold to Append Tip</string>
|
<string name="show_hold_to_append_title">Show Hold to Append Tip</string>
|
||||||
<string name="show_hold_to_append_summary">Show tip when background or popup button is pressed on video details page</string>
|
<string name="show_hold_to_append_summary">Show tip when background or popup button is pressed on video details page</string>
|
||||||
<string name="url_not_supported_toast">URL not supported</string>
|
<string name="url_not_supported_toast">URL not supported</string>
|
||||||
<string name="default_content_country_title">Default content country.</string>
|
<string name="default_content_country_title">Default content country</string>
|
||||||
|
<string name="search_language_title">Default content language</string>
|
||||||
<string name="settings_category_player_title">Player</string>
|
<string name="settings_category_player_title">Player</string>
|
||||||
<string name="settings_category_player_behavior_title">Behavior</string>
|
<string name="settings_category_player_behavior_title">Behavior</string>
|
||||||
<string name="settings_category_video_audio_title">Video & Audio</string>
|
<string name="settings_category_video_audio_title">Video & Audio</string>
|
||||||
|
|
|
@ -3,13 +3,23 @@
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:title="@string/content">
|
android:title="@string/content">
|
||||||
|
|
||||||
|
<ListPreference
|
||||||
|
android:defaultValue="@string/default_country_value"
|
||||||
|
android:entries="@array/country_names"
|
||||||
|
android:entryValues="@array/country_codes"
|
||||||
|
android:key="@string/content_country_key"
|
||||||
|
android:summary="%s"
|
||||||
|
android:title="@string/default_content_country_title"/>
|
||||||
|
|
||||||
|
<!-- TODO: add support for this within code
|
||||||
<ListPreference
|
<ListPreference
|
||||||
android:defaultValue="@string/default_language_value"
|
android:defaultValue="@string/default_language_value"
|
||||||
android:entries="@array/language_names"
|
android:entries="@array/language_names"
|
||||||
android:entryValues="@array/language_codes"
|
android:entryValues="@array/language_codes"
|
||||||
android:key="@string/search_language_key"
|
android:key="@string/search_language_key"
|
||||||
android:summary="%s"
|
android:summary="%s"
|
||||||
android:title="@string/default_content_country_title"/>
|
android:title="@string/search_language_title"/>
|
||||||
|
-->
|
||||||
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
|
|
Loading…
Reference in a new issue