From bae9221070a104d6929b79422436efa5bea8ff7a Mon Sep 17 00:00:00 2001 From: kmarius <5224719+kmarius@users.noreply.github.com> Date: Sun, 4 Jan 2026 17:05:13 +0100 Subject: [PATCH] feat: Ability to toggle artist biography --- .../tempo/ui/fragment/ArtistPageFragment.java | 20 +++++++++++++++++-- .../tempo/util/Preferences.kt | 11 ++++++++++ .../main/res/layout/fragment_artist_page.xml | 13 ++++++++++++ 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/cappielloantonio/tempo/ui/fragment/ArtistPageFragment.java b/app/src/main/java/com/cappielloantonio/tempo/ui/fragment/ArtistPageFragment.java index 0c850038..0b287fc3 100644 --- a/app/src/main/java/com/cappielloantonio/tempo/ui/fragment/ArtistPageFragment.java +++ b/app/src/main/java/com/cappielloantonio/tempo/ui/fragment/ArtistPageFragment.java @@ -9,6 +9,8 @@ import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.Button; +import android.widget.Toast; import android.widget.ToggleButton; 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.util.Constants; import com.cappielloantonio.tempo.util.MusicUtil; +import com.cappielloantonio.tempo.util.Preferences; import com.cappielloantonio.tempo.viewmodel.ArtistPageViewModel; import com.cappielloantonio.tempo.viewmodel.PlaybackViewModel; 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); favoriteToggle.setChecked(artistPageViewModel.getArtist().getStarred() != null); 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() { @@ -200,11 +213,14 @@ public class ArtistPageFragment extends Fragment implements ClickCallback { 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() { bind.artistPageShuffleButton.setOnClickListener(v -> artistPageViewModel.getArtistShuffleList().observe(getViewLifecycleOwner(), new Observer>() { @Override diff --git a/app/src/main/java/com/cappielloantonio/tempo/util/Preferences.kt b/app/src/main/java/com/cappielloantonio/tempo/util/Preferences.kt index c40821ac..542adc8f 100644 --- a/app/src/main/java/com/cappielloantonio/tempo/util/Preferences.kt +++ b/app/src/main/java/com/cappielloantonio/tempo/util/Preferences.kt @@ -82,6 +82,7 @@ object Preferences { 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 SORT_SEARCH_CHRONOLOGICALLY= "sort_search_chronologically" + private const val ARTIST_DISPLAY_BIOGRAPHY= "artist_display_biography" @JvmStatic fun getServer(): String? { @@ -680,4 +681,14 @@ object Preferences { fun isSearchSortingChronologicallyEnabled(): Boolean { 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() + } } \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_artist_page.xml b/app/src/main/res/layout/fragment_artist_page.xml index 5cebfaf5..6712dd2e 100644 --- a/app/src/main/res/layout/fragment_artist_page.xml +++ b/app/src/main/res/layout/fragment_artist_page.xml @@ -124,6 +124,19 @@ android:textOff="" android:textOn="" /> +