Invalidate history & chat lists when contacts are udpated
This commit is contained in:
parent
34e6b15e32
commit
502a70f128
3 changed files with 31 additions and 5 deletions
|
@ -19,6 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.linphone.HistoryListFragment.CallHistoryAdapter;
|
||||||
import org.linphone.core.LinphoneAddress;
|
import org.linphone.core.LinphoneAddress;
|
||||||
import org.linphone.core.LinphoneChatMessage;
|
import org.linphone.core.LinphoneChatMessage;
|
||||||
import org.linphone.core.LinphoneChatRoom;
|
import org.linphone.core.LinphoneChatRoom;
|
||||||
|
@ -55,7 +56,7 @@ import android.widget.TextView;
|
||||||
/**
|
/**
|
||||||
* @author Sylvain Berfini
|
* @author Sylvain Berfini
|
||||||
*/
|
*/
|
||||||
public class ChatListFragment extends Fragment implements OnClickListener, OnItemClickListener {
|
public class ChatListFragment extends Fragment implements OnClickListener, OnItemClickListener, ContactsUpdatedListener {
|
||||||
private LayoutInflater mInflater;
|
private LayoutInflater mInflater;
|
||||||
private List<String> mConversations;
|
private List<String> mConversations;
|
||||||
private ListView chatList;
|
private ListView chatList;
|
||||||
|
@ -193,6 +194,7 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
ContactsManager.addContactsListener(this);
|
||||||
|
|
||||||
if (LinphoneManager.getLc().getCallsNb() > 0) {
|
if (LinphoneManager.getLc().getCallsNb() > 0) {
|
||||||
backInCall.setVisibility(View.VISIBLE);
|
backInCall.setVisibility(View.VISIBLE);
|
||||||
|
@ -219,9 +221,15 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
||||||
if (lc != null) {
|
if (lc != null) {
|
||||||
lc.removeListener(mListener);
|
lc.removeListener(mListener);
|
||||||
}
|
}
|
||||||
|
ContactsManager.removeContactsListener(this);
|
||||||
super.onPause();
|
super.onPause();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onContactsUpdated() {
|
||||||
|
hideAndDisplayMessageIfNoChat();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
|
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
|
||||||
super.onCreateContextMenu(menu, v, menuInfo);
|
super.onCreateContextMenu(menu, v, menuInfo);
|
||||||
|
|
|
@ -52,7 +52,7 @@ import android.widget.TextView;
|
||||||
/**
|
/**
|
||||||
* @author Sylvain Berfini
|
* @author Sylvain Berfini
|
||||||
*/
|
*/
|
||||||
public class HistoryListFragment extends Fragment implements OnClickListener, OnItemClickListener {
|
public class HistoryListFragment extends Fragment implements OnClickListener, OnItemClickListener, ContactsUpdatedListener {
|
||||||
private ListView historyList;
|
private ListView historyList;
|
||||||
private LayoutInflater mInflater;
|
private LayoutInflater mInflater;
|
||||||
private TextView noCallHistory, noMissedCallHistory;
|
private TextView noCallHistory, noMissedCallHistory;
|
||||||
|
@ -198,6 +198,7 @@ public class HistoryListFragment extends Fragment implements OnClickListener, On
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
ContactsManager.addContactsListener(this);
|
||||||
|
|
||||||
if (LinphoneActivity.isInstanciated()) {
|
if (LinphoneActivity.isInstanciated()) {
|
||||||
LinphoneActivity.instance().selectMenu(FragmentsAvailable.HISTORY_LIST);
|
LinphoneActivity.instance().selectMenu(FragmentsAvailable.HISTORY_LIST);
|
||||||
|
@ -211,6 +212,17 @@ public class HistoryListFragment extends Fragment implements OnClickListener, On
|
||||||
historyList.setAdapter(new CallHistoryAdapter(getActivity().getApplicationContext()));
|
historyList.setAdapter(new CallHistoryAdapter(getActivity().getApplicationContext()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPause() {
|
||||||
|
ContactsManager.removeContactsListener(this);
|
||||||
|
super.onPause();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onContactsUpdated() {
|
||||||
|
historyList.setAdapter(new CallHistoryAdapter(getActivity().getApplicationContext()));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
@ -327,18 +339,20 @@ public class HistoryListFragment extends Fragment implements OnClickListener, On
|
||||||
topBar.setVisibility(View.VISIBLE);
|
topBar.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
refresh();
|
refresh();
|
||||||
if (!hideHistoryListAndDisplayMessageIfEmpty()){
|
if (!hideHistoryListAndDisplayMessageIfEmpty()) {
|
||||||
historyList.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE);
|
historyList.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE);
|
||||||
historyList.setAdapter(new CallHistoryAdapter(getActivity().getApplicationContext()));
|
historyList.setAdapter(new CallHistoryAdapter(getActivity().getApplicationContext()));
|
||||||
}
|
}
|
||||||
if(getResources().getBoolean(R.bool.isTablet)){
|
if (getResources().getBoolean(R.bool.isTablet)) {
|
||||||
displayFirstLog();
|
displayFirstLog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class CallHistoryAdapter extends BaseAdapter {
|
class CallHistoryAdapter extends BaseAdapter {
|
||||||
CallHistoryAdapter(Context aContext) {
|
CallHistoryAdapter(Context aContext) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCount() {
|
public int getCount() {
|
||||||
return mLogs.size();
|
return mLogs.size();
|
||||||
}
|
}
|
||||||
|
|
|
@ -400,7 +400,11 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
|
||||||
if (lc.findFriendByAddress(friend.getAddress().asString()) == null) {
|
if (lc.findFriendByAddress(friend.getAddress().asString()) == null) {
|
||||||
try {
|
try {
|
||||||
lc.addFriend(friend);
|
lc.addFriend(friend);
|
||||||
ContactsManager.getInstance().fetchContactsAsync();
|
if (!ContactsManager.getInstance().hasContactsAccess()) {
|
||||||
|
// This refresh is only needed if app has no contacts permission to refresh the list of LinphoneFriends.
|
||||||
|
// Otherwise contacts will be refreshed due to changes in native contact and the handler in ContactsManager
|
||||||
|
ContactsManager.getInstance().fetchContactsAsync();
|
||||||
|
}
|
||||||
} catch (LinphoneCoreException e) {
|
} catch (LinphoneCoreException e) {
|
||||||
Log.e(e);
|
Log.e(e);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue