diff --git a/mastodon/src/main/java/org/joinmastodon/android/api/requests/lists/RemoveList.java b/mastodon/src/main/java/org/joinmastodon/android/api/requests/lists/DeleteList.java similarity index 60% rename from mastodon/src/main/java/org/joinmastodon/android/api/requests/lists/RemoveList.java rename to mastodon/src/main/java/org/joinmastodon/android/api/requests/lists/DeleteList.java index 4a14962a2..57b6b826c 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/api/requests/lists/RemoveList.java +++ b/mastodon/src/main/java/org/joinmastodon/android/api/requests/lists/DeleteList.java @@ -1,10 +1,9 @@ package org.joinmastodon.android.api.requests.lists; import org.joinmastodon.android.api.MastodonAPIRequest; -import java.util.List; -public class RemoveList extends MastodonAPIRequest { - public RemoveList(String listId){ +public class DeleteList extends MastodonAPIRequest { + public DeleteList(String listId){ super(HttpMethod.DELETE, "/lists/"+listId, Object.class); } } diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/ListTimelinesFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/ListTimelinesFragment.java index 1005a9ecf..bd1d32d3d 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ListTimelinesFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ListTimelinesFragment.java @@ -18,6 +18,7 @@ import androidx.recyclerview.widget.RecyclerView; import org.joinmastodon.android.R; import org.joinmastodon.android.api.MastodonAPIRequest; import org.joinmastodon.android.api.requests.lists.AddAccountsToList; +import org.joinmastodon.android.api.requests.lists.DeleteList; import org.joinmastodon.android.api.requests.lists.GetLists; import org.joinmastodon.android.api.requests.lists.RemoveAccountsFromList; import org.joinmastodon.android.model.ListTimeline; @@ -32,6 +33,7 @@ import java.util.List; import java.util.Map; import me.grishka.appkit.Nav; +import me.grishka.appkit.api.Callback; import me.grishka.appkit.api.ErrorResponse; import me.grishka.appkit.api.SimpleCallback; import me.grishka.appkit.fragments.BaseRecyclerFragment; @@ -180,8 +182,8 @@ public class ListTimelinesFragment extends BaseRecyclerFragment im } else { listToggle.setVisibility(View.GONE); } -// edit.setOnClickListener(); -// delete.setOnClickListener(); + edit.setOnClickListener(v -> this.editListName(item.id)); + delete.setOnClickListener(v -> this.deleteList(item.id)); } private void onClickToggle(View view) { @@ -193,12 +195,35 @@ public class ListTimelinesFragment extends BaseRecyclerFragment im UiUtils.openListTimeline(getActivity(), accountId, item); } -// private void editListName(){ -// new M3AlertDialogBuilder(getActivity()) -// .setTitle(R.string.edit_text_edited) + private void editListName(String listId){ + new M3AlertDialogBuilder(getActivity()) + .setTitle(R.string.edit_text_edited) // .setPositiveButton(R.string.discard, (dialog, which)-> ) -// .setNegativeButton(R.string.cancel, null) -// .show(); -// } + .setNegativeButton(R.string.cancel, null) + .show(); + } + + private void deleteList(String listId){ + new M3AlertDialogBuilder(getActivity()) + .setTitle(R.string.sk_delete_list_dialog_title) + .setPositiveButton(R.string.delete, (dialog, which)-> new DeleteList(listId)) + .setNegativeButton(R.string.cancel, null) + .show(); + } + + private void actuallyDeleteList(String listId){ + new DeleteList(listId).setCallback(new Callback() { + + @Override + public void onSuccess(Object result) { + loadData(); + } + + @Override + public void onError(ErrorResponse error) { + error.showToast(getActivity()); + } + }); + } } } diff --git a/mastodon/src/main/res/values/strings_sk.xml b/mastodon/src/main/res/values/strings_sk.xml index a4ba9cd93..5febec930 100644 --- a/mastodon/src/main/res/values/strings_sk.xml +++ b/mastodon/src/main/res/values/strings_sk.xml @@ -50,4 +50,5 @@ Material You Not supported on your device Lists picker + Delete list?