fix sip uri presentation in History
fix landscape mode
This commit is contained in:
parent
8f94e5f38b
commit
b983a3a071
9 changed files with 197 additions and 59 deletions
|
@ -3,34 +3,66 @@
|
|||
android:orientation="vertical" android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
|
||||
<EditText android:id="@+id/SipUri" android:layout_height="wrap_content"
|
||||
android:hint="sip:" android:layout_width="fill_parent"
|
||||
android:singleLine="true"></EditText>
|
||||
<LinearLayout android:id="@+id/LinearLayout02"
|
||||
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"
|
||||
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_width="fill_parent" android:text="<-"
|
||||
android:layout_weight="0.8"></Button>
|
||||
</LinearLayout>
|
||||
|
||||
<TableLayout android:layout_width="fill_parent" android:id="@+id/Dialer" android:layout_height="fill_parent">
|
||||
|
||||
|
||||
|
||||
|
||||
<TableRow android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="1" android:id="@+id/DialerRow05">
|
||||
|
||||
<LinearLayout android:layout_height="wrap_content"
|
||||
android:layout_width="fill_parent" android:id="@+id/IncallAddressLayout">
|
||||
<EditText android:text="@+id/EditText01"
|
||||
android:layout_height="wrap_content" android:lines="1"
|
||||
android:id="@+id/DisplayNameView" android:clickable="false"
|
||||
android:cursorVisible="false" android:gravity="center"
|
||||
android:layout_width="fill_parent"></EditText>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout android:id="@+id/LinearLayout01"
|
||||
android:orientation="vertical" android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
<LinearLayout android:layout_height="fill_parent"
|
||||
android:layout_width="fill_parent" android:id="@+id/IncallControlRow">
|
||||
<ToggleButton android:id="@+id/mic_mute_button"
|
||||
android:textOn="" android:textOff="" android:layout_weight="0.25"
|
||||
android:layout_height="fill_parent" android:layout_width="fill_parent"
|
||||
android:drawableTop="@drawable/mic_active" android:checked="true"></ToggleButton>
|
||||
<ImageButton android:src="@drawable/red"
|
||||
android:layout_height="fill_parent" android:layout_width="fill_parent"
|
||||
android:layout_weight="0.25" android:id="@+id/HangUp"></ImageButton>
|
||||
<ToggleButton android:id="@+id/speaker_button"
|
||||
android:textOn="" android:textOff="" android:layout_weight="0.25"
|
||||
android:layout_height="fill_parent" android:layout_width="fill_parent"
|
||||
android:drawableTop="@drawable/speaker_32_on"></ToggleButton>
|
||||
</LinearLayout>
|
||||
<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:src="@drawable/green"
|
||||
android:layout_width="fill_parent" android:layout_weight="0.25">
|
||||
</ImageButton>
|
||||
|
||||
|
||||
<ImageButton android:id="@+id/HangUp" android:src="@drawable/red"
|
||||
<ImageButton android:src="@drawable/red"
|
||||
android:layout_height="fill_parent" android:layout_width="fill_parent"
|
||||
android:layout_weight="0.25"></ImageButton>
|
||||
android:layout_weight="0.25" android:id="@+id/Decline"></ImageButton>
|
||||
</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:background="@android:color/transparent" android:textColor="@android:color/white"
|
||||
android:lines="1" android:layout_height="wrap_content"></EditText>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
|
||||
|
||||
</TableRow><TableRow android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/DialerRow06"></TableRow>
|
||||
|
||||
<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"></EditText></TableLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
|
|
|
@ -3,8 +3,20 @@
|
|||
android:orientation="vertical" android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
|
||||
<LinearLayout android:id="@+id/LinearLayout02" android:layout_height="wrap_content" android:layout_width="fill_parent"><EditText android:id="@+id/SipUri" android:layout_height="wrap_content" android:hint="sip:" android:layout_width="fill_parent" android:lines="1" android:layout_weight="0.8"></EditText>
|
||||
<Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/Erase" android:text=" <- "></Button>
|
||||
<LinearLayout android:id="@+id/LinearLayout02"
|
||||
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"
|
||||
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_width="fill_parent" android:text="<-" android:layout_weight="0.8"></Button>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<LinearLayout android:layout_height="wrap_content" android:layout_width="fill_parent" android:id="@+id/IncallAddressLayout"><EditText android:text="@+id/EditText01" android:layout_height="wrap_content" android:lines="1" android:id="@+id/DisplayNameView" android:clickable="false" android:cursorVisible="false" android:gravity="center" android:layout_width="fill_parent"></EditText>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<TableLayout android:layout_width="fill_parent" android:id="@+id/Dialer"
|
||||
|
|
|
@ -4,4 +4,5 @@
|
|||
<item android:title="@string/menu_settings" android:id="@+id/menu_settings">
|
||||
</item>
|
||||
<item android:title="@string/menu_exit" android:id="@+id/menu_exit"></item>
|
||||
<item android:id="@+id/menu_about" android:title="@string/menu_about"></item>
|
||||
</menu>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="menu_about">About</string>
|
||||
<string name="pref_audio">Audio</string>
|
||||
<string name="menu_exit">Exit</string>
|
||||
<string name="pref_prefix">Prefix</string>
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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<LinphoneCallLog> 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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue