* #31377: added visual feedback for incall buttons (1)
diff --git a/src/org/sflphone/model/Bubble.java b/src/org/sflphone/model/Bubble.java
index ad534dd..63b7d83 100644
--- a/src/org/sflphone/model/Bubble.java
+++ b/src/org/sflphone/model/Bubble.java
@@ -13,6 +13,7 @@
import android.graphics.PointF;
import android.graphics.RectF;
import android.graphics.Shader;
+import android.view.MotionEvent;
public abstract class Bubble {
@@ -223,7 +224,7 @@
bounds.set(f, y, g, h);
}
- public abstract void generateBitmap();
+ public abstract void generateBitmap(int action);
public RectF getDrawerBounds() {
return bounds;
@@ -269,4 +270,6 @@
return false;
}
+ public abstract boolean onDown(MotionEvent event);
+
}
diff --git a/src/org/sflphone/model/BubbleContact.java b/src/org/sflphone/model/BubbleContact.java
index 6741099..62c6439 100644
--- a/src/org/sflphone/model/BubbleContact.java
+++ b/src/org/sflphone/model/BubbleContact.java
@@ -10,6 +10,7 @@
import android.graphics.Paint;
import android.graphics.RectF;
import android.util.Log;
+import android.view.MotionEvent;
public class BubbleContact extends Bubble {
@@ -46,13 +47,13 @@
// Left
act = new ActionDrawer(width * 2 / 3, (int) (getRadius() * 1.5f), drawerPosition.LEFT);
act.adjustBounds(pos.x, pos.y);
- act.generateBitmap();
+ act.generateBitmap(actions.NOTHING);
} else if (pos.x > 2 * width / 3) {
// Right
act = new ActionDrawer(width * 2 / 3, (int) (getRadius() * 1.5f), drawerPosition.RIGHT);
act.adjustBounds(pos.x, pos.y);
- act.generateBitmap();
+ act.generateBitmap(actions.NOTHING);
} else {
// Middle of the screen
@@ -61,14 +62,14 @@
act = new ActionDrawer((int) (getRadius() * 1.5f), height / 2, drawerPosition.TOP);
act.adjustBounds(pos.x, pos.y);
- act.generateBitmap();
+ act.generateBitmap(actions.NOTHING);
} else if (pos.y > 2 * height / 3) {
// Middle Bottom
act = new ActionDrawer((int) (getRadius() * 1.5f), height / 2, drawerPosition.BOTTOM);
act.adjustBounds(pos.x, pos.y);
- act.generateBitmap();
+ act.generateBitmap(actions.NOTHING);
}
}
@@ -125,7 +126,7 @@
}
- public void generateBitmap() {
+ public void generateBitmap(int action) {
img = Bitmap.createBitmap(mWidth, mHeight, Config.ARGB_8888);
Paint paint = new Paint();
@@ -366,7 +367,7 @@
public void setCall(SipCall call) {
associated_call = call;
if (expanded) {
- act.generateBitmap();
+ act.generateBitmap(actions.NOTHING);
}
}
@@ -385,5 +386,17 @@
public String getCallID() {
return associated_call.getCallId();
}
+
+ @Override
+ public boolean onDown(MotionEvent event) {
+ if (intersects(event.getX(), event.getY()) && !expanded) {
+ dragged = true;
+ last_drag = System.nanoTime();
+ setPos(event.getX(), event.getY());
+ target_scale = .8f;
+ return true;
+ }
+ return false;
+ }
}
diff --git a/src/org/sflphone/model/BubbleUser.java b/src/org/sflphone/model/BubbleUser.java
index 58942d6..080bd7e 100644
--- a/src/org/sflphone/model/BubbleUser.java
+++ b/src/org/sflphone/model/BubbleUser.java
@@ -1,16 +1,18 @@
package org.sflphone.model;
import org.sflphone.R;
-import org.sflphone.model.Bubble.actions;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
+import android.graphics.Paint.Style;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import android.util.Log;
+import android.view.MotionEvent;
+import android.widget.Toast;
public class BubbleUser extends Bubble {
@@ -55,19 +57,19 @@
setDrawer(new ActionDrawer((int) getExpandedRadius() * 2, (int) getExpandedRadius() * 2));
act.setBounds(pos.x - getExpandedRadius(), pos.y - getExpandedRadius(), pos.x + getExpandedRadius(), pos.y + getExpandedRadius());
- act.generateBitmap();
+ act.generateBitmap(actions.NOTHING);
}
@Override
public int getRadius() {
- if(expanded)
+ if (expanded)
return (int) (radius * density);
return (int) (radius * scale * density);
}
public int getExpandedRadius() {
- return (int) (expanded_radius * scale * density);
+ return (int) (expanded_radius * density);
}
@Override
@@ -100,7 +102,7 @@
}
@Override
- public void generateBitmap() {
+ public void generateBitmap(int action) {
img = Bitmap.createBitmap(mWidth, mHeight, Config.ARGB_8888);
Paint paint = new Paint();
paint.setColor(mContext.getResources().getColor(R.color.sfl_blue_9));
@@ -115,16 +117,30 @@
boundsHangUpButton = new RectF(mWidth / 2 - getRadius(), 0, mWidth / 2 + getRadius(), mHeight / 2 - getRadius());
wHang = buttonHangUp.getWidth();
hHang = buttonHangUp.getHeight();
- c.drawBitmap(buttonHangUp, null,
- new RectF((int) boundsHangUpButton.centerX() - wHang / 2, (int) boundsHangUpButton.centerY() - hHang / 2,
- (int) boundsHangUpButton.centerX() + wHang / 2, (int) boundsHangUpButton.centerY() + hHang / 2), test4);
- // c.drawBitmap(buttonHangUp, null, boundsHangUpButton, test4);
+
+ RectF boundsHangUpIcon = new RectF((int) boundsHangUpButton.centerX() - wHang / 2, (int) boundsHangUpButton.centerY() - hHang / 2,
+ (int) boundsHangUpButton.centerX() + wHang / 2, (int) boundsHangUpButton.centerY() + hHang / 2);
+
+ if (action == actions.HANGUP) {
+ Paint selector = new Paint();
+ selector.setStyle(Style.FILL);
+ selector.setColor(mContext.getResources().getColor(R.color.sfl_light_blue));
+ c.drawCircle(boundsHangUpButton.centerX(), boundsHangUpButton.centerY(), boundsHangUpButton.width() / 2, selector);
+ }
+
+ c.drawBitmap(buttonHangUp, null, boundsHangUpIcon, test4);
boundsHoldButton = new RectF(0, mHeight / 2 - getRadius(), mWidth / 2 - getRadius(), mHeight / 2 + getRadius());
- // c.drawBitmap(buttonHold, null, boundsHoldButton, test4);
-
wHold = buttonHold.getWidth();
hHold = buttonHold.getHeight();
+
+ if (action == actions.HOLD) {
+ Paint selector = new Paint();
+ selector.setStyle(Style.FILL);
+ selector.setColor(mContext.getResources().getColor(R.color.sfl_light_blue));
+ c.drawCircle(boundsHoldButton.centerX(), boundsHoldButton.centerY(), boundsHoldButton.width() / 2, selector);
+ }
+
if (associated_call.isOnHold()) {
c.drawBitmap(buttonUnhold, null, new RectF((int) boundsHoldButton.centerX() - wHold / 2,
(int) boundsHoldButton.centerY() - hHold / 2, (int) boundsHoldButton.centerX() + wHold / 2, (int) boundsHoldButton.centerY()
@@ -134,15 +150,40 @@
(int) boundsHoldButton.centerX() + wHold / 2, (int) boundsHoldButton.centerY() + hHold / 2), test4);
}
+ boundsMicButton = new RectF(mWidth / 2 + getRadius(), mHeight / 2 - getRadius(), mWidth, mHeight / 2 + getRadius());
wMic = buttonMic.getWidth();
hMic = buttonMic.getHeight();
- boundsMicButton = new RectF(mWidth / 2 + getRadius(), mHeight / 2 - getRadius(), mWidth, mHeight / 2 + getRadius());
+
+ if (action == actions.MUTE) {
+ Paint selector = new Paint();
+ selector.setStyle(Style.FILL);
+ selector.setColor(mContext.getResources().getColor(R.color.sfl_light_blue));
+ c.drawCircle(boundsMicButton.centerX(), boundsMicButton.centerY(), boundsMicButton.width() / 2, selector);
+ }
+
c.drawBitmap(buttonMic, null, new RectF((int) boundsMicButton.centerX() - wMic / 2, (int) boundsMicButton.centerY() - hMic / 2,
(int) boundsMicButton.centerX() + wMic / 2, (int) boundsMicButton.centerY() + hMic / 2), test4);
- // c.drawBitmap(buttonMic, null, boundsMicButton, test4);
- // //
+
+
boundsRecordButton = new RectF(mWidth / 2 - getRadius(), mHeight / 2 + getRadius(), mWidth / 2 + getRadius(), mHeight);
// c.drawBitmap(buttonRecord, null, boundsRecordButton, test4);
+
+ // float startAngle = ;
+ // float sweepAngle = 60;
+ //
+ // float startX = mHeight / 2;
+ // float startY = mWidth / 2;
+ //
+ // float angle = (float) ((startAngle + sweepAngle / 2) * Math.PI / 180);
+ // float stopX = (float) (startX + getRadius() * Math.cos(angle));
+ // float stopY = (float) (startY + getRadius() * Math.sin(angle));
+ //
+ // Toast.makeText(mContext, "startX:" + startX + " startY:" + startY, Toast.LENGTH_SHORT).show();
+ // Toast.makeText(mContext, "stopX:" + stopX + " stopY:" + stopY, Toast.LENGTH_SHORT).show();
+ //
+ // Paint mPaint = new Paint();
+ // mPaint.setColor(Color.RED);
+ // c.drawLine(startX, startY, stopX, stopY, mPaint);
}
@Override
@@ -151,7 +192,7 @@
float relativeX = x - getDrawerBounds().left;
float relativeY = y - getDrawerBounds().top;
- if(!getDrawerBounds().contains(x, y) && !getBounds().contains(x, y)){
+ if (!getDrawerBounds().contains(x, y) && !getBounds().contains(x, y)) {
return actions.OUT_OF_BOUNDS;
}
@@ -175,7 +216,7 @@
return actions.HANGUP;
}
- return 0;
+ return actions.NOTHING;
}
@@ -194,7 +235,7 @@
public void setConference(Conference c) {
associated_call = c;
if (expanded) {
- act.generateBitmap();
+ act.generateBitmap(actions.NOTHING);
}
}
@@ -215,10 +256,26 @@
else
return associated_call.getParticipants().get(0).getCallId();
}
-
+
@Override
- public boolean isConference(){
+ public boolean isConference() {
return associated_call.hasMultipleParticipants();
}
+ @Override
+ public boolean onDown(MotionEvent event) {
+ if (expanded) {
+ act.generateBitmap(act.getAction(event.getX(), event.getY()));
+ return false;
+ }
+
+ if (intersects(event.getX(), event.getY())) {
+ dragged = true;
+ last_drag = System.nanoTime();
+ setPos(event.getX(), event.getY());
+ target_scale = .8f;
+ return true;
+ }
+ return false;
+ }
}
diff --git a/src/org/sflphone/model/BubblesView.java b/src/org/sflphone/model/BubblesView.java
index df85f60..35a054a 100644
--- a/src/org/sflphone/model/BubblesView.java
+++ b/src/org/sflphone/model/BubblesView.java
@@ -340,7 +340,7 @@
Bubble expand = getExpandedBubble();
if (expand != null) {
-
+
switch (expand.getDrawer().getAction(event.getX(), event.getY())) {
case Bubble.actions.OUT_OF_BOUNDS:
expand.retract();
@@ -376,7 +376,9 @@
case Bubble.actions.MESSAGE:
// TODO
return true;
-
+ case Bubble.actions.MUTE:
+
+ return true;
case Bubble.actions.HANGUP:
try {
if (expand.isConference())
@@ -394,11 +396,8 @@
case Bubble.actions.NOTHING:
break;
}
-
-
- }
-
+ }
List<Bubble> bubbles = model.getBubbles();
final int n_bubbles = bubbles.size();
@@ -469,18 +468,13 @@
@Override
public boolean onDown(MotionEvent event) {
List<Bubble> bubbles = model.getBubbles();
- final int n_bubbles = bubbles.size();
- for (int i = 0; i < n_bubbles; i++) {
+ for (int i = 0; i < bubbles.size(); i++) {
Bubble b = bubbles.get(i);
- if (b.intersects(event.getX(), event.getY()) && !b.expanded) {
- b.dragged = true;
- b.last_drag = System.nanoTime();
- b.setPos(event.getX(), event.getY());
- b.target_scale = .8f;
- dragging_bubble = true;
- }
+ if(b.onDown(event))
+ dragging_bubble= true;
}
+
return true;
}
@@ -493,7 +487,7 @@
@Override
public void onLongPress(MotionEvent e) {
// Log.d("Main", "onLongPress");
- if (isDraggingBubble()) {
+ if (isDraggingBubble() && callback.getConference().isOnGoing()) {
Bubble b = getDraggedBubble(e);
b.expand(model.width, model.height);
}
@@ -515,9 +509,9 @@
public boolean onScroll(MotionEvent e1, MotionEvent event, float distanceX, float distanceY) {
// Log.d("Main", "onScroll");
List<Bubble> bubbles = model.getBubbles();
- final int n_bubbles = bubbles.size();
+
long now = System.nanoTime();
- for (int i = 0; i < n_bubbles; i++) {
+ for (int i = 0; i < bubbles.size(); i++) {
Bubble b = bubbles.get(i);
if (b.dragged) {
float x = event.getX(), y = event.getY();
@@ -527,7 +521,7 @@
b.setPos(event.getX(), event.getY());
b.speed.x = dx / dt;
b.speed.y = dy / dt;
- // }
+
return true;
}
}