diff --git a/res/layout-land/search_contact_cell.xml b/res/layout-land/search_contact_cell.xml
deleted file mode 100644
index 173941114..000000000
--- a/res/layout-land/search_contact_cell.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
-
-
-
-
diff --git a/res/layout/create_chat.xml b/res/layout/create_chat.xml
index 52aceef0a..99ffb9f71 100644
--- a/res/layout/create_chat.xml
+++ b/res/layout/create_chat.xml
@@ -144,9 +144,9 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="@color/colorE"
- android:fastScrollEnabled="true"
+ android:dividerHeight="1dp"
android:fastScrollAlwaysVisible="true"
- android:dividerHeight="1dp" />
+ android:fastScrollEnabled="true"/>
+ android:layout_centerVertical="true"
+ android:gravity="top|left"
+ android:lines="1"/>
+ android:layout_centerVertical="true"
+ android:gravity="bottom|left"
+ android:lines="1"/>
diff --git a/src/android/org/linphone/ChatCreationFragment.java b/src/android/org/linphone/ChatCreationFragment.java
index 4378b26d1..d4bb47672 100644
--- a/src/android/org/linphone/ChatCreationFragment.java
+++ b/src/android/org/linphone/ChatCreationFragment.java
@@ -80,9 +80,6 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
allContactsSelected = view.findViewById(R.id.all_contacts_select);
linphoneContactsSelected = view.findViewById(R.id.linphone_contacts_select);
- allContacts.setEnabled(onlyDisplayLinphoneContacts);
- linphoneContacts.setEnabled(!allContacts.isEnabled());
-
back = (ImageView) view.findViewById(R.id.back);
back.setOnClickListener(this);
@@ -96,9 +93,6 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
contactsFetchInProgress.setVisibility(View.VISIBLE);
searchAdapter = new SearchContactsListAdapter(null, mInflater, contactsFetchInProgress);
- contactsList.setAdapter(searchAdapter);
- contactsList.setOnItemClickListener(this);
-
searchField = (EditText) view.findViewById(R.id.searchField);
searchField.addTextChangedListener(new TextWatcher() {
@@ -119,6 +113,38 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
}
});
+ contactsList.setAdapter(searchAdapter);
+ contactsList.setOnItemClickListener(this);
+ if (savedInstanceState != null && savedInstanceState.getStringArrayList("contactsSelected") != null) {
+ // We need to get all contacts not only sip
+ for (String uri : savedInstanceState.getStringArrayList("contactsSelected")) {
+ for (ContactAddress ca : searchAdapter.getContactsList()) {
+ if (ca.getAddress() == uri) {
+ updateContactsClick(ca);
+ break;
+ }
+ }
+ }
+ updateList();
+ updateListSelected();
+ }
+
+ if (savedInstanceState != null ) {
+ onlyDisplayLinphoneContacts = savedInstanceState.getBoolean("onlySipContact");
+ if (onlyDisplayLinphoneContacts) {
+ allContactsSelected.setVisibility(View.INVISIBLE);
+ linphoneContactsSelected.setVisibility(View.VISIBLE);
+ } else {
+ allContactsSelected.setVisibility(View.VISIBLE);
+ linphoneContactsSelected.setVisibility(View.INVISIBLE);
+ }
+ updateList();
+ }
+
+ searchAdapter.setOnlySipContact(onlyDisplayLinphoneContacts);
+ allContacts.setEnabled(onlyDisplayLinphoneContacts);
+ linphoneContacts.setEnabled(!allContacts.isEnabled());
+
return view;
}
@@ -130,12 +156,14 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
private void updateListSelected() {
if (contactsSelected.size() > 0) {
contactsSelectLayout.setVisibility(View.VISIBLE);
+ contactsSelectLayout.invalidate();
} else {
contactsSelectLayout.setVisibility(View.GONE);
}
}
private void updateContactsClick(ContactAddress ca) {
+ ca.setSelect(!ca.isSelect());
if(ca.isSelect()) {
ContactSelectView csv = new ContactSelectView(LinphoneActivity.instance());
csv.setListener(this);
@@ -144,13 +172,15 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
View viewContact = LayoutInflater.from(LinphoneActivity.instance()).inflate(R.layout.contact_selected, null);
((TextView)viewContact.findViewById(R.id.sipUri)).setText(ca.getContact().getFullName());
viewContact.findViewById(R.id.contactChatDelete).setOnClickListener(this);
+ viewContact.setOnClickListener(this);
ca.setView(viewContact);
contactsSelectedLayout.addView(viewContact);
} else {
contactsSelected.remove(ca);
contactsSelectedLayout.removeAllViews();
for (ContactAddress contactAddress : contactsSelected) {
- contactsSelectedLayout.addView(contactAddress.getView());
+ if (contactAddress.getView() != null)
+ contactsSelectedLayout.addView(contactAddress.getView());
}
}
searchAdapter.setContactsSelectedList(contactsSelected);
@@ -166,6 +196,21 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
}
}
+ @Override
+ public void onSaveInstanceState(Bundle outState) {
+ if (contactsSelected != null && contactsSelected.size() > 0) {
+ ArrayList listUri = new ArrayList();
+ for (ContactAddress ca : contactsSelected) {
+ listUri.add(ca.getAddress());
+ }
+ outState.putStringArrayList("contactsSelected", listUri);
+ }
+
+ outState.putBoolean("onlySipContact", onlyDisplayLinphoneContacts);
+
+ super.onSaveInstanceState(outState);
+ }
+
@Override
public void onClick(View view) {
int id = view.getId();
@@ -200,7 +245,6 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
public void onItemClick(AdapterView> adapterView, View view, int i, long l) {
// Get contact
ContactAddress ca = searchAdapter.getContacts().get(i);
- ca.setSelect(!ca.isSelect());
updateContactsClick(ca);
updateList();
updateListSelected();
diff --git a/src/android/org/linphone/ContactAddress.java b/src/android/org/linphone/ContactAddress.java
index 95d04458a..2af1799e9 100644
--- a/src/android/org/linphone/ContactAddress.java
+++ b/src/android/org/linphone/ContactAddress.java
@@ -21,7 +21,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
import android.view.View;
-public class ContactAddress {
+import java.io.Serializable;
+
+public class ContactAddress implements Serializable {
private LinphoneContact contact;
private String address;
private boolean isLinphoneContact;