Skip to content
Snippets Groups Projects
Commit 6d75d060 authored by Alexandre Lision's avatar Alexandre Lision
Browse files

* #29924: added calls/confs list

parent 20532bcd
Branches
Tags
No related merge requests found
...@@ -40,7 +40,7 @@ as that of the covered work. ...@@ -40,7 +40,7 @@ as that of the covered work.
<RelativeLayout <RelativeLayout
android:id="@+id/calls_layouts" android:id="@+id/calls_layouts"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="100dp" android:layout_height="wrap_content"
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:layout_margin="10dp" android:layout_margin="10dp"
android:background="@drawable/item_call_selector" > android:background="@drawable/item_call_selector" >
...@@ -75,7 +75,6 @@ as that of the covered work. ...@@ -75,7 +75,6 @@ as that of the covered work.
android:id="@+id/calls_list" android:id="@+id/calls_list"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_below="@+id/linear1" > android:layout_below="@+id/linear1" >
</ListView> </ListView>
</RelativeLayout> </RelativeLayout>
...@@ -83,7 +82,7 @@ as that of the covered work. ...@@ -83,7 +82,7 @@ as that of the covered work.
<RelativeLayout <RelativeLayout
android:id="@+id/confs_layouts" android:id="@+id/confs_layouts"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="100dp" android:layout_height="wrap_content"
android:layout_below="@+id/calls_layouts" android:layout_below="@+id/calls_layouts"
android:layout_margin="10dp" android:layout_margin="10dp"
android:background="@drawable/item_call_selector" > android:background="@drawable/item_call_selector" >
...@@ -118,7 +117,6 @@ as that of the covered work. ...@@ -118,7 +117,6 @@ as that of the covered work.
android:id="@+id/confs_list" android:id="@+id/confs_list"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_below="@+id/linear2" > android:layout_below="@+id/linear2" >
</ListView> </ListView>
</RelativeLayout> </RelativeLayout>
......
...@@ -31,13 +31,11 @@ ...@@ -31,13 +31,11 @@
*/ */
package com.savoirfairelinux.sflphone.client; package com.savoirfairelinux.sflphone.client;
import java.util.HashMap;
import java.util.Timer; import java.util.Timer;
import java.util.TimerTask; import java.util.TimerTask;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.Dialog;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
...@@ -46,9 +44,6 @@ import android.content.IntentFilter; ...@@ -46,9 +44,6 @@ import android.content.IntentFilter;
import android.content.ServiceConnection; import android.content.ServiceConnection;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.database.Cursor; import android.database.Cursor;
import android.graphics.Color;
import android.media.AudioFormat;
import android.media.AudioTrack;
import android.os.Bundle; import android.os.Bundle;
import android.os.IBinder; import android.os.IBinder;
import android.os.RemoteException; import android.os.RemoteException;
...@@ -64,13 +59,11 @@ import android.util.TypedValue; ...@@ -64,13 +59,11 @@ import android.util.TypedValue;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.widget.RelativeLayout; import android.widget.RelativeLayout;
import android.widget.TabHost;
import android.widget.TabHost.TabContentFactory; import android.widget.TabHost.TabContentFactory;
import android.widget.Toast; import android.widget.Toast;
import com.savoirfairelinux.sflphone.R; import com.savoirfairelinux.sflphone.R;
import com.savoirfairelinux.sflphone.adapters.SectionsPagerAdapter; import com.savoirfairelinux.sflphone.adapters.SectionsPagerAdapter;
import com.savoirfairelinux.sflphone.client.AccountPreferenceActivity.result;
import com.savoirfairelinux.sflphone.fragments.ContactListFragment; import com.savoirfairelinux.sflphone.fragments.ContactListFragment;
import com.savoirfairelinux.sflphone.fragments.DialingFragment; import com.savoirfairelinux.sflphone.fragments.DialingFragment;
import com.savoirfairelinux.sflphone.fragments.HistoryFragment; import com.savoirfairelinux.sflphone.fragments.HistoryFragment;
......
...@@ -136,7 +136,6 @@ public class SFLPhonePreferenceActivity extends Activity implements ActionBar.Ta ...@@ -136,7 +136,6 @@ public class SFLPhonePreferenceActivity extends Activity implements ActionBar.Ta
@Override @Override
protected void onDestroy() { protected void onDestroy() {
Log.i(TAG, "onDestroy: stopping SipService...");
if (mBound) { if (mBound) {
unbindService(mConnection); unbindService(mConnection);
......
...@@ -456,7 +456,7 @@ public class CallListFragment extends Fragment { ...@@ -456,7 +456,7 @@ public class CallListFragment extends Fragment {
} }
public void remove(Conference transfer) { public void remove(Conference transfer) {
calls.remove(transfer);
} }
public void update(ArrayList<Conference> list) { public void update(ArrayList<Conference> list) {
......
...@@ -30,10 +30,12 @@ ...@@ -30,10 +30,12 @@
*/ */
package com.savoirfairelinux.sflphone.fragments; package com.savoirfairelinux.sflphone.fragments;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import android.app.Activity; import android.app.Activity;
import android.app.Fragment; import android.app.Fragment;
import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import android.os.RemoteException; import android.os.RemoteException;
import android.util.Log; import android.util.Log;
...@@ -43,10 +45,10 @@ import android.view.MenuInflater; ...@@ -43,10 +45,10 @@ import android.view.MenuInflater;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button; import android.widget.Button;
import android.widget.ListView; import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast;
import com.savoirfairelinux.sflphone.R; import com.savoirfairelinux.sflphone.R;
import com.savoirfairelinux.sflphone.model.Conference; import com.savoirfairelinux.sflphone.model.Conference;
...@@ -59,7 +61,10 @@ public class HomeFragment extends Fragment { ...@@ -59,7 +61,10 @@ public class HomeFragment extends Fragment {
private Callbacks mCallbacks = sDummyCallbacks; private Callbacks mCallbacks = sDummyCallbacks;
Button access_calls; Button access_calls;
TextView nb_calls, nb_confs; TextView nb_calls, nb_confs;
ListView list_calls, list_confs; ListView list_calls;
CallListAdapter confs_adapter;
private CallListAdapter calls_adapter;
/** /**
* A dummy implementation of the {@link Callbacks} interface that does nothing. Used only when this fragment is not attached to an activity. * A dummy implementation of the {@link Callbacks} interface that does nothing. Used only when this fragment is not attached to an activity.
...@@ -106,6 +111,7 @@ public class HomeFragment extends Fragment { ...@@ -106,6 +111,7 @@ public class HomeFragment extends Fragment {
super.onResume(); super.onResume();
if (mCallbacks.getService() != null) { if (mCallbacks.getService() != null) {
try { try {
HashMap<String, SipCall> calls = (HashMap<String, SipCall>) mCallbacks.getService().getCallList(); HashMap<String, SipCall> calls = (HashMap<String, SipCall>) mCallbacks.getService().getCallList();
HashMap<String, Conference> confs = (HashMap<String, Conference>) mCallbacks.getService().getConferenceList(); HashMap<String, Conference> confs = (HashMap<String, Conference>) mCallbacks.getService().getConferenceList();
...@@ -117,7 +123,6 @@ public class HomeFragment extends Fragment { ...@@ -117,7 +123,6 @@ public class HomeFragment extends Fragment {
} else { } else {
access_calls.setVisibility(View.GONE); access_calls.setVisibility(View.GONE);
} }
// access_calls.setText(calls.size() + " on going calls and "+confs.size()+" conferences");
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, e.toString()); Log.e(TAG, e.toString());
...@@ -128,10 +133,20 @@ public class HomeFragment extends Fragment { ...@@ -128,10 +133,20 @@ public class HomeFragment extends Fragment {
private void updateConferenceList(HashMap<String, Conference> confs) { private void updateConferenceList(HashMap<String, Conference> confs) {
nb_confs.setText("" + confs.size()); nb_confs.setText("" + confs.size());
confs_adapter.update(new ArrayList<Conference>(confs.values()));
} }
private void updateCallList(HashMap<String, SipCall> calls) { private void updateCallList(HashMap<String, SipCall> calls) {
nb_calls.setText("" + calls.size()); nb_calls.setText("" + calls.size());
ArrayList<Conference> conferences = new ArrayList<Conference>();
for (SipCall call : calls.values()) {
Log.w(TAG, "SimpleCall:" + call.getCallId());
Conference confOne = new Conference("-1");
confOne.getParticipants().add(call);
conferences.add(confOne);
}
calls_adapter.update(conferences);
} }
...@@ -177,31 +192,84 @@ public class HomeFragment extends Fragment { ...@@ -177,31 +192,84 @@ public class HomeFragment extends Fragment {
nb_calls = (TextView) inflatedView.findViewById(R.id.calls_counter); nb_calls = (TextView) inflatedView.findViewById(R.id.calls_counter);
nb_confs = (TextView) inflatedView.findViewById(R.id.confs_counter); nb_confs = (TextView) inflatedView.findViewById(R.id.confs_counter);
list_calls = (ListView) inflatedView.findViewById(R.id.calls_list); list_calls = (ListView) inflatedView.findViewById(R.id.calls_list);
list_confs = (ListView) inflatedView.findViewById(R.id.confs_list);
confs_adapter = new CallListAdapter(getActivity());
((ListView) inflatedView.findViewById(R.id.confs_list)).setAdapter(confs_adapter);
calls_adapter = new CallListAdapter(getActivity());
((ListView) inflatedView.findViewById(R.id.calls_list)).setAdapter(calls_adapter);
access_calls.setOnClickListener(new OnClickListener() { access_calls.setOnClickListener(new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
mCallbacks.resumeCallActivity();
}
});
try { return inflatedView;
HashMap<String, SipCall> calls = (HashMap<String, SipCall>) mCallbacks.getService().getCallList(); }
HashMap<String, Conference> confs = (HashMap<String, Conference>) mCallbacks.getService().getConferenceList();
if (calls.isEmpty() && confs.isEmpty()) {
Toast.makeText(getActivity(), "No calls", Toast.LENGTH_SHORT).show();
} else {
mCallbacks.resumeCallActivity(); public class CallListAdapter extends BaseAdapter {
private ArrayList<Conference> calls;
private Context mContext;
public CallListAdapter(Context act) {
super();
mContext = act;
calls = new ArrayList<Conference>();
} }
} catch (RemoteException e) {
Log.e(TAG, e.toString()); public void remove(Conference transfer) {
} }
public void update(ArrayList<Conference> list) {
calls.clear();
calls.addAll(list);
notifyDataSetChanged();
}
@Override
public int getCount() {
return calls.size();
}
@Override
public Conference getItem(int position) {
return calls.get(position);
}
@Override
public long getItemId(int position) {
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null)
convertView = LayoutInflater.from(mContext).inflate(R.layout.item_calllist, null);
Conference call = calls.get(position);
if (call.getParticipants().size() == 1) {
((TextView) convertView.findViewById(R.id.call_title)).setText(call.getParticipants().get(0).getContact().getmDisplayName());
} else {
String tmp = "Conference with " + call.getParticipants().size() + " participants";
// for (SipCall c : call.getParticipants()) {
// tmp += c.getContact().getmDisplayName() + " ";
// }
((TextView) convertView.findViewById(R.id.call_title)).setText(tmp);
}
// ((TextView) convertView.findViewById(R.id.num_participants)).setText("" + call.getParticipants().size());
((TextView) convertView.findViewById(R.id.call_status)).setText(call.getState());
convertView.setTag(call);
return convertView;
} }
});
return inflatedView;
} }
} }
...@@ -111,7 +111,6 @@ public class MenuFragment extends Fragment implements LoaderCallbacks<ArrayList< ...@@ -111,7 +111,6 @@ public class MenuFragment extends Fragment implements LoaderCallbacks<ArrayList<
mCallbacks = (Callbacks) activity; mCallbacks = (Callbacks) activity;
getLoaderManager().initLoader(LoaderConstants.ACCOUNTS_LOADER, null, this); getLoaderManager().initLoader(LoaderConstants.ACCOUNTS_LOADER, null, this);
} }
@Override @Override
...@@ -154,7 +153,6 @@ public class MenuFragment extends Fragment implements LoaderCallbacks<ArrayList< ...@@ -154,7 +153,6 @@ public class MenuFragment extends Fragment implements LoaderCallbacks<ArrayList<
getActivity().unregisterReceiver(accountReceiver); getActivity().unregisterReceiver(accountReceiver);
} }
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
View inflatedView = inflater.inflate(R.layout.frag_menu, parent, false); View inflatedView = inflater.inflate(R.layout.frag_menu, parent, false);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment