Improved settings for API > 14 + some changes on History new list

This commit is contained in:
Sylvain Berfini 2012-08-09 15:46:41 +02:00
parent 72c0af5937
commit 735ce7389d
20 changed files with 554 additions and 100 deletions

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@color/main_app_color" />
<item
android:drawable="@color/transparent" />
</selector>

View file

@ -75,4 +75,5 @@
android:src="@drawable/chat_send_message" />
</LinearLayout>
</LinearLayout>

View file

@ -45,6 +45,7 @@
<ListView
android:id="@+id/chatList"
android:listSelector="@drawable/list_selector"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="@android:color/darker_gray"

View file

@ -75,8 +75,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:stretchColumns="*"
android:paddingTop="20dp">
</TableLayout>
android:paddingTop="20dp"/>
</ScrollView>

View file

@ -48,6 +48,7 @@
<ListView
android:id="@+id/contactsList"
android:listSelector="@drawable/list_selector"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="@android:color/darker_gray"

View file

@ -55,6 +55,7 @@
<ExpandableListView
android:id="@+id/historyList"
android:listSelector="@drawable/list_selector"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="@android:color/darker_gray"

View file

@ -60,6 +60,8 @@
<ListView
android:id="@android:id/list"
android:listSelector="@drawable/list_selector"
android:cacheColorHint="@color/transparent"
android:layout_above="@id/mark"
android:layout_width="match_parent"
android:layout_height="match_parent" />

View file

@ -1,8 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="main_app_color">#ffcf4c29</color>
<color name="numpad_background_bottom">#ffe4edf2</color>
<color name="numpad_background_dialer">#ffd8d8d8</color>
<color name="numpad_background_top">#ffb1bdc3</color>
<color name="nmissed_calls_background">#ffcf4c29</color>
<color name="transparent">#00000000</color>
</resources>

View file

@ -3,6 +3,8 @@
<!-- Do not translate any of the strings below -->
<string name="pref_disable_account_key">pref_disable_account_key</string>
<string name="pref_extra_accounts">pref_nb_accounts_extra</string>
<string name="pref_default_account_key">pref_default_account</string>
<string name="pref_tunnel_key">pref_tunnel_key</string>
<string name="pref_tunnel_mode_key">pref_tunnel_mode_key</string>

View file

@ -117,7 +117,7 @@
<string name="filter_contacts">Filter contacts</string>
<string name="title_numbers_dialog">%s\'s phone numbers</string>
<string name="pref_delete_account">Delete this account</string>
<string name="pref_default_account_title">Use as default</string>
<string name="pref_default_account">Use as default</string>
<string name="pref_echo_canceller_calibration">Echo canceller calibration</string>
<string name="pref_echo_limiter">Echo limiter</string>
<string name="pref_video_use_front_camera_title">Use front camera</string>
@ -235,10 +235,7 @@
<string name="dynamic_video_accept">Accept video</string>
<string name="dynamic_video_deny">Deny video</string>
<string name="pref_extra_accounts">pref_nb_accounts_extra</string>
<string name="pref_default_account">pref_default_account</string>
<string name="pref_sipaccounts">SIP Accounts</string>
<string name="pref_wifi_only">Use wifi only</string>
<string name="pref_use_bluetooth_if_available">Use bluetooth headset</string>
<string name="pref_use_bluetooth_if_available_summary">Route incoming audio to bluetooth headset if available.</string>

View file

@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:title="@string/pref_sipaccount">
<EditTextPreference
android:title="@string/pref_username"
android:dialogMessage="@string/pref_help_username"
android:persistent="true"/>
<EditTextPreference
android:title="@string/pref_passwd"
android:persistent="true"/>
<EditTextPreference
android:title="@string/pref_domain"
android:dialogMessage="@string/pref_help_domain"
android:persistent="true"/>
</PreferenceCategory>
<PreferenceCategory
android:title="@string/pref_advanced">
<EditTextPreference
android:title="@string/pref_proxy"
android:summary="@string/pref_help_proxy"
android:persistent="true"/>
<SwitchPreference
android:switchTextOn="@string/yes"
android:switchTextOff="@string/no"
android:title="@string/pref_enable_outbound_proxy"
android:dialogMessage="@string/pref_help_outbound_proxy"
android:summary="@string/pref_help_outbound_proxy"
android:persistent="true"/>
<SwitchPreference
android:switchTextOn="@string/yes"
android:switchTextOff="@string/no"
android:title="@string/pref_disable_account"
android:persistent="true"/>
<SwitchPreference
android:switchTextOn="@string/yes"
android:switchTextOff="@string/no"
android:title="@string/pref_default_account"
android:persistent="true"/>
<Preference
android:title="@string/pref_delete_account"
android:persistent="true"/>
</PreferenceCategory>
</PreferenceScreen>

331
res/xml-v14/preferences.xml Normal file
View file

@ -0,0 +1,331 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<Preference
android:title="@string/menu_exit"/>
<PreferenceCategory
android:title="@string/pref_sipaccounts"/>
<Preference
android:title="@string/setup_title"/>
<PreferenceCategory
android:key="@string/pref_tunnel_key"
android:title="@string/pref_tunnel">
<EditTextPreference
android:title="@string/pref_tunnel_host"
android:key="@string/pref_tunnel_host_key"/>
<EditTextPreference
android:title="@string/pref_tunnel_port"
android:key="@string/pref_tunnel_port_key"
android:defaultValue="443"/>
<ListPreference
android:title="@string/pref_tunnel_mode"
android:entries="@array/tunnel_mode_entries"
android:entryValues="@array/tunnel_mode_entry_values"
android:defaultValue="@string/default_tunnel_mode_entry_value"
android:key="@string/pref_tunnel_mode_key" />
</PreferenceCategory>
<PreferenceCategory
android:title="@string/pref_preferences">
<SwitchPreference
android:title="@string/pref_autostart"
android:key="@string/pref_autostart_key"
android:switchTextOn="@string/yes"
android:switchTextOff="@string/no"
android:defaultValue="false"/>
<SwitchPreference
android:defaultValue="true"
android:title="@string/pref_video_enable_title"
android:switchTextOn="@string/yes"
android:switchTextOff="@string/no"
android:key="@string/pref_video_enable_key" />
<EditTextPreference
android:title="@string/pref_stun_server"
android:key="@string/pref_stun_server_key"/>
</PreferenceCategory>
<PreferenceCategory
android:title="@string/pref_audio">
<SwitchPreference
android:key="@string/pref_use_bluetooth_if_available_key"
android:defaultValue="true"
android:switchTextOn="@string/yes"
android:switchTextOff="@string/no"
android:title="@string/pref_use_bluetooth_if_available"
android:summary="@string/pref_use_bluetooth_if_available_summary"/>
<CheckBoxPreference
android:key="@string/pref_echo_limiter_key"
android:title="@string/pref_echo_limiter"
android:summary="@string/pref_echo_limiter_summary"/>
<CheckBoxPreference
android:key="@string/pref_echo_cancellation_key"
android:defaultValue="false"
android:title="@string/pref_echo_cancellation"
android:summary="@string/pref_echo_cancellation_summary"/>
<CheckBoxPreference
android:key="@string/pref_echo_canceller_calibration_key"
android:title="@string/pref_echo_canceller_calibration" />
<PreferenceScreen
android:title="@string/pref_codecs"
android:key="@string/pref_codecs_key">
<SwitchPreference
android:switchTextOn="@string/yes"
android:switchTextOff="@string/no"
android:key="@string/pref_codec_speex16_key"
android:title="@string/pref_codec_speex16"/>
<SwitchPreference
android:switchTextOn="@string/yes"
android:switchTextOff="@string/no"
android:key="@string/pref_codec_speex8_key"
android:title="@string/pref_codec_speex8"/>
<SwitchPreference
android:switchTextOn="@string/yes"
android:switchTextOff="@string/no"
android:key="@string/pref_codec_ilbc_key"
android:title="@string/pref_codec_ilbc"
android:shouldDisableView="true"
android:summary="@string/pref_ilbc_summary"/>
<SwitchPreference
android:switchTextOn="@string/yes"
android:switchTextOff="@string/no"
android:key="@string/pref_codec_amr_key"
android:title="@string/pref_codec_amr"
android:defaultValue="true"
android:shouldDisableView="true" />
<SwitchPreference
android:switchTextOn="@string/yes"
android:switchTextOff="@string/no"
android:key="@string/pref_codec_g729_key"
android:title="@string/pref_codec_g729"
android:defaultValue="true"
android:shouldDisableView="true" />
<SwitchPreference
android:switchTextOn="@string/yes"
android:switchTextOff="@string/no"
android:key="@string/pref_codec_amrwb_key"
android:title="@string/pref_codec_amrwb"
android:defaultValue="true"
android:shouldDisableView="true" />
<SwitchPreference
android:switchTextOn="@string/yes"
android:switchTextOff="@string/no"
android:key="@string/pref_codec_gsm_key"
android:title="@string/pref_codec_gsm"/>
<SwitchPreference
android:switchTextOn="@string/yes"
android:switchTextOff="@string/no"
android:key="@string/pref_codec_g722_key"
android:defaultValue="false"
android:title="@string/pref_codec_g722"/>
<SwitchPreference
android:switchTextOn="@string/yes"
android:switchTextOff="@string/no"
android:key="@string/pref_codec_silk24_key"
android:title="@string/pref_codec_silk24"/>
<SwitchPreference
android:switchTextOn="@string/yes"
android:switchTextOff="@string/no"
android:key="@string/pref_codec_silk16_key"
android:title="@string/pref_codec_silk16"/>
<SwitchPreference
android:switchTextOn="@string/yes"
android:switchTextOff="@string/no"
android:key="@string/pref_codec_pcmu_key"
android:title="@string/pref_codec_pcmu"/>
<SwitchPreference
android:switchTextOn="@string/yes"
android:switchTextOff="@string/no"
android:key="@string/pref_codec_pcma_key"
android:title="@string/pref_codec_pcma"/>
</PreferenceScreen>
</PreferenceCategory>
<PreferenceCategory
android:title="@string/pref_video"
android:dependency="@string/pref_video_enable_key"
android:shouldDisableView="true">
<SwitchPreference
android:switchTextOn="@string/yes"
android:switchTextOff="@string/no"
android:key="@string/pref_video_use_front_camera_key"
android:title="@string/pref_video_use_front_camera_title"
android:dependency="@string/pref_video_enable_key"/>
<SwitchPreference
android:switchTextOn="@string/yes"
android:switchTextOff="@string/no"
android:key="@string/pref_video_initiate_call_with_video_key"
android:defaultValue="true"
android:title="@string/pref_video_initiate_call_with_video_title"
android:summary="@string/pref_video_initiate_call_with_video"
android:dependency="@string/pref_video_enable_key"/>
<SwitchPreference
android:switchTextOn="@string/yes"
android:switchTextOff="@string/no"
android:key="@string/pref_video_automatically_share_my_video_key"
android:title="@string/pref_video_automatically_share_my_video_title"
android:defaultValue="true" android:summary="@string/pref_video_automatically_share_my_video"
android:dependency="@string/pref_video_enable_key"/>
<SwitchPreference
android:switchTextOn="@string/yes"
android:switchTextOff="@string/no"
android:key="@string/pref_video_automatically_accept_video_key"
android:title="@string/pref_video_automatically_accept_video_title"
android:defaultValue="true" android:summary="@string/pref_video_automatically_accept_video"
android:dependency="@string/pref_video_enable_key"/>
<PreferenceScreen
android:dependency="@string/pref_video_enable_key"
android:shouldDisableView="true"
android:key="@string/pref_video_codecs_key"
android:title="@string/pref_video_codecs_title">
<SwitchPreference
android:switchTextOn="@string/yes"
android:switchTextOff="@string/no"
android:key="@string/pref_video_codec_vp8_key"
android:title="@string/pref_video_codec_vp8_title"
android:defaultValue="true"/>
<SwitchPreference
android:switchTextOn="@string/yes"
android:switchTextOff="@string/no"
android:key="@string/pref_video_codec_h264_key"
android:title="@string/pref_video_codec_h264_title"
android:defaultValue="false"/>
<SwitchPreference
android:switchTextOn="@string/yes"
android:switchTextOff="@string/no"
android:key="@string/pref_video_codec_mpeg4_key"
android:title="@string/pref_video_codec_mpeg4_title"
android:defaultValue="false"/>
<SwitchPreference
android:switchTextOn="@string/yes"
android:switchTextOff="@string/no"
android:key="@string/pref_video_codec_h263_key"
android:title="@string/pref_video_codec_h263_title"
android:defaultValue="false" android:layout="@layout/hidden"/>
</PreferenceScreen>
</PreferenceCategory>
<PreferenceCategory
android:title="@string/pref_advanced">
<EditTextPreference
android:title="@string/pref_prefix"
android:key="@string/pref_prefix_key"></EditTextPreference>
<SwitchPreference
android:switchTextOn="@string/yes"
android:switchTextOff="@string/no"
android:key="@string/pref_escape_plus_key"
android:title="@string/pref_escape_plus"/>
<SwitchPreference
android:switchTextOn="@string/yes"
android:switchTextOff="@string/no"
android:key="@string/pref_debug_key"
android:title="@string/pref_debug" android:enabled="true"/>
<PreferenceScreen
android:title="@string/pref_network_title">
<SwitchPreference
android:switchTextOn="@string/yes"
android:switchTextOff="@string/no"
android:key="@string/pref_ipv6_key"
android:title="@string/pref_ipv6_title"
android:defaultValue="false" />
<CheckBoxPreference
android:key="@string/pref_transport_udp_key"
android:title="@string/pref_transport_udp"
android:defaultValue="true"/>
<CheckBoxPreference
android:key="@string/pref_transport_tcp_key"
android:title="@string/pref_transport_tcp" />
<CheckBoxPreference
android:key="@string/pref_transport_tls_key"
android:title="@string/pref_transport_tls" />
<SwitchPreference
android:switchTextOn="@string/yes"
android:switchTextOff="@string/no"
android:key="@string/pref_transport_use_standard_ports_key"
android:title="@string/pref_transport_use_standard_ports"/>
<SwitchPreference
android:switchTextOn="@string/yes"
android:switchTextOff="@string/no"
android:key="@string/pref_wifi_only_key"
android:title="@string/pref_wifi_only"/>
</PreferenceScreen>
<ListPreference
android:title="@string/pref_media_encryption"
android:key="@string/pref_media_encryption_key"
android:defaultValue="@string/pref_media_encryption_key_none" />
<PreferenceScreen
android:title="@string/pref_audio_hacks_title"
android:layout="@layout/hidden">
<CheckBoxPreference
android:key="@string/pref_audio_hacks_use_routing_api_key"
android:title="@string/pref_audio_hacks_use_routing_api_title" />
<CheckBoxPreference
android:key="@string/pref_audio_hacks_use_galaxys_hack_key"
android:title="@string/pref_audio_hacks_use_galaxys_hack_title" />
<EditTextPreference
android:key="@string/pref_audio_use_specific_mode_key"
android:title="@string/pref_audio_use_specific_mode_title"
android:summary="@string/pref_audio_use_specific_mode_summary"
android:defaultValue="0" android:numeric="integer" />
</PreferenceScreen>
</PreferenceCategory>
</PreferenceScreen>

