Rework and rename incoming call and outgoing call activity

This commit is contained in:
Margaux Clerc 2015-10-15 17:55:43 +02:00
parent 23e66f1c70
commit 24af401775
15 changed files with 765 additions and 727 deletions

View file

@ -89,7 +89,7 @@
</intent-filter>
</activity>
<activity android:name="org.linphone.IncomingCallActivity"
<activity android:name=".CallIncomingActivity"
android:theme="@style/NoTitle"
android:noHistory="true"
android:launchMode="singleTop"
@ -99,7 +99,7 @@
</intent-filter>
</activity>
<activity android:name="org.linphone.OutgoingCallActivity"
<activity android:name=".CallOutgoingActivity"
android:theme="@style/NoTitle"
android:noHistory="true"
android:launchMode="singleTop"
@ -109,7 +109,7 @@
</intent-filter>
</activity>
<activity android:name="org.linphone.InCallActivity"
<activity android:name=".CallActivity"
android:theme="@style/FullScreen"
android:noHistory="true"
android:launchMode="singleTop">

View file

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/topLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorH">
<fragment
android:id="@+id/status"
android:name="org.linphone.StatusFragment"
android:layout_width="match_parent"
android:layout_height="40dp"
tools:layout="@layout/status" />
<RelativeLayout
android:id="@+id/top_bar"
android:background="@color/colorF"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_below="@id/status">
<TextView
android:text="@string/incoming_call"
style="@style/font1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="10dp"
android:gravity="center"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/contact_detail"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/menu"
android:layout_below="@id/top_bar"
android:paddingTop="10dp">
<TextView
android:id="@+id/contact_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:textAlignment="center"
android:layout_centerHorizontal="true"
android:padding="5dp"
style="@style/font5"/>
<TextView
android:id="@+id/contact_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/font2"
android:layout_below="@id/contact_name"
android:layout_gravity="center"
android:layout_centerHorizontal="true"
android:padding="5dp"/>
<RelativeLayout
android:id="@+id/avatar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/contact_number"
android:layout_margin="5dp"
android:gravity="center">
<ImageView
android:id="@+id/contact_picture"
android:src="@drawable/avatar"
android:contentDescription="@string/content_description_contact_picture"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:adjustViewBounds="true"/>
<ImageView
android:src="@drawable/avatar_mask"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:layout_alignParentTop="true"/>
</RelativeLayout>
</RelativeLayout>
<LinearLayout
android:id="@+id/menu"
android:visibility="visible"
android:layout_width="match_parent"
android:layout_height="70dp"
android:layout_alignParentBottom="true"
android:orientation="horizontal" >
<ImageView
android:id="@+id/decline"
android:src="@drawable/call_hangup"
android:background="@drawable/hangup"
android:contentDescription="@string/content_description_decline"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="15dp"/>
<ImageView
android:id="@+id/accept"
android:src="@drawable/call_audio_start"
android:background="@drawable/call"
android:contentDescription="@string/content_description_accept"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="15dp"/>
</LinearLayout>
</RelativeLayout>

View file

@ -1,85 +1,96 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/topLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorH">
android:id="@+id/topLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorH">
<fragment
android:id="@+id/status"
android:name="org.linphone.StatusFragment"
tools:layout="@layout/status"
android:layout_width="match_parent"
android:layout_height="40dp"
tools:layout="@layout/status" />
android:layout_height="40dp"/>
<RelativeLayout
android:id="@+id/toolbar"
android:id="@+id/top_bar"
android:background="@color/colorF"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_below="@id/status"
android:background="@color/colorF">
android:layout_below="@id/status">
<TextView
android:text="@string/outgoing_call"
style="@style/font1"
android:layout_width="match_parent"
android:layout_height="match_parent"
style="@style/font1"
android:text="@string/outgoing_call"
android:paddingLeft="10dp"
android:gravity="center"/>
</RelativeLayout>
<LinearLayout
<RelativeLayout
android:id="@+id/contact_detail"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/toolbar"
android:orientation="vertical"
android:gravity="center"
android:layout_above="@id/menu">
android:layout_above="@id/menu"
android:layout_below="@id/top_bar"
android:paddingTop="10dp">
<LinearLayout
android:id="@+id/incoming_caller_profile"
<TextView
android:id="@+id/contact_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:textAlignment="center"
android:layout_centerHorizontal="true"
android:padding="5dp"
style="@style/font5"/>
<TextView
android:id="@+id/contact_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/font2"
android:layout_below="@id/contact_name"
android:layout_gravity="center"
android:layout_centerHorizontal="true"
android:padding="5dp"/>
<RelativeLayout
android:id="@+id/avatar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical"
android:paddingTop="10dp">
android:layout_below="@id/contact_number"
android:layout_margin="5dp"
android:gravity="center">
<ImageView
android:id="@+id/incoming_picture"
android:layout_width="200dp"
android:layout_height="200dp"
android:id="@+id/contact_picture"
android:src="@drawable/avatar"
android:paddingBottom="10dp"
android:layout_marginTop="10dp"/>
<TextView
android:id="@+id/incoming_caller_name"
android:layout_width="wrap_content"
android:contentDescription="@string/content_description_contact_picture"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textAlignment="center"
style="@style/font5"/>
android:adjustViewBounds="true"/>
<TextView
android:id="@+id/incoming_caller_number"
android:layout_width="wrap_content"
<ImageView
android:src="@drawable/avatar_mask"
android:layout_width="200dp"
android:layout_height="wrap_content"
style="@style/font2"
android:layout_gravity="center"/>
android:adjustViewBounds="true"
android:layout_alignParentTop="true"/>
</RelativeLayout>
</LinearLayout>
<org.linphone.mediastream.video.display.GL2JNIView
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:id="@+id/videoSurface"
android:visibility="gone" />
</LinearLayout>
</RelativeLayout>
<org.linphone.mediastream.video.display.GL2JNIView
android:id="@+id/videoSurface"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:visibility="gone" />
<LinearLayout
android:id="@+id/menu"
@ -93,20 +104,20 @@
android:id="@+id/micro"
android:src="@drawable/micro_default"
android:background="@drawable/button_background"
android:contentDescription="@string/content_description_toggle_micro"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:contentDescription="@string/content_description_pause"
android:padding="15dp"/>
<ImageView
android:id="@+id/speaker"
android:src="@drawable/speaker_default"
android:background="@drawable/button_background"
android:contentDescription="@string/content_description_toggle_speaker"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:contentDescription="@string/content_description_pause"
android:padding="20dp"/>
<ImageView

View file

@ -1,112 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/topLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:id="@+id/status"
android:name="org.linphone.StatusFragment"
android:layout_width="match_parent"
android:layout_height="40dp"
tools:layout="@layout/status" />
<RelativeLayout
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_below="@id/status"
android:background="@color/colorF">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
style="@style/font1"
android:text="@string/incoming_call"
android:paddingLeft="10dp"
android:gravity="center"/>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/toolbar"
android:orientation="vertical"
android:gravity="center"
android:layout_above="@id/menu">
<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:paddingTop="10dp">
<ImageView
android:id="@+id/incoming_picture"
android:layout_width="200dp"
android:layout_height="200dp"
android:src="@drawable/avatar"
android:paddingBottom="10dp"
android:layout_marginTop="10dp"/>
<TextView
android:id="@+id/incoming_caller_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textAlignment="center"
style="@style/font5"/>
<TextView
android:id="@+id/incoming_caller_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/font2"
android:layout_gravity="center"/>
</LinearLayout>
<org.linphone.mediastream.video.display.GL2JNIView
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:id="@+id/videoSurface"
android:visibility="gone" />
</LinearLayout>
<LinearLayout
android:id="@+id/menu"
android:layout_width="match_parent"
android:layout_height="70dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:orientation="horizontal" >
<ImageView
android:id="@+id/decline"
android:src="@drawable/call_hangup"
android:background="@drawable/hangup"
android:contentDescription="@string/content_description_pause"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="15dp"/>
<ImageView
android:id="@+id/accept"
android:src="@drawable/call_audio_start"
android:background="@drawable/call"
android:contentDescription="@string/content_description_pause"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="15dp"/>
</LinearLayout>
</RelativeLayout>

View file

@ -22,9 +22,9 @@
</TableRow>
<TableRow android:layout_weight="1" android:gravity="center">
<org.linphone.ui.Digit android:id="@+id/DigitStar" android:text="*" style="@style/DialerDigit" android:background="@drawable/numpad_star" android:soundEffectsEnabled="true" />
<org.linphone.ui.Digit android:id="@+id/DigitStar" android:text="*" style="@style/DialerDigit" android:background="@drawable/numpad_star_digit" android:soundEffectsEnabled="true" />
<org.linphone.ui.Digit android:id="@+id/Digit00" android:text="0+" style="@style/DialerDigit" android:background="@drawable/numpad_zero" android:soundEffectsEnabled="true" />
<org.linphone.ui.Digit android:id="@+id/DigitHash" android:text="#" style="@style/DialerDigit" android:background="@drawable/numpad_sharp" android:soundEffectsEnabled="true" />
</TableRow>
</TableLayout>
</TableLayout>

View file

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Default" parent="android:Theme.Holo.Light" />
<style name="NoTitle" parent="android:Theme.Holo.Light.NoActionBar" />
<style name="FullScreen" parent="android:Theme.Holo.Light.NoActionBar.Fullscreen" />
<style name="Default" parent="android:Theme.Holo.Light" />
<style name="NoTitle" parent="android:Theme.Holo.Light.NoActionBar" />
<style name="FullScreen" parent="android:Theme.Holo.Light.NoActionBar.Fullscreen" />
<style name="font1" parent="@android:style/TextAppearance.Medium">
<item name="android:textColor">@color/colorA</item>

View file

