Only display contacts' SIP addresses when new conversation
This commit is contained in:
parent
901e77aadc
commit
c0bac6ef47
4 changed files with 31 additions and 9 deletions
|
@ -127,7 +127,7 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
||||||
else if (id == R.id.newDiscussion) {
|
else if (id == R.id.newDiscussion) {
|
||||||
String sipUri = fastNewChat.getText().toString();
|
String sipUri = fastNewChat.getText().toString();
|
||||||
if (sipUri.equals("")) {
|
if (sipUri.equals("")) {
|
||||||
LinphoneActivity.instance().displayContacts();
|
LinphoneActivity.instance().displayContacts(true);
|
||||||
} else {
|
} else {
|
||||||
if (!LinphoneUtils.isSipAddress(sipUri)) {
|
if (!LinphoneUtils.isSipAddress(sipUri)) {
|
||||||
sipUri = sipUri + "@" + LinphoneManager.getLc().getDefaultProxyConfig().getDomain();
|
sipUri = sipUri + "@" + LinphoneManager.getLc().getDefaultProxyConfig().getDomain();
|
||||||
|
|
|
@ -41,6 +41,7 @@ public class ContactFragment extends Fragment implements OnClickListener {
|
||||||
private TextView editContact, newContact;
|
private TextView editContact, newContact;
|
||||||
private LayoutInflater inflater;
|
private LayoutInflater inflater;
|
||||||
private View view;
|
private View view;
|
||||||
|
private boolean displayChatAddressOnly = false;
|
||||||
|
|
||||||
private OnClickListener dialListener = new OnClickListener() {
|
private OnClickListener dialListener = new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -63,6 +64,10 @@ public class ContactFragment extends Fragment implements OnClickListener {
|
||||||
this.inflater = inflater;
|
this.inflater = inflater;
|
||||||
view = inflater.inflate(R.layout.contact, container, false);
|
view = inflater.inflate(R.layout.contact, container, false);
|
||||||
|
|
||||||
|
if (getArguments() != null) {
|
||||||
|
displayChatAddressOnly = getArguments().getBoolean("ChatAddressOnly");
|
||||||
|
}
|
||||||
|
|
||||||
editContact = (TextView) view.findViewById(R.id.editContact);
|
editContact = (TextView) view.findViewById(R.id.editContact);
|
||||||
editContact.setOnClickListener(this);
|
editContact.setOnClickListener(this);
|
||||||
newContact = (TextView) view.findViewById(R.id.newContact);
|
newContact = (TextView) view.findViewById(R.id.newContact);
|
||||||
|
@ -100,14 +105,21 @@ public class ContactFragment extends Fragment implements OnClickListener {
|
||||||
}
|
}
|
||||||
((TextView) v.findViewById(R.id.numeroOrAddress)).setText(displayednumberOrAddress);
|
((TextView) v.findViewById(R.id.numeroOrAddress)).setText(displayednumberOrAddress);
|
||||||
|
|
||||||
v.findViewById(R.id.dial).setOnClickListener(dialListener);
|
if (!displayChatAddressOnly) {
|
||||||
v.findViewById(R.id.dial).setTag(numberOrAddress);
|
v.findViewById(R.id.dial).setOnClickListener(dialListener);
|
||||||
|
v.findViewById(R.id.dial).setTag(numberOrAddress);
|
||||||
|
} else {
|
||||||
|
v.findViewById(R.id.dial).setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
if (LinphoneUtils.isSipAddress(numberOrAddress)) {
|
if (LinphoneUtils.isSipAddress(numberOrAddress)) {
|
||||||
v.findViewById(R.id.chat).setOnClickListener(chatListener);
|
v.findViewById(R.id.chat).setOnClickListener(chatListener);
|
||||||
v.findViewById(R.id.chat).setTag(numberOrAddress);
|
v.findViewById(R.id.chat).setTag(numberOrAddress);
|
||||||
} else {
|
} else {
|
||||||
v.findViewById(R.id.chat).setVisibility(View.INVISIBLE);
|
v.findViewById(R.id.chat).setVisibility(View.INVISIBLE);
|
||||||
|
if (displayChatAddressOnly) {
|
||||||
|
v.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
controls.addView(v);
|
controls.addView(v);
|
||||||
|
@ -123,7 +135,7 @@ public class ContactFragment extends Fragment implements OnClickListener {
|
||||||
contact.refresh(getActivity().getContentResolver());
|
contact.refresh(getActivity().getContentResolver());
|
||||||
if (contact.getName() == null || contact.getName().equals("")) {
|
if (contact.getName() == null || contact.getName().equals("")) {
|
||||||
//Contact has been deleted, return
|
//Contact has been deleted, return
|
||||||
LinphoneActivity.instance().displayContacts();
|
LinphoneActivity.instance().displayContacts(false);
|
||||||
}
|
}
|
||||||
displayContact(inflater, view);
|
displayContact(inflater, view);
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class ContactsFragment extends Fragment implements OnClickListener, OnIte
|
||||||
private boolean onlyDisplayLinphoneContacts;
|
private boolean onlyDisplayLinphoneContacts;
|
||||||
private int lastKnownPosition;
|
private int lastKnownPosition;
|
||||||
private AlphabetIndexer indexer;
|
private AlphabetIndexer indexer;
|
||||||
private boolean editOnClick = false, editConsumed = false;
|
private boolean editOnClick = false, editConsumed = false, onlyDisplayChatAddress = false;
|
||||||
private String sipAddressToAdd;
|
private String sipAddressToAdd;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -63,6 +63,8 @@ public class ContactsFragment extends Fragment implements OnClickListener, OnIte
|
||||||
if (getArguments() != null) {
|
if (getArguments() != null) {
|
||||||
editOnClick = getArguments().getBoolean("EditOnClick");
|
editOnClick = getArguments().getBoolean("EditOnClick");
|
||||||
sipAddressToAdd = getArguments().getString("SipAddress");
|
sipAddressToAdd = getArguments().getString("SipAddress");
|
||||||
|
|
||||||
|
onlyDisplayChatAddress = getArguments().getBoolean("ChatAddressOnly");
|
||||||
}
|
}
|
||||||
|
|
||||||
contactsList = (ListView) view.findViewById(R.id.contactsList);
|
contactsList = (ListView) view.findViewById(R.id.contactsList);
|
||||||
|
@ -139,7 +141,7 @@ public class ContactsFragment extends Fragment implements OnClickListener, OnIte
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
} else {
|
} else {
|
||||||
lastKnownPosition = contactsList.getFirstVisiblePosition();
|
lastKnownPosition = contactsList.getFirstVisiblePosition();
|
||||||
LinphoneActivity.instance().displayContact(contact);
|
LinphoneActivity.instance().displayContact(contact, onlyDisplayChatAddress);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -414,7 +414,7 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
||||||
return dateFormat.format(cal.getTime());
|
return dateFormat.format(cal.getTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void displayContact(Contact contact) {
|
public void displayContact(Contact contact, boolean chatOnly) {
|
||||||
Fragment fragment2 = getSupportFragmentManager().findFragmentById(R.id.fragmentContainer2);
|
Fragment fragment2 = getSupportFragmentManager().findFragmentById(R.id.fragmentContainer2);
|
||||||
if (fragment2 != null && fragment2.isVisible() && currentFragment == FragmentsAvailable.CONTACT) {
|
if (fragment2 != null && fragment2.isVisible() && currentFragment == FragmentsAvailable.CONTACT) {
|
||||||
ContactFragment contactFragment = (ContactFragment) fragment2;
|
ContactFragment contactFragment = (ContactFragment) fragment2;
|
||||||
|
@ -422,12 +422,20 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
||||||
} else {
|
} else {
|
||||||
Bundle extras = new Bundle();
|
Bundle extras = new Bundle();
|
||||||
extras.putSerializable("Contact", contact);
|
extras.putSerializable("Contact", contact);
|
||||||
|
extras.putBoolean("ChatAddressOnly", chatOnly);
|
||||||
changeCurrentFragment(FragmentsAvailable.CONTACT, extras);
|
changeCurrentFragment(FragmentsAvailable.CONTACT, extras);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void displayContacts() {
|
public void displayContacts(boolean chatOnly) {
|
||||||
changeCurrentFragment(FragmentsAvailable.CONTACTS, null);
|
if (chatOnly) {
|
||||||
|
preferLinphoneContacts = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Bundle extras = new Bundle();
|
||||||
|
extras.putBoolean("ChatAddressOnly", chatOnly);
|
||||||
|
changeCurrentFragment(FragmentsAvailable.CONTACTS, extras);
|
||||||
|
preferLinphoneContacts = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void displayContactsForEdition(String sipAddress) {
|
public void displayContactsForEdition(String sipAddress) {
|
||||||
|
|
Loading…
Reference in a new issue