ContactsListFragment ListView converted to RecyclerView, Adapter/ViewHolder are now located into a separate Class ContactsListAdapter, all features before conversion are available. This fragment now uses SelectableHelper/Adapter. All fragments converted to RecyclerView now have a divider between items of a list. TODO: convert HistoryListFragment ListView into RecyclerView.
This commit is contained in:
parent
590c56a573
commit
23bdb192ff
15 changed files with 270 additions and 249 deletions
7
res/drawable/divider.xml
Normal file
7
res/drawable/divider.xml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
<size
|
||||||
|
android:width="1dp"
|
||||||
|
android:height="1dp" />
|
||||||
|
<solid android:color="@color/colorE" />
|
||||||
|
</shape>
|
12
res/drawable/line.xml
Normal file
12
res/drawable/line.xml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
|
||||||
|
<solid android:color="@android:color/darker_gray" />
|
||||||
|
|
||||||
|
<padding
|
||||||
|
android:top="10dp"
|
||||||
|
android:left="10dp"
|
||||||
|
android:right="10dp"
|
||||||
|
android:bottom="10dp"/>
|
||||||
|
</shape>
|
9
res/drawable/line_drawable.xml
Normal file
9
res/drawable/line_drawable.xml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<!--<item-->
|
||||||
|
<!--android:state_pressed="true"-->
|
||||||
|
<!--android:drawable="@drawable/line"/>-->
|
||||||
|
|
||||||
|
<!--<item-->
|
||||||
|
<!--android:drawable="@drawable/line"/>-->
|
||||||
|
</selector>
|
|
@ -69,6 +69,7 @@
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignParentRight="true"
|
||||||
android:layout_centerInParent="true"
|
android:layout_centerInParent="true"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
|
android:clickable="false"
|
||||||
android:paddingLeft="5dp"
|
android:paddingLeft="5dp"
|
||||||
android:paddingRight="5dp" />
|
android:paddingRight="5dp" />
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,9 @@
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:background="@color/colorH"
|
android:background="@color/colorH"
|
||||||
android:orientation="vertical" >
|
android:orientation="vertical">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/top_bar"
|
android:id="@+id/top_bar"
|
||||||
|
@ -119,13 +120,18 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<!--android:fastScrollAlwaysVisible="true"-->
|
||||||
<android.support.v7.widget.RecyclerView
|
<android.support.v7.widget.RecyclerView
|
||||||
android:id="@+id/contactsList"
|
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:divider="@color/colorE"
|
||||||
android:fastScrollEnabled="true"
|
app:fastScrollEnabled="true"
|
||||||
android:fastScrollAlwaysVisible="true"
|
app:fastScrollHorizontalThumbDrawable="@drawable/fast_scroll"
|
||||||
|
app:fastScrollHorizontalTrackDrawable="@drawable/line_drawable"
|
||||||
|
app:fastScrollVerticalThumbDrawable="@drawable/fast_scroll"
|
||||||
|
app:fastScrollVerticalTrackDrawable="@drawable/line_drawable"
|
||||||
|
|
||||||
android:dividerHeight="1dp" />
|
android:dividerHeight="1dp" />
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
|
|
|
@ -5,30 +5,20 @@
|
||||||
<item name="android:fastScrollThumbDrawable">@drawable/fast_scroll</item>
|
<item name="android:fastScrollThumbDrawable">@drawable/fast_scroll</item>
|
||||||
<item name="android:fastScrollTextColor">@android:color/white</item>
|
<item name="android:fastScrollTextColor">@android:color/white</item>
|
||||||
<item name="android:fastScrollPreviewBackgroundRight">@drawable/fast_scroll_preview</item>
|
<item name="android:fastScrollPreviewBackgroundRight">@drawable/fast_scroll_preview</item>
|
||||||
<item name="android:windowActionModeOverlay">true</item>
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="NoTitle.ActionMode" parent="@style/Widget.AppCompat.ActionMode">
|
|
||||||
<!--Invisible ContextActionBar-->
|
|
||||||
<item name="android:background"></item>
|
|
||||||
<item name="android:height">1dp</item>
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<style name="NoTitle" parent="android:Theme.Holo.Light.NoActionBar">
|
<style name="NoTitle" parent="android:Theme.Holo.Light.NoActionBar">
|
||||||
<item name="android:actionModeStyle">@style/NoTitle.ActionMode</item>
|
|
||||||
<item name="android:actionModeCloseDrawable">@drawable/cancel_with_padding</item>
|
|
||||||
<item name="android:fastScrollThumbDrawable">@drawable/fast_scroll</item>
|
<item name="android:fastScrollThumbDrawable">@drawable/fast_scroll</item>
|
||||||
<item name="android:fastScrollTextColor">@android:color/white</item>
|
<item name="android:fastScrollTextColor">@android:color/white</item>
|
||||||
<item name="android:fastScrollPreviewBackgroundRight">@drawable/fast_scroll_preview</item>
|
<item name="android:fastScrollPreviewBackgroundRight">@drawable/fast_scroll_preview</item>
|
||||||
<item name="android:windowActionModeOverlay">true</item>
|
|
||||||
<!--windowActionModeOverlay prevents the CAB to push all others layouts to bottom-->
|
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
<style name="FullScreen" parent="android:Theme.Holo.Light.NoActionBar">
|
<style name="FullScreen" parent="android:Theme.Holo.Light.NoActionBar">
|
||||||
<item name="android:fastScrollThumbDrawable">@drawable/fast_scroll</item>
|
<item name="android:fastScrollThumbDrawable">@drawable/fast_scroll</item>
|
||||||
<item name="android:fastScrollTextColor">@android:color/white</item>
|
<item name="android:fastScrollTextColor">@android:color/white</item>
|
||||||
<item name="android:fastScrollPreviewBackgroundRight">@drawable/fast_scroll_preview</item>
|
<item name="android:fastScrollPreviewBackgroundRight">@drawable/fast_scroll_preview</item>
|
||||||
<item name="android:windowActionModeOverlay">true</item>
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="font1" parent="@android:style/TextAppearance.Medium">
|
<style name="font1" parent="@android:style/TextAppearance.Medium">
|
||||||
|
|
|
@ -21,6 +21,7 @@ package org.linphone.chat;
|
||||||
|
|
||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.v7.widget.DividerItemDecoration;
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
|
@ -151,6 +152,14 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
|
||||||
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity().getApplicationContext());
|
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity().getApplicationContext());
|
||||||
mContactsList.setAdapter(mSearchAdapter);
|
mContactsList.setAdapter(mSearchAdapter);
|
||||||
|
|
||||||
|
//Divider between items
|
||||||
|
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mContactsList.getContext(),
|
||||||
|
layoutManager.getOrientation());
|
||||||
|
dividerItemDecoration.setDrawable(getActivity().getApplicationContext().getResources().getDrawable(R.drawable.divider));
|
||||||
|
mContactsList.addItemDecoration(dividerItemDecoration);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
mContactsList.setLayoutManager(layoutManager);
|
mContactsList.setLayoutManager(layoutManager);
|
||||||
// mContactsList.setOnItemClickListener(this);
|
// mContactsList.setOnItemClickListener(this);
|
||||||
if (savedInstanceState != null && savedInstanceState.getStringArrayList("mContactsSelected") != null) {
|
if (savedInstanceState != null && savedInstanceState.getStringArrayList("mContactsSelected") != null) {
|
||||||
|
|
|
@ -166,7 +166,6 @@ public class ChatEventsAdapter extends SelectableAdapter<ChatBubbleViewHolder> {
|
||||||
holder.delete.setOnCheckedChangeListener(null);
|
holder.delete.setOnCheckedChangeListener(null);
|
||||||
holder.delete.setChecked(isSelected(position));
|
holder.delete.setChecked(isSelected(position));
|
||||||
holder.delete.setTag(position);
|
holder.delete.setTag(position);
|
||||||
holder.delete.setOnCheckedChangeListener(getDeleteListener());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//If event is Chat Message
|
//If event is Chat Message
|
||||||
|
|
|
@ -23,6 +23,7 @@ import android.app.Fragment;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.v7.widget.DividerItemDecoration;
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.support.v7.widget.helper.ItemTouchHelper;
|
import android.support.v7.widget.helper.ItemTouchHelper;
|
||||||
|
@ -101,6 +102,15 @@ public class ChatListFragment extends Fragment implements ContactsUpdatedListene
|
||||||
//Initialize the LayoutManager
|
//Initialize the LayoutManager
|
||||||
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(mContext);
|
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(mContext);
|
||||||
mChatRoomsList.setLayoutManager(layoutManager);
|
mChatRoomsList.setLayoutManager(layoutManager);
|
||||||
|
|
||||||
|
|
||||||
|
//Divider between items
|
||||||
|
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mChatRoomsList.getContext(),
|
||||||
|
((LinearLayoutManager) layoutManager).getOrientation());
|
||||||
|
dividerItemDecoration.setDrawable(getActivity().getApplicationContext().getResources().getDrawable(R.drawable.divider));
|
||||||
|
mChatRoomsList.addItemDecoration(dividerItemDecoration);
|
||||||
|
|
||||||
|
|
||||||
mWaitLayout.setVisibility(View.GONE);
|
mWaitLayout.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ import android.os.Bundle;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import android.provider.MediaStore;
|
import android.provider.MediaStore;
|
||||||
|
import android.support.v7.widget.DividerItemDecoration;
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
|
@ -221,6 +222,7 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
|
||||||
mSelectionHelper = new SelectableHelper(view, this);
|
mSelectionHelper = new SelectableHelper(view, this);
|
||||||
layoutManager = new LinearLayoutManager(mContext);
|
layoutManager = new LinearLayoutManager(mContext);
|
||||||
mChatEventsList.setLayoutManager(layoutManager);
|
mChatEventsList.setLayoutManager(layoutManager);
|
||||||
|
|
||||||
// registerForContextMenu(mChatEventsList);
|
// registerForContextMenu(mChatEventsList);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ import android.app.Dialog;
|
||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.v7.widget.DividerItemDecoration;
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
|
@ -79,6 +80,7 @@ public class GroupInfoFragment extends Fragment implements ChatRoomListener {
|
||||||
private ChatRoomListenerStub mChatRoomCreationListener;
|
private ChatRoomListenerStub mChatRoomCreationListener;
|
||||||
private Bundle mShareInfos;
|
private Bundle mShareInfos;
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
private LinearLayoutManager layoutManager;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
@ -126,7 +128,14 @@ public class GroupInfoFragment extends Fragment implements ChatRoomListener {
|
||||||
});
|
});
|
||||||
mParticipantsList.setAdapter(mAdapter);
|
mParticipantsList.setAdapter(mAdapter);
|
||||||
mAdapter.setChatRoom(mChatRoom);
|
mAdapter.setChatRoom(mChatRoom);
|
||||||
mParticipantsList.setLayoutManager(new LinearLayoutManager(mContext));
|
layoutManager = new LinearLayoutManager(mContext);
|
||||||
|
mParticipantsList.setLayoutManager(layoutManager);
|
||||||
|
|
||||||
|
//Divider between items
|
||||||
|
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mParticipantsList.getContext(),
|
||||||
|
layoutManager.getOrientation());
|
||||||
|
dividerItemDecoration.setDrawable(mContext.getResources().getDrawable(R.drawable.divider));
|
||||||
|
mParticipantsList.addItemDecoration(dividerItemDecoration);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ public class ContactsListAdapter extends SelectableAdapter<ContactsListAdapter.V
|
||||||
//public class ContactsListAdapter extends RecyclerView.Adapter<ContactsListAdapter.ViewHolder> implements SectionIndexer {
|
//public class ContactsListAdapter extends RecyclerView.Adapter<ContactsListAdapter.ViewHolder> implements SectionIndexer {
|
||||||
// class ContactsListAdapter extends BaseAdapter implements SectionIndexer {
|
// class ContactsListAdapter extends BaseAdapter implements SectionIndexer {
|
||||||
|
|
||||||
public static class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{
|
public static class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener{
|
||||||
public CheckBox delete;
|
public CheckBox delete;
|
||||||
public ImageView linphoneFriend;
|
public ImageView linphoneFriend;
|
||||||
public TextView name;
|
public TextView name;
|
||||||
|
@ -53,6 +53,8 @@ public class ContactsListAdapter extends SelectableAdapter<ContactsListAdapter.V
|
||||||
//friendStatus = (ImageView) view.findViewById(R.id.friendStatus);
|
//friendStatus = (ImageView) view.findViewById(R.id.friendStatus);
|
||||||
this.listener= listener;
|
this.listener= listener;
|
||||||
view.setOnClickListener(this);
|
view.setOnClickListener(this);
|
||||||
|
view.setOnLongClickListener(this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -63,8 +65,16 @@ public class ContactsListAdapter extends SelectableAdapter<ContactsListAdapter.V
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean onLongClick(View v) {
|
||||||
|
if (listener != null) {
|
||||||
|
return listener.onItemLongClicked(getAdapterPosition());
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public interface ClickListener {
|
public interface ClickListener {
|
||||||
void onItemClicked(int position);
|
void onItemClicked(int position);
|
||||||
|
boolean onItemLongClicked(int position);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -101,31 +111,20 @@ public class ContactsListAdapter extends SelectableAdapter<ContactsListAdapter.V
|
||||||
holder.name.setText(contact.getFullName());
|
holder.name.setText(contact.getFullName());
|
||||||
|
|
||||||
if (!isSearchMode) {
|
if (!isSearchMode) {
|
||||||
if (getPositionForSection(getSectionForPosition(position)) != position) {
|
|
||||||
holder.separator.setVisibility(View.GONE);
|
|
||||||
} else {
|
|
||||||
holder.separator.setVisibility(View.VISIBLE);
|
|
||||||
String fullName = contact.getFullName();
|
String fullName = contact.getFullName();
|
||||||
if (fullName != null && !fullName.isEmpty()) {
|
if (fullName != null && !fullName.isEmpty()) {
|
||||||
holder.separatorText.setText(String.valueOf(fullName.charAt(0)));
|
holder.separatorText.setText(String.valueOf(fullName.charAt(0)));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
|
||||||
holder.separator.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (contact.isInFriendList()) {
|
|
||||||
holder.linphoneFriend.setVisibility(View.VISIBLE);
|
|
||||||
} else {
|
|
||||||
holder.linphoneFriend.setVisibility(View.GONE);
|
|
||||||
}
|
}
|
||||||
|
holder.separator.setVisibility(isSearchMode || (!isSearchMode && getPositionForSection(getSectionForPosition(position)) != position ) ? View.GONE:View.VISIBLE);
|
||||||
|
holder.linphoneFriend.setVisibility(contact.isInFriendList() ? View.VISIBLE:View.GONE);
|
||||||
|
|
||||||
holder.contactPicture.setImageBitmap(ContactsManager.getInstance().getDefaultAvatarBitmap());
|
holder.contactPicture.setImageBitmap(ContactsManager.getInstance().getDefaultAvatarBitmap());
|
||||||
if (contact.hasPhoto()) {
|
if (contact.hasPhoto()) {
|
||||||
LinphoneUtils.setThumbnailPictureFromUri(LinphoneActivity.instance(), holder.contactPicture, contact.getThumbnailUri());
|
LinphoneUtils.setThumbnailPictureFromUri(LinphoneActivity.instance(), holder.contactPicture, contact.getThumbnailUri());
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isOrgVisible = getResources().getBoolean(R.bool.display_contact_organization);
|
boolean isOrgVisible = mContext.getResources().getBoolean(R.bool.display_contact_organization);
|
||||||
String org = contact.getOrganization();
|
String org = contact.getOrganization();
|
||||||
if (org != null && !org.isEmpty() && isOrgVisible) {
|
if (org != null && !org.isEmpty() && isOrgVisible) {
|
||||||
holder.organization.setText(org);
|
holder.organization.setText(org);
|
||||||
|
@ -143,15 +142,19 @@ public class ContactsListAdapter extends SelectableAdapter<ContactsListAdapter.V
|
||||||
return contacts.size();
|
return contacts.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
// public int getCount() {
|
|
||||||
// return contacts.size();
|
|
||||||
// }
|
|
||||||
|
|
||||||
public Object getItem(int position) {
|
public Object getItem(int position) {
|
||||||
if (position >= getItemCount()) return null;
|
if (position >= getItemCount()) return null;
|
||||||
return contacts.get(position);
|
return contacts.get(position);
|
||||||
}
|
}
|
||||||
|
public boolean isSearchMode(){
|
||||||
|
return this.isSearchMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSearchMode(boolean set){
|
||||||
|
isSearchMode = set;
|
||||||
|
}
|
||||||
public long getItemId(int position) {
|
public long getItemId(int position) {
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
|
@ -182,111 +185,6 @@ public class ContactsListAdapter extends SelectableAdapter<ContactsListAdapter.V
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// public View getView(final int position, View convertView, ViewGroup parent) {
|
|
||||||
// View view = null;
|
|
||||||
// LinphoneContact contact = (LinphoneContact) getItem(position);
|
|
||||||
// if (contact == null) return null;
|
|
||||||
//
|
|
||||||
// ViewHolder holder = null;
|
|
||||||
// if (convertView != null) {
|
|
||||||
// view = convertView;
|
|
||||||
// holder = (ViewHolder) view.getTag();
|
|
||||||
// } else {
|
|
||||||
// view = mInflater.inflate(R.layout.contact_cell, parent, false);
|
|
||||||
// holder = new ViewHolder(view);
|
|
||||||
// view.setTag(holder);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// holder.name.setText(contact.getFullName());
|
|
||||||
//
|
|
||||||
// if (!isSearchMode) {
|
|
||||||
// if (getPositionForSection(getSectionForPosition(position)) != position) {
|
|
||||||
// holder.separator.setVisibility(View.GONE);
|
|
||||||
// } else {
|
|
||||||
// holder.separator.setVisibility(View.VISIBLE);
|
|
||||||
// String fullName = contact.getFullName();
|
|
||||||
// if (fullName != null && !fullName.isEmpty()) {
|
|
||||||
// holder.separatorText.setText(String.valueOf(fullName.charAt(0)));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// holder.separator.setVisibility(View.GONE);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (contact.isInFriendList()) {
|
|
||||||
// holder.linphoneFriend.setVisibility(View.VISIBLE);
|
|
||||||
// } else {
|
|
||||||
// holder.linphoneFriend.setVisibility(View.GONE);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// holder.contactPicture.setImageBitmap(ContactsManager.getInstance().getDefaultAvatarBitmap());
|
|
||||||
// if (contact.hasPhoto()) {
|
|
||||||
// LinphoneUtils.setThumbnailPictureFromUri(LinphoneActivity.instance(), holder.contactPicture, contact.getThumbnailUri());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// boolean isOrgVisible = getResources().getBoolean(R.bool.display_contact_organization);
|
|
||||||
// String org = contact.getOrganization();
|
|
||||||
// if (org != null && !org.isEmpty() && isOrgVisible) {
|
|
||||||
// holder.organization.setText(org);
|
|
||||||
// holder.organization.setVisibility(View.VISIBLE);
|
|
||||||
// } else {
|
|
||||||
// holder.organization.setVisibility(View.GONE);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (isEditMode) {
|
|
||||||
// holder.delete.setVisibility(View.VISIBLE);
|
|
||||||
// holder.delete.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
||||||
// @Override
|
|
||||||
// public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
|
|
||||||
// contactsList.setItemChecked(position, b);
|
|
||||||
// if(getNbItemsChecked() == getCount()){
|
|
||||||
// deselectAll.setVisibility(View.VISIBLE);
|
|
||||||
// selectAll.setVisibility(View.GONE);
|
|
||||||
// enabledDeleteButton(true);
|
|
||||||
// } else {
|
|
||||||
// if(getNbItemsChecked() == 0){
|
|
||||||
// deselectAll.setVisibility(View.GONE);
|
|
||||||
// selectAll.setVisibility(View.VISIBLE);
|
|
||||||
// enabledDeleteButton(false);
|
|
||||||
// } else {
|
|
||||||
// deselectAll.setVisibility(View.GONE);
|
|
||||||
// selectAll.setVisibility(View.VISIBLE);
|
|
||||||
// enabledDeleteButton(true);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// if (contactsList.isItemChecked(position)) {
|
|
||||||
// holder.delete.setChecked(true);
|
|
||||||
// } else {
|
|
||||||
// holder.delete.setChecked(false);
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// holder.delete.setVisibility(View.INVISIBLE);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /*Friend[] friends = LinphoneManager.getLc().getFriendsLists();
|
|
||||||
// if (!ContactsManager.getInstance().isContactPresenceDisabled() && friends != null) {
|
|
||||||
// holder.friendStatus.setVisibility(View.VISIBLE);
|
|
||||||
// PresenceActivityType presenceActivity = friends[0].getPresenceModel().getActivity().getType();
|
|
||||||
// if (presenceActivity == PresenceActivityType.Online) {
|
|
||||||
// holder.friendStatus.setImageResource(R.drawable.led_connected);
|
|
||||||
// } else if (presenceActivity == PresenceActivityType.Busy) {
|
|
||||||
// holder.friendStatus.setImageResource(R.drawable.led_error);
|
|
||||||
// } else if (presenceActivity == PresenceActivityType.Away) {
|
|
||||||
// holder.friendStatus.setImageResource(R.drawable.led_inprogress);
|
|
||||||
// } else if (presenceActivity == PresenceActivityType.Offline) {
|
|
||||||
// holder.friendStatus.setImageResource(R.drawable.led_disconnected);
|
|
||||||
// } else {
|
|
||||||
// holder.friendStatus.setImageResource(R.drawable.call_quality_indicator_0);
|
|
||||||
// }
|
|
||||||
// }*/
|
|
||||||
//
|
|
||||||
// return view;
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object[] getSections() {
|
public Object[] getSections() {
|
||||||
return sections;
|
return sections;
|
||||||
|
|
|
@ -23,8 +23,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.graphics.Color;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.v7.widget.DividerItemDecoration;
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
|
@ -48,6 +50,7 @@ import android.widget.ProgressBar;
|
||||||
import android.widget.SectionIndexer;
|
import android.widget.SectionIndexer;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import org.linphone.core.ChatRoom;
|
||||||
import org.linphone.fragments.FragmentsAvailable;
|
import org.linphone.fragments.FragmentsAvailable;
|
||||||
import org.linphone.LinphoneManager;
|
import org.linphone.LinphoneManager;
|
||||||
import org.linphone.LinphoneUtils;
|
import org.linphone.LinphoneUtils;
|
||||||
|
@ -62,15 +65,14 @@ import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class ContactsListFragment extends Fragment implements OnItemClickListener, ContactsUpdatedListener, ContactsListAdapter.ViewHolder.ClickListener ,SelectableHelper.DeleteListener {
|
public class ContactsListFragment extends Fragment implements OnItemClickListener, ContactsUpdatedListener, ContactsListAdapter.ViewHolder.ClickListener ,SelectableHelper.DeleteListener {
|
||||||
//public class ContactsListFragment extends Fragment implements OnClickListener, OnItemClickListener, ContactsUpdatedListener {
|
|
||||||
//public class ContactsListFragment extends Fragment implements OnClickListener, OnItemClickListener, ContactsUpdatedListener {
|
//public class ContactsListFragment extends Fragment implements OnClickListener, OnItemClickListener, ContactsUpdatedListener {
|
||||||
private LayoutInflater mInflater;
|
private LayoutInflater mInflater;
|
||||||
private RecyclerView contactsList;
|
private RecyclerView contactsList;
|
||||||
private TextView noSipContact, noContact;
|
private TextView noSipContact, noContact;
|
||||||
private ImageView allContacts, linphoneContacts, newContact, edit, selectAll, deselectAll, delete, cancel;
|
private ImageView allContacts, linphoneContacts, newContact, edit;
|
||||||
private boolean onlyDisplayLinphoneContacts;
|
private boolean onlyDisplayLinphoneContacts;
|
||||||
private View allContactsSelected, linphoneContactsSelected;
|
private View allContactsSelected, linphoneContactsSelected;
|
||||||
private LinearLayout editList, topbar;
|
private LinearLayout topbar;
|
||||||
private int lastKnownPosition;
|
private int lastKnownPosition;
|
||||||
private boolean editOnClick = false, editConsumed = false, onlyDisplayChatAddress = false;
|
private boolean editOnClick = false, editConsumed = false, onlyDisplayChatAddress = false;
|
||||||
private String sipAddressToAdd, displayName = null;
|
private String sipAddressToAdd, displayName = null;
|
||||||
|
@ -88,6 +90,7 @@ public class ContactsListFragment extends Fragment implements OnItemClickListene
|
||||||
View view = inflater.inflate(R.layout.contacts_list, container, false);
|
View view = inflater.inflate(R.layout.contacts_list, container, false);
|
||||||
mContext = getActivity().getApplicationContext();
|
mContext = getActivity().getApplicationContext();
|
||||||
mSelectionHelper = new SelectableHelper(view, this);
|
mSelectionHelper = new SelectableHelper(view, this);
|
||||||
|
|
||||||
if (getArguments() != null) {
|
if (getArguments() != null) {
|
||||||
editOnClick = getArguments().getBoolean("EditOnClick");
|
editOnClick = getArguments().getBoolean("EditOnClick");
|
||||||
sipAddressToAdd = getArguments().getString("SipAddress");
|
sipAddressToAdd = getArguments().getString("SipAddress");
|
||||||
|
@ -98,46 +101,67 @@ public class ContactsListFragment extends Fragment implements OnItemClickListene
|
||||||
|
|
||||||
noSipContact = (TextView) view.findViewById(R.id.noSipContact);
|
noSipContact = (TextView) view.findViewById(R.id.noSipContact);
|
||||||
noContact = (TextView) view.findViewById(R.id.noContact);
|
noContact = (TextView) view.findViewById(R.id.noContact);
|
||||||
|
|
||||||
contactsList = view.findViewById(R.id.contactsList);
|
contactsList = view.findViewById(R.id.contactsList);
|
||||||
contactsList.setOnItemClickListener(this);
|
|
||||||
|
|
||||||
allContacts = (ImageView) view.findViewById(R.id.all_contacts);
|
allContacts = (ImageView) view.findViewById(R.id.all_contacts);
|
||||||
allContacts.setOnClickListener(this);
|
linphoneContacts = (ImageView) view.findViewById(R.id.linphone_contacts);
|
||||||
|
|
||||||
linphoneContacts = (ImageView) view.findViewById(R.id.linphone_contacts);
|
|
||||||
linphoneContacts.setOnClickListener(this);
|
|
||||||
|
|
||||||
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);
|
||||||
|
topbar = (LinearLayout) view.findViewById(R.id.top_bar);
|
||||||
|
edit = (ImageView) view.findViewById(R.id.edit);
|
||||||
|
contactsFetchInProgress = (ProgressBar) view.findViewById(R.id.contactsFetchInProgress);
|
||||||
|
newContact = (ImageView) view.findViewById(R.id.newContact);
|
||||||
|
|
||||||
|
allContacts.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
onlyDisplayLinphoneContacts = false;
|
||||||
|
allContactsSelected.setVisibility(View.VISIBLE);
|
||||||
|
allContacts.setEnabled(false);
|
||||||
|
linphoneContacts.setEnabled(true);
|
||||||
|
linphoneContactsSelected.setVisibility(View.INVISIBLE);
|
||||||
|
changeContactsAdapter();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
linphoneContacts.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
allContactsSelected.setVisibility(View.INVISIBLE);
|
||||||
|
linphoneContactsSelected.setVisibility(View.VISIBLE);
|
||||||
|
linphoneContacts.setEnabled(false);
|
||||||
|
allContacts.setEnabled(true);
|
||||||
|
onlyDisplayLinphoneContacts = true;
|
||||||
|
changeContactsAdapter();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
newContact.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
editConsumed = true;
|
||||||
|
if(displayName != null)
|
||||||
|
LinphoneActivity.instance().addContact(displayName, sipAddressToAdd);
|
||||||
|
else
|
||||||
|
LinphoneActivity.instance().addContact(null, sipAddressToAdd);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
newContact = (ImageView) view.findViewById(R.id.newContact);
|
|
||||||
newContact.setOnClickListener(this);
|
|
||||||
newContact.setEnabled(LinphoneManager.getLc().getCallsNb() == 0);
|
newContact.setEnabled(LinphoneManager.getLc().getCallsNb() == 0);
|
||||||
|
|
||||||
allContacts.setEnabled(onlyDisplayLinphoneContacts);
|
allContacts.setEnabled(onlyDisplayLinphoneContacts);
|
||||||
linphoneContacts.setEnabled(!allContacts.isEnabled());
|
linphoneContacts.setEnabled(!allContacts.isEnabled());
|
||||||
|
contactsFetchInProgress.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
selectAll = (ImageView) view.findViewById(R.id.select_all);
|
|
||||||
selectAll.setOnClickListener(this);
|
|
||||||
|
|
||||||
deselectAll = (ImageView) view.findViewById(R.id.deselect_all);
|
|
||||||
deselectAll.setOnClickListener(this);
|
|
||||||
|
|
||||||
delete = (ImageView) view.findViewById(R.id.delete);
|
|
||||||
delete.setOnClickListener(this);
|
|
||||||
|
|
||||||
editList = (LinearLayout) view.findViewById(R.id.edit_list);
|
|
||||||
topbar = (LinearLayout) view.findViewById(R.id.top_bar);
|
|
||||||
|
|
||||||
cancel = (ImageView) view.findViewById(R.id.cancel);
|
|
||||||
cancel.setOnClickListener(this);
|
|
||||||
|
|
||||||
edit = (ImageView) view.findViewById(R.id.edit);
|
|
||||||
edit.setOnClickListener(this);
|
|
||||||
|
|
||||||
clearSearchField = (ImageView) view.findViewById(R.id.clearSearchField);
|
clearSearchField = (ImageView) view.findViewById(R.id.clearSearchField);
|
||||||
clearSearchField.setOnClickListener(this);
|
clearSearchField.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
searchField.setText("");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
searchField = (EditText) view.findViewById(R.id.searchField);
|
searchField = (EditText) view.findViewById(R.id.searchField);
|
||||||
searchField.addTextChangedListener(new TextWatcher() {
|
searchField.addTextChangedListener(new TextWatcher() {
|
||||||
|
@ -158,13 +182,18 @@ public class ContactsListFragment extends Fragment implements OnItemClickListene
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
contactsFetchInProgress = (ProgressBar) view.findViewById(R.id.contactsFetchInProgress);
|
|
||||||
contactsFetchInProgress.setVisibility(View.VISIBLE);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
layoutManager = new LinearLayoutManager(mContext);
|
layoutManager = new LinearLayoutManager(mContext);
|
||||||
contactsList.setLayoutManager(layoutManager);
|
contactsList.setLayoutManager(layoutManager);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//Divider between items
|
||||||
|
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(contactsList.getContext(),
|
||||||
|
layoutManager.getOrientation());
|
||||||
|
dividerItemDecoration.setDrawable(getContext().getResources().getDrawable(R.drawable.divider));
|
||||||
|
contactsList.addItemDecoration(dividerItemDecoration);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -173,36 +202,25 @@ public class ContactsListFragment extends Fragment implements OnItemClickListene
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getNbItemsChecked(){
|
// public int getNbItemsChecked(){
|
||||||
int size = contactsList.getAdapter().getItemCount();
|
// int size = mContactAdapter.getItemCount();
|
||||||
int nb = 0;
|
//// int size = contactsList.getAdapter().getItemCount();
|
||||||
for(int i=0; i<size; i++) {
|
// int nb = 0;
|
||||||
if(contactsList.isItemChecked(i)) {
|
// for(int i=0; i<size; i++) {
|
||||||
nb ++;
|
// if(mContactAdapter.isSelected(i)) {
|
||||||
}
|
// nb ++;
|
||||||
}
|
// }
|
||||||
return nb;
|
// }
|
||||||
}
|
// return nb;
|
||||||
|
// }
|
||||||
|
|
||||||
public void enabledDeleteButton(Boolean enabled){
|
// public void quitEditMode(){
|
||||||
if(enabled){
|
// mSelectionHelper.quitEditionMode();
|
||||||
delete.setEnabled(true);
|
// invalidate();
|
||||||
} else {
|
// if(getResources().getBoolean(R.bool.isTablet)){
|
||||||
if (getNbItemsChecked() == 0){
|
// displayFirstContact();
|
||||||
delete.setEnabled(false);
|
// }
|
||||||
}
|
// }
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void quitEditMode(){
|
|
||||||
isEditMode = false;
|
|
||||||
editList.setVisibility(View.GONE);
|
|
||||||
topbar.setVisibility(View.VISIBLE);
|
|
||||||
invalidate();
|
|
||||||
if(getResources().getBoolean(R.bool.isTablet)){
|
|
||||||
displayFirstContact();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void displayFirstContact(){
|
public void displayFirstContact(){
|
||||||
if (contactsList != null && contactsList.getAdapter() != null && contactsList.getAdapter().getItemCount() > 0) {
|
if (contactsList != null && contactsList.getAdapter() != null && contactsList.getAdapter().getItemCount() > 0) {
|
||||||
|
@ -213,64 +231,86 @@ public class ContactsListFragment extends Fragment implements OnItemClickListene
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void searchContacts() {
|
// private void searchContacts() {
|
||||||
searchContacts(searchField.getText().toString());
|
// searchContacts(searchField.getText().toString());
|
||||||
}
|
// }
|
||||||
|
|
||||||
private void searchContacts(String search) {
|
private void searchContacts(String search) {
|
||||||
|
boolean isEditionEnabled = false;
|
||||||
|
|
||||||
if (search == null || search.length() == 0) {
|
if (search == null || search.length() == 0) {
|
||||||
changeContactsAdapter();
|
changeContactsAdapter();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
changeContactsToggle();
|
changeContactsToggle();
|
||||||
|
mContactAdapter.setSearchMode(true);
|
||||||
|
|
||||||
List<LinphoneContact> listContact;
|
List<LinphoneContact> listContact;
|
||||||
isSearchMode = true;
|
|
||||||
|
|
||||||
if (onlyDisplayLinphoneContacts) {
|
if (onlyDisplayLinphoneContacts) {
|
||||||
listContact = ContactsManager.getInstance().getSIPContacts(search);
|
listContact = ContactsManager.getInstance().getSIPContacts(search);
|
||||||
} else {
|
} else {
|
||||||
listContact = ContactsManager.getInstance().getContacts(search);
|
listContact = ContactsManager.getInstance().getContacts(search);
|
||||||
}
|
}
|
||||||
|
if(mContactAdapter != null && mContactAdapter.isEditionEnabled()) {
|
||||||
|
isEditionEnabled=true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
mContactAdapter = new ContactsListAdapter(mContext, listContact, this, mSelectionHelper);
|
mContactAdapter = new ContactsListAdapter(mContext, listContact, this, mSelectionHelper);
|
||||||
contactsList.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE);
|
|
||||||
|
// contactsList.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE);
|
||||||
|
mSelectionHelper.setAdapter(mContactAdapter);
|
||||||
|
if(isEditionEnabled) {
|
||||||
|
mSelectionHelper.enterEditionMode();
|
||||||
|
}
|
||||||
contactsList.setAdapter(mContactAdapter);
|
contactsList.setAdapter(mContactAdapter);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void changeContactsAdapter() {
|
private void changeContactsAdapter() {
|
||||||
changeContactsToggle();
|
changeContactsToggle();
|
||||||
List<LinphoneContact> listContact;
|
List<LinphoneContact> listContact;
|
||||||
isSearchMode = false;
|
|
||||||
noSipContact.setVisibility(View.GONE);
|
noSipContact.setVisibility(View.GONE);
|
||||||
noContact.setVisibility(View.GONE);
|
noContact.setVisibility(View.GONE);
|
||||||
contactsList.setVisibility(View.VISIBLE);
|
contactsList.setVisibility(View.VISIBLE);
|
||||||
|
boolean isEditionEnabled = false;
|
||||||
ContactsListAdapter adapter;
|
if(searchField.getText().toString() == "") {
|
||||||
contactsList.setFastScrollEnabled(false);
|
if (onlyDisplayLinphoneContacts) {
|
||||||
contactsList.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE);
|
listContact = ContactsManager.getInstance().getSIPContacts();
|
||||||
|
} else {
|
||||||
|
listContact = ContactsManager.getInstance().getContacts();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (onlyDisplayLinphoneContacts) {
|
}else{
|
||||||
listContact = ContactsManager.getInstance().getSIPContacts();
|
if (onlyDisplayLinphoneContacts) {
|
||||||
} else {
|
listContact = ContactsManager.getInstance().getSIPContacts(searchField.getText().toString());
|
||||||
listContact = ContactsManager.getInstance().getContacts();
|
} else {
|
||||||
|
listContact = ContactsManager.getInstance().getContacts(searchField.getText().toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(mContactAdapter != null && mContactAdapter.isEditionEnabled()) {
|
||||||
|
isEditionEnabled=true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
mContactAdapter = new ContactsListAdapter(mContext, listContact, this, mSelectionHelper);
|
mContactAdapter = new ContactsListAdapter(mContext, listContact, this, mSelectionHelper);
|
||||||
|
// mContactAdapter.setSearchMode(false);
|
||||||
|
|
||||||
|
mSelectionHelper.setAdapter(mContactAdapter);
|
||||||
|
|
||||||
|
if(isEditionEnabled) {
|
||||||
|
mSelectionHelper.enterEditionMode();
|
||||||
|
}
|
||||||
contactsList.setAdapter(mContactAdapter);
|
contactsList.setAdapter(mContactAdapter);
|
||||||
edit.setEnabled(true);
|
edit.setEnabled(true);
|
||||||
|
|
||||||
|
mContactAdapter.notifyDataSetChanged();
|
||||||
|
|
||||||
|
if (mContactAdapter.getItemCount() > 0) {
|
||||||
|
|
||||||
contactsList.setFastScrollEnabled(true);
|
|
||||||
adapter.notifyDataSetChanged();
|
|
||||||
|
|
||||||
|
|
||||||
if (adapter.getItemCount() > 0) {
|
|
||||||
contactsFetchInProgress.setVisibility(View.GONE);
|
contactsFetchInProgress.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
ContactsManager.getInstance().setLinphoneContactsPrefered(onlyDisplayLinphoneContacts);
|
ContactsManager.getInstance().setLinphoneContactsPrefered(onlyDisplayLinphoneContacts);
|
||||||
|
@ -298,11 +338,19 @@ public class ContactsListFragment extends Fragment implements OnItemClickListene
|
||||||
LinphoneActivity.instance().editContact(contact, sipAddressToAdd);
|
LinphoneActivity.instance().editContact(contact, sipAddressToAdd);
|
||||||
} else {
|
} else {
|
||||||
lastKnownPosition = layoutManager.findFirstVisibleItemPosition();
|
lastKnownPosition = layoutManager.findFirstVisibleItemPosition();
|
||||||
// lastKnownPosition = contactsList.getFirstVisiblePosition();
|
|
||||||
LinphoneActivity.instance().displayContact(contact, onlyDisplayChatAddress);
|
LinphoneActivity.instance().displayContact(contact, onlyDisplayChatAddress);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onItemLongClicked(int position) {
|
||||||
|
if (!mContactAdapter.isEditionEnabled()) {
|
||||||
|
mSelectionHelper.enterEditionMode();
|
||||||
|
}
|
||||||
|
mContactAdapter.toggleSelection(position);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
ContactsManager.addContactsListener(this);
|
ContactsManager.addContactsListener(this);
|
||||||
|
@ -338,13 +386,11 @@ public class ContactsListFragment extends Fragment implements OnItemClickListene
|
||||||
return;
|
return;
|
||||||
ContactsListAdapter adapter = (ContactsListAdapter)contactsList.getAdapter();
|
ContactsListAdapter adapter = (ContactsListAdapter)contactsList.getAdapter();
|
||||||
if (adapter != null) {
|
if (adapter != null) {
|
||||||
contactsList.setFastScrollEnabled(false);
|
|
||||||
if (onlyDisplayLinphoneContacts) {
|
if (onlyDisplayLinphoneContacts) {
|
||||||
adapter.updateDataSet(ContactsManager.getInstance().getSIPContacts());
|
adapter.updateDataSet(ContactsManager.getInstance().getSIPContacts());
|
||||||
} else {
|
} else {
|
||||||
adapter.updateDataSet(ContactsManager.getInstance().getContacts());
|
adapter.updateDataSet(ContactsManager.getInstance().getContacts());
|
||||||
}
|
}
|
||||||
contactsList.setFastScrollEnabled(true);
|
|
||||||
contactsFetchInProgress.setVisibility(View.GONE);
|
contactsFetchInProgress.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -356,16 +402,38 @@ public class ContactsListFragment extends Fragment implements OnItemClickListene
|
||||||
changeContactsAdapter();
|
changeContactsAdapter();
|
||||||
}
|
}
|
||||||
contactsList.scrollToPosition(lastKnownPosition);
|
contactsList.scrollToPosition(lastKnownPosition);
|
||||||
// contactsList.setSelectionFromTop(lastKnownPosition, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDeleteSelection(Object[] objectsToDelete) {
|
public void onDeleteSelection(Object[] objectsToDelete) {
|
||||||
|
ArrayList<String> ids = new ArrayList<String>();
|
||||||
|
int size = mContactAdapter.getSelectedItemCount();
|
||||||
|
for (int i = size - 1; i >= 0; i--) {
|
||||||
|
LinphoneContact contact = (LinphoneContact)objectsToDelete[i];
|
||||||
|
if (contact.isAndroidContact()) {
|
||||||
|
contact.deleteFriend();
|
||||||
|
ids.add(contact.getAndroidId());
|
||||||
|
} else {
|
||||||
|
contact.delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ContactsManager.getInstance().deleteMultipleContactsAtOnce(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onItemClicked(int position) {
|
public void onItemClicked(int position) {
|
||||||
|
LinphoneContact contact = (LinphoneContact) mContactAdapter.getItem(position);
|
||||||
|
|
||||||
|
if (mContactAdapter.isEditionEnabled()) {
|
||||||
|
mContactAdapter.toggleSelection(position);
|
||||||
|
|
||||||
|
}else if (editOnClick) {
|
||||||
|
editConsumed = true;
|
||||||
|
LinphoneActivity.instance().editContact(contact, sipAddressToAdd);
|
||||||
|
} else {
|
||||||
|
lastKnownPosition = layoutManager.findFirstVisibleItemPosition();
|
||||||
|
LinphoneActivity.instance().displayContact(contact, onlyDisplayChatAddress);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,17 +19,15 @@ public abstract class SelectableAdapter<VH extends RecyclerView.ViewHolder> exte
|
||||||
mListHelper = helper;
|
mListHelper = helper;
|
||||||
}
|
}
|
||||||
|
|
||||||
private CompoundButton.OnCheckedChangeListener mDeleteCheckboxListener = new CompoundButton.OnCheckedChangeListener() {
|
// private CompoundButton.OnCheckedChangeListener mDeleteCheckboxListener = new CompoundButton.OnCheckedChangeListener() {
|
||||||
@Override
|
// @Override
|
||||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
// public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||||
// Integer position = (Integer)compoundButton.getTag();
|
// mListHelper.updateSelectionButtons(mSelectedItems.size() == 0, mSelectedItems.size() == getItemCount());
|
||||||
|
// }
|
||||||
mListHelper.updateSelectionButtons(mSelectedItems.size() == 0, mSelectedItems.size() == getItemCount());
|
// };
|
||||||
}
|
// public CompoundButton.OnCheckedChangeListener getDeleteListener() {
|
||||||
};
|
// return mDeleteCheckboxListener;
|
||||||
public CompoundButton.OnCheckedChangeListener getDeleteListener() {
|
// }
|
||||||
return mDeleteCheckboxListener;
|
|
||||||
}
|
|
||||||
public boolean isEditionEnabled() {
|
public boolean isEditionEnabled() {
|
||||||
return mIsEditionEnabled;
|
return mIsEditionEnabled;
|
||||||
}
|
}
|
||||||
|
@ -98,8 +96,11 @@ public abstract class SelectableAdapter<VH extends RecyclerView.ViewHolder> exte
|
||||||
public void selectAll() {
|
public void selectAll() {
|
||||||
for (Integer i = 0; i < getItemCount(); i++) {
|
for (Integer i = 0; i < getItemCount(); i++) {
|
||||||
mSelectedItems.put(i, true);
|
mSelectedItems.put(i, true);
|
||||||
notifyItemChanged(i);
|
// notifyItemChanged(i);
|
||||||
|
notifyDataSetChanged();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mListHelper.updateSelectionButtons(false, true);
|
mListHelper.updateSelectionButtons(false, true);
|
||||||
// notifyDataSetChanged();
|
// notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,7 +144,7 @@ public class SelectableHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void quitEditionMode() {
|
public void quitEditionMode() {
|
||||||
mAdapter.enableEdition(false);
|
mAdapter.enableEdition(false);
|
||||||
mTopBar.setVisibility(View.VISIBLE);
|
mTopBar.setVisibility(View.VISIBLE);
|
||||||
mEditTopBar.setVisibility(View.GONE);
|
mEditTopBar.setVisibility(View.GONE);
|
||||||
|
|
Loading…
Reference in a new issue