mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-26 06:55:42 +03:00
Partial support for #264
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
85ce06a9a9
commit
d9f26d3d00
5 changed files with 112 additions and 5 deletions
|
@ -157,7 +157,7 @@ dependencies {
|
|||
|
||||
implementation 'com.github.wooplr:Spotlight:1.2.3'
|
||||
|
||||
implementation 'com.github.mario:ChatKit:40a8e9cf69'
|
||||
implementation 'com.github.mario:ChatKit:64c1a2fee1'
|
||||
|
||||
implementation 'com.otaliastudios:autocomplete:1.1.0'
|
||||
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Nextcloud Talk application
|
||||
*
|
||||
* @author Mario Danic
|
||||
* Copyright (C) 2017-2018 Mario Danic <mario@lovelyhq.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.nextcloud.talk.adapters.messages;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import com.nextcloud.talk.models.json.chat.ChatMessage;
|
||||
import com.stfalcon.chatkit.messages.MessageHolders;
|
||||
|
||||
public class MagicSystemMessageViewHolder extends MessageHolders.IncomingTextMessageViewHolder<ChatMessage> {
|
||||
|
||||
public MagicSystemMessageViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBind(ChatMessage message) {
|
||||
super.onBind(message);
|
||||
text.setText(message.getText());
|
||||
}
|
||||
}
|
|
@ -485,8 +485,10 @@ public class CallNotificationController extends BaseController {
|
|||
public void onDestroy() {
|
||||
AvatarStatusCodeHolder.getInstance().setStatusCode(0);
|
||||
leavingScreen = true;
|
||||
handler.removeCallbacksAndMessages(null);
|
||||
handler = null;
|
||||
if (handler != null) {
|
||||
handler.removeCallbacksAndMessages(null);
|
||||
handler = null;
|
||||
}
|
||||
dispose();
|
||||
endMediaAndVibratorNotifications();
|
||||
super.onDestroy();
|
||||
|
|
|
@ -62,6 +62,7 @@ import com.nextcloud.talk.R;
|
|||
import com.nextcloud.talk.activities.MagicCallActivity;
|
||||
import com.nextcloud.talk.adapters.messages.MagicIncomingTextMessageViewHolder;
|
||||
import com.nextcloud.talk.adapters.messages.MagicOutcomingTextMessageViewHolder;
|
||||
import com.nextcloud.talk.adapters.messages.MagicSystemMessageViewHolder;
|
||||
import com.nextcloud.talk.api.NcApi;
|
||||
import com.nextcloud.talk.application.NextcloudTalkApplication;
|
||||
import com.nextcloud.talk.callbacks.MentionAutocompleteCallback;
|
||||
|
@ -123,7 +124,7 @@ import retrofit2.Response;
|
|||
|
||||
@AutoInjector(NextcloudTalkApplication.class)
|
||||
public class ChatController extends BaseController implements MessagesListAdapter.OnLoadMoreListener,
|
||||
MessagesListAdapter.Formatter<Date>, MessagesListAdapter.OnMessageLongClickListener {
|
||||
MessagesListAdapter.Formatter<Date>, MessagesListAdapter.OnMessageLongClickListener, MessageHolders.ContentChecker {
|
||||
private static final String TAG = "ChatController";
|
||||
@Inject
|
||||
NcApi ncApi;
|
||||
|
@ -167,6 +168,8 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
|||
private boolean isFirstMessagesProcessing = true;
|
||||
private boolean isHelloClicked;
|
||||
|
||||
private static final byte CONTENT_TYPE_SYSTEM_MESSAGE = 1;
|
||||
|
||||
public ChatController(Bundle args) {
|
||||
super(args);
|
||||
setHasOptionsMenu(true);
|
||||
|
@ -314,6 +317,10 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
|||
messageHolders.setIncomingTextConfig(MagicIncomingTextMessageViewHolder.class, R.layout.item_custom_incoming_text_message);
|
||||
messageHolders.setOutcomingTextConfig(MagicOutcomingTextMessageViewHolder.class, R.layout.item_custom_outcoming_text_message);
|
||||
|
||||
messageHolders.registerContentType(CONTENT_TYPE_SYSTEM_MESSAGE, MagicSystemMessageViewHolder.class,
|
||||
R.layout.item_system_message, MagicSystemMessageViewHolder.class, R.layout.item_system_message,
|
||||
this);
|
||||
|
||||
adapter = new MessagesListAdapter<>(conversationUser.getUserId(), messageHolders, new ImageLoader() {
|
||||
@Override
|
||||
public void loadImage(ImageView imageView, String url) {
|
||||
|
@ -794,7 +801,9 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
|||
|
||||
for (int i = 0; i < chatMessageList.size(); i++) {
|
||||
if (chatMessageList.size() > i + 1) {
|
||||
if (chatMessageList.get(i + 1).getActorId().equals(chatMessageList.get(i).getActorId()) &&
|
||||
if (TextUtils.isEmpty(chatMessageList.get(i).getSystemMessage()) &&
|
||||
TextUtils.isEmpty(chatMessageList.get(i + 1).getSystemMessage()) &&
|
||||
chatMessageList.get(i + 1).getActorId().equals(chatMessageList.get(i).getActorId()) &&
|
||||
countGroupedMessages < 4 && DateFormatter.isSameDay(chatMessageList.get(i).getCreatedAt(),
|
||||
chatMessageList.get(i + 1).getCreatedAt())) {
|
||||
chatMessageList.get(i).setGrouped(true);
|
||||
|
@ -980,4 +989,14 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasContentFor(IMessage message, byte type) {
|
||||
switch (type) {
|
||||
case CONTENT_TYPE_SYSTEM_MESSAGE:
|
||||
return !TextUtils.isEmpty(message.getSystemMessage());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
47
app/src/main/res/layout/item_system_message.xml
Normal file
47
app/src/main/res/layout/item_system_message.xml
Normal file
|
@ -0,0 +1,47 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Nextcloud Talk application
|
||||
~
|
||||
~ @author Mario Danic
|
||||
~ Copyright (C) 2017-2018 Mario Danic <mario@lovelyhq.com>
|
||||
~
|
||||
~ This program is free software: you can redistribute it and/or modify
|
||||
~ it under the terms of the GNU General Public License as published by
|
||||
~ the Free Software Foundation, either version 3 of the License, or
|
||||
~ at your option) any later version.
|
||||
~
|
||||
~ This program is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
~ GNU General Public License for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU General Public License
|
||||
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="8dp">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@id/bubble"
|
||||
android:layout_centerHorizontal="true">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/messageText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:gravity="center_horizontal"
|
||||
android:textAlignment="center"
|
||||
android:textColor="@color/colorPrimary"
|
||||
android:textSize="12sp"/>
|
||||
|
||||
</RelativeLayout>
|
||||
</RelativeLayout>
|
Loading…
Reference in a new issue