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.ArgbEvaluator;
|
||||||
import android.animation.ValueAnimator;
|
import android.animation.ValueAnimator;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Color;
|
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import androidx.annotation.ColorInt;
|
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.ui.fragments.player.flat.FlatPlayerFragment;
|
||||||
import com.dkanada.gramophone.util.PreferenceUtil;
|
import com.dkanada.gramophone.util.PreferenceUtil;
|
||||||
import com.dkanada.gramophone.util.ViewUtil;
|
import com.dkanada.gramophone.util.ViewUtil;
|
||||||
import com.kabouzeid.appthemehelper.ThemeStore;
|
|
||||||
import com.sothree.slidinguppanel.SlidingUpPanelLayout;
|
import com.sothree.slidinguppanel.SlidingUpPanelLayout;
|
||||||
|
|
||||||
public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivity implements SlidingUpPanelLayout.PanelSlideListener, CardPlayerFragment.Callbacks {
|
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) {
|
public void onPanelSlide(View panel, @FloatRange(from = 0, to = 1) float slideOffset) {
|
||||||
setMiniPlayerAlphaProgress(slideOffset);
|
setMiniPlayerAlphaProgress(slideOffset);
|
||||||
if (navigationBarColorAnimator != null) navigationBarColorAnimator.cancel();
|
if (navigationBarColorAnimator != null) navigationBarColorAnimator.cancel();
|
||||||
int color = shiftNavbarColor(playerFragment.getPaletteColor());
|
super.setNavigationbarColor(ColorUtils.blendARGB(navigationbarColor, playerFragment.getPaletteColor(), slideOffset));
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -187,8 +177,7 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivi
|
||||||
int playerFragmentColor = playerFragment.getPaletteColor();
|
int playerFragmentColor = playerFragment.getPaletteColor();
|
||||||
super.setLightStatusbar(false);
|
super.setLightStatusbar(false);
|
||||||
super.setTaskDescriptionColor(playerFragmentColor);
|
super.setTaskDescriptionColor(playerFragmentColor);
|
||||||
int color = shiftNavbarColor(playerFragmentColor);
|
super.setNavigationbarColor(playerFragmentColor);
|
||||||
super.setNavigationbarColor(color);
|
|
||||||
|
|
||||||
playerFragment.setMenuVisibility(true);
|
playerFragment.setMenuVisibility(true);
|
||||||
playerFragment.setUserVisibleHint(true);
|
playerFragment.setUserVisibleHint(true);
|
||||||
|
|
@ -255,8 +244,7 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivi
|
||||||
if (getPanelState() == SlidingUpPanelLayout.PanelState.EXPANDED) {
|
if (getPanelState() == SlidingUpPanelLayout.PanelState.EXPANDED) {
|
||||||
int playerFragmentColor = playerFragment.getPaletteColor();
|
int playerFragmentColor = playerFragment.getPaletteColor();
|
||||||
super.setTaskDescriptionColor(playerFragmentColor);
|
super.setTaskDescriptionColor(playerFragmentColor);
|
||||||
int color = shiftNavbarColor(playerFragmentColor);
|
animateNavigationBarColor(playerFragmentColor);
|
||||||
animateNavigationBarColor(color);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -308,28 +296,4 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivi
|
||||||
protected View getSnackBarContainer() {
|
protected View getSnackBarContainer() {
|
||||||
return findViewById(R.id.content_container);
|
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() {
|
public void setNavigationbarColorAuto() {
|
||||||
if (ThemeStore.coloredNavigationBar(this)) {
|
setNavigationbarColor(ThemeStore.navigationBarColor(this));
|
||||||
setNavigationbarColor(ThemeStore.navigationBarColor(this));
|
|
||||||
} else {
|
|
||||||
setNavigationbarColor(Color.TRANSPARENT);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLightStatusbar(boolean enabled) {
|
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.animator.RefactoredDefaultItemAnimator;
|
||||||
import com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager;
|
import com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager;
|
||||||
import com.h6ah4i.android.widget.advrecyclerview.utils.WrapperAdapterUtils;
|
import com.h6ah4i.android.widget.advrecyclerview.utils.WrapperAdapterUtils;
|
||||||
import com.kabouzeid.appthemehelper.ATH;
|
|
||||||
import com.kabouzeid.appthemehelper.ThemeStore;
|
import com.kabouzeid.appthemehelper.ThemeStore;
|
||||||
import com.kabouzeid.appthemehelper.util.ATHUtil;
|
import com.kabouzeid.appthemehelper.util.ATHUtil;
|
||||||
import com.kabouzeid.appthemehelper.util.ColorUtil;
|
import com.kabouzeid.appthemehelper.util.ColorUtil;
|
||||||
|
|
@ -261,9 +260,6 @@ public class CardPlayerFragment extends AbsPlayerFragment implements PlayerAlbum
|
||||||
public void onHide() {
|
public void onHide() {
|
||||||
playbackControlsFragment.hide();
|
playbackControlsFragment.hide();
|
||||||
onBackPressed();
|
onBackPressed();
|
||||||
if (!ThemeStore.coloredNavigationBar(requireContext())) {
|
|
||||||
ATH.setNavigationbarColor(requireActivity(), Color.TRANSPARENT);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -176,7 +176,6 @@ public class FlatPlayerFragment extends AbsPlayerFragment implements PlayerAlbum
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("ConstantConditions")
|
|
||||||
private void updateCurrentSong() {
|
private void updateCurrentSong() {
|
||||||
impl.updateCurrentSong(MusicPlayerRemote.getCurrentSong());
|
impl.updateCurrentSong(MusicPlayerRemote.getCurrentSong());
|
||||||
}
|
}
|
||||||
|
|
@ -243,7 +242,7 @@ public class FlatPlayerFragment extends AbsPlayerFragment implements PlayerAlbum
|
||||||
@Override
|
@Override
|
||||||
protected void toggleFavorite(Song song) {
|
protected void toggleFavorite(Song song) {
|
||||||
super.toggleFavorite(song);
|
super.toggleFavorite(song);
|
||||||
if (song.id == MusicPlayerRemote.getCurrentSong().id) {
|
if (song.id.equals(MusicPlayerRemote.getCurrentSong().id)) {
|
||||||
if (song.favorite) {
|
if (song.favorite) {
|
||||||
playerAlbumCoverFragment.showHeartAnimation();
|
playerAlbumCoverFragment.showHeartAnimation();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -69,10 +69,10 @@
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
|
android:layout_marginTop="24dp"
|
||||||
android:id="@+id/player_panel"
|
android:id="@+id/player_panel"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content">
|
||||||
android:layout_marginTop="24dp">
|
|
||||||
|
|
||||||
<androidx.cardview.widget.CardView
|
<androidx.cardview.widget.CardView
|
||||||
android:id="@+id/playing_queue_card"
|
android:id="@+id/playing_queue_card"
|
||||||
|
|
@ -95,8 +95,8 @@
|
||||||
android:id="@+id/draggable_area"
|
android:id="@+id/draggable_area"
|
||||||
android:layout_width="72dp"
|
android:layout_width="72dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignTop="@+id/card_content"
|
|
||||||
android:layout_alignBottom="@+id/card_content"
|
android:layout_alignBottom="@+id/card_content"
|
||||||
|
android:layout_alignTop="@+id/card_content"
|
||||||
android:layout_marginTop="48dp" />
|
android:layout_marginTop="48dp" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
<style name="Theme.Phonograph" parent="Theme.Phonograph.Base">
|
<style name="Theme.Phonograph" parent="Theme.Phonograph.Base">
|
||||||
<item name="android:statusBarColor">@android:color/transparent</item>
|
<item name="android:statusBarColor">@android:color/transparent</item>
|
||||||
<item name="android:windowSharedElementsUseOverlay">false</item>
|
<item name="android:windowSharedElementsUseOverlay">false</item>
|
||||||
|
|
@ -28,4 +29,5 @@
|
||||||
<style name="MusicProgressSlider" parent="MusicProgressSliderParent">
|
<style name="MusicProgressSlider" parent="MusicProgressSliderParent">
|
||||||
<item name="android:padding">0dp</item>
|
<item name="android:padding">0dp</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue