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