Start rework incall view
This commit is contained in:
parent
219b3005f8
commit
755569c73e
6 changed files with 327 additions and 114 deletions
|
@ -27,7 +27,7 @@
|
|||
android:id="@+id/status"
|
||||
android:name="org.linphone.StatusFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="40dp"
|
||||
tools:layout="@layout/status" />
|
||||
|
||||
</FrameLayout>
|
||||
|
@ -120,19 +120,15 @@
|
|||
android:text="@string/button_receiver"
|
||||
android:gravity="center"
|
||||
android:paddingTop="40dp"
|
||||
android:textColor="@drawable/text_incall_button_color"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.5" />
|
||||
|
||||
<TextView
|
||||
<ImageView
|
||||
android:id="@+id/transfer"
|
||||
android:visibility="invisible"
|
||||
android:background="@drawable/options_transfer"
|
||||
android:text="@string/button_transfer"
|
||||
android:gravity="center"
|
||||
android:paddingTop="40dp"
|
||||
android:textColor="@drawable/text_incall_button_color"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.5" />
|
||||
|
@ -159,22 +155,17 @@
|
|||
<TextView
|
||||
android:id="@+id/routeSpeaker"
|
||||
android:visibility="invisible"
|
||||
android:text="@string/button_speaker"
|
||||
android:gravity="center"
|
||||
android:paddingTop="40dp"
|
||||
android:textColor="@drawable/text_incall_button_color"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.5" />
|
||||
|
||||
<TextView
|
||||
<ImageView
|
||||
android:id="@+id/addCall"
|
||||
android:visibility="invisible"
|
||||
android:background="@drawable/options_add_call_alt"
|
||||
android:text="@string/button_add_call"
|
||||
android:gravity="center"
|
||||
android:paddingTop="40dp"
|
||||
android:textColor="@drawable/text_incall_button_color"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.5" />
|
||||
|
@ -183,23 +174,22 @@
|
|||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="60dp"
|
||||
android:background="@color/colorF"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center">
|
||||
android:layout_gravity="center">
|
||||
|
||||
<TextView
|
||||
<ImageView
|
||||
android:id="@+id/video"
|
||||
android:background="@drawable/video_off"
|
||||
android:text="@string/button_video"
|
||||
android:gravity="center"
|
||||
android:paddingTop="45dp"
|
||||
android:textColor="@drawable/text_incall_button_color"
|
||||
|
||||
android:src="@drawable/camera_default"
|
||||
android:layout_width="match_parent"
|
||||
android:background="@color/button_addContact"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<ProgressBar
|
||||
|
@ -213,47 +203,37 @@
|
|||
|
||||
</RelativeLayout>
|
||||
|
||||
<TextView
|
||||
<ImageView
|
||||
android:id="@+id/micro"
|
||||
android:background="@drawable/micro_on"
|
||||
android:text="@string/button_micro"
|
||||
android:gravity="center"
|
||||
android:paddingTop="45dp"
|
||||
android:textColor="@drawable/text_incall_button_color"
|
||||
android:src="@drawable/micro_default"
|
||||
android:layout_gravity="center"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/button_addContact"
|
||||
android:layout_weight="1" />
|
||||
|
||||
|
||||
<TextView
|
||||
<ImageView
|
||||
android:id="@+id/speaker"
|
||||
android:background="@drawable/speaker_off"
|
||||
android:text="@string/button_speaker"
|
||||
android:gravity="center"
|
||||
android:paddingTop="45dp"
|
||||
android:textColor="@drawable/text_incall_button_color"
|
||||
android:layout_gravity="center"
|
||||
android:src="@drawable/speaker_default"
|
||||
android:background="@color/button_addContact"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<TextView
|
||||
<ImageView
|
||||
android:id="@+id/audioRoute"
|
||||
android:text="@string/button_route"
|
||||
android:gravity="center"
|
||||
android:paddingTop="45dp"
|
||||
android:textColor="@drawable/text_incall_button_color"
|
||||
android:visibility="gone"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<TextView
|
||||
<ImageView
|
||||
android:id="@+id/options"
|
||||
android:background="@drawable/options"
|
||||
android:text="@string/button_options"
|
||||
android:gravity="center"
|
||||
android:paddingTop="45dp"
|
||||
android:textColor="@drawable/text_incall_button_color"
|
||||
android:src="@drawable/options_default"
|
||||
android:layout_gravity="center"
|
||||
android:background="@color/button_addContact"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1" />
|
||||
|
@ -261,43 +241,42 @@
|
|||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@android:color/black"
|
||||
android:layout_height="60dp"
|
||||
android:layout_gravity="center"
|
||||
android:orientation="horizontal" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/pause"
|
||||
android:contentDescription="@string/content_description_pause"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/pause_off" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/conference"
|
||||
android:contentDescription="@string/content_description_conference"
|
||||
android:visibility="gone"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/conference" />
|
||||
<ImageView
|
||||
android:id="@+id/dialer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="center"
|
||||
android:background="@color/colorC"
|
||||
android:contentDescription="@string/content_description_contacts"
|
||||
android:src="@drawable/footer_dialer" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/hangUp"
|
||||
android:contentDescription="@string/content_description_hang_up"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.97"
|
||||
android:background="@drawable/hangup" />
|
||||
<ImageView
|
||||
android:id="@+id/hangUp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:adjustViewBounds="true"
|
||||
android:layout_weight="0.5"
|
||||
android:background="@color/colorD"
|
||||
android:contentDescription="@string/content_description_contacts"
|
||||
android:src="@drawable/call_hangup" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/dialer"
|
||||
android:contentDescription="@string/content_description_dialer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/dialer_alt" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/chat"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="center"
|
||||
android:background="@color/colorC"
|
||||
android:contentDescription="@string/content_description_contacts"
|
||||
android:src="@drawable/footer_chat" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
@ -5,37 +5,62 @@
|
|||
android:layout_height="match_parent"
|
||||
android:background="@color/background">
|
||||
|
||||
<include layout="@layout/status" android:id="@+id/statusBar" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:layout_below="@id/statusBar"
|
||||
android:background="@color/colorF">
|
||||
|
||||
<TextView
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:textColor="@color/colorA"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:text="@string/incoming"
|
||||
android:textAllCaps="true"
|
||||
android:paddingLeft="10dp"
|
||||
android:gravity="center"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingTop="50dp"
|
||||
android:layout_below="@id/toolbar"
|
||||
android:orientation="vertical"
|
||||
android:layout_above="@id/menu">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/incoming_caller_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:textAlignment="center"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:textColor="@android:color/black"
|
||||
android:textSize="28sp" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/incoming_caller_profile"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="vertical" >
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="10dp"
|
||||
android:weightSum="1">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/incoming_picture"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="259dp"
|
||||
android:layout_height="207dp"
|
||||
android:src="@drawable/avatar"
|
||||
android:paddingBottom="10dp"
|
||||
android:layout_marginTop="10dp" />
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_weight="1.30"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/incoming_caller_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:textAlignment="center"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:textColor="@android:color/black"
|
||||
android:textSize="28sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/incoming_caller_number"
|
||||
|
@ -43,7 +68,7 @@
|
|||
android:layout_height="40dp"
|
||||
android:textColor="@android:color/black"
|
||||
android:textSize="28sp"
|
||||
android:layout_gravity="center_horizontal" />
|
||||
android:layout_gravity="center_horizontal"/>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
@ -165,7 +165,7 @@
|
|||
android:layout_height="25dp"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:background="@drawable/missed_calls_bg"
|
||||
android:background="@drawable/history_chat_indicator"
|
||||
android:gravity="center"
|
||||
android:textSize="20sp"
|
||||
android:visibility="gone" />
|
||||
|
|
|
@ -77,7 +77,7 @@ public class InCallActivity extends Activity implements OnClickListener {
|
|||
private Handler mControlsHandler = new Handler();
|
||||
private Runnable mControls;
|
||||
private ImageView switchCamera;
|
||||
private TextView pause, hangUp, dialer, video, micro, speaker, options, addCall, transfer, conference;
|
||||
private ImageView pause, hangUp, dialer, video, micro, speaker, options, addCall, transfer, conference;
|
||||
private TextView audioRoute, routeSpeaker, routeReceiver, routeBluetooth;
|
||||
private LinearLayout routeLayout;
|
||||
private ProgressBar videoProgress;
|
||||
|
@ -171,7 +171,7 @@ public class InCallActivity extends Activity implements OnClickListener {
|
|||
LinphoneManager.getLc().enableSpeaker(isSpeakerEnabled);
|
||||
|
||||
isMicMuted = LinphoneManager.getLc().isMicMuted();
|
||||
enableAndRefreshInCallActions();
|
||||
//enableAndRefreshInCallActions();
|
||||
|
||||
if (status != null) {
|
||||
videoProgress.setVisibility(View.GONE);
|
||||
|
@ -179,9 +179,9 @@ public class InCallActivity extends Activity implements OnClickListener {
|
|||
}
|
||||
}
|
||||
|
||||
refreshInCallActions();
|
||||
//refreshInCallActions();
|
||||
|
||||
refreshCallList(getResources());
|
||||
//refreshCallList(getResources());
|
||||
|
||||
if (state == State.CallUpdatedByRemote) {
|
||||
// If the correspondent proposes video while audio call
|
||||
|
@ -236,7 +236,7 @@ public class InCallActivity extends Activity implements OnClickListener {
|
|||
LinphoneCall call = LinphoneManager.getLc().getCalls()[0];
|
||||
|
||||
if (LinphoneUtils.isCallEstablished(call)) {
|
||||
enableAndRefreshInCallActions();
|
||||
//enableAndRefreshInCallActions();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -245,7 +245,7 @@ public class InCallActivity extends Activity implements OnClickListener {
|
|||
isSpeakerEnabled = savedInstanceState.getBoolean("Speaker");
|
||||
isMicMuted = savedInstanceState.getBoolean("Mic");
|
||||
isVideoCallPaused = savedInstanceState.getBoolean("VideoCallPaused");
|
||||
refreshInCallActions();
|
||||
//refreshInCallActions();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -303,35 +303,35 @@ public class InCallActivity extends Activity implements OnClickListener {
|
|||
|
||||
}
|
||||
|
||||
video = (TextView) findViewById(R.id.video);
|
||||
video = (ImageView) findViewById(R.id.video);
|
||||
video.setOnClickListener(this);
|
||||
video.setEnabled(false);
|
||||
micro = (TextView) findViewById(R.id.micro);
|
||||
micro = (ImageView) findViewById(R.id.micro);
|
||||
micro.setOnClickListener(this);
|
||||
// micro.setEnabled(false);
|
||||
speaker = (TextView) findViewById(R.id.speaker);
|
||||
speaker = (ImageView) findViewById(R.id.speaker);
|
||||
speaker.setOnClickListener(this);
|
||||
if(isTablet()){
|
||||
speaker.setEnabled(false);
|
||||
}
|
||||
// speaker.setEnabled(false);
|
||||
addCall = (TextView) findViewById(R.id.addCall);
|
||||
addCall = (ImageView) findViewById(R.id.addCall);
|
||||
addCall.setOnClickListener(this);
|
||||
addCall.setEnabled(false);
|
||||
transfer = (TextView) findViewById(R.id.transfer);
|
||||
transfer = (ImageView) findViewById(R.id.transfer);
|
||||
transfer.setOnClickListener(this);
|
||||
transfer.setEnabled(false);
|
||||
options = (TextView) findViewById(R.id.options);
|
||||
options = (ImageView) findViewById(R.id.options);
|
||||
options.setOnClickListener(this);
|
||||
options.setEnabled(false);
|
||||
pause = (TextView) findViewById(R.id.pause);
|
||||
pause.setOnClickListener(this);
|
||||
pause.setEnabled(false);
|
||||
hangUp = (TextView) findViewById(R.id.hangUp);
|
||||
//pause = (ImageView) findViewById(R.id.pause);
|
||||
//pause.setOnClickListener(this);
|
||||
//pause.setEnabled(false);
|
||||
hangUp = (ImageView) findViewById(R.id.hangUp);
|
||||
hangUp.setOnClickListener(this);
|
||||
conference = (TextView) findViewById(R.id.conference);
|
||||
conference.setOnClickListener(this);
|
||||
dialer = (TextView) findViewById(R.id.dialer);
|
||||
//conference = (ImageView) findViewById(R.id.conference);
|
||||
//conference.setOnClickListener(this);
|
||||
dialer = (ImageView) findViewById(R.id.dialer);
|
||||
dialer.setOnClickListener(this);
|
||||
dialer.setEnabled(false);
|
||||
numpad = (Numpad) findViewById(R.id.numpad);
|
||||
|
@ -339,7 +339,7 @@ public class InCallActivity extends Activity implements OnClickListener {
|
|||
videoProgress.setVisibility(View.GONE);
|
||||
|
||||
|
||||
try {
|
||||
/*try {
|
||||
routeLayout = (LinearLayout) findViewById(R.id.routesLayout);
|
||||
audioRoute = (TextView) findViewById(R.id.audioRoute);
|
||||
audioRoute.setOnClickListener(this);
|
||||
|
@ -351,7 +351,7 @@ public class InCallActivity extends Activity implements OnClickListener {
|
|||
routeBluetooth.setOnClickListener(this);
|
||||
} catch (NullPointerException npe) {
|
||||
Log.e("Bluetooth: Audio routes menu disabled on tablets for now (1)");
|
||||
}
|
||||
}*/
|
||||
|
||||
switchCamera = (ImageView) findViewById(R.id.switchCamera);
|
||||
switchCamera.setOnClickListener(this);
|
||||
|
@ -457,7 +457,7 @@ public class InCallActivity extends Activity implements OnClickListener {
|
|||
speaker.setEnabled(true);
|
||||
}
|
||||
transfer.setEnabled(true);
|
||||
pause.setEnabled(true);
|
||||
//pause.setEnabled(true);
|
||||
dialer.setEnabled(true);
|
||||
conference.setEnabled(true);
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ import android.app.Activity;
|
|||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
@ -76,6 +77,22 @@ public class IncomingCallActivity extends Activity implements LinphoneSliderTrig
|
|||
int flags = WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON;
|
||||
getWindow().addFlags(flags);
|
||||
|
||||
ImageView accept = (ImageView) findViewById(R.id.accept);
|
||||
accept.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
answer();
|
||||
}
|
||||
});
|
||||
|
||||
ImageView decline = (ImageView) findViewById(R.id.decline);
|
||||
decline.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
decline();
|
||||
}
|
||||
});
|
||||
|
||||
// "Dial-to-answer" widget for incoming calls.
|
||||
|
||||
mListener = new LinphoneCoreListenerBase(){
|
||||
|
|
192
src/org/linphone/OutgoingCallActivity.java
Normal file
192
src/org/linphone/OutgoingCallActivity.java
Normal file
|
@ -0,0 +1,192 @@
|
|||
/*
|
||||
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 java.util.List;
|
||||
|
||||
import org.linphone.core.LinphoneAddress;
|
||||
import org.linphone.core.LinphoneCall;
|
||||
import org.linphone.core.LinphoneCall.State;
|
||||
import org.linphone.core.LinphoneCallParams;
|
||||
import org.linphone.core.LinphoneCore;
|
||||
import org.linphone.core.LinphoneCoreListenerBase;
|
||||
import org.linphone.mediastream.Log;
|
||||
import org.linphone.ui.LinphoneSliders;
|
||||
import org.linphone.ui.LinphoneSliders.LinphoneSliderTriggered;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
/**
|
||||
* Activity displayed when a call comes in.
|
||||
* It should bypass the screen lock mechanism.
|
||||
*
|
||||
* @author Guillaume Beraudo
|
||||
*/
|
||||
public class OutgoingCallActivity extends Activity {
|
||||
|
||||
private static OutgoingCallActivity instance;
|
||||
|
||||
private TextView mNameView;
|
||||
private TextView mNumberView;
|
||||
private ImageView mPictureView;
|
||||
private LinphoneCall mCall;
|
||||
private LinphoneCoreListenerBase mListener;
|
||||
|
||||
public static OutgoingCallActivity instance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static boolean isInstanciated() {
|
||||
return instance != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
setContentView(R.layout.incoming);
|
||||
|
||||
mNameView = (TextView) findViewById(R.id.incoming_caller_name);
|
||||
mNumberView = (TextView) findViewById(R.id.incoming_caller_number);
|
||||
mPictureView = (ImageView) findViewById(R.id.incoming_picture);
|
||||
|
||||
// set this flag so this activity will stay in front of the keyguard
|
||||
int flags = WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON;
|
||||
getWindow().addFlags(flags);
|
||||
|
||||
// "Dial-to-answer" widget for incoming calls.
|
||||
|
||||
mListener = new LinphoneCoreListenerBase(){
|
||||
@Override
|
||||
public void callState(LinphoneCore lc, LinphoneCall call, LinphoneCall.State state, String message) {
|
||||
if (call == mCall && State.CallEnd == state) {
|
||||
finish();
|
||||
}
|
||||
if (state == State.StreamsRunning) {
|
||||
// The following should not be needed except some devices need it (e.g. Galaxy S).
|
||||
LinphoneManager.getLc().enableSpeaker(LinphoneManager.getLc().isSpeakerEnabled());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
instance = this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
instance = this;
|
||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||
if (lc != null) {
|
||||
lc.addListener(mListener);
|
||||
}
|
||||
|
||||
// Only one call ringing at a time is allowed
|
||||
if (LinphoneManager.getLcIfManagerNotDestroyedOrNull() != null) {
|
||||
List<LinphoneCall> calls = LinphoneUtils.getLinphoneCalls(LinphoneManager.getLc());
|
||||
for (LinphoneCall call : calls) {
|
||||
if (State.IncomingReceived == call.getState()) {
|
||||
mCall = call;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mCall == null) {
|
||||
Log.e("Couldn't find incoming call");
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
LinphoneAddress address = mCall.getRemoteAddress();
|
||||
// May be greatly sped up using a drawable cache
|
||||
Contact contact = ContactsManager.getInstance().findContactWithAddress(getContentResolver(), address);
|
||||
//LinphoneUtils.setImagePictureFromUri(this, mPictureView, contact != null ? contact.getPhotoUri() : null,
|
||||
// contact != null ? contact.getThumbnailUri() : null, R.drawable.unknown_small);
|
||||
|
||||
// To be done after findUriPictureOfContactAndSetDisplayName called
|
||||
mNameView.setText(contact != null ? contact.getName() : "");
|
||||
if (getResources().getBoolean(R.bool.only_display_username_if_unknown)) {
|
||||
mNumberView.setText(address.getUserName());
|
||||
} else {
|
||||
mNumberView.setText(address.asStringUriOnly());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||
if (lc != null) {
|
||||
lc.removeListener(mListener);
|
||||
}
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
instance = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (LinphoneManager.isInstanciated() && (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_HOME)) {
|
||||
LinphoneManager.getLc().terminateCall(mCall);
|
||||
finish();
|
||||
}
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void decline() {
|
||||
LinphoneManager.getLc().terminateCall(mCall);
|
||||
}
|
||||
|
||||
private void answer() {
|
||||
LinphoneCallParams params = LinphoneManager.getLc().createDefaultCallParameters();
|
||||
|
||||
boolean isLowBandwidthConnection = !LinphoneUtils.isHighBandwidthConnection(this);
|
||||
if (isLowBandwidthConnection) {
|
||||
params.enableLowBandwidth(true);
|
||||
Log.d("Low bandwidth enabled in call params");
|
||||
}
|
||||
|
||||
if (!LinphoneManager.getInstance().acceptCallWithParams(mCall, params)) {
|
||||
// the above method takes care of Samsung Galaxy S
|
||||
Toast.makeText(this, R.string.couldnt_accept_call, Toast.LENGTH_LONG).show();
|
||||
} else {
|
||||
if (!LinphoneActivity.isInstanciated()) {
|
||||
return;
|
||||
}
|
||||
final LinphoneCallParams remoteParams = mCall.getRemoteParams();
|
||||
if (remoteParams != null && remoteParams.getVideoEnabled() && LinphonePreferences.instance().shouldAutomaticallyAcceptVideoRequests()) {
|
||||
LinphoneActivity.instance().startVideoActivity(mCall);
|
||||
} else {
|
||||
LinphoneActivity.instance().startIncallActivity(mCall);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue