Digit widget for dialer.
This commit is contained in:
parent
702cb38b22
commit
61e3fd3e69
7 changed files with 259 additions and 214 deletions
|
@ -41,70 +41,45 @@
|
|||
<TableRow android:layout_height="fill_parent"
|
||||
android:layout_weight="1" android:id="@+id/DialerRow01"
|
||||
android:layout_width="fill_parent">
|
||||
<Button android:id="@+id/Button01" android:text="1"
|
||||
android:layout_width="fill_parent" android:layout_height="fill_parent"
|
||||
android:textStyle="bold" android:textSize="20sp"
|
||||
android:layout_weight="1" android:background="@drawable/clavier_bg" android:textColor="@android:color/black"></Button>
|
||||
<Button android:id="@+id/Button02" android:text="2"
|
||||
android:layout_width="fill_parent" android:layout_height="fill_parent"
|
||||
android:textStyle="bold" android:textSize="20sp"
|
||||
android:layout_weight="1" android:background="@drawable/clavier_bg" android:textColor="@android:color/black"></Button>
|
||||
<Button android:id="@+id/Button03" android:text="3"
|
||||
android:layout_width="fill_parent" android:layout_height="fill_parent"
|
||||
android:textStyle="bold" android:textSize="20sp"
|
||||
android:layout_weight="1" android:background="@drawable/clavier_bg" android:textColor="@android:color/black"></Button>
|
||||
<org.linphone.ui.Digit android:id="@+id/Button01"
|
||||
android:text="1" style="@style/DialerDigit" />
|
||||
<org.linphone.ui.Digit android:id="@+id/Button02"
|
||||
android:text="2" style="@style/DialerDigit" />
|
||||
<org.linphone.ui.Digit android:id="@+id/Button03"
|
||||
android:text="3" style="@style/DialerDigit" />
|
||||
</TableRow>
|
||||
<TableRow android:layout_height="fill_parent"
|
||||
android:layout_weight="1" android:id="@+id/DialerRow02"
|
||||
android:layout_width="fill_parent">
|
||||
<Button android:id="@+id/Button04" android:text="4"
|
||||
android:layout_width="fill_parent" android:layout_height="fill_parent"
|
||||
android:textStyle="bold" android:textSize="20sp"
|
||||
android:layout_weight="1" android:background="@drawable/clavier_bg" android:textColor="@android:color/black"></Button>
|
||||
<Button android:text="5" android:id="@+id/Button05"
|
||||
android:layout_width="fill_parent" android:layout_height="fill_parent"
|
||||
android:textStyle="bold" android:textSize="20sp"
|
||||
android:layout_weight="1" android:background="@drawable/clavier_bg" android:textColor="@android:color/black"></Button>
|
||||
<Button android:id="@+id/Button06" android:text="6"
|
||||
android:layout_width="fill_parent" android:layout_height="fill_parent"
|
||||
android:textStyle="bold" android:textSize="20sp"
|
||||
android:layout_weight="1" android:background="@drawable/clavier_bg" android:textColor="@android:color/black"></Button>
|
||||
<org.linphone.ui.Digit android:id="@+id/Button04"
|
||||
android:text="4" style="@style/DialerDigit" />
|
||||
<org.linphone.ui.Digit android:id="@+id/Button05"
|
||||
android:text="5" style="@style/DialerDigit" />
|
||||
<org.linphone.ui.Digit android:id="@+id/Button06"
|
||||
android:text="6" style="@style/DialerDigit" />
|
||||
</TableRow>
|
||||
<TableRow android:layout_weight="1" android:layout_height="fill_parent"
|
||||
android:id="@+id/DialerRow03" android:layout_width="fill_parent">
|
||||
<Button android:text="7" android:id="@+id/Button07"
|
||||
android:layout_width="fill_parent" android:layout_height="fill_parent"
|
||||
android:textStyle="bold" android:textSize="20sp"
|
||||
android:layout_weight="1" android:background="@drawable/clavier_bg" android:textColor="@android:color/black"></Button>
|
||||
<Button android:id="@+id/Button08" android:text="8"
|
||||
android:layout_width="fill_parent" android:layout_height="fill_parent"
|
||||
android:textStyle="bold" android:textSize="20sp"
|
||||
android:layout_weight="1" android:background="@drawable/clavier_bg" android:textColor="@android:color/black"></Button>
|
||||
<Button android:text="9" android:id="@+id/Button09"
|
||||
android:layout_width="fill_parent" android:layout_height="fill_parent"
|
||||
android:textStyle="bold" android:textSize="20sp"
|
||||
android:layout_weight="1" android:background="@drawable/clavier_bg" android:textColor="@android:color/black"></Button>
|
||||
<org.linphone.ui.Digit android:id="@+id/Button07"
|
||||
android:text="7" style="@style/DialerDigit" />
|
||||
<org.linphone.ui.Digit android:id="@+id/Button08"
|
||||
android:text="8" style="@style/DialerDigit" />
|
||||
<org.linphone.ui.Digit android:id="@+id/Button09"
|
||||
android:text="9" style="@style/DialerDigit" />
|
||||
</TableRow>
|
||||
<TableRow android:layout_weight="1" android:layout_height="fill_parent"
|
||||
android:id="@+id/DialerRow04" android:layout_width="fill_parent">
|
||||
<Button android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent" android:text="*" android:id="@+id/ButtonStar"
|
||||
android:textStyle="bold" android:textSize="20sp"
|
||||
android:layout_weight="1" android:background="@drawable/clavier_bg" android:textColor="@android:color/black"></Button>
|
||||
<Button android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent" android:text="0+" android:id="@+id/Button00"
|
||||
android:textStyle="bold" android:textSize="20sp"
|
||||
android:layout_weight="1" android:background="@drawable/clavier_bg" android:textColor="@android:color/black"></Button>
|
||||
<Button android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent" android:id="@+id/ButtonHash"
|
||||
android:text="#" android:textStyle="bold" android:textSize="20sp"
|
||||
android:layout_weight="1" android:background="@drawable/clavier_bg" android:textColor="@android:color/black"></Button>
|
||||
<org.linphone.ui.Digit android:id="@+id/ButtonStar"
|
||||
android:text="*" style="@style/DialerDigit" />
|
||||
<org.linphone.ui.Digit android:id="@+id/Button00"
|
||||
android:text="0+" style="@style/DialerDigit" />
|
||||
<org.linphone.ui.Digit android:id="@+id/ButtonHash"
|
||||
android:text="#" style="@style/DialerDigit" />
|
||||
</TableRow>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<TableRow android:layout_height="fill_parent" android:layout_width="fill_parent" android:id="@+id/IncallControlRow">
|
||||
<ImageButton android:layout_height="fill_parent" android:layout_width="fill_parent" android:id="@+id/AddVideo" android:layout_weight="1" android:src="@drawable/startvideo_green" android:background="@drawable/clavier_bg"></ImageButton>
|
||||
<ImageButton android:layout_height="fill_parent" android:layout_width="fill_parent" android:id="@+id/HangUp" android:layout_weight="1" android:src="@drawable/stopcall_red" android:background="@drawable/clavier_bg"></ImageButton>
|
||||
|
|
12
res/values/digit_style.xml
Normal file
12
res/values/digit_style.xml
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<style name="DialerDigit">
|
||||
<item name="android:layout_width">fill_parent</item>
|
||||
<item name="android:layout_height">fill_parent</item>
|
||||
<item name="android:textColor">@android:color/black</item>
|
||||
<item name="android:background">@drawable/clavier_bg</item>
|
||||
<item name="android:textStyle">bold</item>
|
||||
<item name="android:textSize">20sp</item>
|
||||
<item name="android:layout_weight">1</item>
|
||||
</style>
|
||||
</resources>
|
|
@ -25,12 +25,13 @@ import org.linphone.core.LinphoneAddress;
|
|||
import org.linphone.core.LinphoneCall;
|
||||
import org.linphone.core.LinphoneChatRoom;
|
||||
import org.linphone.core.LinphoneCore;
|
||||
import org.linphone.core.LinphoneCore.EcCalibratorStatus;
|
||||
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.Digit;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
|
@ -48,11 +49,9 @@ import android.preference.PreferenceManager;
|
|||
import android.provider.Settings;
|
||||
import android.text.Html;
|
||||
import android.util.Log;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.View.OnLongClickListener;
|
||||
import android.view.View.OnTouchListener;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.LinearLayout;
|
||||
|
@ -71,19 +70,6 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
|
|||
private ImageButton mHangup;
|
||||
private Button mErase;
|
||||
|
||||
private Button mZero;
|
||||
private Button mOne;
|
||||
private Button mTwo;
|
||||
private Button mThree ;
|
||||
private Button mFour;
|
||||
private Button mFive;
|
||||
private Button mSix;
|
||||
private Button mSeven;
|
||||
private Button mEight;
|
||||
private Button mNine;
|
||||
private Button mStar;
|
||||
private Button mHash;
|
||||
|
||||
private ToggleImageButton mMute;
|
||||
private ToggleImageButton mSpeaker;
|
||||
|
||||
|
@ -113,16 +99,12 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
|
|||
private static boolean accountCheckingDone;
|
||||
|
||||
/**
|
||||
*
|
||||
* @return null if not ready yet
|
||||
*/
|
||||
public static DialerActivity getDialer() {
|
||||
if (theDialer == null) {
|
||||
return null;
|
||||
} else {
|
||||
return theDialer;
|
||||
}
|
||||
}
|
||||
|
||||
public void setContactAddress(String aContact,String aDisplayName) {
|
||||
mAddress.setText(aContact);
|
||||
mDisplayName = aDisplayName;
|
||||
|
@ -139,8 +121,6 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
|
|||
|
||||
|
||||
try {
|
||||
|
||||
|
||||
mAddress = (TextView) findViewById(R.id.SipUri);
|
||||
mDisplayNameView = (TextView) findViewById(R.id.DisplayNameView);
|
||||
mErase = (Button)findViewById(R.id.Erase);
|
||||
|
@ -277,54 +257,16 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
|
|||
mSpeaker.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||
public void onCheckedChanged(ToggleImageButton buttonView, boolean isChecked) {
|
||||
if (isChecked) {
|
||||
routeAudioToSpeaker();
|
||||
LinphoneManager.routeAudioToSpeaker(mAudioManager);
|
||||
} else {
|
||||
routeAudioToReceiver();
|
||||
LinphoneManager.routeAudioToReceiver(mAudioManager);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mZero = (Button) findViewById(R.id.Button00) ;
|
||||
if (mZero != null) {
|
||||
setDigitListener(mZero,'0');
|
||||
mZero.setOnLongClickListener(new OnLongClickListener() {
|
||||
public boolean onLongClick(View arg0) {
|
||||
LinphoneCore lc = LinphoneService.instance().getLinphoneCore();
|
||||
lc.stopDtmf();
|
||||
int lBegin = mAddress.getSelectionStart();
|
||||
if (lBegin == -1) {
|
||||
lBegin = mAddress.getEditableText().length();
|
||||
}
|
||||
if (lBegin >=0) {
|
||||
mAddress.getEditableText().insert(lBegin,"+");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
});
|
||||
mOne = (Button) findViewById(R.id.Button01) ;
|
||||
setDigitListener(mOne,'1');
|
||||
mTwo = (Button) findViewById(R.id.Button02);
|
||||
setDigitListener(mTwo,'2');
|
||||
mThree = (Button) findViewById(R.id.Button03);
|
||||
setDigitListener(mThree,'3');
|
||||
mFour = (Button) findViewById(R.id.Button04);
|
||||
setDigitListener(mFour,'4');
|
||||
mFive = (Button) findViewById(R.id.Button05);
|
||||
setDigitListener(mFive,'5');
|
||||
mSix = (Button) findViewById(R.id.Button06);
|
||||
setDigitListener(mSix,'6');
|
||||
mSeven = (Button) findViewById(R.id.Button07);
|
||||
setDigitListener(mSeven,'7');
|
||||
mEight = (Button) findViewById(R.id.Button08);
|
||||
setDigitListener(mEight,'8');
|
||||
mNine = (Button) findViewById(R.id.Button09);
|
||||
setDigitListener(mNine,'9');
|
||||
mStar = (Button) findViewById(R.id.ButtonStar);
|
||||
setDigitListener(mStar,'*');
|
||||
mHash = (Button) findViewById(R.id.ButtonHash);
|
||||
setDigitListener(mHash,'#');
|
||||
}
|
||||
initializeDigits();
|
||||
|
||||
|
||||
mStatus = (TextView) findViewById(R.id.status_label);
|
||||
theDialer = this;
|
||||
|
@ -338,6 +280,21 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
|
|||
if (!accountCheckingDone) checkAccountsSettings();
|
||||
}
|
||||
|
||||
private void initializeDigits() {
|
||||
((Digit) findViewById(R.id.Button00)).setWidgets(mAddress, mDisplayName);
|
||||
((Digit) findViewById(R.id.Button01)).setWidgets(mAddress, mDisplayName);
|
||||
((Digit) findViewById(R.id.Button02)).setWidgets(mAddress, mDisplayName);
|
||||
((Digit) findViewById(R.id.Button03)).setWidgets(mAddress, mDisplayName);
|
||||
((Digit) findViewById(R.id.Button04)).setWidgets(mAddress, mDisplayName);
|
||||
((Digit) findViewById(R.id.Button05)).setWidgets(mAddress, mDisplayName);
|
||||
((Digit) findViewById(R.id.Button06)).setWidgets(mAddress, mDisplayName);
|
||||
((Digit) findViewById(R.id.Button07)).setWidgets(mAddress, mDisplayName);
|
||||
((Digit) findViewById(R.id.Button08)).setWidgets(mAddress, mDisplayName);
|
||||
((Digit) findViewById(R.id.Button09)).setWidgets(mAddress, mDisplayName);
|
||||
((Digit) findViewById(R.id.ButtonStar)).setWidgets(mAddress, mDisplayName);
|
||||
((Digit) findViewById(R.id.ButtonHash)).setWidgets(mAddress, mDisplayName);
|
||||
}
|
||||
|
||||
private boolean checkDefined(int ... keys) {
|
||||
for (int key : keys) {
|
||||
String conf = mPref.getString(getString(key), null);
|
||||
|
@ -434,7 +391,6 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
|
|||
}
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
// TODO Auto-generated method stub
|
||||
super.onDestroy();
|
||||
if (mWakeLock.isHeld()) mWakeLock.release();
|
||||
theDialer=null;
|
||||
|
@ -491,7 +447,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
|
|||
|
||||
if (state == LinphoneCall.State.OutgoingInit) {
|
||||
enterIncalMode(lc);
|
||||
routeAudioToReceiver();
|
||||
LinphoneManager.routeAudioToReceiver(mAudioManager);
|
||||
} else if (state == LinphoneCall.State.IncomingReceived) {
|
||||
resetCameraFromPreferences();
|
||||
callPending(call);
|
||||
|
@ -543,9 +499,9 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
|
|||
configureMuteAndSpeakerButtons();
|
||||
|
||||
if (mSpeaker.isChecked()) {
|
||||
routeAudioToSpeaker();
|
||||
LinphoneManager.routeAudioToSpeaker(mAudioManager);
|
||||
} else {
|
||||
routeAudioToReceiver();
|
||||
LinphoneManager.routeAudioToReceiver(mAudioManager);
|
||||
}
|
||||
setVolumeControlStream(AudioManager.STREAM_VOICE_CALL);
|
||||
LinphoneActivity.instance().startProxymitySensor();
|
||||
|
@ -584,41 +540,12 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
|
|||
}
|
||||
if (mWakeLock.isHeld())mWakeLock.release();
|
||||
mSpeaker.setChecked(false);
|
||||
routeAudioToReceiver();
|
||||
LinphoneManager.routeAudioToReceiver(mAudioManager);
|
||||
BandwidthManager.getInstance().setUserRestriction(false);
|
||||
resetCameraFromPreferences();
|
||||
LinphoneActivity.instance().stopProxymitySensor();
|
||||
}
|
||||
private void routeAudioToSpeaker() {
|
||||
if (Integer.parseInt(Build.VERSION.SDK) <= 4 /*<donut*/) {
|
||||
mAudioManager.setRouting(AudioManager.MODE_NORMAL,
|
||||
AudioManager.ROUTE_SPEAKER, AudioManager.ROUTE_ALL);
|
||||
} else {
|
||||
mAudioManager.setSpeakerphoneOn(true);
|
||||
}
|
||||
LinphoneCore lLinphoneCore = LinphoneService.instance().getLinphoneCore();
|
||||
if (lLinphoneCore.isIncall()) {
|
||||
/*disable EC*/
|
||||
lLinphoneCore.getCurrentCall().enableEchoCancellation(false);
|
||||
lLinphoneCore.getCurrentCall().enableEchoLimiter(true);
|
||||
}
|
||||
|
||||
}
|
||||
private void routeAudioToReceiver() {
|
||||
if (Integer.parseInt(Build.VERSION.SDK) <=4 /*<donut*/) {
|
||||
mAudioManager.setRouting(AudioManager.MODE_NORMAL,
|
||||
AudioManager.ROUTE_EARPIECE, AudioManager.ROUTE_ALL);
|
||||
} else {
|
||||
mAudioManager.setSpeakerphoneOn(false);
|
||||
}
|
||||
|
||||
LinphoneCore lLinphoneCore = LinphoneService.instance().getLinphoneCore();
|
||||
if (lLinphoneCore.isIncall()) {
|
||||
//Restore default value
|
||||
lLinphoneCore.getCurrentCall().enableEchoCancellation(lLinphoneCore.isEchoCancellationEnabled());
|
||||
lLinphoneCore.getCurrentCall().enableEchoLimiter(false);
|
||||
}
|
||||
}
|
||||
private void callPending(LinphoneCall call) {
|
||||
mDecline.setEnabled(true);
|
||||
//routeAudioToSpeaker();
|
||||
|
@ -673,55 +600,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
|
|||
return;
|
||||
}
|
||||
}
|
||||
private void setDigitListener(Button aButton,char dtmf) {
|
||||
class DialKeyListener implements OnClickListener ,OnTouchListener {
|
||||
final String mKeyCode;
|
||||
final TextView mAddressView;
|
||||
boolean mIsDtmfStarted=false;
|
||||
DialKeyListener(TextView anAddress, char aKeyCode) {
|
||||
mKeyCode = String.valueOf(aKeyCode);
|
||||
mAddressView = anAddress;
|
||||
}
|
||||
public void onClick(View v) {
|
||||
LinphoneCore lc = LinphoneService.instance().getLinphoneCore();
|
||||
stopDtmf();
|
||||
if (lc.isIncall()) {
|
||||
lc.sendDtmf(mKeyCode.charAt(0));
|
||||
} else {
|
||||
int lBegin = mAddressView.getSelectionStart();
|
||||
if (lBegin == -1) {
|
||||
lBegin = mAddressView.getEditableText().length();
|
||||
}
|
||||
if (lBegin >=0) {
|
||||
mAddressView.getEditableText().insert(lBegin,mKeyCode);
|
||||
}
|
||||
mDisplayName="";
|
||||
}
|
||||
}
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN && mIsDtmfStarted ==false) {
|
||||
LinphoneCore lc = LinphoneService.instance().getLinphoneCore();
|
||||
lc.playDtmf(mKeyCode.charAt(0), -1);
|
||||
mIsDtmfStarted=true;
|
||||
} else {
|
||||
if (event.getAction() == MotionEvent.ACTION_UP)
|
||||
stopDtmf();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void stopDtmf() {
|
||||
LinphoneCore lc = LinphoneService.instance().getLinphoneCore();
|
||||
lc.stopDtmf();
|
||||
mIsDtmfStarted =false;
|
||||
}
|
||||
|
||||
};
|
||||
DialKeyListener lListener = new DialKeyListener(mAddress,dtmf);
|
||||
aButton.setOnClickListener(lListener);
|
||||
aButton.setOnTouchListener(lListener);
|
||||
|
||||
}
|
||||
public void newSubscriptionRequest(LinphoneCore lc, LinphoneFriend lf,
|
||||
String url) {
|
||||
// TODO Auto-generated method stub
|
||||
|
|
|
@ -134,7 +134,6 @@ public class LinphoneActivity extends TabActivity {
|
|||
}
|
||||
@Override
|
||||
protected void onPause() {
|
||||
// TODO Auto-generated method stub
|
||||
super.onPause();
|
||||
if (isFinishing()) {
|
||||
//restaure audio settings
|
||||
|
@ -151,18 +150,6 @@ public class LinphoneActivity extends TabActivity {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
// TODO Auto-generated method stub
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
|
||||
}
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
// Inflate the currently selected menu XML resource.
|
||||
|
|
74
src/org/linphone/LinphoneManager.java
Normal file
74
src/org/linphone/LinphoneManager.java
Normal file
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
BigManager.java
|
||||
Copyright (C) 2010 Belledonne Communications, Grenoble, France
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
package org.linphone;
|
||||
|
||||
import org.linphone.core.LinphoneCore;
|
||||
|
||||
import android.media.AudioManager;
|
||||
import android.os.Build;
|
||||
|
||||
public class LinphoneManager {
|
||||
|
||||
private static LinphoneManager instance;
|
||||
|
||||
public static void routeAudioToSpeaker(AudioManager mAudioManager) {
|
||||
if (Integer.parseInt(Build.VERSION.SDK) <= 4 /*<donut*/) {
|
||||
mAudioManager.setRouting(AudioManager.MODE_NORMAL,
|
||||
AudioManager.ROUTE_SPEAKER, AudioManager.ROUTE_ALL);
|
||||
} else {
|
||||
mAudioManager.setSpeakerphoneOn(true);
|
||||
}
|
||||
LinphoneCore lLinphoneCore = LinphoneService.instance().getLinphoneCore();
|
||||
if (lLinphoneCore.isIncall()) {
|
||||
/*disable EC*/
|
||||
lLinphoneCore.getCurrentCall().enableEchoCancellation(false);
|
||||
lLinphoneCore.getCurrentCall().enableEchoLimiter(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void routeAudioToReceiver(AudioManager mAudioManager) {
|
||||
if (Integer.parseInt(Build.VERSION.SDK) <=4 /*<donut*/) {
|
||||
mAudioManager.setRouting(AudioManager.MODE_NORMAL,
|
||||
AudioManager.ROUTE_EARPIECE, AudioManager.ROUTE_ALL);
|
||||
} else {
|
||||
mAudioManager.setSpeakerphoneOn(false);
|
||||
}
|
||||
|
||||
LinphoneCore lLinphoneCore = LinphoneService.instance().getLinphoneCore();
|
||||
if (lLinphoneCore.isIncall()) {
|
||||
//Restore default value
|
||||
lLinphoneCore.getCurrentCall().enableEchoCancellation(lLinphoneCore.isEchoCancellationEnabled());
|
||||
lLinphoneCore.getCurrentCall().enableEchoLimiter(false);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized static final LinphoneManager getInstance() {
|
||||
if (instance == null) instance = new LinphoneManager();
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static final LinphoneCore getLc() {
|
||||
return LinphoneService.getLc();
|
||||
}
|
||||
|
||||
public static void startLinphone() {
|
||||
|
||||
}
|
||||
}
|
|
@ -59,7 +59,6 @@ import android.os.Handler;
|
|||
import android.os.IBinder;
|
||||
import android.os.Vibrator;
|
||||
import android.preference.CheckBoxPreference;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
|
||||
|
|
119
src/org/linphone/ui/Digit.java
Normal file
119
src/org/linphone/ui/Digit.java
Normal file
|
@ -0,0 +1,119 @@
|
|||
/*
|
||||
Digit.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 android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class Digit extends Button {
|
||||
|
||||
private TextView mAddress;
|
||||
private String mDisplayName; // FIXME not linked with dialeractivity
|
||||
|
||||
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);
|
||||
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;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
final CharSequence mKeyCode;
|
||||
boolean mIsDtmfStarted=false;
|
||||
DialKeyListener(String aKeyCode) {
|
||||
mKeyCode = aKeyCode.subSequence(0, 1);
|
||||
}
|
||||
public void onClick(View v) {
|
||||
LinphoneCore lc = LinphoneManager.getLc();
|
||||
stopDtmf();
|
||||
if (lc.isIncall()) {
|
||||
lc.sendDtmf(mKeyCode.charAt(0));
|
||||
} else {
|
||||
int lBegin = mAddress.getSelectionStart();
|
||||
if (lBegin == -1) {
|
||||
lBegin = mAddress.getEditableText().length();
|
||||
}
|
||||
if (lBegin >=0) {
|
||||
mAddress.getEditableText().insert(lBegin,mKeyCode);
|
||||
}
|
||||
mDisplayName="";
|
||||
}
|
||||
}
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN && mIsDtmfStarted ==false) {
|
||||
LinphoneCore lc = LinphoneManager.getLc();
|
||||
lc.playDtmf(mKeyCode.charAt(0), -1);
|
||||
mIsDtmfStarted=true;
|
||||
} else {
|
||||
if (event.getAction() == MotionEvent.ACTION_UP)
|
||||
stopDtmf();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void stopDtmf() {
|
||||
LinphoneCore lc = LinphoneManager.getLc();
|
||||
lc.stopDtmf();
|
||||
mIsDtmfStarted =false;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
public void setWidgets(TextView address, String displayName) {
|
||||
mAddress = address;
|
||||
mDisplayName = displayName;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue