blob: 46059ae2f463ea3cfbda5a90a4ae3737ddfaab23 [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.widget.ImageButton;
alision04a00182013-05-10 17:05:29 -040049import android.widget.Toast;
alisionf76de3b2013-04-16 15:35:22 -040050
51import com.savoirfairelinux.sflphone.R;
alisionf76de3b2013-04-16 15:35:22 -040052import com.savoirfairelinux.sflphone.fragments.CallElementListFragment;
53import com.savoirfairelinux.sflphone.fragments.ContactListFragment;
alisiond9e29442013-04-17 16:10:18 -040054import com.savoirfairelinux.sflphone.fragments.HistoryFragment;
alisionf76de3b2013-04-16 15:35:22 -040055import com.savoirfairelinux.sflphone.model.SipCall;
alision5f899632013-04-22 17:26:56 -040056import com.savoirfairelinux.sflphone.service.ISipClient;
alisionf76de3b2013-04-16 15:35:22 -040057import com.savoirfairelinux.sflphone.service.ISipService;
58import com.savoirfairelinux.sflphone.service.SipService;
59
alisione2a38e12013-04-25 14:20:20 -040060public class SFLPhoneHomeActivity extends Activity implements ActionBar.TabListener, CallElementListFragment.Callbacks, HistoryFragment.Callbacks {
Adrien Béraud33268882013-05-18 03:41:15 +100061 SectionsPagerAdapter mSectionsPagerAdapter = null;
62 static final String TAG = "SFLPhoneHome";
alisiond8c83882013-05-17 17:00:42 -040063
Adrien Béraud33268882013-05-18 03:41:15 +100064 ImageButton buttonCall, buttonHangup;
65 private ContactListFragment mDialingFragment = null;
66 private CallElementListFragment mCallElementList = null;
67 private HistoryFragment mHistorySectionFragment = null;
68 private boolean mBound = false;
69 private ISipService service;
alisiond8c83882013-05-17 17:00:42 -040070
71 private static final int REQUEST_CODE_PREFERENCES = 1;
alisionf76de3b2013-04-16 15:35:22 -040072
Adrien Béraud33268882013-05-18 03:41:15 +100073 private static final int ACTION_BAR_TAB_CONTACT = 0;
74 private static final int ACTION_BAR_TAB_CALL = 1;
75 private static final int ACTION_BAR_TAB_HISTORY = 2;
alisionf76de3b2013-04-16 15:35:22 -040076
Adrien Béraud33268882013-05-18 03:41:15 +100077 /**
78 * The {@link ViewPager} that will host the section contents.
79 */
80 ViewPager mViewPager;
alisionf76de3b2013-04-16 15:35:22 -040081
Adrien Béraud33268882013-05-18 03:41:15 +100082 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 -040083
Adrien Béraud33268882013-05-18 03:41:15 +100084 // public SFLPhoneHome extends Activity implements ActionBar.TabListener, OnClickListener
alisionf76de3b2013-04-16 15:35:22 -040085
Adrien Béraud33268882013-05-18 03:41:15 +100086 /* called before activity is killed, e.g. rotation */
87 @Override
88 protected void onSaveInstanceState(Bundle bundle) {
89 super.onSaveInstanceState(bundle);
90 for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
91 try {
92 /* putFragment (Bundle bundle, String key, Fragment fragment) */
93 getFragmentManager().putFragment(bundle, mSectionsPagerAdapter.getClassName(i), mSectionsPagerAdapter.getFragment(i));
94 } catch (IllegalStateException e) {
95 Log.e(TAG, "fragment=" + mSectionsPagerAdapter.getFragment(i));
96 }
97 }
98 Log.w(TAG, "onSaveInstanceState()");
99 }
alisionf76de3b2013-04-16 15:35:22 -0400100
Adrien Béraud33268882013-05-18 03:41:15 +1000101 @Override
102 public void onCreate(Bundle savedInstanceState) {
103 super.onCreate(savedInstanceState);
alisionf76de3b2013-04-16 15:35:22 -0400104
Adrien Béraud33268882013-05-18 03:41:15 +1000105 String libraryPath = getApplicationInfo().dataDir + "/lib";
106 Log.i(TAG, libraryPath);
alisionf76de3b2013-04-16 15:35:22 -0400107
Adrien Béraud33268882013-05-18 03:41:15 +1000108 // Bind to LocalService
109 if (!mBound) {
110 Log.i(TAG, "onStart: Binding service...");
111 Intent intent = new Intent(this, SipService.class);
112 bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
113 }
alisionf76de3b2013-04-16 15:35:22 -0400114
Adrien Béraud33268882013-05-18 03:41:15 +1000115 setContentView(R.layout.activity_sflphone_home);
alisionf76de3b2013-04-16 15:35:22 -0400116
Adrien Béraud33268882013-05-18 03:41:15 +1000117 if (mSectionsPagerAdapter == null) {
118 mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager());
119 }
alisionf76de3b2013-04-16 15:35:22 -0400120
Adrien Béraud33268882013-05-18 03:41:15 +1000121 /* getFragment(Bundle, String) */
122 if (savedInstanceState != null) {
123 Log.w(TAG, "Activity restarted, recreating PagerAdapter...");
124 /* getFragment (Bundle bundle, String key) */
125 mDialingFragment = (ContactListFragment) getFragmentManager().getFragment(savedInstanceState,
126 mSectionsPagerAdapter.getClassName(ACTION_BAR_TAB_CONTACT));
127 mCallElementList = (CallElementListFragment) getFragmentManager().getFragment(savedInstanceState,
128 mSectionsPagerAdapter.getClassName(ACTION_BAR_TAB_CALL));
129 mHistorySectionFragment = (HistoryFragment) getFragmentManager().getFragment(savedInstanceState,
130 mSectionsPagerAdapter.getClassName(ACTION_BAR_TAB_HISTORY));
131 }
alisionf76de3b2013-04-16 15:35:22 -0400132
Adrien Béraud33268882013-05-18 03:41:15 +1000133 if (mDialingFragment == null) {
134 mDialingFragment = new ContactListFragment();
135 Log.w(TAG, "Recreated mContactListFragment=" + mDialingFragment);
136 }
137 if (mCallElementList == null) {
138 mCallElementList = new CallElementListFragment();
139 Log.w(TAG, "Recreated mCallElementList=" + mCallElementList);
140 }
141 if (mHistorySectionFragment == null) {
142 mHistorySectionFragment = new HistoryFragment();
143 Log.w(TAG, "Recreated mHistorySectionFragment=" + mHistorySectionFragment);
144 }
alisionf76de3b2013-04-16 15:35:22 -0400145
Adrien Béraud33268882013-05-18 03:41:15 +1000146 final ActionBar actionBar = getActionBar();
147 actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
148 // final ActionBar actionBar = getActionBar();
alisionf76de3b2013-04-16 15:35:22 -0400149
Adrien Béraud33268882013-05-18 03:41:15 +1000150 // Set up the ViewPager with the sections adapter.
151 mViewPager = (ViewPager) findViewById(R.id.pager);
152 mViewPager.setAdapter(mSectionsPagerAdapter);
alisionf76de3b2013-04-16 15:35:22 -0400153
Adrien Béraud33268882013-05-18 03:41:15 +1000154 // When swiping between different sections, select the corresponding tab.
155 // We can also use ActionBar.Tab#select() to do this if we have a reference to the
156 // Tab.
157 mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
158 @Override
159 public void onPageSelected(int position) {
160 actionBar.setSelectedNavigationItem(position);
161 }
162 });
alisionf76de3b2013-04-16 15:35:22 -0400163
Adrien Béraud33268882013-05-18 03:41:15 +1000164 // For each of the sections in the app, add a tab to the action bar.
165 for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
166 // Create a tab with text corresponding to the page title defined by the adapter.
167 // Also specify this Activity object, which implements the TabListener interface, as the
168 // listener for when this tab is selected.
169 actionBar.addTab(actionBar.newTab().setIcon(icon_res_id[i]).setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
170 }
alisionf76de3b2013-04-16 15:35:22 -0400171
Adrien Béraud33268882013-05-18 03:41:15 +1000172 actionBar.setSelectedNavigationItem(ACTION_BAR_TAB_CALL);
alisionf76de3b2013-04-16 15:35:22 -0400173
Adrien Béraud33268882013-05-18 03:41:15 +1000174 // buttonHangup.setOnClickListener(new OnClickListener() {
175 // @Override
176 // public void onClick(View v) {
177 // processingHangUpAction();
178 //
179 // }
180 // });
alisionf76de3b2013-04-16 15:35:22 -0400181
Adrien Béraud33268882013-05-18 03:41:15 +1000182 // IntentFilter callFilter = new IntentFilter(CallManagerCallBack.NEW_CALL_CREATED);
183 // callFilter.addAction(CallManagerCallBack.INCOMING_CALL);
184 // callFilter.addAction(CallManagerCallBack.CALL_STATE_CHANGED);
185 // LocalBroadcastManager.getInstance(this).registerReceiver(mCallList, callFilter);
186 //
187 // mAccountList = mApplication.getAccountList();
188 // Log.w(TAG, "mAccountList=" + mAccountList + ", mCallElementList=" + mCallElementList);
alisionf76de3b2013-04-16 15:35:22 -0400189
Adrien Béraud33268882013-05-18 03:41:15 +1000190 // IntentFilter accountFilter = new IntentFilter(ConfigurationManagerCallback.ACCOUNTS_CHANGED);
191 // accountFilter.addAction(ConfigurationManagerCallback.ACCOUNT_STATE_CHANGED);
192 // LocalBroadcastManager.getInstance(this).registerReceiver(mAccountList, accountFilter);
alisionf76de3b2013-04-16 15:35:22 -0400193
Adrien Béraud33268882013-05-18 03:41:15 +1000194 // SipCall.setSFLPhoneHomeContext(this);
195 }
alisionf76de3b2013-04-16 15:35:22 -0400196
Adrien Béraud33268882013-05-18 03:41:15 +1000197 @Override
198 protected void onStart() {
199 Log.i(TAG, "onStart");
200 super.onStart();
201 }
alisionf76de3b2013-04-16 15:35:22 -0400202
Adrien Béraud33268882013-05-18 03:41:15 +1000203 /* user gets back to the activity, e.g. through task manager */
204 @Override
205 protected void onRestart() {
206 super.onRestart();
207 }
alisionf76de3b2013-04-16 15:35:22 -0400208
Adrien Béraud33268882013-05-18 03:41:15 +1000209 /* activity gets back to the foreground and user input */
210 @Override
211 protected void onResume() {
212 Log.i(TAG, "onResume");
213 super.onResume();
214 }
alisionf76de3b2013-04-16 15:35:22 -0400215
Adrien Béraud33268882013-05-18 03:41:15 +1000216 /* activity no more in foreground */
217 @Override
218 protected void onPause() {
219 super.onPause();
220 }
alisionf76de3b2013-04-16 15:35:22 -0400221
Adrien Béraud33268882013-05-18 03:41:15 +1000222 /* activity is no longer visible */
223 @Override
224 protected void onStop() {
225 super.onStop();
226 }
alisionf76de3b2013-04-16 15:35:22 -0400227
Adrien Béraud33268882013-05-18 03:41:15 +1000228 /* activity finishes itself or is being killed by the system */
229 @Override
230 protected void onDestroy() {
231 /* stop the service, if no other bound user, no need to check if it is running */
232 if (mBound) {
233 Log.i(TAG, "onDestroy: Unbinding service...");
234 unbindService(mConnection);
235 mBound = false;
236 }
alisionf76de3b2013-04-16 15:35:22 -0400237
Adrien Béraud33268882013-05-18 03:41:15 +1000238 /* unregister broadcast receiver */
239 // LocalBroadcastManager.getInstance(this).unregisterReceiver(mCallList);
240 // LocalBroadcastManager.getInstance(this).unregisterReceiver(mAccountList);
alisione2a38e12013-04-25 14:20:20 -0400241
Adrien Béraud33268882013-05-18 03:41:15 +1000242 super.onDestroy();
243 }
alisionf76de3b2013-04-16 15:35:22 -0400244
Adrien Béraud33268882013-05-18 03:41:15 +1000245 public void launchCallActivity(SipCall.CallInfo infos) {
246 Log.i(TAG, "Launch Call Activity");
247 Bundle bundle = new Bundle();
248 bundle.putString("action", "incoming");
249 //bundle.putParcelable("CallContact", mListAdapter.getItem(pos));
250 bundle.putParcelable("CallInfo", infos);
251 Intent intent = new Intent().setClass(this, CallActivity.class);
252 intent.putExtras(bundle);
253 startActivity(intent);
254 }
alisionf76de3b2013-04-16 15:35:22 -0400255
Adrien Béraud33268882013-05-18 03:41:15 +1000256 /** Defines callbacks for service binding, passed to bindService() */
257 private ServiceConnection mConnection = new ServiceConnection() {
alision371b77e2013-04-23 14:51:26 -0400258
Adrien Béraud33268882013-05-18 03:41:15 +1000259 private ISipClient callback = new ISipClient.Stub() {
alisione2a38e12013-04-25 14:20:20 -0400260
Adrien Béraud33268882013-05-18 03:41:15 +1000261 @Override
262 public void incomingCall(Intent call) throws RemoteException {
263 Log.i(TAG, "Incoming call transfered from Service");
264 SipCall.CallInfo infos = new SipCall.CallInfo(call);
alision73424b62013-04-26 11:49:18 -0400265
Adrien Béraud33268882013-05-18 03:41:15 +1000266 SipCall c = new SipCall(infos);
267 mCallElementList.addCall(c);
268
269 launchCallActivity(infos);
270 }
271
272 @Override
273 public void callStateChanged(Intent callState) throws RemoteException {
274 Bundle b = callState.getBundleExtra("com.savoirfairelinux.sflphone.service.newstate");
275 String cID = b.getString("CallID");
276 String state = b.getString("State");
277 Log.i(TAG, "callStateChanged" + cID + " " + state);
278 mCallElementList.updateCall(cID, state);
279
280 }
281
282 @Override
283 public void incomingText(Intent msg) throws RemoteException {
284 Bundle b = msg.getBundleExtra("com.savoirfairelinux.sflphone.service.newtext");
285 b.getString("CallID");
286 String from = b.getString("From");
287 String mess = b.getString("Msg");
288 Toast.makeText(getApplicationContext(), "text from "+from+" : " + mess , Toast.LENGTH_LONG).show();
alision371b77e2013-04-23 14:51:26 -0400289
Adrien Béraud33268882013-05-18 03:41:15 +1000290 }
291 };
alision371b77e2013-04-23 14:51:26 -0400292
Adrien Béraud33268882013-05-18 03:41:15 +1000293 @Override
294 public void onServiceConnected(ComponentName className, IBinder binder) {
295 service = ISipService.Stub.asInterface(binder);
alision04a00182013-05-10 17:05:29 -0400296
Adrien Béraud33268882013-05-18 03:41:15 +1000297 mBound = true;
298 mCallElementList.onServiceSipBinded(service);
299 mHistorySectionFragment.onServiceSipBinded(service);
300 Log.d(TAG, "Service connected service=" + service);
alisionf76de3b2013-04-16 15:35:22 -0400301
Adrien Béraud33268882013-05-18 03:41:15 +1000302 try {
303 service.registerClient(callback);
304 } catch (RemoteException e) {
305 Log.e(TAG, e.toString());
306 }
307 }
alision371b77e2013-04-23 14:51:26 -0400308
Adrien Béraud33268882013-05-18 03:41:15 +1000309 @Override
310 public void onServiceDisconnected(ComponentName arg0) {
alision5f899632013-04-22 17:26:56 -0400311
Adrien Béraud33268882013-05-18 03:41:15 +1000312 mBound = false;
313 Log.d(TAG, "Service disconnected service=" + service);
314 }
315 };
alisione2a38e12013-04-25 14:20:20 -0400316
alisiond8c83882013-05-17 17:00:42 -0400317// @Override
318// public boolean onOptionsItemSelected(MenuItem item) {
319// Log.i(TAG, "onOptionsItemSelected " + item.getItemId());
320// switch(item.getItemId()){
321// case R.id.menu_settings :
322// Intent launchPreferencesIntent = new Intent().setClass(this, SFLPhonePreferenceActivity.class);
323// startActivityForResult(launchPreferencesIntent, REQUEST_CODE_PREFERENCES);
324// break;
325// case R.id.menu_custom_draw:
326// Intent launchNewInterfaceIntent = new Intent().setClass(this, BubblesViewActivity.class);
327// startActivityForResult(launchNewInterfaceIntent, 0);
328// break;
329// }
330//
331// return super.onOptionsItemSelected(item);
332// }
alision371b77e2013-04-23 14:51:26 -0400333
Adrien Béraud33268882013-05-18 03:41:15 +1000334 @Override
335 public void onActivityResult(int requestCode, int resultCode, Intent data) {
336 super.onActivityResult(requestCode, resultCode, data);
337 if (REQUEST_CODE_PREFERENCES == requestCode && service != null) {
338 // Refresh Spinner with modified accounts
339 mCallElementList.onServiceSipBinded(service);
340 }
341 }
alision5f899632013-04-22 17:26:56 -0400342
alisiond8c83882013-05-17 17:00:42 -0400343// @Override
344// public boolean onCreateOptionsMenu(Menu menu) {
345// getMenuInflater().inflate(R.menu.activity_sflphone_home, menu);
346// return true;
347// }
alision5f899632013-04-22 17:26:56 -0400348
Adrien Béraud33268882013-05-18 03:41:15 +1000349 @Override
350 public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
351 }
alision5f899632013-04-22 17:26:56 -0400352
Adrien Béraud33268882013-05-18 03:41:15 +1000353 @Override
354 public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
355 // When the given tab is selected, switch to the corresponding page in the ViewPager.
356 mViewPager.setCurrentItem(tab.getPosition());
357 }
alision5f899632013-04-22 17:26:56 -0400358
Adrien Béraud33268882013-05-18 03:41:15 +1000359 @Override
360 public void onTabReselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
361 // Log.d(TAG, "onTabReselected");
362 }
alision5f899632013-04-22 17:26:56 -0400363
Adrien Béraud33268882013-05-18 03:41:15 +1000364 public void processingHangUpAction() {
365 SipCall call = (SipCall) buttonHangup.getTag();
366 if (call != null)
367 call.notifyServiceHangup(service);
368 }
alisionf76de3b2013-04-16 15:35:22 -0400369
Adrien Béraud33268882013-05-18 03:41:15 +1000370 /**
371 * A {@link FragmentStatePagerAdapter} that returns a fragment corresponding to one of the primary sections of the app.
372 */
373 public class SectionsPagerAdapter extends FragmentStatePagerAdapter {
alisionf76de3b2013-04-16 15:35:22 -0400374
Adrien Béraud33268882013-05-18 03:41:15 +1000375 public SectionsPagerAdapter(FragmentManager fm) {
376 super(fm);
377 }
alisionf76de3b2013-04-16 15:35:22 -0400378
Adrien Béraud33268882013-05-18 03:41:15 +1000379 @Override
380 public Fragment getItem(int i) {
381 Fragment fragment;
alisionf76de3b2013-04-16 15:35:22 -0400382
Adrien Béraud33268882013-05-18 03:41:15 +1000383 switch (i) {
384 case 0:
385 mDialingFragment = new ContactListFragment();
386 fragment = mDialingFragment;
387 Log.w(TAG, "getItem() ContactListFragment=" + fragment);
388 break;
389 case 1:
390 mCallElementList = new CallElementListFragment();
391 // SipCall.setCallElementList(mCallElementList);
392 // mCallElementList.setAccountList(mAccountList);
393 fragment = mCallElementList;
394 Log.w(TAG, "getItem() CallElementList=" + fragment);
395 break;
396 case 2:
397 fragment = new HistoryFragment();
398 Log.w(TAG, "getItem() HistoryFragment=" + fragment);
399 break;
400 default:
401 Log.e(TAG, "getItem() unknown tab position " + i);
402 return null;
403 }
alisionf76de3b2013-04-16 15:35:22 -0400404
Adrien Béraud33268882013-05-18 03:41:15 +1000405 // Log.i(TAG, "getItem() fragment is " + fragment);
406 Bundle args = new Bundle();
407 args.putInt(HistoryFragment.ARG_SECTION_NUMBER, i + 1);
408 fragment.setArguments(args);
409 return fragment;
410 }
alisionf76de3b2013-04-16 15:35:22 -0400411
Adrien Béraud33268882013-05-18 03:41:15 +1000412 public Fragment getFragment(int i) {
413 Fragment fragment;
alisionf76de3b2013-04-16 15:35:22 -0400414
Adrien Béraud33268882013-05-18 03:41:15 +1000415 switch (i) {
416 case 0:
417 fragment = mDialingFragment;
418 break;
419 case 1:
420 fragment = mCallElementList;
421 break;
422 case 2:
423 fragment = mHistorySectionFragment;
424 break;
425 default:
426 Log.e(TAG, "getClassName: unknown fragment position " + i);
427 fragment = null;
428 }
alisionf76de3b2013-04-16 15:35:22 -0400429
Adrien Béraud33268882013-05-18 03:41:15 +1000430 // Log.w(TAG, "getFragment: fragment=" + fragment);
431 return fragment;
432 }
alisionf76de3b2013-04-16 15:35:22 -0400433
Adrien Béraud33268882013-05-18 03:41:15 +1000434 public String getClassName(int i) {
435 String name;
alisionf76de3b2013-04-16 15:35:22 -0400436
Adrien Béraud33268882013-05-18 03:41:15 +1000437 switch (i) {
438 case 0:
439 name = ContactListFragment.class.getName();
440 break;
441 case 1:
442 name = CallElementListFragment.class.getName();
443 break;
444 case 2:
445 name = HistoryFragment.class.getName();
446 break;
alisionf76de3b2013-04-16 15:35:22 -0400447
Adrien Béraud33268882013-05-18 03:41:15 +1000448 default:
449 Log.e(TAG, "getClassName: unknown fragment position " + i);
450 return null;
451 }
alisionf76de3b2013-04-16 15:35:22 -0400452
Adrien Béraud33268882013-05-18 03:41:15 +1000453 // Log.w(TAG, "getClassName: name=" + name);
454 return name;
455 }
alisionf76de3b2013-04-16 15:35:22 -0400456
Adrien Béraud33268882013-05-18 03:41:15 +1000457 @Override
458 public int getCount() {
459 return 3;
460 }
alisionf76de3b2013-04-16 15:35:22 -0400461
Adrien Béraud33268882013-05-18 03:41:15 +1000462 @Override
463 public CharSequence getPageTitle(int position) {
464 switch (position) {
465 case 0:
466 return getString(R.string.title_section0).toUpperCase();
467 case 1:
468 return getString(R.string.title_section1).toUpperCase();
469 case 2:
470 return getString(R.string.title_section2).toUpperCase();
471 case 3:
472 return getString(R.string.title_section3).toUpperCase();
473 default:
474 Log.e(TAG, "getPageTitle: unknown tab position " + position);
475 break;
476 }
477 return null;
478 }
479 }
alisionf76de3b2013-04-16 15:35:22 -0400480
Adrien Béraud33268882013-05-18 03:41:15 +1000481 @Override
482 public void onCallSelected(SipCall c) {
483 launchCallActivity(c.mCallInfo);
alisione2a38e12013-04-25 14:20:20 -0400484
Adrien Béraud33268882013-05-18 03:41:15 +1000485 }
alisione2a38e12013-04-25 14:20:20 -0400486
Adrien Béraud33268882013-05-18 03:41:15 +1000487 @Override
488 public ISipService getService() {
489 return service;
490 }
alision371b77e2013-04-23 14:51:26 -0400491
alisionf76de3b2013-04-16 15:35:22 -0400492}