aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2018-04-30 23:51:17 +0200
committerChristian Schneppe <christian@pix-art.de>2018-04-30 23:51:17 +0200
commit30442e84e1a845f4aed59d6c787c2f791b00ecdd (patch)
tree82f1dc89a0bd670d335aaab9450615494199fba2 /src/main/java/de/pixart
parentbae77ff8fe587e981caa44ba27f5371b7a6664f6 (diff)
click on avatars in message search opens contact details
Diffstat (limited to 'src/main/java/de/pixart')
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConversationFragment.java26
-rw-r--r--src/main/java/de/pixart/messenger/ui/SearchActivity.java25
-rw-r--r--src/main/java/de/pixart/messenger/ui/XmppActivity.java11
-rw-r--r--src/main/java/de/pixart/messenger/ui/util/ListViewUtils.java2
4 files changed, 41 insertions, 23 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
index 6d45cf306..bf16aa428 100644
--- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
+++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
@@ -1203,6 +1203,12 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
binding.messagesView.setTranscriptMode(ListView.TRANSCRIPT_MODE_NORMAL);
messageListAdapter = new MessageAdapter((XmppActivity) getActivity(), this.messageList);
messageListAdapter.setOnContactPictureClicked(message -> {
+ String fingerprint;
+ if (message.getEncryption() == Message.ENCRYPTION_PGP || message.getEncryption() == Message.ENCRYPTION_DECRYPTED) {
+ fingerprint = "pgp";
+ } else {
+ fingerprint = message.getFingerprint();
+ }
final boolean received = message.getStatus() <= Message.STATUS_RECEIVED;
if (received) {
if (message.getConversation() instanceof Conversation && message.getConversation().getMode() == Conversation.MODE_MULTI) {
@@ -1221,30 +1227,12 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
return;
} else {
if (!message.getContact().isSelf()) {
- String fingerprint;
- if (message.getEncryption() == Message.ENCRYPTION_PGP
- || message.getEncryption() == Message.ENCRYPTION_DECRYPTED) {
- fingerprint = "pgp";
- } else {
- fingerprint = message.getFingerprint();
- }
activity.switchToContactDetails(message.getContact(), fingerprint);
return;
}
}
}
- Account account = message.getConversation().getAccount();
- Intent intent = new Intent(activity, EditAccountActivity.class);
- intent.putExtra("jid", account.getJid().asBareJid().toString());
- String fingerprint;
- if (message.getEncryption() == Message.ENCRYPTION_PGP
- || message.getEncryption() == Message.ENCRYPTION_DECRYPTED) {
- fingerprint = "pgp";
- } else {
- fingerprint = message.getFingerprint();
- }
- intent.putExtra("fingerprint", fingerprint);
- startActivity(intent);
+ activity.switchToAccount(message.getConversation().getAccount(), fingerprint);
});
messageListAdapter.setOnContactPictureLongClicked(message -> {
if (message.getStatus() <= Message.STATUS_RECEIVED) {
diff --git a/src/main/java/de/pixart/messenger/ui/SearchActivity.java b/src/main/java/de/pixart/messenger/ui/SearchActivity.java
index 28e4ef5b4..d90f5e10a 100644
--- a/src/main/java/de/pixart/messenger/ui/SearchActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/SearchActivity.java
@@ -44,6 +44,7 @@ import java.util.List;
import de.pixart.messenger.R;
import de.pixart.messenger.databinding.ActivitySearchBinding;
+import de.pixart.messenger.entities.Contact;
import de.pixart.messenger.entities.Message;
import de.pixart.messenger.services.MessageSearchTask;
import de.pixart.messenger.ui.adapter.MessageAdapter;
@@ -55,7 +56,7 @@ import de.pixart.messenger.ui.util.ListViewUtils;
import static de.pixart.messenger.ui.util.SoftKeyboardUtils.hideSoftKeyboard;
import static de.pixart.messenger.ui.util.SoftKeyboardUtils.showKeyboard;
-public class SearchActivity extends XmppActivity implements TextWatcher, OnSearchResultsAvailable {
+public class SearchActivity extends XmppActivity implements TextWatcher, OnSearchResultsAvailable, MessageAdapter.OnContactPictureClicked {
private final List<Message> messages = new ArrayList<>();
private ActivitySearchBinding binding;
@@ -68,6 +69,7 @@ public class SearchActivity extends XmppActivity implements TextWatcher, OnSearc
setSupportActionBar((Toolbar) this.binding.toolbar);
configureActionBar(getSupportActionBar());
this.messageListAdapter = new MessageAdapter(this, this.messages);
+ this.messageListAdapter.setOnContactPictureClicked(this);
this.binding.searchResults.setAdapter(messageListAdapter);
}
@@ -147,4 +149,25 @@ public class SearchActivity extends XmppActivity implements TextWatcher, OnSearc
});
}
+ @Override
+ public void onContactPictureClicked(Message message) {
+ String fingerprint;
+ if (message.getEncryption() == Message.ENCRYPTION_PGP || message.getEncryption() == Message.ENCRYPTION_DECRYPTED) {
+ fingerprint = "pgp";
+ } else {
+ fingerprint = message.getFingerprint();
+ }
+ if (message.getStatus() == Message.STATUS_RECEIVED) {
+ final Contact contact = message.getContact();
+ if (contact != null) {
+ if (contact.isSelf()) {
+ switchToAccount(message.getConversation().getAccount(), fingerprint);
+ } else {
+ switchToContactDetails(contact, fingerprint);
+ }
+ }
+ } else {
+ switchToAccount(message.getConversation().getAccount(), fingerprint);
+ }
+ }
} \ No newline at end of file
diff --git a/src/main/java/de/pixart/messenger/ui/XmppActivity.java b/src/main/java/de/pixart/messenger/ui/XmppActivity.java
index 991111634..702f9a5c6 100644
--- a/src/main/java/de/pixart/messenger/ui/XmppActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/XmppActivity.java
@@ -518,17 +518,24 @@ public abstract class XmppActivity extends ActionBarActivity {
startActivity(intent);
}
+ public void switchToAccount(Account account, String fingerprint) {
+ switchToAccount(account, false, fingerprint);
+ }
+
public void switchToAccount(Account account) {
- switchToAccount(account, false);
+ switchToAccount(account, false, null);
}
- public void switchToAccount(Account account, boolean init) {
+ public void switchToAccount(Account account, boolean init, String fingerprint) {
Intent intent = new Intent(this, EditAccountActivity.class);
intent.putExtra("jid", account.getJid().asBareJid().toString());
intent.putExtra("init", init);
if (init) {
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NO_ANIMATION);
}
+ if (fingerprint != null) {
+ intent.putExtra("fingerprint", fingerprint);
+ }
startActivity(intent);
if (init) {
overridePendingTransition(0, 0);
diff --git a/src/main/java/de/pixart/messenger/ui/util/ListViewUtils.java b/src/main/java/de/pixart/messenger/ui/util/ListViewUtils.java
index c35ec3724..b797877e4 100644
--- a/src/main/java/de/pixart/messenger/ui/util/ListViewUtils.java
+++ b/src/main/java/de/pixart/messenger/ui/util/ListViewUtils.java
@@ -33,7 +33,7 @@ import android.widget.ListView;
public class ListViewUtils {
public static void scrollToBottom(final ListView listView) {
- int count = listView.getAdapter().getCount();
+ final int count = listView.getAdapter().getCount();
if (count > 0) {
setSelection(listView, count - 1, true);
}