Added default sensitivity for identities

pull/214/head
M66B 1 year ago
parent 59cba42699
commit e8f36b6682

File diff suppressed because it is too large Load Diff

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

@ -127,6 +127,8 @@ public class EntityIdentity {
@NonNull
public Boolean read_receipt = false; // obsolete
@NonNull
public Integer sensitivity = 0; // Normal
@NonNull
public Boolean store_sent = false; // obsolete
public Long sent_folder = null; // obsolete
public Long sign_key = null; // OpenPGP

@ -1492,6 +1492,8 @@ public class FragmentCompose extends FragmentBase {
db.message().setMessageUiEncrypt(draft.id, draft.ui_encrypt);
db.message().setMessageSensitivity(draft.id, identity.sensitivity < 1 ? null : identity.sensitivity);
return draft.ui_encrypt;
}
@ -5449,6 +5451,8 @@ public class FragmentCompose extends FragmentBase {
if (receipt_default)
data.draft.receipt_request = true;
data.draft.sensitivity = (selected.sensitivity < 1 ? null : selected.sensitivity);
Document document = Document.createShell("");
if (ref == null) {

@ -131,6 +131,7 @@ public class FragmentIdentity extends FragmentBase {
private CheckBox cbSignDefault;
private CheckBox cbEncryptDefault;
private Spinner spReceiptType;
private Spinner spSensitivity;
private CheckBox cbUnicode;
private CheckBox cbOctetMime;
private EditText etMaxSize;
@ -236,6 +237,7 @@ public class FragmentIdentity extends FragmentBase {
cbSignDefault = view.findViewById(R.id.cbSignDefault);
cbEncryptDefault = view.findViewById(R.id.cbEncryptDefault);
spReceiptType = view.findViewById(R.id.spReceiptType);
spSensitivity = view.findViewById(R.id.spSensitivity);
cbUnicode = view.findViewById(R.id.cbUnicode);
cbOctetMime = view.findViewById(R.id.cbOctetMime);
etMaxSize = view.findViewById(R.id.etMaxSize);
@ -515,9 +517,9 @@ 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);
ArrayAdapter<String> radapter = new ArrayAdapter<>(getContext(), R.layout.spinner_item1, android.R.id.text1, receiptNames);
radapter.setDropDownViewResource(R.layout.spinner_item1_dropdown);
spReceiptType.setAdapter(radapter);
btnSave.setOnClickListener(new View.OnClickListener() {
@Override
@ -745,6 +747,7 @@ public class FragmentIdentity extends FragmentBase {
args.putBoolean("sign_default", cbSignDefault.isChecked());
args.putBoolean("encrypt_default", cbEncryptDefault.isChecked());
args.putInt("receipt_type", spReceiptType.getSelectedItemPosition() - 1);
args.putInt("sensitivity", spSensitivity.getSelectedItemPosition());
args.putBoolean("unicode", cbUnicode.isChecked());
args.putBoolean("octetmime", cbOctetMime.isChecked());
args.putString("max_size", etMaxSize.getText().toString());
@ -831,6 +834,7 @@ public class FragmentIdentity extends FragmentBase {
boolean sign_default = args.getBoolean("sign_default");
boolean encrypt_default = args.getBoolean("encrypt_default");
Integer receipt_type = args.getInt("receipt_type");
int sensitivity = args.getInt("sensitivity");
boolean unicode = args.getBoolean("unicode");
boolean octetmime = args.getBoolean("octetmime");
String max_size = args.getString("max_size");
@ -998,6 +1002,8 @@ public class FragmentIdentity extends FragmentBase {
return true;
if (!Objects.equals(identity.receipt_type, receipt_type))
return true;
if (!Objects.equals(identity.sensitivity, sensitivity))
return true;
if (!Objects.equals(identity.unicode, unicode))
return true;
if (!Objects.equals(identity.octetmime, octetmime))
@ -1101,6 +1107,7 @@ public class FragmentIdentity extends FragmentBase {
identity.sign_default = sign_default;
identity.encrypt_default = encrypt_default;
identity.receipt_type = receipt_type;
identity.sensitivity = sensitivity;
identity.unicode = unicode;
identity.octetmime = octetmime;
identity.sent_folder = null;
@ -1289,6 +1296,7 @@ public class FragmentIdentity extends FragmentBase {
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);
spSensitivity.setSelection(identity == null ? 0 : identity.sensitivity);
cbSignDefault.setChecked(identity != null && identity.sign_default);
cbEncryptDefault.setChecked(identity != null && identity.encrypt_default);
cbUnicode.setChecked(identity != null && identity.unicode);

@ -867,11 +867,30 @@
android:id="@+id/spReceiptType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:layout_marginTop="6dp"
android:entries="@array/receiptNames"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvReceiptType" />
<TextView
android:id="@+id/tvSensitivity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_send_sensitivity"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/spReceiptType" />
<Spinner
android:id="@+id/spSensitivity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:entries="@array/sensitivityNames"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvSensitivity" />
<CheckBox
android:id="@+id/cbUnicode"
android:layout_width="wrap_content"
@ -879,7 +898,7 @@
android:layout_marginTop="12dp"
android:text="@string/title_identity_unicode"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/spReceiptType" />
app:layout_constraintTop_toBottomOf="@id/spSensitivity" />
<TextView
android:id="@+id/tvUnicodeHint"
@ -1057,6 +1076,7 @@
btnUri,tvUriHint,tvUriInfo,tvUriPro,
tvE2Encryption,cbSignDefault,cbEncryptDefault,
tvReceiptType,spReceiptType,
tvSensitivity,spSensitivity,
cbUnicode,tvUnicodeHint,cbOctetMime,tvMaxSize,etMaxSize" />
<androidx.constraintlayout.widget.Group

Loading…
Cancel
Save