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