Customization: incoming call, incall/conference

This commit is contained in:
Guillaume Beraudo 2011-09-27 14:03:16 +02:00
parent da73120458
commit 0acbc5c65a
7 changed files with 44 additions and 112 deletions

View file

@ -51,17 +51,6 @@
<org.linphone.ui.HangCallButton android:id="@+id/HangUp" android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="1" android:src="@drawable/stopcall_red" android:background="@drawable/clavier_bg"/> <org.linphone.ui.HangCallButton android:id="@+id/HangUp" android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="1" android:src="@drawable/stopcall_red" android:background="@drawable/clavier_bg"/>
</LinearLayout> </LinearLayout>
<LinearLayout android:id="@+id/AddCallControlRow" android:layout_height="wrap_content" android:layout_width="fill_parent" android:gravity="bottom" android:visibility="gone">
<Button android:id="@+id/AddCallButton" android:text="@string/AddCallButtonText" android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="1" android:background="@drawable/clavier_bg"/>
<Button android:id="@+id/AddCallCancelButton" android:text="@string/CancelButtonText" android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="1" android:background="@drawable/clavier_bg"/>
</LinearLayout>
<LinearLayout android:id="@+id/transferCallControlRow" android:layout_height="wrap_content" android:layout_width="fill_parent" android:gravity="bottom" android:visibility="gone">
<Button android:id="@+id/TransferCallButton" android:text="@string/TransferCallButtonText" android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="1" android:background="@drawable/clavier_bg"/>
<Button android:id="@+id/TransferCallCancelButton" android:text="@string/CancelButtonText" android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="1" android:background="@drawable/clavier_bg"/>
</LinearLayout>
<EditText android:id="@+id/status_label" android:layout_width="fill_parent" <EditText android:id="@+id/status_label" android:layout_width="fill_parent"
android:clickable="false" android:focusable="false" android:clickable="false" android:focusable="false"
android:cursorVisible="false" android:textSize="12sp" android:height="15sp" android:cursorVisible="false" android:textSize="12sp" android:height="15sp"

View file

@ -48,16 +48,6 @@
<org.linphone.ui.HangCallButton android:id="@+id/HangUp" android:src="@drawable/stopcall_red" android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="0.25" android:background="@drawable/clavier_bg"/> <org.linphone.ui.HangCallButton android:id="@+id/HangUp" android:src="@drawable/stopcall_red" android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="0.25" android:background="@drawable/clavier_bg"/>
</LinearLayout> </LinearLayout>
<LinearLayout android:id="@+id/AddCallControlRow" android:layout_height="wrap_content" android:layout_width="fill_parent" android:gravity="bottom" android:visibility="gone">
<Button android:id="@+id/AddCallButton" android:text="@string/AddCallButtonText" android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="1" android:background="@drawable/clavier_bg"/>
<Button android:id="@+id/AddCallCancelButton" android:text="@string/CancelButtonText" android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="1" android:background="@drawable/clavier_bg"/>
</LinearLayout>
<LinearLayout android:id="@+id/transferCallControlRow" android:layout_height="wrap_content" android:layout_width="fill_parent" android:gravity="bottom" android:visibility="gone">
<Button android:id="@+id/TransferCallButton" android:text="@string/TransferCallButtonText" android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="1" android:background="@drawable/clavier_bg"/>
<Button android:id="@+id/TransferCallCancelButton" android:text="@string/CancelButtonText" android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="1" android:background="@drawable/clavier_bg"/>
</LinearLayout>
<EditText 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:layout_width="fill_parent" android:background="@android:color/transparent" android:textColor="@android:color/white" /> <EditText 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:layout_width="fill_parent" android:background="@android:color/transparent" android:textColor="@android:color/white" />
</LinearLayout> </LinearLayout>

View file

@ -10,8 +10,11 @@
<bool name="useFirstLoginActivity">false</bool> <bool name="useFirstLoginActivity">false</bool>
<bool name="useMenuSettings">true</bool> <bool name="useMenuSettings">true</bool>
<bool name="useMenuAbout">true</bool> <bool name="useMenuAbout">true</bool>
<bool name="use_incall_activity">true</bool> <bool name="use_incall_activity">false</bool>
<bool name="use_conference_activity">true</bool>
<bool name="use_video_activity">true</bool> <bool name="use_video_activity">true</bool>
<bool name="use_incoming_call_dialog">false</bool>
<bool name="use_incoming_call_activity">true</bool>
<bool name="show_full_remote_address_on_incoming_call">true</bool> <bool name="show_full_remote_address_on_incoming_call">true</bool>
<string name="notification_title">Linphone</string> <string name="notification_title">Linphone</string>

View file

@ -298,8 +298,6 @@ public class ConferenceActivity extends ListActivity implements
lc().resumeCall(call); lc().resumeCall(call);
break; break;
case R.id.unhook_call: case R.id.unhook_call:
LinphoneCall currentCall = lc().getCurrentCall();
if (currentCall != null) lc().pauseCall(currentCall);
try { try {
lc().acceptCall(call); lc().acceptCall(call);
} catch (LinphoneCoreException e) { } catch (LinphoneCoreException e) {
@ -454,7 +452,7 @@ public class ConferenceActivity extends ListActivity implements
setVisibility(removeFromConfButton, false); setVisibility(removeFromConfButton, false);
final int numberOfCalls = linphoneCalls.size(); final int numberOfCalls = linphoneCalls.size();
setVisibility(v, R.id.addVideo, !showUnhook && numberOfCalls == 1); setVisibility(v, R.id.addVideo, !isInConference && !showUnhook && numberOfCalls == 1);
boolean statusPaused = state== State.Paused || state == State.PausedByRemote; boolean statusPaused = state== State.Paused || state == State.PausedByRemote;
setVisibility(v, R.id.callee_status_paused, statusPaused); setVisibility(v, R.id.callee_status_paused, statusPaused);

View file

@ -47,7 +47,6 @@ import android.os.Bundle;
import android.os.PowerManager; import android.os.PowerManager;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.view.View; import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
@ -87,6 +86,7 @@ public class DialerActivity extends LinphoneManagerWaitActivity implements Linph
private LinphoneCall mCurrentCall; private LinphoneCall mCurrentCall;
private boolean useIncallActivity; private boolean useIncallActivity;
private boolean useVideoActivity; private boolean useVideoActivity;
private boolean useConferenceActivity;
private static final String CURRENT_ADDRESS = "org.linphone.current-address"; private static final String CURRENT_ADDRESS = "org.linphone.current-address";
private static final String CURRENT_DISPLAYNAME = "org.linphone.current-displayname"; private static final String CURRENT_DISPLAYNAME = "org.linphone.current-displayname";
@ -107,6 +107,7 @@ public class DialerActivity extends LinphoneManagerWaitActivity implements Linph
setContentView(R.layout.dialer); setContentView(R.layout.dialer);
useIncallActivity = getResources().getBoolean(R.bool.use_incall_activity); useIncallActivity = getResources().getBoolean(R.bool.use_incall_activity);
useConferenceActivity = getResources().getBoolean(R.bool.use_conference_activity);
useVideoActivity = getResources().getBoolean(R.bool.use_video_activity); useVideoActivity = getResources().getBoolean(R.bool.use_video_activity);
// Don't use Linphone Manager in the onCreate as it takes time in LinphoneService to initialize it. // Don't use Linphone Manager in the onCreate as it takes time in LinphoneService to initialize it.
@ -231,8 +232,9 @@ public class DialerActivity extends LinphoneManagerWaitActivity implements Linph
if (!mWakeLock.isHeld()) mWakeLock.acquire(); if (!mWakeLock.isHeld()) mWakeLock.acquire();
if (useIncallActivity) { if (useIncallActivity) {
// LinphoneActivity.instance().startIncallActivity( LinphoneActivity.instance().startIncallActivity(
// mDisplayNameView.getText(), mAddress.getPictureUri()); mDisplayNameView.getText(), mAddress.getPictureUri());
} else if (useConferenceActivity) {
LinphoneActivity.instance().startConferenceActivity(); LinphoneActivity.instance().startConferenceActivity();
} else { } else {
loadMicAndSpeakerUiStateFromManager(); loadMicAndSpeakerUiStateFromManager();
@ -249,7 +251,8 @@ public class DialerActivity extends LinphoneManagerWaitActivity implements Linph
private void updateIncallVideoCallButton() { private void updateIncallVideoCallButton() {
if (useIncallActivity) throw new RuntimeException("Internal error"); if (useIncallActivity || useConferenceActivity)
throw new RuntimeException("Internal error");
boolean prefVideoEnabled = LinphoneManager.getInstance().isVideoEnabled(); boolean prefVideoEnabled = LinphoneManager.getInstance().isVideoEnabled();
AddVideoButton mAddVideo = (AddVideoButton) findViewById(R.id.AddVideo); AddVideoButton mAddVideo = (AddVideoButton) findViewById(R.id.AddVideo);
@ -264,7 +267,8 @@ public class DialerActivity extends LinphoneManagerWaitActivity implements Linph
private void loadMicAndSpeakerUiStateFromManager() { private void loadMicAndSpeakerUiStateFromManager() {
if (useIncallActivity) throw new RuntimeException("Internal error"); // only dialer widgets are updated with this if (useIncallActivity || useConferenceActivity)
throw new RuntimeException("Internal error"); // only dialer widgets are updated with this
mMute.setChecked(LinphoneManager.getLc().isMicMuted()); mMute.setChecked(LinphoneManager.getLc().isMicMuted());
mSpeaker.setSpeakerOn(LinphoneManager.getInstance().isSpeakerOn()); mSpeaker.setSpeakerOn(LinphoneManager.getInstance().isSpeakerOn());
@ -272,15 +276,21 @@ public class DialerActivity extends LinphoneManagerWaitActivity implements Linph
private void exitCallMode() { private void exitCallMode() {
// Remove dialog if existing if (getResources().getBoolean(R.bool.use_incoming_call_activity)) {
try {
// dismissDialog(incomingCallDialogId);
finishActivity(INCOMING_CALL_ACTIVITY); finishActivity(INCOMING_CALL_ACTIVITY);
} catch (Throwable e) {/* Exception if never created */} } else if (getResources().getBoolean(R.bool.use_incoming_call_dialog)) {
// Remove dialog if existing
try {
dismissDialog(incomingCallDialogId);
} catch (Throwable e) {/* Exception if never created */}
}
if (useIncallActivity) { if (useIncallActivity) {
LinphoneActivity.instance().closeIncallActivity(); LinphoneActivity.instance().closeIncallActivity();
} else { } else if(useConferenceActivity) {
LinphoneActivity.instance().closeConferenceActivity();
}else {
mCallControlRow.setVisibility(View.VISIBLE); mCallControlRow.setVisibility(View.VISIBLE);
mInCallControlRow.setVisibility(View.GONE); mInCallControlRow.setVisibility(View.GONE);
mInCallAddressLayout.setVisibility(View.GONE); mInCallAddressLayout.setVisibility(View.GONE);
@ -308,15 +318,12 @@ public class DialerActivity extends LinphoneManagerWaitActivity implements Linph
private void callPending(final LinphoneCall call) { private void callPending(final LinphoneCall call) {
// showDialog(incomingCallDialogId); if (getResources().getBoolean(R.bool.use_incoming_call_activity)) {
LinphoneAddress address = LinphoneManager.getLc().getRemoteAddress(); Intent intent = new Intent().setClass(this, IncomingCallActivity.class);
String from = LinphoneManager.extractADisplayName(getResources(), address); startActivityForResult(intent, INCOMING_CALL_ACTIVITY);
Intent intent = new Intent() } else if (getResources().getBoolean(R.bool.use_incoming_call_dialog)) {
.setClass(this, IncomingCallActivity.class) showDialog(incomingCallDialogId);
.putExtra("name", from) }
.putExtra("number", address.asStringUriOnly());
startActivityForResult(intent, INCOMING_CALL_ACTIVITY);
} }
@Override @Override
@ -470,7 +477,7 @@ public class DialerActivity extends LinphoneManagerWaitActivity implements Linph
public void onGlobalStateChangedToOn(String message) { public void onGlobalStateChangedToOn(String message) {
mCall.setEnabled(!LinphoneManager.getLc().isIncall()); mCall.setEnabled(!LinphoneManager.getLc().isIncall());
if (!useIncallActivity) updateIncallVideoCallButton(); if (!useIncallActivity && !useConferenceActivity) updateIncallVideoCallButton();
else mHangup.setEnabled(!mCall.isEnabled()); else mHangup.setEnabled(!mCall.isEnabled());
if (getIntent().getData() != null) { if (getIntent().getData() != null) {
@ -503,55 +510,4 @@ public class DialerActivity extends LinphoneManagerWaitActivity implements Linph
super.onResume(); super.onResume();
} }
private void switchControlRow(ViewGroup v, OnClickListener l) {
final View ok = v.getChildAt(0);
final View cancel = v.getChildAt(1);
ok.setOnClickListener(l);
cancel.setOnClickListener(l);
findViewById(R.id.IncallControlRow).setVisibility(View.GONE);
findViewById(R.id.CallControlRow).setVisibility(View.GONE);
v.setVisibility(View.VISIBLE);
}
public void configureForAddingCall() {
ViewGroup v = (ViewGroup) findViewById(R.id.AddCallControlRow);
OnClickListener l = new OnClickListener() {
public void onClick(View v) {
ViewGroup group = (ViewGroup) v.getParent();
if (v == group.getChildAt(1)) {
LinphoneActivity.instance().startConferenceActivity();
} else {
LinphoneManager.getInstance().newOutgoingCall(mAddress);
}
}
};
switchControlRow(v, l);
}
public void configureForTransferingCall(final long callNativeId) {
throw new RuntimeException("create another activity for this");
// ViewGroup v = (ViewGroup) findViewById(R.id.transferCallControlRow);
// OnClickListener l = new OnClickListener() {
// public void onClick(View v) {
// ViewGroup group = (ViewGroup) v.getParent();
// if (v == group.getChildAt(1)) {
// LinphoneActivity.instance().startConferenceActivity();
// } else {
// LinphoneManager.getLc().transferCall(Hacks.createCall(callNativeId),
// mAddress.getText().toString());
// }
// }
// };
// switchControlRow(v, l);
}
public void configureForDialer() {
findViewById(R.id.AddCallControlRow).setVisibility(R.id.transferCallControlRow);
findViewById(R.id.AddCallControlRow).setVisibility(View.GONE);
findViewById(R.id.IncallControlRow).setVisibility(View.GONE);
findViewById(R.id.CallControlRow).setVisibility(View.VISIBLE);
}
} }

View file

@ -32,6 +32,10 @@ import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.widget.TextView; import android.widget.TextView;
/**
* @author Guillaume Beraudo
*
*/
public class IncallActivity extends SoftVolumeActivity implements OnClickListener { public class IncallActivity extends SoftVolumeActivity implements OnClickListener {
public static final String CONTACT_KEY = "contact"; public static final String CONTACT_KEY = "contact";

View file

@ -174,17 +174,6 @@ public class LinphoneActivity extends TabActivity implements SensorEventListener
} }
break; break;
case conference_activity: case conference_activity:
if (data == null) {
DialerActivity.instance().configureForDialer();
} else if (data.getBooleanExtra(ConferenceActivity.ADD_CALL, false)) {
DialerActivity.instance().configureForAddingCall();
gotToDialer();
} else if (data.getBooleanExtra(ConferenceActivity.TRANSFER_TO_NEW_CALL, false)) {
long callId = data.getLongExtra(ConferenceActivity.CALL_NATIVE_ID, 0l);
if (callId == 0) throw new RuntimeException("call id is 0");
DialerActivity.instance().configureForTransferingCall(callId);
gotToDialer();
}
break; break;
default: default:
break; break;
@ -236,7 +225,9 @@ public class LinphoneActivity extends TabActivity implements SensorEventListener
} else { } else {
if (getResources().getBoolean(R.bool.use_incall_activity)) { if (getResources().getBoolean(R.bool.use_incall_activity)) {
LinphoneAddress address = LinphoneManager.getLc().getRemoteAddress(); LinphoneAddress address = LinphoneManager.getLc().getRemoteAddress();
startIncallActivity(LinphoneManager.getInstance().extractADisplayName(getResources(), address), null); startIncallActivity(LinphoneManager.extractADisplayName(getResources(), address), null);
} if (getResources().getBoolean(R.bool.use_conference_activity)) {
startConferenceActivity();
} else { } else {
// TODO // TODO
Log.e("Not handled case: recreation while in call and not using incall activity"); Log.e("Not handled case: recreation while in call and not using incall activity");
@ -497,18 +488,19 @@ public class LinphoneActivity extends TabActivity implements SensorEventListener
} }
public void startIncallActivity(CharSequence callerName, Uri pictureUri) { public void startIncallActivity(CharSequence callerName, Uri pictureUri) {
/* Intent intent = new Intent().setClass(this, IncallActivity.class) Intent intent = new Intent().setClass(this, IncallActivity.class)
.putExtra(IncallActivity.CONTACT_KEY, callerName); .putExtra(IncallActivity.CONTACT_KEY, callerName);
if (pictureUri != null) if (pictureUri != null)
intent.putExtra(IncallActivity.PICTURE_URI_KEY, pictureUri.toString()); intent.putExtra(IncallActivity.PICTURE_URI_KEY, pictureUri.toString());
startActivityForResult(intent, INCALL_ACTIVITY);*/ startActivityForResult(intent, INCALL_ACTIVITY);
// Hacked
startConferenceActivity();
} }
public void closeIncallActivity() { public void closeIncallActivity() {
finishActivity(INCALL_ACTIVITY); finishActivity(INCALL_ACTIVITY);
} }
public void closeConferenceActivity() {
finishActivity(conference_activity);
}
public void startVideoActivity() { public void startVideoActivity() {
mHandler.post(new Runnable() { mHandler.post(new Runnable() {