Added buttons for music management

This commit is contained in:
CappielloAntonio 2021-12-20 12:35:37 +01:00
parent f4888f391b
commit 212550e39e
8 changed files with 136 additions and 61 deletions

5
.idea/misc.xml generated
View file

@ -3,6 +3,7 @@
<component name="DesignSurface">
<option name="filePathToZoomLevelMap">
<map>
<entry key="../../.gradle/caches/transforms-3/20796fa5f04d2ad22571c8f80fdd27bd/transformed/jetified-exoplayer-ui-2.12.2/res/drawable-anydpi-v21/exo_ic_skip_previous.xml" value="0.5484375" />
<entry key="../../.gradle/caches/transforms-3/cfd4e4d299e24db95f3608b5f72af22b/transformed/jetified-exoplayer-ui-2.12.2/res/drawable-anydpi-v21/exo_ic_play_circle_filled.xml" value="0.28055555555555556" />
<entry key="app/src/main/res/drawable-anydpi/ic_api_notification.xml" value="0.44351851851851853" />
<entry key="app/src/main/res/drawable-v24/ic_add.xml" value="0.27685185185185185" />
@ -14,6 +15,7 @@
<entry key="app/src/main/res/drawable-v24/ic_toolbar_motion_on.xml" value="0.28055555555555556" />
<entry key="app/src/main/res/drawable/bottom_nav_selector.xml" value="0.36203703703703705" />
<entry key="app/src/main/res/drawable/bottom_nav_shape.xml" value="0.28055555555555556" />
<entry key="app/src/main/res/drawable/button_favorite_selector.xml" value="0.46296296296296297" />
<entry key="app/src/main/res/drawable/dialog_shape.xml" value="0.27685185185185185" />
<entry key="app/src/main/res/drawable/ic_arrow_back.xml" value="0.28055555555555556" />
<entry key="app/src/main/res/drawable/ic_bottom_sheet_down.xml" value="0.4425925925925926" />
@ -42,9 +44,11 @@
<entry key="app/src/main/res/drawable/ic_shuffle.xml" value="0.2722222222222222" />
<entry key="app/src/main/res/drawable/ic_skip_next.xml" value="0.28055555555555556" />
<entry key="app/src/main/res/drawable/ic_skip_next_white_24dp.xml" value="0.28055555555555556" />
<entry key="app/src/main/res/drawable/ic_skip_previous.xml" value="0.5484375" />
<entry key="app/src/main/res/drawable/ic_skip_previous_white_24dp.xml" value="0.28055555555555556" />
<entry key="app/src/main/res/drawable/ic_star.xml" value="0.2722222222222222" />
<entry key="app/src/main/res/drawable/ic_toolbar_motion_on.xml" value="0.30625" />
<entry key="app/src/main/res/drawable/ic_unfold.xml" value="0.5484375" />
<entry key="app/src/main/res/drawable/ui_empty_list.xml" value="0.28055555555555556" />
<entry key="app/src/main/res/layout/activity_main.xml" value="0.3229166666666667" />
<entry key="app/src/main/res/layout/bottom_sheet_album_dialog.xml" value="0.3229166666666667" />
@ -109,6 +113,7 @@
<entry key="app/src/main/res/layout/item_player_now_playing_song.xml" value="0.3229166666666667" />
<entry key="app/src/main/res/layout/item_player_queue_song.xml" value="0.1" />
<entry key="app/src/main/res/layout/player_body_bottom_sheet.xml" value="0.528125" />
<entry key="app/src/main/res/layout/player_body_new_bottom_sheet.xml" value="0.528125" />
<entry key="app/src/main/res/layout/player_header_bottom_sheet.xml" value="0.3229166666666667" />
<entry key="app/src/main/res/menu/bottom_nav_menu.xml" value="0.3229166666666667" />
<entry key="app/src/main/res/menu/login_page_menu.xml" value="0.3229166666666667" />

View file

