mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-18 11:58:09 +00:00
Add chat in call and fix call problems
This commit is contained in:
parent
a6447e7eaa
commit
b6722d7a65
11 changed files with 107 additions and 130 deletions
|
|
@ -56,6 +56,8 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_gravity="bottom"
|
||||
android:divider="@color/colorF"
|
||||
android:dividerHeight="1dp"
|
||||
android:orientation="vertical">
|
||||
</LinearLayout>
|
||||
|
||||
|
|
@ -85,7 +87,7 @@
|
|||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/contact_name"
|
||||
android:id="@+id/current_contact_name"
|
||||
style="@style/font13"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
@ -94,11 +96,11 @@
|
|||
android:layout_gravity="center"/>
|
||||
|
||||
<Chronometer
|
||||
android:id="@+id/call_timer"
|
||||
android:id="@+id/current_call_timer"
|
||||
style="@style/font11"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/contact_name"
|
||||
android:layout_below="@id/current_contact_name"
|
||||
android:layout_gravity="center"/>
|
||||
</LinearLayout>
|
||||
|
||||
|
|
@ -122,6 +124,8 @@
|
|||
<TextView
|
||||
android:text="@string/call_paused_by_remote"
|
||||
style="@style/font4"
|
||||
android:gravity="center"
|
||||
android:layout_margin="10dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"/>
|
||||
|
|
@ -144,9 +148,10 @@
|
|||
android:src="@drawable/switch_camera"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="80dp"
|
||||
android:padding="10dp"
|
||||
android:padding="15dp"
|
||||
android:contentDescription="@string/content_description_switch_camera"
|
||||
android:visibility="invisible"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_below="@+id/active_call_info"
|
||||
android:layout_alignParentLeft="true"/>
|
||||
</RelativeLayout>
|
||||
|
|
@ -170,8 +175,10 @@
|
|||
<TextView
|
||||
android:text="@string/no_current_call"
|
||||
style="@style/font4"
|
||||
android:gravity="center"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="10dp"
|
||||
android:layout_gravity="center"/>
|
||||
</LinearLayout>
|
||||
|
||||
|
|
@ -276,7 +283,7 @@
|
|||
|
||||
<ImageView
|
||||
android:id="@+id/dialer"
|
||||
android:src="@drawable/footer_dialer"
|
||||
android:src="@drawable/dialer"
|
||||
android:background="@color/colorC"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
@ -295,7 +302,7 @@
|
|||
|
||||
<ImageView
|
||||
android:id="@+id/chat"
|
||||
android:src="@drawable/footer_chat"
|
||||
android:src="@drawable/chat"
|
||||
android:background="@color/colorC"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
|||
|
|
@ -37,6 +37,16 @@
|
|||
android:layout_height="match_parent"
|
||||
android:padding="15dp"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/back_to_call"
|
||||
android:src="@drawable/call_back_button"
|
||||
android:contentDescription="@string/content_description_call"
|
||||
android:layout_toLeftOf="@id/edit"
|
||||
android:layout_width="70dp"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="gone"
|
||||
android:padding="15dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/contact_name"
|
||||
style="@style/font2"
|
||||
|
|
|
|||
|
|
@ -22,8 +22,7 @@
|
|||
|
||||
<ImageView
|
||||
android:id="@+id/back_in_call"
|
||||
android:src="@drawable/call_back"
|
||||
android:background="@drawable/toolbar_button"
|
||||
android:src="@drawable/call_back_button"
|
||||
android:layout_width="70dp"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="15dp"
|
||||
|
|
@ -58,12 +57,11 @@
|
|||
|
||||
<TextView
|
||||
android:id="@+id/noChatHistory"
|
||||
android:text="@string/no_chat_history"
|
||||
style="@style/font2"
|
||||
android:visibility="gone"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:text="@string/no_chat_history"
|
||||
android:textColor="@color/colorB"
|
||||
android:textAppearance="@android:style/TextAppearance.Large"/>
|
||||
android:gravity="center"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
@ -30,7 +30,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical|left"
|
||||
android:paddingLeft="20dp"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="10dp"/>
|
||||
|
||||
|
||||
|
|
@ -40,7 +40,7 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="20dp"
|
||||
android:paddingRight="10dp"
|
||||
android:gravity="center_vertical|right"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
@ -49,8 +49,9 @@
|
|||
<ImageView
|
||||
android:id="@+id/quitConference"
|
||||
android:src="@drawable/conference_exit_default"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="20dp"
|
||||
android:gravity="center_vertical"
|
||||
android:scaleType="fitCenter"
|
||||
android:adjustViewBounds="true" />
|
||||
|
|
|
|||
|
|
@ -634,7 +634,7 @@ public class CallActivity extends Activity implements OnClickListener {
|
|||
video.setAlpha(1f);
|
||||
} else {
|
||||
video.setEnabled(false);
|
||||
video.setAlpha(0.2f);
|
||||
video.setAlpha(0.3f);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -746,6 +746,7 @@ public class CallActivity extends Activity implements OnClickListener {
|
|||
|
||||
private void displayAudioCall(){
|
||||
mActiveCallHeader.setVisibility(View.VISIBLE);
|
||||
mActiveCallHeader.setAlpha(1f);
|
||||
callInfo.setVisibility(View.VISIBLE);
|
||||
contactPicture.setVisibility(View.VISIBLE);
|
||||
mNoCurrentCall.setVisibility(View.GONE);
|
||||
|
|
@ -836,6 +837,7 @@ public class CallActivity extends Activity implements OnClickListener {
|
|||
showStatusBar();
|
||||
mControlsLayout.setVisibility(View.VISIBLE);
|
||||
mActiveCallHeader.setVisibility(View.VISIBLE);
|
||||
mActiveCallHeader.setAlpha(0.7f);
|
||||
callInfo.setVisibility(View.VISIBLE);
|
||||
contactPicture.setVisibility(View.GONE);
|
||||
mNoCurrentCall.setVisibility(View.GONE);
|
||||
|
|
@ -847,6 +849,7 @@ public class CallActivity extends Activity implements OnClickListener {
|
|||
hideStatusBar();
|
||||
mControlsLayout.setVisibility(View.GONE);
|
||||
mActiveCallHeader.setVisibility(View.GONE);
|
||||
mActiveCallHeader.setAlpha(1f);
|
||||
switchCamera.setVisibility(View.GONE);
|
||||
mNoCurrentCall.setVisibility(View.GONE);
|
||||
callsList.setVisibility(View.GONE);
|
||||
|
|
@ -903,7 +906,7 @@ public class CallActivity extends Activity implements OnClickListener {
|
|||
addCall.setVisibility(View.INVISIBLE);
|
||||
displayVideoCall(false);
|
||||
numpad.setVisibility(View.GONE);
|
||||
options.setImageResource(R.drawable.options);
|
||||
options.setImageResource(R.drawable.options_default);
|
||||
} else {
|
||||
Animation animation = slideOutTopToBottom;
|
||||
animation.setAnimationListener(new AnimationListener() {
|
||||
|
|
@ -923,7 +926,7 @@ public class CallActivity extends Activity implements OnClickListener {
|
|||
addCall.setVisibility(View.INVISIBLE);
|
||||
displayVideoCall(false);
|
||||
numpad.setVisibility(View.GONE);
|
||||
options.setImageResource(R.drawable.options);
|
||||
options.setImageResource(R.drawable.options_default);
|
||||
animation.setAnimationListener(null);
|
||||
}
|
||||
});
|
||||
|
|
@ -983,7 +986,7 @@ public class CallActivity extends Activity implements OnClickListener {
|
|||
if (numpad.getVisibility() == View.VISIBLE) {
|
||||
hideNumpad();
|
||||
} else {
|
||||
dialer.setImageResource(R.drawable.dialer_alt_back);
|
||||
dialer.setImageResource(R.drawable.dialer_back_button);
|
||||
if (isAnimationDisabled) {
|
||||
numpad.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
|
|
@ -1443,23 +1446,9 @@ public class CallActivity extends Activity implements OnClickListener {
|
|||
|
||||
//CALL INFORMATION
|
||||
private void displayCurrentCall(LinphoneCall call){
|
||||
//if(!isVideoEnabled(call)){
|
||||
// mActiveCallHeader.setVisibility(View.VISIBLE);
|
||||
// mNoCurrentCall.setVisibility(View.GONE);
|
||||
//}
|
||||
|
||||
LinphoneAddress lAddress = call.getRemoteAddress();
|
||||
TextView contactName = (TextView) findViewById(R.id.contact_name);
|
||||
|
||||
Contact lContact = ContactsManager.getInstance().findContactWithAddress(getContentResolver(), lAddress);
|
||||
if (lContact == null) {
|
||||
contactName.setText(lAddress.getUserName());
|
||||
} else {
|
||||
contactName.setText(lContact.getName());
|
||||
//LinphoneUtils.setImagePictureFromUri(contactPicture.getContext(), contactPicture, lContact.getPhotoUri(), lContact.getThumbnailUri());
|
||||
}
|
||||
|
||||
setContactInformation(contactName, contactPicture, lAddress);
|
||||
TextView currentContactName = (TextView) findViewById(R.id.current_contact_name);
|
||||
currentContactName.setText(LinphoneUtils.getAddressDisplayName(lAddress));
|
||||
registerCallDurationTimer(null, call);
|
||||
}
|
||||
|
||||
|
|
@ -1480,17 +1469,13 @@ public class CallActivity extends Activity implements OnClickListener {
|
|||
contactName.setText(resources.getString(R.string.conference));
|
||||
contactImage.setImageResource(R.drawable.conference_start);
|
||||
} else {
|
||||
setContactInformation(contactName, contactImage, lAddress);
|
||||
contactName.setText(LinphoneUtils.getAddressDisplayName(lAddress));
|
||||
displayCallStatusIconAndReturnCallPaused(callView, call);
|
||||
registerCallDurationTimer(callView, call);
|
||||
callsList.addView(callView);
|
||||
}
|
||||
}
|
||||
|
||||
private void setContactInformation(TextView contactName, ImageView contactPicture, LinphoneAddress lAddress) {
|
||||
contactName.setText(LinphoneUtils.getAddressDisplayName(lAddress));
|
||||
}
|
||||
|
||||
private boolean displayCallStatusIconAndReturnCallPaused(LinearLayout callView, LinphoneCall call) {
|
||||
boolean isCallPaused, isInConference;
|
||||
ImageView callState = (ImageView) callView.findViewById(R.id.call_pause);
|
||||
|
|
@ -1527,7 +1512,7 @@ public class CallActivity extends Activity implements OnClickListener {
|
|||
|
||||
Chronometer timer;
|
||||
if(v == null){
|
||||
timer = (Chronometer) findViewById(R.id.call_timer);
|
||||
timer = (Chronometer) findViewById(R.id.current_call_timer);
|
||||
} else {
|
||||
timer = (Chronometer) v.findViewById(R.id.call_timer);
|
||||
}
|
||||
|
|
@ -1549,7 +1534,6 @@ public class CallActivity extends Activity implements OnClickListener {
|
|||
conferenceList.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
//TODO DON'T SHOW CALLLIST IF THERE IS VIDEO CALL
|
||||
if(callsList != null) {
|
||||
callsList.setVisibility(View.VISIBLE);
|
||||
callsList.removeAllViews();
|
||||
|
|
@ -1617,13 +1601,13 @@ public class CallActivity extends Activity implements OnClickListener {
|
|||
LinearLayout confView = (LinearLayout) inflater.inflate(R.layout.conf_call_control_row, container, false);
|
||||
conferenceList.setId(index+1);
|
||||
TextView contact = (TextView) confView.findViewById(R.id.contactNameOrNumber);
|
||||
|
||||
Contact lContact = ContactsManager.getInstance().findContactWithAddress(getContentResolver(),call.getRemoteAddress());
|
||||
contact.setText(call.getRemoteAddress().getUserName());
|
||||
/*Contact lContact = ContactsManager.getInstance().findContactWithAddress(getContentResolver(),call.getRemoteAddress());
|
||||
if (lContact == null) {
|
||||
contact.setText(call.getRemoteAddress().getUserName());
|
||||
|
||||
} else {
|
||||
contact.setText(lContact.getName());
|
||||
}
|
||||
}*/
|
||||
|
||||
registerCallDurationTimer(confView, call);
|
||||
|
||||
|
|
|
|||
|
|
@ -153,7 +153,6 @@ public class CallIncomingActivity extends Activity implements LinphoneSliderTrig
|
|||
curX = motionEvent.getX();
|
||||
view.scrollBy((int) (declineX - curX), view.getScrollY());
|
||||
declineX = curX;
|
||||
Log.w(curX);
|
||||
if (curX > (screenWidth/2)){
|
||||
decline();
|
||||
return true;
|
||||
|
|
@ -226,13 +225,13 @@ public class CallIncomingActivity extends Activity implements LinphoneSliderTrig
|
|||
return;
|
||||
}
|
||||
LinphoneAddress address = mCall.getRemoteAddress();
|
||||
Contact contact = ContactsManager.getInstance().findContactWithAddress(getContentResolver(), address);
|
||||
if (contact != null) {
|
||||
//Contact contact = ContactsManager.getInstance().findContactWithAddress(getContentResolver(), address);
|
||||
//if (contact != null) {
|
||||
//LinphoneUtils.setImagePictureFromUri(this, contactPicture, contact.getPhotoUri(), contact.getThumbnailUri());
|
||||
name.setText(contact.getName());
|
||||
} else {
|
||||
// name.setText(contact.getName());
|
||||
//} else {
|
||||
name.setText(LinphoneUtils.getAddressDisplayName(address));
|
||||
}
|
||||
//}
|
||||
number.setText(address.asStringUriOnly());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -89,7 +89,6 @@ public class CallOutgoingActivity extends Activity implements OnClickListener{
|
|||
mListener = new LinphoneCoreListenerBase(){
|
||||
@Override
|
||||
public void callState(LinphoneCore lc, LinphoneCall call, LinphoneCall.State state, String message) {
|
||||
Log.w("State " + state);
|
||||
if (LinphoneManager.getLc().getCallsNb() == 0) {
|
||||
finish();
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import android.app.Dialog;
|
|||
import android.app.Fragment;
|
||||
import android.graphics.Matrix;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
|
@ -42,6 +43,7 @@ import org.linphone.core.LinphoneCore;
|
|||
import org.linphone.core.LinphoneChatMessage.State;
|
||||
import org.linphone.core.LinphoneCoreFactory;
|
||||
import org.linphone.core.LinphoneCoreListenerBase;
|
||||
import org.linphone.core.LinphoneFriend;
|
||||
import org.linphone.mediastream.Log;
|
||||
import org.linphone.ui.BubbleChat;
|
||||
|
||||
|
|
@ -113,7 +115,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
private EditText message;
|
||||
private ImageView cancelUpload, edit, selectAll, deselectAll, startCall, delete, sendImage, sendMessage, cancel;
|
||||
private TextView contactName, remoteComposing;
|
||||
private ImageView back;
|
||||
private ImageView back, backToCall;
|
||||
private AutoCompleteTextView searchContactField;
|
||||
private RelativeLayout uploadLayout, textLayout, topBar, editList;
|
||||
private ListView messagesList;
|
||||
|
|
@ -182,6 +184,9 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
startCall = (ImageView) view.findViewById(R.id.start_call);
|
||||
startCall.setOnClickListener(this);
|
||||
|
||||
backToCall = (ImageView) view.findViewById(R.id.back_to_call);
|
||||
backToCall.setOnClickListener(this);
|
||||
|
||||
selectAll = (ImageView) view.findViewById(R.id.select_all);
|
||||
selectAll.setOnClickListener(this);
|
||||
|
||||
|
|
@ -194,7 +199,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
if (newChatConversation) {
|
||||
messagesList.setVisibility(View.GONE);
|
||||
searchContactField.setVisibility(View.VISIBLE);
|
||||
searchContactField.setAdapter(new SearchContactsListAdapter(ContactsManager.getInstance().getAllContacts(), null, inflater));
|
||||
searchContactField.setAdapter(new SearchContactsListAdapter(null , null, inflater));
|
||||
edit.setVisibility(View.INVISIBLE);
|
||||
startCall.setVisibility(View.INVISIBLE);
|
||||
contactName.setVisibility(View.INVISIBLE);
|
||||
|
|
@ -209,7 +214,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
LinphoneAddress lAddress = null;
|
||||
try {
|
||||
lAddress = LinphoneCoreFactory.instance().createLinphoneAddress(sipUri);
|
||||
contact = ContactsManager.getInstance().findContactWithAddress(getActivity().getContentResolver(), lAddress);
|
||||
//contact = ContactsManager.getInstance().findContactWithAddress(getActivity().getContentResolver(), lAddress);
|
||||
} catch (Exception e){
|
||||
|
||||
}
|
||||
|
|
@ -469,7 +474,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
LinphoneAddress lAddress = null;
|
||||
try {
|
||||
lAddress = LinphoneCoreFactory.instance().createLinphoneAddress(sipUri);
|
||||
contact = ContactsManager.getInstance().findContactWithAddress(getActivity().getContentResolver(), lAddress);
|
||||
//contact = ContactsManager.getInstance().findContactWithAddress(getActivity().getContentResolver(), lAddress);
|
||||
} catch (Exception e){
|
||||
Log.w("error");
|
||||
}
|
||||
|
|
@ -586,10 +591,18 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
LinphoneActivity.instance().hideTabBar(false);
|
||||
}
|
||||
|
||||
if(LinphoneManager.getLc().isIncall()){
|
||||
backToCall.setVisibility(View.VISIBLE);
|
||||
startCall.setVisibility(View.INVISIBLE);
|
||||
} else {
|
||||
backToCall.setVisibility(View.INVISIBLE);
|
||||
startCall.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
LinphoneAddress lAddress;
|
||||
try {
|
||||
lAddress = LinphoneCoreFactory.instance().createLinphoneAddress(sipUri);
|
||||
contact = ContactsManager.getInstance().findContactWithAddress(getActivity().getContentResolver(), lAddress);
|
||||
//contact = ContactsManager.getInstance().findContactWithAddress(getActivity().getContentResolver(), lAddress);
|
||||
} catch (Exception e){
|
||||
|
||||
}
|
||||
|
|
@ -643,6 +656,11 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
public void onClick(View v) {
|
||||
int id = v.getId();
|
||||
|
||||
if (id == R.id.back_to_call) {
|
||||
LinphoneActivity.instance().resetClassicMenuLayoutAndGoBackToCallIfStillRunning();
|
||||
return;
|
||||
}
|
||||
|
||||
if (id == R.id.select_all) {
|
||||
deselectAll.setVisibility(View.VISIBLE);
|
||||
selectAll.setVisibility(View.GONE);
|
||||
|
|
@ -728,11 +746,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
LinphoneChatMessage message = chatRoom.createLinphoneChatMessage(messageToSend);
|
||||
chatRoom.sendChatMessage(message);
|
||||
message.setListener(LinphoneManager.getInstance());
|
||||
Contact lContact = ContactsManager.getInstance().findContactWithAddress(getActivity().getContentResolver(), lAddress);
|
||||
if (lContact != null)
|
||||
exitNewConversationMode(lContact, lAddress.asStringUriOnly(), null);
|
||||
else
|
||||
exitNewConversationMode(null, lAddress.asStringUriOnly(), lAddress.getUserName());
|
||||
exitNewConversationMode(lAddress.asStringUriOnly(), LinphoneUtils.getAddressDisplayName(lAddress));
|
||||
}
|
||||
} else {
|
||||
//TODO ERROR MESSAGE
|
||||
|
|
@ -931,7 +945,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
return null;
|
||||
}
|
||||
|
||||
private void exitNewConversationMode(Contact c, String address, String username){
|
||||
private void exitNewConversationMode(String address, String username){
|
||||
searchContactField.setVisibility(View.GONE);
|
||||
sipUri = address;
|
||||
messagesList.setVisibility(View.VISIBLE);
|
||||
|
|
@ -941,11 +955,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
startCall.setVisibility(View.VISIBLE);
|
||||
newChatConversation = false;
|
||||
chatRoom = LinphoneManager.getLc().getOrCreateChatRoom(address);
|
||||
|
||||
if(c != null)
|
||||
changeDisplayedChat(address,c.getName(),null);
|
||||
else
|
||||
changeDisplayedChat(address,username,null);
|
||||
changeDisplayedChat(address,username,null);
|
||||
dispayMessageList();
|
||||
}
|
||||
|
||||
|
|
@ -1000,22 +1010,15 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
}
|
||||
|
||||
class SearchContactsListAdapter extends BaseAdapter implements Filterable {
|
||||
//private List<ContactAddress> contacts;
|
||||
private HashMap<Contact, String> contactsList2;
|
||||
private List<LinphoneFriend> contactList;
|
||||
private Cursor cursor;
|
||||
private LayoutInflater mInflater;
|
||||
|
||||
SearchContactsListAdapter(List<Contact> contactsList, Cursor c, LayoutInflater inflater) {
|
||||
SearchContactsListAdapter(List<LinphoneFriend> list, Cursor c, LayoutInflater inflater) {
|
||||
cursor = c;
|
||||
mInflater = inflater;
|
||||
contactsList2 = new HashMap<Contact, String>();
|
||||
//contacts = new ArrayList<ContactAddress>();
|
||||
for(Contact con: ContactsManager.getInstance().getAllContacts()){
|
||||
for(String numberOrAddress : con.getNumbersOrAddresses()){
|
||||
contactsList2.put(con,numberOrAddress);
|
||||
//contacts.add(new ContactAddress(con,numberOrAddress));
|
||||
}
|
||||
}
|
||||
contactList = new ArrayList<LinphoneFriend>();
|
||||
contactList = getContactsList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -1024,29 +1027,24 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
@Override
|
||||
protected void publishResults(CharSequence constraint,
|
||||
FilterResults results) {
|
||||
|
||||
if (results.count > 0) {
|
||||
//contacts.clear();
|
||||
contactsList2.clear();
|
||||
contactsList2 = ( HashMap<Contact, String>) results.values;
|
||||
//contacts = (List<ContactAddress>) results.values;
|
||||
contactList = new ArrayList<LinphoneFriend>();
|
||||
contactList = (List<LinphoneFriend>) results.values;
|
||||
notifyDataSetChanged();
|
||||
} else {;
|
||||
//contacts.clear();
|
||||
contactsList2.clear();
|
||||
contactsList2 = getContactsList();
|
||||
} else {
|
||||
contactList = new ArrayList<LinphoneFriend>();
|
||||
contactList = getContactsList();
|
||||
notifyDataSetInvalidated();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected FilterResults performFiltering(CharSequence constraint) {
|
||||
//List<ContactAddress> result = new ArrayList<ContactAddress>();
|
||||
HashMap<Contact, String> result = new HashMap<Contact, String>();
|
||||
List<LinphoneFriend> result = new ArrayList<LinphoneFriend>();
|
||||
if(constraint != null) {
|
||||
for (HashMap.Entry<Contact, String> entry : contactsList2.entrySet()) {
|
||||
if (entry.getKey().getName().toLowerCase().startsWith(constraint.toString()) || entry.getValue().startsWith(constraint.toString())) {
|
||||
result.put(entry.getKey(),entry.getValue());
|
||||
for (LinphoneFriend f: contactList) {
|
||||
if (f.getAddress().asStringUriOnly().toLowerCase().startsWith("sip:" + constraint.toString().toLowerCase()) || LinphoneUtils.getAddressDisplayName(f.getAddress()).toLowerCase().startsWith(constraint.toString().toLowerCase())) {
|
||||
result.add(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1058,29 +1056,20 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
};
|
||||
}
|
||||
|
||||
public HashMap<Contact, String> getContactsList(){
|
||||
HashMap<Contact, String> contacts = new HashMap<Contact, String>();
|
||||
for(Contact con: ContactsManager.getInstance().getAllContacts()){
|
||||
for(String numberOrAddress : con.getNumbersOrAddresses()){
|
||||
contacts.put(con, numberOrAddress);
|
||||
}
|
||||
}
|
||||
return contacts;
|
||||
public List<LinphoneFriend> getContactsList(){
|
||||
return Arrays.asList(LinphoneManager.getLc().getFriendList());
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
return contactsList2.size();
|
||||
return contactList.size();
|
||||
}
|
||||
|
||||
public Contact getItem(int position) {
|
||||
if (contactsList2 == null || position >= contactsList2.size()) {
|
||||
contactsList2 = getContactsList();
|
||||
Contact[] s = (Contact[]) contactsList2.keySet().toArray();
|
||||
return s[position];
|
||||
public LinphoneFriend getItem(int position) {
|
||||
if (contactList == null || position >= contactList.size()) {
|
||||
contactList = getContactsList();
|
||||
return contactList.get(position);
|
||||
} else {
|
||||
Object[] s = (Object[]) contactsList2.keySet().toArray();
|
||||
return (Contact) s[position];
|
||||
//return contactsList2.get();
|
||||
return contactList.get(position);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1090,10 +1079,10 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
View view = null;
|
||||
Contact contact;
|
||||
LinphoneFriend f;
|
||||
do {
|
||||
contact = getItem(position);
|
||||
} while (contact == null);
|
||||
f = getItem(position);
|
||||
} while (f == null);
|
||||
|
||||
if (convertView != null) {
|
||||
view = convertView;
|
||||
|
|
@ -1102,18 +1091,17 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
|||
}
|
||||
|
||||
TextView name = (TextView) view.findViewById(R.id.Contact_name);
|
||||
name.setText(contact.getName());
|
||||
name.setText(LinphoneUtils.getAddressDisplayName(f.getAddress()));
|
||||
|
||||
final TextView address = (TextView) view.findViewById(R.id.contact_address);
|
||||
address.setText(contactsList2.get(contact));
|
||||
address.setText(f.getAddress().asStringUriOnly());
|
||||
|
||||
final String a = contactsList2.get(contact);
|
||||
final Contact c = contact;
|
||||
final LinphoneAddress laddress = f.getAddress();
|
||||
|
||||
view.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
exitNewConversationMode(c, a,null);
|
||||
exitNewConversationMode(laddress.asStringUriOnly(),LinphoneUtils.getAddressDisplayName(laddress));
|
||||
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -140,7 +140,6 @@ public class DialerFragment extends Fragment {
|
|||
|
||||
@Override
|
||||
public void onResume() {
|
||||
Log.w("onResume ");
|
||||
super.onResume();
|
||||
|
||||
if (LinphoneActivity.isInstanciated()) {
|
||||
|
|
|
|||
|
|
@ -229,12 +229,10 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
|
||||
@Override
|
||||
public void callState(LinphoneCore lc, LinphoneCall call, LinphoneCall.State state, String message) {
|
||||
Log.w("Call state" + state);
|
||||
if (state == State.IncomingReceived) {
|
||||
//finish();
|
||||
startActivity(new Intent(LinphoneActivity.instance(), CallIncomingActivity.class));
|
||||
} else if (state == State.OutgoingInit || state == State.OutgoingProgress) {
|
||||
Log.w("Call outgoing" + state);
|
||||
startActivity(new Intent(LinphoneActivity.instance(), CallOutgoingActivity.class));
|
||||
} else if (state == State.CallEnd || state == State.Error || state == State.CallReleased) {
|
||||
// Convert LinphoneCore message for internalization
|
||||
|
|
@ -478,6 +476,7 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
statusFragment.closeStatusBar();
|
||||
}*/
|
||||
|
||||
|
||||
LinearLayout ll = (LinearLayout) findViewById(R.id.fragmentContainer2);
|
||||
|
||||
FragmentTransaction transaction = getFragmentManager().beginTransaction();
|
||||
|
|
@ -1019,7 +1018,6 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
}
|
||||
|
||||
public void resetClassicMenuLayoutAndGoBackToCallIfStillRunning() {
|
||||
Log.w("resetClassicMenuLayoutAndGoBackToCallIfStillRunning");
|
||||
if (dialerFragment != null) {
|
||||
((DialerFragment) dialerFragment).resetLayout(false);
|
||||
}
|
||||
|
|
@ -1075,7 +1073,6 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
Log.w("Linphone Activity onActivityResult");
|
||||
if (resultCode == Activity.RESULT_FIRST_USER && requestCode == SETTINGS_ACTIVITY) {
|
||||
if (data.getExtras().getBoolean("Exit", false)) {
|
||||
quit();
|
||||
|
|
@ -1103,7 +1100,6 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
Log.w("onPause ");
|
||||
getIntent().putExtra("PreviousActivity", 0);
|
||||
super.onPause();
|
||||
}
|
||||
|
|
@ -1111,7 +1107,6 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
if (!LinphoneService.isReady()) {
|
||||
startService(new Intent(ACTION_MAIN).setClass(this, LinphoneService.class));
|
||||
}
|
||||
|
|
@ -1178,8 +1173,6 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
protected void onNewIntent(Intent intent) {
|
||||
super.onNewIntent(intent);
|
||||
|
||||
Log.w("Linphone Activity on new intent");
|
||||
|
||||
Bundle extras = intent.getExtras();
|
||||
if (extras != null && extras.getBoolean("GoToChat", false)) {
|
||||
LinphoneService.instance().removeMessageNotification();
|
||||
|
|
|
|||
|
|
@ -389,7 +389,6 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
|||
|
||||
public void newOutgoingCall(AddressType address) {
|
||||
String to = address.getText().toString();
|
||||
Log.w("newOutgoingCall");
|
||||
newOutgoingCall(to, address.getDisplayedName());
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue