Fixed bottom bar sometimes disappearing from itself after changing the theme.

This commit is contained in:
Karim Abou Zeid 2015-08-16 20:36:05 +02:00
commit bd89289a1f
4 changed files with 35 additions and 16 deletions

View file

@ -28,12 +28,15 @@
<h3>Version 0.9.43 beta2</h3> <h3>Version 0.9.43 beta2</h3>
<ol> <ol>
<li><b>FIX:</b> Playlist view wrong background color on dark theme. <li><b>FIX:</b> Playlist view having wrong background color on dark theme.
</li> </li>
<li><b>FIX:</b> Progress slider barely visible with dark theme and black accent or light theme <li><b>FIX:</b> Bottom bar sometimes disappearing from itself after changing the theme.
</li>
<li><b>FIX:</b> Progress slider being barely visible with dark theme and black accent or light
theme
and white accent. and white accent.
</li> </li>
<li><b>FIX:</b> Progress slider stops working when switching between alternative and regular <li><b>FIX:</b> Progress slider stopped working when switching between alternative and regular
progress slider. progress slider.
</li> </li>
<li><b>FIX:</b> Removed the unneeded menu button from the artist and album list. <li><b>FIX:</b> Removed the unneeded menu button from the artist and album list.

View file

@ -161,7 +161,6 @@ public class MusicPlayerRemote {
return -1; return -1;
} }
@Nullable
public static ArrayList<Song> getPlayingQueue() { public static ArrayList<Song> getPlayingQueue() {
if (musicService != null) { if (musicService != null) {
return musicService.getPlayingQueue(); return musicService.getPlayingQueue();

View file

@ -262,8 +262,8 @@ public class MainActivity extends AbsSlidingMusicPanelActivity
} }
private void updateNavigationDrawerHeader() { private void updateNavigationDrawerHeader() {
Song song = MusicPlayerRemote.getCurrentSong(); if (!MusicPlayerRemote.getPlayingQueue().isEmpty()) {
if (song.id != -1) { Song song = MusicPlayerRemote.getCurrentSong();
if (navigationDrawerHeader == null) { if (navigationDrawerHeader == null) {
navigationDrawerHeader = navigationView.inflateHeaderView(R.layout.navigation_drawer_header); navigationDrawerHeader = navigationView.inflateHeaderView(R.layout.navigation_drawer_header);
//noinspection ConstantConditions //noinspection ConstantConditions

View file

@ -2,6 +2,7 @@ package com.kabouzeid.gramophone.ui.activities.base;
import android.animation.Animator; import android.animation.Animator;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.ComponentName;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.res.ColorStateList; import android.content.res.ColorStateList;
@ -11,6 +12,7 @@ import android.graphics.PorterDuff;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.IBinder;
import android.os.Message; import android.os.Message;
import android.support.annotation.ColorInt; import android.support.annotation.ColorInt;
import android.support.annotation.LayoutRes; import android.support.annotation.LayoutRes;
@ -185,11 +187,6 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivi
onPanelSlide(slidingUpPanelLayout, 1); onPanelSlide(slidingUpPanelLayout, 1);
onPanelExpanded(slidingUpPanelLayout); onPanelExpanded(slidingUpPanelLayout);
} }
// ensures that the fab and the mini player are hidden if the queue is empty
if (MusicPlayerRemote.getCurrentSong().id == -1) {
playPauseFab.setVisibility(View.GONE);
hideBottomBar(true);
}
} }
}); });
} }
@ -220,6 +217,12 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivi
updateCurrentSong(); updateCurrentSong();
} }
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
hideBottomBarIfQueueIsEmpty();
super.onServiceConnected(name, service);
}
@Override @Override
public void onRepeatModeChanged() { public void onRepeatModeChanged() {
super.onRepeatModeChanged(); super.onRepeatModeChanged();
@ -433,9 +436,19 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivi
public void hideBottomBar(boolean hide) { public void hideBottomBar(boolean hide) {
if (hide) { if (hide) {
slidingUpPanelLayout.setPanelHeight(0); slidingUpPanelLayout.post(new Runnable() {
@Override
public void run() {
slidingUpPanelLayout.setPanelHeight(0);
}
});
} else { } else {
slidingUpPanelLayout.setPanelHeight(getResources().getDimensionPixelSize(R.dimen.mini_player_height)); slidingUpPanelLayout.post(new Runnable() {
@Override
public void run() {
slidingUpPanelLayout.setPanelHeight(getResources().getDimensionPixelSize(R.dimen.mini_player_height));
}
});
} }
} }
@ -710,15 +723,15 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivi
} }
private void updateCurrentSong() { private void updateCurrentSong() {
hideBottomBarIfQueueIsEmpty();
getCurrentSong(); getCurrentSong();
updateMiniPlayerAndHeaderText(); updateMiniPlayerAndHeaderText();
setUpAlbumArtAndApplyPalette(); setUpAlbumArtAndApplyPalette();
updatePlayerMenu(); updatePlayerMenu();
} }
private void getCurrentSong() { private void hideBottomBarIfQueueIsEmpty() {
song = MusicPlayerRemote.getCurrentSong(); if (MusicPlayerRemote.getPlayingQueue().isEmpty()) {
if (song.id == -1) {
playPauseFab.setVisibility(View.GONE); playPauseFab.setVisibility(View.GONE);
hideBottomBar(true); hideBottomBar(true);
} else { } else {
@ -727,6 +740,10 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivi
} }
} }
private void getCurrentSong() {
song = MusicPlayerRemote.getCurrentSong();
}
private void updateMiniPlayerAndHeaderText() { private void updateMiniPlayerAndHeaderText() {
songTitle.setText(song.title); songTitle.setText(song.title);
songText.setText(song.artistName); songText.setText(song.artistName);