alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 1 | /* |
alision | 2ec64f9 | 2013-06-17 17:28:58 -0400 | [diff] [blame] | 2 | * Copyright (C) 2004-2013 Savoir-Faire Linux Inc. |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 3 | * |
| 4 | * Author: Adrien Beraud <adrien.beraud@gmail.com> |
alision | 11e8e16 | 2013-05-28 10:33:14 -0400 | [diff] [blame] | 5 | * Alexandre Lision <alexandre.lision@savoirfairelinux.com> |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 3 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 20 | * |
| 21 | * Additional permission under GNU GPL version 3 section 7: |
| 22 | * |
| 23 | * If you modify this program, or any covered work, by linking or |
| 24 | * combining it with the OpenSSL project's OpenSSL library (or a |
| 25 | * modified version of that library), containing parts covered by the |
| 26 | * terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc. |
| 27 | * grants you additional permission to convey the resulting work. |
| 28 | * Corresponding Source for a non-source form of such a combination |
| 29 | * shall include the source code for the parts of OpenSSL used as well |
| 30 | * as that of the covered work. |
| 31 | */ |
| 32 | package com.savoirfairelinux.sflphone.client; |
| 33 | |
alision | d45da71 | 2013-05-30 09:18:49 -0400 | [diff] [blame] | 34 | import java.util.HashMap; |
alision | bd45a82 | 2013-06-06 17:35:35 -0400 | [diff] [blame] | 35 | import java.util.Timer; |
| 36 | import java.util.TimerTask; |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 37 | |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 38 | import android.app.Activity; |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 39 | import android.content.ComponentName; |
| 40 | import android.content.Context; |
| 41 | import android.content.Intent; |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 42 | import android.content.IntentFilter; |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 43 | import android.content.ServiceConnection; |
alision | f57d8a6 | 2013-07-02 09:37:12 -0400 | [diff] [blame] | 44 | import android.content.res.Configuration; |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 45 | import android.database.Cursor; |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 46 | import android.os.Bundle; |
| 47 | import android.os.IBinder; |
alision | 5f89963 | 2013-04-22 17:26:56 -0400 | [diff] [blame] | 48 | import android.os.RemoteException; |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 49 | import android.provider.ContactsContract.CommonDataKinds.Phone; |
| 50 | import android.provider.ContactsContract.CommonDataKinds.SipAddress; |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 51 | import android.support.v4.app.ActionBarDrawerToggle; |
| 52 | import android.support.v4.view.GravityCompat; |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 53 | import android.support.v4.view.ViewPager; |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 54 | import android.support.v4.widget.DrawerLayout; |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 55 | import android.util.Log; |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 56 | import android.view.MenuItem; |
| 57 | import android.view.View; |
alision | 7297bdb | 2013-05-21 11:56:55 -0400 | [diff] [blame] | 58 | import android.widget.RelativeLayout; |
alision | d45da71 | 2013-05-30 09:18:49 -0400 | [diff] [blame] | 59 | import android.widget.TabHost; |
alision | 3c5c2a9 | 2013-05-30 09:50:47 -0400 | [diff] [blame] | 60 | import android.widget.TabHost.OnTabChangeListener; |
alision | d45da71 | 2013-05-30 09:18:49 -0400 | [diff] [blame] | 61 | import android.widget.TabHost.TabContentFactory; |
alision | 04a0018 | 2013-05-10 17:05:29 -0400 | [diff] [blame] | 62 | import android.widget.Toast; |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 63 | |
| 64 | import com.savoirfairelinux.sflphone.R; |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 65 | import com.savoirfairelinux.sflphone.adapters.SectionsPagerAdapter; |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 66 | import com.savoirfairelinux.sflphone.fragments.ContactListFragment; |
alision | 7297bdb | 2013-05-21 11:56:55 -0400 | [diff] [blame] | 67 | import com.savoirfairelinux.sflphone.fragments.DialingFragment; |
alision | d9e2944 | 2013-04-17 16:10:18 -0400 | [diff] [blame] | 68 | import com.savoirfairelinux.sflphone.fragments.HistoryFragment; |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 69 | import com.savoirfairelinux.sflphone.fragments.HomeFragment; |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 70 | import com.savoirfairelinux.sflphone.fragments.MenuFragment; |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 71 | import com.savoirfairelinux.sflphone.interfaces.CallInterface; |
alision | 2ec64f9 | 2013-06-17 17:28:58 -0400 | [diff] [blame] | 72 | import com.savoirfairelinux.sflphone.loaders.LoaderConstants; |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 73 | import com.savoirfairelinux.sflphone.model.CallContact; |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 74 | import com.savoirfairelinux.sflphone.model.Conference; |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 75 | import com.savoirfairelinux.sflphone.model.SipCall; |
alision | cc7bb42 | 2013-06-06 15:31:39 -0400 | [diff] [blame] | 76 | import com.savoirfairelinux.sflphone.receivers.CallReceiver; |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 77 | import com.savoirfairelinux.sflphone.service.CallManagerCallBack; |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 78 | import com.savoirfairelinux.sflphone.service.ISipService; |
| 79 | import com.savoirfairelinux.sflphone.service.SipService; |
alision | 7297bdb | 2013-05-21 11:56:55 -0400 | [diff] [blame] | 80 | import com.savoirfairelinux.sflphone.views.CustomSlidingDrawer; |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 81 | |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 82 | public class SFLPhoneHomeActivity extends Activity implements DialingFragment.Callbacks, ContactListFragment.Callbacks, HomeFragment.Callbacks, |
| 83 | HistoryFragment.Callbacks, CallInterface, MenuFragment.Callbacks { |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 84 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 85 | SectionsPagerAdapter mSectionsPagerAdapter = null; |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 86 | static final String TAG = "SFLPhoneHomeActivity"; |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 87 | |
alision | 2cb9956 | 2013-05-30 17:02:20 -0400 | [diff] [blame] | 88 | /** |
| 89 | * Fragments used |
| 90 | */ |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 91 | private ContactListFragment mContactsFragment = null; |
alision | 58356b7 | 2013-06-03 17:13:36 -0400 | [diff] [blame] | 92 | // private DialingFragment mDialingFragment = null; |
| 93 | // private CallElementListFragment mCallElementList = null; |
| 94 | // private HistoryFragment mHistorySectionFragment = null; |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 95 | private MenuFragment fMenu; |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 96 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 97 | private boolean mBound = false; |
| 98 | private ISipService service; |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 99 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 100 | private CharSequence mDrawerTitle; |
| 101 | private CharSequence mTitle; |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 102 | |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 103 | // AccountSelectionAdapter mAdapter; |
| 104 | // private Spinner spinnerAccounts; |
alision | 58356b7 | 2013-06-03 17:13:36 -0400 | [diff] [blame] | 105 | |
alision | 2cb9956 | 2013-05-30 17:02:20 -0400 | [diff] [blame] | 106 | public static final int REQUEST_CODE_PREFERENCES = 1; |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 107 | private static final int REQUEST_CODE_CALL = 2; |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 108 | |
alision | 0b55383 | 2013-05-30 09:31:06 -0400 | [diff] [blame] | 109 | RelativeLayout mSliderButton; |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 110 | CustomSlidingDrawer mDrawer; |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 111 | private DrawerLayout mDrawerLayout; |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 112 | private ActionBarDrawerToggle mDrawerToggle; |
| 113 | /** |
| 114 | * The {@link ViewPager} that will host the section contents. |
| 115 | */ |
| 116 | ViewPager mViewPager; |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 117 | |
alision | 58356b7 | 2013-06-03 17:13:36 -0400 | [diff] [blame] | 118 | CallReceiver callReceiver; |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 119 | |
alision | 3c5c2a9 | 2013-05-30 09:50:47 -0400 | [diff] [blame] | 120 | private TabHost mTabHost; |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 121 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 122 | // public SFLPhoneHome extends Activity implements ActionBar.TabListener, OnClickListener |
| 123 | |
| 124 | /* called before activity is killed, e.g. rotation */ |
| 125 | @Override |
| 126 | protected void onSaveInstanceState(Bundle bundle) { |
| 127 | super.onSaveInstanceState(bundle); |
| 128 | for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { |
| 129 | try { |
| 130 | getFragmentManager().putFragment(bundle, mSectionsPagerAdapter.getClassName(i), mSectionsPagerAdapter.getItem(i)); |
| 131 | } catch (IllegalStateException e) { |
| 132 | Log.e(TAG, "fragment=" + mSectionsPagerAdapter.getItem(i)); |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | getFragmentManager().putFragment(bundle, "ContactsListFragment", mContactsFragment); |
| 137 | Log.w(TAG, "onSaveInstanceState()"); |
| 138 | } |
| 139 | |
| 140 | @Override |
| 141 | public void onCreate(Bundle savedInstanceState) { |
| 142 | super.onCreate(savedInstanceState); |
| 143 | |
alision | 58356b7 | 2013-06-03 17:13:36 -0400 | [diff] [blame] | 144 | callReceiver = new CallReceiver(this); |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 145 | |
alision | 2cb9956 | 2013-05-30 17:02:20 -0400 | [diff] [blame] | 146 | // String libraryPath = getApplicationInfo().dataDir + "/lib"; |
| 147 | // Log.i(TAG, libraryPath); |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 148 | |
alision | 58356b7 | 2013-06-03 17:13:36 -0400 | [diff] [blame] | 149 | setContentView(R.layout.activity_sflphone_home); |
| 150 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 151 | // Bind to LocalService |
| 152 | if (!mBound) { |
| 153 | Log.i(TAG, "onStart: Binding service..."); |
| 154 | Intent intent = new Intent(this, SipService.class); |
| 155 | bindService(intent, mConnection, Context.BIND_AUTO_CREATE); |
| 156 | } |
| 157 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 158 | if (mContactsFragment == null) { |
| 159 | mContactsFragment = new ContactListFragment(); |
| 160 | Log.w(TAG, "Recreated mContactListFragment=" + mContactsFragment); |
| 161 | getFragmentManager().beginTransaction().replace(R.id.contacts_frame, mContactsFragment).commit(); |
| 162 | } |
alision | 2ec64f9 | 2013-06-17 17:28:58 -0400 | [diff] [blame] | 163 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 164 | mDrawer = (CustomSlidingDrawer) findViewById(R.id.custom_sliding_drawer); |
alision | 7297bdb | 2013-05-21 11:56:55 -0400 | [diff] [blame] | 165 | |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 166 | mContactsFragment.setHandleView((RelativeLayout) findViewById(R.id.slider_button)); |
alision | 7297bdb | 2013-05-21 11:56:55 -0400 | [diff] [blame] | 167 | |
| 168 | mDrawer.setmTrackHandle(findViewById(R.id.handle_title)); |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 169 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 170 | // Set up the ViewPager with the sections adapter. |
| 171 | mViewPager = (ViewPager) findViewById(R.id.pager); |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 172 | mViewPager.setPageTransformer(true, new ZoomOutPageTransformer(0.7f)); |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 173 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 174 | mTitle = mDrawerTitle = getTitle(); |
| 175 | mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 176 | |
alision | 0b55383 | 2013-05-30 09:31:06 -0400 | [diff] [blame] | 177 | // set a custom shadow that overlays the main content when the drawer opens |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 178 | mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 179 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 180 | getActionBar().setDisplayHomeAsUpEnabled(true); |
| 181 | getActionBar().setHomeButtonEnabled(true); |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 182 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 183 | mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */ |
| 184 | mDrawerLayout, /* DrawerLayout object */ |
| 185 | R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */ |
| 186 | R.string.drawer_open, /* "open drawer" description for accessibility */ |
| 187 | R.string.drawer_close /* "close drawer" description for accessibility */ |
| 188 | ) { |
alision | 0b55383 | 2013-05-30 09:31:06 -0400 | [diff] [blame] | 189 | @Override |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 190 | public void onDrawerClosed(View view) { |
| 191 | getActionBar().setTitle(mTitle); |
| 192 | invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() |
| 193 | } |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 194 | |
alision | 0b55383 | 2013-05-30 09:31:06 -0400 | [diff] [blame] | 195 | @Override |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 196 | public void onDrawerOpened(View drawerView) { |
| 197 | getActionBar().setTitle(mDrawerTitle); |
| 198 | invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() |
| 199 | } |
| 200 | }; |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 201 | |
alision | 3c5c2a9 | 2013-05-30 09:50:47 -0400 | [diff] [blame] | 202 | mTabHost = (TabHost) findViewById(android.R.id.tabhost); |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 203 | mDrawerLayout.setDrawerListener(mDrawerToggle); |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 204 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 205 | mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { |
| 206 | @Override |
| 207 | public void onPageSelected(int position) { |
alision | 3c5c2a9 | 2013-05-30 09:50:47 -0400 | [diff] [blame] | 208 | mTabHost.setCurrentTab(position); |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 209 | } |
| 210 | }); |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 211 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 212 | } |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 213 | |
alision | 3c5c2a9 | 2013-05-30 09:50:47 -0400 | [diff] [blame] | 214 | private void initialiseTabHost(Bundle args) { |
| 215 | |
alision | 3c5c2a9 | 2013-05-30 09:50:47 -0400 | [diff] [blame] | 216 | mTabHost.setup(); |
| 217 | TabInfo tabInfo = null; |
alision | 2cb9956 | 2013-05-30 17:02:20 -0400 | [diff] [blame] | 218 | SFLPhoneHomeActivity |
| 219 | .AddTab(this, |
| 220 | this.mTabHost, |
| 221 | this.mTabHost.newTabSpec("Tab1").setIndicator(mSectionsPagerAdapter.getPageTitle(0), |
| 222 | getResources().getDrawable(mSectionsPagerAdapter.getIconOf(0))), (tabInfo = new TabInfo("Tab1", |
| 223 | DialingFragment.class, args))); |
alision | 3c5c2a9 | 2013-05-30 09:50:47 -0400 | [diff] [blame] | 224 | this.mapTabInfo.put(tabInfo.tag, tabInfo); |
alision | 2cb9956 | 2013-05-30 17:02:20 -0400 | [diff] [blame] | 225 | SFLPhoneHomeActivity.AddTab( |
| 226 | this, |
| 227 | this.mTabHost, |
| 228 | this.mTabHost.newTabSpec("Tab2").setIndicator(mSectionsPagerAdapter.getPageTitle(1), |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 229 | getResources().getDrawable(mSectionsPagerAdapter.getIconOf(1))), (tabInfo = new TabInfo("Tab2", HomeFragment.class, args))); |
alision | 3c5c2a9 | 2013-05-30 09:50:47 -0400 | [diff] [blame] | 230 | this.mapTabInfo.put(tabInfo.tag, tabInfo); |
alision | 2cb9956 | 2013-05-30 17:02:20 -0400 | [diff] [blame] | 231 | SFLPhoneHomeActivity |
| 232 | .AddTab(this, |
| 233 | this.mTabHost, |
| 234 | this.mTabHost.newTabSpec("Tab3").setIndicator(mSectionsPagerAdapter.getPageTitle(2), |
| 235 | getResources().getDrawable(mSectionsPagerAdapter.getIconOf(2))), (tabInfo = new TabInfo("Tab3", |
| 236 | HistoryFragment.class, args))); |
alision | 3c5c2a9 | 2013-05-30 09:50:47 -0400 | [diff] [blame] | 237 | this.mapTabInfo.put(tabInfo.tag, tabInfo); |
| 238 | |
| 239 | mTabHost.setOnTabChangedListener(new OnTabChangeListener() { |
| 240 | |
| 241 | @Override |
| 242 | public void onTabChanged(String tabId) { |
| 243 | int pos = mTabHost.getCurrentTab(); |
| 244 | mViewPager.setCurrentItem(pos); |
| 245 | |
| 246 | } |
| 247 | }); |
| 248 | } |
alision | 465ceba | 2013-07-04 09:24:30 -0400 | [diff] [blame] | 249 | |
alision | f57d8a6 | 2013-07-02 09:37:12 -0400 | [diff] [blame] | 250 | @Override |
| 251 | protected void onPostCreate(Bundle savedInstanceState) { |
| 252 | super.onPostCreate(savedInstanceState); |
| 253 | // Sync the toggle state after onRestoreInstanceState has occurred. |
| 254 | mDrawerToggle.syncState(); |
| 255 | } |
alision | 465ceba | 2013-07-04 09:24:30 -0400 | [diff] [blame] | 256 | |
alision | f57d8a6 | 2013-07-02 09:37:12 -0400 | [diff] [blame] | 257 | @Override |
| 258 | public void onConfigurationChanged(Configuration newConfig) { |
| 259 | super.onConfigurationChanged(newConfig); |
| 260 | mDrawerToggle.onConfigurationChanged(newConfig); |
| 261 | } |
alision | 3c5c2a9 | 2013-05-30 09:50:47 -0400 | [diff] [blame] | 262 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 263 | @Override |
| 264 | protected void onStart() { |
| 265 | Log.i(TAG, "onStart"); |
| 266 | super.onStart(); |
| 267 | } |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 268 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 269 | /* user gets back to the activity, e.g. through task manager */ |
| 270 | @Override |
| 271 | protected void onRestart() { |
| 272 | super.onRestart(); |
| 273 | } |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 274 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 275 | /* activity gets back to the foreground and user input */ |
| 276 | @Override |
| 277 | protected void onResume() { |
alision | 58356b7 | 2013-06-03 17:13:36 -0400 | [diff] [blame] | 278 | super.onResume(); |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 279 | IntentFilter intentFilter = new IntentFilter(); |
| 280 | intentFilter.addAction(CallManagerCallBack.INCOMING_CALL); |
| 281 | intentFilter.addAction(CallManagerCallBack.INCOMING_TEXT); |
| 282 | intentFilter.addAction(CallManagerCallBack.CALL_STATE_CHANGED); |
alision | 58356b7 | 2013-06-03 17:13:36 -0400 | [diff] [blame] | 283 | registerReceiver(callReceiver, intentFilter); |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 284 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 285 | } |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 286 | |
alision | bd45a82 | 2013-06-06 17:35:35 -0400 | [diff] [blame] | 287 | private boolean isClosing = false; |
| 288 | private Timer t = new Timer(); |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 289 | |
alision | bd45a82 | 2013-06-06 17:35:35 -0400 | [diff] [blame] | 290 | @Override |
| 291 | public void onBackPressed() { |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 292 | |
| 293 | if (getActionBar().getCustomView() != null) { |
alision | 2ec64f9 | 2013-06-17 17:28:58 -0400 | [diff] [blame] | 294 | getActionBar().setDisplayShowCustomEnabled(false); |
| 295 | getActionBar().setCustomView(null); |
| 296 | // Display all the contacts again |
| 297 | getLoaderManager().restartLoader(LoaderConstants.CONTACT_LOADER, null, mContactsFragment); |
| 298 | return; |
| 299 | } |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 300 | |
alision | bd45a82 | 2013-06-06 17:35:35 -0400 | [diff] [blame] | 301 | if (mDrawer.isOpened()) { |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 302 | mDrawer.animateClose(); |
alision | bd45a82 | 2013-06-06 17:35:35 -0400 | [diff] [blame] | 303 | return; |
| 304 | } |
alision | 2ec64f9 | 2013-06-17 17:28:58 -0400 | [diff] [blame] | 305 | |
alision | bd45a82 | 2013-06-06 17:35:35 -0400 | [diff] [blame] | 306 | if (isClosing) { |
| 307 | super.onBackPressed(); |
| 308 | t.cancel(); |
| 309 | finish(); |
| 310 | } else { |
| 311 | |
| 312 | t.schedule(new TimerTask() { |
| 313 | @Override |
| 314 | public void run() { |
| 315 | isClosing = false; |
| 316 | } |
| 317 | }, 3000); |
| 318 | Toast.makeText(this, getResources().getString(R.string.close_msg), Toast.LENGTH_SHORT).show(); |
| 319 | isClosing = true; |
| 320 | } |
| 321 | } |
alision | e2a38e1 | 2013-04-25 14:20:20 -0400 | [diff] [blame] | 322 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 323 | /* activity no more in foreground */ |
| 324 | @Override |
| 325 | protected void onPause() { |
| 326 | super.onPause(); |
alision | 58356b7 | 2013-06-03 17:13:36 -0400 | [diff] [blame] | 327 | unregisterReceiver(callReceiver); |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 328 | try { |
| 329 | service.createNotification(); |
| 330 | |
| 331 | } catch (RemoteException e) { |
| 332 | Log.e(TAG, e.toString()); |
| 333 | } |
alision | 2cb9956 | 2013-05-30 17:02:20 -0400 | [diff] [blame] | 334 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 335 | } |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 336 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 337 | /* activity is no longer visible */ |
| 338 | @Override |
| 339 | protected void onStop() { |
| 340 | super.onStop(); |
alision | 2cb9956 | 2013-05-30 17:02:20 -0400 | [diff] [blame] | 341 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 342 | } |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 343 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 344 | /* activity finishes itself or is being killed by the system */ |
| 345 | @Override |
| 346 | protected void onDestroy() { |
| 347 | /* stop the service, if no other bound user, no need to check if it is running */ |
| 348 | if (mBound) { |
| 349 | Log.i(TAG, "onDestroy: Unbinding service..."); |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 350 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 351 | unbindService(mConnection); |
| 352 | mBound = false; |
alision | 2cb9956 | 2013-05-30 17:02:20 -0400 | [diff] [blame] | 353 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 354 | } |
alision | 371b77e | 2013-04-23 14:51:26 -0400 | [diff] [blame] | 355 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 356 | super.onDestroy(); |
| 357 | } |
alision | 73424b6 | 2013-04-26 11:49:18 -0400 | [diff] [blame] | 358 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 359 | public void launchCallActivity(SipCall infos) { |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 360 | Log.i(TAG, "Launch Call Activity"); |
| 361 | Bundle bundle = new Bundle(); |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 362 | Conference tmp = new Conference("-1"); |
alision | 465ceba | 2013-07-04 09:24:30 -0400 | [diff] [blame] | 363 | |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 364 | tmp.getParticipants().add(infos); |
alision | 465ceba | 2013-07-04 09:24:30 -0400 | [diff] [blame] | 365 | |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 366 | bundle.putParcelable("conference", tmp); |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 367 | Intent intent = new Intent().setClass(this, CallActivity.class); |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 368 | intent.putExtra("resuming", false); |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 369 | intent.putExtras(bundle); |
| 370 | startActivityForResult(intent, REQUEST_CODE_CALL); |
alision | 465ceba | 2013-07-04 09:24:30 -0400 | [diff] [blame] | 371 | overridePendingTransition(R.anim.slide_down, R.anim.slide_up); |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 372 | } |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 373 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 374 | /** Defines callbacks for service binding, passed to bindService() */ |
| 375 | private ServiceConnection mConnection = new ServiceConnection() { |
alision | 371b77e | 2013-04-23 14:51:26 -0400 | [diff] [blame] | 376 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 377 | @Override |
| 378 | public void onServiceConnected(ComponentName className, IBinder binder) { |
| 379 | service = ISipService.Stub.asInterface(binder); |
alision | e2a38e1 | 2013-04-25 14:20:20 -0400 | [diff] [blame] | 380 | |
alision | 2cb9956 | 2013-05-30 17:02:20 -0400 | [diff] [blame] | 381 | try { |
alision | 58356b7 | 2013-06-03 17:13:36 -0400 | [diff] [blame] | 382 | |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 383 | fMenu = new MenuFragment(); |
| 384 | getFragmentManager().beginTransaction().replace(R.id.left_drawer, fMenu).commit(); |
alision | 58356b7 | 2013-06-03 17:13:36 -0400 | [diff] [blame] | 385 | mSectionsPagerAdapter = new SectionsPagerAdapter(SFLPhoneHomeActivity.this, getFragmentManager()); |
| 386 | initialiseTabHost(null); |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 387 | mViewPager.setOffscreenPageLimit(2); |
alision | 58356b7 | 2013-06-03 17:13:36 -0400 | [diff] [blame] | 388 | mViewPager.setAdapter(mSectionsPagerAdapter); |
| 389 | mTabHost.setCurrentTab(1); |
alision | 2cb9956 | 2013-05-30 17:02:20 -0400 | [diff] [blame] | 390 | service.destroyNotification(); |
alision | 58356b7 | 2013-06-03 17:13:36 -0400 | [diff] [blame] | 391 | // mAdapter = new AccountSelectionAdapter(SFLPhoneHomeActivity.this, service, new ArrayList<Account>()); |
| 392 | // spinnerAccounts.setAdapter(mAdapter); |
alision | 2cb9956 | 2013-05-30 17:02:20 -0400 | [diff] [blame] | 393 | } catch (RemoteException e) { |
| 394 | Log.e(TAG, e.toString()); |
| 395 | } |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 396 | mBound = true; |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 397 | Log.d(TAG, "Service connected service=" + service); |
alision | 371b77e | 2013-04-23 14:51:26 -0400 | [diff] [blame] | 398 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 399 | } |
alision | 5f89963 | 2013-04-22 17:26:56 -0400 | [diff] [blame] | 400 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 401 | @Override |
| 402 | public void onServiceDisconnected(ComponentName arg0) { |
alision | 5f89963 | 2013-04-22 17:26:56 -0400 | [diff] [blame] | 403 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 404 | mBound = false; |
| 405 | Log.d(TAG, "Service disconnected service=" + service); |
| 406 | } |
| 407 | }; |
alision | 5f89963 | 2013-04-22 17:26:56 -0400 | [diff] [blame] | 408 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 409 | @Override |
| 410 | public boolean onOptionsItemSelected(MenuItem item) { |
| 411 | Log.i(TAG, "onOptionsItemSelected " + item.getItemId()); |
alision | 5f89963 | 2013-04-22 17:26:56 -0400 | [diff] [blame] | 412 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 413 | if (mDrawerToggle.onOptionsItemSelected(item)) { |
| 414 | return true; |
| 415 | } |
alision | 5f89963 | 2013-04-22 17:26:56 -0400 | [diff] [blame] | 416 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 417 | return super.onOptionsItemSelected(item); |
| 418 | } |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 419 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 420 | @Override |
| 421 | public void onActivityResult(int requestCode, int resultCode, Intent data) { |
| 422 | super.onActivityResult(requestCode, resultCode, data); |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 423 | |
| 424 | switch (requestCode) { |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 425 | case REQUEST_CODE_PREFERENCES: |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 426 | Log.w(TAG, "In Activity"); |
| 427 | fMenu.updateAllAccounts(); |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 428 | break; |
| 429 | case REQUEST_CODE_CALL: |
alision | 2cb9956 | 2013-05-30 17:02:20 -0400 | [diff] [blame] | 430 | Log.w(TAG, "Result out of CallActivity"); |
alision | 465ceba | 2013-07-04 09:24:30 -0400 | [diff] [blame] | 431 | if (mSectionsPagerAdapter.getItem(2) != null) |
| 432 | getLoaderManager().restartLoader(LoaderConstants.HISTORY_LOADER, null, (HistoryFragment) mSectionsPagerAdapter.getItem(2)); |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 433 | break; |
| 434 | } |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 435 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 436 | } |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 437 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 438 | @Override |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 439 | public ISipService getService() { |
| 440 | return service; |
| 441 | } |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 442 | |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 443 | /** |
| 444 | * Interface implemented to handle incoming events |
| 445 | */ |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 446 | @Override |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 447 | public void incomingCall(Intent call) { |
| 448 | Toast.makeText(this, "New Call incoming", Toast.LENGTH_LONG).show(); |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 449 | SipCall infos = call.getParcelableExtra("newcall"); |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 450 | |
alision | 58356b7 | 2013-06-03 17:13:36 -0400 | [diff] [blame] | 451 | // mCallElementList.addCall(infos); |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 452 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 453 | launchCallActivity(infos); |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 454 | |
| 455 | } |
| 456 | |
| 457 | @Override |
| 458 | public void callStateChanged(Intent callState) { |
| 459 | Bundle b = callState.getBundleExtra("com.savoirfairelinux.sflphone.service.newstate"); |
| 460 | String cID = b.getString("CallID"); |
| 461 | String state = b.getString("State"); |
| 462 | Log.i(TAG, "callStateChanged" + cID + " " + state); |
alision | 58356b7 | 2013-06-03 17:13:36 -0400 | [diff] [blame] | 463 | // mCallElementList.updateCall(cID, state); |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 464 | |
| 465 | } |
| 466 | |
| 467 | @Override |
| 468 | public void incomingText(Intent msg) { |
| 469 | Bundle b = msg.getBundleExtra("com.savoirfairelinux.sflphone.service.newtext"); |
| 470 | b.getString("CallID"); |
| 471 | String from = b.getString("From"); |
| 472 | String mess = b.getString("Msg"); |
| 473 | Toast.makeText(getApplicationContext(), "text from " + from + " : " + mess, Toast.LENGTH_LONG).show(); |
| 474 | } |
| 475 | |
| 476 | @Override |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 477 | public void onContactSelected(final CallContact c) { |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 478 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 479 | Thread launcher = new Thread(new Runnable() { |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 480 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 481 | final String[] CONTACTS_PHONES_PROJECTION = new String[] { Phone.NUMBER, Phone.TYPE }; |
| 482 | final String[] CONTACTS_SIP_PROJECTION = new String[] { SipAddress.SIP_ADDRESS, SipAddress.TYPE }; |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 483 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 484 | @Override |
| 485 | public void run() { |
| 486 | SipCall.SipCallBuilder callBuilder = SipCall.SipCallBuilder.getInstance(); |
| 487 | try { |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 488 | callBuilder.startCallCreation().setAccountID(service.getAccountList().get(1).toString()) |
| 489 | .setCallType(SipCall.state.CALL_TYPE_OUTGOING); |
| 490 | Cursor cPhones = getContentResolver().query(Phone.CONTENT_URI, CONTACTS_PHONES_PROJECTION, Phone.CONTACT_ID + " =" + c.getId(), |
| 491 | null, null); |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 492 | |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 493 | while (cPhones.moveToNext()) { |
| 494 | c.addPhoneNumber(cPhones.getString(cPhones.getColumnIndex(Phone.NUMBER)), cPhones.getInt(cPhones.getColumnIndex(Phone.TYPE))); |
| 495 | } |
| 496 | cPhones.close(); |
| 497 | |
| 498 | Cursor cSip = getContentResolver().query(Phone.CONTENT_URI, CONTACTS_SIP_PROJECTION, Phone.CONTACT_ID + "=" + c.getId(), null, |
| 499 | null); |
| 500 | |
| 501 | while (cSip.moveToNext()) { |
| 502 | c.addSipNumber(cSip.getString(cSip.getColumnIndex(SipAddress.SIP_ADDRESS)), cSip.getInt(cSip.getColumnIndex(SipAddress.TYPE))); |
| 503 | } |
| 504 | cSip.close(); |
| 505 | callBuilder.setContact(c); |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 506 | launchCallActivity(callBuilder.build()); |
| 507 | } catch (RemoteException e1) { |
| 508 | Log.e(TAG, e1.toString()); |
| 509 | } catch (Exception e) { |
| 510 | Log.e(TAG, e.toString()); |
| 511 | } |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 512 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 513 | } |
| 514 | }); |
| 515 | launcher.start(); |
| 516 | mDrawer.close(); |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 517 | |
| 518 | } |
| 519 | |
| 520 | @Override |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 521 | public void onCallDialed(String to) { |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 522 | |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 523 | if (fMenu.getSelectedAccount() == null) { |
| 524 | Toast.makeText(this, "No Account Selected", Toast.LENGTH_SHORT).show(); |
| 525 | return; |
| 526 | } |
| 527 | |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 528 | SipCall.SipCallBuilder callBuilder = SipCall.SipCallBuilder.getInstance(); |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 529 | callBuilder.startCallCreation().setAccountID(fMenu.getSelectedAccount().getAccountID()).setCallType(SipCall.state.CALL_TYPE_OUTGOING); |
| 530 | callBuilder.setContact(CallContact.ContactBuilder.buildUnknownContact(to)); |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 531 | |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 532 | try { |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 533 | launchCallActivity(callBuilder.build()); |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 534 | } catch (Exception e) { |
| 535 | Log.e(TAG, e.toString()); |
| 536 | } |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 537 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 538 | } |
alision | 371b77e | 2013-04-23 14:51:26 -0400 | [diff] [blame] | 539 | |
alision | d45da71 | 2013-05-30 09:18:49 -0400 | [diff] [blame] | 540 | @Override |
| 541 | public void onContactDragged() { |
| 542 | |
| 543 | mDrawer.close(); |
alision | 2cb9956 | 2013-05-30 17:02:20 -0400 | [diff] [blame] | 544 | mTabHost.setCurrentTab(1); |
alision | d45da71 | 2013-05-30 09:18:49 -0400 | [diff] [blame] | 545 | |
| 546 | } |
| 547 | |
| 548 | private HashMap<String, TabInfo> mapTabInfo = new HashMap<String, SFLPhoneHomeActivity.TabInfo>(); |
| 549 | |
| 550 | /** |
| 551 | * A simple factory that returns dummy views to the Tabhost |
| 552 | * |
| 553 | * @author mwho |
| 554 | */ |
| 555 | class TabFactory implements TabContentFactory { |
| 556 | |
| 557 | private final Context mContext; |
| 558 | |
| 559 | /** |
| 560 | * @param context |
| 561 | */ |
| 562 | public TabFactory(Context context) { |
| 563 | mContext = context; |
| 564 | } |
| 565 | |
| 566 | /** |
| 567 | * (non-Javadoc) |
| 568 | * |
| 569 | * @see android.widget.TabHost.TabContentFactory#createTabContent(java.lang.String) |
| 570 | */ |
| 571 | public View createTabContent(String tag) { |
| 572 | View v = new View(mContext); |
| 573 | v.setMinimumWidth(0); |
| 574 | v.setMinimumHeight(0); |
| 575 | return v; |
| 576 | } |
| 577 | |
| 578 | } |
| 579 | |
| 580 | /** |
| 581 | * |
| 582 | * @author mwho Maintains extrinsic info of a tab's construct |
| 583 | */ |
| 584 | private class TabInfo { |
| 585 | private String tag; |
alision | d45da71 | 2013-05-30 09:18:49 -0400 | [diff] [blame] | 586 | |
| 587 | TabInfo(String tag, Class<?> clazz, Bundle args) { |
| 588 | this.tag = tag; |
alision | d45da71 | 2013-05-30 09:18:49 -0400 | [diff] [blame] | 589 | } |
| 590 | |
| 591 | } |
| 592 | |
| 593 | private static void AddTab(SFLPhoneHomeActivity activity, TabHost tabHost, TabHost.TabSpec tabSpec, TabInfo tabInfo) { |
| 594 | // Attach a Tab view factory to the spec |
| 595 | tabSpec.setContent(activity.new TabFactory(activity)); |
| 596 | tabHost.addTab(tabSpec); |
| 597 | } |
| 598 | |
alision | 58356b7 | 2013-06-03 17:13:36 -0400 | [diff] [blame] | 599 | @Override |
| 600 | public void openDrawer() { |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 601 | mDrawer.animateOpen(); |
alision | 58356b7 | 2013-06-03 17:13:36 -0400 | [diff] [blame] | 602 | } |
| 603 | |
alision | 806e18e | 2013-06-21 15:30:17 -0400 | [diff] [blame] | 604 | @Override |
| 605 | public void confCreated(Intent intent) { |
| 606 | // TODO Auto-generated method stub |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 607 | |
alision | 806e18e | 2013-06-21 15:30:17 -0400 | [diff] [blame] | 608 | } |
| 609 | |
| 610 | @Override |
| 611 | public void confRemoved(Intent intent) { |
| 612 | // TODO Auto-generated method stub |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 613 | |
alision | 806e18e | 2013-06-21 15:30:17 -0400 | [diff] [blame] | 614 | } |
| 615 | |
| 616 | @Override |
| 617 | public void confChanged(Intent intent) { |
| 618 | // TODO Auto-generated method stub |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 619 | |
| 620 | } |
| 621 | |
| 622 | @Override |
| 623 | public void recordingChanged(Intent intent) { |
| 624 | // TODO Auto-generated method stub |
| 625 | |
| 626 | } |
| 627 | |
| 628 | @Override |
| 629 | public void resumeCallActivity() { |
| 630 | Intent intent = new Intent().setClass(this, CallActivity.class); |
| 631 | intent.putExtra("resuming", true); |
| 632 | startActivityForResult(intent, REQUEST_CODE_CALL); |
alision | 806e18e | 2013-06-21 15:30:17 -0400 | [diff] [blame] | 633 | } |
| 634 | |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 635 | } |