Reworked incall audio interface

This commit is contained in:
Sylvain Berfini 2012-11-19 12:54:23 +01:00
parent 96212a6006
commit a7f77655d3
9 changed files with 112 additions and 103 deletions

View file

@ -4,7 +4,7 @@
android:layout_height="match_parent"
android:background="@drawable/background">
<RelativeLayout
<TableLayout
android:id="@+id/calls"
android:layout_width="match_parent"
android:layout_height="wrap_content"

View file

@ -1,55 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:linphone="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="@+id/row"
android:layout_width="match_parent"
android:layout_height="75dp"
android:background="@drawable/cell_call_first"
android:gravity="center_vertical">
<TextView
android:id="@+id/contactNameOrNumber"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical|left"
android:paddingLeft="20dp"
android:paddingRight="10dp"
android:textColor="@android:color/white"
android:textSize="22dp" />
<ImageView
android:contentDescription="@string/content_description_pause"
android:id="@+id/callStatus"
android:layout_width="30dp"
android:layout_height="30dp"
android:gravity="center_vertical"
android:scaleType="fitCenter"
android:adjustViewBounds="true"
android:src="@drawable/pause" />
<Chronometer
android:id="@+id/callTimer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:paddingRight="20dp"
android:gravity="center_vertical|right"
android:textColor="@android:color/white"
android:textSize="22dp" />
</LinearLayout>
<org.linphone.ui.AvatarWithShadow
android:id="@+id/contactPicture"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal|top"
linphone:picture="@drawable/unknown_small" />
</LinearLayout>

View file

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:linphone="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="75dp"
android:layout_margin="2dp"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="10dp">
<TextView
android:id="@+id/contactNameOrNumber"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical|left"
android:paddingLeft="20dp"
android:paddingRight="10dp"
android:textColor="@android:color/white"
android:textSize="22dp" />
<ImageView
android:contentDescription="@string/content_description_pause"
android:id="@+id/callStatus"
android:layout_width="30dp"
android:layout_height="30dp"
android:gravity="center_vertical"
android:scaleType="fitCenter"
android:adjustViewBounds="true"
android:src="@drawable/pause" />
<Chronometer
android:id="@+id/callTimer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:paddingRight="20dp"
android:gravity="center_vertical|right"
android:textColor="@android:color/white"
android:textSize="22dp" />
</TableRow>

View file

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:linphone="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="75dp"
android:layout_margin="2dp"
android:gravity="center"
android:orientation="horizontal"
android:padding="10dp">
<org.linphone.ui.AvatarWithShadow
android:id="@+id/contactPicture"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal|top"
linphone:picture="@drawable/unknown_small" />
</TableRow>

View file

@ -5,7 +5,7 @@
android:paddingTop="40dp"
android:background="@drawable/background">
<RelativeLayout
<TableLayout
android:id="@+id/calls"
android:layout_width="match_parent"
android:layout_height="wrap_content"

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:linphone="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="75dp"
@ -38,4 +38,4 @@
android:textColor="@android:color/white"
android:textSize="22dp" />
</LinearLayout>
</TableRow>

View file

@ -38,26 +38,16 @@ import android.view.ViewGroup;
import android.widget.Chronometer;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TableLayout;
import android.widget.TextView;
/**
* @author Sylvain Berfini
*/
public class AudioCallFragment extends Fragment implements OnClickListener {
private static final int rowHeight = 75; // Value set in active_call.xml
private static final int rowImageHeight = 75; // Value set in avatar.xml
private static final int rowImageHeightTablet = 150; // Value set in avatar.xml
private static final int botMarginIfImage = 25;
private static final int rowThickRatio = 85; // Ratio dependent from the image
private static final int topMargin = (int) ((rowHeight * rowThickRatio) / 100);
private static final int conferenceMargin = 20;
private static int topMarginWithImage = topMargin + rowImageHeight + botMarginIfImage;
private RelativeLayout callsList;
private TableLayout callsList;
private LayoutInflater inflater;
private ViewGroup container;
private boolean previousCallIsActive = false;
private boolean isConferenceRunning = false;
private InCallActivity incallActvityInstance;
@ -70,10 +60,7 @@ public class AudioCallFragment extends Fragment implements OnClickListener {
this.container = container;
View view = inflater.inflate(R.layout.audio, container, false);
callsList = (RelativeLayout) view.findViewById(R.id.calls);
if (getResources().getBoolean(R.bool.isTablet))
topMarginWithImage = topMargin + rowImageHeightTablet + botMarginIfImage;
callsList = (TableLayout) view.findViewById(R.id.calls);
return view;
}
@ -92,19 +79,38 @@ public class AudioCallFragment extends Fragment implements OnClickListener {
callsList.addView(conferenceHeader);
}
private void displayCall(Resources resources, LinearLayout callView, LinphoneCall call, int index) {
private void displayCall(Resources resources, LinphoneCall call, int index) {
String sipUri = call.getRemoteAddress().asStringUriOnly();
LinphoneAddress lAddress = LinphoneCoreFactory.instance().createLinphoneAddress(sipUri);
Uri pictureUri = LinphoneUtils.findUriPictureOfContactAndSetDisplayName(lAddress, callView.getContext().getContentResolver());
// Control Row
LinearLayout callView = (LinearLayout) inflater.inflate(R.layout.active_call_control_row, container, false);
setContactName(callView, lAddress, sipUri, resources);
boolean hide = displayCallStatusIconAndReturnCallPaused(callView, call);
displayOrHideContactPicture(callView, pictureUri, hide);
setRowBackgroundAndPadding(callView, resources, index, call, !hide);
displayCallStatusIconAndReturnCallPaused(callView, call);
setRowBackground(callView, index);
registerCallDurationTimer(callView, call);
previousCallIsActive = !hide;
callsList.addView(callView);
// Image Row
LinearLayout imageView = (LinearLayout) inflater.inflate(R.layout.active_call_image_row, container, false);
Uri pictureUri = LinphoneUtils.findUriPictureOfContactAndSetDisplayName(lAddress, imageView.getContext().getContentResolver());
displayOrHideContactPicture(imageView, pictureUri, false);
callsList.addView(imageView);
callView.setTag(imageView);
callView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (v.getTag() != null) {
View imageView = (View) v.getTag();
if (imageView.getVisibility() == View.VISIBLE)
imageView.setVisibility(View.GONE);
else
imageView.setVisibility(View.VISIBLE);
callsList.invalidate();
}
}
});
}
private void setContactName(LinearLayout callView, LinphoneAddress lAddress, String sipUri, Resources resources) {
@ -153,10 +159,10 @@ public class AudioCallFragment extends Fragment implements OnClickListener {
if (pictureUri != null) {
LinphoneUtils.setImagePictureFromUri(callView.getContext(), contactPicture.getView(), Uri.parse(pictureUri.toString()), R.drawable.unknown_small);
}
contactPicture.setVisibility(hide ? View.GONE : View.VISIBLE);
callView.setVisibility(hide ? View.GONE : View.VISIBLE);
}
private void setRowBackgroundAndPadding(LinearLayout callView, Resources resources, int index, LinphoneCall call, boolean active) {
private void setRowBackground(LinearLayout callView, int index) {
int backgroundResource;
if (index == 0) {
// backgroundResource = active ? R.drawable.cell_call_first_highlight : R.drawable.cell_call_first;
@ -165,21 +171,7 @@ public class AudioCallFragment extends Fragment implements OnClickListener {
// backgroundResource = active ? R.drawable.cell_call_highlight : R.drawable.cell_call;
backgroundResource = R.drawable.cell_call;
}
callView.findViewById(R.id.row).setBackgroundResource(backgroundResource);
if (index != 0) {
int marginIfConferenceAndCallNotInside = 0;
if (isConferenceRunning) {
if (!call.isInConference()) {
marginIfConferenceAndCallNotInside = conferenceMargin;
}
}
if (previousCallIsActive) {
callView.setPadding(0, LinphoneUtils.pixelsToDpi(resources, (topMarginWithImage * index) + marginIfConferenceAndCallNotInside), 0, 0);
} else {
callView.setPadding(0, LinphoneUtils.pixelsToDpi(resources, (topMargin * index) + marginIfConferenceAndCallNotInside), 0, 0);
}
}
callView.setBackgroundResource(backgroundResource);
}
private void registerCallDurationTimer(View v, LinphoneCall call) {
@ -262,8 +254,7 @@ public class AudioCallFragment extends Fragment implements OnClickListener {
index++;
}
for (LinphoneCall call : LinphoneManager.getLc().getCalls()) {
LinearLayout callView = (LinearLayout) inflater.inflate(R.layout.active_call, container, false);
displayCall(resources, callView, call, index);
displayCall(resources, call, index);
index++;
}

View file

@ -32,6 +32,7 @@ import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration;
import org.linphone.mediastream.video.capture.hwconf.Hacks;
import org.linphone.ui.Numpad;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
@ -892,6 +893,10 @@ public class InCallActivity extends FragmentActivity implements
displayVideoCallControlsIfHidden();
}
}
public void startIncomingCallActivity() {
startActivity(new Intent(this, IncomingCallActivity.class));
}
@Override
public void onCallStateChanged(final LinphoneCall call, State state, String message) {
@ -900,6 +905,11 @@ public class InCallActivity extends FragmentActivity implements
return;
}
if (state == State.IncomingReceived) {
startIncomingCallActivity();
return;
}
if (state == State.StreamsRunning) {
boolean isVideoEnabledInCall = call.getCurrentParamsCopy().getVideoEnabled();
if (isVideoEnabledInCall != isVideoEnabled) {
@ -1071,6 +1081,7 @@ public class InCallActivity extends FragmentActivity implements
videoCallFragment = fragment;
}
@SuppressLint("ValidFragment")
class AcceptCallUpdateDialog extends DialogFragment {
public AcceptCallUpdateDialog() {

View file

@ -48,6 +48,7 @@ import org.linphone.core.OnlineStatus;
import org.linphone.setup.SetupActivity;
import org.linphone.ui.AddressText;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
@ -133,8 +134,7 @@ public class LinphoneActivity extends FragmentActivity implements
Log.e("No service running: avoid crash by starting the launcher", this.getClass().getName());
// super.onCreate called earlier
finish();
startActivity(getIntent().setClass(this,
LinphoneLauncherActivity.class));
startActivity(getIntent().setClass(this, LinphoneLauncherActivity.class));
return;
}
@ -465,6 +465,7 @@ public class LinphoneActivity extends FragmentActivity implements
}
}
@SuppressLint("SimpleDateFormat")
private String secondsToDisplayableString(int secs) {
SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
Calendar cal = Calendar.getInstance();
@ -1364,6 +1365,7 @@ public class LinphoneActivity extends FragmentActivity implements
return super.onKeyDown(keyCode, event);
}
@SuppressLint("ValidFragment")
class AcceptNewFriendDialog extends DialogFragment {
private Contact contact;
private String sipUri;