View file

@ -1,4 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
</PreferenceScreen>
<PreferenceCategory
android:title="@string/pref_sipaccount">
<EditTextPreference
android:title="@string/pref_username"
android:dialogMessage="@string/pref_help_username"
android:persistent="true"/>
<EditTextPreference
android:title="@string/pref_passwd"
android:persistent="true"/>
<EditTextPreference
android:title="@string/pref_domain"
android:dialogMessage="@string/pref_help_domain"
android:persistent="true"/>
</PreferenceCategory>
<PreferenceCategory
android:title="@string/pref_advanced">
<EditTextPreference
android:title="@string/pref_proxy"
android:summary="@string/pref_help_proxy"
android:persistent="true"/>
<CheckBoxPreference
android:title="@string/pref_enable_outbound_proxy"
android:persistent="true"/>
<CheckBoxPreference
android:title="@string/pref_disable_account"
android:persistent="true"/>
<CheckBoxPreference
android:title="@string/pref_default_account"
android:persistent="true"/>
<Preference
android:title="@string/pref_delete_account"
android:persistent="true"/>
</PreferenceCategory>
</PreferenceScreen>

View file

@ -3,23 +3,7 @@
<Preference android:title="@string/menu_exit"></Preference>
<PreferenceCategory android:title="@string/pref_sipaccounts">
<!--<EditTextPreference android:title="@string/pref_username"
android:key="@string/pref_username_key" android:inputType="text|textEmailAddress"></EditTextPreference>
<EditTextPreference android:title="@string/pref_passwd"
android:key="@string/pref_passwd_key" android:password="true"></EditTextPreference>
<EditTextPreference android:title="@string/pref_domain"
android:key="@string/pref_domain_key" android:inputType="text|textEmailAddress"></EditTextPreference>
<EditTextPreference android:title="@string/pref_proxy"
android:key="@string/pref_proxy_key" android:inputType="text|textEmailAddress"></EditTextPreference>
<CheckBoxPreference android:enabled="true"
android:selectable="true" android:key="@string/pref_enable_outbound_proxy_key"
android:title="@string/pref_enable_outbound_proxy"></CheckBoxPreference>-->
</PreferenceCategory>
<PreferenceCategory android:title="@string/pref_sipaccounts"></PreferenceCategory>
<Preference android:title="@string/setup_title"></Preference>

