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