Alexandre Lision | 40954dc | 2013-10-09 15:24:03 -0400 | [diff] [blame] | 1 | package org.sflphone.model; |
| 2 | |
| 3 | import org.sflphone.R; |
| 4 | |
| 5 | import android.content.Context; |
| 6 | import android.graphics.Bitmap; |
| 7 | import android.graphics.Bitmap.Config; |
Alexandre Lision | 8fdcf2b | 2013-10-30 16:06:51 -0400 | [diff] [blame] | 8 | import android.graphics.Paint.Style; |
Alexandre Lision | 40954dc | 2013-10-09 15:24:03 -0400 | [diff] [blame] | 9 | import android.graphics.BitmapFactory; |
| 10 | import android.graphics.Canvas; |
| 11 | import android.graphics.Paint; |
Alexandre Lision | 40954dc | 2013-10-09 15:24:03 -0400 | [diff] [blame] | 12 | import android.graphics.RectF; |
| 13 | import android.util.Log; |
Alexandre Lision | d9c3f7f | 2013-10-30 15:20:55 -0400 | [diff] [blame] | 14 | import android.view.MotionEvent; |
Alexandre Lision | 40954dc | 2013-10-09 15:24:03 -0400 | [diff] [blame] | 15 | |
| 16 | public class BubbleContact extends Bubble { |
| 17 | |
| 18 | public SipCall associated_call; |
Alexandre Lision | ee2494d | 2013-10-09 17:14:00 -0400 | [diff] [blame] | 19 | Bitmap buttonMsg, buttonUnhold, buttonHold, buttonTransfer, buttonHangUp; |
Alexandre Lision | 40954dc | 2013-10-09 15:24:03 -0400 | [diff] [blame] | 20 | |
Alexandre Lision | 6885547 | 2013-10-10 16:20:46 -0400 | [diff] [blame] | 21 | public interface drawerPosition { |
| 22 | int UNDEFINED = -1; |
| 23 | int TOP = 0; |
| 24 | int RIGHT = 1; |
| 25 | int BOTTOM = 2; |
| 26 | int LEFT = 3; |
| 27 | } |
| 28 | |
Alexandre Lision | 40954dc | 2013-10-09 15:24:03 -0400 | [diff] [blame] | 29 | public BubbleContact(Context context, SipCall call, float x, float y, float size) { |
| 30 | super(context, call.getContact(), x, y, size); |
| 31 | associated_call = call; |
Alexandre Lision | 8fdcf2b | 2013-10-30 16:06:51 -0400 | [diff] [blame] | 32 | |
Alexandre Lision | 40954dc | 2013-10-09 15:24:03 -0400 | [diff] [blame] | 33 | buttonMsg = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.ic_action_chat); |
| 34 | buttonHold = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.ic_action_pause_over_video); |
Alexandre Lision | ee2494d | 2013-10-09 17:14:00 -0400 | [diff] [blame] | 35 | buttonUnhold = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.ic_action_play_over_video); |
Alexandre Lision | 40954dc | 2013-10-09 15:24:03 -0400 | [diff] [blame] | 36 | buttonTransfer = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.ic_action_forward); |
| 37 | buttonHangUp = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.ic_action_end_call); |
Alexandre Lision | 8fdcf2b | 2013-10-30 16:06:51 -0400 | [diff] [blame] | 38 | |
| 39 | setDrawer(new ActionDrawer(0, 0, drawerPosition.UNDEFINED)); |
Alexandre Lision | 40954dc | 2013-10-09 15:24:03 -0400 | [diff] [blame] | 40 | |
| 41 | } |
| 42 | |
| 43 | @Override |
| 44 | public void expand(int width, int height) { |
| 45 | |
| 46 | expanded = true; |
| 47 | generateBitmap(); |
| 48 | if (pos.x < width / 3) { |
| 49 | |
Alexandre Lision | 6885547 | 2013-10-10 16:20:46 -0400 | [diff] [blame] | 50 | // Left |
| 51 | act = new ActionDrawer(width * 2 / 3, (int) (getRadius() * 1.5f), drawerPosition.LEFT); |
| 52 | act.adjustBounds(pos.x, pos.y); |
Alexandre Lision | d9c3f7f | 2013-10-30 15:20:55 -0400 | [diff] [blame] | 53 | act.generateBitmap(actions.NOTHING); |
Alexandre Lision | 40954dc | 2013-10-09 15:24:03 -0400 | [diff] [blame] | 54 | |
Alexandre Lision | 40954dc | 2013-10-09 15:24:03 -0400 | [diff] [blame] | 55 | } else if (pos.x > 2 * width / 3) { |
Alexandre Lision | 6885547 | 2013-10-10 16:20:46 -0400 | [diff] [blame] | 56 | // Right |
| 57 | act = new ActionDrawer(width * 2 / 3, (int) (getRadius() * 1.5f), drawerPosition.RIGHT); |
| 58 | act.adjustBounds(pos.x, pos.y); |
Alexandre Lision | d9c3f7f | 2013-10-30 15:20:55 -0400 | [diff] [blame] | 59 | act.generateBitmap(actions.NOTHING); |
Alexandre Lision | 40954dc | 2013-10-09 15:24:03 -0400 | [diff] [blame] | 60 | |
| 61 | } else { |
| 62 | // Middle of the screen |
| 63 | if (pos.y < height / 3) { |
| 64 | // Middle Top |
| 65 | |
Alexandre Lision | 6885547 | 2013-10-10 16:20:46 -0400 | [diff] [blame] | 66 | act = new ActionDrawer((int) (getRadius() * 1.5f), height / 2, drawerPosition.TOP); |
| 67 | act.adjustBounds(pos.x, pos.y); |
Alexandre Lision | d9c3f7f | 2013-10-30 15:20:55 -0400 | [diff] [blame] | 68 | act.generateBitmap(actions.NOTHING); |
Alexandre Lision | 40954dc | 2013-10-09 15:24:03 -0400 | [diff] [blame] | 69 | |
| 70 | } else if (pos.y > 2 * height / 3) { |
| 71 | // Middle Bottom |
| 72 | |
Alexandre Lision | 6885547 | 2013-10-10 16:20:46 -0400 | [diff] [blame] | 73 | act = new ActionDrawer((int) (getRadius() * 1.5f), height / 2, drawerPosition.BOTTOM); |
| 74 | act.adjustBounds(pos.x, pos.y); |
Alexandre Lision | d9c3f7f | 2013-10-30 15:20:55 -0400 | [diff] [blame] | 75 | act.generateBitmap(actions.NOTHING); |
Alexandre Lision | 40954dc | 2013-10-09 15:24:03 -0400 | [diff] [blame] | 76 | |
Alexandre Lision | 40954dc | 2013-10-09 15:24:03 -0400 | [diff] [blame] | 77 | } |
| 78 | } |
| 79 | |
| 80 | } |
| 81 | |
Alexandre Lision | ee2494d | 2013-10-09 17:14:00 -0400 | [diff] [blame] | 82 | protected class ActionDrawer extends Bubble.ActionDrawer { |
Alexandre Lision | 40954dc | 2013-10-09 15:24:03 -0400 | [diff] [blame] | 83 | |
Alexandre Lision | 6885547 | 2013-10-10 16:20:46 -0400 | [diff] [blame] | 84 | int direction; |
Alexandre Lision | 40954dc | 2013-10-09 15:24:03 -0400 | [diff] [blame] | 85 | RectF boundsHoldButton, boundsMsgButton, boundsTransferButton, boundsHangUpButton; |
Alexandre Lision | 5cd659e | 2013-10-29 13:18:23 -0400 | [diff] [blame] | 86 | private String TAG = ActionDrawer.class.getSimpleName(); |
Alexandre Lision | 8fdcf2b | 2013-10-30 16:06:51 -0400 | [diff] [blame] | 87 | Paint mBackgroundPaint; |
| 88 | Paint mSelector; |
| 89 | Paint mButtonPaint; |
| 90 | |
| 91 | int wHang, hHang; |
| 92 | int wHold, hHold; |
| 93 | int wMsg, hMsg; |
| 94 | int wTrans, hTrans; |
| 95 | private RectF boundsTransferIcon; |
| 96 | private RectF boundsMsgIcon; |
| 97 | private RectF boundsHangIcon; |
| 98 | private RectF boundsHoldIcon; |
| 99 | |
| 100 | Paint pButtons = new Paint(); |
Alexandre Lision | 40954dc | 2013-10-09 15:24:03 -0400 | [diff] [blame] | 101 | |
Alexandre Lision | 6885547 | 2013-10-10 16:20:46 -0400 | [diff] [blame] | 102 | public ActionDrawer(int w, int h, int dir) { |
Alexandre Lision | 40954dc | 2013-10-09 15:24:03 -0400 | [diff] [blame] | 103 | super(w, h); |
Alexandre Lision | 6885547 | 2013-10-10 16:20:46 -0400 | [diff] [blame] | 104 | direction = dir; |
Alexandre Lision | 8fdcf2b | 2013-10-30 16:06:51 -0400 | [diff] [blame] | 105 | |
| 106 | mBackgroundPaint = new Paint(); |
| 107 | mBackgroundPaint.setColor(mContext.getResources().getColor(R.color.sfl_blue_9)); |
| 108 | mBackgroundPaint.setDither(true); |
| 109 | |
| 110 | mSelector = new Paint(); |
| 111 | mSelector.setStyle(Style.FILL); |
| 112 | mSelector.setColor(mContext.getResources().getColor(R.color.sfl_light_blue)); |
| 113 | |
| 114 | mButtonPaint = new Paint(); |
| 115 | |
| 116 | wHang = buttonHangUp.getWidth(); |
| 117 | hHang = buttonHangUp.getHeight(); |
| 118 | |
| 119 | wMsg = buttonMsg.getWidth(); |
| 120 | hMsg = buttonMsg.getHeight(); |
| 121 | |
| 122 | wHold = buttonHold.getWidth(); |
| 123 | hHold = buttonHold.getHeight(); |
| 124 | |
| 125 | wTrans = buttonTransfer.getWidth(); |
| 126 | hTrans = buttonTransfer.getHeight(); |
Alexandre Lision | 40954dc | 2013-10-09 15:24:03 -0400 | [diff] [blame] | 127 | } |
Alexandre Lision | ee2494d | 2013-10-09 17:14:00 -0400 | [diff] [blame] | 128 | |
Alexandre Lision | 40954dc | 2013-10-09 15:24:03 -0400 | [diff] [blame] | 129 | @Override |
| 130 | public int getAction(float x, float y) { |
| 131 | |
Alexandre Lision | 5cd659e | 2013-10-29 13:18:23 -0400 | [diff] [blame] | 132 | float relativeX = x - getDrawerBounds().left; |
| 133 | float relativeY = y - getDrawerBounds().top; |
Alexandre Lision | 8fdcf2b | 2013-10-30 16:06:51 -0400 | [diff] [blame] | 134 | |
Alexandre Lision | 5cd659e | 2013-10-29 13:18:23 -0400 | [diff] [blame] | 135 | int result = actions.NOTHING; |
Alexandre Lision | 8fdcf2b | 2013-10-30 16:06:51 -0400 | [diff] [blame] | 136 | |
| 137 | if (!getDrawerBounds().contains(x, y) && !getBounds().contains(x, y)) { |
Alexandre Lision | 5cd659e | 2013-10-29 13:18:23 -0400 | [diff] [blame] | 138 | return actions.OUT_OF_BOUNDS; |
| 139 | } |
Alexandre Lision | 40954dc | 2013-10-09 15:24:03 -0400 | [diff] [blame] | 140 | |
| 141 | if (boundsHoldButton.contains(relativeX, relativeY)) { |
| 142 | Log.i("Bubble", "Holding"); |
Alexandre Lision | 8fdcf2b | 2013-10-30 16:06:51 -0400 | [diff] [blame] | 143 | result = actions.HOLD; |
Alexandre Lision | 40954dc | 2013-10-09 15:24:03 -0400 | [diff] [blame] | 144 | } |
| 145 | |
| 146 | if (boundsMsgButton.contains(relativeX, relativeY)) { |
| 147 | Log.i("Bubble", "Msg"); |
Alexandre Lision | 8fdcf2b | 2013-10-30 16:06:51 -0400 | [diff] [blame] | 148 | result = actions.MESSAGE; |
Alexandre Lision | 40954dc | 2013-10-09 15:24:03 -0400 | [diff] [blame] | 149 | } |
| 150 | |
| 151 | if (boundsHangUpButton.contains(relativeX, relativeY)) { |
| 152 | Log.i("Bubble", "hangUp"); |
Alexandre Lision | 8fdcf2b | 2013-10-30 16:06:51 -0400 | [diff] [blame] | 153 | result = actions.HANGUP; |
Alexandre Lision | 40954dc | 2013-10-09 15:24:03 -0400 | [diff] [blame] | 154 | } |
| 155 | |
| 156 | if (boundsTransferButton.contains(relativeX, relativeY)) { |
| 157 | Log.i("Bubble", "Transfer"); |
Alexandre Lision | 5cd659e | 2013-10-29 13:18:23 -0400 | [diff] [blame] | 158 | result = actions.TRANSFER; |
Alexandre Lision | 40954dc | 2013-10-09 15:24:03 -0400 | [diff] [blame] | 159 | } |
Alexandre Lision | 8fdcf2b | 2013-10-30 16:06:51 -0400 | [diff] [blame] | 160 | |
Alexandre Lision | 5cd659e | 2013-10-29 13:18:23 -0400 | [diff] [blame] | 161 | return result; |
Alexandre Lision | 40954dc | 2013-10-09 15:24:03 -0400 | [diff] [blame] | 162 | |
| 163 | } |
| 164 | |
Alexandre Lision | d9c3f7f | 2013-10-30 15:20:55 -0400 | [diff] [blame] | 165 | public void generateBitmap(int action) { |
Alexandre Lision | 40954dc | 2013-10-09 15:24:03 -0400 | [diff] [blame] | 166 | |
| 167 | img = Bitmap.createBitmap(mWidth, mHeight, Config.ARGB_8888); |
| 168 | Paint paint = new Paint(); |
Alexandre Lision | e5b6602 | 2013-10-30 11:34:15 -0400 | [diff] [blame] | 169 | paint.setColor(mContext.getResources().getColor(R.color.sfl_blue_9)); |
Alexandre Lision | 40954dc | 2013-10-09 15:24:03 -0400 | [diff] [blame] | 170 | Canvas c = new Canvas(img); |
| 171 | c.drawRect(new RectF(0, 0, mWidth, mHeight), paint); |
Alexandre Lision | 6885547 | 2013-10-10 16:20:46 -0400 | [diff] [blame] | 172 | float rHeight, rWidth; |
Alexandre Lision | 40954dc | 2013-10-09 15:24:03 -0400 | [diff] [blame] | 173 | |
Alexandre Lision | 6885547 | 2013-10-10 16:20:46 -0400 | [diff] [blame] | 174 | switch (direction) { |
| 175 | case drawerPosition.TOP: |
| 176 | rHeight = bounds.height() - getRadius(); |
Alexandre Lision | 40954dc | 2013-10-09 15:24:03 -0400 | [diff] [blame] | 177 | boundsHoldButton = new RectF(0, getRadius(), mWidth, getRadius() + rHeight / 4); |
| 178 | boundsMsgButton = new RectF(0, getRadius() + rHeight / 4, mWidth, getRadius() + 2 * rHeight / 4); |
| 179 | boundsTransferButton = new RectF(0, getRadius() + 2 * rHeight / 4, mWidth, getRadius() + 3 * rHeight / 4); |
| 180 | boundsHangUpButton = new RectF(0, getRadius() + 3 * rHeight / 4, mWidth, getRadius() + rHeight); |
| 181 | |
Alexandre Lision | 8fdcf2b | 2013-10-30 16:06:51 -0400 | [diff] [blame] | 182 | calculateIconBounds(); |
| 183 | draw(c, action); |
Alexandre Lision | 6885547 | 2013-10-10 16:20:46 -0400 | [diff] [blame] | 184 | break; |
| 185 | case drawerPosition.BOTTOM: |
| 186 | rHeight = bounds.height() - getRadius(); |
| 187 | boundsHoldButton = new RectF(0, 0, mWidth, rHeight / 4); |
| 188 | boundsMsgButton = new RectF(0, rHeight / 4, mWidth, 2 * rHeight / 4); |
| 189 | boundsTransferButton = new RectF(0, 2 * rHeight / 4, mWidth, 3 * rHeight / 4); |
| 190 | boundsHangUpButton = new RectF(0, 3 * rHeight / 4, mWidth, rHeight); |
| 191 | |
Alexandre Lision | 8fdcf2b | 2013-10-30 16:06:51 -0400 | [diff] [blame] | 192 | calculateIconBounds(); |
| 193 | draw(c, action); |
Alexandre Lision | 6885547 | 2013-10-10 16:20:46 -0400 | [diff] [blame] | 194 | break; |
| 195 | case drawerPosition.RIGHT: |
| 196 | rWidth = bounds.width() - getRadius(); |
| 197 | boundsHoldButton = new RectF(0, 0, rWidth / 4, mHeight); |
| 198 | boundsMsgButton = new RectF(rWidth / 4, 0, 2 * rWidth / 4, mHeight); |
| 199 | boundsTransferButton = new RectF(2 * rWidth / 4, 0, 3 * rWidth / 4, mHeight); |
| 200 | boundsHangUpButton = new RectF(3 * rWidth / 4, 0, rWidth, mHeight); |
| 201 | |
Alexandre Lision | 8fdcf2b | 2013-10-30 16:06:51 -0400 | [diff] [blame] | 202 | calculateIconBounds(); |
| 203 | draw(c, action); |
Alexandre Lision | 6885547 | 2013-10-10 16:20:46 -0400 | [diff] [blame] | 204 | break; |
| 205 | case drawerPosition.LEFT: |
Alexandre Lision | 8fdcf2b | 2013-10-30 16:06:51 -0400 | [diff] [blame] | 206 | |
Alexandre Lision | 6885547 | 2013-10-10 16:20:46 -0400 | [diff] [blame] | 207 | rWidth = bounds.width() - getRadius(); |
| 208 | boundsHoldButton = new RectF(getRadius(), 0, getRadius() + rWidth / 4, mHeight); |
| 209 | boundsMsgButton = new RectF(getRadius() + rWidth / 4, 0, getRadius() + 2 * rWidth / 4, mHeight); |
| 210 | boundsTransferButton = new RectF(getRadius() + 2 * rWidth / 4, 0, getRadius() + 3 * rWidth / 4, mHeight); |
| 211 | boundsHangUpButton = new RectF(getRadius() + 3 * rWidth / 4, 0, getRadius() + rWidth, mHeight); |
| 212 | |
Alexandre Lision | 8fdcf2b | 2013-10-30 16:06:51 -0400 | [diff] [blame] | 213 | calculateIconBounds(); |
| 214 | draw(c, action); |
Alexandre Lision | 6885547 | 2013-10-10 16:20:46 -0400 | [diff] [blame] | 215 | break; |
Alexandre Lision | 40954dc | 2013-10-09 15:24:03 -0400 | [diff] [blame] | 216 | } |
| 217 | |
| 218 | } |
| 219 | |
Alexandre Lision | 8fdcf2b | 2013-10-30 16:06:51 -0400 | [diff] [blame] | 220 | private void draw(Canvas c, int action) { |
| 221 | if (action == actions.HANGUP) { |
| 222 | c.drawCircle(boundsHangUpButton.centerX(), boundsHangUpButton.centerY(), boundsHangUpButton.width() / 2, mSelector); |
| 223 | } |
| 224 | c.drawBitmap(buttonHangUp, null, boundsHangIcon, pButtons); |
| 225 | |
| 226 | if (action == actions.HOLD) { |
| 227 | c.drawCircle(boundsHoldButton.centerX(), boundsHoldButton.centerY(), boundsHoldButton.width() / 2, mSelector); |
| 228 | } |
| 229 | if (associated_call.isOnHold()) { |
| 230 | c.drawBitmap(buttonUnhold, null, boundsHoldIcon, pButtons); |
| 231 | } else { |
| 232 | c.drawBitmap(buttonHold, null, boundsHoldIcon, pButtons); |
| 233 | } |
| 234 | if (action == actions.MESSAGE) { |
| 235 | c.drawCircle(boundsMsgButton.centerX(), boundsMsgButton.centerY(), boundsMsgButton.width() / 2, mSelector); |
| 236 | } |
| 237 | c.drawBitmap(buttonMsg, null, boundsMsgIcon, pButtons); |
| 238 | |
| 239 | if (action == actions.TRANSFER) { |
| 240 | c.drawCircle(boundsTransferButton.centerX(), boundsTransferButton.centerY(), boundsTransferButton.width() / 2, mSelector); |
| 241 | } |
| 242 | c.drawBitmap(buttonTransfer, null, boundsTransferIcon, pButtons); |
| 243 | } |
| 244 | |
| 245 | private void calculateIconBounds() { |
| 246 | boundsHoldIcon = new RectF((int) boundsHoldButton.centerX() - wHold / 2, (int) boundsHoldButton.centerY() - hHold / 2, |
| 247 | (int) boundsHoldButton.centerX() + wHold / 2, (int) boundsHoldButton.centerY() + hHold / 2); |
| 248 | boundsHangIcon = new RectF((int) boundsHangUpButton.centerX() - wHang / 2, (int) boundsHangUpButton.centerY() - hHang / 2, |
| 249 | (int) boundsHangUpButton.centerX() + wHang / 2, (int) boundsHangUpButton.centerY() + hHang / 2); |
| 250 | boundsMsgIcon = new RectF((int) boundsMsgButton.centerX() - wMsg / 2, (int) boundsMsgButton.centerY() - hMsg / 2, |
| 251 | (int) boundsMsgButton.centerX() + wMsg / 2, (int) boundsMsgButton.centerY() + hMsg / 2); |
| 252 | boundsTransferIcon = new RectF((int) boundsTransferButton.centerX() - wTrans / 2, (int) boundsTransferButton.centerY() - hTrans / 2, |
| 253 | (int) boundsTransferButton.centerX() + wTrans / 2, (int) boundsTransferButton.centerY() + hTrans / 2); |
| 254 | } |
| 255 | |
Alexandre Lision | 6885547 | 2013-10-10 16:20:46 -0400 | [diff] [blame] | 256 | public void adjustBounds(float x, float y) { |
| 257 | switch (direction) { |
| 258 | case drawerPosition.TOP: |
| 259 | setBounds(x - getRadius(), y, x + getRadius(), y + getHeight()); |
| 260 | break; |
| 261 | case drawerPosition.BOTTOM: |
| 262 | setBounds(x - getRadius(), y - getHeight(), x + getRadius(), y); |
| 263 | break; |
| 264 | case drawerPosition.RIGHT: |
| 265 | setBounds(x - getWidth(), y - getRadius(), x, y + +getRadius()); |
| 266 | break; |
| 267 | case drawerPosition.LEFT: |
| 268 | setBounds(x, y - getRadius(), x + getWidth(), y + getRadius()); |
| 269 | break; |
| 270 | } |
| 271 | |
| 272 | } |
| 273 | |
| 274 | @Override |
| 275 | public void setBounds(float left, float top, float right, float bottom) { |
| 276 | int margin = (int) (0.5f * getRadius()) / 2; |
| 277 | switch (direction) { |
| 278 | case drawerPosition.TOP: |
| 279 | case drawerPosition.BOTTOM: |
| 280 | super.setBounds(left + margin, top, right - margin, bottom); |
| 281 | break; |
| 282 | case drawerPosition.RIGHT: |
| 283 | case drawerPosition.LEFT: |
| 284 | super.setBounds(left, top + margin, right, bottom - margin); |
| 285 | break; |
| 286 | } |
| 287 | |
| 288 | } |
Alexandre Lision | 40954dc | 2013-10-09 15:24:03 -0400 | [diff] [blame] | 289 | } |
| 290 | |
| 291 | public Bitmap getDrawerBitmap() { |
| 292 | return act.getBitmap(); |
| 293 | } |
| 294 | |
| 295 | public RectF getDrawerBounds() { |
Alexandre Lision | 5cd659e | 2013-10-29 13:18:23 -0400 | [diff] [blame] | 296 | return act.getDrawerBounds(); |
Alexandre Lision | 40954dc | 2013-10-09 15:24:03 -0400 | [diff] [blame] | 297 | } |
| 298 | |
| 299 | @Override |
| 300 | public void set(float x, float y, float s) { |
| 301 | scale = s; |
| 302 | pos.x = x; |
| 303 | pos.y = y; |
| 304 | if (!expanded) { |
| 305 | bounds.set(pos.x - getRadius(), pos.y - getRadius(), pos.x + getRadius(), pos.y + getRadius()); |
| 306 | } else { |
| 307 | bounds.set(pos.x - getRadius(), pos.y - getRadius(), pos.x + getRadius(), pos.y + getRadius()); |
Alexandre Lision | 6885547 | 2013-10-10 16:20:46 -0400 | [diff] [blame] | 308 | act.adjustBounds(pos.x, pos.y); |
Alexandre Lision | 40954dc | 2013-10-09 15:24:03 -0400 | [diff] [blame] | 309 | } |
| 310 | } |
| 311 | |
| 312 | @Override |
| 313 | public int getRadius() { |
Alexandre Lision | 8fdcf2b | 2013-10-30 16:06:51 -0400 | [diff] [blame] | 314 | if (expanded) |
Alexandre Lision | a9485b8 | 2013-10-25 10:00:57 -0400 | [diff] [blame] | 315 | return (int) (radius * density); |
Alexandre Lision | 40954dc | 2013-10-09 15:24:03 -0400 | [diff] [blame] | 316 | return (int) (radius * scale * density); |
| 317 | } |
| 318 | |
Alexandre Lision | 40954dc | 2013-10-09 15:24:03 -0400 | [diff] [blame] | 319 | @Override |
| 320 | public boolean getHoldStatus() { |
| 321 | if (associated_call.isOnHold()) |
| 322 | return true; |
| 323 | else |
| 324 | return false; |
| 325 | } |
| 326 | |
| 327 | @Override |
| 328 | public boolean getRecordStatus() { |
| 329 | if (associated_call.isRecording()) |
| 330 | return true; |
| 331 | else |
| 332 | return false; |
| 333 | } |
| 334 | |
Alexandre Lision | 40954dc | 2013-10-09 15:24:03 -0400 | [diff] [blame] | 335 | public SipCall getCall() { |
| 336 | return associated_call; |
| 337 | } |
| 338 | |
Alexandre Lision | ee2494d | 2013-10-09 17:14:00 -0400 | [diff] [blame] | 339 | public void setCall(SipCall call) { |
| 340 | associated_call = call; |
Alexandre Lision | 6885547 | 2013-10-10 16:20:46 -0400 | [diff] [blame] | 341 | if (expanded) { |
Alexandre Lision | d9c3f7f | 2013-10-30 15:20:55 -0400 | [diff] [blame] | 342 | act.generateBitmap(actions.NOTHING); |
Alexandre Lision | ee2494d | 2013-10-09 17:14:00 -0400 | [diff] [blame] | 343 | } |
Alexandre Lision | 6885547 | 2013-10-10 16:20:46 -0400 | [diff] [blame] | 344 | |
Alexandre Lision | ee2494d | 2013-10-09 17:14:00 -0400 | [diff] [blame] | 345 | } |
| 346 | |
| 347 | @Override |
Alexandre Lision | 6885547 | 2013-10-10 16:20:46 -0400 | [diff] [blame] | 348 | public String getName() { |
| 349 | return associated_call.getContact().getmDisplayName(); |
| 350 | } |
| 351 | |
| 352 | @Override |
| 353 | public boolean callIDEquals(String call) { |
| 354 | return associated_call.getCallId().contentEquals(call); |
| 355 | } |
| 356 | |
| 357 | @Override |
| 358 | public String getCallID() { |
| 359 | return associated_call.getCallId(); |
Alexandre Lision | ee2494d | 2013-10-09 17:14:00 -0400 | [diff] [blame] | 360 | } |
Alexandre Lision | 8fdcf2b | 2013-10-30 16:06:51 -0400 | [diff] [blame] | 361 | |
Alexandre Lision | d9c3f7f | 2013-10-30 15:20:55 -0400 | [diff] [blame] | 362 | @Override |
| 363 | public boolean onDown(MotionEvent event) { |
Alexandre Lision | 8fdcf2b | 2013-10-30 16:06:51 -0400 | [diff] [blame] | 364 | if (expanded) { |
| 365 | act.generateBitmap(act.getAction(event.getX(), event.getY())); |
| 366 | return false; |
| 367 | } |
| 368 | if (intersects(event.getX(), event.getY())) { |
Alexandre Lision | d9c3f7f | 2013-10-30 15:20:55 -0400 | [diff] [blame] | 369 | dragged = true; |
| 370 | last_drag = System.nanoTime(); |
| 371 | setPos(event.getX(), event.getY()); |
| 372 | target_scale = .8f; |
| 373 | return true; |
| 374 | } |
| 375 | return false; |
| 376 | } |
Alexandre Lision | ee2494d | 2013-10-09 17:14:00 -0400 | [diff] [blame] | 377 | |
Alexandre Lision | 40954dc | 2013-10-09 15:24:03 -0400 | [diff] [blame] | 378 | } |