mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-20 12:09:45 +01:00
parent
969a095f61
commit
7de56eb869
@ -46,6 +46,9 @@ import android.view.ViewGroup;
|
|||||||
import android.view.inputmethod.EditorInfo;
|
import android.view.inputmethod.EditorInfo;
|
||||||
import android.widget.AbsListView;
|
import android.widget.AbsListView;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.amulyakhare.textdrawable.TextDrawable;
|
import com.amulyakhare.textdrawable.TextDrawable;
|
||||||
import com.bumptech.glide.load.DataSource;
|
import com.bumptech.glide.load.DataSource;
|
||||||
@ -108,6 +111,7 @@ import javax.inject.Inject;
|
|||||||
|
|
||||||
import autodagger.AutoInjector;
|
import autodagger.AutoInjector;
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
|
import butterknife.OnClick;
|
||||||
import io.reactivex.Observer;
|
import io.reactivex.Observer;
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
import io.reactivex.disposables.Disposable;
|
import io.reactivex.disposables.Disposable;
|
||||||
@ -134,6 +138,12 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
|||||||
MessageInput messageInputView;
|
MessageInput messageInputView;
|
||||||
@BindView(R.id.popupBubbleView)
|
@BindView(R.id.popupBubbleView)
|
||||||
PopupBubble popupBubble;
|
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 List<Disposable> disposableList = new ArrayList<>();
|
||||||
private String conversationName;
|
private String conversationName;
|
||||||
private String roomToken;
|
private String roomToken;
|
||||||
@ -159,6 +169,9 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
|||||||
private String roomId;
|
private String roomId;
|
||||||
private boolean voiceOnly;
|
private boolean voiceOnly;
|
||||||
|
|
||||||
|
private boolean isFirstMessagesProcessing = true;
|
||||||
|
private boolean isHelloClicked;
|
||||||
|
|
||||||
public ChatController(Bundle args) {
|
public ChatController(Bundle args) {
|
||||||
super(args);
|
super(args);
|
||||||
setHasOptionsMenu(true);
|
setHasOptionsMenu(true);
|
||||||
@ -287,9 +300,13 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
|||||||
getActionBar().show();
|
getActionBar().show();
|
||||||
boolean adapterWasNull = false;
|
boolean adapterWasNull = false;
|
||||||
|
|
||||||
|
sendHiTextView.setText(String.format(getResources().getString(R.string.nc_chat_empty), getResources()
|
||||||
|
.getString(R.string.nc_hello)));
|
||||||
|
|
||||||
if (adapter == null) {
|
if (adapter == null) {
|
||||||
|
|
||||||
|
loadingProgressBar.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
cache.evictAll();
|
cache.evictAll();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -329,6 +346,12 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
|||||||
.into(imageView);
|
.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() {
|
private void joinRoomWithPassword() {
|
||||||
|
|
||||||
if (currentCall == null) {
|
if (currentCall == null) {
|
||||||
@ -695,7 +726,26 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
|||||||
ChatOverall chatOverall = (ChatOverall) response.body();
|
ChatOverall chatOverall = (ChatOverall) response.body();
|
||||||
List<ChatMessage> chatMessageList = chatOverall.getOcs().getData();
|
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) {
|
if (!isFromTheFuture) {
|
||||||
|
|
||||||
for (int i = 0; i < chatMessageList.size(); i++) {
|
for (int i = 0; i < chatMessageList.size(); i++) {
|
||||||
chatMessageList.get(i).setBaseUrl(conversationUser.getBaseUrl());
|
chatMessageList.get(i).setBaseUrl(conversationUser.getBaseUrl());
|
||||||
if (globalLastKnownPastMessageId == -1 || chatMessageList.get(i).getJsonMessageId() <
|
if (globalLastKnownPastMessageId == -1 || chatMessageList.get(i).getJsonMessageId() <
|
||||||
@ -710,8 +760,10 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
adapter.addToEnd(chatMessageList, false);
|
adapter.addToEnd(chatMessageList, false);
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < chatMessageList.size(); i++) {
|
for (int i = 0; i < chatMessageList.size(); i++) {
|
||||||
chatMessageList.get(i).setBaseUrl(conversationUser.getBaseUrl());
|
chatMessageList.get(i).setBaseUrl(conversationUser.getBaseUrl());
|
||||||
@ -752,6 +804,15 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
|||||||
pullChatMessages(1);
|
pullChatMessages(1);
|
||||||
}
|
}
|
||||||
} else if (response.code() == 304 && !isFromTheFuture) {
|
} 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;
|
historyRead = true;
|
||||||
|
|
||||||
if (!lookingIntoFuture) {
|
if (!lookingIntoFuture) {
|
||||||
|
@ -24,12 +24,57 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/progressBar"
|
||||||
|
android:layout_width="@dimen/item_height"
|
||||||
|
android:layout_height="@dimen/item_height"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:layout_marginEnd="@dimen/activity_horizontal_margin"
|
||||||
|
android:layout_marginLeft="@dimen/activity_horizontal_margin"
|
||||||
|
android:layout_marginRight="@dimen/activity_horizontal_margin"
|
||||||
|
android:layout_marginStart="@dimen/activity_horizontal_margin"
|
||||||
|
android:indeterminate="true"
|
||||||
|
android:indeterminateTint="@color/colorPrimary"
|
||||||
|
android:indeterminateTintMode="src_in"
|
||||||
|
android:visibility="gone"/>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/emptyLayout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/wawingTextView"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:text="👋"
|
||||||
|
android:textAlignment="center"
|
||||||
|
android:textSize="72sp"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/sendHiTextView"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@+id/wawingTextView"
|
||||||
|
android:layout_margin="8dp"
|
||||||
|
android:textAlignment="center"
|
||||||
|
android:textSize="20sp"/>
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
<com.stfalcon.chatkit.messages.MessagesList
|
<com.stfalcon.chatkit.messages.MessagesList
|
||||||
android:id="@+id/messagesListView"
|
android:id="@+id/messagesListView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:paddingBottom="16dp"
|
|
||||||
android:layout_above="@+id/messageInputView"
|
android:layout_above="@+id/messageInputView"
|
||||||
|
android:paddingBottom="16dp"
|
||||||
|
android:visibility="gone"
|
||||||
|
app:dateHeaderTextSize="13sp"
|
||||||
|
app:incomingBubblePaddingBottom="@dimen/message_bubble_corners_padding"
|
||||||
|
app:incomingBubblePaddingLeft="@dimen/message_bubble_corners_padding"
|
||||||
|
app:incomingBubblePaddingRight="@dimen/message_bubble_corners_padding"
|
||||||
|
app:incomingBubblePaddingTop="@dimen/message_bubble_corners_padding"
|
||||||
app:incomingDefaultBubbleColor="@color/white_two"
|
app:incomingDefaultBubbleColor="@color/white_two"
|
||||||
app:incomingDefaultBubblePressedColor="@color/white_two"
|
app:incomingDefaultBubblePressedColor="@color/white_two"
|
||||||
app:incomingDefaultBubbleSelectedColor="@color/transparent"
|
app:incomingDefaultBubbleSelectedColor="@color/transparent"
|
||||||
@ -37,14 +82,10 @@
|
|||||||
app:incomingTextLinkColor="@color/nc_incoming_text_default"
|
app:incomingTextLinkColor="@color/nc_incoming_text_default"
|
||||||
app:incomingTextSize="@dimen/chat_text_size"
|
app:incomingTextSize="@dimen/chat_text_size"
|
||||||
app:incomingTimeTextSize="12sp"
|
app:incomingTimeTextSize="12sp"
|
||||||
app:incomingBubblePaddingTop="@dimen/message_bubble_corners_padding"
|
|
||||||
app:incomingBubblePaddingBottom="@dimen/message_bubble_corners_padding"
|
|
||||||
app:incomingBubblePaddingLeft="@dimen/message_bubble_corners_padding"
|
|
||||||
app:incomingBubblePaddingRight="@dimen/message_bubble_corners_padding"
|
|
||||||
app:outcomingBubblePaddingTop="@dimen/message_bubble_corners_padding"
|
|
||||||
app:outcomingBubblePaddingBottom="@dimen/message_bubble_corners_padding"
|
app:outcomingBubblePaddingBottom="@dimen/message_bubble_corners_padding"
|
||||||
app:outcomingBubblePaddingLeft="@dimen/message_bubble_corners_padding"
|
app:outcomingBubblePaddingLeft="@dimen/message_bubble_corners_padding"
|
||||||
app:outcomingBubblePaddingRight="@dimen/message_bubble_corners_padding"
|
app:outcomingBubblePaddingRight="@dimen/message_bubble_corners_padding"
|
||||||
|
app:outcomingBubblePaddingTop="@dimen/message_bubble_corners_padding"
|
||||||
app:outcomingDefaultBubbleColor="@color/colorPrimary"
|
app:outcomingDefaultBubbleColor="@color/colorPrimary"
|
||||||
app:outcomingDefaultBubblePressedColor="@color/colorPrimary"
|
app:outcomingDefaultBubblePressedColor="@color/colorPrimary"
|
||||||
app:outcomingDefaultBubbleSelectedColor="@color/transparent"
|
app:outcomingDefaultBubbleSelectedColor="@color/transparent"
|
||||||
@ -52,17 +93,16 @@
|
|||||||
app:outcomingTextLinkColor="@color/nc_outcoming_text_default"
|
app:outcomingTextLinkColor="@color/nc_outcoming_text_default"
|
||||||
app:outcomingTextSize="@dimen/chat_text_size"
|
app:outcomingTextSize="@dimen/chat_text_size"
|
||||||
app:outcomingTimeTextSize="12sp"
|
app:outcomingTimeTextSize="12sp"
|
||||||
app:dateHeaderTextSize="13sp"
|
|
||||||
app:textAutoLink="all"/>
|
app:textAutoLink="all"/>
|
||||||
|
|
||||||
<com.webianks.library.PopupBubble
|
<com.webianks.library.PopupBubble
|
||||||
android:id="@+id/popupBubbleView"
|
android:id="@+id/popupBubbleView"
|
||||||
android:layout_margin="16dp"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_above="@+id/separator"
|
android:layout_above="@+id/separator"
|
||||||
android:paddingEnd="8dp"
|
|
||||||
android:layout_centerHorizontal="true"
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_margin="16dp"
|
||||||
|
android:paddingEnd="8dp"
|
||||||
app:pb_backgroundColor="@color/colorPrimary"
|
app:pb_backgroundColor="@color/colorPrimary"
|
||||||
app:pb_icon="@drawable/ic_baseline_arrow_downward_24px"
|
app:pb_icon="@drawable/ic_baseline_arrow_downward_24px"
|
||||||
app:pb_text="@string/nc_new_messages"
|
app:pb_text="@string/nc_new_messages"
|
||||||
|
@ -195,4 +195,8 @@ Find Nextcloud on https://nextcloud.com</string>
|
|||||||
<string name="nc_description_more_menu_group">Menu for public conversation %1$s</string>
|
<string name="nc_description_more_menu_group">Menu for public conversation %1$s</string>
|
||||||
<string name="nc_description_send_message_button">Send message</string>
|
<string name="nc_description_send_message_button">Send message</string>
|
||||||
|
|
||||||
|
<!-- Chat empty state -->
|
||||||
|
<string name="nc_chat_empty">Click to be the first to say %1$s!</string>
|
||||||
|
<string name="nc_hello">Hello</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user