@ -30,7 +30,7 @@ import android.view.ViewGroup;
* @author Sylvain Berfini
*/
public class AudioCallFragment extends Fragment {
private InCallActivity incallActvityInstance;
private CallActivity incallActvityInstance;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
@ -42,7 +42,7 @@ public class AudioCallFragment extends Fragment {
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
incallActvityInstance = (InCallActivity) activity;
incallActvityInstance = (CallActivity) activity;
if (incallActvityInstance != null) {
incallActvityInstance.bindAudioFragment(this);
@ -55,7 +55,7 @@ public class AudioCallFragment extends Fragment {
// Just to be sure we have incall controls
if (incallActvityInstance != null) {
incallActvityInstance.setCallControlsVisibleAndRemoveCallbacks();
incallActvityInstance.removeCallbacks();
}
}

View file

@ -1,6 +1,6 @@
/*
IncomingCallActivity.java
Copyright (C) 2011 Belledonne Communications, Grenoble, France
CallIncomingActivity.java
Copyright (C) 2015 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
@ -35,58 +35,52 @@ import android.view.KeyEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
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 IncomingCallActivity extends Activity implements LinphoneSliderTriggered {
public class CallIncomingActivity extends Activity implements LinphoneSliderTriggered {
private static IncomingCallActivity instance;
private TextView mNameView;
private TextView mNumberView;
private ImageView mPictureView;
private static CallIncomingActivity instance;
private TextView name, number;
private ImageView contactPicture, acceptArrow, accept, decline;
private LinphoneCall mCall;
private LinphoneCoreListenerBase mListener;
private LinearLayout acceptUnlock;
private StatusFragment status;
public static IncomingCallActivity instance() {
public static CallIncomingActivity instance() {
return instance;
}
public static boolean isInstanciated() {
return instance != null;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
setContentView(R.layout.incoming);
setContentView(R.layout.call_incoming);
mNameView = (TextView) findViewById(R.id.incoming_caller_name);
mNumberView = (TextView) findViewById(R.id.incoming_caller_number);
mPictureView = (ImageView) findViewById(R.id.incoming_picture);
name = (TextView) findViewById(R.id.contact_name);
number = (TextView) findViewById(R.id.contact_number);
contactPicture = (ImageView) findViewById(R.id.contact_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);
// 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);
ImageView accept = (ImageView) findViewById(R.id.accept);
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 = (ImageView) findViewById(R.id.decline);
decline.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -94,22 +88,20 @@ public class IncomingCallActivity extends Activity implements LinphoneSliderTrig
}
});
// "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());
}
}
};
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);
super.onCreate(savedInstanceState);
instance = this;
}
@ -121,7 +113,7 @@ public class IncomingCallActivity extends Activity implements LinphoneSliderTrig
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());
@ -138,16 +130,16 @@ public class IncomingCallActivity extends Activity implements LinphoneSliderTrig
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() : address.getUserName());
mNumberView.setText(address.asStringUriOnly());
if (contact != null) {
LinphoneUtils.setImagePictureFromUri(this, contactPicture, contact.getPhotoUri(), contact.getThumbnailUri());
name.setText(contact.getName());
} else {
name.setText(LinphoneUtils.getAddressDisplayName(address));
}
number.setText(address.asStringUriOnly());
}
@Override
protected void onPause() {
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
@ -156,13 +148,13 @@ public class IncomingCallActivity extends Activity implements LinphoneSliderTrig
}
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)) {
@ -179,16 +171,10 @@ public class IncomingCallActivity extends Activity implements LinphoneSliderTrig
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();
@ -216,4 +202,4 @@ public class IncomingCallActivity extends Activity implements LinphoneSliderTrig
decline();
finish();
}
}
}

View file

@ -1,6 +1,6 @@
/*
IncomingCallActivity.java
Copyright (C) 2011 Belledonne Communications, Grenoble, France
CallOutgoingActivity.java
Copyright (C) 2015 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
@ -29,35 +29,26 @@ import org.linphone.core.LinphoneCoreListenerBase;
import org.linphone.mediastream.Log;
import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.KeyEvent;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import de.timroes.axmlrpc.Call;
public class CallOutgoingActivity extends Activity implements OnClickListener{
/**
* Activity displayed when a call comes in.
* It should bypass the screen lock mechanism.
*
* @author Guillaume Beraudo
*/
public class OutgoingCallActivity extends Activity {
private static CallOutgoingActivity instance;
private static OutgoingCallActivity instance;
private TextView mNameView, mNumberView;
private ImageView mPictureView, micro, speaker, decline;
private TextView name, number;
private ImageView contactPicture, micro, speaker, hangUp;
private LinphoneCall mCall;
private LinphoneCoreListenerBase mListener;
private boolean isMicMuted, isSpeakerEnabled;
private StatusFragment status;
public static OutgoingCallActivity instance() {
public static CallOutgoingActivity instance() {
return instance;
}
@ -74,63 +65,26 @@ public class OutgoingCallActivity extends Activity {
super.onCreate(savedInstanceState);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
setContentView(R.layout.outgoing_call);
setContentView(R.layout.call_outgoing);
mNameView = (TextView) findViewById(R.id.incoming_caller_name);
mNumberView = (TextView) findViewById(R.id.incoming_caller_number);
mPictureView = (ImageView) findViewById(R.id.incoming_picture);
micro = (ImageView) findViewById(R.id.micro);
micro.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
}
});
speaker = (ImageView) findViewById(R.id.speaker);
name = (TextView) findViewById(R.id.contact_name);
number = (TextView) findViewById(R.id.contact_number);
contactPicture = (ImageView) findViewById(R.id.contact_picture);
isMicMuted = false;
isSpeakerEnabled = false;
micro.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
isMicMuted = !isMicMuted;
if(isMicMuted) {
micro.setImageResource(R.drawable.micro_selected);
} else {
micro.setImageResource(R.drawable.micro_default);
}
LinphoneManager.getLc().muteMic(isMicMuted);
}
});
speaker.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
isSpeakerEnabled = !isSpeakerEnabled;
if(isSpeakerEnabled) {
speaker.setImageResource(R.drawable.speaker_selected);
} else {
speaker.setImageResource(R.drawable.speaker_default);
}
LinphoneManager.getLc().enableSpeaker(isSpeakerEnabled);
}
});
micro = (ImageView) findViewById(R.id.micro);
micro.setOnClickListener(this);
speaker = (ImageView) findViewById(R.id.speaker);
speaker.setOnClickListener(this);
// 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.
ImageView decline = (ImageView) findViewById(R.id.hang_up);
decline.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
decline();
}
});
hangUp = (ImageView) findViewById(R.id.hang_up);
hangUp.setOnClickListener(this);
mListener = new LinphoneCoreListenerBase(){
@Override
@ -174,27 +128,27 @@ public class OutgoingCallActivity extends Activity {
if (LinphoneManager.getLcIfManagerNotDestroyedOrNull() != null) {
List<LinphoneCall> calls = LinphoneUtils.getLinphoneCalls(LinphoneManager.getLc());
for (LinphoneCall call : calls) {
if (State.OutgoingInit == call.getState() || State.OutgoingProgress == call.getState()) {
if (State.OutgoingInit == call.getState() || State.OutgoingProgress == call.getState() || State.OutgoingRinging == call.getState() || State.OutgoingEarlyMedia == call.getState()) {
mCall = call;
break;
}
}
}
if (mCall == null) {
Log.e("Couldn't find incoming call");
Log.e("Couldn't find outgoing 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() : address.getUserName());
mNumberView.setText(address.asStringUriOnly());
if (contact != null) {
LinphoneUtils.setImagePictureFromUri(this, contactPicture, contact.getPhotoUri(), contact.getThumbnailUri());
name.setText(contact.getName());
} else {
name.setText(LinphoneUtils.getAddressDisplayName(address));
}
number.setText(address.asStringUriOnly());
}
@Override
@ -212,6 +166,33 @@ public class OutgoingCallActivity extends Activity {
instance = null;
}
@Override
public void onClick(View v) {
int id = v.getId();
if (id == R.id.micro) {
isMicMuted = !isMicMuted;
if(isMicMuted) {
micro.setImageResource(R.drawable.micro_selected);
} else {
micro.setImageResource(R.drawable.micro_default);
}
LinphoneManager.getLc().muteMic(isMicMuted);
}
if (id == R.id.speaker) {
isSpeakerEnabled = !isSpeakerEnabled;
if(isSpeakerEnabled) {
speaker.setImageResource(R.drawable.speaker_selected);
} else {
speaker.setImageResource(R.drawable.speaker_default);
}
LinphoneManager.getLc().enableSpeaker(isSpeakerEnabled);
}
if (id == R.id.hang_up) {
decline();
}
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (LinphoneManager.isInstanciated() && (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_HOME)) {
@ -224,5 +205,4 @@ public class OutgoingCallActivity extends Activity {
private void decline() {
LinphoneManager.getLc().terminateCall(mCall);
}
}

View file

@ -231,9 +231,9 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
public void callState(LinphoneCore lc, LinphoneCall call, LinphoneCall.State state, String message) {
if (state == State.IncomingReceived) {
//finish();
startActivity(new Intent(LinphoneActivity.instance(), IncomingCallActivity.class));
startActivity(new Intent(LinphoneActivity.instance(), CallIncomingActivity.class));
} else if (state == State.OutgoingInit || state == State.OutgoingProgress) {
startActivity(new Intent(LinphoneActivity.instance(), OutgoingCallActivity.class));
startActivity(new Intent(LinphoneActivity.instance(), CallOutgoingActivity.class));
} else if (state == State.CallEnd || state == State.Error || state == State.CallReleased) {
// Convert LinphoneCore message for internalization
if (message != null && call.getReason() == Reason.Declined) {
@ -935,14 +935,14 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
}
public void startVideoActivity(LinphoneCall currentCall) {
Intent intent = new Intent(this, InCallActivity.class);
Intent intent = new Intent(this, CallActivity.class);
intent.putExtra("VideoEnabled", true);
startOrientationSensor();
startActivityForResult(intent, CALL_ACTIVITY);
}
public void startIncallActivity(LinphoneCall currentCall) {
Intent intent = new Intent(this, InCallActivity.class);
Intent intent = new Intent(this, CallActivity.class);
intent.putExtra("VideoEnabled", false);
startOrientationSensor();
startActivityForResult(intent, CALL_ACTIVITY);
@ -1028,7 +1028,7 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
if (LinphoneManager.isInstanciated() && LinphoneManager.getLc().getCallsNb() > 0) {
LinphoneCall call = LinphoneManager.getLc().getCalls()[0];
if (call.getState() == LinphoneCall.State.IncomingReceived) {
startActivity(new Intent(LinphoneActivity.this, IncomingCallActivity.class));
startActivity(new Intent(LinphoneActivity.this, CallIncomingActivity.class));
} else if (call.getCurrentParamsCopy().getVideoEnabled()) {
startVideoActivity(call);
} else {
@ -1124,9 +1124,9 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
LinphoneCall call = LinphoneManager.getLc().getCalls()[0];
LinphoneCall.State callState = call.getState();
if (callState == State.IncomingReceived) {
startActivity(new Intent(this, IncomingCallActivity.class));
startActivity(new Intent(this, CallIncomingActivity.class));
} else if (callState == State.OutgoingInit) {
startActivity(new Intent(this, OutgoingCallActivity.class));
startActivity(new Intent(this, CallOutgoingActivity.class));
} else {
if (call.getCurrentParamsCopy().getVideoEnabled()) {
startVideoActivity(call);
@ -1217,10 +1217,10 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
Collection<LinphoneCall.State> incoming = new ArrayList<LinphoneCall.State>();
incoming.add(LinphoneCall.State.IncomingReceived);
if (LinphoneUtils.getCallsInState(LinphoneManager.getLc(), incoming).size() > 0) {
if (InCallActivity.isInstanciated()) {
InCallActivity.instance().startIncomingCallActivity();
if (CallActivity.isInstanciated()) {
CallActivity.instance().startIncomingCallActivity();
} else {
startActivity(new Intent(this, IncomingCallActivity.class));
startActivity(new Intent(this, CallIncomingActivity.class));
}
}
}

View file

@ -167,6 +167,7 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
mRingbackSoundFile = basePath + "/ringback.wav";
mPauseSoundFile = basePath + "/toy_mono.wav";
mChatDatabaseFile = basePath + "/linphone-history.db";
mCallLogDatabaseFile = basePath + "/linphone-log-history.db";
mErrorToneFile = basePath + "/error.wav";
mConfigFile = basePath + "/configrc";
@ -190,6 +191,7 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
private final String mRingbackSoundFile;
private final String mPauseSoundFile;
private final String mChatDatabaseFile;
private final String mCallLogDatabaseFile;
private final String mErrorToneFile;
private final String mConfigFile;
private ByteArrayInputStream mUploadingImageStream;
@ -413,9 +415,6 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
LinphoneAddress lAddress;
try {
lAddress = mLc.interpretUrl(to);
if (mServiceContext.getResources().getBoolean(R.bool.override_domain_using_default_one)) {
lAddress.setDomain(mServiceContext.getString(R.string.default_domain));
}
LinphoneProxyConfig lpc = mLc.getDefaultProxyConfig();
if (mR.getBoolean(R.bool.forbid_self_call) && lpc!=null && lAddress.asStringUriOnly().equals(lpc.getIdentity())) {
@ -856,7 +855,7 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
try {
Contact contact = ContactsManager.getInstance().findContactWithAddress(mServiceContext.getContentResolver(), from);
if (!mServiceContext.getResources().getBoolean(R.bool.disable_chat__message_notification)) {
if (!mServiceContext.getResources().getBoolean(R.bool.disable_chat_message_notification)) {
if (LinphoneActivity.isInstanciated() && !LinphoneActivity.instance().displayChatMessageNotification(from.asStringUriOnly())) {
return;
} else {
@ -920,10 +919,10 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
try {
if (LinphoneActivity.isInstanciated())
return LinphoneActivity.instance();
else if (InCallActivity.isInstanciated())
return InCallActivity.instance();
else if (IncomingCallActivity.isInstanciated())
return IncomingCallActivity.instance();
else if (CallActivity.isInstanciated())
return CallActivity.instance();
else if (CallIncomingActivity.isInstanciated())
return CallIncomingActivity.instance();
else if (mServiceContext != null)
return mServiceContext;
else if (LinphoneService.isReady())

View file

@ -22,6 +22,8 @@ import java.util.TimerTask;
import org.linphone.assistant.AssistantActivity;
import org.linphone.core.LinphoneCall;
import org.linphone.core.LinphoneCallParams;
import org.linphone.core.LinphoneCallStats;
import org.linphone.core.LinphoneContent;
import org.linphone.core.LinphoneCore;
import org.linphone.core.LinphoneCore.MediaEncryption;
@ -29,6 +31,7 @@ import org.linphone.core.LinphoneCore.RegistrationState;
import org.linphone.core.LinphoneCoreListenerBase;
import org.linphone.core.LinphoneEvent;
import org.linphone.core.LinphoneProxyConfig;
import org.linphone.core.PayloadType;
import org.linphone.mediastream.Log;
import android.app.Activity;
@ -153,17 +156,17 @@ public class StatusFragment extends Fragment {
if (activity instanceof LinphoneActivity) {
((LinphoneActivity) activity).updateStatusFragment(this);
isInCall = false;
} else if (activity instanceof InCallActivity) {
((InCallActivity) activity).updateStatusFragment(this);
} else if (activity instanceof CallActivity) {
((CallActivity) activity).updateStatusFragment(this);
isInCall = true;
} else if (activity instanceof AssistantActivity) {
((AssistantActivity) activity).updateStatusFragment(this);
isInCall = false;
} else if (activity instanceof IncomingCallActivity) {
((IncomingCallActivity) activity).updateStatusFragment(this);
} else if (activity instanceof CallIncomingActivity) {
((CallIncomingActivity) activity).updateStatusFragment(this);
isInCall = true;
} else if (activity instanceof OutgoingCallActivity) {
((OutgoingCallActivity) activity).updateStatusFragment(this);
} else if (activity instanceof CallOutgoingActivity) {
((CallOutgoingActivity) activity).updateStatusFragment(this);
isInCall = true;
}
}
@ -180,7 +183,7 @@ public class StatusFragment extends Fragment {
if (LinphoneManager.isInstanciated() && LinphoneManager.getLc() != null) {
voicemailCount.setVisibility(View.GONE);
if (isInCall && isAttached && getResources().getBoolean(R.bool.display_call_stats)) {
if (isInCall && isAttached) {
LinphoneCall call = LinphoneManager.getLc().getCurrentCall();
//initCallStatsRefresher(call, callStats);
} else if (!isInCall) {
@ -398,12 +401,12 @@ public class StatusFragment extends Fragment {
.show();
}
private void initCallStatsRefresher(final LinphoneCall call, final View view) {
public void initCallStatsRefresher(final LinphoneCall call, final View view) {
if (mTimer != null && mTask != null) {
return;
}
/* mTimer = new Timer();
mTimer = new Timer();
mTask = new TimerTask() {
@Override
public void run() {
@ -467,7 +470,7 @@ public class StatusFragment extends Fragment {
});
}
};
mTimer.scheduleAtFixedRate(mTask, 0, 1000);*/
mTimer.scheduleAtFixedRate(mTask, 0, 1000);
}

View file

@ -52,7 +52,7 @@ public class VideoCallFragment extends Fragment implements OnGestureListener, On
private float mZoomFactor = 1.f;
private float mZoomCenterX, mZoomCenterY;
private CompatibilityScaleGestureDetector mScaleDetector;
private InCallActivity inCallActivity;
private CallActivity inCallActivity;
@SuppressWarnings("deprecation") // Warning useless because value is ignored and automatically set by new APIs.
@Override
@ -274,7 +274,7 @@ public class VideoCallFragment extends Fragment implements OnGestureListener, On
public void onAttach(Activity activity) {
super.onAttach(activity);
inCallActivity = (InCallActivity) activity;
inCallActivity = (CallActivity) activity;
if (inCallActivity != null) {
inCallActivity.bindVideoFragment(this);
}

View file

@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.linphone.ui;
import org.linphone.InCallActivity;
import org.linphone.CallActivity;
import org.linphone.LinphoneManager;
import org.linphone.LinphonePreferences;
import org.linphone.LinphoneService;
@ -166,8 +166,8 @@ public class Digit extends Button implements AddressAware {
if (!mPlayDtmf) return false;
if (!linphoneServiceReady()) return true;
if (InCallActivity.isInstanciated()) {
InCallActivity.instance().resetControlsHidingCallBack();
if (CallActivity.isInstanciated()) {
CallActivity.instance().resetControlsHidingCallBack();
}
LinphoneCore lc = LinphoneManager.getLc();