1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-11-05 17:46:24 +00:00

Made the requested color changes

This commit is contained in:
ge78fug 2023-02-07 18:46:40 +01:00
parent 38db0cc713
commit 26b29ca78d

View File

@ -4,7 +4,6 @@ import android.content.Context;
import android.content.res.ColorStateList; import android.content.res.ColorStateList;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log; import android.util.Log;
import android.util.TypedValue;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
@ -34,6 +33,7 @@ import org.schabi.newpipe.settings.tabs.Tab;
import org.schabi.newpipe.settings.tabs.TabsManager; import org.schabi.newpipe.settings.tabs.TabsManager;
import org.schabi.newpipe.util.NavigationHelper; import org.schabi.newpipe.util.NavigationHelper;
import org.schabi.newpipe.util.ServiceHelper; import org.schabi.newpipe.util.ServiceHelper;
import org.schabi.newpipe.util.ThemeHelper;
import org.schabi.newpipe.views.ScrollableTabLayout; import org.schabi.newpipe.views.ScrollableTabLayout;
import java.util.ArrayList; import java.util.ArrayList;
@ -210,26 +210,25 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte
pagerParams.removeRule(RelativeLayout.BELOW); pagerParams.removeRule(RelativeLayout.BELOW);
pagerParams.addRule(RelativeLayout.ABOVE, R.id.main_tab_layout); pagerParams.addRule(RelativeLayout.ABOVE, R.id.main_tab_layout);
tabLayout.setSelectedTabIndicatorGravity(TabLayout.INDICATOR_GRAVITY_TOP); tabLayout.setSelectedTabIndicatorGravity(TabLayout.INDICATOR_GRAVITY_TOP);
final TypedValue typedValueBackground = new TypedValue(); tabLayout.setBackgroundColor(ThemeHelper
getContext().getTheme().resolveAttribute(R.attr.colorSecondary, typedValueBackground, .resolveColorFromAttr(requireContext(), R.attr.colorSecondary));
true); final int colorAccent = ThemeHelper.resolveColorFromAttr(
tabLayout.setBackgroundColor(typedValueBackground.data); requireContext(), R.attr.colorAccent);
tabLayout.setTabRippleColor(ColorStateList.valueOf( tabLayout.setTabRippleColor(ColorStateList.valueOf(colorAccent).withAlpha(32));
getResources().getColor(R.color.gray))); tabLayout.setTabIconTint(ColorStateList.valueOf(colorAccent));
tabLayout.setTabIconTint(ColorStateList.valueOf(getResources().getColor(R.color.gray))); tabLayout.setSelectedTabIndicatorColor(colorAccent);
tabLayout.setSelectedTabIndicatorColor(getResources().getColor(R.color.gray));
} else { } else {
tabParams.removeRule(RelativeLayout.ALIGN_PARENT_BOTTOM); tabParams.removeRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
tabParams.addRule(RelativeLayout.ALIGN_PARENT_TOP); tabParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
pagerParams.removeRule(RelativeLayout.ABOVE); pagerParams.removeRule(RelativeLayout.ABOVE);
pagerParams.addRule(RelativeLayout.BELOW, R.id.main_tab_layout); pagerParams.addRule(RelativeLayout.BELOW, R.id.main_tab_layout);
tabLayout.setSelectedTabIndicatorGravity(TabLayout.INDICATOR_GRAVITY_BOTTOM); tabLayout.setSelectedTabIndicatorGravity(TabLayout.INDICATOR_GRAVITY_BOTTOM);
final TypedValue typedValue = new TypedValue(); tabLayout.setBackgroundColor(ThemeHelper
getContext().getTheme().resolveAttribute(R.attr.colorPrimary, typedValue, .resolveColorFromAttr(requireContext(), R.attr.colorPrimary));
true); tabLayout.setTabRippleColor(ColorStateList.valueOf(
tabLayout.setBackgroundColor(typedValue.data); getResources().getColor(R.color.white)).withAlpha(32));
tabLayout.setTabRippleColor(binding.mainTabLayout.getTabRippleColor().withAlpha(32)); tabLayout.setTabIconTint(ColorStateList.valueOf(
tabLayout.setTabIconTint(binding.mainTabLayout.getTabIconTint()); getResources().getColor(R.color.white)));
tabLayout.setSelectedTabIndicatorColor(ContextCompat tabLayout.setSelectedTabIndicatorColor(ContextCompat
.getColor(requireContext(), R.color.white)); .getColor(requireContext(), R.color.white));
} }