Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions app/src/main/java/org/schabi/newpipe/RouterActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -361,15 +361,9 @@ protected void onSuccess() {
// Default / Ask always
final List<AdapterChoiceItem> availableChoices = choiceChecker.getAvailableChoices();
switch (availableChoices.size()) {
case 1:
handleChoice(availableChoices.get(0).key);
break;
case 0:
handleChoice(getString(R.string.show_info_key));
break;
default:
showDialog(availableChoices);
break;
case 1 -> handleChoice(availableChoices.get(0).key);
case 0 -> handleChoice(getString(R.string.show_info_key));
default -> showDialog(availableChoices);
}
}

Expand Down
84 changes: 30 additions & 54 deletions app/src/main/java/org/schabi/newpipe/util/ChannelTabHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,68 +48,44 @@ public static boolean isStreamsTab(final ListLinkHandler tab) {

@StringRes
private static int getShowTabKey(final String tab) {
switch (tab) {
case ChannelTabs.VIDEOS:
return R.string.show_channel_tabs_videos;
case ChannelTabs.TRACKS:
return R.string.show_channel_tabs_tracks;
case ChannelTabs.SHORTS:
return R.string.show_channel_tabs_shorts;
case ChannelTabs.LIVESTREAMS:
return R.string.show_channel_tabs_livestreams;
case ChannelTabs.CHANNELS:
return R.string.show_channel_tabs_channels;
case ChannelTabs.PLAYLISTS:
return R.string.show_channel_tabs_playlists;
case ChannelTabs.ALBUMS:
return R.string.show_channel_tabs_albums;
case ChannelTabs.LIKES:
return R.string.show_channel_tabs_likes;
default:
return -1;
}
return switch (tab) {
case ChannelTabs.VIDEOS -> R.string.show_channel_tabs_videos;
case ChannelTabs.TRACKS -> R.string.show_channel_tabs_tracks;
case ChannelTabs.SHORTS -> R.string.show_channel_tabs_shorts;
case ChannelTabs.LIVESTREAMS -> R.string.show_channel_tabs_livestreams;
case ChannelTabs.CHANNELS -> R.string.show_channel_tabs_channels;
case ChannelTabs.PLAYLISTS -> R.string.show_channel_tabs_playlists;
case ChannelTabs.ALBUMS -> R.string.show_channel_tabs_albums;
case ChannelTabs.LIKES -> R.string.show_channel_tabs_likes;
default -> -1;
};
}

@StringRes
private static int getFetchFeedTabKey(final String tab) {
switch (tab) {
case ChannelTabs.VIDEOS:
return R.string.fetch_channel_tabs_videos;
case ChannelTabs.TRACKS:
return R.string.fetch_channel_tabs_tracks;
case ChannelTabs.SHORTS:
return R.string.fetch_channel_tabs_shorts;
case ChannelTabs.LIVESTREAMS:
return R.string.fetch_channel_tabs_livestreams;
case ChannelTabs.LIKES:
return R.string.fetch_channel_tabs_likes;
default:
return -1;
}
return switch (tab) {
case ChannelTabs.VIDEOS -> R.string.fetch_channel_tabs_videos;
case ChannelTabs.TRACKS -> R.string.fetch_channel_tabs_tracks;
case ChannelTabs.SHORTS -> R.string.fetch_channel_tabs_shorts;
case ChannelTabs.LIVESTREAMS -> R.string.fetch_channel_tabs_livestreams;
case ChannelTabs.LIKES -> R.string.fetch_channel_tabs_likes;
default -> -1;
};
}

@StringRes
public static int getTranslationKey(final String tab) {
switch (tab) {
case ChannelTabs.VIDEOS:
return R.string.channel_tab_videos;
case ChannelTabs.TRACKS:
return R.string.channel_tab_tracks;
case ChannelTabs.SHORTS:
return R.string.channel_tab_shorts;
case ChannelTabs.LIVESTREAMS:
return R.string.channel_tab_livestreams;
case ChannelTabs.CHANNELS:
return R.string.channel_tab_channels;
case ChannelTabs.PLAYLISTS:
return R.string.channel_tab_playlists;
case ChannelTabs.ALBUMS:
return R.string.channel_tab_albums;
case ChannelTabs.LIKES:
return R.string.channel_tab_likes;
default:
return R.string.unknown_content;
}
return switch (tab) {
case ChannelTabs.VIDEOS -> R.string.channel_tab_videos;
case ChannelTabs.TRACKS -> R.string.channel_tab_tracks;
case ChannelTabs.SHORTS -> R.string.channel_tab_shorts;
case ChannelTabs.LIVESTREAMS -> R.string.channel_tab_livestreams;
case ChannelTabs.CHANNELS -> R.string.channel_tab_channels;
case ChannelTabs.PLAYLISTS -> R.string.channel_tab_playlists;
case ChannelTabs.ALBUMS -> R.string.channel_tab_albums;
case ChannelTabs.LIKES -> R.string.channel_tab_likes;
default -> R.string.unknown_content;
};
}

public static boolean showChannelTab(final Context context,
Expand Down
19 changes: 5 additions & 14 deletions app/src/main/java/org/schabi/newpipe/util/SavedState.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,12 @@ import kotlinx.parcelize.Parcelize

/**
* Information about the saved state on the disk.
* Path to the saved file.
*
* @property prefixFileSaved Prefix of the saved file
* @property pathFileSaved Path to the saved file
*/
@Parcelize
class SavedState(
/**
* Get the prefix of the saved file.
*
* @return the file prefix
*/
val prefixFileSaved: String,
/**
* Get the path to the saved file.
*
* @return the path to the saved file
*/
val pathFileSaved: String
) : Parcelable {
class SavedState(val prefixFileSaved: String, val pathFileSaved: String) : Parcelable {
override fun toString() = "$prefixFileSaved > $pathFileSaved"
}
88 changes: 31 additions & 57 deletions app/src/main/java/org/schabi/newpipe/util/ServiceHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,52 +32,31 @@ private ServiceHelper() { }

@DrawableRes
public static int getIcon(final int serviceId) {
switch (serviceId) {
case 0:
return R.drawable.ic_smart_display;
case 1:
return R.drawable.ic_cloud;
case 2:
return R.drawable.ic_placeholder_media_ccc;
case 3:
return R.drawable.ic_placeholder_peertube;
case 4:
return R.drawable.ic_placeholder_bandcamp;
default:
return R.drawable.ic_circle;
}
return switch (serviceId) {
case 0 -> R.drawable.ic_smart_display;
case 1 -> R.drawable.ic_cloud;
case 2 -> R.drawable.ic_placeholder_media_ccc;
case 3 -> R.drawable.ic_placeholder_peertube;
case 4 -> R.drawable.ic_placeholder_bandcamp;
default -> R.drawable.ic_circle;
};
}

public static String getTranslatedFilterString(final String filter, final Context c) {
switch (filter) {
case "all":
return c.getString(R.string.all);
case "videos":
case "sepia_videos":
case "music_videos":
return c.getString(R.string.videos_string);
case "channels":
return c.getString(R.string.channels);
case "playlists":
case "music_playlists":
return c.getString(R.string.playlists);
case "tracks":
return c.getString(R.string.tracks);
case "users":
return c.getString(R.string.users);
case "conferences":
return c.getString(R.string.conferences);
case "events":
return c.getString(R.string.events);
case "music_songs":
return c.getString(R.string.songs);
case "music_albums":
return c.getString(R.string.albums);
case "music_artists":
return c.getString(R.string.artists);
default:
return filter;
}
return switch (filter) {
case "all" -> c.getString(R.string.all);
case "videos", "sepia_videos", "music_videos" -> c.getString(R.string.videos_string);
case "channels" -> c.getString(R.string.channels);
case "playlists", "music_playlists" -> c.getString(R.string.playlists);
case "tracks" -> c.getString(R.string.tracks);
case "users" -> c.getString(R.string.users);
case "conferences" -> c.getString(R.string.conferences);
case "events" -> c.getString(R.string.events);
case "music_songs" -> c.getString(R.string.songs);
case "music_albums" -> c.getString(R.string.albums);
case "music_artists" -> c.getString(R.string.artists);
default -> filter;
};
}

/**
Expand All @@ -88,14 +67,11 @@ public static String getTranslatedFilterString(final String filter, final Contex
*/
@StringRes
public static int getImportInstructions(final int serviceId) {
switch (serviceId) {
case 0:
return R.string.import_youtube_instructions;
case 1:
return R.string.import_soundcloud_instructions;
default:
return -1;
}
return switch (serviceId) {
case 0 -> R.string.import_youtube_instructions;
case 1 -> R.string.import_soundcloud_instructions;
default -> -1;
};
}

/**
Expand All @@ -107,12 +83,10 @@ public static int getImportInstructions(final int serviceId) {
*/
@StringRes
public static int getImportInstructionsHint(final int serviceId) {
switch (serviceId) {
case 1:
return R.string.import_soundcloud_instructions_hint;
default:
return -1;
}
return switch (serviceId) {
case 1 -> R.string.import_soundcloud_instructions_hint;
default -> -1;
};
}

public static int getSelectedServiceId(final Context context) {
Expand Down