Alexandre Savard | 14323be | 2012-10-24 10:02:13 -0400 | [diff] [blame] | 1 | /* |
alision | b176388 | 2013-06-18 17:30:51 -0400 | [diff] [blame] | 2 | * Copyright (C) 2004-2013 Savoir-Faire Linux Inc. |
Alexandre Savard | 14323be | 2012-10-24 10:02:13 -0400 | [diff] [blame] | 3 | * |
| 4 | * Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com> |
Adrien Béraud | 71b2f81 | 2013-04-26 18:51:02 +1000 | [diff] [blame] | 5 | * Author: Adrien Béraud <adrien.beraud@savoirfairelinux.com> |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 6 | * Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com> |
Alexandre Savard | 14323be | 2012-10-24 10:02:13 -0400 | [diff] [blame] | 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 3 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 21 | * |
| 22 | * Additional permission under GNU GPL version 3 section 7: |
| 23 | * |
| 24 | * If you modify this program, or any covered work, by linking or |
| 25 | * combining it with the OpenSSL project's OpenSSL library (or a |
| 26 | * modified version of that library), containing parts covered by the |
| 27 | * terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc. |
| 28 | * grants you additional permission to convey the resulting work. |
| 29 | * Corresponding Source for a non-source form of such a combination |
| 30 | * shall include the source code for the parts of OpenSSL used as well |
| 31 | * as that of the covered work. |
| 32 | */ |
| 33 | |
Alexandre Lision | 064e1e0 | 2013-10-01 16:18:42 -0400 | [diff] [blame] | 34 | package org.sflphone.client; |
Alexandre Savard | 14323be | 2012-10-24 10:02:13 -0400 | [diff] [blame] | 35 | |
Alexandre Lision | d568603 | 2013-10-29 11:09:21 -0400 | [diff] [blame] | 36 | import java.util.ArrayList; |
alision | 8570418 | 2013-05-29 15:23:03 -0400 | [diff] [blame] | 37 | import java.util.HashMap; |
Adrien Béraud | 3326888 | 2013-05-18 03:41:15 +1000 | [diff] [blame] | 38 | |
Alexandre Lision | 064e1e0 | 2013-10-01 16:18:42 -0400 | [diff] [blame] | 39 | import org.sflphone.R; |
| 40 | import org.sflphone.fragments.CallFragment; |
Alexandre Lision | 666b377 | 2013-10-28 17:42:48 -0400 | [diff] [blame] | 41 | import org.sflphone.fragments.IMFragment; |
Alexandre Lision | 064e1e0 | 2013-10-01 16:18:42 -0400 | [diff] [blame] | 42 | import org.sflphone.interfaces.CallInterface; |
Alexandre Lision | d588bff | 2013-10-08 12:43:01 -0400 | [diff] [blame] | 43 | import org.sflphone.model.Account; |
Alexandre Lision | 064e1e0 | 2013-10-01 16:18:42 -0400 | [diff] [blame] | 44 | import org.sflphone.model.CallContact; |
| 45 | import org.sflphone.model.Conference; |
| 46 | import org.sflphone.model.SipCall; |
Alexandre Lision | 666b377 | 2013-10-28 17:42:48 -0400 | [diff] [blame] | 47 | import org.sflphone.model.SipMessage; |
Alexandre Lision | 064e1e0 | 2013-10-01 16:18:42 -0400 | [diff] [blame] | 48 | import org.sflphone.receivers.CallReceiver; |
| 49 | import org.sflphone.service.CallManagerCallBack; |
| 50 | import org.sflphone.service.ISipService; |
| 51 | import org.sflphone.service.SipService; |
Alexandre Lision | b8add81 | 2013-10-24 11:42:42 -0400 | [diff] [blame] | 52 | import org.sflphone.utils.CallProximityManager; |
| 53 | import org.sflphone.utils.CallProximityManager.ProximityDirector; |
Alexandre Lision | 064e1e0 | 2013-10-01 16:18:42 -0400 | [diff] [blame] | 54 | import org.sflphone.views.CallPaneLayout; |
| 55 | |
Alexandre Savard | 14323be | 2012-10-24 10:02:13 -0400 | [diff] [blame] | 56 | import android.app.Activity; |
Alexandre Savard | 6d54bbc | 2012-10-24 11:04:23 -0400 | [diff] [blame] | 57 | import android.content.ComponentName; |
alision | 17052d4 | 2013-04-22 10:39:38 -0400 | [diff] [blame] | 58 | import android.content.Context; |
Alexandre Savard | 6d54bbc | 2012-10-24 11:04:23 -0400 | [diff] [blame] | 59 | import android.content.Intent; |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 60 | import android.content.IntentFilter; |
Alexandre Savard | 6d54bbc | 2012-10-24 11:04:23 -0400 | [diff] [blame] | 61 | import android.content.ServiceConnection; |
Alexandre Lision | 93ed33d | 2013-10-29 15:56:59 -0400 | [diff] [blame^] | 62 | import android.graphics.Color; |
Alexandre Lision | 0edf18c | 2013-09-23 17:35:50 -0400 | [diff] [blame] | 63 | import android.graphics.PixelFormat; |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 64 | import android.net.Uri; |
Alexandre Savard | 14323be | 2012-10-24 10:02:13 -0400 | [diff] [blame] | 65 | import android.os.Bundle; |
Alexandre Lision | 0c38451 | 2013-09-17 17:15:57 -0400 | [diff] [blame] | 66 | import android.os.Handler; |
Alexandre Savard | 6d54bbc | 2012-10-24 11:04:23 -0400 | [diff] [blame] | 67 | import android.os.IBinder; |
alision | 8599211 | 2013-05-29 12:18:08 -0400 | [diff] [blame] | 68 | import android.os.RemoteException; |
Alexandre Lision | 0c38451 | 2013-09-17 17:15:57 -0400 | [diff] [blame] | 69 | import android.os.SystemClock; |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 70 | import android.support.v4.widget.SlidingPaneLayout; |
Alexandre Savard | 6d54bbc | 2012-10-24 11:04:23 -0400 | [diff] [blame] | 71 | import android.util.Log; |
Alexandre Lision | 64dc8c0 | 2013-09-25 15:32:25 -0400 | [diff] [blame] | 72 | import android.view.KeyEvent; |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 73 | import android.view.View; |
Alexandre Lision | 93ed33d | 2013-10-29 15:56:59 -0400 | [diff] [blame^] | 74 | import android.view.ViewPropertyAnimator; |
Alexandre Lision | 0edf18c | 2013-09-23 17:35:50 -0400 | [diff] [blame] | 75 | import android.view.Window; |
Alexandre Lision | 93ed33d | 2013-10-29 15:56:59 -0400 | [diff] [blame^] | 76 | import android.view.WindowManager; |
| 77 | import android.view.animation.BounceInterpolator; |
| 78 | import android.view.inputmethod.EditorInfo; |
Adrien Béraud | 3326888 | 2013-05-18 03:41:15 +1000 | [diff] [blame] | 79 | import android.widget.Toast; |
Alexandre Savard | 14323be | 2012-10-24 10:02:13 -0400 | [diff] [blame] | 80 | |
Alexandre Lision | 666b377 | 2013-10-28 17:42:48 -0400 | [diff] [blame] | 81 | public class CallActivity extends Activity implements CallInterface, IMFragment.Callbacks, CallFragment.Callbacks, ProximityDirector { |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 82 | static final String TAG = "CallActivity"; |
| 83 | private ISipService service; |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 84 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 85 | CallReceiver receiver; |
alision | 8599211 | 2013-05-29 12:18:08 -0400 | [diff] [blame] | 86 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 87 | CallPaneLayout slidingPaneLayout; |
Adrien Béraud | 3326888 | 2013-05-18 03:41:15 +1000 | [diff] [blame] | 88 | |
Alexandre Lision | 666b377 | 2013-10-28 17:42:48 -0400 | [diff] [blame] | 89 | IMFragment mIMFragment; |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 90 | CallFragment mCurrentCallFragment; |
Alexandre Lision | 0edf18c | 2013-09-23 17:35:50 -0400 | [diff] [blame] | 91 | // private boolean fragIsChanging; |
Alexandre Lision | 1a9e3b1 | 2013-09-16 11:06:07 -0400 | [diff] [blame] | 92 | |
Alexandre Lision | f1850c0 | 2013-09-23 14:19:34 -0400 | [diff] [blame] | 93 | /* result code sent in case of call failure */ |
Alexandre Lision | c51ccb1 | 2013-09-11 16:00:30 -0400 | [diff] [blame] | 94 | public static int RESULT_FAILURE = -10; |
Alexandre Lision | 666b377 | 2013-10-28 17:42:48 -0400 | [diff] [blame] | 95 | |
Alexandre Lision | b8add81 | 2013-10-24 11:42:42 -0400 | [diff] [blame] | 96 | private CallProximityManager proximityManager; |
Alexandre Savard | 4f42ade | 2012-10-24 18:03:31 -0400 | [diff] [blame] | 97 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 98 | @Override |
| 99 | protected void onCreate(Bundle savedInstanceState) { |
| 100 | super.onCreate(savedInstanceState); |
| 101 | setContentView(R.layout.activity_call_layout); |
Alexandre Savard | 4f42ade | 2012-10-24 18:03:31 -0400 | [diff] [blame] | 102 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 103 | receiver = new CallReceiver(this); |
Adrien Béraud | 3326888 | 2013-05-18 03:41:15 +1000 | [diff] [blame] | 104 | |
Alexandre Lision | b8add81 | 2013-10-24 11:42:42 -0400 | [diff] [blame] | 105 | proximityManager = new CallProximityManager(this, this); |
alision | 8599211 | 2013-05-29 12:18:08 -0400 | [diff] [blame] | 106 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 107 | slidingPaneLayout = (CallPaneLayout) findViewById(R.id.slidingpanelayout); |
Alexandre Lision | 93ed33d | 2013-10-29 15:56:59 -0400 | [diff] [blame^] | 108 | slidingPaneLayout.setParallaxDistance(500); |
| 109 | slidingPaneLayout.setSliderFadeColor(Color.TRANSPARENT); |
| 110 | // ViewPropertyAnimator anim = slidingPaneLayout.animate(); |
| 111 | // anim.setInterpolator(new BounceInterpolator()); |
| 112 | // anim.setDuration(5000); |
| 113 | // anim.s |
| 114 | |
| 115 | |
| 116 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 117 | slidingPaneLayout.setPanelSlideListener(new SlidingPaneLayout.PanelSlideListener() { |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 118 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 119 | @Override |
| 120 | public void onPanelSlide(View view, float offSet) { |
| 121 | } |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 122 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 123 | @Override |
| 124 | public void onPanelOpened(View view) { |
Alexandre Lision | 93ed33d | 2013-10-29 15:56:59 -0400 | [diff] [blame^] | 125 | getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 126 | } |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 127 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 128 | @Override |
| 129 | public void onPanelClosed(View view) { |
Alexandre Lision | 666b377 | 2013-10-28 17:42:48 -0400 | [diff] [blame] | 130 | mCurrentCallFragment.getBubbleView().restartDrawing(); |
Alexandre Lision | 93ed33d | 2013-10-29 15:56:59 -0400 | [diff] [blame^] | 131 | getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING); |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 132 | } |
| 133 | }); |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 134 | |
Alexandre Lision | b8add81 | 2013-10-24 11:42:42 -0400 | [diff] [blame] | 135 | proximityManager.startTracking(); |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 136 | Intent intent = new Intent(this, SipService.class); |
| 137 | bindService(intent, mConnection, Context.BIND_AUTO_CREATE); |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 138 | } |
alision | d45da71 | 2013-05-30 09:18:49 -0400 | [diff] [blame] | 139 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 140 | /* activity gets back to the foreground and user input */ |
| 141 | @Override |
| 142 | protected void onResume() { |
| 143 | Log.i(TAG, "onResume"); |
| 144 | IntentFilter intentFilter = new IntentFilter(); |
| 145 | intentFilter.addAction(CallManagerCallBack.INCOMING_CALL); |
| 146 | intentFilter.addAction(CallManagerCallBack.INCOMING_TEXT); |
| 147 | intentFilter.addAction(CallManagerCallBack.CALL_STATE_CHANGED); |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 148 | intentFilter.addAction(CallManagerCallBack.CONF_CREATED); |
| 149 | intentFilter.addAction(CallManagerCallBack.CONF_REMOVED); |
| 150 | intentFilter.addAction(CallManagerCallBack.CONF_CHANGED); |
| 151 | intentFilter.addAction(CallManagerCallBack.RECORD_STATE_CHANGED); |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 152 | registerReceiver(receiver, intentFilter); |
Alexandre Lision | 0c38451 | 2013-09-17 17:15:57 -0400 | [diff] [blame] | 153 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 154 | super.onResume(); |
| 155 | } |
alision | d45da71 | 2013-05-30 09:18:49 -0400 | [diff] [blame] | 156 | |
Alexandre Lision | 0edf18c | 2013-09-23 17:35:50 -0400 | [diff] [blame] | 157 | @Override |
| 158 | public void onAttachedToWindow() { |
| 159 | super.onAttachedToWindow(); |
| 160 | Window window = getWindow(); |
| 161 | window.setFormat(PixelFormat.RGBA_8888); |
| 162 | } |
| 163 | |
Alexandre Lision | 0c38451 | 2013-09-17 17:15:57 -0400 | [diff] [blame] | 164 | private Handler mHandler = new Handler(); |
| 165 | private Runnable mUpdateTimeTask = new Runnable() { |
Adrien Béraud | 9360f24 | 2013-09-19 11:07:42 +1000 | [diff] [blame] | 166 | @Override |
Alexandre Lision | 0c38451 | 2013-09-17 17:15:57 -0400 | [diff] [blame] | 167 | public void run() { |
Alexandre Lision | 0edf18c | 2013-09-23 17:35:50 -0400 | [diff] [blame] | 168 | if (mCurrentCallFragment != null) |
Alexandre Lision | fd7a88f | 2013-09-18 10:03:17 -0400 | [diff] [blame] | 169 | mCurrentCallFragment.updateTime(); |
Alexandre Lision | 0edf18c | 2013-09-23 17:35:50 -0400 | [diff] [blame] | 170 | // mCallsFragment.update(); |
Alexandre Lision | 0c38451 | 2013-09-17 17:15:57 -0400 | [diff] [blame] | 171 | |
Adrien Béraud | 9360f24 | 2013-09-19 11:07:42 +1000 | [diff] [blame] | 172 | mHandler.postAtTime(this, SystemClock.uptimeMillis() + 1000); |
Alexandre Lision | 0c38451 | 2013-09-17 17:15:57 -0400 | [diff] [blame] | 173 | } |
| 174 | }; |
| 175 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 176 | /* activity no more in foreground */ |
| 177 | @Override |
| 178 | protected void onPause() { |
| 179 | super.onPause(); |
Alexandre Lision | 0c38451 | 2013-09-17 17:15:57 -0400 | [diff] [blame] | 180 | mHandler.removeCallbacks(mUpdateTimeTask); |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 181 | } |
Alexandre Lision | 40954dc | 2013-10-09 15:24:03 -0400 | [diff] [blame] | 182 | |
Alexandre Lision | 64dc8c0 | 2013-09-25 15:32:25 -0400 | [diff] [blame] | 183 | @Override |
| 184 | public boolean onKeyUp(int keyCode, KeyEvent event) { |
Alexandre Lision | 40954dc | 2013-10-09 15:24:03 -0400 | [diff] [blame] | 185 | |
| 186 | if (keyCode == KeyEvent.KEYCODE_BACK) { |
Alexandre Lision | 31f46fc | 2013-09-26 11:19:54 -0400 | [diff] [blame] | 187 | return super.onKeyUp(keyCode, event); |
| 188 | } |
Alexandre Lision | 64dc8c0 | 2013-09-25 15:32:25 -0400 | [diff] [blame] | 189 | mCurrentCallFragment.onKeyUp(keyCode, event); |
| 190 | return true; |
| 191 | } |
Alexandre Savard | 6d54bbc | 2012-10-24 11:04:23 -0400 | [diff] [blame] | 192 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 193 | @Override |
| 194 | protected void onDestroy() { |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 195 | unregisterReceiver(receiver); |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 196 | unbindService(mConnection); |
Alexandre Lision | b8add81 | 2013-10-24 11:42:42 -0400 | [diff] [blame] | 197 | proximityManager.stopTracking(); |
| 198 | proximityManager.release(0); |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 199 | super.onDestroy(); |
| 200 | } |
Adrien Béraud | 3326888 | 2013-05-18 03:41:15 +1000 | [diff] [blame] | 201 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 202 | /** Defines callbacks for service binding, passed to bindService() */ |
| 203 | private ServiceConnection mConnection = new ServiceConnection() { |
| 204 | @Override |
| 205 | public void onServiceConnected(ComponentName className, IBinder binder) { |
| 206 | service = ISipService.Stub.asInterface(binder); |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 207 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 208 | mCurrentCallFragment = new CallFragment(); |
Alexandre Lision | d568603 | 2013-10-29 11:09:21 -0400 | [diff] [blame] | 209 | mIMFragment = new IMFragment(); |
Adrien Béraud | 9360f24 | 2013-09-19 11:07:42 +1000 | [diff] [blame] | 210 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 211 | Uri u = getIntent().getData(); |
| 212 | if (u != null) { |
| 213 | CallContact c = CallContact.ContactBuilder.buildUnknownContact(u.getSchemeSpecificPart()); |
| 214 | try { |
| 215 | service.destroyNotification(); |
Alexandre Lision | 666b377 | 2013-10-28 17:42:48 -0400 | [diff] [blame] | 216 | |
Alexandre Lision | d568603 | 2013-10-29 11:09:21 -0400 | [diff] [blame] | 217 | String accountID = (String) service.getAccountList().get(1); // We use the first account to place outgoing calls |
Alexandre Lision | 666b377 | 2013-10-28 17:42:48 -0400 | [diff] [blame] | 218 | Account acc = new Account(accountID, (HashMap<String, String>) service.getAccountDetails(accountID)); |
| 219 | |
| 220 | SipCall call = SipCall.SipCallBuilder.getInstance().startCallCreation().setContact(c).setAccount(acc) |
| 221 | .setCallType(SipCall.state.CALL_TYPE_OUTGOING).build(); |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 222 | Conference tmp = new Conference("-1"); |
| 223 | tmp.getParticipants().add(call); |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 224 | Bundle b = new Bundle(); |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 225 | b.putParcelable("conference", tmp); |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 226 | mCurrentCallFragment.setArguments(b); |
| 227 | } catch (RemoteException e) { |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 228 | e.printStackTrace(); |
| 229 | } catch (Exception e) { |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 230 | e.printStackTrace(); |
| 231 | } |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 232 | } else { |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 233 | if (getIntent().getBooleanExtra("resuming", false)) { |
| 234 | |
| 235 | Bundle b = new Bundle(); |
Alexandre Lision | d568603 | 2013-10-29 11:09:21 -0400 | [diff] [blame] | 236 | Conference resumed = getIntent().getParcelableExtra("conference"); |
Adrien Béraud | 9360f24 | 2013-09-19 11:07:42 +1000 | [diff] [blame] | 237 | b.putParcelable("conference", getIntent().getParcelableExtra("conference")); |
Alexandre Lision | 1a9e3b1 | 2013-09-16 11:06:07 -0400 | [diff] [blame] | 238 | mCurrentCallFragment.setArguments(b); |
| 239 | |
Alexandre Lision | d568603 | 2013-10-29 11:09:21 -0400 | [diff] [blame] | 240 | Bundle IMBundle = new Bundle(); |
| 241 | IMBundle.putParcelableArrayList("messages", resumed.getMessages()); |
| 242 | mIMFragment.setArguments(IMBundle); |
| 243 | |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 244 | } else { |
| 245 | mCurrentCallFragment.setArguments(getIntent().getExtras()); |
Alexandre Lision | d568603 | 2013-10-29 11:09:21 -0400 | [diff] [blame] | 246 | |
| 247 | Bundle IMBundle = new Bundle(); |
| 248 | IMBundle.putParcelableArrayList("messages", new ArrayList<SipMessage>()); |
| 249 | mIMFragment.setArguments(IMBundle); |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 250 | } |
| 251 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 252 | } |
Alexandre Lision | d568603 | 2013-10-29 11:09:21 -0400 | [diff] [blame] | 253 | |
Alexandre Lision | 666b377 | 2013-10-28 17:42:48 -0400 | [diff] [blame] | 254 | slidingPaneLayout.setCurFragment(mCurrentCallFragment); |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 255 | getIntent().getExtras(); |
Alexandre Lision | 0edf18c | 2013-09-23 17:35:50 -0400 | [diff] [blame] | 256 | // mCallsFragment.update(); |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 257 | getFragmentManager().beginTransaction().replace(R.id.ongoingcall_pane, mCurrentCallFragment).commit(); |
Alexandre Lision | 666b377 | 2013-10-28 17:42:48 -0400 | [diff] [blame] | 258 | getFragmentManager().beginTransaction().replace(R.id.message_list_frame, mIMFragment).commit(); |
alision | d8c8388 | 2013-05-17 17:00:42 -0400 | [diff] [blame] | 259 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 260 | } |
Adrien Béraud | 6bbce91 | 2013-05-24 00:48:13 +1000 | [diff] [blame] | 261 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 262 | @Override |
| 263 | public void onServiceDisconnected(ComponentName arg0) { |
| 264 | } |
| 265 | }; |
Adrien Béraud | 6bbce91 | 2013-05-24 00:48:13 +1000 | [diff] [blame] | 266 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 267 | @Override |
| 268 | public void incomingCall(Intent call) { |
Alexandre Lision | dafe951 | 2013-10-28 16:31:41 -0400 | [diff] [blame] | 269 | Bundle b = new Bundle(); |
| 270 | Conference tmp = new Conference("-1"); |
Alexandre Lision | 666b377 | 2013-10-28 17:42:48 -0400 | [diff] [blame] | 271 | tmp.getParticipants().add((SipCall) call.getParcelableExtra("newcall")); |
Alexandre Lision | dafe951 | 2013-10-28 16:31:41 -0400 | [diff] [blame] | 272 | b.putParcelable("conference", tmp); |
| 273 | mCurrentCallFragment = new CallFragment(); |
| 274 | mCurrentCallFragment.setArguments(b); |
| 275 | getFragmentManager().beginTransaction().replace(R.id.ongoingcall_pane, mCurrentCallFragment).commit(); |
Alexandre Lision | 666b377 | 2013-10-28 17:42:48 -0400 | [diff] [blame] | 276 | slidingPaneLayout.setCurFragment(mCurrentCallFragment); |
Alexandre Savard | df54426 | 2012-10-25 14:24:08 -0400 | [diff] [blame] | 277 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 278 | } |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 279 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 280 | @Override |
| 281 | public void callStateChanged(Intent callState) { |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 282 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 283 | Bundle b = callState.getBundleExtra("com.savoirfairelinux.sflphone.service.newstate"); |
| 284 | processCallStateChangedSignal(b.getString("CallID"), b.getString("State")); |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 285 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 286 | } |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 287 | |
Alexandre Lision | 0edf18c | 2013-09-23 17:35:50 -0400 | [diff] [blame] | 288 | @SuppressWarnings("unchecked") |
| 289 | // No proper solution with HashMap runtime cast |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 290 | public void processCallStateChangedSignal(String callID, String newState) { |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 291 | |
Alexandre Lision | 4fb2262 | 2013-10-21 16:26:33 -0400 | [diff] [blame] | 292 | if (mCurrentCallFragment != null) { |
Alexandre Lision | a764c68 | 2013-09-09 10:02:07 -0400 | [diff] [blame] | 293 | mCurrentCallFragment.changeCallState(callID, newState); |
Alexandre Lision | 4fb2262 | 2013-10-21 16:26:33 -0400 | [diff] [blame] | 294 | } |
Adrien Béraud | 2955604 | 2013-04-26 17:35:43 +1000 | [diff] [blame] | 295 | |
Alexandre Lision | b8add81 | 2013-10-24 11:42:42 -0400 | [diff] [blame] | 296 | proximityManager.updateProximitySensorMode(); |
Alexandre Lision | 666b377 | 2013-10-28 17:42:48 -0400 | [diff] [blame] | 297 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 298 | try { |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 299 | HashMap<String, SipCall> callMap = (HashMap<String, SipCall>) service.getCallList(); |
| 300 | HashMap<String, Conference> confMap = (HashMap<String, Conference>) service.getConferenceList(); |
Alexandre Lision | 3c6b710 | 2013-09-16 16:56:46 -0400 | [diff] [blame] | 301 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 302 | } catch (RemoteException e) { |
Alexandre Lision | 3c6b710 | 2013-09-16 16:56:46 -0400 | [diff] [blame] | 303 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 304 | Log.e(TAG, e.toString()); |
| 305 | } |
Adrien Béraud | 2955604 | 2013-04-26 17:35:43 +1000 | [diff] [blame] | 306 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 307 | Log.w(TAG, "processCallStateChangedSignal " + newState); |
Adrien Béraud | 71b2f81 | 2013-04-26 18:51:02 +1000 | [diff] [blame] | 308 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 309 | } |
| 310 | |
| 311 | @Override |
Alexandre Lision | 666b377 | 2013-10-28 17:42:48 -0400 | [diff] [blame] | 312 | public void incomingText(Intent in) { |
| 313 | Bundle b = in.getBundleExtra("com.savoirfairelinux.sflphone.service.newtext"); |
Alexandre Lision | d568603 | 2013-10-29 11:09:21 -0400 | [diff] [blame] | 314 | |
| 315 | if (mIMFragment != null) { |
Alexandre Lision | 666b377 | 2013-10-28 17:42:48 -0400 | [diff] [blame] | 316 | SipMessage msg = new SipMessage(true, b.getString("Msg")); |
| 317 | mIMFragment.putMessage(msg); |
| 318 | } |
Adrien Béraud | 71b2f81 | 2013-04-26 18:51:02 +1000 | [diff] [blame] | 319 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 320 | } |
alision | 7f18fc8 | 2013-05-01 09:37:33 -0400 | [diff] [blame] | 321 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 322 | @Override |
| 323 | public ISipService getService() { |
| 324 | return service; |
| 325 | } |
alision | 04a0018 | 2013-05-10 17:05:29 -0400 | [diff] [blame] | 326 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 327 | @Override |
| 328 | public void onBackPressed() { |
| 329 | super.onBackPressed(); |
| 330 | Intent launchHome = new Intent(this, SFLPhoneHomeActivity.class); |
| 331 | launchHome.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); |
Alexandre Lision | 5ed2c97 | 2013-10-11 15:36:33 -0400 | [diff] [blame] | 332 | launchHome.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 333 | startActivity(launchHome); |
| 334 | } |
alision | 8599211 | 2013-05-29 12:18:08 -0400 | [diff] [blame] | 335 | |
alision | 806e18e | 2013-06-21 15:30:17 -0400 | [diff] [blame] | 336 | @Override |
| 337 | public void confCreated(Intent intent) { |
Alexandre Lision | 0edf18c | 2013-09-23 17:35:50 -0400 | [diff] [blame] | 338 | // mCallsFragment.update(); |
alision | 34673e6 | 2013-06-25 14:40:07 -0400 | [diff] [blame] | 339 | |
alision | 806e18e | 2013-06-21 15:30:17 -0400 | [diff] [blame] | 340 | } |
| 341 | |
| 342 | @Override |
| 343 | public void confRemoved(Intent intent) { |
Alexandre Lision | 0edf18c | 2013-09-23 17:35:50 -0400 | [diff] [blame] | 344 | // mCallsFragment.update(); |
alision | 806e18e | 2013-06-21 15:30:17 -0400 | [diff] [blame] | 345 | } |
| 346 | |
| 347 | @Override |
| 348 | public void confChanged(Intent intent) { |
Alexandre Lision | 0edf18c | 2013-09-23 17:35:50 -0400 | [diff] [blame] | 349 | // mCallsFragment.update(); |
alision | 806e18e | 2013-06-21 15:30:17 -0400 | [diff] [blame] | 350 | } |
| 351 | |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 352 | @Override |
| 353 | public void recordingChanged(Intent intent) { |
Alexandre Lision | 0edf18c | 2013-09-23 17:35:50 -0400 | [diff] [blame] | 354 | // mCallsFragment.update(); |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 355 | } |
| 356 | |
Alexandre Lision | ccf0c93 | 2013-10-10 16:24:41 -0400 | [diff] [blame] | 357 | @Override |
Alexandre Lision | dafe951 | 2013-10-28 16:31:41 -0400 | [diff] [blame] | 358 | public void terminateCall() { |
Alexandre Lision | ccf0c93 | 2013-10-10 16:24:41 -0400 | [diff] [blame] | 359 | mHandler.removeCallbacks(mUpdateTimeTask); |
| 360 | mCurrentCallFragment.getBubbleView().stopThread(); |
Alexandre Lision | 666b377 | 2013-10-28 17:42:48 -0400 | [diff] [blame] | 361 | // getFragmentManager().beginTransaction().remove(mCurrentCallFragment).commit(); |
| 362 | // mCurrentCallFragment = null; |
Alexandre Lision | 5ed2c97 | 2013-10-11 15:36:33 -0400 | [diff] [blame] | 363 | finish(); |
Alexandre Lision | ccf0c93 | 2013-10-10 16:24:41 -0400 | [diff] [blame] | 364 | |
| 365 | } |
alision | 806e18e | 2013-06-21 15:30:17 -0400 | [diff] [blame] | 366 | |
Alexandre Lision | 0c38451 | 2013-09-17 17:15:57 -0400 | [diff] [blame] | 367 | @Override |
Alexandre Lision | d568603 | 2013-10-29 11:09:21 -0400 | [diff] [blame] | 368 | public boolean sendIM(SipMessage msg) { |
| 369 | |
| 370 | try { |
| 371 | service.sendTextMessage(mCurrentCallFragment.getConference().getId(), msg); |
| 372 | } catch (RemoteException e) { |
| 373 | e.printStackTrace(); |
| 374 | return false; |
| 375 | } |
| 376 | |
| 377 | return true; |
| 378 | } |
| 379 | |
| 380 | @Override |
Alexandre Lision | 0c38451 | 2013-09-17 17:15:57 -0400 | [diff] [blame] | 381 | public void startTimer() { |
| 382 | mHandler.postDelayed(mUpdateTimeTask, 0); |
| 383 | } |
| 384 | |
Alexandre Lision | 40954dc | 2013-10-09 15:24:03 -0400 | [diff] [blame] | 385 | public void onCallSuspended() { |
| 386 | try { |
| 387 | if (mCurrentCallFragment.getConference().hasMultipleParticipants()) { |
| 388 | service.holdConference(mCurrentCallFragment.getConference().getId()); |
| 389 | } else { |
| 390 | service.hold(mCurrentCallFragment.getConference().getParticipants().get(0).getCallId()); |
| 391 | } |
| 392 | } catch (RemoteException e) { |
Alexandre Lision | 40954dc | 2013-10-09 15:24:03 -0400 | [diff] [blame] | 393 | e.printStackTrace(); |
| 394 | } |
| 395 | } |
Alexandre Lision | 6885547 | 2013-10-10 16:20:46 -0400 | [diff] [blame] | 396 | |
| 397 | @Override |
| 398 | public void slideChatScreen() { |
Alexandre Lision | 666b377 | 2013-10-28 17:42:48 -0400 | [diff] [blame] | 399 | |
| 400 | if (slidingPaneLayout.isOpen()) { |
| 401 | slidingPaneLayout.closePane(); |
| 402 | } else { |
| 403 | mCurrentCallFragment.getBubbleView().stopThread(); |
| 404 | slidingPaneLayout.openPane(); |
| 405 | } |
Alexandre Lision | 6885547 | 2013-10-10 16:20:46 -0400 | [diff] [blame] | 406 | } |
Alexandre Lision | b8add81 | 2013-10-24 11:42:42 -0400 | [diff] [blame] | 407 | |
| 408 | @Override |
| 409 | public boolean shouldActivateProximity() { |
| 410 | return true; |
| 411 | } |
| 412 | |
| 413 | @Override |
| 414 | public void onProximityTrackingChanged(boolean acquired) { |
| 415 | // TODO Stub de la méthode généré automatiquement |
Alexandre Lision | 666b377 | 2013-10-28 17:42:48 -0400 | [diff] [blame] | 416 | |
Alexandre Lision | b8add81 | 2013-10-24 11:42:42 -0400 | [diff] [blame] | 417 | } |
Alexandre Savard | 14323be | 2012-10-24 10:02:13 -0400 | [diff] [blame] | 418 | } |