Incall view.
Hack for Audio with Galaxy S
This commit is contained in:
parent
6d38874a4b
commit
75a4d15ac0
19 changed files with 379 additions and 57 deletions
|
@ -27,7 +27,12 @@
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<activity android:name=".IncallActivity">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
<activity android:name=".LinphonePreferencesActivity">
|
<activity android:name=".LinphonePreferencesActivity">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
@ -143,9 +148,5 @@
|
||||||
<uses-permission android:name="android.permission.VIBRATE"></uses-permission>
|
<uses-permission android:name="android.permission.VIBRATE"></uses-permission>
|
||||||
<uses-permission android:name="android.permission.CAMERA" />
|
<uses-permission android:name="android.permission.CAMERA" />
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
|
|
||||||
=======
|
|
||||||
>>>>>>> e7697429c4475fb5f6ddfb800d5bbce0d4c20865
|
|
||||||
<supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:anyDensity="true"/>
|
<supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:anyDensity="true"/>
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|
BIN
res/drawable/numpad.png
Normal file
BIN
res/drawable/numpad.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
|
@ -41,14 +41,14 @@
|
||||||
|
|
||||||
<LinearLayout android:id="@+id/CallControlRow" android:layout_height="wrap_content" android:layout_width="fill_parent" android:gravity="bottom">
|
<LinearLayout android:id="@+id/CallControlRow" android:layout_height="wrap_content" android:layout_width="fill_parent" android:gravity="bottom">
|
||||||
<org.linphone.ui.CallButton android:id="@+id/Call"
|
<org.linphone.ui.CallButton android:id="@+id/Call"
|
||||||
android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="0.25" android:background="@drawable/clavier_bg" android:src="@drawable/startcall_green"/>
|
android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="1" android:background="@drawable/clavier_bg" android:src="@drawable/startcall_green"/>
|
||||||
<org.linphone.ui.HangCallButton android:id="@+id/Decline" android:layout_height="fill_parent" android:layout_width="fill_parent"
|
<org.linphone.ui.HangCallButton android:id="@+id/Decline" android:layout_height="fill_parent" android:layout_width="fill_parent"
|
||||||
android:layout_weight="0.25" android:background="@drawable/clavier_bg" android:src="@drawable/stopcall_red"/>
|
android:layout_weight="1" android:background="@drawable/clavier_bg" android:src="@drawable/stopcall_red"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout android:id="@+id/IncallControlRow" android:layout_height="wrap_content" android:layout_width="fill_parent" android:gravity="bottom">
|
<LinearLayout android:id="@+id/IncallControlRow" android:layout_height="wrap_content" android:layout_width="fill_parent" android:gravity="bottom">
|
||||||
<org.linphone.ui.AddVideoButton android:id="@+id/AddVideo" android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="0.25" android:src="@drawable/startvideo_green" android:background="@drawable/clavier_bg"/>
|
<org.linphone.ui.AddVideoButton android:id="@+id/AddVideo" android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="1" android:src="@drawable/startvideo_green" android:background="@drawable/clavier_bg"/>
|
||||||
<org.linphone.ui.HangCallButton android:id="@+id/HangUp" android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="0.25" android:src="@drawable/stopcall_red" android:background="@drawable/clavier_bg"/>
|
<org.linphone.ui.HangCallButton android:id="@+id/HangUp" android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="1" android:src="@drawable/stopcall_red" android:background="@drawable/clavier_bg"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
|
48
res/layout/incall_view.xml
Normal file
48
res/layout/incall_view.xml
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical">
|
||||||
|
|
||||||
|
<RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content">
|
||||||
|
<TextView android:id="@+id/incallContactName" android:layout_width="fill_parent" android:layout_height="wrap_content"/>
|
||||||
|
<org.linphone.ui.IncallTimer android:id="@+id/incallElapsedTime" android:text="Calling..." android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/incallContactName"/>
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<View android:layout_weight="1" android:layout_width="0px" android:layout_height="0px" android:visibility="invisible"/>
|
||||||
|
|
||||||
|
|
||||||
|
<FrameLayout android:layout_gravity="center" android:layout_margin="20dip"
|
||||||
|
android:layout_width="wrap_content" android:layout_height="wrap_content">
|
||||||
|
<TableLayout android:id="@+id/incallButtonsZone"
|
||||||
|
android:layout_width="wrap_content" android:layout_height="wrap_content">
|
||||||
|
<TableRow>
|
||||||
|
<org.linphone.ui.MuteMicButton checked="@drawable/mic_muted" unchecked="@drawable/mic_active" android:layout_width="wrap_content" android:layout_height="wrap_content" />
|
||||||
|
<RelativeLayout android:layout_gravity="center" ><Button android:id="@+id/incallNumpadShow" android:background="@drawable/numpad"
|
||||||
|
android:layout_width="wrap_content" android:layout_height="wrap_content"/></RelativeLayout>
|
||||||
|
<org.linphone.ui.SpeakerButton checked="@drawable/speaker_32_on" unchecked="@drawable/speaker_32_off" android:layout_width="wrap_content" android:layout_height="wrap_content"/>
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
<TableRow>
|
||||||
|
<org.linphone.ui.AddVideoButton android:id="@+id/AddVideo" android:src="@drawable/startvideo_green"
|
||||||
|
android:layout_height="wrap_content" android:layout_width="wrap_content" android:height="10px"
|
||||||
|
android:layout_column="1" />
|
||||||
|
</TableRow>
|
||||||
|
</TableLayout>
|
||||||
|
|
||||||
|
<org.linphone.ui.Numpad android:id="@+id/incallDialer" android:visibility="gone" android:layout_width="wrap_content" android:layout_height="wrap_content"/>
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
<View android:layout_weight="1" android:layout_width="0px" android:layout_height="0px" android:visibility="invisible"/>
|
||||||
|
|
||||||
|
|
||||||
|
<LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content">
|
||||||
|
<org.linphone.ui.HangCallButton android:id="@+id/incallHang" android:layout_width="wrap_content" android:layout_height="wrap_content"
|
||||||
|
android:src="@drawable/stopcall_red" android:background="@drawable/clavier_bg" android:layout_weight="10" />
|
||||||
|
|
||||||
|
<Button android:text="Close numpad" android:id="@+id/incallNumpadClose"
|
||||||
|
android:visibility="gone" android:layout_width="wrap_content"
|
||||||
|
android:layout_height="fill_parent" android:background="@drawable/clavier_bg" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
|
@ -3,25 +3,25 @@
|
||||||
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1">
|
android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1">
|
||||||
|
|
||||||
<TableRow android:layout_height="fill_parent" android:layout_weight="1" android:layout_width="fill_parent">
|
<TableRow android:layout_weight="1">
|
||||||
<org.linphone.ui.Digit android:id="@+id/Digit1" android:text="1" style="@style/DialerDigit" />
|
<org.linphone.ui.Digit android:id="@+id/Digit1" android:text="1" style="@style/DialerDigit" />
|
||||||
<org.linphone.ui.Digit android:id="@+id/Digit2" android:text="2" style="@style/DialerDigit" />
|
<org.linphone.ui.Digit android:id="@+id/Digit2" android:text="2" style="@style/DialerDigit" />
|
||||||
<org.linphone.ui.Digit android:id="@+id/Digit3" android:text="3" style="@style/DialerDigit" />
|
<org.linphone.ui.Digit android:id="@+id/Digit3" android:text="3" style="@style/DialerDigit" />
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|
||||||
<TableRow android:layout_height="fill_parent" android:layout_weight="1" android:layout_width="fill_parent">
|
<TableRow android:layout_weight="1">
|
||||||
<org.linphone.ui.Digit android:id="@+id/Digit4" android:text="4" style="@style/DialerDigit" />
|
<org.linphone.ui.Digit android:id="@+id/Digit4" android:text="4" style="@style/DialerDigit" />
|
||||||
<org.linphone.ui.Digit android:id="@+id/Digit5" android:text="5" style="@style/DialerDigit" />
|
<org.linphone.ui.Digit android:id="@+id/Digit5" android:text="5" style="@style/DialerDigit" />
|
||||||
<org.linphone.ui.Digit android:id="@+id/Digit6" android:text="6" style="@style/DialerDigit" />
|
<org.linphone.ui.Digit android:id="@+id/Digit6" android:text="6" style="@style/DialerDigit" />
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|
||||||
<TableRow android:layout_weight="1" android:layout_height="fill_parent" android:layout_width="fill_parent">
|
<TableRow android:layout_weight="1">
|
||||||
<org.linphone.ui.Digit android:id="@+id/Digit7" android:text="7" style="@style/DialerDigit" />
|
<org.linphone.ui.Digit android:id="@+id/Digit7" android:text="7" style="@style/DialerDigit" />
|
||||||
<org.linphone.ui.Digit android:id="@+id/Digit8" android:text="8" style="@style/DialerDigit" />
|
<org.linphone.ui.Digit android:id="@+id/Digit8" android:text="8" style="@style/DialerDigit" />
|
||||||
<org.linphone.ui.Digit android:id="@+id/Digit9" android:text="9" style="@style/DialerDigit" />
|
<org.linphone.ui.Digit android:id="@+id/Digit9" android:text="9" style="@style/DialerDigit" />
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|
||||||
<TableRow android:layout_weight="1" android:layout_height="fill_parent" android:layout_width="fill_parent">
|
<TableRow android:layout_weight="1">
|
||||||
<org.linphone.ui.Digit android:id="@+id/DigitStar" android:text="*" style="@style/DialerDigit" />
|
<org.linphone.ui.Digit android:id="@+id/DigitStar" android:text="*" style="@style/DialerDigit" />
|
||||||
<org.linphone.ui.Digit android:id="@+id/Digit00" android:text="0+" style="@style/DialerDigit" />
|
<org.linphone.ui.Digit android:id="@+id/Digit00" android:text="0+" style="@style/DialerDigit" />
|
||||||
<org.linphone.ui.Digit android:id="@+id/DigitHash" android:text="#" style="@style/DialerDigit" />
|
<org.linphone.ui.Digit android:id="@+id/DigitHash" android:text="#" style="@style/DialerDigit" />
|
||||||
|
|
|
@ -20,12 +20,13 @@ package org.linphone;
|
||||||
|
|
||||||
import org.linphone.LinphoneManager.NewOutgoingCallUiListener;
|
import org.linphone.LinphoneManager.NewOutgoingCallUiListener;
|
||||||
import org.linphone.LinphoneService.LinphoneGuiListener;
|
import org.linphone.LinphoneService.LinphoneGuiListener;
|
||||||
|
import org.linphone.core.CallDirection;
|
||||||
import org.linphone.core.LinphoneCall;
|
import org.linphone.core.LinphoneCall;
|
||||||
import org.linphone.core.LinphoneCore;
|
import org.linphone.core.LinphoneCore;
|
||||||
import org.linphone.core.LinphoneCall.State;
|
import org.linphone.core.LinphoneCall.State;
|
||||||
import org.linphone.core.video.AndroidCameraRecordManager;
|
import org.linphone.core.video.AndroidCameraRecordManager;
|
||||||
import org.linphone.ui.AddVideoButton;
|
import org.linphone.ui.AddVideoButton;
|
||||||
import org.linphone.ui.AddressAwareWidget;
|
import org.linphone.ui.AddressAware;
|
||||||
import org.linphone.ui.AddressText;
|
import org.linphone.ui.AddressText;
|
||||||
import org.linphone.ui.CallButton;
|
import org.linphone.ui.CallButton;
|
||||||
import org.linphone.ui.EraseButton;
|
import org.linphone.ui.EraseButton;
|
||||||
|
@ -179,7 +180,7 @@ public class DialerActivity extends Activity implements LinphoneGuiListener, Alr
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
AddressAwareWidget numpad = (AddressAwareWidget) findViewById(R.id.Dialer);
|
AddressAware numpad = (AddressAware) findViewById(R.id.Dialer);
|
||||||
if (numpad != null)
|
if (numpad != null)
|
||||||
numpad.setAddressWidget(mAddress);
|
numpad.setAddressWidget(mAddress);
|
||||||
|
|
||||||
|
@ -196,6 +197,7 @@ public class DialerActivity extends Activity implements LinphoneGuiListener, Alr
|
||||||
checkAccount = false;
|
checkAccount = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -320,14 +322,12 @@ public class DialerActivity extends Activity implements LinphoneGuiListener, Alr
|
||||||
|
|
||||||
|
|
||||||
private void startVideoView(int requestCode) {
|
private void startVideoView(int requestCode) {
|
||||||
Intent lIntent = new Intent();
|
Intent lIntent = new Intent().setClass(this, VideoCallActivity.class);
|
||||||
lIntent.setClass(this, VideoCallActivity.class);
|
|
||||||
startActivityForResult(lIntent,requestCode);
|
startActivityForResult(lIntent,requestCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void enterIncallMode(LinphoneCore lc) {
|
private void enterIncallMode(LinphoneCore lc) {
|
||||||
LinphoneManager m = LinphoneManager.getInstance();
|
|
||||||
mCallControlRow.setVisibility(View.GONE);
|
mCallControlRow.setVisibility(View.GONE);
|
||||||
mInCallControlRow.setVisibility(View.VISIBLE);
|
mInCallControlRow.setVisibility(View.VISIBLE);
|
||||||
mAddressLayout.setVisibility(View.GONE);
|
mAddressLayout.setVisibility(View.GONE);
|
||||||
|
@ -335,17 +335,24 @@ public class DialerActivity extends Activity implements LinphoneGuiListener, Alr
|
||||||
mCall.setEnabled(false);
|
mCall.setEnabled(false);
|
||||||
updateIncallVideoCallButton();
|
updateIncallVideoCallButton();
|
||||||
mHangup.setEnabled(true);
|
mHangup.setEnabled(true);
|
||||||
mDisplayNameView.setText(m.extractADisplayName());
|
mDisplayNameView.setText(LinphoneManager.getInstance().extractADisplayName());
|
||||||
|
|
||||||
loadMicAndSpeakerUiStateFromManager();
|
loadMicAndSpeakerUiStateFromManager();
|
||||||
setVolumeControlStream(AudioManager.STREAM_VOICE_CALL);
|
// setVolumeControlStream(AudioManager.STREAM_VOICE_CALL);
|
||||||
|
|
||||||
LinphoneActivity.instance().startProxymitySensor();
|
LinphoneActivity.instance().startProxymitySensor();
|
||||||
if (!mWakeLock.isHeld()) mWakeLock.acquire();
|
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() {
|
private void updateIncallVideoCallButton() {
|
||||||
boolean prefVideoEnabled = LinphoneManager.getInstance().isVideoEnabled();
|
boolean prefVideoEnabled = LinphoneManager.getInstance().isVideoEnabled();
|
||||||
if (prefVideoEnabled && !mCall.isEnabled()) {
|
if (prefVideoEnabled && !mCall.isEnabled()) {
|
||||||
|
@ -453,12 +460,15 @@ public class DialerActivity extends Activity implements LinphoneGuiListener, Alr
|
||||||
LinphoneCore lc = LinphoneManager.getLc();
|
LinphoneCore lc = LinphoneManager.getLc();
|
||||||
if (state == LinphoneCall.State.OutgoingInit) {
|
if (state == LinphoneCall.State.OutgoingInit) {
|
||||||
enterIncallMode(lc);
|
enterIncallMode(lc);
|
||||||
LinphoneManager.getInstance().routeAudioToReceiver();
|
openIncallActivity(mDisplayNameView.getText());
|
||||||
} else if (state == LinphoneCall.State.IncomingReceived) {
|
} else if (state == LinphoneCall.State.IncomingReceived) {
|
||||||
LinphoneManager.getInstance().resetCameraFromPreferences();
|
LinphoneManager.getInstance().resetCameraFromPreferences();
|
||||||
callPending(call);
|
callPending(call);
|
||||||
} else if (state == LinphoneCall.State.Connected) {
|
} else if (state == LinphoneCall.State.Connected) {
|
||||||
enterIncallMode(lc);
|
if (call.getDirection() == CallDirection.Incoming) {
|
||||||
|
enterIncallMode(lc);
|
||||||
|
openIncallActivity(mDisplayNameView.getText());
|
||||||
|
}
|
||||||
} else if (state == LinphoneCall.State.Error) {
|
} else if (state == LinphoneCall.State.Error) {
|
||||||
if (mWakeLock.isHeld()) mWakeLock.release();
|
if (mWakeLock.isHeld()) mWakeLock.release();
|
||||||
Toast toast = Toast.makeText(this
|
Toast toast = Toast.makeText(this
|
||||||
|
@ -470,9 +480,7 @@ public class DialerActivity extends Activity implements LinphoneGuiListener, Alr
|
||||||
exitCallMode();
|
exitCallMode();
|
||||||
} else if (state == LinphoneCall.State.StreamsRunning) {
|
} else if (state == LinphoneCall.State.StreamsRunning) {
|
||||||
if (LinphoneManager.getLc().getCurrentCall().getCurrentParamsCopy().getVideoEnabled()) {
|
if (LinphoneManager.getLc().getCurrentCall().getCurrentParamsCopy().getVideoEnabled()) {
|
||||||
if (!VideoCallActivity.launched) {
|
startVideoView(VIDEO_VIEW_ACTIVITY);
|
||||||
startVideoView(VIDEO_VIEW_ACTIVITY);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
132
src/org/linphone/IncallActivity.java
Normal file
132
src/org/linphone/IncallActivity.java
Normal file
|
@ -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));
|
||||||
|
}
|
||||||
|
}
|
|
@ -18,6 +18,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
package org.linphone;
|
package org.linphone;
|
||||||
|
|
||||||
|
import static android.media.AudioManager.*;
|
||||||
|
import static org.linphone.core.LinphoneCall.State.*;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -25,6 +27,7 @@ import java.io.InputStream;
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
|
|
||||||
|
import org.linphone.core.Hacks;
|
||||||
import org.linphone.core.LinphoneAddress;
|
import org.linphone.core.LinphoneAddress;
|
||||||
import org.linphone.core.LinphoneAuthInfo;
|
import org.linphone.core.LinphoneAuthInfo;
|
||||||
import org.linphone.core.LinphoneCall;
|
import org.linphone.core.LinphoneCall;
|
||||||
|
@ -140,7 +143,7 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
||||||
|
|
||||||
public void routeAudioToSpeaker() {
|
public void routeAudioToSpeaker() {
|
||||||
if (Integer.parseInt(Build.VERSION.SDK) <= 4 /*<donut*/) {
|
if (Integer.parseInt(Build.VERSION.SDK) <= 4 /*<donut*/) {
|
||||||
mAudioManager.setRouting(AudioManager.MODE_NORMAL,
|
mAudioManager.setRouting(MODE_NORMAL,
|
||||||
AudioManager.ROUTE_SPEAKER, AudioManager.ROUTE_ALL);
|
AudioManager.ROUTE_SPEAKER, AudioManager.ROUTE_ALL);
|
||||||
} else {
|
} else {
|
||||||
mAudioManager.setSpeakerphoneOn(true);
|
mAudioManager.setSpeakerphoneOn(true);
|
||||||
|
@ -155,7 +158,7 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
||||||
|
|
||||||
public void routeAudioToReceiver() {
|
public void routeAudioToReceiver() {
|
||||||
if (Integer.parseInt(Build.VERSION.SDK) <=4 /*<donut*/) {
|
if (Integer.parseInt(Build.VERSION.SDK) <=4 /*<donut*/) {
|
||||||
mAudioManager.setRouting(AudioManager.MODE_NORMAL,
|
mAudioManager.setRouting(MODE_NORMAL,
|
||||||
AudioManager.ROUTE_EARPIECE, AudioManager.ROUTE_ALL);
|
AudioManager.ROUTE_EARPIECE, AudioManager.ROUTE_ALL);
|
||||||
} else {
|
} else {
|
||||||
mAudioManager.setSpeakerphoneOn(false);
|
mAudioManager.setSpeakerphoneOn(false);
|
||||||
|
@ -192,7 +195,7 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
||||||
|
|
||||||
|
|
||||||
public boolean isSpeakerOn() {
|
public boolean isSpeakerOn() {
|
||||||
return (Integer.parseInt(Build.VERSION.SDK) <=4 && mAudioManager.getRouting(AudioManager.MODE_NORMAL) == AudioManager.ROUTE_SPEAKER)
|
return (Integer.parseInt(Build.VERSION.SDK) <=4 && mAudioManager.getRouting(MODE_NORMAL) == ROUTE_SPEAKER)
|
||||||
|| Integer.parseInt(Build.VERSION.SDK) >4 &&mAudioManager.isSpeakerphoneOn();
|
|| Integer.parseInt(Build.VERSION.SDK) >4 &&mAudioManager.isSpeakerphoneOn();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,15 +257,14 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void playDtmf(ContentResolver r, char dtmf) {
|
public void playDtmf(ContentResolver r, char dtmf) {
|
||||||
boolean speaker = true;
|
|
||||||
try {
|
try {
|
||||||
if (Settings.System.getInt(r, Settings.System.DTMF_TONE_WHEN_DIALING) == 0) {
|
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
|
// audible touch disabled: don't play on speaker, only send in outgoing stream
|
||||||
speaker = false;
|
return;
|
||||||
}
|
}
|
||||||
} catch (SettingNotFoundException e) {}
|
} 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() {
|
public void run() {
|
||||||
mLc.iterate();
|
mLc.iterate();
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
mTimer.scheduleAtFixedRate(lTask, 0, 100);
|
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) {
|
public void callState(final LinphoneCore lc,final LinphoneCall call, final State state, final String message) {
|
||||||
Log.i(TAG, "new state ["+state+"]");
|
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){
|
if (call.getReplacedCall()==null){
|
||||||
//no multicall support, just decline
|
//no multicall support, just decline
|
||||||
lc.terminateCall(call);
|
lc.terminateCall(call);
|
||||||
|
@ -590,18 +591,23 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
serviceListener.onCallStateChanged(call, state, message);
|
|
||||||
|
|
||||||
if (state == LinphoneCall.State.IncomingReceived) {
|
if (state == IncomingReceived) {
|
||||||
startRinging();
|
startRinging();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mCurrentCallState == LinphoneCall.State.IncomingReceived) {
|
if (mCurrentCallState == IncomingReceived) {
|
||||||
//previous state was ringing, so stop ringing
|
//previous state was ringing, so stop ringing
|
||||||
stopRinging();
|
stopRinging();
|
||||||
//routeAudioToReceiver();
|
//routeAudioToReceiver();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (state == CallEnd || state == Error) {
|
||||||
|
mAudioManager.setMode(MODE_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
mCurrentCallState=state;
|
mCurrentCallState=state;
|
||||||
|
serviceListener.onCallStateChanged(call, state, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -622,14 +628,18 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
||||||
|
|
||||||
|
|
||||||
private synchronized void startRinging() {
|
private synchronized void startRinging() {
|
||||||
|
if (Hacks.isGalaxyS()) {
|
||||||
|
mAudioManager.setMode(MODE_RINGTONE);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (mAudioManager.shouldVibrate(AudioManager.VIBRATE_TYPE_RINGER) && mVibrator !=null) {
|
if (mAudioManager.shouldVibrate(VIBRATE_TYPE_RINGER) && mVibrator !=null) {
|
||||||
long[] patern = {0,1000,1000};
|
long[] patern = {0,1000,1000};
|
||||||
mVibrator.vibrate(patern, 1);
|
mVibrator.vibrate(patern, 1);
|
||||||
}
|
}
|
||||||
if (mRingerPlayer == null) {
|
if (mRingerPlayer == null) {
|
||||||
mRingerPlayer = new MediaPlayer();
|
mRingerPlayer = new MediaPlayer();
|
||||||
mRingerPlayer.setAudioStreamType(AudioManager.STREAM_RING);
|
mRingerPlayer.setAudioStreamType(STREAM_RING);
|
||||||
serviceListener.onRingerPlayerCreated(mRingerPlayer);
|
serviceListener.onRingerPlayerCreated(mRingerPlayer);
|
||||||
mRingerPlayer.prepare();
|
mRingerPlayer.prepare();
|
||||||
mRingerPlayer.setLooping(true);
|
mRingerPlayer.setLooping(true);
|
||||||
|
@ -652,6 +662,10 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
||||||
if (mVibrator!=null) {
|
if (mVibrator!=null) {
|
||||||
mVibrator.cancel();
|
mVibrator.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Hacks.isGalaxyS()) {
|
||||||
|
mAudioManager.setMode(MODE_IN_CALL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String extractADisplayName() {
|
public String extractADisplayName() {
|
||||||
|
@ -675,6 +689,17 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
||||||
public boolean isVideoEnabled() {
|
public boolean isVideoEnabled() {
|
||||||
return mPref.getBoolean(getString(R.string.pref_video_enable_key), false);
|
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 */
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ import java.io.IOException;
|
||||||
|
|
||||||
import org.linphone.LinphoneManager.LinphoneServiceListener;
|
import org.linphone.LinphoneManager.LinphoneServiceListener;
|
||||||
import org.linphone.LinphoneManager.NewOutgoingCallUiListener;
|
import org.linphone.LinphoneManager.NewOutgoingCallUiListener;
|
||||||
|
import org.linphone.core.Hacks;
|
||||||
import org.linphone.core.LinphoneCall;
|
import org.linphone.core.LinphoneCall;
|
||||||
import org.linphone.core.LinphoneCore;
|
import org.linphone.core.LinphoneCore;
|
||||||
import org.linphone.core.LinphoneCall.State;
|
import org.linphone.core.LinphoneCall.State;
|
||||||
|
|
|
@ -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
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
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.media.AudioManager;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
|
@ -36,6 +36,7 @@ class LinphoneCallImpl implements LinphoneCall {
|
||||||
private native void enableEchoLimiter(long nativePtr,boolean enable);
|
private native void enableEchoLimiter(long nativePtr,boolean enable);
|
||||||
private native boolean isEchoLimiterEnabled(long nativePtr);
|
private native boolean isEchoLimiterEnabled(long nativePtr);
|
||||||
private native long getReplacedCall(long nativePtr);
|
private native long getReplacedCall(long nativePtr);
|
||||||
|
private native int getDuration(long nativePtr);
|
||||||
|
|
||||||
protected LinphoneCallImpl(long aNativePtr) {
|
protected LinphoneCallImpl(long aNativePtr) {
|
||||||
nativePtr = aNativePtr;
|
nativePtr = aNativePtr;
|
||||||
|
@ -96,5 +97,9 @@ class LinphoneCallImpl implements LinphoneCall {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getDuration() {
|
||||||
|
return getDuration(nativePtr);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ class LinphoneCoreImpl implements LinphoneCore {
|
||||||
private native void enableEchoCancellation(long nativePtr,boolean enable);
|
private native void enableEchoCancellation(long nativePtr,boolean enable);
|
||||||
private native boolean isEchoCancellationEnabled(long nativePtr);
|
private native boolean isEchoCancellationEnabled(long nativePtr);
|
||||||
private native long getCurrentCall(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 stopDtmf(long nativePtr);
|
||||||
private native void setVideoWindowId(long nativePtr, Object wid);
|
private native void setVideoWindowId(long nativePtr, Object wid);
|
||||||
private native void setPreviewWindowId(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
|
// TODO Auto-generated method stub
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
public void playDtmf(char number, int duration, boolean speaker) {
|
public void playDtmf(char number, int duration) {
|
||||||
playDtmf(nativePtr,number, duration, speaker);
|
playDtmf(nativePtr,number, duration);
|
||||||
|
|
||||||
}
|
}
|
||||||
public void stopDtmf() {
|
public void stopDtmf() {
|
||||||
|
@ -439,4 +439,7 @@ class LinphoneCoreImpl implements LinphoneCore {
|
||||||
public void startEchoCalibration(Object data) throws LinphoneCoreException {
|
public void startEchoCalibration(Object data) throws LinphoneCoreException {
|
||||||
startEchoCalibration(nativePtr, data);
|
startEchoCalibration(nativePtr, data);
|
||||||
}
|
}
|
||||||
|
public Transport getSignalingTransport() {
|
||||||
|
throw new RuntimeException("Not implemented");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
package org.linphone.core.video;
|
package org.linphone.core.video;
|
||||||
|
|
||||||
import org.linphone.Hacks;
|
import org.linphone.core.Hacks;
|
||||||
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,9 @@ public class AddVideoButton extends ImageButton implements OnClickListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onClick(View v) {
|
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();
|
boolean alreadyInVideoCall = !LinphoneManager.reinviteWithVideo();
|
||||||
if (alreadyInVideoCall && alreadyInVideoCallListener != null) {
|
if (alreadyInVideoCall && alreadyInVideoCallListener != null) {
|
||||||
// In video call; going back to video call activity
|
// In video call; going back to video call activity
|
||||||
|
|
|
@ -20,7 +20,7 @@ package org.linphone.ui;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public interface AddressAwareWidget {
|
public interface AddressAware {
|
||||||
|
|
||||||
void setAddressWidget(AddressText address);
|
void setAddressWidget(AddressText address);
|
||||||
|
|
|
@ -30,7 +30,7 @@ import android.view.View.OnClickListener;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
public class CallButton extends ImageButton implements OnClickListener, AddressAwareWidget {
|
public class CallButton extends ImageButton implements OnClickListener, AddressAware {
|
||||||
|
|
||||||
private AddressText mAddress;
|
private AddressText mAddress;
|
||||||
|
|
||||||
|
@ -40,6 +40,7 @@ public class CallButton extends ImageButton implements OnClickListener, AddressA
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
LinphoneManager.getInstance().setAudioModeIncallForGalaxyS();
|
||||||
LinphoneCore lc = LinphoneManager.getLc();
|
LinphoneCore lc = LinphoneManager.getLc();
|
||||||
if (lc.isInComingInvitePending()) {
|
if (lc.isInComingInvitePending()) {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -27,7 +27,7 @@ import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
|
||||||
public class Digit extends Button implements AddressAwareWidget {
|
public class Digit extends Button implements AddressAware {
|
||||||
|
|
||||||
private AddressText mAddress;
|
private AddressText mAddress;
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ public class Digit extends Button implements AddressAwareWidget {
|
||||||
|
|
||||||
if (lc.isIncall()) {
|
if (lc.isIncall()) {
|
||||||
lc.sendDtmf(mKeyCode.charAt(0));
|
lc.sendDtmf(mKeyCode.charAt(0));
|
||||||
} else {
|
} else if (mAddress != null) {
|
||||||
int lBegin = mAddress.getSelectionStart();
|
int lBegin = mAddress.getSelectionStart();
|
||||||
if (lBegin == -1) {
|
if (lBegin == -1) {
|
||||||
lBegin = mAddress.getEditableText().length();
|
lBegin = mAddress.getEditableText().length();
|
||||||
|
@ -113,6 +113,9 @@ public class Digit extends Button implements AddressAwareWidget {
|
||||||
// Called if "0+" dtmf
|
// Called if "0+" dtmf
|
||||||
LinphoneCore lc = LinphoneManager.getLc();
|
LinphoneCore lc = LinphoneManager.getLc();
|
||||||
lc.stopDtmf();
|
lc.stopDtmf();
|
||||||
|
|
||||||
|
if (mAddress == null) return true;
|
||||||
|
|
||||||
int lBegin = mAddress.getSelectionStart();
|
int lBegin = mAddress.getSelectionStart();
|
||||||
if (lBegin == -1) {
|
if (lBegin == -1) {
|
||||||
lBegin = mAddress.getEditableText().length();
|
lBegin = mAddress.getEditableText().length();
|
||||||
|
|
93
src/org/linphone/ui/IncallTimer.java
Normal file
93
src/org/linphone/ui/IncallTimer.java
Normal file
|
@ -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();
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
|
@ -30,7 +30,7 @@ import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
|
||||||
public class Numpad extends LinearLayout implements AddressAwareWidget {
|
public class Numpad extends LinearLayout implements AddressAware {
|
||||||
|
|
||||||
public Numpad(Context context, AttributeSet attrs) {
|
public Numpad(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
|
@ -39,22 +39,22 @@ public class Numpad extends LinearLayout implements AddressAwareWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAddressWidget(AddressText address) {
|
public void setAddressWidget(AddressText address) {
|
||||||
for (AddressAwareWidget v : retrieveChildren(this)) {
|
for (AddressAware v : retrieveChildren(this)) {
|
||||||
v.setAddressWidget(address);
|
v.setAddressWidget(address);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Collection<AddressAwareWidget> retrieveChildren(ViewGroup viewGroup) {
|
private Collection<AddressAware> retrieveChildren(ViewGroup viewGroup) {
|
||||||
final Collection<AddressAwareWidget> views = new ArrayList<AddressAwareWidget>();
|
final Collection<AddressAware> views = new ArrayList<AddressAware>();
|
||||||
|
|
||||||
for (int i = 0; i < viewGroup.getChildCount(); i++) {
|
for (int i = 0; i < viewGroup.getChildCount(); i++) {
|
||||||
View v = viewGroup.getChildAt(i);
|
View v = viewGroup.getChildAt(i);
|
||||||
if (v instanceof ViewGroup) {
|
if (v instanceof ViewGroup) {
|
||||||
views.addAll(retrieveChildren((ViewGroup) v));
|
views.addAll(retrieveChildren((ViewGroup) v));
|
||||||
} else {
|
} else {
|
||||||
if (v instanceof AddressAwareWidget)
|
if (v instanceof AddressAware)
|
||||||
views.add((AddressAwareWidget) v);
|
views.add((AddressAware) v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue