mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
make use of ask_delete_named_chat in case only one chat is about being deleted
This commit is contained in:
@@ -7,6 +7,7 @@ import static org.thoughtcrime.securesms.util.RelayUtil.isForwarding;
|
||||
import static org.thoughtcrime.securesms.util.RelayUtil.isRelayingMessageContent;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.TypedArray;
|
||||
@@ -246,17 +247,26 @@ public abstract class BaseConversationListFragment extends Fragment implements A
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private void handleDeleteAllSelected() {
|
||||
final DcContext dcContext = DcHelper.getContext(requireActivity());
|
||||
int conversationsCount = getListAdapter().getBatchSelections().size();
|
||||
AlertDialog.Builder alert = new AlertDialog.Builder(requireActivity());
|
||||
alert.setMessage(requireActivity().getResources().getQuantityString(R.plurals.ask_delete_chat,
|
||||
conversationsCount, conversationsCount));
|
||||
final Activity activity = requireActivity();
|
||||
final DcContext dcContext = DcHelper.getContext(activity);
|
||||
final Set<Long> selectedChats = getListAdapter().getBatchSelections();
|
||||
|
||||
final int chatsCount = selectedChats.size();
|
||||
final String alertText;
|
||||
if (chatsCount == 1) {
|
||||
long chatId = selectedChats.iterator().next();
|
||||
alertText = activity.getResources().getString(R.string.ask_delete_named_chat, dcContext.getChat((int)chatId).getName());
|
||||
} else {
|
||||
alertText = activity.getResources().getQuantityString(R.plurals.ask_delete_chat, chatsCount, chatsCount);
|
||||
}
|
||||
|
||||
AlertDialog.Builder alert = new AlertDialog.Builder(activity);
|
||||
alert.setMessage(alertText);
|
||||
alert.setCancelable(true);
|
||||
|
||||
alert.setPositiveButton(R.string.delete, (dialog, which) -> {
|
||||
final Set<Long> selectedConversations = getListAdapter().getBatchSelections();
|
||||
|
||||
if (!selectedConversations.isEmpty()) {
|
||||
if (!selectedChats.isEmpty()) {
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
private ProgressDialog dialog;
|
||||
|
||||
@@ -271,7 +281,7 @@ public abstract class BaseConversationListFragment extends Fragment implements A
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
int accountId = dcContext.getAccountId();
|
||||
for (long chatId : selectedConversations) {
|
||||
for (long chatId : selectedChats) {
|
||||
DcHelper.getNotificationCenter(requireContext()).removeNotifications(accountId, (int) chatId);
|
||||
dcContext.deleteChat((int) chatId);
|
||||
DirectShareUtil.clearShortcut(requireContext(), (int) chatId);
|
||||
|
||||
@@ -632,8 +632,9 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
}
|
||||
|
||||
private void handleDeleteChat() {
|
||||
|
||||
new AlertDialog.Builder(this)
|
||||
.setMessage(getResources().getQuantityString(R.plurals.ask_delete_chat, 1, 1))
|
||||
.setMessage(getResources().getString(R.string.ask_delete_named_chat, dcChat.getName()))
|
||||
.setPositiveButton(R.string.delete, (dialog, which) -> {
|
||||
dcContext.deleteChat(chatId);
|
||||
DirectShareUtil.clearShortcut(this, chatId);
|
||||
|
||||
Reference in New Issue
Block a user