aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/values-es/strings.xml16
-rw-r--r--res/values/strings.xml13
-rw-r--r--src/eu/siacs/conversations/entities/Contact.java37
-rw-r--r--src/eu/siacs/conversations/entities/Roster.java17
-rw-r--r--src/eu/siacs/conversations/services/XmppConnectionService.java25
-rw-r--r--src/eu/siacs/conversations/ui/ContactDetailsActivity.java36
-rw-r--r--src/eu/siacs/conversations/ui/ContactsActivity.java2
-rw-r--r--src/eu/siacs/conversations/ui/ConversationActivity.java2
-rw-r--r--src/eu/siacs/conversations/ui/ShareWithActivity.java2
9 files changed, 111 insertions, 39 deletions
diff --git a/res/values-es/strings.xml b/res/values-es/strings.xml
index c4330d5d..ffe06442 100644
--- a/res/values-es/strings.xml
+++ b/res/values-es/strings.xml
@@ -13,6 +13,7 @@
<string name="action_add_account">Añadir cuenta</string>
<string name="action_edit_contact">Editar contacto</string>
<string name="action_delete_contact">Eliminar contacto de la lista</string>
+ <string name="action_add_phone_book">Añadir a contactos del teléfono</string>
<string name="title_activity_contacts">Contactos</string>
<string name="just_now">ahora</string>
<string name="minutes_ago">min</string>
@@ -26,7 +27,7 @@
<string name="participant">Participante</string>
<string name="visitor">Visitante</string>
<string name="enter_new_name">Introduce un nuevo nombre:</string>
- <string name="remove_contact_text">¿Quieres eliminar a %s de tu lista?. La conversación asociada a esta cuenta no se eliminará.</string>
+ <string name="remove_contact_text">¿Quieres eliminar a %s de tu lista? La conversación asociada a esta cuenta no se eliminará.</string>
<string name="untrusted_cert_hint">El servidor %s presenta un certificado no confiable, posiblemente auto firmado.</string>
<string name="account_info">Información del servidor</string>
<string name="register_account">Registrar nueva cuenta en servidor</string>
@@ -39,6 +40,9 @@
<string name="invite_contacts_to_existing">Invitar a conferencia existente</string>
<string name="new_conference">Crear nueva conferencia</string>
<string name="cancel">Cancelar</string>
+ <string name="add">Añadir</string>
+ <string name="edit">Editar</string>
+ <string name="delete">Eliminar</string>
<string name="create_invite">Crear \u0026 Invitar</string>
<string name="new_conference_explained">¿Quieres crear una nueva conferencia con una dirección generada aleatoriamente e invitar a los contactos seleccionados a ella?</string>
<string name="no_open_mucs">No hay conferencias existentes</string>
@@ -128,11 +132,13 @@
<string name="pref_grant_presence_updates">Suscripción de presencia</string>
<string name="pref_grant_presence_updates_summary">Por defecto otorgar y pedir suscripciones de presencia de los contactos que has creado</string>
<string name="subscriptions">Suscripciones</string>
+ <string name="subscription_updated">Suscripción actualizada</string>
<string name="your_account">Tu cuenta</string>
<string name="keys">Claves</string>
<string name="send_presence_updates">Enviar actualizaciones de presencia</string>
<string name="receive_presence_updates">Recibir actualizaciones de presencia</string>
<string name="ask_for_presence_updates">Solicitar actualizaciones de presencia</string>
+ <string name="asked_for_presence_updates">Solictida actualizaciones de presencia</string>
<string name="attach_choose_picture">Seleccionar imagen</string>
<string name="attach_take_picture">Hacer foto</string>
<string name="preemptively_grant">Por defecto otorgar peticiones de suscripción</string>
@@ -170,4 +176,12 @@
<string name="save">Guardar</string>
<string name="passwords_do_not_match">Las contraseñas no coinciden</string>
<string name="invalid_jid">El identificador no es un identificador de Jabber válido</string>
+ <string name="error_out_of_memory">Sin memoria. La imagen es demasiado grande</string>
+ <string name="add_phone_book_text">¿Te gustaría añadir a %s a tus contactos del teléfono?</string>
+ <string name="contact_status_online">Disponible</string>
+ <string name="contact_status_free_to_chat">Hablador</string>
+ <string name="contact_status_away">Ausente</string>
+ <string name="contact_status_extended_away">Ausencia ext.</string>
+ <string name="contact_status_do_not_disturb">No molestar</string>
+ <string name="contact_status_offline">Desconectado</string>
</resources> \ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 9de0b233..b2c97478 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -12,6 +12,7 @@
<string name="action_secure">Secure conversation</string>
<string name="action_add_account">Add account</string>
<string name="action_edit_contact">Edit name</string>
+ <string name="action_add_phone_book">Add to phone book</string>
<string name="action_delete_contact">Delete from roster</string>
<string name="title_activity_contacts">Contacts</string>
<string name="just_now">just now</string>
@@ -39,6 +40,9 @@
<string name="invite_contacts_to_existing">Invite to existing conference</string>
<string name="new_conference">Create new conference</string>
<string name="cancel">Cancel</string>
+ <string name="add">Add</string>
+ <string name="edit">Edit</string>
+ <string name="delete">Delete</string>
<string name="create_invite">Create \u0026 Invite</string>
<string name="new_conference_explained">Do you want to create a new conference with a randomly generated address and invite the selected contacts to it?</string>
<string name="no_open_mucs">No existing conferences</string>
@@ -128,11 +132,13 @@
<string name="pref_grant_presence_updates">Grant presence updates</string>
<string name="pref_grant_presence_updates_summary">Preemptively grant and ask for presence subscription for contacts you created</string>
<string name="subscriptions">Subscriptions</string>
+ <string name="subscription_updated">Subscription updated</string>
<string name="your_account">Your account</string>
<string name="keys">Keys</string>
<string name="send_presence_updates">Send presence updates</string>
<string name="receive_presence_updates">Receive presence updates</string>
<string name="ask_for_presence_updates">Ask for presence updates</string>
+ <string name="asked_for_presence_updates">Asked for presence updates</string>
<string name="attach_choose_picture">Choose picture</string>
<string name="attach_take_picture">Take picture</string>
<string name="preemptively_grant">Preemptively grant subscription request</string>
@@ -171,4 +177,11 @@
<string name="passwords_do_not_match">Passwords do not match</string>
<string name="invalid_jid">This is not a valid Jabber ID</string>
<string name="error_out_of_memory">Ouf of memory. Image is to large</string>
+ <string name="add_phone_book_text">Do you want to add %s to your phones contact list?</string>
+ <string name="contact_status_online">online</string>
+ <string name="contact_status_free_to_chat">free to chat</string>
+ <string name="contact_status_away">away</string>
+ <string name="contact_status_extended_away">extended away</string>
+ <string name="contact_status_do_not_disturb">do not disturb</string>
+ <string name="contact_status_offline">offline</string>
</resources> \ No newline at end of file
diff --git a/src/eu/siacs/conversations/entities/Contact.java b/src/eu/siacs/conversations/entities/Contact.java
index 2ef6e6fc..cff0dd73 100644
--- a/src/eu/siacs/conversations/entities/Contact.java
+++ b/src/eu/siacs/conversations/entities/Contact.java
@@ -3,12 +3,15 @@ package eu.siacs.conversations.entities;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.Set;
+
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
+
import eu.siacs.conversations.xml.Element;
import android.content.ContentValues;
import android.database.Cursor;
+import android.util.Log;
public class Contact {
public static final String TABLENAME = "contacts";
@@ -36,8 +39,8 @@ public class Contact {
protected boolean inRoster = true;
- public Contact(String account, String systemName,
- String serverName, String jid, int subscription, String photoUri,
+ public Contact(String account, String systemName, String serverName,
+ String jid, int subscription, String photoUri,
String systemAccount, String keys) {
this.accountUuid = account;
this.systemName = systemName;
@@ -247,6 +250,12 @@ public class Contact {
return ((this.subscription & (1 << option)) != 0);
}
+ public boolean showInRoster() {
+ return (this.getOption(Contact.Options.IN_ROSTER) && (!this
+ .getOption(Contact.Options.DIRTY_DELETE)))
+ || (this.getOption(Contact.Options.DIRTY_PUSH));
+ }
+
public void parseSubscriptionFromElement(Element item) {
String ask = item.getAttribute("ask");
String subscription = item.getAttribute("subscription");
@@ -261,13 +270,19 @@ public class Contact {
} else if (subscription.equals("both")) {
this.setOption(Contact.Options.TO);
this.setOption(Contact.Options.FROM);
+ } else if (subscription.equals("none")) {
+ this.resetOption(Contact.Options.FROM);
+ this.resetOption(Contact.Options.TO);
}
}
- if ((ask != null) && (ask.equals("subscribe"))) {
- this.setOption(Contact.Options.ASKING);
- } else {
- this.resetOption(Contact.Options.ASKING);
+ // do NOT override asking if pending push request
+ if (!this.getOption(Contact.Options.DIRTY_PUSH)) {
+ if ((ask != null) && (ask.equals("subscribe"))) {
+ this.setOption(Contact.Options.ASKING);
+ } else {
+ this.resetOption(Contact.Options.ASKING);
+ }
}
}
@@ -284,10 +299,10 @@ public class Contact {
public static final int TO = 0;
public static final int FROM = 1;
public static final int ASKING = 2;
- public static final int PREEMPTIVE_GRANT = 4;
- public static final int IN_ROSTER = 8;
- public static final int PENDING_SUBSCRIPTION_REQUEST = 16;
- public static final int DIRTY_PUSH = 32;
- public static final int DIRTY_DELETE = 64;
+ public static final int PREEMPTIVE_GRANT = 3;
+ public static final int IN_ROSTER = 4;
+ public static final int PENDING_SUBSCRIPTION_REQUEST = 5;
+ public static final int DIRTY_PUSH = 6;
+ public static final int DIRTY_DELETE = 7;
}
}
diff --git a/src/eu/siacs/conversations/entities/Roster.java b/src/eu/siacs/conversations/entities/Roster.java
index 7c18d80a..1b4bc954 100644
--- a/src/eu/siacs/conversations/entities/Roster.java
+++ b/src/eu/siacs/conversations/entities/Roster.java
@@ -31,12 +31,23 @@ public class Roster {
}
public void clearPresences() {
- // TODO Auto-generated method stub
-
+ for(Contact contact : getContacts()) {
+ contact.clearPresences();
+ }
}
public void markAllAsNotInRoster() {
-
+ for(Contact contact : getContacts()) {
+ contact.resetOption(Contact.Options.IN_ROSTER);
+ }
+ }
+
+ public void clearSystemAccounts() {
+ for(Contact contact : getContacts()) {
+ contact.setPhotoUri(null);
+ contact.setSystemName(null);
+ contact.setSystemAccount(null);
+ }
}
public List<Contact> getContacts() {
diff --git a/src/eu/siacs/conversations/services/XmppConnectionService.java b/src/eu/siacs/conversations/services/XmppConnectionService.java
index 63ce6a5b..f879de11 100644
--- a/src/eu/siacs/conversations/services/XmppConnectionService.java
+++ b/src/eu/siacs/conversations/services/XmppConnectionService.java
@@ -234,6 +234,7 @@ public class XmppConnectionService extends Service {
sendUnsendMessages(conversations.get(i));
}
}
+ syncDirtyContacts(account);
scheduleWakeupCall(PING_MAX_INTERVAL, true);
} else if (account.getStatus() == Account.STATUS_OFFLINE) {
if (!account.isOptionSet(Account.OPTION_DISABLED)) {
@@ -490,9 +491,12 @@ public class XmppConnectionService extends Service {
String name = item.getAttribute("name");
String subscription = item.getAttribute("subscription");
Contact contact = account.getRoster().getContact(jid);
- contact.setServerName(name);
+ if (!contact.getOption(Contact.Options.DIRTY_PUSH)) {
+ contact.setServerName(name);
+ }
if (subscription.equals("remove")) {
contact.resetOption(Contact.Options.IN_ROSTER);
+ contact.resetOption(Contact.Options.DIRTY_DELETE);
} else {
contact.setOption(Contact.Options.IN_ROSTER);
contact.parseSubscriptionFromElement(item);
@@ -894,6 +898,9 @@ public class XmppConnectionService extends Service {
new OnPhoneContactsLoadedListener() {
@Override
public void onPhoneContactsLoaded(List<Bundle> phoneContacts) {
+ for(Account account : accounts) {
+ account.getRoster().clearSystemAccounts();
+ }
for (Bundle phoneContact : phoneContacts) {
for (Account account : accounts) {
String jid = phoneContact.getString("jid");
@@ -1188,6 +1195,18 @@ public class XmppConnectionService extends Service {
public void updateMessage(Message message) {
databaseBackend.updateMessage(message);
}
+
+ protected void syncDirtyContacts(Account account) {
+ for(Contact contact : account.getRoster().getContacts()) {
+ if (contact.getOption(Contact.Options.DIRTY_PUSH)) {
+ pushContactToServer(contact);
+ }
+ if (contact.getOption(Contact.Options.DIRTY_DELETE)) {
+ Log.d(LOGTAG,"dirty delete");
+ deleteContactOnServer(contact);
+ }
+ }
+ }
public void createContact(Contact contact) {
SharedPreferences sharedPref = getPreferences();
@@ -1200,12 +1219,12 @@ public class XmppConnectionService extends Service {
}
public void pushContactToServer(Contact contact) {
+ contact.resetOption(Contact.Options.DIRTY_DELETE);
Account account = contact.getAccount();
if (account.getStatus() == Account.STATUS_ONLINE) {
IqPacket iq = new IqPacket(IqPacket.TYPE_SET);
iq.query("jabber:iq:roster").addChild(contact.asElement());
account.getXmppConnection().sendIqPacket(iq, null);
- contact.resetOption(Contact.Options.DIRTY_PUSH);
if (contact.getOption(Contact.Options.ASKING)) {
requestPresenceUpdatesFrom(contact);
}
@@ -1220,6 +1239,7 @@ public class XmppConnectionService extends Service {
}
public void deleteContactOnServer(Contact contact) {
+ contact.resetOption(Contact.Options.DIRTY_PUSH);
Account account = contact.getAccount();
if (account.getStatus() == Account.STATUS_ONLINE) {
IqPacket iq = new IqPacket(IqPacket.TYPE_SET);
@@ -1263,7 +1283,6 @@ public class XmppConnectionService extends Service {
packet.setAttribute("to", contact.getJid());
packet.setAttribute("from", contact.getAccount().getJid());
contact.getAccount().getXmppConnection().sendPresencePacket(packet);
- contact.resetOption(Contact.Options.PENDING_SUBSCRIPTION_REQUEST);
}
public void sendPresence(Account account) {
diff --git a/src/eu/siacs/conversations/ui/ContactDetailsActivity.java b/src/eu/siacs/conversations/ui/ContactDetailsActivity.java
index 72a0909a..83ae99d9 100644
--- a/src/eu/siacs/conversations/ui/ContactDetailsActivity.java
+++ b/src/eu/siacs/conversations/ui/ContactDetailsActivity.java
@@ -89,11 +89,10 @@ public class ContactDetailsActivity extends XmppActivity {
@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.setTitle(getString(R.string.action_add_phone_book));
+ builder.setMessage(getString(R.string.add_phone_book_text, contact.getJid()));
+ builder.setNegativeButton(getString(R.string.cancel), null);
+ builder.setPositiveButton(getString(R.string.add), addToPhonebook);
builder.create().show();
}
};
@@ -125,17 +124,17 @@ public class ContactDetailsActivity extends XmppActivity {
@Override
public boolean onOptionsItemSelected(MenuItem menuItem) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
- builder.setNegativeButton("Cancel", null);
+ builder.setNegativeButton(getString(R.string.cancel), null);
switch (menuItem.getItemId()) {
case android.R.id.home:
finish();
break;
case R.id.action_delete_contact:
- builder.setTitle("Delete from roster")
+ builder.setTitle(getString(R.string.action_delete_contact))
.setMessage(
getString(R.string.remove_contact_text,
contact.getJid()))
- .setPositiveButton("Delete", removeFromRoster).create()
+ .setPositiveButton(getString(R.string.delete), removeFromRoster).create()
.show();
break;
case R.id.action_edit_contact:
@@ -146,7 +145,7 @@ public class ContactDetailsActivity extends XmppActivity {
name = (EditText) view.findViewById(R.id.editText1);
name.setText(contact.getDisplayName());
builder.setView(view).setTitle(contact.getJid())
- .setPositiveButton("Edit", editContactNameListener)
+ .setPositiveButton(getString(R.string.edit), editContactNameListener)
.create().show();
} else {
@@ -191,7 +190,8 @@ public class ContactDetailsActivity extends XmppActivity {
@Override
public void onClick(View v) {
- Toast.makeText(getApplicationContext(), "Asked for presence updates",Toast.LENGTH_SHORT).show();
+ Toast.makeText(getApplicationContext(), getString(R.string.asked_for_presence_updates),
+ Toast.LENGTH_SHORT).show();
xmppConnectionService.requestPresenceUpdatesFrom(contact);
}
@@ -205,31 +205,31 @@ public class ContactDetailsActivity extends XmppActivity {
switch (contact.getMostAvailableStatus()) {
case Presences.CHAT:
- status.setText("free to chat");
+ status.setText(R.string.contact_status_free_to_chat);
status.setTextColor(0xFF83b600);
break;
case Presences.ONLINE:
- status.setText("online");
+ status.setText(R.string.contact_status_online);
status.setTextColor(0xFF83b600);
break;
case Presences.AWAY:
- status.setText("away");
+ status.setText(R.string.contact_status_away);
status.setTextColor(0xFFffa713);
break;
case Presences.XA:
- status.setText("extended away");
+ status.setText(R.string.contact_status_extended_away);
status.setTextColor(0xFFffa713);
break;
case Presences.DND:
- status.setText("do not disturb");
+ status.setText(R.string.contact_status_do_not_disturb);
status.setTextColor(0xFFe92727);
break;
case Presences.OFFLINE:
- status.setText("offline");
+ status.setText(R.string.contact_status_offline);
status.setTextColor(0xFFe92727);
break;
default:
- status.setText("offline");
+ status.setText(R.string.contact_status_offline);
status.setTextColor(0xFFe92727);
break;
}
@@ -346,7 +346,7 @@ public class ContactDetailsActivity extends XmppActivity {
}
}
if (updated) {
- Toast.makeText(getApplicationContext(), "Subscription updated", Toast.LENGTH_SHORT).show();
+ Toast.makeText(getApplicationContext(), getString(R.string.subscription_updated), Toast.LENGTH_SHORT).show();
}
}
diff --git a/src/eu/siacs/conversations/ui/ContactsActivity.java b/src/eu/siacs/conversations/ui/ContactsActivity.java
index ca794b30..c18b0891 100644
--- a/src/eu/siacs/conversations/ui/ContactsActivity.java
+++ b/src/eu/siacs/conversations/ui/ContactsActivity.java
@@ -269,7 +269,7 @@ public class ContactsActivity extends XmppActivity {
aggregatedContacts.clear();
for (Contact contact : rosterContacts) {
- if (contact.match(searchString)&&(contact.getOption(Contact.Options.IN_ROSTER)))
+ if (contact.match(searchString)&&(contact.showInRoster()))
aggregatedContacts.add(contact);
}
diff --git a/src/eu/siacs/conversations/ui/ConversationActivity.java b/src/eu/siacs/conversations/ui/ConversationActivity.java
index bf83990a..bd98e979 100644
--- a/src/eu/siacs/conversations/ui/ConversationActivity.java
+++ b/src/eu/siacs/conversations/ui/ConversationActivity.java
@@ -474,7 +474,7 @@ public class ConversationActivity extends XmppActivity {
break;
case R.id.action_contact_details:
Contact contact = this.getSelectedConversation().getContact();
- if (contact.getOption(Contact.Options.IN_ROSTER)) {
+ if (contact.showInRoster()) {
Intent intent = new Intent(this, ContactDetailsActivity.class);
intent.setAction(ContactDetailsActivity.ACTION_VIEW_CONTACT);
intent.putExtra("account", this.getSelectedConversation().getAccount().getJid());
diff --git a/src/eu/siacs/conversations/ui/ShareWithActivity.java b/src/eu/siacs/conversations/ui/ShareWithActivity.java
index e2188c48..6dbb20c9 100644
--- a/src/eu/siacs/conversations/ui/ShareWithActivity.java
+++ b/src/eu/siacs/conversations/ui/ShareWithActivity.java
@@ -91,7 +91,7 @@ public class ShareWithActivity extends XmppActivity {
List<Contact> contactsList = new ArrayList<Contact>();
for(Account account : xmppConnectionService.getAccounts()) {
for(Contact contact : account.getRoster().getContacts()) {
- if (!displayedContacts.contains(contact)&&(contact.getOption(Contact.Options.IN_ROSTER))) {
+ if (!displayedContacts.contains(contact)&&(contact.showInRoster())) {
contactsList.add(contact);
}
}