mirror of
https://github.com/antebudimir/tempus.git
synced 2026-04-15 16:27:26 +00:00
feat: Ability to toggle artist biography
This commit is contained in:
parent
c0dbe01bf9
commit
bae9221070
3 changed files with 42 additions and 2 deletions
|
|
@ -9,6 +9,8 @@ import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.Toast;
|
||||||
import android.widget.ToggleButton;
|
import android.widget.ToggleButton;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
@ -39,6 +41,7 @@ import com.cappielloantonio.tempo.ui.adapter.ArtistCatalogueAdapter;
|
||||||
import com.cappielloantonio.tempo.ui.adapter.SongHorizontalAdapter;
|
import com.cappielloantonio.tempo.ui.adapter.SongHorizontalAdapter;
|
||||||
import com.cappielloantonio.tempo.util.Constants;
|
import com.cappielloantonio.tempo.util.Constants;
|
||||||
import com.cappielloantonio.tempo.util.MusicUtil;
|
import com.cappielloantonio.tempo.util.MusicUtil;
|
||||||
|
import com.cappielloantonio.tempo.util.Preferences;
|
||||||
import com.cappielloantonio.tempo.viewmodel.ArtistPageViewModel;
|
import com.cappielloantonio.tempo.viewmodel.ArtistPageViewModel;
|
||||||
import com.cappielloantonio.tempo.viewmodel.PlaybackViewModel;
|
import com.cappielloantonio.tempo.viewmodel.PlaybackViewModel;
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
|
@ -119,6 +122,16 @@ public class ArtistPageFragment extends Fragment implements ClickCallback {
|
||||||
ToggleButton favoriteToggle = view.findViewById(R.id.button_favorite);
|
ToggleButton favoriteToggle = view.findViewById(R.id.button_favorite);
|
||||||
favoriteToggle.setChecked(artistPageViewModel.getArtist().getStarred() != null);
|
favoriteToggle.setChecked(artistPageViewModel.getArtist().getStarred() != null);
|
||||||
favoriteToggle.setOnClickListener(v -> artistPageViewModel.setFavorite(requireContext()));
|
favoriteToggle.setOnClickListener(v -> artistPageViewModel.setFavorite(requireContext()));
|
||||||
|
|
||||||
|
|
||||||
|
Button bioToggle = view.findViewById(R.id.button_toggle_bio);
|
||||||
|
bioToggle.setOnClickListener(v ->
|
||||||
|
{
|
||||||
|
boolean displayBio = Preferences.getArtistDisplayBiography();
|
||||||
|
Preferences.setArtistDisplayBiography(!displayBio);
|
||||||
|
if (bind != null)
|
||||||
|
bind.artistPageBioSector.setVisibility(displayBio ? View.GONE : View.VISIBLE);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initAppBar() {
|
private void initAppBar() {
|
||||||
|
|
@ -200,11 +213,14 @@ public class ArtistPageFragment extends Fragment implements ClickCallback {
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (bind != null) bind.artistPageBioSector.setVisibility(View.VISIBLE);
|
if (bind != null) {
|
||||||
|
boolean displayBio = Preferences.getArtistDisplayBiography();
|
||||||
|
bind.artistPageBioSector.setVisibility(displayBio ? View.VISIBLE : View.GONE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initPlayButtons() {
|
private void initPlayButtons() {
|
||||||
bind.artistPageShuffleButton.setOnClickListener(v -> artistPageViewModel.getArtistShuffleList().observe(getViewLifecycleOwner(), new Observer<List<Child>>() {
|
bind.artistPageShuffleButton.setOnClickListener(v -> artistPageViewModel.getArtistShuffleList().observe(getViewLifecycleOwner(), new Observer<List<Child>>() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,7 @@ object Preferences {
|
||||||
private const val DEFAULT_ALBUM_SORT_ORDER = Constants.ALBUM_ORDER_BY_NAME
|
private const val DEFAULT_ALBUM_SORT_ORDER = Constants.ALBUM_ORDER_BY_NAME
|
||||||
private const val ARTIST_SORT_BY_ALBUM_COUNT= "artist_sort_by_album_count"
|
private const val ARTIST_SORT_BY_ALBUM_COUNT= "artist_sort_by_album_count"
|
||||||
private const val SORT_SEARCH_CHRONOLOGICALLY= "sort_search_chronologically"
|
private const val SORT_SEARCH_CHRONOLOGICALLY= "sort_search_chronologically"
|
||||||
|
private const val ARTIST_DISPLAY_BIOGRAPHY= "artist_display_biography"
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun getServer(): String? {
|
fun getServer(): String? {
|
||||||
|
|
@ -680,4 +681,14 @@ object Preferences {
|
||||||
fun isSearchSortingChronologicallyEnabled(): Boolean {
|
fun isSearchSortingChronologicallyEnabled(): Boolean {
|
||||||
return App.getInstance().preferences.getBoolean(SORT_SEARCH_CHRONOLOGICALLY, false)
|
return App.getInstance().preferences.getBoolean(SORT_SEARCH_CHRONOLOGICALLY, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun getArtistDisplayBiography(): Boolean {
|
||||||
|
return App.getInstance().preferences.getBoolean(ARTIST_DISPLAY_BIOGRAPHY, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun setArtistDisplayBiography(displayBiographyEnabled: Boolean) {
|
||||||
|
App.getInstance().preferences.edit().putBoolean(ARTIST_DISPLAY_BIOGRAPHY, displayBiographyEnabled).apply()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -124,6 +124,19 @@
|
||||||
android:textOff=""
|
android:textOff=""
|
||||||
android:textOn="" />
|
android:textOn="" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/button_toggle_bio"
|
||||||
|
android:layout_width="34dp"
|
||||||
|
android:layout_height="34dp"
|
||||||
|
android:layout_marginStart="12dp"
|
||||||
|
android:layout_marginEnd="0dp"
|
||||||
|
android:background="@drawable/ic_info_stream"
|
||||||
|
android:foreground="?android:attr/selectableItemBackgroundBorderless"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text=""
|
||||||
|
android:textOff=""
|
||||||
|
android:textOn="" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<View
|
<View
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue