From 38db0cc713e2d22770556fc5ac31cdf736053fce Mon Sep 17 00:00:00 2001 From: ge78fug Date: Tue, 31 Jan 2023 16:07:57 +0100 Subject: [PATCH] Changed the color --- .../newpipe/fragments/MainFragment.java | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) 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 66b2f57b3..4a702e0dc 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java @@ -1,6 +1,7 @@ package org.schabi.newpipe.fragments; import android.content.Context; +import android.content.res.ColorStateList; import android.os.Bundle; import android.util.Log; import android.util.TypedValue; @@ -15,6 +16,7 @@ import android.widget.RelativeLayout; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; +import androidx.core.content.ContextCompat; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentStatePagerAdapterMenuWorkaround; @@ -208,10 +210,14 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte 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, + final TypedValue typedValueBackground = new TypedValue(); + getContext().getTheme().resolveAttribute(R.attr.colorSecondary, typedValueBackground, true); - getActivity().getWindow().setNavigationBarColor(typedValue.data); + tabLayout.setBackgroundColor(typedValueBackground.data); + tabLayout.setTabRippleColor(ColorStateList.valueOf( + getResources().getColor(R.color.gray))); + tabLayout.setTabIconTint(ColorStateList.valueOf(getResources().getColor(R.color.gray))); + tabLayout.setSelectedTabIndicatorColor(getResources().getColor(R.color.gray)); } else { tabParams.removeRule(RelativeLayout.ALIGN_PARENT_BOTTOM); tabParams.addRule(RelativeLayout.ALIGN_PARENT_TOP); @@ -219,9 +225,13 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte 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, + getContext().getTheme().resolveAttribute(R.attr.colorPrimary, typedValue, true); - getActivity().getWindow().setNavigationBarColor(typedValue.data); + tabLayout.setBackgroundColor(typedValue.data); + tabLayout.setTabRippleColor(binding.mainTabLayout.getTabRippleColor().withAlpha(32)); + tabLayout.setTabIconTint(binding.mainTabLayout.getTabIconTint()); + tabLayout.setSelectedTabIndicatorColor(ContextCompat + .getColor(requireContext(), R.color.white)); } tabLayout.setLayoutParams(tabParams); viewPager.setLayoutParams(pagerParams);