2323import androidx .fragment .app .Fragment ;
2424import androidx .fragment .app .FragmentActivity ;
2525import androidx .lifecycle .ViewModelProvider ;
26+ import androidx .media3 .common .Player ;
2627import androidx .transition .TransitionManager ;
2728import androidx .viewpager2 .adapter .FragmentStateAdapter ;
2829
30+ import com .google .android .material .shape .MaterialShapeDrawable ;
2931import com .google .android .material .transition .MaterialFadeThrough ;
3032
3133import com .xapps .media .xmusic .R ;
@@ -165,9 +167,6 @@ private void setupDimensions() {
165167 binding .bottomNavigation .getPaddingBottom ()
166168 + XUtils .getNavigationBarHeight (activity ));
167169
168-
169- binding .expandedPlayer .actionsContainer .setPadding (0 , 0 , 0 , XUtils .getNavigationBarHeight (activity ));
170-
171170 return Unit .INSTANCE ;
172171 });
173172
@@ -432,26 +431,6 @@ private void computeState() {
432431 }
433432 }
434433
435- private void resyncState () {
436- playerHidden =
437- (layoutState == LAYOUT_STATE_FULL
438- || layoutState == LAYOUT_STATE_EXPOSE_TABS
439- || layoutState == LAYOUT_STATE_EXPOSE_BNV
440- || layoutState == LAYOUT_STATE_EXPOSE_TABS_BNV );
441-
442- bnvHidden =
443- (layoutState == LAYOUT_STATE_FULL
444- || layoutState == LAYOUT_STATE_EXPOSE_TABS
445- || layoutState == LAYOUT_STATE_EXPOSE_PLAYER_ONLY
446- || layoutState == LAYOUT_STATE_EXPOSE_PLAYER_TABS );
447-
448- tabsHidden =
449- (layoutState == LAYOUT_STATE_FULL
450- || layoutState == LAYOUT_STATE_EXPOSE_BNV
451- || layoutState == LAYOUT_STATE_EXPOSE_PLAYER
452- || layoutState == LAYOUT_STATE_EXPOSE_PLAYER_ONLY );
453- }
454-
455434 private void hideBnvInternal (boolean hide , boolean animate ) {
456435 bnvHidden = hide ;
457436 if (animate ) {
@@ -669,7 +648,7 @@ public void updateColors() {
669648 GradientDrawable d3 =
670649 (GradientDrawable ) binding .expandedPlayer .songInfoText .getBackground ();
671650
672- GradientDrawable d = (GradientDrawable ) binding .expandedPlayer .actionsContainer .getBackground ();
651+ MaterialShapeDrawable d = (MaterialShapeDrawable ) binding .expandedPlayer .floatingToolbarLayout .getBackground ();
673652
674653 XSeekbar seekbar = binding .expandedPlayer .songSeekbar ;
675654
@@ -685,8 +664,7 @@ public void updateColors() {
685664 int is = XUtils .interpolateColor (oldSurface , surface , f );
686665 int isc = XUtils .interpolateColor (oldSurfaceContainer , surfaceContainer , f );
687666 int io = XUtils .interpolateColor (oldOutline , outline , f );
688- int iosc =
689- XUtils .interpolateColor (oldOnSurfaceContainer , onSurfaceContainer , f );
667+ int iosc = XUtils .interpolateColor (oldOnSurfaceContainer , onSurfaceContainer , f );
690668 int ios = XUtils .interpolateColor (oldOnSurface , onSurface , f );
691669
692670 LiveColors .primary = ip ;
@@ -728,11 +706,14 @@ public void updateColors() {
728706 binding .collapsedPlayer .action .setBackgroundColor (ip );
729707 binding .collapsedPlayer .action .setRippleColor (ColorStateList .valueOf (ColorUtils .setAlphaComponent (io , 100 )));
730708
731- d .setColor ( isc );
709+ d .setFillColor ( ColorStateList . valueOf ( isc ) );
732710
733711 binding .expandedPlayer .lyricsButton .setIconTint (ColorStateList .valueOf (isOledTheme ? 0xffbdbdbd : iosc ));
734712 binding .expandedPlayer .lyricsButton .setRippleColor (ColorStateList .valueOf (io ));
735713
714+ binding .expandedPlayer .repeatModeButton .setIconTint (ColorStateList .valueOf (isOledTheme ? 0xffbdbdbd : iosc ));
715+ binding .expandedPlayer .repeatModeButton .setRippleColor (ColorStateList .valueOf (io ));
716+
736717 binding .expandedPlayer .artistBigTitle .setTextColor (iosc );
737718 binding .expandedPlayer .songBigTitle .setTextColor (ios );
738719
@@ -743,22 +724,21 @@ public void updateColors() {
743724 binding .expandedPlayer .totalDurationText .setTextColor (iosc );
744725 binding .expandedPlayer .songInfoText .setTextColor (iosc );
745726 });
746- va .addListener (
747- new AnimatorListenerAdapter () {
748- private boolean canceled ;
727+ va .addListener (new AnimatorListenerAdapter () {
728+ private boolean canceled ;
749729
750- @ Override
751- public void onAnimationCancel (Animator animation ) {
730+ @ Override
731+ public void onAnimationCancel (Animator animation ) {
752732 canceled = true ;
753733 }
754734
755- @ Override
756- public void onAnimationEnd (Animator animation ) {
757- if (!canceled ) {
735+ @ Override
736+ public void onAnimationEnd (Animator animation ) {
737+ if (!canceled ) {
758738 effectiveOldColors = new HashMap <>(colors );
759- }
760- }
761- });
739+ }
740+ }
741+ });
762742 if (colorAnimator != null ) {
763743 colorAnimator .cancel ();
764744 }
@@ -933,6 +913,7 @@ public void restoreCoverExpansion() {
933913 }
934914
935915 public void maybeRestoreUIState () {
916+ restoreRepeatButton ();
936917 if (viewModel .isDataSaved ()) {
937918 int savedState = viewModel .getLayoutState ();
938919
@@ -1000,6 +981,27 @@ public void maybeRestoreUIState() {
1000981 }
1001982 }
1002983
984+ private void restoreRepeatButton () {
985+ if (activity == null || activity .getController () == null ) return ;
986+ switch (activity .getController ().getRepeatMode ()) {
987+ case Player .REPEAT_MODE_ALL -> {
988+ binding .expandedPlayer .repeatModeButton .setIconResource (R .drawable .ic_repeat );
989+ binding .expandedPlayer .repeatModeButton .setChecked (true );
990+ }
991+ case Player .REPEAT_MODE_ONE -> {
992+ binding .expandedPlayer .repeatModeButton .setIconResource (R .drawable .ic_repeat_one );
993+ binding .expandedPlayer .repeatModeButton .setChecked (true );
994+ }
995+ case Player .REPEAT_MODE_OFF -> {
996+ binding .expandedPlayer .repeatModeButton .setIconResource (R .drawable .ic_repeat_off );
997+ binding .expandedPlayer .repeatModeButton .setChecked (false );
998+ }
999+ default -> {
1000+ throw new IllegalStateException ("Player repeat mode:" + String .valueOf (activity .getController ().getRepeatMode ()) + " not handled" );
1001+ }
1002+ }
1003+ }
1004+
10031005 public void saveState () {
10041006 viewModel .setLastPosition (activity .getController ().getCurrentMediaItemIndex ());
10051007 computeState ();
@@ -1012,7 +1014,7 @@ public void loadLyrics(String path) {
10121014 LyricsExtractor .extract (path , lyrics -> {
10131015 if (lyrics != null && !lyrics .isEmpty ()) {
10141016 LyricsParser .parse (lyrics , result -> {
1015- binding .xlyricsView .post (() -> {
1017+ binding .lyricsView .post (() -> {
10161018 binding .lyricsView .setLyrics (result .lines ());
10171019 binding .lyricsView .setListener (UIManager .this );
10181020
@@ -1045,7 +1047,6 @@ public void loadSettings() {
10451047 if (isOledTheme ) binding .gradientView .setVisibility (View .GONE );
10461048 isBlurOn = DataManager .isBlurOn ();
10471049 if (XUtils .areBlursOrDynamicColorsSupported () && !isBlurOn ) binding .Coordinator .setRenderEffect (null );
1048- binding .xlyricsView .updateActiveStates ();
10491050 updateFontConfig ();
10501051 }
10511052
0 commit comments