Reworked settings to be much more like iOS...

This commit is contained in:
Sylvain Berfini 2012-11-05 14:25:15 +01:00
parent 46fa49533f
commit 462fd3d5c3
7 changed files with 326 additions and 355 deletions

View file

@ -75,6 +75,7 @@
<string name="unknown_incoming_call_name">Inconnu</string>
<string name="pref_network_title">Réseau</string>
<string name="pref_transport">Transport</string>
<string name="pref_transport_use_standard_ports">Utiliser les ports standards</string>
<string name="at_least_a_protocol">Au moins un est requis</string>

View file

@ -28,7 +28,14 @@
<string name="pref_audio_ringtone">pref_audio_ringtone</string>
<string name="pref_ipv6_key">pref_ipv6_key</string>
<string name="menu_about_key">menu_about_key</string>
<string name="pref_sipaccounts_key">pref_sipaccounts_key</string>
<string name="setup_key">setup_key</string>
<string name="pref_video_key">pref_video_key</string>
<string name="pref_linphone_friend_key">pref_linphone_friend_key</string>
<string name="pref_transport_key">pref_transport_key</string>
<string name="pref_transport_udp_key">pref_transport_udp_key</string>
<string name="pref_transport_tcp_key">pref_transport_tcp_key</string>
<string name="pref_transport_tls_key">pref_transport_tls_key</string>

View file

@ -91,13 +91,13 @@
<string name="unknown_incoming_call_name">Unknown</string>
<string name="pref_network_title">Network</string>
<string name="pref_transport">Transport</string>
<string name="pref_transport_udp">UDP</string>
<string name="pref_transport_tcp">TCP</string>
<string name="pref_transport_tls">TLS</string>
<string name="pref_transport_use_standard_ports">Use standard ports</string>
<string name="at_least_a_protocol">At least one item is required</string>
<string name="first_launch_ok">Registration successful</string>
<string name="error">Error</string>
<string name="click_to_show_first_login_view">Start</string>

View file

