diff --git a/res/drawable-xhdpi/logo.png b/res/drawable-xhdpi/logo.png new file mode 100644 index 000000000..ff1962516 Binary files /dev/null and b/res/drawable-xhdpi/logo.png differ diff --git a/res/drawable-xlarge-xhdpi/logo.png b/res/drawable-xlarge-xhdpi/logo.png new file mode 100644 index 000000000..18f8f255c Binary files /dev/null and b/res/drawable-xlarge-xhdpi/logo.png differ diff --git a/res/layout/setup_ec_calibration.xml b/res/layout/setup_ec_calibration.xml new file mode 100644 index 000000000..0b795c433 --- /dev/null +++ b/res/layout/setup_ec_calibration.xml @@ -0,0 +1,27 @@ + + + + + + + + + + diff --git a/res/values/strings.xml b/res/values/strings.xml index e105a5692..eab717a0c 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -385,6 +385,7 @@ utomatically accept new friend requests Friend request wants to share it\'s presence status with you and be aware of yours. + Echo canceller calibration in progress diff --git a/src/org/linphone/LinphoneActivity.java b/src/org/linphone/LinphoneActivity.java index ce50e93c7..53f2c500e 100644 --- a/src/org/linphone/LinphoneActivity.java +++ b/src/org/linphone/LinphoneActivity.java @@ -25,7 +25,6 @@ import java.util.Calendar; import java.util.List; import org.linphone.LinphoneManager.AddressType; -import org.linphone.LinphoneManager.EcCalibrationListener; import org.linphone.LinphoneManager.LinphoneConfigException; import org.linphone.LinphoneSimpleListener.LinphoneOnCallStateChangedListener; import org.linphone.LinphoneSimpleListener.LinphoneOnMessageReceivedListener; @@ -39,7 +38,6 @@ import org.linphone.core.LinphoneCallLog; import org.linphone.core.LinphoneCallLog.CallStatus; import org.linphone.core.LinphoneChatMessage; import org.linphone.core.LinphoneCore; -import org.linphone.core.LinphoneCore.EcCalibratorStatus; import org.linphone.core.LinphoneCore.RegistrationState; import org.linphone.core.LinphoneCoreException; import org.linphone.core.LinphoneCoreFactory; @@ -47,7 +45,6 @@ import org.linphone.core.LinphoneFriend; import org.linphone.core.Log; import org.linphone.core.OnlineStatus; import org.linphone.mediastream.Version; -import org.linphone.mediastream.video.capture.hwconf.Hacks; import org.linphone.setup.SetupActivity; import org.linphone.ui.AddressText; @@ -90,8 +87,7 @@ import android.widget.Toast; public class LinphoneActivity extends FragmentActivity implements OnClickListener, ContactPicked, LinphoneOnCallStateChangedListener, LinphoneOnMessageReceivedListener, - LinphoneOnRegistrationStateChangedListener, - EcCalibrationListener { + LinphoneOnRegistrationStateChangedListener { public static final String PREF_FIRST_LAUNCH = "pref_first_launch"; private static final int SETTINGS_ACTIVITY = 123; private static final int FIRST_LOGIN_ACTIVITY = 101; @@ -1137,30 +1133,9 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene stopService(new Intent(ACTION_MAIN).setClass(this, LinphoneService.class)); } - public void onEcCalibrationStatus(final EcCalibratorStatus status, final int delayMs) { - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); - SharedPreferences.Editor editor = prefs.edit(); - if (status == EcCalibratorStatus.DoneNoEcho) { - editor.putBoolean(getString(R.string.pref_echo_cancellation_key), false); - } else if ((status == EcCalibratorStatus.Done) || (status == EcCalibratorStatus.Failed)) { - editor.putBoolean(getString(R.string.pref_echo_cancellation_key), true); - } - editor.commit(); - } - @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { - if ((requestCode == FIRST_LOGIN_ACTIVITY) && (resultCode == RESULT_OK)) { - if (!Hacks.hasBuiltInEchoCanceller()) { - Toast.makeText(this, getString(R.string.ec_calibration_launch_message), Toast.LENGTH_LONG).show(); - try { - LinphoneManager.getInstance().startEcCalibration(this); - } catch (LinphoneCoreException e) { - Log.e(e, "Unable to calibrate EC"); - } - } - } - else if (resultCode == Activity.RESULT_FIRST_USER && requestCode == SETTINGS_ACTIVITY) { + if (resultCode == Activity.RESULT_FIRST_USER && requestCode == SETTINGS_ACTIVITY) { if (data.getExtras().getBoolean("Exit", false)) { exit(); } else { diff --git a/src/org/linphone/setup/EchoCancellerCalibrationFragment.java b/src/org/linphone/setup/EchoCancellerCalibrationFragment.java new file mode 100644 index 000000000..23e0622f5 --- /dev/null +++ b/src/org/linphone/setup/EchoCancellerCalibrationFragment.java @@ -0,0 +1,109 @@ +package org.linphone.setup; + +/* +EchoCancellerCalibrationFragment.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 java.net.URL; + +import org.linphone.LinphoneManager; +import org.linphone.LinphoneManager.EcCalibrationListener; +import org.linphone.R; +import org.linphone.core.LinphoneCore.EcCalibratorStatus; +import org.linphone.core.LinphoneCoreException; +import org.linphone.core.Log; + +import de.timroes.axmlrpc.XMLRPCCallback; +import de.timroes.axmlrpc.XMLRPCClient; +import de.timroes.axmlrpc.XMLRPCException; +import de.timroes.axmlrpc.XMLRPCServerException; + +import android.content.SharedPreferences; +import android.os.Build; +import android.os.Bundle; +import android.os.Handler; +import android.preference.PreferenceManager; +import android.support.v4.app.Fragment; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Toast; + +/** + * @author Ghislain MARY + */ +public class EchoCancellerCalibrationFragment extends Fragment implements EcCalibrationListener { + private Handler mHandler = new Handler(); + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.setup_ec_calibration, container, false); + + try { + LinphoneManager.getInstance().startEcCalibration(this); + } catch (LinphoneCoreException e) { + Log.e(e, "Unable to calibrate EC"); + } + + return view; + } + + @Override + public void onEcCalibrationStatus(EcCalibratorStatus status, int delayMs) { + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); + SharedPreferences.Editor editor = prefs.edit(); + if (status == EcCalibratorStatus.DoneNoEcho) { + editor.putBoolean(getString(R.string.pref_echo_cancellation_key), false); + } else if ((status == EcCalibratorStatus.Done) || (status == EcCalibratorStatus.Failed)) { + editor.putBoolean(getString(R.string.pref_echo_cancellation_key), true); + } + editor.commit(); + sendEcCalibrationResult(status, delayMs); + } + + private void sendEcCalibrationResult(EcCalibratorStatus status, int delayMs) { + try { + XMLRPCClient client = new XMLRPCClient(new URL(getString(R.string.wizard_url))); + + XMLRPCCallback listener = new XMLRPCCallback() { + Runnable runFinished = new Runnable() { + public void run() { + SetupActivity.instance().isEchoCalibrationFinished(); + } + }; + + public void onResponse(long id, Object result) { + mHandler.post(runFinished); + } + + public void onError(long id, XMLRPCException error) { + mHandler.post(runFinished); + } + + public void onServerError(long id, XMLRPCServerException error) { + mHandler.post(runFinished); + } + }; + + Log.i("Add echo canceller calibration result: manufacturer=" + Build.MANUFACTURER + " model=" + Build.MODEL + " status=" + status + " delay=" + delayMs + "ms"); + client.callAsync(listener, "add_ec_calibration_result", Build.MANUFACTURER, Build.MODEL, status.toString(), delayMs); + } + catch(Exception ex) {} + } +} diff --git a/src/org/linphone/setup/GenericLoginFragment.java b/src/org/linphone/setup/GenericLoginFragment.java index 7de4c705a..ace26f74f 100644 --- a/src/org/linphone/setup/GenericLoginFragment.java +++ b/src/org/linphone/setup/GenericLoginFragment.java @@ -59,7 +59,7 @@ public class GenericLoginFragment extends Fragment implements OnClickListener { return; } - SetupActivity.instance().logIn(login.getText().toString(), password.getText().toString(), domain.getText().toString()); + SetupActivity.instance().genericLogIn(login.getText().toString(), password.getText().toString(), domain.getText().toString()); } } } diff --git a/src/org/linphone/setup/LinphoneLoginFragment.java b/src/org/linphone/setup/LinphoneLoginFragment.java index 91e5fcf73..198da57cb 100644 --- a/src/org/linphone/setup/LinphoneLoginFragment.java +++ b/src/org/linphone/setup/LinphoneLoginFragment.java @@ -58,7 +58,7 @@ public class LinphoneLoginFragment extends Fragment implements OnClickListener { return; } - SetupActivity.instance().logIn(login.getText().toString(), password.getText().toString(), getString(R.string.default_domain)); + SetupActivity.instance().linphoneLogIn(login.getText().toString(), password.getText().toString()); } } } diff --git a/src/org/linphone/setup/SetupActivity.java b/src/org/linphone/setup/SetupActivity.java index fbec54211..b35e48124 100644 --- a/src/org/linphone/setup/SetupActivity.java +++ b/src/org/linphone/setup/SetupActivity.java @@ -20,6 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. import org.linphone.LinphoneManager; import org.linphone.R; import org.linphone.core.Log; +import org.linphone.mediastream.video.capture.hwconf.Hacks; import android.app.Activity; import android.content.Context; @@ -141,14 +142,32 @@ public class SetupActivity extends FragmentActivity implements OnClickListener { 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) { + logIn(username, password, getString(R.string.default_domain)); if (LinphoneManager.getLc().getDefaultProxyConfig() != null) { - writePreference(R.string.first_launch_suceeded_once_key, true); - setResult(Activity.RESULT_OK); - finish(); + if (!Hacks.hasBuiltInEchoCanceller()) { + EchoCancellerCalibrationFragment fragment = new EchoCancellerCalibrationFragment(); + changeFragment(fragment); + currentFragment = SetupFragments.ECHO_CANCELLER_CALIBRATION; + back.setVisibility(View.GONE); + next.setVisibility(View.VISIBLE); + next.setEnabled(false); + cancel.setEnabled(false); + } else { + success(); + } } } - + + public void genericLogIn(String username, String password, String domain) { + logIn(username, password, domain); + if (LinphoneManager.getLc().getDefaultProxyConfig() != null) { + success(); + } + } + private void writePreference(int key, String value) { mPref.edit().putString(getString(key), value).commit(); } @@ -237,9 +256,12 @@ public class SetupActivity extends FragmentActivity implements OnClickListener { Log.e(e, "Error while initializing from config in first login activity"); Toast.makeText(this, getString(R.string.error), Toast.LENGTH_LONG).show(); } - - writePreference(R.string.first_launch_suceeded_once_key, true); - finish(); + + success(); + } + + public void isEchoCalibrationFinished() { + success(); } public boolean onKeyDown(int keyCode, KeyEvent event) { @@ -249,4 +271,10 @@ public class SetupActivity extends FragmentActivity implements OnClickListener { } return super.onKeyDown(keyCode, event); } + + public void success() { + writePreference(R.string.first_launch_suceeded_once_key, true); + setResult(Activity.RESULT_OK); + finish(); + } } diff --git a/src/org/linphone/setup/SetupFragments.java b/src/org/linphone/setup/SetupFragments.java index 966ab5863..afd878dc4 100644 --- a/src/org/linphone/setup/SetupFragments.java +++ b/src/org/linphone/setup/SetupFragments.java @@ -26,5 +26,6 @@ public enum SetupFragments { WIZARD, WIZARD_CONFIRM, LINPHONE_LOGIN, - GENERIC_LOGIN; + GENERIC_LOGIN, + ECHO_CANCELLER_CALIBRATION; }