From 6e2ef7875193bf3a5ee8d4271676219891bf8847 Mon Sep 17 00:00:00 2001 From: lishoujun Date: Tue, 1 Jan 2019 02:15:35 +0800 Subject: [PATCH] add languages MultiSelectListPreference. but not all languages. --- .../schueller/peertube/activity/VideoListActivity.java | 7 ++++--- .../peertube/network/GetVideoDataService.java | 8 ++++++-- app/src/main/res/values/array.xml | 10 ++++++++++ app/src/main/res/values/strings.xml | 5 +++++ app/src/main/res/xml/pref_general.xml | 8 ++++++++ 5 files changed, 33 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/net/schueller/peertube/activity/VideoListActivity.java b/app/src/main/java/net/schueller/peertube/activity/VideoListActivity.java index bef23d9..e850419 100644 --- a/app/src/main/java/net/schueller/peertube/activity/VideoListActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/VideoListActivity.java @@ -60,6 +60,7 @@ import net.schueller.peertube.service.VideoPlayerService; import java.util.ArrayList; +import java.util.Set; import retrofit2.Call; import retrofit2.Callback; @@ -253,16 +254,16 @@ public class VideoListActivity extends AppCompatActivity { SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); String nsfw = sharedPref.getBoolean("pref_show_nsfw", false) ? "both" : "false"; - + Set languages = sharedPref.getStringSet("pref_language", null); String apiBaseURL = APIUrlHelper.getUrlWithVersion(this); GetVideoDataService service = RetrofitInstance.getRetrofitInstance(apiBaseURL).create(GetVideoDataService.class); Call call; if (!searchQuery.equals("")) { - call = service.searchVideosData(start, count, sort, nsfw, searchQuery, filter); + call = service.searchVideosData(start, count, sort, nsfw, searchQuery, filter, languages); } else { - call = service.getVideosData(start, count, sort, nsfw, filter); + call = service.getVideosData(start, count, sort, nsfw, filter, languages); } /*Log the URL called*/ diff --git a/app/src/main/java/net/schueller/peertube/network/GetVideoDataService.java b/app/src/main/java/net/schueller/peertube/network/GetVideoDataService.java index b66b727..2159070 100644 --- a/app/src/main/java/net/schueller/peertube/network/GetVideoDataService.java +++ b/app/src/main/java/net/schueller/peertube/network/GetVideoDataService.java @@ -20,6 +20,8 @@ package net.schueller.peertube.network; import net.schueller.peertube.model.Video; import net.schueller.peertube.model.VideoList; +import java.util.Set; + import retrofit2.Call; import retrofit2.http.GET; import retrofit2.http.Path; @@ -32,7 +34,8 @@ public interface GetVideoDataService { @Query("count") int count, @Query("sort") String sort, @Query("nsfw") String nsfw, - @Query("filter") String filter + @Query("filter") String filter, + @Query("languageOneOf") Set languages ); @GET("videos/{id}") @@ -47,6 +50,7 @@ public interface GetVideoDataService { @Query("sort") String sort, @Query("nsfw") String nsfw, @Query("search") String search, - @Query("filter") String filter + @Query("filter") String filter, + @Query("languageOneOf") Set languages ); } \ No newline at end of file diff --git a/app/src/main/res/values/array.xml b/app/src/main/res/values/array.xml index 1625c00..6c5083b 100644 --- a/app/src/main/res/values/array.xml +++ b/app/src/main/res/values/array.xml @@ -44,5 +44,15 @@ AppTheme.GRAY AppTheme.BLUEGRAY + + @string/en + @string/fr + + + + en + fr + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8f8f546..cd8057d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -47,6 +47,8 @@ Show NSFW NSFW content will be shown if enabled. + Show Languages + Select languages be shown. UrlVideoPlayActivity Torrent Video Player Video playback via a torrent stream. This requires Storage Permissions. (Alpha, not stable!) @@ -65,6 +67,9 @@ App Theme Restart App for theme to take effect. + English + French + Red Pink Purple diff --git a/app/src/main/res/xml/pref_general.xml b/app/src/main/res/xml/pref_general.xml index d287b5d..98b1da9 100644 --- a/app/src/main/res/xml/pref_general.xml +++ b/app/src/main/res/xml/pref_general.xml @@ -22,6 +22,14 @@ android:summary="@string/pref_description_show_nsfw" android:defaultValue="false" /> + +