@ -2,13 +2,16 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<Preference
android:title="@string/menu_about"/>
android:title="@string/menu_about"
android:key="@string/menu_about_key"/>
<PreferenceCategory
android:title="@string/pref_sipaccounts"/>
android:title="@string/pref_sipaccounts"
android:key="@string/pref_sipaccounts_key"/>
<Preference
android:title="@string/setup_title"/>
android:title="@string/setup_title"
android:key="@string/setup_key"/>
<PreferenceCategory
android:key="@string/pref_tunnel_key"
@ -34,200 +37,285 @@
<PreferenceCategory
android:title="@string/pref_preferences">
<CheckBoxPreference
android:title="@string/pref_autostart"
android:key="@string/pref_autostart_key"
android:defaultValue="false"/>
<CheckBoxPreference
android:defaultValue="true"
android:title="@string/pref_video_enable_title"
android:key="@string/pref_video_enable_key" />
<CheckBoxPreference
android:defaultValue="false"
android:title="@string/pref_animation_enable_title"
android:key="@string/pref_animation_enable_key" />
<EditTextPreference
android:title="@string/pref_stun_server"
android:defaultValue="@string/default_stun"
android:key="@string/pref_stun_server_key"/>
<CheckBoxPreference
android:title="@string/pref_ice_enable"
android:key="@string/pref_ice_enable_key"
android:defaultValue="false"/>
</PreferenceCategory>
<PreferenceCategory
android:title="@string/pref_audio">
<CheckBoxPreference
android:key="@string/pref_echo_cancellation_key"
android:defaultValue="false"
android:title="@string/pref_echo_cancellation"
android:summary="@string/pref_echo_cancellation_summary"/>
<Preference
android:key="@string/pref_echo_canceller_calibration_key"
android:title="@string/pref_echo_canceller_calibration" />
<EditTextPreference
android:key="@string/pref_audio_port_key"
android:title="@string/pref_audio_port_title"
android:summary="@string/pref_audio_port_description"
android:defaultValue="@string/default_audio_port"
android:layout="@layout/hidden"/>
<PreferenceScreen
android:title="@string/pref_codecs"
android:key="@string/pref_codecs_key">
android:title="@string/pref_audio">
<CheckBoxPreference
android:key="@string/pref_echo_cancellation_key"
android:defaultValue="false"
android:title="@string/pref_echo_cancellation"
android:summary="@string/pref_echo_cancellation_summary"/>
<Preference
android:key="@string/pref_echo_canceller_calibration_key"
android:title="@string/pref_echo_canceller_calibration" />
<PreferenceCategory
android:title="@string/pref_codecs"
android:key="@string/pref_codecs_key">
<CheckBoxPreference
android:key="@string/pref_codec_speex16_key"
android:defaultValue="true"
android:title="@string/pref_codec_speex16"/>
<CheckBoxPreference
android:key="@string/pref_codec_speex8_key"
android:defaultValue="true"
android:title="@string/pref_codec_speex8"/>
<CheckBoxPreference
android:key="@string/pref_codec_ilbc_key"
android:title="@string/pref_codec_ilbc"
android:shouldDisableView="true"
android:summary="@string/pref_ilbc_summary"/>
<CheckBoxPreference
android:key="@string/pref_codec_amr_key"
android:title="@string/pref_codec_amr"
android:defaultValue="true"
android:shouldDisableView="true" />
<CheckBoxPreference
android:key="@string/pref_codec_g729_key"
android:title="@string/pref_codec_g729"
android:defaultValue="true"
android:shouldDisableView="true" />
<CheckBoxPreference
android:key="@string/pref_codec_amrwb_key"
android:title="@string/pref_codec_amrwb"
android:defaultValue="true"
android:shouldDisableView="true" />
<CheckBoxPreference
android:key="@string/pref_codec_gsm_key"
android:defaultValue="true"
android:title="@string/pref_codec_gsm"/>
<CheckBoxPreference
android:key="@string/pref_codec_g722_key"
android:defaultValue="false"
android:title="@string/pref_codec_g722"/>
<CheckBoxPreference
android:key="@string/pref_codec_silk24_key"
android:defaultValue="false"
android:title="@string/pref_codec_silk24"/>
<CheckBoxPreference
android:key="@string/pref_codec_silk16_key"
android:defaultValue="false"
android:title="@string/pref_codec_silk16"/>
<CheckBoxPreference
android:key="@string/pref_codec_pcmu_key"
android:defaultValue="true"
android:title="@string/pref_codec_pcmu"/>
<CheckBoxPreference
android:key="@string/pref_codec_pcma_key"
android:defaultValue="true"
android:title="@string/pref_codec_pcma"/>
</PreferenceCategory>
</PreferenceScreen>
<PreferenceScreen
android:title="@string/pref_video"
android:dependency="@string/pref_video_enable_key"
android:key="@string/pref_video_key"
android:shouldDisableView="true">
<CheckBoxPreference
android:key="@string/pref_codec_speex16_key"
android:key="@string/pref_video_use_front_camera_key"
android:defaultValue="true"
android:title="@string/pref_video_use_front_camera_title"
android:dependency="@string/pref_video_enable_key"
android:layout="@layout/hidden"/>
<CheckBoxPreference
android:key="@string/pref_video_initiate_call_with_video_key"
android:defaultValue="true"
android:title="@string/pref_codec_speex16"/>
android:title="@string/pref_video_initiate_call_with_video_title"
android:summary="@string/pref_video_initiate_call_with_video"
android:dependency="@string/pref_video_enable_key"/>
<CheckBoxPreference
android:key="@string/pref_video_automatically_share_my_video_key"
android:title="@string/pref_video_automatically_share_my_video_title"
android:defaultValue="true"
android:summary="@string/pref_video_automatically_share_my_video"
android:dependency="@string/pref_video_enable_key"
android:layout="@layout/hidden"/>
<CheckBoxPreference
android:key="@string/pref_video_automatically_accept_video_key"
android:title="@string/pref_video_automatically_accept_video_title"
android:defaultValue="true"
android:summary="@string/pref_video_automatically_accept_video"
android:dependency="@string/pref_video_enable_key"/>
<PreferenceCategory
android:dependency="@string/pref_video_enable_key"
android:shouldDisableView="true"
android:key="@string/pref_video_codecs_key"
android:title="@string/pref_video_codecs_title">
<CheckBoxPreference
android:key="@string/pref_video_codec_vp8_key"
android:title="@string/pref_video_codec_vp8_title"
android:defaultValue="true"/>
<CheckBoxPreference
android:key="@string/pref_video_codec_h264_key"
android:title="@string/pref_video_codec_h264_title"
android:defaultValue="false"/>
<CheckBoxPreference
android:key="@string/pref_video_codec_mpeg4_key"
android:title="@string/pref_video_codec_mpeg4_title"
android:defaultValue="false"/>
<CheckBoxPreference
android:key="@string/pref_video_codec_h263_key"
android:title="@string/pref_video_codec_h263_title"
android:defaultValue="false"
android:layout="@layout/hidden"/>
</PreferenceCategory>
</PreferenceScreen>
<PreferenceScreen
android:title="@string/call">
<EditTextPreference
android:title="@string/pref_prefix"
android:key="@string/pref_prefix_key"/>
<CheckBoxPreference
android:key="@string/pref_escape_plus_key"
android:title="@string/pref_escape_plus"/>
</PreferenceScreen>
<PreferenceScreen
android:title="@string/pref_network_title">
<CheckBoxPreference
android:key="@string/pref_codec_speex8_key"
android:defaultValue="true"
android:title="@string/pref_codec_speex8"/>
android:key="@string/pref_wifi_only_key"
android:title="@string/pref_wifi_only"/>
<EditTextPreference
android:title="@string/pref_stun_server"
android:defaultValue="@string/default_stun"
android:key="@string/pref_stun_server_key"/>
<CheckBoxPreference
android:title="@string/pref_ice_enable"
android:key="@string/pref_ice_enable_key"
android:defaultValue="false"/>
<CheckBoxPreference
android:key="@string/pref_codec_ilbc_key"
android:title="@string/pref_codec_ilbc"
android:shouldDisableView="true"
android:summary="@string/pref_ilbc_summary"/>
android:key="@string/pref_transport_use_standard_ports_key"
android:title="@string/pref_transport_use_standard_ports"/>
<EditTextPreference
android:key="@string/pref_audio_port_key"
android:title="@string/pref_audio_port_title"
android:summary="@string/pref_audio_port_description"
android:defaultValue="@string/default_audio_port"
android:layout="@layout/hidden"/>
<EditTextPreference
android:key="@string/pref_video_port_key"
android:title="@string/pref_video_port_title"
android:defaultValue="@string/default_video_port"
android:summary="@string/pref_video_port_description"
android:layout="@layout/hidden"/>
<ListPreference
android:title="@string/pref_transport"
android:key="@string/pref_transport_key"
android:defaultValue="@string/pref_transport_udp_key" />
<ListPreference
android:title="@string/pref_media_encryption"
android:key="@string/pref_media_encryption_key"
android:defaultValue="@string/pref_media_encryption_key_none" />
<CheckBoxPreference
android:key="@string/pref_codec_amr_key"
android:title="@string/pref_codec_amr"
android:defaultValue="true"
android:shouldDisableView="true" />
android:key="@string/pref_push_notification_key"
android:title="@string/pref_push_notification"
android:defaultValue="false"/>
<CheckBoxPreference
android:key="@string/pref_codec_g729_key"
android:title="@string/pref_codec_g729"
android:defaultValue="true"
android:shouldDisableView="true" />
<CheckBoxPreference
android:key="@string/pref_codec_amrwb_key"
android:title="@string/pref_codec_amrwb"
android:defaultValue="true"
android:shouldDisableView="true" />
<CheckBoxPreference
android:key="@string/pref_codec_gsm_key"
android:defaultValue="true"
android:title="@string/pref_codec_gsm"/>
<CheckBoxPreference
android:key="@string/pref_codec_g722_key"
android:defaultValue="false"
android:title="@string/pref_codec_g722"/>
<CheckBoxPreference
android:key="@string/pref_codec_silk24_key"
android:defaultValue="false"
android:title="@string/pref_codec_silk24"/>
<CheckBoxPreference
android:key="@string/pref_codec_silk16_key"
android:defaultValue="false"
android:title="@string/pref_codec_silk16"/>
<CheckBoxPreference
android:key="@string/pref_codec_pcmu_key"
android:defaultValue="true"
android:title="@string/pref_codec_pcmu"/>
<CheckBoxPreference
android:key="@string/pref_codec_pcma_key"
android:defaultValue="true"
android:title="@string/pref_codec_pcma"/>
android:key="@string/pref_ipv6_key"
android:title="@string/pref_ipv6_title"
android:defaultValue="false" />
</PreferenceScreen>
</PreferenceCategory>
<PreferenceCategory
android:title="@string/pref_video"
android:dependency="@string/pref_video_enable_key"
android:shouldDisableView="true">
<CheckBoxPreference
android:key="@string/pref_video_use_front_camera_key"
android:defaultValue="true"
android:title="@string/pref_video_use_front_camera_title"
android:dependency="@string/pref_video_enable_key"
android:layout="@layout/hidden"/>
<PreferenceScreen
android:title="@string/pref_advanced">
<CheckBoxPreference
android:key="@string/pref_video_initiate_call_with_video_key"
android:defaultValue="true"
android:title="@string/pref_video_initiate_call_with_video_title"
android:summary="@string/pref_video_initiate_call_with_video"
android:dependency="@string/pref_video_enable_key"/>
<CheckBoxPreference
android:key="@string/pref_video_automatically_share_my_video_key"
android:title="@string/pref_video_automatically_share_my_video_title"
android:defaultValue="true"
android:summary="@string/pref_video_automatically_share_my_video"
android:dependency="@string/pref_video_enable_key"
android:layout="@layout/hidden"/>
<CheckBoxPreference
android:key="@string/pref_video_automatically_accept_video_key"
android:title="@string/pref_video_automatically_accept_video_title"
android:defaultValue="true"
android:summary="@string/pref_video_automatically_accept_video"
android:dependency="@string/pref_video_enable_key"/>
<EditTextPreference
android:key="@string/pref_video_port_key"
android:title="@string/pref_video_port_title"
android:defaultValue="@string/default_video_port"
android:summary="@string/pref_video_port_description"
android:layout="@layout/hidden"/>
<PreferenceScreen
android:dependency="@string/pref_video_enable_key"
android:shouldDisableView="true"
android:key="@string/pref_video_codecs_key"
android:title="@string/pref_video_codecs_title">
<CheckBoxPreference
android:key="@string/pref_debug_key"
android:title="@string/pref_debug"
android:defaultValue="false"/>
<CheckBoxPreference
android:key="@string/pref_video_codec_vp8_key"
android:title="@string/pref_video_codec_vp8_title"
android:defaultValue="true"/>
<CheckBoxPreference
android:defaultValue="false"
android:title="@string/pref_animation_enable_title"
android:key="@string/pref_animation_enable_key" />
<CheckBoxPreference
android:title="@string/pref_autostart"
android:key="@string/pref_autostart_key"
android:defaultValue="false"/>
<EditTextPreference
android:key="@string/pref_incoming_call_timeout_key"
android:title="@string/pref_incoming_call_timeout_title"
android:defaultValue="30"
android:layout="@layout/hidden"/>
<PreferenceScreen
android:title="@string/pref_audio_hacks_title"
android:layout="@layout/hidden">
<CheckBoxPreference
android:key="@string/pref_video_codec_h264_key"
android:title="@string/pref_video_codec_h264_title"
android:defaultValue="false"/>
android:key="@string/pref_audio_hacks_use_routing_api_key"
android:title="@string/pref_audio_hacks_use_routing_api_title" />
<CheckBoxPreference
android:key="@string/pref_video_codec_mpeg4_key"
android:title="@string/pref_video_codec_mpeg4_title"
android:defaultValue="false"/>
<CheckBoxPreference
android:key="@string/pref_video_codec_h263_key"
android:title="@string/pref_video_codec_h263_title"
android:defaultValue="false"
android:layout="@layout/hidden"/>
<CheckBoxPreference
android:key="@string/pref_audio_hacks_use_galaxys_hack_key"
android:title="@string/pref_audio_hacks_use_galaxys_hack_title" />
<EditTextPreference
android:key="@string/pref_audio_use_specific_mode_key"
android:title="@string/pref_audio_use_specific_mode_title"
android:summary="@string/pref_audio_use_specific_mode_summary"
android:defaultValue="0"
android:numeric="integer" />
</PreferenceScreen>
</PreferenceScreen>
</PreferenceCategory>
<PreferenceCategory
android:title="@string/pref_linphone_friend_title">
android:title="@string/pref_linphone_friend_title"
android:key="@string/pref_linphone_friend_key">
<CheckBoxPreference
android:key="@string/pref_auto_accept_friends_key"
@ -237,90 +325,4 @@
</PreferenceCategory>
<PreferenceCategory
android:title="@string/pref_advanced">
<EditTextPreference
android:title="@string/pref_prefix"
android:key="@string/pref_prefix_key"/>
<CheckBoxPreference
android:key="@string/pref_escape_plus_key"
android:title="@string/pref_escape_plus"/>
<EditTextPreference
android:key="@string/pref_incoming_call_timeout_key"
android:title="@string/pref_incoming_call_timeout_title"
android:defaultValue="30"
android:layout="@layout/hidden"/>
<CheckBoxPreference
android:key="@string/pref_debug_key"
android:title="@string/pref_debug"
android:defaultValue="false"/>
<PreferenceScreen
android:title="@string/pref_network_title">
<CheckBoxPreference
android:key="@string/pref_ipv6_key"
android:title="@string/pref_ipv6_title"
android:defaultValue="false" />
<CheckBoxPreference
android:key="@string/pref_transport_udp_key"
android:title="@string/pref_transport_udp"
android:defaultValue="true"/>
<CheckBoxPreference
android:key="@string/pref_transport_tcp_key"
android:title="@string/pref_transport_tcp" />
<CheckBoxPreference
android:key="@string/pref_transport_tls_key"
android:title="@string/pref_transport_tls" />
<CheckBoxPreference
android:key="@string/pref_transport_use_standard_ports_key"
android:title="@string/pref_transport_use_standard_ports"/>
<CheckBoxPreference
android:key="@string/pref_wifi_only_key"
android:title="@string/pref_wifi_only"/>
<CheckBoxPreference
android:key="@string/pref_push_notification_key"
android:title="@string/pref_push_notification"
android:defaultValue="false"/>
</PreferenceScreen>
<ListPreference
android:title="@string/pref_media_encryption"
android:key="@string/pref_media_encryption_key"
android:defaultValue="@string/pref_media_encryption_key_none" />
<PreferenceScreen
android:title="@string/pref_audio_hacks_title"
android:layout="@layout/hidden">
<CheckBoxPreference
android:key="@string/pref_audio_hacks_use_routing_api_key"
android:title="@string/pref_audio_hacks_use_routing_api_title" />
<CheckBoxPreference
android:key="@string/pref_audio_hacks_use_galaxys_hack_key"
android:title="@string/pref_audio_hacks_use_galaxys_hack_title" />
<EditTextPreference
android:key="@string/pref_audio_use_specific_mode_key"
android:title="@string/pref_audio_use_specific_mode_title"
android:summary="@string/pref_audio_use_specific_mode_summary"
android:defaultValue="0"
android:numeric="integer" />
</PreferenceScreen>
</PreferenceCategory>
</PreferenceScreen>

