diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 2ad149b55..5286ed535 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -37,13 +37,30 @@ + + + + + + + + + + + + + + + + + diff --git a/res/layout/incoming.xml b/res/layout/incoming.xml new file mode 100644 index 000000000..16ffcc4d3 --- /dev/null +++ b/res/layout/incoming.xml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org/linphone/DialerActivity.java b/src/org/linphone/DialerActivity.java index cf365e2a3..7a826da4c 100644 --- a/src/org/linphone/DialerActivity.java +++ b/src/org/linphone/DialerActivity.java @@ -27,7 +27,6 @@ import org.linphone.core.LinphoneCore; import org.linphone.core.Log; import org.linphone.core.LinphoneCall.State; import org.linphone.mediastream.Version; -import org.linphone.mediastream.video.capture.hwconf.Hacks; import org.linphone.ui.AddVideoButton; import org.linphone.ui.AddressAware; import org.linphone.ui.AddressText; @@ -93,6 +92,7 @@ public class DialerActivity extends LinphoneManagerWaitActivity implements Linph private static final String CURRENT_DISPLAYNAME = "org.linphone.current-displayname"; private static final int incomingCallDialogId = 1; + private static final int INCOMING_CALL_ACTIVITY = 10; /** * @return null if not ready yet @@ -274,7 +274,8 @@ public class DialerActivity extends LinphoneManagerWaitActivity implements Linph private void exitCallMode() { // Remove dialog if existing try { - dismissDialog(incomingCallDialogId); +// dismissDialog(incomingCallDialogId); + finishActivity(INCOMING_CALL_ACTIVITY); } catch (Throwable e) {/* Exception if never created */} if (useIncallActivity) { @@ -307,7 +308,15 @@ public class DialerActivity extends LinphoneManagerWaitActivity implements Linph private void callPending(final LinphoneCall call) { - showDialog(incomingCallDialogId); +// 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()); + + startActivityForResult(intent, INCOMING_CALL_ACTIVITY); } @Override diff --git a/src/org/linphone/IncomingCallActivity.java b/src/org/linphone/IncomingCallActivity.java new file mode 100644 index 000000000..b4c3c1946 --- /dev/null +++ b/src/org/linphone/IncomingCallActivity.java @@ -0,0 +1,59 @@ +/* +IncomingCallActivity.java +Copyright (C) 2011 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; + +import android.app.Activity; +import android.os.Bundle; +import android.view.WindowManager; +import android.widget.TextView; + +/** + * Activity displayed when a call comes in. + * It should bypass the screen lock mechanism. + * + * @author Guillaume Beraudo + */ +public class IncomingCallActivity extends Activity { + + private TextView mNameView; + private TextView mNumberView; + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.incoming); + + mNameView = (TextView) findViewById(R.id.incoming_caller_name); + mNumberView = (TextView) findViewById(R.id.incoming_caller_number); + + + // set this flag so this activity will stay in front of the keyguard + int flags = WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED; + flags |= WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD; + getWindow().addFlags(flags); + } + + @Override + protected void onResume() { + mNameView.setText(getIntent().getStringExtra("name")); + mNumberView.setText(getIntent().getStringExtra("number")); + super.onResume(); + } +}