diff options
author | iNPUTmice <daniel@gultsch.de> | 2014-06-10 17:34:18 +0200 |
---|---|---|
committer | iNPUTmice <daniel@gultsch.de> | 2014-06-10 17:34:18 +0200 |
commit | 95f1a3d57d6f4a35d4579cf93d24a7621f39cf07 (patch) | |
tree | 3bcbd84c70720f1091e097948ccbdf37c24f6507 /src/eu/siacs | |
parent | 285ffa86e7cfef1014d7e3e4afcd2d860d21163c (diff) |
select presence dialog now suggests last used presence
Diffstat (limited to 'src/eu/siacs')
-rw-r--r-- | src/eu/siacs/conversations/ui/ConversationActivity.java | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/src/eu/siacs/conversations/ui/ConversationActivity.java b/src/eu/siacs/conversations/ui/ConversationActivity.java index 36339bf4..bded4e6f 100644 --- a/src/eu/siacs/conversations/ui/ConversationActivity.java +++ b/src/eu/siacs/conversations/ui/ConversationActivity.java @@ -928,21 +928,37 @@ public class ConversationActivity extends XmppActivity { conversation.setNextPresence(presence); listener.onPresenceSelected(true, presence); } else { + final StringBuilder presence = new StringBuilder(); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(getString(R.string.choose_presence)); final String[] presencesArray = new String[presences.size()]; 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() { @Override public void onClick(DialogInterface dialog, int which) { - String presence = presencesArray[which]; - conversation.setNextPresence(presence); - listener.onPresenceSelected(true, presence); - } - }); + presence.delete(0, presence.length()); + presence.append(presencesArray[which]); + }}); + 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(); } } |