aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs/conversations
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2014-03-05 15:41:14 +0100
committerDaniel Gultsch <daniel@gultsch.de>2014-03-05 15:41:14 +0100
commit78312d71dd1f281f494a2a1c04e4a80f34898d2c (patch)
tree595d3f78836691fc8eb204a3102b8781c4e3bd14 /src/eu/siacs/conversations
parent79ec8b2e8128a1dc1d7d0962ce99e91fdaff8b98 (diff)
reworked contact details
Diffstat (limited to 'src/eu/siacs/conversations')
-rw-r--r--src/eu/siacs/conversations/entities/Contact.java4
-rw-r--r--src/eu/siacs/conversations/persistance/DatabaseBackend.java14
-rw-r--r--src/eu/siacs/conversations/services/XmppConnectionService.java17
-rw-r--r--src/eu/siacs/conversations/ui/ContactDetailsActivity.java226
-rw-r--r--src/eu/siacs/conversations/ui/ConversationActivity.java22
-rw-r--r--src/eu/siacs/conversations/ui/ConversationFragment.java4
-rw-r--r--src/eu/siacs/conversations/ui/DialogContactDetails.java218
-rw-r--r--src/eu/siacs/conversations/ui/MucDetailsActivity.java (renamed from src/eu/siacs/conversations/ui/MucOptionsActivity.java)31
-rw-r--r--src/eu/siacs/conversations/ui/NewConversationActivity.java15
-rw-r--r--src/eu/siacs/conversations/ui/XmppActivity.java14
10 files changed, 307 insertions, 258 deletions
diff --git a/src/eu/siacs/conversations/entities/Contact.java b/src/eu/siacs/conversations/entities/Contact.java
index 0eed39ed..4b97cc41 100644
--- a/src/eu/siacs/conversations/entities/Contact.java
+++ b/src/eu/siacs/conversations/entities/Contact.java
@@ -293,4 +293,8 @@ public class Contact extends AbstractEntity implements Serializable {
public boolean isInRoster() {
return this.inRoster;
}
+
+ public String getAccountUuid() {
+ return this.accountUuid;
+ }
}
diff --git a/src/eu/siacs/conversations/persistance/DatabaseBackend.java b/src/eu/siacs/conversations/persistance/DatabaseBackend.java
index 1a6f934a..e2067141 100644
--- a/src/eu/siacs/conversations/persistance/DatabaseBackend.java
+++ b/src/eu/siacs/conversations/persistance/DatabaseBackend.java
@@ -228,7 +228,7 @@ public class DatabaseBackend extends SQLiteOpenHelper {
}
}
- public List<Contact> getContacts(Account account) {
+ public List<Contact> getContactsByAccount(Account account) {
List<Contact> list = new ArrayList<Contact>();
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor;
@@ -246,7 +246,7 @@ public class DatabaseBackend extends SQLiteOpenHelper {
return list;
}
- public List<Contact> getContats(String where) {
+ public List<Contact> getContacts(String where) {
List<Contact> list = new ArrayList<Contact>();
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.query(Contact.TABLENAME, null, where, null, null, null, null);
@@ -280,5 +280,15 @@ public class DatabaseBackend extends SQLiteOpenHelper {
db.delete(Contact.TABLENAME, Contact.UUID + "=?", args);
}
+ public Contact getContact(String uuid) {
+ SQLiteDatabase db = this.getWritableDatabase();
+ String[] args = { uuid };
+ Cursor cursor = db.query(Contact.TABLENAME, null, Contact.UUID + "=?", args, null, null, null);
+ if (cursor.getCount() == 0)
+ return null;
+ cursor.moveToFirst();
+ return Contact.fromCursor(cursor);
+ }
+
}
diff --git a/src/eu/siacs/conversations/services/XmppConnectionService.java b/src/eu/siacs/conversations/services/XmppConnectionService.java
index 48f0e470..e973afa9 100644
--- a/src/eu/siacs/conversations/services/XmppConnectionService.java
+++ b/src/eu/siacs/conversations/services/XmppConnectionService.java
@@ -535,7 +535,7 @@ public class XmppConnectionService extends Service {
public void getRoster(Account account,
final OnRosterFetchedListener listener) {
- List<Contact> contacts = databaseBackend.getContacts(account);
+ List<Contact> contacts = databaseBackend.getContactsByAccount(account);
for (int i = 0; i < contacts.size(); ++i) {
contacts.get(i).setAccount(account);
}
@@ -575,7 +575,7 @@ public class XmppConnectionService extends Service {
mWhere.append(account.getUuid());
mWhere.append("\"");
List<Contact> contactsToDelete = databaseBackend
- .getContats(mWhere.toString());
+ .getContacts(mWhere.toString());
for (Contact contact : contactsToDelete) {
databaseBackend.deleteContact(contact);
replaceContactInConversation(contact.getJid(),
@@ -604,7 +604,7 @@ public class XmppConnectionService extends Service {
public void onPhoneContactsLoaded(
Hashtable<String, Bundle> phoneContacts) {
List<Contact> contacts = databaseBackend
- .getContacts(null);
+ .getContactsByAccount(null);
for (int i = 0; i < contacts.size(); ++i) {
Contact contact = contacts.get(i);
if (phoneContacts.containsKey(contact.getJid())) {
@@ -938,6 +938,7 @@ public class XmppConnectionService extends Service {
public void updateContact(Contact contact) {
databaseBackend.updateContact(contact);
+ replaceContactInConversation(contact.getJid(), contact);
}
public void updateMessage(Message message) {
@@ -1035,4 +1036,14 @@ public class XmppConnectionService extends Service {
public void updateConversation(Conversation conversation) {
this.databaseBackend.updateConversation(conversation);
}
+
+ public Contact findContact(String uuid) {
+ Contact contact = this.databaseBackend.getContact(uuid);
+ for(Account account : getAccounts()) {
+ if (contact.getAccountUuid().equals(account.getUuid())) {
+ contact.setAccount(account);
+ }
+ }
+ return contact;
+ }
} \ No newline at end of file
diff --git a/src/eu/siacs/conversations/ui/ContactDetailsActivity.java b/src/eu/siacs/conversations/ui/ContactDetailsActivity.java
new file mode 100644
index 00000000..23fb68a1
--- /dev/null
+++ b/src/eu/siacs/conversations/ui/ContactDetailsActivity.java
@@ -0,0 +1,226 @@
+package eu.siacs.conversations.ui;
+
+import android.app.AlertDialog;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Bundle;
+import android.provider.ContactsContract.CommonDataKinds;
+import android.provider.ContactsContract.Contacts;
+import android.provider.ContactsContract.Intents;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.CheckBox;
+import android.widget.EditText;
+import android.widget.QuickContactBadge;
+import android.widget.TextView;
+import eu.siacs.conversations.R;
+import eu.siacs.conversations.entities.Contact;
+import eu.siacs.conversations.entities.Presences;
+import eu.siacs.conversations.utils.UIHelper;
+
+public class ContactDetailsActivity extends XmppActivity {
+ public static final String ACTION_VIEW_CONTACT = "view_contact";
+
+ protected ContactDetailsActivity activity = this;
+
+ private String uuid;
+ private Contact contact;
+
+ private EditText name;
+ private TextView contactJid;
+ private TextView accountJid;
+ private TextView status;
+ private CheckBox send;
+ private CheckBox receive;
+ private QuickContactBadge badge;
+
+ private DialogInterface.OnClickListener removeFromRoster = new DialogInterface.OnClickListener() {
+
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ activity.xmppConnectionService.deleteContact(contact);
+ activity.finish();
+ }
+ };
+
+ private DialogInterface.OnClickListener editContactNameListener = new DialogInterface.OnClickListener() {
+
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ contact.setDisplayName(name.getText().toString());
+ activity.xmppConnectionService.updateContact(contact);
+ populateView();
+ }
+ };
+
+ private DialogInterface.OnClickListener addToPhonebook = new DialogInterface.OnClickListener() {
+
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT);
+ intent.setType(Contacts.CONTENT_ITEM_TYPE);
+ intent.putExtra(Intents.Insert.IM_HANDLE, contact.getJid());
+ intent.putExtra(Intents.Insert.IM_PROTOCOL,
+ CommonDataKinds.Im.PROTOCOL_JABBER);
+ intent.putExtra("finishActivityOnSaveCompleted", true);
+ activity.startActivityForResult(intent, 0);
+ }
+ };
+ private OnClickListener onBadgeClick = new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(activity);
+ builder.setTitle("Add to phone book");
+ builder.setMessage("Do you want to add " + contact.getJid()
+ + " to your phones contact list?");
+ builder.setNegativeButton("Cancel", null);
+ builder.setPositiveButton("Add", addToPhonebook);
+ builder.create().show();
+ }
+ };
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ if (getIntent().getAction().equals(ACTION_VIEW_CONTACT)) {
+ this.uuid = getIntent().getExtras().getString("uuid");
+ }
+ setContentView(R.layout.activity_contact_details);
+
+ contactJid = (TextView) findViewById(R.id.details_contactjid);
+ accountJid = (TextView) findViewById(R.id.details_account);
+ status = (TextView) findViewById(R.id.details_contactstatus);
+ send = (CheckBox) findViewById(R.id.details_send_presence);
+ receive = (CheckBox) findViewById(R.id.details_receive_presence);
+ badge = (QuickContactBadge) findViewById(R.id.details_contact_badge);
+
+ getActionBar().setHomeButtonEnabled(true);
+ getActionBar().setDisplayHomeAsUpEnabled(true);
+
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem menuItem) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ builder.setNegativeButton("Cancel", null);
+ switch (menuItem.getItemId()) {
+ case android.R.id.home:
+ finish();
+ break;
+ case R.id.action_delete_contact:
+ builder.setTitle("Delete from roster")
+ .setMessage(getString(R.string.remove_contact_text, contact.getJid()))
+ .setPositiveButton("Delete", removeFromRoster).create()
+ .show();
+ break;
+ case R.id.action_edit_contact:
+ if (contact.getSystemAccount() == null) {
+
+ View view = (View) getLayoutInflater().inflate(R.layout.edit_contact_name, null);
+ name = (EditText) view.findViewById(R.id.editText1);
+ name.setText(contact.getDisplayName());
+ builder.setView(view)
+ .setTitle(contact.getJid())
+ .setPositiveButton("Edit", editContactNameListener)
+ .create().show();
+
+ } else {
+ Intent intent = new Intent(Intent.ACTION_EDIT);
+ String[] systemAccount = contact.getSystemAccount().split("#");
+ long id = Long.parseLong(systemAccount[0]);
+ Uri uri = Contacts.getLookupUri(id, systemAccount[1]);
+ intent.setDataAndType(uri,Contacts.CONTENT_ITEM_TYPE);
+ intent.putExtra("finishActivityOnSaveCompleted", true);
+ startActivity(intent);
+ }
+ break;
+ }
+ return super.onOptionsItemSelected(menuItem);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.contact_details, menu);
+ return true;
+ }
+
+ private void populateView() {
+ setTitle(contact.getDisplayName());
+ if (contact.getSubscriptionOption(Contact.Subscription.FROM)) {
+ send.setChecked(true);
+ } else {
+ send.setText("Preemptively grant subscription request");
+ if (contact
+ .getSubscriptionOption(Contact.Subscription.PREEMPTIVE_GRANT)) {
+ send.setChecked(true);
+ } else {
+ send.setChecked(false);
+ }
+ }
+ if (contact.getSubscriptionOption(Contact.Subscription.TO)) {
+ receive.setChecked(true);
+ } else {
+ receive.setText("Request presence updates");
+ if (contact
+ .getSubscriptionOption(Contact.Subscription.ASKING)) {
+ receive.setChecked(true);
+ } else {
+ receive.setChecked(false);
+ }
+ }
+
+ switch (contact.getMostAvailableStatus()) {
+ case Presences.CHAT:
+ status.setText("free to chat");
+ status.setTextColor(0xFF83b600);
+ break;
+ case Presences.ONLINE:
+ status.setText("online");
+ status.setTextColor(0xFF83b600);
+ break;
+ case Presences.AWAY:
+ status.setText("away");
+ status.setTextColor(0xFFffa713);
+ break;
+ case Presences.XA:
+ status.setText("extended away");
+ status.setTextColor(0xFFffa713);
+ break;
+ case Presences.DND:
+ status.setText("do not disturb");
+ status.setTextColor(0xFFe92727);
+ break;
+ case Presences.OFFLINE:
+ status.setText("offline");
+ status.setTextColor(0xFFe92727);
+ break;
+ default:
+ status.setText("offline");
+ status.setTextColor(0xFFe92727);
+ break;
+ }
+ contactJid.setText(contact.getJid());
+ accountJid.setText(contact.getAccount().getJid());
+
+ UIHelper.prepareContactBadge(this, badge, contact);
+
+ if (contact.getSystemAccount() == null) {
+ badge.setOnClickListener(onBadgeClick);
+ }
+ }
+
+ @Override
+ public void onBackendConnected() {
+ if (uuid != null) {
+ this.contact = xmppConnectionService.findContact(uuid);
+ if (this.contact != null) {
+ populateView();
+ }
+ }
+ }
+
+}
diff --git a/src/eu/siacs/conversations/ui/ConversationActivity.java b/src/eu/siacs/conversations/ui/ConversationActivity.java
index 4815957e..d4d0e565 100644
--- a/src/eu/siacs/conversations/ui/ConversationActivity.java
+++ b/src/eu/siacs/conversations/ui/ConversationActivity.java
@@ -162,9 +162,9 @@ public class ConversationActivity extends XmppActivity {
}
((TextView) view.findViewById(R.id.conversation_lastupdate))
- .setText(UIHelper.readableTimeDifference(getItem(position).getLatestMessage().getTimeSent()));
+ .setText(UIHelper.readableTimeDifference(conv.getLatestMessage().getTimeSent()));
- Uri profilePhoto = getItem(position).getProfilePhotoUri();
+ Uri profilePhoto = conv.getProfilePhotoUri();
ImageView imageView = (ImageView) view.findViewById(R.id.conversation_image);
if (profilePhoto!=null) {
imageView.setImageURI(profilePhoto);
@@ -272,12 +272,6 @@ public class ConversationActivity extends XmppActivity {
case android.R.id.home:
spl.openPane();
break;
- case R.id.action_settings:
- startActivity(new Intent(this, SettingsActivity.class));
- break;
- case R.id.action_accounts:
- startActivity(new Intent(this, ManageAccountActivity.class));
- break;
case R.id.action_add:
startActivity(new Intent(this, NewConversationActivity.class));
break;
@@ -290,12 +284,12 @@ public class ConversationActivity extends XmppActivity {
selectedConversation = conversationList.get(0);
break;
case R.id.action_contact_details:
- DialogContactDetails details = new DialogContactDetails();
Contact contact = this.getSelectedConversation().getContact();
if (contact != null) {
- contact.setAccount(this.selectedConversation.getAccount());
- details.setContact(contact);
- details.show(getFragmentManager(), "details");
+ Intent intent = new Intent(this,ContactDetailsActivity.class);
+ intent.setAction(ContactDetailsActivity.ACTION_VIEW_CONTACT);
+ intent.putExtra("uuid", contact.getUuid());
+ startActivity(intent);
} else {
String jid = getSelectedConversation().getContactJid();
AlertDialog.Builder builder = new AlertDialog.Builder(this);
@@ -307,8 +301,8 @@ public class ConversationActivity extends XmppActivity {
}
break;
case R.id.action_muc_details:
- Intent intent = new Intent(this,MucOptionsActivity.class);
- intent.setAction(MucOptionsActivity.ACTION_VIEW_MUC);
+ Intent intent = new Intent(this,MucDetailsActivity.class);
+ intent.setAction(MucDetailsActivity.ACTION_VIEW_MUC);
intent.putExtra("uuid", getSelectedConversation().getUuid());
startActivity(intent);
break;
diff --git a/src/eu/siacs/conversations/ui/ConversationFragment.java b/src/eu/siacs/conversations/ui/ConversationFragment.java
index b64fe5b2..6c88fcb3 100644
--- a/src/eu/siacs/conversations/ui/ConversationFragment.java
+++ b/src/eu/siacs/conversations/ui/ConversationFragment.java
@@ -109,8 +109,8 @@ public class ConversationFragment extends Fragment {
@Override
public void onClick(View v) {
- Intent intent = new Intent(getActivity(),MucOptionsActivity.class);
- intent.setAction(MucOptionsActivity.ACTION_VIEW_MUC);
+ Intent intent = new Intent(getActivity(),MucDetailsActivity.class);
+ intent.setAction(MucDetailsActivity.ACTION_VIEW_MUC);
intent.putExtra("uuid", conversation.getUuid());
startActivity(intent);
}
diff --git a/src/eu/siacs/conversations/ui/DialogContactDetails.java b/src/eu/siacs/conversations/ui/DialogContactDetails.java
deleted file mode 100644
index 1210bc3c..00000000
--- a/src/eu/siacs/conversations/ui/DialogContactDetails.java
+++ /dev/null
@@ -1,218 +0,0 @@
-package eu.siacs.conversations.ui;
-
-import eu.siacs.conversations.R;
-import eu.siacs.conversations.entities.Contact;
-import eu.siacs.conversations.entities.Presences;
-import eu.siacs.conversations.utils.UIHelper;
-import android.app.AlertDialog;
-import android.app.Dialog;
-import android.app.DialogFragment;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.os.Bundle;
-import android.provider.ContactsContract.CommonDataKinds;
-import android.provider.ContactsContract.Contacts;
-import android.provider.ContactsContract.Intents;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.widget.CheckBox;
-import android.widget.QuickContactBadge;
-import android.widget.TextView;
-
-public class DialogContactDetails extends DialogFragment {
-
- private Contact contact = null;
- boolean displayingInRoster = false;
-
- private DialogContactDetails mDetailsDialog = this;
- private XmppActivity activity;
-
- private CheckBox send;
- private CheckBox receive;
-
- private DialogInterface.OnClickListener askRemoveFromRoster = new DialogInterface.OnClickListener() {
-
- @Override
- public void onClick(DialogInterface dialog, int which) {
- AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
- builder.setTitle("Delete from roster");
- builder.setMessage("Do you want to delete "+contact.getJid()+" from your roster. The conversation assoziated with this account will not be removed.");
- builder.setNegativeButton("Cancel", null);
- builder.setPositiveButton("Delete",removeFromRoster);
- builder.create().show();
- }
- };
-
- private DialogInterface.OnClickListener removeFromRoster = new DialogInterface.OnClickListener() {
-
- @Override
- public void onClick(DialogInterface dialog, int which) {
- activity.xmppConnectionService.deleteContact(contact);
- mDetailsDialog.dismiss();
- }
- };
-
- private DialogInterface.OnClickListener addToPhonebook = new DialogInterface.OnClickListener() {
-
- @Override
- public void onClick(DialogInterface dialog, int which) {
- Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT);
- intent.setType(Contacts.CONTENT_ITEM_TYPE);
- intent.putExtra(Intents.Insert.IM_HANDLE,contact.getJid());
- intent.putExtra(Intents.Insert.IM_PROTOCOL,CommonDataKinds.Im.PROTOCOL_JABBER);
- intent.putExtra("finishActivityOnSaveCompleted", true);
- getActivity().startActivityForResult(intent,0);
- mDetailsDialog.dismiss();
- }
- };
-
- private DialogInterface.OnClickListener updateSubscriptions = new DialogInterface.OnClickListener() {
-
- @Override
- public void onClick(DialogInterface dialog, int which) {
- boolean needsUpdating = false;
- if (contact.getSubscriptionOption(Contact.Subscription.FROM)) {
- if (!send.isChecked()) {
- contact.resetSubscriptionOption(Contact.Subscription.FROM);
- contact.resetSubscriptionOption(Contact.Subscription.PREEMPTIVE_GRANT);
- activity.xmppConnectionService.stopPresenceUpdatesTo(contact);
- needsUpdating=true;
- }
- } else {
- if (contact.getSubscriptionOption(Contact.Subscription.PREEMPTIVE_GRANT)) {
- if (!send.isChecked()) {
- contact.resetSubscriptionOption(Contact.Subscription.PREEMPTIVE_GRANT);
- needsUpdating=true;
- }
- } else {
- if (send.isChecked()) {
- contact.setSubscriptionOption(Contact.Subscription.PREEMPTIVE_GRANT);
- needsUpdating=true;
- }
- }
- }
- if (contact.getSubscriptionOption(Contact.Subscription.TO)) {
- if (!receive.isChecked()) {
- contact.resetSubscriptionOption(Contact.Subscription.TO);
- activity.xmppConnectionService.stopPresenceUpdatesFrom(contact);
- needsUpdating=true;
- }
- } else {
- if (contact.getSubscriptionOption(Contact.Subscription.ASKING)) {
- if (!receive.isChecked()) {
- contact.resetSubscriptionOption(Contact.Subscription.ASKING);
- activity.xmppConnectionService.stopPresenceUpdatesFrom(contact);
- needsUpdating=true;
- }
- } else {
- if (receive.isChecked()) {
- contact.setSubscriptionOption(Contact.Subscription.ASKING);
- activity.xmppConnectionService.requestPresenceUpdatesFrom(contact);
- needsUpdating=true;
- }
- }
- }
- if (needsUpdating) {
- activity.xmppConnectionService.updateContact(contact);
- }
- }
- };
-
- public void setContact(Contact contact) {
- this.contact = contact;
- }
-
- @Override
- public Dialog onCreateDialog(Bundle savedInstanceState) {
- this.activity = (XmppActivity) getActivity();
- AlertDialog.Builder builder = new AlertDialog.Builder(this.activity);
- LayoutInflater inflater = getActivity().getLayoutInflater();
- View view = inflater.inflate(R.layout.dialog_contact_details, null);
- TextView contactJid = (TextView) view.findViewById(R.id.details_contactjid);
- TextView accountJid = (TextView) view.findViewById(R.id.details_account);
- TextView status = (TextView) view.findViewById(R.id.details_contactstatus);
- send = (CheckBox) view.findViewById(R.id.details_send_presence);
- receive = (CheckBox) view.findViewById(R.id.details_receive_presence);
- //ImageView contactPhoto = (ImageView) view.findViewById(R.id.details_contact_picture);
- QuickContactBadge badge = (QuickContactBadge) view.findViewById(R.id.details_contact_badge);
-
- if (contact.getSubscriptionOption(Contact.Subscription.FROM)) {
- send.setChecked(true);
- } else {
- send.setText("Preemptively grant subscription request");
- if (contact.getSubscriptionOption(Contact.Subscription.PREEMPTIVE_GRANT)) {
- send.setChecked(true);
- } else {
- send.setChecked(false);
- }
- }
- if (contact.getSubscriptionOption(Contact.Subscription.TO)) {
- receive.setChecked(true);
- } else {
- receive.setText("Request presence updates");
- if (contact.getSubscriptionOption(Contact.Subscription.ASKING)) {
- receive.setChecked(true);
- } else {
- receive.setChecked(false);
- }
- }
-
- switch (contact.getMostAvailableStatus()) {
- case Presences.CHAT:
- status.setText("free to chat");
- status.setTextColor(0xFF83b600);
- break;
- case Presences.ONLINE:
- status.setText("online");
- status.setTextColor(0xFF83b600);
- break;
- case Presences.AWAY:
- status.setText("away");
- status.setTextColor(0xFFffa713);
- break;
- case Presences.XA:
- status.setText("extended away");
- status.setTextColor(0xFFffa713);
- break;
- case Presences.DND:
- status.setText("do not disturb");
- status.setTextColor(0xFFe92727);
- break;
- case Presences.OFFLINE:
- status.setText("offline");
- status.setTextColor(0xFFe92727);
- break;
- default:
- status.setText("offline");
- status.setTextColor(0xFFe92727);
- break;
- }
- contactJid.setText(contact.getJid());
- accountJid.setText(contact.getAccount().getJid());
-
- UIHelper.prepareContactBadge(getActivity(), badge, contact);
-
- if (contact.getSystemAccount()==null) {
- badge.setOnClickListener(new OnClickListener() {
-
- @Override
- public void onClick(View v) {
- AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
- builder.setTitle("Add to phone book");
- builder.setMessage("Do you want to add "+contact.getJid()+" to your phones contact list?");
- builder.setNegativeButton("Cancel", null);
- builder.setPositiveButton("Add",addToPhonebook);
- builder.create().show();
- }
- });
- }
-
- builder.setView(view);
- builder.setTitle(contact.getDisplayName());
-
- builder.setNeutralButton("Done", this.updateSubscriptions);
- builder.setPositiveButton("Remove from roster", this.askRemoveFromRoster);
- return builder.create();
- }
-}
diff --git a/src/eu/siacs/conversations/ui/MucOptionsActivity.java b/src/eu/siacs/conversations/ui/MucDetailsActivity.java
index 4381eac4..f28fb480 100644
--- a/src/eu/siacs/conversations/ui/MucOptionsActivity.java
+++ b/src/eu/siacs/conversations/ui/MucDetailsActivity.java
@@ -12,6 +12,8 @@ import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
@@ -22,15 +24,13 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
-public class MucOptionsActivity extends XmppActivity {
+public class MucDetailsActivity extends XmppActivity {
public static final String ACTION_VIEW_MUC = "view_muc";
- private XmppActivity activity = this;
private Conversation conversation;
private EditText mYourNick;
private TextView mRoleAffiliaton;
private TextView mFullJid;
private LinearLayout membersView;
- private TextView mTextParticipantsHead;
private LinearLayout mMoreDetails;
private String uuid = null;
private ArrayAdapter<User> contactsAdapter;
@@ -56,9 +56,8 @@ public class MucOptionsActivity extends XmppActivity {
if (getIntent().getAction().equals(ACTION_VIEW_MUC)) {
this.uuid = getIntent().getExtras().getString("uuid");
}
- setContentView(R.layout.muc_options);
+ setContentView(R.layout.activity_muc_details);
mYourNick = (EditText) findViewById(R.id.muc_your_nick);
- mTextParticipantsHead = (TextView) findViewById(R.id.muc_participants_header);
mFullJid = (TextView) findViewById(R.id.muc_jabberid);
ImageButton imageButton = (ImageButton) findViewById(R.id.muc_edit_nick);
imageButton.setOnClickListener(this.changeNickListener);
@@ -86,10 +85,18 @@ public class MucOptionsActivity extends XmppActivity {
return view;
}
};
+ getActionBar().setHomeButtonEnabled(true);
+ getActionBar().setDisplayHomeAsUpEnabled(true);
+
}
-
- public void setConversation(Conversation conversation) {
- this.conversation = conversation;
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem menuItem) {
+ switch (menuItem.getItemId()) {
+ case android.R.id.home:
+ finish();
+ }
+ return super.onOptionsItemSelected(menuItem);
}
public String getReadableRole(int role) {
@@ -104,6 +111,12 @@ public class MucOptionsActivity extends XmppActivity {
return "";
}
}
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.muc_details, menu);
+ return true;
+ }
@Override
void onBackendConnected() {
@@ -114,6 +127,7 @@ public class MucOptionsActivity extends XmppActivity {
}
}
if (this.conversation != null) {
+ setTitle(conversation.getName());
mFullJid.setText(conversation.getContactJid().split("/")[0]);
mYourNick.setText(conversation.getMucOptions().getNick());
mRoleAffiliaton = (TextView) findViewById(R.id.muc_role);
@@ -139,6 +153,7 @@ public class MucOptionsActivity extends XmppActivity {
this.users.addAll(conversation.getMucOptions().getUsers());
contactsAdapter.notifyDataSetChanged();
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ membersView.removeAllViews();
for(User contact : conversation.getMucOptions().getUsers()) {
View view = (View) inflater.inflate(R.layout.contact, null);
diff --git a/src/eu/siacs/conversations/ui/NewConversationActivity.java b/src/eu/siacs/conversations/ui/NewConversationActivity.java
index 628a3047..4b323c26 100644
--- a/src/eu/siacs/conversations/ui/NewConversationActivity.java
+++ b/src/eu/siacs/conversations/ui/NewConversationActivity.java
@@ -39,7 +39,6 @@ import android.content.Intent;
public class NewConversationActivity extends XmppActivity {
- protected List<Contact> phoneContacts = new ArrayList<Contact>();
protected List<Contact> rosterContacts = new ArrayList<Contact>();
protected List<Contact> aggregatedContacts = new ArrayList<Contact>();
protected ListView contactsView;
@@ -188,10 +187,10 @@ public class NewConversationActivity extends XmppActivity {
@Override
public boolean onItemLongClick(AdapterView<?> arg0, View arg1,
int pos, long arg3) {
- Contact clickedContact = aggregatedContacts.get(pos);
- DialogContactDetails dialog = new DialogContactDetails();
- dialog.setContact(clickedContact);
- dialog.show(getFragmentManager(), "details");
+ Intent intent = new Intent(activity,ContactDetailsActivity.class);
+ intent.setAction(ContactDetailsActivity.ACTION_VIEW_CONTACT);
+ intent.putExtra("uuid", aggregatedContacts.get(pos).getUuid());
+ startActivity(intent);
return true;
}
});
@@ -278,12 +277,6 @@ public class NewConversationActivity extends XmppActivity {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
- case R.id.action_settings:
- startActivity(new Intent(this, SettingsActivity.class));
- break;
- case R.id.action_accounts:
- startActivity(new Intent(this, ManageAccountActivity.class));
- break;
case R.id.action_refresh_contacts:
refreshContacts();
break;
diff --git a/src/eu/siacs/conversations/ui/XmppActivity.java b/src/eu/siacs/conversations/ui/XmppActivity.java
index 6b1d1289..a2951c65 100644
--- a/src/eu/siacs/conversations/ui/XmppActivity.java
+++ b/src/eu/siacs/conversations/ui/XmppActivity.java
@@ -1,5 +1,6 @@
package eu.siacs.conversations.ui;
+import eu.siacs.conversations.R;
import eu.siacs.conversations.services.XmppConnectionService;
import eu.siacs.conversations.services.XmppConnectionService.XmppConnectionBinder;
import android.app.Activity;
@@ -10,6 +11,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.IBinder;
+import android.view.MenuItem;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
@@ -79,4 +81,16 @@ public abstract class XmppActivity extends Activity {
}
abstract void onBackendConnected();
+
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case R.id.action_settings:
+ startActivity(new Intent(this, SettingsActivity.class));
+ break;
+ case R.id.action_accounts:
+ startActivity(new Intent(this, ManageAccountActivity.class));
+ break;
+ }
+ return super.onOptionsItemSelected(item);
+ }
}