added 'view conversation' to context menu

This commit is contained in:
Daniel Gultsch 2018-04-29 14:07:58 +02:00
parent 43b455974b
commit 5c4aacd39e
3 changed files with 16 additions and 4 deletions

View File

@ -132,6 +132,9 @@ public class SearchActivity extends XmppActivity implements TextWatcher, OnSearc
final Message message = selectedMessageReference.get(); final Message message = selectedMessageReference.get();
if (message != null) { if (message != null) {
switch (item.getItemId()) { switch (item.getItemId()) {
case R.id.open_conversation:
switchToConversation(wrap(message.getConversation()));
break;
case R.id.share_with: case R.id.share_with:
ShareUtil.share(this, message); ShareUtil.share(this, message);
break; break;
@ -143,6 +146,7 @@ public class SearchActivity extends XmppActivity implements TextWatcher, OnSearc
break; break;
case R.id.quote_message: case R.id.quote_message:
quote(message); quote(message);
break;
} }
} }
return super.onContextItemSelected(item); return super.onContextItemSelected(item);
@ -151,17 +155,20 @@ public class SearchActivity extends XmppActivity implements TextWatcher, OnSearc
private void quote(Message message) { private void quote(Message message) {
String text = MessageUtils.prepareQuote(message); String text = MessageUtils.prepareQuote(message);
final Conversational conversational = message.getConversation(); final Conversational conversational = message.getConversation();
switchToConversationAndQuote(wrap(message.getConversation()), text);
}
private Conversation wrap(Conversational conversational) {
final Conversation conversation; final Conversation conversation;
if (conversational instanceof Conversation) { if (conversational instanceof Conversation) {
conversation = (Conversation) conversational; return (Conversation) conversational;
} else { } else {
conversation = xmppConnectionService.findOrCreateConversation(conversational.getAccount(), return xmppConnectionService.findOrCreateConversation(conversational.getAccount(),
conversational.getJid(), conversational.getJid(),
conversational.getMode() == Conversational.MODE_MULTI, conversational.getMode() == Conversational.MODE_MULTI,
true, true,
true); true);
} }
switchToConversationAndQuote(conversation, text);
} }
@Override @Override

View File

@ -28,7 +28,11 @@
~ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ~ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--> -->
<menu xmlns:android="http://schemas.android.com/apk/res/android" > <menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/open_conversation"
android:title="@string/view_conversation"/>
<item <item
android:id="@+id/share_with" android:id="@+id/share_with"

View File

@ -705,4 +705,5 @@
<string name="no_microphone_permission">Conversations needs access to the microphone</string> <string name="no_microphone_permission">Conversations needs access to the microphone</string>
<string name="search_messages">Search messages</string> <string name="search_messages">Search messages</string>
<string name="gif">GIF</string> <string name="gif">GIF</string>
<string name="view_conversation">View conversation</string>
</resources> </resources>