mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2025-10-22 19:07:39 +00:00
# Change
Added FEEDGROUP Tab Code to - ChooseTabsFragment - Tab Added strings: - feed_group_page_summary
This commit is contained in:
@@ -34,6 +34,7 @@ import org.schabi.newpipe.error.UserAction;
|
|||||||
import org.schabi.newpipe.settings.SelectChannelFragment;
|
import org.schabi.newpipe.settings.SelectChannelFragment;
|
||||||
import org.schabi.newpipe.settings.SelectKioskFragment;
|
import org.schabi.newpipe.settings.SelectKioskFragment;
|
||||||
import org.schabi.newpipe.settings.SelectPlaylistFragment;
|
import org.schabi.newpipe.settings.SelectPlaylistFragment;
|
||||||
|
import org.schabi.newpipe.settings.SelectFeedGroupFragment;
|
||||||
import org.schabi.newpipe.settings.tabs.AddTabDialog.ChooseTabListItem;
|
import org.schabi.newpipe.settings.tabs.AddTabDialog.ChooseTabListItem;
|
||||||
import org.schabi.newpipe.util.ThemeHelper;
|
import org.schabi.newpipe.util.ThemeHelper;
|
||||||
|
|
||||||
@@ -203,6 +204,14 @@ public class ChooseTabsFragment extends Fragment {
|
|||||||
});
|
});
|
||||||
selectPlaylistFragment.show(getParentFragmentManager(), "select_playlist");
|
selectPlaylistFragment.show(getParentFragmentManager(), "select_playlist");
|
||||||
return;
|
return;
|
||||||
|
case FEEDGROUP:
|
||||||
|
final SelectFeedGroupFragment selectFeedGroupFragment =
|
||||||
|
new SelectFeedGroupFragment();
|
||||||
|
selectFeedGroupFragment.setOnSelectedListener(
|
||||||
|
(groupId, name, iconId) ->
|
||||||
|
addTab(new Tab.FeedGroupTab(groupId, name, iconId)));
|
||||||
|
selectFeedGroupFragment.show(getParentFragmentManager(), "select_feed_group");
|
||||||
|
return;
|
||||||
default:
|
default:
|
||||||
addTab(type.getTab());
|
addTab(type.getTab());
|
||||||
break;
|
break;
|
||||||
@@ -244,6 +253,11 @@ public class ChooseTabsFragment extends Fragment {
|
|||||||
getString(R.string.playlist_page_summary),
|
getString(R.string.playlist_page_summary),
|
||||||
tab.getTabIconRes(context)));
|
tab.getTabIconRes(context)));
|
||||||
break;
|
break;
|
||||||
|
case FEEDGROUP:
|
||||||
|
returnList.add(new ChooseTabListItem(tab.getTabId(),
|
||||||
|
getString(R.string.feed_group_page_summary),
|
||||||
|
tab.getTabIconRes(context)));
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
if (!tabList.contains(tab)) {
|
if (!tabList.contains(tab)) {
|
||||||
returnList.add(new ChooseTabListItem(context, tab));
|
returnList.add(new ChooseTabListItem(context, tab));
|
||||||
@@ -396,6 +410,9 @@ public class ChooseTabsFragment extends Fragment {
|
|||||||
? getString(R.string.local)
|
? getString(R.string.local)
|
||||||
: getNameOfServiceById(serviceId);
|
: getNameOfServiceById(serviceId);
|
||||||
return serviceName + "/" + tab.getTabName(requireContext());
|
return serviceName + "/" + tab.getTabName(requireContext());
|
||||||
|
case FEEDGROUP:
|
||||||
|
return getString(R.string.feed_groups_header_title)
|
||||||
|
+ "/" + tab.getTabName(requireContext());
|
||||||
default:
|
default:
|
||||||
return tab.getTabName(requireContext());
|
return tab.getTabName(requireContext());
|
||||||
}
|
}
|
||||||
|
@@ -93,6 +93,8 @@ public abstract class Tab {
|
|||||||
return new ChannelTab(jsonObject);
|
return new ChannelTab(jsonObject);
|
||||||
case PLAYLIST:
|
case PLAYLIST:
|
||||||
return new PlaylistTab(jsonObject);
|
return new PlaylistTab(jsonObject);
|
||||||
|
case FEEDGROUP:
|
||||||
|
return new FeedGroupTab(jsonObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,7 +164,8 @@ public abstract class Tab {
|
|||||||
HISTORY(new HistoryTab()),
|
HISTORY(new HistoryTab()),
|
||||||
KIOSK(new KioskTab()),
|
KIOSK(new KioskTab()),
|
||||||
CHANNEL(new ChannelTab()),
|
CHANNEL(new ChannelTab()),
|
||||||
PLAYLIST(new PlaylistTab());
|
PLAYLIST(new PlaylistTab()),
|
||||||
|
FEEDGROUP(new FeedGroupTab());
|
||||||
|
|
||||||
private final Tab tab;
|
private final Tab tab;
|
||||||
|
|
||||||
@@ -652,4 +655,93 @@ public abstract class Tab {
|
|||||||
return playlistType;
|
return playlistType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public static class FeedGroupTab extends Tab {
|
||||||
|
public static final int ID = 9;
|
||||||
|
private static final String JSON_FEED_GROUP_ID_KEY = "feed_group_id";
|
||||||
|
private static final String JSON_FEED_GROUP_NAME_KEY = "feed_group_name";
|
||||||
|
private static final String JSON_FEED_GROUP_ICON_KEY = "feed_group_icon";
|
||||||
|
private Long feedGroupId;
|
||||||
|
private String feedGroupName;
|
||||||
|
private int iconId;
|
||||||
|
|
||||||
|
private FeedGroupTab() {
|
||||||
|
this((long) -1, NO_NAME, R.drawable.ic_asterisk);
|
||||||
|
}
|
||||||
|
|
||||||
|
public FeedGroupTab(final Long feedGroupId, final String feedGroupName,
|
||||||
|
final int iconId) {
|
||||||
|
this.feedGroupId = feedGroupId;
|
||||||
|
this.feedGroupName = feedGroupName;
|
||||||
|
this.iconId = iconId;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public FeedGroupTab(final JsonObject jsonObject) {
|
||||||
|
super(jsonObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getTabId() {
|
||||||
|
return ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTabName(final Context context) {
|
||||||
|
return feedGroupName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@DrawableRes
|
||||||
|
@Override
|
||||||
|
public int getTabIconRes(final Context context) {
|
||||||
|
return this.iconId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FeedFragment getFragment(final Context context) {
|
||||||
|
return FeedFragment.newInstance(feedGroupId, feedGroupName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void writeDataToJson(final JsonStringWriter writerSink) {
|
||||||
|
writerSink.value(JSON_FEED_GROUP_ID_KEY, feedGroupId)
|
||||||
|
.value(JSON_FEED_GROUP_NAME_KEY, feedGroupName)
|
||||||
|
.value(JSON_FEED_GROUP_ICON_KEY, iconId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void readDataFromJson(final JsonObject jsonObject) {
|
||||||
|
feedGroupId = jsonObject.getLong(JSON_FEED_GROUP_ID_KEY, -1);
|
||||||
|
feedGroupName = jsonObject.getString(JSON_FEED_GROUP_NAME_KEY, NO_NAME);
|
||||||
|
iconId = jsonObject.getInt(JSON_FEED_GROUP_ICON_KEY, R.drawable.ic_asterisk);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(final Object obj) {
|
||||||
|
if (!(obj instanceof FeedGroupTab)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
final FeedGroupTab other = (FeedGroupTab) obj;
|
||||||
|
return super.equals(obj)
|
||||||
|
&& feedGroupId.equals(other.feedGroupId)
|
||||||
|
&& feedGroupName.equals(other.feedGroupName)
|
||||||
|
&& iconId == other.iconId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(getTabId(), feedGroupId, feedGroupName, iconId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getFeedGroupId() {
|
||||||
|
return feedGroupId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFeedGroupName() {
|
||||||
|
return feedGroupName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getIconId() {
|
||||||
|
return iconId;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -689,6 +689,7 @@
|
|||||||
</plurals>
|
</plurals>
|
||||||
<!-- Feed -->
|
<!-- Feed -->
|
||||||
<string name="fragment_feed_title">What\'s New</string>
|
<string name="fragment_feed_title">What\'s New</string>
|
||||||
|
<string name="feed_group_page_summary">Channel group page</string>
|
||||||
<string name="feed_groups_header_title">Channel groups</string>
|
<string name="feed_groups_header_title">Channel groups</string>
|
||||||
<string name="feed_oldest_subscription_update">Feed last updated: %s</string>
|
<string name="feed_oldest_subscription_update">Feed last updated: %s</string>
|
||||||
<string name="feed_subscription_not_loaded_count">Not loaded: %d</string>
|
<string name="feed_subscription_not_loaded_count">Not loaded: %d</string>
|
||||||
|
Reference in New Issue
Block a user