diff --git a/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsMain.java b/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsMain.java
index 24eaa5aab..cd18e8c42 100644
--- a/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsMain.java
+++ b/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsMain.java
@@ -57,7 +57,6 @@ public class ContentSettingsMain extends Fragment {
tabNames();
initUsedTabs();
- initAddButton(rootView);
usedTabsView = rootView.findViewById(R.id.usedTabs);
usedTabsView.setLayoutManager(new LinearLayoutManager(getContext()));
@@ -80,7 +79,6 @@ public class ContentSettingsMain extends Fragment {
save.append("\n");
}
}
-
saveString = save.toString();
}
@@ -100,18 +98,6 @@ public class ContentSettingsMain extends Fragment {
usedTabs.addAll(Arrays.asList(tabs));
}
- private void initAddButton(View rootView) {
- Button addButton = rootView.findViewById(R.id.buttonAdd);
- addButton.setBackgroundResource(ThemeHelper.getIconByAttr(R.attr.ic_add, getActivity()));
- addButton.setOnClickListener(v -> {
- ContentSettingsMainDialog contentSettingsMainDialog = new ContentSettingsMainDialog();
- contentSettingsMainDialog.setOnAddListener((int position) -> {
- addTab(position);
- });
- contentSettingsMainDialog.show(getFragmentManager(), "select_channel");
- });
- }
-
private void tabNames() {
allTabs[0] = getString(R.string.blank_page_summary);
allTabs[1] = getString(R.string.kiosk_page_summary);
@@ -143,6 +129,10 @@ public class ContentSettingsMain extends Fragment {
// ... code from gist
@Override
public void onItemDismiss(int position) {
+ if(position==getItemCount() - 1) {
+ notifyDataSetChanged();
+ return;
+ }
usedTabs.remove(position);
notifyItemRemoved(position);
saveChanges();
@@ -150,6 +140,7 @@ public class ContentSettingsMain extends Fragment {
@Override
public void onItemMove(int fromPosition, int toPosition) {
+ if(fromPosition==getItemCount() - 1 || toPosition==getItemCount() - 1) return;
if (fromPosition < toPosition) {
for (int i = fromPosition; i < toPosition; i++) {
Collections.swap(usedTabs, i, i + 1);
@@ -178,21 +169,31 @@ public class ContentSettingsMain extends Fragment {
@Override
public int getItemCount() {
- return usedTabs.size();
+ return usedTabs.size() + 1;
}
class TabViewHolder extends RecyclerView.ViewHolder {
TextView text;
+ View view;
public TabViewHolder(View itemView) {
super(itemView);
text = itemView.findViewById(R.id.tabName);
+ view = itemView;
}
void bind(int position) {
- if(usedTabs.get(position).startsWith("6\t")) {
+ if(position == getItemCount() - 1) {
+ String newTabString = "+ " + getString(R.string.tab_new);
+ text.setText(newTabString);
+ view.setOnClickListener(v -> {
+ ContentSettingsMainDialog contentSettingsMainDialog = new ContentSettingsMainDialog();
+ contentSettingsMainDialog.setOnAddListener(ContentSettingsMain.this::addTab);
+ contentSettingsMainDialog.show(getFragmentManager(), "select_channel");
+ });
+ } else if(usedTabs.get(position).startsWith("6\t")) {
String channelInfo[] = usedTabs.get(position).split("\t");
String channelName = "";
if(channelInfo.length==4) channelName = channelInfo[2];
@@ -273,6 +274,7 @@ public class ContentSettingsMain extends Fragment {
@Override
public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
mAdapter.onItemDismiss(viewHolder.getAdapterPosition());
+
}
}
diff --git a/app/src/main/res/layout/dialog_contentsettings.xml b/app/src/main/res/layout/dialog_contentsettings.xml
index 7e62c7eba..6b6bfc023 100644
--- a/app/src/main/res/layout/dialog_contentsettings.xml
+++ b/app/src/main/res/layout/dialog_contentsettings.xml
@@ -4,50 +4,10 @@
android:layout_height="match_parent"
android:orientation="vertical">
-
-
-
-
-
-
-
-
-
-
-
-
+ android:layout_margin="0dp" />
\ No newline at end of file
diff --git a/app/src/main/res/layout/dialog_contentsettingsadd.xml b/app/src/main/res/layout/dialog_contentsettingsadd.xml
index 1c1e7a166..fd5365522 100644
--- a/app/src/main/res/layout/dialog_contentsettingsadd.xml
+++ b/app/src/main/res/layout/dialog_contentsettingsadd.xml
@@ -2,12 +2,27 @@
+ android:orientation="vertical"
+ android:padding="13dp">
+
+
+ android:layout_below="@+id/titleTextView"
+ android:layout_centerHorizontal="true" />
-
\ No newline at end of file
+
diff --git a/app/src/main/res/layout/dialog_contentsettingtab.xml b/app/src/main/res/layout/dialog_contentsettingtab.xml
index 8b2121759..9f503c0f7 100644
--- a/app/src/main/res/layout/dialog_contentsettingtab.xml
+++ b/app/src/main/res/layout/dialog_contentsettingtab.xml
@@ -1,5 +1,6 @@
Main
Subscriptions
Bookmarks
+ New Tab
+ Chose Tab
What\'s New