Adrien Béraud | ffd3241 | 2012-08-07 18:39:23 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2004-2012 Savoir-Faire Linux Inc. |
| 3 | * |
| 4 | * Author: Adrien Beraud <adrien.beraud@gmail.com> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 3 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 19 | * |
| 20 | * Additional permission under GNU GPL version 3 section 7: |
| 21 | * |
| 22 | * If you modify this program, or any covered work, by linking or |
| 23 | * combining it with the OpenSSL project's OpenSSL library (or a |
| 24 | * modified version of that library), containing parts covered by the |
| 25 | * terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc. |
| 26 | * grants you additional permission to convey the resulting work. |
| 27 | * Corresponding Source for a non-source form of such a combination |
| 28 | * shall include the source code for the parts of OpenSSL used as well |
| 29 | * as that of the covered work. |
| 30 | */ |
| 31 | package com.savoirfairelinux.sflphone.client; |
| 32 | |
Emeric Vigier | e89b48b | 2012-08-30 14:16:46 -0400 | [diff] [blame] | 33 | import java.util.Random; |
| 34 | |
Adrien Béraud | ffd3241 | 2012-08-07 18:39:23 -0400 | [diff] [blame] | 35 | import android.app.ActionBar; |
| 36 | import android.app.Activity; |
| 37 | import android.app.Fragment; |
| 38 | import android.app.FragmentManager; |
| 39 | import android.app.FragmentTransaction; |
Alexandre Savard | 1bcaf53 | 2012-09-05 16:23:02 -0400 | [diff] [blame] | 40 | import android.content.Intent; |
Emeric Vigier | 7a255aa | 2012-08-29 09:49:18 -0400 | [diff] [blame] | 41 | import android.content.pm.PackageInfo; |
| 42 | import android.content.pm.PackageManager; |
| 43 | import android.content.pm.PackageManager.NameNotFoundException; |
Adrien Béraud | ffd3241 | 2012-08-07 18:39:23 -0400 | [diff] [blame] | 44 | import android.os.Bundle; |
Emeric Vigier | 383b2a2 | 2012-08-27 14:20:05 -0400 | [diff] [blame] | 45 | import android.os.Handler; |
| 46 | import android.os.Message; |
Adrien Béraud | ffd3241 | 2012-08-07 18:39:23 -0400 | [diff] [blame] | 47 | import android.support.v13.app.FragmentStatePagerAdapter; |
| 48 | import android.support.v4.view.ViewPager; |
Emeric Vigier | 05e894e | 2012-08-20 13:53:02 -0400 | [diff] [blame] | 49 | import android.util.Log; |
Adrien Béraud | ffd3241 | 2012-08-07 18:39:23 -0400 | [diff] [blame] | 50 | import android.view.Gravity; |
| 51 | import android.view.LayoutInflater; |
| 52 | import android.view.Menu; |
Alexandre Savard | 1bcaf53 | 2012-09-05 16:23:02 -0400 | [diff] [blame] | 53 | import android.view.MenuItem; |
Adrien Béraud | ffd3241 | 2012-08-07 18:39:23 -0400 | [diff] [blame] | 54 | import android.view.View; |
Emeric Vigier | 05e894e | 2012-08-20 13:53:02 -0400 | [diff] [blame] | 55 | import android.view.View.OnClickListener; |
Adrien Béraud | ffd3241 | 2012-08-07 18:39:23 -0400 | [diff] [blame] | 56 | import android.view.ViewGroup; |
Emeric Vigier | a6bdb70 | 2012-08-31 15:34:53 -0400 | [diff] [blame] | 57 | import android.view.animation.AlphaAnimation; |
| 58 | import android.view.animation.Animation; |
| 59 | import android.view.animation.LinearInterpolator; |
Emeric Vigier | d5c17f5 | 2012-08-29 09:29:33 -0400 | [diff] [blame] | 60 | import android.widget.EditText; |
Emeric Vigier | e89b48b | 2012-08-30 14:16:46 -0400 | [diff] [blame] | 61 | import android.widget.ImageButton; |
Adrien Béraud | ffd3241 | 2012-08-07 18:39:23 -0400 | [diff] [blame] | 62 | import android.widget.TextView; |
| 63 | |
| 64 | import com.savoirfairelinux.sflphone.R; |
| 65 | |
Emeric Vigier | 62ca14d | 2012-08-24 11:05:09 -0400 | [diff] [blame] | 66 | public class SFLPhoneHome extends Activity implements ActionBar.TabListener, OnClickListener |
Adrien Béraud | ffd3241 | 2012-08-07 18:39:23 -0400 | [diff] [blame] | 67 | { |
| 68 | SectionsPagerAdapter mSectionsPagerAdapter; |
Emeric Vigier | 62ca14d | 2012-08-24 11:05:09 -0400 | [diff] [blame] | 69 | static final String TAG = "SFLPhoneHome"; |
Emeric Vigier | a6bdb70 | 2012-08-31 15:34:53 -0400 | [diff] [blame] | 70 | private ButtonSectionFragment buttonFragment; |
Emeric Vigier | 383b2a2 | 2012-08-27 14:20:05 -0400 | [diff] [blame] | 71 | Handler callbackHandler; |
Emeric Vigier | 9701e03 | 2012-09-12 12:38:01 -0400 | [diff] [blame] | 72 | private Manager manager; |
Emeric Vigier | 78a53e9 | 2012-08-29 18:15:34 -0400 | [diff] [blame] | 73 | /* default callID */ |
| 74 | static String callID = "007"; |
Emeric Vigier | e89b48b | 2012-08-30 14:16:46 -0400 | [diff] [blame] | 75 | static boolean callOnGoing = false; |
Emeric Vigier | a6bdb70 | 2012-08-31 15:34:53 -0400 | [diff] [blame] | 76 | private String incomingCallID = ""; |
Alexandre Savard | 1bcaf53 | 2012-09-05 16:23:02 -0400 | [diff] [blame] | 77 | private static final int REQUEST_CODE_PREFERENCES = 1; |
Emeric Vigier | 090ab60 | 2012-09-17 11:09:46 -0400 | [diff] [blame^] | 78 | ImageButton buttonCall, buttonHangup; |
Adrien Béraud | ffd3241 | 2012-08-07 18:39:23 -0400 | [diff] [blame] | 79 | |
| 80 | /** |
| 81 | * The {@link ViewPager} that will host the section contents. |
| 82 | */ |
| 83 | ViewPager mViewPager; |
| 84 | |
Emeric Vigier | 05e894e | 2012-08-20 13:53:02 -0400 | [diff] [blame] | 85 | final private int[] icon_res_id = {R.drawable.ic_tab_call, R.drawable.ic_tab_history, R.drawable.ic_tab_play_selected}; |
Adrien Béraud | ffd3241 | 2012-08-07 18:39:23 -0400 | [diff] [blame] | 86 | |
| 87 | @Override |
| 88 | public void onCreate(Bundle savedInstanceState) |
| 89 | { |
| 90 | super.onCreate(savedInstanceState); |
| 91 | setContentView(R.layout.activity_sflphone_home); |
| 92 | |
| 93 | mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager()); |
| 94 | |
| 95 | final ActionBar actionBar = getActionBar(); |
| 96 | actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); |
Alexandre Savard | def3bfa | 2012-09-12 16:20:06 -0400 | [diff] [blame] | 97 | // final ActionBar actionBar = getActionBar(); |
Adrien Béraud | ffd3241 | 2012-08-07 18:39:23 -0400 | [diff] [blame] | 98 | |
| 99 | // Set up the ViewPager with the sections adapter. |
| 100 | mViewPager = (ViewPager) findViewById(R.id.pager); |
| 101 | mViewPager.setAdapter(mSectionsPagerAdapter); |
| 102 | |
| 103 | // When swiping between different sections, select the corresponding tab. |
| 104 | // We can also use ActionBar.Tab#select() to do this if we have a reference to the |
| 105 | // Tab. |
| 106 | mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() |
| 107 | { |
| 108 | @Override |
| 109 | public void onPageSelected(int position) |
| 110 | { |
| 111 | actionBar.setSelectedNavigationItem(position); |
| 112 | } |
| 113 | }); |
| 114 | |
| 115 | // For each of the sections in the app, add a tab to the action bar. |
| 116 | for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { |
| 117 | // Create a tab with text corresponding to the page title defined by the adapter. |
| 118 | // Also specify this Activity object, which implements the TabListener interface, as the |
| 119 | // listener for when this tab is selected. |
| 120 | actionBar.addTab(actionBar.newTab().setIcon(icon_res_id[i]).setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); |
| 121 | } |
Emeric Vigier | 383b2a2 | 2012-08-27 14:20:05 -0400 | [diff] [blame] | 122 | |
| 123 | // FIXME |
| 124 | callbackHandler = new Handler() { |
| 125 | public void handleMessage(Message msg) { |
| 126 | Bundle b = msg.getData(); |
| 127 | TextView callVoidText; |
| 128 | |
Emeric Vigier | c411ce3 | 2012-08-29 09:28:28 -0400 | [diff] [blame] | 129 | Log.i(TAG, "handleMessage"); |
Emeric Vigier | 383b2a2 | 2012-08-27 14:20:05 -0400 | [diff] [blame] | 130 | |
| 131 | callVoidText = buttonFragment.getcallVoidText(); |
| 132 | if (callVoidText == null) |
| 133 | Log.e(TAG, "SFLPhoneHome: callVoidText is " + callVoidText); |
| 134 | callVoidText.setText(b.getString("callback_string")); |
| 135 | |
Emeric Vigier | c411ce3 | 2012-08-29 09:28:28 -0400 | [diff] [blame] | 136 | Log.i(TAG, "handleMessage: " + b.getString("callback_string")); |
Emeric Vigier | 383b2a2 | 2012-08-27 14:20:05 -0400 | [diff] [blame] | 137 | } |
| 138 | }; |
Emeric Vigier | a6bdb70 | 2012-08-31 15:34:53 -0400 | [diff] [blame] | 139 | |
| 140 | buttonCall = (ImageButton) findViewById(R.id.buttonCall); |
| 141 | buttonHangup = (ImageButton) findViewById(R.id.buttonHangUp); |
Alexandre Savard | def3bfa | 2012-09-12 16:20:06 -0400 | [diff] [blame] | 142 | |
Emeric Vigier | 9701e03 | 2012-09-12 12:38:01 -0400 | [diff] [blame] | 143 | manager = new Manager(callbackHandler); |
| 144 | Log.i(TAG, "ManagerImpl::instance() = " + manager.managerImpl); |
| 145 | manager.setActivity(this); |
| 146 | /* set static AppPath before calling manager.init */ |
| 147 | manager.managerImpl.setPath(getAppPath()); |
| 148 | Log.i(TAG, "manager created with callbackHandler " + callbackHandler); |
Emeric Vigier | a6bdb70 | 2012-08-31 15:34:53 -0400 | [diff] [blame] | 149 | |
Adrien Béraud | ffd3241 | 2012-08-07 18:39:23 -0400 | [diff] [blame] | 150 | } |
| 151 | |
Emeric Vigier | 62ca14d | 2012-08-24 11:05:09 -0400 | [diff] [blame] | 152 | // FIXME |
| 153 | static { |
| 154 | System.loadLibrary("gnustl_shared"); |
| 155 | System.loadLibrary("expat"); |
| 156 | System.loadLibrary("yaml"); |
| 157 | System.loadLibrary("ccgnu2"); |
| 158 | System.loadLibrary("crypto"); |
| 159 | System.loadLibrary("ssl"); |
| 160 | System.loadLibrary("ccrtp1"); |
| 161 | System.loadLibrary("dbus"); |
| 162 | System.loadLibrary("dbus-c++-1"); |
| 163 | System.loadLibrary("samplerate"); |
| 164 | System.loadLibrary("codec_ulaw"); |
| 165 | System.loadLibrary("codec_alaw"); |
| 166 | System.loadLibrary("speexresampler"); |
| 167 | System.loadLibrary("sflphone"); |
| 168 | } |
Alexandre Savard | 1bcaf53 | 2012-09-05 16:23:02 -0400 | [diff] [blame] | 169 | |
| 170 | @Override |
| 171 | public boolean onOptionsItemSelected(MenuItem item) { |
Alexandre Savard | ebc9443 | 2012-09-13 14:30:55 -0400 | [diff] [blame] | 172 | Log.i("SFLphone", "onOptionsItemSelected " + item.getItemId()); |
Alexandre Savard | 1bcaf53 | 2012-09-05 16:23:02 -0400 | [diff] [blame] | 173 | |
Alexandre Savard | ebc9443 | 2012-09-13 14:30:55 -0400 | [diff] [blame] | 174 | if(item.getItemId() != 0) { |
| 175 | // When the button is clicked, launch an activity through this intent |
| 176 | Intent launchPreferencesIntent = new Intent().setClass(this, SFLPhonePreferenceActivity.class); |
Alexandre Savard | 1bcaf53 | 2012-09-05 16:23:02 -0400 | [diff] [blame] | 177 | |
Alexandre Savard | ebc9443 | 2012-09-13 14:30:55 -0400 | [diff] [blame] | 178 | // Make it a subactivity so we know when it returns |
| 179 | startActivityForResult(launchPreferencesIntent, REQUEST_CODE_PREFERENCES); |
| 180 | } |
Alexandre Savard | 1bcaf53 | 2012-09-05 16:23:02 -0400 | [diff] [blame] | 181 | |
| 182 | return super.onOptionsItemSelected(item); |
| 183 | } |
Emeric Vigier | 62ca14d | 2012-08-24 11:05:09 -0400 | [diff] [blame] | 184 | |
Adrien Béraud | ffd3241 | 2012-08-07 18:39:23 -0400 | [diff] [blame] | 185 | @Override |
| 186 | public boolean onCreateOptionsMenu(Menu menu) |
| 187 | { |
| 188 | getMenuInflater().inflate(R.menu.activity_sflphone_home, menu); |
| 189 | return true; |
| 190 | } |
| 191 | |
| 192 | @Override |
| 193 | public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) |
| 194 | { |
| 195 | } |
| 196 | |
| 197 | @Override |
| 198 | public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) |
| 199 | { |
| 200 | // When the given tab is selected, switch to the corresponding page in the ViewPager. |
| 201 | mViewPager.setCurrentItem(tab.getPosition()); |
| 202 | } |
| 203 | |
| 204 | @Override |
| 205 | public void onTabReselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) |
| 206 | { |
Emeric Vigier | 05e894e | 2012-08-20 13:53:02 -0400 | [diff] [blame] | 207 | // Log.d(TAG, "onTabReselected"); |
Adrien Béraud | ffd3241 | 2012-08-07 18:39:23 -0400 | [diff] [blame] | 208 | } |
| 209 | |
Emeric Vigier | a6bdb70 | 2012-08-31 15:34:53 -0400 | [diff] [blame] | 210 | public void setIncomingCallID(String id) { |
| 211 | incomingCallID = id; |
| 212 | } |
| 213 | |
Adrien Béraud | ffd3241 | 2012-08-07 18:39:23 -0400 | [diff] [blame] | 214 | /** |
| 215 | * A {@link FragmentStatePagerAdapter} that returns a fragment corresponding to |
| 216 | * one of the primary sections of the app. |
| 217 | */ |
| 218 | public class SectionsPagerAdapter extends FragmentStatePagerAdapter |
| 219 | { |
| 220 | |
| 221 | public SectionsPagerAdapter(FragmentManager fm) |
| 222 | { |
| 223 | super(fm); |
| 224 | } |
| 225 | |
| 226 | @Override |
| 227 | public Fragment getItem(int i) |
| 228 | { |
| 229 | Fragment fragment; |
Emeric Vigier | 62ca14d | 2012-08-24 11:05:09 -0400 | [diff] [blame] | 230 | |
Emeric Vigier | 05e894e | 2012-08-20 13:53:02 -0400 | [diff] [blame] | 231 | switch (i) { |
| 232 | case 0: |
Adrien Béraud | ffd3241 | 2012-08-07 18:39:23 -0400 | [diff] [blame] | 233 | fragment = new CallElementList(); |
Emeric Vigier | 05e894e | 2012-08-20 13:53:02 -0400 | [diff] [blame] | 234 | break; |
| 235 | case 1: |
Adrien Béraud | ffd3241 | 2012-08-07 18:39:23 -0400 | [diff] [blame] | 236 | fragment = new DummySectionFragment(); |
Emeric Vigier | 05e894e | 2012-08-20 13:53:02 -0400 | [diff] [blame] | 237 | break; |
| 238 | case 2: |
Alexandre Savard | def3bfa | 2012-09-12 16:20:06 -0400 | [diff] [blame] | 239 | fragment = new ButtonSectionFragment(); |
| 240 | Log.i(TAG, "getItem: fragment is " + fragment); |
Emeric Vigier | 05e894e | 2012-08-20 13:53:02 -0400 | [diff] [blame] | 241 | break; |
| 242 | default: |
| 243 | Log.e(TAG, "getItem: unknown tab position " + i); |
| 244 | return null; |
| 245 | } |
| 246 | |
Adrien Béraud | ffd3241 | 2012-08-07 18:39:23 -0400 | [diff] [blame] | 247 | Bundle args = new Bundle(); |
| 248 | args.putInt(DummySectionFragment.ARG_SECTION_NUMBER, i + 1); |
| 249 | fragment.setArguments(args); |
| 250 | return fragment; |
| 251 | } |
| 252 | |
| 253 | @Override |
| 254 | public int getCount() |
| 255 | { |
Emeric Vigier | 05e894e | 2012-08-20 13:53:02 -0400 | [diff] [blame] | 256 | return 3; |
Adrien Béraud | ffd3241 | 2012-08-07 18:39:23 -0400 | [diff] [blame] | 257 | } |
| 258 | |
| 259 | @Override |
| 260 | public CharSequence getPageTitle(int position) |
| 261 | { |
| 262 | switch (position) { |
| 263 | case 0: |
| 264 | return getString(R.string.title_section1).toUpperCase(); |
| 265 | case 1: |
| 266 | return getString(R.string.title_section2).toUpperCase(); |
Emeric Vigier | 05e894e | 2012-08-20 13:53:02 -0400 | [diff] [blame] | 267 | case 2: |
| 268 | return getString(R.string.title_section3).toUpperCase(); |
| 269 | default: |
| 270 | Log.e(TAG, "getPageTitle: unknown tab position " + position); |
| 271 | break; |
Adrien Béraud | ffd3241 | 2012-08-07 18:39:23 -0400 | [diff] [blame] | 272 | } |
| 273 | return null; |
| 274 | } |
| 275 | } |
| 276 | |
| 277 | /** |
| 278 | * A dummy fragment representing a section of the app, but that simply |
| 279 | * displays dummy text. |
| 280 | */ |
| 281 | public static class DummySectionFragment extends Fragment |
| 282 | { |
| 283 | public DummySectionFragment() |
| 284 | { |
| 285 | setRetainInstance(true); |
| 286 | } |
| 287 | |
| 288 | public static final String ARG_SECTION_NUMBER = "section_number"; |
| 289 | |
| 290 | @Override |
Emeric Vigier | 05e894e | 2012-08-20 13:53:02 -0400 | [diff] [blame] | 291 | public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) |
Adrien Béraud | ffd3241 | 2012-08-07 18:39:23 -0400 | [diff] [blame] | 292 | { |
| 293 | TextView textView = new TextView(getActivity()); |
| 294 | textView.setGravity(Gravity.CENTER); |
| 295 | Bundle args = getArguments(); |
| 296 | textView.setText(Integer.toString(args.getInt(ARG_SECTION_NUMBER))); |
Emeric Vigier | 05e894e | 2012-08-20 13:53:02 -0400 | [diff] [blame] | 297 | textView.setText("java sucks"); |
Adrien Béraud | ffd3241 | 2012-08-07 18:39:23 -0400 | [diff] [blame] | 298 | return textView; |
| 299 | } |
Adrien Béraud | ffd3241 | 2012-08-07 18:39:23 -0400 | [diff] [blame] | 300 | } |
Emeric Vigier | 05e894e | 2012-08-20 13:53:02 -0400 | [diff] [blame] | 301 | |
Emeric Vigier | 7a255aa | 2012-08-29 09:49:18 -0400 | [diff] [blame] | 302 | public String getAppPath() { |
| 303 | PackageManager pkgMng = getPackageManager(); |
| 304 | String pkgName = getPackageName(); |
| 305 | |
| 306 | try { |
| 307 | PackageInfo pkgInfo = pkgMng.getPackageInfo(pkgName, 0); |
| 308 | pkgName = pkgInfo.applicationInfo.dataDir; |
| 309 | } catch (NameNotFoundException e) { |
| 310 | Log.w(TAG, "Error Package name not found ", e); |
| 311 | } |
| 312 | |
| 313 | Log.d(TAG, "Application path: " + pkgName); |
| 314 | return pkgName; |
Emeric Vigier | 62ca14d | 2012-08-24 11:05:09 -0400 | [diff] [blame] | 315 | } |
Emeric Vigier | 05e894e | 2012-08-20 13:53:02 -0400 | [diff] [blame] | 316 | |
Emeric Vigier | 62ca14d | 2012-08-24 11:05:09 -0400 | [diff] [blame] | 317 | @Override |
| 318 | public void onClick(View view) |
Emeric Vigier | e89b48b | 2012-08-30 14:16:46 -0400 | [diff] [blame] | 319 | { |
Emeric Vigier | 62ca14d | 2012-08-24 11:05:09 -0400 | [diff] [blame] | 320 | switch (view.getId()) { |
Emeric Vigier | d5c17f5 | 2012-08-29 09:29:33 -0400 | [diff] [blame] | 321 | case R.id.buttonCall: |
Emeric Vigier | 39a11fa | 2012-08-29 15:25:09 -0400 | [diff] [blame] | 322 | TextView textView = (TextView) findViewById(R.id.editAccountID); |
| 323 | String accountID = textView.getText().toString(); |
| 324 | EditText editText; |
Emeric Vigier | 78a53e9 | 2012-08-29 18:15:34 -0400 | [diff] [blame] | 325 | Random random = new Random(); |
Emeric Vigier | e89b48b | 2012-08-30 14:16:46 -0400 | [diff] [blame] | 326 | |
Emeric Vigier | a6bdb70 | 2012-08-31 15:34:53 -0400 | [diff] [blame] | 327 | if (incomingCallID != "") { |
| 328 | buttonCall.clearAnimation(); |
Emeric Vigier | 9380ae5 | 2012-09-14 17:40:39 -0400 | [diff] [blame] | 329 | // manager.managerImpl.answerCall(incomingCallID); |
| 330 | manager.callmanagerJNI.accept(incomingCallID); |
Emeric Vigier | a6bdb70 | 2012-08-31 15:34:53 -0400 | [diff] [blame] | 331 | callID = incomingCallID; |
| 332 | incomingCallID=""; |
Emeric Vigier | e89b48b | 2012-08-30 14:16:46 -0400 | [diff] [blame] | 333 | callOnGoing = true; |
Emeric Vigier | a6bdb70 | 2012-08-31 15:34:53 -0400 | [diff] [blame] | 334 | buttonCall.setEnabled(false); |
| 335 | buttonHangup.setEnabled(true); |
| 336 | } else { |
| 337 | if (callOnGoing == false) { |
| 338 | editText = (EditText) findViewById(R.id.editTo); |
| 339 | String to = editText.getText().toString(); |
| 340 | if (to == null) { |
| 341 | Log.e(TAG, "to string is " + to); |
| 342 | break; |
| 343 | } |
| 344 | |
Emeric Vigier | a6bdb70 | 2012-08-31 15:34:53 -0400 | [diff] [blame] | 345 | callID = Integer.toString(random.nextInt()); |
| 346 | |
Emeric Vigier | 9701e03 | 2012-09-12 12:38:01 -0400 | [diff] [blame] | 347 | Log.d(TAG, "manager.managerImpl.placeCall(" + accountID + ", " + callID + ", " + to + ");"); |
Emeric Vigier | 9380ae5 | 2012-09-14 17:40:39 -0400 | [diff] [blame] | 348 | // manager.managerImpl.outgoingCall(accountID, callID, to); |
| 349 | manager.callmanagerJNI.placeCall(accountID, callID, to); |
Emeric Vigier | a6bdb70 | 2012-08-31 15:34:53 -0400 | [diff] [blame] | 350 | callOnGoing = true; |
| 351 | buttonCall.setEnabled(false); |
| 352 | buttonHangup.setEnabled(true); |
| 353 | } |
Emeric Vigier | d5c17f5 | 2012-08-29 09:29:33 -0400 | [diff] [blame] | 354 | } |
Emeric Vigier | d5c17f5 | 2012-08-29 09:29:33 -0400 | [diff] [blame] | 355 | break; |
Emeric Vigier | 78a53e9 | 2012-08-29 18:15:34 -0400 | [diff] [blame] | 356 | case R.id.buttonHangUp: |
Emeric Vigier | a6bdb70 | 2012-08-31 15:34:53 -0400 | [diff] [blame] | 357 | if (incomingCallID != "") { |
| 358 | buttonCall.clearAnimation(); |
Emeric Vigier | 9380ae5 | 2012-09-14 17:40:39 -0400 | [diff] [blame] | 359 | // manager.managerImpl.refuseCall(incomingCallID); |
| 360 | manager.callmanagerJNI.refuse(incomingCallID); |
Emeric Vigier | a6bdb70 | 2012-08-31 15:34:53 -0400 | [diff] [blame] | 361 | incomingCallID=""; |
| 362 | buttonCall.setEnabled(true); |
| 363 | buttonHangup.setEnabled(true); |
| 364 | } else { |
| 365 | if (callOnGoing == true) { |
Emeric Vigier | 9701e03 | 2012-09-12 12:38:01 -0400 | [diff] [blame] | 366 | Log.d(TAG, "manager.managerImpl.hangUp(" + callID + ");"); |
Emeric Vigier | 9380ae5 | 2012-09-14 17:40:39 -0400 | [diff] [blame] | 367 | // manager.managerImpl.hangupCall(callID); |
| 368 | manager.callmanagerJNI.hangUp(callID); |
Emeric Vigier | a6bdb70 | 2012-08-31 15:34:53 -0400 | [diff] [blame] | 369 | callOnGoing = false; |
| 370 | buttonCall.setEnabled(true); |
| 371 | buttonHangup.setEnabled(false); |
| 372 | } |
Emeric Vigier | e89b48b | 2012-08-30 14:16:46 -0400 | [diff] [blame] | 373 | } |
Emeric Vigier | a6bdb70 | 2012-08-31 15:34:53 -0400 | [diff] [blame] | 374 | |
| 375 | buttonCall.setImageResource(R.drawable.ic_call); |
Emeric Vigier | 78a53e9 | 2012-08-29 18:15:34 -0400 | [diff] [blame] | 376 | break; |
Emeric Vigier | 62ca14d | 2012-08-24 11:05:09 -0400 | [diff] [blame] | 377 | case R.id.buttonInit: |
Emeric Vigier | 9701e03 | 2012-09-12 12:38:01 -0400 | [diff] [blame] | 378 | Manager.managerImpl.setPath(""); |
| 379 | Manager.managerImpl.init(""); |
Emeric Vigier | 62ca14d | 2012-08-24 11:05:09 -0400 | [diff] [blame] | 380 | break; |
Emeric Vigier | 62ca14d | 2012-08-24 11:05:09 -0400 | [diff] [blame] | 381 | case R.id.buttonCallVoid: |
Emeric Vigier | 9701e03 | 2012-09-12 12:38:01 -0400 | [diff] [blame] | 382 | Manager.callVoid(); |
Emeric Vigier | 62ca14d | 2012-08-24 11:05:09 -0400 | [diff] [blame] | 383 | break; |
| 384 | case R.id.buttonGetNewData: |
Emeric Vigier | 9701e03 | 2012-09-12 12:38:01 -0400 | [diff] [blame] | 385 | Data d = Manager.getNewData(42, "foo"); |
Emeric Vigier | 62ca14d | 2012-08-24 11:05:09 -0400 | [diff] [blame] | 386 | if (d != null) |
| 387 | buttonFragment.getNewDataText().setText("getNewData(42, \"foo\") == Data(" + d.i + ", \"" + d.s + "\")"); |
| 388 | break; |
| 389 | case R.id.buttonGetDataString: |
Emeric Vigier | 383b2a2 | 2012-08-27 14:20:05 -0400 | [diff] [blame] | 390 | Data daita = new Data(43, "bar"); |
Emeric Vigier | 9701e03 | 2012-09-12 12:38:01 -0400 | [diff] [blame] | 391 | String s = Manager.getDataString(daita); |
Emeric Vigier | 62ca14d | 2012-08-24 11:05:09 -0400 | [diff] [blame] | 392 | if (s != "") { |
Emeric Vigier | 383b2a2 | 2012-08-27 14:20:05 -0400 | [diff] [blame] | 393 | buttonFragment.getDataStringText().setText("getDataString(Data(43, \"bar\")) == \"" + s + "\""); |
Emeric Vigier | 62ca14d | 2012-08-24 11:05:09 -0400 | [diff] [blame] | 394 | } |
| 395 | break; |
| 396 | default: |
| 397 | Log.w(TAG, "unknown button " + view.getId()); |
| 398 | break; |
Emeric Vigier | 05e894e | 2012-08-20 13:53:02 -0400 | [diff] [blame] | 399 | } |
Emeric Vigier | 05e894e | 2012-08-20 13:53:02 -0400 | [diff] [blame] | 400 | } |
Adrien Béraud | ffd3241 | 2012-08-07 18:39:23 -0400 | [diff] [blame] | 401 | } |