Set the final strings and the titles of the songs to be synchronized in the home alert

This commit is contained in:
antonio 2023-03-19 18:47:41 +01:00
parent b0b5fc2172
commit c77e23af13
3 changed files with 24 additions and 8 deletions

View file

@ -57,6 +57,7 @@ import com.google.android.gms.cast.framework.CastButtonFactory;
import com.google.android.material.snackbar.Snackbar;
import com.google.common.util.concurrent.ListenableFuture;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@ -267,17 +268,19 @@ public class HomeFragment extends Fragment implements ClickCallback {
@Override
public void onChanged(List<Child> songs) {
if (songs != null) {
boolean showAlert = false;
DownloaderManager manager = DownloadUtil.getDownloadTracker(requireContext());
List<String> toSync = new ArrayList<>();
for (Child song : songs) {
if (!manager.isDownloaded(song.getId())) {
showAlert = true;
break;
toSync.add(song.getTitle());
}
}
if (showAlert) bind.homeSyncStarredCard.setVisibility(View.VISIBLE);
if (!toSync.isEmpty()) {
bind.homeSyncStarredCard.setVisibility(View.VISIBLE);
bind.homeSyncStarredTracksToSync.setText(String.join(", ", toSync));
}
}
homeViewModel.getAllStarredTracks().removeObserver(this);

View file

@ -95,6 +95,19 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/home_sync_starred_title" />
<TextView
android:id="@+id/home_sync_starred_tracks_to_sync"
style="@style/TitleSmall"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:paddingTop="8dp"
android:text="@string/home_sync_starred_subtitle"
android:textAppearance="?attr/textAppearanceBodyMedium"
android:textColor="?android:attr/textColorSecondary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/home_sync_starred_subtitle" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -104,7 +117,7 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/home_sync_starred_subtitle">
app:layout_constraintTop_toBottomOf="@+id/home_sync_starred_tracks_to_sync">
<com.google.android.material.button.MaterialButton
android:id="@+id/home_sync_starred_cancel"
@ -127,7 +140,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.70" />
app:layout_constraintGuide_percent="0.90" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>

View file

@ -59,8 +59,8 @@
<string name="genre_catalogue_title">Genre Catalogue</string>
<string name="genre_catalogue_title_expanded">Browse Genres</string>
<string name="home_subtitle_made_for_you">Start mix from a song you liked</string>
<string name="home_sync_starred_title">Start mix from a song you liked</string>
<string name="home_sync_starred_subtitle">Start mix from a song you liked</string>
<string name="home_sync_starred_title">Looks like there are some starred tracks to sync</string>
<string name="home_sync_starred_subtitle">Downloading these tracks may involve significant data usage</string>
<string name="home_sync_starred_cancel">Cancel</string>
<string name="home_sync_starred_download">Download</string>
<string name="home_title_flashback">Flashback</string>