|
@@ -7,6 +7,8 @@ import android.os.Bundle;
|
|
|
import android.preference.EditTextPreference;
|
|
|
import android.preference.Preference;
|
|
|
import android.preference.PreferenceActivity;
|
|
|
+import android.preference.PreferenceManager;
|
|
|
+import android.util.Log;
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
* SettingsActivity creates the settings defined in /xml/preferences.xml.
|
|
@@ -26,6 +28,20 @@ public class SettingsActivity extends PreferenceActivity implements OnSharedPref
|
|
|
pref = findPreference("pref_upload_server");
|
|
|
etp = (EditTextPreference) pref;
|
|
|
pref.setSummary(etp.getText());
|
|
|
+
|
|
|
+ SharedPreferences defaultPref = PreferenceManager.getDefaultSharedPreferences(this);
|
|
|
+
|
|
|
+ pref = findPreference("pref_max_connections");
|
|
|
+ etp = (EditTextPreference) pref;
|
|
|
+ defaultPref.edit().putInt("max_connections", Integer.valueOf(etp.getText()).intValue()).commit();
|
|
|
+ pref.setSummary(etp.getText());
|
|
|
+
|
|
|
+
|
|
|
+ pref = findPreference("pref_timeout");
|
|
|
+ etp = (EditTextPreference) pref;
|
|
|
+ defaultPref.edit().putInt("timeout", Integer.valueOf(etp.getText()).intValue()).commit();
|
|
|
+ pref.setSummary(etp.getText());
|
|
|
+
|
|
|
}
|
|
|
|
|
|
protected void onResume() {
|
|
@@ -54,8 +70,9 @@ public class SettingsActivity extends PreferenceActivity implements OnSharedPref
|
|
|
if(!path.endsWith("/"))
|
|
|
path = path.concat(new String("/"));
|
|
|
if (!path.matches("/(([a-zA-Z_0-9])+/)*")){
|
|
|
- Toast.makeText(getApplicationContext(), "Path not valid. Must only contain a-zA-Z_0-9", Toast.LENGTH_SHORT).show();
|
|
|
+ Toast.makeText(this, "Path not valid. Must only contain a-zA-Z_0-9", Toast.LENGTH_SHORT).show();
|
|
|
path = "/";
|
|
|
+ sharedPreferences.edit().putString(key, path).commit();
|
|
|
}
|
|
|
pref.setSummary(path);
|
|
|
}
|
|
@@ -64,6 +81,28 @@ public class SettingsActivity extends PreferenceActivity implements OnSharedPref
|
|
|
EditTextPreference etp = (EditTextPreference) pref;
|
|
|
pref.setSummary(etp.getText());
|
|
|
}
|
|
|
+ else if(key.equals("pref_max_connections")){
|
|
|
+ Preference pref = findPreference(key);
|
|
|
+ EditTextPreference etp = (EditTextPreference) pref;
|
|
|
+ String value = etp.getText();
|
|
|
+ if(!value.matches("([0-9])+")){
|
|
|
+ Toast.makeText(getApplicationContext(), "Enter a valid number.", Toast.LENGTH_SHORT).show();
|
|
|
+ value = getResources().getString(R.string.pref_max_connections_default);
|
|
|
+ }
|
|
|
+ sharedPreferences.edit().putInt("max_connections", Integer.valueOf(value).intValue()).commit();
|
|
|
+ pref.setSummary(value);
|
|
|
+ }
|
|
|
+ else if(key.equals("pref_timeout")){
|
|
|
+ Preference pref = findPreference(key);
|
|
|
+ EditTextPreference etp = (EditTextPreference) pref;
|
|
|
+ String value = etp.getText();
|
|
|
+ if(!value.matches("([0-9])+")){
|
|
|
+ Toast.makeText(getApplicationContext(), "Enter a valid number.", Toast.LENGTH_SHORT).show();
|
|
|
+ value = getResources().getString(R.string.pref_timeout_default);
|
|
|
+ }
|
|
|
+ sharedPreferences.edit().putInt("timeout", Integer.valueOf(value).intValue()).commit();
|
|
|
+ pref.setSummary(value);
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
}
|