always color navigation bar
This commit is contained in:
parent
1f32f46bf0
commit
7018445009
6 changed files with 11 additions and 54 deletions
|
|
@ -3,7 +3,6 @@ package com.dkanada.gramophone.ui.activities.base;
|
|||
import android.animation.ArgbEvaluator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import androidx.annotation.ColorInt;
|
||||
|
|
@ -27,7 +26,6 @@ import com.dkanada.gramophone.ui.fragments.player.card.CardPlayerFragment;
|
|||
import com.dkanada.gramophone.ui.fragments.player.flat.FlatPlayerFragment;
|
||||
import com.dkanada.gramophone.util.PreferenceUtil;
|
||||
import com.dkanada.gramophone.util.ViewUtil;
|
||||
import com.kabouzeid.appthemehelper.ThemeStore;
|
||||
import com.sothree.slidinguppanel.SlidingUpPanelLayout;
|
||||
|
||||
public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivity implements SlidingUpPanelLayout.PanelSlideListener, CardPlayerFragment.Callbacks {
|
||||
|
|
@ -144,15 +142,7 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivi
|
|||
public void onPanelSlide(View panel, @FloatRange(from = 0, to = 1) float slideOffset) {
|
||||
setMiniPlayerAlphaProgress(slideOffset);
|
||||
if (navigationBarColorAnimator != null) navigationBarColorAnimator.cancel();
|
||||
int color = shiftNavbarColor(playerFragment.getPaletteColor());
|
||||
|
||||
if (ThemeStore.coloredNavigationBar(this)) {
|
||||
int navbarColor = ColorUtils.blendARGB(navigationbarColor, color, slideOffset);
|
||||
super.setNavigationbarColor(navbarColor);
|
||||
} else {
|
||||
int navbarColor = ColorUtils.blendARGB(Color.TRANSPARENT, color, slideOffset);
|
||||
super.setNavigationbarColor(navbarColor);
|
||||
}
|
||||
super.setNavigationbarColor(ColorUtils.blendARGB(navigationbarColor, playerFragment.getPaletteColor(), slideOffset));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -187,8 +177,7 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivi
|
|||
int playerFragmentColor = playerFragment.getPaletteColor();
|
||||
super.setLightStatusbar(false);
|
||||
super.setTaskDescriptionColor(playerFragmentColor);
|
||||
int color = shiftNavbarColor(playerFragmentColor);
|
||||
super.setNavigationbarColor(color);
|
||||
super.setNavigationbarColor(playerFragmentColor);
|
||||
|
||||
playerFragment.setMenuVisibility(true);
|
||||
playerFragment.setUserVisibleHint(true);
|
||||
|
|
@ -255,8 +244,7 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivi
|
|||
if (getPanelState() == SlidingUpPanelLayout.PanelState.EXPANDED) {
|
||||
int playerFragmentColor = playerFragment.getPaletteColor();
|
||||
super.setTaskDescriptionColor(playerFragmentColor);
|
||||
int color = shiftNavbarColor(playerFragmentColor);
|
||||
animateNavigationBarColor(color);
|
||||
animateNavigationBarColor(playerFragmentColor);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -308,28 +296,4 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivi
|
|||
protected View getSnackBarContainer() {
|
||||
return findViewById(R.id.content_container);
|
||||
}
|
||||
|
||||
/**
|
||||
* To improve contrast with the navbar controls
|
||||
*/
|
||||
private int shiftNavbarColor(int color) {
|
||||
double luminance = ColorUtils.calculateLuminance(color);
|
||||
|
||||
if (luminance > 0.7 || luminance < 0.3) {
|
||||
// The color is really dark or really light, the navbar is just fine
|
||||
return color;
|
||||
} else if (luminance > 0.5) {
|
||||
// The color is a bit lighter than the center, let's make it a bit lighter, so it's easier to see
|
||||
float[] hsv = new float[3];
|
||||
Color.colorToHSV(color, hsv);
|
||||
hsv[2] *= 1.3f;
|
||||
return Color.HSVToColor(hsv);
|
||||
} else {
|
||||
// The color is a bit darker than the center, let's make it a bit darker, so it's easier to see
|
||||
float[] hsv = new float[3];
|
||||
Color.colorToHSV(color, hsv);
|
||||
hsv[2] *= 0.7f;
|
||||
return Color.HSVToColor(hsv);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,11 +73,7 @@ public abstract class AbsThemeActivity extends ATHToolbarActivity {
|
|||
}
|
||||
|
||||
public void setNavigationbarColorAuto() {
|
||||
if (ThemeStore.coloredNavigationBar(this)) {
|
||||
setNavigationbarColor(ThemeStore.navigationBarColor(this));
|
||||
} else {
|
||||
setNavigationbarColor(Color.TRANSPARENT);
|
||||
}
|
||||
setNavigationbarColor(ThemeStore.navigationBarColor(this));
|
||||
}
|
||||
|
||||
public void setLightStatusbar(boolean enabled) {
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ import com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator;
|
|||
import com.h6ah4i.android.widget.advrecyclerview.animator.RefactoredDefaultItemAnimator;
|
||||
import com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager;
|
||||
import com.h6ah4i.android.widget.advrecyclerview.utils.WrapperAdapterUtils;
|
||||
import com.kabouzeid.appthemehelper.ATH;
|
||||
import com.kabouzeid.appthemehelper.ThemeStore;
|
||||
import com.kabouzeid.appthemehelper.util.ATHUtil;
|
||||
import com.kabouzeid.appthemehelper.util.ColorUtil;
|
||||
|
|
@ -261,9 +260,6 @@ public class CardPlayerFragment extends AbsPlayerFragment implements PlayerAlbum
|
|||
public void onHide() {
|
||||
playbackControlsFragment.hide();
|
||||
onBackPressed();
|
||||
if (!ThemeStore.coloredNavigationBar(requireContext())) {
|
||||
ATH.setNavigationbarColor(requireActivity(), Color.TRANSPARENT);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -176,7 +176,6 @@ public class FlatPlayerFragment extends AbsPlayerFragment implements PlayerAlbum
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
private void updateCurrentSong() {
|
||||
impl.updateCurrentSong(MusicPlayerRemote.getCurrentSong());
|
||||
}
|
||||
|
|
@ -243,7 +242,7 @@ public class FlatPlayerFragment extends AbsPlayerFragment implements PlayerAlbum
|
|||
@Override
|
||||
protected void toggleFavorite(Song song) {
|
||||
super.toggleFavorite(song);
|
||||
if (song.id == MusicPlayerRemote.getCurrentSong().id) {
|
||||
if (song.id.equals(MusicPlayerRemote.getCurrentSong().id)) {
|
||||
if (song.favorite) {
|
||||
playerAlbumCoverFragment.showHeartAnimation();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,10 +69,10 @@
|
|||
</FrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_marginTop="24dp"
|
||||
android:id="@+id/player_panel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="24dp">
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/playing_queue_card"
|
||||
|
|
@ -95,8 +95,8 @@
|
|||
android:id="@+id/draggable_area"
|
||||
android:layout_width="72dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignTop="@+id/card_content"
|
||||
android:layout_alignBottom="@+id/card_content"
|
||||
android:layout_alignTop="@+id/card_content"
|
||||
android:layout_marginTop="48dp" />
|
||||
|
||||
<LinearLayout
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<resources>
|
||||
|
||||
<style name="Theme.Phonograph" parent="Theme.Phonograph.Base">
|
||||
<item name="android:statusBarColor">@android:color/transparent</item>
|
||||
<item name="android:windowSharedElementsUseOverlay">false</item>
|
||||
|
|
@ -28,4 +29,5 @@
|
|||
<style name="MusicProgressSlider" parent="MusicProgressSliderParent">
|
||||
<item name="android:padding">0dp</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
||||
</resources>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue