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