Bad layout for preferences fixed
This commit is contained in:
parent
ca74953104
commit
56b23e3c20
8 changed files with 28 additions and 1016 deletions
|
@ -77,17 +77,6 @@
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity android:name=".AccountPreferencesActivity"
|
|
||||||
android:theme="@style/NoTitle">
|
|
||||||
</activity>
|
|
||||||
|
|
||||||
<activity android:name=".PreferencesActivity"
|
|
||||||
android:theme="@style/NoTitle">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN" />
|
|
||||||
</intent-filter>
|
|
||||||
</activity>
|
|
||||||
|
|
||||||
<activity android:name=".setup.SetupActivity"
|
<activity android:name=".setup.SetupActivity"
|
||||||
android:theme="@style/NoTitle"
|
android:theme="@style/NoTitle"
|
||||||
|
|
|
@ -1,183 +1,15 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/topLayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<!-- Hack to adjust perfectly on every screen the bottom of the fragment with the curved menu -->
|
<ListView
|
||||||
<LinearLayout
|
android:id="@+id/list"
|
||||||
android:id="@+id/mark"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:drawSelectorOnTop="false"
|
||||||
android:layout_alignParentBottom="true"
|
android:cacheColorHint="@color/transparent"
|
||||||
android:orientation="horizontal">
|
android:scrollbarAlwaysDrawVerticalTrack="true" />
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="0.2"
|
|
||||||
android:adjustViewBounds="true"
|
|
||||||
android:scaleType="fitXY"
|
|
||||||
android:src="@drawable/mark"
|
|
||||||
android:visibility="invisible" />
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="0.2"
|
|
||||||
android:adjustViewBounds="true"
|
|
||||||
android:scaleType="fitXY"
|
|
||||||
android:src="@drawable/mark"
|
|
||||||
android:visibility="invisible" />
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="0.2"
|
|
||||||
android:adjustViewBounds="true"
|
|
||||||
android:scaleType="fitXY"
|
|
||||||
android:src="@drawable/mark"
|
|
||||||
android:visibility="invisible" />
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="0.2"
|
|
||||||
android:adjustViewBounds="true"
|
|
||||||
android:scaleType="fitXY"
|
|
||||||
android:src="@drawable/mark"
|
|
||||||
android:visibility="invisible" />
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="0.2"
|
|
||||||
android:adjustViewBounds="true"
|
|
||||||
android:scaleType="fitXY"
|
|
||||||
android:src="@drawable/mark"
|
|
||||||
android:visibility="invisible" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<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" />
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/menu"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_alignParentBottom="true"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<RelativeLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="0.2">
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/history"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:adjustViewBounds="true"
|
|
||||||
android:contentDescription="@string/content_description_history"
|
|
||||||
android:scaleType="fitXY"
|
|
||||||
android:src="@drawable/history" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/missedCalls"
|
|
||||||
android:layout_width="25dp"
|
|
||||||
android:layout_height="25dp"
|
|
||||||
android:layout_alignParentRight="true"
|
|
||||||
android:layout_alignParentTop="true"
|
|
||||||
android:background="@drawable/missed_calls_bg"
|
|
||||||
android:gravity="center"
|
|
||||||
android:textSize="20dp"
|
|
||||||
android:visibility="gone" />
|
|
||||||
</RelativeLayout>
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/contacts"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="0.2"
|
|
||||||
android:adjustViewBounds="true"
|
|
||||||
android:contentDescription="@string/content_description_contacts"
|
|
||||||
android:scaleType="fitXY"
|
|
||||||
android:src="@drawable/contacts" />
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/dialer"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="0.2"
|
|
||||||
android:adjustViewBounds="true"
|
|
||||||
android:contentDescription="@string/content_description_dialer"
|
|
||||||
android:scaleType="fitXY"
|
|
||||||
android:src="@drawable/dialer" />
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/settings"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="0.2"
|
|
||||||
android:adjustViewBounds="true"
|
|
||||||
android:contentDescription="@string/content_description_settings"
|
|
||||||
android:scaleType="fitXY"
|
|
||||||
android:src="@drawable/settings" />
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/about_settings"
|
|
||||||
android:visibility="gone"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="0.2"
|
|
||||||
android:adjustViewBounds="true"
|
|
||||||
android:contentDescription="@string/content_description_about"
|
|
||||||
android:scaleType="fitXY"
|
|
||||||
android:src="@drawable/about_settings" />
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/about_chat"
|
|
||||||
android:visibility="gone"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="0.2"
|
|
||||||
android:adjustViewBounds="true"
|
|
||||||
android:contentDescription="@string/content_description_about"
|
|
||||||
android:scaleType="fitXY"
|
|
||||||
android:src="@drawable/about_chat" />
|
|
||||||
|
|
||||||
<RelativeLayout
|
|
||||||
android:id="@+id/completeChat"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="0.2">
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/chat"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:adjustViewBounds="true"
|
|
||||||
android:contentDescription="@string/content_description_chat"
|
|
||||||
android:scaleType="fitXY"
|
|
||||||
android:src="@drawable/chat" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/missedChats"
|
|
||||||
android:layout_width="25dp"
|
|
||||||
android:layout_height="25dp"
|
|
||||||
android:layout_alignParentRight="true"
|
|
||||||
android:layout_alignParentTop="true"
|
|
||||||
android:background="@drawable/missed_calls_bg"
|
|
||||||
android:gravity="center"
|
|
||||||
android:textSize="20dp"
|
|
||||||
android:visibility="gone" />
|
|
||||||
</RelativeLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
|
@ -1,157 +0,0 @@
|
||||||
package org.linphone;
|
|
||||||
/*
|
|
||||||
LinphonePreferencesSIPAccountActivity.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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import org.linphone.compatibility.Compatibility;
|
|
||||||
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.preference.EditTextPreference;
|
|
||||||
import android.preference.Preference;
|
|
||||||
import android.preference.Preference.OnPreferenceChangeListener;
|
|
||||||
import android.preference.Preference.OnPreferenceClickListener;
|
|
||||||
import android.preference.PreferenceCategory;
|
|
||||||
import android.preference.PreferenceScreen;
|
|
||||||
import android.text.InputType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Sylvain Berfini
|
|
||||||
*/
|
|
||||||
public class AccountPreferencesActivity extends LinphonePreferencesActivity {
|
|
||||||
|
|
||||||
protected void onCreate(Bundle savedInstanceState)
|
|
||||||
{
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
addPreferencesFromResource(R.xml.account_preferences);
|
|
||||||
|
|
||||||
PreferenceScreen screen = getPreferenceScreen();
|
|
||||||
int n = getIntent().getExtras().getInt("Account", 1);
|
|
||||||
manageAccountPreferencesFields(screen, n);
|
|
||||||
}
|
|
||||||
|
|
||||||
OnPreferenceChangeListener preferenceChangedListener = new OnPreferenceChangeListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
|
||||||
preference.setSummary(newValue.toString());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private void manageAccountPreferencesFields(PreferenceScreen parent, final int n) {
|
|
||||||
final SharedPreferences prefs = getPreferenceManager().getSharedPreferences();
|
|
||||||
|
|
||||||
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.setKey(getString(R.string.pref_username_key) + getAccountNumber(n));
|
|
||||||
username.setOnPreferenceChangeListener(preferenceChangedListener);
|
|
||||||
username.setSummary(username.getText());
|
|
||||||
|
|
||||||
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.setKey(getString(R.string.pref_passwd_key) + getAccountNumber(n));
|
|
||||||
|
|
||||||
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.setKey(getString(R.string.pref_domain_key) + getAccountNumber(n));
|
|
||||||
domain.setOnPreferenceChangeListener(preferenceChangedListener);
|
|
||||||
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.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());
|
|
||||||
|
|
||||||
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 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 = 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);
|
|
||||||
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_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));
|
|
||||||
}
|
|
||||||
|
|
||||||
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), 0);
|
|
||||||
if (defaultAccount > n) {
|
|
||||||
editor.putInt(getString(R.string.pref_default_account), defaultAccount - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
editor.putInt(getString(R.string.pref_extra_accounts), nbAccounts - 1);
|
|
||||||
editor.commit();
|
|
||||||
AccountPreferencesActivity.this.finish();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
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_key), n);
|
|
||||||
editor.commit();
|
|
||||||
delete.setEnabled(false);
|
|
||||||
disable.setEnabled(false);
|
|
||||||
Compatibility.setPreferenceChecked(disable, false);
|
|
||||||
preference.setEnabled(false);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getAccountNumber(int n) {
|
|
||||||
if (n > 0)
|
|
||||||
return Integer.toString(n);
|
|
||||||
else
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -976,8 +976,7 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
||||||
}
|
}
|
||||||
} else if (keyCode == KeyEvent.KEYCODE_BACK && currentFragment == FragmentsAvailable.SETTINGS) {
|
} else if (keyCode == KeyEvent.KEYCODE_BACK && currentFragment == FragmentsAvailable.SETTINGS) {
|
||||||
reloadConfig();
|
reloadConfig();
|
||||||
}
|
} else if (keyCode == KeyEvent.KEYCODE_MENU && statusFragment != null) {
|
||||||
if (keyCode == KeyEvent.KEYCODE_MENU && statusFragment != null) {
|
|
||||||
statusFragment.openOrCloseStatusBar();
|
statusFragment.openOrCloseStatusBar();
|
||||||
}
|
}
|
||||||
return super.onKeyDown(keyCode, event);
|
return super.onKeyDown(keyCode, event);
|
||||||
|
|
|
@ -1,157 +0,0 @@
|
||||||
package org.linphone;
|
|
||||||
/*
|
|
||||||
LinphonePreferencesActivity.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.
|
|
||||||
*/
|
|
||||||
import org.linphone.compatibility.Compatibility;
|
|
||||||
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.preference.PreferenceActivity;
|
|
||||||
import android.view.KeyEvent;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.View.OnClickListener;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Sylvain Berfini
|
|
||||||
*/
|
|
||||||
public class LinphonePreferencesActivity extends PreferenceActivity implements OnClickListener {
|
|
||||||
private ImageView history, contacts, dialer, settings, chat, aboutChat, aboutSettings;
|
|
||||||
private TextView missedCalls;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
|
|
||||||
// Hack to allow custom view in preferences, in this case the bottom menu
|
|
||||||
setContentView(R.layout.settings);
|
|
||||||
|
|
||||||
initButtons();
|
|
||||||
|
|
||||||
int missedCalls = LinphoneManager.getLc().getMissedCallsCount();
|
|
||||||
displayMissedCalls(missedCalls);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initButtons() {
|
|
||||||
history = (ImageView) findViewById(R.id.history);
|
|
||||||
history.setOnClickListener(this);
|
|
||||||
contacts = (ImageView) findViewById(R.id.contacts);
|
|
||||||
contacts.setOnClickListener(this);
|
|
||||||
dialer = (ImageView) findViewById(R.id.dialer);
|
|
||||||
dialer.setOnClickListener(this);
|
|
||||||
dialer.setSelected(true);
|
|
||||||
settings = (ImageView) findViewById(R.id.settings);
|
|
||||||
settings.setOnClickListener(this);
|
|
||||||
chat = (ImageView) findViewById(R.id.chat);
|
|
||||||
chat.setOnClickListener(this);
|
|
||||||
missedCalls = (TextView) findViewById(R.id.missedCalls);
|
|
||||||
aboutChat = (ImageView) findViewById(R.id.about_chat);
|
|
||||||
aboutChat.setOnClickListener(this);
|
|
||||||
aboutSettings = (ImageView) findViewById(R.id.about_settings);
|
|
||||||
aboutSettings.setOnClickListener(this);
|
|
||||||
|
|
||||||
if (getResources().getBoolean(R.bool.replace_chat_by_about)) {
|
|
||||||
chat.setVisibility(View.GONE);
|
|
||||||
findViewById(R.id.completeChat).setVisibility(View.GONE);
|
|
||||||
aboutChat.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
if (getResources().getBoolean(R.bool.replace_settings_by_about)) {
|
|
||||||
settings.setVisibility(View.GONE);
|
|
||||||
aboutSettings.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
history.setSelected(false);
|
|
||||||
contacts.setSelected(false);
|
|
||||||
dialer.setSelected(false);
|
|
||||||
settings.setSelected(true);
|
|
||||||
chat.setSelected(false);
|
|
||||||
aboutChat.setSelected(false);
|
|
||||||
aboutSettings.setSelected(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
int id = v.getId();
|
|
||||||
|
|
||||||
FragmentsAvailable newFragment = FragmentsAvailable.SETTINGS;
|
|
||||||
if (id == R.id.history) {
|
|
||||||
newFragment = FragmentsAvailable.HISTORY;
|
|
||||||
}
|
|
||||||
else if (id == R.id.contacts) {
|
|
||||||
newFragment = FragmentsAvailable.CONTACTS;
|
|
||||||
}
|
|
||||||
else if (id == R.id.dialer) {
|
|
||||||
newFragment = FragmentsAvailable.DIALER;
|
|
||||||
}
|
|
||||||
else if (id == R.id.chat) {
|
|
||||||
newFragment = FragmentsAvailable.CHATLIST;
|
|
||||||
}
|
|
||||||
else if (id == R.id.about_chat) {
|
|
||||||
newFragment = FragmentsAvailable.ABOUT_INSTEAD_OF_CHAT;
|
|
||||||
}
|
|
||||||
else if (id == R.id.about_settings) {
|
|
||||||
newFragment = FragmentsAvailable.ABOUT_INSTEAD_OF_SETTINGS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (newFragment != FragmentsAvailable.SETTINGS) {
|
|
||||||
Intent intent = new Intent();
|
|
||||||
intent.putExtra("FragmentToDisplay", newFragment);
|
|
||||||
setResult(RESULT_FIRST_USER, intent);
|
|
||||||
finishWithCustomAnimation(newFragment);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
|
||||||
|
|
||||||
if (resultCode == RESULT_FIRST_USER) {
|
|
||||||
// If we were on a LinphonePreferences sub activity, and we came back because of a change of tab, we propagate the event
|
|
||||||
setResult(RESULT_FIRST_USER, data);
|
|
||||||
finish();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void displayMissedCalls(final int missedCallsCount) {
|
|
||||||
if (missedCallsCount > 0) {
|
|
||||||
missedCalls.setText(missedCallsCount + "");
|
|
||||||
missedCalls.setVisibility(View.VISIBLE);
|
|
||||||
} else {
|
|
||||||
missedCalls.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void finishWithCustomAnimation(FragmentsAvailable newFragment) {
|
|
||||||
finish();
|
|
||||||
if (FragmentsAvailable.SETTINGS.isRightOf(newFragment)) {
|
|
||||||
Compatibility.overridePendingTransition(this, R.anim.slide_in_left_to_right, R.anim.slide_out_left_to_right);
|
|
||||||
} else {
|
|
||||||
Compatibility.overridePendingTransition(this, R.anim.slide_in_right_to_left, R.anim.slide_out_right_to_left);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
|
||||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
|
||||||
finishWithCustomAnimation(LinphoneActivity.instance().getCurrentFragment());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return super.onKeyDown(keyCode, event);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,502 +0,0 @@
|
||||||
/*
|
|
||||||
PreferencesActivity.java
|
|
||||||
Copyright (C) 2010 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 static org.linphone.R.string.ec_calibrating;
|
|
||||||
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_echo_cancellation_key;
|
|
||||||
import static org.linphone.R.string.pref_echo_canceller_calibration_key;
|
|
||||||
import static org.linphone.R.string.pref_echo_limiter_key;
|
|
||||||
import static org.linphone.R.string.pref_media_encryption_key;
|
|
||||||
import static org.linphone.R.string.pref_video_enable_key;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.linphone.LinphoneManager.EcCalibrationListener;
|
|
||||||
import org.linphone.LinphoneManager.LinphoneConfigException;
|
|
||||||
import org.linphone.compatibility.Compatibility;
|
|
||||||
import org.linphone.core.LinphoneCore;
|
|
||||||
import org.linphone.core.LinphoneCore.EcCalibratorStatus;
|
|
||||||
import org.linphone.core.LinphoneCore.MediaEncryption;
|
|
||||||
import org.linphone.core.LinphoneCore.RegistrationState;
|
|
||||||
import org.linphone.core.LinphoneCoreException;
|
|
||||||
import org.linphone.core.LinphoneProxyConfig;
|
|
||||||
import org.linphone.core.Log;
|
|
||||||
import org.linphone.mediastream.Version;
|
|
||||||
import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration;
|
|
||||||
import org.linphone.mediastream.video.capture.hwconf.Hacks;
|
|
||||||
import org.linphone.setup.SetupActivity;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.Handler;
|
|
||||||
import android.preference.CheckBoxPreference;
|
|
||||||
import android.preference.ListPreference;
|
|
||||||
import android.preference.Preference;
|
|
||||||
import android.preference.Preference.OnPreferenceChangeListener;
|
|
||||||
import android.preference.Preference.OnPreferenceClickListener;
|
|
||||||
import android.preference.PreferenceCategory;
|
|
||||||
import android.preference.PreferenceScreen;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
|
|
||||||
public class PreferencesActivity extends LinphonePreferencesActivity implements EcCalibrationListener {
|
|
||||||
private Handler mHandler = new Handler();
|
|
||||||
private CheckBoxPreference ecCalibratePref;
|
|
||||||
private CheckBoxPreference elPref;
|
|
||||||
private CheckBoxPreference ecPref;
|
|
||||||
private ListPreference mencPref;
|
|
||||||
private int nbAccounts = 1;
|
|
||||||
private PreferenceCategory accounts;
|
|
||||||
|
|
||||||
private static final int ADD_SIP_ACCOUNT = 0x666;
|
|
||||||
private static final int ACCOUNTS_SETTINGS_ID = 1;
|
|
||||||
private static final int WIZARD_SETTINGS_ID = 2;
|
|
||||||
private static final int CAMERA_SETTINGS_ID = 6;
|
|
||||||
private static final int EXIT_SETTINGS_ID = 0;
|
|
||||||
|
|
||||||
private SharedPreferences prefs() {
|
|
||||||
return getPreferenceManager().getSharedPreferences();
|
|
||||||
}
|
|
||||||
|
|
||||||
private CheckBoxPreference findCheckbox(int key) {
|
|
||||||
return (CheckBoxPreference) findPreference(getString(key));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void detectAudioCodec(int id, String mime, int rate, int channels, boolean hide) {
|
|
||||||
boolean enable = LinphoneService.isReady() && LinphoneManager.getLc().findPayloadType(mime, rate, channels)!=null;
|
|
||||||
Preference cb = findPreference(id);
|
|
||||||
cb.setEnabled(enable);
|
|
||||||
if (hide && !enable) {
|
|
||||||
cb.setLayoutResource(R.layout.hidden);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void detectVideoCodec(int id, String mime) {
|
|
||||||
findPreference(id).setEnabled(LinphoneManager.getInstance().detectVideoCodec(mime));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createDynamicAccountsPreferences() {
|
|
||||||
accounts = (PreferenceCategory) getPreferenceScreen().getPreference(ACCOUNTS_SETTINGS_ID);
|
|
||||||
accounts.removeAll();
|
|
||||||
|
|
||||||
// Get already configured extra accounts
|
|
||||||
SharedPreferences prefs = getPreferenceManager().getSharedPreferences();
|
|
||||||
nbAccounts = prefs.getInt(getString(R.string.pref_extra_accounts), 0);
|
|
||||||
for (int i = 0; i < nbAccounts; i++) {
|
|
||||||
// For each, add menus to configure it
|
|
||||||
addExtraAccountPreferencesButton(accounts, i, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getNbAccountsExtra() {
|
|
||||||
return nbAccounts;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addExitButton() {
|
|
||||||
Preference me = (Preference) getPreferenceScreen().getPreference(EXIT_SETTINGS_ID);
|
|
||||||
|
|
||||||
me.setOnPreferenceClickListener(new OnPreferenceClickListener()
|
|
||||||
{
|
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
|
||||||
Intent result = new Intent();
|
|
||||||
result.putExtra("Exit", true);
|
|
||||||
setResult(Activity.RESULT_FIRST_USER, result);
|
|
||||||
finish();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addExtraAccountPreferencesButton(PreferenceCategory parent, final int n, boolean isNewAccount) {
|
|
||||||
final SharedPreferences prefs = getPreferenceManager().getSharedPreferences();
|
|
||||||
if (isNewAccount) {
|
|
||||||
SharedPreferences.Editor editor = prefs.edit();
|
|
||||||
editor.putInt(getString(R.string.pref_extra_accounts), n+1);
|
|
||||||
editor.commit();
|
|
||||||
}
|
|
||||||
|
|
||||||
final Preference me = new Preference(PreferencesActivity.this);
|
|
||||||
String keyUsername = getString(R.string.pref_username_key);
|
|
||||||
String keyDomain = getString(R.string.pref_domain_key);
|
|
||||||
if (n > 0) {
|
|
||||||
keyUsername += n + "";
|
|
||||||
keyDomain += n + "";
|
|
||||||
}
|
|
||||||
if (prefs.getString(keyUsername, null) == null) {
|
|
||||||
me.setTitle(getString(R.string.pref_sipaccount));
|
|
||||||
} else {
|
|
||||||
me.setTitle(prefs.getString(keyUsername, "") + "@" + prefs.getString(keyDomain, ""));
|
|
||||||
}
|
|
||||||
|
|
||||||
me.setOnPreferenceClickListener(new OnPreferenceClickListener()
|
|
||||||
{
|
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
|
||||||
Intent i = new Intent();
|
|
||||||
i.putExtra("Account", n);
|
|
||||||
i.setClass(PreferencesActivity.this, AccountPreferencesActivity.class);
|
|
||||||
startActivityForResult(i, ADD_SIP_ACCOUNT);
|
|
||||||
Compatibility.overridePendingTransition(PreferencesActivity.this, R.anim.slide_in_right_to_left, R.anim.slide_out_right_to_left);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
parent.addPreference(me);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
|
||||||
|
|
||||||
if (requestCode == ADD_SIP_ACCOUNT) {
|
|
||||||
//Verify if last created account is filled
|
|
||||||
SharedPreferences prefs = getPreferenceManager().getSharedPreferences();
|
|
||||||
int n = prefs.getInt(getString(R.string.pref_extra_accounts), 1);
|
|
||||||
String keyUsername = getString(R.string.pref_username_key) + (n-1 == 0 ? "" : Integer.toString(n-1));
|
|
||||||
|
|
||||||
if (prefs.getString(keyUsername, "").equals("")) {
|
|
||||||
//If not, we suppress it to not display a blank field
|
|
||||||
SharedPreferences.Editor editor = prefs.edit();
|
|
||||||
editor.putInt(getString(R.string.pref_extra_accounts), n-1);
|
|
||||||
editor.commit();
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
LinphoneManager.getInstance().initAccounts();
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
createDynamicAccountsPreferences();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addWizardPreferenceButton() {
|
|
||||||
Preference wizard = (Preference) getPreferenceScreen().getPreference(WIZARD_SETTINGS_ID);
|
|
||||||
wizard.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
|
||||||
Intent intent = new Intent(getApplicationContext(), SetupActivity.class);
|
|
||||||
finish();
|
|
||||||
startActivity(intent);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
// Load the preferences from an XML resource
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
addPreferencesFromResource(R.xml.preferences);
|
|
||||||
|
|
||||||
addExitButton();
|
|
||||||
|
|
||||||
if (!getResources().getBoolean(R.bool.hide_accounts)) {
|
|
||||||
createDynamicAccountsPreferences();
|
|
||||||
} else {
|
|
||||||
// Hide category
|
|
||||||
PreferenceCategory accounts = (PreferenceCategory) getPreferenceScreen().getPreference(ACCOUNTS_SETTINGS_ID);
|
|
||||||
accounts.removeAll();
|
|
||||||
accounts.setLayoutResource(R.layout.hidden);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getResources().getBoolean(R.bool.hide_wizard)) {
|
|
||||||
Preference wizard = (Preference) getPreferenceScreen().getPreference(WIZARD_SETTINGS_ID);
|
|
||||||
wizard.setLayoutResource(R.layout.hidden);
|
|
||||||
} else {
|
|
||||||
addWizardPreferenceButton();
|
|
||||||
}
|
|
||||||
|
|
||||||
addTransportChecboxesListener();
|
|
||||||
|
|
||||||
ecCalibratePref = (CheckBoxPreference) findPreference(pref_echo_canceller_calibration_key);
|
|
||||||
ecCalibratePref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
|
||||||
startEcCalibration();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
ecPref = (CheckBoxPreference) findPreference(pref_echo_cancellation_key);
|
|
||||||
elPref = (CheckBoxPreference) findPreference(pref_echo_limiter_key);
|
|
||||||
mencPref = (ListPreference) findPreference(pref_media_encryption_key);
|
|
||||||
|
|
||||||
boolean fastCpu = Version.hasFastCpu();
|
|
||||||
if (fastCpu) {
|
|
||||||
detectAudioCodec(pref_codec_ilbc_key, "iLBC", 8000, 1, false);
|
|
||||||
findPreference(pref_codec_speex16_key).setEnabled(true);
|
|
||||||
//findPreference(pref_codec_speex32_key)).setEnabled(enableIlbc);
|
|
||||||
}
|
|
||||||
findPreference(pref_echo_limiter_key).setEnabled(true);
|
|
||||||
|
|
||||||
initializeMediaEncryptionPreferences();
|
|
||||||
|
|
||||||
detectAudioCodec(pref_codec_amr_key,"AMR", 8000, 1, false);
|
|
||||||
detectAudioCodec(pref_codec_amrwb_key,"AMR-WB", 16000, 1, false);
|
|
||||||
//detectAudioCodec(R.string.pref_codec_silk8_key,"SILK",8000, 1, true);
|
|
||||||
//detectAudioCodec(R.string.pref_codec_silk12_key,"SILK",12000, 1, true);
|
|
||||||
detectAudioCodec(R.string.pref_codec_silk16_key,"SILK",16000, 1, true);
|
|
||||||
detectAudioCodec(R.string.pref_codec_silk24_key,"SILK",24000, 1, true);
|
|
||||||
detectAudioCodec(R.string.pref_codec_g729_key,"G729",8000, 1, true);
|
|
||||||
|
|
||||||
// No video
|
|
||||||
if (!Version.isVideoCapable()) {
|
|
||||||
uncheckAndDisableCheckbox(pref_video_enable_key);
|
|
||||||
} else if (!AndroidCameraConfiguration.hasFrontCamera()) {
|
|
||||||
uncheckDisableAndHideCheckbox(R.string.pref_video_use_front_camera_key);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (prefs().getBoolean(LinphoneActivity.PREF_FIRST_LAUNCH,true)) {
|
|
||||||
doOnFirstLaunch();
|
|
||||||
}
|
|
||||||
if (Hacks.hasBuiltInEchoCanceller()) {
|
|
||||||
uncheckDisableAndHideCheckbox(R.string.pref_echo_limiter_key);
|
|
||||||
uncheckDisableAndHideCheckbox(R.string.pref_echo_cancellation_key);
|
|
||||||
uncheckDisableAndHideCheckbox(R.string.pref_echo_canceller_calibration_key);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
detectVideoCodec(R.string.pref_video_codec_h264_key, "H264");
|
|
||||||
if (!Version.hasNeon())
|
|
||||||
{
|
|
||||||
// Android without neon doesn't support H264
|
|
||||||
findPreference(R.string.pref_video_codec_h264_key).setEnabled(false);
|
|
||||||
findPreference(R.string.pref_video_codec_h264_key).setDefaultValue(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
addEchoPrefsListener();
|
|
||||||
|
|
||||||
if (Hacks.needSoftvolume()) checkAndDisableCheckbox(R.string.pref_audio_hacks_use_galaxys_hack_key);
|
|
||||||
|
|
||||||
if (!LinphoneManager.getLc().isTunnelAvailable()){
|
|
||||||
hidePreferenceCategory(R.string.pref_tunnel_key);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getResources().getBoolean(R.bool.hide_camera_settings)) {
|
|
||||||
PreferenceScreen screen = getPreferenceScreen();
|
|
||||||
PreferenceCategory videoSettings = (PreferenceCategory) screen.getPreference(CAMERA_SETTINGS_ID);
|
|
||||||
videoSettings.removeAll();
|
|
||||||
videoSettings.setLayoutResource(R.layout.hidden);
|
|
||||||
|
|
||||||
Preference enableVideo = findPreference(R.string.pref_video_enable_key);
|
|
||||||
enableVideo.setLayoutResource(R.layout.hidden);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void hidePreferenceCategory(int key) {
|
|
||||||
PreferenceCategory p = (PreferenceCategory) findPreference(key);
|
|
||||||
p.removeAll();
|
|
||||||
p.setLayoutResource(R.layout.hidden);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void doOnFirstLaunch() {
|
|
||||||
manageCheckbox(R.string.pref_echo_limiter_key, !Hacks.hasBuiltInEchoCanceller(), true, false);
|
|
||||||
prefs().edit().putBoolean(LinphoneActivity.PREF_FIRST_LAUNCH, false).commit();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initializeMediaEncryptionPreferences() {
|
|
||||||
LinphoneCore lc=LinphoneManager.getLc();
|
|
||||||
boolean hasZrtp=lc.mediaEncryptionSupported(MediaEncryption.ZRTP);
|
|
||||||
boolean hasSrtp=lc.mediaEncryptionSupported(MediaEncryption.SRTP);
|
|
||||||
if (!hasSrtp && !hasZrtp){
|
|
||||||
mencPref.setEnabled(false);
|
|
||||||
}else{
|
|
||||||
List<CharSequence> mencEntries=new ArrayList<CharSequence>();
|
|
||||||
List<CharSequence> mencEntryValues=new ArrayList<CharSequence>();
|
|
||||||
mencEntries.add(getString(R.string.media_encryption_none));
|
|
||||||
mencEntryValues.add(getString(R.string.pref_media_encryption_key_none));
|
|
||||||
if (hasSrtp){
|
|
||||||
mencEntries.add(getString(R.string.media_encryption_srtp));
|
|
||||||
mencEntryValues.add(getString(R.string.pref_media_encryption_key_srtp));
|
|
||||||
}
|
|
||||||
if (hasZrtp){
|
|
||||||
mencEntries.add(getString(R.string.media_encryption_zrtp));
|
|
||||||
mencEntryValues.add(getString(R.string.pref_media_encryption_key_zrtp));
|
|
||||||
}
|
|
||||||
CharSequence[] contents=new CharSequence[mencEntries.size()];
|
|
||||||
mencEntries.toArray(contents);
|
|
||||||
mencPref.setEntries(contents);
|
|
||||||
contents=new CharSequence[mencEntryValues.size()];
|
|
||||||
mencEntryValues.toArray(contents);
|
|
||||||
mencPref.setEntryValues(contents);
|
|
||||||
mencPref.setDefaultValue(getString(R.string.media_encryption_none));
|
|
||||||
//mencPref.setValueIndex(mencPref.findIndexOfValue(getString(R.string.media_encryption_none)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addEchoPrefsListener(){
|
|
||||||
OnPreferenceChangeListener ec_listener=new OnPreferenceChangeListener(){
|
|
||||||
public boolean onPreferenceChange(Preference arg0, Object newValue) {
|
|
||||||
Boolean val=(Boolean)newValue;
|
|
||||||
if (val){
|
|
||||||
elPref.setChecked(!val);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
OnPreferenceChangeListener el_listener=new OnPreferenceChangeListener(){
|
|
||||||
public boolean onPreferenceChange(Preference arg0, Object newValue) {
|
|
||||||
Boolean val=(Boolean)newValue;
|
|
||||||
if (val){
|
|
||||||
ecPref.setChecked(!val);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
ecPref.setOnPreferenceChangeListener(ec_listener);
|
|
||||||
elPref.setOnPreferenceChangeListener(el_listener);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addTransportChecboxesListener() {
|
|
||||||
|
|
||||||
final List<CheckBoxPreference> checkboxes = Arrays.asList(
|
|
||||||
findCheckbox(R.string.pref_transport_udp_key)
|
|
||||||
,findCheckbox(R.string.pref_transport_tcp_key)
|
|
||||||
,findCheckbox(R.string.pref_transport_tls_key)
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
OnPreferenceChangeListener changedListener = new OnPreferenceChangeListener() {
|
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
|
||||||
if ((Boolean) newValue) {
|
|
||||||
for (CheckBoxPreference p : checkboxes) {
|
|
||||||
if (p == preference) continue;
|
|
||||||
p.setChecked(false);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
for (CheckBoxPreference p : checkboxes) {
|
|
||||||
if (p == preference) continue;
|
|
||||||
if (p.isChecked()) return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
OnPreferenceClickListener clickListener = new OnPreferenceClickListener() {
|
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
|
||||||
// Forbid no protocol selection
|
|
||||||
|
|
||||||
if (((CheckBoxPreference) preference).isChecked()) {
|
|
||||||
// Trying to unckeck
|
|
||||||
for (CheckBoxPreference p : checkboxes) {
|
|
||||||
if (p == preference) continue;
|
|
||||||
if (p.isChecked()) return false;
|
|
||||||
}
|
|
||||||
/*Toast.makeText(LinphonePreferencesActivity.this,
|
|
||||||
getString(R.string.at_least_a_protocol),
|
|
||||||
Toast.LENGTH_SHORT).show();*/
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
for (CheckBoxPreference c : checkboxes) {
|
|
||||||
c.setOnPreferenceChangeListener(changedListener);
|
|
||||||
c.setOnPreferenceClickListener(clickListener);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private synchronized void startEcCalibration() {
|
|
||||||
try {
|
|
||||||
LinphoneManager.getInstance().startEcCalibration(this);
|
|
||||||
|
|
||||||
ecCalibratePref.setSummary(ec_calibrating);
|
|
||||||
ecCalibratePref.getEditor().putBoolean(getString(pref_echo_canceller_calibration_key), false).commit();
|
|
||||||
} catch (LinphoneCoreException e) {
|
|
||||||
Log.w(e, "Cannot calibrate EC");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onEcCalibrationStatus(final EcCalibratorStatus status, final int delayMs) {
|
|
||||||
|
|
||||||
mHandler.post(new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
if (status == EcCalibratorStatus.Done) {
|
|
||||||
ecCalibratePref.setSummary(String.format(getString(R.string.ec_calibrated), delayMs));
|
|
||||||
ecCalibratePref.setChecked(true);
|
|
||||||
|
|
||||||
} else if (status == EcCalibratorStatus.Failed) {
|
|
||||||
ecCalibratePref.setSummary(R.string.failed);
|
|
||||||
ecCalibratePref.setChecked(false);
|
|
||||||
elPref.setChecked(true);
|
|
||||||
ecPref.setChecked(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void uncheckDisableAndHideCheckbox(int key) {
|
|
||||||
manageCheckbox(key, false, false, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void uncheckAndDisableCheckbox(int key) {
|
|
||||||
manageCheckbox(key, false, false, false);
|
|
||||||
}
|
|
||||||
private void checkAndDisableCheckbox(int key) {
|
|
||||||
manageCheckbox(key, true, false, false);
|
|
||||||
}
|
|
||||||
private void manageCheckbox(int key, boolean value, boolean enabled, boolean hidden) {
|
|
||||||
CheckBoxPreference box = (CheckBoxPreference) findPreference(key);
|
|
||||||
box.setEnabled(enabled);
|
|
||||||
box.setChecked(value);
|
|
||||||
writeBoolean(key, value);
|
|
||||||
if (hidden) box.setLayoutResource(R.layout.hidden);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Preference findPreference(int key) {
|
|
||||||
return getPreferenceManager().findPreference(getString(key));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void writeBoolean(int key, boolean value) {
|
|
||||||
prefs().edit().putBoolean(getString(key), value).commit();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPause() {
|
|
||||||
super.onPause();
|
|
||||||
|
|
||||||
if (!isFinishing()) return;
|
|
||||||
|
|
||||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
|
||||||
|
|
||||||
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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -379,12 +379,6 @@ public class PreferencesFragment extends PreferencesListFragment implements EcCa
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refresh() {
|
public void refresh() {
|
||||||
// try {
|
|
||||||
// LinphoneManager.getInstance().initAccounts();
|
|
||||||
// } catch (Exception e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
// }
|
|
||||||
|
|
||||||
createDynamicAccountsPreferences();
|
createDynamicAccountsPreferences();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,7 @@ import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.ViewParent;
|
import android.view.ViewParent;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
|
|
||||||
@SuppressLint("ValidFragment")
|
@SuppressLint("ValidFragment")
|
||||||
public class PreferencesListFragment extends ListFragment {
|
public class PreferencesListFragment extends ListFragment {
|
||||||
|
@ -74,8 +75,19 @@ public class PreferencesListFragment extends ListFragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle b) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle b) {
|
||||||
|
// Hack to correctly display preferences
|
||||||
|
View view = inflater.inflate(R.layout.settings, null);
|
||||||
|
|
||||||
|
ViewParent p = preferencesList.getParent();
|
||||||
|
if (p != null) {
|
||||||
|
((ViewGroup)p).removeView(preferencesList);
|
||||||
|
}
|
||||||
|
|
||||||
|
RelativeLayout layout = (RelativeLayout) view.findViewById(R.id.topLayout);
|
||||||
|
layout.addView(preferencesList);
|
||||||
|
|
||||||
postBindPreferences();
|
postBindPreferences();
|
||||||
return preferencesList;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -90,9 +102,11 @@ public class PreferencesListFragment extends ListFragment {
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle bundle) {
|
public void onCreate(Bundle bundle) {
|
||||||
super.onCreate(bundle);
|
super.onCreate(bundle);
|
||||||
|
|
||||||
if (bundle != null) {
|
if (bundle != null) {
|
||||||
xmlResID = bundle.getInt("xml");
|
xmlResID = bundle.getInt("xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
mPreferenceManager = onCreatePreferenceManager();
|
mPreferenceManager = onCreatePreferenceManager();
|
||||||
preferencesList = (ListView) LayoutInflater.from(getActivity()).inflate(R.layout.preference_list_content, null);
|
preferencesList = (ListView) LayoutInflater.from(getActivity()).inflate(R.layout.preference_list_content, null);
|
||||||
preferencesList.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
|
preferencesList.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
|
||||||
|
@ -120,9 +134,9 @@ public class PreferencesListFragment extends ListFragment {
|
||||||
Method m = PreferenceManager.class.getDeclaredMethod("dispatchActivityDestroy");
|
Method m = PreferenceManager.class.getDeclaredMethod("dispatchActivityDestroy");
|
||||||
m.setAccessible(true);
|
m.setAccessible(true);
|
||||||
m.invoke(mPreferenceManager);
|
m.invoke(mPreferenceManager);
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue