make presence selector work with empty resources (bare jid)
This commit is contained in:
parent
0dba9f560c
commit
fda9e7b51c
|
@ -205,7 +205,7 @@ public abstract class XmppActivity extends ActionBarActivity {
|
|||
super.onStart();
|
||||
if (!xmppConnectionServiceBound) {
|
||||
if (this.mSkipBackgroundBinding) {
|
||||
Log.d(Config.LOGTAG,"skipping background binding");
|
||||
Log.d(Config.LOGTAG, "skipping background binding");
|
||||
} else {
|
||||
connectToBackend();
|
||||
}
|
||||
|
@ -223,7 +223,7 @@ public abstract class XmppActivity extends ActionBarActivity {
|
|||
try {
|
||||
startService(intent);
|
||||
} catch (IllegalStateException e) {
|
||||
Log.w(Config.LOGTAG,"unable to start service from "+getClass().getSimpleName());
|
||||
Log.w(Config.LOGTAG, "unable to start service from " + getClass().getSimpleName());
|
||||
}
|
||||
bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
|
||||
}
|
||||
|
@ -385,12 +385,8 @@ public abstract class XmppActivity extends ActionBarActivity {
|
|||
listener.onPresenceSelected();
|
||||
}
|
||||
} else if (presences.size() == 1) {
|
||||
String presence = presences.toResourceArray()[0];
|
||||
try {
|
||||
conversation.setNextCounterpart(Jid.of(contact.getJid().getLocal(), contact.getJid().getDomain(), presence));
|
||||
} catch (IllegalArgumentException e) {
|
||||
conversation.setNextCounterpart(null);
|
||||
}
|
||||
final String presence = presences.toResourceArray()[0];
|
||||
conversation.setNextCounterpart(PresenceSelector.getNextCounterpart(contact, presence));
|
||||
listener.onPresenceSelected();
|
||||
} else {
|
||||
PresenceSelector.showPresenceSelectionDialog(this, conversation, listener);
|
||||
|
@ -560,12 +556,12 @@ public abstract class XmppActivity extends ActionBarActivity {
|
|||
try {
|
||||
startService(intent);
|
||||
} catch (Exception e) {
|
||||
Log.e(Config.LOGTAG,"unable to delegate uri permission",e);
|
||||
Log.e(Config.LOGTAG, "unable to delegate uri permission", e);
|
||||
}
|
||||
}
|
||||
|
||||
protected void inviteToConversation(Conversation conversation) {
|
||||
startActivityForResult(ChooseContactActivity.create(this,conversation), REQUEST_INVITE_TO_CONVERSATION);
|
||||
startActivityForResult(ChooseContactActivity.create(this, conversation), REQUEST_INVITE_TO_CONVERSATION);
|
||||
}
|
||||
|
||||
protected void announcePgp(final Account account, final Conversation conversation, Intent intent, final Runnable onSuccess) {
|
||||
|
@ -669,7 +665,7 @@ public abstract class XmppActivity extends ActionBarActivity {
|
|||
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), (dialog, which) -> xmppConnectionService.createContact(contact,true));
|
||||
builder.setPositiveButton(getString(R.string.add_contact), (dialog, which) -> xmppConnectionService.createContact(contact, true));
|
||||
builder.create().show();
|
||||
}
|
||||
|
||||
|
@ -709,7 +705,7 @@ public abstract class XmppActivity extends ActionBarActivity {
|
|||
boolean password,
|
||||
boolean permitEmpty) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
DialogQuickeditBinding binding = DataBindingUtil.inflate(getLayoutInflater(),R.layout.dialog_quickedit, null, false);
|
||||
DialogQuickeditBinding binding = DataBindingUtil.inflate(getLayoutInflater(), R.layout.dialog_quickedit, null, false);
|
||||
if (password) {
|
||||
binding.inputEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
|
||||
}
|
||||
|
@ -841,7 +837,7 @@ public abstract class XmppActivity extends ActionBarActivity {
|
|||
|
||||
@Override
|
||||
public boolean onMenuOpened(int id, Menu menu) {
|
||||
if(id == AppCompatDelegate.FEATURE_SUPPORT_ACTION_BAR && menu != null) {
|
||||
if (id == AppCompatDelegate.FEATURE_SUPPORT_ACTION_BAR && menu != null) {
|
||||
MenuDoubleTabUtil.recordMenuOpen();
|
||||
}
|
||||
return super.onMenuOpened(id, menu);
|
||||
|
@ -1006,7 +1002,7 @@ public abstract class XmppActivity extends ActionBarActivity {
|
|||
if (context instanceof XmppActivity) {
|
||||
return (XmppActivity) context;
|
||||
}
|
||||
context = ((ContextWrapper)context).getBaseContext();
|
||||
context = ((ContextWrapper) context).getBaseContext();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -106,12 +106,21 @@ public class PresenceSelector {
|
|||
builder.setPositiveButton(
|
||||
R.string.ok,
|
||||
(dialog, which) -> onFullJidSelected.onFullJidSelected(
|
||||
Jid.of(contact.getJid().getLocal(), contact.getJid().getDomain(), resourceArray[selectedResource.get()])
|
||||
getNextCounterpart(contact, resourceArray[selectedResource.get()])
|
||||
)
|
||||
);
|
||||
builder.create().show();
|
||||
}
|
||||
|
||||
|
||||
public static Jid getNextCounterpart(final Contact contact, final String resource) {
|
||||
if (resource.isEmpty()) {
|
||||
return contact.getJid().asBareJid();
|
||||
} else {
|
||||
return contact.getJid().withResource(resource);
|
||||
}
|
||||
}
|
||||
|
||||
public static void warnMutualPresenceSubscription(Activity activity, final Conversation conversation, final OnPresenceSelected listener) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||
builder.setTitle(conversation.getContact().getJid().toString());
|
||||
|
|
Loading…
Reference in a new issue