mirror of https://github.com/M66B/FairEmail.git
Allow disabling signature when composing
This commit is contained in:
parent
afaab7c91f
commit
a3dbd6e9ed
File diff suppressed because it is too large
Load Diff
|
@ -58,7 +58,7 @@ import io.requery.android.database.sqlite.RequerySQLiteOpenHelperFactory;
|
||||||
// https://developer.android.com/topic/libraries/architecture/room.html
|
// https://developer.android.com/topic/libraries/architecture/room.html
|
||||||
|
|
||||||
@Database(
|
@Database(
|
||||||
version = 98,
|
version = 99,
|
||||||
entities = {
|
entities = {
|
||||||
EntityIdentity.class,
|
EntityIdentity.class,
|
||||||
EntityAccount.class,
|
EntityAccount.class,
|
||||||
|
@ -992,6 +992,13 @@ public abstract class DB extends RoomDatabase {
|
||||||
db.execSQL("ALTER TABLE `folder` ADD COLUMN `rename` TEXT");
|
db.execSQL("ALTER TABLE `folder` ADD COLUMN `rename` TEXT");
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
.addMigrations(new Migration(98, 99) {
|
||||||
|
@Override
|
||||||
|
public void migrate(@NonNull SupportSQLiteDatabase db) {
|
||||||
|
Log.i("DB migration from version " + startVersion + " to " + endVersion);
|
||||||
|
db.execSQL("ALTER TABLE `message` ADD COLUMN `signature` INTEGER NOT NULL DEFAULT 1");
|
||||||
|
}
|
||||||
|
})
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -396,6 +396,9 @@ public interface DaoMessage {
|
||||||
@Query("UPDATE message SET error = :error WHERE id = :id")
|
@Query("UPDATE message SET error = :error WHERE id = :id")
|
||||||
int setMessageError(long id, String error);
|
int setMessageError(long id, String error);
|
||||||
|
|
||||||
|
@Query("UPDATE message SET signature = :signature WHERE id = :id")
|
||||||
|
int setMessageSignature(long id, boolean signature);
|
||||||
|
|
||||||
@Query("UPDATE message SET revision = :revision WHERE id = :id")
|
@Query("UPDATE message SET revision = :revision WHERE id = :id")
|
||||||
int setMessageRevision(long id, Integer revision);
|
int setMessageRevision(long id, Integer revision);
|
||||||
|
|
||||||
|
|
|
@ -119,6 +119,8 @@ public class EntityMessage implements Serializable {
|
||||||
public Boolean plain_only = null;
|
public Boolean plain_only = null;
|
||||||
public Boolean encrypt = null;
|
public Boolean encrypt = null;
|
||||||
public String preview;
|
public String preview;
|
||||||
|
@NonNull
|
||||||
|
public Boolean signature = true;
|
||||||
public Long sent; // compose = null
|
public Long sent; // compose = null
|
||||||
@NonNull
|
@NonNull
|
||||||
public Long received; // compose = stored
|
public Long received; // compose = stored
|
||||||
|
|
|
@ -84,6 +84,8 @@ import android.view.inputmethod.InputMethodManager;
|
||||||
import android.webkit.MimeTypeMap;
|
import android.webkit.MimeTypeMap;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.CheckBox;
|
||||||
|
import android.widget.CompoundButton;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.FilterQueryProvider;
|
import android.widget.FilterQueryProvider;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
|
@ -172,6 +174,7 @@ public class FragmentCompose extends FragmentBase {
|
||||||
private EditTextCompose etBody;
|
private EditTextCompose etBody;
|
||||||
private TextView tvNoInternet;
|
private TextView tvNoInternet;
|
||||||
private TextView tvSignature;
|
private TextView tvSignature;
|
||||||
|
private CheckBox cbSignature;
|
||||||
private TextView tvReference;
|
private TextView tvReference;
|
||||||
private ImageButton ibCloseRefHint;
|
private ImageButton ibCloseRefHint;
|
||||||
private ImageButton ibReferenceEdit;
|
private ImageButton ibReferenceEdit;
|
||||||
|
@ -265,6 +268,7 @@ public class FragmentCompose extends FragmentBase {
|
||||||
etBody = view.findViewById(R.id.etBody);
|
etBody = view.findViewById(R.id.etBody);
|
||||||
tvNoInternet = view.findViewById(R.id.tvNoInternet);
|
tvNoInternet = view.findViewById(R.id.tvNoInternet);
|
||||||
tvSignature = view.findViewById(R.id.tvSignature);
|
tvSignature = view.findViewById(R.id.tvSignature);
|
||||||
|
cbSignature = view.findViewById(R.id.cbSignature);
|
||||||
tvReference = view.findViewById(R.id.tvReference);
|
tvReference = view.findViewById(R.id.tvReference);
|
||||||
ibCloseRefHint = view.findViewById(R.id.ibCloseRefHint);
|
ibCloseRefHint = view.findViewById(R.id.ibCloseRefHint);
|
||||||
ibReferenceEdit = view.findViewById(R.id.ibReferenceEdit);
|
ibReferenceEdit = view.findViewById(R.id.ibReferenceEdit);
|
||||||
|
@ -346,6 +350,39 @@ public class FragmentCompose extends FragmentBase {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
cbSignature.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putLong("id", working);
|
||||||
|
args.putBoolean("signature", checked);
|
||||||
|
|
||||||
|
new SimpleTask<Integer>() {
|
||||||
|
@Override
|
||||||
|
protected Integer onExecute(Context context, Bundle args) {
|
||||||
|
long id = args.getLong("id");
|
||||||
|
boolean signature = args.getBoolean("signature");
|
||||||
|
|
||||||
|
DB db = DB.getInstance(context);
|
||||||
|
return db.message().setMessageSignature(id, signature);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onExecuted(Bundle args, Integer count) {
|
||||||
|
if (count > 0) {
|
||||||
|
boolean signature = args.getBoolean("signature");
|
||||||
|
tvSignature.setAlpha(signature ? 1.0f : Helper.LOW_LIGHT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onException(Bundle args, Throwable ex) {
|
||||||
|
Helper.unexpectedError(getFragmentManager(), ex);
|
||||||
|
}
|
||||||
|
}.execute(FragmentCompose.this, args, "draft:signature");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
ibCloseRefHint.setOnClickListener(new View.OnClickListener() {
|
ibCloseRefHint.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
|
@ -2999,6 +3036,9 @@ public class FragmentCompose extends FragmentBase {
|
||||||
etBody.setSelection(0);
|
etBody.setSelection(0);
|
||||||
grpBody.setVisibility(View.VISIBLE);
|
grpBody.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
cbSignature.setChecked(draft.signature);
|
||||||
|
tvSignature.setAlpha(draft.signature ? 1.0f : Helper.LOW_LIGHT);
|
||||||
|
|
||||||
boolean ref_has_images = args.getBoolean("ref_has_images");
|
boolean ref_has_images = args.getBoolean("ref_has_images");
|
||||||
|
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||||
|
|
|
@ -252,7 +252,7 @@ public class MessageHelper {
|
||||||
body.append(mdoc.body().html());
|
body.append(mdoc.body().html());
|
||||||
|
|
||||||
// When sending message
|
// When sending message
|
||||||
if (identity != null) {
|
if (identity != null && message.signature) {
|
||||||
if (!TextUtils.isEmpty(identity.signature)) {
|
if (!TextUtils.isEmpty(identity.signature)) {
|
||||||
Document sdoc = Jsoup.parse(identity.signature);
|
Document sdoc = Jsoup.parse(identity.signature);
|
||||||
if (sdoc.body() != null) {
|
if (sdoc.body() != null) {
|
||||||
|
|
|
@ -246,12 +246,21 @@
|
||||||
android:layout_marginTop="6dp"
|
android:layout_marginTop="6dp"
|
||||||
android:layout_marginEnd="6dp"
|
android:layout_marginEnd="6dp"
|
||||||
android:fontFamily="monospace"
|
android:fontFamily="monospace"
|
||||||
|
android:minHeight="24dp"
|
||||||
android:text="Signature"
|
android:text="Signature"
|
||||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toStartOf="@+id/cbSignature"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/vSeparatorBody" />
|
app:layout_constraintTop_toBottomOf="@id/vSeparatorBody" />
|
||||||
|
|
||||||
|
<CheckBox
|
||||||
|
android:id="@+id/cbSignature"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@+id/tvSignature"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="@+id/tvSignature" />
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/vSeparatorSignature"
|
android:id="@+id/vSeparatorSignature"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
@ -362,7 +371,7 @@
|
||||||
android:id="@+id/grpSignature"
|
android:id="@+id/grpSignature"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
app:constraint_referenced_ids="vSeparatorSignature,tvSignature" />
|
app:constraint_referenced_ids="vSeparatorSignature,tvSignature,cbSignature" />
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.Group
|
<androidx.constraintlayout.widget.Group
|
||||||
android:id="@+id/grpReferenceHint"
|
android:id="@+id/grpReferenceHint"
|
||||||
|
|
Loading…
Reference in New Issue