Mario Danic 6 years ago
parent
commit
e300f73483

+ 28 - 0
app/src/main/java/com/nextcloud/talk/controllers/ChatController.java

@@ -31,7 +31,10 @@ import android.graphics.drawable.ColorDrawable;
 import android.graphics.drawable.Drawable;
 import android.graphics.drawable.Drawable;
 import android.os.Bundle;
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.Handler;
+import android.text.Editable;
+import android.text.InputFilter;
 import android.text.TextUtils;
 import android.text.TextUtils;
+import android.text.TextWatcher;
 import android.util.Log;
 import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.LayoutInflater;
 import android.view.Menu;
 import android.view.Menu;
@@ -403,6 +406,31 @@ public class ChatController extends BaseController implements MessagesListAdapte
         });
         });
 
 
 
 
+        InputFilter[] filters = new InputFilter[1];
+        filters[0] = new InputFilter.LengthFilter(1000);
+        messageInputView.getInputEditText() .setFilters(filters);
+
+        messageInputView.getInputEditText().addTextChangedListener(new TextWatcher() {
+            @Override
+            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+
+            }
+
+            @Override
+            public void onTextChanged(CharSequence s, int start, int before, int count) {
+                if (s.length() == 1000) {
+                    messageInputView.getInputEditText().setError(getResources().getString(R.string.nc_limit_hit));
+                } else {
+                    messageInputView.getInputEditText().setError(null);
+                }
+            }
+
+            @Override
+            public void afterTextChanged(Editable s) {
+
+            }
+        });
+
         messageInputView.setInputListener(input -> {
         messageInputView.setInputListener(input -> {
             sendMessage(input, 1);
             sendMessage(input, 1);
             return true;
             return true;

+ 3 - 0
app/src/main/res/values/strings.xml

@@ -228,4 +228,7 @@ Find Nextcloud on https://nextcloud.com</string>
     <string name="nc_conversations_empty">You haven\'t talked to anyone yet!\n Tap to start a conversation.</string>
     <string name="nc_conversations_empty">You haven\'t talked to anyone yet!\n Tap to start a conversation.</string>
     <string name="nc_hello">Hello</string>
     <string name="nc_hello">Hello</string>
 
 
+    <!-- Other -->
+    <string name="nc_limit_hit">1000 characters limit has been hit</string>
+
 </resources>
 </resources>