View file

@ -771,28 +771,35 @@ public final class LinphoneManager implements LinphoneCoreListener {
Log.e("Bad port number ["+lPreviousPort+"] using random instead");
lPreviousPort=(0xDFFF & (int)Math.random())+1024;
}
if (!getPrefBoolean(R.string.pref_transport_tcp_key, false)) {
ports.tcp = 0;
} else if (useStandardPort) {
ports.tcp = 5060;
} else if (ports.tcp==0){
ports.tcp=lPreviousPort;
}
if (!getPrefBoolean(R.string.pref_transport_udp_key, false)) {
String transport = getPrefString(R.string.pref_transport_key, getString(R.string.pref_transport_udp_key));
if (transport.equals(getString(R.string.pref_transport_tcp_key)))
{
ports.udp = 0;
} else if (useStandardPort) {
ports.udp = 5060;
} else if (ports.udp==0) {
ports.udp = lPreviousPort;
}
if (!getPrefBoolean(R.string.pref_transport_tls_key, false)) {
ports.tls = 0;
} else if (useStandardPort) {
ports.tls = 5061;
} else if (ports.tls==0) {
ports.tls=lPreviousPort;
if (useStandardPort) {
ports.tcp = 5060;
} else if (ports.tcp==0){
ports.tcp=lPreviousPort;
}
} else if (transport.equals(getString(R.string.pref_transport_udp_key)))
{
ports.tcp = 0;
ports.tls = 0;
if (useStandardPort) {
ports.udp = 5060;
} else if (ports.udp==0) {
ports.udp = lPreviousPort;
}
} else if (transport.equals(getString(R.string.pref_transport_tls_key)))
{
ports.udp = 0;
ports.tcp = 0;
if (useStandardPort) {
ports.tls = 5061;
} else if (ports.tls==0) {
ports.tls=lPreviousPort;
}
}
mLc.setSignalingTransportPorts(ports);

View file

@ -25,10 +25,10 @@ import static org.linphone.R.string.pref_codec_speex16_key;
import static org.linphone.R.string.pref_echo_cancellation_key;
import static org.linphone.R.string.pref_echo_canceller_calibration_key;
import static org.linphone.R.string.pref_media_encryption_key;
import static org.linphone.R.string.pref_transport_key;
import static org.linphone.R.string.pref_video_enable_key;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.linphone.LinphoneManager.EcCalibrationListener;
@ -55,11 +55,8 @@ import android.os.Handler;
import android.preference.CheckBoxPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceCategory;
import android.preference.PreferenceFragment;
import android.preference.PreferenceScreen;
public class PreferencesFragment extends PreferencesListFragment implements EcCalibrationListener {
private Handler mHandler = new Handler();
@ -70,11 +67,6 @@ public class PreferencesFragment extends PreferencesListFragment implements EcCa
private int nbAccounts = 1;
private PreferenceCategory accounts;
private static final int ABOUT_SETTINGS_ID = 0;
private static final int ACCOUNTS_SETTINGS_ID = 1;
private static final int WIZARD_SETTINGS_ID = 2;
private static final int CAMERA_SETTINGS_ID = 6;
private static final int FRIENDS_SETTINGS_ID = 7;
private static final int WIZARD_INTENT = 1;
public PreferencesFragment() {
@ -88,13 +80,13 @@ public class PreferencesFragment extends PreferencesListFragment implements EcCa
if (getResources().getBoolean(R.bool.hide_accounts)) {
// Hide category
PreferenceCategory accounts = (PreferenceCategory) getPreferenceScreen().getPreference(ACCOUNTS_SETTINGS_ID);
PreferenceCategory accounts = (PreferenceCategory) findPreference(getString(R.string.pref_sipaccounts_key));
accounts.removeAll();
accounts.setLayoutResource(R.layout.hidden);
}
if (getResources().getBoolean(R.bool.hide_wizard) || getResources().getBoolean(R.bool.replace_wizard_with_old_interface)) {
Preference wizard = (Preference) getPreferenceScreen().getPreference(WIZARD_SETTINGS_ID);
Preference wizard = findPreference(getString(R.string.setup_key));
if (getResources().getBoolean(R.bool.replace_wizard_with_old_interface)) {
createAddAccountButton();
} else {
@ -109,12 +101,12 @@ public class PreferencesFragment extends PreferencesListFragment implements EcCa
}
if (!getResources().getBoolean(R.bool.enable_linphone_friends)) {
PreferenceCategory friends = (PreferenceCategory) getPreferenceScreen().getPreference(FRIENDS_SETTINGS_ID);
PreferenceCategory friends = (PreferenceCategory) findPreference(getString(R.string.pref_linphone_friend_key));
friends.removeAll();
friends.setLayoutResource(R.layout.hidden);
}
addTransportChecboxesListener();
initializeTransportPreferences();
ecCalibratePref = findPreference(pref_echo_canceller_calibration_key);
ecCalibratePref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@ -179,8 +171,7 @@ public class PreferencesFragment extends PreferencesListFragment implements EcCa
}
if (getResources().getBoolean(R.bool.hide_camera_settings)) {
PreferenceScreen screen = getPreferenceScreen();
PreferenceCategory videoSettings = (PreferenceCategory) screen.getPreference(CAMERA_SETTINGS_ID);
PreferenceCategory videoSettings = (PreferenceCategory) findPreference(getString(R.string.pref_video_key));
videoSettings.removeAll();
videoSettings.setLayoutResource(R.layout.hidden);
@ -189,7 +180,7 @@ public class PreferencesFragment extends PreferencesListFragment implements EcCa
}
if (getResources().getBoolean(R.bool.display_about_in_settings)) {
getPreferenceScreen().getPreference(ABOUT_SETTINGS_ID).setOnPreferenceClickListener(new OnPreferenceClickListener() {
findPreference(getString(R.string.menu_about_key)).setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
if (LinphoneActivity.isInstanciated()) {
@ -200,12 +191,12 @@ public class PreferencesFragment extends PreferencesListFragment implements EcCa
}
});
} else {
getPreferenceScreen().getPreference(ABOUT_SETTINGS_ID).setLayoutResource(R.layout.hidden);
findPreference(getString(R.string.menu_about_key)).setLayoutResource(R.layout.hidden);
}
}
private void createAddAccountButton() {
Preference addAccount = (Preference) getPreferenceScreen().getPreference(WIZARD_SETTINGS_ID);
Preference addAccount = findPreference(getString(R.string.setup_key));
addAccount.setTitle(getString(R.string.pref_add_account));
addAccount.setOnPreferenceClickListener(new OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) {
@ -227,58 +218,6 @@ public class PreferencesFragment extends PreferencesListFragment implements EcCa
prefs().edit().putBoolean(LinphoneActivity.PREF_FIRST_LAUNCH, false).commit();
}
private void addTransportChecboxesListener() {
final List<CheckBoxPreference> checkboxes = Arrays.asList(
findCheckbox(R.string.pref_transport_udp_key)
,findCheckbox(R.string.pref_transport_tcp_key)
,findCheckbox(R.string.pref_transport_tls_key)
);
OnPreferenceChangeListener changedListener = new OnPreferenceChangeListener() {
public boolean onPreferenceChange(Preference preference, Object newValue) {
if ((Boolean) newValue) {
for (CheckBoxPreference p : checkboxes) {
if (p == preference) continue;
p.setChecked(false);
}
return true;
} else {
for (CheckBoxPreference p : checkboxes) {
if (p == preference) continue;
if (p.isChecked()) return true;
}
return false;
}
}
};
OnPreferenceClickListener clickListener = new OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) {
// Forbid no protocol selection
if (((CheckBoxPreference) preference).isChecked()) {
// Trying to unckeck
for (CheckBoxPreference p : checkboxes) {
if (p == preference) continue;
if (p.isChecked()) return false;
}
/*Toast.makeText(LinphonePreferencesActivity.this,
getString(R.string.at_least_a_protocol),
Toast.LENGTH_SHORT).show();*/
return true;
}
return false;
}
};
for (CheckBoxPreference c : checkboxes) {
c.setOnPreferenceChangeListener(changedListener);
c.setOnPreferenceClickListener(clickListener);
}
}
private synchronized void startEcCalibration() {
try {
LinphoneManager.getInstance().startEcCalibration(this);
@ -335,10 +274,6 @@ public class PreferencesFragment extends PreferencesListFragment implements EcCa
return getPreferenceManager().getSharedPreferences();
}
private CheckBoxPreference findCheckbox(int key) {
return (CheckBoxPreference) findPreference(getString(key));
}
private void detectAudioCodec(int id, String mime, int rate, int channels, boolean hide) {
boolean enable = LinphoneService.isReady() && LinphoneManager.getLc().findPayloadType(mime, rate, channels)!=null;
Preference cb = findPreference(id);
@ -353,7 +288,7 @@ public class PreferencesFragment extends PreferencesListFragment implements EcCa
}
private void createDynamicAccountsPreferences() {
accounts = (PreferenceCategory) getPreferenceScreen().getPreference(ACCOUNTS_SETTINGS_ID);
accounts = (PreferenceCategory) findPreference(getString(R.string.pref_sipaccounts_key));
accounts.removeAll();
// Get already configured extra accounts
@ -429,7 +364,7 @@ public class PreferencesFragment extends PreferencesListFragment implements EcCa
}
private void addWizardPreferenceButton() {
Preference wizard = (Preference) getPreferenceScreen().getPreference(WIZARD_SETTINGS_ID);
Preference wizard = findPreference(getString(R.string.setup_key));
wizard.setOnPreferenceClickListener(new OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) {
Intent intent = new Intent(mContext, SetupActivity.class);
@ -477,6 +412,27 @@ public class PreferencesFragment extends PreferencesListFragment implements EcCa
//mencPref.setValueIndex(mencPref.findIndexOfValue(getString(R.string.media_encryption_none)));
}
}
private void initializeTransportPreferences() {
List<CharSequence> mencEntries=new ArrayList<CharSequence>();
List<CharSequence> mencEntryValues=new ArrayList<CharSequence>();
mencEntries.add(getString(R.string.pref_transport_udp));
mencEntryValues.add(getString(R.string.pref_transport_udp_key));
mencEntries.add(getString(R.string.pref_transport_tcp));
mencEntryValues.add(getString(R.string.pref_transport_tcp_key));
mencEntries.add(getString(R.string.pref_transport_tls));
mencEntryValues.add(getString(R.string.pref_transport_tls_key));
ListPreference transport = (ListPreference) findPreference(pref_transport_key);
CharSequence[] contents=new CharSequence[mencEntries.size()];
mencEntries.toArray(contents);
transport.setEntries(contents);
contents=new CharSequence[mencEntryValues.size()];
mencEntryValues.toArray(contents);
transport.setEntryValues(contents);
}
private Preference findPreference(int key) {
return getPreferenceManager().findPreference(getString(key));

View file

@ -219,9 +219,7 @@ public class SetupActivity extends FragmentActivity implements OnClickListener {
writePreference(R.string.pref_ice_enable_key, true);
writePreference(R.string.pref_push_notification_key, true);
writePreference(R.string.pref_transport_tls_key, true);
writePreference(R.string.pref_transport_tcp_key, false);
writePreference(R.string.pref_transport_udp_key, false);
writePreference(R.string.pref_transport_key, getString(R.string.pref_transport_tls_key));
}
} else {
writePreference(getString(R.string.pref_username_key) + newAccountId, username);