diff --git a/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java
index de68269e9..66b2f57b3 100644
--- a/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java
+++ b/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java
@@ -3,12 +3,14 @@ package org.schabi.newpipe.fragments;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
+import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.RelativeLayout;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -17,6 +19,7 @@ import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapterMenuWorkaround;
import androidx.preference.PreferenceManager;
+import androidx.viewpager.widget.ViewPager;
import com.google.android.material.tabs.TabLayout;
@@ -29,6 +32,7 @@ import org.schabi.newpipe.settings.tabs.Tab;
import org.schabi.newpipe.settings.tabs.TabsManager;
import org.schabi.newpipe.util.NavigationHelper;
import org.schabi.newpipe.util.ServiceHelper;
+import org.schabi.newpipe.views.ScrollableTabLayout;
import java.util.ArrayList;
import java.util.List;
@@ -106,6 +110,7 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte
} else if (hasTabsChanged) {
setupTabs();
}
+ updateTabsPosition();
}
@Override
@@ -189,6 +194,38 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte
private void updateTitleForTab(final int tabPosition) {
setTitle(tabsList.get(tabPosition).getTabName(requireContext()));
}
+ private void updateTabsPosition() {
+ final ScrollableTabLayout tabLayout = binding.mainTabLayout;
+ final ViewPager viewPager = binding.pager;
+ final RelativeLayout.LayoutParams tabParams = (RelativeLayout.LayoutParams)
+ tabLayout.getLayoutParams();
+ final RelativeLayout.LayoutParams pagerParams = (RelativeLayout.LayoutParams)
+ viewPager.getLayoutParams();
+ if (PreferenceManager.getDefaultSharedPreferences(requireContext())
+ .getBoolean(getString(R.string.main_tabs_position_key), false)) {
+ tabParams.removeRule(RelativeLayout.ALIGN_PARENT_TOP);
+ tabParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
+ pagerParams.removeRule(RelativeLayout.BELOW);
+ pagerParams.addRule(RelativeLayout.ABOVE, R.id.main_tab_layout);
+ tabLayout.setSelectedTabIndicatorGravity(TabLayout.INDICATOR_GRAVITY_TOP);
+ final TypedValue typedValue = new TypedValue();
+ getContext().getTheme().resolveAttribute(R.attr.colorPrimary, typedValue,
+ true);
+ getActivity().getWindow().setNavigationBarColor(typedValue.data);
+ } else {
+ tabParams.removeRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
+ tabParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
+ pagerParams.removeRule(RelativeLayout.ABOVE);
+ pagerParams.addRule(RelativeLayout.BELOW, R.id.main_tab_layout);
+ tabLayout.setSelectedTabIndicatorGravity(TabLayout.INDICATOR_GRAVITY_BOTTOM);
+ final TypedValue typedValue = new TypedValue();
+ getContext().getTheme().resolveAttribute(R.attr.colorSecondary, typedValue,
+ true);
+ getActivity().getWindow().setNavigationBarColor(typedValue.data);
+ }
+ tabLayout.setLayoutParams(tabParams);
+ viewPager.setLayoutParams(pagerParams);
+ }
@Override
public void onTabSelected(final TabLayout.Tab selectedTab) {
diff --git a/app/src/main/res/values/settings_keys.xml b/app/src/main/res/values/settings_keys.xml
index 126818969..bbd46f7e1 100644
--- a/app/src/main/res/values/settings_keys.xml
+++ b/app/src/main/res/values/settings_keys.xml
@@ -241,6 +241,9 @@
caption_settings_key
caption_user_set_key
+
+ main_tabs_position
+
show_search_suggestions
show_local_search_suggestions
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 5a4ce92f2..654f01e1e 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -213,6 +213,8 @@
Delete entire search history?
Search history deleted
Fast mode
+ Change the position of the main tabs
+ Main Tabs Position
Error
External storage unavailable
diff --git a/app/src/main/res/xml/appearance_settings.xml b/app/src/main/res/xml/appearance_settings.xml
index d726e26b7..beb46cdf5 100644
--- a/app/src/main/res/xml/appearance_settings.xml
+++ b/app/src/main/res/xml/appearance_settings.xml
@@ -66,4 +66,12 @@
app:singleLineTitle="false"
app:iconSpaceReserved="false" />
+
+