Customization: incoming call, incall/conference
This commit is contained in:
parent
da73120458
commit
0acbc5c65a
7 changed files with 44 additions and 112 deletions
|
@ -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"/>
|
||||
</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"
|
||||
android:clickable="false" android:focusable="false"
|
||||
android:cursorVisible="false" android:textSize="12sp" android:height="15sp"
|
||||
|
|
|
@ -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"/>
|
||||
</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" />
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -10,8 +10,11 @@
|
|||
<bool name="useFirstLoginActivity">false</bool>
|
||||
<bool name="useMenuSettings">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_incoming_call_dialog">false</bool>
|
||||
<bool name="use_incoming_call_activity">true</bool>
|
||||
<bool name="show_full_remote_address_on_incoming_call">true</bool>
|
||||
|
||||
<string name="notification_title">Linphone</string>
|
||||
|
|
|
@ -298,8 +298,6 @@ public class ConferenceActivity extends ListActivity implements
|
|||
lc().resumeCall(call);
|
||||
break;
|
||||
case R.id.unhook_call:
|
||||
LinphoneCall currentCall = lc().getCurrentCall();
|
||||
if (currentCall != null) lc().pauseCall(currentCall);
|
||||
try {
|
||||
lc().acceptCall(call);
|
||||
} catch (LinphoneCoreException e) {
|
||||
|
@ -454,7 +452,7 @@ public class ConferenceActivity extends ListActivity implements
|
|||
setVisibility(removeFromConfButton, false);
|
||||
|
||||
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;
|
||||
setVisibility(v, R.id.callee_status_paused, statusPaused);
|
||||
|
|
|
@ -47,7 +47,6 @@ import android.os.Bundle;
|
|||
import android.os.PowerManager;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
@ -87,6 +86,7 @@ public class DialerActivity extends LinphoneManagerWaitActivity implements Linph
|
|||
private LinphoneCall mCurrentCall;
|
||||
private boolean useIncallActivity;
|
||||
private boolean useVideoActivity;
|
||||
private boolean useConferenceActivity;
|
||||
|
||||
private static final String CURRENT_ADDRESS = "org.linphone.current-address";
|
||||
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);
|
||||
|
||||
useIncallActivity = getResources().getBoolean(R.bool.use_incall_activity);
|
||||
useConferenceActivity = getResources().getBoolean(R.bool.use_conference_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.
|
||||
|
||||
|
@ -231,8 +232,9 @@ public class DialerActivity extends LinphoneManagerWaitActivity implements Linph
|
|||
if (!mWakeLock.isHeld()) mWakeLock.acquire();
|
||||
|
||||
if (useIncallActivity) {
|
||||
// LinphoneActivity.instance().startIncallActivity(
|
||||
// mDisplayNameView.getText(), mAddress.getPictureUri());
|
||||
LinphoneActivity.instance().startIncallActivity(
|
||||
mDisplayNameView.getText(), mAddress.getPictureUri());
|
||||
} else if (useConferenceActivity) {
|
||||
LinphoneActivity.instance().startConferenceActivity();
|
||||
} else {
|
||||
loadMicAndSpeakerUiStateFromManager();
|
||||
|
@ -249,7 +251,8 @@ public class DialerActivity extends LinphoneManagerWaitActivity implements Linph
|
|||
|
||||
|
||||
private void updateIncallVideoCallButton() {
|
||||
if (useIncallActivity) throw new RuntimeException("Internal error");
|
||||
if (useIncallActivity || useConferenceActivity)
|
||||
throw new RuntimeException("Internal error");
|
||||
|
||||
boolean prefVideoEnabled = LinphoneManager.getInstance().isVideoEnabled();
|
||||
AddVideoButton mAddVideo = (AddVideoButton) findViewById(R.id.AddVideo);
|
||||
|
@ -264,7 +267,8 @@ public class DialerActivity extends LinphoneManagerWaitActivity implements Linph
|
|||
|
||||
|
||||
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());
|
||||
mSpeaker.setSpeakerOn(LinphoneManager.getInstance().isSpeakerOn());
|
||||
|
@ -272,14 +276,20 @@ public class DialerActivity extends LinphoneManagerWaitActivity implements Linph
|
|||
|
||||
|
||||
private void exitCallMode() {
|
||||
if (getResources().getBoolean(R.bool.use_incoming_call_activity)) {
|
||||
finishActivity(INCOMING_CALL_ACTIVITY);
|
||||
} else if (getResources().getBoolean(R.bool.use_incoming_call_dialog)) {
|
||||
// Remove dialog if existing
|
||||
try {
|
||||
// dismissDialog(incomingCallDialogId);
|
||||
finishActivity(INCOMING_CALL_ACTIVITY);
|
||||
dismissDialog(incomingCallDialogId);
|
||||
} catch (Throwable e) {/* Exception if never created */}
|
||||
}
|
||||
|
||||
|
||||
if (useIncallActivity) {
|
||||
LinphoneActivity.instance().closeIncallActivity();
|
||||
} else if(useConferenceActivity) {
|
||||
LinphoneActivity.instance().closeConferenceActivity();
|
||||
}else {
|
||||
mCallControlRow.setVisibility(View.VISIBLE);
|
||||
mInCallControlRow.setVisibility(View.GONE);
|
||||
|
@ -308,15 +318,12 @@ public class DialerActivity extends LinphoneManagerWaitActivity implements Linph
|
|||
|
||||
|
||||
private void callPending(final LinphoneCall call) {
|
||||
// showDialog(incomingCallDialogId);
|
||||
LinphoneAddress address = LinphoneManager.getLc().getRemoteAddress();
|
||||
String from = LinphoneManager.extractADisplayName(getResources(), address);
|
||||
Intent intent = new Intent()
|
||||
.setClass(this, IncomingCallActivity.class)
|
||||
.putExtra("name", from)
|
||||
.putExtra("number", address.asStringUriOnly());
|
||||
|
||||
if (getResources().getBoolean(R.bool.use_incoming_call_activity)) {
|
||||
Intent intent = new Intent().setClass(this, IncomingCallActivity.class);
|
||||
startActivityForResult(intent, INCOMING_CALL_ACTIVITY);
|
||||
} else if (getResources().getBoolean(R.bool.use_incoming_call_dialog)) {
|
||||
showDialog(incomingCallDialogId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -470,7 +477,7 @@ public class DialerActivity extends LinphoneManagerWaitActivity implements Linph
|
|||
|
||||
public void onGlobalStateChangedToOn(String message) {
|
||||
mCall.setEnabled(!LinphoneManager.getLc().isIncall());
|
||||
if (!useIncallActivity) updateIncallVideoCallButton();
|
||||
if (!useIncallActivity && !useConferenceActivity) updateIncallVideoCallButton();
|
||||
else mHangup.setEnabled(!mCall.isEnabled());
|
||||
|
||||
if (getIntent().getData() != null) {
|
||||
|
@ -503,55 +510,4 @@ public class DialerActivity extends LinphoneManagerWaitActivity implements Linph
|
|||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -32,6 +32,10 @@ import android.view.View;
|
|||
import android.view.View.OnClickListener;
|
||||
import android.widget.TextView;
|
||||
|
||||
/**
|
||||
* @author Guillaume Beraudo
|
||||
*
|
||||
*/
|
||||
public class IncallActivity extends SoftVolumeActivity implements OnClickListener {
|
||||
|
||||
public static final String CONTACT_KEY = "contact";
|
||||
|
|
|
@ -174,17 +174,6 @@ public class LinphoneActivity extends TabActivity implements SensorEventListener
|
|||
}
|
||||
break;
|
||||
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;
|
||||
default:
|
||||
break;
|
||||
|
@ -236,7 +225,9 @@ public class LinphoneActivity extends TabActivity implements SensorEventListener
|
|||
} else {
|
||||
if (getResources().getBoolean(R.bool.use_incall_activity)) {
|
||||
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 {
|
||||
// TODO
|
||||
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) {
|
||||
/* Intent intent = new Intent().setClass(this, IncallActivity.class)
|
||||
Intent intent = new Intent().setClass(this, IncallActivity.class)
|
||||
.putExtra(IncallActivity.CONTACT_KEY, callerName);
|
||||
if (pictureUri != null)
|
||||
intent.putExtra(IncallActivity.PICTURE_URI_KEY, pictureUri.toString());
|
||||
startActivityForResult(intent, INCALL_ACTIVITY);*/
|
||||
// Hacked
|
||||
startConferenceActivity();
|
||||
startActivityForResult(intent, INCALL_ACTIVITY);
|
||||
}
|
||||
|
||||
public void closeIncallActivity() {
|
||||
finishActivity(INCALL_ACTIVITY);
|
||||
}
|
||||
public void closeConferenceActivity() {
|
||||
finishActivity(conference_activity);
|
||||
}
|
||||
|
||||
public void startVideoActivity() {
|
||||
mHandler.post(new Runnable() {
|
||||
|
|
Loading…
Reference in a new issue