Add several new widgets.

AddressTex, EraseButton, HangCallButton, MuteMicButton, SpeakerButton
This commit is contained in:
Guillaume Beraudo 2011-02-16 13:31:30 +01:00
parent 61e3fd3e69
commit 83b638abbb
11 changed files with 420 additions and 226 deletions

View file

@ -7,12 +7,12 @@
android:layout_height="wrap_content" android:layout_width="fill_parent">
<LinearLayout android:layout_height="wrap_content"
android:layout_width="fill_parent" android:id="@+id/Addresslayout">
<EditText android:id="@+id/SipUri" android:layout_height="wrap_content"
<org.linphone.ui.AddressText android:id="@+id/SipUri" android:layout_height="wrap_content"
android:hint="sip:" android:layout_width="fill_parent" android:lines="1"
android:layout_weight="0.2"></EditText>
<Button android:layout_height="wrap_content" android:id="@+id/Erase"
android:layout_weight="0.2"/>
<org.linphone.ui.EraseButton android:layout_height="wrap_content" android:id="@+id/Erase"
android:layout_width="fill_parent" android:layout_weight="0.8"
android:text="&lt;"></Button>
android:text="&lt;"/>
</LinearLayout>
@ -23,12 +23,12 @@
android:id="@+id/DisplayNameView" android:clickable="false"
android:cursorVisible="false" android:gravity="center"
android:layout_width="fill_parent"></EditText>
<org.linphone.component.ToggleImageButton
<org.linphone.ui.MuteMicButton
android:id="@+id/mic_mute_button" android:layout_height="wrap_content"
android:layout_width="wrap_content" android:layout_weight="0.5"
checked="@drawable/mic_muted" unchecked="@drawable/mic_active"
android:layout_gravity="left|center_vertical" />
<org.linphone.component.ToggleImageButton
<org.linphone.ui.SpeakerButton
android:id="@+id/speaker_button" android:layout_height="wrap_content"
android:layout_width="wrap_content" android:layout_weight="0.5"
checked="@drawable/speaker_32_on" unchecked="@drawable/speaker_32_off"
@ -39,7 +39,7 @@
android:layout_height="fill_parent" android:layout_weight="1">
<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>
<org.linphone.ui.HangCallButton 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"/>
</TableRow>
</TableLayout>
<LinearLayout android:layout_height="fill_parent"
@ -47,8 +47,8 @@
<ImageButton 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">
</ImageButton>
<ImageButton android:layout_height="fill_parent" android:layout_width="fill_parent"
android:layout_weight="0.25" android:id="@+id/Decline" android:background="@drawable/clavier_bg" android:src="@drawable/stopcall_red"></ImageButton>
<org.linphone.ui.HangCallButton android:layout_height="fill_parent" android:layout_width="fill_parent"
android:layout_weight="0.25" android:id="@+id/Decline" android:background="@drawable/clavier_bg" android:src="@drawable/stopcall_red"/>
</LinearLayout>
<EditText android:layout_width="fill_parent" android:id="@+id/status_label"
android:clickable="false" android:focusable="false"

View file

