Skip to content
Snippets Groups Projects
Commit 383b2a29 authored by Emeric Vigier's avatar Emeric Vigier
Browse files

#14917: refactor JNI function call examples and cleanup

Merge branch 'android' of git+ssh://git.sflphone.org/var/repos/sflphone/git/sflphone into android
#14919: Rename output files for debuging
parent 62ca14d2
No related branches found
No related tags found
No related merge requests found
sflphone @ 7555ee13
Subproject commit 68ff480db511284bfd33e55071b2d7f78590a1f2
Subproject commit 7555ee13defb4bbe20acba09cddf51ea512dd5ed
......@@ -2,8 +2,6 @@ package com.savoirfairelinux.sflphone.client;
import android.app.Fragment;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.InflateException;
import android.view.LayoutInflater;
......@@ -16,12 +14,9 @@ import com.savoirfairelinux.sflphone.R;
public class ButtonSectionFragment extends Fragment
{
//private SFLPhoneHome myButtonSectionFragment;
static final String TAG = "ButtonSectionFragment";
public TextView callVoidText, NewDataText, DataStringText;
private TextView callVoidText, NewDataText, DataStringText;
Button buttonCallVoid, buttonGetNewData, buttonGetDataString;
Handler callbackHandler;
ManagerImpl managerImpl;
public ButtonSectionFragment()
{
......@@ -39,12 +34,6 @@ public class ButtonSectionFragment extends Fragment
public TextView getDataStringText() {
return DataStringText;
}
// public ButtonSectionFragment(SFLPhoneHome sflPhoneHome)
// {
// myButtonSectionFragment = sflPhoneHome;
// setRetainInstance(true);
// }
public static final String ARG_SECTION_NUMBER = "section_number";
......@@ -57,17 +46,7 @@ public class ButtonSectionFragment extends Fragment
view = inflater.inflate(R.layout.test_layout, parent, false);
callVoidText = (TextView) view.findViewById(R.id.callVoid_text);
if (callVoidText == null)
Log.e(TAG, "callVoidText is " + callVoidText);
callbackHandler = new Handler() {
public void handlerMessage(Message msg) {
Bundle b = msg.getData();
callVoidText.setText(b.getString("callback_string"));
Log.i(TAG, "handlerMessage: " + b.getString("callback_string"));
}
};
managerImpl = new ManagerImpl(callbackHandler);
NewDataText = (TextView) view.findViewById(R.id.NewData_text);
buttonGetNewData = (Button) view.findViewById(R.id.buttonGetNewData);
......
......@@ -39,7 +39,6 @@ public class ManagerImpl {
public static native void callVoid();
public static native Data getNewData(int i, String s);
public static native String getDataString(Data d);
public static native String getDataString2();
public static native void setSipLogLevel(String level);
public static native String getJniString();
......
......@@ -36,6 +36,8 @@ import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v13.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.Log;
......@@ -56,6 +58,8 @@ public class SFLPhoneHome extends Activity implements ActionBar.TabListener, OnC
SectionsPagerAdapter mSectionsPagerAdapter;
static final String TAG = "SFLPhoneHome";
ButtonSectionFragment buttonFragment;
Handler callbackHandler;
static ManagerImpl managerImpl;
/**
* The {@link ViewPager} that will host the section contents.
......@@ -98,6 +102,25 @@ public class SFLPhoneHome extends Activity implements ActionBar.TabListener, OnC
// listener for when this tab is selected.
actionBar.addTab(actionBar.newTab().setIcon(icon_res_id[i]).setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
}
// FIXME
callbackHandler = new Handler() {
public void handleMessage(Message msg) {
Bundle b = msg.getData();
TextView callVoidText;
Log.i(TAG, "handlerMessage");
callVoidText = buttonFragment.getcallVoidText();
if (callVoidText == null)
Log.e(TAG, "SFLPhoneHome: callVoidText is " + callVoidText);
callVoidText.setText(b.getString("callback_string"));
Log.i(TAG, "handlerMessage: " + b.getString("callback_string"));
}
};
managerImpl = new ManagerImpl(callbackHandler);
Log.i(TAG, "managerImpl created with callbackHandler " + callbackHandler);
}
// FIXME
......@@ -269,13 +292,10 @@ public class SFLPhoneHome extends Activity implements ActionBar.TabListener, OnC
buttonFragment.getNewDataText().setText("getNewData(42, \"foo\") == Data(" + d.i + ", \"" + d.s + "\")");
break;
case R.id.buttonGetDataString:
// Data daita = new Data(43, "bar");
// String s = ManagerImpl.getDataString(daita);
String s = ManagerImpl.getDataString2();
Log.i(TAG, "buttonGetDataString: getDataString2 is " + s);
Data daita = new Data(43, "bar");
String s = ManagerImpl.getDataString(daita);
if (s != "") {
// getDataStringText.setText("getDataString(Data(43, \"bar\")) == \"" + s + "\"");
buttonFragment.getDataStringText().setText("getDataString: " + s);
buttonFragment.getDataStringText().setText("getDataString(Data(43, \"bar\")) == \"" + s + "\"");
}
break;
default:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment