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