* #25382 Added callbacks in JNI
* #25376 Modified handling of touch events to detect longpress
diff --git a/jni/sflphone b/jni/sflphone
index 69b2dc1..6857b26 160000
--- a/jni/sflphone
+++ b/jni/sflphone
@@ -1 +1 @@
-Subproject commit 69b2dc1742a949c0f285ba546a35c360856b882e
+Subproject commit 6857b265b1ade2109eec52c17324e0a14854b48b
diff --git a/res/layout/actionbar.xml b/res/layout/actionbar.xml
new file mode 100644
index 0000000..3b3ca89
--- /dev/null
+++ b/res/layout/actionbar.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" >
+
+ <TextView
+ android:id="@+id/activity_title"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:layout_alignParentLeft="true"
+ android:layout_centerVertical="true"
+ android:gravity="center"
+ android:maxWidth="200dp"
+ android:singleLine="true"
+ android:textSize="20sp" />
+
+ <Spinner
+ android:id="@+id/account_selection"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_toRightOf="@+id/activity_title"
+ android:layout_alignParentRight="true" />
+
+</RelativeLayout>
\ No newline at end of file
diff --git a/res/layout/item_calllist.xml b/res/layout/item_calllist.xml
index dbe39ce..ea1aed9 100644
--- a/res/layout/item_calllist.xml
+++ b/res/layout/item_calllist.xml
@@ -14,17 +14,17 @@
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
- <Button
- android:id="@+id/hangup_button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignBaseline="@+id/call_title"
- android:layout_alignBottom="@+id/call_title"
- android:layout_marginLeft="34dp"
- android:layout_toRightOf="@+id/call_title"
- android:focusable="false"
- android:focusableInTouchMode="false"
- android:text="HangUp" />
+<!-- <Button -->
+<!-- android:id="@+id/hangup_button" -->
+<!-- android:layout_width="wrap_content" -->
+<!-- android:layout_height="wrap_content" -->
+<!-- android:layout_alignBaseline="@+id/call_title" -->
+<!-- android:layout_alignBottom="@+id/call_title" -->
+<!-- android:layout_marginLeft="34dp" -->
+<!-- android:layout_toRightOf="@+id/call_title" -->
+<!-- android:focusable="false" -->
+<!-- android:focusableInTouchMode="false" -->
+<!-- android:text="HangUp" /> -->
<TextView
android:id="@+id/call_status"
@@ -35,16 +35,16 @@
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
- <ToggleButton
- android:id="@+id/hold_switch"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignBaseline="@+id/hangup_button"
- android:layout_alignBottom="@+id/hangup_button"
- android:layout_alignParentRight="true"
- android:focusable="false"
- android:focusableInTouchMode="false"
- android:textOff="Hold"
- android:textOn="Unhold" />
+<!-- <ToggleButton -->
+<!-- android:id="@+id/hold_switch" -->
+<!-- android:layout_width="wrap_content" -->
+<!-- android:layout_height="wrap_content" -->
+<!-- android:layout_alignBaseline="@+id/hangup_button" -->
+<!-- android:layout_alignBottom="@+id/hangup_button" -->
+<!-- android:layout_alignParentRight="true" -->
+<!-- android:focusable="false" -->
+<!-- android:focusableInTouchMode="false" -->
+<!-- android:textOff="Hold" -->
+<!-- android:textOn="Unhold" /> -->
</RelativeLayout>
\ No newline at end of file
diff --git a/src/com/savoirfairelinux/sflphone/adapters/AccountSelectionAdapter.java b/src/com/savoirfairelinux/sflphone/adapters/AccountSelectionAdapter.java
index 9b9bad3..6226021 100644
--- a/src/com/savoirfairelinux/sflphone/adapters/AccountSelectionAdapter.java
+++ b/src/com/savoirfairelinux/sflphone/adapters/AccountSelectionAdapter.java
@@ -3,6 +3,8 @@
import java.util.ArrayList;
import android.content.Context;
+import android.content.Intent;
+import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -102,4 +104,24 @@
notifyDataSetChanged();
}
+ /**
+ * Modify state of specific account
+ * @param accountState
+ */
+ public void updateAccount(Intent accountState) {
+ Log.i(TAG,"updateAccount");
+ String id = accountState.getStringExtra("Account");
+ String newState = accountState.getStringExtra("state");
+ accountState.getStringExtra("Account");
+
+ for(Account a : accounts){
+ if(a.getAccountID().contentEquals(id)){
+ a.setRegistered_state(newState);
+ notifyDataSetChanged();
+ return;
+ }
+ }
+
+ }
+
}
diff --git a/src/com/savoirfairelinux/sflphone/adapters/SectionsPagerAdapter.java b/src/com/savoirfairelinux/sflphone/adapters/SectionsPagerAdapter.java
index a946789..d7e573d 100644
--- a/src/com/savoirfairelinux/sflphone/adapters/SectionsPagerAdapter.java
+++ b/src/com/savoirfairelinux/sflphone/adapters/SectionsPagerAdapter.java
@@ -1,5 +1,7 @@
package com.savoirfairelinux.sflphone.adapters;
+import java.util.ArrayList;
+
import android.app.Fragment;
import android.app.FragmentManager;
import android.content.Context;
@@ -17,39 +19,21 @@
private static final String TAG = SectionsPagerAdapter.class.getSimpleName();
Context mContext;
final private int[] icon_res_id = { R.drawable.ic_tab_call, R.drawable.ic_tab_call, R.drawable.ic_tab_history };
+ ArrayList<Fragment> fragments;
public SectionsPagerAdapter(Context c, FragmentManager fm) {
super(fm);
mContext = c;
+ fragments = new ArrayList<Fragment>();
+ fragments.add(new DialingFragment());
+ fragments.add(new CallElementListFragment());
+ fragments.add(new HistoryFragment());
}
@Override
public Fragment getItem(int i) {
- Fragment fragment;
- switch (i) {
- case 0:
- fragment = new DialingFragment();
- Log.w(TAG, "getItem() DialingFragment=" + fragment);
- break;
- case 1:
- fragment = new CallElementListFragment();
- Log.w(TAG, "getItem() CallElementList=" + fragment);
- break;
- case 2:
- fragment = new HistoryFragment();
- Log.w(TAG, "getItem() HistoryFragment=" + 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(HistoryFragment.ARG_SECTION_NUMBER, i + 1);
- fragment.setArguments(args);
- return fragment;
+ return fragments.get(i);
}
// public Fragment getFragment(int i) {
diff --git a/src/com/savoirfairelinux/sflphone/client/CallActivity.java b/src/com/savoirfairelinux/sflphone/client/CallActivity.java
index d0eac58..abe5303 100644
--- a/src/com/savoirfairelinux/sflphone/client/CallActivity.java
+++ b/src/com/savoirfairelinux/sflphone/client/CallActivity.java
@@ -179,7 +179,7 @@
Log.i(TAG, "Placing call");
mCurrentCallFragment = new CallFragment();
mCurrentCallFragment.setArguments(getIntent().getExtras());
- slidingPaneLayout.curFragment = mCurrentCallFragment;
+ slidingPaneLayout.setCurFragment(mCurrentCallFragment);
getIntent().getExtras();
mCallsFragment.update();
getFragmentManager().beginTransaction().replace(R.id.ongoingcall_pane, mCurrentCallFragment).commit();
@@ -254,7 +254,8 @@
mCurrentCallFragment.setArguments(b);
getFragmentManager().beginTransaction().replace(R.id.ongoingcall_pane, mCurrentCallFragment).commit();
- slidingPaneLayout.curFragment = mCurrentCallFragment;
+ onCallResumed(call);
+ slidingPaneLayout.setCurFragment(mCurrentCallFragment);
slidingPaneLayout.closePane();
}
diff --git a/src/com/savoirfairelinux/sflphone/client/SFLPhoneHomeActivity.java b/src/com/savoirfairelinux/sflphone/client/SFLPhoneHomeActivity.java
index fedcec9..bae5c32 100644
--- a/src/com/savoirfairelinux/sflphone/client/SFLPhoneHomeActivity.java
+++ b/src/com/savoirfairelinux/sflphone/client/SFLPhoneHomeActivity.java
@@ -57,23 +57,27 @@
import android.widget.Toast;
import com.savoirfairelinux.sflphone.R;
+import com.savoirfairelinux.sflphone.adapters.AccountSelectionAdapter;
import com.savoirfairelinux.sflphone.adapters.SectionsPagerAdapter;
+import com.savoirfairelinux.sflphone.client.receiver.AccountsReceiver;
import com.savoirfairelinux.sflphone.client.receiver.CallReceiver;
import com.savoirfairelinux.sflphone.fragments.CallElementListFragment;
import com.savoirfairelinux.sflphone.fragments.ContactListFragment;
import com.savoirfairelinux.sflphone.fragments.DialingFragment;
import com.savoirfairelinux.sflphone.fragments.HistoryFragment;
import com.savoirfairelinux.sflphone.fragments.MenuFragment;
+import com.savoirfairelinux.sflphone.interfaces.AccountsInterface;
import com.savoirfairelinux.sflphone.interfaces.CallInterface;
import com.savoirfairelinux.sflphone.model.CallContact;
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;
import com.savoirfairelinux.sflphone.views.CustomSlidingDrawer;
public class SFLPhoneHomeActivity extends Activity implements DialingFragment.Callbacks, ContactListFragment.Callbacks,
- CallElementListFragment.Callbacks, HistoryFragment.Callbacks, CallInterface {
+ CallElementListFragment.Callbacks, HistoryFragment.Callbacks, CallInterface, AccountsInterface {
SectionsPagerAdapter mSectionsPagerAdapter = null;
static final String TAG = "SFLPhoneHomeActivity";
@@ -82,9 +86,9 @@
* Fragments used
*/
private ContactListFragment mContactsFragment = null;
- private DialingFragment mDialingFragment = null;
- private CallElementListFragment mCallElementList = null;
- private HistoryFragment mHistorySectionFragment = null;
+ // private DialingFragment mDialingFragment = null;
+ // private CallElementListFragment mCallElementList = null;
+ // private HistoryFragment mHistorySectionFragment = null;
private Fragment fMenu;
private boolean mBound = false;
@@ -93,12 +97,15 @@
private CharSequence mDrawerTitle;
private CharSequence mTitle;
+ AccountSelectionAdapter mAdapter;
+// private Spinner spinnerAccounts;
+
public static final int REQUEST_CODE_PREFERENCES = 1;
private static final int REQUEST_CODE_CALL = 2;
- private static final int ACTION_BAR_TAB_DIALING = 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_DIALING = 0;
+// private static final int ACTION_BAR_TAB_CALL = 1;
+// private static final int ACTION_BAR_TAB_HISTORY = 2;
RelativeLayout mSliderButton;
CustomSlidingDrawer mDrawer;
@@ -109,7 +116,8 @@
*/
ViewPager mViewPager;
- CallReceiver receiver;
+ CallReceiver callReceiver;
+ AccountsReceiver accountReceiver;
private TabHost mTabHost;
@@ -135,11 +143,13 @@
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- receiver = new CallReceiver(this);
-
+ callReceiver = new CallReceiver(this);
+ accountReceiver = new AccountsReceiver(this);
// String libraryPath = getApplicationInfo().dataDir + "/lib";
// Log.i(TAG, libraryPath);
+ setContentView(R.layout.activity_sflphone_home);
+
// Bind to LocalService
if (!mBound) {
Log.i(TAG, "onStart: Binding service...");
@@ -147,42 +157,36 @@
bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
}
- setContentView(R.layout.activity_sflphone_home);
-
- if (mSectionsPagerAdapter == null) {
- mSectionsPagerAdapter = new SectionsPagerAdapter(this, getFragmentManager());
- }
-
/* getFragment(Bundle, String) */
- if (savedInstanceState != null) {
- Log.w(TAG, "Activity restarted, recreating PagerAdapter...");
- /* getFragment (Bundle bundle, String key) */
- mDialingFragment = (DialingFragment) getFragmentManager().getFragment(savedInstanceState,
- mSectionsPagerAdapter.getClassName(ACTION_BAR_TAB_DIALING));
- mCallElementList = (CallElementListFragment) getFragmentManager().getFragment(savedInstanceState,
- mSectionsPagerAdapter.getClassName(ACTION_BAR_TAB_CALL));
- mHistorySectionFragment = (HistoryFragment) getFragmentManager().getFragment(savedInstanceState,
- mSectionsPagerAdapter.getClassName(ACTION_BAR_TAB_HISTORY));
- }
+ // if (savedInstanceState != null) {
+ // Log.w(TAG, "Activity restarted, recreating PagerAdapter...");
+ // /* getFragment (Bundle bundle, String key) */
+ // mDialingFragment = (DialingFragment) getFragmentManager().getFragment(savedInstanceState,
+ // mSectionsPagerAdapter.getClassName(ACTION_BAR_TAB_DIALING));
+ // mCallElementList = (CallElementListFragment) getFragmentManager().getFragment(savedInstanceState,
+ // mSectionsPagerAdapter.getClassName(ACTION_BAR_TAB_CALL));
+ // mHistorySectionFragment = (HistoryFragment) getFragmentManager().getFragment(savedInstanceState,
+ // mSectionsPagerAdapter.getClassName(ACTION_BAR_TAB_HISTORY));
+ // }
- if (mDialingFragment == null) {
- mDialingFragment = new DialingFragment();
- Log.w(TAG, "Recreated mDialingFragment=" + mDialingFragment);
- }
-
+ // if (mDialingFragment == null) {
+ // mDialingFragment = new DialingFragment();
+ // Log.w(TAG, "Recreated mDialingFragment=" + mDialingFragment);
+ // }
+ //
if (mContactsFragment == null) {
mContactsFragment = new ContactListFragment();
Log.w(TAG, "Recreated mContactListFragment=" + mContactsFragment);
getFragmentManager().beginTransaction().replace(R.id.contacts_frame, mContactsFragment).commit();
}
- if (mCallElementList == null) {
- mCallElementList = new CallElementListFragment();
- Log.w(TAG, "Recreated mCallElementList=" + mCallElementList);
- }
- if (mHistorySectionFragment == null) {
- mHistorySectionFragment = new HistoryFragment();
- Log.w(TAG, "Recreated mHistorySectionFragment=" + mHistorySectionFragment);
- }
+ // if (mCallElementList == null) {
+ // mCallElementList = new CallElementListFragment();
+ // Log.w(TAG, "Recreated mCallElementList=" + mCallElementList);
+ // }
+ // if (mHistorySectionFragment == null) {
+ // mHistorySectionFragment = new HistoryFragment();
+ // Log.w(TAG, "Recreated mHistorySectionFragment=" + mHistorySectionFragment);
+ // }
mDrawer = (CustomSlidingDrawer) findViewById(R.id.custom_sliding_drawer);
@@ -192,7 +196,7 @@
// Set up the ViewPager with the sections adapter.
mViewPager = (ViewPager) findViewById(R.id.pager);
- mViewPager.setAdapter(mSectionsPagerAdapter);
+
mTitle = mDrawerTitle = getTitle();
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
@@ -232,7 +236,34 @@
}
});
- initialiseTabHost(savedInstanceState);
+ // getActionBar().setCustomView(R.layout.actionbar);
+ // spinnerAccounts = (Spinner) getActionBar().getCustomView().findViewById(R.id.account_selection);
+ // spinnerAccounts.setOnItemSelectedListener(new OnItemSelectedListener() {
+ //
+ // @Override
+ // public void onItemSelected(AdapterView<?> arg0, View view, int pos, long arg3) {
+ // // public void onClick(DialogInterface dialog, int which) {
+ //
+ // Log.i(TAG, "Selected Account: " + mAdapter.getItem(pos));
+ // if (null != view) {
+ // ((RadioButton) view.findViewById(R.id.account_checked)).toggle();
+ // }
+ // mAdapter.setSelectedAccount(pos);
+ // // accountSelectedNotifyAccountList(mAdapter.getItem(pos));
+ // // setSelection(cursor.getPosition(),true);
+ //
+ // }
+ //
+ // @Override
+ // public void onNothingSelected(AdapterView<?> arg0) {
+ // // TODO Auto-generated method stub
+ //
+ // }
+ // });
+ // ((TextView) getActionBar().getCustomView().findViewById(R.id.activity_title)).setText(getTitle());
+ // getActionBar().setDisplayShowCustomEnabled(true);
+
+
fMenu = new MenuFragment();
getFragmentManager().beginTransaction().replace(R.id.left_drawer, fMenu).commit();
@@ -263,6 +294,8 @@
getResources().getDrawable(mSectionsPagerAdapter.getIconOf(2))), (tabInfo = new TabInfo("Tab3",
HistoryFragment.class, args)));
this.mapTabInfo.put(tabInfo.tag, tabInfo);
+
+
mTabHost.setOnTabChangedListener(new OnTabChangeListener() {
@@ -290,20 +323,27 @@
/* activity gets back to the foreground and user input */
@Override
protected void onResume() {
- Log.i(TAG, "onResume");
+ super.onResume();
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(CallManagerCallBack.INCOMING_CALL);
intentFilter.addAction(CallManagerCallBack.INCOMING_TEXT);
intentFilter.addAction(CallManagerCallBack.CALL_STATE_CHANGED);
- registerReceiver(receiver, intentFilter);
- super.onResume();
+ registerReceiver(callReceiver, intentFilter);
+
+
+ IntentFilter intentFilter2 = new IntentFilter();
+ intentFilter2.addAction(ConfigurationManagerCallback.ACCOUNT_STATE_CHANGED);
+ intentFilter2.addAction(ConfigurationManagerCallback.ACCOUNTS_CHANGED);
+ registerReceiver(accountReceiver, intentFilter2);
+
}
/* activity no more in foreground */
@Override
protected void onPause() {
super.onPause();
- unregisterReceiver(receiver);
+ unregisterReceiver(callReceiver);
+ unregisterReceiver(accountReceiver);
}
@@ -352,7 +392,14 @@
service = ISipService.Stub.asInterface(binder);
try {
+
+ mSectionsPagerAdapter = new SectionsPagerAdapter(SFLPhoneHomeActivity.this, getFragmentManager());
+ initialiseTabHost(null);
+ mViewPager.setAdapter(mSectionsPagerAdapter);
+ mTabHost.setCurrentTab(1);
service.destroyNotification();
+ // mAdapter = new AccountSelectionAdapter(SFLPhoneHomeActivity.this, service, new ArrayList<Account>());
+ // spinnerAccounts.setAdapter(mAdapter);
} catch (RemoteException e) {
Log.e(TAG, e.toString());
}
@@ -413,7 +460,7 @@
Toast.makeText(this, "New Call incoming", Toast.LENGTH_LONG).show();
SipCall infos = call.getParcelableExtra("newcall");
- mCallElementList.addCall(infos);
+ // mCallElementList.addCall(infos);
launchCallActivity(infos, CallManagerCallBack.INCOMING_CALL);
@@ -425,7 +472,7 @@
String cID = b.getString("CallID");
String state = b.getString("State");
Log.i(TAG, "callStateChanged" + cID + " " + state);
- mCallElementList.updateCall(cID, state);
+ // mCallElementList.updateCall(cID, state);
}
@@ -533,4 +580,21 @@
tabHost.addTab(tabSpec);
}
+ @Override
+ public void openDrawer() {
+ mDrawer.open();
+ }
+
+ @Override
+ public void accountsChanged() {
+ ((DialingFragment)mSectionsPagerAdapter.getItem(0)).updateAllAccounts();
+
+ }
+
+ @Override
+ public void accountStateChanged(Intent accountState) {
+ ((DialingFragment)mSectionsPagerAdapter.getItem(0)).updateAccount(accountState);
+
+ }
+
}
diff --git a/src/com/savoirfairelinux/sflphone/client/receiver/AccountsReceiver.java b/src/com/savoirfairelinux/sflphone/client/receiver/AccountsReceiver.java
new file mode 100644
index 0000000..f3d7fec
--- /dev/null
+++ b/src/com/savoirfairelinux/sflphone/client/receiver/AccountsReceiver.java
@@ -0,0 +1,33 @@
+package com.savoirfairelinux.sflphone.client.receiver;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.util.Log;
+
+import com.savoirfairelinux.sflphone.interfaces.AccountsInterface;
+import com.savoirfairelinux.sflphone.service.ConfigurationManagerCallback;
+
+public class AccountsReceiver extends BroadcastReceiver {
+
+ static final String TAG = AccountsReceiver.class.getSimpleName();
+
+ AccountsInterface callback;
+
+ public AccountsReceiver(AccountsInterface client) {
+ callback = client;
+ }
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (intent.getAction().contentEquals(ConfigurationManagerCallback.ACCOUNT_STATE_CHANGED)) {
+ Log.i(TAG, "Received" + intent.getAction());
+ callback.accountStateChanged(intent);
+ } else if (intent.getAction().contentEquals(ConfigurationManagerCallback.ACCOUNTS_CHANGED)) {
+ Log.i(TAG, "Received" + intent.getAction());
+ callback.accountsChanged();
+
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/src/com/savoirfairelinux/sflphone/client/receiver/IncomingReceiver.java b/src/com/savoirfairelinux/sflphone/client/receiver/IncomingReceiver.java
index 1fa217a..2e252c2 100644
--- a/src/com/savoirfairelinux/sflphone/client/receiver/IncomingReceiver.java
+++ b/src/com/savoirfairelinux/sflphone/client/receiver/IncomingReceiver.java
@@ -16,7 +16,7 @@
public class IncomingReceiver extends BroadcastReceiver{
- static final String TAG = CallReceiver.class.getSimpleName();
+ static final String TAG = IncomingReceiver.class.getSimpleName();
SipService callback;
@@ -29,10 +29,10 @@
if (intent.getAction().contentEquals(ConfigurationManagerCallback.ACCOUNT_STATE_CHANGED)) {
Log.i(TAG, "Received" + intent.getAction());
- } else if (intent.getAction().contentEquals(ConfigurationManagerCallback.ACCOUNTS_LOADED)) {
- Log.i(TAG, "Received" + intent.getAction());
+ callback.sendBroadcast(intent);
} else if (intent.getAction().contentEquals(ConfigurationManagerCallback.ACCOUNTS_CHANGED)) {
Log.i(TAG, "Received" + intent.getAction());
+ callback.sendBroadcast(intent);
} else if (intent.getAction().contentEquals(CallManagerCallBack.INCOMING_TEXT)) {
Log.i(TAG, "Received" + intent.getAction());
callback.sendBroadcast(intent);
diff --git a/src/com/savoirfairelinux/sflphone/fragments/CallElementListFragment.java b/src/com/savoirfairelinux/sflphone/fragments/CallElementListFragment.java
index 361adc1..3d24cb4 100644
--- a/src/com/savoirfairelinux/sflphone/fragments/CallElementListFragment.java
+++ b/src/com/savoirfairelinux/sflphone/fragments/CallElementListFragment.java
@@ -116,7 +116,6 @@
@Override
public void onResume(){
super.onResume();
- Log.i(TAG,"RESUMING MAIN FRAG BORDEL");
if (mCallbacks.getService() != null) {
try {
HashMap<String, SipCall> calls = (HashMap<String, SipCall>) mCallbacks.getService().getCallList();
diff --git a/src/com/savoirfairelinux/sflphone/fragments/ContactListFragment.java b/src/com/savoirfairelinux/sflphone/fragments/ContactListFragment.java
index 6db2cbd..3fd80fa 100644
--- a/src/com/savoirfairelinux/sflphone/fragments/ContactListFragment.java
+++ b/src/com/savoirfairelinux/sflphone/fragments/ContactListFragment.java
@@ -109,6 +109,10 @@
public void onContactDragged() {
}
+ @Override
+ public void openDrawer() {
+ }
+
};
public interface Callbacks {
@@ -118,6 +122,8 @@
void onContactDragged();
+ void openDrawer();
+
}
@Override
@@ -249,6 +255,8 @@
@Override
public boolean onQueryTextChange(String newText) {
+
+ Log.i(TAG,"onQueryTextChangeonQueryTextChangeonQueryTextChangeonQueryTextChangeonQueryTextChangeonQueryTextChangeonQueryTextChangeonQueryTextChangeonQueryTextChangeonQueryTextChangeonQueryTextChange");
// Called when the action bar search text has changed. Update
// the search filter, and restart the loader to do a new query
// with this filter.
@@ -268,6 +276,7 @@
@Override
public boolean onQueryTextSubmit(String query) {
+ Log.i(TAG,"onQueryTextSubmitonQueryTextSubmitonQueryTextSubmitonQueryTextSubmitonQueryTextSubmitonQueryTextSubmitonQueryTextSubmit");
// Return false to let the SearchView perform the default action
return false;
}
@@ -312,7 +321,14 @@
// ((ImageButton) handle.findViewById(R.id.contact_search)).setTag(R.id.contact_search, false);
((SearchView)mHandle.findViewById(R.id.contact_search_text)).setOnQueryTextListener(this);
-
+ ((SearchView)mHandle.findViewById(R.id.contact_search_text)).setOnSearchClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ mCallbacks.openDrawer();
+
+ }
+ });
// ((ImageButton) mHandle.findViewById(R.id.contact_search)).setOnClickListener(new OnClickListener() {
//
diff --git a/src/com/savoirfairelinux/sflphone/fragments/DialingFragment.java b/src/com/savoirfairelinux/sflphone/fragments/DialingFragment.java
index 10d6300..f50defb 100644
--- a/src/com/savoirfairelinux/sflphone/fragments/DialingFragment.java
+++ b/src/com/savoirfairelinux/sflphone/fragments/DialingFragment.java
@@ -37,6 +37,7 @@
import android.app.Fragment;
import android.app.LoaderManager.LoaderCallbacks;
import android.content.Context;
+import android.content.Intent;
import android.content.Loader;
import android.os.Bundle;
import android.util.Log;
@@ -52,6 +53,7 @@
import android.widget.ImageButton;
import android.widget.RadioButton;
import android.widget.Spinner;
+import android.widget.Toast;
import com.savoirfairelinux.sflphone.R;
import com.savoirfairelinux.sflphone.adapters.AccountSelectionAdapter;
@@ -109,12 +111,13 @@
}
mCallbacks = (Callbacks) activity;
-
+
}
@Override
public void onDetach() {
super.onDetach();
+ mCallbacks = sDummyCallbacks;
}
@Override
@@ -126,7 +129,7 @@
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
View inflatedView = inflater.inflate(R.layout.frag_dialing, parent, false);
-
+
spinnerAccounts = (Spinner) inflatedView.findViewById(R.id.account_selection);
spinnerAccounts.setOnItemSelectedListener(new OnItemSelectedListener() {
@@ -159,7 +162,11 @@
Account account = mAdapter.getSelectedAccount();
String to = textField.getText().toString();
- mCallbacks.onCallDialed(account.getAccountID(), to);
+ if (to.contentEquals("")) {
+ Toast.makeText(getActivity(), "Enter a number", Toast.LENGTH_LONG).show();
+ } else {
+ mCallbacks.onCallDialed(account.getAccountID(), to);
+ }
}
});
@@ -184,12 +191,12 @@
});
isReady = true;
-
+
return inflatedView;
}
-
+
@Override
- public void onResume(){
+ public void onResume() {
super.onResume();
if (mCallbacks.getService() != null) {
@@ -244,4 +251,16 @@
}
+ public void updateAllAccounts() {
+ getActivity().getLoaderManager().initLoader(555, null, this);
+
+ }
+
+ public void updateAccount(Intent accountState) {
+
+ if (mAdapter != null)
+ mAdapter.updateAccount(accountState);
+
+ }
+
}
diff --git a/src/com/savoirfairelinux/sflphone/interfaces/AccountsInterface.java b/src/com/savoirfairelinux/sflphone/interfaces/AccountsInterface.java
new file mode 100644
index 0000000..69fff1c
--- /dev/null
+++ b/src/com/savoirfairelinux/sflphone/interfaces/AccountsInterface.java
@@ -0,0 +1,12 @@
+package com.savoirfairelinux.sflphone.interfaces;
+
+import android.content.Intent;
+
+public interface AccountsInterface {
+
+ public void accountsChanged();
+
+ public void accountStateChanged(Intent accountState);
+
+
+}
diff --git a/src/com/savoirfairelinux/sflphone/model/BubblesView.java b/src/com/savoirfairelinux/sflphone/model/BubblesView.java
index c131016..d760102 100644
--- a/src/com/savoirfairelinux/sflphone/model/BubblesView.java
+++ b/src/com/savoirfairelinux/sflphone/model/BubblesView.java
@@ -11,6 +11,9 @@
import android.os.Message;
import android.util.AttributeSet;
import android.util.Log;
+import android.view.GestureDetector;
+import android.view.GestureDetector.OnGestureListener;
+import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
@@ -51,6 +54,8 @@
name_paint.setTextSize(18 * textDensity);
name_paint.setColor(0xFF303030);
name_paint.setTextAlign(Align.CENTER);
+
+ gDetector = new GestureDetector(getContext(), new MyOnGestureListener());
}
private void createThread() {
@@ -118,62 +123,79 @@
thread = null;
}
+ private GestureDetector gDetector;
+
@Override
public boolean onTouch(View v, MotionEvent event) {
Log.w(TAG, "onTouch " + event.getAction());
-
+
int action = event.getActionMasked();
-
- synchronized (model) {
+//
+// synchronized (model) {
+// List<Bubble> bubbles = model.getBubbles();
+// final int n_bubbles = bubbles.size();
+//
+// if (action == MotionEvent.ACTION_DOWN) {
+// for (int i = 0; i < n_bubbles; i++) {
+// Bubble b = bubbles.get(i);
+// if (b.intersects(event.getX(), event.getY())) {
+// b.dragged = true;
+// b.last_drag = System.nanoTime();
+// b.setPos(event.getX(), event.getY());
+// b.target_scale = .8f;
+// dragging_bubble = true;
+// }
+// }
+// } else if (action == MotionEvent.ACTION_MOVE) {
+// long now = System.nanoTime();
+// for (int i = 0; i < n_bubbles; i++) {
+// Bubble b = bubbles.get(i);
+// if (b.dragged) {
+// float x = event.getX(), y = event.getY();
+// float dt = (float) ((now - b.last_drag) / 1000000000.);
+// float dx = x - b.getPosX(), dy = y - b.getPosY();
+// b.last_drag = now;
+//
+// b.setPos(event.getX(), event.getY());
+// /*
+// * int hn = event.getHistorySize() - 2; Log.w(TAG, "event.getHistorySize() : " + event.getHistorySize()); if(hn > 0) { float
+// * dx = x-event.getHistoricalX(hn); float dy = y-event.getHistoricalY(hn); float dt = event.getHistoricalEventTime(hn)/1000.f;
+// */
+// b.speed.x = dx / dt;
+// b.speed.y = dy / dt;
+// // Log.w(TAG, "onTouch dx:" + b.speed.x + " dy:" + b.speed.y);
+// // }
+// return true;
+// }
+// }
+// } else if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) {
+// for (int i = 0; i < n_bubbles; i++) {
+// Bubble b = bubbles.get(i);
+// if (b.dragged) {
+// b.dragged = false;
+// b.target_scale = 1.f;
+// }
+// }
+// dragging_bubble = false;
+// }
+// }
+//
+// return true;
+
+ if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) {
List<Bubble> bubbles = model.getBubbles();
final int n_bubbles = bubbles.size();
-
- if (action == MotionEvent.ACTION_DOWN) {
- for (int i = 0; i < n_bubbles; i++) {
- Bubble b = bubbles.get(i);
- if (b.intersects(event.getX(), event.getY())) {
- b.dragged = true;
- b.last_drag = System.nanoTime();
- b.setPos(event.getX(), event.getY());
- b.target_scale = .8f;
- dragging_bubble = true;
- }
+ for (int i = 0; i < n_bubbles; i++) {
+ Bubble b = bubbles.get(i);
+ if (b.dragged) {
+ b.dragged = false;
+ b.target_scale = 1.f;
}
- } else if (action == MotionEvent.ACTION_MOVE) {
- long now = System.nanoTime();
- for (int i = 0; i < n_bubbles; i++) {
- Bubble b = bubbles.get(i);
- if (b.dragged) {
- float x = event.getX(), y = event.getY();
- float dt = (float) ((now - b.last_drag) / 1000000000.);
- float dx = x - b.getPosX(), dy = y - b.getPosY();
- b.last_drag = now;
-
- b.setPos(event.getX(), event.getY());
- /*
- * int hn = event.getHistorySize() - 2; Log.w(TAG, "event.getHistorySize() : " + event.getHistorySize()); if(hn > 0) { float
- * dx = x-event.getHistoricalX(hn); float dy = y-event.getHistoricalY(hn); float dt = event.getHistoricalEventTime(hn)/1000.f;
- */
- b.speed.x = dx / dt;
- b.speed.y = dy / dt;
- // Log.w(TAG, "onTouch dx:" + b.speed.x + " dy:" + b.speed.y);
- // }
- return true;
- }
- }
- } else if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) {
- for (int i = 0; i < n_bubbles; i++) {
- Bubble b = bubbles.get(i);
- if (b.dragged) {
- b.dragged = false;
- b.target_scale = 1.f;
- }
- }
- dragging_bubble = false;
}
+ dragging_bubble = false;
}
-
- return true;
+
+ return gDetector.onTouchEvent(event);
}
public boolean isDraggingBubble() {
@@ -261,4 +283,76 @@
}
}
+ class MyOnGestureListener implements OnGestureListener {
+ @Override
+ public boolean onDown(MotionEvent event) {
+ List<Bubble> bubbles = model.getBubbles();
+ final int n_bubbles = bubbles.size();
+ Log.d("Main", "onDown");
+ for (int i = 0; i < n_bubbles; i++) {
+ Bubble b = bubbles.get(i);
+ if (b.intersects(event.getX(), event.getY())) {
+ b.dragged = true;
+ b.last_drag = System.nanoTime();
+ b.setPos(event.getX(), event.getY());
+ b.target_scale = .8f;
+ dragging_bubble = true;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
+ Log.d("Main", "onFling");
+ return true;
+ }
+
+ @Override
+ public void onLongPress(MotionEvent e) {
+ Log.d("Main", "onLongPress");
+ }
+
+ @Override
+ public boolean onScroll(MotionEvent e1, MotionEvent event, float distanceX, float distanceY) {
+ Log.d("Main", "onScroll");
+ List<Bubble> bubbles = model.getBubbles();
+ final int n_bubbles = bubbles.size();
+ long now = System.nanoTime();
+ for (int i = 0; i < n_bubbles; i++) {
+ Bubble b = bubbles.get(i);
+ if (b.dragged) {
+ float x = event.getX(), y = event.getY();
+ float dt = (float) ((now - b.last_drag) / 1000000000.);
+ float dx = x - b.getPosX(), dy = y - b.getPosY();
+ b.last_drag = now;
+
+ b.setPos(event.getX(), event.getY());
+ /*
+ * int hn = event.getHistorySize() - 2; Log.w(TAG, "event.getHistorySize() : " + event.getHistorySize()); if(hn > 0) { float dx =
+ * x-event.getHistoricalX(hn); float dy = y-event.getHistoricalY(hn); float dt = event.getHistoricalEventTime(hn)/1000.f;
+ */
+ b.speed.x = dx / dt;
+ b.speed.y = dy / dt;
+ // Log.w(TAG, "onTouch dx:" + b.speed.x + " dy:" + b.speed.y);
+ // }
+ return true;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public void onShowPress(MotionEvent e) {
+ Log.d("Main", "onShowPress");
+
+ }
+
+ @Override
+ public boolean onSingleTapUp(MotionEvent e) {
+ Log.d("Main", "onSingleTapUp");
+ return true;
+ }
+ }
+
}
diff --git a/src/com/savoirfairelinux/sflphone/service/ConfigurationManagerCallback.java b/src/com/savoirfairelinux/sflphone/service/ConfigurationManagerCallback.java
index e0d4e58..48e1440 100644
--- a/src/com/savoirfairelinux/sflphone/service/ConfigurationManagerCallback.java
+++ b/src/com/savoirfairelinux/sflphone/service/ConfigurationManagerCallback.java
@@ -29,10 +29,9 @@
public class ConfigurationManagerCallback extends ConfigurationCallback {
private static final String TAG = "ConfigurationManagerCallback";
- private Context mContext;
+ private Context mContext;
static public final String SIGNAL_NAME = "signal-name";
- static public final String ACCOUNTS_LOADED = "accounts-loaded";
static public final String ACCOUNTS_CHANGED = "accounts-changed";
static public final String ACCOUNT_STATE_CHANGED = "account-state-changed";
@@ -41,23 +40,66 @@
}
@Override
- public void on_account_state_changed() {
+ public void on_accounts_changed() {
sendAccountsChangedMessage();
}
- private void sendAccountsChangedMessage() {
- Log.d(TAG, "Broadcast Accounts Changed signal");
- Intent intent = new Intent(ACCOUNTS_CHANGED);
- intent.putExtra(SIGNAL_NAME, ACCOUNTS_CHANGED);
- intent.putExtra("message", "Accounts Changed");
+ @Override
+ public void on_account_state_changed(String accoundID, int state) {
+ String strState = "";
+ switch (state){
+ case 0:
+ strState = "UNREGISTERED";
+ break;
+ case 1:
+ strState = "TRYING";
+ break;
+ case 2:
+ strState = "REGISTERED";
+ break;
+ case 3:
+ strState = "ERROR_GENERIC";
+ break;
+ case 4:
+ strState = "ERROR_AUTH";
+ break;
+ case 5:
+ strState = "ERROR_NETWORK";
+ break;
+ case 6:
+ strState = "ERROR_HOST";
+ break;
+ case 7:
+ strState = "ERROR_EXIST_STUN";
+ break;
+ case 8:
+ strState = "ERROR_NOT_ACCEPTABLE";
+ break;
+ case 9:
+ strState = "NUMBER_OF_STATES";
+ break;
+ }
+
+
+ sendAccountsStateChangedMessage(accoundID, strState, 0);
+ }
+
+ @Override
+ public void on_account_state_changed_with_code(String accoundID, String state, int code) {
+ sendAccountsStateChangedMessage(accoundID, state, code);
+ }
+
+ private void sendAccountsStateChangedMessage(String accoundID, String state, int code) {
+ Intent intent = new Intent(ACCOUNT_STATE_CHANGED);
+ intent.putExtra("Account", accoundID);
+ intent.putExtra("state", state);
+ intent.putExtra("code", code);
LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
}
- private void sendAccountStateChangedMessage() {
- Log.d(TAG, "Broadcast Account State Changed signal");
- Intent intent = new Intent(ACCOUNT_STATE_CHANGED);
- intent.putExtra(SIGNAL_NAME, ACCOUNTS_CHANGED);
- intent.putExtra("message", "Account State Changed");
+ private void sendAccountsChangedMessage() {
+ Intent intent = new Intent(ACCOUNTS_CHANGED);
LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
}
+
}
diff --git a/src/com/savoirfairelinux/sflphone/service/SipService.java b/src/com/savoirfairelinux/sflphone/service/SipService.java
index 240ddc3..9ab45a8 100644
--- a/src/com/savoirfairelinux/sflphone/service/SipService.java
+++ b/src/com/savoirfairelinux/sflphone/service/SipService.java
@@ -106,7 +106,6 @@
callFilter.addAction(CallManagerCallBack.NEW_CALL_CREATED);
callFilter.addAction(ConfigurationManagerCallback.ACCOUNT_STATE_CHANGED);
callFilter.addAction(ConfigurationManagerCallback.ACCOUNTS_CHANGED);
- callFilter.addAction(ConfigurationManagerCallback.ACCOUNTS_LOADED);
callFilter.addAction(CallManagerCallBack.INCOMING_TEXT);
LocalBroadcastManager.getInstance(this).registerReceiver(receiver, callFilter);
diff --git a/src/com/savoirfairelinux/sflphone/views/CallPaneLayout.java b/src/com/savoirfairelinux/sflphone/views/CallPaneLayout.java
index 6227732..4082bde 100644
--- a/src/com/savoirfairelinux/sflphone/views/CallPaneLayout.java
+++ b/src/com/savoirfairelinux/sflphone/views/CallPaneLayout.java
@@ -9,9 +9,17 @@
public class CallPaneLayout extends SlidingPaneLayout
{
- public CallFragment curFragment = null;
+ private CallFragment curFragment = null;
- public CallPaneLayout(Context context, AttributeSet attrs)
+ public CallFragment getCurFragment() {
+ return curFragment;
+ }
+
+ public void setCurFragment(CallFragment curFragment) {
+ this.curFragment = curFragment;
+ }
+
+ public CallPaneLayout(Context context, AttributeSet attrs)
{
super(context, attrs);
}