[android] Use TextSendController to disable TextInputView

Fixes #1552
This commit is contained in:
Torsten Grote
2019-04-26 13:45:49 -03:00
parent 421c9c44d6
commit 3d9a8f9bf8
3 changed files with 6 additions and 7 deletions

View File

@@ -4,7 +4,6 @@ import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.StringRes;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.Toolbar;
@@ -198,7 +197,7 @@ public class GroupActivity extends
private void setGroupEnabled(boolean enabled) {
isDissolved = !enabled;
textInput.setEnabled(enabled);
sendController.setReady(enabled);
list.getRecyclerView().setAlpha(enabled ? 1f : 0.5f);
if (!enabled) {

View File

@@ -28,6 +28,7 @@ public abstract class BaseMessageFragment extends BaseFragment
implements SendListener {
protected LargeTextInputView message;
private TextSendController sendController;
private MessageFragmentListener listener;
@Override
@@ -45,8 +46,7 @@ public abstract class BaseMessageFragment extends BaseFragment
View v = inflater.inflate(R.layout.fragment_message, container,
false);
message = v.findViewById(R.id.messageView);
TextSendController sendController =
new TextSendController(message, this, true);
sendController = new TextSendController(message, this, true);
message.setSendController(sendController);
message.setMaxTextLength(listener.getMaximumTextLength());
message.setButtonText(getString(getButtonText()));
@@ -85,7 +85,7 @@ public abstract class BaseMessageFragment extends BaseFragment
@Override
public void onSendClick(@Nullable String text, List<Uri> imageUris) {
// disable button to prevent accidental double actions
message.setEnabled(false);
sendController.setReady(false);
message.hideSoftKeyboard();
listener.onButtonClick(text);

View File

@@ -62,6 +62,7 @@ public abstract class ThreadListActivity<G extends NamedGroup, I extends ThreadI
protected BriarRecyclerView list;
private LinearLayoutManager layoutManager;
protected TextInputView textInput;
protected TextSendController sendController;
protected GroupId groupId;
@Nullable
private Parcelable layoutManagerState;
@@ -87,8 +88,7 @@ public abstract class ThreadListActivity<G extends NamedGroup, I extends ThreadI
getController().setGroupId(groupId);
textInput = findViewById(R.id.text_input_container);
TextSendController sendController =
new TextSendController(textInput, this, false);
sendController = new TextSendController(textInput, this, false);
textInput.setSendController(sendController);
textInput.setMaxTextLength(getMaxTextLength());
textInput.setReady(true);