All code added/edited during RecyclerView conversion cleansed.
This commit is contained in:
parent
7d23170577
commit
0f661de591
16 changed files with 91 additions and 414 deletions
|
@ -7,9 +7,7 @@ import android.support.v7.widget.RecyclerView;
|
|||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
|
@ -18,7 +16,6 @@ import android.widget.TextView;
|
|||
import org.linphone.LinphoneUtils;
|
||||
import org.linphone.R;
|
||||
import org.linphone.activities.LinphoneActivity;
|
||||
import org.linphone.contacts.ContactsListAdapter;
|
||||
import org.linphone.contacts.ContactsManager;
|
||||
import org.linphone.contacts.LinphoneContact;
|
||||
import org.linphone.core.Address;
|
||||
|
@ -32,6 +29,9 @@ import java.util.Calendar;
|
|||
import java.util.List;
|
||||
|
||||
public class CallHistoryAdapter extends SelectableAdapter<CallHistoryAdapter.ViewHolder> {
|
||||
|
||||
//This ViewHolder links fields from the xml to variables that will display values provided by the adapter
|
||||
|
||||
public static class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener,
|
||||
View.OnLongClickListener{
|
||||
public TextView contact;
|
||||
|
@ -40,7 +40,6 @@ public class CallHistoryAdapter extends SelectableAdapter<CallHistoryAdapter.Vie
|
|||
public ImageView callDirection;
|
||||
public ImageView contactPicture;
|
||||
public RelativeLayout CallContact;
|
||||
public RelativeLayout SelectContact;
|
||||
public LinearLayout separator;
|
||||
public TextView separatorText;
|
||||
private CallHistoryAdapter.ViewHolder.ClickListener listener;
|
||||
|
@ -53,7 +52,6 @@ public class CallHistoryAdapter extends SelectableAdapter<CallHistoryAdapter.Vie
|
|||
callDirection = (ImageView) view.findViewById(R.id.icon);
|
||||
contactPicture = (ImageView) view.findViewById(R.id.contact_picture);
|
||||
CallContact = (RelativeLayout) view.findViewById(R.id.history_click);
|
||||
SelectContact = (RelativeLayout) view.findViewById(R.id.history_whole);
|
||||
separator = (LinearLayout) view.findViewById(R.id.separator);
|
||||
separatorText = (TextView) view.findViewById(R.id.separator_text);
|
||||
this.listener = listener;
|
||||
|
@ -62,6 +60,7 @@ public class CallHistoryAdapter extends SelectableAdapter<CallHistoryAdapter.Vie
|
|||
|
||||
}
|
||||
|
||||
//Thoses methods are caught up by the fragment
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (listener != null) {
|
||||
|
@ -78,8 +77,8 @@ public class CallHistoryAdapter extends SelectableAdapter<CallHistoryAdapter.Vie
|
|||
}
|
||||
|
||||
public interface ClickListener {
|
||||
public void onItemClicked(int position);
|
||||
public boolean onItemLongClicked(int position);
|
||||
void onItemClicked(int position);
|
||||
boolean onItemLongClicked(int position);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -103,12 +102,6 @@ public class CallHistoryAdapter extends SelectableAdapter<CallHistoryAdapter.Vie
|
|||
return mLogs.get(position);
|
||||
}
|
||||
|
||||
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
|
@ -117,6 +110,8 @@ public class CallHistoryAdapter extends SelectableAdapter<CallHistoryAdapter.Vie
|
|||
|
||||
}
|
||||
|
||||
//Links datas, visibility and listeners of inner items from the adapter to the ViewHolder
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull final ViewHolder holder, final int position) {
|
||||
final CallLog log= mLogs.get(position);
|
||||
|
|
|
@ -30,20 +30,14 @@ import android.widget.ProgressBar;
|
|||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.LinphoneUtils;
|
||||
import org.linphone.R;
|
||||
import org.linphone.core.ChatMessage;
|
||||
import org.linphone.core.ChatRoom;
|
||||
import org.linphone.core.EventLog;
|
||||
import org.linphone.core.LimeState;
|
||||
|
||||
public class ChatBubbleViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{
|
||||
public String messageId;
|
||||
public Context mContext;
|
||||
public ChatMessage message;
|
||||
public LinearLayout eventLayout;
|
||||
//public TextView eventTime;
|
||||
public TextView eventMessage;
|
||||
|
||||
public RelativeLayout bubbleLayout;
|
||||
|
@ -111,7 +105,6 @@ public class ChatBubbleViewHolder extends RecyclerView.ViewHolder implements Vie
|
|||
}
|
||||
public ChatBubbleViewHolder(View view) {
|
||||
super(view);
|
||||
this.listener = listener;
|
||||
this.eventLayout = view.findViewById(R.id.event);
|
||||
//eventTime = view.findViewById(R.id.event_date);
|
||||
this.eventMessage = view.findViewById(R.id.event_text);
|
||||
|
@ -149,6 +142,6 @@ public class ChatBubbleViewHolder extends RecyclerView.ViewHolder implements Vie
|
|||
}
|
||||
|
||||
public interface ClickListener {
|
||||
public void onItemClicked(int position);
|
||||
void onItemClicked(int position);
|
||||
}
|
||||
}
|
|
@ -30,33 +30,29 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.EditText;
|
||||
import android.widget.HorizontalScrollView;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.LinphonePreferences;
|
||||
import org.linphone.R;
|
||||
import org.linphone.activities.LinphoneActivity;
|
||||
import org.linphone.contacts.ContactAddress;
|
||||
import org.linphone.contacts.ContactsManager;
|
||||
import org.linphone.contacts.LinphoneNumberOrAddress;
|
||||
import org.linphone.contacts.ContactsUpdatedListener;
|
||||
import org.linphone.contacts.SearchContactsListAdapter;
|
||||
import org.linphone.core.Address;
|
||||
import org.linphone.core.ChatRoom;
|
||||
import org.linphone.core.ChatRoomListenerStub;
|
||||
import org.linphone.core.Core;
|
||||
import org.linphone.core.Factory;
|
||||
import org.linphone.core.ProxyConfig;
|
||||
import org.linphone.mediastream.Log;
|
||||
import org.linphone.ui.ContactSelectView;
|
||||
import org.linphone.contacts.ContactsUpdatedListener;
|
||||
import org.linphone.activities.LinphoneActivity;
|
||||
import org.linphone.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -64,7 +60,6 @@ import java.util.List;
|
|||
import static android.content.Context.INPUT_METHOD_SERVICE;
|
||||
|
||||
public class ChatCreationFragment extends Fragment implements View.OnClickListener ,SearchContactsListAdapter.ViewHolder.ClickListener, ContactsUpdatedListener {
|
||||
private LayoutInflater mInflater;
|
||||
private RecyclerView mContactsList;
|
||||
private LinearLayout mContactsSelectedLayout;
|
||||
private HorizontalScrollView mContactsSelectLayout;
|
||||
|
@ -84,7 +79,6 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
|
|||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
mInflater = inflater;
|
||||
View view = inflater.inflate(R.layout.chat_create, container, false);
|
||||
|
||||
mContactsSelected = new ArrayList<>();
|
||||
|
@ -128,7 +122,7 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
|
|||
mContactsFetchInProgress = view.findViewById(R.id.contactsFetchInProgress);
|
||||
mContactsFetchInProgress.setVisibility(View.VISIBLE);
|
||||
|
||||
mSearchAdapter = new SearchContactsListAdapter(null, mInflater, mContactsFetchInProgress, this);
|
||||
mSearchAdapter = new SearchContactsListAdapter(null, mContactsFetchInProgress, this);
|
||||
|
||||
mSearchField = view.findViewById(R.id.searchField);
|
||||
mSearchField.addTextChangedListener(new TextWatcher() {
|
||||
|
@ -149,19 +143,24 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
|
|||
mSearchAdapter.searchContacts(mSearchField.getText().toString(), mContactsList);
|
||||
}
|
||||
});
|
||||
|
||||
//Declares the layout manager, allowing customization of RecyclerView displaying
|
||||
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity().getApplicationContext());
|
||||
|
||||
|
||||
|
||||
mContactsList.setAdapter(mSearchAdapter);
|
||||
|
||||
//Divider between items
|
||||
//Divider between items + binds layout manager to our RecyclerView
|
||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(mContactsList.getContext(),
|
||||
layoutManager.getOrientation());
|
||||
dividerItemDecoration.setDrawable(getActivity().getApplicationContext().getResources().getDrawable(R.drawable.divider));
|
||||
mContactsList.addItemDecoration(dividerItemDecoration);
|
||||
|
||||
|
||||
|
||||
mContactsList.setLayoutManager(layoutManager);
|
||||
// mContactsList.setOnItemClickListener(this);
|
||||
|
||||
|
||||
|
||||
if (savedInstanceState != null && savedInstanceState.getStringArrayList("mContactsSelected") != null) {
|
||||
mContactsSelectedLayout.removeAllViews();
|
||||
// We need to get all contacts not only sip
|
||||
|
@ -362,6 +361,8 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
|
|||
super.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
|
||||
//Removed all selection mode related code, as it is now located into SelectableHelper.
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
int id = view.getId();
|
||||
|
@ -427,7 +428,6 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
|
|||
|
||||
@Override
|
||||
public void onItemClicked(int position) {
|
||||
// public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
||||
ContactAddress ca = mSearchAdapter.getContacts().get(position);
|
||||
Core lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||
ProxyConfig lpc = lc.getDefaultProxyConfig();
|
||||
|
|
|
@ -37,7 +37,6 @@ import android.os.Environment;
|
|||
import android.provider.MediaStore;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.content.FileProvider;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.text.Spanned;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -57,14 +56,10 @@ import org.linphone.contacts.LinphoneContact;
|
|||
import org.linphone.core.Address;
|
||||
import org.linphone.core.ChatMessage;
|
||||
import org.linphone.core.ChatMessageListenerStub;
|
||||
import org.linphone.core.ChatRoom;
|
||||
import org.linphone.core.Content;
|
||||
import org.linphone.core.Event;
|
||||
import org.linphone.core.EventLog;
|
||||
import org.linphone.core.LimeState;
|
||||
import org.linphone.mediastream.Log;
|
||||
import org.linphone.ui.ListSelectionAdapter;
|
||||
import org.linphone.ui.ListSelectionHelper;
|
||||
import org.linphone.ui.SelectableAdapter;
|
||||
import org.linphone.ui.SelectableHelper;
|
||||
|
||||
|
@ -138,6 +133,8 @@ public class ChatEventsAdapter extends SelectableAdapter<ChatBubbleViewHolder> {
|
|||
View v = LayoutInflater.from(parent.getContext())
|
||||
.inflate(this.itemResource, parent, false);
|
||||
ChatBubbleViewHolder VH = new ChatBubbleViewHolder(this.mContext,v, clickListener);
|
||||
|
||||
//Allows onLongClick ContextMenu on bubbles
|
||||
mFragment.registerForContextMenu(v);
|
||||
v.setTag(VH);
|
||||
return VH;
|
||||
|
@ -222,7 +219,7 @@ public class ChatEventsAdapter extends SelectableAdapter<ChatBubbleViewHolder> {
|
|||
holder.imdmLabel.setTextColor(mContext.getResources().getColor(R.color.colorI));
|
||||
}
|
||||
|
||||
|
||||
//layoutParams allow bubbles alignment during selection mode
|
||||
if (isEditionEnabled()) {
|
||||
layoutParams.addRule(RelativeLayout.LEFT_OF, holder.delete.getId());
|
||||
layoutParams.setMargins(SIDE_MARGIN, MARGIN_BETWEEN_MESSAGES/2, 0, MARGIN_BETWEEN_MESSAGES/2);
|
||||
|
@ -398,11 +395,6 @@ public class ChatEventsAdapter extends SelectableAdapter<ChatBubbleViewHolder> {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int i) {
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return this.mHistory.size();
|
||||
|
@ -432,21 +424,14 @@ public class ChatEventsAdapter extends SelectableAdapter<ChatBubbleViewHolder> {
|
|||
mHistory.clear();
|
||||
}
|
||||
|
||||
// @Override
|
||||
public int getCount() {
|
||||
return this.mHistory.size();
|
||||
}
|
||||
|
||||
// @Override
|
||||
public Object getItem(int i) {
|
||||
return mHistory.get(i);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
||||
|
||||
|
||||
|
||||
public void removeItem(int i) {
|
||||
mHistory.remove(i);
|
||||
notifyDataSetChanged();
|
||||
|
|
|
@ -21,18 +21,15 @@ package org.linphone.chat;
|
|||
|
||||
import android.app.Fragment;
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.DividerItemDecoration;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.helper.ItemTouchHelper;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.R;
|
||||
|
@ -47,8 +44,6 @@ import org.linphone.core.CoreListenerStub;
|
|||
import org.linphone.core.EventLog;
|
||||
import org.linphone.fragments.FragmentsAvailable;
|
||||
import org.linphone.ui.SelectableHelper;
|
||||
import org.linphone.ui.SwipeController;
|
||||
import org.linphone.ui.SwipeControllerActions;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
@ -58,13 +53,12 @@ import java.util.List;
|
|||
import static org.linphone.fragments.FragmentsAvailable.CHAT_LIST;
|
||||
|
||||
/*
|
||||
* Sources: Linphone + https://enoent.fr/blog/2015/01/18/recyclerview-basics/
|
||||
* Main sources: Linphone + https://enoent.fr/blog/2015/01/18/recyclerview-basics/
|
||||
* */
|
||||
|
||||
public class ChatListFragment extends Fragment implements ContactsUpdatedListener, ChatRoomsAdapter.ChatRoomViewHolder.ClickListener, SelectableHelper.DeleteListener {
|
||||
|
||||
private RecyclerView mChatRoomsList;
|
||||
private TextView mNoChatHistory;
|
||||
private ImageView mNewDiscussionButton, mBackToCallButton;
|
||||
private ChatRoomsAdapter mChatRoomsAdapter;
|
||||
private CoreListenerStub mListener;
|
||||
|
@ -91,7 +85,7 @@ public class ChatListFragment extends Fragment implements ContactsUpdatedListene
|
|||
mNewDiscussionButton = view.findViewById(R.id.new_discussion);
|
||||
mBackToCallButton = view.findViewById(R.id.back_in_call);
|
||||
|
||||
//Creation and affectation of adapter to the RecyclerView
|
||||
//Creation and affectation of adapter to the RecyclerView and SelectionHelper
|
||||
mSelectionHelper = new SelectableHelper(view, this);
|
||||
mChatRoomsAdapter = new ChatRoomsAdapter(mContext, R.layout.chatlist_cell, mRooms,this, mSelectionHelper);
|
||||
|
||||
|
@ -117,36 +111,36 @@ public class ChatListFragment extends Fragment implements ContactsUpdatedListene
|
|||
|
||||
|
||||
|
||||
//All commentend code below, until line 145, have to be uncommented to allow swipe actions.
|
||||
//All commentend code below, from line 123 to line 148, have to be uncommented to allow swipe actions.
|
||||
|
||||
//Actions allowed by swipe buttons
|
||||
|
||||
final SwipeController swipeController = new SwipeController(new SwipeControllerActions() {
|
||||
// final SwipeController swipeController = new SwipeController(new SwipeControllerActions() {
|
||||
//// @Override
|
||||
//// public void onLeftClicked(int position) {
|
||||
//// super.onLeftClicked(position);
|
||||
//// }
|
||||
//
|
||||
// @Override
|
||||
// public void onLeftClicked(int position) {
|
||||
// super.onLeftClicked(position);
|
||||
// public void onRightClicked(int position) {
|
||||
// mChatRoomsAdapter.removeItem(position);
|
||||
// mChatRoomsAdapter.notifyDataSetChanged();
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void onRightClicked(int position) {
|
||||
mChatRoomsAdapter.removeItem(position);
|
||||
mChatRoomsAdapter.notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
|
||||
//Initialize swipe detection
|
||||
|
||||
|
||||
ItemTouchHelper itemTouchHelper = new ItemTouchHelper(swipeController);
|
||||
itemTouchHelper.attachToRecyclerView(mChatRoomsList);
|
||||
|
||||
//Add swipe buttons
|
||||
mChatRoomsList.addItemDecoration(new RecyclerView.ItemDecoration() {
|
||||
@Override
|
||||
public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
|
||||
swipeController.onDraw(c);
|
||||
}
|
||||
});
|
||||
// });
|
||||
//
|
||||
// //Initialize swipe detection
|
||||
//
|
||||
//
|
||||
// ItemTouchHelper itemTouchHelper = new ItemTouchHelper(swipeController);
|
||||
// itemTouchHelper.attachToRecyclerView(mChatRoomsList);
|
||||
//
|
||||
// //Add swipe buttons
|
||||
// mChatRoomsList.addItemDecoration(new RecyclerView.ItemDecoration() {
|
||||
// @Override
|
||||
// public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
|
||||
// swipeController.onDraw(c);
|
||||
// }
|
||||
// });
|
||||
|
||||
|
||||
// Buttons onClickListeners definitions
|
||||
|
@ -201,10 +195,10 @@ public class ChatListFragment extends Fragment implements ContactsUpdatedListene
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
//On a click on an item, go to the selected ChatRoom if no SelectionMode chosen, select the item if it does
|
||||
@Override
|
||||
public void onItemClicked(int position) {
|
||||
if (mChatRoomsAdapter.isEditionEnabled()) {
|
||||
|
|
|
@ -36,16 +36,12 @@ import org.linphone.activities.LinphoneActivity;
|
|||
import org.linphone.contacts.ContactsManager;
|
||||
import org.linphone.contacts.LinphoneContact;
|
||||
import org.linphone.core.Address;
|
||||
import org.linphone.core.ChatMessage;
|
||||
import org.linphone.core.ChatRoom;
|
||||
import org.linphone.core.ChatRoomCapabilities;
|
||||
import org.linphone.core.ChatRoomListenerStub;
|
||||
import org.linphone.core.Core;
|
||||
import org.linphone.core.EventLog;
|
||||
import org.linphone.ui.SelectableAdapter;
|
||||
import org.linphone.ui.SelectableHelper;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
@ -96,14 +92,12 @@ public class ChatRoomsAdapter extends SelectableAdapter<ChatRoomsAdapter.ChatRoo
|
|||
}
|
||||
|
||||
//Handle the onClick/onLongClick event for the ViewHolder
|
||||
// @Override
|
||||
public void onClick(View v) {
|
||||
if (listener != null) {
|
||||
listener.onItemClicked(getAdapterPosition());
|
||||
}
|
||||
}
|
||||
|
||||
// @Override
|
||||
public boolean onLongClick(View v) {
|
||||
if (listener != null) {
|
||||
return listener.onItemLongClicked(getAdapterPosition());
|
||||
|
@ -226,18 +220,6 @@ public class ChatRoomsAdapter extends SelectableAdapter<ChatRoomsAdapter.ChatRoo
|
|||
holder.bindChatRoom(room);
|
||||
}
|
||||
|
||||
// Let know the adapter if ActionMode is enabled
|
||||
// public void setEditionMode(ActionMode actionMode) {
|
||||
// if ( isEditionEnabled() == true) {
|
||||
// this.editionMode=true;
|
||||
// this.notifyDataSetChanged(); //Needed to update the whole list checkboxes
|
||||
// } else {
|
||||
// this.editionMode=false;
|
||||
// this.notifyDataSetChanged();
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
public void refresh() {
|
||||
mRooms = new ArrayList<>(Arrays.asList(LinphoneManager.getLc().getChatRooms()));
|
||||
Collections.sort(mRooms, new Comparator<ChatRoom>() {
|
||||
|
@ -260,77 +242,6 @@ public class ChatRoomsAdapter extends SelectableAdapter<ChatRoomsAdapter.ChatRoo
|
|||
}
|
||||
|
||||
|
||||
public void removeItem(int position) {
|
||||
|
||||
Core lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||
cleanRoom(position);
|
||||
lc.deleteChatRoom(mRooms.get(position));
|
||||
mRooms.remove(position);
|
||||
notifyItemRemoved(position);
|
||||
}
|
||||
//
|
||||
// public void removeItems(List<Integer> positions) {
|
||||
// // Reverse-sort the list
|
||||
// Collections.sort(positions, new Comparator<Integer>() {
|
||||
// @Override
|
||||
// public int compare(Integer lhs, Integer rhs) {
|
||||
// return rhs - lhs;
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// // Split the list in ranges
|
||||
// while (!positions.isEmpty()) {
|
||||
// if (positions.size() == 1) {
|
||||
// removeItem(positions.get(0));
|
||||
// positions.remove(0);
|
||||
//
|
||||
// } else {
|
||||
// int count = 1;
|
||||
// while (positions.size() > count && positions.get(count).equals(positions.get(count - 1) - 1)) {
|
||||
// ++count;
|
||||
// }
|
||||
//
|
||||
// if (count == 1) {
|
||||
// removeItem(positions.get(0));
|
||||
// } else {
|
||||
// removeRange(positions.get(count - 1), count);
|
||||
// }
|
||||
//
|
||||
// for (int i = 0; i < count; ++i) {
|
||||
// positions.remove(0);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private void removeRange(int positionStart, int itemCount) {
|
||||
// for (int i = 0; i < itemCount; ++i) {
|
||||
// Core lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||
// cleanRoom(positionStart);
|
||||
// lc.deleteChatRoom(mRooms.get(positionStart));
|
||||
// mRooms.remove(positionStart);
|
||||
// }
|
||||
// notifyItemRangeRemoved(positionStart, itemCount);
|
||||
// }
|
||||
//
|
||||
// //Delete downloaded file from incoming message that will be deleted
|
||||
private void cleanRoom (int position) {
|
||||
|
||||
for (EventLog eventLog : mRooms.get(position).getHistoryEvents(0)) {
|
||||
if (eventLog.getType() == EventLog.Type.ConferenceChatMessage) {
|
||||
ChatMessage message = eventLog.getChatMessage();
|
||||
if (message.getAppdata() != null && !message.isOutgoing()) {
|
||||
File file = new File(message.getAppdata());
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Adapter's methods
|
||||
*/
|
||||
|
|
|
@ -34,7 +34,6 @@ import android.os.Bundle;
|
|||
import android.os.Environment;
|
||||
import android.os.Parcelable;
|
||||
import android.provider.MediaStore;
|
||||
import android.support.v7.widget.DividerItemDecoration;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.text.Editable;
|
||||
|
@ -48,7 +47,6 @@ import android.view.ViewGroup;
|
|||
import android.view.ViewTreeObserver;
|
||||
import android.view.WindowManager;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
|
@ -106,7 +104,6 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
|
|||
private Address mRemoteSipAddress, mRemoteParticipantAddress;
|
||||
private ChatRoom mChatRoom;
|
||||
private ArrayList<LinphoneContact> mParticipants;
|
||||
private ArrayList<EventLog> mHistory;
|
||||
private LinearLayoutManager layoutManager;
|
||||
private int mContextMenuMessagePosition;
|
||||
@Override
|
||||
|
@ -223,10 +220,6 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
|
|||
layoutManager = new LinearLayoutManager(mContext);
|
||||
mChatEventsList.setLayoutManager(layoutManager);
|
||||
|
||||
// registerForContextMenu(mChatEventsList);
|
||||
|
||||
|
||||
|
||||
if (getArguments() != null) {
|
||||
String fileSharedUri = getArguments().getString("fileSharedUri");
|
||||
if (fileSharedUri != null) {
|
||||
|
@ -366,7 +359,6 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
|
|||
mContextMenuMessagePosition = holder.getAdapterPosition();
|
||||
|
||||
EventLog event = (EventLog) mEventsAdapter.getItem(mContextMenuMessagePosition);
|
||||
// EventLog event = log.getEventLog();
|
||||
if (event.getType() != EventLog.Type.ConferenceChatMessage) {
|
||||
return;
|
||||
}
|
||||
|
@ -393,13 +385,8 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
|
|||
|
||||
@Override
|
||||
public boolean onContextItemSelected(MenuItem item) {
|
||||
// AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
|
||||
//
|
||||
|
||||
|
||||
|
||||
EventLog event = (EventLog) mEventsAdapter.getItem(mContextMenuMessagePosition);
|
||||
// EventLog event = (EventLog) mEventsAdapter.getItem(info.position);
|
||||
|
||||
if (event.getType() != EventLog.Type.ConferenceChatMessage) {
|
||||
return super.onContextItemSelected(item);
|
||||
|
@ -582,11 +569,7 @@ public class GroupChatFragment extends Fragment implements ChatRoomListener, Con
|
|||
}
|
||||
|
||||
public void scrollToBottom() {
|
||||
// if ((layoutManager.findLastVisibleItemPosition() >= (mEventsAdapter.getCount() - 1)) && (layoutManager.findFirstVisibleItemPosition() <= (mEventsAdapter.getCount() - 1))) {
|
||||
// if (((mChatEventsList.getLastVisiblePosition() >= (mEventsAdapter.getCount() - 1)) && (mChatEventsList.getFirstVisiblePosition() <= (mEventsAdapter.getCount() - 1)))) {
|
||||
mChatEventsList.getLayoutManager().scrollToPosition(mEventsAdapter.getCount() - 1);
|
||||
// mChatEventsList.setSelection(mEventsAdapter.getCount() - 1);
|
||||
// }
|
||||
}
|
||||
|
||||
public String getRemoteSipUri() {
|
||||
|
|
|
@ -42,7 +42,6 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
public class GroupInfoAdapter extends RecyclerView.Adapter<GroupInfoAdapter.ViewHolder> {
|
||||
//public class GroupInfoAdapter extends BaseAdapter {
|
||||
|
||||
public static class ViewHolder extends RecyclerView.ViewHolder{
|
||||
public TextView name;
|
||||
|
@ -66,7 +65,6 @@ public class GroupInfoAdapter extends RecyclerView.Adapter<GroupInfoAdapter.View
|
|||
|
||||
|
||||
|
||||
private LayoutInflater mInflater;
|
||||
private List<ContactAddress> mItems;
|
||||
private View.OnClickListener mDeleteListener;
|
||||
private boolean mHideAdminFeatures;
|
||||
|
@ -75,8 +73,7 @@ public class GroupInfoAdapter extends RecyclerView.Adapter<GroupInfoAdapter.View
|
|||
|
||||
|
||||
|
||||
public GroupInfoAdapter(LayoutInflater inflater, List<ContactAddress> items, boolean hideAdminFeatures, boolean isCreation) {
|
||||
mInflater = inflater;
|
||||
public GroupInfoAdapter(List<ContactAddress> items, boolean hideAdminFeatures, boolean isCreation) {
|
||||
mItems = items;
|
||||
mHideAdminFeatures = hideAdminFeatures || isCreation;
|
||||
|
||||
|
|
|
@ -36,7 +36,6 @@ import android.widget.Button;
|
|||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import org.linphone.LinphoneManager;
|
||||
|
@ -115,7 +114,7 @@ public class GroupInfoFragment extends Fragment implements ChatRoomListener {
|
|||
}
|
||||
|
||||
mParticipantsList = view.findViewById(R.id.chat_room_participants);
|
||||
mAdapter = new GroupInfoAdapter(mInflater, mParticipants, !mIsEditionEnabled, !mIsAlreadyCreatedGroup);
|
||||
mAdapter = new GroupInfoAdapter(mParticipants, !mIsEditionEnabled, !mIsAlreadyCreatedGroup);
|
||||
mAdapter.setOnDeleteClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
|
|
@ -7,7 +7,6 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.SectionIndexer;
|
||||
|
@ -26,8 +25,7 @@ import java.util.Locale;
|
|||
import java.util.Map;
|
||||
|
||||
public class ContactsListAdapter extends SelectableAdapter<ContactsListAdapter.ViewHolder> implements SectionIndexer {
|
||||
//public class ContactsListAdapter extends RecyclerView.Adapter<ContactsListAdapter.ViewHolder> implements SectionIndexer {
|
||||
// class ContactsListAdapter extends BaseAdapter implements SectionIndexer {
|
||||
|
||||
|
||||
public static class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener{
|
||||
public CheckBox delete;
|
||||
|
@ -148,9 +146,6 @@ public class ContactsListAdapter extends SelectableAdapter<ContactsListAdapter.V
|
|||
if (position >= getItemCount()) return null;
|
||||
return contacts.get(position);
|
||||
}
|
||||
public boolean isSearchMode(){
|
||||
return this.isSearchMode;
|
||||
}
|
||||
|
||||
public void setSearchMode(boolean set){
|
||||
isSearchMode = set;
|
||||
|
|
|
@ -20,12 +20,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
*/
|
||||
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.app.Fragment;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v7.widget.DividerItemDecoration;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
|
@ -33,46 +30,29 @@ import android.text.Editable;
|
|||
import android.text.TextWatcher;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.SectionIndexer;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.linphone.core.ChatRoom;
|
||||
import org.linphone.fragments.FragmentsAvailable;
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.LinphoneUtils;
|
||||
import org.linphone.R;
|
||||
import org.linphone.activities.LinphoneActivity;
|
||||
import org.linphone.fragments.FragmentsAvailable;
|
||||
import org.linphone.ui.SelectableHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
public class ContactsListFragment extends Fragment implements OnItemClickListener, ContactsUpdatedListener, ContactsListAdapter.ViewHolder.ClickListener ,SelectableHelper.DeleteListener {
|
||||
//public class ContactsListFragment extends Fragment implements OnClickListener, OnItemClickListener, ContactsUpdatedListener {
|
||||
private LayoutInflater mInflater;
|
||||
private RecyclerView contactsList;
|
||||
private TextView noSipContact, noContact;
|
||||
private ImageView allContacts, linphoneContacts, newContact, edit;
|
||||
private boolean onlyDisplayLinphoneContacts;
|
||||
private View allContactsSelected, linphoneContactsSelected;
|
||||
private LinearLayout topbar;
|
||||
private int lastKnownPosition;
|
||||
private boolean editOnClick = false, editConsumed = false, onlyDisplayChatAddress = false;
|
||||
private String sipAddressToAdd, displayName = null;
|
||||
|
@ -86,7 +66,6 @@ public class ContactsListFragment extends Fragment implements OnItemClickListene
|
|||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
mInflater = inflater;
|
||||
View view = inflater.inflate(R.layout.contacts_list, container, false);
|
||||
mContext = getActivity().getApplicationContext();
|
||||
mSelectionHelper = new SelectableHelper(view, this);
|
||||
|
@ -107,7 +86,6 @@ public class ContactsListFragment extends Fragment implements OnItemClickListene
|
|||
linphoneContacts = (ImageView) view.findViewById(R.id.linphone_contacts);
|
||||
allContactsSelected = view.findViewById(R.id.all_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);
|
||||
|
@ -202,26 +180,6 @@ public class ContactsListFragment extends Fragment implements OnItemClickListene
|
|||
return view;
|
||||
}
|
||||
|
||||
// public int getNbItemsChecked(){
|
||||
// int size = mContactAdapter.getItemCount();
|
||||
//// int size = contactsList.getAdapter().getItemCount();
|
||||
// int nb = 0;
|
||||
// for(int i=0; i<size; i++) {
|
||||
// if(mContactAdapter.isSelected(i)) {
|
||||
// nb ++;
|
||||
// }
|
||||
// }
|
||||
// return nb;
|
||||
// }
|
||||
|
||||
// public void quitEditMode(){
|
||||
// mSelectionHelper.quitEditionMode();
|
||||
// invalidate();
|
||||
// if(getResources().getBoolean(R.bool.isTablet)){
|
||||
// displayFirstContact();
|
||||
// }
|
||||
// }
|
||||
|
||||
public void displayFirstContact(){
|
||||
if (contactsList != null && contactsList.getAdapter() != null && contactsList.getAdapter().getItemCount() > 0) {
|
||||
ContactsListAdapter mAdapt = (ContactsListAdapter)contactsList.getAdapter();
|
||||
|
@ -231,13 +189,8 @@ public class ContactsListFragment extends Fragment implements OnItemClickListene
|
|||
}
|
||||
}
|
||||
|
||||
// private void searchContacts() {
|
||||
// searchContacts(searchField.getText().toString());
|
||||
// }
|
||||
|
||||
private void searchContacts(String search) {
|
||||
boolean isEditionEnabled = false;
|
||||
// mSelectionHelper.quitEditionMode();
|
||||
if (search == null || search.length() == 0) {
|
||||
changeContactsAdapter();
|
||||
return;
|
||||
|
@ -298,7 +251,6 @@ public class ContactsListFragment extends Fragment implements OnItemClickListene
|
|||
|
||||
|
||||
mContactAdapter = new ContactsListAdapter(mContext, listContact, this, mSelectionHelper);
|
||||
// mContactAdapter.setSearchMode(false);
|
||||
|
||||
mSelectionHelper.setAdapter(mContactAdapter);
|
||||
|
||||
|
|
|
@ -24,9 +24,7 @@ import android.support.v7.widget.RecyclerView;
|
|||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
@ -34,7 +32,6 @@ import org.linphone.LinphoneManager;
|
|||
import org.linphone.LinphoneUtils;
|
||||
import org.linphone.R;
|
||||
import org.linphone.activities.LinphoneActivity;
|
||||
import org.linphone.chat.ChatBubbleViewHolder;
|
||||
import org.linphone.core.Address;
|
||||
import org.linphone.core.Factory;
|
||||
import org.linphone.core.ProxyConfig;
|
||||
|
@ -44,7 +41,6 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
public class SearchContactsListAdapter extends RecyclerView.Adapter<SearchContactsListAdapter.ViewHolder> {
|
||||
//public class SearchContactsListAdapter extends BaseAdapter {
|
||||
@SuppressWarnings("unused")
|
||||
private static final String TAG = SearchContactsListAdapter.class.getSimpleName();
|
||||
|
||||
|
@ -76,18 +72,16 @@ public class SearchContactsListAdapter extends RecyclerView.Adapter<SearchContac
|
|||
|
||||
}
|
||||
public interface ClickListener {
|
||||
public void onItemClicked(int position);
|
||||
void onItemClicked(int position);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private List<ContactAddress> contacts;
|
||||
private List<ContactAddress> contactsSelected;
|
||||
private LayoutInflater mInflater;
|
||||
private ProgressBar progressBar;
|
||||
private boolean mOnlySipContact = false;
|
||||
private ViewHolder.ClickListener listener;
|
||||
// private View.OnClickListener listener;
|
||||
|
||||
public List<ContactAddress> getContacts() {
|
||||
return contacts;
|
||||
|
@ -101,9 +95,8 @@ public class SearchContactsListAdapter extends RecyclerView.Adapter<SearchContac
|
|||
this.listener = listener;
|
||||
}
|
||||
|
||||
public SearchContactsListAdapter(List<ContactAddress> contactsList, LayoutInflater inflater, ProgressBar pB, ViewHolder.ClickListener clickListener) {
|
||||
public SearchContactsListAdapter(List<ContactAddress> contactsList, ProgressBar pB, ViewHolder.ClickListener clickListener) {
|
||||
this.listener=clickListener;
|
||||
mInflater = inflater;
|
||||
progressBar = pB;
|
||||
setContactsSelectedList(null);
|
||||
setContactsList(contactsList);
|
||||
|
@ -164,9 +157,6 @@ public class SearchContactsListAdapter extends RecyclerView.Adapter<SearchContac
|
|||
holder.isSelect.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
}
|
||||
// view.setTag(R.id.contact_search_name, address != null ? address : a);
|
||||
// if (listener != null)
|
||||
// view.setOnClickListener(listener);
|
||||
}
|
||||
|
||||
public long getItemId(int position) {
|
||||
|
@ -257,7 +247,6 @@ public class SearchContactsListAdapter extends RecyclerView.Adapter<SearchContac
|
|||
}
|
||||
|
||||
public void searchContacts(String search, RecyclerView resultContactsSearch) {
|
||||
// public void searchContacts(String search, ListView resultContactsSearch) {
|
||||
List<ContactAddress> result = new ArrayList<>();
|
||||
|
||||
String domain = "";
|
||||
|
@ -298,70 +287,5 @@ public class SearchContactsListAdapter extends RecyclerView.Adapter<SearchContac
|
|||
resultContactsSearch.setAdapter(this);
|
||||
this.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public View getView(int position, View convertView, ViewGroup parent) {
|
||||
// View view;
|
||||
// ViewHolder holder;
|
||||
//
|
||||
// if (convertView != null) {
|
||||
// view = convertView;
|
||||
// holder = (ViewHolder) view.getTag();
|
||||
// } else {
|
||||
// view = mInflater.inflate(R.layout.search_contact_cell, parent, false);
|
||||
// holder = new ViewHolder(view);
|
||||
// view.setTag(holder);
|
||||
// }
|
||||
//
|
||||
// ContactAddress contact = getItem(position);
|
||||
// final String a = (contact.getAddressAsDisplayableString().isEmpty()) ? contact.getPhoneNumber() : contact.getAddressAsDisplayableString();
|
||||
// LinphoneContact c = contact.getContact();
|
||||
//
|
||||
// holder.avatar.setImageBitmap(ContactsManager.getInstance().getDefaultAvatarBitmap());
|
||||
// if (c != null && c.hasPhoto()) {
|
||||
// LinphoneUtils.setThumbnailPictureFromUri(LinphoneActivity.instance(), holder.avatar, c.getThumbnailUri());
|
||||
// }
|
||||
//
|
||||
// String address = contact.getAddressAsDisplayableString();
|
||||
// if (c != null && c.getFullName() != null) {
|
||||
// if (address == null)
|
||||
// address = c.getPresenceModelForUriOrTel(a);
|
||||
// holder.name.setVisibility(View.VISIBLE);
|
||||
// holder.name.setText(c.getFullName());
|
||||
// } else if (contact.getAddress() != null) {
|
||||
// if (contact.getAddress().getUsername() != null) {
|
||||
// holder.name.setVisibility(View.VISIBLE);
|
||||
// holder.name.setText(contact.getAddress().getUsername());
|
||||
// } else if (contact.getAddress().getDisplayName() != null) {
|
||||
// holder.name.setVisibility(View.VISIBLE);
|
||||
// holder.name.setText(contact.getAddress().getDisplayName());
|
||||
// }
|
||||
// } else if (address != null) {
|
||||
// Address tmpAddr = Factory.instance().createAddress(address);
|
||||
// holder.name.setVisibility(View.VISIBLE);
|
||||
// holder.name.setText((tmpAddr.getDisplayName() != null) ? tmpAddr.getDisplayName() : tmpAddr.getUsername()) ;
|
||||
// } else {
|
||||
// holder.name.setVisibility(View.GONE);
|
||||
// }
|
||||
// holder.address.setText(a);
|
||||
// if (holder.linphoneContact != null) {
|
||||
// if (contact.isLinphoneContact() && c != null && c.isInFriendList() && address != null) {
|
||||
// holder.linphoneContact.setVisibility(View.VISIBLE);
|
||||
// } else {
|
||||
// holder.linphoneContact.setVisibility(View.GONE);
|
||||
// }
|
||||
// }
|
||||
// if (holder.isSelect != null) {
|
||||
// if (contactIsSelected(contact)) {
|
||||
// holder.isSelect.setVisibility(View.VISIBLE);
|
||||
// } else {
|
||||
// holder.isSelect.setVisibility(View.INVISIBLE);
|
||||
// }
|
||||
// }
|
||||
// view.setTag(R.id.contact_search_name, address != null ? address : a);
|
||||
// if (listener != null)
|
||||
// view.setOnClickListener(listener);
|
||||
// return view;
|
||||
// }
|
||||
}
|
||||
|
||||
|
|
|
@ -19,29 +19,6 @@ along with this program; if not, write to the Free Software
|
|||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
import org.linphone.call.CallHistoryAdapter;
|
||||
import org.linphone.contacts.ContactsListAdapter;
|
||||
import org.linphone.contacts.ContactsManager;
|
||||
import org.linphone.contacts.ContactsUpdatedListener;
|
||||
import org.linphone.contacts.LinphoneContact;
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.LinphoneUtils;
|
||||
import org.linphone.R;
|
||||
import org.linphone.activities.LinphoneActivity;
|
||||
import org.linphone.core.Call;
|
||||
import org.linphone.core.Address;
|
||||
import org.linphone.core.CallLog;
|
||||
import org.linphone.core.Call.Status;
|
||||
import org.linphone.ui.SelectableHelper;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Dialog;
|
||||
import android.app.Fragment;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
|
@ -52,22 +29,29 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.R;
|
||||
import org.linphone.activities.LinphoneActivity;
|
||||
import org.linphone.call.CallHistoryAdapter;
|
||||
import org.linphone.contacts.ContactsManager;
|
||||
import org.linphone.contacts.ContactsUpdatedListener;
|
||||
import org.linphone.core.Address;
|
||||
import org.linphone.core.Call;
|
||||
import org.linphone.core.CallLog;
|
||||
import org.linphone.ui.SelectableHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class HistoryListFragment extends Fragment implements OnClickListener, OnItemClickListener, CallHistoryAdapter.ViewHolder.ClickListener ,ContactsUpdatedListener,SelectableHelper.DeleteListener{
|
||||
private RecyclerView historyList;
|
||||
private LayoutInflater mInflater;
|
||||
private TextView noCallHistory, noMissedCallHistory;
|
||||
private ImageView missedCalls, allCalls, edit, selectAll, deselectAll, delete, cancel;
|
||||
private View allCallsSelected, missedCallsSelected;
|
||||
|
@ -81,7 +65,6 @@ public class HistoryListFragment extends Fragment implements OnClickListener, On
|
|||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
mInflater = inflater;
|
||||
View view = inflater.inflate(R.layout.history, container, false);
|
||||
mContext = getActivity().getApplicationContext();
|
||||
mSelectionHelper = new SelectableHelper(view, this);
|
||||
|
@ -101,20 +84,6 @@ public class HistoryListFragment extends Fragment implements OnClickListener, On
|
|||
dividerItemDecoration.setDrawable(mContext.getResources().getDrawable(R.drawable.divider));
|
||||
historyList.addItemDecoration(dividerItemDecoration);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 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);
|
||||
|
||||
allCalls = (ImageView) view.findViewById(R.id.all_calls);
|
||||
allCalls.setOnClickListener(this);
|
||||
|
||||
|
@ -125,17 +94,10 @@ public class HistoryListFragment extends Fragment implements OnClickListener, On
|
|||
|
||||
missedCallsSelected = view.findViewById(R.id.missed_calls_select);
|
||||
|
||||
// selectAll = (ImageView) view.findViewById(R.id.select_all);
|
||||
// selectAll.setOnClickListener(this);
|
||||
//
|
||||
// deselectAll = (ImageView) view.findViewById(R.id.deselect_all);
|
||||
// deselectAll.setOnClickListener(this);
|
||||
|
||||
allCalls.setEnabled(false);
|
||||
onlyDisplayMissedCalls = false;
|
||||
|
||||
edit = (ImageView) view.findViewById(R.id.edit);
|
||||
// edit.setOnClickListener(this);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
@ -205,7 +167,6 @@ public class HistoryListFragment extends Fragment implements OnClickListener, On
|
|||
|
||||
mLogs = Arrays.asList(LinphoneManager.getLc().getCallLogs());
|
||||
if (!hideHistoryListAndDisplayMessageIfEmpty()) {
|
||||
// historyList.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE);
|
||||
mhistoryAdapter= new CallHistoryAdapter(getActivity().getApplicationContext(), mLogs, this, mSelectionHelper);
|
||||
historyList.setAdapter(mhistoryAdapter);
|
||||
mSelectionHelper.setAdapter(mhistoryAdapter);
|
||||
|
@ -279,6 +240,7 @@ public class HistoryListFragment extends Fragment implements OnClickListener, On
|
|||
}
|
||||
}
|
||||
|
||||
//ClickListeners bound to items
|
||||
@Override
|
||||
public void onItemClicked(int position) {
|
||||
if (mhistoryAdapter.isEditionEnabled()) {
|
||||
|
|
|
@ -2,7 +2,6 @@ package org.linphone.ui;
|
|||
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.SparseBooleanArray;
|
||||
import android.widget.CompoundButton;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -19,15 +18,6 @@ public abstract class SelectableAdapter<VH extends RecyclerView.ViewHolder> exte
|
|||
mListHelper = helper;
|
||||
}
|
||||
|
||||
// private CompoundButton.OnCheckedChangeListener mDeleteCheckboxListener = new CompoundButton.OnCheckedChangeListener() {
|
||||
// @Override
|
||||
// public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
// mListHelper.updateSelectionButtons(mSelectedItems.size() == 0, mSelectedItems.size() == getItemCount());
|
||||
// }
|
||||
// };
|
||||
// public CompoundButton.OnCheckedChangeListener getDeleteListener() {
|
||||
// return mDeleteCheckboxListener;
|
||||
// }
|
||||
public boolean isEditionEnabled() {
|
||||
return mIsEditionEnabled;
|
||||
}
|
||||
|
@ -62,17 +52,6 @@ public abstract class SelectableAdapter<VH extends RecyclerView.ViewHolder> exte
|
|||
notifyItemChanged(position);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the selection status for all items
|
||||
*/
|
||||
// public void clearSelection() {
|
||||
// List<Integer> selection = getSelectedItems();
|
||||
// mSelectedItems.clear();
|
||||
// for (Integer i : selection) {
|
||||
// notifyItemChanged(i);
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* Count the selected items
|
||||
* @return Selected items count
|
||||
|
@ -96,13 +75,10 @@ public abstract class SelectableAdapter<VH extends RecyclerView.ViewHolder> exte
|
|||
public void selectAll() {
|
||||
for (Integer i = 0; i < getItemCount(); i++) {
|
||||
mSelectedItems.put(i, true);
|
||||
// notifyItemChanged(i);
|
||||
notifyDataSetChanged();
|
||||
|
||||
}
|
||||
|
||||
mListHelper.updateSelectionButtons(false, true);
|
||||
// notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void deselectAll() {
|
||||
|
|
|
@ -51,6 +51,8 @@ public class SelectableHelper {
|
|||
mContext = view.getContext();
|
||||
mDeleteListener = listener;
|
||||
|
||||
//Define XML layout items used for selection mode
|
||||
|
||||
mEditTopBar = view.findViewById(R.id.edit_list);
|
||||
mTopBar = view.findViewById(R.id.top_bar);
|
||||
|
||||
|
@ -63,12 +65,13 @@ public class SelectableHelper {
|
|||
});
|
||||
|
||||
mEditButton = view.findViewById(R.id.edit);
|
||||
|
||||
//Set visibility behaviour on click on edit button + enter Edition Mode
|
||||
mEditButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (mAdapter.getItemCount() > 0) {
|
||||
enterEditionMode();
|
||||
// mAdapter.enableEdition(true);
|
||||
mTopBar.setVisibility(View.GONE);
|
||||
mEditTopBar.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
@ -132,12 +135,15 @@ public class SelectableHelper {
|
|||
|
||||
|
||||
public void updateSelectionButtons(boolean isSelectionEmpty, boolean isSelectionFull) {
|
||||
|
||||
//Delete button availability
|
||||
if (isSelectionEmpty) {
|
||||
mDeleteSelectionButton.setEnabled(false);
|
||||
} else {
|
||||
mDeleteSelectionButton.setEnabled(true);
|
||||
}
|
||||
|
||||
//(De)select button visibility
|
||||
if (isSelectionFull) {
|
||||
mSelectAllButton.setVisibility(View.GONE);
|
||||
mDeselectAllButton.setVisibility(View.VISIBLE);
|
||||
|
|
|
@ -22,6 +22,11 @@ enum ButtonsState {
|
|||
* https://codeburst.io/android-swipe-menu-with-recyclerview-8f28a235ff28
|
||||
* */
|
||||
|
||||
|
||||
/*
|
||||
* All commented code is meant to preserve left swipe behaviour for future work
|
||||
* */
|
||||
|
||||
public class SwipeController extends Callback {
|
||||
|
||||
private boolean swipeBack = false;
|
||||
|
|
Loading…
Reference in a new issue