minor changes and refactoring
This commit is contained in:
parent
e56a20f34c
commit
704502f653
9 changed files with 30 additions and 23 deletions
|
|
@ -98,7 +98,7 @@ public class MainActivity extends AbsMusicPanelActivity {
|
||||||
|
|
||||||
// only override when logout selected
|
// only override when logout selected
|
||||||
if (onLogout) {
|
if (onLogout) {
|
||||||
overridePendingTransition(0, R.anim.fade_slow);
|
overridePendingTransition(0, R.anim.fade_quick);
|
||||||
onLogout = false;
|
onLogout = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -160,8 +160,8 @@ public class MainActivity extends AbsMusicPanelActivity {
|
||||||
// it also applies a tacky background color for the checked item
|
// it also applies a tacky background color for the checked item
|
||||||
// this is a hack to check the current item without that
|
// this is a hack to check the current item without that
|
||||||
if (menuItem.getItemId() == R.id.nav_settings
|
if (menuItem.getItemId() == R.id.nav_settings
|
||||||
|| menuItem.getItemId() == R.id.nav_about
|
|| menuItem.getItemId() == R.id.nav_about
|
||||||
|| menuItem.getItemId() == R.id.nav_logout) return true;
|
|| menuItem.getItemId() == R.id.nav_logout) return true;
|
||||||
|
|
||||||
for (int i = 0; i < binding.navigationView.getMenu().size(); i++) {
|
for (int i = 0; i < binding.navigationView.getMenu().size(); i++) {
|
||||||
binding.navigationView.getMenu().getItem(i).setChecked(binding.navigationView.getMenu().getItem(i) == menuItem);
|
binding.navigationView.getMenu().getItem(i).setChecked(binding.navigationView.getMenu().getItem(i) == menuItem);
|
||||||
|
|
@ -194,8 +194,8 @@ public class MainActivity extends AbsMusicPanelActivity {
|
||||||
navigationBinding.text.setText(MusicUtil.getSongInfoString(song));
|
navigationBinding.text.setText(MusicUtil.getSongInfoString(song));
|
||||||
|
|
||||||
CustomGlideRequest.Builder
|
CustomGlideRequest.Builder
|
||||||
.from(this, song.primary, song.blurHash)
|
.from(this, song.primary, song.blurHash)
|
||||||
.build().centerInside().into(navigationBinding.image);
|
.build().centerInside().into(navigationBinding.image);
|
||||||
} else if (binding.navigationView.getHeaderCount() != 0) {
|
} else if (binding.navigationView.getHeaderCount() != 0) {
|
||||||
binding.navigationView.removeHeaderView(navigationBinding.getRoot());
|
binding.navigationView.removeHeaderView(navigationBinding.getRoot());
|
||||||
navigationBinding = null;
|
navigationBinding = null;
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ import java.util.List;
|
||||||
|
|
||||||
@SuppressLint("ClickableViewAccessibility")
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
public class SearchActivity extends AbsMusicServiceActivity implements SearchView.OnQueryTextListener {
|
public class SearchActivity extends AbsMusicServiceActivity implements SearchView.OnQueryTextListener {
|
||||||
private String QUERY = "query";
|
private final String QUERY = "query";
|
||||||
|
|
||||||
private ActivitySearchBinding binding;
|
private ActivitySearchBinding binding;
|
||||||
|
|
||||||
|
|
@ -74,11 +74,8 @@ public class SearchActivity extends AbsMusicServiceActivity implements SearchVie
|
||||||
|
|
||||||
setUpToolBar();
|
setUpToolBar();
|
||||||
|
|
||||||
|
query = savedInstanceState.getString(QUERY, "");
|
||||||
handler = new Handler();
|
handler = new Handler();
|
||||||
if (savedInstanceState != null) {
|
|
||||||
query = savedInstanceState.getString(QUERY);
|
|
||||||
search(query);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import android.view.animation.PathInterpolator;
|
||||||
|
|
||||||
import androidx.annotation.ColorInt;
|
import androidx.annotation.ColorInt;
|
||||||
import androidx.annotation.FloatRange;
|
import androidx.annotation.FloatRange;
|
||||||
|
import androidx.annotation.RequiresApi;
|
||||||
import androidx.core.graphics.ColorUtils;
|
import androidx.core.graphics.ColorUtils;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
|
|
@ -103,6 +104,7 @@ public abstract class AbsMusicPanelActivity extends AbsMusicServiceActivity impl
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
if (currentNowPlayingScreen != PreferenceUtil.getInstance(this).getNowPlayingScreen()) {
|
if (currentNowPlayingScreen != PreferenceUtil.getInstance(this).getNowPlayingScreen()) {
|
||||||
postRecreate();
|
postRecreate();
|
||||||
}
|
}
|
||||||
|
|
@ -241,8 +243,11 @@ public abstract class AbsMusicPanelActivity extends AbsMusicServiceActivity impl
|
||||||
public void onPaletteColorChanged() {
|
public void onPaletteColorChanged() {
|
||||||
if (getPanelState() == SlidingUpPanelLayout.PanelState.EXPANDED) {
|
if (getPanelState() == SlidingUpPanelLayout.PanelState.EXPANDED) {
|
||||||
int playerFragmentColor = playerFragment.getPaletteColor();
|
int playerFragmentColor = playerFragment.getPaletteColor();
|
||||||
|
|
||||||
super.setTaskDescriptionColor(playerFragmentColor);
|
super.setTaskDescriptionColor(playerFragmentColor);
|
||||||
animateNavigationBarColor(playerFragmentColor);
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
|
animateNavigationBarColor(playerFragmentColor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -268,23 +273,25 @@ public abstract class AbsMusicPanelActivity extends AbsMusicServiceActivity impl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||||
private void animateNavigationBarColor(int color) {
|
private void animateNavigationBarColor(int color) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
if (navigationBarColorAnimator != null) {
|
||||||
if (navigationBarColorAnimator != null) navigationBarColorAnimator.cancel();
|
navigationBarColorAnimator.cancel();
|
||||||
|
|
||||||
navigationBarColorAnimator = ValueAnimator
|
|
||||||
.ofArgb(getWindow().getNavigationBarColor(), color)
|
|
||||||
.setDuration(ViewUtil.PHONOGRAPH_ANIM_TIME);
|
|
||||||
|
|
||||||
navigationBarColorAnimator.setInterpolator(new PathInterpolator(0.4f, 0f, 1f, 1f));
|
|
||||||
navigationBarColorAnimator.addUpdateListener(animation -> AbsMusicPanelActivity.super.setNavigationbarColor((Integer) animation.getAnimatedValue()));
|
|
||||||
navigationBarColorAnimator.start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
navigationBarColorAnimator = ValueAnimator
|
||||||
|
.ofArgb(getWindow().getNavigationBarColor(), color)
|
||||||
|
.setDuration(ViewUtil.PHONOGRAPH_ANIM_TIME);
|
||||||
|
|
||||||
|
navigationBarColorAnimator.setInterpolator(new PathInterpolator(0.4f, 0f, 1f, 1f));
|
||||||
|
navigationBarColorAnimator.addUpdateListener(animation -> super.setNavigationbarColor((int) animation.getAnimatedValue()));
|
||||||
|
navigationBarColorAnimator.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
|
|
||||||
if (navigationBarColorAnimator != null) {
|
if (navigationBarColorAnimator != null) {
|
||||||
navigationBarColorAnimator.cancel();
|
navigationBarColorAnimator.cancel();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import android.view.View;
|
||||||
|
|
||||||
import androidx.annotation.ColorInt;
|
import androidx.annotation.ColorInt;
|
||||||
|
|
||||||
|
import com.dkanada.gramophone.BuildConfig;
|
||||||
import com.kabouzeid.appthemehelper.ATH;
|
import com.kabouzeid.appthemehelper.ATH;
|
||||||
import com.kabouzeid.appthemehelper.ThemeStore;
|
import com.kabouzeid.appthemehelper.ThemeStore;
|
||||||
import com.kabouzeid.appthemehelper.common.ATHToolbarActivity;
|
import com.kabouzeid.appthemehelper.common.ATHToolbarActivity;
|
||||||
|
|
@ -45,7 +46,7 @@ public abstract class AbsThemeActivity extends ATHToolbarActivity {
|
||||||
} else {
|
} else {
|
||||||
statusBar.setBackgroundColor(color);
|
statusBar.setBackgroundColor(color);
|
||||||
}
|
}
|
||||||
} else if (Build.VERSION.SDK_INT >= 21) {
|
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
getWindow().setStatusBarColor(ColorUtil.darkenColor(color));
|
getWindow().setStatusBarColor(ColorUtil.darkenColor(color));
|
||||||
setLightStatusbarAuto(color);
|
setLightStatusbarAuto(color);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,7 @@ public class ArtistDetailActivity extends AbsMusicPanelActivity implements Palet
|
||||||
|
|
||||||
ItemQuery albums = new ItemQuery();
|
ItemQuery albums = new ItemQuery();
|
||||||
albums.setArtistIds(new String[]{artist.id});
|
albums.setArtistIds(new String[]{artist.id});
|
||||||
|
|
||||||
QueryUtil.getAlbums(albums, media -> {
|
QueryUtil.getAlbums(albums, media -> {
|
||||||
artist.albums = media;
|
artist.albums = media;
|
||||||
setArtist(artist);
|
setArtist(artist);
|
||||||
|
|
@ -79,6 +80,7 @@ public class ArtistDetailActivity extends AbsMusicPanelActivity implements Palet
|
||||||
|
|
||||||
ItemQuery songs = new ItemQuery();
|
ItemQuery songs = new ItemQuery();
|
||||||
songs.setArtistIds(new String[]{artist.id});
|
songs.setArtistIds(new String[]{artist.id});
|
||||||
|
|
||||||
QueryUtil.getSongs(songs, media -> {
|
QueryUtil.getSongs(songs, media -> {
|
||||||
artist.songs = media;
|
artist.songs = media;
|
||||||
setArtist(artist);
|
setArtist(artist);
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,7 @@ public class GenreDetailActivity extends AbsMusicPanelActivity implements CabHol
|
||||||
|
|
||||||
ItemQuery query = new ItemQuery();
|
ItemQuery query = new ItemQuery();
|
||||||
query.setGenreIds(new String[]{genre.id});
|
query.setGenreIds(new String[]{genre.id});
|
||||||
|
|
||||||
QueryUtil.getSongs(query, media -> {
|
QueryUtil.getSongs(query, media -> {
|
||||||
adapter.getDataSet().addAll(media);
|
adapter.getDataSet().addAll(media);
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,7 @@ public class PlaylistDetailActivity extends AbsMusicPanelActivity implements Cab
|
||||||
|
|
||||||
PlaylistItemQuery query = new PlaylistItemQuery();
|
PlaylistItemQuery query = new PlaylistItemQuery();
|
||||||
query.setId(playlist.id);
|
query.setId(playlist.id);
|
||||||
|
|
||||||
PlaylistUtil.getPlaylist(query, media -> {
|
PlaylistUtil.getPlaylist(query, media -> {
|
||||||
adapter.getDataSet().addAll(media);
|
adapter.getDataSet().addAll(media);
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,6 @@ import com.dkanada.gramophone.service.MusicService;
|
||||||
import static android.content.Context.NOTIFICATION_SERVICE;
|
import static android.content.Context.NOTIFICATION_SERVICE;
|
||||||
|
|
||||||
public abstract class PlayingNotification {
|
public abstract class PlayingNotification {
|
||||||
|
|
||||||
private static final int NOTIFICATION_ID = 1;
|
private static final int NOTIFICATION_ID = 1;
|
||||||
protected static final String NOTIFICATION_CHANNEL_ID = "playing_notification";
|
protected static final String NOTIFICATION_CHANNEL_ID = "playing_notification";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,6 @@ import static com.dkanada.gramophone.service.MusicService.ACTION_SKIP;
|
||||||
import static com.dkanada.gramophone.service.MusicService.ACTION_TOGGLE;
|
import static com.dkanada.gramophone.service.MusicService.ACTION_TOGGLE;
|
||||||
|
|
||||||
public class PlayingNotificationImpl24 extends PlayingNotification {
|
public class PlayingNotificationImpl24 extends PlayingNotification {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void update() {
|
public synchronized void update() {
|
||||||
stopped = false;
|
stopped = false;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue