This seems to fix contact edition issue + added refresher on contact list

This commit is contained in:
Sylvain Berfini 2018-12-06 15:56:14 +01:00
parent 9d66458f36
commit fc5da7f57d
4 changed files with 26 additions and 8 deletions

View file

@ -91,6 +91,7 @@ public class ContactEditorFragment extends Fragment {
Serializable obj = getArguments().getSerializable("Contact"); Serializable obj = getArguments().getSerializable("Contact");
if (obj != null) { if (obj != null) {
mContact = (LinphoneContact) obj; mContact = (LinphoneContact) obj;
mContact.createLinphoneTagIfNeeded();
mIsNewContact = false; mIsNewContact = false;
if (getArguments().getString("NewSipAdress") != null) { if (getArguments().getString("NewSipAdress") != null) {
mNewSipOrNumberToAdd = getArguments().getString("NewSipAdress"); mNewSipOrNumberToAdd = getArguments().getString("NewSipAdress");

View file

@ -34,6 +34,7 @@ import android.widget.TextView;
import androidx.recyclerview.widget.DividerItemDecoration; import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.linphone.LinphoneActivity; import org.linphone.LinphoneActivity;
@ -61,6 +62,7 @@ public class ContactsFragment extends Fragment
private Context mContext; private Context mContext;
private SelectableHelper mSelectionHelper; private SelectableHelper mSelectionHelper;
private ContactsAdapter mContactAdapter; private ContactsAdapter mContactAdapter;
private SwipeRefreshLayout mContactsRefresher;
@Override @Override
public View onCreateView( public View onCreateView(
@ -88,6 +90,15 @@ public class ContactsFragment extends Fragment
mLinphoneContactsSelected = view.findViewById(R.id.linphone_contacts_select); mLinphoneContactsSelected = view.findViewById(R.id.linphone_contacts_select);
mContactsFetchInProgress = view.findViewById(R.id.contactsFetchInProgress); mContactsFetchInProgress = view.findViewById(R.id.contactsFetchInProgress);
mNewContact = view.findViewById(R.id.newContact); mNewContact = view.findViewById(R.id.newContact);
mContactsRefresher = view.findViewById(R.id.contactsListRefresher);
mContactsRefresher.setOnRefreshListener(
new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
ContactsManager.getInstance().fetchContactsAsync();
}
});
mAllContacts.setOnClickListener( mAllContacts.setOnClickListener(
new View.OnClickListener() { new View.OnClickListener() {
@ -364,6 +375,7 @@ public class ContactsFragment extends Fragment
} }
} }
mContactsFetchInProgress.setVisibility(View.GONE); mContactsFetchInProgress.setVisibility(View.GONE);
mContactsRefresher.setRefreshing(false);
} }
private void invalidate() { private void invalidate() {

View file

@ -776,7 +776,6 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
&& ContactsManager.getInstance().hasContactsAccess() && ContactsManager.getInstance().hasContactsAccess()
&& mChangesToCommit.size() > 0) { && mChangesToCommit.size() > 0) {
try { try {
createLinphoneTagIfNeeded();
LinphoneService.instance() LinphoneService.instance()
.getContentResolver() .getContentResolver()
.applyBatch(ContactsContract.AUTHORITY, mChangesToCommit); .applyBatch(ContactsContract.AUTHORITY, mChangesToCommit);
@ -1077,7 +1076,7 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
return result; return result;
} }
private void createLinphoneTagIfNeeded() { public void createLinphoneTagIfNeeded() {
if (LinphoneManager.getInstance() if (LinphoneManager.getInstance()
.getContext() .getContext()
.getResources() .getResources()

View file

@ -110,14 +110,20 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<!--android:fastScrollAlwaysVisible="true"--> <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
<androidx.recyclerview.widget.RecyclerView android:id="@+id/contactsListRefresher"
android:id="@+id/contactsList"
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:dividerHeight="1dp" /> <androidx.recyclerview.widget.RecyclerView
android:id="@+id/contactsList"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="@color/colorE"
android:dividerHeight="1dp" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
<ProgressBar <ProgressBar
android:id="@+id/contactsFetchInProgress" android:id="@+id/contactsFetchInProgress"