Fixed UI issues if default proxy config isn't sip.linphone.org

This commit is contained in:
Sylvain Berfini 2019-03-01 14:56:34 +01:00
parent eb46992c70
commit c294a8ad1b
2 changed files with 25 additions and 17 deletions

View file

@ -221,9 +221,12 @@ public class ChatRoomCreationFragment extends Fragment
updateListSelected(); updateListSelected();
} }
mOnlyDisplayLinphoneContacts = ContactsManager.getInstance().getSIPContacts().size() > 0; mOnlyDisplayLinphoneContacts =
ContactsManager.getInstance().isLinphoneContactsPrefered()
|| getResources().getBoolean(R.bool.hide_non_linphone_contacts);
if (savedInstanceState != null) { if (savedInstanceState != null) {
mOnlyDisplayLinphoneContacts = savedInstanceState.getBoolean("onlySipContact", true); mOnlyDisplayLinphoneContacts =
savedInstanceState.getBoolean("onlySipContact", mOnlyDisplayLinphoneContacts);
} }
mSearchAdapter.setOnlySipContact(mOnlyDisplayLinphoneContacts); mSearchAdapter.setOnlySipContact(mOnlyDisplayLinphoneContacts);
updateList(); updateList();
@ -328,7 +331,20 @@ public class ChatRoomCreationFragment extends Fragment
mContactsList.setVisibility(View.VISIBLE); mContactsList.setVisibility(View.VISIBLE);
mSearchLayout.setVisibility(View.VISIBLE); mSearchLayout.setVisibility(View.VISIBLE);
if (mCreateGroupChatRoom) {
mLinphoneContactsToggle.setVisibility(View.GONE);
mAllContactsToggle.setVisibility(View.GONE);
mContactsSelectLayout.setVisibility(View.VISIBLE);
mNextButton.setVisibility(View.VISIBLE);
} else {
mLinphoneContactsToggle.setVisibility(View.VISIBLE);
mAllContactsToggle.setVisibility(View.VISIBLE);
mContactsSelectLayout.setVisibility(View.GONE);
mNextButton.setVisibility(View.GONE);
}
if (getResources().getBoolean(R.bool.hide_non_linphone_contacts)) { if (getResources().getBoolean(R.bool.hide_non_linphone_contacts)) {
mLinphoneContactsToggle.setVisibility(View.GONE);
mLinphoneContactsButton.setVisibility(View.INVISIBLE); mLinphoneContactsButton.setVisibility(View.INVISIBLE);
mAllContactsButton.setEnabled(false); mAllContactsButton.setEnabled(false);
@ -357,18 +373,6 @@ public class ChatRoomCreationFragment extends Fragment
mLinphoneContactsButton.setEnabled(!mAllContactsButton.isEnabled()); mLinphoneContactsButton.setEnabled(!mAllContactsButton.isEnabled());
} }
if (mCreateGroupChatRoom) {
mLinphoneContactsToggle.setVisibility(View.GONE);
mAllContactsToggle.setVisibility(View.GONE);
mContactsSelectLayout.setVisibility(View.VISIBLE);
mNextButton.setVisibility(View.VISIBLE);
} else {
mLinphoneContactsToggle.setVisibility(View.VISIBLE);
mAllContactsToggle.setVisibility(View.VISIBLE);
mContactsSelectLayout.setVisibility(View.GONE);
mNextButton.setVisibility(View.GONE);
}
mContactsSelectedLayout.removeAllViews(); mContactsSelectedLayout.removeAllViews();
if (mSearchAdapter.getContactsSelectedList().size() > 0) { if (mSearchAdapter.getContactsSelectedList().size() > 0) {
for (ContactAddress ca : mSearchAdapter.getContactsSelectedList()) { for (ContactAddress ca : mSearchAdapter.getContactsSelectedList()) {
@ -458,7 +462,8 @@ public class ChatRoomCreationFragment extends Fragment
public void onClick(View view) { public void onClick(View view) {
int id = view.getId(); int id = view.getId();
if (id == R.id.all_contacts) { if (id == R.id.all_contacts) {
mSearchAdapter.setOnlySipContact(mOnlyDisplayLinphoneContacts = false); mOnlyDisplayLinphoneContacts = false;
mSearchAdapter.setOnlySipContact(mOnlyDisplayLinphoneContacts);
mAllContactsSelected.setVisibility(View.VISIBLE); mAllContactsSelected.setVisibility(View.VISIBLE);
mAllContactsButton.setEnabled(false); mAllContactsButton.setEnabled(false);
mLinphoneContactsButton.setEnabled(true); mLinphoneContactsButton.setEnabled(true);
@ -469,7 +474,8 @@ public class ChatRoomCreationFragment extends Fragment
mSearchAdapter.setOnlySipContact(true); mSearchAdapter.setOnlySipContact(true);
mLinphoneContactsSelected.setVisibility(View.VISIBLE); mLinphoneContactsSelected.setVisibility(View.VISIBLE);
mLinphoneContactsButton.setEnabled(false); mLinphoneContactsButton.setEnabled(false);
mAllContactsButton.setEnabled(mOnlyDisplayLinphoneContacts = true); mOnlyDisplayLinphoneContacts = true;
mAllContactsButton.setEnabled(mOnlyDisplayLinphoneContacts);
mAllContactsSelected.setVisibility(View.INVISIBLE); mAllContactsSelected.setVisibility(View.INVISIBLE);
updateList(); updateList();
resetAndResearch(); resetAndResearch();

View file

@ -57,7 +57,9 @@ public class ContactAvatar {
String[] names = displayName.split(" "); String[] names = displayName.split(" ");
StringBuilder generatedAvatarText = new StringBuilder(); StringBuilder generatedAvatarText = new StringBuilder();
for (String name : names) { for (String name : names) {
generatedAvatarText.append(name.charAt(0)); if (name != null && name.length() > 0) {
generatedAvatarText.append(name.charAt(0));
}
} }
return generatedAvatarText.toString().toUpperCase(); return generatedAvatarText.toString().toUpperCase();
} }