Added chat preferences folder with lime encryption setting

This commit is contained in:
Sylvain Berfini 2016-07-15 12:32:20 +02:00
parent 7ea7da9f0d
commit d8e8700e60
9 changed files with 117 additions and 32 deletions

View file

@ -199,4 +199,6 @@
<item>Send logs</item> <item>Send logs</item>
<item>Cancel</item> <item>Cancel</item>
</string-array> </string-array>
<string name="pref_use_lime_encryption_key">pref_use_lime_encryption_key</string>
</resources> </resources>

View file

@ -271,6 +271,15 @@
<string name="pref_rfc2833_dtmf">Send RFC2833 DTMFs</string> <string name="pref_rfc2833_dtmf">Send RFC2833 DTMFs</string>
<string name="pref_sipinfo_dtmf">Send SIP INFO DTMFs</string> <string name="pref_sipinfo_dtmf">Send SIP INFO DTMFs</string>
<string name="pref_voice_mail">Voice mail URI</string> <string name="pref_voice_mail">Voice mail URI</string>
<!-- Chat settings -->
<string name="pref_chat_title">Chat</string>
<string name="pref_image_sharing_server_title">Sharing server</string>
<string name="pref_image_sharing_server_desc">Do not edit unless you know what you are doing!</string>
<string name="pref_use_lime_encryption">Use LIME encryption</string>
<string name="lime_encryption_entry_disabled">Disabled</string>
<string name="lime_encryption_entry_mandatory">Mandatory</string>
<string name="lime_encryption_entry_preferred">Preferred</string>
<!-- Network settings --> <!-- Network settings -->
<string name="pref_network_title">Network</string> <string name="pref_network_title">Network</string>
@ -296,7 +305,6 @@
<string name="pref_service_notification">Enable service notification</string> <string name="pref_service_notification">Enable service notification</string>
<string name="pref_autostart">Start at boot time</string> <string name="pref_autostart">Start at boot time</string>
<string name="pref_incoming_call_timeout_title">Incoming call hangup (in seconds)</string> <string name="pref_incoming_call_timeout_title">Incoming call hangup (in seconds)</string>
<string name="pref_image_sharing_server_title">Sharing server</string>
<string name="pref_remote_provisioning_title">Remote provisioning</string> <string name="pref_remote_provisioning_title">Remote provisioning</string>
<string name="pref_primary_account_title">Primary account</string> <string name="pref_primary_account_title">Primary account</string>
<string name="pref_display_name_title">Display name</string> <string name="pref_display_name_title">Display name</string>

View file

@ -141,6 +141,20 @@
android:key="@string/pref_voice_mail_key"/> android:key="@string/pref_voice_mail_key"/>
</PreferenceScreen> </PreferenceScreen>
<PreferenceScreen
android:title="@string/pref_chat_title">
<EditTextPreference
android:title="@string/pref_image_sharing_server_title"
android:key="@string/pref_image_sharing_server_key"
android:summary="@string/pref_image_sharing_server_desc"/>
<ListPreference
android:title="@string/pref_use_lime_encryption"
android:key="@string/pref_use_lime_encryption_key"/>
</PreferenceScreen>
<PreferenceScreen <PreferenceScreen
android:title="@string/pref_network_title"> android:title="@string/pref_network_title">
@ -224,10 +238,6 @@
android:key="@string/pref_incoming_call_timeout_key" android:key="@string/pref_incoming_call_timeout_key"
android:layout="@layout/hidden"/> android:layout="@layout/hidden"/>
<EditTextPreference
android:title="@string/pref_image_sharing_server_title"
android:key="@string/pref_image_sharing_server_key"/>
<EditTextPreference <EditTextPreference
android:title="@string/pref_remote_provisioning_title" android:title="@string/pref_remote_provisioning_title"
android:key="@string/pref_remote_provisioning_key"/> android:key="@string/pref_remote_provisioning_key"/>

View file

