Removed the "Unset Thumbnail" item if you can't use this feature
This commit is contained in:
parent
dfd6534a1c
commit
2679a4bf1e
2 changed files with 17 additions and 37 deletions
|
@ -8,8 +8,6 @@ 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.ArrayAdapter;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
@ -34,6 +32,7 @@ import org.schabi.newpipe.local.playlist.RemotePlaylistManager;
|
||||||
import org.schabi.newpipe.util.NavigationHelper;
|
import org.schabi.newpipe.util.NavigationHelper;
|
||||||
import org.schabi.newpipe.util.OnClickGesture;
|
import org.schabi.newpipe.util.OnClickGesture;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import icepick.State;
|
import icepick.State;
|
||||||
|
@ -267,49 +266,30 @@ public final class BookmarkFragment extends BaseLocalListFragment<List<PlaylistL
|
||||||
|
|
||||||
final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||||
|
|
||||||
final ArrayAdapter<String> arrayAdapter = getLocalDialogArrayAdapter(isThumbnailPermanent,
|
final ArrayList<String> items = new ArrayList<>();
|
||||||
unsetThumbnail);
|
items.add(rename);
|
||||||
arrayAdapter.addAll(rename, delete, unsetThumbnail);
|
items.add(delete);
|
||||||
|
if (isThumbnailPermanent) {
|
||||||
|
items.add(unsetThumbnail);
|
||||||
|
}
|
||||||
|
|
||||||
final DialogInterface.OnClickListener action = (dialog, index) -> {
|
final DialogInterface.OnClickListener action = (d, index) -> {
|
||||||
if (index == arrayAdapter.getPosition(rename)) {
|
if (items.get(index).equals(rename)) {
|
||||||
showRenameDialog(selectedItem);
|
showRenameDialog(selectedItem);
|
||||||
} else if (index == arrayAdapter.getPosition(delete)) {
|
} else if (items.get(index).equals(delete)) {
|
||||||
showDeleteDialog(selectedItem.name, localPlaylistManager
|
showDeleteDialog(selectedItem.name,
|
||||||
.deletePlaylist(selectedItem.uid));
|
localPlaylistManager.deletePlaylist(selectedItem.uid));
|
||||||
} else if (isThumbnailPermanent) {
|
} else if (isThumbnailPermanent && items.get(index).equals(unsetThumbnail)) {
|
||||||
final String thumbnailUrl = localPlaylistManager
|
final String thumbnailUrl = localPlaylistManager
|
||||||
.getAutomaticPlaylistThumbnail(selectedItem.uid);
|
.getAutomaticPlaylistThumbnail(selectedItem.uid);
|
||||||
localPlaylistManager.changePlaylistThumbnail(selectedItem.uid, thumbnailUrl, false)
|
localPlaylistManager
|
||||||
|
.changePlaylistThumbnail(selectedItem.uid, thumbnailUrl, false)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe();
|
.subscribe();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
builder.setAdapter(arrayAdapter, action)
|
builder.setItems(items.toArray(new String[0]), action).create().show();
|
||||||
.create()
|
|
||||||
.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
private ArrayAdapter<String> getLocalDialogArrayAdapter(final boolean isPlaylistThumbnailSet,
|
|
||||||
final String unsetThumbnail) {
|
|
||||||
return new ArrayAdapter<>(getContext(), android.R.layout.simple_list_item_1) {
|
|
||||||
@Override
|
|
||||||
public View getView(final int position, final View convertView,
|
|
||||||
final ViewGroup parent) {
|
|
||||||
final View v = super.getView(position, convertView, parent);
|
|
||||||
final TextView textView = v.findViewById(android.R.id.text1);
|
|
||||||
|
|
||||||
// If the PlaylistThumbnail is not set permanently, the unset option is disabled.
|
|
||||||
if (!isPlaylistThumbnailSet && textView.getText().equals(unsetThumbnail)) {
|
|
||||||
textView.setEnabled(false);
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
|
|
||||||
textView.setEnabled(true);
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showRenameDialog(final PlaylistMetadataEntry selectedItem) {
|
private void showRenameDialog(final PlaylistMetadataEntry selectedItem) {
|
||||||
|
|
|
@ -438,7 +438,7 @@
|
||||||
<string name="mute">Mute</string>
|
<string name="mute">Mute</string>
|
||||||
<string name="unmute">Unmute</string>
|
<string name="unmute">Unmute</string>
|
||||||
<string name="set_as_playlist_thumbnail">Set as playlist thumbnail</string>
|
<string name="set_as_playlist_thumbnail">Set as playlist thumbnail</string>
|
||||||
<string name="unset_playlist_thumbnail">Unset thumbnail</string>
|
<string name="unset_playlist_thumbnail">Unset permanent thumbnail</string>
|
||||||
<string name="bookmark_playlist">Bookmark Playlist</string>
|
<string name="bookmark_playlist">Bookmark Playlist</string>
|
||||||
<string name="unbookmark_playlist">Remove Bookmark</string>
|
<string name="unbookmark_playlist">Remove Bookmark</string>
|
||||||
<string name="delete_playlist_prompt">Delete this playlist\?</string>
|
<string name="delete_playlist_prompt">Delete this playlist\?</string>
|
||||||
|
|
Loading…
Reference in a new issue