- Client proof-of concept UI using Android APIs 14
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index fca278d..a70ab90 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1,14 +1,72 @@
+<!--
+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.
+ -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.savoirfairelinux.sflphone_daemon"
+ package="com.savoirfairelinux.sflphone"
android:versionCode="1"
android:versionName="1.0">
- <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="15" />
+ <uses-sdk
+ android:minSdkVersion="13"
+ android:targetSdkVersion="15" />
- <application android:label="@string/app_name"
- android:icon="@drawable/ic_launcher"
- android:theme="@style/AppTheme">
+ <uses-permission android:name="android.permission.INTERNET" />
+ <uses-permission android:name="android.permission.READ_CONTACTS" />
+ <uses-permission android:name="android.permission.CALL_PHONE" />
+ <uses-permission android:name="android.permission.CALL_PRIVILEGED" />
+ <uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
+ <uses-permission android:name="android.permission.READ_PHONE_STATE" />
- </application>
+ <application
+ android:icon="@drawable/ic_launcher"
+ android:label="@string/app_name"
+ android:theme="@style/AppTheme" >
+ <activity
+ android:name=".client.SFLPhoneHome"
+ android:label="@string/title_activity_sflphone_home"
+ android:theme="@style/AppTheme" >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+
+ <receiver
+ android:name=".client.receiver.NewOutgoingCallReceiver"
+ android:exported="true" >
+ <intent-filter>
+ <action android:name="android.intent.action.NEW_OUTGOING_CALL" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ </receiver>
+ </application>
</manifest>
diff --git a/res/drawable-hdpi/box_border.9.png b/res/drawable-hdpi/box_border.9.png
new file mode 100644
index 0000000..18f0f6c
--- /dev/null
+++ b/res/drawable-hdpi/box_border.9.png
Binary files differ
diff --git a/res/drawable-hdpi/call_pause.png b/res/drawable-hdpi/call_pause.png
new file mode 100644
index 0000000..01858e3
--- /dev/null
+++ b/res/drawable-hdpi/call_pause.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_menu_search.png b/res/drawable-hdpi/ic_menu_search.png
new file mode 100644
index 0000000..e6b7045
--- /dev/null
+++ b/res/drawable-hdpi/ic_menu_search.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_menu_settings.png b/res/drawable-hdpi/ic_menu_settings.png
new file mode 100644
index 0000000..04b65dc
--- /dev/null
+++ b/res/drawable-hdpi/ic_menu_settings.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_tab_call.png b/res/drawable-hdpi/ic_tab_call.png
new file mode 100644
index 0000000..db81b3e
--- /dev/null
+++ b/res/drawable-hdpi/ic_tab_call.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_tab_history.png b/res/drawable-hdpi/ic_tab_history.png
new file mode 100644
index 0000000..ad23317
--- /dev/null
+++ b/res/drawable-hdpi/ic_tab_history.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_menu_search.png b/res/drawable-mdpi/ic_menu_search.png
new file mode 100644
index 0000000..3aa6440
--- /dev/null
+++ b/res/drawable-mdpi/ic_menu_search.png
Binary files differ
diff --git a/res/layout/activity_sflphone_home.xml b/res/layout/activity_sflphone_home.xml
new file mode 100644
index 0000000..86863af
--- /dev/null
+++ b/res/layout/activity_sflphone_home.xml
@@ -0,0 +1,38 @@
+<?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.
+ -->
+
+<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:id="@+id/pager"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:context=".SFLPhoneHome" />
\ No newline at end of file
diff --git a/res/layout/call_element.xml b/res/layout/call_element.xml
new file mode 100644
index 0000000..aae8e70
--- /dev/null
+++ b/res/layout/call_element.xml
@@ -0,0 +1,120 @@
+<?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.
+ -->
+
+<com.savoirfairelinux.sflphone.client.CallElementView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/panel"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:minHeight="70dp" >
+
+ <RelativeLayout
+ android:id="@+id/contactview"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="@drawable/box_border" >
+
+ <ImageButton
+ android:id="@+id/toggleButton1"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentBottom="true"
+ android:layout_alignParentLeft="true"
+ android:layout_alignTop="@+id/button2"
+ android:background="#00000000"
+ android:drawableLeft="@drawable/call_pause"
+ android:gravity="left|center_vertical"
+ android:src="@drawable/call_pause"
+ android:visibility="gone" />
+
+ <Button
+ android:id="@+id/button2"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentBottom="true"
+ android:layout_toRightOf="@+id/toggleButton1"
+ android:text="Button"
+ android:visibility="gone" />
+
+ <ImageView
+ android:id="@+id/photo"
+ android:layout_width="70dp"
+ android:layout_height="70dp"
+ android:src="@drawable/box_border" />
+
+ <TextView
+ android:id="@+id/display_name"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentTop="true"
+ android:layout_toRightOf="@+id/photo"
+ android:paddingLeft="@dimen/padding_small"
+ android:paddingTop="@dimen/padding_small"
+ android:text="Contact Name"
+ android:textAppearance="?android:attr/textAppearanceMedium" />
+
+ <TextView
+ android:id="@+id/phones"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_below="@+id/display_name"
+ android:layout_toRightOf="@+id/photo"
+ android:paddingBottom="@dimen/padding_small"
+ android:paddingLeft="@dimen/padding_small"
+ android:text="Small Text"
+ android:textAppearance="?android:attr/textAppearanceSmall" />
+
+ <ImageButton
+ android:id="@+id/imageButton1"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentRight="true"
+ android:layout_alignParentTop="true"
+ android:background="#00000000"
+ android:src="@android:drawable/sym_action_call" />
+ </RelativeLayout>
+
+ <RelativeLayout
+ android:id="@+id/callview"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="@drawable/box_border" >
+
+ <TextView
+ android:id="@+id/phones"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:text="Conversation card"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:gravity="center"/>
+ </RelativeLayout>
+
+</com.savoirfairelinux.sflphone.client.CallElementView>
\ No newline at end of file
diff --git a/res/layout/call_element_list.xml b/res/layout/call_element_list.xml
new file mode 100644
index 0000000..e167559
--- /dev/null
+++ b/res/layout/call_element_list.xml
@@ -0,0 +1,56 @@
+<?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.
+ -->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ android:paddingLeft="8dp"
+ android:paddingRight="8dp" >
+
+ <ListView
+ android:id="@id/android:list"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ style="@style/CallElementList"
+ android:drawSelectorOnTop="false" />
+
+ <TextView
+ android:id="@id/android:empty"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_gravity="center"
+ android:gravity="center"
+ android:text="No data" />
+
+</LinearLayout>
\ No newline at end of file
diff --git a/res/menu/activity_sflphone_home.xml b/res/menu/activity_sflphone_home.xml
new file mode 100644
index 0000000..d78d6f5
--- /dev/null
+++ b/res/menu/activity_sflphone_home.xml
@@ -0,0 +1,7 @@
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:id="@+id/menu_settings"
+ android:title="@string/menu_settings"
+ android:orderInCategory="100"
+ android:showAsAction="ifRoom"
+ android:icon="@drawable/ic_menu_settings" />
+</menu>
diff --git a/res/values-v14/styles.xml b/res/values-v14/styles.xml
index 1c089a7..d408cbc 100644
--- a/res/values-v14/styles.xml
+++ b/res/values-v14/styles.xml
@@ -1,5 +1,5 @@
<resources>
- <style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar" />
+ <style name="AppTheme" parent="android:Theme.Holo.Light" />
</resources>
\ No newline at end of file
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
new file mode 100644
index 0000000..e72ac9f
--- /dev/null
+++ b/res/values/dimens.xml
@@ -0,0 +1,38 @@
+<?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.
+ -->
+<resources>
+
+ <dimen name="padding_small">8dp</dimen>
+ <dimen name="padding_medium">8dp</dimen>
+ <dimen name="padding_large">16dp</dimen>
+
+</resources>
\ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 9d54cda..e36c6ed 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1,3 +1,39 @@
+<?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.
+ -->
+
<resources>
- <string name="app_name">sflphone-daemon</string>
+ <string name="app_name">SFLPhone</string>
+ <string name="title_section2">History</string>
+ <string name="title_section1">Call</string>
+ <string name="menu_settings">Settings</string>
+ <string name="title_activity_sflphone_home">SFLPhone</string>
</resources>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 4dba0d0..4842a6c 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -1,5 +1,42 @@
+<?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.
+-->
+
<resources>
- <style name="AppTheme" parent="android:Theme.Light" />
+ <style name="AppTheme" parent="android:Theme.Light" />
+ <style name="CallElementList">
+ <item name="android:divider">#00000000</item>
+ <item name="android:dividerHeight">5dp</item>
+ </style>
+
</resources>
\ No newline at end of file
diff --git a/src/com/savoirfairelinux/sflphone/client/CallElementList.java b/src/com/savoirfairelinux/sflphone/client/CallElementList.java
new file mode 100644
index 0000000..3484e8f
--- /dev/null
+++ b/src/com/savoirfairelinux/sflphone/client/CallElementList.java
@@ -0,0 +1,332 @@
+/*
+ * 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.
+ */
+package com.savoirfairelinux.sflphone.client;
+
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import android.app.ListFragment;
+import android.app.LoaderManager;
+import android.content.ContentResolver;
+import android.content.ContentUris;
+import android.content.Context;
+import android.content.CursorLoader;
+import android.content.Loader;
+import android.database.Cursor;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.net.Uri;
+import android.os.Bundle;
+import android.provider.*;
+import android.provider.ContactsContract.CommonDataKinds;
+import android.provider.ContactsContract.CommonDataKinds.Phone;
+import android.provider.ContactsContract.CommonDataKinds.SipAddress;
+import android.provider.ContactsContract.Contacts;
+import android.text.TextUtils;
+import android.util.Log;
+import android.view.*;
+import android.widget.*;
+import android.widget.SearchView.OnQueryTextListener;
+
+import com.savoirfairelinux.sflphone.R;
+
+/**
+ * Main list of Call Elements.
+ * We don't manage contacts ourself so they are
+ */
+public class CallElementList extends ListFragment implements OnQueryTextListener, LoaderManager.LoaderCallbacks<Cursor>
+{
+ CursorAdapter mAdapter;
+ String mCurFilter;
+
+ // These are the Contacts rows that we will retrieve.
+ static final String[] CONTACTS_SUMMARY_PROJECTION = new String[] { Contacts._ID, Contacts.DISPLAY_NAME,
+ Contacts.PHOTO_ID,
+ Contacts.LOOKUP_KEY };
+
+ static final String[] CONTACTS_PHONES_PROJECTION = new String[] { Phone.NUMBER, Phone.TYPE };
+ static final String[] CONTACTS_SIP_PROJECTION = new String[] { SipAddress.SIP_ADDRESS, SipAddress.TYPE };
+
+ /**
+ * Runnable that fill information in a contact card asynchroniously.
+ */
+ public static class InfosLoader implements Runnable
+ {
+ private View view;
+ private long cid;
+ private ContentResolver cr;
+
+ public InfosLoader(Context context, View element, long contact_id)
+ {
+ cid = contact_id;
+ cr = context.getContentResolver();
+ view = element;
+ }
+
+ public static Bitmap loadContactPhoto(ContentResolver cr, long id) {
+ Uri uri = ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI, id);
+ InputStream input = ContactsContract.Contacts.openContactPhotoInputStream(cr, uri);
+ if (input == null) {
+ return null;
+ }
+ return BitmapFactory.decodeStream(input);
+ }
+
+ @Override
+ public void run()
+ {
+ final Bitmap photo_bmp = loadContactPhoto(cr, cid);
+
+ Cursor phones = cr.query( CommonDataKinds.Phone.CONTENT_URI,
+ CONTACTS_PHONES_PROJECTION,
+ CommonDataKinds.Phone.CONTACT_ID + " = ?",
+ new String[] { Long.toString(cid) },
+ null);
+ final List<String> numbers = new ArrayList<String>();
+ while (phones.moveToNext()) {
+ String number = phones.getString(phones.getColumnIndex(CommonDataKinds.Phone.NUMBER));
+ //int type = phones.getInt(phones.getColumnIndex(CommonDataKinds.Phone.TYPE));
+ numbers.add(number);
+ }
+ phones.close();
+ // TODO: same for SIP adresses.
+
+ final Bitmap bmp = photo_bmp;
+ view.post(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ ImageView photo_view = (ImageView) view.findViewById(R.id.photo);
+ TextView phones_txt = (TextView) view.findViewById(R.id.phones);
+
+ if (photo_bmp != null) {
+ photo_view.setImageBitmap(bmp);
+ photo_view.setVisibility(View.VISIBLE);
+ } else {
+ photo_view.setVisibility(View.GONE);
+ }
+
+ if (numbers.size() > 0) {
+ String phonestxt = numbers.get(0);
+ for (int i = 1, n = numbers.size(); i < n; i++)
+ phonestxt += "\n" + numbers.get(i);
+ phones_txt.setText(phonestxt);
+ phones_txt.setVisibility(View.VISIBLE);
+ } else
+ phones_txt.setVisibility(View.GONE);
+ }
+ });
+
+ }
+
+ }
+
+ /**
+ * A CursorAdapter that creates and update call elements using corresponding contact infos.
+ * TODO: handle contact list separatly to allow showing synchronized contacts on Call cards with multiple contacts etc.
+ */
+ class CallElementAdapter extends CursorAdapter
+ {
+ private ExecutorService infos_fetcher = Executors.newCachedThreadPool();
+
+ public CallElementAdapter(Context context, Cursor c)
+ {
+ super(context, c, 0);
+ }
+
+ @Override
+ public View newView(Context context, Cursor cursor, ViewGroup parent)
+ {
+ LayoutInflater inflater = LayoutInflater.from(context);
+ View v = inflater.inflate(R.layout.call_element, parent, false);
+ bindView(v, context, cursor);
+ return v;
+ }
+
+ @Override
+ public void bindView(final View view, Context context, Cursor cursor)
+ {
+ final long contact_id = cursor.getLong(cursor.getColumnIndex(BaseColumns._ID));
+ final String display_name = cursor.getString(cursor.getColumnIndex(Contacts.DISPLAY_NAME));
+ //final long photo_uri_string = cursor.getLong(cursor.getColumnIndex(Contacts.PHOTO_ID));
+ //final String photo_uri_string = cursor.getString(cursor.getColumnIndex(Contacts.PHOTO_THUMBNAIL_URI));
+
+ TextView display_name_txt = (TextView) view.findViewById(R.id.display_name);
+ display_name_txt.setText(display_name);
+
+ ImageView photo_view = (ImageView) view.findViewById(R.id.photo);
+ photo_view.setVisibility(View.GONE);
+
+ infos_fetcher.execute(new InfosLoader(getActivity(), view, contact_id));
+ }
+
+ };
+
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState)
+ {
+ super.onActivityCreated(savedInstanceState);
+
+ // Give some text to display if there is no data. In a real
+ // application this would come from a resource.
+ //setEmptyText("No phone numbers");
+
+ // We have a menu item to show in action bar.
+ setHasOptionsMenu(true);
+
+ // Create an empty adapter we will use to display the loaded data.
+ mAdapter = new CallElementAdapter(getActivity(), null);
+ setListAdapter(mAdapter);
+
+ // Start out with a progress indicator.
+ //setListShown(false);
+
+ // Prepare the loader. Either re-connect with an existing one,
+ // or start a new one.
+ getLoaderManager().initLoader(0, null, this);
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ //LayoutInflater newInflater = inflater.cloneInContext(new ContextThemeWrapper(getActivity(), R.style.));
+ View inflatedView = inflater.inflate(R.layout.call_element_list, container, false);
+ return inflatedView;
+ }
+
+ @Override
+ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
+ {
+ // Place an action bar item for searching.
+ MenuItem item = menu.add("Search");
+ //item.setIcon(android.R.drawable.ic_menu_search);
+ item.setIcon(R.drawable.ic_menu_search);
+ item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
+ SearchView sv = new SearchView(getActivity());
+ sv.setOnQueryTextListener(this);
+ item.setActionView(sv);
+ }
+
+ @Override
+ public boolean onQueryTextChange(String newText)
+ {
+ // Called when the action bar search text has changed. Update
+ // the search filter, and restart the loader to do a new query
+ // with this filter.
+ String newFilter = !TextUtils.isEmpty(newText) ? newText : null;
+ // Don't do anything if the filter hasn't actually changed.
+ // Prevents restarting the loader when restoring state.
+ if (mCurFilter == null && newFilter == null) { return true; }
+ if (mCurFilter != null && mCurFilter.equals(newFilter)) { return true; }
+ mCurFilter = newFilter;
+ getLoaderManager().restartLoader(0, null, this);
+ return true;
+ }
+
+ @Override
+ public boolean onQueryTextSubmit(String query)
+ {
+ // Don't care about this.
+ return true;
+ }
+
+ @Override
+ public void onListItemClick(ListView l, View v, int position, long id)
+ {
+ // Insert desired behavior here.
+ Log.i("FragmentComplexList", "Item clicked: " + id);
+ }
+
+ @Override
+ public Loader<Cursor> onCreateLoader(int id, Bundle args)
+ {
+
+ //return new CursorLoader(getActivity(), CommonDataKinds.Phone.CONTENT_URI, null,null,null, null);
+
+ // This is called when a new Loader needs to be created. This
+ // sample only has one Loader, so we don't care about the ID.
+ // First, pick the base URI to use depending on whether we are
+ // currently filtering.
+ Uri baseUri;
+
+ if (mCurFilter != null) {
+ baseUri = Uri.withAppendedPath(Contacts.CONTENT_FILTER_URI, Uri.encode(mCurFilter));
+ } else {
+ baseUri = Contacts.CONTENT_URI;
+ }
+
+ // Now create and return a CursorLoader that will take care of
+ // creating a Cursor for the data being displayed.
+ String select = "((" + Contacts.DISPLAY_NAME
+ + " NOTNULL) AND ("
+ + Contacts.HAS_PHONE_NUMBER
+ + "=1) AND ("
+ + Contacts.DISPLAY_NAME
+ + " != '' ))";
+ //String select = "((" + Contacts.DISPLAY_NAME + " NOTNULL) AND (" + Contacts.DISPLAY_NAME + " != '' ))";
+
+ return new CursorLoader(getActivity(),
+ baseUri,
+ CONTACTS_SUMMARY_PROJECTION,
+ select,
+ null,
+ Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC");
+ }
+
+ @Override
+ public void onLoadFinished(Loader<Cursor> loader, Cursor data)
+ {
+ // Swap the new cursor in. (The framework will take care of closing the
+ // old cursor once we return.)
+ mAdapter.swapCursor(data);
+
+ // The list should now be shown.
+ /*
+ if (isResumed()) {
+ setListShown(true);
+ } else {
+ setListShownNoAnimation(true);
+ }*/
+ }
+
+ @Override
+ public void onLoaderReset(Loader<Cursor> loader)
+ {
+ // This is called when the last Cursor provided to onLoadFinished()
+ // above is about to be closed. We need to make sure we are no
+ // longer using it.
+ mAdapter.swapCursor(null);
+ }
+
+}
diff --git a/src/com/savoirfairelinux/sflphone/client/CallElementView.java b/src/com/savoirfairelinux/sflphone/client/CallElementView.java
new file mode 100644
index 0000000..9ccd7bc
--- /dev/null
+++ b/src/com/savoirfairelinux/sflphone/client/CallElementView.java
@@ -0,0 +1,108 @@
+/*
+ * 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.
+ */
+package com.savoirfairelinux.sflphone.client;
+
+import android.animation.Animator;
+import android.animation.AnimatorListenerAdapter;
+import android.animation.ObjectAnimator;
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.animation.AccelerateInterpolator;
+import android.view.animation.DecelerateInterpolator;
+import android.view.animation.Interpolator;
+import android.widget.FrameLayout;
+
+import com.savoirfairelinux.sflphone.R;
+
+public class CallElementView extends FrameLayout
+{
+ private ViewGroup contactCard = null;
+ private ViewGroup callCard = null;
+
+ public CallElementView(Context context, AttributeSet attrs)
+ {
+ super(context, attrs);
+ }
+
+ public CallElementView(Context context, AttributeSet attrs, int defStyle)
+ {
+ super(context, attrs, defStyle);
+ }
+
+ @Override
+ protected void onAttachedToWindow()
+ {
+ // Layouts may be inflated or we may use fragments.
+ contactCard = (ViewGroup) findViewById(R.id.contactview);
+ callCard = (ViewGroup) findViewById(R.id.callview);
+ callCard.setVisibility(View.GONE);
+ }
+
+ private Interpolator accelerator = new AccelerateInterpolator();
+ private Interpolator decelerator = new DecelerateInterpolator();
+
+ // from Android API Demo "ListFlipper"
+ private void flipit()
+ {
+ if(contactCard == null || callCard == null)
+ return;
+
+ final View visibleList;
+ final View invisibleList;
+ if (contactCard.getVisibility() == View.GONE) {
+ visibleList = callCard;
+ invisibleList = contactCard;
+ } else {
+ invisibleList = callCard;
+ visibleList = contactCard;
+ }
+ ObjectAnimator visToInvis = ObjectAnimator.ofFloat(visibleList, "rotationY", 0f, 90f);
+ visToInvis.setDuration(500);
+ visToInvis.setInterpolator(accelerator);
+ final ObjectAnimator invisToVis = ObjectAnimator.ofFloat(invisibleList, "rotationY",
+ -90f, 0f);
+ invisToVis.setDuration(500);
+ invisToVis.setInterpolator(decelerator);
+ visToInvis.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator anim) {
+ visibleList.setVisibility(View.GONE);
+ invisToVis.start();
+ invisibleList.setVisibility(View.VISIBLE);
+ }
+ });
+ visToInvis.start();
+ }
+
+
+}
diff --git a/src/com/savoirfairelinux/sflphone/client/SFLPhoneHome.java b/src/com/savoirfairelinux/sflphone/client/SFLPhoneHome.java
new file mode 100644
index 0000000..d204112
--- /dev/null
+++ b/src/com/savoirfairelinux/sflphone/client/SFLPhoneHome.java
@@ -0,0 +1,191 @@
+/*
+ * 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.
+ */
+package com.savoirfairelinux.sflphone.client;
+
+import android.app.ActionBar;
+import android.app.Activity;
+import android.app.Fragment;
+import android.app.FragmentManager;
+import android.app.FragmentTransaction;
+import android.os.Bundle;
+import android.support.v13.app.FragmentStatePagerAdapter;
+import android.support.v4.view.ViewPager;
+import android.view.Gravity;
+import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+import com.savoirfairelinux.sflphone.R;
+
+public class SFLPhoneHome extends Activity implements ActionBar.TabListener
+{
+ SectionsPagerAdapter mSectionsPagerAdapter;
+
+ /**
+ * 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};
+
+ @Override
+ public void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_sflphone_home);
+
+ mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager());
+
+ final ActionBar actionBar = getActionBar();
+ actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
+
+ // Set up the ViewPager with the sections adapter.
+ mViewPager = (ViewPager) findViewById(R.id.pager);
+ mViewPager.setAdapter(mSectionsPagerAdapter);
+
+ // When swiping between different sections, select the corresponding tab.
+ // We can also use ActionBar.Tab#select() to do this if we have a reference to the
+ // Tab.
+ mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener()
+ {
+ @Override
+ public void onPageSelected(int position)
+ {
+ actionBar.setSelectedNavigationItem(position);
+ }
+ });
+
+ // For each of the sections in the app, add a tab to the action bar.
+ for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
+ // Create a tab with text corresponding to the page title defined by the adapter.
+ // Also specify this Activity object, which implements the TabListener interface, as the
+ // listener for when this tab is selected.
+ actionBar.addTab(actionBar.newTab().setIcon(icon_res_id[i]).setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
+ }
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu)
+ {
+ getMenuInflater().inflate(R.menu.activity_sflphone_home, menu);
+ return true;
+ }
+
+ @Override
+ public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction)
+ {
+ }
+
+ @Override
+ public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction)
+ {
+ // When the given tab is selected, switch to the corresponding page in the ViewPager.
+ mViewPager.setCurrentItem(tab.getPosition());
+ }
+
+ @Override
+ public void onTabReselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction)
+ {
+ }
+
+ /**
+ * A {@link FragmentStatePagerAdapter} that returns a fragment corresponding to
+ * one of the primary sections of the app.
+ */
+ public class SectionsPagerAdapter extends FragmentStatePagerAdapter
+ {
+
+ public SectionsPagerAdapter(FragmentManager fm)
+ {
+ super(fm);
+ }
+
+ @Override
+ public Fragment getItem(int i)
+ {
+ Fragment fragment;
+ if(i == 0) {
+ fragment = new CallElementList();
+
+ } else
+ fragment = new DummySectionFragment();
+ Bundle args = new Bundle();
+ args.putInt(DummySectionFragment.ARG_SECTION_NUMBER, i + 1);
+ fragment.setArguments(args);
+ return fragment;
+ }
+
+ @Override
+ public int getCount()
+ {
+ return 2;
+ }
+
+ @Override
+ public CharSequence getPageTitle(int position)
+ {
+ switch (position) {
+ case 0:
+ return getString(R.string.title_section1).toUpperCase();
+ case 1:
+ return getString(R.string.title_section2).toUpperCase();
+ }
+ return null;
+ }
+ }
+
+ /**
+ * A dummy fragment representing a section of the app, but that simply
+ * displays dummy text.
+ */
+ public static class DummySectionFragment extends Fragment
+ {
+ public DummySectionFragment()
+ {
+ setRetainInstance(true);
+ }
+
+ public static final String ARG_SECTION_NUMBER = "section_number";
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
+ {
+ TextView textView = new TextView(getActivity());
+ textView.setGravity(Gravity.CENTER);
+ Bundle args = getArguments();
+ textView.setText(Integer.toString(args.getInt(ARG_SECTION_NUMBER)));
+ return textView;
+ }
+
+ }
+}
diff --git a/src/com/savoirfairelinux/sflphone/client/receiver/NewOutgoingCallReceiver.java b/src/com/savoirfairelinux/sflphone/client/receiver/NewOutgoingCallReceiver.java
new file mode 100644
index 0000000..62833a4
--- /dev/null
+++ b/src/com/savoirfairelinux/sflphone/client/receiver/NewOutgoingCallReceiver.java
@@ -0,0 +1,51 @@
+/*
+ * 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.
+ */
+package com.savoirfairelinux.sflphone.client.receiver;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.util.Log;
+
+public class NewOutgoingCallReceiver extends BroadcastReceiver
+{
+
+ @Override
+ public void onReceive(Context context, Intent intent)
+ {
+ String incomingNumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
+ Log.d("NewOutgoingCallReceiver", ">>>>>> Intent.EXTRA_PHONE_NUMBER: " + incomingNumber);
+ //setResultData(null);
+
+
+ }
+
+}