blob: dd1a74698d7b0e5285ee5825c69451f1587d612e [file] [log] [blame]
alisionf76de3b2013-04-16 15:35:22 -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
alision04a00182013-05-10 17:05:29 -040033import java.io.ObjectInputStream.GetField;
34
alisionf76de3b2013-04-16 15:35:22 -040035import android.app.ActionBar;
36import android.app.Activity;
37import android.app.Fragment;
38import android.app.FragmentManager;
39import android.app.FragmentTransaction;
40import android.content.ComponentName;
41import android.content.Context;
42import android.content.Intent;
alisionf76de3b2013-04-16 15:35:22 -040043import android.content.ServiceConnection;
44import android.os.Bundle;
45import android.os.IBinder;
alision5f899632013-04-22 17:26:56 -040046import android.os.RemoteException;
alisionf76de3b2013-04-16 15:35:22 -040047import android.support.v13.app.FragmentStatePagerAdapter;
alisionf76de3b2013-04-16 15:35:22 -040048import android.support.v4.view.ViewPager;
49import android.util.Log;
alisionf76de3b2013-04-16 15:35:22 -040050import android.view.Menu;
51import android.view.MenuItem;
alisionf76de3b2013-04-16 15:35:22 -040052import android.widget.ImageButton;
alision04a00182013-05-10 17:05:29 -040053import android.widget.Toast;
alisionf76de3b2013-04-16 15:35:22 -040054
55import com.savoirfairelinux.sflphone.R;
alisionf76de3b2013-04-16 15:35:22 -040056import com.savoirfairelinux.sflphone.fragments.CallElementListFragment;
57import com.savoirfairelinux.sflphone.fragments.ContactListFragment;
alisiond9e29442013-04-17 16:10:18 -040058import com.savoirfairelinux.sflphone.fragments.HistoryFragment;
alisionf76de3b2013-04-16 15:35:22 -040059import com.savoirfairelinux.sflphone.model.SipCall;
alision5f899632013-04-22 17:26:56 -040060import com.savoirfairelinux.sflphone.service.ISipClient;
alisionf76de3b2013-04-16 15:35:22 -040061import com.savoirfairelinux.sflphone.service.ISipService;
62import com.savoirfairelinux.sflphone.service.SipService;
63
alisione2a38e12013-04-25 14:20:20 -040064public class SFLPhoneHomeActivity extends Activity implements ActionBar.TabListener, CallElementListFragment.Callbacks, HistoryFragment.Callbacks {
alision5f899632013-04-22 17:26:56 -040065 SectionsPagerAdapter mSectionsPagerAdapter = null;
66 static final String TAG = "SFLPhoneHome";
67 private static final int REQUEST_CODE_PREFERENCES = 1;
68 ImageButton buttonCall, buttonHangup;
69 private ContactListFragment mContactListFragment = null;
70 private CallElementListFragment mCallElementList = null;
71 private HistoryFragment mHistorySectionFragment = null;
72 private boolean mBound = false;
73 private ISipService service;
alisionf76de3b2013-04-16 15:35:22 -040074
alision5f899632013-04-22 17:26:56 -040075 private static final int ACTION_BAR_TAB_CONTACT = 0;
76 private static final int ACTION_BAR_TAB_CALL = 1;
77 private static final int ACTION_BAR_TAB_HISTORY = 2;
alisionf76de3b2013-04-16 15:35:22 -040078
alision5f899632013-04-22 17:26:56 -040079 /**
80 * The {@link ViewPager} that will host the section contents.
81 */
82 ViewPager mViewPager;
alisionf76de3b2013-04-16 15:35:22 -040083
alision5f899632013-04-22 17:26:56 -040084 final private int[] icon_res_id = { R.drawable.ic_tab_call, R.drawable.ic_tab_call, R.drawable.ic_tab_history };
alisionf76de3b2013-04-16 15:35:22 -040085
alision5f899632013-04-22 17:26:56 -040086 // public SFLPhoneHome extends Activity implements ActionBar.TabListener, OnClickListener
alisionf76de3b2013-04-16 15:35:22 -040087
alision5f899632013-04-22 17:26:56 -040088 /* called before activity is killed, e.g. rotation */
89 @Override
90 protected void onSaveInstanceState(Bundle bundle) {
91 super.onSaveInstanceState(bundle);
92 for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
93 try {
94 /* putFragment (Bundle bundle, String key, Fragment fragment) */
95 getFragmentManager().putFragment(bundle, mSectionsPagerAdapter.getClassName(i), mSectionsPagerAdapter.getFragment(i));
96 } catch (IllegalStateException e) {
alision7f18fc82013-05-01 09:37:33 -040097 Log.e(TAG, "fragment=" + mSectionsPagerAdapter.getFragment(i));
alision5f899632013-04-22 17:26:56 -040098 }
99 }
100 Log.w(TAG, "onSaveInstanceState()");
101 }
alisionf76de3b2013-04-16 15:35:22 -0400102
alision5f899632013-04-22 17:26:56 -0400103 @Override
104 public void onCreate(Bundle savedInstanceState) {
105 super.onCreate(savedInstanceState);
alisionf76de3b2013-04-16 15:35:22 -0400106
alision5f899632013-04-22 17:26:56 -0400107 // Bind to LocalService
108 if (!mBound) {
109 Log.i(TAG, "onStart: Binding service...");
110 Intent intent = new Intent(this, SipService.class);
111 bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
112 }
alisionf76de3b2013-04-16 15:35:22 -0400113
alision5f899632013-04-22 17:26:56 -0400114 setContentView(R.layout.activity_sflphone_home);
alisionf76de3b2013-04-16 15:35:22 -0400115
alision5f899632013-04-22 17:26:56 -0400116 if (mSectionsPagerAdapter == null) {
117 mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager());
118 }
alisionf76de3b2013-04-16 15:35:22 -0400119
alision5f899632013-04-22 17:26:56 -0400120 /* getFragment(Bundle, String) */
121 if (savedInstanceState != null) {
122 Log.w(TAG, "Activity restarted, recreating PagerAdapter...");
123 /* getFragment (Bundle bundle, String key) */
124 mContactListFragment = (ContactListFragment) getFragmentManager().getFragment(savedInstanceState,
125 mSectionsPagerAdapter.getClassName(ACTION_BAR_TAB_CONTACT));
126 mCallElementList = (CallElementListFragment) getFragmentManager().getFragment(savedInstanceState,
127 mSectionsPagerAdapter.getClassName(ACTION_BAR_TAB_CALL));
128 mHistorySectionFragment = (HistoryFragment) getFragmentManager().getFragment(savedInstanceState,
129 mSectionsPagerAdapter.getClassName(ACTION_BAR_TAB_HISTORY));
130 }
alisionf76de3b2013-04-16 15:35:22 -0400131
alision5f899632013-04-22 17:26:56 -0400132 if (mContactListFragment == null) {
133 mContactListFragment = new ContactListFragment();
134 Log.w(TAG, "Recreated mContactListFragment=" + mContactListFragment);
135 }
136 if (mCallElementList == null) {
137 mCallElementList = new CallElementListFragment();
138 Log.w(TAG, "Recreated mCallElementList=" + mCallElementList);
139 }
140 if (mHistorySectionFragment == null) {
141 mHistorySectionFragment = new HistoryFragment();
142 Log.w(TAG, "Recreated mHistorySectionFragment=" + mHistorySectionFragment);
143 }
alisionf76de3b2013-04-16 15:35:22 -0400144
alision5f899632013-04-22 17:26:56 -0400145 final ActionBar actionBar = getActionBar();
146 actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
147 // final ActionBar actionBar = getActionBar();
alisionf76de3b2013-04-16 15:35:22 -0400148
alision5f899632013-04-22 17:26:56 -0400149 // Set up the ViewPager with the sections adapter.
150 mViewPager = (ViewPager) findViewById(R.id.pager);
151 mViewPager.setAdapter(mSectionsPagerAdapter);
alisionf76de3b2013-04-16 15:35:22 -0400152
alision5f899632013-04-22 17:26:56 -0400153 // When swiping between different sections, select the corresponding tab.
154 // We can also use ActionBar.Tab#select() to do this if we have a reference to the
155 // Tab.
156 mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
157 @Override
158 public void onPageSelected(int position) {
159 actionBar.setSelectedNavigationItem(position);
160 }
161 });
alisionf76de3b2013-04-16 15:35:22 -0400162
alision5f899632013-04-22 17:26:56 -0400163 // For each of the sections in the app, add a tab to the action bar.
164 for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
165 // Create a tab with text corresponding to the page title defined by the adapter.
166 // Also specify this Activity object, which implements the TabListener interface, as the
167 // listener for when this tab is selected.
168 actionBar.addTab(actionBar.newTab().setIcon(icon_res_id[i]).setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
169 }
alisionf76de3b2013-04-16 15:35:22 -0400170
alision5f899632013-04-22 17:26:56 -0400171 actionBar.setSelectedNavigationItem(ACTION_BAR_TAB_CALL);
alisionf76de3b2013-04-16 15:35:22 -0400172
alisione2a38e12013-04-25 14:20:20 -0400173 // buttonHangup.setOnClickListener(new OnClickListener() {
174 // @Override
175 // public void onClick(View v) {
176 // processingHangUpAction();
177 //
178 // }
179 // });
alisionf76de3b2013-04-16 15:35:22 -0400180
alision371b77e2013-04-23 14:51:26 -0400181 // IntentFilter callFilter = new IntentFilter(CallManagerCallBack.NEW_CALL_CREATED);
182 // callFilter.addAction(CallManagerCallBack.INCOMING_CALL);
183 // callFilter.addAction(CallManagerCallBack.CALL_STATE_CHANGED);
184 // LocalBroadcastManager.getInstance(this).registerReceiver(mCallList, callFilter);
185 //
186 // mAccountList = mApplication.getAccountList();
187 // Log.w(TAG, "mAccountList=" + mAccountList + ", mCallElementList=" + mCallElementList);
alisionf76de3b2013-04-16 15:35:22 -0400188
alision4a0eb092013-05-07 13:52:03 -0400189// IntentFilter accountFilter = new IntentFilter(ConfigurationManagerCallback.ACCOUNTS_CHANGED);
190// accountFilter.addAction(ConfigurationManagerCallback.ACCOUNT_STATE_CHANGED);
alision371b77e2013-04-23 14:51:26 -0400191 // LocalBroadcastManager.getInstance(this).registerReceiver(mAccountList, accountFilter);
alisionf76de3b2013-04-16 15:35:22 -0400192
alisione2a38e12013-04-25 14:20:20 -0400193 // SipCall.setSFLPhoneHomeContext(this);
alision5f899632013-04-22 17:26:56 -0400194 }
alisionf76de3b2013-04-16 15:35:22 -0400195
alision5f899632013-04-22 17:26:56 -0400196 @Override
197 protected void onStart() {
198 Log.i(TAG, "onStart");
199 super.onStart();
200 }
alisionf76de3b2013-04-16 15:35:22 -0400201
alision5f899632013-04-22 17:26:56 -0400202 /* user gets back to the activity, e.g. through task manager */
203 @Override
204 protected void onRestart() {
205 super.onRestart();
206 }
alisionf76de3b2013-04-16 15:35:22 -0400207
alision5f899632013-04-22 17:26:56 -0400208 /* activity gets back to the foreground and user input */
209 @Override
210 protected void onResume() {
211 Log.i(TAG, "onResume");
212 super.onResume();
213 }
alisionf76de3b2013-04-16 15:35:22 -0400214
alision5f899632013-04-22 17:26:56 -0400215 /* activity no more in foreground */
216 @Override
217 protected void onPause() {
218 super.onPause();
219 }
alisionf76de3b2013-04-16 15:35:22 -0400220
alision5f899632013-04-22 17:26:56 -0400221 /* activity is no longer visible */
222 @Override
223 protected void onStop() {
224 super.onStop();
225 }
alisionf76de3b2013-04-16 15:35:22 -0400226
alision5f899632013-04-22 17:26:56 -0400227 /* activity finishes itself or is being killed by the system */
228 @Override
229 protected void onDestroy() {
230 /* stop the service, if no other bound user, no need to check if it is running */
231 if (mBound) {
alision4a0eb092013-05-07 13:52:03 -0400232 Log.i(TAG, "onDestroy: Unbinding service...");
alision5f899632013-04-22 17:26:56 -0400233 unbindService(mConnection);
234 mBound = false;
235 }
alisionf76de3b2013-04-16 15:35:22 -0400236
alision5f899632013-04-22 17:26:56 -0400237 /* unregister broadcast receiver */
alision371b77e2013-04-23 14:51:26 -0400238 // LocalBroadcastManager.getInstance(this).unregisterReceiver(mCallList);
239 // LocalBroadcastManager.getInstance(this).unregisterReceiver(mAccountList);
alisionf76de3b2013-04-16 15:35:22 -0400240
alision5f899632013-04-22 17:26:56 -0400241 super.onDestroy();
242 }
alisione2a38e12013-04-25 14:20:20 -0400243
244 public void launchCallActivity(SipCall.CallInfo infos) {
alision371b77e2013-04-23 14:51:26 -0400245 Log.i(TAG, "Launch Call Activity");
246 Bundle bundle = new Bundle();
247 bundle.putParcelable("CallInfo", infos);
248 Intent intent = new Intent().setClass(this, CallActivity.class);
249 intent.putExtras(bundle);
250 startActivity(intent);
251 }
alisionf76de3b2013-04-16 15:35:22 -0400252
alision5f899632013-04-22 17:26:56 -0400253 /** Defines callbacks for service binding, passed to bindService() */
254 private ServiceConnection mConnection = new ServiceConnection() {
alisionf76de3b2013-04-16 15:35:22 -0400255
alision5f899632013-04-22 17:26:56 -0400256 private ISipClient callback = new ISipClient.Stub() {
alision371b77e2013-04-23 14:51:26 -0400257
alision5f899632013-04-22 17:26:56 -0400258 @Override
alision371b77e2013-04-23 14:51:26 -0400259 public void incomingCall(Intent call) throws RemoteException {
260 Log.i(TAG, "Incoming call transfered from Service");
261 SipCall.CallInfo infos = new SipCall.CallInfo(call);
alisione2a38e12013-04-25 14:20:20 -0400262
alision371b77e2013-04-23 14:51:26 -0400263 SipCall c = new SipCall(infos);
264 mCallElementList.addCall(c);
alision73424b62013-04-26 11:49:18 -0400265
Adrien Béraud1947a102013-04-26 22:05:34 +1000266 launchCallActivity(infos);
alision371b77e2013-04-23 14:51:26 -0400267 }
268
269 @Override
270 public void callStateChanged(Intent callState) throws RemoteException {
271 Bundle b = callState.getBundleExtra("com.savoirfairelinux.sflphone.service.newstate");
272 String cID = b.getString("CallID");
273 String state = b.getString("State");
alisione2a38e12013-04-25 14:20:20 -0400274 Log.i(TAG, "callStateChanged" + cID + " " + state);
alision371b77e2013-04-23 14:51:26 -0400275 mCallElementList.updateCall(cID, state);
276
alision5f899632013-04-22 17:26:56 -0400277 }
alision04a00182013-05-10 17:05:29 -0400278
279 @Override
280 public void incomingText(Intent msg) throws RemoteException {
281 Bundle b = msg.getBundleExtra("com.savoirfairelinux.sflphone.service.newtext");
282 b.getString("CallID");
283 String from = b.getString("From");
284 String mess = b.getString("Msg");
285 Toast.makeText(getApplicationContext(), "text from "+from+" : " + mess , Toast.LENGTH_LONG).show();
286
287 }
alision5f899632013-04-22 17:26:56 -0400288 };
alisionf76de3b2013-04-16 15:35:22 -0400289
alision5f899632013-04-22 17:26:56 -0400290 @Override
291 public void onServiceConnected(ComponentName className, IBinder binder) {
292 service = ISipService.Stub.asInterface(binder);
alision371b77e2013-04-23 14:51:26 -0400293
alisione2a38e12013-04-25 14:20:20 -0400294 mBound = true;
295 mCallElementList.onServiceSipBinded(service);
296 mHistorySectionFragment.onServiceSipBinded(service);
297 Log.d(TAG, "Service connected service=" + service);
298
alision5f899632013-04-22 17:26:56 -0400299 try {
alision371b77e2013-04-23 14:51:26 -0400300 service.registerClient(callback);
alision5f899632013-04-22 17:26:56 -0400301 } catch (RemoteException e) {
alision371b77e2013-04-23 14:51:26 -0400302 Log.e(TAG, e.toString());
alision5f899632013-04-22 17:26:56 -0400303 }
alision5f899632013-04-22 17:26:56 -0400304 }
305
306 @Override
307 public void onServiceDisconnected(ComponentName arg0) {
alisione2a38e12013-04-25 14:20:20 -0400308
alision5f899632013-04-22 17:26:56 -0400309 mBound = false;
310 Log.d(TAG, "Service disconnected service=" + service);
311 }
312 };
313
314 @Override
315 public boolean onOptionsItemSelected(MenuItem item) {
alisionfe9cf712013-05-03 17:26:08 -0400316 Log.i(TAG, "onOptionsItemSelected " + item.getItemId());
317 switch(item.getItemId()){
318 case R.id.menu_settings :
alision5f899632013-04-22 17:26:56 -0400319 Intent launchPreferencesIntent = new Intent().setClass(this, SFLPhonePreferenceActivity.class);
alision5f899632013-04-22 17:26:56 -0400320 startActivityForResult(launchPreferencesIntent, REQUEST_CODE_PREFERENCES);
alisionfe9cf712013-05-03 17:26:08 -0400321 break;
322 case R.id.menu_custom_draw:
323 Intent launchNewInterfaceIntent = new Intent().setClass(this, BubblesViewActivity.class);
324 startActivityForResult(launchNewInterfaceIntent, 0);
325 break;
alision5f899632013-04-22 17:26:56 -0400326 }
alisionfe9cf712013-05-03 17:26:08 -0400327
alision5f899632013-04-22 17:26:56 -0400328 return super.onOptionsItemSelected(item);
329 }
alision371b77e2013-04-23 14:51:26 -0400330
alision5f899632013-04-22 17:26:56 -0400331 @Override
alision371b77e2013-04-23 14:51:26 -0400332 public void onActivityResult(int requestCode, int resultCode, Intent data) {
alision5f899632013-04-22 17:26:56 -0400333 super.onActivityResult(requestCode, resultCode, data);
alision371b77e2013-04-23 14:51:26 -0400334 if (REQUEST_CODE_PREFERENCES == requestCode && service != null) {
335 // Refresh Spinner with modified accounts
alision5f899632013-04-22 17:26:56 -0400336 mCallElementList.onServiceSipBinded(service);
337 }
338 }
339
340 @Override
341 public boolean onCreateOptionsMenu(Menu menu) {
342 getMenuInflater().inflate(R.menu.activity_sflphone_home, menu);
343 return true;
344 }
345
346 @Override
347 public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
348 }
349
350 @Override
351 public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
352 // When the given tab is selected, switch to the corresponding page in the ViewPager.
353 mViewPager.setCurrentItem(tab.getPosition());
354 }
355
356 @Override
357 public void onTabReselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
358 // Log.d(TAG, "onTabReselected");
359 }
360
alision5f899632013-04-22 17:26:56 -0400361 public void processingHangUpAction() {
362 SipCall call = (SipCall) buttonHangup.getTag();
363 if (call != null)
364 call.notifyServiceHangup(service);
365 }
alisionf76de3b2013-04-16 15:35:22 -0400366
alision5f899632013-04-22 17:26:56 -0400367 /**
368 * A {@link FragmentStatePagerAdapter} that returns a fragment corresponding to one of the primary sections of the app.
369 */
370 public class SectionsPagerAdapter extends FragmentStatePagerAdapter {
alisionf76de3b2013-04-16 15:35:22 -0400371
alision5f899632013-04-22 17:26:56 -0400372 public SectionsPagerAdapter(FragmentManager fm) {
373 super(fm);
374 }
alisionf76de3b2013-04-16 15:35:22 -0400375
alision5f899632013-04-22 17:26:56 -0400376 @Override
377 public Fragment getItem(int i) {
378 Fragment fragment;
alisionf76de3b2013-04-16 15:35:22 -0400379
alision5f899632013-04-22 17:26:56 -0400380 switch (i) {
381 case 0:
382 mContactListFragment = new ContactListFragment();
383 fragment = mContactListFragment;
384 Log.w(TAG, "getItem() ContactListFragment=" + fragment);
385 break;
386 case 1:
387 mCallElementList = new CallElementListFragment();
alisione2a38e12013-04-25 14:20:20 -0400388 // SipCall.setCallElementList(mCallElementList);
alision371b77e2013-04-23 14:51:26 -0400389 // mCallElementList.setAccountList(mAccountList);
alision5f899632013-04-22 17:26:56 -0400390 fragment = mCallElementList;
391 Log.w(TAG, "getItem() CallElementList=" + fragment);
392 break;
393 case 2:
394 fragment = new HistoryFragment();
395 Log.w(TAG, "getItem() HistoryFragment=" + fragment);
396 break;
397 default:
398 Log.e(TAG, "getItem() unknown tab position " + i);
399 return null;
400 }
alisionf76de3b2013-04-16 15:35:22 -0400401
alision5f899632013-04-22 17:26:56 -0400402 // Log.i(TAG, "getItem() fragment is " + fragment);
403 Bundle args = new Bundle();
404 args.putInt(HistoryFragment.ARG_SECTION_NUMBER, i + 1);
405 fragment.setArguments(args);
406 return fragment;
407 }
alisionf76de3b2013-04-16 15:35:22 -0400408
alision5f899632013-04-22 17:26:56 -0400409 public Fragment getFragment(int i) {
410 Fragment fragment;
alisionf76de3b2013-04-16 15:35:22 -0400411
alision5f899632013-04-22 17:26:56 -0400412 switch (i) {
413 case 0:
414 fragment = mContactListFragment;
415 break;
416 case 1:
417 fragment = mCallElementList;
418 break;
419 case 2:
420 fragment = mHistorySectionFragment;
421 break;
422 default:
423 Log.e(TAG, "getClassName: unknown fragment position " + i);
424 fragment = null;
425 }
alisionf76de3b2013-04-16 15:35:22 -0400426
alision5f899632013-04-22 17:26:56 -0400427 // Log.w(TAG, "getFragment: fragment=" + fragment);
428 return fragment;
429 }
alisionf76de3b2013-04-16 15:35:22 -0400430
alision5f899632013-04-22 17:26:56 -0400431 public String getClassName(int i) {
432 String name;
alisionf76de3b2013-04-16 15:35:22 -0400433
alision5f899632013-04-22 17:26:56 -0400434 switch (i) {
435 case 0:
436 name = ContactListFragment.class.getName();
437 break;
438 case 1:
439 name = CallElementListFragment.class.getName();
440 break;
441 case 2:
442 name = HistoryFragment.class.getName();
443 break;
alisionf76de3b2013-04-16 15:35:22 -0400444
alision5f899632013-04-22 17:26:56 -0400445 default:
446 Log.e(TAG, "getClassName: unknown fragment position " + i);
447 return null;
448 }
alisionf76de3b2013-04-16 15:35:22 -0400449
alision5f899632013-04-22 17:26:56 -0400450 // Log.w(TAG, "getClassName: name=" + name);
451 return name;
452 }
alisionf76de3b2013-04-16 15:35:22 -0400453
alision5f899632013-04-22 17:26:56 -0400454 @Override
455 public int getCount() {
456 return 3;
457 }
alisionf76de3b2013-04-16 15:35:22 -0400458
alision5f899632013-04-22 17:26:56 -0400459 @Override
460 public CharSequence getPageTitle(int position) {
461 switch (position) {
462 case 0:
463 return getString(R.string.title_section0).toUpperCase();
464 case 1:
465 return getString(R.string.title_section1).toUpperCase();
466 case 2:
467 return getString(R.string.title_section2).toUpperCase();
468 case 3:
469 return getString(R.string.title_section3).toUpperCase();
470 default:
471 Log.e(TAG, "getPageTitle: unknown tab position " + position);
472 break;
473 }
474 return null;
475 }
476 }
alisionf76de3b2013-04-16 15:35:22 -0400477
alision371b77e2013-04-23 14:51:26 -0400478 @Override
479 public void onCallSelected(SipCall c) {
480 launchCallActivity(c.mCallInfo);
alisione2a38e12013-04-25 14:20:20 -0400481
482 }
483
484 @Override
485 public ISipService getService() {
486 return service;
alision371b77e2013-04-23 14:51:26 -0400487 }
488
alisionf76de3b2013-04-16 15:35:22 -0400489}