mirror of https://github.com/M66B/FairEmail.git
Added option to use template as read receipt
This commit is contained in:
parent
4835aec2ae
commit
317363793c
File diff suppressed because it is too large
Load Diff
|
@ -69,6 +69,7 @@ public class AdapterAnswer extends RecyclerView.Adapter<AdapterAnswer.ViewHolder
|
|||
private TextView tvGroup;
|
||||
private ImageView ivStandard;
|
||||
private ImageView ivFavorite;
|
||||
private ImageView ivReceipt;
|
||||
|
||||
private TwoStateOwner powner = new TwoStateOwner(owner, "RulePopup");
|
||||
|
||||
|
@ -80,6 +81,7 @@ public class AdapterAnswer extends RecyclerView.Adapter<AdapterAnswer.ViewHolder
|
|||
tvGroup = itemView.findViewById(R.id.tvGroup);
|
||||
ivStandard = itemView.findViewById(R.id.ivStandard);
|
||||
ivFavorite = itemView.findViewById(R.id.ivFavorite);
|
||||
ivReceipt = itemView.findViewById(R.id.ivReceipt);
|
||||
}
|
||||
|
||||
private void wire() {
|
||||
|
@ -99,6 +101,7 @@ public class AdapterAnswer extends RecyclerView.Adapter<AdapterAnswer.ViewHolder
|
|||
tvGroup.setVisibility(TextUtils.isEmpty(answer.group) ? View.GONE : View.VISIBLE);
|
||||
ivStandard.setVisibility(answer.standard ? View.VISIBLE : View.GONE);
|
||||
ivFavorite.setVisibility(answer.favorite ? View.VISIBLE : View.GONE);
|
||||
ivReceipt.setVisibility(answer.receipt ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -65,7 +65,7 @@ import static eu.faircode.email.ServiceAuthenticator.AUTH_TYPE_PASSWORD;
|
|||
// https://developer.android.com/topic/libraries/architecture/room.html
|
||||
|
||||
@Database(
|
||||
version = 194,
|
||||
version = 195,
|
||||
entities = {
|
||||
EntityIdentity.class,
|
||||
EntityAccount.class,
|
||||
|
@ -2001,6 +2001,12 @@ public abstract class DB extends RoomDatabase {
|
|||
Log.i("DB migration from version " + startVersion + " to " + endVersion);
|
||||
db.execSQL("ALTER TABLE `identity` ADD COLUMN `sender_extra_name` INTEGER NOT NULL DEFAULT 0");
|
||||
}
|
||||
}).addMigrations(new Migration(194, 195) {
|
||||
@Override
|
||||
public void migrate(@NonNull SupportSQLiteDatabase db) {
|
||||
Log.i("DB migration from version " + startVersion + " to " + endVersion);
|
||||
db.execSQL("ALTER TABLE `answer` ADD COLUMN `receipt` INTEGER NOT NULL DEFAULT 0");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -47,6 +47,10 @@ public interface DaoAnswer {
|
|||
" WHERE standard AND NOT hide")
|
||||
EntityAnswer getStandardAnswer();
|
||||
|
||||
@Query("SELECT * FROM answer" +
|
||||
" WHERE receipt AND NOT hide")
|
||||
EntityAnswer getReceiptAnswer();
|
||||
|
||||
@Query("SELECT * FROM answer" +
|
||||
" ORDER BY -favorite, name COLLATE NOCASE")
|
||||
LiveData<List<EntityAnswer>> liveAnswers();
|
||||
|
@ -67,6 +71,9 @@ public interface DaoAnswer {
|
|||
@Query("UPDATE answer SET standard = 0 WHERE NOT (standard IS 0)")
|
||||
void resetStandard();
|
||||
|
||||
@Query("UPDATE answer SET receipt = 0 WHERE NOT (receipt IS 0)")
|
||||
void resetReceipt();
|
||||
|
||||
@Query("DELETE FROM answer WHERE id = :id")
|
||||
void deleteAnswer(long id);
|
||||
}
|
||||
|
|
|
@ -54,6 +54,8 @@ public class EntityAnswer implements Serializable {
|
|||
@NonNull
|
||||
public Boolean favorite;
|
||||
@NonNull
|
||||
public Boolean receipt;
|
||||
@NonNull
|
||||
public Boolean hide;
|
||||
@NonNull
|
||||
public String text;
|
||||
|
@ -123,6 +125,7 @@ public class EntityAnswer implements Serializable {
|
|||
json.put("group", group);
|
||||
json.put("standard", standard);
|
||||
json.put("favorite", favorite);
|
||||
json.put("receipt", receipt);
|
||||
json.put("hide", hide);
|
||||
json.put("text", text);
|
||||
return json;
|
||||
|
@ -135,6 +138,7 @@ public class EntityAnswer implements Serializable {
|
|||
answer.group = json.optString("group");
|
||||
answer.standard = json.optBoolean("standard");
|
||||
answer.favorite = json.optBoolean("favorite");
|
||||
answer.receipt = json.optBoolean("receipt");
|
||||
answer.hide = json.optBoolean("hide");
|
||||
answer.text = json.getString("text");
|
||||
return answer;
|
||||
|
@ -148,6 +152,7 @@ public class EntityAnswer implements Serializable {
|
|||
Objects.equals(this.group, other.group) &&
|
||||
this.standard.equals(other.standard) &&
|
||||
this.favorite.equals(other.favorite) &&
|
||||
this.receipt.equals(other.receipt) &&
|
||||
this.hide.equals(other.hide) &&
|
||||
this.text.equals(other.text)
|
||||
);
|
||||
|
|
|
@ -59,6 +59,7 @@ public class FragmentAnswer extends FragmentBase {
|
|||
private EditText etGroup;
|
||||
private CheckBox cbStandard;
|
||||
private CheckBox cbFavorite;
|
||||
private CheckBox cbReceipt;
|
||||
private CheckBox cbHide;
|
||||
private EditTextCompose etText;
|
||||
private BottomNavigationView style_bar;
|
||||
|
@ -102,6 +103,7 @@ public class FragmentAnswer extends FragmentBase {
|
|||
etGroup = view.findViewById(R.id.etGroup);
|
||||
cbStandard = view.findViewById(R.id.cbStandard);
|
||||
cbFavorite = view.findViewById(R.id.cbFavorite);
|
||||
cbReceipt = view.findViewById(R.id.cbReceipt);
|
||||
cbHide = view.findViewById(R.id.cbHide);
|
||||
etText = view.findViewById(R.id.etText);
|
||||
|
||||
|
@ -190,6 +192,7 @@ public class FragmentAnswer extends FragmentBase {
|
|||
etGroup.setText(answer == null ? null : answer.group);
|
||||
cbStandard.setChecked(answer == null ? false : answer.standard);
|
||||
cbFavorite.setChecked(answer == null ? false : answer.favorite);
|
||||
cbReceipt.setChecked(answer == null ? false : answer.receipt);
|
||||
cbHide.setChecked(answer == null ? false : answer.hide);
|
||||
|
||||
String html = (answer == null ? a.getString("html") : answer.text);
|
||||
|
@ -303,6 +306,7 @@ public class FragmentAnswer extends FragmentBase {
|
|||
args.putString("group", etGroup.getText().toString().trim());
|
||||
args.putBoolean("standard", cbStandard.isChecked());
|
||||
args.putBoolean("favorite", cbFavorite.isChecked());
|
||||
args.putBoolean("receipt", cbReceipt.isChecked());
|
||||
args.putBoolean("hide", cbHide.isChecked());
|
||||
args.putString("html", HtmlHelper.toHtml(etText.getText(), getContext()));
|
||||
|
||||
|
@ -324,6 +328,7 @@ public class FragmentAnswer extends FragmentBase {
|
|||
String group = args.getString("group");
|
||||
boolean standard = args.getBoolean("standard");
|
||||
boolean favorite = args.getBoolean("favorite");
|
||||
boolean receipt = args.getBoolean("receipt");
|
||||
boolean hide = args.getBoolean("hide");
|
||||
String html = args.getString("html");
|
||||
|
||||
|
@ -340,6 +345,8 @@ public class FragmentAnswer extends FragmentBase {
|
|||
|
||||
if (standard)
|
||||
db.answer().resetStandard();
|
||||
if (receipt)
|
||||
db.answer().resetReceipt();
|
||||
|
||||
if (id < 0) {
|
||||
EntityAnswer answer = new EntityAnswer();
|
||||
|
@ -347,6 +354,7 @@ public class FragmentAnswer extends FragmentBase {
|
|||
answer.group = group;
|
||||
answer.standard = standard;
|
||||
answer.favorite = favorite;
|
||||
answer.receipt = receipt;
|
||||
answer.hide = hide;
|
||||
answer.text = document.body().html();
|
||||
answer.id = db.answer().insertAnswer(answer);
|
||||
|
@ -356,6 +364,7 @@ public class FragmentAnswer extends FragmentBase {
|
|||
answer.group = group;
|
||||
answer.standard = standard;
|
||||
answer.favorite = favorite;
|
||||
answer.receipt = receipt;
|
||||
answer.hide = hide;
|
||||
answer.text = document.body().html();
|
||||
db.answer().updateAnswer(answer);
|
||||
|
|
|
@ -3886,8 +3886,17 @@ public class FragmentCompose extends FragmentBase {
|
|||
String[] texts;
|
||||
if (EntityMessage.DSN_HARD_BOUNCE.equals(dsn))
|
||||
texts = new String[]{context.getString(R.string.title_hard_bounce_text)};
|
||||
else
|
||||
texts = Helper.getStrings(context, ref.language, R.string.title_receipt_text);
|
||||
else {
|
||||
EntityAnswer receipt = db.answer().getReceiptAnswer();
|
||||
if (receipt == null)
|
||||
texts = Helper.getStrings(context, ref.language, R.string.title_receipt_text);
|
||||
else {
|
||||
texts = new String[0];
|
||||
Document d = JsoupEx.parse(receipt.getText(null));
|
||||
document.body().append(d.body().html());
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < texts.length; i++) {
|
||||
if (i > 0)
|
||||
document.body()
|
||||
|
|
|
@ -72,6 +72,16 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/cbStandard" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/cbReceipt"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_marginTop="6dp"
|
||||
android:text="@string/title_answer_receipt"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/cbFavorite" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/cbHide"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -80,7 +90,7 @@
|
|||
android:layout_marginTop="6dp"
|
||||
android:text="@string/title_answer_hide"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/cbFavorite" />
|
||||
app:layout_constraintTop_toBottomOf="@+id/cbReceipt" />
|
||||
|
||||
<View
|
||||
android:id="@+id/vSeparator"
|
||||
|
|
|
@ -37,10 +37,20 @@
|
|||
android:maxLines="1"
|
||||
android:text="Group"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintEnd_toStartOf="@+id/ivStandard"
|
||||
app:layout_constraintEnd_toStartOf="@+id/ivReceipt"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tvName" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivReceipt"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="12dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/ivStandard"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:srcCompat="@drawable/twotone_playlist_add_check_24" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivStandard"
|
||||
android:layout_width="wrap_content"
|
||||
|
|
|
@ -1239,6 +1239,7 @@
|
|||
<string name="title_answer_group">Template group (optional)</string>
|
||||
<string name="title_answer_standard">Default</string>
|
||||
<string name="title_answer_favorite">Favorite</string>
|
||||
<string name="title_answer_receipt">Use as read receipt</string>
|
||||
<string name="title_answer_hide">Hide from menus</string>
|
||||
<string name="title_answer_text">Template text</string>
|
||||
<string name="title_answer_placeholder">Placeholder</string>
|
||||
|
|
Loading…
Reference in New Issue