* #25232 Notification working
Overall design improvement
diff --git a/res/drawable/call_button.xml b/res/drawable/call_button.xml
index c9bce2b..e89bb18 100644
--- a/res/drawable/call_button.xml
+++ b/res/drawable/call_button.xml
@@ -4,7 +4,7 @@
<item android:state_pressed="true"
android:state_enabled="true" >
- <shape>
+ <shape android:shape="oval">
<gradient
android:startColor="#ccff00"
android:endColor="#99cc00"
@@ -23,7 +23,7 @@
</item>
<item android:state_enabled="false" >
- <shape>
+ <shape android:shape="oval">
<gradient
android:startColor="#cccccc"
android:endColor="#669900"
@@ -42,7 +42,7 @@
</item>
<item>
- <shape>
+ <shape android:shape="oval">
<gradient
android:startColor="#99cc00"
android:endColor="#669900"
diff --git a/res/drawable/item_call_pressed.xml b/res/drawable/item_call_pressed.xml
index a4ec627..2c83878 100644
--- a/res/drawable/item_call_pressed.xml
+++ b/res/drawable/item_call_pressed.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
- <solid android:color="@color/light"/>
+ <solid android:color="@color/darker_gray"/>
<padding
android:bottom="10dp"
diff --git a/res/layout/activity_sflphone_home.xml b/res/layout/activity_sflphone_home.xml
index 9f59dc9..d4221f2 100644
--- a/res/layout/activity_sflphone_home.xml
+++ b/res/layout/activity_sflphone_home.xml
@@ -68,6 +68,7 @@
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
+ android:background="@color/lighter_gray"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
@@ -142,7 +143,7 @@
android:id="@+id/contacts_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:background="#FFFFFF" />
+ android:background="@color/lighter_gray" />
</com.savoirfairelinux.sflphone.views.CustomSlidingDrawer>
</RelativeLayout>
diff --git a/res/layout/clearable_edit_text.xml b/res/layout/clearable_edit_text.xml
index dc9d71d..4915d9c 100644
--- a/res/layout/clearable_edit_text.xml
+++ b/res/layout/clearable_edit_text.xml
@@ -5,8 +5,8 @@
<EditText
android:id="@+id/clearable_edit"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
+ android:layout_width="match_parent"
+ android:layout_height="50dp"
android:hint="Type phone number"
android:paddingRight="35dip" />
diff --git a/res/layout/frag_call_element.xml b/res/layout/frag_call_element.xml
index 4dd9d6f..a72702c 100644
--- a/res/layout/frag_call_element.xml
+++ b/res/layout/frag_call_element.xml
@@ -45,23 +45,12 @@
android:drawSelectorOnTop="false" />
-
- <TextView
- android:id="@id/android:empty"
- android:layout_width="match_parent"
+ <Button
+ android:id="@+id/access_callactivity"
+ android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
- android:gravity="center"
- android:text="No data" />
-
- <!-- <Button -->
- <!-- android:id="@+id/button_attended" -->
- <!-- android:layout_width="wrap_content" -->
- <!-- android:layout_height="wrap_content" -->
- <!-- android:layout_above="@+id/phoneNumberTextEntry" -->
- <!-- android:layout_alignParentLeft="true" -->
- <!-- android:text="Attended transfer" /> -->
-
+ android:text="Current Calls" />
<!-- <Button -->
<!-- android:id="@+id/button_conf" -->
diff --git a/res/layout/frag_contact_list.xml b/res/layout/frag_contact_list.xml
index f84c00b..1002096 100644
--- a/res/layout/frag_contact_list.xml
+++ b/res/layout/frag_contact_list.xml
@@ -36,16 +36,13 @@
android:focusable="false"
android:focusableInTouchMode="false"
android:orientation="vertical"
- android:paddingLeft="8dp"
- android:paddingRight="8dp" >
+ android:padding="10dp" >
-
<ListView
android:id="@+id/contacts_list"
style="@style/CallElementList"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:background="#DDDDDD"
android:clickable="true"
android:focusable="true"
android:focusableInTouchMode="true" />
diff --git a/res/layout/frag_dialing.xml b/res/layout/frag_dialing.xml
index c865285..ae2dbdd 100644
--- a/res/layout/frag_dialing.xml
+++ b/res/layout/frag_dialing.xml
@@ -11,21 +11,12 @@
android:layout_height="wrap_content"
android:layout_alignParentTop="true" />
- <ImageButton
- android:id="@+id/buttonCall"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_alignParentBottom="true"
- android:layout_margin="10dp"
- android:background="@drawable/call_button"
- android:gravity="center_vertical"
- android:onClick="onClick"
- android:src="@drawable/ic_call" />
-
<LinearLayout
android:id="@+id/keyboard_choice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_marginTop="15dp"
+ android:layout_marginBottom="15dp"
android:layout_alignLeft="@+id/textField"
android:layout_alignRight="@+id/textField"
android:layout_below="@+id/textField"
@@ -51,7 +42,17 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/keyboard_choice" />
-
-
+
+ <ImageButton
+ android:id="@+id/buttonCall"
+ android:layout_width="60dp"
+ android:layout_height="60dp"
+ android:layout_below="@+id/account_selection"
+ android:layout_margin="10dp"
+ android:layout_centerHorizontal="true"
+ android:adjustViewBounds="true"
+ android:background="@drawable/call_button"
+ android:gravity="center_vertical"
+ android:src="@drawable/ic_call" />
</RelativeLayout>
\ No newline at end of file
diff --git a/res/layout/item_contact.xml b/res/layout/item_contact.xml
index 91e565e..fcab27c 100644
--- a/res/layout/item_contact.xml
+++ b/res/layout/item_contact.xml
@@ -32,7 +32,7 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/contactview"
- android:background="@drawable/box_border"
+ android:background="@drawable/item_call_selector"
android:layout_width="match_parent"
android:layout_height="match_parent" >
@@ -46,28 +46,13 @@
android:id="@+id/display_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_alignParentTop="true"
+ android:layout_alignTop="@+id/photo"
+ android:layout_alignBottom="@+id/photo"
+ android:gravity="center_vertical"
android:layout_toRightOf="@+id/photo"
+ android:layout_marginLeft="5dp"
android:textAppearance="?android:attr/textAppearanceMedium" />
- <TextView
- android:id="@+id/phones"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_below="@+id/display_name"
- android:layout_toRightOf="@+id/photo"
- android:text="Small Text"
- android:textAppearance="?android:attr/textAppearanceSmall" />
-
- <TextView
- android:id="@+id/callstate"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_below="@+id/display_name"
- android:layout_toRightOf="@+id/phones"
- android:paddingBottom="@dimen/padding_small"
- android:paddingLeft="@dimen/padding_small"
- android:textAppearance="?android:attr/textAppearanceSmall" />
<!-- <ImageButton -->
<!-- android:id="@+id/toggleButton1" -->
diff --git a/res/layout/item_history.xml b/res/layout/item_history.xml
index 62359c8..95383cd 100644
--- a/res/layout/item_history.xml
+++ b/res/layout/item_history.xml
@@ -34,7 +34,7 @@
android:id="@+id/contactview"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:background="@drawable/box_border" >
+ android:background="@drawable/item_call_selector" >
<ImageButton
android:id="@+id/toggleButton1"
diff --git a/src/com/savoirfairelinux/sflphone/adapters/CallElementAdapter.java b/src/com/savoirfairelinux/sflphone/adapters/CallElementAdapter.java
index 3214a32..a9f88a2 100644
--- a/src/com/savoirfairelinux/sflphone/adapters/CallElementAdapter.java
+++ b/src/com/savoirfairelinux/sflphone/adapters/CallElementAdapter.java
@@ -52,8 +52,8 @@
entryView = new CallElementView();
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);
+// 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
diff --git a/src/com/savoirfairelinux/sflphone/client/CallActivity.java b/src/com/savoirfairelinux/sflphone/client/CallActivity.java
index 41c802b..d0eac58 100644
--- a/src/com/savoirfairelinux/sflphone/client/CallActivity.java
+++ b/src/com/savoirfairelinux/sflphone/client/CallActivity.java
@@ -57,7 +57,6 @@
import com.savoirfairelinux.sflphone.fragments.CallFragment;
import com.savoirfairelinux.sflphone.fragments.CallListFragment;
import com.savoirfairelinux.sflphone.interfaces.CallInterface;
-import com.savoirfairelinux.sflphone.model.CallContact;
import com.savoirfairelinux.sflphone.model.SipCall;
import com.savoirfairelinux.sflphone.model.SipCall.state;
import com.savoirfairelinux.sflphone.service.CallManagerCallBack;
@@ -69,8 +68,6 @@
static final String TAG = "CallActivity";
private ISipService service;
- private String pendingAction = null;
-
private ExecutorService infos_fetcher = Executors.newCachedThreadPool();
CallReceiver receiver;
@@ -153,12 +150,22 @@
protected void onPause() {
super.onPause();
unregisterReceiver(receiver);
+ try {
+ service.createNotification();
+ } catch (RemoteException e) {
+ Log.e(TAG, e.toString());
+ }
}
@Override
protected void onDestroy() {
// Log.i(TAG, "Destroying Call Activity for call " + mCall.getCallId());
// LocalBroadcastManager.getInstance(this).unregisterReceiver(mMessageReceiver);
+ try {
+ service.destroyNotification();
+ } catch (RemoteException e) {
+ Log.e(TAG, e.toString());
+ }
unbindService(mConnection);
super.onDestroy();
@@ -174,8 +181,7 @@
mCurrentCallFragment.setArguments(getIntent().getExtras());
slidingPaneLayout.curFragment = mCurrentCallFragment;
getIntent().getExtras();
- // SipCall info = getIntent().getExtras().getParcelable("CallInfo");
- // mCallPagerAdapter.addCall(info.mCallID, newCall);
+ mCallsFragment.update();
getFragmentManager().beginTransaction().replace(R.id.ongoingcall_pane, mCurrentCallFragment).commit();
}
@@ -223,45 +229,6 @@
}
-
- // if (newState.equals("INCOMING")) {
- // fr.changeCallState(SipCall.state.CALL_STATE_INCOMING);
- //
- // } else if (newState.equals("RINGING")) {
- // fr.changeCallState(SipCall.state.CALL_STATE_RINGING);
- //
- // } else if (newState.equals("CURRENT")) {
- // fr.changeCallState(SipCall.state.CALL_STATE_CURRENT);
- //
- // } else if (newState.equals("HUNGUP")) {
- // // mCallPagerAdapter.remove(callID);
- // // if (mCallPagerAdapter.getCount() == 0) {
- // // finish();
- // // }
- //
- // } else if (newState.equals("BUSY")) {
- // // mCallPagerAdapter.remove(callID);
- // // if (mCallPagerAdapter.getCount() == 0) {
- // // finish();
- // // }
- //
- // } else if (newState.equals("FAILURE")) {
- // // mCallPagerAdapter.remove(callID);
- // // if (mCallPagerAdapter.getCount() == 0) {
- // // finish();
- // // }
- //
- // } else if (newState.equals("HOLD")) {
- // fr.changeCallState(SipCall.state.CALL_STATE_HOLD);
- //
- // } else if (newState.equals("UNHOLD")) {
- // fr.changeCallState(SipCall.state.CALL_STATE_CURRENT);
- //
- // } else {
- // fr.changeCallState(SipCall.state.CALL_STATE_NONE);
- //
- // }
-
Log.w(TAG, "processCallStateChangedSignal " + newState);
}
@@ -288,7 +255,7 @@
getFragmentManager().beginTransaction().replace(R.id.ongoingcall_pane, mCurrentCallFragment).commit();
slidingPaneLayout.curFragment = mCurrentCallFragment;
- slidingPaneLayout.openPane();
+ slidingPaneLayout.closePane();
}
diff --git a/src/com/savoirfairelinux/sflphone/client/RelativePositioningLayout.java b/src/com/savoirfairelinux/sflphone/client/RelativePositioningLayout.java
deleted file mode 100644
index 3e5f611..0000000
--- a/src/com/savoirfairelinux/sflphone/client/RelativePositioningLayout.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.savoirfairelinux.sflphone.client;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.widget.RelativeLayout;
-
-public class RelativePositioningLayout extends RelativeLayout
-{
- public RelativePositioningLayout(Context context, AttributeSet attrs)
- {
- super(context, attrs);
- }
-
- public float getXFraction()
- {
- return getX() / getWidth();
- }
-
- public void setXFraction(float xFraction)
- {
- final int width = getWidth();
- setX((width > 0) ? (xFraction * width) : -9999);
- }
-}
\ No newline at end of file
diff --git a/src/com/savoirfairelinux/sflphone/client/SFLPhoneHomeActivity.java b/src/com/savoirfairelinux/sflphone/client/SFLPhoneHomeActivity.java
index ee5e2aa..fedcec9 100644
--- a/src/com/savoirfairelinux/sflphone/client/SFLPhoneHomeActivity.java
+++ b/src/com/savoirfairelinux/sflphone/client/SFLPhoneHomeActivity.java
@@ -33,10 +33,8 @@
import java.util.HashMap;
-import android.app.ActionBar;
import android.app.Activity;
import android.app.Fragment;
-import android.app.FragmentTransaction;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@@ -74,18 +72,20 @@
import com.savoirfairelinux.sflphone.service.SipService;
import com.savoirfairelinux.sflphone.views.CustomSlidingDrawer;
-public class SFLPhoneHomeActivity extends Activity implements ActionBar.TabListener, DialingFragment.Callbacks, ContactListFragment.Callbacks,
+public class SFLPhoneHomeActivity extends Activity implements DialingFragment.Callbacks, ContactListFragment.Callbacks,
CallElementListFragment.Callbacks, HistoryFragment.Callbacks, CallInterface {
SectionsPagerAdapter mSectionsPagerAdapter = null;
static final String TAG = "SFLPhoneHomeActivity";
+ /**
+ * Fragments used
+ */
private ContactListFragment mContactsFragment = null;
private DialingFragment mDialingFragment = null;
private CallElementListFragment mCallElementList = null;
private HistoryFragment mHistorySectionFragment = null;
-
- Fragment fMenu;
+ private Fragment fMenu;
private boolean mBound = false;
private ISipService service;
@@ -93,7 +93,7 @@
private CharSequence mDrawerTitle;
private CharSequence mTitle;
- private static final int REQUEST_CODE_PREFERENCES = 1;
+ 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;
@@ -111,7 +111,6 @@
CallReceiver receiver;
-
private TabHost mTabHost;
// public SFLPhoneHome extends Activity implements ActionBar.TabListener, OnClickListener
@@ -138,8 +137,8 @@
receiver = new CallReceiver(this);
- String libraryPath = getApplicationInfo().dataDir + "/lib";
- Log.i(TAG, libraryPath);
+ // String libraryPath = getApplicationInfo().dataDir + "/lib";
+ // Log.i(TAG, libraryPath);
// Bind to LocalService
if (!mBound) {
@@ -191,7 +190,6 @@
mDrawer.setmTrackHandle(findViewById(R.id.handle_title));
-
// Set up the ViewPager with the sections adapter.
mViewPager = (ViewPager) findViewById(R.id.pager);
mViewPager.setAdapter(mSectionsPagerAdapter);
@@ -242,17 +240,28 @@
private void initialiseTabHost(Bundle args) {
-
mTabHost.setup();
TabInfo tabInfo = null;
- SFLPhoneHomeActivity.AddTab(this, this.mTabHost, this.mTabHost.newTabSpec("Tab1").setIndicator(mSectionsPagerAdapter.getPageTitle(0),getResources().getDrawable(mSectionsPagerAdapter.getIconOf(0))), (tabInfo = new TabInfo("Tab1",
- DialingFragment.class, args)));
+ SFLPhoneHomeActivity
+ .AddTab(this,
+ this.mTabHost,
+ this.mTabHost.newTabSpec("Tab1").setIndicator(mSectionsPagerAdapter.getPageTitle(0),
+ getResources().getDrawable(mSectionsPagerAdapter.getIconOf(0))), (tabInfo = new TabInfo("Tab1",
+ DialingFragment.class, args)));
this.mapTabInfo.put(tabInfo.tag, tabInfo);
- SFLPhoneHomeActivity.AddTab(this, this.mTabHost, this.mTabHost.newTabSpec("Tab2").setIndicator(mSectionsPagerAdapter.getPageTitle(1),getResources().getDrawable(mSectionsPagerAdapter.getIconOf(1))), (tabInfo = new TabInfo("Tab2",
- CallElementListFragment.class, args)));
+ SFLPhoneHomeActivity.AddTab(
+ this,
+ this.mTabHost,
+ this.mTabHost.newTabSpec("Tab2").setIndicator(mSectionsPagerAdapter.getPageTitle(1),
+ getResources().getDrawable(mSectionsPagerAdapter.getIconOf(1))), (tabInfo = new TabInfo("Tab2",
+ CallElementListFragment.class, args)));
this.mapTabInfo.put(tabInfo.tag, tabInfo);
- SFLPhoneHomeActivity.AddTab(this, this.mTabHost, this.mTabHost.newTabSpec("Tab3").setIndicator(mSectionsPagerAdapter.getPageTitle(2),getResources().getDrawable(mSectionsPagerAdapter.getIconOf(2))), (tabInfo = new TabInfo("Tab3",
- HistoryFragment.class, args)));
+ SFLPhoneHomeActivity
+ .AddTab(this,
+ this.mTabHost,
+ this.mTabHost.newTabSpec("Tab3").setIndicator(mSectionsPagerAdapter.getPageTitle(2),
+ getResources().getDrawable(mSectionsPagerAdapter.getIconOf(2))), (tabInfo = new TabInfo("Tab3",
+ HistoryFragment.class, args)));
this.mapTabInfo.put(tabInfo.tag, tabInfo);
mTabHost.setOnTabChangedListener(new OnTabChangeListener() {
@@ -295,12 +304,14 @@
protected void onPause() {
super.onPause();
unregisterReceiver(receiver);
+
}
/* activity is no longer visible */
@Override
protected void onStop() {
super.onStop();
+
}
/* activity finishes itself or is being killed by the system */
@@ -309,8 +320,15 @@
/* stop the service, if no other bound user, no need to check if it is running */
if (mBound) {
Log.i(TAG, "onDestroy: Unbinding service...");
+ try {
+ service.createNotification();
+
+ } catch (RemoteException e) {
+ Log.e(TAG, e.toString());
+ }
unbindService(mConnection);
mBound = false;
+
}
super.onDestroy();
@@ -333,10 +351,12 @@
public void onServiceConnected(ComponentName className, IBinder binder) {
service = ISipService.Stub.asInterface(binder);
+ try {
+ service.destroyNotification();
+ } catch (RemoteException e) {
+ Log.e(TAG, e.toString());
+ }
mBound = true;
- mCallElementList.onServiceSipBinded(service);
- mHistorySectionFragment.onServiceSipBinded(service);
- mDialingFragment.onServiceSipBinded(service);
Log.d(TAG, "Service connected service=" + service);
}
@@ -366,34 +386,17 @@
switch (requestCode) {
case REQUEST_CODE_PREFERENCES:
- mCallElementList.onServiceSipBinded(service);
break;
case REQUEST_CODE_CALL:
-
+ Log.w(TAG, "Result out of CallActivity");
break;
}
}
-
- @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");
- }
-
@Override
public void onCallSelected(SipCall c) {
- // launchCallActivity(c.mCallInfo);
+ launchCallActivity(c, "display");
}
@@ -440,14 +443,11 @@
SipCall.SipCallBuilder callBuilder = SipCall.SipCallBuilder.getInstance();
try {
- callBuilder.startCallCreation().setAccountID(service.getAccountList().get(0).toString()).setCallType(SipCall.state.CALL_TYPE_OUTGOING);
+ callBuilder.startCallCreation().setAccountID(service.getAccountList().get(1).toString()).setCallType(SipCall.state.CALL_TYPE_OUTGOING);
+ callBuilder.addContact(c);
+ launchCallActivity(callBuilder.build(), "call");
} catch (RemoteException e1) {
Log.e(TAG, e1.toString());
- }
- callBuilder.addContact(c);
-
- try {
- launchCallActivity(callBuilder.build(), "call");
} catch (Exception e) {
Log.e(TAG, e.toString());
}
@@ -473,7 +473,7 @@
public void onContactDragged() {
mDrawer.close();
- getActionBar().setSelectedNavigationItem(ACTION_BAR_TAB_CALL);
+ mTabHost.setCurrentTab(1);
}
diff --git a/src/com/savoirfairelinux/sflphone/client/receiver/IncomingReceiver.java b/src/com/savoirfairelinux/sflphone/client/receiver/IncomingReceiver.java
new file mode 100644
index 0000000..1fa217a
--- /dev/null
+++ b/src/com/savoirfairelinux/sflphone/client/receiver/IncomingReceiver.java
@@ -0,0 +1,87 @@
+package com.savoirfairelinux.sflphone.client.receiver;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+import android.os.Vibrator;
+import android.util.Log;
+
+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.SipService;
+
+public class IncomingReceiver extends BroadcastReceiver{
+
+ static final String TAG = CallReceiver.class.getSimpleName();
+
+ SipService callback;
+
+ public IncomingReceiver(SipService 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());
+ } else if (intent.getAction().contentEquals(ConfigurationManagerCallback.ACCOUNTS_LOADED)) {
+ Log.i(TAG, "Received" + intent.getAction());
+ } else if (intent.getAction().contentEquals(ConfigurationManagerCallback.ACCOUNTS_CHANGED)) {
+ Log.i(TAG, "Received" + intent.getAction());
+ } else if (intent.getAction().contentEquals(CallManagerCallBack.INCOMING_TEXT)) {
+ Log.i(TAG, "Received" + intent.getAction());
+ callback.sendBroadcast(intent);
+ } else if (intent.getAction().contentEquals(CallManagerCallBack.INCOMING_CALL)) {
+ Bundle b = intent.getBundleExtra("com.savoirfairelinux.sflphone.service.newcall");
+
+ SipCall.SipCallBuilder callBuilder = SipCall.SipCallBuilder.getInstance();
+ callBuilder.startCallCreation(b.getString("CallID")).setAccountID(b.getString("AccountID"))
+ .setCallState(SipCall.state.CALL_STATE_RINGING).setCallType(SipCall.state.CALL_TYPE_INCOMING);
+ callBuilder.addContact(CallContact.ContactBuilder.buildUnknownContact(b.getString("From")));
+
+ Intent toSend = new Intent(CallManagerCallBack.INCOMING_CALL);
+ try {
+ SipCall newCall = callBuilder.build();
+ toSend.putExtra("newcall", newCall);
+ callback.getCurrent_calls().put(newCall.getCallId(), newCall);
+ callback.sendBroadcast(toSend);
+ } catch (Exception e) {
+ Log.e(TAG, e.toString());
+ }
+
+ } else if (intent.getAction().contentEquals(CallManagerCallBack.CALL_STATE_CHANGED)) {
+
+ Bundle b = intent.getBundleExtra("com.savoirfairelinux.sflphone.service.newstate");
+ String newState = b.getString("State");
+ if (newState.equals("INCOMING")) {
+ callback.getCurrent_calls().get(b.getString("CallID")).setCallState(SipCall.state.CALL_STATE_INCOMING);
+ } else if (newState.equals("RINGING")) {
+ callback.getCurrent_calls().get(b.getString("CallID")).setCallState(SipCall.state.CALL_STATE_RINGING);
+ } else if (newState.equals("CURRENT")) {
+ callback.getCurrent_calls().get(b.getString("CallID")).setCallState(SipCall.state.CALL_STATE_CURRENT);
+ } else if (newState.equals("HUNGUP")) {
+ callback.getCurrent_calls().remove(b.getString("CallID"));
+ } else if (newState.equals("BUSY")) {
+ callback.getCurrent_calls().remove(b.getString("CallID"));
+ } else if (newState.equals("FAILURE")) {
+ callback.getCurrent_calls().remove(b.getString("CallID"));
+ } else if (newState.equals("HOLD")) {
+ callback.getCurrent_calls().get(b.getString("CallID")).setCallState(SipCall.state.CALL_STATE_HOLD);
+ } else if (newState.equals("UNHOLD")) {
+ callback.getCurrent_calls().get(b.getString("CallID")).setCallState(SipCall.state.CALL_STATE_CURRENT);
+ } else {
+ callback.getCurrent_calls().get(b.getString("CallID")).setCallState(SipCall.state.CALL_STATE_NONE);
+ }
+
+ callback.sendBroadcast(intent);
+ } else if (intent.getAction().contentEquals(CallManagerCallBack.NEW_CALL_CREATED)) {
+ Log.i(TAG, "Received" + intent.getAction());
+ }
+
+ }
+}
diff --git a/src/com/savoirfairelinux/sflphone/fragments/CallElementListFragment.java b/src/com/savoirfairelinux/sflphone/fragments/CallElementListFragment.java
index 316b763..361adc1 100644
--- a/src/com/savoirfairelinux/sflphone/fragments/CallElementListFragment.java
+++ b/src/com/savoirfairelinux/sflphone/fragments/CallElementListFragment.java
@@ -31,6 +31,7 @@
package com.savoirfairelinux.sflphone.fragments;
import java.util.ArrayList;
+import java.util.HashMap;
import android.app.Activity;
import android.app.AlertDialog;
@@ -39,25 +40,25 @@
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
-import android.provider.ContactsContract.CommonDataKinds.Phone;
-import android.provider.ContactsContract.CommonDataKinds.SipAddress;
-import android.provider.ContactsContract.Contacts;
+import android.os.RemoteException;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
+import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemLongClickListener;
import android.widget.Button;
import android.widget.ListView;
-import android.widget.ToggleButton;
+import android.widget.Toast;
import com.savoirfairelinux.sflphone.R;
import com.savoirfairelinux.sflphone.adapters.CallElementAdapter;
+import com.savoirfairelinux.sflphone.client.SFLPhoneHomeActivity;
import com.savoirfairelinux.sflphone.client.SFLPhonePreferenceActivity;
import com.savoirfairelinux.sflphone.model.SipCall;
import com.savoirfairelinux.sflphone.service.ISipService;
@@ -69,13 +70,9 @@
private static final String TAG = CallElementListFragment.class.getSimpleName();
private CallElementAdapter mAdapter;
- private ISipService service;
-
- Button attendedTransfer, conference;
private Callbacks mCallbacks = sDummyCallbacks;
- private boolean isReady = false;
-
+ Button access_calls;
/**
* A dummy implementation of the {@link Callbacks} interface that does nothing. Used only when this fragment is not attached to an activity.
@@ -87,7 +84,7 @@
@Override
public ISipService getService() {
- // TODO Auto-generated method stub
+ Log.i(TAG, "I'm a dummy");
return null;
}
};
@@ -112,6 +109,26 @@
}
mCallbacks = (Callbacks) activity;
+
+
+ }
+
+ @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();
+ Log.i(TAG, "Call size "+calls.size());
+ access_calls.setText(calls.size()+" on going calls");
+
+
+ } catch (RemoteException e) {
+ Log.e(TAG, e.toString());
+ }
+ }
+
}
@Override
@@ -147,7 +164,7 @@
*/
public void addCall(SipCall c) {
-// Log.i(TAG, "Adding call " + c.mCallInfo.mDisplayName);
+ // Log.i(TAG, "Adding call " + c.mCallInfo.mDisplayName);
if (mAdapter == null) {
Log.w(TAG, "mAdapter is null");
return;
@@ -164,6 +181,7 @@
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mAdapter = new CallElementAdapter(getActivity(), new ArrayList<SipCall>());
+
}
@Override
@@ -194,23 +212,23 @@
@Override
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;
-// }
+ // 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();
@@ -245,7 +263,7 @@
switch (item.getItemId()) {
case R.id.menu_settings:
Intent launchPreferencesIntent = new Intent().setClass(getActivity(), SFLPhonePreferenceActivity.class);
- startActivityForResult(launchPreferencesIntent, REQUEST_CODE_PREFERENCES);
+ startActivityForResult(launchPreferencesIntent, SFLPhoneHomeActivity.REQUEST_CODE_PREFERENCES);
break;
}
@@ -265,6 +283,29 @@
Log.i(TAG, "onCreateView");
View inflatedView = inflater.inflate(R.layout.frag_call_element, container, false);
+ access_calls = (Button) inflatedView.findViewById(R.id.access_callactivity);
+
+ access_calls.setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ HashMap<String, SipCall> calls;
+ try {
+ calls = (HashMap<String, SipCall>) mCallbacks.getService().getCallList();
+ if (calls.size() == 0) {
+ Toast.makeText(getActivity(), "No calls", Toast.LENGTH_SHORT).show();
+ } else {
+ mCallbacks.onCallSelected((SipCall) calls.values().toArray()[0]);
+ }
+ } catch (RemoteException e) {
+ Log.e(TAG, e.toString());
+ }
+
+ }
+ });
+
+
+
// ((Button) inflatedView.findViewById(R.id.button_attended)).setOnClickListener(new OnClickListener() {
//
// @Override
@@ -320,25 +361,8 @@
// }
// });
- isReady = true;
- if (mCallbacks.getService() != null) {
-
- onServiceSipBinded(mCallbacks.getService());
- }
return inflatedView;
}
- /**
- * Called by activity to pass a reference to sipservice to Fragment.
- *
- * @param isip
- */
- public void onServiceSipBinded(ISipService isip) {
-
- if (isReady) {
- service = isip;
- }
-
- }
}
diff --git a/src/com/savoirfairelinux/sflphone/fragments/MenuFragment.java b/src/com/savoirfairelinux/sflphone/fragments/MenuFragment.java
index 93ab1e5..7ac0f81 100644
--- a/src/com/savoirfairelinux/sflphone/fragments/MenuFragment.java
+++ b/src/com/savoirfairelinux/sflphone/fragments/MenuFragment.java
@@ -2,15 +2,21 @@
import android.app.Activity;
import android.app.Fragment;
+import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
+import android.widget.Toast;
import com.savoirfairelinux.sflphone.R;
import com.savoirfairelinux.sflphone.adapters.MenuAdapter;
+import com.savoirfairelinux.sflphone.client.SFLPhoneHomeActivity;
+import com.savoirfairelinux.sflphone.client.SFLPhonePreferenceActivity;
public class MenuFragment extends Fragment {
@@ -49,11 +55,23 @@
}
+
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
View inflatedView = inflater.inflate(R.layout.frag_menu, parent, false);
((ListView) inflatedView.findViewById(R.id.listView)).setAdapter(mAdapter);
+ ((ListView) inflatedView.findViewById(R.id.listView)).setOnItemClickListener(new OnItemClickListener() {
+
+ @Override
+ public void onItemClick(AdapterView<?> arg0, View arg1, int pos, long arg3) {
+ if(pos == 1 || pos == 2 || pos == 3){
+ Intent launchPreferencesIntent = new Intent().setClass(getActivity(), SFLPhonePreferenceActivity.class);
+ startActivityForResult(launchPreferencesIntent, SFLPhoneHomeActivity.REQUEST_CODE_PREFERENCES);
+ }
+
+ }
+ });
return inflatedView;
}
diff --git a/src/com/savoirfairelinux/sflphone/model/BubblesView.java b/src/com/savoirfairelinux/sflphone/model/BubblesView.java
index f764b34..c131016 100644
--- a/src/com/savoirfairelinux/sflphone/model/BubblesView.java
+++ b/src/com/savoirfairelinux/sflphone/model/BubblesView.java
@@ -17,261 +17,248 @@
import android.view.View;
import android.view.View.OnTouchListener;
-public class BubblesView extends SurfaceView implements SurfaceHolder.Callback, OnTouchListener
-{
- private static final String TAG = BubblesView.class.getSimpleName();
+public class BubblesView extends SurfaceView implements SurfaceHolder.Callback, OnTouchListener {
+ private static final String TAG = BubblesView.class.getSimpleName();
- private BubblesThread thread = null;
- private BubbleModel model;
+ private BubblesThread thread = null;
+ private BubbleModel model;
- private Paint attractor_paint = new Paint();
- private Paint name_paint = new Paint(Paint.ANTI_ALIAS_FLAG);
+ private Paint attractor_paint = new Paint();
+ private Paint name_paint = new Paint(Paint.ANTI_ALIAS_FLAG);
- private float density;
- private float textDensity;
+ private float density;
+ private float textDensity;
- private boolean dragging_bubble = false;
+ private boolean dragging_bubble = false;
- public BubblesView(Context context, AttributeSet attrs)
- {
- super(context, attrs);
+ public BubblesView(Context context, AttributeSet attrs) {
+ super(context, attrs);
- density = getResources().getDisplayMetrics().density;
- textDensity = getResources().getDisplayMetrics().scaledDensity;
+ density = getResources().getDisplayMetrics().density;
+ textDensity = getResources().getDisplayMetrics().scaledDensity;
- SurfaceHolder holder = getHolder();
- holder.addCallback(this);
+ SurfaceHolder holder = getHolder();
+ holder.addCallback(this);
- // create thread only; it's started in surfaceCreated()
- createThread();
+ // create thread only; it's started in surfaceCreated()
+ createThread();
- setOnTouchListener(this);
- setFocusable(true);
+ setOnTouchListener(this);
+ setFocusable(true);
- attractor_paint.setColor(Color.RED);
- //attractor_paint.set
- name_paint.setTextSize(18 * textDensity);
- name_paint.setColor(0xFF303030);
- name_paint.setTextAlign(Align.CENTER);
- }
+ attractor_paint.setColor(Color.RED);
+ // attractor_paint.set
+ name_paint.setTextSize(18 * textDensity);
+ name_paint.setColor(0xFF303030);
+ name_paint.setTextAlign(Align.CENTER);
+ }
- private void createThread()
- {
- if (thread != null)
- return;
- thread = new BubblesThread(getHolder(), getContext(), new Handler() {
- @Override
- public void handleMessage(Message m)
- {
- /* mStatusText.setVisibility(m.getData().getInt("viz"));
- mStatusText.setText(m.getData().getString("text"));*/
- }
- });
- if (model != null)
- thread.setModel(model);
- }
+ private void createThread() {
+ if (thread != null)
+ return;
+ thread = new BubblesThread(getHolder(), getContext(), new Handler() {
+ @Override
+ public void handleMessage(Message m) {
+ /*
+ * mStatusText.setVisibility(m.getData().getInt("viz")); mStatusText.setText(m.getData().getString("text"));
+ */
+ }
+ });
+ if (model != null)
+ thread.setModel(model);
+ }
- public void setModel(BubbleModel model)
- {
- this.model = model;
- thread.setModel(model);
- }
+ public void setModel(BubbleModel model) {
+ this.model = model;
+ thread.setModel(model);
+ }
- /*@Override
- public void onWindowFocusChanged(boolean hasWindowFocus) {
- if (!hasWindowFocus) {
- thread.pause();
- }
- }*/
+ /*
+ * @Override public void onWindowFocusChanged(boolean hasWindowFocus) { if (!hasWindowFocus) { thread.pause(); } }
+ */
- @Override
- public void surfaceChanged(SurfaceHolder holder, int format, int width, int height)
- {
- Log.w(TAG, "surfaceChanged "+width+"-"+height);
- thread.setSurfaceSize(width, height);
- }
+ @Override
+ public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
+ Log.w(TAG, "surfaceChanged " + width + "-" + height);
+ thread.setSurfaceSize(width, height);
+ }
- /*
- * Callback invoked when the Surface has been created and is ready to be
- * used.
- */
- @Override
- public void surfaceCreated(SurfaceHolder holder)
- {
- // start the thread here so that we don't busy-wait in run()
- // waiting for the surface to be created
- createThread();
+ /*
+ * Callback invoked when the Surface has been created and is ready to be used.
+ */
+ @Override
+ public void surfaceCreated(SurfaceHolder holder) {
+ // start the thread here so that we don't busy-wait in run()
+ // waiting for the surface to be created
+ createThread();
- Log.w(TAG, "surfaceCreated");
- thread.setRunning(true);
- thread.start();
- }
+ Log.w(TAG, "surfaceCreated");
+ thread.setRunning(true);
+ thread.start();
+ }
- /*
- * Callback invoked when the Surface has been destroyed and must no longer
- * be touched. WARNING: after this method returns, the Surface/Canvas must
- * never be touched again!
- */
- @Override
- public void surfaceDestroyed(SurfaceHolder holder)
- {
- // we have to tell thread to shut down & wait for it to finish, or else
- // it might touch the Surface after we return and explode
- Log.w(TAG, "surfaceDestroyed");
- boolean retry = true;
- thread.setRunning(false);
- while (retry) {
- try {
- thread.join();
- retry = false;
- } catch (InterruptedException e) {
- }
- }
- thread = null;
- }
+ /*
+ * Callback invoked when the Surface has been destroyed and must no longer be touched. WARNING: after this method returns, the Surface/Canvas must
+ * never be touched again!
+ */
+ @Override
+ public void surfaceDestroyed(SurfaceHolder holder) {
+ // we have to tell thread to shut down & wait for it to finish, or else
+ // it might touch the Surface after we return and explode
+ Log.w(TAG, "surfaceDestroyed");
+ boolean retry = true;
+ thread.setRunning(false);
+ while (retry) {
+ try {
+ thread.join();
+ retry = false;
+ } catch (InterruptedException e) {
+ }
+ }
+ thread = null;
+ }
- @Override
- public boolean onTouch(View v, MotionEvent event)
- {
- Log.w(TAG, "onTouch " + event.getAction());
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ Log.w(TAG, "onTouch " + event.getAction());
- int action = event.getActionMasked();
+ int action = event.getActionMasked();
- synchronized (model) {
- List<Bubble> bubbles = model.getBubbles();
- final int n_bubbles = bubbles.size();
+ 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;
+ 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;
- }
- }
+ 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;
- }
+ return true;
+ }
- public boolean isDraggingBubble()
- {
- return dragging_bubble;
- }
+ public boolean isDraggingBubble() {
+ return dragging_bubble;
+ }
- class BubblesThread extends Thread
- {
- private boolean running = false;
- private SurfaceHolder surfaceHolder;
+ class BubblesThread extends Thread {
+ private boolean running = false;
+ private SurfaceHolder surfaceHolder;
- BubbleModel model = null;
+ BubbleModel model = null;
- public BubblesThread(SurfaceHolder holder, Context context, Handler handler)
- {
- surfaceHolder = holder;
- }
+ public BubblesThread(SurfaceHolder holder, Context context, Handler handler) {
+ surfaceHolder = holder;
+ }
- public void setModel(BubbleModel model)
- {
- this.model = model;
- }
+ public void setModel(BubbleModel model) {
+ this.model = model;
+ }
- @Override
- public void run()
- {
- while (running) {
- Canvas c = null;
- try {
- c = surfaceHolder.lockCanvas(null);
+ @Override
+ public void run() {
+ while (running) {
+ Canvas c = null;
+ try {
+ c = surfaceHolder.lockCanvas(null);
- // for the case the surface is destroyed while already in the loop
- if (c == null || model == null)
- continue;
+ // for the case the surface is destroyed while already in the loop
+ if (c == null || model == null)
+ continue;
- synchronized (surfaceHolder) {
- //Log.w(TAG, "Thread doDraw");
- model.update();
- doDraw(c);
- }
- } finally {
- if (c != null)
- surfaceHolder.unlockCanvasAndPost(c);
- }
- }
- }
+ synchronized (surfaceHolder) {
+ // Log.w(TAG, "Thread doDraw");
+ model.update();
+ doDraw(c);
+ }
+ } finally {
+ if (c != null)
+ surfaceHolder.unlockCanvasAndPost(c);
+ }
+ }
+ }
- public void setRunning(boolean b)
- {
- running = b;
- }
+ public void setRunning(boolean b) {
+ running = b;
+ }
- public void setSurfaceSize(int width, int height)
- {
- synchronized (surfaceHolder) {
- if (model != null) {
- model.width = width;
- model.height = height;
- }
- }
- }
+ public void setSurfaceSize(int width, int height) {
+ synchronized (surfaceHolder) {
+ if (model != null) {
+ model.width = width;
+ model.height = height;
+ }
+ }
+ }
- private void doDraw(Canvas canvas)
- {
- canvas.drawColor(Color.WHITE);
+ /**
+ * I got multiple IndexOutOfBoundsException, when switching calls. //FIXME
+ *
+ * @param canvas
+ */
+ private void doDraw(Canvas canvas) {
+ canvas.drawColor(Color.WHITE);
- synchronized (model) {
- List<Bubble> bubbles = model.getBubbles();
- List<Attractor> attractors = model.getAttractors();
+ synchronized (model) {
+ List<Bubble> bubbles = model.getBubbles();
+ List<Attractor> attractors = model.getAttractors();
+ try {
- for (int i = 0, n = attractors.size(); i < n; i++) {
- Attractor a = attractors.get(i);
- canvas.drawBitmap(a.getBitmap(), null, a.getBounds(), null);
- }
+ for (int i = 0, n = attractors.size(); i < n; i++) {
+ Attractor a = attractors.get(i);
+ canvas.drawBitmap(a.getBitmap(), null, a.getBounds(), null);
+ }
- for (int i = 0, n = bubbles.size(); i < n; i++) {
- Bubble b = bubbles.get(i);
- canvas.drawBitmap(b.getBitmap(), null, b.getBounds(), null);
- canvas.drawText(b.contact.getmDisplayName(), b.getPosX(), b.getPosY() - 50 * density, name_paint);
- }
- }
- }
- }
+ for (int i = 0, n = bubbles.size(); i < n; i++) {
+ Bubble b = bubbles.get(i);
+ canvas.drawBitmap(b.getBitmap(), null, b.getBounds(), null);
+ canvas.drawText(b.contact.getmDisplayName(), b.getPosX(), b.getPosY() - 50 * density, name_paint);
+ }
+
+ } catch (IndexOutOfBoundsException e) {
+ Log.e(TAG, e.toString());
+ }
+ }
+ }
+ }
}
diff --git a/src/com/savoirfairelinux/sflphone/service/ISipService.aidl b/src/com/savoirfairelinux/sflphone/service/ISipService.aidl
index 95460bb..589bdb4 100644
--- a/src/com/savoirfairelinux/sflphone/service/ISipService.aidl
+++ b/src/com/savoirfairelinux/sflphone/service/ISipService.aidl
@@ -23,6 +23,11 @@
/* History */
List getHistory();
+ /* Notification */
+ void createNotification();
+ void destroyNotification();
+
+
/* Recording */
void setRecordPath(in String path);
String getRecordPath();
diff --git a/src/com/savoirfairelinux/sflphone/service/SipService.java b/src/com/savoirfairelinux/sflphone/service/SipService.java
index 1abfdaa..240ddc3 100644
--- a/src/com/savoirfairelinux/sflphone/service/SipService.java
+++ b/src/com/savoirfairelinux/sflphone/service/SipService.java
@@ -29,9 +29,12 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Random;
+import android.app.Notification;
+import android.app.NotificationManager;
+import android.app.PendingIntent;
import android.app.Service;
-import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
@@ -41,18 +44,19 @@
import android.os.IBinder;
import android.os.Looper;
import android.os.Message;
-import android.os.Parcelable;
import android.os.RemoteException;
-import android.os.Vibrator;
+import android.support.v4.app.NotificationCompat;
import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;
import android.widget.Toast;
+import com.savoirfairelinux.sflphone.R;
import com.savoirfairelinux.sflphone.account.AccountDetailsHandler;
import com.savoirfairelinux.sflphone.account.AudioHandler;
import com.savoirfairelinux.sflphone.account.HistoryHandler;
+import com.savoirfairelinux.sflphone.client.SFLPhoneHomeActivity;
import com.savoirfairelinux.sflphone.client.SFLphoneApplication;
-import com.savoirfairelinux.sflphone.model.CallContact;
+import com.savoirfairelinux.sflphone.client.receiver.IncomingReceiver;
import com.savoirfairelinux.sflphone.model.SipCall;
public class SipService extends Service {
@@ -70,75 +74,13 @@
private ConfigurationManagerCallback configurationManagerCallback;
private ManagerImpl managerImpl;
private boolean isPjSipStackStarted = false;
+
+ public static final String NOTIF_CREATION = "notif_creation";
+ public static final String NOTIF_DELETION = "notif_deletion";
- HashMap<String, SipCall> current_calls = new HashMap<String, SipCall>();
+ private HashMap<String, SipCall> current_calls = new HashMap<String, SipCall>();
- private BroadcastReceiver IncomingReceiver = new BroadcastReceiver() {
-
- @Override
- public void onReceive(Context context, Intent intent) {
- // Get instance of Vibrator from current Context
-
- 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());
- } else if (intent.getAction().contentEquals(ConfigurationManagerCallback.ACCOUNTS_CHANGED)) {
- Log.i(TAG, "Received" + intent.getAction());
- } else if (intent.getAction().contentEquals(CallManagerCallBack.INCOMING_TEXT)) {
- Log.i(TAG, "Received" + intent.getAction());
- sendBroadcast(intent);
- } else if (intent.getAction().contentEquals(CallManagerCallBack.INCOMING_CALL)) {
- Bundle b = intent.getBundleExtra("com.savoirfairelinux.sflphone.service.newcall");
-
- SipCall.SipCallBuilder callBuilder = SipCall.SipCallBuilder.getInstance();
- callBuilder.startCallCreation(b.getString("CallID")).setAccountID(b.getString("AccountID"))
- .setCallState(SipCall.state.CALL_STATE_RINGING).setCallType(SipCall.state.CALL_TYPE_INCOMING);
- callBuilder.addContact(CallContact.ContactBuilder.buildUnknownContact(b.getString("From")));
-
- Intent toSend = new Intent(CallManagerCallBack.INCOMING_CALL);
- try {
- SipCall newCall = callBuilder.build();
- toSend.putExtra("newcall", newCall);
- current_calls.put(newCall.getCallId(), newCall);
- sendBroadcast(toSend);
- } catch (Exception e) {
- Log.e(TAG, e.toString());
- }
-
- } else if (intent.getAction().contentEquals(CallManagerCallBack.CALL_STATE_CHANGED)) {
-
- Bundle b = intent.getBundleExtra("com.savoirfairelinux.sflphone.service.newstate");
- String newState = b.getString("State");
- if (newState.equals("INCOMING")) {
- current_calls.get(b.getString("CallID")).setCallState(SipCall.state.CALL_STATE_INCOMING);
- } else if (newState.equals("RINGING")) {
- current_calls.get(b.getString("CallID")).setCallState(SipCall.state.CALL_STATE_RINGING);
- } else if (newState.equals("CURRENT")) {
- current_calls.get(b.getString("CallID")).setCallState(SipCall.state.CALL_STATE_CURRENT);
- } else if (newState.equals("HUNGUP")) {
- current_calls.remove(b.getString("CallID"));
- } else if (newState.equals("BUSY")) {
- current_calls.remove(b.getString("CallID"));
- } else if (newState.equals("FAILURE")) {
- current_calls.remove(b.getString("CallID"));
- } else if (newState.equals("HOLD")) {
- current_calls.get(b.getString("CallID")).setCallState(SipCall.state.CALL_STATE_HOLD);
- } else if (newState.equals("UNHOLD")) {
- current_calls.get(b.getString("CallID")).setCallState(SipCall.state.CALL_STATE_CURRENT);
- } else {
- current_calls.get(b.getString("CallID")).setCallState(SipCall.state.CALL_STATE_NONE);
- }
-
- sendBroadcast(intent);
- } else if (intent.getAction().contentEquals(CallManagerCallBack.NEW_CALL_CREATED)) {
- Log.i(TAG, "Received" + intent.getAction());
- Vibrator mVibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
- mVibrator.vibrate(300);
- }
-
- }
- };
+ private IncomingReceiver receiver = new IncomingReceiver(this);
@Override
public boolean onUnbind(Intent i) {
@@ -156,6 +98,8 @@
sflphoneApp = (SFLphoneApplication) getApplication();
sipServiceThread = new SipServiceThread();
+
+
IntentFilter callFilter = new IntentFilter(CallManagerCallBack.CALL_STATE_CHANGED);
callFilter.addAction(CallManagerCallBack.INCOMING_CALL);
@@ -165,9 +109,13 @@
callFilter.addAction(ConfigurationManagerCallback.ACCOUNTS_LOADED);
callFilter.addAction(CallManagerCallBack.INCOMING_TEXT);
- LocalBroadcastManager.getInstance(this).registerReceiver(IncomingReceiver, callFilter);
+ LocalBroadcastManager.getInstance(this).registerReceiver(receiver, callFilter);
+
getExecutor().execute(new StartRunnable());
+
}
+
+
/* called for each startService() */
@Override
@@ -191,6 +139,8 @@
sipServiceThread.interrupt();
sipServiceThread = null;
runFlag = false;
+ unregisterReceiver(receiver);
+
sflphoneApp.setServiceRunning(false);
Toast.makeText(this, "Sflphone Service stopped", Toast.LENGTH_SHORT).show();
super.onDestroy();
@@ -301,6 +251,14 @@
return;
}
+ public HashMap<String, SipCall> getCurrent_calls() {
+ return current_calls;
+ }
+
+ public void setCurrent_calls(HashMap<String, SipCall> current_calls) {
+ this.current_calls = current_calls;
+ }
+
// Enforce same thread contract to ensure we do not call from somewhere else
public class SameThreadException extends Exception {
private static final long serialVersionUID = -905639124232613768L;
@@ -392,7 +350,7 @@
protected void doRun() throws SameThreadException {
Log.i(TAG, "SipService.placeCall() thread running...");
callManagerJNI.placeCall(call.getAccountID(), call.getCallId(), call.getContacts().get(0).getPhones().get(0).getNumber());
- current_calls.put(call.getCallId(), call);
+ getCurrent_calls().put(call.getCallId(), call);
}
});
}
@@ -924,12 +882,55 @@
// nativemap.add(t);
// }
- return current_calls;
+ return getCurrent_calls();
}
@Override
public SipCall getCall(String callID) throws RemoteException {
- return current_calls.get(callID);
+ return getCurrent_calls().get(callID);
+ }
+
+ /***********************
+ * Notification API
+ ***********************/
+ @Override
+ public void createNotification() throws RemoteException {
+ makeNotification();
+
+ }
+
+ @Override
+ public void destroyNotification() throws RemoteException {
+ removeNotification();
+
+ }
+
+ private int NOTIFICATION_ID = new Random().nextInt(1000);
+
+ private void makeNotification() {
+ if(current_calls.size() == 0){
+ return;
+ }
+ Intent notificationIntent = new Intent(getApplicationContext(), SFLPhoneHomeActivity.class);
+ PendingIntent contentIntent = PendingIntent.getActivity(getApplicationContext(), 007, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
+
+ NotificationManager nm = (NotificationManager) getBaseContext().getSystemService(Context.NOTIFICATION_SERVICE);
+
+ NotificationCompat.Builder builder = new NotificationCompat.Builder(getBaseContext());
+ //
+// builder.setContent(view);
+ builder.setContentIntent(contentIntent).setOngoing(true).setSmallIcon(R.drawable.ic_launcher).setContentTitle(getCurrent_calls().size()+" ongoing calls").setTicker("Pending calls").setWhen(System.currentTimeMillis()).setAutoCancel(false);
+ builder.setPriority(NotificationCompat.PRIORITY_MAX);
+ Notification n = builder.build();
+
+ nm.notify(NOTIFICATION_ID, n);
+
+ }
+
+ public void removeNotification() {
+ NotificationManager nm = (NotificationManager) getBaseContext().getSystemService(Context.NOTIFICATION_SERVICE);
+ nm.cancel(NOTIFICATION_ID);
+
}
};
diff --git a/src/com/savoirfairelinux/sflphone/views/CustomSlidingDrawer.java b/src/com/savoirfairelinux/sflphone/views/CustomSlidingDrawer.java
index 421571b..e83ae8a 100644
--- a/src/com/savoirfairelinux/sflphone/views/CustomSlidingDrawer.java
+++ b/src/com/savoirfairelinux/sflphone/views/CustomSlidingDrawer.java
@@ -335,7 +335,6 @@
@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
- Log.i(TAG, "onInterceptTouchEvent");
if (mLocked) {
Log.i(TAG, "Locked");
return false;
@@ -360,7 +359,7 @@
// handle.getHitRect(frame);
if (!mTracking && !frame.contains((int) x, (int) y)) {
- Log.i(TAG, "not tracking and not in frame");
+// Log.i(TAG, "not tracking and not in frame");
return false;
}