blob: 7951a8ec4f3f9721f91f4a80680a9c7648c1311d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
package de.thedevstack.conversationsplus.ui.listeners;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import de.thedevstack.conversationsplus.entities.Contact;
import de.thedevstack.conversationsplus.entities.Conversation;
import de.thedevstack.conversationsplus.ui.ConferenceDetailsActivity;
import de.thedevstack.conversationsplus.ui.ContactDetailsActivity;
import de.thedevstack.conversationsplus.ui.XmppActivity;
/**
* This listener opens on click
* <ul>
* <li>the conference details activity if the conversation is a MUC conversation</li>
* <li>the contact details activity if the conversation is a One-To-One conversation</li>
* </ul>
*/
public class AvatarLogoOnClickListener implements View.OnClickListener {
private final Conversation conversation;
/**
* Initializes the on click listener for a conversation.
* @param conversation the conversation to be used
*/
public AvatarLogoOnClickListener(Conversation conversation) {
this.conversation = conversation;
}
/**
* Called when a view has been clicked.
*
* @param v The view that was clicked.
*/
@Override
public void onClick(View v) {
if (this.conversation.getMode() == Conversation.MODE_MULTI) {
this.openConferenceDetails(v.getContext());
} else {
this.openContactDetails(v.getContext());
}
}
/**
* Opens the conference details activity.
* @see de.thedevstack.conversationsplus.ui.ConversationFragment#onCreateView(LayoutInflater, ViewGroup, Bundle)
* @param context the context to start the activity from.
*/
private void openConferenceDetails(Context context) {
Intent intent = new Intent(context, ConferenceDetailsActivity.class);
intent.setAction(ConferenceDetailsActivity.ACTION_VIEW_MUC);
intent.putExtra("uuid", this.conversation.getUuid());
context.startActivity(intent);
}
/**
* Opens the contact details activity.
* @param context the context to start the activity from.
* @see de.thedevstack.conversationsplus.ui.ConversationActivity#onOptionsItemSelected(MenuItem)
*/
public void openContactDetails(Context context) {
Contact contact = this.conversation.getContact();
Intent intent = new Intent(context, ContactDetailsActivity.class);
intent.setAction(ContactDetailsActivity.ACTION_VIEW_CONTACT);
intent.putExtra(XmppActivity.EXTRA_ACCOUNT, contact.getAccount().getJid().toBareJid().toString());
intent.putExtra("contact", contact.getJid().toBareJid().toString());
intent.putExtra("fingerprint", (String)null);
context.startActivity(intent);
}
}
|