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

* #25115 First Implementation of new CallActivity with dual-pane

* #25116 SipCall redesigned, holding list of contacts (android or unknown)
parent 11e8e160
No related branches found
No related tags found
No related merge requests found
Showing
with 845 additions and 444 deletions
......@@ -30,16 +30,19 @@ shall include the source code for the parts of OpenSSL used as well
as that of the covered work.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/CallActivityLayout"
<android.support.v4.widget.SlidingPaneLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/slidingpanelayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical" >
android:layout_height="match_parent" >
<android.support.v4.view.ViewPager
android:id="@+id/pager"
<FrameLayout
android:id="@+id/ongoingcall_pane"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
\ No newline at end of file
<FrameLayout
android:id="@+id/calllist_pane"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.v4.widget.SlidingPaneLayout>
\ No newline at end of file
<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
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#99FF0000"
android:orientation="vertical" >
<ExpandableListView
android:id="@+id/call_list"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ExpandableListView>
</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="GLOUBIBIB"
android:textColor="#FFFFFF"
android:padding="10dp"
android:textSize="14sp"
android:textStyle="bold" />
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
</LinearLayout>
......@@ -20,7 +20,6 @@ public class AccountSelectionAdapter extends BaseAdapter {
ArrayList<Account> accounts;
Context mContext;
// AccountManager accManager;
ISipService service;
int selectedAccount = 0;
......@@ -29,7 +28,6 @@ public class AccountSelectionAdapter extends BaseAdapter {
accounts = newList;
mContext = cont;
service = s;
// accManager = new AccountManager(mContext);
}
@Override
......@@ -84,144 +82,7 @@ public class AccountSelectionAdapter extends BaseAdapter {
public RadioButton select;
}
// /**
// * Asynchronous account details retriever
// */
// public class AccountManager {
//
// // private static final String TAG = ImageManager.class.getSimpleName();
//
// private HashMap<String, HashMap<String, String>> accountMap = new HashMap<String, HashMap<String, String>>();
// private AccountQueue accountQueue = new AccountQueue();
// private Thread accountLoaderThread = new Thread(new AccountQueueManager());
//
//
// public AccountManager(Context context) {
// accountLoaderThread.setPriority(Thread.NORM_PRIORITY - 1);
//
// }
//
// public void displayAccountDetails(String id, AccountView account) {
//
// if (accountMap.containsKey(id)) {
//
// HashMap<String, String> details = accountMap.get(id);
// account.alias.setText(details.get(AccountDetailBasic.CONFIG_ACCOUNT_ALIAS));
// account.host.setText(details.get(AccountDetailBasic.CONFIG_ACCOUNT_HOSTNAME));
//
// } else {
// queueAccount(id, account);
// }
// }
//
// private void queueAccount(String id, AccountView row) {
// // This ImageView might have been used for other images, so we clear
// // the queue of old tasks before starting.
// // accountQueue.Clean(row);
// AccountRef p = new AccountRef(id, row);
//
// synchronized (accountQueue.accountRefsStack) {
// accountQueue.accountRefsStack.push(p);
// accountQueue.accountRefsStack.notifyAll();
// }
//
// // Start thread if it's not started yet
// if (accountLoaderThread.getState() == Thread.State.NEW) {
// accountLoaderThread.start();
// }
// }
//
// /** Classes **/
//
// private class AccountRef {
// public String accountID;
// public AccountView row;
//
// public AccountRef(String u, AccountView i) {
// accountID = u;
// row = i;
// }
// }
//
// private class AccountQueue {
// private Stack<AccountRef> accountRefsStack = new Stack<AccountRef>();
//
// // removes all instances of this account
// // public void Clean(AccountView view) {
// //
// // for (int i = 0; i < accountRefsStack.size();) {
// // if (accountRefsStack.get(i).row == view)
// // accountRefsStack.remove(i);
// // else
// // ++i;
// // }
// // }
// }
//
// private class AccountQueueManager implements Runnable {
// @Override
// public void run() {
// try {
// while (true) {
// // Thread waits until there are accountsID in the queue to be retrieved
// if (accountQueue.accountRefsStack.size() == 0) {
// synchronized (accountQueue.accountRefsStack) {
// accountQueue.accountRefsStack.wait();
// }
// }
//
// // When we have accounts to load
// if (accountQueue.accountRefsStack.size() != 0) {
// AccountRef accountToLoad;
//
// synchronized (accountQueue.accountRefsStack) {
// accountToLoad = accountQueue.accountRefsStack.pop();
// }
//
// HashMap<String, String> details = (HashMap<String, String>) service.getAccountDetails(accountToLoad.accountID);
//
// accountMap.put(accountToLoad.accountID, details);
// AccountDisplayer accDisplayer = new AccountDisplayer(details, accountToLoad.row);
// Activity a = (Activity) mContext;
//
// a.runOnUiThread(accDisplayer);
//
// }
//
// if (Thread.interrupted())
// break;
// }
// } catch (InterruptedException e) {
// Log.e(TAG, e.toString());
// } catch (RemoteException e) {
// Log.e(TAG, e.toString());
// }
// }
// }
//
// // Used to display details in the UI thread
// private class AccountDisplayer implements Runnable {
// HashMap<String, String> displayDetails;
// AccountView displayRow;
//
// public AccountDisplayer(HashMap<String, String> details, AccountView row) {
// displayRow = row;
// displayDetails = details;
// }
//
// public void run() {
// displayRow.alias.setText(displayDetails.get(AccountDetailBasic.CONFIG_ACCOUNT_ALIAS));
// displayRow.host.setText(displayDetails.get(AccountDetailBasic.CONFIG_ACCOUNT_HOSTNAME));
// }
// }
//
// public void removeFromCache(Uri uri) {
// if (accountMap.containsKey(uri)) {
// accountMap.remove(uri);
// }
// }
// }
//
public void setSelectedAccount(int pos) {
selectedAccount = pos;
}
......
......@@ -66,8 +66,8 @@ public class CallElementAdapter extends BaseAdapter {
// to the view objects
SipCall call = (SipCall) mCallList.values().toArray()[position];
entryView.displayName.setText(call.getDisplayName());
entryView.phones.setText(call.getPhone());
entryView.displayName.setText(call.getContacts().get(0).getmDisplayName());
entryView.phones.setText(call.getContacts().get(0).getPhones().get(0).getNumber());
entryView.state.setText(CURRENT_STATE_LABEL + call.getCallStateString());
return rowView;
......@@ -110,26 +110,26 @@ public class CallElementAdapter extends BaseAdapter {
return;
}
if (newState.equals("INCOMING")) {
mCallList.get(id).setCallState(SipCall.CALL_STATE_INCOMING);
mCallList.get(id).setCallState(SipCall.state.CALL_STATE_INCOMING);
} else if (newState.equals("RINGING")) {
mCallList.get(id).setCallState(SipCall.CALL_STATE_RINGING);
mCallList.get(id).setCallState(SipCall.state.CALL_STATE_RINGING);
} else if (newState.equals("CURRENT")) {
mCallList.get(id).setCallState(SipCall.CALL_STATE_CURRENT);
mCallList.get(id).setCallState(SipCall.state.CALL_STATE_CURRENT);
} else if (newState.equals("HUNGUP")) {
mCallList.get(id).setCallState(SipCall.CALL_STATE_HUNGUP);
mCallList.get(id).setCallState(SipCall.state.CALL_STATE_HUNGUP);
mCallList.remove(id);
} else if (newState.equals("BUSY")) {
mCallList.get(id).setCallState(SipCall.CALL_STATE_BUSY);
mCallList.get(id).setCallState(SipCall.state.CALL_STATE_BUSY);
mCallList.remove(id);
} else if (newState.equals("FAILURE")) {
mCallList.get(id).setCallState(SipCall.CALL_STATE_FAILURE);
mCallList.get(id).setCallState(SipCall.state.CALL_STATE_FAILURE);
mCallList.remove(id);
} else if (newState.equals("HOLD")) {
mCallList.get(id).setCallState(SipCall.CALL_STATE_HOLD);
mCallList.get(id).setCallState(SipCall.state.CALL_STATE_HOLD);
} else if (newState.equals("UNHOLD")) {
mCallList.get(id).setCallState(SipCall.CALL_STATE_CURRENT);
mCallList.get(id).setCallState(SipCall.state.CALL_STATE_CURRENT);
} else {
mCallList.get(id).setCallState(SipCall.CALL_STATE_NONE);
mCallList.get(id).setCallState(SipCall.state.CALL_STATE_NONE);
}
notifyDataSetChanged();
......
package com.savoirfairelinux.sflphone.adapters;
import java.util.ArrayList;
import java.util.HashMap;
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.TextView;
import android.widget.Toast;
import com.savoirfairelinux.sflphone.R;
import com.savoirfairelinux.sflphone.model.SipCall;
public class CallListAdapter extends BaseExpandableListAdapter {
private HashMap<String, 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) {
mContext = c;
calls = hashMap;
groupItem = grList;
this.Childtem = childItem;
}
// @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;
}
@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();
}
@Override
public Object getGroup(int groupPosition) {
return null;
}
@Override
public int getGroupCount() {
return groupItem.size();
}
@Override
public void onGroupCollapsed(int groupPosition) {
super.onGroupCollapsed(groupPosition);
}
@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.grouprow, null);
}
((CheckedTextView) convertView).setText(groupItem.get(groupPosition));
((CheckedTextView) convertView).setChecked(isExpanded);
return convertView;
}
@Override
public boolean hasStableIds() {
return false;
}
@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
return false;
}
}
package com.savoirfairelinux.sflphone.adapters;
import java.util.ArrayList;
import java.util.HashMap;
import android.app.Fragment;
import android.app.FragmentManager;
import android.content.Context;
import android.support.v13.app.FragmentStatePagerAdapter;
import android.support.v4.view.PagerAdapter;
import android.util.Log;
import com.savoirfairelinux.sflphone.R;
......@@ -36,8 +36,7 @@ public class CallPagerAdapter extends FragmentStatePagerAdapter {
for(int j = 0 ; j <= i ; ++j){
calls.entrySet().iterator().next();
}
return calls.entrySet().iterator().next().getValue();
}
......@@ -106,6 +105,11 @@ public class CallPagerAdapter extends FragmentStatePagerAdapter {
}
return null;
}
@Override
public int getItemPosition(Object object){
return PagerAdapter.POSITION_NONE;
}
public void addCall(String mCallID, CallFragment newCall) {
Log.w(TAG, "Put "+mCallID);
......
......@@ -3,6 +3,7 @@
*
* Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com>
* Author: Adrien Béraud <adrien.beraud@savoirfairelinux.com>
* Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -43,22 +44,23 @@ import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;
import android.support.v4.view.ViewPager;
import android.support.v4.widget.SlidingPaneLayout;
import android.util.Log;
import android.view.View;
import android.widget.Toast;
import com.savoirfairelinux.sflphone.R;
import com.savoirfairelinux.sflphone.adapters.CallPagerAdapter;
import com.savoirfairelinux.sflphone.client.receiver.CallReceiver;
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.service.CallManagerCallBack;
import com.savoirfairelinux.sflphone.service.ISipService;
import com.savoirfairelinux.sflphone.service.SipService;
public class CallActivity extends Activity implements CallInterface, CallFragment.Callbacks {
public class CallActivity extends Activity implements CallInterface, CallFragment.Callbacks, CallListFragment.Callbacks {
static final String TAG = "CallActivity";
private ISipService service;
......@@ -66,10 +68,13 @@ public class CallActivity extends Activity implements CallInterface, CallFragmen
private ExecutorService infos_fetcher = Executors.newCachedThreadPool();
CallReceiver receiver;
CallListFragment mCallsFragment;
CallFragment mCurrentCallFragment;
ViewPager vp;
private CallPagerAdapter mCallPagerAdapter;
private ViewPager mViewPager;
// private CallPagerAdapter mCallPagerAdapter;
// private ViewPager mViewPager;
/*
* private BroadcastReceiver mMessageReceiver = new BroadcastReceiver() {
......@@ -88,13 +93,47 @@ public class CallActivity extends Activity implements CallInterface, CallFragmen
receiver = new CallReceiver(this);
if (mCallPagerAdapter == null) {
mCallPagerAdapter = new CallPagerAdapter(this, getFragmentManager());
}
mViewPager = (ViewPager) findViewById(R.id.pager);
mViewPager.setAdapter(mCallPagerAdapter);
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() {
@Override
public void onPanelSlide(View view, float offSet) {
}
@Override
public void onPanelOpened(View view) {
switch (view.getId()) {
case R.id.calllist_pane:
// getFragmentManager().findFragmentById(R.id.calllist_pane).setHasOptionsMenu(true);
// getFragmentManager().findFragmentById(R.id.ongoingcall_pane).setHasOptionsMenu(false);
break;
default:
break;
}
}
@Override
public void onPanelClosed(View view) {
switch (view.getId()) {
case R.id.ongoingcall_pane:
// getFragmentManager().findFragmentById(R.id.calllist_pane).setHasOptionsMenu(false);
// getFragmentManager().findFragmentById(R.id.ongoingcall_pane).setHasOptionsMenu(true);
break;
default:
break;
}
}
});
Bundle b = getIntent().getExtras();
......@@ -102,7 +141,6 @@ public class CallActivity extends Activity implements CallInterface, CallFragmen
// setCallStateDisplay(mCall.getCallStateString());
bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
}
......@@ -140,12 +178,13 @@ public class CallActivity extends Activity implements CallInterface, CallFragmen
@Override
public void onServiceConnected(ComponentName className, IBinder binder) {
service = ISipService.Stub.asInterface(binder);
Log.i(TAG, "Placing call");
CallFragment newCall = new CallFragment();
newCall.setArguments(getIntent().getExtras());
getIntent().getExtras();
SipCall.CallInfo info = getIntent().getExtras().getParcelable("CallInfo");
mCallPagerAdapter.addCall(info.mCallID, newCall);
Log.i(TAG, "Placing call");
mCurrentCallFragment = new CallFragment();
mCurrentCallFragment.setArguments(getIntent().getExtras());
getIntent().getExtras();
SipCall info = getIntent().getExtras().getParcelable("CallInfo");
// mCallPagerAdapter.addCall(info.mCallID, newCall);
getFragmentManager().beginTransaction().replace(R.id.ongoingcall_pane, mCurrentCallFragment).commit();
}
......@@ -158,7 +197,7 @@ public class CallActivity extends Activity implements CallInterface, CallFragmen
public void incomingCall(Intent call) {
Toast.makeText(this, "New Call incoming", Toast.LENGTH_LONG).show();
// TODO Handle multicall here
mCallsFragment.update();
}
......@@ -175,34 +214,43 @@ 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 = (CallFragment) mCallPagerAdapter.getCall(callID);
CallFragment fr = mCurrentCallFragment;
if (newState.equals("INCOMING")) {
fr.changeCallState(SipCall.CALL_STATE_INCOMING);
fr.changeCallState(SipCall.state.CALL_STATE_INCOMING);
} else if (newState.equals("RINGING")) {
fr.changeCallState(SipCall.CALL_STATE_RINGING);
fr.changeCallState(SipCall.state.CALL_STATE_RINGING);
} else if (newState.equals("CURRENT")) {
fr.changeCallState(SipCall.CALL_STATE_CURRENT);
fr.changeCallState(SipCall.state.CALL_STATE_CURRENT);
} else if (newState.equals("HUNGUP")) {
mCallPagerAdapter.remove(callID);
// mCallPagerAdapter.remove(callID);
// if (mCallPagerAdapter.getCount() == 0) {
// finish();
// }
} else if (newState.equals("BUSY")) {
mCallPagerAdapter.remove(callID);
// mCallPagerAdapter.remove(callID);
// if (mCallPagerAdapter.getCount() == 0) {
// finish();
// }
} else if (newState.equals("FAILURE")) {
mCallPagerAdapter.remove(callID);
// mCallPagerAdapter.remove(callID);
// if (mCallPagerAdapter.getCount() == 0) {
// finish();
// }
} else if (newState.equals("HOLD")) {
fr.changeCallState(SipCall.CALL_STATE_HOLD);
fr.changeCallState(SipCall.state.CALL_STATE_HOLD);
} else if (newState.equals("UNHOLD")) {
fr.changeCallState(SipCall.CALL_STATE_CURRENT);
fr.changeCallState(SipCall.state.CALL_STATE_CURRENT);
} else {
fr.changeCallState(SipCall.CALL_STATE_NONE);
fr.changeCallState(SipCall.state.CALL_STATE_NONE);
}
......
......@@ -52,7 +52,6 @@ import android.support.v4.widget.DrawerLayout;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageButton;
import android.widget.RelativeLayout;
import android.widget.Toast;
......@@ -75,10 +74,10 @@ import com.savoirfairelinux.sflphone.views.CustomSlidingDrawer;
public class SFLPhoneHomeActivity extends Activity implements ActionBar.TabListener, DialingFragment.Callbacks, ContactListFragment.Callbacks,
CallElementListFragment.Callbacks, HistoryFragment.Callbacks, CallInterface {
SectionsPagerAdapter mSectionsPagerAdapter = null;
static final String TAG = "SFLPhoneHomeActivity";
ImageButton buttonCall, buttonHangup;
private ContactListFragment mContactsFragment = null;
private DialingFragment mDialingFragment = null;
private CallElementListFragment mCallElementList = null;
......@@ -297,11 +296,10 @@ public class SFLPhoneHomeActivity extends Activity implements ActionBar.TabListe
super.onDestroy();
}
public void launchCallActivity(SipCall.CallInfo infos, String action) {
public void launchCallActivity(SipCall infos, String action) {
Log.i(TAG, "Launch Call Activity");
Bundle bundle = new Bundle();
bundle.putString("action", action);
// bundle.putParcelable("CallContact", mListAdapter.getItem(pos));
bundle.putParcelable("CallInfo", infos);
Intent intent = new Intent().setClass(this, CallActivity.class);
intent.putExtras(bundle);
......@@ -378,12 +376,6 @@ public class SFLPhoneHomeActivity extends Activity implements ActionBar.TabListe
// Log.d(TAG, "onTabReselected");
}
public void processingHangUpAction() {
SipCall call = (SipCall) buttonHangup.getTag();
if (call != null)
call.notifyServiceHangup(service);
}
@Override
public void onCallSelected(SipCall c) {
// launchCallActivity(c.mCallInfo);
......@@ -401,13 +393,10 @@ public class SFLPhoneHomeActivity extends Activity implements ActionBar.TabListe
@Override
public void incomingCall(Intent call) {
Toast.makeText(this, "New Call incoming", Toast.LENGTH_LONG).show();
SipCall.CallInfo infos = new SipCall.CallInfo(call);
SipCall c = new SipCall(infos);
mCallElementList.addCall(c);
SipCall infos = call.getParcelableExtra("newcall");
mCallElementList.addCall(infos);
CallContact.ContactBuilder builder = new ContactBuilder();
infos.contacts.add(builder.buildUnknownContact(infos.mPhone));
launchCallActivity(infos, CallManagerCallBack.INCOMING_CALL);
}
......@@ -433,42 +422,35 @@ public class SFLPhoneHomeActivity extends Activity implements ActionBar.TabListe
@Override
public void onContactSelected(CallContact c) {
String callID = Integer.toString(new Random().nextInt());
SipCall.CallInfo info = new SipCall.CallInfo();
info.mCallID = callID;
SipCall.SipCallBuilder callBuilder = SipCall.SipCallBuilder.getInstance();
try {
info.mAccountID = service.getAccountList().get(1).toString();
} catch (RemoteException e) {
Log.e(TAG, e.toString());
callBuilder.startCallCreation().setAccountID(service.getAccountList().get(1).toString()).setCallType(SipCall.state.CALL_TYPE_OUTGOING);
} catch (RemoteException e1) {
Log.e(TAG,e1.toString());
}
info.mDisplayName = c.getmDisplayName();
info.mPhone = c.getSipPhone().getNumber();
info.mEmail = c.getmEmail();
info.mCallType = SipCall.CALL_TYPE_OUTGOING;
info.contacts.add(c);
callBuilder.addContact(c);
launchCallActivity(info, "call");
try {
launchCallActivity(callBuilder.build(), "call");
} catch (Exception e) {
Log.e(TAG, e.toString());
}
}
@Override
public void onCallDialed(String accountID, String to) {
Random random = new Random();
String callID = Integer.toString(random.nextInt());
SipCall.CallInfo info = new SipCall.CallInfo();
info.mCallID = callID;
info.mAccountID = accountID;
info.mDisplayName = "Username";
info.mPhone = to;
info.mEmail = "username@xxxx.com";
info.mCallType = SipCall.CALL_TYPE_OUTGOING;
CallContact.ContactBuilder builder = new ContactBuilder();
info.contacts.add(builder.buildUnknownContact(info.mPhone));
SipCall.SipCallBuilder callBuilder = SipCall.SipCallBuilder.getInstance();
callBuilder.startCallCreation().setAccountID(accountID).setCallType(SipCall.state.CALL_TYPE_OUTGOING);
callBuilder.addContact(CallContact.ContactBuilder.buildUnknownContact(to));
launchCallActivity(info, "call");
try {
launchCallActivity(callBuilder.build(), "call");
} catch (Exception e) {
Log.e(TAG, e.toString());
}
}
......
......@@ -147,7 +147,7 @@ public class CallElementListFragment extends ListFragment {
*/
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;
......@@ -189,7 +189,7 @@ public class CallElementListFragment extends ListFragment {
// // FIXME
// service = sflphoneApplication.getSipService();
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle("Action to perform with " + call.mCallInfo.mDisplayName).setCancelable(true)
builder.setTitle("Action to perform with " + call.getContacts().get(0).getmDisplayName()).setCancelable(true)
.setItems(items, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int item) {
......
/*
* Copyright (C) 2004-2012 Savoir-Faire Linux Inc.
*
* Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Additional permission under GNU GPL version 3 section 7:
*
* If you modify this program, or any covered work, by linking or
* combining it with the OpenSSL project's OpenSSL library (or a
* modified version of that library), containing parts covered by the
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
* grants you additional permission to convey the resulting work.
* Corresponding Source for a non-source form of such a combination
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
package com.savoirfairelinux.sflphone.fragments;
import java.util.HashMap;
......@@ -81,6 +112,12 @@ public class CallFragment extends Fragment {
mCallbacks = (Callbacks) activity;
}
@Override
public void onDetach() {
super.onDetach();
mCallbacks = sDummyCallbacks;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
......@@ -91,13 +128,12 @@ public class CallFragment extends Fragment {
Bundle b = getArguments();
SipCall.CallInfo info = b.getParcelable("CallInfo");
Log.i(TAG, "Starting fragment for call " + info.mCallID);
mCall = new SipCall(info);
mCall = b.getParcelable("CallInfo");
Log.i(TAG, "Starting fragment for call " + mCall.getCallId());
String pendingAction = b.getString("action");
if (pendingAction != null && pendingAction.contentEquals("call")) {
callContact(info);
callContact(mCall);
} else if (pendingAction.equals(CallManagerCallBack.INCOMING_CALL)) {
callIncoming();
}
......@@ -105,11 +141,11 @@ public class CallFragment extends Fragment {
return rootView;
}
private void callContact(SipCall.CallInfo infos) {
private void callContact(SipCall infos) {
// TODO off-thread image loading
Bubble contact_bubble;
if (infos.contacts.get(0).getPhoto_id() > 0) {
Bitmap photo = ContactPictureLoader.loadContactPhoto(getActivity().getContentResolver(), infos.contacts.get(0).getId());
if (infos.getContacts().get(0).getPhoto_id() > 0) {
Bitmap photo = ContactPictureLoader.loadContactPhoto(getActivity().getContentResolver(), infos.getContacts().get(0).getId());
contact_bubble = new Bubble(getActivity(), screenCenter.x, screenCenter.y, 150, photo);
} else {
contact_bubble = new Bubble(getActivity(), screenCenter.x, screenCenter.y, 150, R.drawable.ic_contact_picture);
......@@ -124,12 +160,12 @@ public class CallFragment extends Fragment {
}
}));
contact_bubble.contact = infos.contacts.get(0);
contact_bubble.contact = infos.getContacts().get(0);
model.listBubbles.add(contact_bubble);
contacts.put(infos.contacts.get(0), contact_bubble);
contacts.put(infos.getContacts().get(0), contact_bubble);
try {
mCallbacks.getService().placeCall(infos.mAccountID, infos.mCallID, infos.mPhone);
mCallbacks.getService().placeCall(infos);
} catch (RemoteException e) {
Log.e(TAG, e.toString());
}
......@@ -152,8 +188,6 @@ public class CallFragment extends Fragment {
}
public void onCallAccepted() {
mCall.notifyServiceAnswer(mCallbacks.getService());
......@@ -189,15 +223,14 @@ public class CallFragment extends Fragment {
}
public void onSendMessage(String msg) {
mCall.notifyServiceSendMsg(mCallbacks.getService(), msg);
}
// public void onSendMessage(String msg) {
// mCall.notifyServiceSendMsg(mCallbacks.getService(), msg);
//
// }
public void changeCallState(int callState) {
mCall.setCallState(callState);
}
}
/*
* Copyright (C) 2004-2012 Savoir-Faire Linux Inc.
*
* Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Additional permission under GNU GPL version 3 section 7:
*
* If you modify this program, or any covered work, by linking or
* combining it with the OpenSSL project's OpenSSL library (or a
* modified version of that library), containing parts covered by the
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
* grants you additional permission to convey the resulting work.
* Corresponding Source for a non-source form of such a combination
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
package com.savoirfairelinux.sflphone.fragments;
import java.util.ArrayList;
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 com.savoirfairelinux.sflphone.R;
import com.savoirfairelinux.sflphone.adapters.CallListAdapter;
import com.savoirfairelinux.sflphone.model.SipCall;
import com.savoirfairelinux.sflphone.service.ISipService;
public class CallListFragment extends Fragment {
static final String TAG = "CallFragment";
private Callbacks mCallbacks = sDummyCallbacks;
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);
}
/**
* A dummy implementation of the {@link Callbacks} interface that does nothing. Used only when this fragment is not attached to an activity.
*/
private static Callbacks sDummyCallbacks = new Callbacks() {
@Override
public ISipService getService() {
// TODO Auto-generated method stub
return null;
}
};
/**
* The Activity calling this fragment has to implement this interface
*
*/
public interface Callbacks {
public ISipService getService();
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
if (!(activity instanceof Callbacks)) {
throw new IllegalStateException("Activity must implement fragment's callbacks.");
}
mCallbacks = (Callbacks) activity;
}
@Override
public void onDetach() {
super.onDetach();
mCallbacks = sDummyCallbacks;
}
@Override
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);
expandbleLis.setAdapter(mAdapter);
return rootView;
}
public void update() {
try {
HashMap<String, SipCall> list = (HashMap<String, SipCall>) mCallbacks.getService().getCallList();
} catch (RemoteException e) {
Log.e(TAG, e.toString());
}
}
}
......@@ -123,6 +123,12 @@ public class ContactListFragment extends Fragment implements OnQueryTextListener
mCallbacks = (Callbacks) activity;
}
@Override
public void onDetach() {
super.onDetach();
mCallbacks = sDummyCallbacks;
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
......
......@@ -152,8 +152,8 @@ public class CallContact implements Parcelable {
return new ContactBuilder();
}
public CallContact buildUnknownContact(String to) {
phones = new ArrayList<Phone>();
public static CallContact buildUnknownContact(String to) {
ArrayList<Phone> phones = new ArrayList<Phone>();
phones.add(new Phone(to, 0));
return new CallContact(-1, to, 0, phones, new ArrayList<CallContact.Phone>(), "");
......
package com.savoirfairelinux.sflphone.model;
parcelable SipCall;
\ No newline at end of file
This diff is collapsed.
......@@ -81,7 +81,6 @@ public class CallManagerCallBack extends Callback {
bundle.putString("CallID", callID);
bundle.putString("State", state);
Intent intent = new Intent(CALL_STATE_CHANGED);
intent.putExtra(SIGNAL_NAME, CALL_STATE_CHANGED);
intent.putExtra("com.savoirfairelinux.sflphone.service.newstate", bundle);
LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
}
......
package com.savoirfairelinux.sflphone.service;
import com.savoirfairelinux.sflphone.model.SipCall;
interface ISipService {
void placeCall(String accountID, in String callID, in String to);
/*void placeCall(String accountID, in String callID, in String to);*/
void placeCall(in SipCall call);
void refuse(in String callID);
void accept(in String callID);
void hangUp(in String callID);
......@@ -44,7 +46,7 @@ interface ISipService {
void holdConference(in String confID);
void unholdConference(in String confID);
List getConferenceList();
List getCallList();
Map getCallList();
List getParticipantList(in String confID);
String getConferenceId(in String callID);
Map getConferenceDetails(in String callID);
......
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