mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
allow to mute/unmute from chatlist (#2948)
This commit is contained in:
committed by
GitHub
parent
1388e1a996
commit
9a2968d502
@@ -7,8 +7,12 @@
|
||||
android:icon="?menu_trash_icon"
|
||||
app:showAsAction="always" />
|
||||
|
||||
<item android:title="@string/menu_mute"
|
||||
android:id="@+id/menu_mute_selected"
|
||||
app:showAsAction="never"/>
|
||||
|
||||
<item android:title="@string/menu_select_all"
|
||||
android:id="@+id/menu_select_all"
|
||||
app:showAsAction="never"/>
|
||||
|
||||
</menu>
|
||||
</menu>
|
||||
|
||||
@@ -311,6 +311,28 @@ public class ConversationListFragment extends Fragment
|
||||
}
|
||||
}
|
||||
|
||||
private void handleMuteAllSelected() {
|
||||
final DcContext dcContext = DcHelper.getContext(getActivity());
|
||||
final Set<Long> selectedConversations = new HashSet<>(getListAdapter().getBatchSelections());
|
||||
if (areSomeSelectedChatsUnmuted()) {
|
||||
MuteDialog.show(getActivity(), duration -> {
|
||||
for (long chatId : selectedConversations) {
|
||||
dcContext.setChatMuteDuration((int)chatId, duration);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// unmute
|
||||
for (long chatId : selectedConversations) {
|
||||
dcContext.setChatMuteDuration((int)chatId, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (actionMode != null) {
|
||||
actionMode.finish();
|
||||
actionMode = null;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private void handleArchiveAllSelected() {
|
||||
final DcContext dcContext = DcHelper.getContext(getActivity());
|
||||
@@ -546,6 +568,18 @@ public class ConversationListFragment extends Fragment
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean areSomeSelectedChatsUnmuted() {
|
||||
DcContext dcContext = DcHelper.getContext(getActivity());
|
||||
final Set<Long> selectedChats = getListAdapter().getBatchSelections();
|
||||
for (long chatId : selectedChats) {
|
||||
DcChat dcChat = dcContext.getChat((int)chatId);
|
||||
if (!dcChat.isMuted()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void updateActionModeItems(Menu menu) {
|
||||
// We do not show action mode icons when relaying (= sharing or forwarding).
|
||||
if (!isRelayingMessageContent(getActivity())) {
|
||||
@@ -557,6 +591,12 @@ public class ConversationListFragment extends Fragment
|
||||
pinItem.setIcon(R.drawable.ic_unpin_white);
|
||||
pinItem.setTitle(R.string.unpin_chat);
|
||||
}
|
||||
MenuItem muteItem = menu.findItem(R.id.menu_mute_selected);
|
||||
if (areSomeSelectedChatsUnmuted()) {
|
||||
muteItem.setTitle(R.string.menu_mute);
|
||||
} else {
|
||||
muteItem.setTitle(R.string.menu_unmute);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -602,6 +642,7 @@ public class ConversationListFragment extends Fragment
|
||||
case R.id.menu_delete_selected: handleDeleteAllSelected(); return true;
|
||||
case R.id.menu_pin_selected: handlePinAllSelected(); return true;
|
||||
case R.id.menu_archive_selected: handleArchiveAllSelected(); return true;
|
||||
case R.id.menu_mute_selected: handleMuteAllSelected(); return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user