Changed way of using linphone to store settings
This commit is contained in:
parent
2ce47e5064
commit
a7fb6e73d3
20 changed files with 479 additions and 1072 deletions
|
@ -121,31 +121,4 @@
|
||||||
<string name="pref_upnp_enable_key">pref_upnp_enable_key</string>
|
<string name="pref_upnp_enable_key">pref_upnp_enable_key</string>
|
||||||
|
|
||||||
<string name="pref_first_time_linphone_chat_storage">pref_first_time_linphone_chat_storage</string>
|
<string name="pref_first_time_linphone_chat_storage">pref_first_time_linphone_chat_storage</string>
|
||||||
|
|
||||||
|
|
||||||
<!-- LP Config preferences names -->
|
|
||||||
<string-array name="lpconfig_net_keys">
|
|
||||||
</string-array>
|
|
||||||
|
|
||||||
<string name="lpconfig_sip_media_enc_key">media_encryption</string>
|
|
||||||
<string-array name="lpconfig_sip_keys">
|
|
||||||
<item>@string/lpconfig_sip_media_enc_key</item>
|
|
||||||
</string-array>
|
|
||||||
|
|
||||||
<string-array name="lpconfig_rtp_keys">
|
|
||||||
<item></item>
|
|
||||||
</string-array>
|
|
||||||
|
|
||||||
<string-array name="lpconfig_sound_keys">
|
|
||||||
<item></item>
|
|
||||||
</string-array>
|
|
||||||
|
|
||||||
<string-array name="lpconfig_video_keys">
|
|
||||||
<item></item>
|
|
||||||
</string-array>
|
|
||||||
|
|
||||||
<string-array name="lpconfig_misc_keys">
|
|
||||||
<item></item>
|
|
||||||
</string-array>
|
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -14,25 +14,22 @@
|
||||||
android:key="@string/setup_key"/>
|
android:key="@string/setup_key"/>
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="@string/pref_tunnel_key"
|
android:title="@string/pref_tunnel"
|
||||||
android:title="@string/pref_tunnel">
|
android:key="@string/pref_tunnel_key">
|
||||||
|
|
||||||
<EditTextPreference
|
<EditTextPreference
|
||||||
android:title="@string/pref_tunnel_host"
|
android:title="@string/pref_tunnel_host"
|
||||||
android:key="@string/pref_tunnel_host_key"
|
android:key="@string/pref_tunnel_host_key"/>
|
||||||
android:defaultValue="@string/pref_tunnel_host_default"/>
|
|
||||||
|
|
||||||
<EditTextPreference
|
<EditTextPreference
|
||||||
android:title="@string/pref_tunnel_port"
|
android:title="@string/pref_tunnel_port"
|
||||||
android:key="@string/pref_tunnel_port_key"
|
android:key="@string/pref_tunnel_port_key"/>
|
||||||
android:defaultValue="@string/pref_tunnel_port_default"/>
|
|
||||||
|
|
||||||
<ListPreference
|
<ListPreference
|
||||||
android:title="@string/pref_tunnel_mode"
|
android:title="@string/pref_tunnel_mode"
|
||||||
|
android:key="@string/pref_tunnel_mode_key"
|
||||||
android:entries="@array/tunnel_mode_entries"
|
android:entries="@array/tunnel_mode_entries"
|
||||||
android:entryValues="@array/tunnel_mode_entry_values"
|
android:entryValues="@array/tunnel_mode_entry_values"/>
|
||||||
android:defaultValue="@string/default_tunnel_mode_entry_value"
|
|
||||||
android:key="@string/pref_tunnel_mode_key" />
|
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
@ -40,65 +37,57 @@
|
||||||
android:title="@string/pref_preferences">
|
android:title="@string/pref_preferences">
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:defaultValue="@bool/pref_video_enable_default"
|
|
||||||
android:title="@string/pref_video_enable_title"
|
android:title="@string/pref_video_enable_title"
|
||||||
android:key="@string/pref_video_enable_key" />
|
android:key="@string/pref_video_enable_key"/>
|
||||||
|
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
android:title="@string/pref_audio">
|
android:title="@string/pref_audio">
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:key="@string/pref_echo_cancellation_key"
|
|
||||||
android:defaultValue="@bool/pref_echo_canceller_default"
|
|
||||||
android:title="@string/pref_echo_cancellation"
|
android:title="@string/pref_echo_cancellation"
|
||||||
|
android:key="@string/pref_echo_cancellation_key"
|
||||||
android:summary="@string/pref_echo_cancellation_summary"/>
|
android:summary="@string/pref_echo_cancellation_summary"/>
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="@string/pref_echo_canceller_calibration_key"
|
android:title="@string/pref_echo_canceller_calibration"
|
||||||
android:title="@string/pref_echo_canceller_calibration" />
|
android:key="@string/pref_echo_canceller_calibration_key"/>
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:title="@string/pref_codecs"
|
android:title="@string/pref_codecs"
|
||||||
android:key="@string/pref_codecs_key">
|
android:key="@string/pref_codecs_key">
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:key="@string/pref_codec_opus_key"
|
android:title="@string/pref_codec_opus"
|
||||||
android:defaultValue="@bool/pref_codec_opus_default"
|
android:key="@string/pref_codec_opus_key"/>
|
||||||
android:title="@string/pref_codec_opus"/><CheckBoxPreference
|
|
||||||
android:key="@string/pref_codec_speex16_key"
|
|
||||||
android:defaultValue="@bool/pref_codec_speex16_default"
|
|
||||||
android:title="@string/pref_codec_speex16"/>
|
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:key="@string/pref_codec_speex8_key"
|
android:title="@string/pref_codec_speex16"
|
||||||
android:defaultValue="@bool/pref_codec_speex8_default"
|
android:key="@string/pref_codec_speex16_key"/>
|
||||||
android:title="@string/pref_codec_speex8"/>
|
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:title="@string/pref_codec_speex8"
|
||||||
|
android:key="@string/pref_codec_speex8_key"/>
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:key="@string/pref_codec_ilbc_key"
|
|
||||||
android:title="@string/pref_codec_ilbc"
|
android:title="@string/pref_codec_ilbc"
|
||||||
android:defaultValue="@bool/pref_codec_ilbc_default"
|
android:key="@string/pref_codec_ilbc_key"
|
||||||
android:summary="@string/pref_ilbc_summary"/>
|
android:summary="@string/pref_ilbc_summary"/>
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:key="@string/pref_codec_amr_key"
|
|
||||||
android:title="@string/pref_codec_amr"
|
android:title="@string/pref_codec_amr"
|
||||||
android:defaultValue="@bool/pref_codec_amr_default" />
|
android:key="@string/pref_codec_amr_key"/>
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:key="@string/pref_codec_g729_key"
|
|
||||||
android:title="@string/pref_codec_g729"
|
android:title="@string/pref_codec_g729"
|
||||||
android:defaultValue="@bool/pref_codec_g729_default" />
|
android:key="@string/pref_codec_g729_key"/>
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:key="@string/pref_codec_amrwb_key"
|
|
||||||
android:title="@string/pref_codec_amrwb"
|
android:title="@string/pref_codec_amrwb"
|
||||||
android:defaultValue="@bool/pref_codec_amrwb_default" />
|
android:key="@string/pref_codec_amrwb_key"/>
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:key="@string/pref_codec_gsm_key"
|
android:title="@string/pref_codec_gsm"
|
||||||
android:defaultValue="@bool/pref_codec_gsm_default"
|
android:key="@string/pref_codec_gsm_key"/>
|
||||||
android:title="@string/pref_codec_gsm"/>
|
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:key="@string/pref_codec_g722_key"
|
android:key="@string/pref_codec_g722_key"
|
||||||
|
@ -106,24 +95,20 @@
|
||||||
android:title="@string/pref_codec_g722"/>
|
android:title="@string/pref_codec_g722"/>
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:key="@string/pref_codec_silk8_key"
|
android:title="@string/pref_codec_silk8"
|
||||||
android:defaultValue="@bool/pref_codec_silk8_default"
|
android:key="@string/pref_codec_silk8_key"/>
|
||||||
android:title="@string/pref_codec_silk8"/>
|
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:key="@string/pref_codec_silk16_key"
|
android:title="@string/pref_codec_silk16"
|
||||||
android:defaultValue="@bool/pref_codec_silk16_default"
|
android:key="@string/pref_codec_silk16_key"/>
|
||||||
android:title="@string/pref_codec_silk16"/>
|
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:key="@string/pref_codec_pcmu_key"
|
android:title="@string/pref_codec_pcmu"
|
||||||
android:defaultValue="@bool/pref_codec_pcmu_default"
|
android:key="@string/pref_codec_pcmu_key"/>
|
||||||
android:title="@string/pref_codec_pcmu"/>
|
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:key="@string/pref_codec_pcma_key"
|
android:title="@string/pref_codec_pcma"
|
||||||
android:defaultValue="@bool/pref_codec_pcma_default"
|
android:key="@string/pref_codec_pcma_key"/>
|
||||||
android:title="@string/pref_codec_pcma"/>
|
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
@ -131,69 +116,60 @@
|
||||||
|
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
android:title="@string/pref_video"
|
android:title="@string/pref_video"
|
||||||
android:dependency="@string/pref_video_enable_key"
|
|
||||||
android:key="@string/pref_video_key"
|
android:key="@string/pref_video_key"
|
||||||
|
android:dependency="@string/pref_video_enable_key"
|
||||||
android:shouldDisableView="true">
|
android:shouldDisableView="true">
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:key="@string/pref_video_use_front_camera_key"
|
|
||||||
android:defaultValue="@bool/pref_video_use_front_camera_default"
|
|
||||||
android:title="@string/pref_video_use_front_camera_title"
|
android:title="@string/pref_video_use_front_camera_title"
|
||||||
|
android:key="@string/pref_video_use_front_camera_key"
|
||||||
android:dependency="@string/pref_video_enable_key"
|
android:dependency="@string/pref_video_enable_key"
|
||||||
android:layout="@layout/hidden"/>
|
android:layout="@layout/hidden"/>
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:key="@string/pref_video_initiate_call_with_video_key"
|
|
||||||
android:defaultValue="@bool/pref_video_initiate_call_with_video_default"
|
|
||||||
android:title="@string/pref_video_initiate_call_with_video_title"
|
android:title="@string/pref_video_initiate_call_with_video_title"
|
||||||
|
android:key="@string/pref_video_initiate_call_with_video_key"
|
||||||
android:summary="@string/pref_video_initiate_call_with_video"
|
android:summary="@string/pref_video_initiate_call_with_video"
|
||||||
android:dependency="@string/pref_video_enable_key"/>
|
android:dependency="@string/pref_video_enable_key"/>
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:key="@string/pref_video_automatically_share_my_video_key"
|
|
||||||
android:title="@string/pref_video_automatically_share_my_video_title"
|
android:title="@string/pref_video_automatically_share_my_video_title"
|
||||||
android:defaultValue="@bool/pref_video_automatically_share_my_video_default"
|
android:key="@string/pref_video_automatically_share_my_video_key"
|
||||||
android:summary="@string/pref_video_automatically_share_my_video"
|
android:summary="@string/pref_video_automatically_share_my_video"
|
||||||
android:dependency="@string/pref_video_enable_key"
|
android:dependency="@string/pref_video_enable_key"
|
||||||
android:layout="@layout/hidden"/>
|
android:layout="@layout/hidden"/>
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:key="@string/pref_video_automatically_accept_video_key"
|
|
||||||
android:title="@string/pref_video_automatically_accept_video_title"
|
android:title="@string/pref_video_automatically_accept_video_title"
|
||||||
android:defaultValue="@bool/pref_video_automatically_accept_video_default"
|
android:key="@string/pref_video_automatically_accept_video_key"
|
||||||
android:summary="@string/pref_video_automatically_accept_video"
|
android:summary="@string/pref_video_automatically_accept_video"
|
||||||
android:dependency="@string/pref_video_enable_key"/>
|
android:dependency="@string/pref_video_enable_key"/>
|
||||||
|
|
||||||
<ListPreference
|
<ListPreference
|
||||||
android:title="@string/pref_preferred_video_size"
|
android:title="@string/pref_preferred_video_size"
|
||||||
android:key="@string/pref_preferred_video_size_key"
|
android:key="@string/pref_preferred_video_size_key"/>
|
||||||
android:defaultValue="@string/pref_preferred_video_size_default" />
|
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:dependency="@string/pref_video_enable_key"
|
android:title="@string/pref_video_codecs_title"
|
||||||
android:shouldDisableView="true"
|
|
||||||
android:key="@string/pref_video_codecs_key"
|
android:key="@string/pref_video_codecs_key"
|
||||||
android:title="@string/pref_video_codecs_title">
|
android:dependency="@string/pref_video_enable_key"
|
||||||
|
android:shouldDisableView="true" >
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:key="@string/pref_video_codec_vp8_key"
|
|
||||||
android:title="@string/pref_video_codec_vp8_title"
|
android:title="@string/pref_video_codec_vp8_title"
|
||||||
android:defaultValue="@bool/pref_video_codec_vp8_default"/>
|
android:key="@string/pref_video_codec_vp8_key"/>
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:key="@string/pref_video_codec_h264_key"
|
|
||||||
android:title="@string/pref_video_codec_h264_title"
|
android:title="@string/pref_video_codec_h264_title"
|
||||||
android:defaultValue="@bool/pref_video_codec_h264_default"/>
|
android:key="@string/pref_video_codec_h264_key"/>
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:key="@string/pref_video_codec_mpeg4_key"
|
|
||||||
android:title="@string/pref_video_codec_mpeg4_title"
|
android:title="@string/pref_video_codec_mpeg4_title"
|
||||||
android:defaultValue="@bool/pref_video_codec_mpeg4_default"/>
|
android:key="@string/pref_video_codec_mpeg4_key"/>
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:key="@string/pref_video_codec_h263_key"
|
|
||||||
android:title="@string/pref_video_codec_h263_title"
|
android:title="@string/pref_video_codec_h263_title"
|
||||||
android:defaultValue="@bool/pref_video_codec_h263_default"
|
android:key="@string/pref_video_codec_h263_key"
|
||||||
android:layout="@layout/hidden"/>
|
android:layout="@layout/hidden"/>
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
@ -208,18 +184,16 @@
|
||||||
android:key="@string/pref_prefix_key"/>
|
android:key="@string/pref_prefix_key"/>
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:key="@string/pref_escape_plus_key"
|
android:title="@string/pref_escape_plus"
|
||||||
android:title="@string/pref_escape_plus"/>
|
android:key="@string/pref_escape_plus_key"/>
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:key="@string/pref_sipinfo_dtmf_key"
|
android:title="@string/pref_sipinfo_dtmf"
|
||||||
android:defaultValue="@bool/pref_sipinfo_dtmf_default"
|
android:key="@string/pref_sipinfo_dtmf_key"/>
|
||||||
android:title="@string/pref_sipinfo_dtmf"/>
|
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:key="@string/pref_rfc2833_dtmf_key"
|
android:title="@string/pref_rfc2833_dtmf"
|
||||||
android:defaultValue="@bool/pref_rfc2833_dtmf_default"
|
android:key="@string/pref_rfc2833_dtmf_key"/>
|
||||||
android:title="@string/pref_rfc2833_dtmf"/>
|
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|
||||||
|
@ -227,69 +201,57 @@
|
||||||
android:title="@string/pref_network_title">
|
android:title="@string/pref_network_title">
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:key="@string/pref_wifi_only_key"
|
|
||||||
android:title="@string/pref_wifi_only"
|
android:title="@string/pref_wifi_only"
|
||||||
android:defaultValue="@bool/pref_wifi_only_default"/>
|
android:key="@string/pref_wifi_only_key"/>
|
||||||
|
|
||||||
<EditTextPreference
|
<EditTextPreference
|
||||||
android:title="@string/pref_stun_server"
|
android:title="@string/pref_stun_server"
|
||||||
android:defaultValue="@string/default_stun"
|
|
||||||
android:key="@string/pref_stun_server_key"/>
|
android:key="@string/pref_stun_server_key"/>
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:title="@string/pref_ice_enable"
|
android:title="@string/pref_ice_enable"
|
||||||
android:key="@string/pref_ice_enable_key"
|
android:key="@string/pref_ice_enable_key"/>
|
||||||
android:defaultValue="@bool/pref_ice_enabled_default"/>
|
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:title="@string/pref_upnp_enable"
|
android:title="@string/pref_upnp_enable"
|
||||||
android:key="@string/pref_upnp_enable_key"
|
android:key="@string/pref_upnp_enable_key"/>
|
||||||
android:defaultValue="@bool/pref_upnp_enabled_default"/>
|
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:key="@string/pref_transport_use_random_ports_key"
|
|
||||||
android:title="@string/pref_transport_use_random_ports"
|
android:title="@string/pref_transport_use_random_ports"
|
||||||
android:defaultValue="@bool/pref_transport_use_random_ports_default"/>
|
android:key="@string/pref_transport_use_random_ports_key"/>
|
||||||
|
|
||||||
<EditTextPreference
|
<EditTextPreference
|
||||||
android:key="@string/pref_sip_port_key"
|
|
||||||
android:title="@string/pref_sip_port_title"
|
android:title="@string/pref_sip_port_title"
|
||||||
android:defaultValue="@string/pref_sip_port_default"
|
android:key="@string/pref_sip_port_key"
|
||||||
android:numeric="integer"/>
|
android:numeric="integer"/>
|
||||||
|
|
||||||
<EditTextPreference
|
<EditTextPreference
|
||||||
android:key="@string/pref_audio_port_key"
|
|
||||||
android:title="@string/pref_audio_port_title"
|
android:title="@string/pref_audio_port_title"
|
||||||
|
android:key="@string/pref_audio_port_key"
|
||||||
android:summary="@string/pref_audio_port_description"
|
android:summary="@string/pref_audio_port_description"
|
||||||
android:defaultValue="@string/default_audio_port"
|
|
||||||
android:layout="@layout/hidden"/>
|
android:layout="@layout/hidden"/>
|
||||||
|
|
||||||
<EditTextPreference
|
<EditTextPreference
|
||||||
android:key="@string/pref_video_port_key"
|
|
||||||
android:title="@string/pref_video_port_title"
|
android:title="@string/pref_video_port_title"
|
||||||
android:defaultValue="@string/default_video_port"
|
android:key="@string/pref_video_port_key"
|
||||||
android:summary="@string/pref_video_port_description"
|
android:summary="@string/pref_video_port_description"
|
||||||
android:layout="@layout/hidden"/>
|
android:layout="@layout/hidden"/>
|
||||||
|
|
||||||
<ListPreference
|
<ListPreference
|
||||||
android:title="@string/pref_transport"
|
android:title="@string/pref_transport"
|
||||||
android:key="@string/pref_transport_key"
|
android:key="@string/pref_transport_key"/>
|
||||||
android:defaultValue="@string/pref_transport_default" />
|
|
||||||
|
|
||||||
<ListPreference
|
<ListPreference
|
||||||
android:title="@string/pref_media_encryption"
|
android:title="@string/pref_media_encryption"
|
||||||
android:key="@string/pref_media_encryption_key"
|
android:key="@string/pref_media_encryption_key"/>
|
||||||
android:defaultValue="@string/pref_media_encryption_default" />
|
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:key="@string/pref_push_notification_key"
|
|
||||||
android:title="@string/pref_push_notification"
|
android:title="@string/pref_push_notification"
|
||||||
android:defaultValue="@bool/pref_push_notification_default"/>
|
android:key="@string/pref_push_notification_key"/>
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:key="@string/pref_ipv6_key"
|
|
||||||
android:title="@string/pref_ipv6_title"
|
android:title="@string/pref_ipv6_title"
|
||||||
android:defaultValue="@bool/pref_ipv6_default" />
|
android:key="@string/pref_ipv6_key"/>
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|
||||||
|
@ -297,58 +259,48 @@
|
||||||
android:title="@string/pref_advanced">
|
android:title="@string/pref_advanced">
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:key="@string/pref_debug_key"
|
|
||||||
android:title="@string/pref_debug"
|
android:title="@string/pref_debug"
|
||||||
android:defaultValue="@bool/pref_debug_default"/>
|
android:key="@string/pref_debug_key"/>
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:key="@string/pref_background_mode_key"
|
|
||||||
android:title="@string/pref_background_mode"
|
android:title="@string/pref_background_mode"
|
||||||
android:defaultValue="@bool/pref_background_mode_default"/>
|
android:key="@string/pref_background_mode_key"/>
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:defaultValue="@bool/pref_animation_enable_default"
|
|
||||||
android:title="@string/pref_animation_enable_title"
|
android:title="@string/pref_animation_enable_title"
|
||||||
android:key="@string/pref_animation_enable_key" />
|
android:key="@string/pref_animation_enable_key"/>
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:title="@string/pref_autostart"
|
android:title="@string/pref_autostart"
|
||||||
android:key="@string/pref_autostart_key"
|
android:key="@string/pref_autostart_key"/>
|
||||||
android:defaultValue="@bool/pref_autostart_default"/>
|
|
||||||
|
|
||||||
<EditTextPreference
|
<EditTextPreference
|
||||||
android:key="@string/pref_incoming_call_timeout_key"
|
|
||||||
android:title="@string/pref_incoming_call_timeout_title"
|
android:title="@string/pref_incoming_call_timeout_title"
|
||||||
android:defaultValue="@string/pref_incoming_call_timeout_default"
|
android:key="@string/pref_incoming_call_timeout_key"
|
||||||
android:layout="@layout/hidden"/>
|
android:layout="@layout/hidden"/>
|
||||||
|
|
||||||
<EditTextPreference
|
<EditTextPreference
|
||||||
android:key="@string/pref_expire_key"
|
|
||||||
android:title="@string/pref_expire_title"
|
android:title="@string/pref_expire_title"
|
||||||
android:defaultValue="@string/pref_expire_default"
|
android:key="@string/pref_expire_key"
|
||||||
android:numeric="integer" />
|
android:numeric="integer" />
|
||||||
|
|
||||||
<EditTextPreference
|
<EditTextPreference
|
||||||
android:key="@string/pref_image_sharing_server_key"
|
|
||||||
android:title="@string/pref_image_sharing_server_title"
|
android:title="@string/pref_image_sharing_server_title"
|
||||||
android:defaultValue="@string/pref_image_sharing_server_default" />
|
android:key="@string/pref_image_sharing_server_key"/>
|
||||||
|
|
||||||
<EditTextPreference
|
<EditTextPreference
|
||||||
android:key="@string/pref_remote_provisioning_key"
|
|
||||||
android:title="@string/pref_remote_provisioning_title"
|
android:title="@string/pref_remote_provisioning_title"
|
||||||
android:defaultValue="@string/pref_remote_provisioning_default" />
|
android:key="@string/pref_remote_provisioning_key"/>
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:title="@string/pref_primary_account_title">
|
android:title="@string/pref_primary_account_title">
|
||||||
|
|
||||||
<EditTextPreference
|
<EditTextPreference
|
||||||
android:title="@string/pref_display_name_title"
|
android:title="@string/pref_display_name_title"
|
||||||
android:defaultValue="@string/pref_display_name_default"
|
|
||||||
android:key="@string/pref_display_name_key"/>
|
android:key="@string/pref_display_name_key"/>
|
||||||
|
|
||||||
<EditTextPreference
|
<EditTextPreference
|
||||||
android:title="@string/pref_user_name_title"
|
android:title="@string/pref_user_name_title"
|
||||||
android:defaultValue="@string/pref_user_name_default"
|
|
||||||
android:key="@string/pref_user_name_key"/>
|
android:key="@string/pref_user_name_key"/>
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
@ -358,18 +310,17 @@
|
||||||
android:layout="@layout/hidden">
|
android:layout="@layout/hidden">
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:key="@string/pref_audio_hacks_use_routing_api_key"
|
android:title="@string/pref_audio_hacks_use_routing_api_title"
|
||||||
android:title="@string/pref_audio_hacks_use_routing_api_title" />
|
android:key="@string/pref_audio_hacks_use_routing_api_key"/>
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:key="@string/pref_audio_hacks_use_galaxys_hack_key"
|
android:title="@string/pref_audio_hacks_use_galaxys_hack_title"
|
||||||
android:title="@string/pref_audio_hacks_use_galaxys_hack_title" />
|
android:key="@string/pref_audio_hacks_use_galaxys_hack_key"/>
|
||||||
|
|
||||||
<EditTextPreference
|
<EditTextPreference
|
||||||
android:key="@string/pref_audio_use_specific_mode_key"
|
|
||||||
android:title="@string/pref_audio_use_specific_mode_title"
|
android:title="@string/pref_audio_use_specific_mode_title"
|
||||||
|
android:key="@string/pref_audio_use_specific_mode_key"
|
||||||
android:summary="@string/pref_audio_use_specific_mode_summary"
|
android:summary="@string/pref_audio_use_specific_mode_summary"
|
||||||
android:defaultValue="@string/pref_audio_use_specific_mode_default"
|
|
||||||
android:numeric="integer" />
|
android:numeric="integer" />
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
@ -383,10 +334,9 @@
|
||||||
android:key="@string/pref_linphone_friend_key">
|
android:key="@string/pref_linphone_friend_key">
|
||||||
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:key="@string/pref_auto_accept_friends_key"
|
|
||||||
android:title="@string/pref_auto_accept_friends_title"
|
android:title="@string/pref_auto_accept_friends_title"
|
||||||
android:summary="@string/pref_auto_accept_friends_desc"
|
android:key="@string/pref_auto_accept_friends_key"
|
||||||
android:defaultValue="@bool/pref_auto_accept_friends_default"/>
|
android:summary="@string/pref_auto_accept_friends_desc"/>
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:title="Root">
|
|
||||||
|
|
||||||
<PreferenceCategory
|
|
||||||
android:title="@string/pref_preferences">
|
|
||||||
|
|
||||||
<ListPreference
|
|
||||||
android:title="@string/pref_media_encryption"
|
|
||||||
android:key="@string/lpconfig_sip_media_enc_key" />
|
|
||||||
|
|
||||||
</PreferenceCategory>
|
|
||||||
|
|
||||||
</PreferenceScreen>
|
|
|
@ -21,7 +21,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
import org.linphone.compatibility.Compatibility;
|
import org.linphone.compatibility.Compatibility;
|
||||||
import org.linphone.ui.PreferencesListFragment;
|
import org.linphone.ui.PreferencesListFragment;
|
||||||
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.EditTextPreference;
|
import android.preference.EditTextPreference;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
|
@ -36,7 +35,6 @@ import android.text.InputType;
|
||||||
*/
|
*/
|
||||||
public class AccountPreferencesFragment extends PreferencesListFragment {
|
public class AccountPreferencesFragment extends PreferencesListFragment {
|
||||||
private int n;
|
private int n;
|
||||||
private String key;
|
|
||||||
|
|
||||||
public AccountPreferencesFragment() {
|
public AccountPreferencesFragment() {
|
||||||
super(R.xml.account_preferences);
|
super(R.xml.account_preferences);
|
||||||
|
@ -48,122 +46,116 @@ public class AccountPreferencesFragment extends PreferencesListFragment {
|
||||||
|
|
||||||
PreferenceScreen screen = getPreferenceScreen();
|
PreferenceScreen screen = getPreferenceScreen();
|
||||||
n = getArguments().getInt("Account", 0);
|
n = getArguments().getInt("Account", 0);
|
||||||
key = getAccountNumber(n);
|
|
||||||
manageAccountPreferencesFields(screen);
|
manageAccountPreferencesFields(screen);
|
||||||
}
|
}
|
||||||
|
|
||||||
OnPreferenceChangeListener preferenceChangedListener = new OnPreferenceChangeListener() {
|
OnPreferenceChangeListener usernameChangedListener = new OnPreferenceChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
preference.setSummary(newValue.toString());
|
LinphonePreferences.instance().setAccountUsername(n, newValue.toString());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
OnPreferenceChangeListener useridChangedListener = new OnPreferenceChangeListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
|
LinphonePreferences.instance().setAccountUserId(n, newValue.toString());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
OnPreferenceChangeListener passwordChangedListener = new OnPreferenceChangeListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
|
LinphonePreferences.instance().setAccountPassword(n, newValue.toString());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
OnPreferenceChangeListener domainChangedListener = new OnPreferenceChangeListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
|
LinphonePreferences.instance().setAccountDomain(n, newValue.toString());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
OnPreferenceChangeListener proxyChangedListener = new OnPreferenceChangeListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
|
LinphonePreferences.instance().setAccountProxy(n, newValue.toString());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
OnPreferenceChangeListener outboundProxyChangedListener = new OnPreferenceChangeListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
|
LinphonePreferences.instance().setAccountOutboundProxyEnabled(n, (Boolean)newValue);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
OnPreferenceChangeListener disableChangedListener = new OnPreferenceChangeListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
|
LinphonePreferences.instance().setAccountEnabled(n, (Boolean)newValue);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private void manageAccountPreferencesFields(PreferenceScreen parent) {
|
private void manageAccountPreferencesFields(PreferenceScreen parent) {
|
||||||
final SharedPreferences prefs = getPreferenceManager().getSharedPreferences();
|
|
||||||
|
|
||||||
PreferenceCategory account = (PreferenceCategory) getPreferenceScreen().getPreference(0);
|
PreferenceCategory account = (PreferenceCategory) getPreferenceScreen().getPreference(0);
|
||||||
EditTextPreference username = (EditTextPreference) account.getPreference(0);
|
EditTextPreference username = (EditTextPreference) account.getPreference(0);
|
||||||
username.setText(prefs.getString(getString(R.string.pref_username_key) + key, ""));
|
username.setText(LinphonePreferences.instance().getAccountUsername(n));
|
||||||
username.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
|
username.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
|
||||||
username.setKey(getString(R.string.pref_username_key) + key);
|
username.setOnPreferenceChangeListener(usernameChangedListener);
|
||||||
username.setOnPreferenceChangeListener(preferenceChangedListener);
|
|
||||||
username.setSummary(username.getText());
|
username.setSummary(username.getText());
|
||||||
|
|
||||||
EditTextPreference userid = (EditTextPreference) account.getPreference(1);
|
EditTextPreference userid = (EditTextPreference) account.getPreference(1);
|
||||||
userid.setText(prefs.getString(getString(R.string.pref_auth_userid_key) + key, ""));
|
userid.setText(LinphonePreferences.instance().getAccountUserId(n));
|
||||||
userid.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
|
userid.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
|
||||||
userid.setKey(getString(R.string.pref_auth_userid_key) + key);
|
userid.setOnPreferenceChangeListener(useridChangedListener);
|
||||||
userid.setOnPreferenceChangeListener(preferenceChangedListener);
|
|
||||||
userid.setSummary(userid.getText());
|
userid.setSummary(userid.getText());
|
||||||
|
|
||||||
EditTextPreference password = (EditTextPreference) account.getPreference(2);
|
EditTextPreference password = (EditTextPreference) account.getPreference(2);
|
||||||
password.setText(prefs.getString(getString(R.string.pref_passwd_key) + key, ""));
|
password.setText(LinphonePreferences.instance().getAccountPassword(n));
|
||||||
password.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
|
password.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
|
||||||
password.setKey(getString(R.string.pref_passwd_key) + key);
|
password.setOnPreferenceChangeListener(passwordChangedListener);
|
||||||
|
|
||||||
EditTextPreference domain = (EditTextPreference) account.getPreference(3);
|
EditTextPreference domain = (EditTextPreference) account.getPreference(3);
|
||||||
domain.setText(prefs.getString(getString(R.string.pref_domain_key) + key, ""));
|
domain.setText(LinphonePreferences.instance().getAccountDomain(n));
|
||||||
domain.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
|
domain.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
|
||||||
domain.setKey(getString(R.string.pref_domain_key) + key);
|
domain.setOnPreferenceChangeListener(domainChangedListener);
|
||||||
domain.setOnPreferenceChangeListener(preferenceChangedListener);
|
|
||||||
domain.setSummary(domain.getText());
|
domain.setSummary(domain.getText());
|
||||||
|
|
||||||
PreferenceCategory advanced = (PreferenceCategory) getPreferenceScreen().getPreference(1);
|
PreferenceCategory advanced = (PreferenceCategory) getPreferenceScreen().getPreference(1);
|
||||||
EditTextPreference proxy = (EditTextPreference) advanced.getPreference(0);
|
EditTextPreference proxy = (EditTextPreference) advanced.getPreference(0);
|
||||||
proxy.setText(prefs.getString(getString(R.string.pref_proxy_key) + key, ""));
|
proxy.setText(LinphonePreferences.instance().getAccountProxy(n));
|
||||||
proxy.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
|
proxy.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
|
||||||
proxy.setKey(getString(R.string.pref_proxy_key) + key);
|
proxy.setOnPreferenceChangeListener(proxyChangedListener);
|
||||||
proxy.setOnPreferenceChangeListener(preferenceChangedListener);
|
|
||||||
proxy.setSummary("".equals(proxy.getText()) || (proxy.getText() == null) ? getString(R.string.pref_help_proxy) : proxy.getText());
|
proxy.setSummary("".equals(proxy.getText()) || (proxy.getText() == null) ? getString(R.string.pref_help_proxy) : proxy.getText());
|
||||||
|
|
||||||
Preference outboundProxy = advanced.getPreference(1);
|
Preference outboundProxy = advanced.getPreference(1);
|
||||||
Compatibility.setPreferenceChecked(outboundProxy, prefs.getBoolean(getString(R.string.pref_enable_outbound_proxy_key) + key, false));
|
Compatibility.setPreferenceChecked(outboundProxy, LinphonePreferences.instance().isAccountOutboundProxySet(n));
|
||||||
outboundProxy.setKey(getString(R.string.pref_enable_outbound_proxy_key) + key);
|
outboundProxy.setOnPreferenceChangeListener(outboundProxyChangedListener);
|
||||||
|
|
||||||
final Preference disable = advanced.getPreference(2);
|
final Preference disable = advanced.getPreference(2);
|
||||||
disable.setEnabled(true);
|
disable.setEnabled(true);
|
||||||
Compatibility.setPreferenceChecked(disable, prefs.getBoolean(getString(R.string.pref_disable_account_key) + key, false));
|
Compatibility.setPreferenceChecked(disable, !LinphonePreferences.instance().isAccountEnabled(n));
|
||||||
disable.setKey(getString(R.string.pref_disable_account_key) + key);
|
|
||||||
|
|
||||||
final Preference delete = advanced.getPreference(4);
|
final Preference delete = advanced.getPreference(4);
|
||||||
delete.setEnabled(true);
|
delete.setEnabled(true);
|
||||||
delete.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
delete.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
int nbAccounts = prefs.getInt(getString(R.string.pref_extra_accounts), 1);
|
LinphonePreferences.instance().deleteAccount(n);
|
||||||
SharedPreferences.Editor editor = prefs.edit();
|
|
||||||
|
|
||||||
for (int i = n; i < nbAccounts - 1; i++) {
|
|
||||||
editor.putString(getString(R.string.pref_username_key) + getAccountNumber(i), prefs.getString(getString(R.string.pref_username_key) + getAccountNumber(i+1), null));
|
|
||||||
editor.putString(getString(R.string.pref_auth_userid_key) + getAccountNumber(i), prefs.getString(getString(R.string.pref_auth_userid_key) + getAccountNumber(i+1), null));
|
|
||||||
editor.putString(getString(R.string.pref_passwd_key) + getAccountNumber(i), prefs.getString(getString(R.string.pref_passwd_key) + getAccountNumber(i+1), null));
|
|
||||||
editor.putString(getString(R.string.pref_domain_key) + getAccountNumber(i), prefs.getString(getString(R.string.pref_domain_key) + getAccountNumber(i+1), null));
|
|
||||||
editor.putString(getString(R.string.pref_proxy_key) + getAccountNumber(i), prefs.getString(getString(R.string.pref_proxy_key) + getAccountNumber(i+1), null));
|
|
||||||
editor.putBoolean(getString(R.string.pref_enable_outbound_proxy_key) + getAccountNumber(i), prefs.getBoolean(getString(R.string.pref_enable_outbound_proxy_key) + getAccountNumber(i+1), false));
|
|
||||||
editor.putBoolean(getString(R.string.pref_disable_account_key) + getAccountNumber(i), prefs.getBoolean(getString(R.string.pref_disable_account_key) + getAccountNumber(i+1), false));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (n != 0) {
|
|
||||||
int lastAccount = nbAccounts - 1;
|
|
||||||
editor.putString(getString(R.string.pref_username_key) + getAccountNumber(lastAccount), null);
|
|
||||||
editor.putString(getString(R.string.pref_passwd_key) + getAccountNumber(lastAccount), null);
|
|
||||||
editor.putString(getString(R.string.pref_domain_key) + getAccountNumber(lastAccount), null);
|
|
||||||
editor.putString(getString(R.string.pref_proxy_key) + getAccountNumber(lastAccount), null);
|
|
||||||
editor.putBoolean(getString(R.string.pref_enable_outbound_proxy_key) + getAccountNumber(lastAccount), false);
|
|
||||||
editor.putBoolean(getString(R.string.pref_disable_account_key) + getAccountNumber(lastAccount), false);
|
|
||||||
|
|
||||||
int defaultAccount = prefs.getInt(getString(R.string.pref_default_account_key), 0);
|
|
||||||
if (defaultAccount > n) {
|
|
||||||
editor.putInt(getString(R.string.pref_default_account_key), defaultAccount - 1);
|
|
||||||
}
|
|
||||||
editor.putInt(getString(R.string.pref_extra_accounts), nbAccounts - 1);
|
|
||||||
} else if (n == 0 && nbAccounts <= 1) {
|
|
||||||
editor.putString(getString(R.string.pref_username_key), "");
|
|
||||||
editor.putString(getString(R.string.pref_passwd_key), "");
|
|
||||||
editor.putString(getString(R.string.pref_domain_key), "");
|
|
||||||
} else {
|
|
||||||
editor.putInt(getString(R.string.pref_extra_accounts), nbAccounts - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
editor.commit();
|
|
||||||
|
|
||||||
LinphoneActivity.instance().displaySettings();
|
LinphoneActivity.instance().displaySettings();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Preference mainAccount = advanced.getPreference(3);
|
Preference mainAccount = advanced.getPreference(3);
|
||||||
Compatibility.setPreferenceChecked(mainAccount, prefs.getInt(getString(R.string.pref_default_account_key), 0) == n);
|
Compatibility.setPreferenceChecked(mainAccount, LinphonePreferences.instance().getDefaultAccountIndex() == n);
|
||||||
mainAccount.setEnabled(!Compatibility.isPreferenceChecked(mainAccount));
|
mainAccount.setEnabled(!Compatibility.isPreferenceChecked(mainAccount));
|
||||||
mainAccount.setOnPreferenceClickListener(new OnPreferenceClickListener()
|
mainAccount.setOnPreferenceClickListener(new OnPreferenceClickListener()
|
||||||
{
|
{
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
|
LinphonePreferences.instance().setDefaultAccount(n);
|
||||||
SharedPreferences.Editor editor = prefs.edit();
|
|
||||||
editor.putInt(getString(R.string.pref_default_account_key), n);
|
|
||||||
editor.commit();
|
|
||||||
disable.setEnabled(false);
|
disable.setEnabled(false);
|
||||||
Compatibility.setPreferenceChecked(disable, false);
|
Compatibility.setPreferenceChecked(disable, false);
|
||||||
preference.setEnabled(false);
|
preference.setEnabled(false);
|
||||||
|
@ -172,30 +164,14 @@ public class AccountPreferencesFragment extends PreferencesListFragment {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getAccountNumber(int n) {
|
|
||||||
if (n > 0)
|
|
||||||
return Integer.toString(n);
|
|
||||||
else
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
|
|
||||||
SharedPreferences prefs = getPreferenceManager().getSharedPreferences();
|
int n = LinphonePreferences.instance().getAccountCount();
|
||||||
int n = prefs.getInt(getString(R.string.pref_extra_accounts), 1);
|
if (LinphonePreferences.instance().getAccountUsername(n).equals("")) {
|
||||||
String keyUsername = getString(R.string.pref_username_key) + getAccountNumber(n-1);
|
|
||||||
|
|
||||||
if (prefs.getString(keyUsername, "").equals("")) {
|
|
||||||
//If not, we suppress it to not display a blank field
|
//If not, we suppress it to not display a blank field
|
||||||
SharedPreferences.Editor editor = prefs.edit();
|
LinphonePreferences.instance().setAccountCount(n-1);
|
||||||
editor.putInt(getString(R.string.pref_extra_accounts), n-1);
|
|
||||||
editor.commit();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (LinphoneActivity.isInstanciated()) {
|
|
||||||
LinphoneActivity.instance().applyConfigChangesIfNeeded();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,14 +21,13 @@ package org.linphone;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
|
|
||||||
public class BootReceiver extends BroadcastReceiver {
|
public class BootReceiver extends BroadcastReceiver {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
|
||||||
if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean(context.getString(R.string.pref_autostart_key), false)) {
|
if (LinphonePreferences.instance().shouldStartAtStartup()) {
|
||||||
Intent lLinphoneServiceIntent = new Intent(Intent.ACTION_MAIN);
|
Intent lLinphoneServiceIntent = new Intent(Intent.ACTION_MAIN);
|
||||||
lLinphoneServiceIntent.setClass(context, LinphoneService.class);
|
lLinphoneServiceIntent.setClass(context, LinphoneService.class);
|
||||||
context.startService(lLinphoneServiceIntent);;
|
context.startService(lLinphoneServiceIntent);;
|
||||||
|
|
|
@ -48,7 +48,6 @@ import android.annotation.SuppressLint;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.Bitmap.CompressFormat;
|
import android.graphics.Bitmap.CompressFormat;
|
||||||
|
@ -61,7 +60,6 @@ import android.os.Bundle;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
import android.provider.MediaStore;
|
import android.provider.MediaStore;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.content.CursorLoader;
|
import android.support.v4.content.CursorLoader;
|
||||||
|
@ -194,8 +192,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
}
|
}
|
||||||
displayChat(displayName, pictureUri);
|
displayChat(displayName, pictureUri);
|
||||||
|
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(LinphoneActivity.instance());
|
uploadServerUri = LinphonePreferences.instance().getSharingPictureServerUrl();
|
||||||
uploadServerUri = prefs.getString(getString(R.string.pref_image_sharing_server_key), getString(R.string.pref_image_sharing_server_default));
|
|
||||||
|
|
||||||
textWatcher = new TextWatcher() {
|
textWatcher = new TextWatcher() {
|
||||||
public void afterTextChanged(Editable arg0) {
|
public void afterTextChanged(Editable arg0) {
|
||||||
|
|
|
@ -37,7 +37,6 @@ import org.linphone.ui.Numpad;
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
@ -45,7 +44,6 @@ import android.os.Bundle;
|
||||||
import android.os.CountDownTimer;
|
import android.os.CountDownTimer;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
import android.support.v4.app.DialogFragment;
|
import android.support.v4.app.DialogFragment;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.app.FragmentActivity;
|
import android.support.v4.app.FragmentActivity;
|
||||||
|
@ -127,8 +125,7 @@ public class InCallActivity extends FragmentActivity implements
|
||||||
isTransferAllowed = getApplicationContext().getResources().getBoolean(R.bool.allow_transfers);
|
isTransferAllowed = getApplicationContext().getResources().getBoolean(R.bool.allow_transfers);
|
||||||
showCallListInVideo = getApplicationContext().getResources().getBoolean(R.bool.show_current_calls_above_video);
|
showCallListInVideo = getApplicationContext().getResources().getBoolean(R.bool.show_current_calls_above_video);
|
||||||
|
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
isAnimationDisabled = getApplicationContext().getResources().getBoolean(R.bool.disable_animations) || !LinphonePreferences.instance().areAnimationsEnabled();
|
||||||
isAnimationDisabled = getApplicationContext().getResources().getBoolean(R.bool.disable_animations) || !prefs.getBoolean(getString(R.string.pref_animation_enable_key), false);
|
|
||||||
cameraNumber = AndroidCameraConfiguration.retrieveCameras().length;
|
cameraNumber = AndroidCameraConfiguration.retrieveCameras().length;
|
||||||
|
|
||||||
if (findViewById(R.id.fragmentContainer) != null) {
|
if (findViewById(R.id.fragmentContainer) != null) {
|
||||||
|
@ -273,7 +270,7 @@ public class InCallActivity extends FragmentActivity implements
|
||||||
mHandler.post(new Runnable() {
|
mHandler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!isVideoActivatedInSettings()) {
|
if (!LinphonePreferences.instance().isVideoEnabled()) {
|
||||||
video.setEnabled(false);
|
video.setEnabled(false);
|
||||||
} else {
|
} else {
|
||||||
if (isVideoEnabled) {
|
if (isVideoEnabled) {
|
||||||
|
@ -356,12 +353,6 @@ public class InCallActivity extends FragmentActivity implements
|
||||||
status = statusFragment;
|
status = statusFragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isVideoActivatedInSettings() {
|
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
|
||||||
boolean settingsVideoEnabled = prefs.getBoolean(getString(R.string.pref_video_enable_key), false);
|
|
||||||
return settingsVideoEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
int id = v.getId();
|
int id = v.getId();
|
||||||
|
@ -1087,7 +1078,7 @@ public class InCallActivity extends FragmentActivity implements
|
||||||
|
|
||||||
if (state == State.CallUpdatedByRemote) {
|
if (state == State.CallUpdatedByRemote) {
|
||||||
// If the correspondent proposes video while audio call
|
// If the correspondent proposes video while audio call
|
||||||
boolean isVideoEnabled = LinphoneManager.getInstance().isVideoEnabled();
|
boolean isVideoEnabled = LinphonePreferences.instance().isVideoEnabled();
|
||||||
if (!isVideoEnabled) {
|
if (!isVideoEnabled) {
|
||||||
acceptCallUpdate(false);
|
acceptCallUpdate(false);
|
||||||
return;
|
return;
|
||||||
|
@ -1095,7 +1086,7 @@ public class InCallActivity extends FragmentActivity implements
|
||||||
|
|
||||||
boolean remoteVideo = call.getRemoteParams().getVideoEnabled();
|
boolean remoteVideo = call.getRemoteParams().getVideoEnabled();
|
||||||
boolean localVideo = call.getCurrentParamsCopy().getVideoEnabled();
|
boolean localVideo = call.getCurrentParamsCopy().getVideoEnabled();
|
||||||
boolean autoAcceptCameraPolicy = LinphoneManager.getInstance().isAutoAcceptCamera();
|
boolean autoAcceptCameraPolicy = LinphonePreferences.instance().shouldAutomaticallyAcceptVideoRequests();
|
||||||
if (remoteVideo && !localVideo && !autoAcceptCameraPolicy && !LinphoneManager.getLc().isInConference()) {
|
if (remoteVideo && !localVideo && !autoAcceptCameraPolicy && !LinphoneManager.getLc().isInConference()) {
|
||||||
mHandler.post(new Runnable() {
|
mHandler.post(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
|
@ -156,7 +156,7 @@ public class IncomingCallActivity extends Activity implements LinphoneOnCallStat
|
||||||
|
|
||||||
private void answer() {
|
private void answer() {
|
||||||
LinphoneCallParams params = LinphoneManager.getLc().createDefaultCallParameters();
|
LinphoneCallParams params = LinphoneManager.getLc().createDefaultCallParameters();
|
||||||
if (mCall != null && mCall.getRemoteParams() != null && mCall.getRemoteParams().getVideoEnabled() && LinphoneManager.isInstanciated() && LinphoneManager.getInstance().isAutoAcceptCamera()) {
|
if (mCall != null && mCall.getRemoteParams() != null && mCall.getRemoteParams().getVideoEnabled() && LinphonePreferences.instance().shouldAutomaticallyAcceptVideoRequests()) {
|
||||||
params.setVideoEnabled(true);
|
params.setVideoEnabled(true);
|
||||||
} else {
|
} else {
|
||||||
params.setVideoEnabled(false);
|
params.setVideoEnabled(false);
|
||||||
|
@ -176,7 +176,7 @@ public class IncomingCallActivity extends Activity implements LinphoneOnCallStat
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final LinphoneCallParams remoteParams = mCall.getRemoteParams();
|
final LinphoneCallParams remoteParams = mCall.getRemoteParams();
|
||||||
if (remoteParams != null && remoteParams.getVideoEnabled() && LinphoneManager.getInstance().isAutoAcceptCamera()) {
|
if (remoteParams != null && remoteParams.getVideoEnabled() && LinphonePreferences.instance().shouldAutomaticallyAcceptVideoRequests()) {
|
||||||
LinphoneActivity.instance().startVideoActivity(mCall);
|
LinphoneActivity.instance().startVideoActivity(mCall);
|
||||||
} else {
|
} else {
|
||||||
LinphoneActivity.instance().startIncallActivity(mCall);
|
LinphoneActivity.instance().startIncallActivity(mCall);
|
||||||
|
|
|
@ -27,7 +27,6 @@ import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.linphone.LinphoneManager.AddressType;
|
import org.linphone.LinphoneManager.AddressType;
|
||||||
import org.linphone.LinphoneManager.LinphoneConfigException;
|
|
||||||
import org.linphone.LinphoneSimpleListener.LinphoneOnCallStateChangedListener;
|
import org.linphone.LinphoneSimpleListener.LinphoneOnCallStateChangedListener;
|
||||||
import org.linphone.LinphoneSimpleListener.LinphoneOnMessageReceivedListener;
|
import org.linphone.LinphoneSimpleListener.LinphoneOnMessageReceivedListener;
|
||||||
import org.linphone.LinphoneSimpleListener.LinphoneOnRegistrationStateChangedListener;
|
import org.linphone.LinphoneSimpleListener.LinphoneOnRegistrationStateChangedListener;
|
||||||
|
@ -53,14 +52,12 @@ import android.annotation.SuppressLint;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.content.pm.ActivityInfo;
|
import android.content.pm.ActivityInfo;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
import android.support.v4.app.DialogFragment;
|
import android.support.v4.app.DialogFragment;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.app.Fragment.SavedState;
|
import android.support.v4.app.Fragment.SavedState;
|
||||||
|
@ -139,10 +136,9 @@ public class LinphoneActivity extends FragmentActivity implements
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean useFirstLoginActivity = getResources().getBoolean(R.bool.display_account_wizard_at_first_start);
|
boolean useFirstLoginActivity = getResources().getBoolean(R.bool.display_account_wizard_at_first_start);
|
||||||
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
|
if (useFirstLoginActivity && LinphonePreferences.instance().isFirstLaunch()) {
|
||||||
if (useFirstLoginActivity && !pref.getBoolean(getString(R.string.first_launch_suceeded_once_key), false)) {
|
if (LinphonePreferences.instance().getAccountCount() > 0) {
|
||||||
if (pref.getInt(getString(R.string.pref_extra_accounts), -1) > -1) {
|
LinphonePreferences.instance().firstLaunchSuccessful();
|
||||||
pref.edit().putBoolean(getString(R.string.first_launch_suceeded_once_key), true);
|
|
||||||
} else {
|
} else {
|
||||||
startActivityForResult(new Intent().setClass(this, SetupActivity.class), FIRST_LOGIN_ACTIVITY);
|
startActivityForResult(new Intent().setClass(this, SetupActivity.class), FIRST_LOGIN_ACTIVITY);
|
||||||
}
|
}
|
||||||
|
@ -320,8 +316,7 @@ public class LinphoneActivity extends FragmentActivity implements
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateAnimationsState() {
|
private void updateAnimationsState() {
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
isAnimationDisabled = getResources().getBoolean(R.bool.disable_animations) || !LinphonePreferences.instance().areAnimationsEnabled();
|
||||||
isAnimationDisabled = getResources().getBoolean(R.bool.disable_animations) || !prefs.getBoolean(getString(R.string.pref_animation_enable_key), false);
|
|
||||||
isContactPresenceDisabled = !getResources().getBoolean(R.bool.enable_linphone_friends);
|
isContactPresenceDisabled = !getResources().getBoolean(R.bool.enable_linphone_friends);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -674,30 +669,13 @@ public class LinphoneActivity extends FragmentActivity implements
|
||||||
|
|
||||||
public void applyConfigChangesIfNeeded() {
|
public void applyConfigChangesIfNeeded() {
|
||||||
if (nextFragment != FragmentsAvailable.SETTINGS && nextFragment != FragmentsAvailable.ACCOUNT_SETTINGS) {
|
if (nextFragment != FragmentsAvailable.SETTINGS && nextFragment != FragmentsAvailable.ACCOUNT_SETTINGS) {
|
||||||
reloadConfig();
|
|
||||||
updateAnimationsState();
|
updateAnimationsState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
private void reloadConfig() {
|
private void reloadConfig() {
|
||||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
// Nothing to do here anymore
|
||||||
|
|
||||||
if (lc != null && (lc.isInComingInvitePending() || lc.isIncall())) {
|
|
||||||
Log.w("Call in progress => settings not applied");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
LinphoneManager.getInstance().initFromConf();
|
|
||||||
lc.setVideoPolicy(LinphoneManager.getInstance().isAutoInitiateVideoCalls(), LinphoneManager.getInstance().isAutoAcceptCamera());
|
|
||||||
} catch (LinphoneException e) {
|
|
||||||
if (!(e instanceof LinphoneConfigException)) {
|
|
||||||
Log.e(e, "Cannot update config");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
LinphoneActivity.instance().showPreferenceErrorDialog(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void displayAccountSettings(int accountNumber) {
|
public void displayAccountSettings(int accountNumber) {
|
||||||
|
@ -996,8 +974,7 @@ public class LinphoneActivity extends FragmentActivity implements
|
||||||
}
|
}
|
||||||
|
|
||||||
sipUri = sipUri.replace("<", "").replace(">", "");
|
sipUri = sipUri.replace("<", "").replace(">", "");
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
if (LinphonePreferences.instance().shouldAutomaticallyAcceptFriendsRequests()) {
|
||||||
if (prefs.getBoolean(getString(R.string.pref_auto_accept_friends_key), false)) {
|
|
||||||
Contact contact = findContactWithSipAddress(sipUri);
|
Contact contact = findContactWithSipAddress(sipUri);
|
||||||
if (contact != null) {
|
if (contact != null) {
|
||||||
friend.enableSubscribes(true);
|
friend.enableSubscribes(true);
|
||||||
|
@ -1364,7 +1341,7 @@ public class LinphoneActivity extends FragmentActivity implements
|
||||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||||
if (currentFragment == FragmentsAvailable.DIALER) {
|
if (currentFragment == FragmentsAvailable.DIALER) {
|
||||||
boolean isBackgroundModeActive = PreferenceManager.getDefaultSharedPreferences(this).getBoolean(getString(R.string.pref_background_mode_key), getResources().getBoolean(R.bool.pref_background_mode_default));
|
boolean isBackgroundModeActive = LinphonePreferences.instance().isBackgroundModeEnabled();
|
||||||
if (!isBackgroundModeActive) {
|
if (!isBackgroundModeActive) {
|
||||||
stopService(new Intent(Intent.ACTION_MAIN).setClass(this, LinphoneService.class));
|
stopService(new Intent(Intent.ACTION_MAIN).setClass(this, LinphoneService.class));
|
||||||
finish();
|
finish();
|
||||||
|
|
|
@ -21,12 +21,6 @@ package org.linphone;
|
||||||
import static android.media.AudioManager.MODE_RINGTONE;
|
import static android.media.AudioManager.MODE_RINGTONE;
|
||||||
import static android.media.AudioManager.STREAM_RING;
|
import static android.media.AudioManager.STREAM_RING;
|
||||||
import static android.media.AudioManager.STREAM_VOICE_CALL;
|
import static android.media.AudioManager.STREAM_VOICE_CALL;
|
||||||
import static org.linphone.R.string.pref_codec_amr_key;
|
|
||||||
import static org.linphone.R.string.pref_codec_amrwb_key;
|
|
||||||
import static org.linphone.R.string.pref_codec_ilbc_key;
|
|
||||||
import static org.linphone.R.string.pref_codec_speex16_key;
|
|
||||||
import static org.linphone.R.string.pref_codec_speex32_key;
|
|
||||||
import static org.linphone.R.string.pref_video_enable_key;
|
|
||||||
import static org.linphone.core.LinphoneCall.State.CallEnd;
|
import static org.linphone.core.LinphoneCall.State.CallEnd;
|
||||||
import static org.linphone.core.LinphoneCall.State.Error;
|
import static org.linphone.core.LinphoneCall.State.Error;
|
||||||
import static org.linphone.core.LinphoneCall.State.IncomingReceived;
|
import static org.linphone.core.LinphoneCall.State.IncomingReceived;
|
||||||
|
@ -51,7 +45,6 @@ import org.linphone.LinphoneSimpleListener.LinphoneServiceListener;
|
||||||
import org.linphone.compatibility.Compatibility;
|
import org.linphone.compatibility.Compatibility;
|
||||||
import org.linphone.core.CallDirection;
|
import org.linphone.core.CallDirection;
|
||||||
import org.linphone.core.LinphoneAddress;
|
import org.linphone.core.LinphoneAddress;
|
||||||
import org.linphone.core.LinphoneAuthInfo;
|
|
||||||
import org.linphone.core.LinphoneCall;
|
import org.linphone.core.LinphoneCall;
|
||||||
import org.linphone.core.LinphoneCall.State;
|
import org.linphone.core.LinphoneCall.State;
|
||||||
import org.linphone.core.LinphoneCallParams;
|
import org.linphone.core.LinphoneCallParams;
|
||||||
|
@ -61,11 +54,8 @@ import org.linphone.core.LinphoneChatRoom;
|
||||||
import org.linphone.core.LinphoneContent;
|
import org.linphone.core.LinphoneContent;
|
||||||
import org.linphone.core.LinphoneCore;
|
import org.linphone.core.LinphoneCore;
|
||||||
import org.linphone.core.LinphoneCore.EcCalibratorStatus;
|
import org.linphone.core.LinphoneCore.EcCalibratorStatus;
|
||||||
import org.linphone.core.LinphoneCore.FirewallPolicy;
|
|
||||||
import org.linphone.core.LinphoneCore.GlobalState;
|
import org.linphone.core.LinphoneCore.GlobalState;
|
||||||
import org.linphone.core.LinphoneCore.MediaEncryption;
|
|
||||||
import org.linphone.core.LinphoneCore.RegistrationState;
|
import org.linphone.core.LinphoneCore.RegistrationState;
|
||||||
import org.linphone.core.LinphoneCore.Transports;
|
|
||||||
import org.linphone.core.LinphoneCoreException;
|
import org.linphone.core.LinphoneCoreException;
|
||||||
import org.linphone.core.LinphoneCoreFactory;
|
import org.linphone.core.LinphoneCoreFactory;
|
||||||
import org.linphone.core.LinphoneCoreListener;
|
import org.linphone.core.LinphoneCoreListener;
|
||||||
|
@ -95,8 +85,6 @@ import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.content.SharedPreferences.Editor;
|
|
||||||
import android.content.pm.PackageManager.NameNotFoundException;
|
import android.content.pm.PackageManager.NameNotFoundException;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.hardware.Sensor;
|
import android.hardware.Sensor;
|
||||||
|
@ -111,7 +99,6 @@ import android.os.Build;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
import android.os.PowerManager.WakeLock;
|
import android.os.PowerManager.WakeLock;
|
||||||
import android.os.Vibrator;
|
import android.os.Vibrator;
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.provider.Settings.SettingNotFoundException;
|
import android.provider.Settings.SettingNotFoundException;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
|
@ -142,16 +129,12 @@ public class LinphoneManager implements LinphoneCoreListener {
|
||||||
private Context mServiceContext;
|
private Context mServiceContext;
|
||||||
private AudioManager mAudioManager;
|
private AudioManager mAudioManager;
|
||||||
private PowerManager mPowerManager;
|
private PowerManager mPowerManager;
|
||||||
private ConnectivityManager mConnectivityManager;
|
|
||||||
private SharedPreferences mPref;
|
|
||||||
private Resources mR;
|
private Resources mR;
|
||||||
|
private LinphonePreferences mPrefs;
|
||||||
private LinphoneCore mLc;
|
private LinphoneCore mLc;
|
||||||
private static Transports initialTransports;
|
|
||||||
private static LinphonePreferenceManager sLPref;
|
|
||||||
private String lastLcStatusMessage;
|
private String lastLcStatusMessage;
|
||||||
private String basePath;
|
private String basePath;
|
||||||
private static boolean sExited;
|
private static boolean sExited;
|
||||||
private String contactParams;
|
|
||||||
private boolean mAudioFocused;
|
private boolean mAudioFocused;
|
||||||
private boolean isNetworkReachable;
|
private boolean isNetworkReachable;
|
||||||
|
|
||||||
|
@ -189,12 +172,9 @@ public class LinphoneManager implements LinphoneCoreListener {
|
||||||
mPauseSoundFile = basePath + "/toy_mono.wav";
|
mPauseSoundFile = basePath + "/toy_mono.wav";
|
||||||
mChatDatabaseFile = basePath + "/linphone-history.db";
|
mChatDatabaseFile = basePath + "/linphone-history.db";
|
||||||
|
|
||||||
sLPref = LinphonePreferenceManager.getInstance(c);
|
|
||||||
mAudioManager = ((AudioManager) c.getSystemService(Context.AUDIO_SERVICE));
|
mAudioManager = ((AudioManager) c.getSystemService(Context.AUDIO_SERVICE));
|
||||||
mVibrator = (Vibrator) c.getSystemService(Context.VIBRATOR_SERVICE);
|
mVibrator = (Vibrator) c.getSystemService(Context.VIBRATOR_SERVICE);
|
||||||
mPref = PreferenceManager.getDefaultSharedPreferences(c);
|
|
||||||
mPowerManager = (PowerManager) c.getSystemService(Context.POWER_SERVICE);
|
mPowerManager = (PowerManager) c.getSystemService(Context.POWER_SERVICE);
|
||||||
mConnectivityManager = (ConnectivityManager) c.getSystemService(Context.CONNECTIVITY_SERVICE);
|
|
||||||
mR = c.getResources();
|
mR = c.getResources();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,7 +190,7 @@ public class LinphoneManager implements LinphoneCoreListener {
|
||||||
private final String mPauseSoundFile;
|
private final String mPauseSoundFile;
|
||||||
private final String mChatDatabaseFile;
|
private final String mChatDatabaseFile;
|
||||||
|
|
||||||
private Timer mTimer = new Timer("Linphone scheduler");
|
private Timer mTimer;
|
||||||
|
|
||||||
private BroadcastReceiver mKeepAliveReceiver = new KeepAliveReceiver();
|
private BroadcastReceiver mKeepAliveReceiver = new KeepAliveReceiver();
|
||||||
|
|
||||||
|
@ -414,9 +394,8 @@ public class LinphoneManager implements LinphoneCoreListener {
|
||||||
if (mLc.isNetworkReachable()) {
|
if (mLc.isNetworkReachable()) {
|
||||||
try {
|
try {
|
||||||
if (Version.isVideoCapable()) {
|
if (Version.isVideoCapable()) {
|
||||||
boolean prefVideoEnable = isVideoEnabled();
|
boolean prefVideoEnable = mPrefs.isVideoEnabled();
|
||||||
int key = R.string.pref_video_initiate_call_with_video_key;
|
boolean prefInitiateWithVideo = mPrefs.shouldInitiateVideoCall();
|
||||||
boolean prefInitiateWithVideo = getPrefBoolean(key, false);
|
|
||||||
CallManager.getInstance().inviteAddress(lAddress, prefVideoEnable && prefInitiateWithVideo, isLowBandwidthConnection);
|
CallManager.getInstance().inviteAddress(lAddress, prefVideoEnable && prefInitiateWithVideo, isLowBandwidthConnection);
|
||||||
} else {
|
} else {
|
||||||
CallManager.getInstance().inviteAddress(lAddress, false, isLowBandwidthConnection);
|
CallManager.getInstance().inviteAddress(lAddress, false, isLowBandwidthConnection);
|
||||||
|
@ -435,7 +414,7 @@ public class LinphoneManager implements LinphoneCoreListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resetCameraFromPreferences() {
|
private void resetCameraFromPreferences() {
|
||||||
boolean useFrontCam = getPrefBoolean(R.string.pref_video_use_front_camera_key, mR.getBoolean(R.bool.pref_video_use_front_camera_default));
|
boolean useFrontCam = mPrefs.useFrontCam();
|
||||||
|
|
||||||
int camId = 0;
|
int camId = 0;
|
||||||
AndroidCamera[] cameras = AndroidCameraConfiguration.retrieveCameras();
|
AndroidCamera[] cameras = AndroidCameraConfiguration.retrieveCameras();
|
||||||
|
@ -469,6 +448,7 @@ public class LinphoneManager implements LinphoneCoreListener {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void enableCamera(LinphoneCall call, boolean enable) {
|
public void enableCamera(LinphoneCall call, boolean enable) {
|
||||||
if (call != null) {
|
if (call != null) {
|
||||||
call.enableCamera(enable);
|
call.enableCamera(enable);
|
||||||
|
@ -507,7 +487,7 @@ public class LinphoneManager implements LinphoneCoreListener {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
String pref = getPrefString(R.string.pref_tunnel_mode_key, R.string.default_tunnel_mode_entry_value);
|
String pref = mPrefs.getTunnelMode();
|
||||||
|
|
||||||
if (getString(R.string.tunnel_mode_entry_value_always).equals(pref)) {
|
if (getString(R.string.tunnel_mode_entry_value_always).equals(pref)) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -532,7 +512,7 @@ public class LinphoneManager implements LinphoneCoreListener {
|
||||||
mLc.tunnelEnable(true);
|
mLc.tunnelEnable(true);
|
||||||
} else {
|
} else {
|
||||||
Log.i("Tunnel should not be used");
|
Log.i("Tunnel should not be used");
|
||||||
String pref = getPrefString(R.string.pref_tunnel_mode_key, R.string.default_tunnel_mode_entry_value);
|
String pref = mPrefs.getTunnelMode();
|
||||||
mLc.tunnelEnable(false);
|
mLc.tunnelEnable(false);
|
||||||
if (getString(R.string.tunnel_mode_entry_value_auto).equals(pref)) {
|
if (getString(R.string.tunnel_mode_entry_value_auto).equals(pref)) {
|
||||||
mLc.tunnelAutoDetect();
|
mLc.tunnelAutoDetect();
|
||||||
|
@ -549,13 +529,32 @@ public class LinphoneManager implements LinphoneCoreListener {
|
||||||
LinphoneCoreFactory.instance().setDebugMode(isDebugLogEnabled, getString(R.string.app_name));
|
LinphoneCoreFactory.instance().setDebugMode(isDebugLogEnabled, getString(R.string.app_name));
|
||||||
|
|
||||||
// Try to get remote provisioning
|
// Try to get remote provisioning
|
||||||
String remote_provisioning = (getPrefString(R.string.pref_remote_provisioning_key, mR.getString(R.string.pref_remote_provisioning_default)));
|
String remote_provisioning = mPrefs.getRemoteProvisioningUrl();
|
||||||
if(remote_provisioning != null && remote_provisioning.length() > 0 && RemoteProvisioning.isAvailable()) {
|
if(remote_provisioning != null && remote_provisioning.length() > 0 && RemoteProvisioning.isAvailable()) {
|
||||||
RemoteProvisioning.download(remote_provisioning, mLinphoneConfigFile);
|
RemoteProvisioning.download(remote_provisioning, mLinphoneConfigFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
initLiblinphone(c);
|
||||||
|
|
||||||
|
IntentFilter lFilter = new IntentFilter(Intent.ACTION_SCREEN_ON);
|
||||||
|
lFilter.addAction(Intent.ACTION_SCREEN_OFF);
|
||||||
|
mServiceContext.registerReceiver(mKeepAliveReceiver, lFilter);
|
||||||
|
|
||||||
|
updateNetworkReachability();
|
||||||
|
|
||||||
|
startBluetooth();
|
||||||
|
resetCameraFromPreferences();
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
Log.e(e, "Cannot start linphone");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void initLiblinphone(Context c) throws LinphoneCoreException {
|
||||||
|
boolean isDebugLogEnabled = !(mR.getBoolean(R.bool.disable_every_log)) && mPrefs.isDebugEnabled();
|
||||||
|
LinphoneCoreFactory.instance().setDebugMode(isDebugLogEnabled, getString(R.string.app_name));
|
||||||
|
|
||||||
mLc = LinphoneCoreFactory.instance().createLinphoneCore(this, mLinphoneConfigFile, mLinphoneInitialConfigFile, null);
|
mLc = LinphoneCoreFactory.instance().createLinphoneCore(this, mLinphoneConfigFile, mLinphoneInitialConfigFile, null);
|
||||||
mLc.getConfig().setInt("sip", "store_auth_info", 0);
|
|
||||||
mLc.setContext(c);
|
mLc.setContext(c);
|
||||||
try {
|
try {
|
||||||
String versionName = c.getPackageManager().getPackageInfo(c.getPackageName(), 0).versionName;
|
String versionName = c.getPackageManager().getPackageInfo(c.getPackageName(), 0).versionName;
|
||||||
|
@ -578,12 +577,6 @@ public class LinphoneManager implements LinphoneCoreListener {
|
||||||
Log.w("MediaStreamer : " + availableCores + " cores detected and configured");
|
Log.w("MediaStreamer : " + availableCores + " cores detected and configured");
|
||||||
mLc.setCpuCount(availableCores);
|
mLc.setCpuCount(availableCores);
|
||||||
|
|
||||||
try {
|
|
||||||
initFromConf();
|
|
||||||
} catch (LinphoneException e) {
|
|
||||||
Log.w("no config ready yet");
|
|
||||||
}
|
|
||||||
|
|
||||||
TimerTask lTask = new TimerTask() {
|
TimerTask lTask = new TimerTask() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -591,18 +584,8 @@ public class LinphoneManager implements LinphoneCoreListener {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
/*use schedule instead of scheduleAtFixedRate to avoid iterate from being call in burst after cpu wake up*/
|
/*use schedule instead of scheduleAtFixedRate to avoid iterate from being call in burst after cpu wake up*/
|
||||||
|
mTimer = new Timer("Linphone scheduler");
|
||||||
mTimer.schedule(lTask, 0, 20);
|
mTimer.schedule(lTask, 0, 20);
|
||||||
|
|
||||||
IntentFilter lFilter = new IntentFilter(Intent.ACTION_SCREEN_ON);
|
|
||||||
lFilter.addAction(Intent.ACTION_SCREEN_OFF);
|
|
||||||
mServiceContext.registerReceiver(mKeepAliveReceiver, lFilter);
|
|
||||||
|
|
||||||
startBluetooth();
|
|
||||||
resetCameraFromPreferences();
|
|
||||||
}
|
|
||||||
catch (Exception e) {
|
|
||||||
Log.e(e, "Cannot start linphone");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void copyAssetsFromPackage() throws IOException {
|
private void copyAssetsFromPackage() throws IOException {
|
||||||
|
@ -613,12 +596,14 @@ public class LinphoneManager implements LinphoneCoreListener {
|
||||||
copyIfNotExist(R.raw.lpconfig, new File(mLPConfigXsd).getName());
|
copyIfNotExist(R.raw.lpconfig, new File(mLPConfigXsd).getName());
|
||||||
copyIfNotExist(R.raw.rootca, new File(mLinphoneRootCaFile).getName());
|
copyIfNotExist(R.raw.rootca, new File(mLinphoneRootCaFile).getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void copyIfNotExist(int ressourceId,String target) throws IOException {
|
private void copyIfNotExist(int ressourceId,String target) throws IOException {
|
||||||
File lFileToCopy = new File(target);
|
File lFileToCopy = new File(target);
|
||||||
if (!lFileToCopy.exists()) {
|
if (!lFileToCopy.exists()) {
|
||||||
copyFromPackage(ressourceId,lFileToCopy.getName());
|
copyFromPackage(ressourceId,lFileToCopy.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void copyFromPackage(int ressourceId,String target) throws IOException{
|
private void copyFromPackage(int ressourceId,String target) throws IOException{
|
||||||
FileOutputStream lOutputStream = mServiceContext.openFileOutput (target, 0);
|
FileOutputStream lOutputStream = mServiceContext.openFileOutput (target, 0);
|
||||||
InputStream lInputStream = mR.openRawResource(ressourceId);
|
InputStream lInputStream = mR.openRawResource(ressourceId);
|
||||||
|
@ -646,188 +631,6 @@ public class LinphoneManager implements LinphoneCoreListener {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initFromConfTunnel(){
|
|
||||||
if (!mLc.isTunnelAvailable())
|
|
||||||
return;
|
|
||||||
|
|
||||||
NetworkInfo info = mConnectivityManager.getActiveNetworkInfo();
|
|
||||||
mLc.tunnelCleanServers();
|
|
||||||
String host = getString(R.string.tunnel_host);
|
|
||||||
if (host == null || host.length() == 0)
|
|
||||||
host = mPref.getString(getString(R.string.pref_tunnel_host_key), "");
|
|
||||||
int port = Integer.parseInt(getPrefString(R.string.pref_tunnel_port_key, "443"));
|
|
||||||
mLc.tunnelAddServerAndMirror(host, port, 12345,500);
|
|
||||||
manageTunnelServer(info);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void initAccounts() throws LinphoneCoreException {
|
|
||||||
mLc.clearAuthInfos();
|
|
||||||
mLc.clearProxyConfigs();
|
|
||||||
|
|
||||||
for (int i = 0; i < getPrefExtraAccountsNumber(); i++) {
|
|
||||||
String key = i == 0 ? "" : String.valueOf(i);
|
|
||||||
if (!getPrefBoolean(getString(R.string.pref_disable_account_key) + key, false)) {
|
|
||||||
initAccount(key, i == getPrefInt(R.string.pref_default_account_key, 0));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LinphoneProxyConfig lDefaultProxyConfig = mLc.getDefaultProxyConfig();
|
|
||||||
if (lDefaultProxyConfig != null) {
|
|
||||||
//prefix
|
|
||||||
String lPrefix = getPrefString(R.string.pref_prefix_key, null);
|
|
||||||
if (lPrefix != null) {
|
|
||||||
lDefaultProxyConfig.setDialPrefix(lPrefix);
|
|
||||||
}
|
|
||||||
//escape +
|
|
||||||
lDefaultProxyConfig.setDialEscapePlus(getPrefBoolean(R.string.pref_escape_plus_key, false));
|
|
||||||
} else if (LinphoneService.isReady()) {
|
|
||||||
LinphoneService.instance().onRegistrationStateChanged(RegistrationState.RegistrationNone, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initAccount(String key, boolean defaultAccount) throws LinphoneCoreException {
|
|
||||||
String username = getPrefString(getString(R.string.pref_username_key) + key, null);
|
|
||||||
String userid = getPrefString(getString(R.string.pref_auth_userid_key) + key, null);
|
|
||||||
String password = getPrefString(getString(R.string.pref_passwd_key) + key, null);
|
|
||||||
String domain = getPrefString(getString(R.string.pref_domain_key) + key, null);
|
|
||||||
if (username != null && username.length() > 0 && password != null) {
|
|
||||||
LinphoneAuthInfo lAuthInfo = LinphoneCoreFactory.instance().createAuthInfo(username
|
|
||||||
, userid
|
|
||||||
, password
|
|
||||||
, null
|
|
||||||
,null);
|
|
||||||
mLc.addAuthInfo(lAuthInfo);
|
|
||||||
|
|
||||||
if (domain != null && domain.length() > 0) {
|
|
||||||
String identity = "sip:" + username +"@" + domain;
|
|
||||||
String proxy = getPrefString(getString(R.string.pref_proxy_key) + key, null);
|
|
||||||
if (proxy == null || proxy.length() == 0) {
|
|
||||||
proxy = "sip:" + domain;
|
|
||||||
}
|
|
||||||
if (!proxy.startsWith("sip:")) {
|
|
||||||
proxy = "sip:" + proxy;
|
|
||||||
}
|
|
||||||
|
|
||||||
LinphoneProxyConfig proxycon = LinphoneCoreFactory.instance().createProxyConfig(identity, proxy, null, true);
|
|
||||||
String defaultExpire = getString(R.string.pref_expire_default);
|
|
||||||
proxycon.setExpires(tryToParseIntValue(getPrefString(R.string.pref_expire_key, defaultExpire), defaultExpire));
|
|
||||||
|
|
||||||
// Add parameters for push notifications
|
|
||||||
if (mR.getBoolean(R.bool.enable_push_id)) {
|
|
||||||
String regId = getPrefString(R.string.push_reg_id_key, null);
|
|
||||||
String appId = getString(R.string.push_sender_id);
|
|
||||||
if (regId != null && getPrefBoolean(R.string.pref_push_notification_key, mR.getBoolean(R.bool.pref_push_notification_default))) {
|
|
||||||
String contactInfos = "app-id=" + appId + ";pn-type=google;pn-tok=" + regId + ";pn-msg-str=IM_MSG;pn-call-str=IC_MSG;pn-call-snd=ring.caf;pn-msg-snd=msg.caf";
|
|
||||||
proxycon.setContactParameters(contactInfos);
|
|
||||||
}
|
|
||||||
} else if (contactParams != null) {
|
|
||||||
proxycon.setContactParameters(contactParams);
|
|
||||||
}
|
|
||||||
mLc.addProxyConfig(proxycon);
|
|
||||||
|
|
||||||
//outbound proxy
|
|
||||||
if (getPrefBoolean(getString(R.string.pref_enable_outbound_proxy_key) + key, false)) {
|
|
||||||
proxycon.setRoute(proxy);
|
|
||||||
} else {
|
|
||||||
proxycon.setRoute(null);
|
|
||||||
}
|
|
||||||
proxycon.done();
|
|
||||||
|
|
||||||
if (defaultAccount) {
|
|
||||||
mLc.setDefaultProxyConfig(proxycon);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void readAndSetAudioAndVideoPorts() throws NumberFormatException {
|
|
||||||
int aPortStart, aPortEnd, vPortStart, vPortEnd;
|
|
||||||
int defaultAudioPort, defaultVideoPort;
|
|
||||||
defaultAudioPort = Integer.parseInt(getString(R.string.default_audio_port));
|
|
||||||
defaultVideoPort = Integer.parseInt(getString(R.string.default_video_port));
|
|
||||||
aPortStart = aPortEnd = defaultAudioPort;
|
|
||||||
vPortStart = vPortEnd = defaultVideoPort;
|
|
||||||
|
|
||||||
String audioPort = getPrefString(R.string.pref_audio_port_key, String.valueOf(aPortStart));
|
|
||||||
String videoPort = getPrefString(R.string.pref_video_port_key, String.valueOf(vPortStart));
|
|
||||||
|
|
||||||
if (audioPort.contains("-")) {
|
|
||||||
// Port range
|
|
||||||
aPortStart = Integer.parseInt(audioPort.split("-")[0]);
|
|
||||||
aPortEnd = Integer.parseInt(audioPort.split("-")[1]);
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
aPortStart = aPortEnd = Integer.parseInt(audioPort);
|
|
||||||
} catch (NumberFormatException nfe) {
|
|
||||||
aPortStart = aPortEnd = defaultAudioPort;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (videoPort.contains("-")) {
|
|
||||||
// Port range
|
|
||||||
vPortStart = Integer.parseInt(videoPort.split("-")[0]);
|
|
||||||
vPortEnd = Integer.parseInt(videoPort.split("-")[1]);
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
vPortStart = vPortEnd = Integer.parseInt(videoPort);
|
|
||||||
} catch (NumberFormatException nfe) {
|
|
||||||
vPortStart = vPortEnd = defaultVideoPort;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (aPortStart >= aPortEnd) {
|
|
||||||
mLc.setAudioPort(aPortStart);
|
|
||||||
} else {
|
|
||||||
mLc.setAudioPortRange(aPortStart, aPortEnd);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (vPortStart >= vPortEnd) {
|
|
||||||
mLc.setVideoPort(vPortStart);
|
|
||||||
} else {
|
|
||||||
mLc.setVideoPortRange(vPortStart, vPortEnd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private int tryToParseIntValue(String valueToParse, String defaultValue) {
|
|
||||||
return tryToParseIntValue(valueToParse, Integer.parseInt(defaultValue));
|
|
||||||
}
|
|
||||||
|
|
||||||
private int tryToParseIntValue(String valueToParse, int defaultValue) {
|
|
||||||
try {
|
|
||||||
int returned = Integer.parseInt(valueToParse);
|
|
||||||
return returned;
|
|
||||||
} catch (NumberFormatException nfe) {
|
|
||||||
|
|
||||||
}
|
|
||||||
return defaultValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setContactParams(String params) {
|
|
||||||
contactParams = params;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void initFromConf() throws LinphoneConfigException {
|
|
||||||
boolean isDebugLogEnabled = !(mR.getBoolean(R.bool.disable_every_log)) && getPrefBoolean(R.string.pref_debug_key, mR.getBoolean(R.bool.pref_debug_default));
|
|
||||||
LinphoneCoreFactory.instance().setDebugMode(isDebugLogEnabled, getString(R.string.app_name));
|
|
||||||
initFromConfTunnel();
|
|
||||||
|
|
||||||
if (initialTransports == null)
|
|
||||||
initialTransports = mLc.getSignalingTransportPorts();
|
|
||||||
|
|
||||||
setSignalingTransportsFromConfiguration(initialTransports);
|
|
||||||
setPreferredVideoSizeFromConfiguration();
|
|
||||||
|
|
||||||
//accounts
|
|
||||||
try {
|
|
||||||
initAccounts();
|
|
||||||
|
|
||||||
//init network state
|
|
||||||
updateNetworkReachability();
|
|
||||||
} catch (LinphoneCoreException e) {
|
|
||||||
throw new LinphoneConfigException(getString(R.string.wrong_settings),e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateNetworkReachability() {
|
public void updateNetworkReachability() {
|
||||||
ConnectivityManager cm = (ConnectivityManager) mServiceContext.getSystemService(Context.CONNECTIVITY_SERVICE);
|
ConnectivityManager cm = (ConnectivityManager) mServiceContext.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
NetworkInfo eventInfo = cm.getActiveNetworkInfo();
|
NetworkInfo eventInfo = cm.getActiveNetworkInfo();
|
||||||
|
@ -840,8 +643,7 @@ public class LinphoneManager implements LinphoneCoreListener {
|
||||||
}
|
}
|
||||||
} else if (eventInfo.getState() == NetworkInfo.State.CONNECTED){
|
} else if (eventInfo.getState() == NetworkInfo.State.CONNECTED){
|
||||||
manageTunnelServer(eventInfo);
|
manageTunnelServer(eventInfo);
|
||||||
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(mServiceContext);
|
boolean wifiOnly = LinphonePreferences.instance().shouldOnlyRegisterOnWifiNetwork();
|
||||||
boolean wifiOnly = pref.getBoolean(getString(R.string.pref_wifi_only_key), mR.getBoolean(R.bool.pref_wifi_only_default));
|
|
||||||
if ((eventInfo.getTypeName().equals("WIFI")) || (!eventInfo.getTypeName().equals("WIFI") && !wifiOnly)) {
|
if ((eventInfo.getTypeName().equals("WIFI")) || (!eventInfo.getTypeName().equals("WIFI") && !wifiOnly)) {
|
||||||
if (!isNetworkReachable) {
|
if (!isNetworkReachable) {
|
||||||
isNetworkReachable = true;
|
isNetworkReachable = true;
|
||||||
|
@ -858,96 +660,6 @@ public class LinphoneManager implements LinphoneCoreListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setSignalingTransportsFromConfiguration(Transports t) {
|
|
||||||
Transports ports = new Transports(t);
|
|
||||||
boolean useRandomPort = getPrefBoolean(R.string.pref_transport_use_random_ports_key, mR.getBoolean(R.bool.pref_transport_use_random_ports_default));
|
|
||||||
int lPreviousPort = tryToParseIntValue(getPrefString(R.string.pref_sip_port_key, getString(R.string.pref_sip_port_default)), 5060);
|
|
||||||
if (lPreviousPort>0xFFFF || useRandomPort) {
|
|
||||||
lPreviousPort=(int)(Math.random() * (0xFFFF - 1024)) + 1024;
|
|
||||||
Log.w("Using random port " + lPreviousPort);
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
ports.tls = 0;
|
|
||||||
ports.tcp = lPreviousPort;
|
|
||||||
} else if (transport.equals(getString(R.string.pref_transport_udp_key)))
|
|
||||||
{
|
|
||||||
ports.tcp = 0;
|
|
||||||
ports.tls = 0;
|
|
||||||
ports.udp = lPreviousPort;
|
|
||||||
} else if (transport.equals(getString(R.string.pref_transport_tls_key)))
|
|
||||||
{
|
|
||||||
ports.udp = 0;
|
|
||||||
ports.tcp = 0;
|
|
||||||
ports.tls = lPreviousPort;
|
|
||||||
}
|
|
||||||
|
|
||||||
mLc.setSignalingTransportPorts(ports);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void enableDisableAudioCodec(String codec, int rate, int channels, int key) throws LinphoneCoreException {
|
|
||||||
PayloadType pt = mLc.findPayloadType(codec, rate, channels);
|
|
||||||
if (pt !=null) {
|
|
||||||
boolean enable= getPrefBoolean(key,false);
|
|
||||||
mLc.enablePayloadType(pt, enable);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void enableDisableAudioCodec(String codec, int rate, int channels, boolean enable) throws LinphoneCoreException {
|
|
||||||
PayloadType pt = mLc.findPayloadType(codec, rate, channels);
|
|
||||||
if (pt !=null) {
|
|
||||||
mLc.enablePayloadType(pt, enable);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void enableDisableVideoCodecs(PayloadType videoCodec) throws LinphoneCoreException {
|
|
||||||
String mime = videoCodec.getMime();
|
|
||||||
int key;
|
|
||||||
int defaultValueKey;
|
|
||||||
|
|
||||||
if ("MP4V-ES".equals(mime)) {
|
|
||||||
key = R.string.pref_video_codec_mpeg4_key;
|
|
||||||
defaultValueKey = R.bool.pref_video_codec_mpeg4_default;
|
|
||||||
} else if ("H264".equals(mime)) {
|
|
||||||
key = R.string.pref_video_codec_h264_key;
|
|
||||||
defaultValueKey = R.bool.pref_video_codec_h264_default;
|
|
||||||
} else if ("H263-1998".equals(mime)) {
|
|
||||||
key = R.string.pref_video_codec_h263_key;
|
|
||||||
defaultValueKey = R.bool.pref_video_codec_h263_default;
|
|
||||||
} else if ("VP8".equals(mime)) {
|
|
||||||
key = R.string.pref_video_codec_vp8_key;
|
|
||||||
defaultValueKey = R.bool.pref_video_codec_vp8_default;
|
|
||||||
} else {
|
|
||||||
Log.e("Unhandled video codec ", mime);
|
|
||||||
mLc.enablePayloadType(videoCodec, false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean enable = getPrefBoolean(key, mR.getBoolean(defaultValueKey));
|
|
||||||
mLc.enablePayloadType(videoCodec, enable);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setPreferredVideoSizeFromConfiguration() {
|
|
||||||
String preferredVideoSize = getPrefString(R.string.pref_preferred_video_size_key, getString(R.string.pref_preferred_video_size_vga_key));
|
|
||||||
int bandwidth = 512 + 60;
|
|
||||||
if (preferredVideoSize.equals(getString(R.string.pref_preferred_video_size_hd_key))) {
|
|
||||||
preferredVideoSize = "uxga";
|
|
||||||
bandwidth = 1024 + 60;
|
|
||||||
} else if (preferredVideoSize.equals(getString(R.string.pref_preferred_video_size_vga_key))) {
|
|
||||||
preferredVideoSize = "vga";
|
|
||||||
bandwidth = 512 + 60;
|
|
||||||
} else if (preferredVideoSize.equals(getString(R.string.pref_preferred_video_size_qvga_key))) {
|
|
||||||
preferredVideoSize = "qvga";
|
|
||||||
bandwidth = 380 + 60;
|
|
||||||
}
|
|
||||||
|
|
||||||
mLc.setPreferredVideoSizeByName(preferredVideoSize);
|
|
||||||
mLc.setUploadBandwidth(bandwidth);
|
|
||||||
mLc.setDownloadBandwidth(bandwidth);
|
|
||||||
}
|
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
|
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
|
||||||
private void doDestroy() {
|
private void doDestroy() {
|
||||||
ChatStorage.getInstance().close();
|
ChatStorage.getInstance().close();
|
||||||
|
@ -984,28 +696,6 @@ public class LinphoneManager implements LinphoneCoreListener {
|
||||||
private String getString(int key) {
|
private String getString(int key) {
|
||||||
return mR.getString(key);
|
return mR.getString(key);
|
||||||
}
|
}
|
||||||
private boolean getPrefBoolean(int key, boolean value) {
|
|
||||||
return mPref.getBoolean(mR.getString(key), value);
|
|
||||||
}
|
|
||||||
private boolean getPrefBoolean(String key, boolean value) {
|
|
||||||
return mPref.getBoolean(key, value);
|
|
||||||
}
|
|
||||||
private String getPrefString(int key, String value) {
|
|
||||||
return mPref.getString(mR.getString(key), value);
|
|
||||||
}
|
|
||||||
private int getPrefInt(int key, int value) {
|
|
||||||
return mPref.getInt(mR.getString(key), value);
|
|
||||||
}
|
|
||||||
private String getPrefString(int key, int value) {
|
|
||||||
return mPref.getString(mR.getString(key), mR.getString(value));
|
|
||||||
}
|
|
||||||
private String getPrefString(String key, String value) {
|
|
||||||
return mPref.getString(key, value);
|
|
||||||
}
|
|
||||||
private int getPrefExtraAccountsNumber() {
|
|
||||||
return mPref.getInt(getString(R.string.pref_extra_accounts), 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Simple implementation as Android way seems very complicate:
|
/* Simple implementation as Android way seems very complicate:
|
||||||
For example: with wifi and mobile actives; when pulling mobile down:
|
For example: with wifi and mobile actives; when pulling mobile down:
|
||||||
|
@ -1205,7 +895,7 @@ public class LinphoneManager implements LinphoneCoreListener {
|
||||||
Compatibility.setAudioManagerInCallMode(mAudioManager);
|
Compatibility.setAudioManagerInCallMode(mAudioManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Hacks.needSoftvolume() || sLPref.useSoftvolume()) {
|
if (Hacks.needSoftvolume() || LinphonePreferences.instance().shouldUseSoftvolume()) {
|
||||||
adjustVolume(0); // Synchronize
|
adjustVolume(0); // Synchronize
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1372,55 +1062,6 @@ public class LinphoneManager implements LinphoneCoreListener {
|
||||||
return CallManager.getInstance().reinviteWithVideo();
|
return CallManager.getInstance().reinviteWithVideo();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isVideoEnabled() {
|
|
||||||
return getPrefBoolean(R.string.pref_video_enable_key, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isAutoAcceptCamera() {
|
|
||||||
return isVideoEnabled() && getPrefBoolean(R.string.pref_video_automatically_accept_video_key, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isAutoInitiateVideoCalls() {
|
|
||||||
return isVideoEnabled() && getPrefBoolean(R.string.pref_video_initiate_call_with_video_key, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Called on first launch only
|
|
||||||
public void initializePayloads() {
|
|
||||||
Log.i("Initializing supported payloads");
|
|
||||||
Editor e = mPref.edit();
|
|
||||||
boolean fastCpu = Version.hasFastCpu();
|
|
||||||
|
|
||||||
e.putBoolean(getString(R.string.pref_codec_gsm_key), true);
|
|
||||||
e.putBoolean(getString(R.string.pref_codec_pcma_key), true);
|
|
||||||
e.putBoolean(getString(R.string.pref_codec_pcmu_key), true);
|
|
||||||
e.putBoolean(getString(R.string.pref_codec_speex8_key), true);
|
|
||||||
e.putBoolean(getString(R.string.pref_codec_g722_key), false);
|
|
||||||
e.putBoolean(getString(pref_codec_speex16_key), fastCpu);
|
|
||||||
e.putBoolean(getString(pref_codec_speex32_key), fastCpu);
|
|
||||||
|
|
||||||
boolean ilbc = LinphoneService.isReady() && LinphoneManager.getLc()
|
|
||||||
.findPayloadType("iLBC", 8000, 1)!=null;
|
|
||||||
e.putBoolean(getString(pref_codec_ilbc_key), ilbc);
|
|
||||||
|
|
||||||
boolean amr = LinphoneService.isReady() && LinphoneManager.getLc()
|
|
||||||
.findPayloadType("AMR", 8000, 1)!=null;
|
|
||||||
e.putBoolean(getString(pref_codec_amr_key), amr);
|
|
||||||
|
|
||||||
boolean amrwb = LinphoneService.isReady() && LinphoneManager.getLc()
|
|
||||||
.findPayloadType("AMR-WB", 16000, 1)!=null;
|
|
||||||
e.putBoolean(getString(pref_codec_amrwb_key), amrwb);
|
|
||||||
|
|
||||||
boolean g729 = LinphoneService.isReady() && LinphoneManager.getLc()
|
|
||||||
.findPayloadType("G729", 8000, 1)!=null;
|
|
||||||
e.putBoolean(getString(R.string.pref_codec_g729_key), g729);
|
|
||||||
|
|
||||||
if (Version.sdkStrictlyBelow(5) || !Version.hasNeon() || !Hacks.hasCamera()) {
|
|
||||||
e.putBoolean(getString(pref_video_enable_key), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
e.commit();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return false if already in video call.
|
* @return false if already in video call.
|
||||||
|
|
|
@ -1,66 +0,0 @@
|
||||||
/*
|
|
||||||
PreferenceManager.java
|
|
||||||
Copyright (C) 2011 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.
|
|
||||||
*/
|
|
||||||
package org.linphone;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
|
|
||||||
public class LinphonePreferenceManager {
|
|
||||||
|
|
||||||
private static LinphonePreferenceManager instance;
|
|
||||||
private Context c;
|
|
||||||
private SharedPreferences p;
|
|
||||||
|
|
||||||
public LinphonePreferenceManager(Context context) {
|
|
||||||
c = context.getApplicationContext();
|
|
||||||
p = PreferenceManager.getDefaultSharedPreferences(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getString(int key) {
|
|
||||||
return c.getString(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean useSoftvolume() {
|
|
||||||
return p.getBoolean(
|
|
||||||
getString(R.string.pref_audio_soft_volume_key), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean useAudioRoutingAPIHack() {
|
|
||||||
return p.getBoolean(
|
|
||||||
getString(R.string.pref_audio_hacks_use_routing_api_key), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean useGalaxySHack() {
|
|
||||||
return p.getBoolean(
|
|
||||||
getString(R.string.pref_audio_hacks_use_galaxys_hack_key), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int useSpecificAudioModeHack() {
|
|
||||||
return Integer.parseInt(p.getString(getString(R.string.pref_audio_use_specific_mode_key), "0"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final synchronized LinphonePreferenceManager getInstance(Context c) {
|
|
||||||
if (instance == null) {
|
|
||||||
instance = new LinphonePreferenceManager(c.getApplicationContext());
|
|
||||||
}
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -17,97 +17,182 @@ You should have received a copy of the GNU General Public License
|
||||||
along with this program; if not, write to the Free Software
|
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.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.linphone.core.LinphoneCoreFactory;
|
|
||||||
import org.linphone.core.LpConfig;
|
|
||||||
import org.linphone.mediastream.Log;
|
|
||||||
|
|
||||||
import android.content.res.Resources;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Sylvain Berfini
|
* @author Sylvain Berfini
|
||||||
*/
|
*/
|
||||||
public class LinphonePreferences {
|
public class LinphonePreferences {
|
||||||
private static LinphonePreferences instance;
|
private static LinphonePreferences instance;
|
||||||
private Map<String,String> dict, changesDict;
|
|
||||||
private LpConfig config;
|
|
||||||
|
|
||||||
public static final synchronized LinphonePreferences getInstance() {
|
public static final synchronized LinphonePreferences instance() {
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
instance = new LinphonePreferences();
|
instance = new LinphonePreferences();
|
||||||
instance.load();
|
|
||||||
}
|
}
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
private LinphonePreferences() {
|
private LinphonePreferences() {
|
||||||
dict = new HashMap<String,String>();
|
|
||||||
changesDict = new HashMap<String,String>();
|
|
||||||
if (LinphoneManager.getLcIfManagerNotDestroyedOrNull() == null) {
|
|
||||||
config = LinphoneCoreFactory.instance().createLpConfig(LinphoneManager.getInstance().mLinphoneConfigFile);
|
|
||||||
} else {
|
|
||||||
config = LinphoneManager.getLc().getConfig();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String get(String key) {
|
public boolean isFirstLaunch() {
|
||||||
if (dict.containsKey(key)) {
|
return false;
|
||||||
return dict.get(key);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void firstLaunchSuccessful() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDebugEnabled() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRemoteProvisioningUrl() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNew(String key) {
|
public String getTunnelMode() {
|
||||||
if (changesDict.containsKey(key)) {
|
|
||||||
return changesDict.get(key);
|
|
||||||
} else if (dict.containsKey(key)) {
|
|
||||||
return dict.get(key);
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void set(String key, String value) {
|
public boolean useFrontCam() {
|
||||||
if (dict.containsKey(key)) {
|
return false;
|
||||||
if (dict.get(key) != value || value.length() == 0) {
|
|
||||||
changesDict.put(key, value);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
changesDict.put(key, value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasValueChanged(String key) {
|
public boolean isVideoEnabled() {
|
||||||
return changesDict.containsKey(key);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void load() {
|
public boolean shouldInitiateVideoCall() {
|
||||||
loadSection("sip", R.array.lpconfig_sip_keys);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadSection(String section, int resourcesID) {
|
public boolean shouldAutomaticallyAcceptVideoRequests() {
|
||||||
Log.w("Preferences loading for section " + section);
|
return false;
|
||||||
for (String key : LinphoneService.instance().getResources().getStringArray(resourcesID)) {
|
|
||||||
String value = config.getString("sip", key, "");
|
|
||||||
if (value != null && value.length() > 0) {
|
|
||||||
Log.w("Value read for key " + key + " : " + value);
|
|
||||||
dict.put(key, value);
|
|
||||||
} else {
|
|
||||||
Log.w("Value not found for key " + key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save() {
|
public void setPushNotificationRegistrationID(String regId) {
|
||||||
Log.w("Preferences saving...");
|
|
||||||
Resources res = LinphoneService.instance().getResources();
|
|
||||||
for (String key : res.getStringArray(R.array.lpconfig_sip_keys)) {
|
|
||||||
if (hasValueChanged(key)) {
|
|
||||||
Log.w("Saving changed preference : " + getNew(key));
|
|
||||||
config.setString("sip", key, getNew(key));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getPushNotificationRegistrationID() {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
config.sync();
|
|
||||||
|
public boolean shouldStartAtStartup() {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getSharingPictureServerUrl() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean shouldUseLinphoneToStoreChatHistory() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean areAnimationsEnabled() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean shouldAutomaticallyAcceptFriendsRequests() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isBackgroundModeEnabled() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean shouldOnlyRegisterOnWifiNetwork() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean shouldUseSoftvolume() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRingtone(String defaultRingtone) {
|
||||||
|
return defaultRingtone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRingtone(String ringtone) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Accounts
|
||||||
|
public void setAccountUsername(int n, String string) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAccountUsername(int i) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAccountUserId(int n, String string) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAccountUserId(int n) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAccountPassword(int n, String string) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAccountPassword(int n) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAccountDomain(int n, String string) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAccountDomain(int i) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAccountProxy(int n, String string) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAccountProxy(int n) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAccountOutboundProxyEnabled(int n, Boolean newValue) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAccountOutboundProxySet(int n) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAccountEnabled(int n, Boolean newValue) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDefaultAccount(int accountIndex) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDefaultAccountIndex() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAccountCount(int i) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAccountCount() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAccountEnabled(int n) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteAccount(int n) {
|
||||||
|
|
||||||
|
}
|
||||||
|
// End of Accounts
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,6 @@ import android.app.PendingIntent;
|
||||||
import android.app.Service;
|
import android.app.Service;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.content.pm.PackageInfo;
|
import android.content.pm.PackageInfo;
|
||||||
import android.content.pm.PackageManager.NameNotFoundException;
|
import android.content.pm.PackageManager.NameNotFoundException;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
|
@ -60,7 +59,6 @@ import android.os.Build;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
import android.provider.MediaStore;
|
import android.provider.MediaStore;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -137,8 +135,6 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
|
|
||||||
// In case restart after a crash. Main in LinphoneActivity
|
// In case restart after a crash. Main in LinphoneActivity
|
||||||
LinphonePreferenceManager.getInstance(this);
|
|
||||||
|
|
||||||
mNotificationTitle = getString(R.string.app_name);
|
mNotificationTitle = getString(R.string.app_name);
|
||||||
|
|
||||||
// Dump some debugging information to the logs
|
// Dump some debugging information to the logs
|
||||||
|
@ -576,7 +572,7 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
|
||||||
// If the correspondent proposes video while audio call
|
// If the correspondent proposes video while audio call
|
||||||
boolean remoteVideo = call.getRemoteParams().getVideoEnabled();
|
boolean remoteVideo = call.getRemoteParams().getVideoEnabled();
|
||||||
boolean localVideo = call.getCurrentParamsCopy().getVideoEnabled();
|
boolean localVideo = call.getCurrentParamsCopy().getVideoEnabled();
|
||||||
boolean autoAcceptCameraPolicy = LinphoneManager.getInstance().isAutoAcceptCamera();
|
boolean autoAcceptCameraPolicy = LinphonePreferences.instance().shouldAutomaticallyAcceptVideoRequests();
|
||||||
if (remoteVideo && !localVideo && !autoAcceptCameraPolicy && !LinphoneManager.getLc().isInConference()) {
|
if (remoteVideo && !localVideo && !autoAcceptCameraPolicy && !LinphoneManager.getLc().isInConference()) {
|
||||||
try {
|
try {
|
||||||
LinphoneManager.getLc().deferCallUpdate(call);
|
LinphoneManager.getLc().deferCallUpdate(call);
|
||||||
|
@ -616,14 +612,11 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
|
||||||
}
|
}
|
||||||
|
|
||||||
public void changeRingtone(String ringtone) {
|
public void changeRingtone(String ringtone) {
|
||||||
SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(this).edit();
|
LinphonePreferences.instance().setRingtone(ringtone);
|
||||||
editor.putString(getString(R.string.pref_audio_ringtone), ringtone);
|
|
||||||
editor.commit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onRingerPlayerCreated(MediaPlayer mRingerPlayer) {
|
public void onRingerPlayerCreated(MediaPlayer mRingerPlayer) {
|
||||||
String uriString = PreferenceManager.getDefaultSharedPreferences(this).getString(getString(R.string.pref_audio_ringtone),
|
String uriString = LinphonePreferences.instance().getRingtone(android.provider.Settings.System.DEFAULT_RINGTONE_URI.toString());
|
||||||
android.provider.Settings.System.DEFAULT_RINGTONE_URI.toString());
|
|
||||||
try {
|
try {
|
||||||
if (uriString.startsWith("content://")) {
|
if (uriString.startsWith("content://")) {
|
||||||
mRingerPlayer.setDataSource(this, Uri.parse(uriString));
|
mRingerPlayer.setDataSource(this, Uri.parse(uriString));
|
||||||
|
|
|
@ -50,7 +50,6 @@ import org.linphone.ui.PreferencesListFragment;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.preference.CheckBoxPreference;
|
import android.preference.CheckBoxPreference;
|
||||||
|
@ -160,9 +159,6 @@ public class PreferencesFragment extends PreferencesListFragment implements EcCa
|
||||||
|
|
||||||
initializePreferredVideoSizePreferences();
|
initializePreferredVideoSizePreferences();
|
||||||
|
|
||||||
if (prefs().getBoolean(LinphoneActivity.PREF_FIRST_LAUNCH,true)) {
|
|
||||||
doOnFirstLaunch();
|
|
||||||
}
|
|
||||||
if (Hacks.hasBuiltInEchoCanceller()) {
|
if (Hacks.hasBuiltInEchoCanceller()) {
|
||||||
uncheckDisableAndHideCheckbox(R.string.pref_echo_cancellation_key);
|
uncheckDisableAndHideCheckbox(R.string.pref_echo_cancellation_key);
|
||||||
findPreference(R.string.pref_echo_canceller_calibration_key).setLayoutResource(R.layout.hidden);
|
findPreference(R.string.pref_echo_canceller_calibration_key).setLayoutResource(R.layout.hidden);
|
||||||
|
@ -275,9 +271,8 @@ public class PreferencesFragment extends PreferencesListFragment implements EcCa
|
||||||
addAccount.setTitle(getString(R.string.pref_add_account));
|
addAccount.setTitle(getString(R.string.pref_add_account));
|
||||||
addAccount.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
addAccount.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
SharedPreferences prefs = getPreferenceManager().getSharedPreferences();
|
nbAccounts = LinphonePreferences.instance().getAccountCount();
|
||||||
nbAccounts = prefs.getInt(getString(R.string.pref_extra_accounts), 0);
|
LinphonePreferences.instance().setAccountCount(nbAccounts + 1);
|
||||||
prefs.edit().putInt(getString(R.string.pref_extra_accounts), nbAccounts+1).commit();
|
|
||||||
|
|
||||||
addExtraAccountPreferencesButton(accounts, nbAccounts, true);
|
addExtraAccountPreferencesButton(accounts, nbAccounts, true);
|
||||||
LinphoneActivity.instance().displayAccountSettings(nbAccounts);
|
LinphoneActivity.instance().displayAccountSettings(nbAccounts);
|
||||||
|
@ -293,10 +288,6 @@ public class PreferencesFragment extends PreferencesListFragment implements EcCa
|
||||||
p.setLayoutResource(R.layout.hidden);
|
p.setLayoutResource(R.layout.hidden);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doOnFirstLaunch() {
|
|
||||||
prefs().edit().putBoolean(LinphoneActivity.PREF_FIRST_LAUNCH, false).commit();
|
|
||||||
}
|
|
||||||
|
|
||||||
private synchronized void startEcCalibration() {
|
private synchronized void startEcCalibration() {
|
||||||
try {
|
try {
|
||||||
LinphoneManager.getInstance().startEcCalibration(this);
|
LinphoneManager.getInstance().startEcCalibration(this);
|
||||||
|
@ -341,18 +332,9 @@ public class PreferencesFragment extends PreferencesListFragment implements EcCa
|
||||||
Preference box = findPreference(key);
|
Preference box = findPreference(key);
|
||||||
box.setEnabled(enabled);
|
box.setEnabled(enabled);
|
||||||
Compatibility.setPreferenceChecked(box, value);
|
Compatibility.setPreferenceChecked(box, value);
|
||||||
writeBoolean(key, value);
|
|
||||||
if (hidden) box.setLayoutResource(R.layout.hidden);
|
if (hidden) box.setLayoutResource(R.layout.hidden);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeBoolean(int key, boolean value) {
|
|
||||||
prefs().edit().putBoolean(getString(key), value).commit();
|
|
||||||
}
|
|
||||||
|
|
||||||
private SharedPreferences prefs() {
|
|
||||||
return getPreferenceManager().getSharedPreferences();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void detectAudioCodec(int id, String mime, int rate, int channels, boolean hide) {
|
private void detectAudioCodec(int id, String mime, int rate, int channels, boolean hide) {
|
||||||
Log.w("Payload type for codec " + mime + " = " + LinphoneManager.getLc().findPayloadType(mime, rate, channels));
|
Log.w("Payload type for codec " + mime + " = " + LinphoneManager.getLc().findPayloadType(mime, rate, channels));
|
||||||
boolean enable = LinphoneService.isReady() && LinphoneManager.getLc().findPayloadType(mime, rate, channels)!=null;
|
boolean enable = LinphoneService.isReady() && LinphoneManager.getLc().findPayloadType(mime, rate, channels)!=null;
|
||||||
|
@ -372,8 +354,7 @@ public class PreferencesFragment extends PreferencesListFragment implements EcCa
|
||||||
accounts.removeAll();
|
accounts.removeAll();
|
||||||
|
|
||||||
// Get already configured extra accounts
|
// Get already configured extra accounts
|
||||||
SharedPreferences prefs = getPreferenceManager().getSharedPreferences();
|
nbAccounts = LinphonePreferences.instance().getAccountCount();
|
||||||
nbAccounts = prefs.getInt(getString(R.string.pref_extra_accounts), 0);
|
|
||||||
for (int i = 0; i < nbAccounts; i++) {
|
for (int i = 0; i < nbAccounts; i++) {
|
||||||
// For each, add menus to configure it
|
// For each, add menus to configure it
|
||||||
addExtraAccountPreferencesButton(accounts, i, false);
|
addExtraAccountPreferencesButton(accounts, i, false);
|
||||||
|
@ -385,30 +366,20 @@ public class PreferencesFragment extends PreferencesListFragment implements EcCa
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addExtraAccountPreferencesButton(PreferenceCategory parent, final int n, boolean isNewAccount) {
|
private void addExtraAccountPreferencesButton(PreferenceCategory parent, final int n, boolean isNewAccount) {
|
||||||
SharedPreferences prefs = getPreferenceManager().getSharedPreferences();
|
|
||||||
if (isNewAccount) {
|
if (isNewAccount) {
|
||||||
SharedPreferences.Editor editor = prefs.edit();
|
LinphonePreferences.instance().setAccountCount(n+1);
|
||||||
editor.putInt(getString(R.string.pref_extra_accounts), n+1);
|
|
||||||
editor.commit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final LedPreference me = new LedPreference(mContext);
|
final LedPreference led = new LedPreference(mContext);
|
||||||
String keyUsername = getString(R.string.pref_username_key);
|
String username = LinphonePreferences.instance().getAccountUsername(n);
|
||||||
String keyDomain = getString(R.string.pref_domain_key);
|
String domain = LinphonePreferences.instance().getAccountDomain(n);
|
||||||
if (n > 0) {
|
|
||||||
keyUsername += n + "";
|
|
||||||
keyDomain += n + "";
|
|
||||||
}
|
|
||||||
|
|
||||||
String username = prefs.getString(keyUsername, "");
|
|
||||||
String domain = prefs.getString(keyDomain, "");
|
|
||||||
if (username == null) {
|
if (username == null) {
|
||||||
me.setTitle(getString(R.string.pref_sipaccount));
|
led.setTitle(getString(R.string.pref_sipaccount));
|
||||||
} else {
|
} else {
|
||||||
me.setTitle(username + "@" + domain);
|
led.setTitle(username + "@" + domain);
|
||||||
}
|
}
|
||||||
|
|
||||||
me.setOnPreferenceClickListener(new OnPreferenceClickListener()
|
led.setOnPreferenceClickListener(new OnPreferenceClickListener()
|
||||||
{
|
{
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
LinphoneActivity.instance().displayAccountSettings(n);
|
LinphoneActivity.instance().displayAccountSettings(n);
|
||||||
|
@ -416,8 +387,8 @@ public class PreferencesFragment extends PreferencesListFragment implements EcCa
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
updateAccountLed(me, username, domain);
|
updateAccountLed(led, username, domain);
|
||||||
parent.addPreference(me);
|
parent.addPreference(led);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateAccountLed(final LedPreference me, final String username, final String domain) {
|
private void updateAccountLed(final LedPreference me, final String username, final String domain) {
|
||||||
|
|
|
@ -7,71 +7,54 @@ import org.linphone.LinphoneManager.EcCalibrationListener;
|
||||||
import org.linphone.core.LinphoneCore;
|
import org.linphone.core.LinphoneCore;
|
||||||
import org.linphone.core.LinphoneCore.EcCalibratorStatus;
|
import org.linphone.core.LinphoneCore.EcCalibratorStatus;
|
||||||
import org.linphone.core.LinphoneCore.MediaEncryption;
|
import org.linphone.core.LinphoneCore.MediaEncryption;
|
||||||
import org.linphone.mediastream.Log;
|
|
||||||
import org.linphone.ui.PreferencesListFragment;
|
import org.linphone.ui.PreferencesListFragment;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.preference.CheckBoxPreference;
|
||||||
import android.preference.ListPreference;
|
import android.preference.ListPreference;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.preference.PreferenceCategory;
|
import android.preference.Preference.OnPreferenceClickListener;
|
||||||
import android.preference.Preference.OnPreferenceChangeListener;
|
|
||||||
import android.preference.PreferenceScreen;
|
|
||||||
|
|
||||||
public class SettingsFragment extends PreferencesListFragment implements EcCalibrationListener {
|
public class SettingsFragment extends PreferencesListFragment implements EcCalibrationListener {
|
||||||
private LinphonePreferences mPrefs;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onEcCalibrationStatus(EcCalibratorStatus status, int delayMs) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public SettingsFragment() {
|
public SettingsFragment() {
|
||||||
super(R.xml.settings);
|
super(R.xml.preferences);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle bundle) {
|
public void onCreate(Bundle bundle) {
|
||||||
super.onCreate(bundle);
|
super.onCreate(bundle);
|
||||||
PreferenceScreen screen = getPreferenceScreen();
|
|
||||||
|
|
||||||
mPrefs = LinphonePreferences.getInstance();
|
// Init the settings page interface
|
||||||
mPrefs.load();
|
initSettings();
|
||||||
|
hideSettings();
|
||||||
// Init some settings
|
setListeners();
|
||||||
initMediaEncryptionPreference((ListPreference) screen.findPreference(getString(R.string.lpconfig_sip_media_enc_key)));
|
|
||||||
|
|
||||||
// Sets default values and value change listener for each of them
|
|
||||||
setListenerForPreference(screen);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setListenerForPreference(Preference pref) {
|
// Inits the values or the listener on some settings
|
||||||
// FIXME: first display doesn't match the linphonerc values
|
private void initSettings() {
|
||||||
|
initMediaEncryptionPreference((ListPreference) findPreference(getString(R.string.pref_media_encryption_key)));
|
||||||
|
initializeTransportPreferences((ListPreference) findPreference(getString(R.string.pref_transport_key)));
|
||||||
|
|
||||||
if (pref.hasKey()) {
|
// Add action on About button
|
||||||
pref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
findPreference(getString(R.string.menu_about_key)).setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
Log.w("New value for preference key " + preference.getKey() + ":" + newValue.toString());
|
if (LinphoneActivity.isInstanciated()) {
|
||||||
mPrefs.set(preference.getKey(), newValue.toString());
|
LinphoneActivity.instance().displayAbout();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
if (pref instanceof PreferenceCategory) {
|
// Disable sip port choice if port is random
|
||||||
PreferenceCategory cat = (PreferenceCategory) pref;
|
findPreference(getString(R.string.pref_sip_port_key)).setEnabled(!((CheckBoxPreference)findPreference(getString(R.string.pref_transport_use_random_ports_key))).isChecked());
|
||||||
int count = cat.getPreferenceCount();
|
|
||||||
for (int i = 0; i < count; i++) {
|
|
||||||
Preference p = cat.getPreference(i);
|
|
||||||
setListenerForPreference(p);
|
|
||||||
}
|
|
||||||
} else if (pref instanceof PreferenceScreen) {
|
|
||||||
PreferenceScreen screen = (PreferenceScreen) pref;
|
|
||||||
int count = screen.getPreferenceCount();
|
|
||||||
for (int i = 0; i < count; i++) {
|
|
||||||
Preference p = screen.getPreference(i);
|
|
||||||
setListenerForPreference(p);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Read the values set in resources and hides the settings accordingly
|
||||||
|
private void hideSettings() {
|
||||||
|
if (!getResources().getBoolean(R.bool.display_about_in_settings)) {
|
||||||
|
findPreference(getString(R.string.menu_about_key)).setLayoutResource(R.layout.hidden);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,18 +64,13 @@ public class SettingsFragment extends PreferencesListFragment implements EcCalib
|
||||||
lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
} catch (Exception e) {}
|
} catch (Exception e) {}
|
||||||
|
|
||||||
List<CharSequence> mencEntries=new ArrayList<CharSequence>();
|
List<CharSequence> mencEntries = new ArrayList<CharSequence>();
|
||||||
List<CharSequence> mencEntryValues=new ArrayList<CharSequence>();
|
List<CharSequence> mencEntryValues = new ArrayList<CharSequence>();
|
||||||
mencEntries.add(getString(R.string.media_encryption_none));
|
mencEntries.add(getString(R.string.media_encryption_none));
|
||||||
mencEntryValues.add(getString(R.string.pref_media_encryption_key_none));
|
mencEntryValues.add(getString(R.string.pref_media_encryption_key_none));
|
||||||
|
|
||||||
if (lc == null || getResources().getBoolean(R.bool.disable_all_security_features_for_markets)) {
|
if (lc == null || getResources().getBoolean(R.bool.disable_all_security_features_for_markets)) {
|
||||||
CharSequence[] contents = new CharSequence[mencEntries.size()];
|
setListPreferenceValues(pref, mencEntries, mencEntryValues);
|
||||||
mencEntries.toArray(contents);
|
|
||||||
pref.setEntries(contents);
|
|
||||||
contents = new CharSequence[mencEntryValues.size()];
|
|
||||||
mencEntryValues.toArray(contents);
|
|
||||||
pref.setEntryValues(contents);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,18 +87,49 @@ public class SettingsFragment extends PreferencesListFragment implements EcCalib
|
||||||
mencEntries.add(getString(R.string.media_encryption_zrtp));
|
mencEntries.add(getString(R.string.media_encryption_zrtp));
|
||||||
mencEntryValues.add(getString(R.string.pref_media_encryption_key_zrtp));
|
mencEntryValues.add(getString(R.string.pref_media_encryption_key_zrtp));
|
||||||
}
|
}
|
||||||
CharSequence[] contents=new CharSequence[mencEntries.size()];
|
setListPreferenceValues(pref, mencEntries, mencEntryValues);
|
||||||
mencEntries.toArray(contents);
|
|
||||||
pref.setEntries(contents);
|
|
||||||
contents=new CharSequence[mencEntryValues.size()];
|
|
||||||
mencEntryValues.toArray(contents);
|
|
||||||
pref.setEntryValues(contents);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void initializeTransportPreferences(ListPreference pref) {
|
||||||
|
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));
|
||||||
|
|
||||||
|
if (!getResources().getBoolean(R.bool.disable_all_security_features_for_markets)) {
|
||||||
|
mencEntries.add(getString(R.string.pref_transport_tls));
|
||||||
|
mencEntryValues.add(getString(R.string.pref_transport_tls_key));
|
||||||
|
}
|
||||||
|
setListPreferenceValues(pref, mencEntries, mencEntryValues);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void setListPreferenceValues(ListPreference pref, List<CharSequence> entries, List<CharSequence> values) {
|
||||||
|
CharSequence[] contents = new CharSequence[entries.size()];
|
||||||
|
entries.toArray(contents);
|
||||||
|
pref.setEntries(contents);
|
||||||
|
contents = new CharSequence[values.size()];
|
||||||
|
values.toArray(contents);
|
||||||
|
pref.setEntryValues(contents);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setListeners() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onEcCalibrationStatus(EcCalibratorStatus status, int delayMs) {
|
||||||
LinphonePreferences.getInstance().save();
|
|
||||||
super.onDestroy();
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
|
||||||
|
if (LinphoneActivity.isInstanciated()) {
|
||||||
|
LinphoneActivity.instance().selectMenu(FragmentsAvailable.SETTINGS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,10 +38,8 @@ import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
|
@ -485,13 +483,9 @@ public class StatusFragment extends Fragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
class AccountsListAdapter extends BaseAdapter {
|
class AccountsListAdapter extends BaseAdapter {
|
||||||
private SharedPreferences prefs;
|
|
||||||
private List<CheckBox> checkboxes;
|
private List<CheckBox> checkboxes;
|
||||||
|
|
||||||
AccountsListAdapter() {
|
AccountsListAdapter() {
|
||||||
if (LinphoneActivity.isInstanciated()) {
|
|
||||||
prefs = PreferenceManager.getDefaultSharedPreferences(LinphoneActivity.instance());
|
|
||||||
}
|
|
||||||
checkboxes = new ArrayList<CheckBox>();
|
checkboxes = new ArrayList<CheckBox>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -501,23 +495,16 @@ public class StatusFragment extends Fragment {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
CheckBox checkBox = (CheckBox) v;
|
CheckBox checkBox = (CheckBox) v;
|
||||||
if (checkBox.isChecked()) {
|
if (checkBox.isChecked()) {
|
||||||
SharedPreferences.Editor editor = prefs.edit();
|
|
||||||
String tag = (String) checkBox.getTag();
|
String tag = (String) checkBox.getTag();
|
||||||
String sipAddress = tag.split(":")[0];
|
String sipAddress = tag.split(":")[0];
|
||||||
int accountPosition = Integer.parseInt(tag.split(":")[1]);
|
int accountPosition = Integer.parseInt(tag.split(":")[1]);
|
||||||
|
|
||||||
int nbAccounts = prefs.getInt(getString(R.string.pref_extra_accounts), 0);
|
int nbAccounts = LinphonePreferences.instance().getAccountCount();
|
||||||
int accountIndex = 0;
|
int accountIndex = 0;
|
||||||
for (int i = 0; i < nbAccounts; i++)
|
for (int i = 0; i < nbAccounts; i++)
|
||||||
{
|
{
|
||||||
String keyUsername = getString(R.string.pref_username_key);
|
String username = LinphonePreferences.instance().getAccountUsername(i);
|
||||||
String keyDomain = getString(R.string.pref_domain_key);
|
String domain = LinphonePreferences.instance().getAccountDomain(i);
|
||||||
if (i > 0) {
|
|
||||||
keyUsername += i + "";
|
|
||||||
keyDomain += i + "";
|
|
||||||
}
|
|
||||||
String username = prefs.getString(keyUsername, "");
|
|
||||||
String domain = prefs.getString(keyDomain, "");
|
|
||||||
String identity = username + "@" + domain;
|
String identity = username + "@" + domain;
|
||||||
if (identity.equals(sipAddress)) {
|
if (identity.equals(sipAddress)) {
|
||||||
accountIndex = i;
|
accountIndex = i;
|
||||||
|
@ -525,8 +512,7 @@ public class StatusFragment extends Fragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
editor.putInt(getString(R.string.pref_default_account_key), accountIndex);
|
LinphonePreferences.instance().setDefaultAccount(accountIndex);
|
||||||
editor.commit();
|
|
||||||
|
|
||||||
for (CheckBox cb : checkboxes) {
|
for (CheckBox cb : checkboxes) {
|
||||||
cb.setChecked(false);
|
cb.setChecked(false);
|
||||||
|
@ -590,35 +576,25 @@ public class StatusFragment extends Fragment {
|
||||||
isDefault.setChecked(false);
|
isDefault.setChecked(false);
|
||||||
isDefault.setEnabled(true);
|
isDefault.setEnabled(true);
|
||||||
|
|
||||||
if (prefs != null) {
|
int nbAccounts = LinphonePreferences.instance().getAccountCount();
|
||||||
int nbAccounts = prefs.getInt(getString(R.string.pref_extra_accounts), 0);
|
|
||||||
int accountIndex = 0;
|
int accountIndex = 0;
|
||||||
for (int i = 0; i < nbAccounts; i++)
|
for (int i = 0; i < nbAccounts; i++)
|
||||||
{
|
{
|
||||||
String keyUsername = getString(R.string.pref_username_key);
|
String username = LinphonePreferences.instance().getAccountUsername(i);
|
||||||
String keyDomain = getString(R.string.pref_domain_key);
|
String domain = LinphonePreferences.instance().getAccountDomain(i);
|
||||||
if (i > 0) {
|
|
||||||
keyUsername += i + "";
|
|
||||||
keyDomain += i + "";
|
|
||||||
}
|
|
||||||
String username = prefs.getString(keyUsername, "");
|
|
||||||
String domain = prefs.getString(keyDomain, "");
|
|
||||||
String id = username + "@" + domain;
|
String id = username + "@" + domain;
|
||||||
if (id.equals(sipAddress)) {
|
if (id.equals(sipAddress)) {
|
||||||
accountIndex = i;
|
accountIndex = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (prefs.getInt(getString(R.string.pref_default_account_key), 0) == accountIndex) {
|
if (LinphonePreferences.instance().getDefaultAccountIndex() == accountIndex) {
|
||||||
isDefault.setChecked(true);
|
isDefault.setChecked(true);
|
||||||
isDefault.setEnabled(false);
|
isDefault.setEnabled(false);
|
||||||
status.setImageResource(getStatusIconResource(lpc.getState(), true));
|
status.setImageResource(getStatusIconResource(lpc.getState(), true));
|
||||||
} else {
|
} else {
|
||||||
status.setImageResource(getStatusIconResource(lpc.getState(), false));
|
status.setImageResource(getStatusIconResource(lpc.getState(), false));
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
status.setImageResource(getStatusIconResource(lpc.getState(), false));
|
|
||||||
}
|
|
||||||
|
|
||||||
isDefault.setOnClickListener(defaultListener);
|
isDefault.setOnClickListener(defaultListener);
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
package org.linphone.compatibility;
|
package org.linphone.compatibility;
|
||||||
|
|
||||||
|
import org.linphone.LinphonePreferences;
|
||||||
import org.linphone.R;
|
import org.linphone.R;
|
||||||
import org.linphone.mediastream.Log;
|
import org.linphone.mediastream.Log;
|
||||||
|
|
||||||
import android.annotation.TargetApi;
|
import android.annotation.TargetApi;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
import android.view.Display;
|
import android.view.Display;
|
||||||
|
|
||||||
import com.google.android.gcm.GCMRegistrar;
|
import com.google.android.gcm.GCMRegistrar;
|
||||||
|
@ -40,28 +39,21 @@ public class ApiEightPlus {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void initPushNotificationService(Context context) {
|
public static void initPushNotificationService(Context context) {
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Starting the push notification service
|
// Starting the push notification service
|
||||||
GCMRegistrar.checkDevice(context);
|
GCMRegistrar.checkDevice(context);
|
||||||
GCMRegistrar.checkManifest(context);
|
GCMRegistrar.checkManifest(context);
|
||||||
final String regId = GCMRegistrar.getRegistrationId(context);
|
final String regId = GCMRegistrar.getRegistrationId(context);
|
||||||
String newPushSenderID = context.getString(R.string.push_sender_id);
|
String newPushSenderID = context.getString(R.string.push_sender_id);
|
||||||
String currentPushSenderID = prefs.getString(context.getString(R.string.push_sender_id_key), null);
|
String currentPushSenderID = LinphonePreferences.instance().getPushNotificationRegistrationID();
|
||||||
if (regId.equals("") || currentPushSenderID == null || !currentPushSenderID.equals(newPushSenderID)) {
|
if (regId.equals("") || currentPushSenderID == null || !currentPushSenderID.equals(newPushSenderID)) {
|
||||||
GCMRegistrar.register(context, newPushSenderID);
|
GCMRegistrar.register(context, newPushSenderID);
|
||||||
|
|
||||||
Log.d("Push Notification : storing current sender id = " + newPushSenderID);
|
Log.d("Push Notification : storing current sender id = " + newPushSenderID);
|
||||||
SharedPreferences.Editor editor = prefs.edit();
|
LinphonePreferences.instance().setPushNotificationRegistrationID(newPushSenderID);
|
||||||
editor.putString(context.getString(R.string.push_sender_id_key), newPushSenderID);
|
|
||||||
|
|
||||||
editor.commit();
|
|
||||||
} else {
|
} else {
|
||||||
Log.d("Push Notification : already registered with id = " + regId);
|
Log.d("Push Notification : already registered with id = " + regId);
|
||||||
SharedPreferences.Editor editor = prefs.edit();
|
LinphonePreferences.instance().setPushNotificationRegistrationID(regId);
|
||||||
editor.putString(context.getString(R.string.push_reg_id_key), regId);
|
|
||||||
editor.commit();
|
|
||||||
}
|
}
|
||||||
} catch (java.lang.UnsupportedOperationException e) {
|
} catch (java.lang.UnsupportedOperationException e) {
|
||||||
Log.i("Push Notification not activated");
|
Log.i("Push Notification not activated");
|
||||||
|
|
|
@ -19,14 +19,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.linphone.LinphoneManager;
|
import org.linphone.LinphoneManager;
|
||||||
|
import org.linphone.LinphonePreferences;
|
||||||
import org.linphone.R;
|
import org.linphone.R;
|
||||||
import org.linphone.core.LinphoneCoreException;
|
|
||||||
import org.linphone.mediastream.Log;
|
import org.linphone.mediastream.Log;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
|
|
||||||
import com.google.android.gcm.GCMBaseIntentService;
|
import com.google.android.gcm.GCMBaseIntentService;
|
||||||
|
|
||||||
|
@ -57,27 +55,13 @@ public class GCMService extends GCMBaseIntentService {
|
||||||
@Override
|
@Override
|
||||||
protected void onRegistered(Context context, String regId) {
|
protected void onRegistered(Context context, String regId) {
|
||||||
Log.d("Registered push notification : " + regId);
|
Log.d("Registered push notification : " + regId);
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
LinphonePreferences.instance().setPushNotificationRegistrationID(regId);
|
||||||
SharedPreferences.Editor editor = prefs.edit();
|
|
||||||
editor.putString(context.getString(R.string.push_reg_id_key), regId);
|
|
||||||
editor.commit();
|
|
||||||
|
|
||||||
if (LinphoneManager.isInstanciated()) {
|
|
||||||
try {
|
|
||||||
LinphoneManager.getInstance().initAccounts();
|
|
||||||
} catch (LinphoneCoreException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onUnregistered(Context context, String regId) {
|
protected void onUnregistered(Context context, String regId) {
|
||||||
Log.w("Unregistered push notification : " + regId);
|
Log.w("Unregistered push notification : " + regId);
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
LinphonePreferences.instance().setPushNotificationRegistrationID(null);
|
||||||
SharedPreferences.Editor editor = prefs.edit();
|
|
||||||
editor.putString(context.getString(R.string.push_reg_id_key), null);
|
|
||||||
editor.commit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String[] getSenderIds(Context context) {
|
protected String[] getSenderIds(Context context) {
|
||||||
|
|
|
@ -18,10 +18,10 @@ 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 org.linphone.LinphoneManager;
|
import org.linphone.LinphoneManager;
|
||||||
|
import org.linphone.LinphonePreferences;
|
||||||
import org.linphone.LinphoneSimpleListener.LinphoneOnRegistrationStateChangedListener;
|
import org.linphone.LinphoneSimpleListener.LinphoneOnRegistrationStateChangedListener;
|
||||||
import org.linphone.R;
|
import org.linphone.R;
|
||||||
import org.linphone.core.LinphoneCore.RegistrationState;
|
import org.linphone.core.LinphoneCore.RegistrationState;
|
||||||
import org.linphone.mediastream.Log;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
@ -115,6 +115,7 @@ public class SetupActivity extends FragmentActivity implements OnClickListener {
|
||||||
setResult(Activity.RESULT_CANCELED);
|
setResult(Activity.RESULT_CANCELED);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
LinphonePreferences.instance().firstLaunchSuccessful();
|
||||||
} else if (id == R.id.setup_next) {
|
} else if (id == R.id.setup_next) {
|
||||||
if (firstFragment == SetupFragmentsEnum.LINPHONE_LOGIN) {
|
if (firstFragment == SetupFragmentsEnum.LINPHONE_LOGIN) {
|
||||||
LinphoneLoginFragment linphoneFragment = (LinphoneLoginFragment) fragment;
|
LinphoneLoginFragment linphoneFragment = (LinphoneLoginFragment) fragment;
|
||||||
|
@ -145,6 +146,7 @@ public class SetupActivity extends FragmentActivity implements OnClickListener {
|
||||||
setResult(Activity.RESULT_CANCELED);
|
setResult(Activity.RESULT_CANCELED);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
LinphonePreferences.instance().firstLaunchSuccessful();
|
||||||
}
|
}
|
||||||
if (currentFragment == SetupFragmentsEnum.MENU) {
|
if (currentFragment == SetupFragmentsEnum.MENU) {
|
||||||
WelcomeFragment fragment = new WelcomeFragment();
|
WelcomeFragment fragment = new WelcomeFragment();
|
||||||
|
@ -184,14 +186,6 @@ public class SetupActivity extends FragmentActivity implements OnClickListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
saveCreatedAccount(username, password, domain);
|
saveCreatedAccount(username, password, domain);
|
||||||
LinphoneManager.getInstance().initializePayloads();
|
|
||||||
|
|
||||||
try {
|
|
||||||
LinphoneManager.getInstance().initFromConf();
|
|
||||||
} catch (Throwable e) {
|
|
||||||
Log.e(e, "Error while initializing from config in first login activity");
|
|
||||||
Toast.makeText(this, getString(R.string.error), Toast.LENGTH_LONG).show();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (LinphoneManager.getLc().getDefaultProxyConfig() != null) {
|
if (LinphoneManager.getLc().getDefaultProxyConfig() != null) {
|
||||||
launchEchoCancellerCalibration(sendEcCalibrationResult);
|
launchEchoCancellerCalibration(sendEcCalibrationResult);
|
||||||
|
@ -227,17 +221,6 @@ public class SetupActivity extends FragmentActivity implements OnClickListener {
|
||||||
LinphoneManager.addListener(registrationListener);
|
LinphoneManager.addListener(registrationListener);
|
||||||
|
|
||||||
saveCreatedAccount(username, password, domain);
|
saveCreatedAccount(username, password, domain);
|
||||||
LinphoneManager.getInstance().initializePayloads();
|
|
||||||
|
|
||||||
try {
|
|
||||||
LinphoneManager.getInstance().initFromConf();
|
|
||||||
} catch (Throwable e) {
|
|
||||||
LinphoneManager.removeListener(registrationListener);
|
|
||||||
deleteCreatedAccount();
|
|
||||||
|
|
||||||
Log.e(e, "Error while initializing from config in first login activity");
|
|
||||||
Toast.makeText(this, getString(R.string.error), Toast.LENGTH_LONG).show();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void linphoneLogIn(String username, String password, boolean validate) {
|
public void linphoneLogIn(String username, String password, boolean validate) {
|
||||||
|
@ -375,16 +358,6 @@ public class SetupActivity extends FragmentActivity implements OnClickListener {
|
||||||
|
|
||||||
public void isAccountVerified() {
|
public void isAccountVerified() {
|
||||||
Toast.makeText(this, getString(R.string.setup_account_validated), Toast.LENGTH_LONG).show();
|
Toast.makeText(this, getString(R.string.setup_account_validated), Toast.LENGTH_LONG).show();
|
||||||
|
|
||||||
LinphoneManager.getInstance().initializePayloads();
|
|
||||||
|
|
||||||
try {
|
|
||||||
LinphoneManager.getInstance().initFromConf();
|
|
||||||
} catch (Throwable e) {
|
|
||||||
Log.e(e, "Error while initializing from config in first login activity");
|
|
||||||
Toast.makeText(this, getString(R.string.error), Toast.LENGTH_LONG).show();
|
|
||||||
}
|
|
||||||
|
|
||||||
launchEchoCancellerCalibration(true);
|
launchEchoCancellerCalibration(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit b8453d1bc16ab5bac06255bc8467bed0c60bcc3a
|
Subproject commit 13442d397b8a8e5c8c95bb525fa0491d0ad1599b
|
Loading…
Reference in a new issue