@ -19,7 +19,7 @@ import java.util.ArrayList;
import java.util.List;
public class PlayerNowPlayingSongAdapter extends RecyclerView.Adapter<PlayerNowPlayingSongAdapter.ViewHolder> {
private static final String TAG = "DiscoverSongAdapter";
private static final String TAG = "PlayerNowPlayingSongAdapter";
private final LayoutInflater inflater;
private final Context context;

View file

@ -159,7 +159,7 @@ public class MainActivity extends BaseActivity {
PlayerBottomSheetFragment playerBottomSheetFragment = (PlayerBottomSheetFragment) getSupportFragmentManager().findFragmentByTag("PlayerBottomSheet");
if (playerBottomSheetFragment != null) {
playerBottomSheetFragment.scrollOnTop();
playerBottomSheetFragment.setLyricsTextViewVisibility(false);
playerBottomSheetFragment.setPlayerCommandViewVisibility(false);
}
break;
case BottomSheetBehavior.STATE_DRAGGING:

View file

@ -79,6 +79,7 @@ public class PlayerBottomSheetFragment extends Fragment implements MusicServiceE
initQueueSlideView();
initQueueRecyclerView();
initFavoriteButtonClick();
initMusicCommandUnfoldButton();
initMusicCommandButton();
initArtistLabelButton();
@ -127,7 +128,7 @@ public class PlayerBottomSheetFragment extends Fragment implements MusicServiceE
}
private void initLyricsView() {
playerBottomSheetViewModel.getLyrics().observe(requireActivity(), lyrics -> {
/*playerBottomSheetViewModel.getLyrics().observe(requireActivity(), lyrics -> {
if (lyrics != null && !lyrics.trim().equals("")) {
bodyBind.playerSongLyricsCardview.setVisibility(View.VISIBLE);
} else {
@ -143,7 +144,7 @@ public class PlayerBottomSheetFragment extends Fragment implements MusicServiceE
} else {
setLyricsTextViewVisibility(false);
}
});
});*/
}
private void initQueueSlideView() {
@ -265,7 +266,18 @@ public class PlayerBottomSheetFragment extends Fragment implements MusicServiceE
});
}
private void initMusicCommandUnfoldButton() {
bodyBind.playerCommandUnfoldButton.setOnClickListener(view -> {
if (bodyBind.playerCommandCardview.getVisibility() == View.INVISIBLE || bodyBind.playerCommandCardview.getVisibility() == View.GONE) {
setPlayerCommandViewVisibility(true);
} else {
setPlayerCommandViewVisibility(false);
}
});
}
private void initMusicCommandButton() {
// Header
headerBind.playerHeaderButton.setOnClickListener(v -> {
if (MusicPlayerRemote.isPlaying()) {
MusicPlayerRemote.pauseSong();
@ -275,6 +287,18 @@ public class PlayerBottomSheetFragment extends Fragment implements MusicServiceE
});
headerBind.playerHeaderNextSongButton.setOnClickListener(v -> MusicPlayerRemote.playNextSong());
// Body
bodyBind.playerBigPlayPauseButton.setOnClickListener(v -> {
if (MusicPlayerRemote.isPlaying()) {
MusicPlayerRemote.pauseSong();
} else {
MusicPlayerRemote.resumePlaying();
}
});
bodyBind.playerBigNextButton.setOnClickListener(v -> MusicPlayerRemote.playNextSong());
bodyBind.playerBigPreviousButton.setOnClickListener(v -> MusicPlayerRemote.playPreviousSong());
}
private void initArtistLabelButton() {
@ -317,7 +341,7 @@ public class PlayerBottomSheetFragment extends Fragment implements MusicServiceE
}
private void setSongInfo(Song song) {
setLyricsTextViewVisibility(false);
// setLyricsTextViewVisibility(false);
playerBottomSheetViewModel.refreshSongLyrics(requireActivity(), song);
bodyBind.playerSongTitleLabel.setText(MusicUtil.getReadableString(song.getTitle()));
@ -335,13 +359,11 @@ public class PlayerBottomSheetFragment extends Fragment implements MusicServiceE
bodyBind.buttonFavorite.setChecked(song.isFavorite());
}
public void setLyricsTextViewVisibility(boolean isVisible) {
public void setPlayerCommandViewVisibility(boolean isVisible) {
if(isVisible) {
bodyBind.playerSongLyricsTextView.setVisibility(View.VISIBLE);
bodyBind.playerSongLyricsLabelClickable.setText(R.string.player_hide_lyrics_button);
bodyBind.playerCommandCardview.setVisibility(View.VISIBLE);
} else {
bodyBind.playerSongLyricsTextView.setVisibility(View.GONE);
bodyBind.playerSongLyricsLabelClickable.setText(R.string.player_show_lyrics_button);
bodyBind.playerCommandCardview.setVisibility(View.GONE);
}
}

View file

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@color/titleTextColor"
android:pathData="M6,6h2v12L6,18zM9.5,12l8.5,6L18,6z" />
</vector>

View file

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@color/titleTextColor"
android:pathData="M12,5.83L15.17,9l1.41,-1.41L12,3 7.41,7.59 8.83,9 12,5.83zM12,18.17L8.83,15l-1.41,1.41L12,21l4.59,-4.59L15.17,15 12,18.17z"/>
</vector>

View file

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -148,66 +149,95 @@
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/player_song_title_label" />
<View
android:id="@+id/player_divider_top"
style="@style/Divider"
android:layout_marginStart="18dp"
android:layout_marginEnd="18dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/player_artist_name_label" />
<androidx.cardview.widget.CardView
android:id="@+id/player_song_lyrics_cardview"
<LinearLayout
android:id="@+id/player_music_command_sector"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/player_artist_name_label">
<View
android:layout_width="0dp"
android:layout_height="0.5dp"
android:layout_weight="1"
android:layout_gravity="center_vertical"
android:background="@color/dividerColor"
android:layout_marginStart="18dp"
android:layout_marginEnd="18dp" />
<ImageButton
android:id="@+id/player_command_unfold_button"
android:layout_width="18dp"
android:layout_height="18dp"
android:background="@drawable/ic_unfold"
android:scaleType="fitCenter"/>
<View
android:layout_width="0dp"
android:layout_height="0.5dp"
android:layout_weight="1"
android:layout_gravity="center_vertical"
android:background="@color/dividerColor"
android:layout_marginStart="18dp"
android:layout_marginEnd="18dp" />
</LinearLayout>
<androidx.cardview.widget.CardView
android:id="@+id/player_command_cardview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:backgroundTint="@color/colorPrimary"
android:visibility="gone"
app:cardElevation="0dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/player_divider_top">
app:layout_constraintTop_toBottomOf="@+id/player_music_command_sector">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:clipChildren="false">
<TextView
android:id="@+id/player_song_lyrics_label"
style="@style/HeadlineTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="12dp"
android:paddingStart="24dp"
android:paddingEnd="24dp"
android:text="@string/player_song_lyrics_label"
<ImageButton
android:id="@+id/player_big_previous_button"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_marginEnd="24dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:scaleType="fitCenter"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/player_big_play_pause_button"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_skip_previous" />
<ToggleButton
android:id="@+id/player_big_play_pause_button"
android:layout_width="48dp"
android:layout_height="48dp"
android:background="@drawable/button_play_pause_selector"
android:checked="true"
android:foreground="?android:attr/selectableItemBackgroundBorderless"
android:text=""
android:textOff=""
android:textOn=""
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/player_song_lyrics_label_clickable"
style="@style/SubheadTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="8dp"
android:paddingEnd="20dp"
android:text="@string/player_show_lyrics_button"
app:layout_constraintBottom_toBottomOf="@+id/player_song_lyrics_label"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/player_song_lyrics_text_view"
style="@style/SubheadTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="24dp"
android:paddingEnd="24dp"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/player_song_lyrics_label" />
<ImageButton
android:id="@+id/player_big_next_button"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_marginStart="24dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:scaleType="fitCenter"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/player_big_play_pause_button"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_skip_next" />
<View
android:id="@+id/player_divider_bottom"
@ -217,7 +247,7 @@
android:layout_marginEnd="18dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/player_song_lyrics_text_view" />
app:layout_constraintTop_toBottomOf="@+id/player_big_play_pause_button" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
@ -230,5 +260,5 @@
android:paddingBottom="18dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/player_song_lyrics_cardview" />
app:layout_constraintTop_toBottomOf="@+id/player_command_cardview" />
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -42,5 +42,5 @@
<color name="placeholderColor">#F1F3F4</color>
<color name="iconLauncher">https://icon.kitchen/i/H4sIAAAAAAAAAzWQu27DMAxF%2F4VdPbhBsmTt0LVAuxVFIUuUIoAWDT36gJF%2Fz5WCcJCow8uXdvox0rjQeScfXiRuJtf%2BKIyLHHvTpNJE0WoCEE7le5GW6TrREj7%2BNwYN2bjIqevA%2BK%2B2DLxTfbi0ajHR3pNeH2oorIrmZwiejmaevUeFgQ4dzcOATAqCKscT8jFlF%2FS4H4a4D2%2FGuZjCaKobnQ%2BniXIMFzTp7qK16nr3hf2gY5b3ixkb2JgtWoCt6pr0D%2FlEW5c1ur69Fpy%2FvNDX9QZCITMSMwEAAA%3D%3D</color>
<!-- <color name="iconLauncher">https://icon.kitchen/i/H4sIAAAAAAAAAzWQu27DMAxF%2F4VdPbhBsmTt0LVAuxVFIUuUIoAWDT36gJF%2Fz5WCcJCow8uXdvox0rjQeScfXiRuJtf%2BKIyLHHvTpNJE0WoCEE7le5GW6TrREj7%2BNwYN2bjIqevA%2BK%2B2DLxTfbi0ajHR3pNeH2oorIrmZwiejmaevUeFgQ4dzcOATAqCKscT8jFlF%2FS4H4a4D2%2FGuZjCaKobnQ%2BniXIMFzTp7qK16nr3hf2gY5b3ixkb2JgtWoCt6pr0D%2FlEW5c1ur69Fpy%2FvNDX9QZCITMSMwEAAA%3D%3D</color> -->
</resources>