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

* #30226: first implementation on Home screen

parent 98c21bf0
No related branches found
No related tags found
No related merge requests found
...@@ -161,6 +161,13 @@ public class SFLPhoneHomeActivity extends Activity implements DialingFragment.Ca ...@@ -161,6 +161,13 @@ public class SFLPhoneHomeActivity extends Activity implements DialingFragment.Ca
// Set up the ViewPager with the sections adapter. // Set up the ViewPager with the sections adapter.
mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager = (ViewPager) findViewById(R.id.pager);
mViewPager.setPageTransformer(true, new ZoomOutPageTransformer(0.7f)); mViewPager.setPageTransformer(true, new ZoomOutPageTransformer(0.7f));
final PagerTabStrip strip = PagerTabStrip.class.cast(mViewPager.findViewById(R.id.pts_main));
strip.setDrawFullUnderline(false);
strip.setTabIndicatorColor(getResources().getColor(R.color.holo_blue_dark));
strip.setBackgroundColor(getResources().getColor(R.color.darker_gray));
strip.setNonPrimaryAlpha(0.5f);
strip.setTextSpacing(25);
strip.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
mTitle = mDrawerTitle = getTitle(); mTitle = mDrawerTitle = getTitle();
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
...@@ -342,13 +349,7 @@ public class SFLPhoneHomeActivity extends Activity implements DialingFragment.Ca ...@@ -342,13 +349,7 @@ public class SFLPhoneHomeActivity extends Activity implements DialingFragment.Ca
getFragmentManager().beginTransaction().replace(R.id.left_drawer, fMenu).commit(); getFragmentManager().beginTransaction().replace(R.id.left_drawer, fMenu).commit();
mSectionsPagerAdapter = new SectionsPagerAdapter(SFLPhoneHomeActivity.this, getFragmentManager()); mSectionsPagerAdapter = new SectionsPagerAdapter(SFLPhoneHomeActivity.this, getFragmentManager());
final PagerTabStrip strip = PagerTabStrip.class.cast(mViewPager.findViewById(R.id.pts_main));
strip.setDrawFullUnderline(false);
strip.setTabIndicatorColor(getResources().getColor(R.color.holo_blue_dark));
strip.setBackgroundColor(getResources().getColor(R.color.darker_gray));
strip.setNonPrimaryAlpha(0.5f);
strip.setTextSpacing(25);
strip.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
// initialiseTabHost(null); // initialiseTabHost(null);
mViewPager.setOffscreenPageLimit(2); mViewPager.setOffscreenPageLimit(2);
......
...@@ -30,16 +30,23 @@ ...@@ -30,16 +30,23 @@
*/ */
package com.savoirfairelinux.sflphone.fragments; package com.savoirfairelinux.sflphone.fragments;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Locale;
import java.util.Observable; import java.util.Observable;
import java.util.Observer; import java.util.Observer;
import java.util.TimeZone;
import android.app.Activity; import android.app.Activity;
import android.app.Fragment; import android.app.Fragment;
import android.content.Context; import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler;
import android.os.RemoteException; import android.os.RemoteException;
import android.os.SystemClock;
import android.text.format.DateFormat;
import android.util.Log; import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
...@@ -109,24 +116,49 @@ public class HomeFragment extends Fragment { ...@@ -109,24 +116,49 @@ public class HomeFragment extends Fragment {
} }
private Runnable mUpdateTimeTask = new Runnable() {
public void run() {
final long start = SystemClock.uptimeMillis();
long millis = SystemClock.uptimeMillis() - start;
int seconds = (int) (millis / 1000);
int minutes = seconds / 60;
seconds = seconds % 60;
calls_adapter.notifyDataSetChanged();
mHandler.postAtTime(this, start + (((minutes * 60) + seconds + 1) * 1000));
}
};
private Handler mHandler = new Handler();
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
if (mCallbacks.getService() != null) { if (mCallbacks.getService() != null) {
try { try {
timer = new CallTimer(); // timer = new CallTimer();
updateLists(); updateLists();
if (!calls_adapter.isEmpty() || !confs_adapter.isEmpty()) { if (!calls_adapter.isEmpty() || !confs_adapter.isEmpty()) {
timer.addObserver(calls_adapter); mHandler.postDelayed(mUpdateTimeTask, 0);
timer.addObserver(confs_adapter);
new Thread(timer).start(); //
// timer.addObserver(calls_adapter);
// timer.addObserver(confs_adapter);
// TimerTask test = new TimerTask() {
//
// @Override
// public void run() {
// timer.run();
// }
// };
//
} }
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, e.toString()); Log.e(TAG, e.toString());
} }
...@@ -134,7 +166,6 @@ public class HomeFragment extends Fragment { ...@@ -134,7 +166,6 @@ public class HomeFragment extends Fragment {
} }
public void updateLists() throws RemoteException { public void updateLists() throws RemoteException {
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();
...@@ -145,7 +176,7 @@ public class HomeFragment extends Fragment { ...@@ -145,7 +176,7 @@ 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())); confs_adapter.updateDataset(new ArrayList<Conference>(confs.values()));
} }
private void updateCallList(HashMap<String, SipCall> calls) { private void updateCallList(HashMap<String, SipCall> calls) {
...@@ -158,7 +189,7 @@ public class HomeFragment extends Fragment { ...@@ -158,7 +189,7 @@ public class HomeFragment extends Fragment {
conferences.add(confOne); conferences.add(confOne);
} }
calls_adapter.update(conferences); calls_adapter.updateDataset(conferences);
} }
...@@ -225,7 +256,6 @@ public class HomeFragment extends Fragment { ...@@ -225,7 +256,6 @@ public class HomeFragment extends Fragment {
} }
}; };
public class CallListAdapter extends BaseAdapter implements Observer { public class CallListAdapter extends BaseAdapter implements Observer {
private ArrayList<Conference> calls; private ArrayList<Conference> calls;
...@@ -247,7 +277,7 @@ public class HomeFragment extends Fragment { ...@@ -247,7 +277,7 @@ public class HomeFragment extends Fragment {
} }
public void update(ArrayList<Conference> list) { public void updateDataset(ArrayList<Conference> list) {
calls.clear(); calls.clear();
calls.addAll(list); calls.addAll(list);
notifyDataSetChanged(); notifyDataSetChanged();
...@@ -276,6 +306,10 @@ public class HomeFragment extends Fragment { ...@@ -276,6 +306,10 @@ public class HomeFragment extends Fragment {
Conference call = calls.get(position); Conference call = calls.get(position);
if (call.getParticipants().size() == 1) { if (call.getParticipants().size() == 1) {
((TextView) convertView.findViewById(R.id.call_title)).setText(call.getParticipants().get(0).getContact().getmDisplayName()); ((TextView) convertView.findViewById(R.id.call_title)).setText(call.getParticipants().get(0).getContact().getmDisplayName());
long duration = System.currentTimeMillis() / 1000 - (call.getParticipants().get(0).getTimestamp_start());
((TextView) convertView.findViewById(R.id.call_time)).setText(String.format("%d:%02d:%02d", duration/3600, (duration%3600)/60, (duration%60)));
} else { } else {
String tmp = "Conference with " + call.getParticipants().size() + " participants"; String tmp = "Conference with " + call.getParticipants().size() + " participants";
((TextView) convertView.findViewById(R.id.call_title)).setText(tmp); ((TextView) convertView.findViewById(R.id.call_title)).setText(tmp);
...@@ -290,6 +324,7 @@ public class HomeFragment extends Fragment { ...@@ -290,6 +324,7 @@ public class HomeFragment extends Fragment {
@Override @Override
public void update(Observable observable, Object data) { public void update(Observable observable, Object data) {
Log.i(TAG, "Updating views..."); Log.i(TAG, "Updating views...");
notifyDataSetChanged();
} }
} }
......
...@@ -69,6 +69,7 @@ public class SipCall implements Parcelable { ...@@ -69,6 +69,7 @@ public class SipCall implements Parcelable {
mCallType = in.readInt(); mCallType = in.readInt();
mCallState = in.readInt(); mCallState = in.readInt();
mMediaState = in.readInt(); mMediaState = in.readInt();
timestamp_start = in.readLong();
} }
...@@ -123,6 +124,7 @@ public class SipCall implements Parcelable { ...@@ -123,6 +124,7 @@ public class SipCall implements Parcelable {
out.writeInt(mCallType); out.writeInt(mCallType);
out.writeInt(mCallState); out.writeInt(mCallState);
out.writeInt(mMediaState); out.writeInt(mMediaState);
out.writeLong(timestamp_start);
} }
public static final Parcelable.Creator<SipCall> CREATOR = new Parcelable.Creator<SipCall>() { public static final Parcelable.Creator<SipCall> CREATOR = new Parcelable.Creator<SipCall>() {
......
package com.savoirfairelinux.sflphone.receivers; package com.savoirfairelinux.sflphone.receivers;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map.Entry; import java.util.Map.Entry;
...@@ -11,13 +12,16 @@ import android.os.Bundle; ...@@ -11,13 +12,16 @@ import android.os.Bundle;
import android.os.RemoteException; import android.os.RemoteException;
import android.util.Log; import android.util.Log;
import com.savoirfairelinux.sflphone.account.CallDetailsHandler;
import com.savoirfairelinux.sflphone.model.CallContact; import com.savoirfairelinux.sflphone.model.CallContact;
import com.savoirfairelinux.sflphone.model.Conference; import com.savoirfairelinux.sflphone.model.Conference;
import com.savoirfairelinux.sflphone.model.SipCall; import com.savoirfairelinux.sflphone.model.SipCall;
import com.savoirfairelinux.sflphone.service.CallManagerCallBack; import com.savoirfairelinux.sflphone.service.CallManagerCallBack;
import com.savoirfairelinux.sflphone.service.ConfigurationManagerCallback; import com.savoirfairelinux.sflphone.service.ConfigurationManagerCallback;
import com.savoirfairelinux.sflphone.service.ServiceConstants;
import com.savoirfairelinux.sflphone.service.ISipService.Stub; import com.savoirfairelinux.sflphone.service.ISipService.Stub;
import com.savoirfairelinux.sflphone.service.SipService; import com.savoirfairelinux.sflphone.service.SipService;
import com.savoirfairelinux.sflphone.service.StringMap;
public class IncomingReceiver extends BroadcastReceiver { public class IncomingReceiver extends BroadcastReceiver {
...@@ -61,6 +65,8 @@ public class IncomingReceiver extends BroadcastReceiver { ...@@ -61,6 +65,8 @@ public class IncomingReceiver extends BroadcastReceiver {
try { try {
SipCall newCall = callBuilder.build(); SipCall newCall = callBuilder.build();
toSend.putExtra("newcall", newCall); toSend.putExtra("newcall", newCall);
HashMap<String, String> details = (HashMap<String, String>) mBinder.getCallDetails(b.getString("CallID"));
newCall.setTimestamp_start(Long.parseLong(details.get(ServiceConstants.call.TIMESTAMP_START)));
callback.getCurrent_calls().put(newCall.getCallId(), newCall); callback.getCurrent_calls().put(newCall.getCallId(), newCall);
callback.sendBroadcast(toSend); callback.sendBroadcast(toSend);
} catch (Exception e) { } catch (Exception e) {
......
...@@ -360,6 +360,7 @@ public class SipService extends Service { ...@@ -360,6 +360,7 @@ public class SipService extends Service {
callManagerJNI.placeCall(call.getAccountID(), call.getCallId(), call.getContact().getPhones().get(0).getNumber()); callManagerJNI.placeCall(call.getAccountID(), call.getCallId(), call.getContact().getPhones().get(0).getNumber());
HashMap<String, String> details = CallDetailsHandler.convertSwigToNative(callManagerJNI.getCallDetails(call.getCallId())); HashMap<String, String> details = CallDetailsHandler.convertSwigToNative(callManagerJNI.getCallDetails(call.getCallId()));
// watchout timestamp stored by sflphone is in seconds
call.setTimestamp_start(Long.parseLong(details.get(ServiceConstants.call.TIMESTAMP_START))); call.setTimestamp_start(Long.parseLong(details.get(ServiceConstants.call.TIMESTAMP_START)));
getCurrent_calls().put(call.getCallId(), call); getCurrent_calls().put(call.getCallId(), call);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment