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