From d0c0d1c433b6f69394062e15cd948373cbbf0b37 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Wed, 15 Oct 2014 09:37:27 +0200 Subject: [PATCH] Do not save account if username and/or domain not provided --- res/values/non_localizable_custom.xml | 28 +++++++++---------- .../linphone/AccountPreferencesFragment.java | 13 +++++++-- src/org/linphone/LinphonePreferences.java | 10 +++++-- 3 files changed, 32 insertions(+), 19 deletions(-) diff --git a/res/values/non_localizable_custom.xml b/res/values/non_localizable_custom.xml index a0f32cd1e..9c2e24e3a 100644 --- a/res/values/non_localizable_custom.xml +++ b/res/values/non_localizable_custom.xml @@ -2,7 +2,7 @@ false - + true 622464153529 @@ -18,9 +18,9 @@ false true false - + false - false + true false false @@ -33,13 +33,13 @@ false true true - + false false false true - + false true false @@ -48,13 +48,13 @@ false true false - + false - + true false false - + true false @@ -71,23 +71,23 @@ false true false - + false false false - + true - + false false false false - + linphone-android@belledonne-communications.com linphone-android-photo-temp.jpg linphone-android-photo-%s.jpg - + true - + diff --git a/src/org/linphone/AccountPreferencesFragment.java b/src/org/linphone/AccountPreferencesFragment.java index fc5861f2b..51e3f5088 100644 --- a/src/org/linphone/AccountPreferencesFragment.java +++ b/src/org/linphone/AccountPreferencesFragment.java @@ -495,9 +495,16 @@ public class AccountPreferencesFragment extends PreferencesListFragment { } setListPreferenceValues(pref, entries, values); - pref.setSummary(mPrefs.getAccountTransportString(n)); - pref.setDefaultValue(mPrefs.getAccountTransportKey(n)); - pref.setValueIndex(entries.indexOf(mPrefs.getAccountTransportString(n))); + if (! isNewAccount) { + pref.setSummary(mPrefs.getAccountTransportString(n)); + pref.setDefaultValue(mPrefs.getAccountTransportKey(n)); + pref.setValueIndex(entries.indexOf(mPrefs.getAccountTransportString(n))); + } else { + + pref.setSummary(getString(R.string.pref_transport_udp)); + pref.setDefaultValue(getString(R.string.pref_transport_udp)); + pref.setValueIndex(entries.indexOf(getString(R.string.pref_transport_udp))); + } } private static void setListPreferenceValues(ListPreference pref, List entries, List values) { diff --git a/src/org/linphone/LinphonePreferences.java b/src/org/linphone/LinphonePreferences.java index 429809e4f..c3bfbbda5 100644 --- a/src/org/linphone/LinphonePreferences.java +++ b/src/org/linphone/LinphonePreferences.java @@ -283,6 +283,12 @@ public class LinphonePreferences { * @throws LinphoneCoreException */ public void saveNewAccount() throws LinphoneCoreException { + + if (tempUsername == null || tempUsername.length() < 1 || tempDomain == null || tempDomain.length() < 1) { + Log.w("Skipping account save: username or domain not provided"); + return; + } + String identity = "sip:" + tempUsername + "@" + tempDomain; String proxy = "sip:"; if (tempProxy == null) { @@ -785,11 +791,11 @@ public class LinphonePreferences { public void sendDTMFsAsSipInfo(boolean use) { getLc().setUseSipInfoForDtmfs(use); } - + public String getVoiceMailUri() { return getConfig().getString("app", "voice_mail", null); } - + public void setVoiceMailUri(String uri) { getConfig().setString("app", "voice_mail", uri); }