Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Account priority setting

  • Loading branch information...
commit 2be90e07e944d67f71a65e9939f39f18d6759567 1 parent 8cb90cd
Dev Random authored
2  res/xml/account_settings.xml
@@ -27,7 +27,7 @@
27 27
 		android:title="@string/xmpp_resource" />
28 28
 	<EditTextPreference android:key="@string/pref_account_xmpp_resource_prio"
29 29
 		android:summary="@string/xmpp_resource_prio_summary"
30  
-		android:defaultValue="5"
  30
+		android:defaultValue="20"
31 31
 		android:numeric="integer"
32 32
 		android:title="@string/xmpp_resource_prio_title" />
33 33
 	<EditTextPreference android:key="@string/pref_account_port"
2  src/info/guardianproject/otr/app/im/app/AccountSettingsActivity.java
@@ -95,7 +95,7 @@ public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
95 95
     			mXmppResource.setSummary(value);
96 96
     		}
97 97
     	} else if (key.equals(getString(R.string.pref_account_xmpp_resource_prio))) {
98  
-    		value = prefs.getString(key, "5");
  98
+    		value = prefs.getString(key, "20");
99 99
     		try {
100 100
     			settings.setXmppResourcePrio(Integer.parseInt(value));
101 101
     		} catch (NumberFormatException nfe) {
9  src/info/guardianproject/otr/app/im/plugin/xmpp/XmppConnection.java
@@ -126,6 +126,7 @@
126 126
 	private String mUsername;
127 127
 	private String mPassword;
128 128
 	private String mResource;
  129
+	private int mPriority;
129 130
 	
130 131
 	public XmppConnection(Context context) {
131 132
 		super(context);
@@ -230,7 +231,7 @@ protected void doUpdateUserPresenceAsync(Presence presence) {
230 231
 		String statusText = presence.getStatusText();
231 232
         Type type = Type.available;
232 233
         Mode mode = Mode.available;
233  
-        int priority = 20;
  234
+        int priority = mPriority;
234 235
         if (presence.getStatus() == Presence.AWAY) {
235 236
         	priority = 10;
236 237
         	mode = Mode.away;
@@ -248,6 +249,11 @@ else if (presence.getStatus() == Presence.OFFLINE) {
248 249
         	type = Type.unavailable;
249 250
         	statusText = "Offline";
250 251
         }
  252
+        
  253
+        // The user set priority is the maximum allowed
  254
+        if (priority > mPriority)
  255
+        	priority = mPriority;
  256
+        
251 257
 		org.jivesoftware.smack.packet.Presence packet = 
252 258
         	new org.jivesoftware.smack.packet.Presence(type, statusText, priority, mode);
253 259
 		
@@ -431,6 +437,7 @@ private void initConnection(String userName, final String password,
431 437
 		String domain = providerSettings.getDomain();
432 438
 		String server = providerSettings.getServer();
433 439
 		String xmppResource = providerSettings.getXmppResource();
  440
+		mPriority = providerSettings.getXmppResourcePrio();
434 441
 		int serverPort = providerSettings.getPort();
435 442
 		
436 443
 		providerSettings.close(); // close this, which was opened in do_login()

0 notes on commit 2be90e0

Please sign in to comment.
Something went wrong with that request. Please try again.