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 | e89b48b | 2012-08-30 14:16:46 -0400 | [diff] [blame] | 71 | ImageButton buttonCall, buttonHangup; |
Emeric Vigier | 383b2a2 | 2012-08-27 14:20:05 -0400 | [diff] [blame] | 72 | Handler callbackHandler; |
| 73 | static ManagerImpl managerImpl; |
Emeric Vigier | 78a53e9 | 2012-08-29 18:15:34 -0400 | [diff] [blame] | 74 | /* default callID */ |
| 75 | static String callID = "007"; |
Emeric Vigier | e89b48b | 2012-08-30 14:16:46 -0400 | [diff] [blame] | 76 | static boolean callOnGoing = false; |
Emeric Vigier | a6bdb70 | 2012-08-31 15:34:53 -0400 | [diff] [blame] | 77 | private String incomingCallID = ""; |
Alexandre Savard | 1bcaf53 | 2012-09-05 16:23:02 -0400 | [diff] [blame] | 78 | private static final int REQUEST_CODE_PREFERENCES = 1; |
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); |
| 97 | |
| 98 | // Set up the ViewPager with the sections adapter. |
| 99 | mViewPager = (ViewPager) findViewById(R.id.pager); |
| 100 | mViewPager.setAdapter(mSectionsPagerAdapter); |
| 101 | |
| 102 | // When swiping between different sections, select the corresponding tab. |
| 103 | // We can also use ActionBar.Tab#select() to do this if we have a reference to the |
| 104 | // Tab. |
| 105 | mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() |
| 106 | { |
| 107 | @Override |
| 108 | public void onPageSelected(int position) |
| 109 | { |
| 110 | actionBar.setSelectedNavigationItem(position); |
| 111 | } |
| 112 | }); |
| 113 | |
| 114 | // For each of the sections in the app, add a tab to the action bar. |
| 115 | for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { |
| 116 | // Create a tab with text corresponding to the page title defined by the adapter. |
| 117 | // Also specify this Activity object, which implements the TabListener interface, as the |
| 118 | // listener for when this tab is selected. |
| 119 | actionBar.addTab(actionBar.newTab().setIcon(icon_res_id[i]).setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); |
| 120 | } |
Emeric Vigier | 383b2a2 | 2012-08-27 14:20:05 -0400 | [diff] [blame] | 121 | |
| 122 | // FIXME |
| 123 | callbackHandler = new Handler() { |
| 124 | public void handleMessage(Message msg) { |
| 125 | Bundle b = msg.getData(); |
| 126 | TextView callVoidText; |
| 127 | |
Emeric Vigier | c411ce3 | 2012-08-29 09:28:28 -0400 | [diff] [blame] | 128 | Log.i(TAG, "handleMessage"); |
Emeric Vigier | 383b2a2 | 2012-08-27 14:20:05 -0400 | [diff] [blame] | 129 | |
| 130 | callVoidText = buttonFragment.getcallVoidText(); |
| 131 | if (callVoidText == null) |
| 132 | Log.e(TAG, "SFLPhoneHome: callVoidText is " + callVoidText); |
| 133 | callVoidText.setText(b.getString("callback_string")); |
| 134 | |
Emeric Vigier | c411ce3 | 2012-08-29 09:28:28 -0400 | [diff] [blame] | 135 | Log.i(TAG, "handleMessage: " + b.getString("callback_string")); |
Emeric Vigier | 383b2a2 | 2012-08-27 14:20:05 -0400 | [diff] [blame] | 136 | } |
| 137 | }; |
Emeric Vigier | 7a255aa | 2012-08-29 09:49:18 -0400 | [diff] [blame] | 138 | ManagerImpl.setAppPath(getAppPath()); |
Emeric Vigier | 383b2a2 | 2012-08-27 14:20:05 -0400 | [diff] [blame] | 139 | managerImpl = new ManagerImpl(callbackHandler); |
Emeric Vigier | a6bdb70 | 2012-08-31 15:34:53 -0400 | [diff] [blame] | 140 | managerImpl.setActivity(this); |
Emeric Vigier | 383b2a2 | 2012-08-27 14:20:05 -0400 | [diff] [blame] | 141 | Log.i(TAG, "managerImpl created with callbackHandler " + callbackHandler); |
Emeric Vigier | a6bdb70 | 2012-08-31 15:34:53 -0400 | [diff] [blame] | 142 | |
| 143 | buttonCall = (ImageButton) findViewById(R.id.buttonCall); |
| 144 | buttonHangup = (ImageButton) findViewById(R.id.buttonHangUp); |
| 145 | // buttonIncomingCall = (ImageButton) findViewById(R.id.buttonIncomingCall); |
Adrien Béraud | ffd3241 | 2012-08-07 18:39:23 -0400 | [diff] [blame] | 146 | } |
| 147 | |
Emeric Vigier | 62ca14d | 2012-08-24 11:05:09 -0400 | [diff] [blame] | 148 | // FIXME |
| 149 | static { |
| 150 | System.loadLibrary("gnustl_shared"); |
| 151 | System.loadLibrary("expat"); |
| 152 | System.loadLibrary("yaml"); |
| 153 | System.loadLibrary("ccgnu2"); |
| 154 | System.loadLibrary("crypto"); |
| 155 | System.loadLibrary("ssl"); |
| 156 | System.loadLibrary("ccrtp1"); |
| 157 | System.loadLibrary("dbus"); |
| 158 | System.loadLibrary("dbus-c++-1"); |
| 159 | System.loadLibrary("samplerate"); |
| 160 | System.loadLibrary("codec_ulaw"); |
| 161 | System.loadLibrary("codec_alaw"); |
| 162 | System.loadLibrary("speexresampler"); |
| 163 | System.loadLibrary("sflphone"); |
| 164 | } |
Alexandre Savard | 1bcaf53 | 2012-09-05 16:23:02 -0400 | [diff] [blame] | 165 | |
| 166 | @Override |
| 167 | public boolean onOptionsItemSelected(MenuItem item) { |
| 168 | Log.i("SFLphone", "onOptionsItemSelected"); |
| 169 | |
| 170 | // When the button is clicked, launch an activity through this intent |
| 171 | Intent launchPreferencesIntent = new Intent().setClass(this, SFLPhonePreferenceActivity.class); |
| 172 | |
| 173 | // Make it a subactivity so we know when it returns |
| 174 | startActivityForResult(launchPreferencesIntent, REQUEST_CODE_PREFERENCES); |
| 175 | |
| 176 | return super.onOptionsItemSelected(item); |
| 177 | } |
Emeric Vigier | 62ca14d | 2012-08-24 11:05:09 -0400 | [diff] [blame] | 178 | |
Adrien Béraud | ffd3241 | 2012-08-07 18:39:23 -0400 | [diff] [blame] | 179 | @Override |
| 180 | public boolean onCreateOptionsMenu(Menu menu) |
| 181 | { |
| 182 | getMenuInflater().inflate(R.menu.activity_sflphone_home, menu); |
| 183 | return true; |
| 184 | } |
| 185 | |
| 186 | @Override |
| 187 | public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) |
| 188 | { |
| 189 | } |
| 190 | |
| 191 | @Override |
| 192 | public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) |
| 193 | { |
| 194 | // When the given tab is selected, switch to the corresponding page in the ViewPager. |
| 195 | mViewPager.setCurrentItem(tab.getPosition()); |
| 196 | } |
| 197 | |
| 198 | @Override |
| 199 | public void onTabReselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) |
| 200 | { |
Emeric Vigier | 05e894e | 2012-08-20 13:53:02 -0400 | [diff] [blame] | 201 | // Log.d(TAG, "onTabReselected"); |
| 202 | // ManagerImpl.initN(""); |
Adrien Béraud | ffd3241 | 2012-08-07 18:39:23 -0400 | [diff] [blame] | 203 | } |
| 204 | |
Emeric Vigier | a6bdb70 | 2012-08-31 15:34:53 -0400 | [diff] [blame] | 205 | public void setIncomingCallID(String id) { |
| 206 | incomingCallID = id; |
| 207 | } |
| 208 | |
Adrien Béraud | ffd3241 | 2012-08-07 18:39:23 -0400 | [diff] [blame] | 209 | /** |
| 210 | * A {@link FragmentStatePagerAdapter} that returns a fragment corresponding to |
| 211 | * one of the primary sections of the app. |
| 212 | */ |
| 213 | public class SectionsPagerAdapter extends FragmentStatePagerAdapter |
| 214 | { |
| 215 | |
| 216 | public SectionsPagerAdapter(FragmentManager fm) |
| 217 | { |
| 218 | super(fm); |
| 219 | } |
| 220 | |
| 221 | @Override |
| 222 | public Fragment getItem(int i) |
| 223 | { |
| 224 | Fragment fragment; |
Emeric Vigier | 62ca14d | 2012-08-24 11:05:09 -0400 | [diff] [blame] | 225 | |
Emeric Vigier | 05e894e | 2012-08-20 13:53:02 -0400 | [diff] [blame] | 226 | switch (i) { |
| 227 | case 0: |
Adrien Béraud | ffd3241 | 2012-08-07 18:39:23 -0400 | [diff] [blame] | 228 | fragment = new CallElementList(); |
Emeric Vigier | 05e894e | 2012-08-20 13:53:02 -0400 | [diff] [blame] | 229 | break; |
| 230 | case 1: |
Adrien Béraud | ffd3241 | 2012-08-07 18:39:23 -0400 | [diff] [blame] | 231 | fragment = new DummySectionFragment(); |
Emeric Vigier | 05e894e | 2012-08-20 13:53:02 -0400 | [diff] [blame] | 232 | break; |
| 233 | case 2: |
Emeric Vigier | 62ca14d | 2012-08-24 11:05:09 -0400 | [diff] [blame] | 234 | buttonFragment = new ButtonSectionFragment(); |
| 235 | Log.i(TAG, "getItem: fragment is " + buttonFragment); |
| 236 | fragment = buttonFragment; |
Emeric Vigier | a6bdb70 | 2012-08-31 15:34:53 -0400 | [diff] [blame] | 237 | managerImpl.setButtonFragment(buttonFragment); |
Emeric Vigier | 05e894e | 2012-08-20 13:53:02 -0400 | [diff] [blame] | 238 | break; |
| 239 | default: |
| 240 | Log.e(TAG, "getItem: unknown tab position " + i); |
| 241 | return null; |
| 242 | } |
| 243 | |
Adrien Béraud | ffd3241 | 2012-08-07 18:39:23 -0400 | [diff] [blame] | 244 | Bundle args = new Bundle(); |
| 245 | args.putInt(DummySectionFragment.ARG_SECTION_NUMBER, i + 1); |
| 246 | fragment.setArguments(args); |
| 247 | return fragment; |
| 248 | } |
| 249 | |
| 250 | @Override |
| 251 | public int getCount() |
| 252 | { |
Emeric Vigier | 05e894e | 2012-08-20 13:53:02 -0400 | [diff] [blame] | 253 | return 3; |
Adrien Béraud | ffd3241 | 2012-08-07 18:39:23 -0400 | [diff] [blame] | 254 | } |
| 255 | |
| 256 | @Override |
| 257 | public CharSequence getPageTitle(int position) |
| 258 | { |
| 259 | switch (position) { |
| 260 | case 0: |
| 261 | return getString(R.string.title_section1).toUpperCase(); |
| 262 | case 1: |
| 263 | return getString(R.string.title_section2).toUpperCase(); |
Emeric Vigier | 05e894e | 2012-08-20 13:53:02 -0400 | [diff] [blame] | 264 | case 2: |
| 265 | return getString(R.string.title_section3).toUpperCase(); |
| 266 | default: |
| 267 | Log.e(TAG, "getPageTitle: unknown tab position " + position); |
| 268 | break; |
Adrien Béraud | ffd3241 | 2012-08-07 18:39:23 -0400 | [diff] [blame] | 269 | } |
| 270 | return null; |
| 271 | } |
| 272 | } |
| 273 | |
| 274 | /** |
| 275 | * A dummy fragment representing a section of the app, but that simply |
| 276 | * displays dummy text. |
| 277 | */ |
| 278 | public static class DummySectionFragment extends Fragment |
| 279 | { |
| 280 | public DummySectionFragment() |
| 281 | { |
| 282 | setRetainInstance(true); |
| 283 | } |
| 284 | |
| 285 | public static final String ARG_SECTION_NUMBER = "section_number"; |
| 286 | |
| 287 | @Override |
Emeric Vigier | 05e894e | 2012-08-20 13:53:02 -0400 | [diff] [blame] | 288 | public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) |
Adrien Béraud | ffd3241 | 2012-08-07 18:39:23 -0400 | [diff] [blame] | 289 | { |
| 290 | TextView textView = new TextView(getActivity()); |
| 291 | textView.setGravity(Gravity.CENTER); |
| 292 | Bundle args = getArguments(); |
| 293 | textView.setText(Integer.toString(args.getInt(ARG_SECTION_NUMBER))); |
Emeric Vigier | 05e894e | 2012-08-20 13:53:02 -0400 | [diff] [blame] | 294 | textView.setText("java sucks"); |
Adrien Béraud | ffd3241 | 2012-08-07 18:39:23 -0400 | [diff] [blame] | 295 | return textView; |
| 296 | } |
Adrien Béraud | ffd3241 | 2012-08-07 18:39:23 -0400 | [diff] [blame] | 297 | } |
Emeric Vigier | 05e894e | 2012-08-20 13:53:02 -0400 | [diff] [blame] | 298 | |
Emeric Vigier | 7a255aa | 2012-08-29 09:49:18 -0400 | [diff] [blame] | 299 | public String getAppPath() { |
| 300 | PackageManager pkgMng = getPackageManager(); |
| 301 | String pkgName = getPackageName(); |
| 302 | |
| 303 | try { |
| 304 | PackageInfo pkgInfo = pkgMng.getPackageInfo(pkgName, 0); |
| 305 | pkgName = pkgInfo.applicationInfo.dataDir; |
| 306 | } catch (NameNotFoundException e) { |
| 307 | Log.w(TAG, "Error Package name not found ", e); |
| 308 | } |
| 309 | |
| 310 | Log.d(TAG, "Application path: " + pkgName); |
| 311 | return pkgName; |
Emeric Vigier | 62ca14d | 2012-08-24 11:05:09 -0400 | [diff] [blame] | 312 | } |
Emeric Vigier | 05e894e | 2012-08-20 13:53:02 -0400 | [diff] [blame] | 313 | |
Emeric Vigier | 62ca14d | 2012-08-24 11:05:09 -0400 | [diff] [blame] | 314 | @Override |
| 315 | public void onClick(View view) |
Emeric Vigier | e89b48b | 2012-08-30 14:16:46 -0400 | [diff] [blame] | 316 | { |
Emeric Vigier | a6bdb70 | 2012-08-31 15:34:53 -0400 | [diff] [blame] | 317 | buttonCall = buttonFragment.getCallButton(); |
| 318 | buttonHangup = buttonFragment.getHangUpButton(); |
| 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(); |
| 329 | ManagerImpl.answerCall(incomingCallID); |
| 330 | callID = incomingCallID; |
| 331 | incomingCallID=""; |
Emeric Vigier | e89b48b | 2012-08-30 14:16:46 -0400 | [diff] [blame] | 332 | callOnGoing = true; |
Emeric Vigier | a6bdb70 | 2012-08-31 15:34:53 -0400 | [diff] [blame] | 333 | buttonCall.setEnabled(false); |
| 334 | buttonHangup.setEnabled(true); |
| 335 | } else { |
| 336 | if (callOnGoing == false) { |
| 337 | editText = (EditText) findViewById(R.id.editTo); |
| 338 | String to = editText.getText().toString(); |
| 339 | if (to == null) { |
| 340 | Log.e(TAG, "to string is " + to); |
| 341 | break; |
| 342 | } |
| 343 | |
| 344 | /* new random callID */ |
| 345 | callID = Integer.toString(random.nextInt()); |
| 346 | |
| 347 | Log.d(TAG, "ManagerImpl.placeCall(" + accountID + ", " + callID + ", " + to + ");"); |
| 348 | ManagerImpl.placeCall(accountID, callID, to); |
| 349 | callOnGoing = true; |
| 350 | buttonCall.setEnabled(false); |
| 351 | buttonHangup.setEnabled(true); |
| 352 | } |
Emeric Vigier | d5c17f5 | 2012-08-29 09:29:33 -0400 | [diff] [blame] | 353 | } |
Emeric Vigier | d5c17f5 | 2012-08-29 09:29:33 -0400 | [diff] [blame] | 354 | break; |
Emeric Vigier | 78a53e9 | 2012-08-29 18:15:34 -0400 | [diff] [blame] | 355 | case R.id.buttonHangUp: |
Emeric Vigier | a6bdb70 | 2012-08-31 15:34:53 -0400 | [diff] [blame] | 356 | if (incomingCallID != "") { |
| 357 | buttonCall.clearAnimation(); |
| 358 | ManagerImpl.refuseCall(incomingCallID); |
| 359 | incomingCallID=""; |
| 360 | buttonCall.setEnabled(true); |
| 361 | buttonHangup.setEnabled(true); |
| 362 | } else { |
| 363 | if (callOnGoing == true) { |
| 364 | Log.d(TAG, "ManagerImpl.hangUp(" + callID + ");"); |
| 365 | ManagerImpl.hangUp(callID); |
| 366 | callOnGoing = false; |
| 367 | buttonCall.setEnabled(true); |
| 368 | buttonHangup.setEnabled(false); |
| 369 | } |
Emeric Vigier | e89b48b | 2012-08-30 14:16:46 -0400 | [diff] [blame] | 370 | } |
Emeric Vigier | a6bdb70 | 2012-08-31 15:34:53 -0400 | [diff] [blame] | 371 | |
| 372 | buttonCall.setImageResource(R.drawable.ic_call); |
Emeric Vigier | 78a53e9 | 2012-08-29 18:15:34 -0400 | [diff] [blame] | 373 | break; |
Emeric Vigier | 62ca14d | 2012-08-24 11:05:09 -0400 | [diff] [blame] | 374 | case R.id.buttonInit: |
| 375 | ManagerImpl.initN(""); |
| 376 | break; |
Emeric Vigier | 62ca14d | 2012-08-24 11:05:09 -0400 | [diff] [blame] | 377 | case R.id.buttonCallVoid: |
| 378 | ManagerImpl.callVoid(); |
| 379 | break; |
| 380 | case R.id.buttonGetNewData: |
| 381 | Data d = ManagerImpl.getNewData(42, "foo"); |
| 382 | if (d != null) |
| 383 | buttonFragment.getNewDataText().setText("getNewData(42, \"foo\") == Data(" + d.i + ", \"" + d.s + "\")"); |
| 384 | break; |
| 385 | case R.id.buttonGetDataString: |
Emeric Vigier | 383b2a2 | 2012-08-27 14:20:05 -0400 | [diff] [blame] | 386 | Data daita = new Data(43, "bar"); |
| 387 | String s = ManagerImpl.getDataString(daita); |
Emeric Vigier | 62ca14d | 2012-08-24 11:05:09 -0400 | [diff] [blame] | 388 | if (s != "") { |
Emeric Vigier | 383b2a2 | 2012-08-27 14:20:05 -0400 | [diff] [blame] | 389 | buttonFragment.getDataStringText().setText("getDataString(Data(43, \"bar\")) == \"" + s + "\""); |
Emeric Vigier | 62ca14d | 2012-08-24 11:05:09 -0400 | [diff] [blame] | 390 | } |
| 391 | break; |
| 392 | default: |
| 393 | Log.w(TAG, "unknown button " + view.getId()); |
| 394 | break; |
Emeric Vigier | 05e894e | 2012-08-20 13:53:02 -0400 | [diff] [blame] | 395 | } |
Emeric Vigier | 05e894e | 2012-08-20 13:53:02 -0400 | [diff] [blame] | 396 | } |
Adrien Béraud | ffd3241 | 2012-08-07 18:39:23 -0400 | [diff] [blame] | 397 | } |