Alexandre Savard | 14323be | 2012-10-24 10:02:13 -0400 | [diff] [blame] | 1 | /* |
Alexandre Lision | c1024c0 | 2014-01-06 11:12:53 -0500 | [diff] [blame] | 2 | * Copyright (C) 2004-2014 Savoir-Faire Linux Inc. |
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 | a7ab2e3 | 2014-02-14 15:33:33 -0500 | [diff] [blame] | 36 | import java.util.*; |
Adrien Béraud | 3326888 | 2013-05-18 03:41:15 +1000 | [diff] [blame] | 37 | |
Alexandre Lision | 5f144b8 | 2014-02-11 09:59:36 -0500 | [diff] [blame] | 38 | import android.support.v4.app.FragmentActivity; |
Alexandre Lision | a7ab2e3 | 2014-02-14 15:33:33 -0500 | [diff] [blame] | 39 | import android.util.Log; |
Alexandre Lision | 064e1e0 | 2013-10-01 16:18:42 -0400 | [diff] [blame] | 40 | import org.sflphone.R; |
| 41 | import org.sflphone.fragments.CallFragment; |
Alexandre Lision | 666b377 | 2013-10-28 17:42:48 -0400 | [diff] [blame] | 42 | import org.sflphone.fragments.IMFragment; |
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.service.ISipService; |
| 49 | import org.sflphone.service.SipService; |
Alexandre Lision | b8add81 | 2013-10-24 11:42:42 -0400 | [diff] [blame] | 50 | import org.sflphone.utils.CallProximityManager; |
| 51 | import org.sflphone.utils.CallProximityManager.ProximityDirector; |
Alexandre Lision | 064e1e0 | 2013-10-01 16:18:42 -0400 | [diff] [blame] | 52 | import org.sflphone.views.CallPaneLayout; |
| 53 | |
Alexandre Savard | 6d54bbc | 2012-10-24 11:04:23 -0400 | [diff] [blame] | 54 | import android.content.ComponentName; |
alision | 17052d4 | 2013-04-22 10:39:38 -0400 | [diff] [blame] | 55 | import android.content.Context; |
Alexandre Savard | 6d54bbc | 2012-10-24 11:04:23 -0400 | [diff] [blame] | 56 | import android.content.Intent; |
| 57 | import android.content.ServiceConnection; |
Alexandre Lision | 93ed33d | 2013-10-29 15:56:59 -0400 | [diff] [blame] | 58 | import android.graphics.Color; |
Alexandre Lision | 0edf18c | 2013-09-23 17:35:50 -0400 | [diff] [blame] | 59 | import android.graphics.PixelFormat; |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 60 | import android.net.Uri; |
Alexandre Savard | 14323be | 2012-10-24 10:02:13 -0400 | [diff] [blame] | 61 | import android.os.Bundle; |
Alexandre Lision | 0c38451 | 2013-09-17 17:15:57 -0400 | [diff] [blame] | 62 | import android.os.Handler; |
Alexandre Savard | 6d54bbc | 2012-10-24 11:04:23 -0400 | [diff] [blame] | 63 | import android.os.IBinder; |
alision | 8599211 | 2013-05-29 12:18:08 -0400 | [diff] [blame] | 64 | import android.os.RemoteException; |
Alexandre Lision | 0c38451 | 2013-09-17 17:15:57 -0400 | [diff] [blame] | 65 | import android.os.SystemClock; |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 66 | import android.support.v4.widget.SlidingPaneLayout; |
Alexandre Lision | 64dc8c0 | 2013-09-25 15:32:25 -0400 | [diff] [blame] | 67 | import android.view.KeyEvent; |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 68 | import android.view.View; |
Alexandre Lision | 0edf18c | 2013-09-23 17:35:50 -0400 | [diff] [blame] | 69 | import android.view.Window; |
Alexandre Lision | 93ed33d | 2013-10-29 15:56:59 -0400 | [diff] [blame] | 70 | import android.view.WindowManager; |
Alexandre Savard | 14323be | 2012-10-24 10:02:13 -0400 | [diff] [blame] | 71 | |
Alexandre Lision | 5f144b8 | 2014-02-11 09:59:36 -0500 | [diff] [blame] | 72 | public class CallActivity extends FragmentActivity implements IMFragment.Callbacks, CallFragment.Callbacks, ProximityDirector { |
| 73 | |
| 74 | @SuppressWarnings("unused") |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 75 | static final String TAG = "CallActivity"; |
Alexandre Lision | 47a7204 | 2013-12-10 10:43:02 -0500 | [diff] [blame] | 76 | private ISipService mService; |
Alexandre Lision | 47a7204 | 2013-12-10 10:43:02 -0500 | [diff] [blame] | 77 | CallPaneLayout mSlidingPaneLayout; |
Adrien Béraud | 3326888 | 2013-05-18 03:41:15 +1000 | [diff] [blame] | 78 | |
Alexandre Lision | 666b377 | 2013-10-28 17:42:48 -0400 | [diff] [blame] | 79 | IMFragment mIMFragment; |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 80 | CallFragment mCurrentCallFragment; |
Alexandre Lision | 48b49eb | 2014-02-11 13:37:33 -0500 | [diff] [blame] | 81 | private Conference mDisplayedConference; |
Alexandre Lision | f02190d | 2013-12-12 17:26:12 -0500 | [diff] [blame] | 82 | |
Alexandre Lision | f1850c0 | 2013-09-23 14:19:34 -0400 | [diff] [blame] | 83 | /* result code sent in case of call failure */ |
Alexandre Lision | c51ccb1 | 2013-09-11 16:00:30 -0400 | [diff] [blame] | 84 | public static int RESULT_FAILURE = -10; |
Alexandre Lision | 47a7204 | 2013-12-10 10:43:02 -0500 | [diff] [blame] | 85 | private CallProximityManager mProximityManager; |
Alexandre Savard | 4f42ade | 2012-10-24 18:03:31 -0400 | [diff] [blame] | 86 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 87 | @Override |
| 88 | protected void onCreate(Bundle savedInstanceState) { |
| 89 | super.onCreate(savedInstanceState); |
| 90 | setContentView(R.layout.activity_call_layout); |
Alexandre Savard | 4f42ade | 2012-10-24 18:03:31 -0400 | [diff] [blame] | 91 | |
Alexandre Lision | 47a7204 | 2013-12-10 10:43:02 -0500 | [diff] [blame] | 92 | mProximityManager = new CallProximityManager(this, this); |
alision | 8599211 | 2013-05-29 12:18:08 -0400 | [diff] [blame] | 93 | |
Alexandre Lision | 47a7204 | 2013-12-10 10:43:02 -0500 | [diff] [blame] | 94 | mSlidingPaneLayout = (CallPaneLayout) findViewById(R.id.slidingpanelayout); |
| 95 | mSlidingPaneLayout.setParallaxDistance(500); |
| 96 | mSlidingPaneLayout.setSliderFadeColor(Color.TRANSPARENT); |
Alexandre Lision | 3b7148e | 2013-11-13 17:23:06 -0500 | [diff] [blame] | 97 | |
Alexandre Lision | f02190d | 2013-12-12 17:26:12 -0500 | [diff] [blame] | 98 | Window w = getWindow(); |
| 99 | w.setFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED, WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); |
| 100 | |
Alexandre Lision | 47a7204 | 2013-12-10 10:43:02 -0500 | [diff] [blame] | 101 | mSlidingPaneLayout.setPanelSlideListener(new SlidingPaneLayout.PanelSlideListener() { |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 102 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 103 | @Override |
| 104 | public void onPanelSlide(View view, float offSet) { |
| 105 | } |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 106 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 107 | @Override |
| 108 | public void onPanelOpened(View view) { |
Alexandre Lision | 93ed33d | 2013-10-29 15:56:59 -0400 | [diff] [blame] | 109 | getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 110 | } |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 111 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 112 | @Override |
| 113 | public void onPanelClosed(View view) { |
Alexandre Lision | 666b377 | 2013-10-28 17:42:48 -0400 | [diff] [blame] | 114 | mCurrentCallFragment.getBubbleView().restartDrawing(); |
Alexandre Lision | 93ed33d | 2013-10-29 15:56:59 -0400 | [diff] [blame] | 115 | getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING); |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 116 | } |
| 117 | }); |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 118 | |
Alexandre Lision | 47a7204 | 2013-12-10 10:43:02 -0500 | [diff] [blame] | 119 | mProximityManager.startTracking(); |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 120 | Intent intent = new Intent(this, SipService.class); |
| 121 | bindService(intent, mConnection, Context.BIND_AUTO_CREATE); |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 122 | } |
alision | d45da71 | 2013-05-30 09:18:49 -0400 | [diff] [blame] | 123 | |
Alexandre Lision | 0edf18c | 2013-09-23 17:35:50 -0400 | [diff] [blame] | 124 | @Override |
| 125 | public void onAttachedToWindow() { |
| 126 | super.onAttachedToWindow(); |
| 127 | Window window = getWindow(); |
| 128 | window.setFormat(PixelFormat.RGBA_8888); |
| 129 | } |
| 130 | |
Alexandre Lision | 0c38451 | 2013-09-17 17:15:57 -0400 | [diff] [blame] | 131 | private Handler mHandler = new Handler(); |
| 132 | private Runnable mUpdateTimeTask = new Runnable() { |
Adrien Béraud | 9360f24 | 2013-09-19 11:07:42 +1000 | [diff] [blame] | 133 | @Override |
Alexandre Lision | 0c38451 | 2013-09-17 17:15:57 -0400 | [diff] [blame] | 134 | public void run() { |
Alexandre Lision | 0edf18c | 2013-09-23 17:35:50 -0400 | [diff] [blame] | 135 | if (mCurrentCallFragment != null) |
Alexandre Lision | fd7a88f | 2013-09-18 10:03:17 -0400 | [diff] [blame] | 136 | mCurrentCallFragment.updateTime(); |
Adrien Béraud | 9360f24 | 2013-09-19 11:07:42 +1000 | [diff] [blame] | 137 | mHandler.postAtTime(this, SystemClock.uptimeMillis() + 1000); |
Alexandre Lision | 0c38451 | 2013-09-17 17:15:57 -0400 | [diff] [blame] | 138 | } |
| 139 | }; |
| 140 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 141 | /* activity no more in foreground */ |
| 142 | @Override |
| 143 | protected void onPause() { |
| 144 | super.onPause(); |
Alexandre Lision | 0c38451 | 2013-09-17 17:15:57 -0400 | [diff] [blame] | 145 | mHandler.removeCallbacks(mUpdateTimeTask); |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 146 | } |
Alexandre Lision | 40954dc | 2013-10-09 15:24:03 -0400 | [diff] [blame] | 147 | |
Alexandre Lision | 64dc8c0 | 2013-09-25 15:32:25 -0400 | [diff] [blame] | 148 | @Override |
| 149 | public boolean onKeyUp(int keyCode, KeyEvent event) { |
Alexandre Lision | 40954dc | 2013-10-09 15:24:03 -0400 | [diff] [blame] | 150 | |
| 151 | if (keyCode == KeyEvent.KEYCODE_BACK) { |
Alexandre Lision | 31f46fc | 2013-09-26 11:19:54 -0400 | [diff] [blame] | 152 | return super.onKeyUp(keyCode, event); |
| 153 | } |
Alexandre Lision | 64dc8c0 | 2013-09-25 15:32:25 -0400 | [diff] [blame] | 154 | mCurrentCallFragment.onKeyUp(keyCode, event); |
| 155 | return true; |
| 156 | } |
Alexandre Savard | 6d54bbc | 2012-10-24 11:04:23 -0400 | [diff] [blame] | 157 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 158 | @Override |
| 159 | protected void onDestroy() { |
Alexandre Lision | 5f144b8 | 2014-02-11 09:59:36 -0500 | [diff] [blame] | 160 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 161 | unbindService(mConnection); |
Alexandre Lision | f02190d | 2013-12-12 17:26:12 -0500 | [diff] [blame] | 162 | |
Alexandre Lision | 47a7204 | 2013-12-10 10:43:02 -0500 | [diff] [blame] | 163 | mProximityManager.stopTracking(); |
| 164 | mProximityManager.release(0); |
Alexandre Lision | f02190d | 2013-12-12 17:26:12 -0500 | [diff] [blame] | 165 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 166 | super.onDestroy(); |
| 167 | } |
Adrien Béraud | 3326888 | 2013-05-18 03:41:15 +1000 | [diff] [blame] | 168 | |
Alexandre Lision | 707f908 | 2014-01-16 15:09:07 -0500 | [diff] [blame] | 169 | /** |
| 170 | * Defines callbacks for service binding, passed to bindService() |
| 171 | */ |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 172 | private ServiceConnection mConnection = new ServiceConnection() { |
Alexandre Lision | a8b7872 | 2013-12-13 10:18:33 -0500 | [diff] [blame] | 173 | @SuppressWarnings("unchecked") |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 174 | @Override |
| 175 | public void onServiceConnected(ComponentName className, IBinder binder) { |
Alexandre Lision | 47a7204 | 2013-12-10 10:43:02 -0500 | [diff] [blame] | 176 | mService = ISipService.Stub.asInterface(binder); |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 177 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 178 | mCurrentCallFragment = new CallFragment(); |
Alexandre Lision | d568603 | 2013-10-29 11:09:21 -0400 | [diff] [blame] | 179 | mIMFragment = new IMFragment(); |
Adrien Béraud | 9360f24 | 2013-09-19 11:07:42 +1000 | [diff] [blame] | 180 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 181 | Uri u = getIntent().getData(); |
| 182 | if (u != null) { |
| 183 | CallContact c = CallContact.ContactBuilder.buildUnknownContact(u.getSchemeSpecificPart()); |
| 184 | try { |
Alexandre Lision | 47a7204 | 2013-12-10 10:43:02 -0500 | [diff] [blame] | 185 | mService.destroyNotification(); |
Alexandre Lision | 666b377 | 2013-10-28 17:42:48 -0400 | [diff] [blame] | 186 | |
Alexandre Lision | 47a7204 | 2013-12-10 10:43:02 -0500 | [diff] [blame] | 187 | String accountID = (String) mService.getAccountList().get(1); // We use the first account to place outgoing calls |
| 188 | HashMap<String, String> details = (HashMap<String, String>) mService.getAccountDetails(accountID); |
| 189 | ArrayList<HashMap<String, String>> credentials = (ArrayList<HashMap<String, String>>) mService.getCredentials(accountID); |
Alexandre Lision | 3b7148e | 2013-11-13 17:23:06 -0500 | [diff] [blame] | 190 | Account acc = new Account(accountID, details, credentials); |
Alexandre Lision | 666b377 | 2013-10-28 17:42:48 -0400 | [diff] [blame] | 191 | |
Alexandre Lision | a7ab2e3 | 2014-02-14 15:33:33 -0500 | [diff] [blame] | 192 | Bundle args = new Bundle(); |
| 193 | args.putString(SipCall.ID, Integer.toString(Math.abs(new Random().nextInt()))); |
| 194 | args.putParcelable(SipCall.ACCOUNT, acc); |
| 195 | args.putInt(SipCall.STATE, SipCall.state.CALL_STATE_RINGING); |
| 196 | args.putInt(SipCall.TYPE, SipCall.direction.CALL_TYPE_OUTGOING); |
| 197 | args.putParcelable(SipCall.CONTACT, c); |
| 198 | |
Alexandre Lision | 48b49eb | 2014-02-11 13:37:33 -0500 | [diff] [blame] | 199 | mDisplayedConference = new Conference(Conference.DEFAULT_ID); |
Alexandre Lision | a7ab2e3 | 2014-02-14 15:33:33 -0500 | [diff] [blame] | 200 | mDisplayedConference.getParticipants().add(new SipCall(args)); |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 201 | } catch (RemoteException e) { |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 202 | e.printStackTrace(); |
| 203 | } catch (Exception e) { |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 204 | e.printStackTrace(); |
| 205 | } |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 206 | } else { |
Alexandre Lision | a7ab2e3 | 2014-02-14 15:33:33 -0500 | [diff] [blame] | 207 | mDisplayedConference = getIntent().getParcelableExtra("conference"); |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 208 | if (getIntent().getBooleanExtra("resuming", false)) { |
Alexandre Lision | d568603 | 2013-10-29 11:09:21 -0400 | [diff] [blame] | 209 | Bundle IMBundle = new Bundle(); |
Alexandre Lision | 48b49eb | 2014-02-11 13:37:33 -0500 | [diff] [blame] | 210 | IMBundle.putParcelableArrayList("messages", mDisplayedConference.getMessages()); |
Alexandre Lision | d568603 | 2013-10-29 11:09:21 -0400 | [diff] [blame] | 211 | mIMFragment.setArguments(IMBundle); |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 212 | } else { |
Alexandre Lision | d568603 | 2013-10-29 11:09:21 -0400 | [diff] [blame] | 213 | Bundle IMBundle = new Bundle(); |
Alexandre Lision | a7ab2e3 | 2014-02-14 15:33:33 -0500 | [diff] [blame] | 214 | try { |
| 215 | mService.placeCall(mDisplayedConference.getParticipants().get(0)); |
| 216 | } catch (RemoteException e) { |
| 217 | e.printStackTrace(); |
| 218 | } |
Alexandre Lision | d568603 | 2013-10-29 11:09:21 -0400 | [diff] [blame] | 219 | IMBundle.putParcelableArrayList("messages", new ArrayList<SipMessage>()); |
| 220 | mIMFragment.setArguments(IMBundle); |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 221 | } |
| 222 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 223 | } |
Alexandre Lision | d568603 | 2013-10-29 11:09:21 -0400 | [diff] [blame] | 224 | |
Alexandre Lision | 47a7204 | 2013-12-10 10:43:02 -0500 | [diff] [blame] | 225 | mSlidingPaneLayout.setCurFragment(mCurrentCallFragment); |
Alexandre Lision | 5f144b8 | 2014-02-11 09:59:36 -0500 | [diff] [blame] | 226 | getSupportFragmentManager().beginTransaction().replace(R.id.ongoingcall_pane, mCurrentCallFragment) |
Alexandre Lision | 3e1e06f | 2014-02-10 12:13:25 -0500 | [diff] [blame] | 227 | .replace(R.id.message_list_frame, mIMFragment).commit(); |
alision | d8c8388 | 2013-05-17 17:00:42 -0400 | [diff] [blame] | 228 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 229 | } |
Adrien Béraud | 6bbce91 | 2013-05-24 00:48:13 +1000 | [diff] [blame] | 230 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 231 | @Override |
| 232 | public void onServiceDisconnected(ComponentName arg0) { |
| 233 | } |
| 234 | }; |
Adrien Béraud | 6bbce91 | 2013-05-24 00:48:13 +1000 | [diff] [blame] | 235 | |
alision | 7f18fc8 | 2013-05-01 09:37:33 -0400 | [diff] [blame] | 236 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 237 | @Override |
| 238 | public ISipService getService() { |
Alexandre Lision | 47a7204 | 2013-12-10 10:43:02 -0500 | [diff] [blame] | 239 | return mService; |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 240 | } |
alision | 04a0018 | 2013-05-10 17:05:29 -0400 | [diff] [blame] | 241 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 242 | @Override |
Alexandre Lision | 48b49eb | 2014-02-11 13:37:33 -0500 | [diff] [blame] | 243 | public Conference getDisplayedConference() { |
| 244 | return mDisplayedConference; |
| 245 | } |
| 246 | |
| 247 | @Override |
Alexandre Lision | a7ab2e3 | 2014-02-14 15:33:33 -0500 | [diff] [blame] | 248 | public void updateDisplayedConference(Conference c) { |
Alexandre Lision | a7ab2e3 | 2014-02-14 15:33:33 -0500 | [diff] [blame] | 249 | if(mDisplayedConference.equals(c)){ |
Alexandre Lision | a7ab2e3 | 2014-02-14 15:33:33 -0500 | [diff] [blame] | 250 | mDisplayedConference = c; |
| 251 | } |
| 252 | } |
| 253 | |
| 254 | @Override |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 255 | public void onBackPressed() { |
| 256 | super.onBackPressed(); |
Alexandre Lision | 4ab5397 | 2013-11-04 16:59:18 -0500 | [diff] [blame] | 257 | Intent launchHome = new Intent(this, HomeActivity.class); |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 258 | launchHome.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); |
Alexandre Lision | 5ed2c97 | 2013-10-11 15:36:33 -0400 | [diff] [blame] | 259 | launchHome.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 260 | startActivity(launchHome); |
| 261 | } |
alision | 8599211 | 2013-05-29 12:18:08 -0400 | [diff] [blame] | 262 | |
alision | 806e18e | 2013-06-21 15:30:17 -0400 | [diff] [blame] | 263 | @Override |
Alexandre Lision | dafe951 | 2013-10-28 16:31:41 -0400 | [diff] [blame] | 264 | public void terminateCall() { |
Alexandre Lision | ccf0c93 | 2013-10-10 16:24:41 -0400 | [diff] [blame] | 265 | mHandler.removeCallbacks(mUpdateTimeTask); |
| 266 | mCurrentCallFragment.getBubbleView().stopThread(); |
Alexandre Lision | e4b9584 | 2013-11-12 10:36:51 -0500 | [diff] [blame] | 267 | TimerTask quit = new TimerTask() { |
Alexandre Lision | 3b7148e | 2013-11-13 17:23:06 -0500 | [diff] [blame] | 268 | |
Alexandre Lision | e4b9584 | 2013-11-12 10:36:51 -0500 | [diff] [blame] | 269 | @Override |
| 270 | public void run() { |
Alexandre Lision | 2cd17d3 | 2014-02-27 15:57:20 -0500 | [diff] [blame] | 271 | /*try { |
Alexandre Lision | 3c37dca | 2014-02-21 14:13:26 -0500 | [diff] [blame] | 272 | // We hang it up again to avoid infinite failure tone |
| 273 | mService.hangUp(mDisplayedConference.getId()); |
| 274 | } catch (RemoteException e) { |
| 275 | e.printStackTrace(); |
Alexandre Lision | 2cd17d3 | 2014-02-27 15:57:20 -0500 | [diff] [blame] | 276 | }*/ |
Alexandre Lision | e4b9584 | 2013-11-12 10:36:51 -0500 | [diff] [blame] | 277 | finish(); |
| 278 | } |
| 279 | }; |
Alexandre Lision | 3b7148e | 2013-11-13 17:23:06 -0500 | [diff] [blame] | 280 | |
Alexandre Lision | 681d029 | 2013-11-22 12:47:34 -0500 | [diff] [blame] | 281 | new Timer().schedule(quit, 1000); |
Alexandre Lision | ccf0c93 | 2013-10-10 16:24:41 -0400 | [diff] [blame] | 282 | } |
alision | 806e18e | 2013-06-21 15:30:17 -0400 | [diff] [blame] | 283 | |
Alexandre Lision | 0c38451 | 2013-09-17 17:15:57 -0400 | [diff] [blame] | 284 | @Override |
Alexandre Lision | d568603 | 2013-10-29 11:09:21 -0400 | [diff] [blame] | 285 | public boolean sendIM(SipMessage msg) { |
| 286 | |
| 287 | try { |
Alexandre Lision | a7ab2e3 | 2014-02-14 15:33:33 -0500 | [diff] [blame] | 288 | Log.i(TAG, "Sending:"+msg.comment+"to"+mDisplayedConference.getId()); |
| 289 | mService.sendTextMessage(mDisplayedConference.getId(), msg); |
Alexandre Lision | d568603 | 2013-10-29 11:09:21 -0400 | [diff] [blame] | 290 | } catch (RemoteException e) { |
| 291 | e.printStackTrace(); |
| 292 | return false; |
| 293 | } |
| 294 | |
| 295 | return true; |
| 296 | } |
| 297 | |
| 298 | @Override |
Alexandre Lision | 0c38451 | 2013-09-17 17:15:57 -0400 | [diff] [blame] | 299 | public void startTimer() { |
| 300 | mHandler.postDelayed(mUpdateTimeTask, 0); |
| 301 | } |
| 302 | |
Alexandre Lision | 6885547 | 2013-10-10 16:20:46 -0400 | [diff] [blame] | 303 | @Override |
| 304 | public void slideChatScreen() { |
Alexandre Lision | 666b377 | 2013-10-28 17:42:48 -0400 | [diff] [blame] | 305 | |
Alexandre Lision | 47a7204 | 2013-12-10 10:43:02 -0500 | [diff] [blame] | 306 | if (mSlidingPaneLayout.isOpen()) { |
| 307 | mSlidingPaneLayout.closePane(); |
Alexandre Lision | 666b377 | 2013-10-28 17:42:48 -0400 | [diff] [blame] | 308 | } else { |
| 309 | mCurrentCallFragment.getBubbleView().stopThread(); |
Alexandre Lision | 47a7204 | 2013-12-10 10:43:02 -0500 | [diff] [blame] | 310 | mSlidingPaneLayout.openPane(); |
Alexandre Lision | 666b377 | 2013-10-28 17:42:48 -0400 | [diff] [blame] | 311 | } |
Alexandre Lision | 6885547 | 2013-10-10 16:20:46 -0400 | [diff] [blame] | 312 | } |
Alexandre Lision | b8add81 | 2013-10-24 11:42:42 -0400 | [diff] [blame] | 313 | |
| 314 | @Override |
| 315 | public boolean shouldActivateProximity() { |
| 316 | return true; |
| 317 | } |
| 318 | |
| 319 | @Override |
| 320 | public void onProximityTrackingChanged(boolean acquired) { |
| 321 | // TODO Stub de la méthode généré automatiquement |
Alexandre Lision | 666b377 | 2013-10-28 17:42:48 -0400 | [diff] [blame] | 322 | |
Alexandre Lision | b8add81 | 2013-10-24 11:42:42 -0400 | [diff] [blame] | 323 | } |
Alexandre Savard | 14323be | 2012-10-24 10:02:13 -0400 | [diff] [blame] | 324 | } |