blob: 1be990974599abebe886820423b479d0534ae0dd [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
alisionf76de3b2013-04-16 15:35:22 -040033import android.app.ActionBar;
34import android.app.Activity;
35import android.app.Fragment;
36import android.app.FragmentManager;
37import android.app.FragmentTransaction;
38import android.content.ComponentName;
39import android.content.Context;
40import android.content.Intent;
alisionf76de3b2013-04-16 15:35:22 -040041import android.content.ServiceConnection;
42import android.os.Bundle;
43import android.os.IBinder;
alision5f899632013-04-22 17:26:56 -040044import android.os.RemoteException;
alisionf76de3b2013-04-16 15:35:22 -040045import android.support.v13.app.FragmentStatePagerAdapter;
alisionf76de3b2013-04-16 15:35:22 -040046import android.support.v4.view.ViewPager;
47import android.util.Log;
alisionf76de3b2013-04-16 15:35:22 -040048import android.view.Menu;
49import android.view.MenuItem;
alisionf76de3b2013-04-16 15:35:22 -040050import android.widget.ImageButton;
alision04a00182013-05-10 17:05:29 -040051import android.widget.Toast;
alisionf76de3b2013-04-16 15:35:22 -040052
53import com.savoirfairelinux.sflphone.R;
alisionf76de3b2013-04-16 15:35:22 -040054import com.savoirfairelinux.sflphone.fragments.CallElementListFragment;
55import com.savoirfairelinux.sflphone.fragments.ContactListFragment;
alisiond295ec22013-05-17 10:12:13 -040056import com.savoirfairelinux.sflphone.fragments.DialingFragment;
alisiond9e29442013-04-17 16:10:18 -040057import com.savoirfairelinux.sflphone.fragments.HistoryFragment;
alisionf76de3b2013-04-16 15:35:22 -040058import com.savoirfairelinux.sflphone.model.SipCall;
alision5f899632013-04-22 17:26:56 -040059import com.savoirfairelinux.sflphone.service.ISipClient;
alisionf76de3b2013-04-16 15:35:22 -040060import com.savoirfairelinux.sflphone.service.ISipService;
61import com.savoirfairelinux.sflphone.service.SipService;
62
alisione2a38e12013-04-25 14:20:20 -040063public class SFLPhoneHomeActivity extends Activity implements ActionBar.TabListener, CallElementListFragment.Callbacks, HistoryFragment.Callbacks {
alision5f899632013-04-22 17:26:56 -040064 SectionsPagerAdapter mSectionsPagerAdapter = null;
65 static final String TAG = "SFLPhoneHome";
66 private static final int REQUEST_CODE_PREFERENCES = 1;
67 ImageButton buttonCall, buttonHangup;
alisiond295ec22013-05-17 10:12:13 -040068 private ContactListFragment mDialingFragment = null;
alision5f899632013-04-22 17:26:56 -040069 private CallElementListFragment mCallElementList = null;
70 private HistoryFragment mHistorySectionFragment = null;
71 private boolean mBound = false;
72 private ISipService service;
alisionf76de3b2013-04-16 15:35:22 -040073
alision5f899632013-04-22 17:26:56 -040074 private static final int ACTION_BAR_TAB_CONTACT = 0;
75 private static final int ACTION_BAR_TAB_CALL = 1;
76 private static final int ACTION_BAR_TAB_HISTORY = 2;
alisionf76de3b2013-04-16 15:35:22 -040077
alision5f899632013-04-22 17:26:56 -040078 /**
79 * The {@link ViewPager} that will host the section contents.
80 */
81 ViewPager mViewPager;
alisionf76de3b2013-04-16 15:35:22 -040082
alision5f899632013-04-22 17:26:56 -040083 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 -040084
alision5f899632013-04-22 17:26:56 -040085 // public SFLPhoneHome extends Activity implements ActionBar.TabListener, OnClickListener
alisionf76de3b2013-04-16 15:35:22 -040086
alision5f899632013-04-22 17:26:56 -040087 /* called before activity is killed, e.g. rotation */
88 @Override
89 protected void onSaveInstanceState(Bundle bundle) {
90 super.onSaveInstanceState(bundle);
91 for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
92 try {
93 /* putFragment (Bundle bundle, String key, Fragment fragment) */
94 getFragmentManager().putFragment(bundle, mSectionsPagerAdapter.getClassName(i), mSectionsPagerAdapter.getFragment(i));
95 } catch (IllegalStateException e) {
alision7f18fc82013-05-01 09:37:33 -040096 Log.e(TAG, "fragment=" + mSectionsPagerAdapter.getFragment(i));
alision5f899632013-04-22 17:26:56 -040097 }
98 }
99 Log.w(TAG, "onSaveInstanceState()");
100 }
alisionf76de3b2013-04-16 15:35:22 -0400101
alision5f899632013-04-22 17:26:56 -0400102 @Override
103 public void onCreate(Bundle savedInstanceState) {
104 super.onCreate(savedInstanceState);
alisiond295ec22013-05-17 10:12:13 -0400105
106 String libraryPath = getApplicationInfo().dataDir + "/lib";
107 Log.i(TAG, libraryPath);
alisionf76de3b2013-04-16 15:35:22 -0400108
alision5f899632013-04-22 17:26:56 -0400109 // Bind to LocalService
110 if (!mBound) {
111 Log.i(TAG, "onStart: Binding service...");
112 Intent intent = new Intent(this, SipService.class);
113 bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
114 }
alisionf76de3b2013-04-16 15:35:22 -0400115
alision5f899632013-04-22 17:26:56 -0400116 setContentView(R.layout.activity_sflphone_home);
alisionf76de3b2013-04-16 15:35:22 -0400117
alision5f899632013-04-22 17:26:56 -0400118 if (mSectionsPagerAdapter == null) {
119 mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager());
120 }
alisionf76de3b2013-04-16 15:35:22 -0400121
alision5f899632013-04-22 17:26:56 -0400122 /* getFragment(Bundle, String) */
123 if (savedInstanceState != null) {
124 Log.w(TAG, "Activity restarted, recreating PagerAdapter...");
125 /* getFragment (Bundle bundle, String key) */
alisiond295ec22013-05-17 10:12:13 -0400126 mDialingFragment = (ContactListFragment) getFragmentManager().getFragment(savedInstanceState,
alision5f899632013-04-22 17:26:56 -0400127 mSectionsPagerAdapter.getClassName(ACTION_BAR_TAB_CONTACT));
128 mCallElementList = (CallElementListFragment) getFragmentManager().getFragment(savedInstanceState,
129 mSectionsPagerAdapter.getClassName(ACTION_BAR_TAB_CALL));
130 mHistorySectionFragment = (HistoryFragment) getFragmentManager().getFragment(savedInstanceState,
131 mSectionsPagerAdapter.getClassName(ACTION_BAR_TAB_HISTORY));
132 }
alisionf76de3b2013-04-16 15:35:22 -0400133
alisiond295ec22013-05-17 10:12:13 -0400134 if (mDialingFragment == null) {
135 mDialingFragment = new ContactListFragment();
136 Log.w(TAG, "Recreated mContactListFragment=" + mDialingFragment);
alision5f899632013-04-22 17:26:56 -0400137 }
138 if (mCallElementList == null) {
139 mCallElementList = new CallElementListFragment();
140 Log.w(TAG, "Recreated mCallElementList=" + mCallElementList);
141 }
142 if (mHistorySectionFragment == null) {
143 mHistorySectionFragment = new HistoryFragment();
144 Log.w(TAG, "Recreated mHistorySectionFragment=" + mHistorySectionFragment);
145 }
alisionf76de3b2013-04-16 15:35:22 -0400146
alision5f899632013-04-22 17:26:56 -0400147 final ActionBar actionBar = getActionBar();
148 actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
149 // final ActionBar actionBar = getActionBar();
alisionf76de3b2013-04-16 15:35:22 -0400150
alision5f899632013-04-22 17:26:56 -0400151 // Set up the ViewPager with the sections adapter.
152 mViewPager = (ViewPager) findViewById(R.id.pager);
153 mViewPager.setAdapter(mSectionsPagerAdapter);
alisionf76de3b2013-04-16 15:35:22 -0400154
alision5f899632013-04-22 17:26:56 -0400155 // When swiping between different sections, select the corresponding tab.
156 // We can also use ActionBar.Tab#select() to do this if we have a reference to the
157 // Tab.
158 mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
159 @Override
160 public void onPageSelected(int position) {
161 actionBar.setSelectedNavigationItem(position);
162 }
163 });
alisionf76de3b2013-04-16 15:35:22 -0400164
alision5f899632013-04-22 17:26:56 -0400165 // For each of the sections in the app, add a tab to the action bar.
166 for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
167 // Create a tab with text corresponding to the page title defined by the adapter.
168 // Also specify this Activity object, which implements the TabListener interface, as the
169 // listener for when this tab is selected.
170 actionBar.addTab(actionBar.newTab().setIcon(icon_res_id[i]).setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
171 }
alisionf76de3b2013-04-16 15:35:22 -0400172
alision5f899632013-04-22 17:26:56 -0400173 actionBar.setSelectedNavigationItem(ACTION_BAR_TAB_CALL);
alisionf76de3b2013-04-16 15:35:22 -0400174
alisione2a38e12013-04-25 14:20:20 -0400175 // buttonHangup.setOnClickListener(new OnClickListener() {
176 // @Override
177 // public void onClick(View v) {
178 // processingHangUpAction();
179 //
180 // }
181 // });
alisionf76de3b2013-04-16 15:35:22 -0400182
alision371b77e2013-04-23 14:51:26 -0400183 // IntentFilter callFilter = new IntentFilter(CallManagerCallBack.NEW_CALL_CREATED);
184 // callFilter.addAction(CallManagerCallBack.INCOMING_CALL);
185 // callFilter.addAction(CallManagerCallBack.CALL_STATE_CHANGED);
186 // LocalBroadcastManager.getInstance(this).registerReceiver(mCallList, callFilter);
187 //
188 // mAccountList = mApplication.getAccountList();
189 // Log.w(TAG, "mAccountList=" + mAccountList + ", mCallElementList=" + mCallElementList);
alisionf76de3b2013-04-16 15:35:22 -0400190
alision4a0eb092013-05-07 13:52:03 -0400191// IntentFilter accountFilter = new IntentFilter(ConfigurationManagerCallback.ACCOUNTS_CHANGED);
192// accountFilter.addAction(ConfigurationManagerCallback.ACCOUNT_STATE_CHANGED);
alision371b77e2013-04-23 14:51:26 -0400193 // LocalBroadcastManager.getInstance(this).registerReceiver(mAccountList, accountFilter);
alisionf76de3b2013-04-16 15:35:22 -0400194
alisione2a38e12013-04-25 14:20:20 -0400195 // SipCall.setSFLPhoneHomeContext(this);
alision5f899632013-04-22 17:26:56 -0400196 }
alisionf76de3b2013-04-16 15:35:22 -0400197
alision5f899632013-04-22 17:26:56 -0400198 @Override
199 protected void onStart() {
200 Log.i(TAG, "onStart");
201 super.onStart();
202 }
alisionf76de3b2013-04-16 15:35:22 -0400203
alision5f899632013-04-22 17:26:56 -0400204 /* user gets back to the activity, e.g. through task manager */
205 @Override
206 protected void onRestart() {
207 super.onRestart();
208 }
alisionf76de3b2013-04-16 15:35:22 -0400209
alision5f899632013-04-22 17:26:56 -0400210 /* activity gets back to the foreground and user input */
211 @Override
212 protected void onResume() {
213 Log.i(TAG, "onResume");
214 super.onResume();
215 }
alisionf76de3b2013-04-16 15:35:22 -0400216
alision5f899632013-04-22 17:26:56 -0400217 /* activity no more in foreground */
218 @Override
219 protected void onPause() {
220 super.onPause();
221 }
alisionf76de3b2013-04-16 15:35:22 -0400222
alision5f899632013-04-22 17:26:56 -0400223 /* activity is no longer visible */
224 @Override
225 protected void onStop() {
226 super.onStop();
227 }
alisionf76de3b2013-04-16 15:35:22 -0400228
alision5f899632013-04-22 17:26:56 -0400229 /* activity finishes itself or is being killed by the system */
230 @Override
231 protected void onDestroy() {
232 /* stop the service, if no other bound user, no need to check if it is running */
233 if (mBound) {
alision4a0eb092013-05-07 13:52:03 -0400234 Log.i(TAG, "onDestroy: Unbinding service...");
alision5f899632013-04-22 17:26:56 -0400235 unbindService(mConnection);
236 mBound = false;
237 }
alisionf76de3b2013-04-16 15:35:22 -0400238
alision5f899632013-04-22 17:26:56 -0400239 /* unregister broadcast receiver */
alision371b77e2013-04-23 14:51:26 -0400240 // LocalBroadcastManager.getInstance(this).unregisterReceiver(mCallList);
241 // LocalBroadcastManager.getInstance(this).unregisterReceiver(mAccountList);
alisionf76de3b2013-04-16 15:35:22 -0400242
alision5f899632013-04-22 17:26:56 -0400243 super.onDestroy();
244 }
alisione2a38e12013-04-25 14:20:20 -0400245
246 public void launchCallActivity(SipCall.CallInfo infos) {
alision371b77e2013-04-23 14:51:26 -0400247 Log.i(TAG, "Launch Call Activity");
248 Bundle bundle = new Bundle();
249 bundle.putParcelable("CallInfo", infos);
250 Intent intent = new Intent().setClass(this, CallActivity.class);
251 intent.putExtras(bundle);
252 startActivity(intent);
253 }
alisionf76de3b2013-04-16 15:35:22 -0400254
alision5f899632013-04-22 17:26:56 -0400255 /** Defines callbacks for service binding, passed to bindService() */
256 private ServiceConnection mConnection = new ServiceConnection() {
alisionf76de3b2013-04-16 15:35:22 -0400257
alision5f899632013-04-22 17:26:56 -0400258 private ISipClient callback = new ISipClient.Stub() {
alision371b77e2013-04-23 14:51:26 -0400259
alision5f899632013-04-22 17:26:56 -0400260 @Override
alision371b77e2013-04-23 14:51:26 -0400261 public void incomingCall(Intent call) throws RemoteException {
262 Log.i(TAG, "Incoming call transfered from Service");
263 SipCall.CallInfo infos = new SipCall.CallInfo(call);
alisione2a38e12013-04-25 14:20:20 -0400264
alision371b77e2013-04-23 14:51:26 -0400265 SipCall c = new SipCall(infos);
266 mCallElementList.addCall(c);
alision73424b62013-04-26 11:49:18 -0400267
Adrien Béraud1947a102013-04-26 22:05:34 +1000268 launchCallActivity(infos);
alision371b77e2013-04-23 14:51:26 -0400269 }
270
271 @Override
272 public void callStateChanged(Intent callState) throws RemoteException {
273 Bundle b = callState.getBundleExtra("com.savoirfairelinux.sflphone.service.newstate");
274 String cID = b.getString("CallID");
275 String state = b.getString("State");
alisione2a38e12013-04-25 14:20:20 -0400276 Log.i(TAG, "callStateChanged" + cID + " " + state);
alision371b77e2013-04-23 14:51:26 -0400277 mCallElementList.updateCall(cID, state);
278
alision5f899632013-04-22 17:26:56 -0400279 }
alision04a00182013-05-10 17:05:29 -0400280
281 @Override
282 public void incomingText(Intent msg) throws RemoteException {
283 Bundle b = msg.getBundleExtra("com.savoirfairelinux.sflphone.service.newtext");
284 b.getString("CallID");
285 String from = b.getString("From");
286 String mess = b.getString("Msg");
287 Toast.makeText(getApplicationContext(), "text from "+from+" : " + mess , Toast.LENGTH_LONG).show();
288
289 }
alision5f899632013-04-22 17:26:56 -0400290 };
alisionf76de3b2013-04-16 15:35:22 -0400291
alision5f899632013-04-22 17:26:56 -0400292 @Override
293 public void onServiceConnected(ComponentName className, IBinder binder) {
294 service = ISipService.Stub.asInterface(binder);
alision371b77e2013-04-23 14:51:26 -0400295
alisione2a38e12013-04-25 14:20:20 -0400296 mBound = true;
297 mCallElementList.onServiceSipBinded(service);
298 mHistorySectionFragment.onServiceSipBinded(service);
299 Log.d(TAG, "Service connected service=" + service);
300
alision5f899632013-04-22 17:26:56 -0400301 try {
alision371b77e2013-04-23 14:51:26 -0400302 service.registerClient(callback);
alision5f899632013-04-22 17:26:56 -0400303 } catch (RemoteException e) {
alision371b77e2013-04-23 14:51:26 -0400304 Log.e(TAG, e.toString());
alision5f899632013-04-22 17:26:56 -0400305 }
alision5f899632013-04-22 17:26:56 -0400306 }
307
308 @Override
309 public void onServiceDisconnected(ComponentName arg0) {
alisione2a38e12013-04-25 14:20:20 -0400310
alision5f899632013-04-22 17:26:56 -0400311 mBound = false;
312 Log.d(TAG, "Service disconnected service=" + service);
313 }
314 };
315
316 @Override
317 public boolean onOptionsItemSelected(MenuItem item) {
alisionfe9cf712013-05-03 17:26:08 -0400318 Log.i(TAG, "onOptionsItemSelected " + item.getItemId());
319 switch(item.getItemId()){
320 case R.id.menu_settings :
alision5f899632013-04-22 17:26:56 -0400321 Intent launchPreferencesIntent = new Intent().setClass(this, SFLPhonePreferenceActivity.class);
alision5f899632013-04-22 17:26:56 -0400322 startActivityForResult(launchPreferencesIntent, REQUEST_CODE_PREFERENCES);
alisionfe9cf712013-05-03 17:26:08 -0400323 break;
324 case R.id.menu_custom_draw:
325 Intent launchNewInterfaceIntent = new Intent().setClass(this, BubblesViewActivity.class);
326 startActivityForResult(launchNewInterfaceIntent, 0);
327 break;
alision5f899632013-04-22 17:26:56 -0400328 }
alisionfe9cf712013-05-03 17:26:08 -0400329
alision5f899632013-04-22 17:26:56 -0400330 return super.onOptionsItemSelected(item);
331 }
alision371b77e2013-04-23 14:51:26 -0400332
alision5f899632013-04-22 17:26:56 -0400333 @Override
alision371b77e2013-04-23 14:51:26 -0400334 public void onActivityResult(int requestCode, int resultCode, Intent data) {
alision5f899632013-04-22 17:26:56 -0400335 super.onActivityResult(requestCode, resultCode, data);
alision371b77e2013-04-23 14:51:26 -0400336 if (REQUEST_CODE_PREFERENCES == requestCode && service != null) {
337 // Refresh Spinner with modified accounts
alision5f899632013-04-22 17:26:56 -0400338 mCallElementList.onServiceSipBinded(service);
339 }
340 }
341
342 @Override
343 public boolean onCreateOptionsMenu(Menu menu) {
344 getMenuInflater().inflate(R.menu.activity_sflphone_home, menu);
345 return true;
346 }
347
348 @Override
349 public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
350 }
351
352 @Override
353 public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
354 // When the given tab is selected, switch to the corresponding page in the ViewPager.
355 mViewPager.setCurrentItem(tab.getPosition());
356 }
357
358 @Override
359 public void onTabReselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
360 // Log.d(TAG, "onTabReselected");
361 }
362
alision5f899632013-04-22 17:26:56 -0400363 public void processingHangUpAction() {
364 SipCall call = (SipCall) buttonHangup.getTag();
365 if (call != null)
366 call.notifyServiceHangup(service);
367 }
alisionf76de3b2013-04-16 15:35:22 -0400368
alision5f899632013-04-22 17:26:56 -0400369 /**
370 * A {@link FragmentStatePagerAdapter} that returns a fragment corresponding to one of the primary sections of the app.
371 */
372 public class SectionsPagerAdapter extends FragmentStatePagerAdapter {
alisionf76de3b2013-04-16 15:35:22 -0400373
alision5f899632013-04-22 17:26:56 -0400374 public SectionsPagerAdapter(FragmentManager fm) {
375 super(fm);
376 }
alisionf76de3b2013-04-16 15:35:22 -0400377
alision5f899632013-04-22 17:26:56 -0400378 @Override
379 public Fragment getItem(int i) {
380 Fragment fragment;
alisionf76de3b2013-04-16 15:35:22 -0400381
alision5f899632013-04-22 17:26:56 -0400382 switch (i) {
383 case 0:
alisiond295ec22013-05-17 10:12:13 -0400384 mDialingFragment = new ContactListFragment();
385 fragment = mDialingFragment;
alision5f899632013-04-22 17:26:56 -0400386 Log.w(TAG, "getItem() ContactListFragment=" + fragment);
387 break;
388 case 1:
389 mCallElementList = new CallElementListFragment();
alisione2a38e12013-04-25 14:20:20 -0400390 // SipCall.setCallElementList(mCallElementList);
alision371b77e2013-04-23 14:51:26 -0400391 // mCallElementList.setAccountList(mAccountList);
alision5f899632013-04-22 17:26:56 -0400392 fragment = mCallElementList;
393 Log.w(TAG, "getItem() CallElementList=" + fragment);
394 break;
395 case 2:
396 fragment = new HistoryFragment();
397 Log.w(TAG, "getItem() HistoryFragment=" + fragment);
398 break;
399 default:
400 Log.e(TAG, "getItem() unknown tab position " + i);
401 return null;
402 }
alisionf76de3b2013-04-16 15:35:22 -0400403
alision5f899632013-04-22 17:26:56 -0400404 // Log.i(TAG, "getItem() fragment is " + fragment);
405 Bundle args = new Bundle();
406 args.putInt(HistoryFragment.ARG_SECTION_NUMBER, i + 1);
407 fragment.setArguments(args);
408 return fragment;
409 }
alisionf76de3b2013-04-16 15:35:22 -0400410
alision5f899632013-04-22 17:26:56 -0400411 public Fragment getFragment(int i) {
412 Fragment fragment;
alisionf76de3b2013-04-16 15:35:22 -0400413
alision5f899632013-04-22 17:26:56 -0400414 switch (i) {
415 case 0:
alisiond295ec22013-05-17 10:12:13 -0400416 fragment = mDialingFragment;
alision5f899632013-04-22 17:26:56 -0400417 break;
418 case 1:
419 fragment = mCallElementList;
420 break;
421 case 2:
422 fragment = mHistorySectionFragment;
423 break;
424 default:
425 Log.e(TAG, "getClassName: unknown fragment position " + i);
426 fragment = null;
427 }
alisionf76de3b2013-04-16 15:35:22 -0400428
alision5f899632013-04-22 17:26:56 -0400429 // Log.w(TAG, "getFragment: fragment=" + fragment);
430 return fragment;
431 }
alisionf76de3b2013-04-16 15:35:22 -0400432
alision5f899632013-04-22 17:26:56 -0400433 public String getClassName(int i) {
434 String name;
alisionf76de3b2013-04-16 15:35:22 -0400435
alision5f899632013-04-22 17:26:56 -0400436 switch (i) {
437 case 0:
438 name = ContactListFragment.class.getName();
439 break;
440 case 1:
441 name = CallElementListFragment.class.getName();
442 break;
443 case 2:
444 name = HistoryFragment.class.getName();
445 break;
alisionf76de3b2013-04-16 15:35:22 -0400446
alision5f899632013-04-22 17:26:56 -0400447 default:
448 Log.e(TAG, "getClassName: unknown fragment position " + i);
449 return null;
450 }
alisionf76de3b2013-04-16 15:35:22 -0400451
alision5f899632013-04-22 17:26:56 -0400452 // Log.w(TAG, "getClassName: name=" + name);
453 return name;
454 }
alisionf76de3b2013-04-16 15:35:22 -0400455
alision5f899632013-04-22 17:26:56 -0400456 @Override
457 public int getCount() {
458 return 3;
459 }
alisionf76de3b2013-04-16 15:35:22 -0400460
alision5f899632013-04-22 17:26:56 -0400461 @Override
462 public CharSequence getPageTitle(int position) {
463 switch (position) {
464 case 0:
465 return getString(R.string.title_section0).toUpperCase();
466 case 1:
467 return getString(R.string.title_section1).toUpperCase();
468 case 2:
469 return getString(R.string.title_section2).toUpperCase();
470 case 3:
471 return getString(R.string.title_section3).toUpperCase();
472 default:
473 Log.e(TAG, "getPageTitle: unknown tab position " + position);
474 break;
475 }
476 return null;
477 }
478 }
alisionf76de3b2013-04-16 15:35:22 -0400479
alision371b77e2013-04-23 14:51:26 -0400480 @Override
481 public void onCallSelected(SipCall c) {
482 launchCallActivity(c.mCallInfo);
alisione2a38e12013-04-25 14:20:20 -0400483
484 }
485
486 @Override
487 public ISipService getService() {
488 return service;
alision371b77e2013-04-23 14:51:26 -0400489 }
490
alisionf76de3b2013-04-16 15:35:22 -0400491}