blob: 13baa153211c66614365a7f9b658c5814d093812 [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);
alisionf57d8a62013-07-02 09:37:12 -040084 BUBBLE_SIZE = 50 * getResources().getDisplayMetrics().density;
alision1005ba12013-06-19 13:52:44 -040085 }
alision85992112013-05-29 12:18:08 -040086
alision1005ba12013-06-19 13:52:44 -040087 /**
88 * A dummy implementation of the {@link Callbacks} interface that does nothing. Used only when this fragment is not attached to an activity.
89 */
90 private static Callbacks sDummyCallbacks = new Callbacks() {
91 @Override
92 public void onSendMessage(SipCall call, String msg) {
93 }
alision85992112013-05-29 12:18:08 -040094
alision1005ba12013-06-19 13:52:44 -040095 @Override
96 public void callContact(SipCall call) {
97 }
alision85992112013-05-29 12:18:08 -040098
alision1005ba12013-06-19 13:52:44 -040099 @Override
100 public void onCallAccepted(SipCall call) {
101 }
alision85704182013-05-29 15:23:03 -0400102
alision1005ba12013-06-19 13:52:44 -0400103 @Override
104 public void onCallRejected(SipCall call) {
105 }
alision85992112013-05-29 12:18:08 -0400106
alision1005ba12013-06-19 13:52:44 -0400107 @Override
108 public void onCallEnded(SipCall call) {
109 }
alision85704182013-05-29 15:23:03 -0400110
alision1005ba12013-06-19 13:52:44 -0400111 @Override
112 public void onCallSuspended(SipCall call) {
113 }
alision85992112013-05-29 12:18:08 -0400114
alision1005ba12013-06-19 13:52:44 -0400115 @Override
116 public void onCallResumed(SipCall call) {
117 }
alision85704182013-05-29 15:23:03 -0400118
alision1005ba12013-06-19 13:52:44 -0400119 @Override
120 public void onCalltransfered(SipCall call, String to) {
121 }
alision85992112013-05-29 12:18:08 -0400122
alision1005ba12013-06-19 13:52:44 -0400123 @Override
124 public void onRecordCall(SipCall call) {
125 }
alision85704182013-05-29 15:23:03 -0400126
alision1005ba12013-06-19 13:52:44 -0400127 @Override
128 public ISipService getService() {
129 return null;
130 }
alisiondf1dac92013-06-27 17:35:53 -0400131
132 @Override
133 public void replaceCurrentCallDisplayed() {
134 }
alision1005ba12013-06-19 13:52:44 -0400135 };
alision907bde72013-06-20 14:40:37 -0400136
alision1005ba12013-06-19 13:52:44 -0400137 /**
138 * The Activity calling this fragment has to implement this interface
139 *
140 */
141 public interface Callbacks {
alision85992112013-05-29 12:18:08 -0400142
alision1005ba12013-06-19 13:52:44 -0400143 public ISipService getService();
alision85704182013-05-29 15:23:03 -0400144
alision1005ba12013-06-19 13:52:44 -0400145 public void callContact(SipCall call);
alision85992112013-05-29 12:18:08 -0400146
alision1005ba12013-06-19 13:52:44 -0400147 public void onCallAccepted(SipCall call);
alision85704182013-05-29 15:23:03 -0400148
alision1005ba12013-06-19 13:52:44 -0400149 public void onCallRejected(SipCall call);
alision85992112013-05-29 12:18:08 -0400150
alision1005ba12013-06-19 13:52:44 -0400151 public void onCallEnded(SipCall call);
alision85704182013-05-29 15:23:03 -0400152
alision1005ba12013-06-19 13:52:44 -0400153 public void onCallSuspended(SipCall call);
alision85704182013-05-29 15:23:03 -0400154
alision1005ba12013-06-19 13:52:44 -0400155 public void onCallResumed(SipCall call);
alision84813a12013-05-27 17:40:39 -0400156
alision1005ba12013-06-19 13:52:44 -0400157 public void onCalltransfered(SipCall call, String to);
alision84813a12013-05-27 17:40:39 -0400158
alision1005ba12013-06-19 13:52:44 -0400159 public void onRecordCall(SipCall call);
alision85704182013-05-29 15:23:03 -0400160
alision1005ba12013-06-19 13:52:44 -0400161 public void onSendMessage(SipCall call, String msg);
alisiondf1dac92013-06-27 17:35:53 -0400162
163 public void replaceCurrentCallDisplayed();
alision1005ba12013-06-19 13:52:44 -0400164 }
alision85992112013-05-29 12:18:08 -0400165
alision1005ba12013-06-19 13:52:44 -0400166 @Override
167 public void onAttach(Activity activity) {
168 super.onAttach(activity);
alision85992112013-05-29 12:18:08 -0400169
alision1005ba12013-06-19 13:52:44 -0400170 if (!(activity instanceof Callbacks)) {
171 throw new IllegalStateException("Activity must implement fragment's callbacks.");
172 }
alision85992112013-05-29 12:18:08 -0400173
alision1005ba12013-06-19 13:52:44 -0400174 // rootView.requestDisallowInterceptTouchEvent(true);
alision85992112013-05-29 12:18:08 -0400175
alision1005ba12013-06-19 13:52:44 -0400176 mCallbacks = (Callbacks) activity;
alision50fa0722013-06-25 17:29:44 -0400177 myself = SipCall.SipCallBuilder.buildMyselfCall(activity.getContentResolver(), "Me");
alision85992112013-05-29 12:18:08 -0400178
alision1005ba12013-06-19 13:52:44 -0400179 }
alision85992112013-05-29 12:18:08 -0400180
alision1005ba12013-06-19 13:52:44 -0400181 @Override
182 public void onDetach() {
183 super.onDetach();
184 mCallbacks = sDummyCallbacks;
185 // rootView.requestDisallowInterceptTouchEvent(false);
186 }
alision907bde72013-06-20 14:40:37 -0400187
alision1005ba12013-06-19 13:52:44 -0400188 @Override
alision907bde72013-06-20 14:40:37 -0400189 public void onStop() {
alision1005ba12013-06-19 13:52:44 -0400190 super.onStop();
191 }
alision85992112013-05-29 12:18:08 -0400192
alision1005ba12013-06-19 13:52:44 -0400193 @Override
194 public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
195 ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.frag_call, container, false);
alision85992112013-05-29 12:18:08 -0400196
alision1005ba12013-06-19 13:52:44 -0400197 view = (BubblesView) rootView.findViewById(R.id.main_view);
alision34673e62013-06-25 14:40:07 -0400198 view.setFragment(this);
alision1005ba12013-06-19 13:52:44 -0400199 view.setModel(model);
200 view.getHolder().addCallback(this);
alision84813a12013-05-27 17:40:39 -0400201
alision50fa0722013-06-25 17:29:44 -0400202 callStatusTxt = (CounterTextView) rootView.findViewById(R.id.call_status_txt);
alision84813a12013-05-27 17:40:39 -0400203
alision1005ba12013-06-19 13:52:44 -0400204 hangup_icon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_hangup);
205 call_icon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_call);
alisiondf1dac92013-06-27 17:35:53 -0400206 separate_icon = BitmapFactory.decodeResource(getResources(), R.drawable.icon_separate);
alision84813a12013-05-27 17:40:39 -0400207
alision1005ba12013-06-19 13:52:44 -0400208 // Do nothing here, the view is not initialized yet.
209 return rootView;
210 }
alision85992112013-05-29 12:18:08 -0400211
alision1005ba12013-06-19 13:52:44 -0400212 private void initNormalStateDisplay() {
213 Log.i(TAG, "Start normal display");
alision84813a12013-05-27 17:40:39 -0400214
alision1005ba12013-06-19 13:52:44 -0400215 callStatusTxt.setText("0 min");
alision84813a12013-05-27 17:40:39 -0400216
alision1005ba12013-06-19 13:52:44 -0400217 getBubbleFor(myself, model.width / 2, model.height / 2);
alision907bde72013-06-20 14:40:37 -0400218
alisiondf1dac92013-06-27 17:35:53 -0400219 int angle_part = 360 / conf.getParticipants().size();
alision806e18e2013-06-21 15:30:17 -0400220 double dX = 0;
221 double dY = 0;
222 int radiusCalls = model.width / 2 - 150;
alisiondf1dac92013-06-27 17:35:53 -0400223 for (int i = 0; i < conf.getParticipants().size(); ++i) {
224
225 if (conf.getParticipants().get(i) == null) {
226 Log.i(TAG, i + " null ");
227 continue;
228 }
alision34673e62013-06-25 14:40:07 -0400229 dX = Math.cos(Math.toRadians(angle_part * i - 90)) * radiusCalls;
230 dY = Math.sin(Math.toRadians(angle_part * i - 90)) * radiusCalls;
alisiondf1dac92013-06-27 17:35:53 -0400231 getBubbleFor(conf.getParticipants().get(i), (int) (model.width / 2 + dX), (int) (model.height / 2 + dY));
alision806e18e2013-06-21 15:30:17 -0400232 }
alision1005ba12013-06-19 13:52:44 -0400233
234 model.clearAttractors();
alisiondf1dac92013-06-27 17:35:53 -0400235 model.addAttractor(new Attractor(new PointF(model.width / 1.1f, model.height * .1f), ATTRACTOR_SIZE, new Attractor.Callback() {
236 @Override
237 public boolean onBubbleSucked(Bubble b) {
238 Log.w(TAG, "Bubble sucked ! ");
239
alisioncd8fb912013-06-28 14:43:51 -0400240 if (b.associated_call.getContact().isUser()) {
alisiondf1dac92013-06-27 17:35:53 -0400241
alisioncd8fb912013-06-28 14:43:51 -0400242 try {
243 if (conf.hasMultipleParticipants())
244 mCallbacks.getService().hangUpConference(conf.getId());
245 else
246 mCallbacks.onCallEnded(conf.getParticipants().get(0));
247 } catch (RemoteException e) {
248 e.printStackTrace();
249 }
250
251 } else {
252 mCallbacks.onCallEnded(b.associated_call);
253 }
alisiondf1dac92013-06-27 17:35:53 -0400254 bubbleRemoved(b);
255 return true;
256 }
257 }, hangup_icon));
258
259 // if (conf.hasMultipleParticipants()) {
260 // model.addAttractor(new Attractor(new PointF(model.width / 1.1f, model.height * .9f), ATTRACTOR_SIZE, new Attractor.Callback() {
261 // @Override
262 // public boolean onBubbleSucked(Bubble b) {
263 //
264 // try {
265 // mCallbacks.getService().detachParticipant(b.associated_call.getCallId());
266 // } catch (RemoteException e) {
267 // e.printStackTrace();
268 // }
269 //
270 // bubbleRemoved(b);
271 // return true;
272 // }
273 // }, separate_icon));
274 // }
275
276 // if(mCalls.size() == 1 && mCalls.get(0).isOnHold()){
277 // mCallbacks.onCallResumed(mCalls.get(0));
278 // }
alision84813a12013-05-27 17:40:39 -0400279
alision1005ba12013-06-19 13:52:44 -0400280 }
alision85704182013-05-29 15:23:03 -0400281
alision1005ba12013-06-19 13:52:44 -0400282 private void initIncomingCallDisplay() {
283 Log.i(TAG, "Start incoming display");
alision84813a12013-05-27 17:40:39 -0400284
alisiondf1dac92013-06-27 17:35:53 -0400285 callStatusTxt.setText("Incoming call");
alision84813a12013-05-27 17:40:39 -0400286
alisiondf1dac92013-06-27 17:35:53 -0400287 getBubbleFor(conf.getParticipants().get(0), model.width / 2, model.height / 2);
alision85704182013-05-29 15:23:03 -0400288
alision1005ba12013-06-19 13:52:44 -0400289 model.clearAttractors();
290 model.addAttractor(new Attractor(new PointF(4 * model.width / 5, model.height / 2), ATTRACTOR_SIZE, new Attractor.Callback() {
291 @Override
292 public boolean onBubbleSucked(Bubble b) {
alisiondf1dac92013-06-27 17:35:53 -0400293 mCallbacks.onCallAccepted(conf.getParticipants().get(0));
alision1005ba12013-06-19 13:52:44 -0400294 return false;
295 }
296 }, call_icon));
297 model.addAttractor(new Attractor(new PointF(model.width / 5, model.height / 2), ATTRACTOR_SIZE, new Attractor.Callback() {
298 @Override
299 public boolean onBubbleSucked(Bubble b) {
alisiondf1dac92013-06-27 17:35:53 -0400300 mCallbacks.onCallRejected(conf.getParticipants().get(0));
alision1005ba12013-06-19 13:52:44 -0400301 bubbleRemoved(b);
302 return true;
303 }
304 }, hangup_icon));
305 }
alision85704182013-05-29 15:23:03 -0400306
alision1005ba12013-06-19 13:52:44 -0400307 private void initOutGoingCallDisplay() {
308 Log.i(TAG, "Start outgoing display");
alision85704182013-05-29 15:23:03 -0400309
alision1005ba12013-06-19 13:52:44 -0400310 callStatusTxt.setText("Calling...");
alision85704182013-05-29 15:23:03 -0400311
alision1005ba12013-06-19 13:52:44 -0400312 getBubbleFor(myself, model.width / 2, model.height / 2);
alision85704182013-05-29 15:23:03 -0400313
alisiondf1dac92013-06-27 17:35:53 -0400314 // TODO off-thread image loading
315 int angle_part = 360 / conf.getParticipants().size();
316 double dX = 0;
317 double dY = 0;
318 int radiusCalls = model.width / 2 - 150;
319 for (int i = 0; i < conf.getParticipants().size(); ++i) {
320 dX = Math.cos(Math.toRadians(angle_part * i - 90)) * radiusCalls;
321 dY = Math.sin(Math.toRadians(angle_part * i - 90)) * radiusCalls;
322 getBubbleFor(conf.getParticipants().get(i), (int) (model.width / 2 + dX), (int) (model.height / 2 + dY));
323 }
alision907bde72013-06-20 14:40:37 -0400324
alision1005ba12013-06-19 13:52:44 -0400325 model.clearAttractors();
alision806e18e2013-06-21 15:30:17 -0400326 model.addAttractor(new Attractor(new PointF(model.width / 1.1f, model.height * .1f), 40, new Attractor.Callback() {
alision1005ba12013-06-19 13:52:44 -0400327 @Override
328 public boolean onBubbleSucked(Bubble b) {
329 Log.w(TAG, "Bubble sucked ! ");
alisiondf1dac92013-06-27 17:35:53 -0400330 mCallbacks.onCallEnded(conf.getParticipants().get(0));
alision1005ba12013-06-19 13:52:44 -0400331 bubbleRemoved(b);
332 return true;
333 }
334 }, hangup_icon));
335 }
alision85704182013-05-29 15:23:03 -0400336
alision1005ba12013-06-19 13:52:44 -0400337 /**
338 * Retrieves or create a bubble for a given contact. If the bubble exists, it is moved to the new location.
339 *
alision806e18e2013-06-21 15:30:17 -0400340 * @param call
341 * The call associated to a contact
alision1005ba12013-06-19 13:52:44 -0400342 * @param x
343 * Initial or new x position.
344 * @param y
345 * Initial or new y position.
346 * @return Bubble corresponding to the contact.
347 */
alision806e18e2013-06-21 15:30:17 -0400348 private Bubble getBubbleFor(SipCall call, float x, float y) {
alisiondf1dac92013-06-27 17:35:53 -0400349 Bubble contact_bubble = model.getBubble(call);
alision1005ba12013-06-19 13:52:44 -0400350 if (contact_bubble != null) {
351 contact_bubble.attractor.set(x, y);
352 return contact_bubble;
353 }
alision84813a12013-05-27 17:40:39 -0400354
alision34673e62013-06-25 14:40:07 -0400355 contact_bubble = new Bubble(getActivity(), call, x, y, BUBBLE_SIZE);
alision84813a12013-05-27 17:40:39 -0400356
alision1005ba12013-06-19 13:52:44 -0400357 model.addBubble(contact_bubble);
alision1005ba12013-06-19 13:52:44 -0400358 return contact_bubble;
359 }
Adrien Béraud0c9bd8f2013-05-30 16:16:57 +1000360
alision1005ba12013-06-19 13:52:44 -0400361 /**
362 * Should be called when a bubble is removed from the model
363 */
364 void bubbleRemoved(Bubble b) {
alision806e18e2013-06-21 15:30:17 -0400365 if (b.associated_call == null) {
alision1005ba12013-06-19 13:52:44 -0400366 return;
367 }
alision1005ba12013-06-19 13:52:44 -0400368 }
Adrien Béraudc9c424d2013-05-30 17:47:35 +1000369
alision1005ba12013-06-19 13:52:44 -0400370 public void changeCallState(String callID, String newState) {
alisioncd8fb912013-06-28 14:43:51 -0400371 Log.w(TAG, "Call :" + callID + newState);
alisiondf1dac92013-06-27 17:35:53 -0400372 if (newState.contentEquals("FAILURE")) {
373 try {
374 mCallbacks.getService().hangUp(callID);
375 } catch (RemoteException e) {
376 e.printStackTrace();
alision806e18e2013-06-21 15:30:17 -0400377 }
alision1005ba12013-06-19 13:52:44 -0400378 }
alisiondf1dac92013-06-27 17:35:53 -0400379 if (conf.getParticipants() == null) {
alisioncd8fb912013-06-28 14:43:51 -0400380 Log.w(TAG, "IT IS NULL");
alisiondf1dac92013-06-27 17:35:53 -0400381 return;
382 }
383
alisioncd8fb912013-06-28 14:43:51 -0400384 Log.w(TAG, "conf.getParticipants().size():" + conf.getParticipants().size());
alisiondf1dac92013-06-27 17:35:53 -0400385 for (int i = 0; i < conf.getParticipants().size(); ++i) {
386 // conf.getParticipants().get(i).printCallInfo();
alisioncd8fb912013-06-28 14:43:51 -0400387 Log.w(TAG, "Call id:" + conf.getParticipants().get(i).getCallId());
388 Log.w(TAG, "Searching:" + callID);
alisiondf1dac92013-06-27 17:35:53 -0400389 if (callID.equals(conf.getParticipants().get(i).getCallId())) {
390 if (newState.contentEquals("HUNGUP")) {
alisioncd8fb912013-06-28 14:43:51 -0400391 Log.w(TAG, "Call hungup:" + conf.getParticipants().get(i).getContact().getmDisplayName());
alisiondf1dac92013-06-27 17:35:53 -0400392 model.removeBubble(conf.getParticipants().get(i));
393 conf.getParticipants().remove(i);
394 } else {
alisioncd8fb912013-06-28 14:43:51 -0400395 Log.w(TAG, "Call:" + conf.getParticipants().get(i).getContact().getmDisplayName() + " state:" + newState);
alisiondf1dac92013-06-27 17:35:53 -0400396 conf.getParticipants().get(i).setCallState(newState);
397 }
398 }
399 }
400
401 if (conf.isOnGoing())
402 initNormalStateDisplay();
403
404 if (conf.getParticipants().size() == 0) {
405 mCallbacks.replaceCurrentCallDisplayed();
406 }
407
alision1005ba12013-06-19 13:52:44 -0400408 }
alision84813a12013-05-27 17:40:39 -0400409
alision1005ba12013-06-19 13:52:44 -0400410 public boolean draggingBubble() {
411 return view == null ? false : view.isDraggingBubble();
412 }
Adrien Béraudc9c424d2013-05-30 17:47:35 +1000413
alision1005ba12013-06-19 13:52:44 -0400414 @Override
415 public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
alision806e18e2013-06-21 15:30:17 -0400416 // Log.i(TAG, "Init fragment " + mCall.getCallId());
Adrien Béraud13cde0b2013-05-30 20:27:20 +1000417
alision806e18e2013-06-21 15:30:17 -0400418 // mCall.printCallInfo();
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}