@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:linphone="http://schemas.android.com/apk/res/linphone"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
@ -7,11 +9,11 @@
android:layout_height="wrap_content" android:layout_width="fill_parent">
<LinearLayout android:layout_height="wrap_content"
android:layout_width="fill_parent" android:id="@+id/Addresslayout">
<EditText android:id="@+id/SipUri" android:background="@drawable/clavier_bg_grey" android:hint="sip:" android:layout_width="fill_parent"
android:lines="1" android:layout_weight="0.2" android:layout_height="fill_parent" android:padding="10px" android:maxLines="1"></EditText>
<Button android:layout_height="fill_parent" android:background="@drawable/clavier_bg" android:id="@+id/Erase"
<org.linphone.ui.AddressText android:id="@+id/SipUri" android:background="@drawable/clavier_bg_grey" android:hint="sip:" android:layout_width="fill_parent"
android:lines="1" android:layout_weight="0.2" android:layout_height="fill_parent" android:padding="10px" android:maxLines="1"/>
<org.linphone.ui.EraseButton android:layout_height="fill_parent" android:background="@drawable/clavier_bg" android:id="@+id/Erase"
android:layout_width="fill_parent" android:layout_weight="0.8" android:textSize="20sp"
android:textStyle="bold" android:text="&lt;" android:layout_gravity="top" android:textColor="@android:color/black"></Button>
android:textStyle="bold" android:text="&lt;" android:layout_gravity="top" android:textColor="@android:color/black"/>
</LinearLayout>
@ -22,13 +24,12 @@
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:lines="1"
android:id="@+id/DisplayNameView" android:clickable="false"
android:cursorVisible="false" android:layout_gravity="center"
></EditText>
<org.linphone.component.ToggleImageButton android:id="@+id/mic_mute_button"
android:cursorVisible="false" android:layout_gravity="center"></EditText>
<org.linphone.ui.MuteMicButton android:id="@+id/mic_mute_button"
android:layout_height="wrap_content" android:layout_width="wrap_content"
checked="@drawable/mic_muted" unchecked="@drawable/mic_active"
android:layout_gravity="left|center_vertical"/>
<org.linphone.component.ToggleImageButton android:id="@+id/speaker_button"
<org.linphone.ui.SpeakerButton android:id="@+id/speaker_button"
android:layout_height="wrap_content" android:layout_width="wrap_content"
checked="@drawable/speaker_32_on" unchecked="@drawable/speaker_32_off"
android:layout_gravity="right|center_vertical"/>
@ -41,39 +42,39 @@
<TableRow android:layout_height="fill_parent"
android:layout_weight="1" android:id="@+id/DialerRow01"
android:layout_width="fill_parent">
<org.linphone.ui.Digit android:id="@+id/Button01"
<org.linphone.ui.Digit android:id="@+id/Digit1"
android:text="1" style="@style/DialerDigit" />
<org.linphone.ui.Digit android:id="@+id/Button02"
<org.linphone.ui.Digit android:id="@+id/Digit2"
android:text="2" style="@style/DialerDigit" />
<org.linphone.ui.Digit android:id="@+id/Button03"
<org.linphone.ui.Digit android:id="@+id/Digit3"
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">
<org.linphone.ui.Digit android:id="@+id/Button04"
<org.linphone.ui.Digit android:id="@+id/Digit4"
android:text="4" style="@style/DialerDigit" />
<org.linphone.ui.Digit android:id="@+id/Button05"
<org.linphone.ui.Digit android:id="@+id/Digit5"
android:text="5" style="@style/DialerDigit" />
<org.linphone.ui.Digit android:id="@+id/Button06"
<org.linphone.ui.Digit android:id="@+id/Digit6"
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">
<org.linphone.ui.Digit android:id="@+id/Button07"
<org.linphone.ui.Digit android:id="@+id/Digit7"
android:text="7" style="@style/DialerDigit" />
<org.linphone.ui.Digit android:id="@+id/Button08"
<org.linphone.ui.Digit android:id="@+id/Digit8"
android:text="8" style="@style/DialerDigit" />
<org.linphone.ui.Digit android:id="@+id/Button09"
<org.linphone.ui.Digit android:id="@+id/Digit9"
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">
<org.linphone.ui.Digit android:id="@+id/ButtonStar"
<org.linphone.ui.Digit android:id="@+id/DigitStar"
android:text="*" style="@style/DialerDigit" />
<org.linphone.ui.Digit android:id="@+id/Button00"
<org.linphone.ui.Digit android:id="@+id/Digit00"
android:text="0+" style="@style/DialerDigit" />
<org.linphone.ui.Digit android:id="@+id/ButtonHash"
<org.linphone.ui.Digit android:id="@+id/DigitHash"
android:text="#" style="@style/DialerDigit" />
</TableRow>
@ -82,14 +83,14 @@
<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>
<org.linphone.ui.HangCallButton 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"/>
</TableRow>
</TableLayout>
<LinearLayout android:id="@+id/LinearLayout01" android:layout_height="wrap_content" android:orientation="vertical" android:layout_width="fill_parent">
<LinearLayout android:layout_height="fill_parent" android:layout_width="fill_parent" android:id="@+id/CallControlRow">
<ImageButton android:id="@+id/Call" android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="0.25" android:src="@drawable/startcall_green" android:background="@drawable/clavier_bg"></ImageButton>
<ImageButton android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="0.25" android:id="@+id/Decline" android:src="@drawable/stopcall_red" android:background="@drawable/clavier_bg"></ImageButton>
<org.linphone.ui.HangCallButton android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="0.25" android:id="@+id/Decline" android:src="@drawable/stopcall_red" android:background="@drawable/clavier_bg"/>
</LinearLayout><EditText android:layout_width="fill_parent" android:id="@+id/status_label" android:clickable="false" android:focusable="false" android:cursorVisible="false" android:textSize="12sp" android:height="15sp" android:layout_height="wrap_content" android:background="@android:color/transparent" android:textColor="@android:color/white"></EditText>
</LinearLayout>