View file

@ -18,9 +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.
*/
import org.linphone.compatibility.Compatibility;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.EditTextPreference;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
@ -41,7 +42,7 @@ public class AccountPreferencesActivity extends LinphonePreferencesActivity {
PreferenceScreen screen = getPreferenceScreen();
int n = getIntent().getExtras().getInt("Account", 1);
addExtraAccountPreferencesFields(screen, n);
manageAccountPreferencesFields(screen, n);
}
OnPreferenceChangeListener preferenceChangedListener = new OnPreferenceChangeListener() {
@ -52,50 +53,48 @@ public class AccountPreferencesActivity extends LinphonePreferencesActivity {
}
};
private void addExtraAccountPreferencesFields(PreferenceScreen parent, final int n) {
private void manageAccountPreferencesFields(PreferenceScreen parent, final int n) {
final SharedPreferences prefs = getPreferenceManager().getSharedPreferences();
EditTextPreference username = new EditTextPreference(this);
PreferenceCategory account = (PreferenceCategory) getPreferenceScreen().getPreference(0);
EditTextPreference username = (EditTextPreference) account.getPreference(0);
username.setText(prefs.getString(getString(R.string.pref_username_key) + getAccountNumber(n), ""));
username.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
username.setTitle(getString(R.string.pref_username));
username.setPersistent(true);
username.setDialogMessage(getString(R.string.pref_help_username));
username.setKey(getString(R.string.pref_username_key) + getAccountNumber(n));
username.setOnPreferenceChangeListener(preferenceChangedListener);
username.setSummary(username.getText());
EditTextPreference password = new EditTextPreference(this);
EditTextPreference password = (EditTextPreference) account.getPreference(1);
password.setText(prefs.getString(getString(R.string.pref_passwd_key) + getAccountNumber(n), ""));
password.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
password.setTitle(getString(R.string.pref_passwd));
password.setPersistent(true);
password.setKey(getString(R.string.pref_passwd_key) + getAccountNumber(n));
EditTextPreference domain = new EditTextPreference(this);
EditTextPreference domain = (EditTextPreference) account.getPreference(2);
domain.setText(prefs.getString(getString(R.string.pref_domain_key) + getAccountNumber(n), ""));
domain.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
domain.setTitle(getString(R.string.pref_domain));
domain.setPersistent(true);
domain.setDialogMessage(getString(R.string.pref_help_domain));
domain.setKey(getString(R.string.pref_domain_key) + getAccountNumber(n));
domain.setOnPreferenceChangeListener(preferenceChangedListener);
EditTextPreference proxy = new EditTextPreference(this);
domain.setSummary(domain.getText());
PreferenceCategory advanced = (PreferenceCategory) getPreferenceScreen().getPreference(1);
EditTextPreference proxy = (EditTextPreference) advanced.getPreference(0);
proxy.setText(prefs.getString(getString(R.string.pref_proxy_key) + getAccountNumber(n), ""));
proxy.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
proxy.setTitle(getString(R.string.pref_proxy));
proxy.setPersistent(true);
proxy.setKey(getString(R.string.pref_proxy_key) + getAccountNumber(n));
proxy.setOnPreferenceChangeListener(preferenceChangedListener);
proxy.setSummary("".equals(proxy.getText()) || (proxy.getText() == null) ? getString(R.string.pref_help_proxy) : proxy.getText());
CheckBoxPreference outboundProxy = new CheckBoxPreference(this);
outboundProxy.setTitle(getString(R.string.pref_enable_outbound_proxy));
outboundProxy.setPersistent(true);
Preference outboundProxy = advanced.getPreference(1);
Compatibility.setPreferenceChecked(outboundProxy, prefs.getBoolean(getString(R.string.pref_enable_outbound_proxy_key) + getAccountNumber(n), false));
outboundProxy.setKey(getString(R.string.pref_enable_outbound_proxy_key) + getAccountNumber(n));
final CheckBoxPreference disable = new CheckBoxPreference(this);
disable.setTitle(getString(R.string.pref_disable_account));
disable.setPersistent(true);
final Preference disable = advanced.getPreference(2);
disable.setEnabled(prefs.getInt(getString(R.string.pref_default_account), 0) != n);
Compatibility.setPreferenceChecked(outboundProxy, prefs.getBoolean(getString(R.string.pref_disable_account_key) + getAccountNumber(n), false));
disable.setKey(getString(R.string.pref_disable_account_key) + getAccountNumber(n));
final Preference delete = new Preference(this);
delete.setTitle(R.string.pref_delete_account);
final Preference delete = advanced.getPreference(4);
delete.setEnabled(prefs.getInt(getString(R.string.pref_default_account), 0) != n);
delete.setOnPreferenceClickListener(new OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) {
int nbAccounts = prefs.getInt(getString(R.string.pref_extra_accounts), 1);
@ -130,48 +129,23 @@ public class AccountPreferencesActivity extends LinphonePreferencesActivity {
}
});
CheckBoxPreference mainAccount = new CheckBoxPreference(this);
mainAccount.setTitle(R.string.pref_default_account_title);
Preference mainAccount = advanced.getPreference(3);
Compatibility.setPreferenceChecked(mainAccount, prefs.getInt(getString(R.string.pref_default_account), 0) == n);
mainAccount.setEnabled(!Compatibility.isPreferenceChecked(mainAccount));
mainAccount.setOnPreferenceClickListener(new OnPreferenceClickListener()
{
public boolean onPreferenceClick(Preference preference) {
SharedPreferences.Editor editor = prefs.edit();
editor.putInt(getString(R.string.pref_default_account), n);
editor.putInt(getString(R.string.pref_default_account_key), n);
editor.commit();
delete.setEnabled(false);
disable.setEnabled(false);
disable.setChecked(false);
Compatibility.setPreferenceChecked(disable, false);
preference.setEnabled(false);
return true;
}
});
mainAccount.setChecked(prefs.getInt(getString(R.string.pref_default_account), 0) == n);
mainAccount.setEnabled(!mainAccount.isChecked());
delete.setEnabled(prefs.getInt(getString(R.string.pref_default_account), 0) != n);
disable.setEnabled(prefs.getInt(getString(R.string.pref_default_account), 0) != n);
PreferenceCategory category = new PreferenceCategory(this);
category.setTitle(getString(R.string.pref_sipaccount));
parent.addPreference(category);
category.addPreference(username);
category.addPreference(password);
category.addPreference(domain);
category = new PreferenceCategory(this);
category.setTitle(getString(R.string.pref_advanced));
parent.addPreference(category);
category.addPreference(proxy);
category.addPreference(outboundProxy);
category.addPreference(disable);
category.addPreference(mainAccount);
category.addPreference(delete);
username.setSummary(username.getText());
domain.setSummary(domain.getText());
proxy.setSummary("".equals(proxy.getText()) || (proxy.getText() == null) ? getString(R.string.pref_help_proxy) : proxy.getText());
outboundProxy.setSummary(getString(R.string.pref_help_outbound_proxy));
}
private String getAccountNumber(int n) {

View file

@ -87,9 +87,9 @@ public class HistoryFragment extends Fragment implements OnClickListener, OnChil
if (LinphoneActivity.isInstanciated())
LinphoneActivity.instance().selectMenu(FragmentsAvailable.HISTORY);
List<LinphoneCallLog> logs = Arrays.asList(LinphoneManager.getLc().getCallLogs());
initLogsLists(logs);
initLogsLists(Arrays.asList(LinphoneManager.getLc().getCallLogs()));
historyList.setAdapter(new CallHistoryAdapter(getActivity()));
expandAllGroups();
}
private void initLogsLists(List<LinphoneCallLog> logs) {
@ -131,19 +131,6 @@ public class HistoryFragment extends Fragment implements OnClickListener, OnChil
}
}
private void collapseAllGroups() {
mHandler.post(new Runnable() {
@Override
public void run() {
for (int groupToCollapse = 0; groupToCollapse < historyList.getExpandableListAdapter().getGroupCount(); groupToCollapse++) {
if (historyList.isGroupExpanded(groupToCollapse)) {
historyList.collapseGroup(groupToCollapse);
}
}
}
});
}
private void expandAllGroups() {
mHandler.post(new Runnable() {
@Override
@ -216,10 +203,7 @@ public class HistoryFragment extends Fragment implements OnClickListener, OnChil
}
historyList.setAdapter(new CallHistoryAdapter(getActivity().getApplicationContext()));
if (id == R.id.ok) {
collapseAllGroups();
}
else if (id == R.id.edit) {
if (id != R.id.ok) {
expandAllGroups();
}
}

View file

@ -382,7 +382,7 @@ public class StatusFragment extends Fragment {
ImageView status = (ImageView) view.findViewById(R.id.State);
TextView identity = (TextView) view.findViewById(R.id.Identity);
String sipAddress = lpc.getIdentity().startsWith("sip:") ? lpc.getIdentity().split("sip:")[1] : lpc.getIdentity();
String sipAddress = (lpc.getIdentity() != null && lpc.getIdentity().startsWith("sip:")) ? lpc.getIdentity().split("sip:")[1] : lpc.getIdentity();
identity.setText(sipAddress);
CheckBox isDefault = (CheckBox) view.findViewById(R.id.Default);

View file

@ -24,6 +24,8 @@ import android.database.Cursor;
import android.database.MatrixCursor;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.preference.CheckBoxPreference;
import android.preference.Preference;
import android.provider.ContactsContract;
import android.provider.ContactsContract.CommonDataKinds;
import android.provider.ContactsContract.CommonDataKinds.Phone;
@ -343,4 +345,12 @@ public class ApiFivePlus {
public static void setNotificationLatestEventInfo(Notification notif, Context context, String title, String content, PendingIntent intent) {
notif.setLatestEventInfo(context, title, content, intent);
}
public static void setPreferenceChecked(Preference preference, boolean checked) {
((CheckBoxPreference) preference).setChecked(checked);
}
public static boolean isPreferenceChecked(Preference preference) {
return ((CheckBoxPreference) preference).isChecked();
}
}

View file

@ -0,0 +1,38 @@
package org.linphone.compatibility;
import android.annotation.TargetApi;
import android.preference.Preference;
import android.preference.SwitchPreference;
/*
ApiFourteenPlus.java
Copyright (C) 2012 Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/**
* @author Sylvain Berfini
*/
@TargetApi(8)
public class ApiFourteenPlus {
public static void setPreferenceChecked(Preference preference, boolean checked) {
((SwitchPreference) preference).setChecked(checked);
}
public static boolean isPreferenceChecked(Preference preference) {
return ((SwitchPreference) preference).isChecked();
}
}

View file

@ -34,6 +34,7 @@ import android.database.Cursor;
import android.graphics.Bitmap;
import android.media.AudioManager;
import android.net.Uri;
import android.preference.Preference;
import android.view.Display;
/**
* @author Sylvain Berfini
@ -185,4 +186,20 @@ public class Compatibility {
}
return false;
}
public static void setPreferenceChecked(Preference preference, boolean checked) {
if (Version.sdkAboveOrEqual(8)) {
ApiFourteenPlus.setPreferenceChecked(preference, checked);
} else {
ApiFivePlus.setPreferenceChecked(preference, checked);
}
}
public static boolean isPreferenceChecked(Preference preference) {
if (Version.sdkAboveOrEqual(8)) {
return ApiFourteenPlus.isPreferenceChecked(preference);
} else {
return ApiFivePlus.isPreferenceChecked(preference);
}
}
}