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