|
@@ -46,6 +46,9 @@ import android.view.ViewGroup;
|
|
|
import android.view.inputmethod.EditorInfo;
|
|
|
import android.widget.AbsListView;
|
|
|
import android.widget.ImageView;
|
|
|
+import android.widget.ProgressBar;
|
|
|
+import android.widget.RelativeLayout;
|
|
|
+import android.widget.TextView;
|
|
|
|
|
|
import com.amulyakhare.textdrawable.TextDrawable;
|
|
|
import com.bumptech.glide.load.DataSource;
|
|
@@ -108,6 +111,7 @@ import javax.inject.Inject;
|
|
|
|
|
|
import autodagger.AutoInjector;
|
|
|
import butterknife.BindView;
|
|
|
+import butterknife.OnClick;
|
|
|
import io.reactivex.Observer;
|
|
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
|
|
import io.reactivex.disposables.Disposable;
|
|
@@ -134,6 +138,12 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
|
|
MessageInput messageInputView;
|
|
|
@BindView(R.id.popupBubbleView)
|
|
|
PopupBubble popupBubble;
|
|
|
+ @BindView(R.id.emptyLayout)
|
|
|
+ RelativeLayout emptyLayout;
|
|
|
+ @BindView(R.id.sendHiTextView)
|
|
|
+ TextView sendHiTextView;
|
|
|
+ @BindView(R.id.progressBar)
|
|
|
+ ProgressBar loadingProgressBar;
|
|
|
private List<Disposable> disposableList = new ArrayList<>();
|
|
|
private String conversationName;
|
|
|
private String roomToken;
|
|
@@ -159,6 +169,9 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
|
|
private String roomId;
|
|
|
private boolean voiceOnly;
|
|
|
|
|
|
+ private boolean isFirstMessagesProcessing = true;
|
|
|
+ private boolean isHelloClicked;
|
|
|
+
|
|
|
public ChatController(Bundle args) {
|
|
|
super(args);
|
|
|
setHasOptionsMenu(true);
|
|
@@ -287,9 +300,13 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
|
|
getActionBar().show();
|
|
|
boolean adapterWasNull = false;
|
|
|
|
|
|
+ sendHiTextView.setText(String.format(getResources().getString(R.string.nc_chat_empty), getResources()
|
|
|
+ .getString(R.string.nc_hello)));
|
|
|
|
|
|
if (adapter == null) {
|
|
|
|
|
|
+ loadingProgressBar.setVisibility(View.VISIBLE);
|
|
|
+
|
|
|
try {
|
|
|
cache.evictAll();
|
|
|
} catch (IOException e) {
|
|
@@ -329,6 +346,12 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
|
|
.into(imageView);
|
|
|
}
|
|
|
});
|
|
|
+ } else {
|
|
|
+ if (adapter.getItemCount() == 0) {
|
|
|
+ emptyLayout.setVisibility(View.VISIBLE);
|
|
|
+ } else {
|
|
|
+ messagesListView.setVisibility(View.VISIBLE);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
@@ -478,6 +501,14 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
|
|
|
|
|
}
|
|
|
|
|
|
+ @OnClick(R.id.emptyLayout)
|
|
|
+ public void sendHello() {
|
|
|
+ if (!isHelloClicked) {
|
|
|
+ isHelloClicked = true;
|
|
|
+ sendMessage(getResources().getString(R.string.nc_hello) + " 👋", 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void joinRoomWithPassword() {
|
|
|
|
|
|
if (currentCall == null) {
|
|
@@ -695,7 +726,26 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
|
|
ChatOverall chatOverall = (ChatOverall) response.body();
|
|
|
List<ChatMessage> chatMessageList = chatOverall.getOcs().getData();
|
|
|
|
|
|
+ if (isFirstMessagesProcessing) {
|
|
|
+ isFirstMessagesProcessing = false;
|
|
|
+ loadingProgressBar.setVisibility(View.GONE);
|
|
|
+
|
|
|
+ if (chatMessageList.size() == 0) {
|
|
|
+ emptyLayout.setVisibility(View.VISIBLE);
|
|
|
+ } else {
|
|
|
+ messagesListView.setVisibility(View.VISIBLE);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (emptyLayout.getVisibility() != View.GONE) {
|
|
|
+ emptyLayout.setVisibility(View.GONE);
|
|
|
+ }
|
|
|
+ if (messagesListView.getVisibility() != View.VISIBLE) {
|
|
|
+ messagesListView.setVisibility(View.VISIBLE);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if (!isFromTheFuture) {
|
|
|
+
|
|
|
for (int i = 0; i < chatMessageList.size(); i++) {
|
|
|
chatMessageList.get(i).setBaseUrl(conversationUser.getBaseUrl());
|
|
|
if (globalLastKnownPastMessageId == -1 || chatMessageList.get(i).getJsonMessageId() <
|
|
@@ -710,8 +760,10 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
adapter.addToEnd(chatMessageList, false);
|
|
|
|
|
|
+
|
|
|
} else {
|
|
|
for (int i = 0; i < chatMessageList.size(); i++) {
|
|
|
chatMessageList.get(i).setBaseUrl(conversationUser.getBaseUrl());
|
|
@@ -752,6 +804,15 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
|
|
pullChatMessages(1);
|
|
|
}
|
|
|
} else if (response.code() == 304 && !isFromTheFuture) {
|
|
|
+ if (isFirstMessagesProcessing) {
|
|
|
+ isFirstMessagesProcessing = false;
|
|
|
+ loadingProgressBar.setVisibility(View.GONE);
|
|
|
+
|
|
|
+ if (emptyLayout.getVisibility() != View.VISIBLE) {
|
|
|
+ emptyLayout.setVisibility(View.VISIBLE);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
historyRead = true;
|
|
|
|
|
|
if (!lookingIntoFuture) {
|