|
@@ -7,6 +7,7 @@ import android.os.Bundle;
|
|
|
import android.preference.EditTextPreference;
|
|
|
import android.preference.Preference;
|
|
|
import android.preference.PreferenceActivity;
|
|
|
+import android.widget.Toast;
|
|
|
|
|
|
public class SettingsActivity extends PreferenceActivity implements OnSharedPreferenceChangeListener {
|
|
|
@Override
|
|
@@ -36,10 +37,25 @@ public class SettingsActivity extends PreferenceActivity implements OnSharedPref
|
|
|
|
|
|
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
|
|
|
String key) {
|
|
|
- if(key.equals("pref_external_location") || key.equals("pref_upload_server")){
|
|
|
+ if(key.equals("pref_external_location")){
|
|
|
+ Preference pref = findPreference(key);
|
|
|
+ EditTextPreference etp = (EditTextPreference) pref;
|
|
|
+ String path = etp.getText();
|
|
|
+ if(!path.startsWith("/"))
|
|
|
+ path = new String("/").concat(path);
|
|
|
+ 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();
|
|
|
+ path = "/";
|
|
|
+ }
|
|
|
+ pref.setSummary(path);
|
|
|
+ }
|
|
|
+ else if(key.equals("pref_upload_server")){
|
|
|
Preference pref = findPreference(key);
|
|
|
EditTextPreference etp = (EditTextPreference) pref;
|
|
|
pref.setSummary(etp.getText());
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
}
|