Fix Chat list and Chat room for tablet
This commit is contained in:
parent
02026adb86
commit
12b1618a19
3 changed files with 44 additions and 6 deletions
|
@ -104,6 +104,9 @@ import java.util.Locale;
|
||||||
import static android.content.Intent.FLAG_GRANT_READ_URI_PERMISSION;
|
import static android.content.Intent.FLAG_GRANT_READ_URI_PERMISSION;
|
||||||
import static org.linphone.FragmentsAvailable.CHAT;
|
import static org.linphone.FragmentsAvailable.CHAT;
|
||||||
|
|
||||||
|
interface ChatUpdatedListener {
|
||||||
|
void onChatUpdated();
|
||||||
|
}
|
||||||
|
|
||||||
public class ChatFragment extends Fragment implements OnClickListener, LinphoneChatMessage.LinphoneChatMessageListener, ContactsUpdatedListener{
|
public class ChatFragment extends Fragment implements OnClickListener, LinphoneChatMessage.LinphoneChatMessageListener, ContactsUpdatedListener{
|
||||||
private static final int ADD_PHOTO = 1337;
|
private static final int ADD_PHOTO = 1337;
|
||||||
|
@ -144,6 +147,20 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
private boolean newChatConversation = false;
|
private boolean newChatConversation = false;
|
||||||
private String fileSharedUri, fileAlreadySharedUri;
|
private String fileSharedUri, fileAlreadySharedUri;
|
||||||
|
|
||||||
|
private static ArrayList<ChatUpdatedListener> ChatUpdatedListeners;
|
||||||
|
|
||||||
|
public static void createIfNotExist() {
|
||||||
|
if (ChatUpdatedListeners == null)
|
||||||
|
ChatUpdatedListeners = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void addChatListener(ChatUpdatedListener listener) {
|
||||||
|
ChatUpdatedListeners.add(listener);
|
||||||
|
}
|
||||||
|
public static void removeChatListener(ChatUpdatedListener listener) {
|
||||||
|
ChatUpdatedListeners.remove(listener);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
@ -256,6 +273,11 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
LinphoneActivity.instance().checkAndRequestExternalStoragePermission();
|
LinphoneActivity.instance().checkAndRequestExternalStoragePermission();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (getResources().getBoolean(R.bool.isTablet)) {
|
||||||
|
for (ChatUpdatedListener c : ChatUpdatedListeners) {
|
||||||
|
c.onChatUpdated();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -389,6 +411,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
resultContactsSearch.setVisibility(View.GONE);
|
resultContactsSearch.setVisibility(View.GONE);
|
||||||
displayChatHeader(lAddress);
|
displayChatHeader(lAddress);
|
||||||
displayMessageList();
|
displayMessageList();
|
||||||
|
remoteComposing.setVisibility(chatRoom.isRemoteComposing() ? View.VISIBLE : View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -875,6 +898,11 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
private void invalidate() {
|
private void invalidate() {
|
||||||
adapter.refreshHistory();
|
adapter.refreshHistory();
|
||||||
chatRoom.markAsRead();
|
chatRoom.markAsRead();
|
||||||
|
if (getResources().getBoolean(R.bool.isTablet)) {
|
||||||
|
for (ChatUpdatedListener c : ChatUpdatedListeners) {
|
||||||
|
c.onChatUpdated();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resendMessage(LinphoneChatMessage message) {
|
private void resendMessage(LinphoneChatMessage message) {
|
||||||
|
@ -1588,6 +1616,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
chatRoom.markAsRead();
|
chatRoom.markAsRead();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
|
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
|
||||||
if (message.isOutgoing()) {
|
if (message.isOutgoing()) {
|
||||||
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
|
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
|
||||||
|
@ -1696,6 +1725,12 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getResources().getBoolean(R.bool.isTablet)) {
|
||||||
|
for (ChatUpdatedListener c : ChatUpdatedListeners) {
|
||||||
|
c.onChatUpdated();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ import static org.linphone.FragmentsAvailable.CHAT_LIST;
|
||||||
/**
|
/**
|
||||||
* @author Sylvain Berfini
|
* @author Sylvain Berfini
|
||||||
*/
|
*/
|
||||||
public class ChatListFragment extends Fragment implements OnClickListener, OnItemClickListener, ContactsUpdatedListener {
|
public class ChatListFragment extends Fragment implements OnClickListener, OnItemClickListener, ContactsUpdatedListener, ChatUpdatedListener {
|
||||||
private LayoutInflater mInflater;
|
private LayoutInflater mInflater;
|
||||||
private List<String> mConversations;
|
private List<String> mConversations;
|
||||||
private ListView chatList;
|
private ListView chatList;
|
||||||
|
@ -109,6 +109,9 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ChatFragment.createIfNotExist();
|
||||||
|
ChatFragment.addChatListener(this);
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,9 +186,6 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
||||||
|
|
||||||
public void refresh() {
|
public void refresh() {
|
||||||
mConversations = LinphoneActivity.instance().getChatList();
|
mConversations = LinphoneActivity.instance().getChatList();
|
||||||
if (getResources().getBoolean(R.bool.isTablet)) {
|
|
||||||
LinphoneActivity.instance().displayChat("", null, null);
|
|
||||||
}
|
|
||||||
hideAndDisplayMessageIfNoChat();
|
hideAndDisplayMessageIfNoChat();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -354,6 +354,11 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onChatUpdated() {
|
||||||
|
refresh();
|
||||||
|
}
|
||||||
|
|
||||||
class ChatListAdapter extends BaseAdapter {
|
class ChatListAdapter extends BaseAdapter {
|
||||||
private class ViewHolder {
|
private class ViewHolder {
|
||||||
public TextView lastMessageView;
|
public TextView lastMessageView;
|
||||||
|
|
|
@ -19,7 +19,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
package org.linphone;
|
package org.linphone;
|
||||||
|
|
||||||
import android.Manifest;
|
|
||||||
import android.accounts.Account;
|
import android.accounts.Account;
|
||||||
import android.accounts.AccountManager;
|
import android.accounts.AccountManager;
|
||||||
import android.content.ContentProviderOperation;
|
import android.content.ContentProviderOperation;
|
||||||
|
@ -43,7 +42,6 @@ import org.linphone.core.LinphoneFriend;
|
||||||
import org.linphone.core.LinphoneFriendImpl;
|
import org.linphone.core.LinphoneFriendImpl;
|
||||||
import org.linphone.core.LinphoneProxyConfig;
|
import org.linphone.core.LinphoneProxyConfig;
|
||||||
import org.linphone.mediastream.Log;
|
import org.linphone.mediastream.Log;
|
||||||
import org.linphone.mediastream.Version;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
Loading…
Reference in a new issue