* #29924: removed sliding incall panel
diff --git a/src/com/savoirfairelinux/sflphone/client/CallActivity.java b/src/com/savoirfairelinux/sflphone/client/CallActivity.java
index d92b53f..1306e73 100644
--- a/src/com/savoirfairelinux/sflphone/client/CallActivity.java
+++ b/src/com/savoirfairelinux/sflphone/client/CallActivity.java
@@ -74,11 +74,11 @@
CallPaneLayout slidingPaneLayout;
- CallListFragment mCallsFragment;
+// CallListFragment mCallsFragment;
CallFragment mCurrentCallFragment;
private boolean fragIsChanging;
- /* result code sent in c&ase of call failure */
+ /* result code sent in case of call failure */
public static int RESULT_FAILURE = -10;
@Override
@@ -88,9 +88,9 @@
receiver = new CallReceiver(this);
- mCallsFragment = new CallListFragment();
+// mCallsFragment = new CallListFragment();
- getFragmentManager().beginTransaction().replace(R.id.calllist_pane, mCallsFragment).commit();
+// getFragmentManager().beginTransaction().replace(R.id.calllist_pane, mCallsFragment).commit();
slidingPaneLayout = (CallPaneLayout) findViewById(R.id.slidingpanelayout);
@@ -116,26 +116,25 @@
@Override
public void onPanelClosed(View view) {
- switch (view.getId()) {
- case R.id.ongoingcall_pane:
- if (fragIsChanging) {
- getFragmentManager().beginTransaction().replace(R.id.ongoingcall_pane, mCurrentCallFragment).commit();
-
- fragIsChanging = false;
- } else if (mCurrentCallFragment != null && mCurrentCallFragment.getBubbleView() != null) {
- mCurrentCallFragment.getBubbleView().restartDrawing();
- }
-
- break;
- default:
- break;
- }
+// switch (view.getId()) {
+// case R.id.ongoingcall_pane:
+// if (fragIsChanging) {
+// getFragmentManager().beginTransaction().replace(R.id.ongoingcall_pane, mCurrentCallFragment).commit();
+//
+// fragIsChanging = false;
+// } else if (mCurrentCallFragment != null && mCurrentCallFragment.getBubbleView() != null) {
+// mCurrentCallFragment.getBubbleView().restartDrawing();
+// }
+//
+// break;
+// default:
+// break;
+// }
}
});
Intent intent = new Intent(this, SipService.class);
bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
- slidingPaneLayout.setCoveredFadeColor(0xFF0000);
}
/* activity gets back to the foreground and user input */
@@ -161,7 +160,7 @@
public void run() {
if(mCurrentCallFragment != null)
mCurrentCallFragment.updateTime();
- mCallsFragment.update();
+// mCallsFragment.update();
mHandler.postAtTime(this, SystemClock.uptimeMillis() + 1000);
}
@@ -235,9 +234,9 @@
}
- slidingPaneLayout.setCurFragment(mCurrentCallFragment);
+// slidingPaneLayout.setCurFragment(mCurrentCallFragment);
getIntent().getExtras();
- mCallsFragment.update();
+// mCallsFragment.update();
getFragmentManager().beginTransaction().replace(R.id.ongoingcall_pane, mCurrentCallFragment).commit();
}
@@ -251,7 +250,7 @@
public void incomingCall(Intent call) {
Toast.makeText(this, "New Call incoming", Toast.LENGTH_LONG).show();
- mCallsFragment.update();
+// mCallsFragment.update();
}
@@ -271,7 +270,7 @@
*/
// CallFragment fr = mCurrentCallFragment;
- mCallsFragment.update();
+// mCallsFragment.update();
if (mCurrentCallFragment != null)
mCurrentCallFragment.changeCallState(callID, newState);
@@ -329,7 +328,7 @@
// onCallResumed(calls.get(0));
// }
- slidingPaneLayout.setCurFragment(mCurrentCallFragment);
+// slidingPaneLayout.setCurFragment(mCurrentCallFragment);
slidingPaneLayout.closePane();
fragIsChanging = true;
@@ -467,18 +466,18 @@
@Override
public void confCreated(Intent intent) {
- mCallsFragment.update();
+// mCallsFragment.update();
}
@Override
public void confRemoved(Intent intent) {
- mCallsFragment.update();
+// mCallsFragment.update();
}
@Override
public void confChanged(Intent intent) {
- mCallsFragment.update();
+// mCallsFragment.update();
}
@Override
@@ -488,7 +487,7 @@
@Override
public void recordingChanged(Intent intent) {
- mCallsFragment.update();
+// mCallsFragment.update();
}
@Override
diff --git a/src/com/savoirfairelinux/sflphone/client/SFLphoneApplication.java b/src/com/savoirfairelinux/sflphone/client/SFLphoneApplication.java
index 4344cd9..bc3d7c8 100644
--- a/src/com/savoirfairelinux/sflphone/client/SFLphoneApplication.java
+++ b/src/com/savoirfairelinux/sflphone/client/SFLphoneApplication.java
@@ -84,20 +84,4 @@
{
sipService = service;
}
-
- public String getAppPath()
- {
- PackageManager pkgMng = getPackageManager();
- String pkgName = getPackageName();
-
- try {
- PackageInfo pkgInfo = pkgMng.getPackageInfo(pkgName, 0);
- pkgName = pkgInfo.applicationInfo.dataDir;
- } catch (NameNotFoundException e) {
- Log.w(TAG, "Error Package name not found ", e);
- }
-
- Log.d(TAG, "Application path: " + pkgName);
- return pkgName;
- }
}
diff --git a/src/com/savoirfairelinux/sflphone/fragments/CallFragment.java b/src/com/savoirfairelinux/sflphone/fragments/CallFragment.java
index 42c4f73..bdbf740 100644
--- a/src/com/savoirfairelinux/sflphone/fragments/CallFragment.java
+++ b/src/com/savoirfairelinux/sflphone/fragments/CallFragment.java
@@ -36,10 +36,15 @@
import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
+import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.PointF;
+import android.hardware.Sensor;
+import android.hardware.SensorEvent;
+import android.hardware.SensorEventListener;
+import android.hardware.SensorManager;
import android.os.Bundle;
import android.os.RemoteException;
import android.util.Log;
@@ -48,6 +53,7 @@
import android.view.SurfaceHolder.Callback;
import android.view.View;
import android.view.ViewGroup;
+import android.view.WindowManager;
import android.widget.TextView;
import android.widget.Toast;
@@ -60,7 +66,7 @@
import com.savoirfairelinux.sflphone.model.SipCall;
import com.savoirfairelinux.sflphone.service.ISipService;
-public class CallFragment extends Fragment implements Callback {
+public class CallFragment extends Fragment implements Callback, SensorEventListener {
static final String TAG = "CallFragment";
@@ -84,6 +90,10 @@
private Bitmap hangup_icon, transfer_icon;
private Bitmap call_icon;
+ private SensorManager mSensorManager;
+
+ private Sensor mSensor;
+
@Override
public void onCreate(Bundle savedBundle) {
super.onCreate(savedBundle);
@@ -92,6 +102,8 @@
model = new BubbleModel(getResources().getDisplayMetrics().density);
BUBBLE_SIZE = getResources().getDimension(R.dimen.bubble_size);
Log.e(TAG, "BUBBLE_SIZE " + BUBBLE_SIZE);
+ mSensorManager = (SensorManager) getActivity().getSystemService(Context.SENSOR_SERVICE);
+ mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
}
@@ -193,13 +205,13 @@
mCallbacks = (Callbacks) activity;
myself = SipCall.SipCallBuilder.buildMyselfCall(activity.getContentResolver(), "Me");
-
}
@Override
public void onDetach() {
super.onDetach();
mCallbacks = sDummyCallbacks;
+ mSensorManager.unregisterListener(this);
// rootView.requestDisallowInterceptTouchEvent(false);
}
@@ -209,6 +221,18 @@
}
@Override
+ public void onResume() {
+ super.onResume();
+ mSensorManager.registerListener(this, mSensor, SensorManager.SENSOR_DELAY_NORMAL);
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+ mSensorManager.unregisterListener(this);
+ }
+
+ @Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
SipCall transfer = null;
@@ -443,7 +467,7 @@
}
public void changeCallState(String callID, String newState) {
- Log.w(TAG, "Call :" + callID + newState);
+ Log.w(TAG, "Call :" + callID + " " + newState);
if (newState.contentEquals("FAILURE")) {
try {
mCallbacks.getService().hangUp(callID);
@@ -451,23 +475,19 @@
e.printStackTrace();
}
}
- if (conf.getParticipants() == null) {
- Log.w(TAG, "IT IS NULL");
- return;
- }
- Log.w(TAG, "conf.getParticipants().size():" + conf.getParticipants().size());
+ // Log.w(TAG, "conf.getParticipants().size():" + conf.getParticipants().size());
for (int i = 0; i < conf.getParticipants().size(); ++i) {
// conf.getParticipants().get(i).printCallInfo();
- Log.w(TAG, "Call id:" + conf.getParticipants().get(i).getCallId());
- Log.w(TAG, "Searching:" + callID);
+ // Log.w(TAG, "Call id:" + conf.getParticipants().get(i).getCallId());
+ // Log.w(TAG, "Searching:" + callID);
if (callID.equals(conf.getParticipants().get(i).getCallId())) {
if (newState.contentEquals("HUNGUP")) {
- Log.w(TAG, "Call hungup:" + conf.getParticipants().get(i).getContact().getmDisplayName());
+ // Log.w(TAG, "Call hungup:" + conf.getParticipants().get(i).getContact().getmDisplayName());
model.removeBubble(conf.getParticipants().get(i));
conf.getParticipants().remove(i);
} else {
- Log.w(TAG, "Call:" + conf.getParticipants().get(i).getContact().getmDisplayName() + " state:" + newState);
+ // Log.w(TAG, "Call:" + conf.getParticipants().get(i).getContact().getmDisplayName() + " state:" + newState);
conf.getParticipants().get(i).setCallState(newState);
}
}
@@ -545,7 +565,35 @@
public void updateTime() {
long duration = System.currentTimeMillis() / 1000 - this.conf.getParticipants().get(0).getTimestamp_start();
- callStatusTxt.setText(String.format("%d:%02d:%02d", duration/3600, duration%3600/60, duration%60));
+ callStatusTxt.setText(String.format("%d:%02d:%02d", duration / 3600, duration % 3600 / 60, duration % 60));
+
+ }
+
+ @Override
+ public void onAccuracyChanged(Sensor sensor, int accuracy) {
+ Log.i(TAG, "onAccuracyChanged");
+
+ }
+
+ @Override
+ public void onSensorChanged(SensorEvent event) {
+ Log.i(TAG, "onSensorChanged:" + event.sensor.getName());
+ Log.i(TAG, "onSensorChanged:" + event.sensor.getType());
+ if (event.values[0] == 0) {
+// PowerManager pm = (PowerManager) getActivity().getSystemService(Context.POWER_SERVICE);
+// pm.goToSleep(SystemClock.uptimeMillis());
+ WindowManager.LayoutParams params = getActivity().getWindow().getAttributes();
+ params.flags |= WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
+ params.screenBrightness = 0.004f;
+ getActivity().getWindow().setAttributes(params);
+// Settings.System.putInt(getActivity().getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT, 1000);
+ } else {
+ WindowManager.LayoutParams params = getActivity().getWindow().getAttributes();
+ params.flags = WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
+ params.screenBrightness = 1f;
+ getActivity().getWindow().setAttributes(params);
+ }
+ // Sensor.TYPE_PROXIMITY
}
}
diff --git a/src/com/savoirfairelinux/sflphone/fragments/HomeFragment.java b/src/com/savoirfairelinux/sflphone/fragments/HomeFragment.java
index cb6cb0b..1072562 100644
--- a/src/com/savoirfairelinux/sflphone/fragments/HomeFragment.java
+++ b/src/com/savoirfairelinux/sflphone/fragments/HomeFragment.java
@@ -37,24 +37,35 @@
import android.app.Activity;
import android.app.Fragment;
+import android.content.ClipData;
import android.content.Context;
+import android.content.Intent;
+import android.content.ClipData.Item;
+import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.os.RemoteException;
import android.os.SystemClock;
+import android.os.Vibrator;
import android.util.Log;
+import android.view.DragEvent;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.view.View.DragShadowBuilder;
+import android.view.View.OnDragListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
+import android.widget.AdapterView.OnItemLongClickListener;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;
+import android.widget.Toast;
import com.savoirfairelinux.sflphone.R;
+import com.savoirfairelinux.sflphone.fragments.CallListFragment.DropActionsChoice;
import com.savoirfairelinux.sflphone.model.CallTimer;
import com.savoirfairelinux.sflphone.model.Conference;
import com.savoirfairelinux.sflphone.model.SipCall;
@@ -64,11 +75,12 @@
private static final String TAG = HomeFragment.class.getSimpleName();
private Callbacks mCallbacks = sDummyCallbacks;
- TextView nb_calls, nb_confs;
- CallListAdapter confs_adapter;
+ private TextView nb_calls, nb_confs;
+ CallListAdapter confs_adapter, calls_adapter;
CallTimer timer;
-
- private CallListAdapter calls_adapter;
+
+ public static final int REQUEST_TRANSFER = 10;
+ public static final int REQUEST_CONF = 20;
/**
* A dummy implementation of the {@link Callbacks} interface that does nothing. Used only when this fragment is not attached to an activity.
@@ -133,7 +145,7 @@
try {
updateLists();
if (!calls_adapter.isEmpty() || !confs_adapter.isEmpty()) {
- mHandler.postDelayed(mUpdateTimeTask, 0);
+ mHandler.postDelayed(mUpdateTimeTask, 0);
}
} catch (RemoteException e) {
@@ -143,7 +155,8 @@
}
- @SuppressWarnings("unchecked") // No proper solution with HashMap runtime cast
+ @SuppressWarnings("unchecked")
+ // No proper solution with HashMap runtime cast
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();
@@ -183,9 +196,9 @@
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
-
+
@Override
- public void onPause(){
+ public void onPause() {
super.onPause();
mHandler.removeCallbacks(mUpdateTimeTask);
}
@@ -227,6 +240,9 @@
((ListView) inflatedView.findViewById(R.id.calls_list)).setOnItemClickListener(callClickListener);
((ListView) inflatedView.findViewById(R.id.confs_list)).setOnItemClickListener(callClickListener);
+ ((ListView) inflatedView.findViewById(R.id.calls_list)).setOnItemLongClickListener(mItemLongClickListener);
+ ((ListView) inflatedView.findViewById(R.id.confs_list)).setOnItemLongClickListener(mItemLongClickListener);
+
return inflatedView;
}
@@ -238,6 +254,25 @@
}
};
+ private OnItemLongClickListener mItemLongClickListener = new OnItemLongClickListener() {
+
+ @Override
+ public boolean onItemLongClick(AdapterView<?> adptv, View view, int pos, long arg3) {
+ final Vibrator vibe = (Vibrator) view.getContext().getSystemService(Context.VIBRATOR_SERVICE);
+ vibe.vibrate(80);
+ Intent i = new Intent();
+ Bundle b = new Bundle();
+ b.putParcelable("conference", (Conference) adptv.getAdapter().getItem(pos));
+ i.putExtra("bconference", b);
+
+ DragShadowBuilder shadowBuilder = new View.DragShadowBuilder(view);
+ ClipData data = ClipData.newIntent("conference", i);
+ view.startDrag(data, shadowBuilder, view, 0);
+ return false;
+ }
+
+ };
+
public class CallListAdapter extends BaseAdapter implements Observer {
private ArrayList<Conference> calls;
@@ -291,7 +326,8 @@
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)));
+ ((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);
@@ -299,7 +335,9 @@
// ((TextView) convertView.findViewById(R.id.num_participants)).setText("" + call.getParticipants().size());
((TextView) convertView.findViewById(R.id.call_status)).setText(call.getState());
+ convertView.setOnDragListener(dragListener);
convertView.setTag(call);
+
return convertView;
}
@@ -311,4 +349,144 @@
}
+ OnDragListener dragListener = new OnDragListener() {
+
+ @SuppressWarnings("deprecation")
+ // deprecated in API 16....
+ @Override
+ public boolean onDrag(View v, DragEvent event) {
+ switch (event.getAction()) {
+ case DragEvent.ACTION_DRAG_STARTED:
+ // Do nothing
+ Log.w(TAG, "ACTION_DRAG_STARTED");
+ break;
+ case DragEvent.ACTION_DRAG_ENTERED:
+ Log.w(TAG, "ACTION_DRAG_ENTERED");
+ v.setBackgroundColor(Color.GREEN);
+ break;
+ case DragEvent.ACTION_DRAG_EXITED:
+ Log.w(TAG, "ACTION_DRAG_EXITED");
+ v.setBackgroundDrawable(getResources().getDrawable(R.drawable.item_call_selector));
+ break;
+ case DragEvent.ACTION_DROP:
+ Log.w(TAG, "ACTION_DROP");
+ View view = (View) event.getLocalState();
+
+ Item i = event.getClipData().getItemAt(0);
+ Intent intent = i.getIntent();
+ intent.setExtrasClassLoader(Conference.class.getClassLoader());
+
+ Conference initial = (Conference) view.getTag();
+ Conference target = (Conference) v.getTag();
+
+ if (initial == target) {
+ return true;
+ }
+
+ DropActionsChoice dialog = DropActionsChoice.newInstance();
+ Bundle b = new Bundle();
+ b.putParcelable("call_initial", initial);
+ b.putParcelable("call_targeted", target);
+ dialog.setArguments(b);
+ dialog.setTargetFragment(HomeFragment.this, 0);
+ dialog.show(getFragmentManager(), "dialog");
+
+ // view.setBackgroundColor(Color.WHITE);
+ // v.setBackgroundColor(Color.BLACK);
+ break;
+ case DragEvent.ACTION_DRAG_ENDED:
+ Log.w(TAG, "ACTION_DRAG_ENDED");
+ View view1 = (View) event.getLocalState();
+ view1.setVisibility(View.VISIBLE);
+ v.setBackgroundDrawable(getResources().getDrawable(R.drawable.item_call_selector));
+ default:
+ break;
+ }
+ return true;
+ }
+
+ };
+
+ @Override
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
+ super.onActivityResult(requestCode, resultCode, data);
+ Conference transfer = null;
+ if (requestCode == REQUEST_TRANSFER) {
+ switch (resultCode) {
+ case 0:
+ Conference c = data.getParcelableExtra("target");
+ transfer = data.getParcelableExtra("transfer");
+ try {
+
+ mCallbacks.getService().attendedTransfer(transfer.getParticipants().get(0).getCallId(), c.getParticipants().get(0).getCallId());
+ calls_adapter.remove(transfer);
+ calls_adapter.remove(c);
+ calls_adapter.notifyDataSetChanged();
+ } catch (RemoteException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ Toast.makeText(getActivity(), "Transfer complete", Toast.LENGTH_LONG).show();
+ break;
+
+ case 1:
+ String to = data.getStringExtra("to_number");
+ transfer = data.getParcelableExtra("transfer");
+ try {
+ Toast.makeText(getActivity(), "Transferring " + transfer.getParticipants().get(0).getContact().getmDisplayName() + " to " + to,
+ Toast.LENGTH_SHORT).show();
+ mCallbacks.getService().transfer(transfer.getParticipants().get(0).getCallId(), to);
+ mCallbacks.getService().hangUp(transfer.getParticipants().get(0).getCallId());
+ } catch (RemoteException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ break;
+
+ default:
+ break;
+ }
+ } else if (requestCode == REQUEST_CONF) {
+ switch (resultCode) {
+ case 0:
+ Conference call_to_add = data.getParcelableExtra("transfer");
+ Conference call_target = data.getParcelableExtra("target");
+
+ bindCalls(call_to_add, call_target);
+ break;
+
+ default:
+ break;
+ }
+ }
+ }
+
+ private void bindCalls(Conference call_to_add, Conference call_target) {
+ try {
+
+ if (call_target.hasMultipleParticipants() && !call_to_add.hasMultipleParticipants()) {
+
+ mCallbacks.getService().addParticipant(call_to_add.getParticipants().get(0), call_target.getId());
+
+ } else if (call_target.hasMultipleParticipants() && call_to_add.hasMultipleParticipants()) {
+
+ // We join two conferences
+ mCallbacks.getService().joinConference(call_to_add.getId(), call_target.getId());
+
+ } else if (!call_target.hasMultipleParticipants() && call_to_add.hasMultipleParticipants()) {
+
+ mCallbacks.getService().addParticipant(call_target.getParticipants().get(0), call_to_add.getId());
+
+ } else {
+ // We join two single calls to create a conf
+ mCallbacks.getService().joinParticipant(call_to_add.getParticipants().get(0).getCallId(),
+ call_target.getParticipants().get(0).getCallId());
+ }
+
+ } catch (RemoteException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
}
diff --git a/src/com/savoirfairelinux/sflphone/model/Conference.java b/src/com/savoirfairelinux/sflphone/model/Conference.java
index ef0a2c8..3278c18 100644
--- a/src/com/savoirfairelinux/sflphone/model/Conference.java
+++ b/src/com/savoirfairelinux/sflphone/model/Conference.java
@@ -28,11 +28,9 @@
@Override
public void writeToParcel(Parcel out, int flags) {
-
out.writeString(id);
out.writeString(state);
out.writeTypedList(participants);
-
}
public static final Parcelable.Creator<Conference> CREATOR = new Parcelable.Creator<Conference>() {
@@ -46,12 +44,10 @@
};
private Conference(Parcel in) {
-
participants = new ArrayList<SipCall>();
id = in.readString();
state = in.readString();
in.readTypedList(participants, SipCall.CREATOR);
-
}
public Conference(String cID) {
diff --git a/src/com/savoirfairelinux/sflphone/views/CallPaneLayout.java b/src/com/savoirfairelinux/sflphone/views/CallPaneLayout.java
index 4082bde..e12d5b7 100644
--- a/src/com/savoirfairelinux/sflphone/views/CallPaneLayout.java
+++ b/src/com/savoirfairelinux/sflphone/views/CallPaneLayout.java
@@ -35,7 +35,9 @@
if(curFragment!=null && curFragment.draggingBubble()) {
return false;
}
- return super.onInterceptTouchEvent(event);
+
+ return false;
+// return super.onInterceptTouchEvent(event);
}
}