diff --git a/res/layout-land/dialer.xml b/res/layout-land/dialer.xml index c820fd542..2b98dc7d4 100644 --- a/res/layout-land/dialer.xml +++ b/res/layout-land/dialer.xml @@ -3,34 +3,66 @@ android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> - + + + + + - - - - - - + + + + + + + + + + + + - - - + android:layout_weight="0.25" android:id="@+id/Decline"> + + + - - - - - + diff --git a/res/layout/dialer.xml b/res/layout/dialer.xml index db93411f3..a39483f34 100644 --- a/res/layout/dialer.xml +++ b/res/layout/dialer.xml @@ -3,8 +3,20 @@ android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> - - + + + + + + + + + + diff --git a/res/values/strings.xml b/res/values/strings.xml index 8c8fbed04..a5cc7cbf4 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -1,5 +1,6 @@ + About Audio Exit Prefix diff --git a/src/org/linphone/DialerActivity.java b/src/org/linphone/DialerActivity.java index 7124eabf7..759c06e16 100644 --- a/src/org/linphone/DialerActivity.java +++ b/src/org/linphone/DialerActivity.java @@ -27,7 +27,6 @@ import org.linphone.core.LinphoneCore.GeneralState; import android.app.Activity; import android.content.Context; -import android.content.res.Configuration; import android.media.AudioManager; import android.os.Build; import android.os.Bundle; @@ -35,19 +34,25 @@ import android.util.Log; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; +import android.widget.CompoundButton; import android.widget.ImageButton; import android.widget.LinearLayout; -import android.widget.TableRow; import android.widget.TextView; import android.widget.Toast; +import android.widget.ToggleButton; +import android.widget.CompoundButton.OnCheckedChangeListener; public class DialerActivity extends Activity implements LinphoneCoreListener { private TextView mAddress; + private TextView mDisplayNameView; + private TextView mStatus; private ImageButton mCall; private ImageButton mDecline; private ImageButton mHangup; + private Button mErase; + private Button mZero; private Button mOne; private Button mTwo; @@ -61,8 +66,13 @@ public class DialerActivity extends Activity implements LinphoneCoreListener { private Button mStar; private Button mHash; + private ToggleButton mMute; + private ToggleButton mSpeaker; + private LinearLayout mCallControlRow; private LinearLayout mInCallControlRow; + private LinearLayout mAddressLayout; + private LinearLayout mInCallAddressLayout; private static DialerActivity theDialer; @@ -92,7 +102,15 @@ public class DialerActivity extends Activity implements LinphoneCoreListener { mAddress = (TextView) findViewById(R.id.SipUri); - + mDisplayNameView = (TextView) findViewById(R.id.DisplayNameView); + mErase = (Button)findViewById(R.id.Erase); + + mErase.setOnClickListener(new OnClickListener() { + public void onClick(View v) { + mAddress.getEditableText().delete(mAddress.getEditableText().length()-1, mAddress.getEditableText().length()); + } + }); + mCall = (ImageButton) findViewById(R.id.Call); mCall.setOnClickListener(new OnClickListener() { public void onClick(View v) { @@ -149,13 +167,18 @@ public class DialerActivity extends Activity implements LinphoneCoreListener { mAddressView = anAddress; } public void onClick(View v) { - mAddressView.append(mKeyCode); + mAddressView.append(mKeyCode); + mDisplayName=""; } }; mCallControlRow = (LinearLayout) findViewById(R.id.CallControlRow); mInCallControlRow = (LinearLayout) findViewById(R.id.IncallControlRow); + mAddressLayout = (LinearLayout) findViewById(R.id.Addresslayout); + mInCallAddressLayout = (LinearLayout) findViewById(R.id.IncallAddressLayout); + mInCallControlRow.setVisibility(View.GONE); + mInCallAddressLayout.setVisibility(View.GONE); if (LinphoneService.isready()) { if (LinphoneService.instance().getLinphoneCore().isIncall()) { @@ -163,9 +186,43 @@ public class DialerActivity extends Activity implements LinphoneCoreListener { mHangup.setEnabled(!mCall.isEnabled()); mCallControlRow.setVisibility(View.GONE); mInCallControlRow.setVisibility(View.VISIBLE); + mAddressLayout.setVisibility(View.GONE); + mInCallAddressLayout.setVisibility(View.VISIBLE); } } + + + mMute = (ToggleButton)findViewById(R.id.mic_mute_button); + mMute.setOnCheckedChangeListener(new OnCheckedChangeListener() { + + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + LinphoneCore lc = LinphoneService.instance().getLinphoneCore(); + if (isChecked) { + lc.muteMic(false); + mMute.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.mic_active, 0, 0); + } else { + lc.muteMic(true); + mMute.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.mic_muted, 0, 0); + } + + } + }); + + mSpeaker = (ToggleButton)findViewById(R.id.speaker_button); + mSpeaker.setOnCheckedChangeListener(new OnCheckedChangeListener() { + + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + if (isChecked) { + routeAudioToSpeaker(); + } else { + routeAudioToReceiver(); + } + + } + + }); + mZero = (Button) findViewById(R.id.Button00) ; if (mZero != null) { @@ -199,6 +256,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener { } catch (Exception e) { Log.e(LinphoneService.TAG,"Cannot start linphone",e); + finish(); } } @@ -230,39 +288,22 @@ public class DialerActivity extends Activity implements LinphoneCoreListener { switch(state) { case GSTATE_POWER_ON: - mCall.setEnabled(!LinphoneService.instance().getLinphoneCore().isIncall()); + mCall.setEnabled(!lc.isIncall()); mHangup.setEnabled(!mCall.isEnabled()); break; case GSTATE_REG_OK: { break; } case GSTATE_CALL_OUT_INVITE: { - //de-activate green button - mCall.setEnabled(false); - mCallControlRow.setVisibility(View.GONE); - mInCallControlRow.setVisibility(View.VISIBLE); } case GSTATE_CALL_IN_INVITE: { - // activate red button - mHangup.setEnabled(true); - if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.DONUT) { - mAudioManager.setMode(AudioManager.MODE_NORMAL); - mAudioManager.setRouting(AudioManager.MODE_NORMAL, - AudioManager.ROUTE_SPEAKER, AudioManager.ROUTE_ALL); - } else { - mAudioManager.setSpeakerphoneOn(true); - } + enterIncalMode(lc); + routeAudioToSpeaker(); break; } case GSTATE_CALL_IN_CONNECTED: case GSTATE_CALL_OUT_CONNECTED: { - if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.DONUT) { - mAudioManager.setMode(AudioManager.MODE_IN_CALL); - mAudioManager.setRouting(AudioManager.MODE_NORMAL, - AudioManager.ROUTE_EARPIECE, AudioManager.ROUTE_ALL); - } else { - mAudioManager.setSpeakerphoneOn(false); - } + routeAudioToReceiver(); setVolumeControlStream(AudioManager.STREAM_VOICE_CALL); break; } @@ -288,12 +329,47 @@ public class DialerActivity extends Activity implements LinphoneCoreListener { } + private void enterIncalMode(LinphoneCore lc) { + mCallControlRow.setVisibility(View.GONE); + mInCallControlRow.setVisibility(View.VISIBLE); + mAddressLayout.setVisibility(View.GONE); + mInCallAddressLayout.setVisibility(View.VISIBLE); + mCall.setEnabled(false); + mHangup.setEnabled(true); + String DisplayName = lc.getRemoteAddress().getDisplayName(); + if (DisplayName!=null) { + mDisplayNameView.setText(DisplayName); + } else { + mDisplayNameView.setText(lc.getRemoteAddress().getUserName()); + } + } private void exitCallMode() { mCallControlRow.setVisibility(View.VISIBLE); mInCallControlRow.setVisibility(View.GONE); + mAddressLayout.setVisibility(View.VISIBLE); + mInCallAddressLayout.setVisibility(View.GONE); mCall.setEnabled(true); mHangup.setEnabled(false); setVolumeControlStream(AudioManager.USE_DEFAULT_STREAM_TYPE); } + private void routeAudioToSpeaker() { + if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.DONUT) { + mAudioManager.setMode(AudioManager.MODE_NORMAL); + mAudioManager.setRouting(AudioManager.MODE_NORMAL, + AudioManager.ROUTE_SPEAKER, AudioManager.ROUTE_ALL); + } else { + mAudioManager.setSpeakerphoneOn(true); + } + + } + private void routeAudioToReceiver() { + if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.DONUT) { + mAudioManager.setMode(AudioManager.MODE_IN_CALL); + mAudioManager.setRouting(AudioManager.MODE_NORMAL, + AudioManager.ROUTE_EARPIECE, AudioManager.ROUTE_ALL); + } else { + mAudioManager.setSpeakerphoneOn(false); + } + } } diff --git a/src/org/linphone/HistoryActivity.java b/src/org/linphone/HistoryActivity.java index 821c2758d..49c5a3510 100644 --- a/src/org/linphone/HistoryActivity.java +++ b/src/org/linphone/HistoryActivity.java @@ -24,6 +24,8 @@ import java.util.List; import org.linphone.core.LinphoneAddress; import org.linphone.core.LinphoneCallLog; +import org.linphone.core.LinphoneCore; +import org.linphone.core.LinphoneProxyConfig; import org.linphone.core.LinphoneCallLog.CallDirection; import android.app.ListActivity; @@ -70,10 +72,8 @@ public class HistoryActivity extends ListActivity { class CallHistoryAdapter extends BaseAdapter { - private final Context mContext; final List mLogs; CallHistoryAdapter(Context aContext) { - mContext = aContext; mLogs = LinphoneService.instance().getLinphoneCore().getCallLogs(); } public int getCount() { @@ -114,13 +114,22 @@ public class HistoryActivity extends ListActivity { lDirectionImageIn.setVisibility(View.GONE); lDirectionImageOut.setVisibility(View.VISIBLE); } - - if (lAddress.getDisplayName() == null) { - lFirstLineView.setText(lAddress.getUserName()); + LinphoneCore lc = LinphoneService.instance().getLinphoneCore(); + LinphoneProxyConfig lProxyConfig = lc.getDefaultProxyConfig(); + String lDetailedName=null; + String lDisplayName = lAddress.getDisplayName(); + + if (lProxyConfig != null && lProxyConfig.getDomain().equals(lAddress.getDomain())) { + lDetailedName = lAddress.getUserName(); + } else { + lDetailedName = lAddress.toUri(); + } + if (lDisplayName == null) { + lFirstLineView.setText(lDetailedName); lSecondLineView.setVisibility(View.GONE); } else { - lFirstLineView.setText(lAddress.getDisplayName()); - lSecondLineView.setText(lAddress.getUserName()); + lFirstLineView.setText(lDisplayName); + lSecondLineView.setText(lDetailedName); lSecondLineView.setVisibility(View.VISIBLE); } diff --git a/src/org/linphone/core/LinphoneCore.java b/src/org/linphone/core/LinphoneCore.java index 915062118..753dfa12f 100644 --- a/src/org/linphone/core/LinphoneCore.java +++ b/src/org/linphone/core/LinphoneCore.java @@ -146,5 +146,11 @@ public interface LinphoneCore { * @return level in db */ public float getSoftPlayLevel(); + /** + * Mutes or unmutes the local microphone. + * @param isMuted + */ + public void muteMic(boolean isMuted); + } diff --git a/src/org/linphone/core/LinphoneCoreImpl.java b/src/org/linphone/core/LinphoneCoreImpl.java index 81685e886..eda069112 100644 --- a/src/org/linphone/core/LinphoneCoreImpl.java +++ b/src/org/linphone/core/LinphoneCoreImpl.java @@ -23,14 +23,11 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; -import org.linphone.LinphoneService; - -import android.util.Log; - class LinphoneCoreImpl implements LinphoneCore { - private final LinphoneCoreListener mListener; + @SuppressWarnings("unused") + private final LinphoneCoreListener mListener; //to make sure to keep a reference on this object private long nativePtr = 0; private native long newLinphoneCore(LinphoneCoreListener listener,String userConfig,String factoryConfig,Object userdata); private native void iterate(long nativePtr); @@ -54,6 +51,7 @@ class LinphoneCoreImpl implements LinphoneCore { private native void setNetworkStateReachable(long nativePtr,boolean isReachable); private native void setSoftPlayLevel(long nativeptr, float gain); private native float getSoftPlayLevel(long nativeptr); + private native void muteMic(long nativePtr,boolean isMuted); LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException { @@ -168,4 +166,7 @@ class LinphoneCoreImpl implements LinphoneCore { public float getSoftPlayLevel() { return getSoftPlayLevel(nativePtr); } + public void muteMic(boolean isMuted) { + muteMic(nativePtr,isMuted); + } } diff --git a/src/org/linphone/core/LinphoneProxyConfigImpl.java b/src/org/linphone/core/LinphoneProxyConfigImpl.java index 3794c58bf..11e746946 100644 --- a/src/org/linphone/core/LinphoneProxyConfigImpl.java +++ b/src/org/linphone/core/LinphoneProxyConfigImpl.java @@ -42,8 +42,8 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig { ownPtr=false; } protected void finalize() throws Throwable { - Log.e(LinphoneService.TAG,"fixme, should release underlying proxy config"); - // FIXME if (ownPtr) delete(nativePtr); + //Log.e(LinphoneService.TAG,"fixme, should release underlying proxy config"); + if (ownPtr) delete(nativePtr); } private native long newLinphoneProxyConfig(); private native void delete(long ptr);