mirror of
https://github.com/antebudimir/tempus.git
synced 2025-12-31 09:33:33 +00:00
feat: implemented playlist sharing
This commit is contained in:
parent
26b8f3f65c
commit
7f820bd5a6
5 changed files with 68 additions and 15 deletions
|
|
@ -2,8 +2,12 @@ package com.cappielloantonio.tempo.ui.dialog;
|
|||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
|
|
@ -99,6 +103,14 @@ public class PlaylistEditorDialog extends DialogFragment {
|
|||
playlistEditorViewModel.deletePlaylist();
|
||||
dialogDismiss();
|
||||
});
|
||||
|
||||
bind.playlistShareButton.setOnClickListener(view -> {
|
||||
playlistEditorViewModel.sharePlaylist().observe(requireActivity(), sharedPlaylist -> {
|
||||
ClipboardManager clipboardManager = (ClipboardManager) requireActivity().getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipData clipData = ClipData.newPlainText(getString(R.string.app_name), sharedPlaylist.getUrl());
|
||||
clipboardManager.setPrimaryClip(clipData);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private void initSongsView() {
|
||||
|
|
|
|||
|
|
@ -50,9 +50,12 @@ public class MusicUtil {
|
|||
uri.append("&maxBitRate=").append(getBitratePreference());
|
||||
if (!Preferences.isServerPrioritized())
|
||||
uri.append("&format=").append(getTranscodingFormatPreference());
|
||||
if (false)
|
||||
uri.append("&estimateContentLength=true");
|
||||
|
||||
uri.append("&id=").append(id);
|
||||
|
||||
|
||||
Log.d(TAG, "getStreamUri: " + uri);
|
||||
|
||||
return Uri.parse(uri.toString());
|
||||
|
|
|
|||
|
|
@ -8,8 +8,10 @@ import androidx.lifecycle.LiveData;
|
|||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
import com.cappielloantonio.tempo.repository.PlaylistRepository;
|
||||
import com.cappielloantonio.tempo.repository.SharingRepository;
|
||||
import com.cappielloantonio.tempo.subsonic.models.Child;
|
||||
import com.cappielloantonio.tempo.subsonic.models.Playlist;
|
||||
import com.cappielloantonio.tempo.subsonic.models.Share;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
|
@ -20,6 +22,7 @@ public class PlaylistEditorViewModel extends AndroidViewModel {
|
|||
private static final String TAG = "PlaylistEditorViewModel";
|
||||
|
||||
private final PlaylistRepository playlistRepository;
|
||||
private final SharingRepository sharingRepository;
|
||||
|
||||
private Child toAdd;
|
||||
private Playlist toEdit;
|
||||
|
|
@ -30,6 +33,7 @@ public class PlaylistEditorViewModel extends AndroidViewModel {
|
|||
super(application);
|
||||
|
||||
playlistRepository = new PlaylistRepository();
|
||||
sharingRepository = new SharingRepository();
|
||||
}
|
||||
|
||||
public void createPlaylist(String name) {
|
||||
|
|
@ -92,4 +96,8 @@ public class PlaylistEditorViewModel extends AndroidViewModel {
|
|||
|
||||
return ids;
|
||||
}
|
||||
|
||||
public MutableLiveData<Share> sharePlaylist() {
|
||||
return sharingRepository.createShare(toEdit.getId(), toEdit.getName(), null);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
9
app/src/main/res/drawable/ic_share.xml
Normal file
9
app/src/main/res/drawable/ic_share.xml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="20dp"
|
||||
android:height="20dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960">
|
||||
<path
|
||||
android:fillColor="@color/titleTextColor"
|
||||
android:pathData="M696,864Q646,864 611,829Q576,794 576,744Q576,736 577,729.5Q578,723 580,715L342,570Q327,586 306.65,593Q286.29,600 264,600Q214,600 179,565Q144,530 144,480Q144,430 179,395Q214,360 264,360Q286,360 306.5,367.5Q327,375 342,390L580,245Q578,237 577,230.5Q576,224 576,216Q576,166 611,131Q646,96 696,96Q746,96 781,131Q816,166 816,216Q816,266 781,301Q746,336 696,336Q673.71,336 653.35,329Q633,322 618,306L380,451Q382,459 383,465.5Q384,472 384,480Q384,488 383,494.5Q382,501 380,509L618,654Q633,637 653.35,630.5Q673.71,624 696,624Q746,624 781,659Q816,694 816,744Q816,794 781,829Q746,864 696,864Z"/>
|
||||
</vector>
|
||||
|
|
@ -4,26 +4,47 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
style="@style/Widget.Material3.TextInputLayout.OutlinedBox"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="24dp"
|
||||
android:orientation="horizontal"
|
||||
android:layout_marginTop="24dp"
|
||||
android:layout_marginEnd="24dp"
|
||||
android:textColorHint="?android:textColorHint"
|
||||
app:endIconMode="clear_text"
|
||||
app:endIconTint="?android:textColorSecondary"
|
||||
app:errorEnabled="true">
|
||||
android:layout_marginStart="24dp"
|
||||
android:layout_marginEnd="12dp">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/playlist_name_text_view"
|
||||
android:layout_width="match_parent"
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
style="@style/Widget.Material3.TextInputLayout.OutlinedBox"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/playlist_editor_dialog_hint_name"
|
||||
android:inputType="textNoSuggestions"
|
||||
android:textCursorDrawable="@null" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
android:layout_weight="1"
|
||||
android:textColorHint="?android:textColorHint"
|
||||
app:endIconMode="clear_text"
|
||||
app:endIconTint="?android:textColorSecondary"
|
||||
app:errorEnabled="true">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/playlist_name_text_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/playlist_editor_dialog_hint_name"
|
||||
android:inputType="textNoSuggestions"
|
||||
android:textCursorDrawable="@null" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/playlist_share_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="12dp"
|
||||
android:layout_marginTop="10dp">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:background="@drawable/ic_share"
|
||||
android:foreground="?android:attr/selectableItemBackgroundBorderless" />
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/playlist_song_recycler_view"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue