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 | */ |
Alexandre Lision | 064e1e0 | 2013-10-01 16:18:42 -0400 | [diff] [blame] | 32 | package org.sflphone.client; |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 33 | |
Alexandre Lision | 5ed2c97 | 2013-10-11 15:36:33 -0400 | [diff] [blame] | 34 | import java.io.InvalidObjectException; |
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 | |
Alexandre Lision | 064e1e0 | 2013-10-01 16:18:42 -0400 | [diff] [blame] | 38 | import org.sflphone.R; |
| 39 | import org.sflphone.adapters.SectionsPagerAdapter; |
| 40 | import org.sflphone.fragments.ContactListFragment; |
| 41 | import org.sflphone.fragments.DialingFragment; |
| 42 | import org.sflphone.fragments.HistoryFragment; |
| 43 | import org.sflphone.fragments.HomeFragment; |
| 44 | import org.sflphone.fragments.MenuFragment; |
| 45 | import org.sflphone.interfaces.CallInterface; |
Alexandre Lision | 064e1e0 | 2013-10-01 16:18:42 -0400 | [diff] [blame] | 46 | import org.sflphone.model.CallContact; |
| 47 | import org.sflphone.model.Conference; |
| 48 | import org.sflphone.model.SipCall; |
| 49 | import org.sflphone.receivers.CallReceiver; |
| 50 | import org.sflphone.service.CallManagerCallBack; |
| 51 | import org.sflphone.service.ISipService; |
| 52 | import org.sflphone.service.SipService; |
Alexandre Lision | e5b6602 | 2013-10-30 11:34:15 -0400 | [diff] [blame] | 53 | import org.sflphone.views.PagerSlidingTabStrip; |
Alexandre Lision | 450458a | 2013-11-22 11:33:12 -0500 | [diff] [blame^] | 54 | import org.sflphone.views.SlidingUpPanelLayout; |
| 55 | import org.sflphone.views.SlidingUpPanelLayout.PanelSlideListener; |
Alexandre Lision | 064e1e0 | 2013-10-01 16:18:42 -0400 | [diff] [blame] | 56 | |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 57 | import android.app.Activity; |
Alexandre Lision | c51ccb1 | 2013-09-11 16:00:30 -0400 | [diff] [blame] | 58 | import android.app.AlertDialog; |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 59 | import android.content.ComponentName; |
| 60 | import android.content.Context; |
Alexandre Lision | c51ccb1 | 2013-09-11 16:00:30 -0400 | [diff] [blame] | 61 | import android.content.DialogInterface; |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 62 | import android.content.Intent; |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 63 | import android.content.IntentFilter; |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 64 | import android.content.ServiceConnection; |
alision | f57d8a6 | 2013-07-02 09:37:12 -0400 | [diff] [blame] | 65 | import android.content.res.Configuration; |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 66 | import android.database.Cursor; |
Alexandre Lision | 450458a | 2013-11-22 11:33:12 -0500 | [diff] [blame^] | 67 | import android.graphics.Color; |
Alexandre Lision | c59685a | 2013-10-04 16:36:36 -0400 | [diff] [blame] | 68 | import android.net.Uri; |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 69 | import android.os.Bundle; |
| 70 | import android.os.IBinder; |
alision | 5f89963 | 2013-04-22 17:26:56 -0400 | [diff] [blame] | 71 | import android.os.RemoteException; |
Alexandre Lision | c59685a | 2013-10-04 16:36:36 -0400 | [diff] [blame] | 72 | import android.provider.ContactsContract; |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 73 | import android.provider.ContactsContract.CommonDataKinds.Phone; |
| 74 | import android.provider.ContactsContract.CommonDataKinds.SipAddress; |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 75 | import android.support.v4.app.ActionBarDrawerToggle; |
| 76 | import android.support.v4.view.GravityCompat; |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 77 | import android.support.v4.view.ViewPager; |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 78 | import android.support.v4.widget.DrawerLayout; |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 79 | import android.util.Log; |
Alexandre Lision | 3ccccf0 | 2013-10-07 14:10:46 -0400 | [diff] [blame] | 80 | import android.view.Gravity; |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 81 | import android.view.MenuItem; |
| 82 | import android.view.View; |
Alexandre Lision | 6890005 | 2013-11-01 11:34:56 -0400 | [diff] [blame] | 83 | import android.widget.ImageView; |
alision | 7297bdb | 2013-05-21 11:56:55 -0400 | [diff] [blame] | 84 | import android.widget.RelativeLayout; |
alision | 04a0018 | 2013-05-10 17:05:29 -0400 | [diff] [blame] | 85 | import android.widget.Toast; |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 86 | |
Alexandre Lision | 4ab5397 | 2013-11-04 16:59:18 -0500 | [diff] [blame] | 87 | public class HomeActivity extends Activity implements DialingFragment.Callbacks, ContactListFragment.Callbacks, HomeFragment.Callbacks, |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 88 | HistoryFragment.Callbacks, CallInterface, MenuFragment.Callbacks { |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 89 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 90 | SectionsPagerAdapter mSectionsPagerAdapter = null; |
Alexandre Lision | 9d052a1 | 2013-11-06 15:13:34 -0500 | [diff] [blame] | 91 | static final String TAG = "HomeActivity"; |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 92 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 93 | private ContactListFragment mContactsFragment = null; |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 94 | private MenuFragment fMenu; |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 95 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 96 | private boolean mBound = false; |
| 97 | private ISipService service; |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 98 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 99 | private CharSequence mDrawerTitle; |
| 100 | private CharSequence mTitle; |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 101 | |
alision | 2cb9956 | 2013-05-30 17:02:20 -0400 | [diff] [blame] | 102 | public static final int REQUEST_CODE_PREFERENCES = 1; |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 103 | private static final int REQUEST_CODE_CALL = 2; |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 104 | |
alision | 0b55383 | 2013-05-30 09:31:06 -0400 | [diff] [blame] | 105 | RelativeLayout mSliderButton; |
Alexandre Lision | 450458a | 2013-11-22 11:33:12 -0500 | [diff] [blame^] | 106 | SlidingUpPanelLayout mContactDrawer; |
Alexandre Lision | 6890005 | 2013-11-01 11:34:56 -0400 | [diff] [blame] | 107 | private DrawerLayout mNavigationDrawer; |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 108 | private ActionBarDrawerToggle mDrawerToggle; |
Alexandre Lision | c87763a | 2013-11-01 12:53:38 -0400 | [diff] [blame] | 109 | ImageView mShadow; |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 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; |
Alexandre Lision | 9d052a1 | 2013-11-06 15:13:34 -0500 | [diff] [blame] | 116 | private boolean isClosing = false; |
| 117 | private Timer t = new Timer(); |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 118 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 119 | /* called before activity is killed, e.g. rotation */ |
| 120 | @Override |
| 121 | protected void onSaveInstanceState(Bundle bundle) { |
| 122 | super.onSaveInstanceState(bundle); |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 123 | getFragmentManager().putFragment(bundle, "ContactsListFragment", mContactsFragment); |
| 124 | Log.w(TAG, "onSaveInstanceState()"); |
| 125 | } |
| 126 | |
| 127 | @Override |
| 128 | public void onCreate(Bundle savedInstanceState) { |
| 129 | super.onCreate(savedInstanceState); |
| 130 | |
alision | 58356b7 | 2013-06-03 17:13:36 -0400 | [diff] [blame] | 131 | callReceiver = new CallReceiver(this); |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 132 | |
alision | 58356b7 | 2013-06-03 17:13:36 -0400 | [diff] [blame] | 133 | setContentView(R.layout.activity_sflphone_home); |
| 134 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 135 | // Bind to LocalService |
| 136 | if (!mBound) { |
| 137 | Log.i(TAG, "onStart: Binding service..."); |
| 138 | Intent intent = new Intent(this, SipService.class); |
Alexandre Lision | 0f550ee | 2013-10-25 15:34:38 -0400 | [diff] [blame] | 139 | startService(intent); |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 140 | bindService(intent, mConnection, Context.BIND_AUTO_CREATE); |
| 141 | } |
Alexandre Lision | 8b9d8e8 | 2013-10-04 09:21:27 -0400 | [diff] [blame] | 142 | |
| 143 | if (savedInstanceState != null) { |
Alexandre Lision | 23628c1 | 2013-09-24 11:17:05 -0400 | [diff] [blame] | 144 | mContactsFragment = (ContactListFragment) getFragmentManager().getFragment(savedInstanceState, "ContactsListFragment"); |
| 145 | } |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 146 | if (mContactsFragment == null) { |
| 147 | mContactsFragment = new ContactListFragment(); |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 148 | getFragmentManager().beginTransaction().replace(R.id.contacts_frame, mContactsFragment).commit(); |
| 149 | } |
alision | 2ec64f9 | 2013-06-17 17:28:58 -0400 | [diff] [blame] | 150 | |
Alexandre Lision | 450458a | 2013-11-22 11:33:12 -0500 | [diff] [blame^] | 151 | mContactDrawer = (SlidingUpPanelLayout) findViewById(R.id.contact_panel); |
| 152 | // mContactDrawer.setShadowDrawable(getResources().getDrawable(R.drawable.above_shadow)); |
| 153 | mContactDrawer.setAnchorPoint(0.3f); |
| 154 | mContactDrawer.setDragView(findViewById(R.id.contacts_frame)); |
| 155 | mContactDrawer.setEnableDragViewTouchEvents(true); |
| 156 | // mContactDrawer.setCoveredFadeColor(0xff000000); |
| 157 | mContactDrawer.setPanelSlideListener(new PanelSlideListener() { |
Alexandre Lision | 8b9d8e8 | 2013-10-04 09:21:27 -0400 | [diff] [blame] | 158 | |
| 159 | @Override |
Alexandre Lision | 450458a | 2013-11-22 11:33:12 -0500 | [diff] [blame^] | 160 | public void onPanelSlide(View panel, float slideOffset) { |
| 161 | if (slideOffset < 0.2) { |
| 162 | if (getActionBar().isShowing()) { |
| 163 | getActionBar().hide(); |
| 164 | } |
| 165 | } else { |
| 166 | if (!getActionBar().isShowing()) { |
| 167 | getActionBar().show(); |
| 168 | } |
Alexandre Lision | 8b9d8e8 | 2013-10-04 09:21:27 -0400 | [diff] [blame] | 169 | } |
| 170 | } |
Alexandre Lision | 450458a | 2013-11-22 11:33:12 -0500 | [diff] [blame^] | 171 | |
| 172 | @Override |
| 173 | public void onPanelExpanded(View panel) { |
| 174 | |
| 175 | } |
| 176 | |
| 177 | @Override |
| 178 | public void onPanelCollapsed(View panel) { |
| 179 | |
| 180 | } |
| 181 | |
| 182 | @Override |
| 183 | public void onPanelAnchored(View panel) { |
| 184 | |
| 185 | } |
Alexandre Lision | 8b9d8e8 | 2013-10-04 09:21:27 -0400 | [diff] [blame] | 186 | }); |
Alexandre Lision | d588bff | 2013-10-08 12:43:01 -0400 | [diff] [blame] | 187 | |
Alexandre Lision | 450458a | 2013-11-22 11:33:12 -0500 | [diff] [blame^] | 188 | // TODO |
| 189 | // mContactsFragment.setHandleView((RelativeLayout) findViewById(R.id.slider_button)); |
Alexandre Lision | c87763a | 2013-11-01 12:53:38 -0400 | [diff] [blame] | 190 | mShadow = (ImageView) findViewById(R.id.overall_shadow); |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 191 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 192 | // Set up the ViewPager with the sections adapter. |
| 193 | mViewPager = (ViewPager) findViewById(R.id.pager); |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 194 | mViewPager.setPageTransformer(true, new ZoomOutPageTransformer(0.7f)); |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 195 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 196 | mTitle = mDrawerTitle = getTitle(); |
Alexandre Lision | 6890005 | 2013-11-01 11:34:56 -0400 | [diff] [blame] | 197 | mNavigationDrawer = (DrawerLayout) findViewById(R.id.drawer_layout); |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 198 | |
alision | 0b55383 | 2013-05-30 09:31:06 -0400 | [diff] [blame] | 199 | // set a custom shadow that overlays the main content when the drawer opens |
Alexandre Lision | 6890005 | 2013-11-01 11:34:56 -0400 | [diff] [blame] | 200 | mNavigationDrawer.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 201 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 202 | getActionBar().setDisplayHomeAsUpEnabled(true); |
| 203 | getActionBar().setHomeButtonEnabled(true); |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 204 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 205 | mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */ |
Alexandre Lision | 6890005 | 2013-11-01 11:34:56 -0400 | [diff] [blame] | 206 | mNavigationDrawer, /* DrawerLayout object */ |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 207 | R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */ |
| 208 | R.string.drawer_open, /* "open drawer" description for accessibility */ |
| 209 | R.string.drawer_close /* "close drawer" description for accessibility */ |
| 210 | ) { |
alision | 0b55383 | 2013-05-30 09:31:06 -0400 | [diff] [blame] | 211 | @Override |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 212 | public void onDrawerClosed(View view) { |
| 213 | getActionBar().setTitle(mTitle); |
| 214 | invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() |
| 215 | } |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 216 | |
alision | 0b55383 | 2013-05-30 09:31:06 -0400 | [diff] [blame] | 217 | @Override |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 218 | public void onDrawerOpened(View drawerView) { |
| 219 | getActionBar().setTitle(mDrawerTitle); |
| 220 | invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() |
| 221 | } |
| 222 | }; |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 223 | |
Alexandre Lision | c51ccb1 | 2013-09-11 16:00:30 -0400 | [diff] [blame] | 224 | // mTabHost = (TabHost) findViewById(android.R.id.tabhost); |
Alexandre Lision | 6890005 | 2013-11-01 11:34:56 -0400 | [diff] [blame] | 225 | mNavigationDrawer.setDrawerListener(mDrawerToggle); |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 226 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 227 | } |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 228 | |
alision | f57d8a6 | 2013-07-02 09:37:12 -0400 | [diff] [blame] | 229 | @Override |
| 230 | protected void onPostCreate(Bundle savedInstanceState) { |
| 231 | super.onPostCreate(savedInstanceState); |
| 232 | // Sync the toggle state after onRestoreInstanceState has occurred. |
| 233 | mDrawerToggle.syncState(); |
Alexandre Lision | 450458a | 2013-11-22 11:33:12 -0500 | [diff] [blame^] | 234 | if (mContactDrawer.isExpanded()) { |
Alexandre Lision | d16bad9 | 2013-10-09 17:16:20 -0400 | [diff] [blame] | 235 | getActionBar().hide(); |
| 236 | } |
alision | f57d8a6 | 2013-07-02 09:37:12 -0400 | [diff] [blame] | 237 | } |
alision | 465ceba | 2013-07-04 09:24:30 -0400 | [diff] [blame] | 238 | |
alision | f57d8a6 | 2013-07-02 09:37:12 -0400 | [diff] [blame] | 239 | @Override |
| 240 | public void onConfigurationChanged(Configuration newConfig) { |
| 241 | super.onConfigurationChanged(newConfig); |
| 242 | mDrawerToggle.onConfigurationChanged(newConfig); |
| 243 | } |
alision | 3c5c2a9 | 2013-05-30 09:50:47 -0400 | [diff] [blame] | 244 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 245 | @Override |
| 246 | protected void onStart() { |
| 247 | Log.i(TAG, "onStart"); |
| 248 | super.onStart(); |
Alexandre Lision | c51ccb1 | 2013-09-11 16:00:30 -0400 | [diff] [blame] | 249 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 250 | } |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 251 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 252 | /* user gets back to the activity, e.g. through task manager */ |
| 253 | @Override |
| 254 | protected void onRestart() { |
| 255 | super.onRestart(); |
| 256 | } |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 257 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 258 | /* activity gets back to the foreground and user input */ |
| 259 | @Override |
| 260 | protected void onResume() { |
alision | 58356b7 | 2013-06-03 17:13:36 -0400 | [diff] [blame] | 261 | super.onResume(); |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 262 | IntentFilter intentFilter = new IntentFilter(); |
| 263 | intentFilter.addAction(CallManagerCallBack.INCOMING_CALL); |
| 264 | intentFilter.addAction(CallManagerCallBack.INCOMING_TEXT); |
| 265 | intentFilter.addAction(CallManagerCallBack.CALL_STATE_CHANGED); |
alision | 58356b7 | 2013-06-03 17:13:36 -0400 | [diff] [blame] | 266 | registerReceiver(callReceiver, intentFilter); |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 267 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 268 | } |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 269 | |
alision | bd45a82 | 2013-06-06 17:35:35 -0400 | [diff] [blame] | 270 | @Override |
| 271 | public void onBackPressed() { |
Alexandre Lision | d588bff | 2013-10-08 12:43:01 -0400 | [diff] [blame] | 272 | |
Alexandre Lision | 6890005 | 2013-11-01 11:34:56 -0400 | [diff] [blame] | 273 | if (mNavigationDrawer.isDrawerVisible(Gravity.LEFT)) { |
| 274 | mNavigationDrawer.closeDrawer(Gravity.LEFT); |
Alexandre Lision | 6885547 | 2013-10-10 16:20:46 -0400 | [diff] [blame] | 275 | return; |
Alexandre Lision | 3ccccf0 | 2013-10-07 14:10:46 -0400 | [diff] [blame] | 276 | } |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 277 | |
Alexandre Lision | 450458a | 2013-11-22 11:33:12 -0500 | [diff] [blame^] | 278 | if (mContactDrawer.isExpanded() || mContactDrawer.isAnchored()) { |
| 279 | mContactDrawer.collapsePane(); |
alision | bd45a82 | 2013-06-06 17:35:35 -0400 | [diff] [blame] | 280 | return; |
| 281 | } |
alision | 2ec64f9 | 2013-06-17 17:28:58 -0400 | [diff] [blame] | 282 | |
alision | bd45a82 | 2013-06-06 17:35:35 -0400 | [diff] [blame] | 283 | if (isClosing) { |
| 284 | super.onBackPressed(); |
| 285 | t.cancel(); |
| 286 | finish(); |
| 287 | } else { |
| 288 | |
| 289 | t.schedule(new TimerTask() { |
| 290 | @Override |
| 291 | public void run() { |
| 292 | isClosing = false; |
| 293 | } |
| 294 | }, 3000); |
| 295 | Toast.makeText(this, getResources().getString(R.string.close_msg), Toast.LENGTH_SHORT).show(); |
| 296 | isClosing = true; |
| 297 | } |
| 298 | } |
alision | e2a38e1 | 2013-04-25 14:20:20 -0400 | [diff] [blame] | 299 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 300 | /* activity no more in foreground */ |
| 301 | @Override |
| 302 | protected void onPause() { |
| 303 | super.onPause(); |
alision | 58356b7 | 2013-06-03 17:13:36 -0400 | [diff] [blame] | 304 | unregisterReceiver(callReceiver); |
Alexandre Lision | b4a9e39 | 2013-10-01 14:39:43 -0400 | [diff] [blame] | 305 | if (mBound) { |
| 306 | unbindService(mConnection); |
| 307 | mBound = false; |
| 308 | } |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 309 | } |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 310 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 311 | /* activity finishes itself or is being killed by the system */ |
| 312 | @Override |
| 313 | protected void onDestroy() { |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 314 | super.onDestroy(); |
Alexandre Lision | b4a9e39 | 2013-10-01 14:39:43 -0400 | [diff] [blame] | 315 | Log.i(TAG, "onDestroy: destroying service..."); |
| 316 | Intent sipServiceIntent = new Intent(this, SipService.class); |
| 317 | stopService(sipServiceIntent); |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 318 | } |
alision | 73424b6 | 2013-04-26 11:49:18 -0400 | [diff] [blame] | 319 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 320 | public void launchCallActivity(SipCall infos) { |
Alexandre Lision | c59685a | 2013-10-04 16:36:36 -0400 | [diff] [blame] | 321 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 322 | Bundle bundle = new Bundle(); |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 323 | Conference tmp = new Conference("-1"); |
alision | 465ceba | 2013-07-04 09:24:30 -0400 | [diff] [blame] | 324 | |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 325 | tmp.getParticipants().add(infos); |
alision | 465ceba | 2013-07-04 09:24:30 -0400 | [diff] [blame] | 326 | |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 327 | bundle.putParcelable("conference", tmp); |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 328 | Intent intent = new Intent().setClass(this, CallActivity.class); |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 329 | intent.putExtra("resuming", false); |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 330 | intent.putExtras(bundle); |
| 331 | startActivityForResult(intent, REQUEST_CODE_CALL); |
Alexandre Lision | d588bff | 2013-10-08 12:43:01 -0400 | [diff] [blame] | 332 | |
Alexandre Lision | 8b9d8e8 | 2013-10-04 09:21:27 -0400 | [diff] [blame] | 333 | // overridePendingTransition(R.anim.slide_down, R.anim.slide_up); |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 334 | } |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 335 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 336 | /** Defines callbacks for service binding, passed to bindService() */ |
| 337 | private ServiceConnection mConnection = new ServiceConnection() { |
alision | 371b77e | 2013-04-23 14:51:26 -0400 | [diff] [blame] | 338 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 339 | @Override |
| 340 | public void onServiceConnected(ComponentName className, IBinder binder) { |
| 341 | service = ISipService.Stub.asInterface(binder); |
alision | e2a38e1 | 2013-04-25 14:20:20 -0400 | [diff] [blame] | 342 | |
alision | 2cb9956 | 2013-05-30 17:02:20 -0400 | [diff] [blame] | 343 | try { |
alision | 58356b7 | 2013-06-03 17:13:36 -0400 | [diff] [blame] | 344 | |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 345 | fMenu = new MenuFragment(); |
| 346 | getFragmentManager().beginTransaction().replace(R.id.left_drawer, fMenu).commit(); |
Alexandre Lision | 4ab5397 | 2013-11-04 16:59:18 -0500 | [diff] [blame] | 347 | mSectionsPagerAdapter = new SectionsPagerAdapter(HomeActivity.this, getFragmentManager()); |
Alexandre Lision | c51ccb1 | 2013-09-11 16:00:30 -0400 | [diff] [blame] | 348 | |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 349 | mViewPager.setOffscreenPageLimit(2); |
alision | 58356b7 | 2013-06-03 17:13:36 -0400 | [diff] [blame] | 350 | mViewPager.setAdapter(mSectionsPagerAdapter); |
Alexandre Lision | c51ccb1 | 2013-09-11 16:00:30 -0400 | [diff] [blame] | 351 | mViewPager.setCurrentItem(1); |
Alexandre Lision | e5b6602 | 2013-10-30 11:34:15 -0400 | [diff] [blame] | 352 | |
| 353 | final PagerSlidingTabStrip strip = PagerSlidingTabStrip.class.cast(findViewById(R.id.pts_main)); |
| 354 | |
Alexandre Lision | e5b6602 | 2013-10-30 11:34:15 -0400 | [diff] [blame] | 355 | strip.setViewPager(mViewPager); |
alision | 2cb9956 | 2013-05-30 17:02:20 -0400 | [diff] [blame] | 356 | service.destroyNotification(); |
| 357 | } catch (RemoteException e) { |
| 358 | Log.e(TAG, e.toString()); |
| 359 | } |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 360 | mBound = true; |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 361 | Log.d(TAG, "Service connected service=" + service); |
alision | 371b77e | 2013-04-23 14:51:26 -0400 | [diff] [blame] | 362 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 363 | } |
alision | 5f89963 | 2013-04-22 17:26:56 -0400 | [diff] [blame] | 364 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 365 | @Override |
| 366 | public void onServiceDisconnected(ComponentName arg0) { |
alision | 5f89963 | 2013-04-22 17:26:56 -0400 | [diff] [blame] | 367 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 368 | mBound = false; |
| 369 | Log.d(TAG, "Service disconnected service=" + service); |
| 370 | } |
| 371 | }; |
alision | 5f89963 | 2013-04-22 17:26:56 -0400 | [diff] [blame] | 372 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 373 | @Override |
| 374 | public boolean onOptionsItemSelected(MenuItem item) { |
| 375 | Log.i(TAG, "onOptionsItemSelected " + item.getItemId()); |
alision | 5f89963 | 2013-04-22 17:26:56 -0400 | [diff] [blame] | 376 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 377 | if (mDrawerToggle.onOptionsItemSelected(item)) { |
| 378 | return true; |
| 379 | } |
alision | 5f89963 | 2013-04-22 17:26:56 -0400 | [diff] [blame] | 380 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 381 | return super.onOptionsItemSelected(item); |
| 382 | } |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 383 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 384 | @Override |
| 385 | public void onActivityResult(int requestCode, int resultCode, Intent data) { |
| 386 | super.onActivityResult(requestCode, resultCode, data); |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 387 | |
| 388 | switch (requestCode) { |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 389 | case REQUEST_CODE_PREFERENCES: |
Alexandre Lision | e5b6602 | 2013-10-30 11:34:15 -0400 | [diff] [blame] | 390 | if (fMenu != null) |
Alexandre Lision | 933ef0a | 2013-10-15 17:28:40 -0400 | [diff] [blame] | 391 | fMenu.updateAllAccounts(); |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 392 | break; |
| 393 | case REQUEST_CODE_CALL: |
Alexandre Lision | c51ccb1 | 2013-09-11 16:00:30 -0400 | [diff] [blame] | 394 | if (resultCode == CallActivity.RESULT_FAILURE) { |
Alexandre Lision | 8b9d8e8 | 2013-10-04 09:21:27 -0400 | [diff] [blame] | 395 | Log.w(TAG, "Call Failed"); |
Alexandre Lision | c51ccb1 | 2013-09-11 16:00:30 -0400 | [diff] [blame] | 396 | } |
| 397 | // if (mSectionsPagerAdapter != null && mSectionsPagerAdapter.getItem(2) != null) |
| 398 | // getLoaderManager().restartLoader(LoaderConstants.HISTORY_LOADER, null, (HistoryFragment) mSectionsPagerAdapter.getItem(2)); |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 399 | break; |
| 400 | } |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 401 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 402 | } |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 403 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 404 | @Override |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 405 | public ISipService getService() { |
| 406 | return service; |
| 407 | } |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 408 | |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 409 | /** |
| 410 | * Interface implemented to handle incoming events |
| 411 | */ |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 412 | @Override |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 413 | public void incomingCall(Intent call) { |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 414 | SipCall infos = call.getParcelableExtra("newcall"); |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 415 | |
alision | 58356b7 | 2013-06-03 17:13:36 -0400 | [diff] [blame] | 416 | // mCallElementList.addCall(infos); |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 417 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 418 | launchCallActivity(infos); |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 419 | |
| 420 | } |
| 421 | |
| 422 | @Override |
| 423 | public void callStateChanged(Intent callState) { |
| 424 | Bundle b = callState.getBundleExtra("com.savoirfairelinux.sflphone.service.newstate"); |
| 425 | String cID = b.getString("CallID"); |
| 426 | String state = b.getString("State"); |
| 427 | Log.i(TAG, "callStateChanged" + cID + " " + state); |
Alexandre Lision | 1a9e3b1 | 2013-09-16 11:06:07 -0400 | [diff] [blame] | 428 | mSectionsPagerAdapter.updateHome(); |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 429 | |
| 430 | } |
| 431 | |
| 432 | @Override |
| 433 | public void incomingText(Intent msg) { |
| 434 | Bundle b = msg.getBundleExtra("com.savoirfairelinux.sflphone.service.newtext"); |
| 435 | b.getString("CallID"); |
| 436 | String from = b.getString("From"); |
| 437 | String mess = b.getString("Msg"); |
| 438 | Toast.makeText(getApplicationContext(), "text from " + from + " : " + mess, Toast.LENGTH_LONG).show(); |
| 439 | } |
Alexandre Lision | d588bff | 2013-10-08 12:43:01 -0400 | [diff] [blame] | 440 | |
Alexandre Lision | e1c96db | 2013-10-04 14:34:21 -0400 | [diff] [blame] | 441 | @Override |
| 442 | public void onTextContact(final CallContact c) { |
| 443 | // TODO |
| 444 | } |
Alexandre Lision | d588bff | 2013-10-08 12:43:01 -0400 | [diff] [blame] | 445 | |
Alexandre Lision | c59685a | 2013-10-04 16:36:36 -0400 | [diff] [blame] | 446 | @Override |
| 447 | public void onEditContact(final CallContact c) { |
| 448 | Intent intent = new Intent(Intent.ACTION_VIEW); |
| 449 | Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_URI, String.valueOf(c.getId())); |
| 450 | intent.setData(uri); |
| 451 | startActivity(intent); |
| 452 | } |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 453 | |
| 454 | @Override |
Alexandre Lision | e1c96db | 2013-10-04 14:34:21 -0400 | [diff] [blame] | 455 | public void onCallContact(final CallContact c) { |
Alexandre Lision | 8b9d8e8 | 2013-10-04 09:21:27 -0400 | [diff] [blame] | 456 | |
Alexandre Lision | f0b993d | 2013-09-12 13:25:10 -0400 | [diff] [blame] | 457 | if (fMenu.getSelectedAccount() == null) { |
Alexandre Lision | f0b993d | 2013-09-12 13:25:10 -0400 | [diff] [blame] | 458 | createAccountDialog().show(); |
| 459 | return; |
| 460 | } |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 461 | |
Alexandre Lision | d588bff | 2013-10-08 12:43:01 -0400 | [diff] [blame] | 462 | if (!fMenu.getSelectedAccount().isRegistered()) { |
| 463 | createNotRegisteredDialog().show(); |
| 464 | return; |
| 465 | } |
| 466 | |
Alexandre Lision | d16bad9 | 2013-10-09 17:16:20 -0400 | [diff] [blame] | 467 | getActionBar().show(); |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 468 | Thread launcher = new Thread(new Runnable() { |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 469 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 470 | final String[] CONTACTS_PHONES_PROJECTION = new String[] { Phone.NUMBER, Phone.TYPE }; |
| 471 | final String[] CONTACTS_SIP_PROJECTION = new String[] { SipAddress.SIP_ADDRESS, SipAddress.TYPE }; |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 472 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 473 | @Override |
| 474 | public void run() { |
| 475 | SipCall.SipCallBuilder callBuilder = SipCall.SipCallBuilder.getInstance(); |
| 476 | try { |
Alexandre Lision | d588bff | 2013-10-08 12:43:01 -0400 | [diff] [blame] | 477 | callBuilder.startCallCreation().setAccount(fMenu.getSelectedAccount()).setCallType(SipCall.state.CALL_TYPE_OUTGOING); |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 478 | Cursor cPhones = getContentResolver().query(Phone.CONTENT_URI, CONTACTS_PHONES_PROJECTION, Phone.CONTACT_ID + " =" + c.getId(), |
| 479 | null, null); |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 480 | |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 481 | while (cPhones.moveToNext()) { |
| 482 | c.addPhoneNumber(cPhones.getString(cPhones.getColumnIndex(Phone.NUMBER)), cPhones.getInt(cPhones.getColumnIndex(Phone.TYPE))); |
| 483 | } |
| 484 | cPhones.close(); |
| 485 | |
| 486 | Cursor cSip = getContentResolver().query(Phone.CONTENT_URI, CONTACTS_SIP_PROJECTION, Phone.CONTACT_ID + "=" + c.getId(), null, |
| 487 | null); |
| 488 | |
| 489 | while (cSip.moveToNext()) { |
| 490 | c.addSipNumber(cSip.getString(cSip.getColumnIndex(SipAddress.SIP_ADDRESS)), cSip.getInt(cSip.getColumnIndex(SipAddress.TYPE))); |
| 491 | } |
| 492 | cSip.close(); |
| 493 | callBuilder.setContact(c); |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 494 | launchCallActivity(callBuilder.build()); |
Alexandre Lision | 5ed2c97 | 2013-10-11 15:36:33 -0400 | [diff] [blame] | 495 | } catch (InvalidObjectException e) { |
| 496 | e.printStackTrace(); |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 497 | } |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 498 | |
alision | 55c36cb | 2013-06-14 14:57:38 -0400 | [diff] [blame] | 499 | } |
| 500 | }); |
| 501 | launcher.start(); |
Alexandre Lision | 450458a | 2013-11-22 11:33:12 -0500 | [diff] [blame^] | 502 | mContactDrawer.collapsePane(); |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 503 | |
| 504 | } |
| 505 | |
| 506 | @Override |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 507 | public void onCallDialed(String to) { |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 508 | |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 509 | if (fMenu.getSelectedAccount() == null) { |
Alexandre Lision | c51ccb1 | 2013-09-11 16:00:30 -0400 | [diff] [blame] | 510 | createAccountDialog().show(); |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 511 | return; |
| 512 | } |
| 513 | |
Alexandre Lision | d588bff | 2013-10-08 12:43:01 -0400 | [diff] [blame] | 514 | if (fMenu.getSelectedAccount().isRegistered()) { |
| 515 | SipCall.SipCallBuilder callBuilder = SipCall.SipCallBuilder.getInstance(); |
| 516 | callBuilder.startCallCreation().setAccount(fMenu.getSelectedAccount()).setCallType(SipCall.state.CALL_TYPE_OUTGOING); |
| 517 | callBuilder.setContact(CallContact.ContactBuilder.buildUnknownContact(to)); |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 518 | |
Alexandre Lision | d588bff | 2013-10-08 12:43:01 -0400 | [diff] [blame] | 519 | try { |
| 520 | launchCallActivity(callBuilder.build()); |
| 521 | } catch (Exception e) { |
| 522 | Log.e(TAG, e.toString()); |
| 523 | } |
| 524 | } else { |
Alexandre Lision | 5ed2c97 | 2013-10-11 15:36:33 -0400 | [diff] [blame] | 525 | createNotRegisteredDialog().show(); |
| 526 | ; |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 527 | } |
alision | 84813a1 | 2013-05-27 17:40:39 -0400 | [diff] [blame] | 528 | |
alision | 9f7a6ec | 2013-05-24 16:26:26 -0400 | [diff] [blame] | 529 | } |
alision | 371b77e | 2013-04-23 14:51:26 -0400 | [diff] [blame] | 530 | |
Alexandre Lision | d588bff | 2013-10-08 12:43:01 -0400 | [diff] [blame] | 531 | private AlertDialog createNotRegisteredDialog() { |
| 532 | final Activity ownerActivity = this; |
| 533 | AlertDialog.Builder builder = new AlertDialog.Builder(ownerActivity); |
| 534 | |
| 535 | builder.setMessage(getResources().getString(R.string.cannot_pass_sipcall)) |
| 536 | .setTitle(getResources().getString(R.string.cannot_pass_sipcall_title)) |
| 537 | .setPositiveButton(getResources().getString(android.R.string.ok), new DialogInterface.OnClickListener() { |
| 538 | public void onClick(DialogInterface dialog, int whichButton) { |
Alexandre Lision | 5ed2c97 | 2013-10-11 15:36:33 -0400 | [diff] [blame] | 539 | |
Alexandre Lision | d588bff | 2013-10-08 12:43:01 -0400 | [diff] [blame] | 540 | } |
| 541 | }); |
| 542 | |
| 543 | AlertDialog alertDialog = builder.create(); |
| 544 | alertDialog.setOwnerActivity(ownerActivity); |
| 545 | |
| 546 | return alertDialog; |
| 547 | } |
| 548 | |
Alexandre Lision | c51ccb1 | 2013-09-11 16:00:30 -0400 | [diff] [blame] | 549 | private AlertDialog createAccountDialog() { |
| 550 | final Activity ownerActivity = this; |
| 551 | AlertDialog.Builder builder = new AlertDialog.Builder(ownerActivity); |
| 552 | |
| 553 | builder.setMessage(getResources().getString(R.string.create_new_account_dialog)) |
| 554 | .setTitle(getResources().getString(R.string.create_new_account_dialog_title)) |
| 555 | .setPositiveButton(getResources().getString(android.R.string.ok), new DialogInterface.OnClickListener() { |
| 556 | public void onClick(DialogInterface dialog, int whichButton) { |
| 557 | Intent in = new Intent(); |
Alexandre Lision | 40954dc | 2013-10-09 15:24:03 -0400 | [diff] [blame] | 558 | in.setClass(ownerActivity, AccountWizard.class); |
Alexandre Lision | 4ab5397 | 2013-11-04 16:59:18 -0500 | [diff] [blame] | 559 | ownerActivity.startActivityForResult(in, HomeActivity.REQUEST_CODE_PREFERENCES); |
Alexandre Lision | c51ccb1 | 2013-09-11 16:00:30 -0400 | [diff] [blame] | 560 | } |
| 561 | }).setNegativeButton(getResources().getString(android.R.string.cancel), new DialogInterface.OnClickListener() { |
| 562 | public void onClick(DialogInterface dialog, int whichButton) { |
| 563 | dialog.dismiss(); |
| 564 | } |
| 565 | }); |
| 566 | |
| 567 | AlertDialog alertDialog = builder.create(); |
| 568 | alertDialog.setOwnerActivity(ownerActivity); |
| 569 | |
| 570 | return alertDialog; |
| 571 | } |
| 572 | |
alision | d45da71 | 2013-05-30 09:18:49 -0400 | [diff] [blame] | 573 | @Override |
| 574 | public void onContactDragged() { |
Alexandre Lision | 450458a | 2013-11-22 11:33:12 -0500 | [diff] [blame^] | 575 | mContactDrawer.collapsePane(); |
alision | d45da71 | 2013-05-30 09:18:49 -0400 | [diff] [blame] | 576 | } |
| 577 | |
alision | 58356b7 | 2013-06-03 17:13:36 -0400 | [diff] [blame] | 578 | @Override |
| 579 | public void openDrawer() { |
Alexandre Lision | 450458a | 2013-11-22 11:33:12 -0500 | [diff] [blame^] | 580 | mContactDrawer.expandPane(); |
alision | 58356b7 | 2013-06-03 17:13:36 -0400 | [diff] [blame] | 581 | } |
| 582 | |
alision | 806e18e | 2013-06-21 15:30:17 -0400 | [diff] [blame] | 583 | @Override |
| 584 | public void confCreated(Intent intent) { |
| 585 | // TODO Auto-generated method stub |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 586 | |
alision | 806e18e | 2013-06-21 15:30:17 -0400 | [diff] [blame] | 587 | } |
| 588 | |
| 589 | @Override |
| 590 | public void confRemoved(Intent intent) { |
| 591 | // TODO Auto-generated method stub |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 592 | |
alision | 806e18e | 2013-06-21 15:30:17 -0400 | [diff] [blame] | 593 | } |
| 594 | |
| 595 | @Override |
| 596 | public void confChanged(Intent intent) { |
| 597 | // TODO Auto-generated method stub |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 598 | |
| 599 | } |
| 600 | |
| 601 | @Override |
| 602 | public void recordingChanged(Intent intent) { |
| 603 | // TODO Auto-generated method stub |
| 604 | |
| 605 | } |
| 606 | |
| 607 | @Override |
Alexandre Lision | 1a9e3b1 | 2013-09-16 11:06:07 -0400 | [diff] [blame] | 608 | public void selectedCall(Conference c) { |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 609 | Intent intent = new Intent().setClass(this, CallActivity.class); |
| 610 | intent.putExtra("resuming", true); |
Alexandre Lision | 1a9e3b1 | 2013-09-16 11:06:07 -0400 | [diff] [blame] | 611 | intent.putExtra("conference", c); |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 612 | startActivityForResult(intent, REQUEST_CODE_CALL); |
alision | 806e18e | 2013-06-21 15:30:17 -0400 | [diff] [blame] | 613 | } |
Alexandre Lision | 8b9d8e8 | 2013-10-04 09:21:27 -0400 | [diff] [blame] | 614 | |
Alexandre Lision | 3f1aa68 | 2013-11-18 10:49:28 -0500 | [diff] [blame] | 615 | public class ZoomOutPageTransformer implements ViewPager.PageTransformer { |
Alexandre Lision | ee37f7c | 2013-09-25 17:36:39 -0400 | [diff] [blame] | 616 | private static final float MIN_ALPHA = .6f; |
Alexandre Lision | 8b9d8e8 | 2013-10-04 09:21:27 -0400 | [diff] [blame] | 617 | |
| 618 | // private final float scalingStart; |
Alexandre Lision | ee37f7c | 2013-09-25 17:36:39 -0400 | [diff] [blame] | 619 | |
| 620 | public ZoomOutPageTransformer(float scalingStart) { |
| 621 | super(); |
Alexandre Lision | 8b9d8e8 | 2013-10-04 09:21:27 -0400 | [diff] [blame] | 622 | // this.scalingStart = 1 - scalingStart; |
Alexandre Lision | ee37f7c | 2013-09-25 17:36:39 -0400 | [diff] [blame] | 623 | } |
| 624 | |
| 625 | @Override |
| 626 | public void transformPage(View page, float position) { |
| 627 | // page.setRotationY(position * -30); |
| 628 | final float normalizedposition = Math.abs(Math.abs(position) - 1); |
Alexandre Lision | 8b9d8e8 | 2013-10-04 09:21:27 -0400 | [diff] [blame] | 629 | page.setAlpha(MIN_ALPHA + (1.f - MIN_ALPHA) * normalizedposition); |
Alexandre Lision | ee37f7c | 2013-09-25 17:36:39 -0400 | [diff] [blame] | 630 | } |
| 631 | } |
alision | 806e18e | 2013-06-21 15:30:17 -0400 | [diff] [blame] | 632 | |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 633 | } |