1
0
mirror of https://github.com/TeamNewPipe/NewPipe.git synced 2024-11-21 18:42:35 +01:00

make new filtersystem translatable

This commit is contained in:
Christian Schabesberger 2018-07-19 16:18:57 +02:00
parent 39e04de208
commit e60db5f928
5 changed files with 25 additions and 3 deletions

View File

@ -54,7 +54,7 @@ dependencies {
exclude module: 'support-annotations' exclude module: 'support-annotations'
} }
implementation 'com.github.TeamNewPipe:NewPipeExtractor:8ee068fd98' implementation 'com.github.TeamNewPipe:NewPipeExtractor:1eff8c5708'
testImplementation 'junit:junit:4.12' testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:2.8.9' testImplementation 'org.mockito:mockito-core:2.8.9'

View File

@ -51,6 +51,7 @@ import org.schabi.newpipe.util.AnimationUtils;
import org.schabi.newpipe.util.ExtractorHelper; import org.schabi.newpipe.util.ExtractorHelper;
import org.schabi.newpipe.util.LayoutManagerSmoothScroller; import org.schabi.newpipe.util.LayoutManagerSmoothScroller;
import org.schabi.newpipe.util.NavigationHelper; import org.schabi.newpipe.util.NavigationHelper;
import org.schabi.newpipe.util.ServiceHelper;
import java.io.IOException; import java.io.IOException;
import java.io.InterruptedIOException; import java.io.InterruptedIOException;
@ -360,8 +361,12 @@ public class SearchFragment
int itemId = 0; int itemId = 0;
boolean isFirstItem = true; boolean isFirstItem = true;
final Context c = getContext();
for(String filter : service.getSearchQIHFactory().getAvailableContentFilter()) { 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) { if(isFirstItem) {
item.setChecked(true); item.setChecked(true);
isFirstItem = false; isFirstItem = false;

View File

@ -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. * Get a resource string with instructions for importing subscriptions for each service.
* *

View File

@ -125,7 +125,12 @@
<string name="error_report_title">Error report</string> <string name="error_report_title">Error report</string>
<string name="all">All</string> <string name="all">All</string>
<string name="channel">Channel</string> <string name="channel">Channel</string>
<string name="channels">Channels</string>
<string name="playlist">Playlist</string> <string name="playlist">Playlist</string>
<string name="playlists">Playlists</string>
<string name="videos">Videos</string>
<string name="tracks">Tracks</string>
<string name="users">Users</string>
<string name="yes">Yes</string> <string name="yes">Yes</string>
<string name="later">Later</string> <string name="later">Later</string>
<string name="disabled">Disabled</string> <string name="disabled">Disabled</string>

View File

@ -6,7 +6,7 @@ buildscript {
google() google()
} }
dependencies { 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 // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // in the individual module build.gradle files