blob: 9276db04d023aa5695be22d3a1f4aec0833ec908 [file] [log] [blame]
alisionfde875f2013-05-28 17:01:54 -04001/*
alision2ec64f92013-06-17 17:28:58 -04002 * Copyright (C) 2004-2013 Savoir-Faire Linux Inc.
alisionfde875f2013-05-28 17:01:54 -04003 *
4 * Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 * Additional permission under GNU GPL version 3 section 7:
21 *
22 * If you modify this program, or any covered work, by linking or
23 * combining it with the OpenSSL project's OpenSSL library (or a
24 * modified version of that library), containing parts covered by the
25 * terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
26 * grants you additional permission to convey the resulting work.
27 * Corresponding Source for a non-source form of such a combination
28 * shall include the source code for the parts of OpenSSL used as well
29 * as that of the covered work.
30 */
31
alision84813a12013-05-27 17:40:39 -040032package com.savoirfairelinux.sflphone.fragments;
33
alision84813a12013-05-27 17:40:39 -040034import android.app.Activity;
35import android.app.Fragment;
36import android.graphics.Bitmap;
Adrien Béraud0c9bd8f2013-05-30 16:16:57 +100037import android.graphics.BitmapFactory;
alision84813a12013-05-27 17:40:39 -040038import android.graphics.PointF;
39import android.os.Bundle;
40import android.os.RemoteException;
alision84813a12013-05-27 17:40:39 -040041import android.util.Log;
42import android.view.LayoutInflater;
Adrien Béraud13cde0b2013-05-30 20:27:20 +100043import android.view.SurfaceHolder;
44import android.view.SurfaceHolder.Callback;
alision84813a12013-05-27 17:40:39 -040045import android.view.View;
46import android.view.ViewGroup;
alision84813a12013-05-27 17:40:39 -040047
48import com.savoirfairelinux.sflphone.R;
alision84813a12013-05-27 17:40:39 -040049import com.savoirfairelinux.sflphone.model.Attractor;
50import com.savoirfairelinux.sflphone.model.Bubble;
51import com.savoirfairelinux.sflphone.model.BubbleModel;
52import com.savoirfairelinux.sflphone.model.BubblesView;
alisiondf1dac92013-06-27 17:35:53 -040053import com.savoirfairelinux.sflphone.model.Conference;
alision84813a12013-05-27 17:40:39 -040054import com.savoirfairelinux.sflphone.model.SipCall;
alision84813a12013-05-27 17:40:39 -040055import com.savoirfairelinux.sflphone.service.ISipService;
alision50fa0722013-06-25 17:29:44 -040056import com.savoirfairelinux.sflphone.views.CounterTextView;
alision84813a12013-05-27 17:40:39 -040057
Adrien Béraud13cde0b2013-05-30 20:27:20 +100058public class CallFragment extends Fragment implements Callback {
alision84813a12013-05-27 17:40:39 -040059
alision1005ba12013-06-19 13:52:44 -040060 static final String TAG = "CallFragment";
alision84813a12013-05-27 17:40:39 -040061
alisionf57d8a62013-07-02 09:37:12 -040062 float BUBBLE_SIZE = 75;
alision1005ba12013-06-19 13:52:44 -040063 static final float ATTRACTOR_SIZE = 40;
alision84813a12013-05-27 17:40:39 -040064
alisiondf1dac92013-06-27 17:35:53 -040065 private Conference conf;
alision84813a12013-05-27 17:40:39 -040066
alision50fa0722013-06-25 17:29:44 -040067 private CounterTextView callStatusTxt;
alision1005ba12013-06-19 13:52:44 -040068 private BubblesView view;
69 private BubbleModel model;
alision84813a12013-05-27 17:40:39 -040070
alision1005ba12013-06-19 13:52:44 -040071 private Callbacks mCallbacks = sDummyCallbacks;
alision84813a12013-05-27 17:40:39 -040072
alision806e18e2013-06-21 15:30:17 -040073 private SipCall myself;
alision85704182013-05-29 15:23:03 -040074
alisiondf1dac92013-06-27 17:35:53 -040075 private Bitmap hangup_icon, separate_icon;
alision1005ba12013-06-19 13:52:44 -040076 private Bitmap call_icon;
alision85704182013-05-29 15:23:03 -040077
alision1005ba12013-06-19 13:52:44 -040078 @Override
79 public void onCreate(Bundle savedBundle) {
80 super.onCreate(savedBundle);
alision1005ba12013-06-19 13:52:44 -040081 Bundle b = getArguments();
alisioncd8fb912013-06-28 14:43:51 -040082 conf = new Conference((Conference) b.getParcelable("conference"));
alisiondf1dac92013-06-27 17:35:53 -040083 model = new BubbleModel(getResources().getDisplayMetrics().density);
alision729b0a22013-07-02 11:57:33 -040084 BUBBLE_SIZE = getResources().getDimension(R.dimen.bubble_size);
85 Log.e(TAG,"BUBBLE_SIZE "+BUBBLE_SIZE);
86
alision1005ba12013-06-19 13:52:44 -040087 }
alision85992112013-05-29 12:18:08 -040088
alision1005ba12013-06-19 13:52:44 -040089 /**
90 * A dummy implementation of the {@link Callbacks} interface that does nothing. Used only when this fragment is not attached to an activity.
91 */
92 private static Callbacks sDummyCallbacks = new Callbacks() {
93 @Override
94 public void onSendMessage(SipCall call, String msg) {
95 }
alision85992112013-05-29 12:18:08 -040096
alision1005ba12013-06-19 13:52:44 -040097 @Override
98 public void callContact(SipCall call) {
99 }
alision85992112013-05-29 12:18:08 -0400100
alision1005ba12013-06-19 13:52:44 -0400101 @Override
102 public void onCallAccepted(SipCall call) {
103 }
alision85704182013-05-29 15:23:03 -0400104
alision1005ba12013-06-19 13:52:44 -0400105 @Override
106 public void onCallRejected(SipCall call) {
107 }
alision85992112013-05-29 12:18:08 -0400108
alision1005ba12013-06-19 13:52:44 -0400109 @Override
110 public void onCallEnded(SipCall call) {
111 }
alision85704182013-05-29 15:23:03 -0400112
alision1005ba12013-06-19 13:52:44 -0400113 @Override
114 public void onCallSuspended(SipCall call) {
115 }
alision85992112013-05-29 12:18:08 -0400116
alision1005ba12013-06-19 13:52:44 -0400117 @Override
118 public void onCallResumed(SipCall call) {
119 }
alision85704182013-05-29 15:23:03 -0400120
alision1005ba12013-06-19 13:52:44 -0400121 @Override
122 public void onCalltransfered(SipCall call, String to) {
123 }
alision85992112013-05-29 12:18:08 -0400124
alision1005ba12013-06-19 13:52:44 -0400125 @Override
126 public void onRecordCall(SipCall call) {
127 }
alision85704182013-05-29 15:23:03 -0400128
alision1005ba12013-06-19 13:52:44 -0400129 @Override
130 public ISipService getService() {
131 return null;
132 }
alisiondf1dac92013-06-27 17:35:53 -0400133
134 @Override
135 public void replaceCurrentCallDisplayed() {
136 }
alision1005ba12013-06-19 13:52:44 -0400137 };
alision907bde72013-06-20 14:40:37 -0400138
alision1005ba12013-06-19 13:52:44 -0400139 /**
140 * The Activity calling this fragment has to implement this interface
141 *
142 */
143 public interface Callbacks {
alision85992112013-05-29 12:18:08 -0400144
alision1005ba12013-06-19 13:52:44 -0400145 public ISipService getService();
alision85704182013-05-29 15:23:03 -0400146
alision1005ba12013-06-19 13:52:44 -0400147 public void callContact(SipCall call);
alision85992112013-05-29 12:18:08 -0400148
alision1005ba12013-06-19 13:52:44 -0400149 public void onCallAccepted(SipCall call);
alision85704182013-05-29 15:23:03 -0400150
alision1005ba12013-06-19 13:52:44 -0400151 public void onCallRejected(SipCall call);
alision85992112013-05-29 12:18:08 -0400152
alision1005ba12013-06-19 13:52:44 -0400153 public void onCallEnded(SipCall call);
alision85704182013-05-29 15:23:03 -0400154
alision1005ba12013-06-19 13:52:44 -0400155 public void onCallSuspended(SipCall call);
alision85704182013-05-29 15:23:03 -0400156
alision1005ba12013-06-19 13:52:44 -0400157 public void onCallResumed(SipCall call);
alision84813a12013-05-27 17:40:39 -0400158
alision1005ba12013-06-19 13:52:44 -0400159 public void onCalltransfered(SipCall call, String to);
alision84813a12013-05-27 17:40:39 -0400160
alision1005ba12013-06-19 13:52:44 -0400161 public void onRecordCall(SipCall call);
alision85704182013-05-29 15:23:03 -0400162
alision1005ba12013-06-19 13:52:44 -0400163 public void onSendMessage(SipCall call, String msg);
alisiondf1dac92013-06-27 17:35:53 -0400164
165 public void replaceCurrentCallDisplayed();
alision1005ba12013-06-19 13:52:44 -0400166 }
alision85992112013-05-29 12:18:08 -0400167
alision1005ba12013-06-19 13:52:44 -0400168 @Override
169 public void onAttach(Activity activity) {
170 super.onAttach(activity);
alision85992112013-05-29 12:18:08 -0400171
alision1005ba12013-06-19 13:52:44 -0400172 if (!(activity instanceof Callbacks)) {
173 throw new IllegalStateException("Activity must implement fragment's callbacks.");
174 }
alision85992112013-05-29 12:18:08 -0400175
alision1005ba12013-06-19 13:52:44 -0400176 // rootView.requestDisallowInterceptTouchEvent(true);
alision85992112013-05-29 12:18:08 -0400177
alision1005ba12013-06-19 13:52:44 -0400178 mCallbacks = (Callbacks) activity;
alision50fa0722013-06-25 17:29:44 -0400179 myself = SipCall.SipCallBuilder.buildMyselfCall(activity.getContentResolver(), "Me");
alision85992112013-05-29 12:18:08 -0400180
alision1005ba12013-06-19 13:52:44 -0400181 }
alision85992112013-05-29 12:18:08 -0400182
alision1005ba12013-06-19 13:52:44 -0400183 @Override
184 public void onDetach() {
185 super.onDetach();
186 mCallbacks = sDummyCallbacks;
187 // rootView.requestDisallowInterceptTouchEvent(false);
188 }
alision907bde72013-06-20 14:40:37 -0400189
alision1005ba12013-06-19 13:52:44 -0400190 @Override
alision907bde72013-06-20 14:40:37 -0400191 public void onStop() {
alision1005ba12013-06-19 13:52:44 -0400192 super.onStop();
193 }
alision85992112013-05-29 12:18:08 -0400194
alision1005ba12013-06-19 13:52:44 -0400195 @Override
196 public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
197 ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.frag_call, container, false);
alision85992112013-05-29 12:18:08 -0400198
alision1005ba12013-06-19 13:52:44 -0400199 view = (BubblesView) rootView.findViewById(R.id.main_view);
alision34673e62013-06-25 14:40:07 -0400200 view.setFragment(this);
alision1005ba12013-06-19 13:52:44 -0400201 view.setModel(model);
202 view.getHolder().addCallback(this);
alision84813a12013-05-27 17:40:39 -0400203
alision50fa0722013-06-25 17:29:44 -0400204 callStatusTxt = (CounterTextView) rootView.findViewById(R.id.call_status_txt);
alision84813a12013-05-27 17:40:39 -0400205
alision1005ba12013-06-19 13:52:44 -0400206 hangup_icon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_hangup);
207 call_icon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_call);
alisiondf1dac92013-06-27 17:35:53 -0400208 separate_icon = BitmapFactory.decodeResource(getResources(), R.drawable.icon_separate);
alision84813a12013-05-27 17:40:39 -0400209
alision1005ba12013-06-19 13:52:44 -0400210 // Do nothing here, the view is not initialized yet.
211 return rootView;
212 }
alision85992112013-05-29 12:18:08 -0400213
alision1005ba12013-06-19 13:52:44 -0400214 private void initNormalStateDisplay() {
215 Log.i(TAG, "Start normal display");
alision84813a12013-05-27 17:40:39 -0400216
alision1005ba12013-06-19 13:52:44 -0400217 callStatusTxt.setText("0 min");
alision84813a12013-05-27 17:40:39 -0400218
alision1005ba12013-06-19 13:52:44 -0400219 getBubbleFor(myself, model.width / 2, model.height / 2);
alision907bde72013-06-20 14:40:37 -0400220
alisiondf1dac92013-06-27 17:35:53 -0400221 int angle_part = 360 / conf.getParticipants().size();
alision806e18e2013-06-21 15:30:17 -0400222 double dX = 0;
223 double dY = 0;
alision465ceba2013-07-04 09:24:30 -0400224 int radiusCalls = (int) (model.width / 2 - BUBBLE_SIZE);
alisiondf1dac92013-06-27 17:35:53 -0400225 for (int i = 0; i < conf.getParticipants().size(); ++i) {
226
227 if (conf.getParticipants().get(i) == null) {
228 Log.i(TAG, i + " null ");
229 continue;
230 }
alision34673e62013-06-25 14:40:07 -0400231 dX = Math.cos(Math.toRadians(angle_part * i - 90)) * radiusCalls;
232 dY = Math.sin(Math.toRadians(angle_part * i - 90)) * radiusCalls;
alisiondf1dac92013-06-27 17:35:53 -0400233 getBubbleFor(conf.getParticipants().get(i), (int) (model.width / 2 + dX), (int) (model.height / 2 + dY));
alision806e18e2013-06-21 15:30:17 -0400234 }
alision1005ba12013-06-19 13:52:44 -0400235
236 model.clearAttractors();
alisiondf1dac92013-06-27 17:35:53 -0400237 model.addAttractor(new Attractor(new PointF(model.width / 1.1f, model.height * .1f), ATTRACTOR_SIZE, new Attractor.Callback() {
238 @Override
239 public boolean onBubbleSucked(Bubble b) {
240 Log.w(TAG, "Bubble sucked ! ");
241
alisioncd8fb912013-06-28 14:43:51 -0400242 if (b.associated_call.getContact().isUser()) {
alisiondf1dac92013-06-27 17:35:53 -0400243
alisioncd8fb912013-06-28 14:43:51 -0400244 try {
245 if (conf.hasMultipleParticipants())
246 mCallbacks.getService().hangUpConference(conf.getId());
247 else
248 mCallbacks.onCallEnded(conf.getParticipants().get(0));
249 } catch (RemoteException e) {
250 e.printStackTrace();
251 }
252
253 } else {
254 mCallbacks.onCallEnded(b.associated_call);
255 }
alisiondf1dac92013-06-27 17:35:53 -0400256 bubbleRemoved(b);
257 return true;
258 }
259 }, hangup_icon));
260
261 // if (conf.hasMultipleParticipants()) {
262 // model.addAttractor(new Attractor(new PointF(model.width / 1.1f, model.height * .9f), ATTRACTOR_SIZE, new Attractor.Callback() {
263 // @Override
264 // public boolean onBubbleSucked(Bubble b) {
265 //
266 // try {
267 // mCallbacks.getService().detachParticipant(b.associated_call.getCallId());
268 // } catch (RemoteException e) {
269 // e.printStackTrace();
270 // }
271 //
272 // bubbleRemoved(b);
273 // return true;
274 // }
275 // }, separate_icon));
276 // }
277
278 // if(mCalls.size() == 1 && mCalls.get(0).isOnHold()){
279 // mCallbacks.onCallResumed(mCalls.get(0));
280 // }
alision84813a12013-05-27 17:40:39 -0400281
alision1005ba12013-06-19 13:52:44 -0400282 }
alision85704182013-05-29 15:23:03 -0400283
alision1005ba12013-06-19 13:52:44 -0400284 private void initIncomingCallDisplay() {
285 Log.i(TAG, "Start incoming display");
alision84813a12013-05-27 17:40:39 -0400286
alisiondf1dac92013-06-27 17:35:53 -0400287 callStatusTxt.setText("Incoming call");
alision84813a12013-05-27 17:40:39 -0400288
alisiondf1dac92013-06-27 17:35:53 -0400289 getBubbleFor(conf.getParticipants().get(0), model.width / 2, model.height / 2);
alision85704182013-05-29 15:23:03 -0400290
alision1005ba12013-06-19 13:52:44 -0400291 model.clearAttractors();
292 model.addAttractor(new Attractor(new PointF(4 * model.width / 5, model.height / 2), ATTRACTOR_SIZE, new Attractor.Callback() {
293 @Override
294 public boolean onBubbleSucked(Bubble b) {
alisiondf1dac92013-06-27 17:35:53 -0400295 mCallbacks.onCallAccepted(conf.getParticipants().get(0));
alision1005ba12013-06-19 13:52:44 -0400296 return false;
297 }
298 }, call_icon));
299 model.addAttractor(new Attractor(new PointF(model.width / 5, model.height / 2), ATTRACTOR_SIZE, new Attractor.Callback() {
300 @Override
301 public boolean onBubbleSucked(Bubble b) {
alisiondf1dac92013-06-27 17:35:53 -0400302 mCallbacks.onCallRejected(conf.getParticipants().get(0));
alision1005ba12013-06-19 13:52:44 -0400303 bubbleRemoved(b);
304 return true;
305 }
306 }, hangup_icon));
307 }
alision85704182013-05-29 15:23:03 -0400308
alision1005ba12013-06-19 13:52:44 -0400309 private void initOutGoingCallDisplay() {
310 Log.i(TAG, "Start outgoing display");
alision85704182013-05-29 15:23:03 -0400311
alision1005ba12013-06-19 13:52:44 -0400312 callStatusTxt.setText("Calling...");
alision85704182013-05-29 15:23:03 -0400313
alision465ceba2013-07-04 09:24:30 -0400314 getBubbleFor(myself, model.width / 2, (float) (model.height / 1.2));
alision85704182013-05-29 15:23:03 -0400315
alisiondf1dac92013-06-27 17:35:53 -0400316 // TODO off-thread image loading
317 int angle_part = 360 / conf.getParticipants().size();
318 double dX = 0;
319 double dY = 0;
alision465ceba2013-07-04 09:24:30 -0400320 int radiusCalls = (int) ((model.width / 2 - BUBBLE_SIZE));
alisiondf1dac92013-06-27 17:35:53 -0400321 for (int i = 0; i < conf.getParticipants().size(); ++i) {
322 dX = Math.cos(Math.toRadians(angle_part * i - 90)) * radiusCalls;
323 dY = Math.sin(Math.toRadians(angle_part * i - 90)) * radiusCalls;
324 getBubbleFor(conf.getParticipants().get(i), (int) (model.width / 2 + dX), (int) (model.height / 2 + dY));
325 }
alision907bde72013-06-20 14:40:37 -0400326
alision1005ba12013-06-19 13:52:44 -0400327 model.clearAttractors();
alision806e18e2013-06-21 15:30:17 -0400328 model.addAttractor(new Attractor(new PointF(model.width / 1.1f, model.height * .1f), 40, new Attractor.Callback() {
alision1005ba12013-06-19 13:52:44 -0400329 @Override
330 public boolean onBubbleSucked(Bubble b) {
331 Log.w(TAG, "Bubble sucked ! ");
alisiondf1dac92013-06-27 17:35:53 -0400332 mCallbacks.onCallEnded(conf.getParticipants().get(0));
alision1005ba12013-06-19 13:52:44 -0400333 bubbleRemoved(b);
334 return true;
335 }
336 }, hangup_icon));
337 }
alision85704182013-05-29 15:23:03 -0400338
alision1005ba12013-06-19 13:52:44 -0400339 /**
340 * Retrieves or create a bubble for a given contact. If the bubble exists, it is moved to the new location.
341 *
alision806e18e2013-06-21 15:30:17 -0400342 * @param call
343 * The call associated to a contact
alision1005ba12013-06-19 13:52:44 -0400344 * @param x
345 * Initial or new x position.
346 * @param y
347 * Initial or new y position.
348 * @return Bubble corresponding to the contact.
349 */
alision806e18e2013-06-21 15:30:17 -0400350 private Bubble getBubbleFor(SipCall call, float x, float y) {
alisiondf1dac92013-06-27 17:35:53 -0400351 Bubble contact_bubble = model.getBubble(call);
alision1005ba12013-06-19 13:52:44 -0400352 if (contact_bubble != null) {
353 contact_bubble.attractor.set(x, y);
354 return contact_bubble;
355 }
alision84813a12013-05-27 17:40:39 -0400356
alision34673e62013-06-25 14:40:07 -0400357 contact_bubble = new Bubble(getActivity(), call, x, y, BUBBLE_SIZE);
alision84813a12013-05-27 17:40:39 -0400358
alision1005ba12013-06-19 13:52:44 -0400359 model.addBubble(contact_bubble);
alision1005ba12013-06-19 13:52:44 -0400360 return contact_bubble;
361 }
Adrien Béraud0c9bd8f2013-05-30 16:16:57 +1000362
alision1005ba12013-06-19 13:52:44 -0400363 /**
364 * Should be called when a bubble is removed from the model
365 */
366 void bubbleRemoved(Bubble b) {
alision806e18e2013-06-21 15:30:17 -0400367 if (b.associated_call == null) {
alision1005ba12013-06-19 13:52:44 -0400368 return;
369 }
alision1005ba12013-06-19 13:52:44 -0400370 }
Adrien Béraudc9c424d2013-05-30 17:47:35 +1000371
alision1005ba12013-06-19 13:52:44 -0400372 public void changeCallState(String callID, String newState) {
alisioncd8fb912013-06-28 14:43:51 -0400373 Log.w(TAG, "Call :" + callID + newState);
alisiondf1dac92013-06-27 17:35:53 -0400374 if (newState.contentEquals("FAILURE")) {
375 try {
376 mCallbacks.getService().hangUp(callID);
377 } catch (RemoteException e) {
378 e.printStackTrace();
alision806e18e2013-06-21 15:30:17 -0400379 }
alision1005ba12013-06-19 13:52:44 -0400380 }
alisiondf1dac92013-06-27 17:35:53 -0400381 if (conf.getParticipants() == null) {
alisioncd8fb912013-06-28 14:43:51 -0400382 Log.w(TAG, "IT IS NULL");
alisiondf1dac92013-06-27 17:35:53 -0400383 return;
384 }
385
alisioncd8fb912013-06-28 14:43:51 -0400386 Log.w(TAG, "conf.getParticipants().size():" + conf.getParticipants().size());
alisiondf1dac92013-06-27 17:35:53 -0400387 for (int i = 0; i < conf.getParticipants().size(); ++i) {
388 // conf.getParticipants().get(i).printCallInfo();
alisioncd8fb912013-06-28 14:43:51 -0400389 Log.w(TAG, "Call id:" + conf.getParticipants().get(i).getCallId());
390 Log.w(TAG, "Searching:" + callID);
alisiondf1dac92013-06-27 17:35:53 -0400391 if (callID.equals(conf.getParticipants().get(i).getCallId())) {
392 if (newState.contentEquals("HUNGUP")) {
alisioncd8fb912013-06-28 14:43:51 -0400393 Log.w(TAG, "Call hungup:" + conf.getParticipants().get(i).getContact().getmDisplayName());
alisiondf1dac92013-06-27 17:35:53 -0400394 model.removeBubble(conf.getParticipants().get(i));
395 conf.getParticipants().remove(i);
396 } else {
alisioncd8fb912013-06-28 14:43:51 -0400397 Log.w(TAG, "Call:" + conf.getParticipants().get(i).getContact().getmDisplayName() + " state:" + newState);
alisiondf1dac92013-06-27 17:35:53 -0400398 conf.getParticipants().get(i).setCallState(newState);
399 }
400 }
401 }
402
403 if (conf.isOnGoing())
404 initNormalStateDisplay();
405
406 if (conf.getParticipants().size() == 0) {
407 mCallbacks.replaceCurrentCallDisplayed();
408 }
409
alision1005ba12013-06-19 13:52:44 -0400410 }
alision84813a12013-05-27 17:40:39 -0400411
alision1005ba12013-06-19 13:52:44 -0400412 public boolean draggingBubble() {
413 return view == null ? false : view.isDraggingBubble();
414 }
Adrien Béraudc9c424d2013-05-30 17:47:35 +1000415
alision1005ba12013-06-19 13:52:44 -0400416 @Override
417 public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
Adrien Béraud13cde0b2013-05-30 20:27:20 +1000418
alisiondf1dac92013-06-27 17:35:53 -0400419 if (conf.getParticipants().size() == 1) {
Adrien Béraud13cde0b2013-05-30 20:27:20 +1000420
alisiondf1dac92013-06-27 17:35:53 -0400421 if (conf.getParticipants().get(0).isIncoming() && conf.getParticipants().get(0).isRinging()) {
alision806e18e2013-06-21 15:30:17 -0400422 initIncomingCallDisplay();
423 } else {
alisiondf1dac92013-06-27 17:35:53 -0400424 if (conf.getParticipants().get(0).isRinging()) {
alision1005ba12013-06-19 13:52:44 -0400425 initOutGoingCallDisplay();
426 }
alision806e18e2013-06-21 15:30:17 -0400427 try {
alisiondf1dac92013-06-27 17:35:53 -0400428 if (conf.getParticipants().get(0).isOutGoing()
429 && mCallbacks.getService().getCall(conf.getParticipants().get(0).getCallId()) == null) {
430 mCallbacks.getService().placeCall(conf.getParticipants().get(0));
alision806e18e2013-06-21 15:30:17 -0400431 initOutGoingCallDisplay();
alisiondf1dac92013-06-27 17:35:53 -0400432 } else if (conf.getParticipants().get(0).isOutGoing() && conf.getParticipants().get(0).isRinging()) {
alision806e18e2013-06-21 15:30:17 -0400433 initOutGoingCallDisplay();
434 }
435 } catch (RemoteException e) {
436 Log.e(TAG, e.toString());
437 }
alision1005ba12013-06-19 13:52:44 -0400438 }
Adrien Béraud13cde0b2013-05-30 20:27:20 +1000439
alisiondf1dac92013-06-27 17:35:53 -0400440 if (conf.getParticipants().get(0).isOngoing()) {
alision806e18e2013-06-21 15:30:17 -0400441 initNormalStateDisplay();
442 }
alisiondf1dac92013-06-27 17:35:53 -0400443 } else if (conf.getParticipants().size() > 1) {
alision1005ba12013-06-19 13:52:44 -0400444 initNormalStateDisplay();
445 }
Adrien Béraud13cde0b2013-05-30 20:27:20 +1000446
alision1005ba12013-06-19 13:52:44 -0400447 }
Adrien Béraud13cde0b2013-05-30 20:27:20 +1000448
alision1005ba12013-06-19 13:52:44 -0400449 @Override
450 public void surfaceCreated(SurfaceHolder holder) {
451 }
Adrien Béraud13cde0b2013-05-30 20:27:20 +1000452
alision1005ba12013-06-19 13:52:44 -0400453 @Override
454 public void surfaceDestroyed(SurfaceHolder holder) {
455 }
Adrien Béraud13cde0b2013-05-30 20:27:20 +1000456
alisione38001f2013-06-04 14:14:39 -0400457 public BubblesView getBubbleView() {
458 return view;
alisione38001f2013-06-04 14:14:39 -0400459
alision1005ba12013-06-19 13:52:44 -0400460 }
alision84813a12013-05-27 17:40:39 -0400461
alision84813a12013-05-27 17:40:39 -0400462}