Эх сурвалжийг харах

Fix #211

Signed-off-by: Mario Danic <mario@lovelyhq.com>
Mario Danic 6 жил өмнө
parent
commit
c907c62c3c

+ 2 - 0
app/build.gradle

@@ -160,6 +160,8 @@ dependencies {
     implementation 'com.webianks.library:popup-bubble:1.0.5'
     implementation 'com.webianks.library:popup-bubble:1.0.5'
 
 
     implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
     implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
+    implementation 'com.kevalpatel2106:emoticongifkeyboard:1.1'
+
     testImplementation 'junit:junit:4.12'
     testImplementation 'junit:junit:4.12'
     androidTestImplementation ('com.android.support.test.espresso:espresso-core:3.0.1', {
     androidTestImplementation ('com.android.support.test.espresso:espresso-core:3.0.1', {
         exclude group: 'com.android.support', module: 'support-annotations'
         exclude group: 'com.android.support', module: 'support-annotations'

+ 2 - 1
app/src/main/java/com/nextcloud/talk/adapters/messages/MagicIncomingTextMessageViewHolder.java

@@ -26,6 +26,7 @@ import android.text.TextUtils;
 import android.view.View;
 import android.view.View;
 import android.widget.TextView;
 import android.widget.TextView;
 
 
+import com.kevalpatel2106.emoticongifkeyboard.widget.EmoticonTextView;
 import com.nextcloud.talk.R;
 import com.nextcloud.talk.R;
 import com.nextcloud.talk.application.NextcloudTalkApplication;
 import com.nextcloud.talk.application.NextcloudTalkApplication;
 import com.nextcloud.talk.models.database.UserEntity;
 import com.nextcloud.talk.models.database.UserEntity;
@@ -50,7 +51,7 @@ public class MagicIncomingTextMessageViewHolder
     TextView messageAuthor;
     TextView messageAuthor;
 
 
     @BindView(R.id.messageText)
     @BindView(R.id.messageText)
-    TextView messageText;
+    EmoticonTextView messageText;
 
 
     @Inject
     @Inject
     UserUtils userUtils;
     UserUtils userUtils;

+ 2 - 2
app/src/main/java/com/nextcloud/talk/adapters/messages/MagicOutcomingTextMessageViewHolder.java

@@ -23,8 +23,8 @@ package com.nextcloud.talk.adapters.messages;
 import android.text.Spannable;
 import android.text.Spannable;
 import android.text.SpannableString;
 import android.text.SpannableString;
 import android.view.View;
 import android.view.View;
-import android.widget.TextView;
 
 
+import com.kevalpatel2106.emoticongifkeyboard.widget.EmoticonTextView;
 import com.nextcloud.talk.R;
 import com.nextcloud.talk.R;
 import com.nextcloud.talk.application.NextcloudTalkApplication;
 import com.nextcloud.talk.application.NextcloudTalkApplication;
 import com.nextcloud.talk.models.database.UserEntity;
 import com.nextcloud.talk.models.database.UserEntity;
@@ -44,7 +44,7 @@ import butterknife.ButterKnife;
 @AutoInjector(NextcloudTalkApplication.class)
 @AutoInjector(NextcloudTalkApplication.class)
 public class MagicOutcomingTextMessageViewHolder extends MessageHolders.OutcomingTextMessageViewHolder<ChatMessage> {
 public class MagicOutcomingTextMessageViewHolder extends MessageHolders.OutcomingTextMessageViewHolder<ChatMessage> {
     @BindView(R.id.messageText)
     @BindView(R.id.messageText)
-    TextView messageText;
+    EmoticonTextView messageText;
 
 
     @Inject
     @Inject
     UserUtils userUtils;
     UserUtils userUtils;

+ 3 - 2
app/src/main/java/com/nextcloud/talk/controllers/ChatController.java

@@ -75,11 +75,11 @@ import com.nextcloud.talk.models.json.rooms.RoomOverall;
 import com.nextcloud.talk.models.json.rooms.RoomsOverall;
 import com.nextcloud.talk.models.json.rooms.RoomsOverall;
 import com.nextcloud.talk.presenters.MentionAutocompletePresenter;
 import com.nextcloud.talk.presenters.MentionAutocompletePresenter;
 import com.nextcloud.talk.utils.ApiUtils;
 import com.nextcloud.talk.utils.ApiUtils;
-import com.nextcloud.talk.utils.singletons.ApplicationWideCurrentRoomHolder;
 import com.nextcloud.talk.utils.KeyboardUtils;
 import com.nextcloud.talk.utils.KeyboardUtils;
 import com.nextcloud.talk.utils.bundle.BundleKeys;
 import com.nextcloud.talk.utils.bundle.BundleKeys;
 import com.nextcloud.talk.utils.database.user.UserUtils;
 import com.nextcloud.talk.utils.database.user.UserUtils;
 import com.nextcloud.talk.utils.glide.GlideApp;
 import com.nextcloud.talk.utils.glide.GlideApp;
+import com.nextcloud.talk.utils.singletons.ApplicationWideCurrentRoomHolder;
 import com.otaliastudios.autocomplete.Autocomplete;
 import com.otaliastudios.autocomplete.Autocomplete;
 import com.otaliastudios.autocomplete.AutocompleteCallback;
 import com.otaliastudios.autocomplete.AutocompleteCallback;
 import com.otaliastudios.autocomplete.AutocompletePresenter;
 import com.otaliastudios.autocomplete.AutocompletePresenter;
@@ -92,6 +92,7 @@ import com.stfalcon.chatkit.messages.MessagesListAdapter;
 import com.stfalcon.chatkit.utils.DateFormatter;
 import com.stfalcon.chatkit.utils.DateFormatter;
 import com.webianks.library.PopupBubble;
 import com.webianks.library.PopupBubble;
 
 
+import org.apache.commons.lang3.StringEscapeUtils;
 import org.parceler.Parcels;
 import org.parceler.Parcels;
 
 
 import java.io.IOException;
 import java.io.IOException;
@@ -374,7 +375,7 @@ public class ChatController extends BaseController implements MessagesListAdapte
 
 
         messageInputView.getInputEditText().setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
         messageInputView.getInputEditText().setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
         messageInputView.setInputListener(input -> {
         messageInputView.setInputListener(input -> {
-            sendMessage(input.toString(), 1);
+            sendMessage(StringEscapeUtils.escapeJava(input.toString()), 1);
             return true;
             return true;
         });
         });
 
 

+ 3 - 1
app/src/main/java/com/nextcloud/talk/models/json/chat/ChatMessage.java

@@ -26,6 +26,7 @@ import com.nextcloud.talk.utils.ApiUtils;
 import com.stfalcon.chatkit.commons.models.IMessage;
 import com.stfalcon.chatkit.commons.models.IMessage;
 import com.stfalcon.chatkit.commons.models.IUser;
 import com.stfalcon.chatkit.commons.models.IUser;
 
 
+import org.apache.commons.lang3.StringEscapeUtils;
 import org.parceler.Parcel;
 import org.parceler.Parcel;
 
 
 import java.util.Date;
 import java.util.Date;
@@ -113,6 +114,7 @@ public class ChatMessage implements IMessage {
             }
             }
         }
         }
 
 
-        return message;
+
+        return StringEscapeUtils.unescapeJava(message);
     }
     }
 }
 }

+ 1 - 1
app/src/main/res/layout/item_custom_incoming_text_message.xml

@@ -55,7 +55,7 @@
             android:textColor="@color/colorPrimary"
             android:textColor="@color/colorPrimary"
             android:textSize="12sp"/>
             android:textSize="12sp"/>
 
 
-        <TextView
+        <com.kevalpatel2106.emoticongifkeyboard.widget.EmoticonTextView
             android:id="@id/messageText"
             android:id="@id/messageText"
             android:layout_width="wrap_content"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_height="wrap_content"

+ 1 - 1
app/src/main/res/layout/item_custom_outcoming_text_message.xml

@@ -42,7 +42,7 @@
         app:flexWrap="wrap"
         app:flexWrap="wrap"
         app:justifyContent="flex_end">
         app:justifyContent="flex_end">
 
 
-        <TextView
+        <com.kevalpatel2106.emoticongifkeyboard.widget.EmoticonTextView
             android:id="@id/messageText"
             android:id="@id/messageText"
             android:layout_width="wrap_content"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_height="wrap_content"

+ 67 - 0
app/src/main/res/layout/view_message_input.xml

@@ -0,0 +1,67 @@
+<?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/>.
+  -->
+
+<merge
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:orientation="vertical">
+
+    <ImageButton
+        android:id="@id/attachmentButton"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_centerVertical="true"/>
+
+    <android.support.v4.widget.Space
+        android:id="@id/attachmentButtonSpace"
+        android:layout_width="0dp"
+        android:layout_height="0dp"
+        android:layout_toEndOf="@id/attachmentButton"
+        android:layout_toRightOf="@id/attachmentButton"/>
+
+    <com.kevalpatel2106.emoticongifkeyboard.widget.EmoticonEditText
+        android:id="@id/messageInput"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_centerVertical="true"
+        android:layout_toEndOf="@id/attachmentButtonSpace"
+        android:layout_toLeftOf="@id/sendButtonSpace"
+        android:layout_toRightOf="@id/attachmentButtonSpace"
+        android:layout_toStartOf="@id/sendButtonSpace"
+        android:inputType="textAutoCorrect|textAutoComplete|textMultiLine|textCapSentences"/>
+
+    <android.support.v4.widget.Space
+        android:id="@id/sendButtonSpace"
+        android:layout_width="0dp"
+        android:layout_height="0dp"
+        android:layout_toLeftOf="@id/messageSendButton"
+        android:layout_toStartOf="@id/messageSendButton"/>
+
+    <ImageButton
+        android:id="@id/messageSendButton"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignParentEnd="true"
+        android:layout_alignParentRight="true"
+        android:layout_centerVertical="true"/>
+
+</merge>