Fixing rotation on create chat view
This commit is contained in:
parent
f8bf1b24c5
commit
b211b25efc
5 changed files with 63 additions and 41 deletions
|
@ -1,26 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:id="@+id/layout"
|
|
||||||
android:background="@drawable/list_selector"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="40dp"
|
|
||||||
android:padding="5dp"
|
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:orientation="horizontal" >
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/contact_name"
|
|
||||||
style="@style/font6"
|
|
||||||
android:lines="1"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/contact_address"
|
|
||||||
style="@style/font2"
|
|
||||||
android:lines="1"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"/>
|
|
||||||
</LinearLayout>
|
|
|
@ -144,9 +144,9 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:divider="@color/colorE"
|
android:divider="@color/colorE"
|
||||||
android:fastScrollEnabled="true"
|
android:dividerHeight="1dp"
|
||||||
android:fastScrollAlwaysVisible="true"
|
android:fastScrollAlwaysVisible="true"
|
||||||
android:dividerHeight="1dp" />
|
android:fastScrollEnabled="true"/>
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:id="@+id/contactsFetchInProgress"
|
android:id="@+id/contactsFetchInProgress"
|
||||||
|
|
|
@ -22,18 +22,20 @@
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/contact_name"
|
android:id="@+id/contact_name"
|
||||||
style="@style/font6"
|
style="@style/font6"
|
||||||
android:lines="1"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_centerVertical="true" />
|
android:layout_centerVertical="true"
|
||||||
|
android:gravity="top|left"
|
||||||
|
android:lines="1"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/contact_address"
|
android:id="@+id/contact_address"
|
||||||
style="@style/font2"
|
style="@style/font2"
|
||||||
android:lines="1"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_centerVertical="true"/>
|
android:layout_centerVertical="true"
|
||||||
|
android:gravity="bottom|left"
|
||||||
|
android:lines="1"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
|
@ -80,9 +80,6 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
|
||||||
allContactsSelected = view.findViewById(R.id.all_contacts_select);
|
allContactsSelected = view.findViewById(R.id.all_contacts_select);
|
||||||
linphoneContactsSelected = view.findViewById(R.id.linphone_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 = (ImageView) view.findViewById(R.id.back);
|
||||||
back.setOnClickListener(this);
|
back.setOnClickListener(this);
|
||||||
|
|
||||||
|
@ -96,9 +93,6 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
|
||||||
contactsFetchInProgress.setVisibility(View.VISIBLE);
|
contactsFetchInProgress.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
searchAdapter = new SearchContactsListAdapter(null, mInflater, contactsFetchInProgress);
|
searchAdapter = new SearchContactsListAdapter(null, mInflater, contactsFetchInProgress);
|
||||||
contactsList.setAdapter(searchAdapter);
|
|
||||||
contactsList.setOnItemClickListener(this);
|
|
||||||
|
|
||||||
|
|
||||||
searchField = (EditText) view.findViewById(R.id.searchField);
|
searchField = (EditText) view.findViewById(R.id.searchField);
|
||||||
searchField.addTextChangedListener(new TextWatcher() {
|
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;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,12 +156,14 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
|
||||||
private void updateListSelected() {
|
private void updateListSelected() {
|
||||||
if (contactsSelected.size() > 0) {
|
if (contactsSelected.size() > 0) {
|
||||||
contactsSelectLayout.setVisibility(View.VISIBLE);
|
contactsSelectLayout.setVisibility(View.VISIBLE);
|
||||||
|
contactsSelectLayout.invalidate();
|
||||||
} else {
|
} else {
|
||||||
contactsSelectLayout.setVisibility(View.GONE);
|
contactsSelectLayout.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateContactsClick(ContactAddress ca) {
|
private void updateContactsClick(ContactAddress ca) {
|
||||||
|
ca.setSelect(!ca.isSelect());
|
||||||
if(ca.isSelect()) {
|
if(ca.isSelect()) {
|
||||||
ContactSelectView csv = new ContactSelectView(LinphoneActivity.instance());
|
ContactSelectView csv = new ContactSelectView(LinphoneActivity.instance());
|
||||||
csv.setListener(this);
|
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);
|
View viewContact = LayoutInflater.from(LinphoneActivity.instance()).inflate(R.layout.contact_selected, null);
|
||||||
((TextView)viewContact.findViewById(R.id.sipUri)).setText(ca.getContact().getFullName());
|
((TextView)viewContact.findViewById(R.id.sipUri)).setText(ca.getContact().getFullName());
|
||||||
viewContact.findViewById(R.id.contactChatDelete).setOnClickListener(this);
|
viewContact.findViewById(R.id.contactChatDelete).setOnClickListener(this);
|
||||||
|
viewContact.setOnClickListener(this);
|
||||||
ca.setView(viewContact);
|
ca.setView(viewContact);
|
||||||
contactsSelectedLayout.addView(viewContact);
|
contactsSelectedLayout.addView(viewContact);
|
||||||
} else {
|
} else {
|
||||||
contactsSelected.remove(ca);
|
contactsSelected.remove(ca);
|
||||||
contactsSelectedLayout.removeAllViews();
|
contactsSelectedLayout.removeAllViews();
|
||||||
for (ContactAddress contactAddress : contactsSelected) {
|
for (ContactAddress contactAddress : contactsSelected) {
|
||||||
contactsSelectedLayout.addView(contactAddress.getView());
|
if (contactAddress.getView() != null)
|
||||||
|
contactsSelectedLayout.addView(contactAddress.getView());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
searchAdapter.setContactsSelectedList(contactsSelected);
|
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<String> listUri = new ArrayList<String>();
|
||||||
|
for (ContactAddress ca : contactsSelected) {
|
||||||
|
listUri.add(ca.getAddress());
|
||||||
|
}
|
||||||
|
outState.putStringArrayList("contactsSelected", listUri);
|
||||||
|
}
|
||||||
|
|
||||||
|
outState.putBoolean("onlySipContact", onlyDisplayLinphoneContacts);
|
||||||
|
|
||||||
|
super.onSaveInstanceState(outState);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
int id = view.getId();
|
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) {
|
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
||||||
// Get contact
|
// Get contact
|
||||||
ContactAddress ca = searchAdapter.getContacts().get(i);
|
ContactAddress ca = searchAdapter.getContacts().get(i);
|
||||||
ca.setSelect(!ca.isSelect());
|
|
||||||
updateContactsClick(ca);
|
updateContactsClick(ca);
|
||||||
updateList();
|
updateList();
|
||||||
updateListSelected();
|
updateListSelected();
|
||||||
|
|
|
@ -21,7 +21,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
public class ContactAddress {
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
public class ContactAddress implements Serializable {
|
||||||
private LinphoneContact contact;
|
private LinphoneContact contact;
|
||||||
private String address;
|
private String address;
|
||||||
private boolean isLinphoneContact;
|
private boolean isLinphoneContact;
|
||||||
|
|
Loading…
Reference in a new issue