@ -1250,7 +1250,7 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
if (!LinphoneService.isReady()) { if (!LinphoneService.isReady()) {
startService(new Intent(Intent.ACTION_MAIN).setClass(this, LinphoneService.class)); startService(new Intent(Intent.ACTION_MAIN).setClass(this, LinphoneService.class));
} }
@ -1336,7 +1336,7 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
@Override @Override
protected void onNewIntent(Intent intent) { protected void onNewIntent(Intent intent) {
super.onNewIntent(intent); super.onNewIntent(intent);
Bundle extras = intent.getExtras(); Bundle extras = intent.getExtras();
if (extras != null && extras.getBoolean("GoToChat", false)) { if (extras != null && extras.getBoolean("GoToChat", false)) {
LinphoneService.instance().removeMessageNotification(); LinphoneService.instance().removeMessageNotification();

View file

@ -20,7 +20,6 @@ package org.linphone;
import static android.content.Intent.ACTION_MAIN; import static android.content.Intent.ACTION_MAIN;
import org.linphone.mediastream.Log;
import org.linphone.assistant.RemoteProvisioningActivity; import org.linphone.assistant.RemoteProvisioningActivity;
import org.linphone.tutorials.TutorialLauncherActivity; import org.linphone.tutorials.TutorialLauncherActivity;
@ -83,7 +82,6 @@ public class LinphoneLauncherActivity extends Activity {
}, 1000); }, 1000);
} }
private class ServiceWaitThread extends Thread { private class ServiceWaitThread extends Thread {
public void run() { public void run() {
while (!LinphoneService.isReady()) { while (!LinphoneService.isReady()) {

View file

@ -32,6 +32,7 @@ import org.linphone.core.LinphoneAuthInfo;
import org.linphone.core.LinphoneCore; import org.linphone.core.LinphoneCore;
import org.linphone.core.LinphoneCore.AdaptiveRateAlgorithm; import org.linphone.core.LinphoneCore.AdaptiveRateAlgorithm;
import org.linphone.core.LinphoneCore.FirewallPolicy; import org.linphone.core.LinphoneCore.FirewallPolicy;
import org.linphone.core.LinphoneCore.LinphoneLimeState;
import org.linphone.core.LinphoneCore.MediaEncryption; import org.linphone.core.LinphoneCore.MediaEncryption;
import org.linphone.core.LinphoneCore.Transports; import org.linphone.core.LinphoneCore.Transports;
import org.linphone.core.LinphoneCoreException; import org.linphone.core.LinphoneCoreException;
@ -1310,4 +1311,12 @@ public class LinphonePreferences {
public void enableOverlay(boolean enable) { public void enableOverlay(boolean enable) {
getConfig().setBool("app", "display_overlay", enable); getConfig().setBool("app", "display_overlay", enable);
} }
public LinphoneLimeState getLimeEncryption() {
return getLc().getLimeEncryption();
}
public void setLimeEncryption(LinphoneLimeState lime) {
getLc().setLimeEncryption(lime);
}
} }

View file

@ -19,13 +19,14 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.linphone.core.LinphoneAddress; import org.linphone.core.LinphoneAddress;
import org.linphone.core.LinphoneCore; import org.linphone.core.LinphoneCore;
import org.linphone.core.LinphoneCore.AdaptiveRateAlgorithm;
import org.linphone.core.LinphoneCore.EcCalibratorStatus; import org.linphone.core.LinphoneCore.EcCalibratorStatus;
import org.linphone.core.LinphoneCore.LinphoneLimeState;
import org.linphone.core.LinphoneCore.MediaEncryption; import org.linphone.core.LinphoneCore.MediaEncryption;
import org.linphone.core.LinphoneCoreException; import org.linphone.core.LinphoneCoreException;
import org.linphone.core.LinphoneCoreListenerBase; import org.linphone.core.LinphoneCoreListenerBase;
@ -37,9 +38,8 @@ import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration;
import org.linphone.purchase.InAppPurchaseActivity; import org.linphone.purchase.InAppPurchaseActivity;
import org.linphone.ui.LedPreference; import org.linphone.ui.LedPreference;
import org.linphone.ui.PreferencesListFragment; import org.linphone.ui.PreferencesListFragment;
import android.content.Intent;
import android.net.Uri; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.preference.CheckBoxPreference; import android.preference.CheckBoxPreference;
@ -50,27 +50,24 @@ import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.Preference.OnPreferenceClickListener; import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceCategory; import android.preference.PreferenceCategory;
import android.preference.PreferenceScreen; import android.preference.PreferenceScreen;
import android.provider.Settings;
/** /**
* @author Sylvain Berfini * @author Sylvain Berfini
*/ */
public class SettingsFragment extends PreferencesListFragment { public class SettingsFragment extends PreferencesListFragment {
private static final int WIZARD_INTENT = 1;
private static final int STORE_INTENT = 2; private static final int STORE_INTENT = 2;
private LinphonePreferences mPrefs; private LinphonePreferences mPrefs;
private Handler mHandler = new Handler(); private Handler mHandler = new Handler();
private LinphoneCoreListenerBase mListener; private LinphoneCoreListenerBase mListener;
public SettingsFragment() {
super(R.xml.preferences);
mPrefs = LinphonePreferences.instance();
}
@Override @Override
public void onCreate(Bundle bundle) { public void onCreate(Bundle bundle) {
super.onCreate(bundle); super.onCreate(bundle);
mPrefs = LinphonePreferences.instance();
removePreviousPreferencesFile(); // Required when updating the preferences order
addPreferencesFromResource(R.xml.preferences);
// Init the settings page interface // Init the settings page interface
initSettings(); initSettings();
setListeners(); setListeners();
@ -100,6 +97,11 @@ public class SettingsFragment extends PreferencesListFragment {
} }
}; };
} }
private void removePreviousPreferencesFile() {
File dir = new File(LinphoneActivity.instance().getFilesDir().getAbsolutePath() + "shared_prefs");
dir.delete();
}
// Inits the values or the listener on some settings // Inits the values or the listener on some settings
private void initSettings() { private void initSettings() {
@ -107,6 +109,7 @@ public class SettingsFragment extends PreferencesListFragment {
initAudioSettings(); initAudioSettings();
initVideoSettings(); initVideoSettings();
initCallSettings(); initCallSettings();
initChatSettings();
initNetworkSettings(); initNetworkSettings();
initAdvancedSettings(); initAdvancedSettings();
@ -134,6 +137,7 @@ public class SettingsFragment extends PreferencesListFragment {
setAudioPreferencesListener(); setAudioPreferencesListener();
setVideoPreferencesListener(); setVideoPreferencesListener();
setCallPreferencesListener(); setCallPreferencesListener();
setChatPreferencesListener();
setNetworkPreferencesListener(); setNetworkPreferencesListener();
setAdvancedPreferencesListener(); setAdvancedPreferencesListener();
} }
@ -436,6 +440,30 @@ public class SettingsFragment extends PreferencesListFragment {
pref.setSummary(value); pref.setSummary(value);
pref.setValue(value); pref.setValue(value);
} }
private void initLimeEncryptionPreference(ListPreference pref) {
List<CharSequence> entries = new ArrayList<CharSequence>();
List<CharSequence> values = new ArrayList<CharSequence>();
entries.add(getString(R.string.lime_encryption_entry_disabled));
values.add(LinphoneLimeState.Disabled.toString());
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
if (lc == null || !lc.isLimeEncryptionAvailable()) {
setListPreferenceValues(pref, entries, values);
pref.setEnabled(false);
return;
}
entries.add(getString(R.string.lime_encryption_entry_mandatory));
values.add(LinphoneLimeState.Mandatory.toString());
entries.add(getString(R.string.lime_encryption_entry_preferred));
values.add(LinphoneLimeState.Preferred.toString());
setListPreferenceValues(pref, entries, values);
LinphoneLimeState lime = mPrefs.getLimeEncryption();
pref.setSummary(lime.toString());
pref.setValue(lime.toString());
}
private static void setListPreferenceValues(ListPreference pref, List<CharSequence> entries, List<CharSequence> values) { private static void setListPreferenceValues(ListPreference pref, List<CharSequence> entries, List<CharSequence> values) {
CharSequence[] contents = new CharSequence[entries.size()]; CharSequence[] contents = new CharSequence[entries.size()];
@ -776,6 +804,47 @@ public class SettingsFragment extends PreferencesListFragment {
}); });
} }
private void initChatSettings() {
setPreferenceDefaultValueAndSummary(R.string.pref_image_sharing_server_key, mPrefs.getSharingPictureServerUrl());
initLimeEncryptionPreference((ListPreference) findPreference(getString(R.string.pref_use_lime_encryption_key)));
}
private void setChatPreferencesListener() {
findPreference(getString(R.string.pref_image_sharing_server_key)).setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
String value = (String) newValue;
mPrefs.setSharingPictureServerUrl(value);
preference.setSummary(value);
return true;
}
});
findPreference(getString(R.string.pref_use_lime_encryption_key)).setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
String value = newValue.toString();
LinphoneLimeState lime = LinphoneLimeState.Disabled;
if (value.equals(LinphoneLimeState.Mandatory.toString()))
lime = LinphoneLimeState.Mandatory;
else if (value.equals(LinphoneLimeState.Preferred.toString()))
lime = LinphoneLimeState.Preferred;
mPrefs.setLimeEncryption(lime);
lime = mPrefs.getLimeEncryption();
if (lime == LinphoneLimeState.Disabled) {
preference.setSummary(getString(R.string.lime_encryption_entry_disabled));
} else if (lime == LinphoneLimeState.Mandatory) {
preference.setSummary(getString(R.string.lime_encryption_entry_mandatory));
} else if (lime == LinphoneLimeState.Preferred) {
preference.setSummary(getString(R.string.lime_encryption_entry_preferred));
}
return true;
}
});
}
private void initNetworkSettings() { private void initNetworkSettings() {
initMediaEncryptionPreference((ListPreference) findPreference(getString(R.string.pref_media_encryption_key))); initMediaEncryptionPreference((ListPreference) findPreference(getString(R.string.pref_media_encryption_key)));
@ -919,7 +988,6 @@ public class SettingsFragment extends PreferencesListFragment {
((CheckBoxPreference)findPreference(getString(R.string.pref_animation_enable_key))).setChecked(mPrefs.areAnimationsEnabled()); ((CheckBoxPreference)findPreference(getString(R.string.pref_animation_enable_key))).setChecked(mPrefs.areAnimationsEnabled());
((CheckBoxPreference)findPreference(getString(R.string.pref_service_notification_key))).setChecked(mPrefs.getServiceNotificationVisibility()); ((CheckBoxPreference)findPreference(getString(R.string.pref_service_notification_key))).setChecked(mPrefs.getServiceNotificationVisibility());
((CheckBoxPreference)findPreference(getString(R.string.pref_autostart_key))).setChecked(mPrefs.isAutoStartEnabled()); ((CheckBoxPreference)findPreference(getString(R.string.pref_autostart_key))).setChecked(mPrefs.isAutoStartEnabled());
setPreferenceDefaultValueAndSummary(R.string.pref_image_sharing_server_key, mPrefs.getSharingPictureServerUrl());
setPreferenceDefaultValueAndSummary(R.string.pref_remote_provisioning_key, mPrefs.getRemoteProvisioningUrl()); setPreferenceDefaultValueAndSummary(R.string.pref_remote_provisioning_key, mPrefs.getRemoteProvisioningUrl());
setPreferenceDefaultValueAndSummary(R.string.pref_display_name_key, mPrefs.getDefaultDisplayName()); setPreferenceDefaultValueAndSummary(R.string.pref_display_name_key, mPrefs.getDefaultDisplayName());
setPreferenceDefaultValueAndSummary(R.string.pref_user_name_key, mPrefs.getDefaultUsername()); setPreferenceDefaultValueAndSummary(R.string.pref_user_name_key, mPrefs.getDefaultUsername());
@ -976,16 +1044,6 @@ public class SettingsFragment extends PreferencesListFragment {
} }
}); });
findPreference(getString(R.string.pref_image_sharing_server_key)).setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
String value = (String) newValue;
mPrefs.setSharingPictureServerUrl(value);
preference.setSummary(value);
return true;
}
});
findPreference(getString(R.string.pref_remote_provisioning_key)).setOnPreferenceChangeListener(new OnPreferenceChangeListener() { findPreference(getString(R.string.pref_remote_provisioning_key)).setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {

@ -1 +1 @@
Subproject commit 374a1ae8be6eea497df54e90041b11d81bb32cdf Subproject commit 245bdae5fe12032e4d0c3041c9e0c6f0d78ed2a7

@ -1 +1 @@
Subproject commit e45b4fe4eb58eed27ece1ca9c33c08be35a7d993 Subproject commit d3e8feeb605b087e33c628ebfd0c79e84d598120