alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 1 | /* |
alision | 2ec64f9 | 2013-06-17 17:28:58 -0400 | [diff] [blame] | 2 | * Copyright (C) 2004-2013 Savoir-Faire Linux Inc. |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 3 | * |
| 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 | |
Alexandre Lision | 064e1e0 | 2013-10-01 16:18:42 -0400 | [diff] [blame] | 32 | package org.sflphone.fragments; |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 33 | |
Alexandre Lision | 2b23792 | 2013-09-09 16:23:02 -0400 | [diff] [blame] | 34 | import java.util.ArrayList; |
Alexandre Lision | 31f46fc | 2013-09-26 11:19:54 -0400 | [diff] [blame] | 35 | import java.util.Locale; |
Alexandre Lision | 2b23792 | 2013-09-09 16:23:02 -0400 | [diff] [blame] | 36 | |
Alexandre Lision | 064e1e0 | 2013-10-01 16:18:42 -0400 | [diff] [blame] | 37 | import org.sflphone.R; |
| 38 | import org.sflphone.model.Attractor; |
| 39 | import org.sflphone.model.Bubble; |
Alexandre Lision | 40954dc | 2013-10-09 15:24:03 -0400 | [diff] [blame] | 40 | import org.sflphone.model.BubbleContact; |
Alexandre Lision | 064e1e0 | 2013-10-01 16:18:42 -0400 | [diff] [blame] | 41 | import org.sflphone.model.BubbleModel; |
Alexandre Lision | 40954dc | 2013-10-09 15:24:03 -0400 | [diff] [blame] | 42 | import org.sflphone.model.BubbleUser; |
Alexandre Lision | 064e1e0 | 2013-10-01 16:18:42 -0400 | [diff] [blame] | 43 | import org.sflphone.model.BubblesView; |
Alexandre Lision | 6885547 | 2013-10-10 16:20:46 -0400 | [diff] [blame] | 44 | import org.sflphone.model.CallContact; |
Alexandre Lision | 064e1e0 | 2013-10-01 16:18:42 -0400 | [diff] [blame] | 45 | import org.sflphone.model.Conference; |
| 46 | import org.sflphone.model.SipCall; |
| 47 | import org.sflphone.service.ISipService; |
| 48 | |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 49 | import android.app.Activity; |
| 50 | import android.app.Fragment; |
Alexandre Lision | 2b23792 | 2013-09-09 16:23:02 -0400 | [diff] [blame] | 51 | import android.app.FragmentManager; |
Alexandre Lision | f1850c0 | 2013-09-23 14:19:34 -0400 | [diff] [blame] | 52 | import android.content.Context; |
Alexandre Lision | 2b23792 | 2013-09-09 16:23:02 -0400 | [diff] [blame] | 53 | import android.content.Intent; |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 54 | import android.graphics.Bitmap; |
Adrien Béraud | 0c9bd8f | 2013-05-30 16:16:57 +1000 | [diff] [blame] | 55 | import android.graphics.BitmapFactory; |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 56 | import android.graphics.PointF; |
| 57 | import android.os.Bundle; |
| 58 | import android.os.RemoteException; |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 59 | import android.util.Log; |
Alexandre Lision | 64dc8c0 | 2013-09-25 15:32:25 -0400 | [diff] [blame] | 60 | import android.view.KeyEvent; |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 61 | import android.view.LayoutInflater; |
Alexandre Lision | d588bff | 2013-10-08 12:43:01 -0400 | [diff] [blame] | 62 | import android.view.Menu; |
| 63 | import android.view.MenuInflater; |
| 64 | import android.view.MenuItem; |
Adrien Béraud | 13cde0b | 2013-05-30 20:27:20 +1000 | [diff] [blame] | 65 | import android.view.SurfaceHolder; |
| 66 | import android.view.SurfaceHolder.Callback; |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 67 | import android.view.View; |
Alexandre Lision | 84208a3 | 2013-09-25 13:18:37 -0400 | [diff] [blame] | 68 | import android.view.View.OnClickListener; |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 69 | import android.view.ViewGroup; |
Alexandre Lision | 84208a3 | 2013-09-25 13:18:37 -0400 | [diff] [blame] | 70 | import android.view.inputmethod.InputMethodManager; |
Alexandre Lision | 3557713 | 2013-12-06 15:21:15 -0500 | [diff] [blame] | 71 | import android.widget.CompoundButton; |
| 72 | import android.widget.CompoundButton.OnCheckedChangeListener; |
Alexandre Lision | 84208a3 | 2013-09-25 13:18:37 -0400 | [diff] [blame] | 73 | import android.widget.ImageButton; |
Alexandre Lision | 3c6b710 | 2013-09-16 16:56:46 -0400 | [diff] [blame] | 74 | import android.widget.TextView; |
Alexandre Lision | 3557713 | 2013-12-06 15:21:15 -0500 | [diff] [blame] | 75 | import android.widget.ToggleButton; |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 76 | |
Alexandre Lision | fda4d1d | 2013-10-25 15:29:53 -0400 | [diff] [blame] | 77 | public class CallFragment extends Fragment implements Callback { |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 78 | |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 79 | static final String TAG = "CallFragment"; |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 80 | |
alision | f57d8a6 | 2013-07-02 09:37:12 -0400 | [diff] [blame] | 81 | float BUBBLE_SIZE = 75; |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 82 | static final float ATTRACTOR_SIZE = 40; |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 83 | |
Alexandre Lision | 2b23792 | 2013-09-09 16:23:02 -0400 | [diff] [blame] | 84 | public static final int REQUEST_TRANSFER = 10; |
| 85 | |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 86 | private Conference conf; |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 87 | |
Alexandre Lision | 3c6b710 | 2013-09-16 16:56:46 -0400 | [diff] [blame] | 88 | private TextView callStatusTxt; |
Alexandre Lision | b8add81 | 2013-10-24 11:42:42 -0400 | [diff] [blame] | 89 | private TextView codecNameTxt; |
Alexandre Lision | cb2345c | 2013-12-09 15:39:13 -0500 | [diff] [blame] | 90 | |
Alexandre Lision | 3557713 | 2013-12-06 15:21:15 -0500 | [diff] [blame] | 91 | private ToggleButton speakers; |
Alexandre Lision | b8add81 | 2013-10-24 11:42:42 -0400 | [diff] [blame] | 92 | |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 93 | private BubblesView view; |
| 94 | private BubbleModel model; |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 95 | |
Alexandre Lision | 6885547 | 2013-10-10 16:20:46 -0400 | [diff] [blame] | 96 | public Callbacks mCallbacks = sDummyCallbacks; |
Alexandre Lision | a764c68 | 2013-09-09 10:02:07 -0400 | [diff] [blame] | 97 | boolean accepted = false; |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 98 | private Bitmap call_icon; |
alision | 8570418 | 2013-05-29 15:23:03 -0400 | [diff] [blame] | 99 | |
Alexandre Lision | 0eb0203 | 2013-09-27 16:32:40 -0400 | [diff] [blame] | 100 | TransferDFragment editName; |
Alexandre Lision | f1850c0 | 2013-09-23 14:19:34 -0400 | [diff] [blame] | 101 | |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 102 | @Override |
| 103 | public void onCreate(Bundle savedBundle) { |
| 104 | super.onCreate(savedBundle); |
Alexandre Lision | dafe951 | 2013-10-28 16:31:41 -0400 | [diff] [blame] | 105 | conf = new Conference((Conference) getArguments().getParcelable("conference")); |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 106 | model = new BubbleModel(getResources().getDisplayMetrics().density); |
alision | 729b0a2 | 2013-07-02 11:57:33 -0400 | [diff] [blame] | 107 | BUBBLE_SIZE = getResources().getDimension(R.dimen.bubble_size); |
Alexandre Lision | a764c68 | 2013-09-09 10:02:07 -0400 | [diff] [blame] | 108 | Log.e(TAG, "BUBBLE_SIZE " + BUBBLE_SIZE); |
Alexandre Lision | d588bff | 2013-10-08 12:43:01 -0400 | [diff] [blame] | 109 | this.setHasOptionsMenu(true); |
alision | 729b0a2 | 2013-07-02 11:57:33 -0400 | [diff] [blame] | 110 | |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 111 | } |
alision | 8599211 | 2013-05-29 12:18:08 -0400 | [diff] [blame] | 112 | |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 113 | /** |
| 114 | * A dummy implementation of the {@link Callbacks} interface that does nothing. Used only when this fragment is not attached to an activity. |
| 115 | */ |
| 116 | private static Callbacks sDummyCallbacks = new Callbacks() { |
alision | 8570418 | 2013-05-29 15:23:03 -0400 | [diff] [blame] | 117 | |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 118 | @Override |
| 119 | public ISipService getService() { |
| 120 | return null; |
| 121 | } |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 122 | |
Alexandre Lision | ccf0c93 | 2013-10-10 16:24:41 -0400 | [diff] [blame] | 123 | @Override |
Alexandre Lision | dafe951 | 2013-10-28 16:31:41 -0400 | [diff] [blame] | 124 | public void terminateCall() { |
Alexandre Lision | ccf0c93 | 2013-10-10 16:24:41 -0400 | [diff] [blame] | 125 | } |
Alexandre Lision | 0c38451 | 2013-09-17 17:15:57 -0400 | [diff] [blame] | 126 | |
| 127 | @Override |
Adrien Béraud | e78d06f | 2013-09-19 13:33:44 +1000 | [diff] [blame] | 128 | public void startTimer() { |
Alexandre Lision | 0c38451 | 2013-09-17 17:15:57 -0400 | [diff] [blame] | 129 | } |
Alexandre Lision | 6885547 | 2013-10-10 16:20:46 -0400 | [diff] [blame] | 130 | |
| 131 | @Override |
Alexandre Lision | b8add81 | 2013-10-24 11:42:42 -0400 | [diff] [blame] | 132 | public void slideChatScreen() { |
Alexandre Lision | 6885547 | 2013-10-10 16:20:46 -0400 | [diff] [blame] | 133 | } |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 134 | }; |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 135 | |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 136 | /** |
| 137 | * The Activity calling this fragment has to implement this interface |
| 138 | * |
| 139 | */ |
| 140 | public interface Callbacks { |
alision | 8599211 | 2013-05-29 12:18:08 -0400 | [diff] [blame] | 141 | |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 142 | public ISipService getService(); |
alision | 8570418 | 2013-05-29 15:23:03 -0400 | [diff] [blame] | 143 | |
Alexandre Lision | 0c38451 | 2013-09-17 17:15:57 -0400 | [diff] [blame] | 144 | public void startTimer(); |
Alexandre Lision | 6885547 | 2013-10-10 16:20:46 -0400 | [diff] [blame] | 145 | |
| 146 | public void slideChatScreen(); |
Alexandre Lision | b8add81 | 2013-10-24 11:42:42 -0400 | [diff] [blame] | 147 | |
Alexandre Lision | dafe951 | 2013-10-28 16:31:41 -0400 | [diff] [blame] | 148 | public void terminateCall(); |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 149 | } |
alision | 8599211 | 2013-05-29 12:18:08 -0400 | [diff] [blame] | 150 | |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 151 | @Override |
| 152 | public void onAttach(Activity activity) { |
| 153 | super.onAttach(activity); |
alision | 8599211 | 2013-05-29 12:18:08 -0400 | [diff] [blame] | 154 | |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 155 | if (!(activity instanceof Callbacks)) { |
| 156 | throw new IllegalStateException("Activity must implement fragment's callbacks."); |
| 157 | } |
alision | 8599211 | 2013-05-29 12:18:08 -0400 | [diff] [blame] | 158 | |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 159 | // rootView.requestDisallowInterceptTouchEvent(true); |
alision | 8599211 | 2013-05-29 12:18:08 -0400 | [diff] [blame] | 160 | |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 161 | mCallbacks = (Callbacks) activity; |
Alexandre Lision | b8add81 | 2013-10-24 11:42:42 -0400 | [diff] [blame] | 162 | // myself = SipCall.SipCallBuilder.buildMyselfCall(activity.getContentResolver(), "Me"); |
Adrien Béraud | e78d06f | 2013-09-19 13:33:44 +1000 | [diff] [blame] | 163 | |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 164 | } |
Alexandre Lision | b8add81 | 2013-10-24 11:42:42 -0400 | [diff] [blame] | 165 | |
Alexandre Lision | d588bff | 2013-10-08 12:43:01 -0400 | [diff] [blame] | 166 | @Override |
| 167 | public void onCreateOptionsMenu(Menu m, MenuInflater inf) { |
| 168 | super.onCreateOptionsMenu(m, inf); |
Alexandre Lision | 6885547 | 2013-10-10 16:20:46 -0400 | [diff] [blame] | 169 | inf.inflate(R.menu.ac_call, m); |
Alexandre Lision | d588bff | 2013-10-08 12:43:01 -0400 | [diff] [blame] | 170 | } |
| 171 | |
| 172 | @Override |
| 173 | public boolean onOptionsItemSelected(MenuItem item) { |
| 174 | super.onOptionsItemSelected(item); |
Alexandre Lision | 666b377 | 2013-10-28 17:42:48 -0400 | [diff] [blame] | 175 | switch (item.getItemId()) { |
| 176 | case R.id.menuitem_chat: |
| 177 | mCallbacks.slideChatScreen(); |
| 178 | break; |
| 179 | } |
Alexandre Lision | d588bff | 2013-10-08 12:43:01 -0400 | [diff] [blame] | 180 | |
| 181 | return true; |
| 182 | } |
alision | 8599211 | 2013-05-29 12:18:08 -0400 | [diff] [blame] | 183 | |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 184 | @Override |
| 185 | public void onDetach() { |
| 186 | super.onDetach(); |
| 187 | mCallbacks = sDummyCallbacks; |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 188 | } |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 189 | |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 190 | @Override |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 191 | public void onStop() { |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 192 | super.onStop(); |
| 193 | } |
alision | 8599211 | 2013-05-29 12:18:08 -0400 | [diff] [blame] | 194 | |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 195 | @Override |
Alexandre Lision | f1850c0 | 2013-09-23 14:19:34 -0400 | [diff] [blame] | 196 | public void onResume() { |
| 197 | super.onResume(); |
Alexandre Lision | f1850c0 | 2013-09-23 14:19:34 -0400 | [diff] [blame] | 198 | } |
| 199 | |
| 200 | @Override |
| 201 | public void onPause() { |
| 202 | super.onPause(); |
Alexandre Lision | f1850c0 | 2013-09-23 14:19:34 -0400 | [diff] [blame] | 203 | } |
| 204 | |
| 205 | @Override |
Alexandre Lision | 2b23792 | 2013-09-09 16:23:02 -0400 | [diff] [blame] | 206 | public void onActivityResult(int requestCode, int resultCode, Intent data) { |
| 207 | super.onActivityResult(requestCode, resultCode, data); |
| 208 | SipCall transfer = null; |
| 209 | if (requestCode == REQUEST_TRANSFER) { |
| 210 | switch (resultCode) { |
Adrien Béraud | e78d06f | 2013-09-19 13:33:44 +1000 | [diff] [blame] | 211 | case TransferDFragment.RESULT_TRANSFER_CONF: |
Alexandre Lision | 2b23792 | 2013-09-09 16:23:02 -0400 | [diff] [blame] | 212 | Conference c = data.getParcelableExtra("target"); |
| 213 | transfer = data.getParcelableExtra("transfer"); |
| 214 | try { |
| 215 | |
| 216 | mCallbacks.getService().attendedTransfer(transfer.getCallId(), c.getParticipants().get(0).getCallId()); |
| 217 | |
| 218 | } catch (RemoteException e) { |
Alexandre Lision | 2b23792 | 2013-09-09 16:23:02 -0400 | [diff] [blame] | 219 | e.printStackTrace(); |
| 220 | } |
Alexandre Lision | 2b23792 | 2013-09-09 16:23:02 -0400 | [diff] [blame] | 221 | break; |
| 222 | |
Adrien Béraud | e78d06f | 2013-09-19 13:33:44 +1000 | [diff] [blame] | 223 | case TransferDFragment.RESULT_TRANSFER_NUMBER: |
Alexandre Lision | 2b23792 | 2013-09-09 16:23:02 -0400 | [diff] [blame] | 224 | String to = data.getStringExtra("to_number"); |
| 225 | transfer = data.getParcelableExtra("transfer"); |
| 226 | try { |
Alexandre Lision | 2b23792 | 2013-09-09 16:23:02 -0400 | [diff] [blame] | 227 | mCallbacks.getService().transfer(transfer.getCallId(), to); |
| 228 | mCallbacks.getService().hangUp(transfer.getCallId()); |
| 229 | } catch (RemoteException e) { |
Alexandre Lision | 2b23792 | 2013-09-09 16:23:02 -0400 | [diff] [blame] | 230 | e.printStackTrace(); |
| 231 | } |
| 232 | break; |
Adrien Béraud | 9751284 | 2013-09-19 13:37:19 +1000 | [diff] [blame] | 233 | case Activity.RESULT_CANCELED: |
Alexandre Lision | 2b23792 | 2013-09-09 16:23:02 -0400 | [diff] [blame] | 234 | default: |
Adrien Béraud | e78d06f | 2013-09-19 13:33:44 +1000 | [diff] [blame] | 235 | model.clear(); |
| 236 | initNormalStateDisplay(); |
Alexandre Lision | 2b23792 | 2013-09-09 16:23:02 -0400 | [diff] [blame] | 237 | break; |
| 238 | } |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | @Override |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 243 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { |
Alexandre Lision | 84208a3 | 2013-09-25 13:18:37 -0400 | [diff] [blame] | 244 | final ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.frag_call, container, false); |
alision | 8599211 | 2013-05-29 12:18:08 -0400 | [diff] [blame] | 245 | |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 246 | view = (BubblesView) rootView.findViewById(R.id.main_view); |
alision | 34673e6 | 2013-06-25 14:40:07 -0400 | [diff] [blame] | 247 | view.setFragment(this); |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 248 | view.setModel(model); |
| 249 | view.getHolder().addCallback(this); |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 250 | |
Alexandre Lision | 4fb2262 | 2013-10-21 16:26:33 -0400 | [diff] [blame] | 251 | codecNameTxt = (TextView) rootView.findViewById(R.id.codec_name_txt); |
Alexandre Lision | 3c6b710 | 2013-09-16 16:56:46 -0400 | [diff] [blame] | 252 | callStatusTxt = (TextView) rootView.findViewById(R.id.call_status_txt); |
Alexandre Lision | 6885547 | 2013-10-10 16:20:46 -0400 | [diff] [blame] | 253 | call_icon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_action_call); |
Alexandre Lision | cb2345c | 2013-12-09 15:39:13 -0500 | [diff] [blame] | 254 | |
Alexandre Lision | baeeb21 | 2013-12-09 12:54:47 -0500 | [diff] [blame] | 255 | speakers = (ToggleButton) rootView.findViewById(R.id.speaker_toggle); |
Alexandre Lision | cb2345c | 2013-12-09 15:39:13 -0500 | [diff] [blame] | 256 | |
Alexandre Lision | 3557713 | 2013-12-06 15:21:15 -0500 | [diff] [blame] | 257 | speakers.setOnCheckedChangeListener(new OnCheckedChangeListener() { |
Alexandre Lision | cb2345c | 2013-12-09 15:39:13 -0500 | [diff] [blame] | 258 | |
Alexandre Lision | 3557713 | 2013-12-06 15:21:15 -0500 | [diff] [blame] | 259 | @Override |
| 260 | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { |
| 261 | try { |
| 262 | mCallbacks.getService().toggleSpeakerPhone(isChecked); |
| 263 | } catch (RemoteException e) { |
| 264 | e.printStackTrace(); |
| 265 | } |
Alexandre Lision | cb2345c | 2013-12-09 15:39:13 -0500 | [diff] [blame] | 266 | |
Alexandre Lision | 3557713 | 2013-12-06 15:21:15 -0500 | [diff] [blame] | 267 | } |
| 268 | }); |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 269 | |
Alexandre Lision | 84208a3 | 2013-09-25 13:18:37 -0400 | [diff] [blame] | 270 | ((ImageButton) rootView.findViewById(R.id.dialpad_btn)).setOnClickListener(new OnClickListener() { |
| 271 | |
| 272 | @Override |
| 273 | public void onClick(View v) { |
| 274 | InputMethodManager lManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); |
| 275 | lManager.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, InputMethodManager.HIDE_IMPLICIT_ONLY); |
| 276 | } |
| 277 | }); |
| 278 | |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 279 | return rootView; |
| 280 | } |
Alexandre Lision | c30e841 | 2013-09-26 15:12:59 -0400 | [diff] [blame] | 281 | |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 282 | private void initNormalStateDisplay() { |
| 283 | Log.i(TAG, "Start normal display"); |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 284 | |
Alexandre Lision | 0c38451 | 2013-09-17 17:15:57 -0400 | [diff] [blame] | 285 | mCallbacks.startTimer(); |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 286 | |
Alexandre Lision | ee2494d | 2013-10-09 17:14:00 -0400 | [diff] [blame] | 287 | getBubbleForUser(conf, model.width / 2, model.height / 2); |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 288 | |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 289 | int angle_part = 360 / conf.getParticipants().size(); |
alision | 806e18e | 2013-06-21 15:30:17 -0400 | [diff] [blame] | 290 | double dX = 0; |
| 291 | double dY = 0; |
alision | 465ceba | 2013-07-04 09:24:30 -0400 | [diff] [blame] | 292 | int radiusCalls = (int) (model.width / 2 - BUBBLE_SIZE); |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 293 | for (int i = 0; i < conf.getParticipants().size(); ++i) { |
| 294 | |
| 295 | if (conf.getParticipants().get(i) == null) { |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 296 | continue; |
| 297 | } |
alision | 34673e6 | 2013-06-25 14:40:07 -0400 | [diff] [blame] | 298 | dX = Math.cos(Math.toRadians(angle_part * i - 90)) * radiusCalls; |
| 299 | dY = Math.sin(Math.toRadians(angle_part * i - 90)) * radiusCalls; |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 300 | getBubbleFor(conf.getParticipants().get(i), (int) (model.width / 2 + dX), (int) (model.height / 2 + dY)); |
alision | 806e18e | 2013-06-21 15:30:17 -0400 | [diff] [blame] | 301 | } |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 302 | |
| 303 | model.clearAttractors(); |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 304 | } |
alision | 8570418 | 2013-05-29 15:23:03 -0400 | [diff] [blame] | 305 | |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 306 | private void initIncomingCallDisplay() { |
| 307 | Log.i(TAG, "Start incoming display"); |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 308 | |
Alexandre Lision | 0c38451 | 2013-09-17 17:15:57 -0400 | [diff] [blame] | 309 | mCallbacks.startTimer(); |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 310 | |
Alexandre Lision | 23628c1 | 2013-09-24 11:17:05 -0400 | [diff] [blame] | 311 | int radiusCalls = (int) (model.width / 2 - BUBBLE_SIZE); |
Alexandre Lision | ee2494d | 2013-10-09 17:14:00 -0400 | [diff] [blame] | 312 | getBubbleForUser(conf, model.width / 2, model.height / 2 + radiusCalls); |
Alexandre Lision | 23628c1 | 2013-09-24 11:17:05 -0400 | [diff] [blame] | 313 | getBubbleFor(conf.getParticipants().get(0), model.width / 2, model.height / 2 - radiusCalls); |
alision | 8570418 | 2013-05-29 15:23:03 -0400 | [diff] [blame] | 314 | |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 315 | model.clearAttractors(); |
Alexandre Lision | 23628c1 | 2013-09-24 11:17:05 -0400 | [diff] [blame] | 316 | model.addAttractor(new Attractor(new PointF(model.width / 2, model.height / 2), ATTRACTOR_SIZE, new Attractor.Callback() { |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 317 | @Override |
| 318 | public boolean onBubbleSucked(Bubble b) { |
Alexandre Lision | a764c68 | 2013-09-09 10:02:07 -0400 | [diff] [blame] | 319 | |
| 320 | if (!accepted) { |
Alexandre Lision | 6885547 | 2013-10-10 16:20:46 -0400 | [diff] [blame] | 321 | try { |
| 322 | mCallbacks.getService().accept(b.getCallID()); |
| 323 | } catch (RemoteException e) { |
| 324 | e.printStackTrace(); |
| 325 | } |
Alexandre Lision | a764c68 | 2013-09-09 10:02:07 -0400 | [diff] [blame] | 326 | accepted = true; |
| 327 | } |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 328 | return false; |
| 329 | } |
| 330 | }, call_icon)); |
Alexandre Lision | cb2345c | 2013-12-09 15:39:13 -0500 | [diff] [blame] | 331 | |
| 332 | if (conf.getParticipants().get(0).getAccount().isAutoanswerEnabled()) { |
Alexandre Lision | 332f491 | 2013-11-12 13:04:32 -0500 | [diff] [blame] | 333 | try { |
| 334 | mCallbacks.getService().accept(conf.getParticipants().get(0).getCallId()); |
| 335 | } catch (RemoteException e) { |
| 336 | e.printStackTrace(); |
| 337 | } |
| 338 | } |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 339 | } |
alision | 8570418 | 2013-05-29 15:23:03 -0400 | [diff] [blame] | 340 | |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 341 | private void initOutGoingCallDisplay() { |
| 342 | Log.i(TAG, "Start outgoing display"); |
alision | 8570418 | 2013-05-29 15:23:03 -0400 | [diff] [blame] | 343 | |
Alexandre Lision | 0c38451 | 2013-09-17 17:15:57 -0400 | [diff] [blame] | 344 | mCallbacks.startTimer(); |
alision | 8570418 | 2013-05-29 15:23:03 -0400 | [diff] [blame] | 345 | |
Alexandre Lision | ee2494d | 2013-10-09 17:14:00 -0400 | [diff] [blame] | 346 | getBubbleForUser(conf, model.width / 2, model.height / 2); |
alision | 8570418 | 2013-05-29 15:23:03 -0400 | [diff] [blame] | 347 | |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 348 | // TODO off-thread image loading |
| 349 | int angle_part = 360 / conf.getParticipants().size(); |
| 350 | double dX = 0; |
| 351 | double dY = 0; |
Adrien Béraud | e78d06f | 2013-09-19 13:33:44 +1000 | [diff] [blame] | 352 | int radiusCalls = (int) (model.width / 2 - BUBBLE_SIZE); |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 353 | for (int i = 0; i < conf.getParticipants().size(); ++i) { |
| 354 | dX = Math.cos(Math.toRadians(angle_part * i - 90)) * radiusCalls; |
| 355 | dY = Math.sin(Math.toRadians(angle_part * i - 90)) * radiusCalls; |
| 356 | getBubbleFor(conf.getParticipants().get(i), (int) (model.width / 2 + dX), (int) (model.height / 2 + dY)); |
| 357 | } |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 358 | |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 359 | model.clearAttractors(); |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 360 | } |
alision | 8570418 | 2013-05-29 15:23:03 -0400 | [diff] [blame] | 361 | |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 362 | /** |
| 363 | * Retrieves or create a bubble for a given contact. If the bubble exists, it is moved to the new location. |
| 364 | * |
alision | 806e18e | 2013-06-21 15:30:17 -0400 | [diff] [blame] | 365 | * @param call |
| 366 | * The call associated to a contact |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 367 | * @param x |
| 368 | * Initial or new x position. |
| 369 | * @param y |
| 370 | * Initial or new y position. |
| 371 | * @return Bubble corresponding to the contact. |
| 372 | */ |
alision | 806e18e | 2013-06-21 15:30:17 -0400 | [diff] [blame] | 373 | private Bubble getBubbleFor(SipCall call, float x, float y) { |
Alexandre Lision | ee2494d | 2013-10-09 17:14:00 -0400 | [diff] [blame] | 374 | Bubble contact_bubble = model.getBubble(call.getCallId()); |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 375 | if (contact_bubble != null) { |
Alexandre Lision | b8add81 | 2013-10-24 11:42:42 -0400 | [diff] [blame] | 376 | ((BubbleContact) contact_bubble).setCall(call); |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 377 | contact_bubble.attractor.set(x, y); |
| 378 | return contact_bubble; |
| 379 | } |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 380 | |
Alexandre Lision | 40954dc | 2013-10-09 15:24:03 -0400 | [diff] [blame] | 381 | contact_bubble = new BubbleContact(getActivity(), call, x, y, BUBBLE_SIZE); |
| 382 | |
| 383 | model.addBubble(contact_bubble); |
| 384 | return contact_bubble; |
| 385 | } |
Alexandre Lision | b8add81 | 2013-10-24 11:42:42 -0400 | [diff] [blame] | 386 | |
Alexandre Lision | ee2494d | 2013-10-09 17:14:00 -0400 | [diff] [blame] | 387 | private Bubble getBubbleForUser(Conference conf, float x, float y) { |
Alexandre Lision | d568603 | 2013-10-29 11:09:21 -0400 | [diff] [blame] | 388 | Bubble contact_bubble = model.getUser(); |
Alexandre Lision | 40954dc | 2013-10-09 15:24:03 -0400 | [diff] [blame] | 389 | if (contact_bubble != null) { |
| 390 | contact_bubble.attractor.set(x, y); |
Alexandre Lision | b8add81 | 2013-10-24 11:42:42 -0400 | [diff] [blame] | 391 | ((BubbleUser) contact_bubble).setConference(conf); |
Alexandre Lision | cb2345c | 2013-12-09 15:39:13 -0500 | [diff] [blame] | 392 | |
Alexandre Lision | 40954dc | 2013-10-09 15:24:03 -0400 | [diff] [blame] | 393 | return contact_bubble; |
| 394 | } |
| 395 | |
Alexandre Lision | cb2345c | 2013-12-09 15:39:13 -0500 | [diff] [blame] | 396 | contact_bubble = new BubbleUser(getActivity(), CallContact.ContactBuilder.buildUserContact(getActivity().getContentResolver()), conf, x, y, |
| 397 | BUBBLE_SIZE * 1.3f); |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 398 | |
Alexandre Lision | c9fca9e | 2013-11-08 15:21:18 -0500 | [diff] [blame] | 399 | try { |
| 400 | ((BubbleUser) contact_bubble).setMute(mCallbacks.getService().isCaptureMuted()); |
| 401 | } catch (RemoteException e) { |
| 402 | e.printStackTrace(); |
Alexandre Lision | cb2345c | 2013-12-09 15:39:13 -0500 | [diff] [blame] | 403 | } catch (NullPointerException e1) { |
Alexandre Lision | c9fca9e | 2013-11-08 15:21:18 -0500 | [diff] [blame] | 404 | e1.printStackTrace(); |
| 405 | } |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 406 | model.addBubble(contact_bubble); |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 407 | return contact_bubble; |
| 408 | } |
Adrien Béraud | 0c9bd8f | 2013-05-30 16:16:57 +1000 | [diff] [blame] | 409 | |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 410 | public void changeCallState(String callID, String newState) { |
Alexandre Lision | e4b9584 | 2013-11-12 10:36:51 -0500 | [diff] [blame] | 411 | Log.i(TAG, "Call :" + callID + " " + newState); |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 412 | if (newState.contentEquals("FAILURE")) { |
| 413 | try { |
| 414 | mCallbacks.getService().hangUp(callID); |
| 415 | } catch (RemoteException e) { |
| 416 | e.printStackTrace(); |
alision | 806e18e | 2013-06-21 15:30:17 -0400 | [diff] [blame] | 417 | } |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 418 | } |
Alexandre Lision | cb2345c | 2013-12-09 15:39:13 -0500 | [diff] [blame] | 419 | if (conf == null) { |
Alexandre Lision | e4b9584 | 2013-11-12 10:36:51 -0500 | [diff] [blame] | 420 | return; |
| 421 | } |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 422 | for (int i = 0; i < conf.getParticipants().size(); ++i) { |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 423 | if (callID.equals(conf.getParticipants().get(i).getCallId())) { |
| 424 | if (newState.contentEquals("HUNGUP")) { |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 425 | model.removeBubble(conf.getParticipants().get(i)); |
| 426 | conf.getParticipants().remove(i); |
| 427 | } else { |
| 428 | conf.getParticipants().get(i).setCallState(newState); |
| 429 | } |
| 430 | } |
| 431 | } |
| 432 | |
Alexandre Lision | 4fb2262 | 2013-10-21 16:26:33 -0400 | [diff] [blame] | 433 | if (conf.isOnGoing()) { |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 434 | initNormalStateDisplay(); |
Alexandre Lision | 4fb2262 | 2013-10-21 16:26:33 -0400 | [diff] [blame] | 435 | try { |
| 436 | updateCodecName(mCallbacks.getService().getCurrentAudioCodecName(callID)); |
| 437 | } catch (RemoteException e) { |
| 438 | e.printStackTrace(); |
| 439 | } |
| 440 | } |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 441 | |
Alexandre Lision | ccf0c93 | 2013-10-10 16:24:41 -0400 | [diff] [blame] | 442 | if (conf.getParticipants().size() == 0) { |
Alexandre Lision | e4b9584 | 2013-11-12 10:36:51 -0500 | [diff] [blame] | 443 | callStatusTxt.setText(newState); |
Alexandre Lision | dafe951 | 2013-10-28 16:31:41 -0400 | [diff] [blame] | 444 | mCallbacks.terminateCall(); |
Alexandre Lision | ccf0c93 | 2013-10-10 16:24:41 -0400 | [diff] [blame] | 445 | } |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 446 | } |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 447 | |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 448 | public boolean draggingBubble() { |
| 449 | return view == null ? false : view.isDraggingBubble(); |
| 450 | } |
Adrien Béraud | c9c424d | 2013-05-30 17:47:35 +1000 | [diff] [blame] | 451 | |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 452 | @Override |
| 453 | public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { |
Adrien Béraud | 13cde0b | 2013-05-30 20:27:20 +1000 | [diff] [blame] | 454 | |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 455 | if (conf.getParticipants().size() == 1) { |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 456 | if (conf.getParticipants().get(0).isIncoming() && conf.getParticipants().get(0).isRinging()) { |
alision | 806e18e | 2013-06-21 15:30:17 -0400 | [diff] [blame] | 457 | initIncomingCallDisplay(); |
| 458 | } else { |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 459 | if (conf.getParticipants().get(0).isRinging()) { |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 460 | initOutGoingCallDisplay(); |
| 461 | } |
alision | 806e18e | 2013-06-21 15:30:17 -0400 | [diff] [blame] | 462 | try { |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 463 | if (conf.getParticipants().get(0).isOutGoing() |
| 464 | && mCallbacks.getService().getCall(conf.getParticipants().get(0).getCallId()) == null) { |
| 465 | mCallbacks.getService().placeCall(conf.getParticipants().get(0)); |
alision | 806e18e | 2013-06-21 15:30:17 -0400 | [diff] [blame] | 466 | initOutGoingCallDisplay(); |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 467 | } else if (conf.getParticipants().get(0).isOutGoing() && conf.getParticipants().get(0).isRinging()) { |
alision | 806e18e | 2013-06-21 15:30:17 -0400 | [diff] [blame] | 468 | initOutGoingCallDisplay(); |
| 469 | } |
| 470 | } catch (RemoteException e) { |
| 471 | Log.e(TAG, e.toString()); |
| 472 | } |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 473 | } |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 474 | if (conf.getParticipants().get(0).isOngoing()) { |
alision | 806e18e | 2013-06-21 15:30:17 -0400 | [diff] [blame] | 475 | initNormalStateDisplay(); |
| 476 | } |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 477 | } else if (conf.getParticipants().size() > 1) { |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 478 | initNormalStateDisplay(); |
| 479 | } |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 480 | } |
Adrien Béraud | 13cde0b | 2013-05-30 20:27:20 +1000 | [diff] [blame] | 481 | |
Alexandre Lision | 40954dc | 2013-10-09 15:24:03 -0400 | [diff] [blame] | 482 | public void makeTransfer(BubbleContact contact) { |
Alexandre Lision | 2b23792 | 2013-09-09 16:23:02 -0400 | [diff] [blame] | 483 | FragmentManager fm = getFragmentManager(); |
Alexandre Lision | 0eb0203 | 2013-09-27 16:32:40 -0400 | [diff] [blame] | 484 | editName = TransferDFragment.newInstance(); |
Alexandre Lision | 2b23792 | 2013-09-09 16:23:02 -0400 | [diff] [blame] | 485 | Bundle b = new Bundle(); |
Alexandre Lision | 6ae652d | 2013-09-26 16:39:20 -0400 | [diff] [blame] | 486 | try { |
Alexandre Lision | b8add81 | 2013-10-24 11:42:42 -0400 | [diff] [blame] | 487 | b.putParcelableArrayList("calls", (ArrayList<Conference>) mCallbacks.getService().getConcurrentCalls()); |
Alexandre Lision | 6ae652d | 2013-09-26 16:39:20 -0400 | [diff] [blame] | 488 | b.putParcelable("call_selected", contact.associated_call); |
| 489 | editName.setArguments(b); |
| 490 | editName.setTargetFragment(this, REQUEST_TRANSFER); |
| 491 | editName.show(fm, ""); |
| 492 | } catch (RemoteException e) { |
| 493 | Log.e(TAG, e.toString()); |
| 494 | } |
| 495 | |
Alexandre Lision | 2b23792 | 2013-09-09 16:23:02 -0400 | [diff] [blame] | 496 | } |
| 497 | |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 498 | @Override |
| 499 | public void surfaceCreated(SurfaceHolder holder) { |
Alexandre Lision | c30e841 | 2013-09-26 15:12:59 -0400 | [diff] [blame] | 500 | |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 501 | } |
Adrien Béraud | 13cde0b | 2013-05-30 20:27:20 +1000 | [diff] [blame] | 502 | |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 503 | @Override |
| 504 | public void surfaceDestroyed(SurfaceHolder holder) { |
Alexandre Lision | 84208a3 | 2013-09-25 13:18:37 -0400 | [diff] [blame] | 505 | // check that soft input is hidden |
| 506 | InputMethodManager lManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); |
| 507 | lManager.hideSoftInputFromWindow(view.getWindowToken(), 0); |
Alexandre Lision | b8add81 | 2013-10-24 11:42:42 -0400 | [diff] [blame] | 508 | if (editName != null && editName.isVisible()) { |
Alexandre Lision | 0eb0203 | 2013-09-27 16:32:40 -0400 | [diff] [blame] | 509 | editName.dismiss(); |
| 510 | } |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 511 | } |
Adrien Béraud | 13cde0b | 2013-05-30 20:27:20 +1000 | [diff] [blame] | 512 | |
alision | e38001f | 2013-06-04 14:14:39 -0400 | [diff] [blame] | 513 | public BubblesView getBubbleView() { |
| 514 | return view; |
alision | 1005ba1 | 2013-06-19 13:52:44 -0400 | [diff] [blame] | 515 | } |
Alexandre Lision | 0c38451 | 2013-09-17 17:15:57 -0400 | [diff] [blame] | 516 | |
| 517 | public void updateTime() { |
Adrien Béraud | e78d06f | 2013-09-19 13:33:44 +1000 | [diff] [blame] | 518 | long duration = System.currentTimeMillis() / 1000 - this.conf.getParticipants().get(0).getTimestamp_start(); |
Alexandre Lision | cb2345c | 2013-12-09 15:39:13 -0500 | [diff] [blame] | 519 | if (conf.isOnGoing()) |
Alexandre Lision | e4b9584 | 2013-11-12 10:36:51 -0500 | [diff] [blame] | 520 | callStatusTxt.setText(String.format("%d:%02d:%02d", duration / 3600, duration % 3600 / 60, duration % 60)); |
Alexandre Lision | f1850c0 | 2013-09-23 14:19:34 -0400 | [diff] [blame] | 521 | } |
| 522 | |
Alexandre Lision | 0edf18c | 2013-09-23 17:35:50 -0400 | [diff] [blame] | 523 | public Conference getConference() { |
| 524 | return conf; |
| 525 | } |
Alexandre Lision | 64dc8c0 | 2013-09-25 15:32:25 -0400 | [diff] [blame] | 526 | |
| 527 | public void onKeyUp(int keyCode, KeyEvent event) { |
| 528 | try { |
Alexandre Lision | b8add81 | 2013-10-24 11:42:42 -0400 | [diff] [blame] | 529 | |
Alexandre Lision | fda4d1d | 2013-10-25 15:29:53 -0400 | [diff] [blame] | 530 | switch (keyCode) { |
| 531 | case KeyEvent.KEYCODE_VOLUME_DOWN: |
| 532 | case KeyEvent.KEYCODE_VOLUME_UP: |
| 533 | break; |
| 534 | default: |
| 535 | String toSend = Character.toString(event.getDisplayLabel()); |
| 536 | toSend.toUpperCase(Locale.getDefault()); |
| 537 | Log.d(TAG, "toSend " + toSend); |
| 538 | mCallbacks.getService().playDtmf(toSend); |
| 539 | break; |
| 540 | } |
Alexandre Lision | 64dc8c0 | 2013-09-25 15:32:25 -0400 | [diff] [blame] | 541 | } catch (RemoteException e) { |
| 542 | e.printStackTrace(); |
| 543 | } |
| 544 | } |
Alexandre Lision | 4fb2262 | 2013-10-21 16:26:33 -0400 | [diff] [blame] | 545 | |
| 546 | public void updateCodecName(String currentAudioCodecName) { |
Alexandre Lision | f30ff85 | 2013-12-09 17:08:40 -0500 | [diff] [blame^] | 547 | // In case of multiple codec in the String |
Alexandre Lision | cb2345c | 2013-12-09 15:39:13 -0500 | [diff] [blame] | 548 | if (currentAudioCodecName.indexOf(' ') > 0) |
| 549 | codecNameTxt.setText(currentAudioCodecName.subSequence(0, currentAudioCodecName.indexOf(' '))); |
| 550 | else |
| 551 | codecNameTxt.setText(currentAudioCodecName); |
Alexandre Lision | 4fb2262 | 2013-10-21 16:26:33 -0400 | [diff] [blame] | 552 | } |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 553 | } |