Added answer rule option resend

This commit is contained in:
M66B
2022-04-04 10:56:57 +02:00
parent ff6b18be51
commit bfc9b0cee8
5 changed files with 139 additions and 90 deletions

View File

@@ -32,7 +32,9 @@ import android.net.Uri;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.speech.tts.TextToSpeech;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
@@ -145,6 +147,7 @@ public class FragmentRule extends FragmentBase {
private CheckBox cbWithAttachments;
private EditText etTo;
private ImageButton ibTo;
private CheckBox cbResend;
private CheckBox cbCc;
private Button btnTtsSetup;
@@ -297,6 +300,7 @@ public class FragmentRule extends FragmentBase {
cbWithAttachments = view.findViewById(R.id.cbWithAttachments);
etTo = view.findViewById(R.id.etTo);
ibTo = view.findViewById(R.id.ibTo);
cbResend = view.findViewById(R.id.cbResend);
cbCc = view.findViewById(R.id.cbCc);
btnTtsSetup = view.findViewById(R.id.btnTtsSetup);
@@ -617,6 +621,21 @@ public class FragmentRule extends FragmentBase {
spIdent.setOnItemSelectedListener(onItemSelectedListener);
spAnswer.setOnItemSelectedListener(onItemSelectedListener);
etTo.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) {
}
@Override
public void afterTextChanged(Editable s) {
cbResend.setEnabled(!TextUtils.isEmpty(s.toString()));
}
});
ibTo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@@ -625,6 +644,17 @@ public class FragmentRule extends FragmentBase {
}
});
cbResend.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
checked = (checked && compoundButton.isEnabled());
spAnswer.setEnabled(!checked);
cbAnswerSubject.setEnabled(!checked);
cbOriginalText.setEnabled(!checked);
cbWithAttachments.setEnabled(!checked);
}
});
btnTtsSetup.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
@@ -1146,6 +1176,7 @@ public class FragmentRule extends FragmentBase {
cbWithAttachments.setChecked(jaction.optBoolean("attachments"));
etTo.setText(jaction.optString("to"));
cbResend.setChecked(jaction.optBoolean("resend"));
cbCc.setChecked(jaction.optBoolean("cc"));
break;
@@ -1488,6 +1519,7 @@ public class FragmentRule extends FragmentBase {
jaction.put("original_text", cbOriginalText.isChecked());
jaction.put("attachments", cbWithAttachments.isChecked());
jaction.put("to", etTo.getText().toString().trim());
jaction.put("resend", cbResend.isChecked());
jaction.put("cc", cbCc.isChecked());
break;