blob: ab2a23dc106809266062563bcd86534276857fc4 [file] [log] [blame]
Alexandre Lision2e52d392013-11-06 15:14:31 -05001/*
2 * Copyright (C) 2004-2013 Savoir-Faire Linux Inc.
3 *
4 * Author: Alexandre Lision <alexandre.lision@savoirfairelinux.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 */
31
Alexandre Lision72e37322013-11-04 17:14:11 -050032package org.sflphone.client;
33
Alexandre Lision2e52d392013-11-06 15:14:31 -050034import org.sflphone.R;
35import org.sflphone.fragments.DetailsHistoryEntryFragment;
36import org.sflphone.fragments.HistoryFragment;
37import org.sflphone.service.ISipService;
38import org.sflphone.service.SipService;
Alexandre Lision72e37322013-11-04 17:14:11 -050039
Alexandre Lision2e52d392013-11-06 15:14:31 -050040import android.app.Activity;
41import android.app.Fragment;
42import android.app.FragmentTransaction;
43import android.content.ComponentName;
44import android.content.Context;
45import android.content.Intent;
46import android.content.ServiceConnection;
47import android.os.Bundle;
48import android.os.IBinder;
49import android.util.Log;
50import android.view.MenuItem;
51
52public class DetailHistoryActivity extends Activity implements DetailsHistoryEntryFragment.Callbacks {
53
54 private boolean mBound = false;
55 private ISipService service;
56 private String TAG = DetailHistoryActivity.class.getSimpleName();
57
58 @Override
59 protected void onCreate(Bundle savedInstanceState) {
60 super.onCreate(savedInstanceState);
61 setContentView(R.layout.activity_holder);
62
63 Intent intent = new Intent(this, SipService.class);
64 bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
65 getActionBar().setDisplayHomeAsUpEnabled(true);
66 }
67
68 @Override
69 public boolean onOptionsItemSelected(MenuItem item) {
70 switch (item.getItemId()) {
71 case android.R.id.home:
72 finish();
73 return true;
74 default:
75 return true;
76 }
77 }
78
79 @Override
80 public ISipService getService() {
81 return service;
82 }
83
84 @Override
85 protected void onPause() {
86 super.onPause();
87 if (mBound) {
88 unbindService(mConnection);
89 mBound = false;
90 }
91 }
92
93 /** Defines callbacks for service binding, passed to bindService() */
94 private ServiceConnection mConnection = new ServiceConnection() {
95
96 @Override
97 public void onServiceConnected(ComponentName className, IBinder binder) {
98 service = ISipService.Stub.asInterface(binder);
99
100 FragmentTransaction ft = getFragmentManager().beginTransaction();
101
102 Fragment fr = new DetailsHistoryEntryFragment();
103 fr.setArguments(getIntent().getBundleExtra(HistoryFragment.ARGS));
104 ft.replace(R.id.frag_container, fr);
105
106 ft.commit();
107
108 mBound = true;
109 Log.d(TAG, "Service connected service=" + service);
110
111 }
112
113 @Override
114 public void onServiceDisconnected(ComponentName arg0) {
115
116 mBound = false;
117 Log.d(TAG, "Service disconnected service=" + service);
118 }
119 };
120
121}