diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 3addcdbb3..013d29c53 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -27,7 +27,12 @@
-
+
+
+
+
+
+
@@ -143,9 +148,5 @@
-<<<<<<< HEAD
-
-=======
->>>>>>> e7697429c4475fb5f6ddfb800d5bbce0d4c20865
diff --git a/res/drawable/numpad.png b/res/drawable/numpad.png
new file mode 100644
index 000000000..f3965ef43
Binary files /dev/null and b/res/drawable/numpad.png differ
diff --git a/res/layout-land/dialer.xml b/res/layout-land/dialer.xml
index 97fcdb753..4243d0dfb 100644
--- a/res/layout-land/dialer.xml
+++ b/res/layout-land/dialer.xml
@@ -41,14 +41,14 @@
+ android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="1" android:background="@drawable/clavier_bg" android:src="@drawable/startcall_green"/>
+ android:layout_weight="1" android:background="@drawable/clavier_bg" android:src="@drawable/stopcall_red"/>
-
-
+
+
diff --git a/res/layout/incall_view.xml b/res/layout/incall_view.xml
new file mode 100644
index 000000000..74a4bd303
--- /dev/null
+++ b/res/layout/incall_view.xml
@@ -0,0 +1,48 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/layout/numpad.xml b/res/layout/numpad.xml
index c1c99e4df..9e65e4805 100644
--- a/res/layout/numpad.xml
+++ b/res/layout/numpad.xml
@@ -3,25 +3,25 @@
-
+
-
+
-
+
-
+
diff --git a/src/org/linphone/DialerActivity.java b/src/org/linphone/DialerActivity.java
index 9daff6f58..723011bf5 100644
--- a/src/org/linphone/DialerActivity.java
+++ b/src/org/linphone/DialerActivity.java
@@ -20,12 +20,13 @@ package org.linphone;
import org.linphone.LinphoneManager.NewOutgoingCallUiListener;
import org.linphone.LinphoneService.LinphoneGuiListener;
+import org.linphone.core.CallDirection;
import org.linphone.core.LinphoneCall;
import org.linphone.core.LinphoneCore;
import org.linphone.core.LinphoneCall.State;
import org.linphone.core.video.AndroidCameraRecordManager;
import org.linphone.ui.AddVideoButton;
-import org.linphone.ui.AddressAwareWidget;
+import org.linphone.ui.AddressAware;
import org.linphone.ui.AddressText;
import org.linphone.ui.CallButton;
import org.linphone.ui.EraseButton;
@@ -179,7 +180,7 @@ public class DialerActivity extends Activity implements LinphoneGuiListener, Alr
finish();
}
- AddressAwareWidget numpad = (AddressAwareWidget) findViewById(R.id.Dialer);
+ AddressAware numpad = (AddressAware) findViewById(R.id.Dialer);
if (numpad != null)
numpad.setAddressWidget(mAddress);
@@ -196,6 +197,7 @@ public class DialerActivity extends Activity implements LinphoneGuiListener, Alr
checkAccount = false;
}
}
+
}
@@ -320,14 +322,12 @@ public class DialerActivity extends Activity implements LinphoneGuiListener, Alr
private void startVideoView(int requestCode) {
- Intent lIntent = new Intent();
- lIntent.setClass(this, VideoCallActivity.class);
+ Intent lIntent = new Intent().setClass(this, VideoCallActivity.class);
startActivityForResult(lIntent,requestCode);
}
private void enterIncallMode(LinphoneCore lc) {
- LinphoneManager m = LinphoneManager.getInstance();
mCallControlRow.setVisibility(View.GONE);
mInCallControlRow.setVisibility(View.VISIBLE);
mAddressLayout.setVisibility(View.GONE);
@@ -335,17 +335,24 @@ public class DialerActivity extends Activity implements LinphoneGuiListener, Alr
mCall.setEnabled(false);
updateIncallVideoCallButton();
mHangup.setEnabled(true);
- mDisplayNameView.setText(m.extractADisplayName());
+ mDisplayNameView.setText(LinphoneManager.getInstance().extractADisplayName());
loadMicAndSpeakerUiStateFromManager();
- setVolumeControlStream(AudioManager.STREAM_VOICE_CALL);
+// setVolumeControlStream(AudioManager.STREAM_VOICE_CALL);
LinphoneActivity.instance().startProxymitySensor();
if (!mWakeLock.isHeld()) mWakeLock.acquire();
-
+
}
+ private void openIncallActivity(CharSequence callerName) {
+ startActivity(new Intent()
+ .setClass(this, IncallActivity.class)
+ .putExtra(IncallActivity.CONTACT_KEY, callerName));
+ }
+
+
private void updateIncallVideoCallButton() {
boolean prefVideoEnabled = LinphoneManager.getInstance().isVideoEnabled();
if (prefVideoEnabled && !mCall.isEnabled()) {
@@ -453,12 +460,15 @@ public class DialerActivity extends Activity implements LinphoneGuiListener, Alr
LinphoneCore lc = LinphoneManager.getLc();
if (state == LinphoneCall.State.OutgoingInit) {
enterIncallMode(lc);
- LinphoneManager.getInstance().routeAudioToReceiver();
+ openIncallActivity(mDisplayNameView.getText());
} else if (state == LinphoneCall.State.IncomingReceived) {
LinphoneManager.getInstance().resetCameraFromPreferences();
callPending(call);
} else if (state == LinphoneCall.State.Connected) {
- enterIncallMode(lc);
+ if (call.getDirection() == CallDirection.Incoming) {
+ enterIncallMode(lc);
+ openIncallActivity(mDisplayNameView.getText());
+ }
} else if (state == LinphoneCall.State.Error) {
if (mWakeLock.isHeld()) mWakeLock.release();
Toast toast = Toast.makeText(this
@@ -470,9 +480,7 @@ public class DialerActivity extends Activity implements LinphoneGuiListener, Alr
exitCallMode();
} else if (state == LinphoneCall.State.StreamsRunning) {
if (LinphoneManager.getLc().getCurrentCall().getCurrentParamsCopy().getVideoEnabled()) {
- if (!VideoCallActivity.launched) {
- startVideoView(VIDEO_VIEW_ACTIVITY);
- }
+ startVideoView(VIDEO_VIEW_ACTIVITY);
}
}
}
diff --git a/src/org/linphone/IncallActivity.java b/src/org/linphone/IncallActivity.java
new file mode 100644
index 000000000..79cb0d972
--- /dev/null
+++ b/src/org/linphone/IncallActivity.java
@@ -0,0 +1,132 @@
+/*
+IncallActivity.java
+Copyright (C) 2011 Belledonne Communications, Grenoble, France
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+package org.linphone;
+
+import java.util.Timer;
+import java.util.TimerTask;
+
+import org.linphone.ui.AddVideoButton;
+import org.linphone.ui.HangCallButton;
+import org.linphone.ui.AddVideoButton.AlreadyInVideoCallListener;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.os.Handler;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.TextView;
+
+public class IncallActivity extends Activity implements OnClickListener {
+
+ public static final String CONTACT_KEY = "contact";
+ private View numpadClose;
+ private View numpadShow;
+ private View numpad;
+ private View buttonsZone;
+ private HangCallButton hangButton;
+ private Timer timer = new Timer();
+ private TimerTask task;
+ private TextView elapsedTime;
+ private Handler handler = new Handler();
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.incall_view);
+
+ numpad = findViewById(R.id.incallDialer);
+ buttonsZone = findViewById(R.id.incallButtonsZone);
+
+ numpadClose = findViewById(R.id.incallNumpadClose);
+ numpadClose.setOnClickListener(this);
+
+ numpadShow = findViewById(R.id.incallNumpadShow);
+ numpadShow.setOnClickListener(this);
+
+ hangButton = (HangCallButton) findViewById(R.id.incallHang);
+ hangButton.setOnClickListener(this);
+
+ TextView contact = (TextView) findViewById(R.id.incallContactName);
+ if (getIntent().getExtras() != null) {
+ contact.setText(getIntent().getExtras().getCharSequence(CONTACT_KEY));
+ } else {
+ contact.setVisibility(View.GONE);
+ }
+
+ elapsedTime = (TextView) findViewById(R.id.incallElapsedTime);
+
+ AddVideoButton addVideoButton = (AddVideoButton) findViewById(R.id.AddVideo);
+ addVideoButton.setOnAlreadyInVideoCallListener(DialerActivity.instance());
+ }
+
+ public void onClick(View v) {
+ if (v == numpadClose) {
+ numpad.setVisibility(View.GONE);
+ numpadClose.setVisibility(View.GONE);
+ buttonsZone.setVisibility(View.VISIBLE);
+ } else if (v == numpadShow) {
+ buttonsZone.setVisibility(View.GONE);
+ numpad.setVisibility(View.VISIBLE);
+ numpadClose.setVisibility(View.VISIBLE);
+ } else if (v == hangButton) {
+ hangButton.onClick(v);
+ finish();
+ }
+ }
+
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+
+ task = new TimerTask() {
+ @Override
+ public void run() {
+ if (LinphoneManager.getLc().isIncall()) {
+ final int duration = LinphoneManager.getLc().getCurrentCall().getDuration();
+ if (duration != 0) {
+ handler.post(new Runnable() {
+ public void run() {
+ elapsedTime.setText(String.valueOf(duration));
+ }
+ });
+
+ }
+ }
+ }
+ };
+
+ timer.scheduleAtFixedRate(task, 0, 1000);
+ }
+
+ @Override
+ protected void onPause() {
+ super.onPause();
+
+ if (task != null) {
+ task.cancel();
+ task = null;
+ }
+ }
+
+ void showVideoCallActivity() {
+ startActivity(new Intent().setClass(this, VideoCallActivity.class));
+ }
+}
diff --git a/src/org/linphone/LinphoneManager.java b/src/org/linphone/LinphoneManager.java
index 50b2ea57f..f2270b70f 100644
--- a/src/org/linphone/LinphoneManager.java
+++ b/src/org/linphone/LinphoneManager.java
@@ -18,6 +18,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.linphone;
+import static android.media.AudioManager.*;
+import static org.linphone.core.LinphoneCall.State.*;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -25,6 +27,7 @@ import java.io.InputStream;
import java.util.Timer;
import java.util.TimerTask;
+import org.linphone.core.Hacks;
import org.linphone.core.LinphoneAddress;
import org.linphone.core.LinphoneAuthInfo;
import org.linphone.core.LinphoneCall;
@@ -140,7 +143,7 @@ public final class LinphoneManager implements LinphoneCoreListener {
public void routeAudioToSpeaker() {
if (Integer.parseInt(Build.VERSION.SDK) <= 4 /*4 &&mAudioManager.isSpeakerphoneOn();
}
@@ -254,15 +257,14 @@ public final class LinphoneManager implements LinphoneCoreListener {
}
public void playDtmf(ContentResolver r, char dtmf) {
- boolean speaker = true;
try {
if (Settings.System.getInt(r, Settings.System.DTMF_TONE_WHEN_DIALING) == 0) {
// audible touch disabled: don't play on speaker, only send in outgoing stream
- speaker = false;
+ return;
}
} catch (SettingNotFoundException e) {}
- getLc().playDtmf(dtmf, -1, speaker);
+ getLc().playDtmf(dtmf, -1);
}
@@ -313,7 +315,6 @@ public final class LinphoneManager implements LinphoneCoreListener {
public void run() {
mLc.iterate();
}
-
};
mTimer.scheduleAtFixedRate(lTask, 0, 100);
@@ -582,7 +583,7 @@ public final class LinphoneManager implements LinphoneCoreListener {
public void callState(final LinphoneCore lc,final LinphoneCall call, final State state, final String message) {
Log.i(TAG, "new state ["+state+"]");
- if (state == LinphoneCall.State.IncomingReceived && !call.equals(lc.getCurrentCall())) {
+ if (state == IncomingReceived && !call.equals(lc.getCurrentCall())) {
if (call.getReplacedCall()==null){
//no multicall support, just decline
lc.terminateCall(call);
@@ -590,18 +591,23 @@ public final class LinphoneManager implements LinphoneCoreListener {
return;
}
- serviceListener.onCallStateChanged(call, state, message);
- if (state == LinphoneCall.State.IncomingReceived) {
+ if (state == IncomingReceived) {
startRinging();
}
- if (mCurrentCallState == LinphoneCall.State.IncomingReceived) {
+ if (mCurrentCallState == IncomingReceived) {
//previous state was ringing, so stop ringing
stopRinging();
//routeAudioToReceiver();
}
+
+ if (state == CallEnd || state == Error) {
+ mAudioManager.setMode(MODE_NORMAL);
+ }
+
mCurrentCallState=state;
+ serviceListener.onCallStateChanged(call, state, message);
}
@@ -622,14 +628,18 @@ public final class LinphoneManager implements LinphoneCoreListener {
private synchronized void startRinging() {
+ if (Hacks.isGalaxyS()) {
+ mAudioManager.setMode(MODE_RINGTONE);
+ }
+
try {
- if (mAudioManager.shouldVibrate(AudioManager.VIBRATE_TYPE_RINGER) && mVibrator !=null) {
+ if (mAudioManager.shouldVibrate(VIBRATE_TYPE_RINGER) && mVibrator !=null) {
long[] patern = {0,1000,1000};
mVibrator.vibrate(patern, 1);
}
if (mRingerPlayer == null) {
mRingerPlayer = new MediaPlayer();
- mRingerPlayer.setAudioStreamType(AudioManager.STREAM_RING);
+ mRingerPlayer.setAudioStreamType(STREAM_RING);
serviceListener.onRingerPlayerCreated(mRingerPlayer);
mRingerPlayer.prepare();
mRingerPlayer.setLooping(true);
@@ -652,6 +662,10 @@ public final class LinphoneManager implements LinphoneCoreListener {
if (mVibrator!=null) {
mVibrator.cancel();
}
+
+ if (Hacks.isGalaxyS()) {
+ mAudioManager.setMode(MODE_IN_CALL);
+ }
}
public String extractADisplayName() {
@@ -675,6 +689,17 @@ public final class LinphoneManager implements LinphoneCoreListener {
public boolean isVideoEnabled() {
return mPref.getBoolean(getString(R.string.pref_video_enable_key), false);
}
-
-
+
+ public void setAudioModeIncallForGalaxyS() {
+ if (!Hacks.isGalaxyS()) return;
+
+ try {
+ stopRinging();
+ Thread.sleep(100);
+ mAudioManager.setMode(AudioManager.MODE_IN_CALL);
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ /* ops */
+ }
+ }
}
diff --git a/src/org/linphone/LinphoneService.java b/src/org/linphone/LinphoneService.java
index adeaed939..f20875ca9 100644
--- a/src/org/linphone/LinphoneService.java
+++ b/src/org/linphone/LinphoneService.java
@@ -22,6 +22,7 @@ import java.io.IOException;
import org.linphone.LinphoneManager.LinphoneServiceListener;
import org.linphone.LinphoneManager.NewOutgoingCallUiListener;
+import org.linphone.core.Hacks;
import org.linphone.core.LinphoneCall;
import org.linphone.core.LinphoneCore;
import org.linphone.core.LinphoneCall.State;
diff --git a/src/org/linphone/Hacks.java b/src/org/linphone/core/Hacks.java
similarity index 98%
rename from src/org/linphone/Hacks.java
rename to src/org/linphone/core/Hacks.java
index bfc323d33..49c3125ae 100644
--- a/src/org/linphone/Hacks.java
+++ b/src/org/linphone/core/Hacks.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;
+package org.linphone.core;
import android.media.AudioManager;
import android.os.Build;
diff --git a/src/org/linphone/core/LinphoneCallImpl.java b/src/org/linphone/core/LinphoneCallImpl.java
index a7104ffef..b60d92fda 100644
--- a/src/org/linphone/core/LinphoneCallImpl.java
+++ b/src/org/linphone/core/LinphoneCallImpl.java
@@ -36,6 +36,7 @@ class LinphoneCallImpl implements LinphoneCall {
private native void enableEchoLimiter(long nativePtr,boolean enable);
private native boolean isEchoLimiterEnabled(long nativePtr);
private native long getReplacedCall(long nativePtr);
+ private native int getDuration(long nativePtr);
protected LinphoneCallImpl(long aNativePtr) {
nativePtr = aNativePtr;
@@ -96,5 +97,9 @@ class LinphoneCallImpl implements LinphoneCall {
}
return null;
}
+
+ public int getDuration() {
+ return getDuration(nativePtr);
+ }
}
diff --git a/src/org/linphone/core/LinphoneCoreImpl.java b/src/org/linphone/core/LinphoneCoreImpl.java
index 533ee8b97..61afcd5d0 100644
--- a/src/org/linphone/core/LinphoneCoreImpl.java
+++ b/src/org/linphone/core/LinphoneCoreImpl.java
@@ -64,7 +64,7 @@ class LinphoneCoreImpl implements LinphoneCore {
private native void enableEchoCancellation(long nativePtr,boolean enable);
private native boolean isEchoCancellationEnabled(long nativePtr);
private native long getCurrentCall(long nativePtr) ;
- private native void playDtmf(long nativePtr,char dtmf,int duration, boolean speaker);
+ private native void playDtmf(long nativePtr,char dtmf,int duration);
private native void stopDtmf(long nativePtr);
private native void setVideoWindowId(long nativePtr, Object wid);
private native void setPreviewWindowId(long nativePtr, Object wid);
@@ -298,8 +298,8 @@ class LinphoneCoreImpl implements LinphoneCore {
// TODO Auto-generated method stub
return false;
}
- public void playDtmf(char number, int duration, boolean speaker) {
- playDtmf(nativePtr,number, duration, speaker);
+ public void playDtmf(char number, int duration) {
+ playDtmf(nativePtr,number, duration);
}
public void stopDtmf() {
@@ -439,4 +439,7 @@ class LinphoneCoreImpl implements LinphoneCore {
public void startEchoCalibration(Object data) throws LinphoneCoreException {
startEchoCalibration(nativePtr, data);
}
+ public Transport getSignalingTransport() {
+ throw new RuntimeException("Not implemented");
+ }
}
diff --git a/src/org/linphone/core/video/AndroidCameraConf.java b/src/org/linphone/core/video/AndroidCameraConf.java
index 1d430082e..065ea22af 100644
--- a/src/org/linphone/core/video/AndroidCameraConf.java
+++ b/src/org/linphone/core/video/AndroidCameraConf.java
@@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.linphone.core.video;
-import org.linphone.Hacks;
+import org.linphone.core.Hacks;
import android.util.Log;
diff --git a/src/org/linphone/ui/AddVideoButton.java b/src/org/linphone/ui/AddVideoButton.java
index 1d519d2ff..6a2c8fec2 100644
--- a/src/org/linphone/ui/AddVideoButton.java
+++ b/src/org/linphone/ui/AddVideoButton.java
@@ -36,7 +36,9 @@ public class AddVideoButton extends ImageButton implements OnClickListener {
}
public void onClick(View v) {
- // If no in video call; try to reinvite with video
+ if (!LinphoneManager.getLc().isIncall()) return;
+
+ // If not in video call; try to reinvite with video
boolean alreadyInVideoCall = !LinphoneManager.reinviteWithVideo();
if (alreadyInVideoCall && alreadyInVideoCallListener != null) {
// In video call; going back to video call activity
diff --git a/src/org/linphone/ui/AddressAwareWidget.java b/src/org/linphone/ui/AddressAware.java
similarity index 95%
rename from src/org/linphone/ui/AddressAwareWidget.java
rename to src/org/linphone/ui/AddressAware.java
index 451271e3f..61c02fa71 100644
--- a/src/org/linphone/ui/AddressAwareWidget.java
+++ b/src/org/linphone/ui/AddressAware.java
@@ -20,7 +20,7 @@ package org.linphone.ui;
-public interface AddressAwareWidget {
+public interface AddressAware {
void setAddressWidget(AddressText address);
diff --git a/src/org/linphone/ui/CallButton.java b/src/org/linphone/ui/CallButton.java
index 05a54f2b7..c8dba18a1 100644
--- a/src/org/linphone/ui/CallButton.java
+++ b/src/org/linphone/ui/CallButton.java
@@ -30,7 +30,7 @@ import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.Toast;
-public class CallButton extends ImageButton implements OnClickListener, AddressAwareWidget {
+public class CallButton extends ImageButton implements OnClickListener, AddressAware {
private AddressText mAddress;
@@ -40,6 +40,7 @@ public class CallButton extends ImageButton implements OnClickListener, AddressA
}
public void onClick(View v) {
+ LinphoneManager.getInstance().setAudioModeIncallForGalaxyS();
LinphoneCore lc = LinphoneManager.getLc();
if (lc.isInComingInvitePending()) {
try {
diff --git a/src/org/linphone/ui/Digit.java b/src/org/linphone/ui/Digit.java
index 023bbd5d0..986281b88 100644
--- a/src/org/linphone/ui/Digit.java
+++ b/src/org/linphone/ui/Digit.java
@@ -27,7 +27,7 @@ import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
-public class Digit extends Button implements AddressAwareWidget {
+public class Digit extends Button implements AddressAware {
private AddressText mAddress;
@@ -84,7 +84,7 @@ public class Digit extends Button implements AddressAwareWidget {
if (lc.isIncall()) {
lc.sendDtmf(mKeyCode.charAt(0));
- } else {
+ } else if (mAddress != null) {
int lBegin = mAddress.getSelectionStart();
if (lBegin == -1) {
lBegin = mAddress.getEditableText().length();
@@ -113,6 +113,9 @@ public class Digit extends Button implements AddressAwareWidget {
// Called if "0+" dtmf
LinphoneCore lc = LinphoneManager.getLc();
lc.stopDtmf();
+
+ if (mAddress == null) return true;
+
int lBegin = mAddress.getSelectionStart();
if (lBegin == -1) {
lBegin = mAddress.getEditableText().length();
diff --git a/src/org/linphone/ui/IncallTimer.java b/src/org/linphone/ui/IncallTimer.java
new file mode 100644
index 000000000..80992fa60
--- /dev/null
+++ b/src/org/linphone/ui/IncallTimer.java
@@ -0,0 +1,93 @@
+/*
+IncallTimer.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;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.widget.TextView;
+
+/**
+ * Widget displaying a time
+ * @author Guillaume Beraudo
+ *
+ */
+public class IncallTimer extends TextView {
+
+ public IncallTimer(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ }
+
+ public IncallTimer(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public IncallTimer(Context context) {
+ super(context);
+ }
+
+
+ @Override
+ public void setText(CharSequence text, BufferType type) {
+ try {
+ int seconds = Integer.parseInt(text.toString());
+ super.setText(formatTime(seconds), type);
+ } catch (Throwable e) {
+ super.setText(text, type);
+ }
+ }
+
+ protected String formatTime(final int seconds) {
+ String time = String.format("%02d : %02d",
+ (seconds / 60) % 60,
+ seconds % 60);
+
+ int hours = seconds / 3600;
+ if (hours != 0) {
+ return hours + " - " + time;
+ } else {
+ return time;
+ }
+ }
+
+
+ /**
+ * Format time as "days - hh : mm : ss".
+ * @param seconds
+ * @return formated string
+ */
+ /*protected String formatTime(final int seconds) {
+ int value = seconds;
+ StringBuilder sb = new StringBuilder();
+
+ for (int base : Arrays.asList(60, 60, 24)) {
+ if (value == 0) break;
+
+ int remainder = value % base;
+ value /= base;
+
+ if (sb.length() != 0) sb.insert(0, " : ");
+ sb.insert(0, remainder < 10 ? "0" + remainder : remainder);
+ }
+
+ if (value != 0) sb.insert(0, value + " - ");
+
+ return sb.toString();
+ }
+ */
+}
diff --git a/src/org/linphone/ui/Numpad.java b/src/org/linphone/ui/Numpad.java
index 5070c4842..cfbcbfb92 100644
--- a/src/org/linphone/ui/Numpad.java
+++ b/src/org/linphone/ui/Numpad.java
@@ -30,7 +30,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
-public class Numpad extends LinearLayout implements AddressAwareWidget {
+public class Numpad extends LinearLayout implements AddressAware {
public Numpad(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -39,22 +39,22 @@ public class Numpad extends LinearLayout implements AddressAwareWidget {
}
public void setAddressWidget(AddressText address) {
- for (AddressAwareWidget v : retrieveChildren(this)) {
+ for (AddressAware v : retrieveChildren(this)) {
v.setAddressWidget(address);
}
}
- private Collection retrieveChildren(ViewGroup viewGroup) {
- final Collection views = new ArrayList();
+ private Collection retrieveChildren(ViewGroup viewGroup) {
+ final Collection views = new ArrayList();
for (int i = 0; i < viewGroup.getChildCount(); i++) {
View v = viewGroup.getChildAt(i);
if (v instanceof ViewGroup) {
views.addAll(retrieveChildren((ViewGroup) v));
} else {
- if (v instanceof AddressAwareWidget)
- views.add((AddressAwareWidget) v);
+ if (v instanceof AddressAware)
+ views.add((AddressAware) v);
}
}