Added read/delivery receipt type selection to identities

This commit is contained in:
M66B 2023-09-02 11:18:10 +02:00
parent 92a08fddb2
commit fa5bc2d313
8 changed files with 3031 additions and 4 deletions

File diff suppressed because it is too large Load Diff

View File

@ -68,7 +68,7 @@ import javax.mail.internet.InternetAddress;
// https://developer.android.com/topic/libraries/architecture/room.html
@Database(
version = 281,
version = 282,
entities = {
EntityIdentity.class,
EntityAccount.class,
@ -2847,8 +2847,13 @@ public abstract class DB extends RoomDatabase {
logMigration(startVersion, endVersion);
db.execSQL("ALTER TABLE `attachment` ADD COLUMN `section` TEXT");
}
})
.addMigrations(new Migration(998, 999) {
}).addMigrations(new Migration(281, 282) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {
logMigration(startVersion, endVersion);
db.execSQL("ALTER TABLE `identity` ADD COLUMN `receipt_type` INTEGER");
}
}).addMigrations(new Migration(998, 999) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {
logMigration(startVersion, endVersion);

View File

@ -121,6 +121,7 @@ public class EntityIdentity {
public Boolean encrypt_default = false;
@NonNull
public Integer encrypt = 0; // Default method 0=PGP 1=S/MIME
public Integer receipt_type;
@NonNull
public Boolean delivery_receipt = false; // obsolete
@NonNull
@ -381,6 +382,7 @@ public class EntityIdentity {
Objects.equals(i1.sign_default, other.sign_default) &&
Objects.equals(i1.encrypt_default, other.encrypt_default) &&
Objects.equals(i1.encrypt, other.encrypt) &&
Objects.equals(i1.receipt_type, other.receipt_type) &&
// delivery_receipt
// read_receipt
// store_sent

View File

@ -71,6 +71,7 @@ import com.google.android.material.textfield.TextInputLayout;
import java.io.FileNotFoundException;
import java.net.UnknownHostException;
import java.security.cert.X509Certificate;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@ -129,6 +130,7 @@ public class FragmentIdentity extends FragmentBase {
private TextView tvUriPro;
private CheckBox cbSignDefault;
private CheckBox cbEncryptDefault;
private Spinner spReceiptType;
private CheckBox cbUnicode;
private CheckBox cbOctetMime;
private EditText etMaxSize;
@ -233,6 +235,7 @@ public class FragmentIdentity extends FragmentBase {
tvUriPro = view.findViewById(R.id.tvUriPro);
cbSignDefault = view.findViewById(R.id.cbSignDefault);
cbEncryptDefault = view.findViewById(R.id.cbEncryptDefault);
spReceiptType = view.findViewById(R.id.spReceiptType);
cbUnicode = view.findViewById(R.id.cbUnicode);
cbOctetMime = view.findViewById(R.id.cbOctetMime);
etMaxSize = view.findViewById(R.id.etMaxSize);
@ -510,6 +513,12 @@ public class FragmentIdentity extends FragmentBase {
}
});
ArrayList<String> receiptNames = new ArrayList<>(Arrays.asList(getResources().getStringArray(R.array.receiptNames)));
receiptNames.add(0, getString(R.string.title_global_default));
ArrayAdapter<String> adapter = new ArrayAdapter<>(getContext(), R.layout.spinner_item1, android.R.id.text1, receiptNames);
adapter.setDropDownViewResource(R.layout.spinner_item1_dropdown);
spReceiptType.setAdapter(adapter);
btnSave.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -735,6 +744,7 @@ public class FragmentIdentity extends FragmentBase {
args.putString("uri", (String) btnUri.getTag());
args.putBoolean("sign_default", cbSignDefault.isChecked());
args.putBoolean("encrypt_default", cbEncryptDefault.isChecked());
args.putInt("receipt_type", spReceiptType.getSelectedItemPosition() - 1);
args.putBoolean("unicode", cbUnicode.isChecked());
args.putBoolean("octetmime", cbOctetMime.isChecked());
args.putString("max_size", etMaxSize.getText().toString());
@ -820,6 +830,7 @@ public class FragmentIdentity extends FragmentBase {
String uri = args.getString("uri");
boolean sign_default = args.getBoolean("sign_default");
boolean encrypt_default = args.getBoolean("encrypt_default");
Integer receipt_type = args.getInt("receipt_type");
boolean unicode = args.getBoolean("unicode");
boolean octetmime = args.getBoolean("octetmime");
String max_size = args.getString("max_size");
@ -909,6 +920,9 @@ public class FragmentIdentity extends FragmentBase {
if (TextUtils.isEmpty(signature))
signature = null;
if (receipt_type < 0)
receipt_type = null;
Long user_max_size = (TextUtils.isEmpty(max_size) ? null : Integer.parseInt(max_size) * 1000 * 1000L);
DB db = DB.getInstance(context);
@ -982,6 +996,8 @@ public class FragmentIdentity extends FragmentBase {
return true;
if (!Objects.equals(identity.encrypt_default, encrypt_default))
return true;
if (!Objects.equals(identity.receipt_type, receipt_type))
return true;
if (!Objects.equals(identity.unicode, unicode))
return true;
if (!Objects.equals(identity.octetmime, octetmime))
@ -1084,6 +1100,7 @@ public class FragmentIdentity extends FragmentBase {
identity.uri = uri;
identity.sign_default = sign_default;
identity.encrypt_default = encrypt_default;
identity.receipt_type = receipt_type;
identity.unicode = unicode;
identity.octetmime = octetmime;
identity.sent_folder = null;
@ -1271,6 +1288,7 @@ public class FragmentIdentity extends FragmentBase {
etInternal.setText(identity == null ? null : identity.internal);
btnUri.setTag(identity == null ? null : identity.uri);
tvUriInfo.setText(identity == null ? null : getUriInfo(identity.uri));
spReceiptType.setSelection(identity == null || identity.receipt_type == null ? 0 : identity.receipt_type + 1);
cbSignDefault.setChecked(identity != null && identity.sign_default);
cbEncryptDefault.setChecked(identity != null && identity.encrypt_default);
cbUnicode.setChecked(identity != null && identity.unicode);

View File

@ -336,6 +336,9 @@ public class MessageHelper {
boolean encrypt_subject = prefs.getBoolean("encrypt_subject", false);
boolean forward_new = prefs.getBoolean("forward_new", true);
if (identity != null && identity.receipt_type != null)
receipt_type = identity.receipt_type;
Map<String, String> c = new HashMap<>();
c.put("id", message.id == null ? null : Long.toString(message.id));
c.put("encrypt", message.encrypt + "/" + message.ui_encrypt);

View File

@ -759,6 +759,8 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar
if (message.receipt_request != null && message.receipt_request) {
int receipt_type = prefs.getInt("receipt_type", 2);
if (ident.receipt_type != null)
receipt_type = ident.receipt_type;
if (receipt_type == 1 || receipt_type == 2) // Delivery receipt
iservice.setDsnNotify("SUCCESS,FAILURE,DELAY");
}

View File

@ -848,6 +848,28 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbSignDefault" />
<TextView
android:id="@+id/tvReceiptType"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:layout_marginEnd="48dp"
android:text="@string/title_advanced_receipt"
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/cbEncryptDefault" />
<Spinner
android:id="@+id/spReceiptType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:entries="@array/receiptNames"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvReceiptType" />
<CheckBox
android:id="@+id/cbUnicode"
android:layout_width="wrap_content"
@ -855,7 +877,7 @@
android:layout_marginTop="12dp"
android:text="@string/title_identity_unicode"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbEncryptDefault" />
app:layout_constraintTop_toBottomOf="@id/spReceiptType" />
<TextView
android:id="@+id/tvUnicodeHint"
@ -1032,6 +1054,7 @@
tvInternal,etInternal,tvInternalHint,
btnUri,tvUriHint,tvUriInfo,tvUriPro,
tvE2Encryption,cbSignDefault,cbEncryptDefault,
tvReceiptType,spReceiptType,
cbUnicode,tvUnicodeHint,cbOctetMime,tvMaxSize,etMaxSize" />
<androidx.constraintlayout.widget.Group

View File

@ -2225,6 +2225,7 @@
<string name="title_loading">Loading &#8230;</string>
<string name="title_fetching_again">Fetching message again from the server</string>
<string name="title_go_back">Go back</string>
<string name="title_global_default">Use global default</string>
<string name="title_conversation_actions">Actions</string>
<string name="title_conversation_action_reply">Reply with: \'%1$s\'</string>