From e60db5f928a2af528ea595f323110c3951dfd7e6 Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Thu, 19 Jul 2018 16:18:57 +0200 Subject: [PATCH] make new filtersystem translatable --- app/build.gradle | 2 +- .../fragments/list/search/SearchFragment.java | 7 ++++++- .../java/org/schabi/newpipe/util/ServiceHelper.java | 12 ++++++++++++ app/src/main/res/values/strings.xml | 5 +++++ build.gradle | 2 +- 5 files changed, 25 insertions(+), 3 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 014f379f6..fbaab1214 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -54,7 +54,7 @@ dependencies { exclude module: 'support-annotations' } - implementation 'com.github.TeamNewPipe:NewPipeExtractor:8ee068fd98' + implementation 'com.github.TeamNewPipe:NewPipeExtractor:1eff8c5708' testImplementation 'junit:junit:4.12' testImplementation 'org.mockito:mockito-core:2.8.9' diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java index 77274c96a..5e511c03b 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java @@ -51,6 +51,7 @@ import org.schabi.newpipe.util.AnimationUtils; import org.schabi.newpipe.util.ExtractorHelper; import org.schabi.newpipe.util.LayoutManagerSmoothScroller; import org.schabi.newpipe.util.NavigationHelper; +import org.schabi.newpipe.util.ServiceHelper; import java.io.IOException; import java.io.InterruptedIOException; @@ -360,8 +361,12 @@ public class SearchFragment int itemId = 0; boolean isFirstItem = true; + final Context c = getContext(); for(String filter : service.getSearchQIHFactory().getAvailableContentFilter()) { - MenuItem item = menu.add(1, itemId++, 0, filter); + MenuItem item = menu.add(1, + itemId++, + 0, + ServiceHelper.getTranslatedFilterString(filter, c)); if(isFirstItem) { item.setChecked(true); isFirstItem = false; diff --git a/app/src/main/java/org/schabi/newpipe/util/ServiceHelper.java b/app/src/main/java/org/schabi/newpipe/util/ServiceHelper.java index e7e52f393..7c781eb14 100644 --- a/app/src/main/java/org/schabi/newpipe/util/ServiceHelper.java +++ b/app/src/main/java/org/schabi/newpipe/util/ServiceHelper.java @@ -30,6 +30,18 @@ public class ServiceHelper { } } + public static String getTranslatedFilterString(String filter, Context c) { + switch(filter) { + case "all": return c.getString(R.string.all); + case "videos": return c.getString(R.string.videos); + case "channels": return c.getString(R.string.channels); + case "playlists": return c.getString(R.string.playlists); + case "tracks": return c.getString(R.string.tracks); + case "users": return c.getString(R.string.users); + default: return filter; + } + } + /** * Get a resource string with instructions for importing subscriptions for each service. * diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8686d21d3..502483667 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -125,7 +125,12 @@ Error report All Channel + Channels Playlist + Playlists + Videos + Tracks + Users Yes Later Disabled diff --git a/build.gradle b/build.gradle index a45c00aef..0448ed61e 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ buildscript { google() } dependencies { - classpath 'com.android.tools.build:gradle:3.1.2' + classpath 'com.android.tools.build:gradle:3.1.3' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files