basic pin/unpin chat functionality
|
After Width: | Height: | Size: 633 B |
|
After Width: | Height: | Size: 1020 B |
|
After Width: | Height: | Size: 505 B |
|
After Width: | Height: | Size: 712 B |
|
After Width: | Height: | Size: 922 B |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 2.1 KiB |
|
After Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 3.3 KiB |
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item android:title="@string/pin_chat"
|
||||
android:id="@+id/menu_pin_selected"
|
||||
android:icon="@drawable/ic_pin_white"
|
||||
app:showAsAction="always"/>
|
||||
|
||||
</menu>
|
||||
@@ -183,6 +183,14 @@
|
||||
<string name="device_talk_explain">Messages in this chat are generated locally by your Delta Chat app. Its makers use it to inform about app updates and problems during usage.</string>
|
||||
<string name="device_talk_welcome_message">Welcome to Delta Chat! – Delta Chat looks and feels like other popular messenger apps, but does not involve centralized control, tracking or selling you, friends, colleagues or family out to large organizations.\n\nTechnically, Delta Chat is an email application with a modern chat interface. Email in a new dress if you will 👻\n\nUse Delta Chat with anyone out of billions of people: just use their e-mail address. Recipients don\'t need to install Delta Chat, visit websites or sign up anywhere - however, of course, if they like, you may point them to 👉 https://get.delta.chat</string>
|
||||
<string name="edit_contact">Edit contact</string>
|
||||
<!-- Translators: "Pin" here is the verb for pinning, making sth. sticky. this is NOT the appreviation for "pin number". -->
|
||||
<string name="pin_chat">Pin chat</string>
|
||||
<!-- Translators: this is the opposite of "Pin chat", removing the sticky-state from a chat. -->
|
||||
<string name="unpin_chat">Unpin chat</string>
|
||||
<!-- Translators: this is the verb for pinning, making sth. sticky. this is NOT the appreviation for "pin number". -->
|
||||
<string name="pin">Pin</string>
|
||||
<!-- Translators: this is the opposite of "Pin", removing the sticky-state from sth. -->
|
||||
<string name="unpin">Unpin</string>
|
||||
|
||||
<string name="mute_for_one_hour">Mute for 1 hour</string>
|
||||
<string name="mute_for_two_hours">Mute for 2 hours</string>
|
||||
|
||||
@@ -214,6 +214,19 @@ public class ConversationListFragment extends Fragment
|
||||
getLoaderManager().restartLoader(0, null, this);
|
||||
}
|
||||
|
||||
private void handlePinAllSelected() {
|
||||
final DcContext dcContext = DcHelper.getContext(getActivity());
|
||||
final Set<Long> selectedConversations = new HashSet<>(getListAdapter().getBatchSelections());
|
||||
boolean doPin = areSomeSelectedChatsUnpinned();
|
||||
for (long chatId : selectedConversations) {
|
||||
dcContext.archiveChat((int)chatId, doPin? 2 : 0);
|
||||
}
|
||||
if (actionMode != null) {
|
||||
actionMode.finish();
|
||||
actionMode = null;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private void handleArchiveAllSelected() {
|
||||
final DcContext dcContext = DcHelper.getContext(getActivity());
|
||||
@@ -405,6 +418,7 @@ public class ConversationListFragment extends Fragment
|
||||
if (adapter.getBatchSelections().size() == 0) {
|
||||
actionMode.finish();
|
||||
} else {
|
||||
updateActionModeItems(actionMode.getMenu());
|
||||
actionMode.setTitle(String.valueOf(getListAdapter().getBatchSelections().size()));
|
||||
}
|
||||
|
||||
@@ -419,6 +433,7 @@ public class ConversationListFragment extends Fragment
|
||||
getListAdapter().initializeBatchMode(true);
|
||||
getListAdapter().toggleThreadInBatchSet(item.getChatId());
|
||||
getListAdapter().notifyDataSetChanged();
|
||||
updateActionModeItems(actionMode.getMenu());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -429,7 +444,30 @@ public class ConversationListFragment extends Fragment
|
||||
public interface ConversationSelectedListener {
|
||||
void onCreateConversation(int chatId);
|
||||
void onSwitchToArchive();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean areSomeSelectedChatsUnpinned() {
|
||||
ApplicationDcContext dcContext = DcHelper.getContext(getActivity());
|
||||
final Set<Long> selectedChats = getListAdapter().getBatchSelections();
|
||||
for (long chatId : selectedChats) {
|
||||
DcChat dcChat = dcContext.getChat((int)chatId);
|
||||
if (dcChat.getArchived()!=2) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void updateActionModeItems(Menu menu) {
|
||||
MenuItem pinItem = menu.findItem(R.id.menu_pin_selected);
|
||||
if (areSomeSelectedChatsUnpinned()) {
|
||||
pinItem.setIcon(R.drawable.ic_pin_white);
|
||||
pinItem.setTitle(R.string.pin_chat);
|
||||
} else {
|
||||
pinItem.setIcon(R.drawable.ic_unpin_white);
|
||||
pinItem.setTitle(R.string.unpin_chat);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
|
||||
@@ -439,6 +477,8 @@ public class ConversationListFragment extends Fragment
|
||||
|
||||
MenuInflater inflater = getActivity().getMenuInflater();
|
||||
|
||||
inflater.inflate(R.menu.conversation_list_batch_pin, menu);
|
||||
|
||||
if (archive) inflater.inflate(R.menu.conversation_list_batch_unarchive, menu);
|
||||
else inflater.inflate(R.menu.conversation_list_batch_archive, menu);
|
||||
|
||||
@@ -463,6 +503,7 @@ public class ConversationListFragment extends Fragment
|
||||
switch (item.getItemId()) {
|
||||
case R.id.menu_select_all: handleSelectAllThreads(); return true;
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||