View file

@ -18,8 +18,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.linphone;
import org.linphone.component.ToggleImageButton;
import org.linphone.component.ToggleImageButton.OnCheckedChangeListener;
import org.linphone.core.AndroidCameraRecordManager;
import org.linphone.core.LinphoneAddress;
import org.linphone.core.LinphoneCall;
@ -31,7 +29,11 @@ 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.AddressText;
import org.linphone.ui.Digit;
import org.linphone.ui.EraseButton;
import org.linphone.ui.MuteMicButton;
import org.linphone.ui.SpeakerButton;
import android.app.Activity;
import android.app.AlertDialog;
@ -41,7 +43,6 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.os.Build;
import android.os.Bundle;
import android.os.PowerManager;
import android.os.Vibrator;
@ -51,8 +52,6 @@ import android.text.Html;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TableRow;
@ -61,17 +60,16 @@ import android.widget.Toast;
public class DialerActivity extends Activity implements LinphoneCoreListener {
private TextView mAddress;
private AddressText mAddress;
private TextView mDisplayNameView;
private TextView mStatus;
private ImageButton mCall;
private ImageButton mDecline;
private ImageButton mHangup;
private Button mErase;
private View mDecline;
private View mHangup;
private ToggleImageButton mMute;
private ToggleImageButton mSpeaker;
private MuteMicButton mMute;
private SpeakerButton mSpeaker;
private LinearLayout mCallControlRow;
private TableRow mInCallControlRow;
@ -80,8 +78,6 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
private static DialerActivity theDialer;
private String mDisplayName;
private AudioManager mAudioManager;
private PowerManager.WakeLock mWakeLock;
private SharedPreferences mPref;
private ImageButton mAddVideo;
@ -105,15 +101,11 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
return theDialer;
}
public void setContactAddress(String aContact,String aDisplayName) {
mAddress.setText(aContact);
mDisplayName = aDisplayName;
}
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.dialer);
mAudioManager = ((AudioManager)getSystemService(Context.AUDIO_SERVICE));
LinphoneManager.getInstance().setAudioManager(((AudioManager)getSystemService(Context.AUDIO_SERVICE)));
PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
mVibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
mWakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK|PowerManager.ON_AFTER_RELEASE,"Linphone");
@ -121,30 +113,10 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
try {
mAddress = (TextView) findViewById(R.id.SipUri);
mAddress = (AddressText) findViewById(R.id.SipUri);
mDisplayNameView = (TextView) findViewById(R.id.DisplayNameView);
mErase = (Button)findViewById(R.id.Erase);
((EraseButton) findViewById(R.id.Erase)).setAddressView(mAddress);
mErase.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mDisplayName=null;
if (mAddress.length() >0) {
int lBegin = mAddress.getSelectionStart();
if (lBegin == -1) {
lBegin = mAddress.getEditableText().length()-1;
}
if (lBegin >0) {
mAddress.getEditableText().delete(lBegin-1,lBegin);
}
}
}
});
mErase.setOnLongClickListener(new OnLongClickListener() {
public boolean onLongClick(View arg0) {
mAddress.getEditableText().clear();
return true;
}
});
mAddVideo = (ImageButton) findViewById(R.id.AddVideo);
mAddVideo.setOnClickListener(new OnClickListener() {
@ -161,46 +133,21 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
mCall = (ImageButton) findViewById(R.id.Call);
mCall.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
LinphoneCore lLinphoneCore = LinphoneService.instance().getLinphoneCore();
if (lLinphoneCore.isInComingInvitePending()) {
try {
lLinphoneCore.acceptCall(lLinphoneCore.getCurrentCall());
} catch (LinphoneCoreException e) {
lLinphoneCore.terminateCall(lLinphoneCore.getCurrentCall());
Toast toast = Toast.makeText(DialerActivity.this
,String.format(getString(R.string.warning_wrong_destination_address),mAddress.getText().toString())
,Toast.LENGTH_LONG);
toast.show();
}
return;
}
if (mAddress.getText().length() >0) {
newOutgoingCall(mAddress.getText().toString(),mDisplayName);
}
callOrAcceptIncommingCall();
}
});
mDecline= (ImageButton) findViewById(R.id.Decline);
mHangup = (ImageButton) findViewById(R.id.HangUp);
OnClickListener lHangupListener = new OnClickListener() {
public void onClick(View v) {
LinphoneCore lLinphoneCore = LinphoneService.instance().getLinphoneCore();
lLinphoneCore.terminateCall(lLinphoneCore.getCurrentCall());
}
};
mHangup.setOnClickListener(lHangupListener);
mDecline.setOnClickListener(lHangupListener);
mDecline= findViewById(R.id.Decline);
mDecline.setEnabled(false);
mHangup = findViewById(R.id.HangUp);
mCallControlRow = (LinearLayout) findViewById(R.id.CallControlRow);
mInCallControlRow = (TableRow) findViewById(R.id.IncallControlRow);
mAddressLayout = (View) findViewById(R.id.Addresslayout);
mInCallAddressLayout = (View) findViewById(R.id.IncallAddressLayout);
mMute = (ToggleImageButton)findViewById(R.id.mic_mute_button);
mSpeaker = (ToggleImageButton)findViewById(R.id.speaker_button);
mMute = (MuteMicButton)findViewById(R.id.mic_mute_button);
mSpeaker = (SpeakerButton)findViewById(R.id.speaker_button);
/* if (Hacks.isGalaxyS()) {
// Galaxy S doesn't handle audio routing properly
// so disabling it totally
@ -208,16 +155,17 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
}*/
mInCallControlRow.setVisibility(View.GONE);
mInCallAddressLayout.setVisibility(View.GONE);
mDecline.setEnabled(false);
if (LinphoneService.isready() && getIntent().getData() != null && !LinphoneService.instance().getLinphoneCore().isIncall()) {
if (LinphoneService.isready() && getIntent().getData() != null && !LinphoneService.getLc().isIncall()) {
newOutgoingCall(getIntent().getData().toString().substring("tel://".length()));
getIntent().setData(null);
}
if (LinphoneService.isready()) {
LinphoneCore lLinphoneCore = LinphoneService.instance().getLinphoneCore();
if (lLinphoneCore.isIncall()) {
if(lLinphoneCore.isInComingInvitePending()) {
callPending(lLinphoneCore.getCurrentCall());
LinphoneCore lc = LinphoneService.getLc();
if (lc.isIncall()) {
if(lc.isInComingInvitePending()) {
callPending(lc.getCurrentCall());
} else {
mCall.setEnabled(false);
mHangup.setEnabled(!mCall.isEnabled());
@ -227,43 +175,19 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
mAddressLayout.setVisibility(View.GONE);
mInCallAddressLayout.setVisibility(View.VISIBLE);
String DisplayName = lLinphoneCore.getRemoteAddress().getDisplayName();
String DisplayName = lc.getRemoteAddress().getDisplayName();
if (DisplayName!=null) {
mDisplayNameView.setText(DisplayName);
} else {
mDisplayNameView.setText(lLinphoneCore.getRemoteAddress().getUserName());
mDisplayNameView.setText(lc.getRemoteAddress().getUserName());
}
configureMuteAndSpeakerButtons();
loadMicAndSpeakerUiStateFromLibrary();
LinphoneActivity.instance().startProxymitySensor();
mWakeLock.acquire();
}
}
}
mMute.setOnCheckedChangeListener(new OnCheckedChangeListener() {
public void onCheckedChanged(ToggleImageButton button, boolean isChecked) {
LinphoneCore lc = LinphoneService.instance().getLinphoneCore();
if (isChecked) {
lc.muteMic(true);
} else {
lc.muteMic(false);
}
}
});
mSpeaker.setOnCheckedChangeListener(new OnCheckedChangeListener() {
public void onCheckedChanged(ToggleImageButton buttonView, boolean isChecked) {
if (isChecked) {
LinphoneManager.routeAudioToSpeaker(mAudioManager);
} else {
LinphoneManager.routeAudioToReceiver(mAudioManager);
}
}
});
initializeDigits();
@ -280,19 +204,40 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
if (!accountCheckingDone) checkAccountsSettings();
}
private void callOrAcceptIncommingCall() {
LinphoneCore lLinphoneCore = LinphoneService.instance().getLinphoneCore();
if (lLinphoneCore.isInComingInvitePending()) {
try {
lLinphoneCore.acceptCall(lLinphoneCore.getCurrentCall());
} catch (LinphoneCoreException e) {
lLinphoneCore.terminateCall(lLinphoneCore.getCurrentCall());
Toast toast = Toast.makeText(DialerActivity.this
,String.format(getString(R.string.warning_wrong_destination_address),mAddress.getText().toString())
,Toast.LENGTH_LONG);
toast.show();
}
return;
}
if (mAddress.getText().length() >0) {
newOutgoingCall(mAddress.getText().toString(), mAddress.getDisplayedName());
}
}
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);
if (findViewById(R.id.Digit00) == null) return; // In landscape view, no keyboard
((Digit) findViewById(R.id.Digit00)).setAddressWidget(mAddress);
((Digit) findViewById(R.id.Digit1)).setAddressWidget(mAddress);
((Digit) findViewById(R.id.Digit2)).setAddressWidget(mAddress);
((Digit) findViewById(R.id.Digit3)).setAddressWidget(mAddress);
((Digit) findViewById(R.id.Digit4)).setAddressWidget(mAddress);
((Digit) findViewById(R.id.Digit5)).setAddressWidget(mAddress);
((Digit) findViewById(R.id.Digit6)).setAddressWidget(mAddress);
((Digit) findViewById(R.id.Digit7)).setAddressWidget(mAddress);
((Digit) findViewById(R.id.Digit8)).setAddressWidget(mAddress);
((Digit) findViewById(R.id.Digit9)).setAddressWidget(mAddress);
((Digit) findViewById(R.id.DigitStar)).setAddressWidget(mAddress);
((Digit) findViewById(R.id.DigitHash)).setAddressWidget(mAddress);
}
private boolean checkDefined(int ... keys) {
@ -377,7 +322,8 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
public void onSaveInstanceState(Bundle savedInstanceState) {
super.onSaveInstanceState(savedInstanceState);
savedInstanceState.putString(CURRENT_ADDRESS, mAddress.getText().toString());
if (mDisplayName != null) savedInstanceState.putString(CURRENT_DISPLAYNAME,mDisplayName);
if (mAddress.getDisplayedName() != null)
savedInstanceState.putString(CURRENT_DISPLAYNAME,mAddress.getDisplayedName());
}
@Override
@ -387,7 +333,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
if (lAddress != null && mAddress != null) {
mAddress.setText(lAddress);
}
mDisplayName = savedInstanceState.getString(CURRENT_DISPLAYNAME);
mAddress.setDisplayedName(savedInstanceState.getString(CURRENT_DISPLAYNAME));
}
@Override
protected void onDestroy() {
@ -400,27 +346,17 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
protected void onResume() {
super.onResume();
}
public void authInfoRequested(LinphoneCore lc, String realm, String username) {
// TODO Auto-generated method stub
}
public void byeReceived(LinphoneCore lc, String from) {
// TODO Auto-generated method stub
}
public void displayMessage(LinphoneCore lc, String message) {
// TODO Auto-generated method stub
}
public void authInfoRequested(LinphoneCore lc, String realm, String username) /*nop*/{}
public void byeReceived(LinphoneCore lc, String from) {/*nop*/}
public void displayMessage(LinphoneCore lc, String message) {/*nop*/}
public void displayWarning(LinphoneCore lc, String message) {/*nop*/}
public void displayStatus(LinphoneCore lc, String message) {
mStatus.setText(message);
}
public void displayWarning(LinphoneCore lc, String message) {
// TODO Auto-generated method stub
}
public void globalState(LinphoneCore lc, LinphoneCore.GlobalState state, String message) {
public void globalState(LinphoneCore lc, LinphoneCore.GlobalState state, String message) {
if (state == LinphoneCore.GlobalState.GlobalOn) {
mCall.setEnabled(!lc.isIncall());
mHangup.setEnabled(!mCall.isEnabled());
@ -436,6 +372,8 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
}
}
}
private void startVideoView(int requestCode) {
Intent lIntent = new Intent();
lIntent.setClass(this, VideoCallActivity.class);
@ -447,7 +385,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
if (state == LinphoneCall.State.OutgoingInit) {
enterIncalMode(lc);
LinphoneManager.routeAudioToReceiver(mAudioManager);
LinphoneManager.getInstance().routeAudioToReceiver();
} else if (state == LinphoneCall.State.IncomingReceived) {
resetCameraFromPreferences();
callPending(call);
@ -469,13 +407,9 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
}
}
}
}
public void show(LinphoneCore lc) {
// TODO Auto-generated method stub
}
public void show(LinphoneCore lc) {/*nop*/}
private void enterIncalMode(LinphoneCore lc) {
mCallControlRow.setVisibility(View.GONE);
@ -496,26 +430,21 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
mDisplayNameView.setText(lc.getRemoteAddress().toString());
}
}
configureMuteAndSpeakerButtons();
loadMicAndSpeakerUiStateFromLibrary();
if (mSpeaker.isChecked()) {
LinphoneManager.routeAudioToSpeaker(mAudioManager);
if (mSpeaker.isSpeakerOn()) {
LinphoneManager.getInstance().routeAudioToSpeaker();
} else {
LinphoneManager.routeAudioToReceiver(mAudioManager);
LinphoneManager.getInstance().routeAudioToReceiver();
}
setVolumeControlStream(AudioManager.STREAM_VOICE_CALL);
LinphoneActivity.instance().startProxymitySensor();
if (!mWakeLock.isHeld()) mWakeLock.acquire();
}
private void configureMuteAndSpeakerButtons() {
mMute.setChecked(LinphoneService.instance().getLinphoneCore().isMicMuted());
if ((Integer.parseInt(Build.VERSION.SDK) <=4 && mAudioManager.getRouting(AudioManager.MODE_NORMAL) == AudioManager.ROUTE_SPEAKER)
|| Integer.parseInt(Build.VERSION.SDK) >4 &&mAudioManager.isSpeakerphoneOn()) {
mSpeaker.setChecked(true);
} else {
mSpeaker.setChecked(false);
}
private void loadMicAndSpeakerUiStateFromLibrary() {
mMute.setChecked(LinphoneService.getLc().isMicMuted());
mSpeaker.setSpeakerOn(LinphoneManager.getInstance().isSpeakerOn());
}
private void resetCameraFromPreferences() {
@ -539,8 +468,8 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
finishActivity(VIDEO_VIEW_ACTIVITY);
}
if (mWakeLock.isHeld())mWakeLock.release();
mSpeaker.setChecked(false);
LinphoneManager.routeAudioToReceiver(mAudioManager);
mSpeaker.setSpeakerOn(false);
LinphoneManager.getInstance().routeAudioToReceiver();
BandwidthManager.getInstance().setUserRestriction(false);
resetCameraFromPreferences();
LinphoneActivity.instance().stopProxymitySensor();
@ -561,13 +490,13 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
}
public synchronized void newOutgoingCall(String aTo, String displayName) {
private synchronized void newOutgoingCall(String aTo, String displayName) {
String lto = aTo;
if (aTo.contains(OutgoingCallReceiver.TAG)) {
lto = aTo.replace(OutgoingCallReceiver.TAG, "");
}
mAddress.setText(lto);
mDisplayName = displayName;
mAddress.setDisplayedName(displayName);
LinphoneCore lLinphoneCore = LinphoneService.instance().getLinphoneCore();
if (lLinphoneCore.isIncall()) {
Toast toast = Toast.makeText(DialerActivity.this, getString(R.string.warning_already_incall), Toast.LENGTH_LONG);
@ -584,7 +513,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
toast.show();
return;
}
lAddress.setDisplayName(mDisplayName);
lAddress.setDisplayName(mAddress.getDisplayedName());
try {
boolean prefVideoEnable = mPref.getBoolean(getString(R.string.pref_video_enable_key), false);
@ -601,28 +530,22 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
}
}
public void newSubscriptionRequest(LinphoneCore lc, LinphoneFriend lf,
String url) {
// TODO Auto-generated method stub
}
public void notifyPresenceReceived(LinphoneCore lc, LinphoneFriend lf) {
// TODO Auto-generated method stub
}
public void newSubscriptionRequest(LinphoneCore lc, LinphoneFriend lf, String url) {}
public void notifyPresenceReceived(LinphoneCore lc, LinphoneFriend lf) {}
public void textReceived(LinphoneCore lc, LinphoneChatRoom cr,
LinphoneAddress from, String message) {
// TODO Auto-generated method stub
}
LinphoneAddress from, String message) {}
private AndroidCameraRecordManager getVideoManager() {
return AndroidCameraRecordManager.getInstance();
}
public void ecCalibrationStatus(LinphoneCore lc, EcCalibratorStatus status,
int delay_ms, Object data) {
int delay_ms, Object data) {}
public void setContactAddress(String aContact,String aDisplayName) {
mAddress.setText(aContact);
mAddress.setDisplayedName(aDisplayName);
}
}

View file

@ -1,5 +1,5 @@
/*
BigManager.java
LinphoneManager.java
Copyright (C) 2010 Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or
@ -20,30 +20,33 @@ package org.linphone;
import org.linphone.core.LinphoneCore;
import android.content.SharedPreferences;
import android.media.AudioManager;
import android.os.Build;
public class LinphoneManager {
private static LinphoneManager instance;
private AudioManager mAudioManager;
public static void routeAudioToSpeaker(AudioManager mAudioManager) {
public 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()) {
LinphoneCore lc = LinphoneService.getLc();
if (lc.isIncall()) {
/*disable EC*/
lLinphoneCore.getCurrentCall().enableEchoCancellation(false);
lLinphoneCore.getCurrentCall().enableEchoLimiter(true);
lc.getCurrentCall().enableEchoCancellation(false);
lc.getCurrentCall().enableEchoLimiter(true);
}
}
public static void routeAudioToReceiver(AudioManager mAudioManager) {
public void routeAudioToReceiver() {
if (Integer.parseInt(Build.VERSION.SDK) <=4 /*<donut*/) {
mAudioManager.setRouting(AudioManager.MODE_NORMAL,
AudioManager.ROUTE_EARPIECE, AudioManager.ROUTE_ALL);
@ -51,11 +54,11 @@ public class LinphoneManager {
mAudioManager.setSpeakerphoneOn(false);
}
LinphoneCore lLinphoneCore = LinphoneService.instance().getLinphoneCore();
if (lLinphoneCore.isIncall()) {
LinphoneCore lc = LinphoneService.getLc();
if (lc.isIncall()) {
//Restore default value
lLinphoneCore.getCurrentCall().enableEchoCancellation(lLinphoneCore.isEchoCancellationEnabled());
lLinphoneCore.getCurrentCall().enableEchoLimiter(false);
lc.getCurrentCall().enableEchoCancellation(lc.isEchoCancellationEnabled());
lc.getCurrentCall().enableEchoLimiter(false);
}
}
@ -71,4 +74,17 @@ public class LinphoneManager {
public static void startLinphone() {
}
public void setAudioManager(AudioManager manager) {
mAudioManager = manager;
}
public boolean isSpeakerOn() {
return (Integer.parseInt(Build.VERSION.SDK) <=4 && mAudioManager.getRouting(AudioManager.MODE_NORMAL) == AudioManager.ROUTE_SPEAKER)
|| Integer.parseInt(Build.VERSION.SDK) >4 &&mAudioManager.isSpeakerphoneOn();
}
}

View file

@ -36,7 +36,8 @@ import android.widget.ImageButton;
*
*/
public class ToggleImageButton extends ImageButton implements OnClickListener {
private static final String namespace = null;
// private static final String ns = "http://schemas.android.com/apk/res/linphone";
private static final String ns = null;
private boolean checked;
private Drawable stateChecked;
private Drawable stateUnChecked;
@ -44,8 +45,8 @@ public class ToggleImageButton extends ImageButton implements OnClickListener {
public ToggleImageButton(Context context, AttributeSet attrs) {
super(context, attrs);
stateChecked = getResources().getDrawable(attrs.getAttributeResourceValue(namespace, "checked", -1));
stateUnChecked = getResources().getDrawable(attrs.getAttributeResourceValue(namespace, "unchecked", -1));
stateChecked = getResources().getDrawable(attrs.getAttributeResourceValue(ns, "checked", -1));
stateUnChecked = getResources().getDrawable(attrs.getAttributeResourceValue(ns, "unchecked", -1));
setBackgroundColor(Color.TRANSPARENT);
setOnClickListener(this);

View file

@ -0,0 +1,49 @@
/*
AddressView.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 android.content.Context;
import android.util.AttributeSet;
import android.widget.EditText;
public class AddressText extends EditText {
private String displayedName;
public AddressText(Context context, AttributeSet attrs) {
super(context, attrs);
}
public void clearDisplayedName() {
displayedName = "";
}
public String getDisplayedName() {
return displayedName;
}
public void setContactAddress(String uri, String displayedName) {
this.displayedName = displayedName;
setText(uri);
}
public void setDisplayedName(String displayedName) {
this.displayedName = displayedName;
}
}

View file

@ -26,12 +26,10 @@ 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 AddressText mAddress;
private final void createWidget(Context context, AttributeSet attrs) {
String ns = "http://schemas.android.com/apk/res/android";
@ -89,7 +87,7 @@ public class Digit extends Button {
if (lBegin >=0) {
mAddress.getEditableText().insert(lBegin,mKeyCode);
}
mDisplayName="";
mAddress.clearDisplayedName();
}
}
public boolean onTouch(View v, MotionEvent event) {
@ -112,8 +110,7 @@ public class Digit extends Button {
};
public void setWidgets(TextView address, String displayName) {
public void setAddressWidget(AddressText address) {
mAddress = address;
mDisplayName = displayName;
}
}

View file

@ -0,0 +1,60 @@
/*
EraseButton.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 android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
import android.widget.Button;
public class EraseButton extends Button implements OnClickListener, OnLongClickListener{
private AddressText address;
public EraseButton(Context context, AttributeSet attrs) {
super(context, attrs);
setOnClickListener(this);
setOnLongClickListener(this);
}
public void onClick(View v) {
address.clearDisplayedName();
if (address.getText().length() >0) {
int lBegin = address.getSelectionStart();
if (lBegin == -1) {
lBegin = address.getEditableText().length()-1;
}
if (lBegin >0) {
address.getEditableText().delete(lBegin-1,lBegin);
}
}
}
public boolean onLongClick(View v) {
address.getEditableText().clear();
return true;
}
public void setAddressView(AddressText view) {
address = view;
}
}

View file

@ -0,0 +1,41 @@
/*
SpeakerButton.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.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
public class HangCallButton extends ImageButton implements OnClickListener {
public HangCallButton(Context context, AttributeSet attrs) {
super(context, attrs);
setOnClickListener(this);
}
public void onClick(View v) {
LinphoneCore lc = LinphoneManager.getLc();
lc.terminateCall(lc.getCurrentCall());
}
}

View file

@ -0,0 +1,52 @@
/*
SpeakerButton.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.component.ToggleImageButton;
import org.linphone.component.ToggleImageButton.OnCheckedChangeListener;
import android.content.Context;
import android.util.AttributeSet;
public class MuteMicButton extends ToggleImageButton implements OnCheckedChangeListener {
public MuteMicButton(Context context, AttributeSet attrs) {
super(context, attrs);
setOnCheckedChangeListener(this);
}
public boolean isMicMuted() {
return isChecked();
}
public void setMicMuted(boolean state) {
setChecked(state);
}
public void onCheckedChanged(ToggleImageButton button, boolean checked) {
if (checked) {
LinphoneManager.getLc().muteMic(true);
} else {
LinphoneManager.getLc().muteMic(false);
}
}
}

View file

@ -0,0 +1,54 @@
/*
SpeakerButton.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.component.ToggleImageButton;
import org.linphone.component.ToggleImageButton.OnCheckedChangeListener;
import android.content.Context;
import android.util.AttributeSet;
public class SpeakerButton extends ToggleImageButton implements OnCheckedChangeListener {
public SpeakerButton(Context context, AttributeSet attrs) {
super(context, attrs);
setOnCheckedChangeListener(this);
}
public boolean isSpeakerOn() {
return isChecked();
}
public void setSpeakerOn(boolean state) {
setChecked(state);
}
public void onCheckedChanged(ToggleImageButton button, boolean checked) {
if (checked) {
LinphoneManager.getInstance().routeAudioToSpeaker();
} else {
LinphoneManager.getInstance().routeAudioToReceiver();
}
}
}