aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/eu')
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java111
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ConversationActivity.java22
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ConversationFragment.java9
-rw-r--r--src/main/java/eu/siacs/conversations/ui/XmppActivity.java12
4 files changed, 82 insertions, 72 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java b/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java
index 7a500c0b..fda0c617 100644
--- a/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java
@@ -18,6 +18,7 @@ import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
+import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
@@ -40,6 +41,7 @@ import eu.siacs.conversations.services.XmppConnectionService.OnRosterUpdate;
import eu.siacs.conversations.utils.CryptoHelper;
import eu.siacs.conversations.utils.UIHelper;
import eu.siacs.conversations.xmpp.OnUpdateBlocklist;
+import eu.siacs.conversations.xmpp.XmppConnection;
import eu.siacs.conversations.xmpp.jid.InvalidJidException;
import eu.siacs.conversations.xmpp.jid.Jid;
@@ -51,9 +53,7 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd
@Override
public void onClick(DialogInterface dialog, int which) {
- ContactDetailsActivity.this.xmppConnectionService
- .deleteContactOnServer(contact);
- ContactDetailsActivity.this.finish();
+ xmppConnectionService.deleteContactOnServer(contact);
}
};
private OnCheckedChangeListener mOnSendCheckedChange = new OnCheckedChangeListener() {
@@ -102,6 +102,7 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd
private TextView lastseen;
private CheckBox send;
private CheckBox receive;
+ private Button addContactButton;
private QuickContactBadge badge;
private LinearLayout keys;
private LinearLayout tags;
@@ -142,6 +143,7 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd
@Override
public void run() {
+ invalidateOptionsMenu();
populateView();
}
});
@@ -153,6 +155,7 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd
@Override
public void run() {
+ invalidateOptionsMenu();
populateView();
}
});
@@ -188,6 +191,13 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd
send = (CheckBox) findViewById(R.id.details_send_presence);
receive = (CheckBox) findViewById(R.id.details_receive_presence);
badge = (QuickContactBadge) findViewById(R.id.details_contact_badge);
+ addContactButton = (Button) findViewById(R.id.add_contact_button);
+ addContactButton.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ showAddToRosterDialog(contact);
+ }
+ });
keys = (LinearLayout) findViewById(R.id.details_contact_keys);
tags = (LinearLayout) findViewById(R.id.tags);
if (getActionBar() != null) {
@@ -250,58 +260,83 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
getMenuInflater().inflate(R.menu.contact_details, menu);
- if (this.contact.isBlocked()) {
- menu.findItem(R.id.action_block).setVisible(false);
+ MenuItem block = menu.findItem(R.id.action_block);
+ MenuItem unblock = menu.findItem(R.id.action_unblock);
+ MenuItem edit = menu.findItem(R.id.action_edit_contact);
+ MenuItem delete = menu.findItem(R.id.action_delete_contact);
+ final XmppConnection connection = contact.getAccount().getXmppConnection();
+ if (connection != null && connection.getFeatures().blocking()) {
+ if (this.contact.isBlocked()) {
+ menu.findItem(R.id.action_block).setVisible(false);
+ } else {
+ menu.findItem(R.id.action_unblock).setVisible(false);
+ }
} else {
menu.findItem(R.id.action_unblock).setVisible(false);
+ menu.findItem(R.id.action_block).setVisible(false);
+ }
+ if (!contact.showInRoster()) {
+ edit.setVisible(false);
+ delete.setVisible(false);
}
-
return true;
}
private void populateView() {
- send.setOnCheckedChangeListener(null);
- receive.setOnCheckedChangeListener(null);
setTitle(contact.getDisplayName());
- if (contact.getOption(Contact.Options.FROM)) {
- send.setText(R.string.send_presence_updates);
- send.setChecked(true);
- } else if (contact
- .getOption(Contact.Options.PENDING_SUBSCRIPTION_REQUEST)) {
- send.setChecked(false);
- send.setText(R.string.send_presence_updates);
- } else {
- send.setText(R.string.preemptively_grant);
- if (contact.getOption(Contact.Options.PREEMPTIVE_GRANT)) {
+ if (contact.showInRoster()) {
+ send.setVisibility(View.VISIBLE);
+ receive.setVisibility(View.VISIBLE);
+ addContactButton.setVisibility(View.GONE);
+ send.setOnCheckedChangeListener(null);
+ receive.setOnCheckedChangeListener(null);
+
+ if (contact.getOption(Contact.Options.FROM)) {
+ send.setText(R.string.send_presence_updates);
send.setChecked(true);
- } else {
+ } else if (contact.getOption(Contact.Options.PENDING_SUBSCRIPTION_REQUEST)) {
send.setChecked(false);
+ send.setText(R.string.send_presence_updates);
+ } else {
+ send.setText(R.string.preemptively_grant);
+ if (contact.getOption(Contact.Options.PREEMPTIVE_GRANT)) {
+ send.setChecked(true);
+ } else {
+ send.setChecked(false);
+ }
}
- }
- if (contact.getOption(Contact.Options.TO)) {
- receive.setText(R.string.receive_presence_updates);
- receive.setChecked(true);
- } else {
- receive.setText(R.string.ask_for_presence_updates);
- if (contact.getOption(Contact.Options.ASKING)) {
+ if (contact.getOption(Contact.Options.TO)) {
+ receive.setText(R.string.receive_presence_updates);
receive.setChecked(true);
} else {
- receive.setChecked(false);
+ receive.setText(R.string.ask_for_presence_updates);
+ if (contact.getOption(Contact.Options.ASKING)) {
+ receive.setChecked(true);
+ } else {
+ receive.setChecked(false);
+ }
}
- }
- if (contact.getAccount().getStatus() == Account.State.ONLINE) {
- receive.setEnabled(true);
- send.setEnabled(true);
+ if (contact.getAccount().isOnlineAndConnected()) {
+ receive.setEnabled(true);
+ send.setEnabled(true);
+ } else {
+ receive.setEnabled(false);
+ send.setEnabled(false);
+ }
+
+ send.setOnCheckedChangeListener(this.mOnSendCheckedChange);
+ receive.setOnCheckedChangeListener(this.mOnReceiveCheckedChange);
} else {
- receive.setEnabled(false);
- send.setEnabled(false);
+ addContactButton.setVisibility(View.VISIBLE);
+ send.setVisibility(View.GONE);
+ receive.setVisibility(View.GONE);
}
- send.setOnCheckedChangeListener(this.mOnSendCheckedChange);
- receive.setOnCheckedChangeListener(this.mOnReceiveCheckedChange);
-
- lastseen.setText(UIHelper.lastseen(getApplicationContext(),
- contact.lastseen.time));
+ if (contact.isBlocked() && !this.showDynamicTags) {
+ lastseen.setText(R.string.contact_blocked);
+ } else {
+ lastseen.setText(UIHelper.lastseen(getApplicationContext(), contact.lastseen.time));
+ }
if (contact.getPresences().size() > 1) {
contactJidTv.setText(contact.getJid() + " ("
diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
index ad9c13aa..7aa48c0c 100644
--- a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
@@ -280,8 +280,6 @@ public class ConversationActivity extends XmppActivity
final MenuItem menuInviteContact = menu.findItem(R.id.action_invite);
final MenuItem menuMute = menu.findItem(R.id.action_mute);
final MenuItem menuUnmute = menu.findItem(R.id.action_unmute);
- final MenuItem menuBlock = menu.findItem(R.id.action_block);
- final MenuItem menuUnblock = menu.findItem(R.id.action_unblock);
if (isConversationsOverviewVisable() && isConversationsOverviewHideable()) {
menuArchive.setVisible(false);
@@ -293,8 +291,6 @@ public class ConversationActivity extends XmppActivity
menuClearHistory.setVisible(false);
menuMute.setVisible(false);
menuUnmute.setVisible(false);
- menuBlock.setVisible(false);
- menuUnblock.setVisible(false);
} else {
menuAdd.setVisible(!isConversationsOverviewHideable());
if (this.getSelectedConversation() != null) {
@@ -305,21 +301,10 @@ public class ConversationActivity extends XmppActivity
if (this.getSelectedConversation().getMode() == Conversation.MODE_MULTI) {
menuContactDetails.setVisible(false);
menuAttach.setVisible(false);
- menuBlock.setVisible(false);
- menuUnblock.setVisible(false);
menuInviteContact.setVisible(getSelectedConversation().getMucOptions().canInvite());
} else {
menuMucDetails.setVisible(false);
- if (this.getSelectedConversation().isBlocked()) {
- menuBlock.setVisible(false);
- } else {
- menuUnblock.setVisible(false);
- }
final Account account = this.getSelectedConversation().getAccount();
- if (!(account.isOnlineAndConnected() && account.getXmppConnection().getFeatures().blocking())) {
- menuBlock.setVisible(false);
- menuUnblock.setVisible(false);
- }
}
if (this.getSelectedConversation().isMuted()) {
menuMute.setVisible(false);
@@ -445,12 +430,7 @@ public class ConversationActivity extends XmppActivity
this.endConversation(getSelectedConversation());
break;
case R.id.action_contact_details:
- Contact contact = this.getSelectedConversation().getContact();
- if (contact.showInRoster()) {
- switchToContactDetails(contact);
- } else {
- showAddToRosterDialog(getSelectedConversation());
- }
+ switchToContactDetails(getSelectedConversation().getContact());
break;
case R.id.action_muc_details:
Intent intent = new Intent(this,
diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
index e767fbea..c1e02400 100644
--- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
+++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
@@ -362,14 +362,7 @@ public class ConversationFragment extends Fragment {
}
}
} else {
- Contact contact = message.getConversation()
- .getContact();
- if (contact.showInRoster()) {
- activity.switchToContactDetails(contact);
- } else {
- activity.showAddToRosterDialog(message
- .getConversation());
- }
+ activity.switchToContactDetails(message.getContact());
}
} else {
Account account = message.getConversation().getAccount();
diff --git a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
index 9a4f9c7f..7fd1094c 100644
--- a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
@@ -438,9 +438,12 @@ public abstract class XmppActivity extends Activity {
}
protected void showAddToRosterDialog(final Conversation conversation) {
- final Jid jid = conversation.getJid();
+ showAddToRosterDialog(conversation.getContact());
+ }
+
+ protected void showAddToRosterDialog(final Contact contact) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
- builder.setTitle(jid.toString());
+ builder.setTitle(contact.getJid().toString());
builder.setMessage(getString(R.string.not_in_roster));
builder.setNegativeButton(getString(R.string.cancel), null);
builder.setPositiveButton(getString(R.string.add_contact),
@@ -448,11 +451,10 @@ public abstract class XmppActivity extends Activity {
@Override
public void onClick(DialogInterface dialog, int which) {
- final Jid jid = conversation.getJid();
- Account account = conversation.getAccount();
+ final Jid jid = contact.getJid();
+ Account account = contact.getAccount();
Contact contact = account.getRoster().getContact(jid);
xmppConnectionService.createContact(contact);
- switchToContactDetails(contact);
}
});
builder.create().show();