|
1 | 1 | package org.schabi.newpipe.fragments; |
2 | 2 |
|
3 | 3 | import android.content.Context; |
| 4 | +import android.content.res.ColorStateList; |
4 | 5 | import android.os.Bundle; |
5 | 6 | import android.util.Log; |
6 | 7 | import android.util.TypedValue; |
|
15 | 16 | import androidx.annotation.NonNull; |
16 | 17 | import androidx.annotation.Nullable; |
17 | 18 | import androidx.appcompat.app.ActionBar; |
| 19 | +import androidx.core.content.ContextCompat; |
18 | 20 | import androidx.fragment.app.Fragment; |
19 | 21 | import androidx.fragment.app.FragmentManager; |
20 | 22 | import androidx.fragment.app.FragmentStatePagerAdapterMenuWorkaround; |
@@ -208,20 +210,28 @@ private void updateTabsPosition() { |
208 | 210 | pagerParams.removeRule(RelativeLayout.BELOW); |
209 | 211 | pagerParams.addRule(RelativeLayout.ABOVE, R.id.main_tab_layout); |
210 | 212 | tabLayout.setSelectedTabIndicatorGravity(TabLayout.INDICATOR_GRAVITY_TOP); |
211 | | - final TypedValue typedValue = new TypedValue(); |
212 | | - getContext().getTheme().resolveAttribute(R.attr.colorPrimary, typedValue, |
| 213 | + final TypedValue typedValueBackground = new TypedValue(); |
| 214 | + getContext().getTheme().resolveAttribute(R.attr.colorSecondary, typedValueBackground, |
213 | 215 | true); |
214 | | - getActivity().getWindow().setNavigationBarColor(typedValue.data); |
| 216 | + tabLayout.setBackgroundColor(typedValueBackground.data); |
| 217 | + tabLayout.setTabRippleColor(ColorStateList.valueOf( |
| 218 | + getResources().getColor(R.color.gray))); |
| 219 | + tabLayout.setTabIconTint(ColorStateList.valueOf(getResources().getColor(R.color.gray))); |
| 220 | + tabLayout.setSelectedTabIndicatorColor(getResources().getColor(R.color.gray)); |
215 | 221 | } else { |
216 | 222 | tabParams.removeRule(RelativeLayout.ALIGN_PARENT_BOTTOM); |
217 | 223 | tabParams.addRule(RelativeLayout.ALIGN_PARENT_TOP); |
218 | 224 | pagerParams.removeRule(RelativeLayout.ABOVE); |
219 | 225 | pagerParams.addRule(RelativeLayout.BELOW, R.id.main_tab_layout); |
220 | 226 | tabLayout.setSelectedTabIndicatorGravity(TabLayout.INDICATOR_GRAVITY_BOTTOM); |
221 | 227 | final TypedValue typedValue = new TypedValue(); |
222 | | - getContext().getTheme().resolveAttribute(R.attr.colorSecondary, typedValue, |
| 228 | + getContext().getTheme().resolveAttribute(R.attr.colorPrimary, typedValue, |
223 | 229 | true); |
224 | | - getActivity().getWindow().setNavigationBarColor(typedValue.data); |
| 230 | + tabLayout.setBackgroundColor(typedValue.data); |
| 231 | + tabLayout.setTabRippleColor(binding.mainTabLayout.getTabRippleColor().withAlpha(32)); |
| 232 | + tabLayout.setTabIconTint(binding.mainTabLayout.getTabIconTint()); |
| 233 | + tabLayout.setSelectedTabIndicatorColor(ContextCompat |
| 234 | + .getColor(requireContext(), R.color.white)); |
225 | 235 | } |
226 | 236 | tabLayout.setLayoutParams(tabParams); |
227 | 237 | viewPager.setLayoutParams(pagerParams); |
|
0 commit comments