Allow disabling signature when composing

pull/162/head
M66B 5 years ago
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
@Database(
version = 98,
version = 99,
entities = {
EntityIdentity.class,
EntityAccount.class,
@ -992,6 +992,13 @@ public abstract class DB extends RoomDatabase {
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();
}

@ -396,6 +396,9 @@ public interface DaoMessage {
@Query("UPDATE message SET error = :error WHERE id = :id")
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")
int setMessageRevision(long id, Integer revision);

@ -119,6 +119,8 @@ public class EntityMessage implements Serializable {
public Boolean plain_only = null;
public Boolean encrypt = null;
public String preview;
@NonNull
public Boolean signature = true;
public Long sent; // compose = null
@NonNull
public Long received; // compose = stored

@ -84,6 +84,8 @@ import android.view.inputmethod.InputMethodManager;
import android.webkit.MimeTypeMap;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.FilterQueryProvider;
import android.widget.ImageButton;
@ -172,6 +174,7 @@ public class FragmentCompose extends FragmentBase {
private EditTextCompose etBody;
private TextView tvNoInternet;
private TextView tvSignature;
private CheckBox cbSignature;
private TextView tvReference;
private ImageButton ibCloseRefHint;
private ImageButton ibReferenceEdit;
@ -265,6 +268,7 @@ public class FragmentCompose extends FragmentBase {
etBody = view.findViewById(R.id.etBody);
tvNoInternet = view.findViewById(R.id.tvNoInternet);
tvSignature = view.findViewById(R.id.tvSignature);
cbSignature = view.findViewById(R.id.cbSignature);
tvReference = view.findViewById(R.id.tvReference);
ibCloseRefHint = view.findViewById(R.id.ibCloseRefHint);
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() {
@Override
public void onClick(View view) {
@ -2999,6 +3036,9 @@ public class FragmentCompose extends FragmentBase {
etBody.setSelection(0);
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");
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());

@ -252,7 +252,7 @@ public class MessageHelper {
body.append(mdoc.body().html());
// When sending message
if (identity != null) {
if (identity != null && message.signature) {
if (!TextUtils.isEmpty(identity.signature)) {
Document sdoc = Jsoup.parse(identity.signature);
if (sdoc.body() != null) {

@ -246,12 +246,21 @@
android:layout_marginTop="6dp"
android:layout_marginEnd="6dp"
android:fontFamily="monospace"
android:minHeight="24dp"
android:text="Signature"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintEnd_toStartOf="@+id/cbSignature"
app:layout_constraintStart_toStartOf="parent"
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
android:id="@+id/vSeparatorSignature"
android:layout_width="0dp"
@ -362,7 +371,7 @@
android:id="@+id/grpSignature"
android:layout_width="0dp"
android:layout_height="0dp"
app:constraint_referenced_ids="vSeparatorSignature,tvSignature" />
app:constraint_referenced_ids="vSeparatorSignature,tvSignature,cbSignature" />
<androidx.constraintlayout.widget.Group
android:id="@+id/grpReferenceHint"

Loading…
Cancel
Save