blob: b4f99a4e26da222acf6fefb8ef92ebf67c2146b2 [file] [log] [blame]
Adrien Béraudffd32412012-08-07 18:39:23 -04001/*
2 * Copyright (C) 2004-2012 Savoir-Faire Linux Inc.
3 *
4 * Author: Adrien Beraud <adrien.beraud@gmail.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 */
31package com.savoirfairelinux.sflphone.client;
32
Emeric Vigiere89b48b2012-08-30 14:16:46 -040033import java.util.Random;
34
Adrien Béraudffd32412012-08-07 18:39:23 -040035import android.app.ActionBar;
36import android.app.Activity;
Emeric Vigier12d61d82012-09-19 15:08:18 -040037import android.app.AlertDialog;
Adrien Béraudffd32412012-08-07 18:39:23 -040038import android.app.Fragment;
39import android.app.FragmentManager;
40import android.app.FragmentTransaction;
Emeric Vigier6119d782012-09-21 18:04:14 -040041import android.content.ComponentName;
42import android.content.Context;
Alexandre Savard1bcaf532012-09-05 16:23:02 -040043import android.content.Intent;
Emeric Vigier6119d782012-09-21 18:04:14 -040044import android.content.ServiceConnection;
Adrien Béraudffd32412012-08-07 18:39:23 -040045import android.os.Bundle;
Emeric Vigier383b2a22012-08-27 14:20:05 -040046import android.os.Handler;
Emeric Vigier6119d782012-09-21 18:04:14 -040047import android.os.IBinder;
Emeric Vigier383b2a22012-08-27 14:20:05 -040048import android.os.Message;
Emeric Vigier6119d782012-09-21 18:04:14 -040049import android.os.RemoteException;
Adrien Béraudffd32412012-08-07 18:39:23 -040050import android.support.v13.app.FragmentStatePagerAdapter;
51import android.support.v4.view.ViewPager;
Emeric Vigier05e894e2012-08-20 13:53:02 -040052import android.util.Log;
Adrien Béraudffd32412012-08-07 18:39:23 -040053import android.view.Gravity;
54import android.view.LayoutInflater;
55import android.view.Menu;
Alexandre Savard1bcaf532012-09-05 16:23:02 -040056import android.view.MenuItem;
Adrien Béraudffd32412012-08-07 18:39:23 -040057import android.view.View;
Emeric Vigier05e894e2012-08-20 13:53:02 -040058import android.view.View.OnClickListener;
Adrien Béraudffd32412012-08-07 18:39:23 -040059import android.view.ViewGroup;
Emeric Vigiera6bdb702012-08-31 15:34:53 -040060import android.view.animation.AlphaAnimation;
61import android.view.animation.Animation;
62import android.view.animation.LinearInterpolator;
Emeric Vigiereaf2c492012-09-19 14:38:20 -040063import android.widget.Button;
Emeric Vigierd5c17f52012-08-29 09:29:33 -040064import android.widget.EditText;
Emeric Vigiere89b48b2012-08-30 14:16:46 -040065import android.widget.ImageButton;
Adrien Béraudffd32412012-08-07 18:39:23 -040066import android.widget.TextView;
67
68import com.savoirfairelinux.sflphone.R;
Emeric Vigier6119d782012-09-21 18:04:14 -040069import com.savoirfairelinux.sflphone.service.ISipService;
Emeric Vigiereaf2c492012-09-19 14:38:20 -040070import com.savoirfairelinux.sflphone.service.SipService;
Adrien Béraudffd32412012-08-07 18:39:23 -040071
Emeric Vigier62ca14d2012-08-24 11:05:09 -040072public class SFLPhoneHome extends Activity implements ActionBar.TabListener, OnClickListener
Adrien Béraudffd32412012-08-07 18:39:23 -040073{
Alexandre Savard6c0584e2012-09-20 09:42:59 -040074 SectionsPagerAdapter mSectionsPagerAdapter;
75 static final String TAG = "SFLPhoneHome";
76 private ButtonSectionFragment buttonFragment;
Alexandre Savard6c0584e2012-09-20 09:42:59 -040077 /* default callID */
78 static String callID = "007";
79 static boolean callOnGoing = false;
Emeric Vigiereaf2c492012-09-19 14:38:20 -040080 static boolean serviceIsOn = false;
Alexandre Savard6c0584e2012-09-20 09:42:59 -040081 private String incomingCallID = "";
82 private static final int REQUEST_CODE_PREFERENCES = 1;
83 ImageButton buttonCall, buttonHangup;
84 Button buttonService;
Emeric Vigier419ba7b2012-09-19 14:55:14 -040085 static Animation animation;
Alexandre Savard6c0584e2012-09-20 09:42:59 -040086 ContactListFragment mContactListFragment;
87 CallElementList mCallElementList;
Emeric Vigier6119d782012-09-21 18:04:14 -040088 private boolean mBound = false;
89 private ISipService service;
Adrien Béraudffd32412012-08-07 18:39:23 -040090
Alexandre Savard6c0584e2012-09-20 09:42:59 -040091 /**
92 * The {@link ViewPager} that will host the section contents.
93 */
94 ViewPager mViewPager;
Emeric Vigierbbde1ae2012-09-21 18:13:56 -040095
Alexandre Savard6c0584e2012-09-20 09:42:59 -040096 final private int[] icon_res_id = {R.drawable.ic_tab_call, R.drawable.ic_tab_call, R.drawable.ic_tab_history, R.drawable.ic_tab_play_selected};
Adrien Béraudffd32412012-08-07 18:39:23 -040097
Alexandre Savard6c0584e2012-09-20 09:42:59 -040098 @Override
99 public void onCreate(Bundle savedInstanceState)
100 {
101 super.onCreate(savedInstanceState);
102 setContentView(R.layout.activity_sflphone_home);
Adrien Béraudffd32412012-08-07 18:39:23 -0400103
Alexandre Savard6c0584e2012-09-20 09:42:59 -0400104 mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager());
Adrien Béraudffd32412012-08-07 18:39:23 -0400105
Alexandre Savard6c0584e2012-09-20 09:42:59 -0400106 final ActionBar actionBar = getActionBar();
107 actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
108 // final ActionBar actionBar = getActionBar();
Adrien Béraudffd32412012-08-07 18:39:23 -0400109
Alexandre Savard6c0584e2012-09-20 09:42:59 -0400110 // Set up the ViewPager with the sections adapter.
111 mViewPager = (ViewPager) findViewById(R.id.pager);
112 mViewPager.setAdapter(mSectionsPagerAdapter);
Adrien Béraudffd32412012-08-07 18:39:23 -0400113
Alexandre Savard6c0584e2012-09-20 09:42:59 -0400114 // When swiping between different sections, select the corresponding tab.
115 // We can also use ActionBar.Tab#select() to do this if we have a reference to the
116 // Tab.
117 mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener()
118 {
119 @Override
120 public void onPageSelected(int position)
121 {
122 actionBar.setSelectedNavigationItem(position);
123 }
124 });
Emeric Vigier383b2a22012-08-27 14:20:05 -0400125
Alexandre Savard6c0584e2012-09-20 09:42:59 -0400126 // For each of the sections in the app, add a tab to the action bar.
127 for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
128 // Create a tab with text corresponding to the page title defined by the adapter.
129 // Also specify this Activity object, which implements the TabListener interface, as the
130 // listener for when this tab is selected.
131 Log.i(TAG, "adding tab: " + i);
132 actionBar.addTab(actionBar.newTab().setIcon(icon_res_id[i]).setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
133 }
Emeric Vigier383b2a22012-08-27 14:20:05 -0400134
Alexandre Savard6c0584e2012-09-20 09:42:59 -0400135 buttonCall = (ImageButton) findViewById(R.id.buttonCall);
136 buttonHangup = (ImageButton) findViewById(R.id.buttonHangUp);
Alexandre Savarddef3bfa2012-09-12 16:20:06 -0400137
Emeric Vigier419ba7b2012-09-19 14:55:14 -0400138 // Change alpha from fully visible to invisible
139 animation = new AlphaAnimation(1, 0);
140 // duration - half a second
141 animation.setDuration(500);
142 // do not alter animation rate
143 animation.setInterpolator(new LinearInterpolator());
144 // Repeat animation infinitely
145 animation.setRepeatCount(Animation.INFINITE);
146 // Reverse
147 animation.setRepeatMode(Animation.REVERSE);
Adrien Béraudffd32412012-08-07 18:39:23 -0400148
Emeric Vigierfae29bd2012-09-24 11:32:03 -0400149 if (!serviceIsOn) {
150 Log.i(TAG, "starting SipService");
151 startSipService();
152 }
Alexandre Savard6c0584e2012-09-20 09:42:59 -0400153 }
Alexandre Savard1bcaf532012-09-05 16:23:02 -0400154
Emeric Vigier12d61d82012-09-19 15:08:18 -0400155 @Override
156 protected void onStart() {
157 Log.i(TAG, "onStart");
158 super.onStart();
Emeric Vigier6119d782012-09-21 18:04:14 -0400159 // Bind to LocalService
160 if (!mBound) {
Emeric Vigierfae29bd2012-09-24 11:32:03 -0400161 Log.i(TAG, "onStart: Binding service...");
Emeric Vigier6119d782012-09-21 18:04:14 -0400162 Intent intent = new Intent(this, SipService.class);
163 bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
164 }
Emeric Vigier12d61d82012-09-19 15:08:18 -0400165 }
Alexandre Savard1bcaf532012-09-05 16:23:02 -0400166
Emeric Vigier6119d782012-09-21 18:04:14 -0400167 /* user gets back to the activity, e.g. through task manager */
Emeric Vigier12d61d82012-09-19 15:08:18 -0400168 @Override
169 protected void onRestart() {
170 super.onRestart();
171 }
172
Emeric Vigier6119d782012-09-21 18:04:14 -0400173 /* activity gets back to the foreground and user input */
Emeric Vigier12d61d82012-09-19 15:08:18 -0400174 @Override
175 protected void onResume() {
176 Log.i(TAG, "onResume");
177 super.onResume();
Emeric Vigier12d61d82012-09-19 15:08:18 -0400178 }
179
Emeric Vigier6119d782012-09-21 18:04:14 -0400180 /* activity no more in foreground */
Emeric Vigier12d61d82012-09-19 15:08:18 -0400181 @Override
182 protected void onPause() {
Emeric Vigier12d61d82012-09-19 15:08:18 -0400183 super.onPause();
184 }
185
Emeric Vigier6119d782012-09-21 18:04:14 -0400186 /* activity is no longer visible */
Emeric Vigier12d61d82012-09-19 15:08:18 -0400187 @Override
188 protected void onStop() {
189 super.onStop();
Emeric Vigier6119d782012-09-21 18:04:14 -0400190 /* stop the service, if no other bound user, no need to check if it is running */
191 if (mBound) {
Emeric Vigierfae29bd2012-09-24 11:32:03 -0400192 Log.i(TAG, "onStop: Unbinding service...");
Emeric Vigier6119d782012-09-21 18:04:14 -0400193 unbindService(mConnection);
194 mBound = false;
195 }
Emeric Vigier12d61d82012-09-19 15:08:18 -0400196 }
197
Emeric Vigier6119d782012-09-21 18:04:14 -0400198 /* activity finishes itself or is being killed by the system */
Emeric Vigier12d61d82012-09-19 15:08:18 -0400199 @Override
200 protected void onDestroy() {
Emeric Vigierfae29bd2012-09-24 11:32:03 -0400201 Log.i(TAG, "onDestroy: stopping SipService...");
202 stopService(new Intent(this, SipService.class));
Emeric Vigier6119d782012-09-21 18:04:14 -0400203 serviceIsOn = false;
Emeric Vigier12d61d82012-09-19 15:08:18 -0400204 super.onDestroy();
205 }
206
Emeric Vigier6119d782012-09-21 18:04:14 -0400207 /** Defines callbacks for service binding, passed to bindService() */
208 private ServiceConnection mConnection = new ServiceConnection() {
209
210 @Override
211 public void onServiceConnected(ComponentName className,
212 IBinder binder) {
213 service = ISipService.Stub.asInterface(binder);
214 mBound = true;
215 Log.d(TAG, "Service connected");
216 }
217
218 @Override
219 public void onServiceDisconnected(ComponentName arg0) {
220 mBound = false;
221 Log.d(TAG, "Service disconnected");
222 }
223 };
224
Emeric Vigier12d61d82012-09-19 15:08:18 -0400225 private void startSipService() {
226 Thread thread = new Thread("StartSFLphoneService") {
227 public void run() {
228 Intent sipServiceIntent = new Intent(SFLPhoneHome.this, SipService.class);
229 //sipServiceIntent.putExtra(ServiceConstants.EXTRA_OUTGOING_ACTIVITY, new ComponentName(SFLPhoneHome.this, SFLPhoneHome.class));
230 startService(sipServiceIntent);
Emeric Vigierfae29bd2012-09-24 11:32:03 -0400231 serviceIsOn = true;
Emeric Vigier12d61d82012-09-19 15:08:18 -0400232 };
233 };
234 try {
235 thread.start();
236 } catch (IllegalThreadStateException e) {
237 AlertDialog.Builder builder = new AlertDialog.Builder(this);
238 builder.setMessage("Cannot start SFLPhone SipService!");
239 AlertDialog alert = builder.create();
240 alert.show();
241 finish();
242 }
Emeric Vigier12d61d82012-09-19 15:08:18 -0400243 }
244
245 @Override
246 public boolean onOptionsItemSelected(MenuItem item) {
247 Log.i("SFLphone", "onOptionsItemSelected " + item.getItemId());
Emeric Vigierbbde1ae2012-09-21 18:13:56 -0400248 if(item.getItemId() != 0) {
249 // When the button is clicked, launch an activity through this intent
250 Intent launchPreferencesIntent = new Intent().setClass(this, SFLPhonePreferenceActivity.class);
Alexandre Savard1bcaf532012-09-05 16:23:02 -0400251
Emeric Vigierbbde1ae2012-09-21 18:13:56 -0400252 // Make it a subactivity so we know when it returns
253 startActivityForResult(launchPreferencesIntent, REQUEST_CODE_PREFERENCES);
Alexandre Savard1bcaf532012-09-05 16:23:02 -0400254 }
Adrien Béraudffd32412012-08-07 18:39:23 -0400255
Emeric Vigierbbde1ae2012-09-21 18:13:56 -0400256 return super.onOptionsItemSelected(item);
257 }
Adrien Béraudffd32412012-08-07 18:39:23 -0400258
Emeric Vigierbbde1ae2012-09-21 18:13:56 -0400259 @Override
260 public boolean onCreateOptionsMenu(Menu menu)
261 {
262 getMenuInflater().inflate(R.menu.activity_sflphone_home, menu);
263 return true;
264 }
Adrien Béraudffd32412012-08-07 18:39:23 -0400265
Emeric Vigierbbde1ae2012-09-21 18:13:56 -0400266 @Override
267 public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction)
268 {
269 }
Adrien Béraudffd32412012-08-07 18:39:23 -0400270
Emeric Vigierbbde1ae2012-09-21 18:13:56 -0400271 @Override
272 public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction)
273 {
274 // When the given tab is selected, switch to the corresponding page in the ViewPager.
275 mViewPager.setCurrentItem(tab.getPosition());
276 }
277
278 @Override
279 public void onTabReselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction)
280 {
281 // Log.d(TAG, "onTabReselected");
282 }
283
284 public void setIncomingCallID(String accountID, String callID, String from) {
Emeric Vigier419ba7b2012-09-19 14:55:14 -0400285 Log.i(TAG, "incomingCall(" + accountID + ", " + callID + ", " + from + ")");
Emeric Vigierbbde1ae2012-09-21 18:13:56 -0400286 incomingCallID = callID;
Emeric Vigier419ba7b2012-09-19 14:55:14 -0400287 buttonCall.startAnimation(animation);
288 buttonCall.setImageResource(R.drawable.ic_incomingcall);
Emeric Vigierbbde1ae2012-09-21 18:13:56 -0400289 }
Adrien Béraudffd32412012-08-07 18:39:23 -0400290
Emeric Vigierbbde1ae2012-09-21 18:13:56 -0400291 /**
292 * A {@link FragmentStatePagerAdapter} that returns a fragment corresponding to
293 * one of the primary sections of the app.
294 */
295 public class SectionsPagerAdapter extends FragmentStatePagerAdapter
296 {
Adrien Béraudffd32412012-08-07 18:39:23 -0400297
Emeric Vigierbbde1ae2012-09-21 18:13:56 -0400298 public SectionsPagerAdapter(FragmentManager fm)
299 {
300 super(fm);
301 }
Emeric Vigier05e894e2012-08-20 13:53:02 -0400302
Emeric Vigierbbde1ae2012-09-21 18:13:56 -0400303 @Override
304 public Fragment getItem(int i)
305 {
306 Fragment fragment;
Adrien Béraudffd32412012-08-07 18:39:23 -0400307
Emeric Vigierbbde1ae2012-09-21 18:13:56 -0400308 switch (i) {
309 case 0:
310 mContactListFragment = new ContactListFragment();
311 fragment = mContactListFragment;
312 break;
313 case 1:
314 mCallElementList = new CallElementList();
315 SipCall.setCallElementList(mCallElementList);
316 fragment = mCallElementList;
317 break;
318 case 2:
319 fragment = new DummySectionFragment();
320 break;
321 case 3:
322 fragment = new ButtonSectionFragment();
323 Log.i(TAG, "getItem: fragment is " + fragment);
324 break;
325 default:
326 Log.e(TAG, "getItem: unknown tab position " + i);
327 return null;
328 }
Adrien Béraudffd32412012-08-07 18:39:23 -0400329
Emeric Vigierbbde1ae2012-09-21 18:13:56 -0400330 Bundle args = new Bundle();
331 args.putInt(DummySectionFragment.ARG_SECTION_NUMBER, i + 1);
332 fragment.setArguments(args);
333 return fragment;
334 }
Adrien Béraudffd32412012-08-07 18:39:23 -0400335
Emeric Vigierbbde1ae2012-09-21 18:13:56 -0400336 @Override
337 public int getCount()
338 {
339 return 4;
340 }
Adrien Béraudffd32412012-08-07 18:39:23 -0400341
Emeric Vigierbbde1ae2012-09-21 18:13:56 -0400342 @Override
343 public CharSequence getPageTitle(int position)
344 {
345 switch (position) {
346 case 0:
347 return getString(R.string.title_section0).toUpperCase();
348 case 1:
349 return getString(R.string.title_section1).toUpperCase();
350 case 2:
351 return getString(R.string.title_section2).toUpperCase();
352 case 3:
353 return getString(R.string.title_section3).toUpperCase();
354 default:
355 Log.e(TAG, "getPageTitle: unknown tab position " + position);
356 break;
357 }
358 return null;
359 }
360 }
Adrien Béraudffd32412012-08-07 18:39:23 -0400361
Emeric Vigierbbde1ae2012-09-21 18:13:56 -0400362 /**
363 * A dummy fragment representing a section of the app, but that simply
364 * displays dummy text.
365 */
366 public static class DummySectionFragment extends Fragment
367 {
368 public DummySectionFragment()
369 {
370 setRetainInstance(true);
371 }
Emeric Vigier05e894e2012-08-20 13:53:02 -0400372
Emeric Vigierbbde1ae2012-09-21 18:13:56 -0400373 public static final String ARG_SECTION_NUMBER = "section_number";
374
375 @Override
376 public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState)
377 {
378 TextView textView = new TextView(getActivity());
379 textView.setGravity(Gravity.CENTER);
380 Bundle args = getArguments();
381 textView.setText(Integer.toString(args.getInt(ARG_SECTION_NUMBER)));
382 textView.setText("java sucks");
383 return textView;
384 }
385 }
386
387 @Override
Emeric Vigier62ca14d2012-08-24 11:05:09 -0400388 public void onClick(View view)
Emeric Vigiere89b48b2012-08-30 14:16:46 -0400389 {
Alexandre Savard2c50e692012-09-24 11:18:31 -0400390 Log.i("SFLPhoneHome", "onClic from SFLPhoneHome");
391
Emeric Vigiereaf2c492012-09-19 14:38:20 -0400392 buttonService = (Button) findViewById(R.id.buttonService);
Emeric Vigier6119d782012-09-21 18:04:14 -0400393
394 try {
Emeric Vigierbbde1ae2012-09-21 18:13:56 -0400395 switch (view.getId()) {
396 case R.id.buttonCall:
397 TextView textView = (TextView) findViewById(R.id.editAccountID);
398 String accountID = textView.getText().toString();
399 EditText editText;
400 Random random = new Random();
Emeric Vigiere89b48b2012-08-30 14:16:46 -0400401
Emeric Vigierbbde1ae2012-09-21 18:13:56 -0400402 if (incomingCallID != "") {
403 buttonCall.clearAnimation();
404 service.accept(incomingCallID);
405 callID = incomingCallID;
406 incomingCallID="";
407 callOnGoing = true;
408 buttonCall.setEnabled(false);
409 buttonHangup.setEnabled(true);
410 } else {
411 if (callOnGoing == false) {
412 editText = (EditText) findViewById(R.id.editTo);
413 String to = editText.getText().toString();
414 if (to == null) {
415 Log.e(TAG, "to string is " + to);
416 break;
417 }
Emeric Vigiera6bdb702012-08-31 15:34:53 -0400418
Emeric Vigierbbde1ae2012-09-21 18:13:56 -0400419 callID = Integer.toString(random.nextInt());
Emeric Vigiera6bdb702012-08-31 15:34:53 -0400420
Emeric Vigierbbde1ae2012-09-21 18:13:56 -0400421 Log.d(TAG, "service.placeCall(" + accountID + ", " + callID + ", " + to + ");");
422 service.placeCall(accountID, callID, to);
423 callOnGoing = true;
424 buttonCall.setEnabled(false);
425 buttonHangup.setEnabled(true);
426 }
427 }
428 break;
429 case R.id.buttonHangUp:
430 if (incomingCallID != "") {
431 buttonCall.clearAnimation();
432 Log.d(TAG, "service.refuse(" + incomingCallID + ");");
433 service.refuse(incomingCallID);
434 incomingCallID="";
435 buttonCall.setEnabled(true);
436 buttonHangup.setEnabled(true);
437 } else {
438 if (callOnGoing == true) {
439 Log.d(TAG, "service.hangUp(" + callID + ");");
440 service.hangUp(callID);
441 callOnGoing = false;
442 buttonCall.setEnabled(true);
443 buttonHangup.setEnabled(false);
444 }
445 }
Emeric Vigiera6bdb702012-08-31 15:34:53 -0400446
Emeric Vigierbbde1ae2012-09-21 18:13:56 -0400447 buttonCall.setImageResource(R.drawable.ic_call);
448 break;
449 case R.id.buttonInit:
450 Log.i(TAG, "R.id.buttonInit");
451 break;
452 case R.id.buttonService:
453 if (!serviceIsOn) {
454 startService(new Intent(this, SipService.class));
455 serviceIsOn = true;
456 buttonService.setText("disable Service");
457 }
458 else {
459 stopService(new Intent(this, SipService.class));
460 serviceIsOn = false;
461 buttonService.setText("enable Service");
462 }
463 break;
Emeric Vigierbbde1ae2012-09-21 18:13:56 -0400464 default:
465 Log.w(TAG, "unknown button " + view.getId());
466 break;
Emeric Vigiereaf2c492012-09-19 14:38:20 -0400467 }
Emeric Vigier6119d782012-09-21 18:04:14 -0400468 } catch (RemoteException e) {
469 Log.e(TAG, "Cannot call service method", e);
470 }
Emeric Vigierbbde1ae2012-09-21 18:13:56 -0400471 }
Adrien Béraudffd32412012-08-07 18:39:23 -0400472}