Permalink
Browse files

Account priority setting

  • Loading branch information...
1 parent 8cb90cd commit 2be90e07e944d67f71a65e9939f39f18d6759567 @devrandom committed Apr 11, 2012
@@ -27,7 +27,7 @@
android:title="@string/xmpp_resource" />
<EditTextPreference android:key="@string/pref_account_xmpp_resource_prio"
android:summary="@string/xmpp_resource_prio_summary"
- android:defaultValue="5"
+ android:defaultValue="20"
android:numeric="integer"
android:title="@string/xmpp_resource_prio_title" />
<EditTextPreference android:key="@string/pref_account_port"
@@ -95,7 +95,7 @@ public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
mXmppResource.setSummary(value);
}
} else if (key.equals(getString(R.string.pref_account_xmpp_resource_prio))) {
- value = prefs.getString(key, "5");
+ value = prefs.getString(key, "20");
try {
settings.setXmppResourcePrio(Integer.parseInt(value));
} catch (NumberFormatException nfe) {
@@ -126,6 +126,7 @@
private String mUsername;
private String mPassword;
private String mResource;
+ private int mPriority;
public XmppConnection(Context context) {
super(context);
@@ -230,7 +231,7 @@ protected void doUpdateUserPresenceAsync(Presence presence) {
String statusText = presence.getStatusText();
Type type = Type.available;
Mode mode = Mode.available;
- int priority = 20;
+ int priority = mPriority;
if (presence.getStatus() == Presence.AWAY) {
priority = 10;
mode = Mode.away;
@@ -248,6 +249,11 @@ else if (presence.getStatus() == Presence.OFFLINE) {
type = Type.unavailable;
statusText = "Offline";
}
+
+ // The user set priority is the maximum allowed
+ if (priority > mPriority)
+ priority = mPriority;
+
org.jivesoftware.smack.packet.Presence packet =
new org.jivesoftware.smack.packet.Presence(type, statusText, priority, mode);
@@ -431,6 +437,7 @@ private void initConnection(String userName, final String password,
String domain = providerSettings.getDomain();
String server = providerSettings.getServer();
String xmppResource = providerSettings.getXmppResource();
+ mPriority = providerSettings.getXmppResourcePrio();
int serverPort = providerSettings.getPort();
providerSettings.close(); // close this, which was opened in do_login()

0 comments on commit 2be90e0

Please sign in to comment.