Modified Hiearchy of packages (clean up)
Modified AccountSelectionButton to Spinner
Modified build instructions
Added make-glue.sh to generate interfaces (using dbusxx)
diff --git a/src/com/savoirfairelinux/sflphone/utils/AccountDetail.java b/src/com/savoirfairelinux/sflphone/account/AccountDetail.java
similarity index 97%
rename from src/com/savoirfairelinux/sflphone/utils/AccountDetail.java
rename to src/com/savoirfairelinux/sflphone/account/AccountDetail.java
index 4992356..50a6257 100644
--- a/src/com/savoirfairelinux/sflphone/utils/AccountDetail.java
+++ b/src/com/savoirfairelinux/sflphone/account/AccountDetail.java
@@ -19,7 +19,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-package com.savoirfairelinux.sflphone.utils;
+package com.savoirfairelinux.sflphone.account;
import java.util.ArrayList;
import java.util.HashMap;
diff --git a/src/com/savoirfairelinux/sflphone/utils/AccountDetailAdvanced.java b/src/com/savoirfairelinux/sflphone/account/AccountDetailAdvanced.java
similarity index 98%
rename from src/com/savoirfairelinux/sflphone/utils/AccountDetailAdvanced.java
rename to src/com/savoirfairelinux/sflphone/account/AccountDetailAdvanced.java
index d3bace1..04de9ff 100644
--- a/src/com/savoirfairelinux/sflphone/utils/AccountDetailAdvanced.java
+++ b/src/com/savoirfairelinux/sflphone/account/AccountDetailAdvanced.java
@@ -19,10 +19,10 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-package com.savoirfairelinux.sflphone.utils;
+package com.savoirfairelinux.sflphone.account;
import com.savoirfairelinux.sflphone.R;
-import com.savoirfairelinux.sflphone.utils.AccountDetail;
+import com.savoirfairelinux.sflphone.account.AccountDetail;
import android.util.Log;
diff --git a/src/com/savoirfairelinux/sflphone/utils/AccountDetailBasic.java b/src/com/savoirfairelinux/sflphone/account/AccountDetailBasic.java
similarity index 97%
rename from src/com/savoirfairelinux/sflphone/utils/AccountDetailBasic.java
rename to src/com/savoirfairelinux/sflphone/account/AccountDetailBasic.java
index cb07474..03a1354 100644
--- a/src/com/savoirfairelinux/sflphone/utils/AccountDetailBasic.java
+++ b/src/com/savoirfairelinux/sflphone/account/AccountDetailBasic.java
@@ -19,10 +19,10 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-package com.savoirfairelinux.sflphone.utils;
+package com.savoirfairelinux.sflphone.account;
import com.savoirfairelinux.sflphone.R;
-import com.savoirfairelinux.sflphone.utils.AccountDetail;
+import com.savoirfairelinux.sflphone.account.AccountDetail;
import android.util.Log;
diff --git a/src/com/savoirfairelinux/sflphone/utils/AccountDetailSrtp.java b/src/com/savoirfairelinux/sflphone/account/AccountDetailSrtp.java
similarity index 97%
rename from src/com/savoirfairelinux/sflphone/utils/AccountDetailSrtp.java
rename to src/com/savoirfairelinux/sflphone/account/AccountDetailSrtp.java
index 7cf8149..d0b67ec 100644
--- a/src/com/savoirfairelinux/sflphone/utils/AccountDetailSrtp.java
+++ b/src/com/savoirfairelinux/sflphone/account/AccountDetailSrtp.java
@@ -19,10 +19,10 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-package com.savoirfairelinux.sflphone.utils;
+package com.savoirfairelinux.sflphone.account;
import com.savoirfairelinux.sflphone.R;
-import com.savoirfairelinux.sflphone.utils.AccountDetail;
+import com.savoirfairelinux.sflphone.account.AccountDetail;
import android.util.Log;
diff --git a/src/com/savoirfairelinux/sflphone/utils/AccountDetailTls.java b/src/com/savoirfairelinux/sflphone/account/AccountDetailTls.java
similarity index 98%
rename from src/com/savoirfairelinux/sflphone/utils/AccountDetailTls.java
rename to src/com/savoirfairelinux/sflphone/account/AccountDetailTls.java
index 1bbd504..0db1640 100644
--- a/src/com/savoirfairelinux/sflphone/utils/AccountDetailTls.java
+++ b/src/com/savoirfairelinux/sflphone/account/AccountDetailTls.java
@@ -19,10 +19,10 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-package com.savoirfairelinux.sflphone.utils;
+package com.savoirfairelinux.sflphone.account;
import com.savoirfairelinux.sflphone.R;
-import com.savoirfairelinux.sflphone.utils.AccountDetail;
+import com.savoirfairelinux.sflphone.account.AccountDetail;
import android.util.Log;
diff --git a/src/com/savoirfairelinux/sflphone/utils/AccountDetailsHandler.java b/src/com/savoirfairelinux/sflphone/account/AccountDetailsHandler.java
similarity index 99%
rename from src/com/savoirfairelinux/sflphone/utils/AccountDetailsHandler.java
rename to src/com/savoirfairelinux/sflphone/account/AccountDetailsHandler.java
index 111469f..3e71d72 100644
--- a/src/com/savoirfairelinux/sflphone/utils/AccountDetailsHandler.java
+++ b/src/com/savoirfairelinux/sflphone/account/AccountDetailsHandler.java
@@ -19,7 +19,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-package com.savoirfairelinux.sflphone.utils;
+package com.savoirfairelinux.sflphone.account;
import android.util.Log;
diff --git a/src/com/savoirfairelinux/sflphone/utils/AccountList.java b/src/com/savoirfairelinux/sflphone/account/AccountListReceiver.java
similarity index 96%
rename from src/com/savoirfairelinux/sflphone/utils/AccountList.java
rename to src/com/savoirfairelinux/sflphone/account/AccountListReceiver.java
index 3a8c791..d78db6f 100644
--- a/src/com/savoirfairelinux/sflphone/utils/AccountList.java
+++ b/src/com/savoirfairelinux/sflphone/account/AccountListReceiver.java
@@ -29,7 +29,7 @@
* as that of the covered work.
*/
-package com.savoirfairelinux.sflphone.utils;
+package com.savoirfairelinux.sflphone.account;
import android.content.BroadcastReceiver;
import android.content.Intent;
@@ -42,7 +42,7 @@
import com.savoirfairelinux.sflphone.service.ConfigurationManagerCallback;
import com.savoirfairelinux.sflphone.service.ISipService;
-public class AccountList extends BroadcastReceiver
+public class AccountListReceiver extends BroadcastReceiver
{
private static final long serialVersionUID = -9178386308804218835L;
static final String TAG = "AccountList";
@@ -54,7 +54,7 @@
public static final String DEFAULT_ACCOUNT_ID = "IP2IP";
- public AccountList() {
+ public AccountListReceiver() {
}
public void setSipService(ISipService service) {
diff --git a/src/com/savoirfairelinux/sflphone/utils/AccountManagementUI.java b/src/com/savoirfairelinux/sflphone/account/AccountManagementUI.java
similarity index 90%
rename from src/com/savoirfairelinux/sflphone/utils/AccountManagementUI.java
rename to src/com/savoirfairelinux/sflphone/account/AccountManagementUI.java
index c6ec217..6401d5b 100644
--- a/src/com/savoirfairelinux/sflphone/utils/AccountManagementUI.java
+++ b/src/com/savoirfairelinux/sflphone/account/AccountManagementUI.java
@@ -28,15 +28,15 @@
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
-package com.savoirfairelinux.sflphone.utils;
+package com.savoirfairelinux.sflphone.account;
import java.util.ArrayList;
-import com.savoirfairelinux.sflphone.utils.AccountList;
+import com.savoirfairelinux.sflphone.account.AccountListReceiver;
public interface AccountManagementUI
{
- public void setAccountList(AccountList accountList);
+ public void setAccountList(AccountListReceiver accountList);
public void accountSelectedNotifyAccountList(String accountID);
diff --git a/src/com/savoirfairelinux/sflphone/account/AccountSelectionSpinner.java b/src/com/savoirfairelinux/sflphone/account/AccountSelectionSpinner.java
new file mode 100644
index 0000000..ef23f35
--- /dev/null
+++ b/src/com/savoirfairelinux/sflphone/account/AccountSelectionSpinner.java
@@ -0,0 +1,133 @@
+/*
+ * Copyright (C) 2004-2012 Savoir-Faire Linux Inc.
+ *
+ * Author: Alexandre Savard <alexandre.savard@savoirfairelinux.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.account;
+
+import java.util.ArrayList;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.Spinner;
+import android.widget.TextView;
+
+public class AccountSelectionSpinner extends Spinner implements AccountManagementUI {
+ private static final String TAG = "AccountSelectionButton";
+ private Context mContext;
+ private ArrayList<String> mList = new ArrayList<String>();
+ private AccountListReceiver mAccountList = null;
+ ArrayAdapter mListAdapter;
+
+ public AccountSelectionSpinner(Context context) {
+ super(context);
+ mContext = context;
+
+ }
+
+ public AccountSelectionSpinner(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ mContext = context;
+
+
+ }
+
+ public AccountSelectionSpinner(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ mContext = context;
+ mListAdapter = new ArrayAdapter(mContext, android.R.layout.simple_expandable_list_item_1, mList.toArray());
+
+ setOnItemSelectedListener(onClick);
+ setAdapter(mListAdapter);
+ }
+
+ private AdapterView.OnItemSelectedListener onClick = new AdapterView.OnItemSelectedListener() {
+
+ @Override
+ public void onItemSelected(AdapterView<?> arg0, View view, int arg2, long arg3) {
+ // public void onClick(DialogInterface dialog, int which) {
+
+ Log.i(TAG, "Selected Account: " + ((TextView) view).getText());
+ // mButton.setText(((TextView)view).getText());
+ accountSelectedNotifyAccountList(((TextView) view).getText().toString());
+ // setSelection(cursor.getPosition(),true);
+
+ }
+
+ @Override
+ public void onNothingSelected(AdapterView<?> arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ };
+
+
+ public void setAccountList(AccountListReceiver accountList) {
+ Log.i(TAG,"setAccountList");
+ mAccountList = accountList;
+
+ }
+
+ public void accountSelectedNotifyAccountList(String accountID) {
+ Log.i(TAG, "->accountSelectedNotifyAccountList");
+ if (mAccountList != null) {
+ mAccountList.accountSelected(accountID, this);
+ }
+ }
+
+ public void setSelectedAccount(String accountID) {
+ Log.i(TAG,"Account Selected");
+ // setText(accountID);
+ }
+
+ public void accountAdded(ArrayList<String> newList) {
+ mListAdapter = new ArrayAdapter(mContext, android.R.layout.simple_expandable_list_item_1, newList.toArray());
+
+ setOnItemSelectedListener(onClick);
+ setAdapter(mListAdapter);
+ // Log.i(TAG, "Account added");
+ // mList = newList;
+ //
+ // if(newList.size() == 1) {
+ // setText(newList.get(0));
+ // }
+ }
+
+ public void accountRemoved() {
+ Log.i(TAG,"Account Removed");
+ }
+
+ public void accountUpdated() {
+ Log.i(TAG,"Account Updated");
+ }
+}
diff --git a/src/com/savoirfairelinux/sflphone/client/AccountCreationActivity.java b/src/com/savoirfairelinux/sflphone/client/AccountCreationActivity.java
index 010e7f8..93de02e 100644
--- a/src/com/savoirfairelinux/sflphone/client/AccountCreationActivity.java
+++ b/src/com/savoirfairelinux/sflphone/client/AccountCreationActivity.java
@@ -31,6 +31,9 @@
package com.savoirfairelinux.sflphone.client;
+import java.util.ArrayList;
+import java.util.HashMap;
+
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
@@ -42,30 +45,23 @@
import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;
+import android.preference.CheckBoxPreference;
+import android.preference.EditTextPreference;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceManager;
-import android.preference.EditTextPreference;
-import android.preference.CheckBoxPreference;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
-import android.view.Window;
import com.savoirfairelinux.sflphone.R;
-import com.savoirfairelinux.sflphone.service.SipService;
+import com.savoirfairelinux.sflphone.account.AccountDetail;
+import com.savoirfairelinux.sflphone.account.AccountDetailAdvanced;
+import com.savoirfairelinux.sflphone.account.AccountDetailBasic;
+import com.savoirfairelinux.sflphone.account.AccountDetailSrtp;
+import com.savoirfairelinux.sflphone.account.AccountDetailTls;
import com.savoirfairelinux.sflphone.service.ISipService;
-import com.savoirfairelinux.sflphone.utils.AccountDetail;
-import com.savoirfairelinux.sflphone.utils.AccountDetailsHandler;
-import com.savoirfairelinux.sflphone.utils.AccountDetailBasic;
-import com.savoirfairelinux.sflphone.utils.AccountDetailAdvanced;
-import com.savoirfairelinux.sflphone.utils.AccountDetailSrtp;
-import com.savoirfairelinux.sflphone.utils.AccountDetailTls;
-
-import java.util.ArrayList;
-import java.util.EnumSet;
-import java.util.HashMap;
-import java.util.Set;
+import com.savoirfairelinux.sflphone.service.SipService;
public class AccountCreationActivity extends PreferenceActivity
{
diff --git a/src/com/savoirfairelinux/sflphone/client/AccountPreferenceActivity.java b/src/com/savoirfairelinux/sflphone/client/AccountPreferenceActivity.java
index 5c105e0..72c8efd 100644
--- a/src/com/savoirfairelinux/sflphone/client/AccountPreferenceActivity.java
+++ b/src/com/savoirfairelinux/sflphone/client/AccountPreferenceActivity.java
@@ -52,12 +52,12 @@
import android.view.MenuItem;
import com.savoirfairelinux.sflphone.R;
-import com.savoirfairelinux.sflphone.utils.AccountDetail;
-import com.savoirfairelinux.sflphone.utils.AccountDetailsHandler;
-import com.savoirfairelinux.sflphone.utils.AccountDetailBasic;
-import com.savoirfairelinux.sflphone.utils.AccountDetailAdvanced;
-import com.savoirfairelinux.sflphone.utils.AccountDetailSrtp;
-import com.savoirfairelinux.sflphone.utils.AccountDetailTls;
+import com.savoirfairelinux.sflphone.account.AccountDetail;
+import com.savoirfairelinux.sflphone.account.AccountDetailAdvanced;
+import com.savoirfairelinux.sflphone.account.AccountDetailBasic;
+import com.savoirfairelinux.sflphone.account.AccountDetailSrtp;
+import com.savoirfairelinux.sflphone.account.AccountDetailTls;
+import com.savoirfairelinux.sflphone.account.AccountDetailsHandler;
import java.util.HashMap;
import java.util.ArrayList;
diff --git a/src/com/savoirfairelinux/sflphone/client/AccountSelectionDialog.java b/src/com/savoirfairelinux/sflphone/client/AccountSelectionDialog.java
deleted file mode 100644
index 32d8a1b..0000000
--- a/src/com/savoirfairelinux/sflphone/client/AccountSelectionDialog.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (C) 2004-2012 Savoir-Faire Linux Inc.
- *
- * Author: Alexandre Savard <alexandre.savard@savoirfairelinux.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.AlertDialog;
-import android.app.Dialog;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.View;
-import android.widget.AdapterView;
-import android.widget.ArrayAdapter;
-import android.widget.ListView;
-import android.widget.TextView;
-
-import java.util.ArrayList;
-
-import com.savoirfairelinux.sflphone.utils.AccountSelectionButton;
-
-public class AccountSelectionDialog extends AlertDialog
-{
- private static final String TAG = "AccountSelectionDialog";
- Context mContext;
- ListView mListView;
- ArrayAdapter mListAdapter;
- ArrayList<String> mItems;
- AccountSelectionButton mButton;
-
- public AccountSelectionDialog(Context context, ArrayList<String> items, AccountSelectionButton b)
- {
- super(context);
- mContext = context;
- mItems = items;
- mButton = b;
- }
-
- private AdapterView.OnItemClickListener onClick = new AdapterView.OnItemClickListener()
- {
- // public void onClick(DialogInterface dialog, int which) {
- public void onItemClick (AdapterView<?> parent, View view, int position, long id) {
- Log.i(TAG, "Selected Account: " + ((TextView)view).getText());
- // mButton.setText(((TextView)view).getText());
- mButton.accountSelectedNotifyAccountList(((TextView)view).getText().toString());
- }
- };
-
- public void onCreate(Bundle savedInstanceState)
- {
- mListView = new ListView(mContext);
-
- mListAdapter = new ArrayAdapter(mContext, android.R.layout.simple_expandable_list_item_1, mItems.toArray());
-
- mListView.setOnItemClickListener(onClick);
- mListView.setAdapter(mListAdapter);
- setContentView(mListView);
- }
-
- public Dialog onCreateDialog(Bundle savedInstanceState)
- {
- AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
- builder.setTitle("Account Selection");
-
- return builder.create();
- }
-}
diff --git a/src/com/savoirfairelinux/sflphone/client/CallActivity.java b/src/com/savoirfairelinux/sflphone/client/CallActivity.java
index 91c52b0..3b0bfd5 100644
--- a/src/com/savoirfairelinux/sflphone/client/CallActivity.java
+++ b/src/com/savoirfairelinux/sflphone/client/CallActivity.java
@@ -48,7 +48,7 @@
import android.widget.TextView;
import com.savoirfairelinux.sflphone.R;
-import com.savoirfairelinux.sflphone.client.SipCall;
+import com.savoirfairelinux.sflphone.model.SipCall;
import com.savoirfairelinux.sflphone.service.CallManagerCallBack;
import com.savoirfairelinux.sflphone.service.ISipService;
import com.savoirfairelinux.sflphone.service.SipService;
@@ -77,7 +77,7 @@
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
- setContentView(R.layout.call_activity_layout);
+ setContentView(R.layout.activity_call_layout);
Bundle b = getIntent().getExtras();
// Parcelable value = b.getParcelable("CallInfo");
diff --git a/src/com/savoirfairelinux/sflphone/client/CallElementList.java b/src/com/savoirfairelinux/sflphone/client/CallElementList.java
deleted file mode 100644
index bc11533..0000000
--- a/src/com/savoirfairelinux/sflphone/client/CallElementList.java
+++ /dev/null
@@ -1,424 +0,0 @@
-/*
- * 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.Activity;
-import android.app.ListFragment;
-import android.app.LoaderManager;
-import android.app.AlertDialog;
-import android.app.AlertDialog.Builder;
-import android.content.ContentResolver;
-import android.content.ContentUris;
-import android.content.Context;
-import android.content.CursorLoader;
-import android.content.DialogInterface;
-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.os.RemoteException;
-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.util.Log;
-import android.view.*;
-import android.widget.AdapterView.OnItemLongClickListener;
-import android.widget.AdapterView.OnItemSelectedListener;
-import android.widget.*;
-import java.util.List;
-import java.util.ArrayList;
-
-import com.savoirfairelinux.sflphone.R;
-import com.savoirfairelinux.sflphone.service.ISipService;
-import com.savoirfairelinux.sflphone.utils.AccountSelectionButton;
-import com.savoirfairelinux.sflphone.utils.AccountList;
-
-/**
- * Main list of Call Elements.
- * We don't manage contacts ourself so they are
- */
-public class CallElementList extends ListFragment implements LoaderManager.LoaderCallbacks<Cursor>
-{
- private static final String TAG = "CallElementList";
- private static final String CURRENT_STATE_LABEL = " CURRENT STATE: ";
- private ContactManager mContactManager;
- private CallElementAdapter mAdapter;
- private String mCurFilter;
- private SFLPhoneHome sflphoneHome;
- private SFLphoneApplication sflphoneApplication;
- private ISipService service;
- private AccountSelectionButton mAccountSelectionButton;
- private AccountList mAccountList;
-
- 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 };
-
- @Override
- public void onAttach(Activity activity) {
- super.onAttach(activity);
- sflphoneHome = (SFLPhoneHome) activity;
- service = ((SFLphoneApplication) sflphoneHome.getApplication()).getSipService();
- mAccountList = ((SFLphoneApplication) sflphoneHome.getApplication()).getAccountList();
- Log.w(TAG, "onAttach() service=" + service + ", accountList=" + mAccountList);
- }
-
- public String getSelectedAccount() {
- return mAccountSelectionButton.getText().toString();
- }
-
- /**
- * 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.
- */
- public static class CallElementAdapter extends ArrayAdapter
- {
- private ExecutorService infos_fetcher = Executors.newCachedThreadPool();
- private Context mContext;
- private final List mCallList;
-
- public CallElementAdapter(Context context, List callList)
- {
- super(context, R.layout.call_element, callList);
- mContext = context;
- mCallList = callList;
- }
-
- @Override
- public View getView(int position, View convertView, ViewGroup parent)
- {
- View rowView = convertView;
- CallElementView entryView = null;
-
- if(rowView == null)
- {
- // Get a new instance of the row layout view
- LayoutInflater inflater = LayoutInflater.from(mContext);
- rowView = inflater.inflate(R.layout.call_element, null);
-
- // Hold the view objects in an object
- // so they don't need to be re-fetched
- entryView = new CallElementView();
- entryView.toggleButton = (ImageButton) rowView.findViewById(R.id.toggleButton1);
- entryView.button = (Button) rowView.findViewById(R.id.button2);
- entryView.photo = (ImageView) rowView.findViewById(R.id.photo);
- entryView.displayName = (TextView) rowView.findViewById(R.id.display_name);
- entryView.phones = (TextView) rowView.findViewById(R.id.phones);
- entryView.state = (TextView) rowView.findViewById(R.id.callstate);
-
- // Cache the view obects in the tag
- // so they can be re-accessed later
- rowView.setTag(entryView);
- } else {
- entryView = (CallElementView) rowView.getTag();
- }
-
- // Transfer the stock data from the data object
- // to the view objects
- SipCall call = (SipCall) mCallList.get(position);
- call.setAssociatedRowView(rowView);
- entryView.displayName.setText(call.getDisplayName());
- entryView.phones.setText(call.getPhone());
- entryView.state.setText(CURRENT_STATE_LABEL + call.getCallStateString());
-
- return rowView;
- }
- };
-
- public static class CallElementView
- {
- protected ImageButton toggleButton;
- protected Button button;
- protected ImageView photo;
- protected TextView displayName;
- protected TextView phones;
- protected TextView state;
- }
-
- public CallElementList()
- {
- super();
- }
-
- public void setAccountList(AccountList accountList) {
- mAccountList = accountList;
- }
-
- public void addCall(SipCall c)
- {
- Log.i(TAG, "Adding call " + c.mCallInfo.mDisplayName);
- mAdapter.add(c);
- }
-
- public void removeCall(SipCall c)
- {
- Log.i(TAG, "Removing call " + c.mCallInfo.mDisplayName);
- mAdapter.remove(c);
- }
-
-
- @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.
- ArrayList calls = new ArrayList();
- mAdapter = new CallElementAdapter(getActivity(), calls);
- 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)
-
- final Context context = getActivity();
- ListView lv = getListView();
- lv.setOnItemLongClickListener(new OnItemLongClickListener() {
- @Override
- public boolean onItemLongClick(AdapterView<?> av, View v, int pos, long id) {
- Log.i(TAG, "On Long Click");
- final CharSequence[] items = {"Hang up Call", "Send Message", "Add to Conference"};
- final SipCall call = (SipCall) mAdapter.getItem(pos);
- // FIXME
- service = sflphoneApplication.getSipService();
- AlertDialog.Builder builder = new AlertDialog.Builder(context);
- builder.setTitle("Action to perform with " + call.mCallInfo.mDisplayName)
- .setCancelable(true)
- .setItems(items, new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int item) {
- Log.i(TAG, "Selected " + items[item]);
- switch (item) {
- case 0:
- call.notifyServiceHangup(service);
- break;
- case 1:
- call.sendTextMessage();
- // Need to hangup this call immediately since no way to do it after this action
- call.notifyServiceHangup(service);
- break;
- case 2:
- call.addToConference();
- // Need to hangup this call immediately since no way to do it after this action
- call.notifyServiceHangup(service);
- break;
- default:
- break;
- }
- }
- });
- AlertDialog alert = builder.create();
- alert.show();
-
- return true;
- }
- });
- }
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- View inflatedView = inflater.inflate(R.layout.call_element_list, container, false);
-
- mAccountSelectionButton = (AccountSelectionButton) inflatedView.findViewById(R.id.account_selection_button);
- mAccountList.addManagementUI(mAccountSelectionButton);
- mAccountSelectionButton.setAccountList(mAccountList);
-
- return inflatedView;
- }
-
- public void onListItemClick(ListView l, View v, int position, long id)
- {
- // Insert desired behavior here.
- SipCall call = (SipCall) mAdapter.getItem(position);
- Log.i(TAG, "Call Clicked: " + call.getCallId());
-
- call.launchCallActivity(getActivity());
-
- sflphoneHome.onSelectedCallAction(call);
- }
-
- @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
index 82606f0..1031e09 100644
--- a/src/com/savoirfairelinux/sflphone/client/CallElementView.java
+++ b/src/com/savoirfairelinux/sflphone/client/CallElementView.java
@@ -44,39 +44,34 @@
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);
- }
-
+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;
-
+ private void flipit() {
+ if (contactCard == null || callCard == null)
+ return;
+
final View visibleList;
final View invisibleList;
if (contactCard.getVisibility() == View.GONE) {
@@ -89,8 +84,7 @@
ObjectAnimator visToInvis = ObjectAnimator.ofFloat(visibleList, "rotationY", 0f, 90f);
visToInvis.setDuration(500);
visToInvis.setInterpolator(accelerator);
- final ObjectAnimator invisToVis = ObjectAnimator.ofFloat(invisibleList, "rotationY",
- -90f, 0f);
+ final ObjectAnimator invisToVis = ObjectAnimator.ofFloat(invisibleList, "rotationY", -90f, 0f);
invisToVis.setDuration(500);
invisToVis.setInterpolator(decelerator);
visToInvis.addListener(new AnimatorListenerAdapter() {
@@ -104,5 +98,4 @@
visToInvis.start();
}
-
}
diff --git a/src/com/savoirfairelinux/sflphone/client/CustomListEntry.java b/src/com/savoirfairelinux/sflphone/client/CustomListEntry.java
deleted file mode 100644
index c9d1da7..0000000
--- a/src/com/savoirfairelinux/sflphone/client/CustomListEntry.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.savoirfairelinux.sflphone.client;
-
-public class CustomListEntry
-{
- private String mTextAlpha;
- private String mTextBeta;
-
- public CustomListEntry(String textA, String textB)
- {
- mTextAlpha = textA;
- mTextBeta = textB;
- }
-
- public String getTextAlpha()
- {
- return mTextAlpha;
- }
-
- public String getTextBeta()
- {
- return mTextBeta;
- }
-}
diff --git a/src/com/savoirfairelinux/sflphone/client/Data.java b/src/com/savoirfairelinux/sflphone/client/Data.java
deleted file mode 100644
index 27e5654..0000000
--- a/src/com/savoirfairelinux/sflphone/client/Data.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package com.savoirfairelinux.sflphone.client;
-
-public class Data {
- public int i;
- public String s;
-
- public Data() {}
-
- public Data(int i, String s) {
- this.i = i;
- this.s = s;
- }
-}
diff --git a/src/com/savoirfairelinux/sflphone/client/SFLPhoneHome.java b/src/com/savoirfairelinux/sflphone/client/SFLPhoneHome.java
deleted file mode 100644
index 666278a..0000000
--- a/src/com/savoirfairelinux/sflphone/client/SFLPhoneHome.java
+++ /dev/null
@@ -1,594 +0,0 @@
-/*
- * 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.util.Random;
-
-import android.app.ActionBar;
-import android.app.Activity;
-import android.app.AlertDialog;
-import android.app.Fragment;
-import android.app.FragmentManager;
-import android.app.FragmentTransaction;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.content.ServiceConnection;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.IBinder;
-import android.os.Message;
-import android.os.RemoteException;
-import android.support.v13.app.FragmentStatePagerAdapter;
-import android.support.v4.view.ViewPager;
-import android.support.v4.content.LocalBroadcastManager;
-import android.util.Log;
-import android.view.Gravity;
-import android.view.LayoutInflater;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.View.OnClickListener;
-import android.view.animation.AlphaAnimation;
-import android.view.animation.Animation;
-import android.view.animation.LinearInterpolator;
-import android.widget.Button;
-import android.widget.EditText;
-import android.widget.ImageButton;
-import android.widget.TextView;
-
-import com.savoirfairelinux.sflphone.R;
-import com.savoirfairelinux.sflphone.service.ISipService;
-import com.savoirfairelinux.sflphone.service.SipService;
-import com.savoirfairelinux.sflphone.utils.AccountList;
-import com.savoirfairelinux.sflphone.utils.CallList;
-
-import java.util.HashMap;
-
-public class SFLPhoneHome extends Activity implements ActionBar.TabListener, OnClickListener
-{
- SectionsPagerAdapter mSectionsPagerAdapter = null;
- static final String TAG = "SFLPhoneHome";
- private static final int REQUEST_CODE_PREFERENCES = 1;
- ImageButton buttonCall, buttonHangup;
- static Animation animation;
- private ContactListFragment mContactListFragment = null;
- private CallElementList mCallElementList = null;
- private HistorySectionFragment mHistorySectionFragment = null;
- private ButtonSectionFragment mButtonSectionFragment = null;
- private boolean mBound = false;
- private ISipService service;
- public AccountList mAccountList;
- public CallList mCallList = new CallList(this);
- private SFLphoneApplication mApplication;
-
- private static final int ACTION_BAR_TAB_CONTACT = 0;
- private static final int ACTION_BAR_TAB_CALL = 1;
- private static final int ACTION_BAR_TAB_HISTORY = 2;
- private static final int ACTION_BAR_TAB_TEST = 3;
-
- /**
- * 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_call, R.drawable.ic_tab_history, R.drawable.ic_tab_play_selected};
-
- // public SFLPhoneHome extends Activity implements ActionBar.TabListener, OnClickListener
-
- /* called before activity is killed, e.g. rotation */
- @Override
- protected void onSaveInstanceState(Bundle bundle) {
- super.onSaveInstanceState(bundle);
- for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
- try {
- /* putFragment (Bundle bundle, String key, Fragment fragment) */
- getFragmentManager().putFragment(bundle, mSectionsPagerAdapter.getClassName(i), mSectionsPagerAdapter.getFragment(i));
- } catch (IllegalStateException e) {
- Log.e(TAG, "IllegalStateException: fragment=" + mSectionsPagerAdapter.getFragment(i));
- }
- }
- Log.w(TAG, "onSaveInstanceState()");
- }
-
- @Override
- public void onCreate(Bundle savedInstanceState)
- {
- super.onCreate(savedInstanceState);
-
- mApplication = (SFLphoneApplication) getApplication();
-
- // Bind to LocalService
- if (!mBound) {
- Log.i(TAG, "onStart: Binding service...");
- Intent intent = new Intent(this, SipService.class);
- bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
- }
-
- setContentView(R.layout.activity_sflphone_home);
-
- if (mSectionsPagerAdapter == null) {
- mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager());
- }
-
- /* getFragment(Bundle, String) */
- if (savedInstanceState != null) {
- Log.w(TAG, "Activity restarted, recreating PagerAdapter...");
- /* getFragment (Bundle bundle, String key) */
- mContactListFragment = (ContactListFragment) getFragmentManager().getFragment(
- savedInstanceState, mSectionsPagerAdapter.getClassName(ACTION_BAR_TAB_CONTACT));
- mCallElementList = (CallElementList) getFragmentManager().getFragment(
- savedInstanceState, mSectionsPagerAdapter.getClassName(ACTION_BAR_TAB_CALL));
- mHistorySectionFragment = (HistorySectionFragment) getFragmentManager().getFragment(
- savedInstanceState, mSectionsPagerAdapter.getClassName(ACTION_BAR_TAB_HISTORY));
- mButtonSectionFragment = (ButtonSectionFragment) getFragmentManager().getFragment(
- savedInstanceState, mSectionsPagerAdapter.getClassName(ACTION_BAR_TAB_TEST));
- }
-
- if (mContactListFragment == null) {
- mContactListFragment = new ContactListFragment();
- Log.w(TAG, "Recreated mContactListFragment=" + mContactListFragment);
- }
- if (mCallElementList == null) {
- mCallElementList = new CallElementList();
- Log.w(TAG, "Recreated mCallElementList=" + mCallElementList);
- }
- if (mHistorySectionFragment == null) {
- mHistorySectionFragment = new HistorySectionFragment();
- Log.w(TAG, "Recreated mHistorySectionFragment=" + mHistorySectionFragment);
- }
- if (mButtonSectionFragment == null) {
- mButtonSectionFragment = new ButtonSectionFragment();
- Log.w(TAG, "Recreated mButtonSectionFragment=" + mButtonSectionFragment);
- }
-
- final ActionBar actionBar = getActionBar();
- actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
- // final ActionBar actionBar = getActionBar();
-
- // 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));
- }
-
- actionBar.setSelectedNavigationItem(ACTION_BAR_TAB_CALL);
-
- buttonCall = (ImageButton) findViewById(R.id.buttonCall);
- buttonHangup = (ImageButton) findViewById(R.id.buttonHangUp);
-
- // Change alpha from fully visible to invisible
- animation = new AlphaAnimation(1, 0);
- // duration - half a second
- animation.setDuration(500);
- // do not alter animation rate
- animation.setInterpolator(new LinearInterpolator());
- // Repeat animation infinitely
- animation.setRepeatCount(Animation.INFINITE);
- // Reverse
- animation.setRepeatMode(Animation.REVERSE);
-
- LocalBroadcastManager.getInstance(this).registerReceiver(mCallList, new IntentFilter("new-call-created"));
- LocalBroadcastManager.getInstance(this).registerReceiver(mCallList, new IntentFilter("call-state-changed"));
- LocalBroadcastManager.getInstance(this).registerReceiver(mCallList, new IntentFilter("incoming-call"));
-
- mAccountList = mApplication.getAccountList();
- Log.w(TAG, "mAccountList=" + mAccountList + ", mCallElementList=" + mCallElementList);
-
- LocalBroadcastManager.getInstance(this).registerReceiver(mAccountList, new IntentFilter("accounts-changed"));
- LocalBroadcastManager.getInstance(this).registerReceiver(mAccountList, new IntentFilter("account-state-changed"));
-
- SipCall.setSFLPhoneHomeContext(this);
- }
-
- @Override
- protected void onStart() {
- Log.i(TAG, "onStart");
- super.onStart();
- }
-
- /* user gets back to the activity, e.g. through task manager */
- @Override
- protected void onRestart() {
- super.onRestart();
- }
-
- /* activity gets back to the foreground and user input */
- @Override
- protected void onResume() {
- Log.i(TAG, "onResume");
- super.onResume();
- }
-
- /* activity no more in foreground */
- @Override
- protected void onPause() {
- super.onPause();
- }
-
- /* activity is no longer visible */
- @Override
- protected void onStop() {
- super.onStop();
- }
-
- /* activity finishes itself or is being killed by the system */
- @Override
- protected void onDestroy() {
- /* stop the service, if no other bound user, no need to check if it is running */
- if (mBound) {
- Log.i(TAG, "onStop: Unbinding service...");
- unbindService(mConnection);
- mBound = false;
- }
-// Log.i(TAG, "onDestroy: stopping SipService...");
-// stopService(new Intent(this, SipService.class));
-// mApplication.setServiceRunning(false);
-
- /* unregister broadcast receiver */
- LocalBroadcastManager.getInstance(this).unregisterReceiver(mCallList);
- LocalBroadcastManager.getInstance(this).unregisterReceiver(mAccountList);
-
- super.onDestroy();
- }
-
- /** Defines callbacks for service binding, passed to bindService() */
- private ServiceConnection mConnection = new ServiceConnection() {
-
- @Override
- public void onServiceConnected(ComponentName className,
- IBinder binder) {
- service = ISipService.Stub.asInterface(binder);
- mApplication.setSipService(service);
- mBound = true;
- mAccountList.setSipService(service);
- Log.d(TAG, "Service connected service=" + service);
- }
-
- @Override
- public void onServiceDisconnected(ComponentName arg0) {
- mApplication.setSipService(null);
- mBound = false;
- Log.d(TAG, "Service disconnected service=" + service);
- }
- };
-
-// private void startSipService() {
-// Thread thread = new Thread("StartSFLphoneService") {
-// public void run() {
-// Intent sipServiceIntent = new Intent(SFLPhoneHome.this, SipService.class);
-// //sipServiceIntent.putExtra(ServiceConstants.EXTRA_OUTGOING_ACTIVITY, new ComponentName(SFLPhoneHome.this, SFLPhoneHome.class));
-// startService(sipServiceIntent);
-// mApplication.setServiceRunning(true);
-// };
-// };
-// try {
-// thread.start();
-// } catch (IllegalThreadStateException e) {
-// AlertDialog.Builder builder = new AlertDialog.Builder(this);
-// builder.setMessage("Cannot start SFLPhone SipService!");
-// AlertDialog alert = builder.create();
-// alert.show();
-// finish();
-// }
-// }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- Log.i("SFLphone", "onOptionsItemSelected " + item.getItemId());
- if(item.getItemId() != 0) {
- // When the button is clicked, launch an activity through this intent
- Intent launchPreferencesIntent = new Intent().setClass(this, SFLPhonePreferenceActivity.class);
-
- // Make it a subactivity so we know when it returns
- startActivityForResult(launchPreferencesIntent, REQUEST_CODE_PREFERENCES);
- }
-
- return super.onOptionsItemSelected(item);
- }
-
- @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)
- {
- // Log.d(TAG, "onTabReselected");
- }
-
- public void onSelectedCallAction(SipCall call) {
- int callState = call.getCallStateInt();
-
- if((callState == SipCall.CALL_STATE_NONE) ||
- (callState == SipCall.CALL_STATE_CURRENT)) {
- buttonCall.setEnabled(false);
- buttonHangup.setEnabled(true);
- }
- else {
- buttonCall.setEnabled(true);
- buttonHangup.setEnabled(false);
- }
-
- buttonCall.setTag(call);
- buttonHangup.setTag(call);
- }
-
- public void onUnselectedCallAction() {
- buttonCall.setTag(null);
- buttonCall.setTag(null);
-
- buttonCall.setEnabled(true);
- buttonHangup.setEnabled(false);
- }
-
- public void setIncomingCallID(String accountID, String callID, String from) {
- Log.i(TAG, "incomingCall(" + accountID + ", " + callID + ", " + from + ")");
- buttonCall.startAnimation(animation);
- buttonCall.setImageResource(R.drawable.ic_incomingcall);
- }
-
- /**
- * 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;
-
- switch (i) {
- case 0:
- mContactListFragment = new ContactListFragment();
- fragment = mContactListFragment;
- Log.w(TAG, "getItem() ContactListFragment=" + fragment);
- break;
- case 1:
- mCallElementList = new CallElementList();
- SipCall.setCallElementList(mCallElementList);
- mCallElementList.setAccountList(mAccountList);
- fragment = mCallElementList;
- Log.w(TAG, "getItem() CallElementList=" + fragment);
- break;
- case 2:
- fragment = new HistorySectionFragment();
- Log.w(TAG, "getItem() HistorySectionFragment=" + fragment);
- break;
- case 3:
- fragment = new ButtonSectionFragment();
- Log.w(TAG, "getItem() ButtonSectionFragment=" + fragment);
- break;
- default:
- Log.e(TAG, "getItem() unknown tab position " + i);
- return null;
- }
-
-// Log.i(TAG, "getItem() fragment is " + fragment);
- Bundle args = new Bundle();
- args.putInt(HistorySectionFragment.ARG_SECTION_NUMBER, i + 1);
- fragment.setArguments(args);
- return fragment;
- }
-
- public Fragment getFragment(int i)
- {
- Fragment fragment;
-
- switch (i) {
- case 0:
- fragment = mContactListFragment;
- break;
- case 1:
- fragment = mCallElementList;
- break;
- case 2:
- fragment = mHistorySectionFragment;
- break;
- case 3:
- fragment = mButtonSectionFragment;
- break;
- default:
- Log.e(TAG, "getClassName: unknown fragment position " + i);
- fragment = null;
- }
-
-// Log.w(TAG, "getFragment: fragment=" + fragment);
- return fragment;
- }
-
- public String getClassName(int i)
- {
- String name;
-
- switch (i) {
- case 0:
- name = ContactListFragment.class.getName();
- break;
- case 1:
- name = CallElementList.class.getName();
- break;
- case 2:
- name = HistorySectionFragment.class.getName();
- break;
- case 3:
- name = ButtonSectionFragment.class.getName();
- break;
- default:
- Log.e(TAG, "getClassName: unknown fragment position " + i);
- return null;
- }
-
-// Log.w(TAG, "getClassName: name=" + name);
- return name;
- }
-
- @Override
- public int getCount()
- {
- return 4;
- }
-
- @Override
- public CharSequence getPageTitle(int position)
- {
- switch (position) {
- case 0:
- return getString(R.string.title_section0).toUpperCase();
- case 1:
- return getString(R.string.title_section1).toUpperCase();
- case 2:
- return getString(R.string.title_section2).toUpperCase();
- case 3:
- return getString(R.string.title_section3).toUpperCase();
- default:
- Log.e(TAG, "getPageTitle: unknown tab position " + position);
- break;
- }
- return null;
- }
- }
-
- /**
- * A dummy fragment representing a section of the app, but that simply
- * displays dummy text.
- */
- public static class HistorySectionFragment extends Fragment
- {
- public HistorySectionFragment()
- {
- setRetainInstance(true);
- }
-
- public static final String ARG_SECTION_NUMBER = "section_number";
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState)
- {
- TextView textView = new TextView(getActivity());
- textView.setGravity(Gravity.CENTER);
- Bundle args = getArguments();
- textView.setText("ARG_SECTION_NUMBER=" + Integer.toString(args.getInt(ARG_SECTION_NUMBER)));
- return textView;
- }
- }
-
- @Override
- public void onClick(View view)
- {
- Log.i(TAG, "onClic from SFLPhoneHome");
- switch (view.getId()) {
- case R.id.buttonCall:
- processingNewCallAction();
- break;
- case R.id.buttonHangUp:
- processingHangUpAction();
- break;
- default:
- Log.w(TAG, "unknown button " + view.getId());
- break;
- }
- }
-
- public void processingNewCallAction() {
- // String accountID = mAccountList.currentAccountID;
- Log.w(TAG, "processingNewCallAction() mCallElementList=" + mCallElementList);
- String accountID = mCallElementList.getSelectedAccount();
- EditText editText = (EditText) findViewById(R.id.phoneNumberTextEntry);
- String to = editText.getText().toString();
-
- Random random = new Random();
- String callID = Integer.toString(random.nextInt());
- SipCall.CallInfo info = new SipCall.CallInfo();
-
- info.mCallID = callID;
- info.mAccountID = accountID;
- info.mDisplayName = "Cool Guy!";
- info.mPhone = to;
- info.mEmail = "coolGuy@coolGuy.com";
- info.mCallType = SipCall.CALL_TYPE_OUTGOING;
-
- SipCall call = CallList.getCallInstance(info);
- call.launchCallActivity(this);
- call.placeCallUpdateUi();
- call.notifyServicePlaceCall(service);
-
- onSelectedCallAction(call);
- }
-
- public void processingHangUpAction() {
- SipCall call = (SipCall)buttonHangup.getTag();
- if(call != null)
- call.notifyServiceHangup(service);
- }
-}
diff --git a/src/com/savoirfairelinux/sflphone/client/SFLPhoneHomeActivity.java b/src/com/savoirfairelinux/sflphone/client/SFLPhoneHomeActivity.java
new file mode 100644
index 0000000..26eb7b3
--- /dev/null
+++ b/src/com/savoirfairelinux/sflphone/client/SFLPhoneHomeActivity.java
@@ -0,0 +1,571 @@
+/*
+ * 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.util.Random;
+
+import android.app.ActionBar;
+import android.app.Activity;
+import android.app.Fragment;
+import android.app.FragmentManager;
+import android.app.FragmentTransaction;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.ServiceConnection;
+import android.os.Bundle;
+import android.os.IBinder;
+import android.support.v13.app.FragmentStatePagerAdapter;
+import android.support.v4.content.LocalBroadcastManager;
+import android.support.v4.view.ViewPager;
+import android.util.Log;
+import android.view.Gravity;
+import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.ViewGroup;
+import android.view.animation.AlphaAnimation;
+import android.view.animation.Animation;
+import android.view.animation.LinearInterpolator;
+import android.widget.EditText;
+import android.widget.ImageButton;
+import android.widget.TextView;
+
+import com.savoirfairelinux.sflphone.R;
+import com.savoirfairelinux.sflphone.account.AccountListReceiver;
+import com.savoirfairelinux.sflphone.client.receiver.CallList;
+import com.savoirfairelinux.sflphone.fragments.ButtonSectionFragment;
+import com.savoirfairelinux.sflphone.fragments.CallElementListFragment;
+import com.savoirfairelinux.sflphone.fragments.ContactListFragment;
+import com.savoirfairelinux.sflphone.model.SipCall;
+import com.savoirfairelinux.sflphone.service.CallManagerCallBack;
+import com.savoirfairelinux.sflphone.service.ConfigurationManagerCallback;
+import com.savoirfairelinux.sflphone.service.ISipService;
+import com.savoirfairelinux.sflphone.service.SipService;
+
+public class SFLPhoneHomeActivity extends Activity implements ActionBar.TabListener, OnClickListener {
+ SectionsPagerAdapter mSectionsPagerAdapter = null;
+ static final String TAG = "SFLPhoneHome";
+ private static final int REQUEST_CODE_PREFERENCES = 1;
+ ImageButton buttonCall, buttonHangup;
+ static Animation animation;
+ private ContactListFragment mContactListFragment = null;
+ private CallElementListFragment mCallElementList = null;
+ private HistorySectionFragment mHistorySectionFragment = null;
+ private ButtonSectionFragment mButtonSectionFragment = null;
+ private boolean mBound = false;
+ private ISipService service;
+ public AccountListReceiver mAccountList;
+ public CallList mCallList = new CallList(this);
+ private SFLphoneApplication mApplication;
+
+ private static final int ACTION_BAR_TAB_CONTACT = 0;
+ private static final int ACTION_BAR_TAB_CALL = 1;
+ private static final int ACTION_BAR_TAB_HISTORY = 2;
+ private static final int ACTION_BAR_TAB_TEST = 3;
+
+ /**
+ * 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_call, R.drawable.ic_tab_history, R.drawable.ic_tab_play_selected };
+
+ // public SFLPhoneHome extends Activity implements ActionBar.TabListener, OnClickListener
+
+ /* called before activity is killed, e.g. rotation */
+ @Override
+ protected void onSaveInstanceState(Bundle bundle) {
+ super.onSaveInstanceState(bundle);
+ for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
+ try {
+ /* putFragment (Bundle bundle, String key, Fragment fragment) */
+ getFragmentManager().putFragment(bundle, mSectionsPagerAdapter.getClassName(i), mSectionsPagerAdapter.getFragment(i));
+ } catch (IllegalStateException e) {
+ Log.e(TAG, "IllegalStateException: fragment=" + mSectionsPagerAdapter.getFragment(i));
+ }
+ }
+ Log.w(TAG, "onSaveInstanceState()");
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ mApplication = (SFLphoneApplication) getApplication();
+
+ // Bind to LocalService
+ if (!mBound) {
+ Log.i(TAG, "onStart: Binding service...");
+ Intent intent = new Intent(this, SipService.class);
+ bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
+ }
+
+ setContentView(R.layout.activity_sflphone_home);
+
+ if (mSectionsPagerAdapter == null) {
+ mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager());
+ }
+
+ /* getFragment(Bundle, String) */
+ if (savedInstanceState != null) {
+ Log.w(TAG, "Activity restarted, recreating PagerAdapter...");
+ /* getFragment (Bundle bundle, String key) */
+ mContactListFragment = (ContactListFragment) getFragmentManager().getFragment(savedInstanceState,
+ mSectionsPagerAdapter.getClassName(ACTION_BAR_TAB_CONTACT));
+ mCallElementList = (CallElementListFragment) getFragmentManager().getFragment(savedInstanceState,
+ mSectionsPagerAdapter.getClassName(ACTION_BAR_TAB_CALL));
+ mHistorySectionFragment = (HistorySectionFragment) getFragmentManager().getFragment(savedInstanceState,
+ mSectionsPagerAdapter.getClassName(ACTION_BAR_TAB_HISTORY));
+ mButtonSectionFragment = (ButtonSectionFragment) getFragmentManager().getFragment(savedInstanceState,
+ mSectionsPagerAdapter.getClassName(ACTION_BAR_TAB_TEST));
+ }
+
+ if (mContactListFragment == null) {
+ mContactListFragment = new ContactListFragment();
+ Log.w(TAG, "Recreated mContactListFragment=" + mContactListFragment);
+ }
+ if (mCallElementList == null) {
+ mCallElementList = new CallElementListFragment();
+ Log.w(TAG, "Recreated mCallElementList=" + mCallElementList);
+ }
+ if (mHistorySectionFragment == null) {
+ mHistorySectionFragment = new HistorySectionFragment();
+ Log.w(TAG, "Recreated mHistorySectionFragment=" + mHistorySectionFragment);
+ }
+ if (mButtonSectionFragment == null) {
+ mButtonSectionFragment = new ButtonSectionFragment();
+ Log.w(TAG, "Recreated mButtonSectionFragment=" + mButtonSectionFragment);
+ }
+
+ final ActionBar actionBar = getActionBar();
+ actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
+ // final ActionBar actionBar = getActionBar();
+
+ // 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));
+ }
+
+ actionBar.setSelectedNavigationItem(ACTION_BAR_TAB_CALL);
+
+ buttonCall = (ImageButton) findViewById(R.id.buttonCall);
+ buttonHangup = (ImageButton) findViewById(R.id.buttonHangUp);
+
+ // Change alpha from fully visible to invisible
+ animation = new AlphaAnimation(1, 0);
+ // duration - half a second
+ animation.setDuration(500);
+ // do not alter animation rate
+ animation.setInterpolator(new LinearInterpolator());
+ // Repeat animation infinitely
+ animation.setRepeatCount(Animation.INFINITE);
+ // Reverse
+ animation.setRepeatMode(Animation.REVERSE);
+
+ IntentFilter callFilter = new IntentFilter(CallManagerCallBack.NEW_CALL_CREATED);
+ callFilter.addAction(CallManagerCallBack.INCOMING_CALL);
+ callFilter.addAction(CallManagerCallBack.CALL_STATE_CHANGED);
+ LocalBroadcastManager.getInstance(this).registerReceiver(mCallList, callFilter);
+
+ mAccountList = mApplication.getAccountList();
+ Log.w(TAG, "mAccountList=" + mAccountList + ", mCallElementList=" + mCallElementList);
+
+ IntentFilter accountFilter = new IntentFilter(ConfigurationManagerCallback.ACCOUNTS_CHANGED);
+ accountFilter.addAction(ConfigurationManagerCallback.ACCOUNT_STATE_CHANGED);
+ LocalBroadcastManager.getInstance(this).registerReceiver(mAccountList, accountFilter);
+
+ SipCall.setSFLPhoneHomeContext(this);
+ }
+
+ @Override
+ protected void onStart() {
+ Log.i(TAG, "onStart");
+ super.onStart();
+ }
+
+ /* user gets back to the activity, e.g. through task manager */
+ @Override
+ protected void onRestart() {
+ super.onRestart();
+ }
+
+ /* activity gets back to the foreground and user input */
+ @Override
+ protected void onResume() {
+ Log.i(TAG, "onResume");
+ super.onResume();
+ }
+
+ /* activity no more in foreground */
+ @Override
+ protected void onPause() {
+ super.onPause();
+ }
+
+ /* activity is no longer visible */
+ @Override
+ protected void onStop() {
+ super.onStop();
+ }
+
+ /* activity finishes itself or is being killed by the system */
+ @Override
+ protected void onDestroy() {
+ /* stop the service, if no other bound user, no need to check if it is running */
+ if (mBound) {
+ Log.i(TAG, "onStop: Unbinding service...");
+ unbindService(mConnection);
+ mBound = false;
+ }
+ // Log.i(TAG, "onDestroy: stopping SipService...");
+ // stopService(new Intent(this, SipService.class));
+ // mApplication.setServiceRunning(false);
+
+ /* unregister broadcast receiver */
+ LocalBroadcastManager.getInstance(this).unregisterReceiver(mCallList);
+ LocalBroadcastManager.getInstance(this).unregisterReceiver(mAccountList);
+
+ super.onDestroy();
+ }
+
+ /** Defines callbacks for service binding, passed to bindService() */
+ private ServiceConnection mConnection = new ServiceConnection() {
+
+ @Override
+ public void onServiceConnected(ComponentName className, IBinder binder) {
+ service = ISipService.Stub.asInterface(binder);
+ mApplication.setSipService(service);
+ mBound = true;
+ mAccountList.setSipService(service);
+ Log.d(TAG, "Service connected service=" + service);
+ }
+
+ @Override
+ public void onServiceDisconnected(ComponentName arg0) {
+ mApplication.setSipService(null);
+ mBound = false;
+ Log.d(TAG, "Service disconnected service=" + service);
+ }
+ };
+
+ // private void startSipService() {
+ // Thread thread = new Thread("StartSFLphoneService") {
+ // public void run() {
+ // Intent sipServiceIntent = new Intent(SFLPhoneHome.this, SipService.class);
+ // //sipServiceIntent.putExtra(ServiceConstants.EXTRA_OUTGOING_ACTIVITY, new ComponentName(SFLPhoneHome.this, SFLPhoneHome.class));
+ // startService(sipServiceIntent);
+ // mApplication.setServiceRunning(true);
+ // };
+ // };
+ // try {
+ // thread.start();
+ // } catch (IllegalThreadStateException e) {
+ // AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ // builder.setMessage("Cannot start SFLPhone SipService!");
+ // AlertDialog alert = builder.create();
+ // alert.show();
+ // finish();
+ // }
+ // }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ Log.i("SFLphone", "onOptionsItemSelected " + item.getItemId());
+ if (item.getItemId() != 0) {
+ // When the button is clicked, launch an activity through this intent
+ Intent launchPreferencesIntent = new Intent().setClass(this, SFLPhonePreferenceActivity.class);
+
+ // Make it a subactivity so we know when it returns
+ startActivityForResult(launchPreferencesIntent, REQUEST_CODE_PREFERENCES);
+ }
+
+ return super.onOptionsItemSelected(item);
+ }
+
+ @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) {
+ // Log.d(TAG, "onTabReselected");
+ }
+
+ public void onSelectedCallAction(SipCall call) {
+ int callState = call.getCallStateInt();
+
+ if ((callState == SipCall.CALL_STATE_NONE) || (callState == SipCall.CALL_STATE_CURRENT)) {
+ buttonCall.setEnabled(false);
+ buttonHangup.setEnabled(true);
+ } else {
+ buttonCall.setEnabled(true);
+ buttonHangup.setEnabled(false);
+ }
+
+ buttonCall.setTag(call);
+ buttonHangup.setTag(call);
+ }
+
+ public void onUnselectedCallAction() {
+ buttonCall.setTag(null);
+ buttonCall.setTag(null);
+
+ buttonCall.setEnabled(true);
+ buttonHangup.setEnabled(false);
+ }
+
+ public void setIncomingCallID(String accountID, String callID, String from) {
+ Log.i(TAG, "incomingCall(" + accountID + ", " + callID + ", " + from + ")");
+ buttonCall.startAnimation(animation);
+ buttonCall.setImageResource(R.drawable.ic_incomingcall);
+ }
+
+ /**
+ * 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;
+
+ switch (i) {
+ case 0:
+ mContactListFragment = new ContactListFragment();
+ fragment = mContactListFragment;
+ Log.w(TAG, "getItem() ContactListFragment=" + fragment);
+ break;
+ case 1:
+ mCallElementList = new CallElementListFragment();
+ SipCall.setCallElementList(mCallElementList);
+ mCallElementList.setAccountList(mAccountList);
+ fragment = mCallElementList;
+ Log.w(TAG, "getItem() CallElementList=" + fragment);
+ break;
+ case 2:
+ fragment = new HistorySectionFragment();
+ Log.w(TAG, "getItem() HistorySectionFragment=" + fragment);
+ break;
+ case 3:
+ fragment = new ButtonSectionFragment();
+ Log.w(TAG, "getItem() ButtonSectionFragment=" + fragment);
+ break;
+ default:
+ Log.e(TAG, "getItem() unknown tab position " + i);
+ return null;
+ }
+
+ // Log.i(TAG, "getItem() fragment is " + fragment);
+ Bundle args = new Bundle();
+ args.putInt(HistorySectionFragment.ARG_SECTION_NUMBER, i + 1);
+ fragment.setArguments(args);
+ return fragment;
+ }
+
+ public Fragment getFragment(int i) {
+ Fragment fragment;
+
+ switch (i) {
+ case 0:
+ fragment = mContactListFragment;
+ break;
+ case 1:
+ fragment = mCallElementList;
+ break;
+ case 2:
+ fragment = mHistorySectionFragment;
+ break;
+ case 3:
+ fragment = mButtonSectionFragment;
+ break;
+ default:
+ Log.e(TAG, "getClassName: unknown fragment position " + i);
+ fragment = null;
+ }
+
+ // Log.w(TAG, "getFragment: fragment=" + fragment);
+ return fragment;
+ }
+
+ public String getClassName(int i) {
+ String name;
+
+ switch (i) {
+ case 0:
+ name = ContactListFragment.class.getName();
+ break;
+ case 1:
+ name = CallElementListFragment.class.getName();
+ break;
+ case 2:
+ name = HistorySectionFragment.class.getName();
+ break;
+ case 3:
+ name = ButtonSectionFragment.class.getName();
+ break;
+ default:
+ Log.e(TAG, "getClassName: unknown fragment position " + i);
+ return null;
+ }
+
+ // Log.w(TAG, "getClassName: name=" + name);
+ return name;
+ }
+
+ @Override
+ public int getCount() {
+ return 4;
+ }
+
+ @Override
+ public CharSequence getPageTitle(int position) {
+ switch (position) {
+ case 0:
+ return getString(R.string.title_section0).toUpperCase();
+ case 1:
+ return getString(R.string.title_section1).toUpperCase();
+ case 2:
+ return getString(R.string.title_section2).toUpperCase();
+ case 3:
+ return getString(R.string.title_section3).toUpperCase();
+ default:
+ Log.e(TAG, "getPageTitle: unknown tab position " + position);
+ break;
+ }
+ return null;
+ }
+ }
+
+ /**
+ * A dummy fragment representing a section of the app, but that simply displays dummy text.
+ */
+ public static class HistorySectionFragment extends Fragment {
+ public HistorySectionFragment() {
+ setRetainInstance(true);
+ }
+
+ public static final String ARG_SECTION_NUMBER = "section_number";
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
+ TextView textView = new TextView(getActivity());
+ textView.setGravity(Gravity.CENTER);
+ Bundle args = getArguments();
+ textView.setText("ARG_SECTION_NUMBER=" + Integer.toString(args.getInt(ARG_SECTION_NUMBER)));
+ return textView;
+ }
+ }
+
+ @Override
+ public void onClick(View view) {
+ Log.i(TAG, "onClic from SFLPhoneHome");
+ switch (view.getId()) {
+ case R.id.buttonCall:
+ processingNewCallAction();
+ break;
+ case R.id.buttonHangUp:
+ processingHangUpAction();
+ break;
+ default:
+ Log.w(TAG, "unknown button " + view.getId());
+ break;
+ }
+ }
+
+ public void processingNewCallAction() {
+ // String accountID = mAccountList.currentAccountID;
+ Log.w(TAG, "processingNewCallAction() mCallElementList=" + mCallElementList);
+ String accountID = mCallElementList.getSelectedAccount();
+ EditText editText = (EditText) findViewById(R.id.phoneNumberTextEntry);
+ String to = editText.getText().toString();
+
+ Random random = new Random();
+ String callID = Integer.toString(random.nextInt());
+ SipCall.CallInfo info = new SipCall.CallInfo();
+
+ info.mCallID = callID;
+ info.mAccountID = accountID;
+ info.mDisplayName = "Cool Guy!";
+ info.mPhone = to;
+ info.mEmail = "coolGuy@coolGuy.com";
+ info.mCallType = SipCall.CALL_TYPE_OUTGOING;
+
+ SipCall call = CallList.getCallInstance(info);
+ call.launchCallActivity(this);
+ call.placeCallUpdateUi();
+ call.notifyServicePlaceCall(service);
+
+ onSelectedCallAction(call);
+ }
+
+ public void processingHangUpAction() {
+ SipCall call = (SipCall) buttonHangup.getTag();
+ if (call != null)
+ call.notifyServiceHangup(service);
+ }
+}
diff --git a/src/com/savoirfairelinux/sflphone/client/SFLPhonePreferenceActivity.java b/src/com/savoirfairelinux/sflphone/client/SFLPhonePreferenceActivity.java
index 57f1e2c..17bed3e 100644
--- a/src/com/savoirfairelinux/sflphone/client/SFLPhonePreferenceActivity.java
+++ b/src/com/savoirfairelinux/sflphone/client/SFLPhonePreferenceActivity.java
@@ -31,9 +31,6 @@
package com.savoirfairelinux.sflphone.client;
-import java.util.List;
-
-import android.app.AlertDialog;
import android.app.ActionBar;
import android.app.Activity;
import android.app.Fragment;
@@ -46,17 +43,15 @@
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
-import android.preference.PreferenceActivity;
-import android.util.Log;
-import android.support.v4.view.ViewPager;
import android.support.v13.app.FragmentStatePagerAdapter;
-import android.view.View;
-import android.widget.Button;
-import android.widget.TextView;
+import android.support.v4.view.ViewPager;
+import android.util.Log;
import com.savoirfairelinux.sflphone.R;
-import com.savoirfairelinux.sflphone.service.SipService;
+import com.savoirfairelinux.sflphone.fragments.AccountManagementFragment;
+import com.savoirfairelinux.sflphone.fragments.PrefManagementFragment;
import com.savoirfairelinux.sflphone.service.ISipService;
+import com.savoirfairelinux.sflphone.service.SipService;
public class SFLPhonePreferenceActivity extends Activity implements ActionBar.TabListener
{
diff --git a/src/com/savoirfairelinux/sflphone/client/SFLphoneApplication.java b/src/com/savoirfairelinux/sflphone/client/SFLphoneApplication.java
index 1373947..f7ef9c9 100644
--- a/src/com/savoirfairelinux/sflphone/client/SFLphoneApplication.java
+++ b/src/com/savoirfairelinux/sflphone/client/SFLphoneApplication.java
@@ -8,16 +8,16 @@
import android.content.pm.PackageManager.NameNotFoundException;
import android.util.Log;
+import com.savoirfairelinux.sflphone.account.AccountListReceiver;
import com.savoirfairelinux.sflphone.service.ISipService;
import com.savoirfairelinux.sflphone.service.SipService;
-import com.savoirfairelinux.sflphone.utils.AccountList;
public class SFLphoneApplication extends Application {
static final String TAG = "SFLphoneApplication";
private boolean serviceRunning = false;
private ISipService sipService;
- private AccountList accountList = new AccountList();
+ private AccountListReceiver accountList = new AccountListReceiver();
private void startSipService() {
Thread thread = new Thread("StartSFLphoneService") {
@@ -79,7 +79,7 @@
sipService = service;
}
- public AccountList getAccountList() {
+ public AccountListReceiver getAccountList() {
return accountList;
}
diff --git a/src/com/savoirfairelinux/sflphone/utils/CallList.java b/src/com/savoirfairelinux/sflphone/client/receiver/CallList.java
similarity index 94%
rename from src/com/savoirfairelinux/sflphone/utils/CallList.java
rename to src/com/savoirfairelinux/sflphone/client/receiver/CallList.java
index 1bf60e0..bfec63a 100644
--- a/src/com/savoirfairelinux/sflphone/utils/CallList.java
+++ b/src/com/savoirfairelinux/sflphone/client/receiver/CallList.java
@@ -29,9 +29,8 @@
* as that of the covered work.
*/
-package com.savoirfairelinux.sflphone.utils;
+package com.savoirfairelinux.sflphone.client.receiver;
-import com.savoirfairelinux.sflphone.client.SipCall;
import android.content.BroadcastReceiver;
import android.content.Context;
@@ -41,15 +40,16 @@
import java.util.ArrayList;
+import com.savoirfairelinux.sflphone.model.SipCall;
import com.savoirfairelinux.sflphone.service.CallManagerCallBack;
-import com.savoirfairelinux.sflphone.client.SFLPhoneHome;
+import com.savoirfairelinux.sflphone.client.SFLPhoneHomeActivity;
public class CallList extends BroadcastReceiver
{
static final String TAG = "CallList";
static ArrayList<SipCall> mList = new ArrayList<SipCall>();
// Requires a reference to the main context when sending call activity
- static private SFLPhoneHome mHome = null;
+ static private SFLPhoneHomeActivity mHome = null;
private enum Signals {
NEW_CALL_CREATED,
@@ -81,7 +81,7 @@
return call;
}
- public CallList(SFLPhoneHome home) {
+ public CallList(SFLPhoneHomeActivity home) {
mHome = home;
}
@@ -92,6 +92,7 @@
Log.d(TAG, "Signal received: " + signalName);
if(signalName.equals(CallManagerCallBack.NEW_CALL_CREATED)) {
+
} else if(signalName.equals(CallManagerCallBack.CALL_STATE_CHANGED)) {
processCallStateChangedSignal(intent);
} else if(signalName.equals(CallManagerCallBack.INCOMING_CALL)) {
diff --git a/src/com/savoirfairelinux/sflphone/client/AccountManagementFragment.java b/src/com/savoirfairelinux/sflphone/fragments/AccountManagementFragment.java
similarity index 90%
rename from src/com/savoirfairelinux/sflphone/client/AccountManagementFragment.java
rename to src/com/savoirfairelinux/sflphone/fragments/AccountManagementFragment.java
index 52fabed..6568ade 100644
--- a/src/com/savoirfairelinux/sflphone/client/AccountManagementFragment.java
+++ b/src/com/savoirfairelinux/sflphone/fragments/AccountManagementFragment.java
@@ -29,41 +29,38 @@
* as that of the covered work.
*/
-package com.savoirfairelinux.sflphone.client;
+package com.savoirfairelinux.sflphone.fragments;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Set;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
-import android.preference.EditTextPreference;
+import android.os.Bundle;
+import android.os.RemoteException;
import android.preference.Preference;
import android.preference.PreferenceCategory;
import android.preference.PreferenceFragment;
import android.preference.PreferenceScreen;
-import android.preference.ListPreference;
-import android.preference.PreferenceManager;
-import android.os.Bundle;
-import android.os.RemoteException;
import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;
-import android.view.View;
-import android.widget.ArrayAdapter;
-import android.widget.ListView;
-
-import java.util.Set;
-import java.util.HashMap;
-import java.util.ArrayList;
import com.savoirfairelinux.sflphone.R;
-import com.savoirfairelinux.sflphone.service.ISipService;
-import com.savoirfairelinux.sflphone.utils.AccountDetail;
-import com.savoirfairelinux.sflphone.utils.AccountDetailsHandler;
-import com.savoirfairelinux.sflphone.utils.AccountDetailBasic;
-import com.savoirfairelinux.sflphone.utils.AccountDetailAdvanced;
-import com.savoirfairelinux.sflphone.utils.AccountDetailSrtp;
-import com.savoirfairelinux.sflphone.utils.AccountDetailTls;
+import com.savoirfairelinux.sflphone.account.AccountDetail;
+import com.savoirfairelinux.sflphone.account.AccountDetailAdvanced;
+import com.savoirfairelinux.sflphone.account.AccountDetailBasic;
+import com.savoirfairelinux.sflphone.account.AccountDetailSrtp;
+import com.savoirfairelinux.sflphone.account.AccountDetailTls;
+import com.savoirfairelinux.sflphone.client.AccountCreationActivity;
import com.savoirfairelinux.sflphone.client.AccountPreferenceActivity;
+import com.savoirfairelinux.sflphone.client.SFLPhonePreferenceActivity;
+import com.savoirfairelinux.sflphone.client.SFLphoneApplication;
+import com.savoirfairelinux.sflphone.service.ISipService;
public class AccountManagementFragment extends PreferenceFragment
{
@@ -271,7 +268,7 @@
{
ArrayList<String> accountList = null;
try {
- accountList = (ArrayList) service.getAccountList();
+ accountList = (ArrayList<String>) service.getAccountList();
} catch (RemoteException e) {
Log.e(TAG, "Cannot call service method", e);
}
@@ -282,11 +279,11 @@
return accountList;
}
- private HashMap getAccountDetails(String accountID)
+ private HashMap<String, String> getAccountDetails(String accountID)
{
- HashMap accountDetails = null;
+ HashMap<String, String> accountDetails = null;
try {
- accountDetails = (HashMap) service.getAccountDetails(accountID);
+ accountDetails = (HashMap<String, String>) service.getAccountDetails(accountID);
} catch (RemoteException e) {
Log.e(TAG, "Cannot call service method", e);
}
@@ -339,6 +336,12 @@
Preference createAccountPreferenceScreen(String accountID) {
+ HashMap<String, String> details = getAccountDetails(accountID);
+ Set<String> keys = details.keySet();
+ Iterator<String> ite = keys.iterator();
+ while(ite.hasNext()){
+ Log.i(TAG,"key : "+ ite.next());
+ }
Bundle bundle = new Bundle();
bundle.putString("AccountID", accountID);
@@ -346,7 +349,8 @@
intent.putExtras(bundle);
Preference editAccount = new Preference(getActivity());
- editAccount.setTitle(accountID);
+ editAccount.setTitle(details.get(AccountDetailBasic.CONFIG_ACCOUNT_ALIAS));
+ editAccount.setSummary(details.get(AccountDetailBasic.CONFIG_ACCOUNT_HOSTNAME));
editAccount.setOnPreferenceClickListener(launchAccountEditOnClick);
editAccount.setIntent(intent);
diff --git a/src/com/savoirfairelinux/sflphone/client/ButtonSectionFragment.java b/src/com/savoirfairelinux/sflphone/fragments/ButtonSectionFragment.java
similarity index 69%
rename from src/com/savoirfairelinux/sflphone/client/ButtonSectionFragment.java
rename to src/com/savoirfairelinux/sflphone/fragments/ButtonSectionFragment.java
index e15dddc..02c72e5 100644
--- a/src/com/savoirfairelinux/sflphone/client/ButtonSectionFragment.java
+++ b/src/com/savoirfairelinux/sflphone/fragments/ButtonSectionFragment.java
@@ -1,19 +1,15 @@
-package com.savoirfairelinux.sflphone.client;
+package com.savoirfairelinux.sflphone.fragments;
import android.app.Fragment;
import android.os.Bundle;
-import android.text.Editable;
import android.util.Log;
-import android.view.InflateException;
import android.view.LayoutInflater;
import android.view.View;
-import android.view.View.OnClickListener;
import android.view.ViewGroup;
-import android.widget.Button;
import android.widget.EditText;
-import android.widget.TextView;
import com.savoirfairelinux.sflphone.R;
+import com.savoirfairelinux.sflphone.model.Numpad;
public class ButtonSectionFragment extends Fragment
{
@@ -33,15 +29,17 @@
{
View view;
Log.i(TAG, "onCreateView" );
- view = inflater.inflate(R.layout.test_layout, parent, false);
-
- /*
+ view = inflater.inflate(R.layout.frag_button_section, parent, false);
+
Numpad numpad = (Numpad) view.findViewById(R.id.numPad);
- mTextEntry = (EditText) view.findViewById(R.id.numDisplay);
+ mTextEntry = (EditText) parent.findViewById(R.id.phoneNumberTextEntry);
+ if(mTextEntry == null){
+ Log.i(TAG,"NULL");
+ }
numpad.setEditText(mTextEntry);
- */
+
return view;
}
diff --git a/src/com/savoirfairelinux/sflphone/fragments/CallElementListFragment.java b/src/com/savoirfairelinux/sflphone/fragments/CallElementListFragment.java
new file mode 100644
index 0000000..ae5fc4a
--- /dev/null
+++ b/src/com/savoirfairelinux/sflphone/fragments/CallElementListFragment.java
@@ -0,0 +1,385 @@
+/*
+ * 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.fragments;
+
+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.Activity;
+import android.app.AlertDialog;
+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.DialogInterface;
+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.ContactsContract;
+import android.provider.ContactsContract.CommonDataKinds;
+import android.provider.ContactsContract.CommonDataKinds.Phone;
+import android.provider.ContactsContract.CommonDataKinds.SipAddress;
+import android.provider.ContactsContract.Contacts;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.AdapterView.OnItemLongClickListener;
+import android.widget.ArrayAdapter;
+import android.widget.Button;
+import android.widget.ImageButton;
+import android.widget.ImageView;
+import android.widget.ListView;
+import android.widget.TextView;
+
+import com.savoirfairelinux.sflphone.R;
+import com.savoirfairelinux.sflphone.account.AccountListReceiver;
+import com.savoirfairelinux.sflphone.account.AccountSelectionSpinner;
+import com.savoirfairelinux.sflphone.client.SFLPhoneHomeActivity;
+import com.savoirfairelinux.sflphone.client.SFLphoneApplication;
+import com.savoirfairelinux.sflphone.model.ContactManager;
+import com.savoirfairelinux.sflphone.model.SipCall;
+import com.savoirfairelinux.sflphone.service.ISipService;
+
+/**
+ * Main list of Call Elements. We don't manage contacts ourself so they are
+ */
+public class CallElementListFragment extends ListFragment implements LoaderManager.LoaderCallbacks<Cursor> {
+ private static final String TAG = "CallElementList";
+ private static final String CURRENT_STATE_LABEL = " CURRENT STATE: ";
+ private ContactManager mContactManager;
+ private CallElementAdapter mAdapter;
+ private String mCurFilter;
+ private SFLPhoneHomeActivity sflphoneHome;
+ private SFLphoneApplication sflphoneApplication;
+ private ISipService service;
+ private AccountSelectionSpinner mAccountSelectionButton;
+ private AccountListReceiver mAccountList;
+
+ 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 };
+
+ @Override
+ public void onAttach(Activity activity) {
+ super.onAttach(activity);
+ sflphoneHome = (SFLPhoneHomeActivity) activity;
+ service = ((SFLphoneApplication) sflphoneHome.getApplication()).getSipService();
+ mAccountList = ((SFLphoneApplication) sflphoneHome.getApplication()).getAccountList();
+ Log.w(TAG, "onAttach() service=" + service + ", accountList=" + mAccountList);
+ }
+
+ public String getSelectedAccount() {
+// return mAccountSelectionButton.getText().toString();
+ return "CIOUCOU";
+ }
+
+ /**
+ * 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.
+ */
+ public static class CallElementAdapter extends ArrayAdapter {
+ private ExecutorService infos_fetcher = Executors.newCachedThreadPool();
+ private Context mContext;
+ private final List mCallList;
+
+ public CallElementAdapter(Context context, List callList) {
+ super(context, R.layout.item_contact, callList);
+ mContext = context;
+ mCallList = callList;
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ View rowView = convertView;
+ CallElementView entryView = null;
+
+ if (rowView == null) {
+ // Get a new instance of the row layout view
+ LayoutInflater inflater = LayoutInflater.from(mContext);
+ rowView = inflater.inflate(R.layout.item_contact, null);
+
+ // Hold the view objects in an object
+ // so they don't need to be re-fetched
+ entryView = new CallElementView();
+ entryView.toggleButton = (ImageButton) rowView.findViewById(R.id.toggleButton1);
+ entryView.button = (Button) rowView.findViewById(R.id.button2);
+ entryView.photo = (ImageView) rowView.findViewById(R.id.photo);
+ entryView.displayName = (TextView) rowView.findViewById(R.id.display_name);
+ entryView.phones = (TextView) rowView.findViewById(R.id.phones);
+ entryView.state = (TextView) rowView.findViewById(R.id.callstate);
+
+ // Cache the view obects in the tag
+ // so they can be re-accessed later
+ rowView.setTag(entryView);
+ } else {
+ entryView = (CallElementView) rowView.getTag();
+ }
+
+ // Transfer the stock data from the data object
+ // to the view objects
+ SipCall call = (SipCall) mCallList.get(position);
+ call.setAssociatedRowView(rowView);
+ entryView.displayName.setText(call.getDisplayName());
+ entryView.phones.setText(call.getPhone());
+ entryView.state.setText(CURRENT_STATE_LABEL + call.getCallStateString());
+
+ return rowView;
+ }
+ };
+
+ public static class CallElementView {
+ protected ImageButton toggleButton;
+ protected Button button;
+ protected ImageView photo;
+ protected TextView displayName;
+ protected TextView phones;
+ public TextView state;
+ }
+
+ public CallElementListFragment() {
+ super();
+ }
+
+ public void setAccountList(AccountListReceiver accountList) {
+ mAccountList = accountList;
+ }
+
+ public void addCall(SipCall c) {
+ Log.i(TAG, "Adding call " + c.mCallInfo.mDisplayName);
+ mAdapter.add(c);
+ }
+
+ public void removeCall(SipCall c) {
+ Log.i(TAG, "Removing call " + c.mCallInfo.mDisplayName);
+ mAdapter.remove(c);
+ }
+
+ @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.
+ ArrayList calls = new ArrayList();
+ mAdapter = new CallElementAdapter(getActivity(), calls);
+ 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)
+
+ final Context context = getActivity();
+ ListView lv = getListView();
+ lv.setOnItemLongClickListener(new OnItemLongClickListener() {
+ @Override
+ public boolean onItemLongClick(AdapterView<?> av, View v, int pos, long id) {
+ Log.i(TAG, "On Long Click");
+ final CharSequence[] items = { "Hang up Call", "Send Message", "Add to Conference" };
+ final SipCall call = (SipCall) mAdapter.getItem(pos);
+ // FIXME
+ service = sflphoneApplication.getSipService();
+ AlertDialog.Builder builder = new AlertDialog.Builder(context);
+ builder.setTitle("Action to perform with " + call.mCallInfo.mDisplayName).setCancelable(true)
+ .setItems(items, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int item) {
+ Log.i(TAG, "Selected " + items[item]);
+ switch (item) {
+ case 0:
+ call.notifyServiceHangup(service);
+ break;
+ case 1:
+ call.sendTextMessage();
+ // Need to hangup this call immediately since no way to do it after this action
+ call.notifyServiceHangup(service);
+ break;
+ case 2:
+ call.addToConference();
+ // Need to hangup this call immediately since no way to do it after this action
+ call.notifyServiceHangup(service);
+ break;
+ default:
+ break;
+ }
+ }
+ });
+ AlertDialog alert = builder.create();
+ alert.show();
+
+ return true;
+ }
+ });
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ View inflatedView = inflater.inflate(R.layout.frag_call_element, container, false);
+
+ mAccountSelectionButton = (AccountSelectionSpinner) inflatedView.findViewById(R.id.account_selection_button);
+ mAccountList.addManagementUI(mAccountSelectionButton);
+ mAccountSelectionButton.setAccountList(mAccountList);
+
+ return inflatedView;
+ }
+
+ public void onListItemClick(ListView l, View v, int position, long id) {
+ // Insert desired behavior here.
+ SipCall call = (SipCall) mAdapter.getItem(position);
+ Log.i(TAG, "Call Clicked: " + call.getCallId());
+
+ call.launchCallActivity(getActivity());
+
+ sflphoneHome.onSelectedCallAction(call);
+ }
+
+ @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/ContactListFragment.java b/src/com/savoirfairelinux/sflphone/fragments/ContactListFragment.java
similarity index 92%
rename from src/com/savoirfairelinux/sflphone/client/ContactListFragment.java
rename to src/com/savoirfairelinux/sflphone/fragments/ContactListFragment.java
index 83037f4..a968d36 100644
--- a/src/com/savoirfairelinux/sflphone/client/ContactListFragment.java
+++ b/src/com/savoirfairelinux/sflphone/fragments/ContactListFragment.java
@@ -28,13 +28,18 @@
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
-package com.savoirfairelinux.sflphone.client;
+package com.savoirfairelinux.sflphone.fragments;
+
+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.Activity;
+import android.app.AlertDialog;
import android.app.ListFragment;
import android.app.LoaderManager;
-import android.app.AlertDialog;
-import android.app.AlertDialog.Builder;
import android.content.ContentResolver;
import android.content.ContentUris;
import android.content.Context;
@@ -46,41 +51,38 @@
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
-import android.os.RemoteException;
-import android.provider.*;
+import android.provider.BaseColumns;
+import android.provider.ContactsContract;
import android.provider.ContactsContract.CommonDataKinds;
import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.provider.ContactsContract.CommonDataKinds.SipAddress;
import android.provider.ContactsContract.Contacts;
+import android.support.v4.view.MenuItemCompat;
import android.text.TextUtils;
+import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
-import android.view.MenuItem;
import android.view.MenuInflater;
+import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
-import android.widget.Button;
-import android.widget.CursorAdapter;
-import android.widget.ImageView;
-import android.widget.ListView;
-import android.widget.TextView;
-import android.widget.Toast;
-import android.widget.SearchView;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemLongClickListener;
import android.widget.AdapterView.OnItemSelectedListener;
+import android.widget.CursorAdapter;
+import android.widget.ImageView;
+import android.widget.ListView;
+import android.widget.SearchView;
import android.widget.SearchView.OnQueryTextListener;
-import android.util.Log;
-import java.io.InputStream;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.List;
-import java.util.ArrayList;
+import android.widget.TextView;
import com.savoirfairelinux.sflphone.R;
+import com.savoirfairelinux.sflphone.account.AccountListReceiver;
+import com.savoirfairelinux.sflphone.account.AccountSelectionSpinner;
+import com.savoirfairelinux.sflphone.client.SFLPhoneHomeActivity;
+import com.savoirfairelinux.sflphone.client.SFLphoneApplication;
+import com.savoirfairelinux.sflphone.model.SipCall;
import com.savoirfairelinux.sflphone.service.ISipService;
-import com.savoirfairelinux.sflphone.utils.AccountList;
-import com.savoirfairelinux.sflphone.utils.AccountSelectionButton;
public class ContactListFragment extends ListFragment implements OnQueryTextListener, LoaderManager.LoaderCallbacks<Cursor>
{
@@ -88,11 +90,10 @@
ContactElementAdapter mAdapter;
Activity mContext;
String mCurFilter;
- private SFLPhoneHome sflphoneHome;
+ private SFLPhoneHomeActivity sflphoneHome;
private SFLphoneApplication sflphoneApplication;
private ISipService service;
- private AccountSelectionButton mAccountSelectionButton;
- private AccountList mAccountList;
+ private AccountListReceiver mAccountList;
// These are the Contacts rows that we will retrieve.
static final String[] CONTACTS_SUMMARY_PROJECTION = new String[] { Contacts._ID, Contacts.DISPLAY_NAME,
@@ -103,7 +104,7 @@
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
- sflphoneHome = (SFLPhoneHome) activity;
+ sflphoneHome = (SFLPhoneHomeActivity) activity;
sflphoneApplication = (SFLphoneApplication) sflphoneHome.getApplication();
service = sflphoneApplication.getSipService();
mAccountList = sflphoneApplication.getAccountList();
@@ -176,7 +177,7 @@
public View newView(Context context, Cursor cursor, ViewGroup parent)
{
LayoutInflater inflater = LayoutInflater.from(context);
- View v = inflater.inflate(R.layout.call_element, parent, false);
+ View v = inflater.inflate(R.layout.item_contact, parent, false);
bindView(v, context, cursor);
return v;
}
@@ -280,13 +281,7 @@
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
- View inflatedView = inflater.inflate(R.layout.call_element_list, container, false);
-
- // Button accountSelectionButton = (Button) inflatedView.findViewById(R.id.account_selection_button);
- mAccountSelectionButton = (AccountSelectionButton) inflatedView.findViewById(R.id.account_selection_button);
- mAccountList.addManagementUI(mAccountSelectionButton);
- mAccountSelectionButton.setAccountList(mAccountList);
-
+ View inflatedView = inflater.inflate(R.layout.frag_contact_list, container, false);
return inflatedView;
}
@@ -296,7 +291,8 @@
// Place an action bar item for searching
MenuItem item = menu.add("Search");
item.setIcon(R.drawable.ic_menu_search);
- item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
+
+ item.setShowAsAction(MenuItemCompat.SHOW_AS_ACTION_IF_ROOM | MenuItemCompat.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
SearchView sv = new SearchView(getActivity());
sv.setOnQueryTextListener(this);
item.setActionView(sv);
diff --git a/src/com/savoirfairelinux/sflphone/client/PrefManagementFragment.java b/src/com/savoirfairelinux/sflphone/fragments/PrefManagementFragment.java
similarity index 99%
rename from src/com/savoirfairelinux/sflphone/client/PrefManagementFragment.java
rename to src/com/savoirfairelinux/sflphone/fragments/PrefManagementFragment.java
index d1f8697..bc2916a 100644
--- a/src/com/savoirfairelinux/sflphone/client/PrefManagementFragment.java
+++ b/src/com/savoirfairelinux/sflphone/fragments/PrefManagementFragment.java
@@ -29,7 +29,7 @@
* as that of the covered work.
*/
-package com.savoirfairelinux.sflphone.client;
+package com.savoirfairelinux.sflphone.fragments;
import android.app.Activity;
import android.content.Context;
diff --git a/src/com/savoirfairelinux/sflphone/client/CallContact.java b/src/com/savoirfairelinux/sflphone/model/CallContact.java
similarity index 97%
rename from src/com/savoirfairelinux/sflphone/client/CallContact.java
rename to src/com/savoirfairelinux/sflphone/model/CallContact.java
index d56632e..fd3ea34 100644
--- a/src/com/savoirfairelinux/sflphone/client/CallContact.java
+++ b/src/com/savoirfairelinux/sflphone/model/CallContact.java
@@ -28,7 +28,7 @@
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
-package com.savoirfairelinux.sflphone.client;
+package com.savoirfairelinux.sflphone.model;
public class CallContact
{
diff --git a/src/com/savoirfairelinux/sflphone/client/ContactManager.java b/src/com/savoirfairelinux/sflphone/model/ContactManager.java
similarity index 98%
rename from src/com/savoirfairelinux/sflphone/client/ContactManager.java
rename to src/com/savoirfairelinux/sflphone/model/ContactManager.java
index 13bfe18..861b0ad 100644
--- a/src/com/savoirfairelinux/sflphone/client/ContactManager.java
+++ b/src/com/savoirfairelinux/sflphone/model/ContactManager.java
@@ -28,7 +28,7 @@
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
-package com.savoirfairelinux.sflphone.client;
+package com.savoirfairelinux.sflphone.model;
import android.content.ContentResolver;
import android.content.Context;
@@ -38,6 +38,7 @@
import android.util.Log;
import java.util.ArrayList;
+
public class ContactManager
{
int mCount;
diff --git a/src/com/savoirfairelinux/sflphone/client/Numpad.java b/src/com/savoirfairelinux/sflphone/model/Numpad.java
similarity index 97%
rename from src/com/savoirfairelinux/sflphone/client/Numpad.java
rename to src/com/savoirfairelinux/sflphone/model/Numpad.java
index e8a570a..707e3b4 100644
--- a/src/com/savoirfairelinux/sflphone/client/Numpad.java
+++ b/src/com/savoirfairelinux/sflphone/model/Numpad.java
@@ -1,4 +1,4 @@
-package com.savoirfairelinux.sflphone.client;
+package com.savoirfairelinux.sflphone.model;
import android.content.Context;
import android.text.Editable;
diff --git a/src/com/savoirfairelinux/sflphone/client/SipCall.java b/src/com/savoirfairelinux/sflphone/model/SipCall.java
similarity index 95%
rename from src/com/savoirfairelinux/sflphone/client/SipCall.java
rename to src/com/savoirfairelinux/sflphone/model/SipCall.java
index 25fec63..0466cdf 100644
--- a/src/com/savoirfairelinux/sflphone/client/SipCall.java
+++ b/src/com/savoirfairelinux/sflphone/model/SipCall.java
@@ -28,7 +28,7 @@
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
-package com.savoirfairelinux.sflphone.client;
+package com.savoirfairelinux.sflphone.model;
import android.content.Context;
import android.content.Intent;
@@ -42,15 +42,17 @@
import com.savoirfairelinux.sflphone.service.ISipService;
import com.savoirfairelinux.sflphone.client.CallActivity;
-import com.savoirfairelinux.sflphone.client.CallElementList.CallElementView;
+import com.savoirfairelinux.sflphone.client.SFLPhoneHomeActivity;
+import com.savoirfairelinux.sflphone.fragments.CallElementListFragment;
+import com.savoirfairelinux.sflphone.fragments.CallElementListFragment.CallElementView;
public class SipCall
{
final static String TAG = "SipCall";
public CallInfo mCallInfo;
// Update UI on actions (answer, hangup)
- static private CallElementList mCallElementList = null;
- static private SFLPhoneHome mHome = null;
+ static private CallElementListFragment mCallElementList = null;
+ static private SFLPhoneHomeActivity mHome = null;
private View mRowView = null;
public static final int CALL_TYPE_UNDETERMINED = 0;
@@ -148,12 +150,12 @@
mCallInfo = info;
}
- public static void setCallElementList(CallElementList list)
+ public static void setCallElementList(CallElementListFragment list)
{
mCallElementList = list;
}
- public static void setSFLPhoneHomeContext(SFLPhoneHome home)
+ public static void setSFLPhoneHomeContext(SFLPhoneHomeActivity home)
{
mHome = home;
}
diff --git a/src/com/savoirfairelinux/sflphone/service/ConfigurationManagerJNI.java b/src/com/savoirfairelinux/sflphone/service/ConfigurationManagerJNI.java
index 6e38495..6106216 100644
--- a/src/com/savoirfairelinux/sflphone/service/ConfigurationManagerJNI.java
+++ b/src/com/savoirfairelinux/sflphone/service/ConfigurationManagerJNI.java
@@ -219,30 +219,6 @@
return SFLPhoneserviceJNI.ConfigurationManagerJNI_getAudioManager(swigCPtr, this);
}
- public void setMailNotify() {
- SFLPhoneserviceJNI.ConfigurationManagerJNI_setMailNotify(swigCPtr, this);
- }
-
- public SWIGTYPE_p_int32_t getMailNotify() {
- return new SWIGTYPE_p_int32_t(SFLPhoneserviceJNI.ConfigurationManagerJNI_getMailNotify(swigCPtr, this), true);
- }
-
- public SWIGTYPE_p_std__mapT_std__string_int32_t_t getAddressbookSettings() {
- return new SWIGTYPE_p_std__mapT_std__string_int32_t_t(SFLPhoneserviceJNI.ConfigurationManagerJNI_getAddressbookSettings(swigCPtr, this), true);
- }
-
- public void setAddressbookSettings(SWIGTYPE_p_std__mapT_std__string_int32_t_t settings) {
- SFLPhoneserviceJNI.ConfigurationManagerJNI_setAddressbookSettings(swigCPtr, this, SWIGTYPE_p_std__mapT_std__string_int32_t_t.getCPtr(settings));
- }
-
- public StringVect getAddressbookList() {
- return new StringVect(SFLPhoneserviceJNI.ConfigurationManagerJNI_getAddressbookList(swigCPtr, this), true);
- }
-
- public void setAddressbookList(StringVect list) {
- SFLPhoneserviceJNI.ConfigurationManagerJNI_setAddressbookList(swigCPtr, this, StringVect.getCPtr(list), list);
- }
-
public StringMap getHookSettings() {
return new StringMap(SFLPhoneserviceJNI.ConfigurationManagerJNI_getHookSettings(swigCPtr, this), true);
}
diff --git a/src/com/savoirfairelinux/sflphone/service/SipService.java b/src/com/savoirfairelinux/sflphone/service/SipService.java
index 0a156e7..e060006 100644
--- a/src/com/savoirfairelinux/sflphone/service/SipService.java
+++ b/src/com/savoirfairelinux/sflphone/service/SipService.java
@@ -37,9 +37,9 @@
import android.widget.Toast;
import com.savoirfairelinux.sflphone.service.ManagerImpl;
+import com.savoirfairelinux.sflphone.account.AccountDetailsHandler;
import com.savoirfairelinux.sflphone.client.SFLphoneApplication;
import com.savoirfairelinux.sflphone.service.ISipService;
-import com.savoirfairelinux.sflphone.utils.AccountDetailsHandler;
import java.util.Map;
import java.util.HashMap;
diff --git a/src/com/savoirfairelinux/sflphone/utils/AccountSelectionButton.java b/src/com/savoirfairelinux/sflphone/utils/AccountSelectionButton.java
deleted file mode 100644
index ad18e8b..0000000
--- a/src/com/savoirfairelinux/sflphone/utils/AccountSelectionButton.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright (C) 2004-2012 Savoir-Faire Linux Inc.
- *
- * Author: Alexandre Savard <alexandre.savard@savoirfairelinux.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.utils;
-
-import android.content.Context;
-import android.os.RemoteException;
-import android.util.Log;
-import android.util.AttributeSet;
-import android.view.View;
-import android.widget.Button;
-
-import com.savoirfairelinux.sflphone.client.AccountSelectionDialog;
-import com.savoirfairelinux.sflphone.service.ISipService;
-
-import java.util.ArrayList;
-
-public class AccountSelectionButton extends Button implements AccountManagementUI
-{
- private static final String TAG = "AccountSelectionButton";
- private Context mContext;
- private ArrayList<String> mList = new ArrayList<String>();
- private AccountList mAccountList = null;
-
- public AccountSelectionButton(Context context) {
- super(context);
- mContext = context;
- init();
- }
-
- public AccountSelectionButton(Context context, AttributeSet attrs) {
- super(context, attrs);
- mContext = context;
- init();
- }
-
- public AccountSelectionButton(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- mContext = context;
- init();
- }
-
- private void init() {
- final AccountSelectionButton b = this;
-
- setOnClickListener(new View.OnClickListener() {
- public void onClick(View v) {
- AccountSelectionDialog accountSelectionDialog = new AccountSelectionDialog(mContext, mList, b);
- accountSelectionDialog.show();
- }
- });
- }
-
- public void setAccountList(AccountList accountList) {
- mAccountList = accountList;
- }
-
- public void accountSelectedNotifyAccountList(String accountID) {
- if(mAccountList != null) {
- mAccountList.accountSelected(accountID, this);
- }
- }
-
- public void setSelectedAccount(String accountID) {
- setText(accountID);
- }
-
- public void accountAdded(ArrayList<String> newList) {
- Log.i(TAG, "Account added");
- mList = newList;
-
- if(newList.size() == 1) {
- setText(newList.get(0));
- }
- }
-
- public void accountRemoved() {
-
- }
-
- public void accountUpdated() {
-
- }
-}