* #26029 Working implementation of buttons
diff --git a/res/layout/item_calllist.xml b/res/layout/item_calllist.xml
index 8be2be9..f6d56e9 100644
--- a/res/layout/item_calllist.xml
+++ b/res/layout/item_calllist.xml
@@ -1,16 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
- android:layout_height="match_parent"
+ android:layout_height="wrap_content"
android:background="@drawable/item_call_selector" >
<RelativeLayout
android:id="@+id/call_entry"
android:layout_width="wrap_content"
- android:layout_height="match_parent"
+ android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
- android:clickable="true"
- android:layout_toLeftOf="@+id/expand_button" >
+ android:layout_toLeftOf="@+id/expand_button"
+ android:clickable="true" >
<TextView
android:id="@+id/call_title"
@@ -18,8 +18,8 @@
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
- android:text="Large Text"
- android:textAppearance="?android:attr/textAppearanceLarge" />
+ android:text="call_title"
+ android:textSize="20sp" />
<TextView
android:id="@+id/call_status"
@@ -27,8 +27,17 @@
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/call_title"
- android:text="Medium Text"
- android:textAppearance="?android:attr/textAppearanceMedium" />
+ android:text="call_status"
+ android:textSize="12sp" />
+
+ <TextView
+ android:id="@+id/call_time"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_toRightOf="@+id/call_status"
+ android:layout_below="@+id/call_title"
+ android:text="call_time"
+ android:textSize="12sp" />
</RelativeLayout>
<ImageButton
diff --git a/src/com/savoirfairelinux/sflphone/client/CallActivity.java b/src/com/savoirfairelinux/sflphone/client/CallActivity.java
index 48c9943..c1d0826 100644
--- a/src/com/savoirfairelinux/sflphone/client/CallActivity.java
+++ b/src/com/savoirfairelinux/sflphone/client/CallActivity.java
@@ -239,12 +239,13 @@
mCurrentCallFragment.changeCallState(callID, newState);
- HashMap<String, SipCall> map;
+ HashMap<String, SipCall> callMap;
try {
- map = (HashMap<String, SipCall>) service.getCallList();
- if (map.size() == 0) {
-
-// finish();
+ callMap = (HashMap<String, SipCall>) service.getCallList();
+ ArrayList<String> confMap = (ArrayList<String>) service.getConferenceList();
+ if (callMap.size() == 0 && confMap.size() == 0) {
+
+ finish();
}
} catch (RemoteException e) {
Log.e(TAG, e.toString());
@@ -273,12 +274,12 @@
mCurrentCallFragment.getBubbleView().restartDrawing();
mCurrentCallFragment = new CallFragment();
Bundle b = new Bundle();
-
+
b.putParcelableArrayList("CallsInfo", calls);
mCurrentCallFragment.setArguments(b);
getFragmentManager().beginTransaction().replace(R.id.ongoingcall_pane, mCurrentCallFragment).commit();
-// onCallResumed(calls);
+ // onCallResumed(calls);
slidingPaneLayout.setCurFragment(mCurrentCallFragment);
slidingPaneLayout.closePane();
@@ -417,7 +418,7 @@
@Override
public void confCreated(Intent intent) {
mCallsFragment.update();
-
+
}
@Override
@@ -433,7 +434,7 @@
@Override
public void onCallsTerminated() {
Toast.makeText(this, "No Calls ", Toast.LENGTH_SHORT).show();
-
+
}
}
diff --git a/src/com/savoirfairelinux/sflphone/fragments/CallFragment.java b/src/com/savoirfairelinux/sflphone/fragments/CallFragment.java
index a502bab..f18b0bf 100644
--- a/src/com/savoirfairelinux/sflphone/fragments/CallFragment.java
+++ b/src/com/savoirfairelinux/sflphone/fragments/CallFragment.java
@@ -196,6 +196,7 @@
ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.frag_call, container, false);
view = (BubblesView) rootView.findViewById(R.id.main_view);
+ view.setFragment(this);
view.setModel(model);
view.getHolder().addCallback(this);
@@ -220,8 +221,8 @@
double dY = 0;
int radiusCalls = model.width / 2 - 150;
for (int i = 0; i < mCalls.size(); ++i) {
- dX = Math.cos(Math.toRadians(angle_part * i) - 90) * radiusCalls;
- dY = Math.sin(Math.toRadians(angle_part * i) - 90) * radiusCalls;
+ dX = Math.cos(Math.toRadians(angle_part * i - 90)) * radiusCalls;
+ dY = Math.sin(Math.toRadians(angle_part * i - 90)) * radiusCalls;
getBubbleFor(mCalls.get(i), (int) (model.width / 2 + dX), (int) (model.height / 2 + dY));
}
@@ -230,7 +231,7 @@
@Override
public boolean onBubbleSucked(Bubble b) {
Log.w(TAG, "Bubble sucked ! ");
- if(mCalls.size() == 1){
+ if (mCalls.size() == 1) {
mCallbacks.onCallEnded(b.associated_call);
} else {
try {
@@ -239,7 +240,7 @@
e.printStackTrace();
}
}
-
+
bubbleRemoved(b);
return true;
}
@@ -313,13 +314,7 @@
return contact_bubble;
}
- // TODO off-thread image loading
- if (call.getContact().getPhoto_id() > 0) {
- Bitmap photo = ContactPictureLoader.loadContactPhoto(getActivity().getContentResolver(), call.getContact().getId());
- contact_bubble = new Bubble(call, x, y, BUBBLE_SIZE, photo);
- } else {
- contact_bubble = new Bubble(call, x, y, BUBBLE_SIZE, getActivity(), R.drawable.ic_contact_picture);
- }
+ contact_bubble = new Bubble(getActivity(), call, x, y, BUBBLE_SIZE);
model.addBubble(contact_bubble);
contacts.put(call.getContact(), contact_bubble);
diff --git a/src/com/savoirfairelinux/sflphone/fragments/ConferenceDFragment.java b/src/com/savoirfairelinux/sflphone/fragments/ConferenceDFragment.java
index 06a4d72..3c5ae73 100644
--- a/src/com/savoirfairelinux/sflphone/fragments/ConferenceDFragment.java
+++ b/src/com/savoirfairelinux/sflphone/fragments/ConferenceDFragment.java
@@ -36,7 +36,7 @@
/**
* Create a new instance of CallActionsDFragment
*/
- static ConferenceDFragment newInstance() {
+ public static ConferenceDFragment newInstance() {
ConferenceDFragment f = new ConferenceDFragment();
return f;
}
diff --git a/src/com/savoirfairelinux/sflphone/model/Bubble.java b/src/com/savoirfairelinux/sflphone/model/Bubble.java
index b71c618..de69770 100644
--- a/src/com/savoirfairelinux/sflphone/model/Bubble.java
+++ b/src/com/savoirfairelinux/sflphone/model/Bubble.java
@@ -6,13 +6,14 @@
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
-import android.graphics.Path;
import android.graphics.PointF;
import android.graphics.PorterDuff.Mode;
import android.graphics.PorterDuffXfermode;
import android.graphics.RectF;
+import android.util.Log;
import com.savoirfairelinux.sflphone.R;
+import com.savoirfairelinux.sflphone.adapters.ContactPictureLoader;
public class Bubble {
@@ -40,23 +41,31 @@
this.attractor = attractor;
}
- public Bubble(SipCall call, float x, float y, float size, Bitmap photo) {
+ public Bubble(Context context, SipCall call, float x, float y, float size) {
+
+ Bitmap photo = null;
+ if (call.getContact().getPhoto_id() > 0) {
+ photo = ContactPictureLoader.loadContactPhoto(context.getContentResolver(), call.getContact().getId());
+ } else {
+ photo = BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_contact_picture);
+ }
+
saved_photo = photo;
internalBMP = Bitmap.createScaledBitmap(photo, (int) size, (int) size, false);
- int w = internalBMP.getWidth(), h = internalBMP.getHeight();
+
associated_call = call;
pos.set(x, y);
- radius = w / 2;
+ radius = internalBMP.getWidth() / 2;
bounds = new RectF(pos.x - radius, pos.y - radius, pos.x + radius, pos.y + radius);
attractor = new PointF(x, y);
Paint circlePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
circlePaint.setStyle(Paint.Style.FILL);
- Bitmap circle = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
+ Bitmap circle = Bitmap.createBitmap(internalBMP.getWidth(), internalBMP.getHeight(), Bitmap.Config.ARGB_8888);
Canvas circle_drawer = new Canvas(circle);
- circle_drawer.drawOval(new RectF(0, 0, w, h), circlePaint);
+ circle_drawer.drawOval(new RectF(0, 0, internalBMP.getWidth(), internalBMP.getHeight()), circlePaint);
- externalBMP = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
+ externalBMP = Bitmap.createBitmap(internalBMP.getWidth(), internalBMP.getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(externalBMP);
circlePaint.setFilterBitmap(false);
@@ -66,11 +75,6 @@
canvas.drawBitmap(circle, 0, 0, circlePaint);
}
- public Bubble(SipCall call, float x, float y, float rad, Context c, int resID) {
- // Initialize the bitmap object by loading an image from the resources folder
- this(call, x, y, rad, BitmapFactory.decodeResource(c.getResources(), resID == -1 ? resID : R.drawable.ic_contact_picture));
- }
-
public Bitmap getBitmap() {
return externalBMP;
}
@@ -119,8 +123,16 @@
* Point intersection test.
*/
boolean intersects(float x, float y) {
- float dx = x - pos.x, dy = y - pos.y;
- return dx * dx + dy * dy < getRadius() * getRadius();
+ float dx = x - pos.x;
+ float dy = y - pos.y;
+ Log.i("Bubble","dx:"+dx);
+ Log.i("Bubble","dy:"+dy);
+ Log.i("Bubble", "Intersection dx²+dy²="+(dx * dx + dy * dy));
+ Log.i("Bubble", "Intersection getRadius²="+getRadius() * getRadius());
+
+ Log.i("Bubble","pos.x:"+pos.x);
+ Log.i("Bubble","pos.y:"+pos.y);
+ return dx * dx + dy * dy < getRadius() * density * getRadius() * density;
}
/**
@@ -138,70 +150,63 @@
public void expand(int i) {
- // bounds = new RectF(pos.x - 200, pos.y - 200, pos.x + 200, pos.y + 200);
- // Path path = new Path();
- // path.addCircle(radius, radius, radius, Path.Direction.CW);
- //
- // Paint circlePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
- // circlePaint.setStyle(Paint.Style.FILL);
- // Bitmap circle = Bitmap.createBitmap((int) (2 * radius), (int) (2 * radius), Bitmap.Config.ARGB_8888);
- // Canvas circle_drawer = new Canvas(circle);
- // circle_drawer.drawOval(new RectF(800 - radius, 800 - radius, 2 * radius, 2 * radius), circlePaint);
- //
- // externalBMP = Bitmap.createBitmap(400, 400, Bitmap.Config.ARGB_8888);
- // Canvas canvas = new Canvas(externalBMP);
- //
- // circlePaint.setFilterBitmap(false);
- // canvas.drawBitmap(internalBMP, 200 - radius, 200 - radius, circlePaint);
- //
- // circlePaint.setXfermode(new PorterDuffXfermode(Mode.DST_IN));
- // canvas.drawBitmap(circle, 200 - radius, 200 - radius, circlePaint);
-
expanded_radius = i;
expanded = true;
internalBMP = Bitmap.createScaledBitmap(saved_photo, (int) (2 * radius), (int) (2 * radius), false);
- int w = internalBMP.getWidth(), h = internalBMP.getHeight();
bounds = new RectF(pos.x - getRadius(), pos.y - getRadius(), pos.x + getRadius(), pos.y + getRadius());
Paint circlePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
+ circlePaint.setAntiAlias(true);
+ circlePaint.setDither(true);
circlePaint.setStyle(Paint.Style.FILL);
- Bitmap circle = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
+ circlePaint.setColor(Color.RED);
+
+ Bitmap circle = Bitmap.createBitmap(internalBMP.getWidth(), internalBMP.getHeight(), Bitmap.Config.ARGB_8888);
Canvas circle_drawer = new Canvas(circle);
- circle_drawer.drawOval(new RectF((float) (getRadius() - radius), (float) (getRadius() - radius), w, h), circlePaint);
+ circle_drawer.drawOval(new RectF(0, 0, internalBMP.getWidth(), internalBMP.getHeight()), circlePaint);
- externalBMP = Bitmap.createBitmap((int) (getRadius()*2), (int) (getRadius()*2), Bitmap.Config.ARGB_8888);
- Canvas canvas = new Canvas(externalBMP);
-
+ Canvas canvas = new Canvas(internalBMP);
circlePaint.setFilterBitmap(false);
- canvas.drawBitmap(internalBMP, (float) (getRadius() - radius), (float) (getRadius() - radius), circlePaint);
+ canvas.drawBitmap(internalBMP, 0, 0, circlePaint);
+
+ circlePaint.setXfermode(new PorterDuffXfermode(Mode.DST_IN));
+ canvas.drawBitmap(circle, 0, 0, circlePaint);
+ circle_drawer.drawOval(new RectF(0, 0, internalBMP.getWidth(), internalBMP.getHeight()), circlePaint);
+
+ externalBMP = Bitmap.createBitmap((int) (getRadius() * 2), (int) (getRadius() * 2), Bitmap.Config.ARGB_8888);
+ Canvas canvasf = new Canvas(externalBMP);
Paint mPaintPath = new Paint(Paint.ANTI_ALIAS_FLAG);
mPaintPath.setStyle(Paint.Style.FILL);
- mPaintPath.setColor(Color.BLUE);
-// mPaintPath.setXfermode(new PorterDuffXfermode(Mode.DST_IN));
+ mPaintPath.setColor(0xAA000000);
- canvas.drawOval(new RectF(0, 0, getRadius()*2, getRadius()*2), mPaintPath);
+ Paint fatality = new Paint(Paint.ANTI_ALIAS_FLAG);
+ fatality.setAntiAlias(true);
+ fatality.setDither(true);
+ fatality.setStyle(Paint.Style.FILL);
- circlePaint.setXfermode(new PorterDuffXfermode(Mode.DST_IN));
- canvas.drawBitmap(circle, (float) (getRadius() - radius), (float) (getRadius() - radius), circlePaint);
+ canvasf.drawOval(new RectF(0, 0, getRadius() * 2, getRadius() * 2), mPaintPath); // background with buttons
+ canvasf.drawBitmap(internalBMP, (float) (getRadius() - radius), (float) (getRadius() - radius), fatality);
}
public void retract() {
expanded = false;
internalBMP = Bitmap.createScaledBitmap(saved_photo, (int) (2 * radius), (int) (2 * radius), false);
- int w = internalBMP.getWidth(), h = internalBMP.getHeight();
bounds = new RectF(pos.x - getRadius(), pos.y - getRadius(), pos.x + getRadius(), pos.y + getRadius());
Paint circlePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
+ circlePaint.setAntiAlias(true);
+ circlePaint.setDither(true);
circlePaint.setStyle(Paint.Style.FILL);
- Bitmap circle = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
- Canvas circle_drawer = new Canvas(circle);
- circle_drawer.drawOval(new RectF(0, 0, w, h), circlePaint);
- externalBMP = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
+ Bitmap circle = Bitmap.createBitmap(internalBMP.getWidth(), internalBMP.getHeight(), Bitmap.Config.ARGB_8888);
+ Canvas circle_drawer = new Canvas(circle);
+ circle_drawer.drawOval(new RectF(0, 0, internalBMP.getWidth(), internalBMP.getHeight()), circlePaint);
+
+ externalBMP = Bitmap.createBitmap(internalBMP.getWidth(), internalBMP.getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(externalBMP);
circlePaint.setFilterBitmap(false);
@@ -211,4 +216,41 @@
canvas.drawBitmap(circle, 0, 0, circlePaint);
}
+
+ /**
+ * When bubble is expanded we need to check on wich action button the user tap
+ *
+ * @param x
+ * @param y
+ * @return
+ */
+ public int getAction(float x, float y) {
+ float relativeX = x - pos.x + externalBMP.getWidth() / 2;
+ float relativeY = y - pos.y + externalBMP.getHeight() / 2;
+
+ Log.i("Bubble","relativeX:"+relativeX);
+ Log.i("Bubble","relativeY:"+relativeY);
+
+ Log.i("Bubble","pos.x:"+pos.x);
+ Log.i("Bubble","pos.y:"+pos.y);
+
+ Log.i("Bubble","externalBMP.getWidth():"+externalBMP.getWidth());
+ Log.i("Bubble","externalBMP.getHeight():"+externalBMP.getHeight());
+
+ // Hold - Left
+ if (relativeX < externalBMP.getWidth() / 3 && relativeY > externalBMP.getHeight() / 3) {
+ return 1;
+ }
+
+ // Record - Right
+ if (relativeX > externalBMP.getWidth() * 2 / 3 && relativeY > externalBMP.getHeight() / 3) {
+ return 2;
+ }
+
+ // Transfer - Bottom
+ if (relativeY > externalBMP.getHeight() * 2 / 3) {
+ return 3;
+ }
+ return 0;
+ }
}
diff --git a/src/com/savoirfairelinux/sflphone/model/BubblesView.java b/src/com/savoirfairelinux/sflphone/model/BubblesView.java
index 0f1b33f..26103fb 100644
--- a/src/com/savoirfairelinux/sflphone/model/BubblesView.java
+++ b/src/com/savoirfairelinux/sflphone/model/BubblesView.java
@@ -34,13 +34,13 @@
import java.util.List;
+import android.app.FragmentManager;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Align;
-import android.graphics.PointF;
-import android.graphics.RectF;
+import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.AttributeSet;
@@ -52,6 +52,11 @@
import android.view.SurfaceView;
import android.view.View;
import android.view.View.OnTouchListener;
+import android.widget.Toast;
+
+import com.savoirfairelinux.sflphone.client.CallActivity;
+import com.savoirfairelinux.sflphone.fragments.CallFragment;
+import com.savoirfairelinux.sflphone.fragments.TransferDFragment;
public class BubblesView extends SurfaceView implements SurfaceHolder.Callback, OnTouchListener {
private static final String TAG = BubblesView.class.getSimpleName();
@@ -60,7 +65,8 @@
private BubbleModel model;
private Paint attractor_paint = new Paint();
- private Paint name_paint = new Paint(Paint.ANTI_ALIAS_FLAG);
+ private Paint black_name_paint = new Paint(Paint.ANTI_ALIAS_FLAG);
+ private Paint white_name_paint = new Paint(Paint.ANTI_ALIAS_FLAG);
private GestureDetector gDetector;
@@ -69,6 +75,8 @@
private boolean dragging_bubble = false;
+ private CallFragment callback;
+
public BubblesView(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -86,9 +94,13 @@
attractor_paint.setColor(Color.RED);
// attractor_paint.set
- name_paint.setTextSize(18 * textDensity);
- name_paint.setColor(0xFF303030);
- name_paint.setTextAlign(Align.CENTER);
+ black_name_paint.setTextSize(18 * textDensity);
+ black_name_paint.setColor(0xFF303030);
+ black_name_paint.setTextAlign(Align.CENTER);
+
+ white_name_paint.setTextSize(18 * textDensity);
+ white_name_paint.setColor(0xFFEEEEEE);
+ white_name_paint.setTextAlign(Align.CENTER);
gDetector = new GestureDetector(getContext(), new MyOnGestureListener());
}
@@ -259,8 +271,16 @@
for (int i = 0, n = bubbles.size(); i < n; i++) {
Bubble b = bubbles.get(i);
canvas.drawBitmap(b.getBitmap(), null, b.getBounds(), null);
- canvas.drawText(b.associated_call.getContact().getmDisplayName(), b.getPosX(), b.getPosY() - 50 * density, name_paint);
-
+ canvas.drawText(b.associated_call.getContact().getmDisplayName(), b.getPosX(), b.getPosY() - 40 * density, getNamePaint(b));
+ }
+ Bubble first_plan = getExpandedBubble();
+ if (first_plan != null) {
+ canvas.drawBitmap(first_plan.getBitmap(), null, first_plan.getBounds(), null);
+ canvas.drawText(first_plan.associated_call.getContact().getmDisplayName(), first_plan.getPosX(), first_plan.getPosY() - 50
+ * density, getNamePaint(first_plan));
+ canvas.drawText("Transfer", first_plan.getPosX(), first_plan.getPosY() + 70 * density, getNamePaint(first_plan));
+ canvas.drawText("Hold", first_plan.getPosX() - 70 * density, first_plan.getPosY(), getNamePaint(first_plan));
+ canvas.drawText("Record", first_plan.getPosX() + 70 * density, first_plan.getPosY(), getNamePaint(first_plan));
}
} catch (IndexOutOfBoundsException e) {
@@ -268,6 +288,13 @@
}
}
}
+
+ }
+
+ private Paint getNamePaint(Bubble b) {
+ if (b.expanded)
+ return white_name_paint;
+ return black_name_paint;
}
@Override
@@ -302,8 +329,18 @@
return gDetector.onTouchEvent(event);
}
- RectF intern;
- RectF external;
+ private Bubble getExpandedBubble() {
+ List<Bubble> bubbles = model.getBubbles();
+ final int n_bubbles = bubbles.size();
+ for (int i = 0; i < n_bubbles; i++) {
+ Bubble b = bubbles.get(i);
+ if (b.expanded) {
+ return b;
+ }
+ }
+ return null;
+ }
+
class MyOnGestureListener implements OnGestureListener {
@Override
@@ -311,14 +348,28 @@
List<Bubble> bubbles = model.getBubbles();
final int n_bubbles = bubbles.size();
Bubble expand = getExpandedBubble();
- if (expand != null && !expand.intersects(event.getX(), event.getY())) {
-
- expand.retract();
+ if (expand != null) {
+ if (!expand.intersects(event.getX(), event.getY())) {
+ expand.retract();
+ } else {
+ Log.d("Main", "getAction");
+ switch(expand.getAction(event.getX(), event.getY())){
+ case 0: expand.retract();
+ break;
+ case 1: Log.d("Main", "onCallSuspended");((CallActivity)callback.getActivity()).onCallSuspended(expand.associated_call);
+ break;
+ case 2: Log.d("Main", "onRecordCall");((CallActivity)callback.getActivity()).onRecordCall(expand.associated_call);
+ break;
+ case 3: Toast.makeText(getContext(), "Not implemented here",Toast.LENGTH_SHORT).show();
+ break;
+ }
+ }
+ return true;
}
Log.d("Main", "onDown");
for (int i = 0; i < n_bubbles; i++) {
Bubble b = bubbles.get(i);
- if (b.intersects(event.getX(), event.getY())) {
+ if (b.intersects(event.getX(), event.getY()) && !b.expanded) {
b.dragged = true;
b.last_drag = System.nanoTime();
b.setPos(event.getX(), event.getY());
@@ -328,18 +379,8 @@
}
return true;
}
-
- private Bubble getExpandedBubble() {
- List<Bubble> bubbles = model.getBubbles();
- final int n_bubbles = bubbles.size();
- for (int i = 0; i < n_bubbles; i++) {
- Bubble b = bubbles.get(i);
- if (b.expanded) {
- return b;
- }
- }
- return null;
- }
+
+
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
@@ -352,24 +393,10 @@
Log.d("Main", "onLongPress");
if (isDraggingBubble()) {
Bubble b = getDraggedBubble(e);
-
- calculateBounds(b.getPos(), b.getRadius());
-
b.expand(100);
}
}
- private void calculateBounds(PointF pointF, float radius) {
- // intern = new RectF();
- // float half_square = (float) (radius / Math.sqrt(2));
- // intern.set(pointF.x - half_square, pointF.y - half_square, pointF.x + half_square, pointF.y + half_square);
-
- external = new RectF();
- float large_half_square = 200;
- external.set(pointF.x - large_half_square, pointF.y - large_half_square, pointF.x + large_half_square, pointF.y + large_half_square);
-
- }
-
private Bubble getDraggedBubble(MotionEvent e) {
List<Bubble> bubbles = model.getBubbles();
final int n_bubbles = bubbles.size();
@@ -431,4 +458,9 @@
}
}
+ public void setFragment(CallFragment callFragment) {
+ callback = callFragment;
+
+ }
+
}
diff --git a/src/com/savoirfairelinux/sflphone/receivers/IncomingReceiver.java b/src/com/savoirfairelinux/sflphone/receivers/IncomingReceiver.java
index 536395f..69cbed9 100644
--- a/src/com/savoirfairelinux/sflphone/receivers/IncomingReceiver.java
+++ b/src/com/savoirfairelinux/sflphone/receivers/IncomingReceiver.java
@@ -1,17 +1,17 @@
package com.savoirfairelinux.sflphone.receivers;
import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Map.Entry;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.RemoteException;
-import android.os.Vibrator;
import android.util.Log;
import android.widget.Toast;
-import com.savoirfairelinux.sflphone.interfaces.CallInterface;
import com.savoirfairelinux.sflphone.model.CallContact;
import com.savoirfairelinux.sflphone.model.Conference;
import com.savoirfairelinux.sflphone.model.SipCall;
@@ -20,36 +20,36 @@
import com.savoirfairelinux.sflphone.service.ISipService.Stub;
import com.savoirfairelinux.sflphone.service.SipService;
-public class IncomingReceiver extends BroadcastReceiver{
-
+public class IncomingReceiver extends BroadcastReceiver {
+
static final String TAG = IncomingReceiver.class.getSimpleName();
SipService callback;
Stub mBinder;
-
- public IncomingReceiver(SipService client, Stub bind){
+
+ public IncomingReceiver(SipService client, Stub bind) {
callback = client;
mBinder = bind;
}
-
+
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().contentEquals(ConfigurationManagerCallback.ACCOUNT_STATE_CHANGED)) {
-
+
Log.i(TAG, "Received" + intent.getAction());
callback.sendBroadcast(intent);
-
+
} else if (intent.getAction().contentEquals(ConfigurationManagerCallback.ACCOUNTS_CHANGED)) {
-
+
Log.i(TAG, "Received" + intent.getAction());
callback.sendBroadcast(intent);
-
+
} else if (intent.getAction().contentEquals(CallManagerCallBack.INCOMING_TEXT)) {
-
+
Log.i(TAG, "Received" + intent.getAction());
callback.sendBroadcast(intent);
-
+
} else if (intent.getAction().contentEquals(CallManagerCallBack.INCOMING_CALL)) {
Bundle b = intent.getBundleExtra("com.savoirfairelinux.sflphone.service.newcall");
@@ -85,27 +85,52 @@
} else if (newState.equals("FAILURE")) {
callback.getCurrent_calls().remove(b.getString("CallID"));
} else if (newState.equals("HOLD")) {
- callback.getCurrent_calls().get(b.getString("CallID")).setCallState(SipCall.state.CALL_STATE_HOLD);
+ if (callback.getCurrent_calls().get(b.getString("CallID")) != null) {
+ callback.getCurrent_calls().get(b.getString("CallID")).setCallState(SipCall.state.CALL_STATE_HOLD);
+ } else {
+ // Check if call is in a conference
+ Iterator<Entry<String, Conference>> it = callback.getCurrent_confs().entrySet().iterator();
+ while(it.hasNext()){
+ Conference tmp = it.next().getValue();
+ for(SipCall c : tmp.getParticipants()){
+ if(c.getCallId().contentEquals(b.getString("CallID")));
+ c.setCallState(SipCall.state.CALL_STATE_HOLD);
+ }
+ }
+ }
} else if (newState.equals("UNHOLD")) {
- callback.getCurrent_calls().get(b.getString("CallID")).setCallState(SipCall.state.CALL_STATE_CURRENT);
+
+ if (callback.getCurrent_calls().get(b.getString("CallID")) != null) {
+ callback.getCurrent_calls().get(b.getString("CallID")).setCallState(SipCall.state.CALL_STATE_CURRENT);
+ } else {
+ // Check if call is in a conference
+ Iterator<Entry<String, Conference>> it = callback.getCurrent_confs().entrySet().iterator();
+ while(it.hasNext()){
+ Conference tmp = it.next().getValue();
+ for(SipCall c : tmp.getParticipants()){
+ if(c.getCallId().contentEquals(b.getString("CallID")));
+ c.setCallState(SipCall.state.CALL_STATE_CURRENT);
+ }
+ }
+ }
} else {
callback.getCurrent_calls().get(b.getString("CallID")).setCallState(SipCall.state.CALL_STATE_NONE);
}
callback.sendBroadcast(intent);
-
+
} else if (intent.getAction().contentEquals(CallManagerCallBack.NEW_CALL_CREATED)) {
-
+
Log.i(TAG, "Received" + intent.getAction());
-
+
} else if (intent.getAction().contentEquals(CallManagerCallBack.CONF_CREATED)) {
-
+
Log.i(TAG, "Received" + intent.getAction());
Conference created = new Conference(intent.getStringExtra("confID"));
ArrayList<String> all_participants;
try {
all_participants = (ArrayList<String>) mBinder.getParticipantList(intent.getStringExtra("confID"));
- for(String participant : all_participants){
+ for (String participant : all_participants) {
created.getParticipants().add(callback.getCurrent_calls().get(participant));
}
Intent toSend = new Intent(CallManagerCallBack.CONF_CREATED);
@@ -116,22 +141,22 @@
e1.printStackTrace();
}
Log.i(TAG, "current_confs size " + callback.getCurrent_confs().size());
-
+
} else if (intent.getAction().contentEquals(CallManagerCallBack.CONF_REMOVED)) {
-
+
Log.i(TAG, "Received" + intent.getAction());
Conference toDestroy = callback.getCurrent_confs().get(intent.getStringExtra("confID"));
- for(int i = 0; i < toDestroy.getParticipants().size() ; ++i){
+ for (int i = 0; i < toDestroy.getParticipants().size(); ++i) {
callback.getCurrent_calls().put(toDestroy.getParticipants().get(i).getCallId(), toDestroy.getParticipants().get(i));
}
callback.getCurrent_confs().remove(intent.getStringExtra("confID"));
Toast.makeText(callback, "Removed conf ", Toast.LENGTH_SHORT).show();
-
+
} else if (intent.getAction().contentEquals(CallManagerCallBack.CONF_CHANGED)) {
-
+
Log.i(TAG, "Received" + intent.getAction());
callback.getCurrent_confs().get(intent.getStringExtra("confID")).setState(intent.getStringExtra("State"));
- Toast.makeText(callback, "Changing conf state: "+ intent.getStringExtra("State"), Toast.LENGTH_SHORT).show();
+ Toast.makeText(callback, "Changing conf state: " + intent.getStringExtra("State"), Toast.LENGTH_SHORT).show();
}
}