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

14399: add test tab to java UI

parent 1f55608f
No related branches found
No related tags found
No related merge requests found
Showing
with 249 additions and 6 deletions
res/drawable-hdpi-v5/ic_tab_play_selected.png

2.46 KiB

res/drawable-hdpi/ic_tab_play_selected.png

2.28 KiB

res/drawable-ldpi-v5/ic_tab_play_selected.png

1.04 KiB

res/drawable-ldpi/ic_tab_play_selected.png

1012 B

res/drawable-mdpi-v5/ic_tab_play_selected.png

1.11 KiB

res/drawable-mdpi/ic_tab_play_selected.png

1.2 KiB

res/drawable-xhdpi-v5/ic_tab_play_selected.png

2.73 KiB

res/drawable-xhdpi/ic_tab_play_selected.png

2.76 KiB

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/ic_tab_play_selected" android:state_selected="true" android:state_pressed="false" />
<item android:drawable="@drawable/ic_tab_play_unselected" />
</selector>
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2004-2012 Savoir-Faire Linux Inc.
Author: Adrien Beraud <adrien.beraud@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Additional permission under GNU GPL version 3 section 7:
If you modify this program, or any covered work, by linking or
combining it with the OpenSSL project's OpenSSL library (or a
modified version of that library), containing parts covered by the
terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
grants you additional permission to convey the resulting work.
Corresponding Source for a non-source form of such a combination
shall include the source code for the parts of OpenSSL used as well
as that of the covered work.
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingLeft="8dp"
android:paddingRight="8dp" >
<Button
android:id="@+id/buttonInit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:onClick="onClick"
android:text="init" />
<Button
android:id="@+id/buttonCall"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/buttonInit"
android:onClick="onClick"
android:text="call" />
<Button
android:id="@+id/buttonTest1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/buttonCall"
android:onClick="onClick"
android:text="test1" />
</RelativeLayout>
\ No newline at end of file
......@@ -34,6 +34,7 @@ as that of the covered work.
<string name="app_name">SFLPhone</string>
<string name="title_section2">History</string>
<string name="title_section1">Call</string>
<string name="title_section3">Test</string>
<string name="menu_settings">Settings</string>
<string name="title_activity_sflphone_home">SFLPhone</string>
</resources>
package com.savoirfairelinux.sflphone.client;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.util.Log;
public class ManagerImpl {
private static final String TAG = "ManagerImpl";
private static String sipLogLevel;
public static boolean outgoingCallJ(String account_id) {
Log.i(TAG, "account_id:" + account_id);
return true;
}
/* native implementation */
static {
System.setProperty("SIPLOGLEVEL", "4");
sipLogLevel = System.getProperty("SIPLOGLEVEL");
Log.i(TAG, "SIPLOGLEVEL: " + sipLogLevel);
// FIXME
System.loadLibrary("expat");
System.loadLibrary("yaml");
System.loadLibrary("ccgnu2");
System.loadLibrary("crypto");
System.loadLibrary("ssl");
System.loadLibrary("ccrtp1");
System.loadLibrary("dbus");
System.loadLibrary("dbus-c++-1");
System.loadLibrary("samplerate");
System.loadLibrary("codec_ulaw");
System.loadLibrary("codec_alaw");
System.loadLibrary("speexresampler");
System.loadLibrary("sflphone");
}
public String getSipLogLevel() {
return sipLogLevel;
}
//public static native JNI_OnLoad(JavaVM* vm, void* reserved);
public static native void setSipLogLevel(String level);
public static native String getJniString();
public static native boolean outgoingCallN(String account_id);
public static native void initN(String config_file);
}
......@@ -35,14 +35,21 @@ import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;
import android.support.v13.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.Gravity;
import android.view.InflateException;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import com.savoirfairelinux.sflphone.R;
......@@ -50,13 +57,14 @@ import com.savoirfairelinux.sflphone.R;
public class SFLPhoneHome extends Activity implements ActionBar.TabListener
{
SectionsPagerAdapter mSectionsPagerAdapter;
private static final String TAG = "SFLPhoneHome";
/**
* The {@link ViewPager} that will host the section contents.
*/
ViewPager mViewPager;
final private int[] icon_res_id = {R.drawable.ic_tab_call, R.drawable.ic_tab_history};
final private int[] icon_res_id = {R.drawable.ic_tab_call, R.drawable.ic_tab_history, R.drawable.ic_tab_play_selected};
@Override
public void onCreate(Bundle savedInstanceState)
......@@ -116,6 +124,8 @@ public class SFLPhoneHome extends Activity implements ActionBar.TabListener
@Override
public void onTabReselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction)
{
// Log.d(TAG, "onTabReselected");
// ManagerImpl.initN("");
}
/**
......@@ -134,11 +144,21 @@ public class SFLPhoneHome extends Activity implements ActionBar.TabListener
public Fragment getItem(int i)
{
Fragment fragment;
if(i == 0) {
switch (i) {
case 0:
fragment = new CallElementList();
} else
break;
case 1:
fragment = new DummySectionFragment();
break;
case 2:
fragment = new ButtonSectionFragment();
break;
default:
Log.e(TAG, "getItem: unknown tab position " + i);
return null;
}
Bundle args = new Bundle();
args.putInt(DummySectionFragment.ARG_SECTION_NUMBER, i + 1);
fragment.setArguments(args);
......@@ -148,7 +168,7 @@ public class SFLPhoneHome extends Activity implements ActionBar.TabListener
@Override
public int getCount()
{
return 2;
return 3;
}
@Override
......@@ -159,6 +179,11 @@ public class SFLPhoneHome extends Activity implements ActionBar.TabListener
return getString(R.string.title_section1).toUpperCase();
case 1:
return getString(R.string.title_section2).toUpperCase();
case 2:
return getString(R.string.title_section3).toUpperCase();
default:
Log.e(TAG, "getPageTitle: unknown tab position " + position);
break;
}
return null;
}
......@@ -178,14 +203,109 @@ public class SFLPhoneHome extends Activity implements ActionBar.TabListener
public static final String ARG_SECTION_NUMBER = "section_number";
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState)
{
TextView textView = new TextView(getActivity());
textView.setGravity(Gravity.CENTER);
Bundle args = getArguments();
textView.setText(Integer.toString(args.getInt(ARG_SECTION_NUMBER)));
textView.setText("java sucks");
return textView;
}
}
public static class ButtonSectionFragment extends Fragment implements OnClickListener
{
public ButtonSectionFragment()
{
setRetainInstance(true);
}
public static final String ARG_SECTION_NUMBER = "section_number";
public static final OnClickListener myListener = new OnClickListener() {
@Override
public void onClick(View view)
{
switch (view.getId()) {
case R.id.buttonCall:
ManagerImpl.outgoingCallJ("");
break;
case R.id.buttonInit:
ManagerImpl.initN("");
break;
case R.id.buttonTest1:
Log.i(TAG, "buttonTest1");
break;
default:
Log.w(TAG, "unknown button " + view.getId());
break;
}
}
};
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState)
{
View view;
Button buttonInit, buttonCall, buttonTest1;
Log.i(TAG, "onCreateView" );
view = inflater.inflate(R.layout.test_layout, parent, false);
buttonInit = (Button) view.findViewById(R.id.buttonInit);
if (buttonInit == null)
Log.e(TAG, "buttonInit is " + buttonInit);
buttonInit.setOnClickListener(myListener);
buttonCall = (Button) view.findViewById(R.id.buttonCall);
if (buttonCall == null)
Log.e(TAG, "buttonCall is " + buttonCall);
buttonCall.setOnClickListener(myListener);
buttonTest1 = (Button) view.findViewById(R.id.buttonTest1);
if (buttonTest1 == null)
Log.e(TAG, "buttonTest1 is " + buttonTest1);
buttonTest1.setOnClickListener(myListener);
// buttonInit.setGravity(Gravity.CENTER);
// buttonInit.setText("init");
// buttonInit.setOnClickListener(this);
//TextView textView = new TextView(getActivity());
//textView.setGravity(Gravity.CENTER);
//Bundle args = getArguments();
//textView.setText(Integer.toString(args.getInt(ARG_SECTION_NUMBER)));
//textView.setText("java sucks");
if (parent == null)
Log.e(TAG, "parent is " + parent);
if (R.layout.test_layout == 0)
Log.e(TAG, "buttonInit = " + R.layout.test_layout);
try {
inflater.inflate(R.layout.test_layout, parent, false);
} catch (InflateException e) {
Log.e(TAG, "Error inflating test_layout ", e);
return null;
}
return view;
}
@Override
public void onClick(View view)
{
Log.d(TAG, "onClick ");
}
}
public String getAppPath() {
PackageManager m = getPackageManager();
String s = getPackageName();
Log.d(TAG, "Application path: " + s);
try {
PackageInfo p = m.getPackageInfo(s, 0);
s = p.applicationInfo.dataDir;
} catch (NameNotFoundException e) {
Log.w(TAG, "Error Package name not found ", e);
}
return s;
}
}
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