diff --git a/res/values/non_localizable_strings.xml b/res/values/non_localizable_strings.xml
index 557f9092a..e9195c066 100644
--- a/res/values/non_localizable_strings.xml
+++ b/res/values/non_localizable_strings.xml
@@ -94,7 +94,6 @@
pref_stun_server_key
pref_ice_enable_key
pref_video_codec_vp8_key
- pref_media_encryption_key
none
srtp
zrtp
@@ -121,4 +120,36 @@
pref_upnp_enable_key
pref_first_time_linphone_chat_storage
+
+
+ lpconfig_sip_media_enc_key
+
+
+ download_bw
+ upload_bw
+
+
+
+
+ media_encryption
+
+ - @string/lpconfig_sip_media_enc_key
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/res/xml/settings.xml b/res/xml/settings.xml
new file mode 100644
index 000000000..4fb09040f
--- /dev/null
+++ b/res/xml/settings.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/src/org/linphone/LinphoneActivity.java b/src/org/linphone/LinphoneActivity.java
index ceeb649da..b31ae29ab 100644
--- a/src/org/linphone/LinphoneActivity.java
+++ b/src/org/linphone/LinphoneActivity.java
@@ -289,7 +289,7 @@ public class LinphoneActivity extends FragmentActivity implements
dialerFragment = newFragment;
break;
case SETTINGS:
- newFragment = new PreferencesFragment();
+ newFragment = new SettingsFragment();
break;
case ACCOUNT_SETTINGS:
newFragment = new AccountPreferencesFragment();
diff --git a/src/org/linphone/LinphoneManager.java b/src/org/linphone/LinphoneManager.java
index 42753f712..ca0dad75c 100644
--- a/src/org/linphone/LinphoneManager.java
+++ b/src/org/linphone/LinphoneManager.java
@@ -204,7 +204,7 @@ public class LinphoneManager implements LinphoneCoreListener {
private final String mLPConfigXsd;
private final String mLinphoneInitialConfigFile;
private final String mLinphoneRootCaFile;
- private final String mLinphoneConfigFile;
+ public final String mLinphoneConfigFile;
private final String mRingSoundFile;
private final String mRingbackSoundFile;
private final String mPauseSoundFile;
diff --git a/src/org/linphone/LinphonePreferences.java b/src/org/linphone/LinphonePreferences.java
new file mode 100644
index 000000000..685e87abb
--- /dev/null
+++ b/src/org/linphone/LinphonePreferences.java
@@ -0,0 +1,100 @@
+package org.linphone;
+/*
+ChatListFragment.java
+Copyright (C) 2012 Belledonne Communications, Grenoble, France
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+import java.util.HashMap;
+import java.util.Map;
+
+import org.linphone.core.LinphoneCoreFactory;
+import org.linphone.core.LpConfig;
+
+import android.content.res.Resources;
+
+/**
+ * @author Sylvain Berfini
+ */
+public class LinphonePreferences {
+ private static LinphonePreferences instance;
+ private Map dict, changesDict;
+ private LpConfig config;
+
+ public static final synchronized LinphonePreferences getInstance() {
+ if (instance == null) {
+ instance = new LinphonePreferences();
+ instance.Load();
+ }
+ return instance;
+ }
+
+ private LinphonePreferences() {
+ dict = new HashMap();
+ changesDict = new HashMap();
+ if (LinphoneManager.getLcIfManagerNotDestroyedOrNull() == null) {
+ config = LinphoneCoreFactory.instance().createLpConfig(LinphoneManager.getInstance().mLinphoneConfigFile);
+ } else {
+ config = LinphoneManager.getLc().getConfig();
+ }
+ }
+
+ public String get(String key) {
+ if (dict.containsKey(key)) {
+ return dict.get(key);
+ }
+ return null;
+ }
+
+ public String getNew(String key) {
+ if (changesDict.containsKey(key)) {
+ return changesDict.get(key);
+ } else if (dict.containsKey(key)) {
+ return dict.get(key);
+ }
+ return null;
+ }
+
+ public void set(String key, String value) {
+ if (dict.containsKey(key)) {
+ if (dict.get(key) != value || value.length() == 0) {
+ changesDict.put(key, value);
+ }
+ } else {
+ changesDict.put(key, value);
+ }
+ }
+
+ public boolean hasValueChanged(String key) {
+ return changesDict.containsKey(key);
+ }
+
+ public void Load() {
+ Resources res = LinphoneService.instance().getResources();
+ for (String key : res.getStringArray(R.array.lpconfig_net_keys)) {
+ dict.put(key, config.getString("net", key, null));
+ }
+ }
+
+ public void Save() {
+ Resources res = LinphoneService.instance().getResources();
+ for (String key : res.getStringArray(R.array.lpconfig_net_keys)) {
+ if (hasValueChanged(key)) {
+ config.setString("net", key, getNew(key));
+ }
+ }
+ config.sync();
+ }
+}
diff --git a/src/org/linphone/SettingsFragment.java b/src/org/linphone/SettingsFragment.java
new file mode 100644
index 000000000..2ea1a9a6c
--- /dev/null
+++ b/src/org/linphone/SettingsFragment.java
@@ -0,0 +1,41 @@
+package org.linphone;
+
+import org.linphone.LinphoneManager.EcCalibrationListener;
+import org.linphone.core.LinphoneCore.EcCalibratorStatus;
+import org.linphone.ui.PreferencesListFragment;
+
+import android.os.Bundle;
+import android.preference.Preference;
+import android.preference.Preference.OnPreferenceChangeListener;
+
+public class SettingsFragment extends PreferencesListFragment implements EcCalibrationListener {
+ @Override
+ public void onEcCalibrationStatus(EcCalibratorStatus status, int delayMs) {
+
+ }
+
+ public SettingsFragment() {
+ super(R.xml.settings);
+ }
+
+ @Override
+ public void onCreate(Bundle bundle) {
+ super.onCreate(bundle);
+
+ final LinphonePreferences prefs = LinphonePreferences.getInstance();
+ int count = getPreferenceScreen().getPreferenceCount();
+ for (int i = 0; i < count; i++) {
+ Preference pref = getPreferenceScreen().getPreference(i);
+ if (pref.hasKey()) {
+ pref.setDefaultValue(prefs.get(pref.getKey()));
+ pref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ prefs.set(preference.getKey(), newValue.toString());
+ return true;
+ }
+ });
+ }
+ }
+ }
+}