Allow selecting action for answer menu

This commit is contained in:
M66B 2023-01-19 12:20:53 +01:00
parent 507e62f5ec
commit e9bc8f8e7b
4 changed files with 72 additions and 22 deletions

View File

@ -3356,17 +3356,14 @@ public class FragmentMessages extends FragmentBase
if (message == null)
return;
if (long_press && message.content) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
String answer_action = prefs.getString("answer_action", "reply");
if ("reply".equals(answer_action) ||
"reply_all".equals(answer_action) ||
"list".equals(answer_action))
onMenuReply(message, answer_action, selected);
else
onMenuReply(message, answer_action);
} else
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
String action = prefs.getString(
long_press ? "answer_action" : "answer_single",
long_press ? "reply" : "menu");
if ("menu".equals(action) || !message.content)
onReply(message, selected, fabReply);
else
onMenuReply(message, action);
}
}
@ -3569,6 +3566,10 @@ public class FragmentMessages extends FragmentBase
final Context context = getContext();
if (context == null)
return;
if (!"reply".equals(action) &&
!"reply_all".equals(action) &&
!"list".equals(action))
selected = null;
Intent reply = new Intent(context, ActivityCompose.class)
.putExtra("action", action)
.putExtra("reference", message.id)

View File

@ -78,7 +78,8 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
private SwitchCompat swAutoSaveDot;
private SwitchCompat swDiscardDelete;
private Spinner spSendDelayed;
private Spinner spAnswerAction;
private Spinner spAnswerActionSingle;
private Spinner spAnswerActionLong;
private Button btnSound;
private ViewButtonColor btnComposeColor;
@ -121,7 +122,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
"send_reminders", "send_chips", "send_pending",
"auto_save_paragraph", "auto_save_dot", "discard_delete",
"send_delayed",
"answer_action",
"answer_single", "answer_action",
"sound_sent",
"compose_color", "compose_font",
"prefix_once", "prefix_count", "alt_re", "alt_fwd",
@ -160,7 +161,8 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
swAutoSaveDot = view.findViewById(R.id.swAutoSaveDot);
swDiscardDelete = view.findViewById(R.id.swDiscardDelete);
spSendDelayed = view.findViewById(R.id.spSendDelayed);
spAnswerAction = view.findViewById(R.id.spAnswerAction);
spAnswerActionSingle = view.findViewById(R.id.spAnswerActionSingle);
spAnswerActionLong = view.findViewById(R.id.spAnswerActionLong);
btnSound = view.findViewById(R.id.btnSound);
btnComposeColor = view.findViewById(R.id.btnComposeColor);
@ -343,7 +345,20 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
}
});
spAnswerAction.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
spAnswerActionSingle.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) {
String[] values = getResources().getStringArray(R.array.answerValues);
prefs.edit().putString("answer_single", values[position]).apply();
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
prefs.edit().remove("answer_single").apply();
}
});
spAnswerActionLong.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) {
String[] values = getResources().getStringArray(R.array.answerValues);
@ -352,7 +367,7 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
@Override
public void onNothingSelected(AdapterView<?> parent) {
prefs.edit().remove("sender_ellipsize").apply();
prefs.edit().remove("answer_action").apply();
}
});
@ -726,12 +741,20 @@ public class FragmentOptionsSend extends FragmentBase implements SharedPreferenc
break;
}
String[] answerValues = getResources().getStringArray(R.array.answerValues);
String answer_default = prefs.getString("answer_single", "menu");
for (int pos = 0; pos < answerValues.length; pos++)
if (answerValues[pos].equals(answer_default)) {
spAnswerActionSingle.setSelection(pos);
break;
}
boolean reply_all = prefs.getBoolean("reply_all", false);
String answer_action = prefs.getString("answer_action", reply_all ? "reply_all" : "reply");
String[] answerValues = getResources().getStringArray(R.array.answerValues);
for (int pos = 0; pos < answerValues.length; pos++)
if (answerValues[pos].equals(answer_action)) {
spAnswerAction.setSelection(pos);
spAnswerActionLong.setSelection(pos);
break;
}

View File

@ -324,7 +324,29 @@
app:layout_constraintTop_toBottomOf="@id/tvSendDelayed" />
<TextView
android:id="@+id/tvAnswerAction"
android:id="@+id/tvAnswerActionSingle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:layout_marginEnd="48dp"
android:text="@string/title_advanced_answer_default"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?android:attr/textColorPrimary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/spSendDelayed" />
<Spinner
android:id="@+id/spAnswerActionSingle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:entries="@array/answerNames"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvAnswerActionSingle" />
<TextView
android:id="@+id/tvAnswerActionLong"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
@ -334,16 +356,16 @@
android:textColor="?android:attr/textColorPrimary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/spSendDelayed" />
app:layout_constraintTop_toBottomOf="@id/spAnswerActionSingle" />
<Spinner
android:id="@+id/spAnswerAction"
android:id="@+id/spAnswerActionLong"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:entries="@array/answerNames"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvAnswerAction" />
app:layout_constraintTop_toBottomOf="@id/tvAnswerActionLong" />
<Button
android:id="@+id/btnSound"
@ -355,7 +377,7 @@
android:drawablePadding="6dp"
android:text="@string/title_advanced_sound"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/spAnswerAction" />
app:layout_constraintTop_toBottomOf="@id/spAnswerActionLong" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>

View File

@ -435,6 +435,7 @@
<string name="title_advanced_send_reminders">Show reminders</string>
<string name="title_advanced_send_delayed">Delay sending messages</string>
<string name="title_advanced_attach_new">Add shared files to a new draft</string>
<string name="title_advanced_answer_default">Short pressing on the answer button will:</string>
<string name="title_advanced_answer_action">Long pressing on the answer button will:</string>
<string name="title_advanced_send_pending">Show non-obtrusive send delayed icon</string>
@ -1357,6 +1358,7 @@
<string name="title_reply_receipt">Send read receipt</string>
<string name="title_reply_hard_bounce">Send hard bounce</string>
<string name="title_reply_template">Reply with template</string>
<string name="title_reply_menu">Show selection menu</string>
<string name="title_move_undo">Moving to %1$s (%2$d)</string>
<string name="title_authentication_failed">%1$s authentication failed</string>
<string name="title_on_blocklist">On spam block list</string>
@ -2518,6 +2520,7 @@
<item>forward</item>
<item>resend</item>
<item>editasnew</item>
<item>menu</item>
</string-array>
<string-array name="answerNames" translatable="false">
@ -2527,6 +2530,7 @@
<item>@string/title_forward</item>
<item>@string/title_resend</item>
<item>@string/title_editasnew</item>
<item>@string/title_reply_menu</item>
</string-array>
<string-array name="contactTypes">