always allow access to contact details. provide add button in contact details
This commit is contained in:
parent
764ef3c8cd
commit
be9af442ef
|
@ -18,6 +18,7 @@ import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
|
import android.widget.Button;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
import android.widget.CompoundButton;
|
import android.widget.CompoundButton;
|
||||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
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.CryptoHelper;
|
||||||
import eu.siacs.conversations.utils.UIHelper;
|
import eu.siacs.conversations.utils.UIHelper;
|
||||||
import eu.siacs.conversations.xmpp.OnUpdateBlocklist;
|
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.InvalidJidException;
|
||||||
import eu.siacs.conversations.xmpp.jid.Jid;
|
import eu.siacs.conversations.xmpp.jid.Jid;
|
||||||
|
|
||||||
|
@ -51,9 +53,7 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
ContactDetailsActivity.this.xmppConnectionService
|
xmppConnectionService.deleteContactOnServer(contact);
|
||||||
.deleteContactOnServer(contact);
|
|
||||||
ContactDetailsActivity.this.finish();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private OnCheckedChangeListener mOnSendCheckedChange = new OnCheckedChangeListener() {
|
private OnCheckedChangeListener mOnSendCheckedChange = new OnCheckedChangeListener() {
|
||||||
|
@ -102,6 +102,7 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd
|
||||||
private TextView lastseen;
|
private TextView lastseen;
|
||||||
private CheckBox send;
|
private CheckBox send;
|
||||||
private CheckBox receive;
|
private CheckBox receive;
|
||||||
|
private Button addContactButton;
|
||||||
private QuickContactBadge badge;
|
private QuickContactBadge badge;
|
||||||
private LinearLayout keys;
|
private LinearLayout keys;
|
||||||
private LinearLayout tags;
|
private LinearLayout tags;
|
||||||
|
@ -142,6 +143,7 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
invalidateOptionsMenu();
|
||||||
populateView();
|
populateView();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -153,6 +155,7 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
invalidateOptionsMenu();
|
||||||
populateView();
|
populateView();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -188,6 +191,13 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd
|
||||||
send = (CheckBox) findViewById(R.id.details_send_presence);
|
send = (CheckBox) findViewById(R.id.details_send_presence);
|
||||||
receive = (CheckBox) findViewById(R.id.details_receive_presence);
|
receive = (CheckBox) findViewById(R.id.details_receive_presence);
|
||||||
badge = (QuickContactBadge) findViewById(R.id.details_contact_badge);
|
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);
|
keys = (LinearLayout) findViewById(R.id.details_contact_keys);
|
||||||
tags = (LinearLayout) findViewById(R.id.tags);
|
tags = (LinearLayout) findViewById(R.id.tags);
|
||||||
if (getActionBar() != null) {
|
if (getActionBar() != null) {
|
||||||
|
@ -250,58 +260,83 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(final Menu menu) {
|
public boolean onCreateOptionsMenu(final Menu menu) {
|
||||||
getMenuInflater().inflate(R.menu.contact_details, menu);
|
getMenuInflater().inflate(R.menu.contact_details, menu);
|
||||||
if (this.contact.isBlocked()) {
|
MenuItem block = menu.findItem(R.id.action_block);
|
||||||
menu.findItem(R.id.action_block).setVisible(false);
|
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 {
|
} else {
|
||||||
menu.findItem(R.id.action_unblock).setVisible(false);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void populateView() {
|
private void populateView() {
|
||||||
send.setOnCheckedChangeListener(null);
|
|
||||||
receive.setOnCheckedChangeListener(null);
|
|
||||||
setTitle(contact.getDisplayName());
|
setTitle(contact.getDisplayName());
|
||||||
if (contact.getOption(Contact.Options.FROM)) {
|
if (contact.showInRoster()) {
|
||||||
send.setText(R.string.send_presence_updates);
|
send.setVisibility(View.VISIBLE);
|
||||||
send.setChecked(true);
|
receive.setVisibility(View.VISIBLE);
|
||||||
} else if (contact
|
addContactButton.setVisibility(View.GONE);
|
||||||
.getOption(Contact.Options.PENDING_SUBSCRIPTION_REQUEST)) {
|
send.setOnCheckedChangeListener(null);
|
||||||
send.setChecked(false);
|
receive.setOnCheckedChangeListener(null);
|
||||||
send.setText(R.string.send_presence_updates);
|
|
||||||
} else {
|
if (contact.getOption(Contact.Options.FROM)) {
|
||||||
send.setText(R.string.preemptively_grant);
|
send.setText(R.string.send_presence_updates);
|
||||||
if (contact.getOption(Contact.Options.PREEMPTIVE_GRANT)) {
|
|
||||||
send.setChecked(true);
|
send.setChecked(true);
|
||||||
} else {
|
} else if (contact.getOption(Contact.Options.PENDING_SUBSCRIPTION_REQUEST)) {
|
||||||
send.setChecked(false);
|
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)) {
|
||||||
if (contact.getOption(Contact.Options.TO)) {
|
receive.setText(R.string.receive_presence_updates);
|
||||||
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)) {
|
|
||||||
receive.setChecked(true);
|
receive.setChecked(true);
|
||||||
} else {
|
} 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().isOnlineAndConnected()) {
|
||||||
if (contact.getAccount().getStatus() == Account.State.ONLINE) {
|
receive.setEnabled(true);
|
||||||
receive.setEnabled(true);
|
send.setEnabled(true);
|
||||||
send.setEnabled(true);
|
} else {
|
||||||
|
receive.setEnabled(false);
|
||||||
|
send.setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
send.setOnCheckedChangeListener(this.mOnSendCheckedChange);
|
||||||
|
receive.setOnCheckedChangeListener(this.mOnReceiveCheckedChange);
|
||||||
} else {
|
} else {
|
||||||
receive.setEnabled(false);
|
addContactButton.setVisibility(View.VISIBLE);
|
||||||
send.setEnabled(false);
|
send.setVisibility(View.GONE);
|
||||||
|
receive.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
send.setOnCheckedChangeListener(this.mOnSendCheckedChange);
|
if (contact.isBlocked() && !this.showDynamicTags) {
|
||||||
receive.setOnCheckedChangeListener(this.mOnReceiveCheckedChange);
|
lastseen.setText(R.string.contact_blocked);
|
||||||
|
} else {
|
||||||
lastseen.setText(UIHelper.lastseen(getApplicationContext(),
|
lastseen.setText(UIHelper.lastseen(getApplicationContext(), contact.lastseen.time));
|
||||||
contact.lastseen.time));
|
}
|
||||||
|
|
||||||
if (contact.getPresences().size() > 1) {
|
if (contact.getPresences().size() > 1) {
|
||||||
contactJidTv.setText(contact.getJid() + " ("
|
contactJidTv.setText(contact.getJid() + " ("
|
||||||
|
|
|
@ -280,8 +280,6 @@ public class ConversationActivity extends XmppActivity
|
||||||
final MenuItem menuInviteContact = menu.findItem(R.id.action_invite);
|
final MenuItem menuInviteContact = menu.findItem(R.id.action_invite);
|
||||||
final MenuItem menuMute = menu.findItem(R.id.action_mute);
|
final MenuItem menuMute = menu.findItem(R.id.action_mute);
|
||||||
final MenuItem menuUnmute = menu.findItem(R.id.action_unmute);
|
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()) {
|
if (isConversationsOverviewVisable() && isConversationsOverviewHideable()) {
|
||||||
menuArchive.setVisible(false);
|
menuArchive.setVisible(false);
|
||||||
|
@ -293,8 +291,6 @@ public class ConversationActivity extends XmppActivity
|
||||||
menuClearHistory.setVisible(false);
|
menuClearHistory.setVisible(false);
|
||||||
menuMute.setVisible(false);
|
menuMute.setVisible(false);
|
||||||
menuUnmute.setVisible(false);
|
menuUnmute.setVisible(false);
|
||||||
menuBlock.setVisible(false);
|
|
||||||
menuUnblock.setVisible(false);
|
|
||||||
} else {
|
} else {
|
||||||
menuAdd.setVisible(!isConversationsOverviewHideable());
|
menuAdd.setVisible(!isConversationsOverviewHideable());
|
||||||
if (this.getSelectedConversation() != null) {
|
if (this.getSelectedConversation() != null) {
|
||||||
|
@ -305,21 +301,10 @@ public class ConversationActivity extends XmppActivity
|
||||||
if (this.getSelectedConversation().getMode() == Conversation.MODE_MULTI) {
|
if (this.getSelectedConversation().getMode() == Conversation.MODE_MULTI) {
|
||||||
menuContactDetails.setVisible(false);
|
menuContactDetails.setVisible(false);
|
||||||
menuAttach.setVisible(false);
|
menuAttach.setVisible(false);
|
||||||
menuBlock.setVisible(false);
|
|
||||||
menuUnblock.setVisible(false);
|
|
||||||
menuInviteContact.setVisible(getSelectedConversation().getMucOptions().canInvite());
|
menuInviteContact.setVisible(getSelectedConversation().getMucOptions().canInvite());
|
||||||
} else {
|
} else {
|
||||||
menuMucDetails.setVisible(false);
|
menuMucDetails.setVisible(false);
|
||||||
if (this.getSelectedConversation().isBlocked()) {
|
|
||||||
menuBlock.setVisible(false);
|
|
||||||
} else {
|
|
||||||
menuUnblock.setVisible(false);
|
|
||||||
}
|
|
||||||
final Account account = this.getSelectedConversation().getAccount();
|
final Account account = this.getSelectedConversation().getAccount();
|
||||||
if (!(account.isOnlineAndConnected() && account.getXmppConnection().getFeatures().blocking())) {
|
|
||||||
menuBlock.setVisible(false);
|
|
||||||
menuUnblock.setVisible(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (this.getSelectedConversation().isMuted()) {
|
if (this.getSelectedConversation().isMuted()) {
|
||||||
menuMute.setVisible(false);
|
menuMute.setVisible(false);
|
||||||
|
@ -445,12 +430,7 @@ public class ConversationActivity extends XmppActivity
|
||||||
this.endConversation(getSelectedConversation());
|
this.endConversation(getSelectedConversation());
|
||||||
break;
|
break;
|
||||||
case R.id.action_contact_details:
|
case R.id.action_contact_details:
|
||||||
Contact contact = this.getSelectedConversation().getContact();
|
switchToContactDetails(getSelectedConversation().getContact());
|
||||||
if (contact.showInRoster()) {
|
|
||||||
switchToContactDetails(contact);
|
|
||||||
} else {
|
|
||||||
showAddToRosterDialog(getSelectedConversation());
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case R.id.action_muc_details:
|
case R.id.action_muc_details:
|
||||||
Intent intent = new Intent(this,
|
Intent intent = new Intent(this,
|
||||||
|
|
|
@ -362,14 +362,7 @@ public class ConversationFragment extends Fragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Contact contact = message.getConversation()
|
activity.switchToContactDetails(message.getContact());
|
||||||
.getContact();
|
|
||||||
if (contact.showInRoster()) {
|
|
||||||
activity.switchToContactDetails(contact);
|
|
||||||
} else {
|
|
||||||
activity.showAddToRosterDialog(message
|
|
||||||
.getConversation());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Account account = message.getConversation().getAccount();
|
Account account = message.getConversation().getAccount();
|
||||||
|
|
|
@ -438,9 +438,12 @@ public abstract class XmppActivity extends Activity {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void showAddToRosterDialog(final Conversation conversation) {
|
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);
|
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.setMessage(getString(R.string.not_in_roster));
|
||||||
builder.setNegativeButton(getString(R.string.cancel), null);
|
builder.setNegativeButton(getString(R.string.cancel), null);
|
||||||
builder.setPositiveButton(getString(R.string.add_contact),
|
builder.setPositiveButton(getString(R.string.add_contact),
|
||||||
|
@ -448,11 +451,10 @@ public abstract class XmppActivity extends Activity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
final Jid jid = conversation.getJid();
|
final Jid jid = contact.getJid();
|
||||||
Account account = conversation.getAccount();
|
Account account = contact.getAccount();
|
||||||
Contact contact = account.getRoster().getContact(jid);
|
Contact contact = account.getRoster().getContact(jid);
|
||||||
xmppConnectionService.createContact(contact);
|
xmppConnectionService.createContact(contact);
|
||||||
switchToContactDetails(contact);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.create().show();
|
builder.create().show();
|
||||||
|
|
|
@ -65,6 +65,13 @@
|
||||||
android:textSize="?attr/TextSizeBody" />
|
android:textSize="?attr/TextSizeBody" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/add_contact_button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:text="@string/add_contact"/>
|
||||||
|
|
||||||
<CheckBox
|
<CheckBox
|
||||||
android:id="@+id/details_send_presence"
|
android:id="@+id/details_send_presence"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
|
|
@ -56,18 +56,6 @@
|
||||||
android:showAsAction="never"
|
android:showAsAction="never"
|
||||||
android:title="@string/enable_notifications"/>
|
android:title="@string/enable_notifications"/>
|
||||||
|
|
||||||
<item
|
|
||||||
android:id="@+id/action_block"
|
|
||||||
android:orderInCategory="72"
|
|
||||||
android:showAsAction="never"
|
|
||||||
android:title="@string/action_block_contact"/>
|
|
||||||
|
|
||||||
<item
|
|
||||||
android:id="@+id/action_unblock"
|
|
||||||
android:orderInCategory="73"
|
|
||||||
android:showAsAction="never"
|
|
||||||
android:title="@string/action_unblock_contact"/>
|
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_accounts"
|
android:id="@+id/action_accounts"
|
||||||
android:orderInCategory="90"
|
android:orderInCategory="90"
|
||||||
|
|
Loading…
Reference in New Issue