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
......@@ -145,7 +145,7 @@ public class SFLPhoneHomeActivity extends Activity implements DialingFragment.Ca
Intent intent = new Intent(this, SipService.class);
bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
}
if (mContactsFragment == null) {
mContactsFragment = new ContactListFragment();
Log.w(TAG, "Recreated mContactListFragment=" + mContactsFragment);
......@@ -161,6 +161,13 @@ public class SFLPhoneHomeActivity extends Activity implements DialingFragment.Ca
// Set up the ViewPager with the sections adapter.
mViewPager = (ViewPager) findViewById(R.id.pager);
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();
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
......@@ -342,13 +349,7 @@ public class SFLPhoneHomeActivity extends Activity implements DialingFragment.Ca
getFragmentManager().beginTransaction().replace(R.id.left_drawer, fMenu).commit();
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);
mViewPager.setOffscreenPageLimit(2);
......
......@@ -30,16 +30,23 @@
*/
package com.savoirfairelinux.sflphone.fragments;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Locale;
import java.util.Observable;
import java.util.Observer;
import java.util.TimeZone;
import android.app.Activity;
import android.app.Fragment;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.os.RemoteException;
import android.os.SystemClock;
import android.text.format.DateFormat;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
......@@ -62,10 +69,10 @@ public class HomeFragment extends Fragment {
private static final String TAG = HomeFragment.class.getSimpleName();
private Callbacks mCallbacks = sDummyCallbacks;
// Button access_calls;
// Button access_calls;
TextView nb_calls, nb_confs;
CallListAdapter confs_adapter;
CallTimer timer;
CallTimer timer;
private CallListAdapter calls_adapter;
......@@ -109,23 +116,48 @@ 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
public void onResume() {
super.onResume();
if (mCallbacks.getService() != null) {
try {
timer = new CallTimer();
// timer = new CallTimer();
updateLists();
if(!calls_adapter.isEmpty() || !confs_adapter.isEmpty()){
timer.addObserver(calls_adapter);
timer.addObserver(confs_adapter);
new Thread(timer).start();
if (!calls_adapter.isEmpty() || !confs_adapter.isEmpty()) {
mHandler.postDelayed(mUpdateTimeTask, 0);
//
// timer.addObserver(calls_adapter);
// timer.addObserver(confs_adapter);
// TimerTask test = new TimerTask() {
//
// @Override
// public void run() {
// timer.run();
// }
// };
//
}
} catch (RemoteException e) {
Log.e(TAG, e.toString());
......@@ -134,7 +166,6 @@ public class HomeFragment extends Fragment {
}
public void updateLists() throws RemoteException {
HashMap<String, SipCall> calls = (HashMap<String, SipCall>) mCallbacks.getService().getCallList();
HashMap<String, Conference> confs = (HashMap<String, Conference>) mCallbacks.getService().getConferenceList();
......@@ -145,7 +176,7 @@ public class HomeFragment extends Fragment {
private void updateConferenceList(HashMap<String, Conference> confs) {
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) {
......@@ -158,7 +189,7 @@ public class HomeFragment extends Fragment {
conferences.add(confOne);
}
calls_adapter.update(conferences);
calls_adapter.updateDataset(conferences);
}
......@@ -179,7 +210,7 @@ public class HomeFragment extends Fragment {
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
// Give some text to display if there is no data. In a real
......@@ -216,15 +247,14 @@ public class HomeFragment extends Fragment {
return inflatedView;
}
OnItemClickListener callClickListener= new OnItemClickListener() {
OnItemClickListener callClickListener = new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View v, int arg2, long arg3) {
mCallbacks.selectedCall((Conference)v.getTag());
mCallbacks.selectedCall((Conference) v.getTag());
}
};
public class CallListAdapter extends BaseAdapter implements Observer {
......@@ -247,7 +277,7 @@ public class HomeFragment extends Fragment {
}
public void update(ArrayList<Conference> list) {
public void updateDataset(ArrayList<Conference> list) {
calls.clear();
calls.addAll(list);
notifyDataSetChanged();
......@@ -276,6 +306,10 @@ public class HomeFragment extends Fragment {
Conference call = calls.get(position);
if (call.getParticipants().size() == 1) {
((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 {
String tmp = "Conference with " + call.getParticipants().size() + " participants";
((TextView) convertView.findViewById(R.id.call_title)).setText(tmp);
......@@ -289,7 +323,8 @@ public class HomeFragment extends Fragment {
@Override
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 {
mCallType = in.readInt();
mCallState = in.readInt();
mMediaState = in.readInt();
timestamp_start = in.readLong();
}
......@@ -123,6 +124,7 @@ public class SipCall implements Parcelable {
out.writeInt(mCallType);
out.writeInt(mCallState);
out.writeInt(mMediaState);
out.writeLong(timestamp_start);
}
public static final Parcelable.Creator<SipCall> CREATOR = new Parcelable.Creator<SipCall>() {
......
package com.savoirfairelinux.sflphone.receivers;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
......@@ -11,13 +12,16 @@ import android.os.Bundle;
import android.os.RemoteException;
import android.util.Log;
import com.savoirfairelinux.sflphone.account.CallDetailsHandler;
import com.savoirfairelinux.sflphone.model.CallContact;
import com.savoirfairelinux.sflphone.model.Conference;
import com.savoirfairelinux.sflphone.model.SipCall;
import com.savoirfairelinux.sflphone.service.CallManagerCallBack;
import com.savoirfairelinux.sflphone.service.ConfigurationManagerCallback;
import com.savoirfairelinux.sflphone.service.ServiceConstants;
import com.savoirfairelinux.sflphone.service.ISipService.Stub;
import com.savoirfairelinux.sflphone.service.SipService;
import com.savoirfairelinux.sflphone.service.StringMap;
public class IncomingReceiver extends BroadcastReceiver {
......@@ -61,6 +65,8 @@ public class IncomingReceiver extends BroadcastReceiver {
try {
SipCall newCall = callBuilder.build();
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.sendBroadcast(toSend);
} catch (Exception e) {
......@@ -122,7 +128,7 @@ public class IncomingReceiver extends BroadcastReceiver {
}
}
callback.sendBroadcast(intent);
} else if (newState.equals("BUSY")) {
......
......@@ -360,6 +360,7 @@ public class SipService extends Service {
callManagerJNI.placeCall(call.getAccountID(), call.getCallId(), call.getContact().getPhones().get(0).getNumber());
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)));
getCurrent_calls().put(call.getCallId(), call);
......
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