Skip to content
Snippets Groups Projects
Commit 85992119 authored by alision's avatar alision
Browse files

* #25117 CallList reflects ongoing calls

Small refactoring on SipCall
parent b3aa0fe6
No related branches found
No related tags found
No related merge requests found
Showing
with 438 additions and 446 deletions
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<solid android:color="@color/light"/>
<padding
android:bottom="10dp"
android:left="10dp"
android:right="10dp"
android:top="10dp" />
<corners
android:bottomLeftRadius="5dp"
android:bottomRightRadius="5dp"
android:topLeftRadius="5dp"
android:topRightRadius="5dp" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<solid android:color="@color/light"/>
<padding
android:bottom="10dp"
android:left="10dp"
android:right="10dp"
android:top="10dp" />
<corners
android:bottomLeftRadius="5dp"
android:bottomRightRadius="5dp"
android:topLeftRadius="5dp"
android:topRightRadius="5dp" />
</shape>
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/item_call_pressed" android:state_pressed="true"/>
<item android:drawable="@drawable/item_call_pressed" android:state_focused="true"/>
<item android:drawable="@drawable/item_call_normal"/>
</selector>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="@android:color/black"
android:clickable="true"
android:orientation="vertical"
android:paddingLeft="40dp"
tools:context=".MainActivity" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="39dp"
android:gravity="center_vertical" >
<ImageView
android:id="@+id/childImage"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_margin="5dp"
android:background="@drawable/ic_launcher"
android:contentDescription="Coucou" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="MOUHAAHHAHA"
android:textColor="#FFFFFF"
android:textSize="14sp"
android:textStyle="bold" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@android:color/white" />
</LinearLayout>
\ No newline at end of file
......@@ -2,13 +2,13 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#99FF0000"
android:background="@color/lighter_gray"
android:orientation="vertical" >
<ExpandableListView
<ListView
android:id="@+id/call_list"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ExpandableListView>
</ListView>
</LinearLayout>
\ No newline at end of file
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_marginLeft="5dp"
android:drawableRight="@drawable/ic_contact_picture"
android:gravity="center_vertical"
android:text="GLOUBIBBI"
android:textColor="#FFFFFF"
android:padding="10dp"
android:textSize="14sp"
android:textStyle="bold" />
\ No newline at end of file
<?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"
android:background="@drawable/item_call_selector" >
<TextView
android:id="@+id/call_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_margin="15dp"
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" />
<TextView
android:id="@+id/call_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/hangup_button"
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" />
</RelativeLayout>
\ No newline at end of file
......@@ -7,118 +7,77 @@ import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.BaseExpandableListAdapter;
import android.widget.CheckedTextView;
import android.widget.BaseAdapter;
import android.widget.TextView;
import android.widget.Toast;
import com.savoirfairelinux.sflphone.R;
import com.savoirfairelinux.sflphone.model.SipCall;
public class CallListAdapter extends BaseExpandableListAdapter {
public class CallListAdapter extends BaseAdapter {
private HashMap<String, SipCall> calls;
private ArrayList<SipCall> calls;
private Context mContext;
public ArrayList<String> groupItem, tempChild;
public ArrayList<Object> Childtem = new ArrayList<Object>();
public CallListAdapter(Context c, HashMap<String, SipCall> hashMap, ArrayList<String> grList, ArrayList<Object> childItem) {
public CallListAdapter(Context c, ArrayList<SipCall> array) {
mContext = c;
calls = hashMap;
groupItem = grList;
this.Childtem = childItem;
calls = array;
}
// @Override
// public SipCall getItem(int position) {
// for(int j = 0 ; j <= position ; ++j){
// calls.entrySet().iterator().next();
// }
//
// return calls.entrySet().iterator().next().getValue();
// }
@Override
public Object getChild(int groupPosition, int childPosition) {
return null;
public SipCall getItem(int position) {
return calls.get(position);
}
@Override
public long getChildId(int groupPosition, int childPosition) {
return 0;
}
@Override
public View getChildView(int groupPosition, final int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
tempChild = (ArrayList<String>) Childtem.get(groupPosition);
TextView text = null;
if (convertView == null) {
convertView = LayoutInflater.from(mContext).inflate(R.layout.childrow, null);
}
text = (TextView) convertView.findViewById(R.id.textView1);
text.setText(tempChild.get(childPosition));
convertView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(mContext, tempChild.get(childPosition), Toast.LENGTH_SHORT).show();
}
});
return convertView;
}
@Override
public int getChildrenCount(int groupPosition) {
return ((ArrayList<String>) Childtem.get(groupPosition)).size();
public int getCount() {
return calls.size();
}
@Override
public Object getGroup(int groupPosition) {
return null;
}
@Override
public int getGroupCount() {
return groupItem.size();
}
@Override
public void onGroupCollapsed(int groupPosition) {
super.onGroupCollapsed(groupPosition);
public long getItemId(int position) {
return Long.parseLong(calls.get(position).getCallId());
}
@Override
public void onGroupExpanded(int groupPosition) {
super.onGroupExpanded(groupPosition);
}
@Override
public long getGroupId(int groupPosition) {
return 0;
}
@Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = LayoutInflater.from(mContext).inflate(R.layout.item_calllist, null);
}
((CheckedTextView) convertView).setText(groupItem.get(groupPosition));
((CheckedTextView) convertView).setChecked(isExpanded);
return convertView;
}
public View getView(int position, View convertView, ViewGroup parent) {
View rowView = convertView;
@Override
public boolean hasStableIds() {
return false;
if (rowView == null) {
LayoutInflater inflater = LayoutInflater.from(mContext);
rowView = inflater.inflate(R.layout.item_calllist, null);
}
SipCall tmp = calls.get(position);
((TextView)rowView.findViewById(R.id.call_title)).setText(tmp.getContacts().get(0).getmDisplayName());
((TextView)rowView.findViewById(R.id.call_status)).setText(""+tmp.getmCallState());
return rowView;
}
@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
return false;
public void update(HashMap<String, SipCall> list) {
calls.clear();
calls.addAll(list.values());
notifyDataSetChanged();
}
}
......@@ -43,7 +43,9 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.Environment;
import android.os.IBinder;
import android.os.RemoteException;
import android.support.v4.view.ViewPager;
import android.support.v4.widget.SlidingPaneLayout;
import android.util.Log;
......@@ -56,6 +58,7 @@ import com.savoirfairelinux.sflphone.fragments.CallFragment;
import com.savoirfairelinux.sflphone.fragments.CallListFragment;
import com.savoirfairelinux.sflphone.interfaces.CallInterface;
import com.savoirfairelinux.sflphone.model.SipCall;
import com.savoirfairelinux.sflphone.model.SipCall.state;
import com.savoirfairelinux.sflphone.service.CallManagerCallBack;
import com.savoirfairelinux.sflphone.service.ISipService;
import com.savoirfairelinux.sflphone.service.SipService;
......@@ -68,11 +71,10 @@ public class CallActivity extends Activity implements CallInterface, CallFragmen
private ExecutorService infos_fetcher = Executors.newCachedThreadPool();
CallReceiver receiver;
CallListFragment mCallsFragment;
CallFragment mCurrentCallFragment;
// private CallPagerAdapter mCallPagerAdapter;
// private ViewPager mViewPager;
......@@ -93,13 +95,9 @@ public class CallActivity extends Activity implements CallInterface, CallFragmen
receiver = new CallReceiver(this);
mCallsFragment = new CallListFragment();
getFragmentManager().beginTransaction().replace(R.id.calllist_pane, mCallsFragment).commit();
final SlidingPaneLayout slidingPaneLayout = (SlidingPaneLayout) findViewById(R.id.slidingpanelayout);
slidingPaneLayout.setPanelSlideListener(new SlidingPaneLayout.PanelSlideListener() {
......@@ -113,8 +111,8 @@ public class CallActivity extends Activity implements CallInterface, CallFragmen
switch (view.getId()) {
case R.id.calllist_pane:
// getFragmentManager().findFragmentById(R.id.calllist_pane).setHasOptionsMenu(true);
// getFragmentManager().findFragmentById(R.id.ongoingcall_pane).setHasOptionsMenu(false);
// getFragmentManager().findFragmentById(R.id.calllist_pane).setHasOptionsMenu(true);
// getFragmentManager().findFragmentById(R.id.ongoingcall_pane).setHasOptionsMenu(false);
break;
default:
break;
......@@ -126,8 +124,8 @@ public class CallActivity extends Activity implements CallInterface, CallFragmen
switch (view.getId()) {
case R.id.ongoingcall_pane:
// getFragmentManager().findFragmentById(R.id.calllist_pane).setHasOptionsMenu(false);
// getFragmentManager().findFragmentById(R.id.ongoingcall_pane).setHasOptionsMenu(true);
// getFragmentManager().findFragmentById(R.id.calllist_pane).setHasOptionsMenu(false);
// getFragmentManager().findFragmentById(R.id.ongoingcall_pane).setHasOptionsMenu(true);
break;
default:
break;
......@@ -182,7 +180,7 @@ public class CallActivity extends Activity implements CallInterface, CallFragmen
mCurrentCallFragment = new CallFragment();
mCurrentCallFragment.setArguments(getIntent().getExtras());
getIntent().getExtras();
SipCall info = getIntent().getExtras().getParcelable("CallInfo");
// SipCall info = getIntent().getExtras().getParcelable("CallInfo");
// mCallPagerAdapter.addCall(info.mCallID, newCall);
getFragmentManager().beginTransaction().replace(R.id.ongoingcall_pane, mCurrentCallFragment).commit();
......@@ -214,61 +212,196 @@ public class CallActivity extends Activity implements CallInterface, CallFragmen
* Bundle bundle = intent.getBundleExtra("com.savoirfairelinux.sflphone.service.newstate"); String callID = bundle.getString("CallID"); String
* newState = bundle.getString("State");
*/
CallFragment fr = mCurrentCallFragment;
// CallFragment fr = mCurrentCallFragment;
if (newState.equals("INCOMING")) {
fr.changeCallState(SipCall.state.CALL_STATE_INCOMING);
mCallsFragment.update();
} else if (newState.equals("RINGING")) {
fr.changeCallState(SipCall.state.CALL_STATE_RINGING);
// 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);
//
// }
} else if (newState.equals("CURRENT")) {
fr.changeCallState(SipCall.state.CALL_STATE_CURRENT);
Log.w(TAG, "processCallStateChangedSignal " + newState);
} 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();
// }
@Override
public void incomingText(Intent msg) {
Toast.makeText(this, "New Call incoming", Toast.LENGTH_LONG).show();
} else if (newState.equals("FAILURE")) {
// mCallPagerAdapter.remove(callID);
// if (mCallPagerAdapter.getCount() == 0) {
// finish();
// }
// TODO link text message to associate call and display it at the right place
} else if (newState.equals("HOLD")) {
fr.changeCallState(SipCall.state.CALL_STATE_HOLD);
}
} else if (newState.equals("UNHOLD")) {
fr.changeCallState(SipCall.state.CALL_STATE_CURRENT);
@Override
public ISipService getService() {
return service;
}
} else {
fr.changeCallState(SipCall.state.CALL_STATE_NONE);
@Override
public void onCallSelected(SipCall call) {
mCurrentCallFragment = new CallFragment();
Bundle b = new Bundle();
b.putParcelable("CallInfo", call);
mCurrentCallFragment.setArguments(b);
getFragmentManager().beginTransaction().replace(R.id.ongoingcall_pane, mCurrentCallFragment).commit();
}
@Override
public void callContact(SipCall call) {
try {
service.placeCall(call);
} catch (RemoteException e) {
Log.e(TAG, "Cannot call service method", e);
}
Log.w(TAG, "processCallStateChangedSignal " + newState);
}
@Override
public void onCallAccepted(SipCall call) {
int callState = call.getCallStateInt();
if ((callState != state.CALL_STATE_RINGING) && (callState != state.CALL_STATE_NONE)) {
return;
}
try {
service.accept(call.getCallId());
} catch (RemoteException e) {
Log.e(TAG, "Cannot call service method", e);
}
}
@Override
public void incomingText(Intent msg) {
Toast.makeText(this, "New Call incoming", Toast.LENGTH_LONG).show();
public void onCallRejected(SipCall call) {
try {
if (call.getCallStateInt() == state.CALL_STATE_RINGING) {
service.refuse(call.getCallId());
return;
}
} catch (RemoteException e) {
Log.e(TAG, "Cannot call service method", e);
}
}
// TODO link text message to associate call and display it at the right place
@Override
public void onCallEnded(SipCall call) {
try {
if ((call.getCallStateInt() == state.CALL_STATE_NONE) || (call.getCallStateInt() == state.CALL_STATE_CURRENT)
|| (call.getCallStateInt() == state.CALL_STATE_HOLD)) {
service.hangUp(call.getCallId());
return;
} else if (call.getCallStateInt() == state.CALL_STATE_RINGING) {
if (call.getCallType() == state.CALL_TYPE_INCOMING) {
service.refuse(call.getCallId());
return;
} else if (call.getCallType() == state.CALL_TYPE_OUTGOING) {
service.hangUp(call.getCallId());
return;
}
}
} catch (RemoteException e) {
Log.e(TAG, "Cannot call service method", e);
}
}
@Override
public void onCallSuspended(SipCall call) {
try {
if (call.getCallStateInt() == state.CALL_STATE_CURRENT) {
service.hold(call.getCallId());
return;
}
} catch (RemoteException e) {
Log.e(TAG, "Cannot call service method", e);
}
}
@Override
public ISipService getService() {
return service;
public void onCallResumed(SipCall call) {
try {
if (call.getCallStateInt() == state.CALL_STATE_HOLD) {
service.unhold(call.getCallId());
return;
}
} catch (RemoteException e) {
Log.e(TAG, "Cannot call service method", e);
}
}
@Override
public void onCalltransfered(SipCall call,String to) {
try {
if (call.getCallStateInt() == state.CALL_STATE_CURRENT) {
service.transfer(call.getCallId(), to);
}
} catch (RemoteException e) {
Log.e(TAG, "Cannot call service method", e);
}
}
@Override
public void onRecordCall(SipCall call) {
try {
if (call.getCallStateInt() == state.CALL_STATE_CURRENT) {
service.setRecordPath(Environment.getExternalStorageDirectory().getAbsolutePath());
Log.w(TAG, "Recording path" + service.getRecordPath());
service.setRecordingCall(call.getCallId());
}
} catch (RemoteException e) {
Log.e(TAG, "Cannot call service method", e);
}
}
@Override
public void onSendMessage(SipCall call, String msg) {
try {
if (call.getCallStateInt() == state.CALL_STATE_CURRENT) {
service.sendTextMessage(call.getCallId(), msg, "Me");
}
} catch (RemoteException e) {
Log.e(TAG, "Cannot call service method", e);
}
}
}
......@@ -194,23 +194,23 @@ public class CallElementListFragment extends ListFragment {
@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();
......
......@@ -86,10 +86,57 @@ public class CallFragment extends Fragment {
*/
private static Callbacks sDummyCallbacks = new Callbacks() {
@Override
public void onSendMessage(SipCall call, String msg) {
}
@Override
public void callContact(SipCall call) {
}
@Override
public void onCallAccepted(SipCall call) {
// TODO Auto-generated method stub
}
@Override
public void onCallRejected(SipCall call) {
// TODO Auto-generated method stub
}
@Override
public void onCallEnded(SipCall call) {
// TODO Auto-generated method stub
}
@Override
public void onCallSuspended(SipCall call) {
// TODO Auto-generated method stub
}
@Override
public void onCallResumed(SipCall call) {
// TODO Auto-generated method stub
}
@Override
public void onCalltransfered(SipCall call, String to) {
// TODO Auto-generated method stub
}
@Override
public ISipService getService() {
public void onRecordCall(SipCall call) {
// TODO Auto-generated method stub
return null;
}
};
......@@ -98,8 +145,24 @@ public class CallFragment extends Fragment {
*
*/
public interface Callbacks {
public ISipService getService();
public void callContact(SipCall call);
public void onCallAccepted(SipCall call);
public void onCallRejected(SipCall call);
public void onCallEnded(SipCall call);
public void onCallSuspended(SipCall call);
public void onCallResumed(SipCall call);
public void onCalltransfered(SipCall call, String to);
public void onRecordCall(SipCall call);
public void onSendMessage(SipCall call, String msg);
}
@Override
......@@ -112,7 +175,7 @@ public class CallFragment extends Fragment {
mCallbacks = (Callbacks) activity;
}
@Override
public void onDetach() {
super.onDetach();
......@@ -131,10 +194,11 @@ public class CallFragment extends Fragment {
mCall = b.getParcelable("CallInfo");
Log.i(TAG, "Starting fragment for call " + mCall.getCallId());
mCall.printCallInfo();
String pendingAction = b.getString("action");
if (pendingAction != null && pendingAction.contentEquals("call")) {
callContact(mCall);
} else if (pendingAction.equals(CallManagerCallBack.INCOMING_CALL)) {
} else if (pendingAction.contentEquals(CallManagerCallBack.INCOMING_CALL)) {
callIncoming();
}
......@@ -156,7 +220,7 @@ public class CallFragment extends Fragment {
@Override
public void onBubbleSucked(Bubble b) {
Log.w(TAG, "Bubble sucked ! ");
onCallEnded();
mCallbacks.onCallEnded(mCall);
}
}));
......@@ -164,11 +228,8 @@ public class CallFragment extends Fragment {
model.listBubbles.add(contact_bubble);
contacts.put(infos.getContacts().get(0), contact_bubble);
try {
mCallbacks.getService().placeCall(infos);
} catch (RemoteException e) {
Log.e(TAG, e.toString());
}
mCallbacks.callContact(infos);
}
private void callIncoming() {
......@@ -176,58 +237,18 @@ public class CallFragment extends Fragment {
model.attractors.add(new Attractor(new PointF(3 * metrics.widthPixels / 4, metrics.heightPixels / 4), new Attractor.Callback() {
@Override
public void onBubbleSucked(Bubble b) {
onCallAccepted();
mCallbacks.onCallAccepted(mCall);
}
}));
model.attractors.add(new Attractor(new PointF(metrics.widthPixels / 4, metrics.heightPixels / 4), new Attractor.Callback() {
@Override
public void onBubbleSucked(Bubble b) {
onCallRejected();
mCallbacks.onCallRejected(mCall);
}
}));
}
public void onCallAccepted() {
mCall.notifyServiceAnswer(mCallbacks.getService());
}
public void onCallRejected() {
if (mCall.notifyServiceHangup(mCallbacks.getService()))
;
}
public void onCallEnded() {
if (mCall.notifyServiceHangup(mCallbacks.getService()))
;
}
public void onCallSuspended() {
mCall.notifyServiceHold(mCallbacks.getService());
}
public void onCallResumed() {
mCall.notifyServiceUnhold(mCallbacks.getService());
}
public void onCalltransfered(String to) {
mCall.notifyServiceTransfer(mCallbacks.getService(), to);
}
public void onRecordCall() {
mCall.notifyServiceRecord(mCallbacks.getService());
}
// public void onSendMessage(String msg) {
// mCall.notifyServiceSendMsg(mCallbacks.getService(), msg);
//
// }
public void changeCallState(int callState) {
mCall.setCallState(callState);
......
......@@ -36,14 +36,15 @@ import java.util.HashMap;
import android.app.Activity;
import android.app.Fragment;
import android.content.Context;
import android.os.Bundle;
import android.os.RemoteException;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ExpandableListView;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import com.savoirfairelinux.sflphone.R;
import com.savoirfairelinux.sflphone.adapters.CallListAdapter;
......@@ -57,57 +58,12 @@ public class CallListFragment extends Fragment {
CallListAdapter mAdapter;
ArrayList<String> groupItem = new ArrayList<String>();
ArrayList<Object> childItem = new ArrayList<Object>();
@Override
public void onCreate(Bundle savedBundle) {
super.onCreate(savedBundle);
groupItem.add("TechNology");
groupItem.add("Mobile");
groupItem.add("Manufacturer");
groupItem.add("Extras");
/**
* Add Data For TecthNology
*/
ArrayList<String> child = new ArrayList<String>();
child.add("Java");
child.add("Drupal");
child.add(".Net Framework");
child.add("PHP");
childItem.add(child);
/**
* Add Data For Mobile
*/
child = new ArrayList<String>();
child.add("Android");
child.add("Window Mobile");
child.add("iPHone");
child.add("Blackberry");
childItem.add(child);
/**
* Add Data For Manufacture
*/
child = new ArrayList<String>();
child.add("HTC");
child.add("Apple");
child.add("Samsung");
child.add("Nokia");
childItem.add(child);
/**
* Add Data For Extras
*/
child = new ArrayList<String>();
child.add("Contact Us");
child.add("About Us");
child.add("Location");
child.add("Root Cause");
childItem.add(child);
mAdapter = new CallListAdapter(getActivity(), new HashMap<String, SipCall>(), groupItem, childItem);
mAdapter = new CallListAdapter(getActivity(), new ArrayList<SipCall>());
}
......@@ -118,9 +74,12 @@ public class CallListFragment extends Fragment {
@Override
public ISipService getService() {
// TODO Auto-generated method stub
return null;
}
@Override
public void onCallSelected(SipCall call) {
}
};
/**
......@@ -129,6 +88,7 @@ public class CallListFragment extends Fragment {
*/
public interface Callbacks {
public ISipService getService();
public void onCallSelected(SipCall call);
}
......@@ -153,22 +113,34 @@ public class CallListFragment extends Fragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.frag_call_list, container, false);
ExpandableListView expandbleLis = (ExpandableListView) rootView.findViewById(R.id.call_list);
expandbleLis.setDividerHeight(2);
expandbleLis.setGroupIndicator(null);
expandbleLis.setClickable(true);
ListView list = (ListView) rootView.findViewById(R.id.call_list);
list.setDividerHeight(2);
// expandbleLis.setGroupIndicator(null);
list.setClickable(true);
expandbleLis.setAdapter(mAdapter);
list.setAdapter(mAdapter);
list.setOnItemClickListener(itemClickListener);
return rootView;
}
public void update() {
try {
HashMap<String, SipCall> list = (HashMap<String, SipCall>) mCallbacks.getService().getCallList();
mAdapter.update(list);
} catch (RemoteException e) {
Log.e(TAG, e.toString());
}
}
OnItemClickListener itemClickListener = new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View view, int pos, long arg3) {
mCallbacks.onCallSelected(mAdapter.getItem(pos));
}
};
}
......@@ -273,33 +273,6 @@ public class SipCall implements Parcelable {
return mMediaState;
}
public boolean notifyServiceAnswer(ISipService service) {
int callState = getCallStateInt();
if ((callState != state.CALL_STATE_RINGING) && (callState != state.CALL_STATE_NONE)) {
return false;
}
try {
service.accept(mCallID);
} catch (RemoteException e) {
Log.e(TAG, "Cannot call service method", e);
}
return true;
}
/**
* Perform hangup action without sending request to the service Used when SipService haved been notified that this call hung up
*/
// public void hangupUpdateUi() {
// Log.i(TAG, "Hangup call " + mCallID);
//
// if(mCallElementList != null)
// mCallElementList.removeCall(this);
//
// if(mHome != null)
// mHome.onUnselectedCallAction();
// }
public static class SipCallBuilder {
......@@ -369,87 +342,12 @@ public class SipCall implements Parcelable {
}
/**
* Perform hangup action and send request to the service
*/
public boolean notifyServiceHangup(ISipService service) {
try {
if ((getCallStateInt() == state.CALL_STATE_NONE) || (getCallStateInt() == state.CALL_STATE_CURRENT)
|| (getCallStateInt() == state.CALL_STATE_HOLD)) {
service.hangUp(mCallID);
return true;
} else if (getCallStateInt() == state.CALL_STATE_RINGING) {
if (getCallType() == state.CALL_TYPE_INCOMING) {
service.refuse(mCallID);
return true;
} else if (getCallType() == state.CALL_TYPE_OUTGOING) {
service.hangUp(mCallID);
return true;
}
}
} catch (RemoteException e) {
Log.e(TAG, "Cannot call service method", e);
}
return false;
}
public boolean notifyServiceRefuse(ISipService service) {
try {
if (getCallStateInt() == state.CALL_STATE_RINGING) {
service.refuse(mCallID);
return true;
}
} catch (RemoteException e) {
Log.e(TAG, "Cannot call service method", e);
}
return false;
}
public boolean notifyServiceHold(ISipService service) {
try {
if (getCallStateInt() == state.CALL_STATE_CURRENT) {
service.hold(mCallID);
return true;
}
} catch (RemoteException e) {
Log.e(TAG, "Cannot call service method", e);
}
return false;
}
public boolean notifyServiceUnhold(ISipService service) {
try {
if (getCallStateInt() == state.CALL_STATE_HOLD) {
service.unhold(mCallID);
return true;
}
} catch (RemoteException e) {
Log.e(TAG, "Cannot call service method", e);
}
return false;
}
public void addToConference() {
Log.i(TAG, "Add call to conference");
}
public void sendTextMessage() {
Log.i(TAG, "Send text message");
}
// public void printCallInfo() {
// Log.i(TAG, "CallInfo: CallID: " + mCallID);
// Log.i(TAG, " AccountID: " + mAccountID);
// Log.i(TAG, " Display Name: " + mDisplayName);
// Log.i(TAG, " Phone: " + mPhone);
// Log.i(TAG, " Email: " + mEmail);
// Log.i(TAG, " Contact: " + mRemoteContact);
// }
public void printCallInfo() {
Log.i(TAG, "CallInfo: CallID: " + mCallID);
Log.i(TAG, " AccountID: " + mAccountID);
Log.i(TAG, " CallState: " + mCallState);
Log.i(TAG, " CallType: " + mCallType);
}
/**
* Compare sip calls based on call ID
......@@ -463,37 +361,5 @@ public class SipCall implements Parcelable {
}
public void notifyServiceTransfer(ISipService service, String to) {
try {
if (getCallStateInt() == state.CALL_STATE_CURRENT) {
service.transfer(mCallID, to);
}
} catch (RemoteException e) {
Log.e(TAG, "Cannot call service method", e);
}
}
public void notifyServiceRecord(ISipService service) {
try {
if (getCallStateInt() == state.CALL_STATE_CURRENT) {
service.setRecordPath(Environment.getExternalStorageDirectory().getAbsolutePath());
Log.w(TAG, "Recording path" + service.getRecordPath());
service.setRecordingCall(mCallID);
}
} catch (RemoteException e) {
Log.e(TAG, "Cannot call service method", e);
}
}
// public void notifyServiceSendMsg(ISipService service, String msg) {
// try {
// if (getCallStateInt() == state.CALL_STATE_CURRENT) {
// service.sendTextMessage(mCallID, msg, mDisplayName);
// }
// } catch (RemoteException e) {
// Log.e(TAG, "Cannot call service method", e);
// }
//
// }
}
......@@ -96,7 +96,7 @@ public class SipService extends Service {
callBuilder.startCallCreation(b.getString("CallID")).setAccountID(b.getString("AccountID")).setCallType(SipCall.state.CALL_TYPE_OUTGOING);
callBuilder.addContact(CallContact.ContactBuilder.buildUnknownContact(b.getString("From")));
Intent toSend = new Intent();
Intent toSend = new Intent(CallManagerCallBack.INCOMING_CALL);
try {
SipCall newCall = callBuilder.build();
toSend.putExtra("newcall",newCall);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment