Improved display of calls when more than one

This commit is contained in:
Sylvain Berfini 2012-07-16 16:56:56 +02:00
parent dd64d09eae
commit ea1b7823e5
5 changed files with 19 additions and 15 deletions

View file

@ -7,7 +7,7 @@
<LinearLayout
android:id="@+id/row"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_height="75dp"
android:background="@drawable/sel_call_first"
android:gravity="center_vertical">

View file

@ -3,12 +3,11 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
<FrameLayout
android:id="@+id/calls"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="top"
android:background="@drawable/background"
android:orientation="vertical" />
android:background="@drawable/background" />
</ScrollView>

View file

@ -32,6 +32,7 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Chronometer;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
@ -41,9 +42,12 @@ import android.widget.TextView;
*/
public class AudioCallFragment extends Fragment {
private static AudioCallFragment instance;
private LinearLayout callsList;
private FrameLayout callsList;
private LayoutInflater inflater;
private ViewGroup container;
private static final int rowHeight = 75; // Value set in active_call.xml
private static final int rowThickRatio = 85; // Ratio dependent from the image
private static final int topMargin = (int) ((rowHeight * rowThickRatio) / 100);
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
@ -53,12 +57,12 @@ public class AudioCallFragment extends Fragment {
this.container = container;
View view = inflater.inflate(R.layout.audio, container, false);
callsList = (LinearLayout) view.findViewById(R.id.calls);
callsList = (FrameLayout) view.findViewById(R.id.calls);
return view;
}
private void displayCall(Resources resources, LinearLayout callView, LinphoneCall call, boolean first, boolean hide) {
private void displayCall(Resources resources, LinearLayout callView, LinphoneCall call, int index, boolean hide) {
String sipUri = call.getRemoteAddress().asStringUriOnly();
LinphoneAddress lAddress = LinphoneCoreFactory.instance().createLinphoneAddress(sipUri);
Uri pictureUri = LinphoneUtils.findUriPictureOfContactAndSetDisplayName(lAddress, callView.getContext().getContentResolver());
@ -88,11 +92,12 @@ public class AudioCallFragment extends Fragment {
if (hide) {
contactPicture.setVisibility(View.GONE);
}
if (first) {
if (index == 0) {
callView.findViewById(R.id.row).setBackgroundResource(R.drawable.sel_call_first);
} else {
callView.findViewById(R.id.row).setBackgroundResource(R.drawable.sel_call);
callView.setPadding(0, LinphoneUtils.pixelsToDpi(resources, topMargin * index), 0, 0);
}
registerCallDurationTimer(callView, call);
@ -148,7 +153,7 @@ public class AudioCallFragment extends Fragment {
for (LinphoneCall call : LinphoneManager.getLc().getCalls()) {
LinearLayout callView = (LinearLayout) inflater.inflate(R.layout.active_call, container, false);
displayCall(resources, callView, call, index == 0, index != callsNb - 1);
displayCall(resources, callView, call, index, index != callsNb - 1);
callsList.addView(callView);
index++;
}

View file

@ -18,9 +18,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.linphone.LinphoneSimpleListener.LinphoneOnCallEncryptionChangedListener;
import org.linphone.LinphoneSimpleListener.LinphoneOnCallStateChangedListener;
@ -43,11 +41,9 @@ import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.widget.Chronometer;
import android.widget.ImageView;
import android.widget.LinearLayout;
//FIXME : Chronometer for calls
/**
* @author Sylvain Berfini
*/
@ -67,7 +63,6 @@ public class InCallActivity extends FragmentActivity implements
private VideoCallFragment videoCallFragment;
private boolean isSpeakerEnabled = false, isMicMuted = false, isVideoEnabled = false;
private LinearLayout mControlsLayout;
private Set<Chronometer> mChronometers = new HashSet<Chronometer>();
static final boolean isInstanciated() {
return instance != null;

View file

@ -42,10 +42,12 @@ import android.app.Activity;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Build;
import android.util.TypedValue;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
@ -234,5 +236,8 @@ public final class LinphoneUtils {
v.setOnClickListener(l);
}
public static int pixelsToDpi(Resources res, int pixels) {
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, (float) pixels, res.getDisplayMetrics());
}
}