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