This commit is contained in:
Mario Danic 2018-10-23 23:45:25 +02:00
parent 0ad443bb31
commit e300f73483
2 changed files with 31 additions and 0 deletions

View File

@ -31,7 +31,10 @@ import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
import android.text.Editable;
import android.text.InputFilter;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.Log;
import android.view.LayoutInflater;
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 -> {
sendMessage(input, 1);
return true;

View File

@ -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_hello">Hello</string>
<!-- Other -->
<string name="nc_limit_hit">1000 characters limit has been hit</string>
</resources>