select presence dialog now suggests last used presence
This commit is contained in:
parent
285ffa86e7
commit
95f1a3d57d
|
@ -928,19 +928,35 @@ public class ConversationActivity extends XmppActivity {
|
||||||
conversation.setNextPresence(presence);
|
conversation.setNextPresence(presence);
|
||||||
listener.onPresenceSelected(true, presence);
|
listener.onPresenceSelected(true, presence);
|
||||||
} else {
|
} else {
|
||||||
|
final StringBuilder presence = new StringBuilder();
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
builder.setTitle(getString(R.string.choose_presence));
|
builder.setTitle(getString(R.string.choose_presence));
|
||||||
final String[] presencesArray = new String[presences.size()];
|
final String[] presencesArray = new String[presences.size()];
|
||||||
presences.keySet().toArray(presencesArray);
|
presences.keySet().toArray(presencesArray);
|
||||||
builder.setItems(presencesArray,
|
int preselectedPresence = 0;
|
||||||
|
for(int i = 0; i < presencesArray.length; ++i) {
|
||||||
|
if (presencesArray[i].equals(contact.lastseen.presence)) {
|
||||||
|
preselectedPresence = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
presence.append(presencesArray[preselectedPresence]);
|
||||||
|
builder.setSingleChoiceItems(presencesArray,preselectedPresence ,
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog,
|
public void onClick(DialogInterface dialog,
|
||||||
int which) {
|
int which) {
|
||||||
String presence = presencesArray[which];
|
presence.delete(0, presence.length());
|
||||||
conversation.setNextPresence(presence);
|
presence.append(presencesArray[which]);
|
||||||
listener.onPresenceSelected(true, presence);
|
}});
|
||||||
|
builder.setNegativeButton(R.string.cancel, null);
|
||||||
|
builder.setPositiveButton(R.string.ok, new OnClickListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
conversation.setNextPresence(presence.toString());
|
||||||
|
listener.onPresenceSelected(true, presence.toString());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.create().show();
|
builder.create().show();
|
||||||
|
|
Loading…
Reference in a new issue