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