diff --git a/res/layout-land/dialer.xml b/res/layout-land/dialer.xml
index 30b1d79e9..eb1da6ff1 100644
--- a/res/layout-land/dialer.xml
+++ b/res/layout-land/dialer.xml
@@ -38,15 +38,14 @@
-
+
-
-
+
diff --git a/res/layout/dialer.xml b/res/layout/dialer.xml
index 0a5634187..a029f42c7 100644
--- a/res/layout/dialer.xml
+++ b/res/layout/dialer.xml
@@ -40,56 +40,43 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ android:layout_weight="1" android:id="@+id/DialerRow01"
+ android:layout_width="fill_parent">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
diff --git a/src/org/linphone/DialerActivity.java b/src/org/linphone/DialerActivity.java
index 9ccb8cee4..6503b80a3 100644
--- a/src/org/linphone/DialerActivity.java
+++ b/src/org/linphone/DialerActivity.java
@@ -18,22 +18,26 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.linphone;
+import org.linphone.LinphoneManager.NewOutgoingCallUiListener;
import org.linphone.core.AndroidCameraRecordManager;
import org.linphone.core.LinphoneAddress;
import org.linphone.core.LinphoneCall;
import org.linphone.core.LinphoneChatRoom;
import org.linphone.core.LinphoneCore;
-import org.linphone.core.LinphoneCoreException;
import org.linphone.core.LinphoneCoreListener;
import org.linphone.core.LinphoneFriend;
import org.linphone.core.LinphoneProxyConfig;
import org.linphone.core.LinphoneCall.State;
import org.linphone.core.LinphoneCore.EcCalibratorStatus;
+import org.linphone.ui.AddVideoButton;
import org.linphone.ui.AddressText;
+import org.linphone.ui.CallButton;
import org.linphone.ui.Digit;
import org.linphone.ui.EraseButton;
import org.linphone.ui.MuteMicButton;
import org.linphone.ui.SpeakerButton;
+import org.linphone.ui.AddVideoButton.AlreadyInVideoCallListener;
+import org.linphone.ui.CallButton.CallButtonListener;
import android.app.Activity;
import android.app.AlertDialog;
@@ -51,20 +55,18 @@ import android.provider.Settings;
import android.text.Html;
import android.util.Log;
import android.view.View;
-import android.view.View.OnClickListener;
-import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TableRow;
import android.widget.TextView;
import android.widget.Toast;
-public class DialerActivity extends Activity implements LinphoneCoreListener {
+public class DialerActivity extends Activity implements LinphoneCoreListener, AlreadyInVideoCallListener, CallButtonListener, NewOutgoingCallUiListener {
private AddressText mAddress;
private TextView mDisplayNameView;
private TextView mStatus;
- private ImageButton mCall;
+ private CallButton mCall;
private View mDecline;
private View mHangup;
@@ -80,7 +82,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
private PowerManager.WakeLock mWakeLock;
private SharedPreferences mPref;
- private ImageButton mAddVideo;
+ private AddVideoButton mAddVideo;
private static final String PREF_CHECK_CONFIG = "pref_check_config";
public static final String PREF_FIRST_LAUNCH = "pref_first_launch";
@@ -105,11 +107,13 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.dialer);
- LinphoneManager.getInstance().setAudioManager(((AudioManager)getSystemService(Context.AUDIO_SERVICE)));
+ mPref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
+ AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
+ LinphoneManager.getInstance().setUsefullStuff(am, mPref, getWindowManager(), getResources());
PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
mVibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
mWakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK|PowerManager.ON_AFTER_RELEASE,"Linphone");
- mPref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
+
try {
@@ -118,24 +122,15 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
((EraseButton) findViewById(R.id.Erase)).setAddressView(mAddress);
- mAddVideo = (ImageButton) findViewById(R.id.AddVideo);
- mAddVideo.setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- // If no in video call; try to reinvite with video
- boolean alreadyInVideoCall = !CallManager.getInstance().reinviteWithVideo();
- if (alreadyInVideoCall) {
- // In video call; going back to video call activity
- startVideoView(VIDEO_VIEW_ACTIVITY);
- }
- }
- });
+ mAddVideo = (AddVideoButton) findViewById(R.id.AddVideo);
+ mAddVideo.setOnAlreadyInVideoCallListener(this);
+
+
+
+ mCall = (CallButton) findViewById(R.id.Call);
+ mCall.setCallButtonListerner(this);
+ mCall.setAddressWidget(mAddress);
- mCall = (ImageButton) findViewById(R.id.Call);
- mCall.setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- callOrAcceptIncommingCall();
- }
- });
mDecline= findViewById(R.id.Decline);
mDecline.setEnabled(false);
@@ -143,18 +138,15 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
mCallControlRow = (LinearLayout) findViewById(R.id.CallControlRow);
- mInCallControlRow = (TableRow) findViewById(R.id.IncallControlRow);
mAddressLayout = (View) findViewById(R.id.Addresslayout);
+
+ mInCallControlRow = (TableRow) findViewById(R.id.IncallControlRow);
+ mInCallControlRow.setVisibility(View.GONE);
mInCallAddressLayout = (View) findViewById(R.id.IncallAddressLayout);
+ mInCallAddressLayout.setVisibility(View.GONE);
mMute = (MuteMicButton)findViewById(R.id.mic_mute_button);
mSpeaker = (SpeakerButton)findViewById(R.id.speaker_button);
-/* if (Hacks.isGalaxyS()) {
- // Galaxy S doesn't handle audio routing properly
- // so disabling it totally
- mSpeaker.setVisibility(View.GONE);
- }*/
- mInCallControlRow.setVisibility(View.GONE);
- mInCallAddressLayout.setVisibility(View.GONE);
+
if (LinphoneService.isready() && getIntent().getData() != null && !LinphoneService.getLc().isIncall()) {
newOutgoingCall(getIntent().getData().toString().substring("tel://".length()));
@@ -189,8 +181,21 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
}
- initializeDigits();
-
+ if (findViewById(R.id.Digit00) != null) { // In landscape view, no keyboard
+ ((Digit) findViewById(R.id.Digit00)).setAddressWidget(mAddress);
+ ((Digit) findViewById(R.id.Digit1)).setAddressWidget(mAddress);
+ ((Digit) findViewById(R.id.Digit2)).setAddressWidget(mAddress);
+ ((Digit) findViewById(R.id.Digit3)).setAddressWidget(mAddress);
+ ((Digit) findViewById(R.id.Digit4)).setAddressWidget(mAddress);
+ ((Digit) findViewById(R.id.Digit5)).setAddressWidget(mAddress);
+ ((Digit) findViewById(R.id.Digit6)).setAddressWidget(mAddress);
+ ((Digit) findViewById(R.id.Digit7)).setAddressWidget(mAddress);
+ ((Digit) findViewById(R.id.Digit8)).setAddressWidget(mAddress);
+ ((Digit) findViewById(R.id.Digit9)).setAddressWidget(mAddress);
+ ((Digit) findViewById(R.id.DigitStar)).setAddressWidget(mAddress);
+ ((Digit) findViewById(R.id.DigitHash)).setAddressWidget(mAddress);
+ }
+
mStatus = (TextView) findViewById(R.id.status_label);
theDialer = this;
@@ -201,44 +206,21 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
}
- if (!accountCheckingDone) checkAccountsSettings();
- }
-
- private void callOrAcceptIncommingCall() {
- LinphoneCore lLinphoneCore = LinphoneService.instance().getLinphoneCore();
- if (lLinphoneCore.isInComingInvitePending()) {
- try {
- lLinphoneCore.acceptCall(lLinphoneCore.getCurrentCall());
- } catch (LinphoneCoreException e) {
- lLinphoneCore.terminateCall(lLinphoneCore.getCurrentCall());
- Toast toast = Toast.makeText(DialerActivity.this
- ,String.format(getString(R.string.warning_wrong_destination_address),mAddress.getText().toString())
- ,Toast.LENGTH_LONG);
- toast.show();
+ if (!accountCheckingDone) {
+ if (mPref.getBoolean(PREF_FIRST_LAUNCH, true)) {
+ onFirstLaunch();
+ } else if (!mPref.getBoolean(PREF_CHECK_CONFIG, false)
+ && !checkDefined(R.string.pref_username_key, R.string.pref_passwd_key, R.string.pref_domain_key)) {
+ onBadSettings();
+ } else {
+ accountCheckingDone = true;
}
- return;
- }
- if (mAddress.getText().length() >0) {
- newOutgoingCall(mAddress.getText().toString(), mAddress.getDisplayedName());
}
}
- private void initializeDigits() {
- if (findViewById(R.id.Digit00) == null) return; // In landscape view, no keyboard
- ((Digit) findViewById(R.id.Digit00)).setAddressWidget(mAddress);
- ((Digit) findViewById(R.id.Digit1)).setAddressWidget(mAddress);
- ((Digit) findViewById(R.id.Digit2)).setAddressWidget(mAddress);
- ((Digit) findViewById(R.id.Digit3)).setAddressWidget(mAddress);
- ((Digit) findViewById(R.id.Digit4)).setAddressWidget(mAddress);
- ((Digit) findViewById(R.id.Digit5)).setAddressWidget(mAddress);
- ((Digit) findViewById(R.id.Digit6)).setAddressWidget(mAddress);
- ((Digit) findViewById(R.id.Digit7)).setAddressWidget(mAddress);
- ((Digit) findViewById(R.id.Digit8)).setAddressWidget(mAddress);
- ((Digit) findViewById(R.id.Digit9)).setAddressWidget(mAddress);
- ((Digit) findViewById(R.id.DigitStar)).setAddressWidget(mAddress);
- ((Digit) findViewById(R.id.DigitHash)).setAddressWidget(mAddress);
- }
+
+
private boolean checkDefined(int ... keys) {
for (int key : keys) {
@@ -249,66 +231,58 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
return true;
}
+ private void onFirstLaunch() {
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ TextView lDialogTextView = new TextView(this);
+ lDialogTextView.setAutoLinkMask(0x0f/*all*/);
+ lDialogTextView.setPadding(10, 10, 10, 10);
- private void checkAccountsSettings() {
- if (mPref.getBoolean(PREF_FIRST_LAUNCH, true)) {
- // First launch
- AlertDialog.Builder builder = new AlertDialog.Builder(this);
- TextView lDialogTextView = new TextView(this);
- lDialogTextView.setAutoLinkMask(0x0f/*all*/);
- lDialogTextView.setPadding(10, 10, 10, 10);
+ lDialogTextView.setText(Html.fromHtml(getString(R.string.first_launch_message)));
- lDialogTextView.setText(Html.fromHtml(getString(R.string.first_launch_message)));
+ builder.setCustomTitle(lDialogTextView)
+ .setCancelable(false)
+ .setPositiveButton(getString(R.string.cont), new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int id) {
+ LinphoneActivity.instance().startprefActivity();
+ accountCheckingDone = true;
+ }
+ });
- builder.setCustomTitle(lDialogTextView)
- .setCancelable(false)
- .setPositiveButton(getString(R.string.cont), new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- LinphoneActivity.instance().startprefActivity();
- accountCheckingDone = true;
- }
- });
-
- builder.create().show();
-
-
- } else if (!mPref.getBoolean(PREF_CHECK_CONFIG, false)
- && !checkDefined(R.string.pref_username_key, R.string.pref_passwd_key, R.string.pref_domain_key)) {
- // Account not set
-
- AlertDialog.Builder builder = new AlertDialog.Builder(this);
- TextView lDialogTextView = new TextView(this);
- lDialogTextView.setAutoLinkMask(0x0f/*all*/);
- lDialogTextView.setPadding(10, 10, 10, 10);
-
- lDialogTextView.setText(Html.fromHtml(getString(R.string.initial_config_error)));
-
- builder.setCustomTitle(lDialogTextView)
- .setCancelable(false)
- .setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- LinphoneActivity.instance().startprefActivity();
- accountCheckingDone = true;
- }
- }).setNeutralButton(getString(R.string.no), new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- dialog.cancel();
- accountCheckingDone = true;
- }
- }).setNegativeButton(getString(R.string.never_remind), new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- mPref.edit().putBoolean(PREF_CHECK_CONFIG, true).commit();
- dialog.cancel();
- accountCheckingDone = true;
- }
- });
-
- builder.create().show();
- } else {
- accountCheckingDone = true;
- }
+ builder.create().show();
}
+ private void onBadSettings() {
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ TextView lDialogTextView = new TextView(this);
+ lDialogTextView.setAutoLinkMask(0x0f/*all*/);
+ lDialogTextView.setPadding(10, 10, 10, 10);
+
+ lDialogTextView.setText(Html.fromHtml(getString(R.string.initial_config_error)));
+
+ builder.setCustomTitle(lDialogTextView)
+ .setCancelable(false)
+ .setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int id) {
+ LinphoneActivity.instance().startprefActivity();
+ accountCheckingDone = true;
+ }
+ }).setNeutralButton(getString(R.string.no), new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int id) {
+ dialog.cancel();
+ accountCheckingDone = true;
+ }
+ }).setNegativeButton(getString(R.string.never_remind), new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int id) {
+ mPref.edit().putBoolean(PREF_CHECK_CONFIG, true).commit();
+ dialog.cancel();
+ accountCheckingDone = true;
+ }
+ });
+
+ builder.create().show();
+ }
+
+
private void updateIncallVideoCallButton() {
boolean prefVideoEnabled = mPref.getBoolean(getString(R.string.pref_video_enable_key), false);
if (prefVideoEnabled && !mCall.isEnabled()) {
@@ -384,13 +358,13 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
public void callState(final LinphoneCore lc,final LinphoneCall call, final State state, final String message) {
if (state == LinphoneCall.State.OutgoingInit) {
- enterIncalMode(lc);
+ enterIncallMode(lc);
LinphoneManager.getInstance().routeAudioToReceiver();
} else if (state == LinphoneCall.State.IncomingReceived) {
- resetCameraFromPreferences();
+ LinphoneManager.getInstance().resetCameraFromPreferences();
callPending(call);
} else if (state == LinphoneCall.State.Connected) {
- enterIncalMode(lc);
+ enterIncallMode(lc);
} else if (state == LinphoneCall.State.Error) {
if (mWakeLock.isHeld()) mWakeLock.release();
Toast toast = Toast.makeText(this
@@ -401,7 +375,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
} else if (state == LinphoneCall.State.CallEnd) {
exitCallMode();
} else if (state == LinphoneCall.State.StreamsRunning) {
- if (LinphoneService.instance().getLinphoneCore().getCurrentCall().getCurrentParamsCopy().getVideoEnabled()) {
+ if (LinphoneService.getLc().getCurrentCall().getCurrentParamsCopy().getVideoEnabled()) {
if (!VideoCallActivity.launched) {
startVideoView(VIDEO_VIEW_ACTIVITY);
}
@@ -411,7 +385,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
public void show(LinphoneCore lc) {/*nop*/}
- private void enterIncalMode(LinphoneCore lc) {
+ private void enterIncallMode(LinphoneCore lc) {
mCallControlRow.setVisibility(View.GONE);
mInCallControlRow.setVisibility(View.VISIBLE);
mAddressLayout.setVisibility(View.GONE);
@@ -447,12 +421,6 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
mSpeaker.setSpeakerOn(LinphoneManager.getInstance().isSpeakerOn());
}
- private void resetCameraFromPreferences() {
- boolean useFrontCam = mPref.getBoolean(getString(R.string.pref_video_use_front_camera_key), false);
- getVideoManager().setUseFrontCamera(useFrontCam);
- final int phoneOrientation = 90 * getWindowManager().getDefaultDisplay().getOrientation();
- getVideoManager().setPhoneOrientation(phoneOrientation);
- }
private void exitCallMode() {
mCallControlRow.setVisibility(View.VISIBLE);
@@ -471,7 +439,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
mSpeaker.setSpeakerOn(false);
LinphoneManager.getInstance().routeAudioToReceiver();
BandwidthManager.getInstance().setUserRestriction(false);
- resetCameraFromPreferences();
+ LinphoneManager.getInstance().resetCameraFromPreferences();
LinphoneActivity.instance().stopProxymitySensor();
}
@@ -482,53 +450,17 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
// Privacy setting to not share the user camera by default
boolean prefVideoEnable = mPref.getBoolean(getString(R.string.pref_video_enable_key), false);
boolean prefAutomaticallyShareMyCamera = mPref.getBoolean(getString(R.string.pref_video_automatically_share_my_video_key), false);
- getVideoManager().setMuted(!(prefVideoEnable && prefAutomaticallyShareMyCamera));
+ AndroidCameraRecordManager.getInstance().setMuted(!(prefVideoEnable && prefAutomaticallyShareMyCamera));
call.enableCamera(prefAutomaticallyShareMyCamera);
}
public void newOutgoingCall(String aTo) {
- newOutgoingCall(aTo,null);
+ mAddress.setText(aTo);
+ mAddress.clearDisplayedName();
+ LinphoneManager.getInstance().newOutgoingCall(mAddress);
}
- private synchronized void newOutgoingCall(String aTo, String displayName) {
- String lto = aTo;
- if (aTo.contains(OutgoingCallReceiver.TAG)) {
- lto = aTo.replace(OutgoingCallReceiver.TAG, "");
- }
- mAddress.setText(lto);
- mAddress.setDisplayedName(displayName);
- LinphoneCore lLinphoneCore = LinphoneService.instance().getLinphoneCore();
- if (lLinphoneCore.isIncall()) {
- Toast toast = Toast.makeText(DialerActivity.this, getString(R.string.warning_already_incall), Toast.LENGTH_LONG);
- toast.show();
- return;
- }
- LinphoneAddress lAddress;
- try {
- lAddress = lLinphoneCore.interpretUrl(lto);
- } catch (LinphoneCoreException e) {
- Toast toast = Toast.makeText(DialerActivity.this
- ,String.format(getString(R.string.warning_wrong_destination_address),mAddress.getText().toString())
- , Toast.LENGTH_LONG);
- toast.show();
- return;
- }
- lAddress.setDisplayName(mAddress.getDisplayedName());
-
- try {
- boolean prefVideoEnable = mPref.getBoolean(getString(R.string.pref_video_enable_key), false);
- boolean prefInitiateWithVideo = mPref.getBoolean(getString(R.string.pref_video_initiate_call_with_video_key), false);
- resetCameraFromPreferences();
- CallManager.getInstance().inviteAddress(lAddress, prefVideoEnable && prefInitiateWithVideo);
-
- } catch (LinphoneCoreException e) {
- Toast toast = Toast.makeText(DialerActivity.this
- ,String.format(getString(R.string.error_cannot_get_call_parameters),mAddress.getText().toString())
- ,Toast.LENGTH_LONG);
- toast.show();
- return;
- }
- }
+
public void newSubscriptionRequest(LinphoneCore lc, LinphoneFriend lf, String url) {}
public void notifyPresenceReceived(LinphoneCore lc, LinphoneFriend lf) {}
@@ -536,9 +468,6 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
LinphoneAddress from, String message) {}
- private AndroidCameraRecordManager getVideoManager() {
- return AndroidCameraRecordManager.getInstance();
- }
public void ecCalibrationStatus(LinphoneCore lc, EcCalibratorStatus status,
int delay_ms, Object data) {}
@@ -546,6 +475,34 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
mAddress.setText(aContact);
mAddress.setDisplayedName(aDisplayName);
}
+
+
+ public void onAlreadyInVideoCall() {
+ startVideoView(VIDEO_VIEW_ACTIVITY);
+ }
+
+
+ public void onWrongDestinationAddress() {
+ Toast toast = Toast.makeText(DialerActivity.this
+ ,String.format(getString(R.string.warning_wrong_destination_address),mAddress.getText().toString())
+ ,Toast.LENGTH_LONG);
+ toast.show();
+ }
+
+
+ public void onAlreadyInCall() {
+ Toast toast = Toast.makeText(DialerActivity.this, getString(R.string.warning_already_incall), Toast.LENGTH_LONG);
+ toast.show();
+ }
+
+
+ public void onCannotGetCallParameters() {
+ Toast toast = Toast.makeText(DialerActivity.this
+ ,String.format(getString(R.string.error_cannot_get_call_parameters),mAddress.getText().toString())
+ ,Toast.LENGTH_LONG);
+ toast.show();
+
+ }
}
diff --git a/src/org/linphone/Hacks.java b/src/org/linphone/Hacks.java
index 0c6809048..bfc323d33 100644
--- a/src/org/linphone/Hacks.java
+++ b/src/org/linphone/Hacks.java
@@ -24,6 +24,8 @@ import android.util.Log;
public class Hacks {
+ private Hacks() {}
+
public static boolean isGalaxyS() {
return Build.DEVICE.startsWith("GT-I9000") || Build.DEVICE.startsWith("GT-P1000");
}
diff --git a/src/org/linphone/KeepAliveManager.java b/src/org/linphone/KeepAliveReceiver.java
similarity index 94%
rename from src/org/linphone/KeepAliveManager.java
rename to src/org/linphone/KeepAliveReceiver.java
index 3baf685c9..fba931aa3 100644
--- a/src/org/linphone/KeepAliveManager.java
+++ b/src/org/linphone/KeepAliveReceiver.java
@@ -1,5 +1,5 @@
/*
-ContactPickerActivity.java
+KeepAliveReceiver.java
Copyright (C) 2010 Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or
@@ -25,7 +25,7 @@ import android.util.Log;
-public class KeepAliveManager extends BroadcastReceiver {
+public class KeepAliveReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
diff --git a/src/org/linphone/LinphoneException.java b/src/org/linphone/LinphoneException.java
index 61bcd1253..cc44df65a 100644
--- a/src/org/linphone/LinphoneException.java
+++ b/src/org/linphone/LinphoneException.java
@@ -21,22 +21,17 @@ package org.linphone;
@SuppressWarnings("serial")
public class LinphoneException extends Exception {
- public LinphoneException() {
- // TODO Auto-generated constructor stub
- }
+ public LinphoneException() {}
public LinphoneException(String detailMessage) {
super(detailMessage);
- // TODO Auto-generated constructor stub
}
public LinphoneException(Throwable throwable) {
super(throwable);
- // TODO Auto-generated constructor stub
}
public LinphoneException(String detailMessage, Throwable throwable) {
super(detailMessage, throwable);
- // TODO Auto-generated constructor stub
}
}
diff --git a/src/org/linphone/LinphoneManager.java b/src/org/linphone/LinphoneManager.java
index 5e9fac29f..a01ccc88f 100644
--- a/src/org/linphone/LinphoneManager.java
+++ b/src/org/linphone/LinphoneManager.java
@@ -18,17 +18,27 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.linphone;
+import org.linphone.core.AndroidCameraRecordManager;
+import org.linphone.core.LinphoneAddress;
import org.linphone.core.LinphoneCore;
+import org.linphone.core.LinphoneCoreException;
import android.content.SharedPreferences;
+import android.content.res.Resources;
import android.media.AudioManager;
import android.os.Build;
+import android.view.WindowManager;
public class LinphoneManager {
private static LinphoneManager instance;
private AudioManager mAudioManager;
+ private NewOutgoingCallUiListener newOutgoingCallUiListener;
+ private SharedPreferences mPref;
+ private Resources mR;
+ private WindowManager mWindowManager;
+ private LinphoneManager() {}
public void routeAudioToSpeaker() {
if (Integer.parseInt(Build.VERSION.SDK) <= 4 /*4 &&mAudioManager.isSpeakerphoneOn();
}
+
+ public void newOutgoingCall(AddressType address) {
+ String to = address.getText().toString();
+ if (to.contains(OutgoingCallReceiver.TAG)) {
+ to = to.replace(OutgoingCallReceiver.TAG, "");
+ address.setText(to);
+ }
+ LinphoneCore lLinphoneCore = LinphoneService.instance().getLinphoneCore();
+ if (lLinphoneCore.isIncall()) {
+ newOutgoingCallUiListener.onAlreadyInCall();
+ return;
+ }
+ LinphoneAddress lAddress;
+ try {
+ lAddress = lLinphoneCore.interpretUrl(to);
+ } catch (LinphoneCoreException e) {
+ newOutgoingCallUiListener.onWrongDestinationAddress();
+ return;
+ }
+ lAddress.setDisplayName(address.getDisplayedName());
+
+ try {
+
+ boolean prefVideoEnable = mPref.getBoolean(mR.getString(R.string.pref_video_enable_key), false);
+ boolean prefInitiateWithVideo = mPref.getBoolean(mR.getString(R.string.pref_video_initiate_call_with_video_key), false);
+ resetCameraFromPreferences();
+ CallManager.getInstance().inviteAddress(lAddress, prefVideoEnable && prefInitiateWithVideo);
+
+ } catch (LinphoneCoreException e) {
+ newOutgoingCallUiListener.onCannotGetCallParameters();
+ return;
+ }
+ }
+
+
+ public void resetCameraFromPreferences() {
+ boolean useFrontCam = mPref.getBoolean(mR.getString(R.string.pref_video_use_front_camera_key), false);
+ AndroidCameraRecordManager.getInstance().setUseFrontCamera(useFrontCam);
+ final int phoneOrientation = 90 * mWindowManager.getDefaultDisplay().getOrientation();
+ AndroidCameraRecordManager.getInstance().setPhoneOrientation(phoneOrientation);
+ }
+
+ public void setNewOutgoingCallUiListener(NewOutgoingCallUiListener l) {
+ this.newOutgoingCallUiListener = l;
+ }
+
+ public static interface AddressType {
+ void setText(CharSequence s);
+ CharSequence getText();
+ void setDisplayedName(String s);
+ String getDisplayedName();
+ }
+
+
+ public static interface NewOutgoingCallUiListener {
+ public void onWrongDestinationAddress();
+ public void onCannotGetCallParameters();
+ public void onAlreadyInCall();
+ }
+
+
+ public void sendStaticImage(boolean send) {
+ LinphoneCore lc = LinphoneService.getLc();
+ if (lc.isIncall()) {
+ lc.getCurrentCall().enableCamera(!send);
+ }
+ }
}
diff --git a/src/org/linphone/LinphoneService.java b/src/org/linphone/LinphoneService.java
index 071ed4c2e..22628deb2 100644
--- a/src/org/linphone/LinphoneService.java
+++ b/src/org/linphone/LinphoneService.java
@@ -90,7 +90,7 @@ public class LinphoneService extends Service implements LinphoneCoreListener {
LinphoneCall.State mCurrentCallState;
Vibrator mVibrator;
private AudioManager mAudioManager;
- private BroadcastReceiver mKeepAliveMgrReceiver = new KeepAliveManager();
+ private BroadcastReceiver mKeepAliveMgrReceiver = new KeepAliveReceiver();
private BroadcastReceiver mOutgoingCallReceiver = null;
private Handler mHandler = new Handler() ;
diff --git a/src/org/linphone/VideoCallActivity.java b/src/org/linphone/VideoCallActivity.java
index e7549e0b1..63cfed8b4 100644
--- a/src/org/linphone/VideoCallActivity.java
+++ b/src/org/linphone/VideoCallActivity.java
@@ -68,7 +68,7 @@ public class VideoCallActivity extends Activity {
recordManager.setSurfaceView(mVideoCaptureView, phoneOrientation);
mVideoCaptureView.setZOrderOnTop(true);
- if (!recordManager.isMuted()) sendStaticImage(false);
+ if (!recordManager.isMuted()) LinphoneManager.getInstance().sendStaticImage(false);
PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK|PowerManager.ON_AFTER_RELEASE,"Linphone");
mWakeLock.acquire();
@@ -134,12 +134,7 @@ public class VideoCallActivity extends Activity {
return true;
}
- private void sendStaticImage(boolean send) {
- LinphoneCore lc = LinphoneService.getLc();
- if (lc.isIncall()) {
- lc.getCurrentCall().enableCamera(!send);
- }
- }
+
/**
* @param sv capture surface view to resize the layout
@@ -167,13 +162,13 @@ public class VideoCallActivity extends Activity {
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.videocall_menu_back_to_dialer:
- if (!recordManager.isMuted()) sendStaticImage(true);
+ if (!recordManager.isMuted()) LinphoneManager.getInstance().sendStaticImage(true);
finish();
break;
case R.id.videocall_menu_change_resolution:
BandwidthManager manager = BandwidthManager.getInstance();
manager.setUserRestriction(!manager.isUserRestriction());
- sendStaticImage(recordManager.isMuted());
+ LinphoneManager.getInstance().sendStaticImage(recordManager.isMuted());
rewriteChangeResolutionItem(item);
// Resize preview frame
@@ -188,7 +183,7 @@ public class VideoCallActivity extends Activity {
finish();
break;
case R.id.videocall_menu_toggle_camera:
- sendStaticImage(recordManager.toggleMute());
+ LinphoneManager.getInstance().sendStaticImage(recordManager.toggleMute());
rewriteToggleCameraItem(item);
break;
case R.id.videocall_menu_switch_camera:
diff --git a/src/org/linphone/ui/AddVideoButton.java b/src/org/linphone/ui/AddVideoButton.java
new file mode 100644
index 000000000..115fc7cfc
--- /dev/null
+++ b/src/org/linphone/ui/AddVideoButton.java
@@ -0,0 +1,58 @@
+/*
+AddVideoButton.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.ui;
+
+import org.linphone.CallManager;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.ImageButton;
+
+public class AddVideoButton extends ImageButton implements OnClickListener {
+
+ private AlreadyInVideoCallListener alreadyInVideoCallListener;
+
+ public AddVideoButton(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ setOnClickListener(this);
+ }
+
+ public void onClick(View v) {
+ // If no in video call; try to reinvite with video
+ boolean alreadyInVideoCall = !CallManager.getInstance().reinviteWithVideo();
+ if (alreadyInVideoCall && alreadyInVideoCallListener != null) {
+ // In video call; going back to video call activity
+ alreadyInVideoCallListener.onAlreadyInVideoCall();
+ }
+ }
+
+
+ public void setOnAlreadyInVideoCallListener(AlreadyInVideoCallListener listener) {
+ this.alreadyInVideoCallListener = listener;
+ }
+
+
+
+ public static interface AlreadyInVideoCallListener {
+ void onAlreadyInVideoCall();
+ }
+
+}
diff --git a/src/org/linphone/ui/AddressAwareWidget.java b/src/org/linphone/ui/AddressAwareWidget.java
new file mode 100644
index 000000000..5a46cc6db
--- /dev/null
+++ b/src/org/linphone/ui/AddressAwareWidget.java
@@ -0,0 +1,25 @@
+/*
+AddressAwareWidget.java
+Copyright (C) 2011 Belledonne Communications, Grenoble, France
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+package org.linphone.ui;
+
+public interface AddressAwareWidget {
+
+ void setAddressWidget(AddressText address);
+
+}
diff --git a/src/org/linphone/ui/AddressText.java b/src/org/linphone/ui/AddressText.java
index 7c70dcb5a..55faf0bd3 100644
--- a/src/org/linphone/ui/AddressText.java
+++ b/src/org/linphone/ui/AddressText.java
@@ -18,11 +18,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.linphone.ui;
+import org.linphone.LinphoneManager.AddressType;
+
import android.content.Context;
import android.util.AttributeSet;
import android.widget.EditText;
-public class AddressText extends EditText {
+public class AddressText extends EditText implements AddressType {
private String displayedName;
diff --git a/src/org/linphone/ui/CallButton.java b/src/org/linphone/ui/CallButton.java
new file mode 100644
index 000000000..e00f3da8a
--- /dev/null
+++ b/src/org/linphone/ui/CallButton.java
@@ -0,0 +1,72 @@
+/*
+CallButton.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.ui;
+
+import org.linphone.LinphoneManager;
+import org.linphone.core.LinphoneCore;
+import org.linphone.core.LinphoneCoreException;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.ImageButton;
+
+public class CallButton extends ImageButton implements OnClickListener, AddressAwareWidget {
+
+ private CallButtonListener callButtonListener;
+ private AddressText mAddress;
+
+ public CallButton(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ setOnClickListener(this);
+ }
+
+ public void onClick(View v) {
+ LinphoneCore lc = LinphoneManager.getLc();
+ if (lc.isInComingInvitePending()) {
+ try {
+ lc.acceptCall(lc.getCurrentCall());
+ } catch (LinphoneCoreException e) {
+ lc.terminateCall(lc.getCurrentCall());
+ callButtonListener.onWrongDestinationAddress();
+ }
+ return;
+ }
+ if (mAddress.getText().length() >0) {
+ LinphoneManager.getInstance().newOutgoingCall(mAddress);
+ }
+ }
+
+
+
+ public static interface CallButtonListener {
+ void onWrongDestinationAddress();
+ }
+
+
+ public void setCallButtonListerner(CallButtonListener listener) {
+ callButtonListener = listener;
+ }
+
+ public void setAddressWidget(AddressText address) {
+ mAddress = address;
+ }
+
+}
diff --git a/src/org/linphone/ui/Digit.java b/src/org/linphone/ui/Digit.java
index 6e70d7d51..40673c291 100644
--- a/src/org/linphone/ui/Digit.java
+++ b/src/org/linphone/ui/Digit.java
@@ -25,54 +25,64 @@ import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
+import android.view.View.OnLongClickListener;
import android.widget.Button;
-public class Digit extends Button {
+public class Digit extends Button implements OnLongClickListener, AddressAwareWidget {
private AddressText mAddress;
- private final void createWidget(Context context, AttributeSet attrs) {
- String ns = "http://schemas.android.com/apk/res/android";
- String dtmf = attrs.getAttributeValue(ns, "text");
- DialKeyListener lListener = new DialKeyListener(dtmf);
+
+ @Override
+ protected void onTextChanged(CharSequence text, int start, int before,
+ int after) {
+ super.onTextChanged(text, start, before, after);
+
+ if (text == null || text.length() < 1) return;
+
+ DialKeyListener lListener = new DialKeyListener();
setOnClickListener(lListener);
setOnTouchListener(lListener);
- if ("0+".equals(dtmf)) {
- setOnLongClickListener(new OnLongClickListener() {
- public boolean onLongClick(View arg0) {
- LinphoneCore lc = LinphoneManager.getLc();
- lc.stopDtmf();
- int lBegin = mAddress.getSelectionStart();
- if (lBegin == -1) {
- lBegin = mAddress.getEditableText().length();
- }
- if (lBegin >=0) {
- mAddress.getEditableText().insert(lBegin,"+");
- }
- return true;
- }
- });
+ if ("0+".equals(text)) {
+ setOnLongClickListener(this);
}
}
+ public boolean onLongClick(View arg0) {
+ // Called if "0+" dtmf
+ LinphoneCore lc = LinphoneManager.getLc();
+ lc.stopDtmf();
+ int lBegin = mAddress.getSelectionStart();
+ if (lBegin == -1) {
+ lBegin = mAddress.getEditableText().length();
+ }
+ if (lBegin >=0) {
+ mAddress.getEditableText().insert(lBegin,"+");
+ }
+ return true;
+ }
+
public Digit(Context context, AttributeSet attrs, int style) {
super(context, attrs, style);
- createWidget(context, attrs);
}
public Digit(Context context, AttributeSet attrs) {
super(context, attrs);
- createWidget(context, attrs);
}
-
-
- private class DialKeyListener implements OnClickListener ,OnTouchListener {
+ public Digit(Context context) {
+ super(context);
+ }
+
+
+
+
+ private class DialKeyListener implements OnClickListener, OnTouchListener {
final CharSequence mKeyCode;
boolean mIsDtmfStarted=false;
- DialKeyListener(String aKeyCode) {
- mKeyCode = aKeyCode.subSequence(0, 1);
+ DialKeyListener() {
+ mKeyCode = Digit.this.getText().subSequence(0, 1);
}
public void onClick(View v) {
LinphoneCore lc = LinphoneManager.getLc();
diff --git a/src/org/linphone/ui/HangCallButton.java b/src/org/linphone/ui/HangCallButton.java
index 9f51741c2..d2064c82b 100644
--- a/src/org/linphone/ui/HangCallButton.java
+++ b/src/org/linphone/ui/HangCallButton.java
@@ -1,5 +1,5 @@
/*
-SpeakerButton.java
+HangCallButton.java
Copyright (C) 2010 Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or
diff --git a/src/org/linphone/ui/MuteMicButton.java b/src/org/linphone/ui/MuteMicButton.java
index 50e6f9dbc..090e58cb0 100644
--- a/src/org/linphone/ui/MuteMicButton.java
+++ b/src/org/linphone/ui/MuteMicButton.java
@@ -19,8 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
package org.linphone.ui;
import org.linphone.LinphoneManager;
-import org.linphone.component.ToggleImageButton;
-import org.linphone.component.ToggleImageButton.OnCheckedChangeListener;
+import org.linphone.ui.ToggleImageButton.OnCheckedChangeListener;
import android.content.Context;
import android.util.AttributeSet;
diff --git a/src/org/linphone/ui/SpeakerButton.java b/src/org/linphone/ui/SpeakerButton.java
index 14bbb8c3c..e1dbfb631 100644
--- a/src/org/linphone/ui/SpeakerButton.java
+++ b/src/org/linphone/ui/SpeakerButton.java
@@ -19,8 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
package org.linphone.ui;
import org.linphone.LinphoneManager;
-import org.linphone.component.ToggleImageButton;
-import org.linphone.component.ToggleImageButton.OnCheckedChangeListener;
+import org.linphone.ui.ToggleImageButton.OnCheckedChangeListener;
import android.content.Context;
import android.util.AttributeSet;
diff --git a/src/org/linphone/component/ToggleImageButton.java b/src/org/linphone/ui/ToggleImageButton.java
similarity index 98%
rename from src/org/linphone/component/ToggleImageButton.java
rename to src/org/linphone/ui/ToggleImageButton.java
index 21cd620f2..d4e61006d 100644
--- a/src/org/linphone/component/ToggleImageButton.java
+++ b/src/org/linphone/ui/ToggleImageButton.java
@@ -16,7 +16,7 @@ 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.component;
+package org.linphone.ui;
import android.content.Context;