Select reason when moderating

This commit is contained in:
Stephen Paul Weber 2024-06-30 21:08:26 +02:00 committed by Arne
parent 8c7f6b8733
commit edcab814a3
3 changed files with 11 additions and 2 deletions

View file

@ -2468,7 +2468,7 @@ public class ConversationFragment extends XmppFragment
activity.quickEdit("Spam", (reason) -> {
activity.xmppConnectionService.moderateMessage(conversation.getAccount(), selectedMessage, reason);
return null;
}, R.string.moderate_reason, false, false, true);
}, R.string.moderate_reason, false, false, true, true);
return true;
} else if (itemId == R.id.copy_message) {
ShareUtil.copyToClipboard(activity, selectedMessage);

View file

@ -34,6 +34,7 @@ import androidx.databinding.DataBindingUtil;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;

View file

@ -923,13 +923,18 @@ public abstract class XmppActivity extends ActionBarActivity {
quickEdit(previousValue, callback, hint, password, permitEmpty, false);
}
protected void quickEdit(final String previousValue, final OnValueEdited callback, final @StringRes int hint, boolean password, boolean permitEmpty, boolean alwaysCallback) {
quickEdit(previousValue, callback, hint, password, permitEmpty, alwaysCallback, false);
}
@SuppressLint("InflateParams")
protected void quickEdit(final String previousValue,
final OnValueEdited callback,
final @StringRes int hint,
boolean password,
boolean permitEmpty,
boolean alwaysCallback) {
boolean alwaysCallback,
boolean startSelected) {
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
DialogQuickeditBinding binding = DataBindingUtil.inflate(getLayoutInflater(), R.layout.dialog_quickedit, null, false);
if (password) {
@ -948,6 +953,9 @@ public abstract class XmppActivity extends ActionBarActivity {
final AlertDialog dialog = builder.create();
dialog.setOnShowListener(d -> SoftKeyboardUtils.showKeyboard(binding.inputEditText));
dialog.show();
if (startSelected) {
binding.inputEditText.selectAll();
}
View.OnClickListener clickListener = v -> {
String value = binding.inputEditText.getText().toString();
if ((alwaysCallback || !value.equals(previousValue)) && (!value.trim().isEmpty() || permitEmpty)) {