mirror of https://github.com/M66B/FairEmail.git
Signature save changes
This commit is contained in:
parent
d88d158f64
commit
6439d6d107
|
@ -32,8 +32,10 @@ import android.text.Editable;
|
|||
import android.text.Html;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.Spanned;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.text.style.ImageSpan;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
|
@ -53,6 +55,8 @@ import com.google.android.material.snackbar.Snackbar;
|
|||
|
||||
import org.jsoup.nodes.Document;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class ActivitySignature extends ActivityBase {
|
||||
private ViewGroup view;
|
||||
private EditTextCompose etText;
|
||||
|
@ -131,6 +135,43 @@ public class ActivitySignature extends ActivityBase {
|
|||
}
|
||||
});
|
||||
|
||||
addKeyPressedListener(new IKeyPressedListener() {
|
||||
@Override
|
||||
public boolean onKeyPressed(KeyEvent event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBackPressed() {
|
||||
String prev = getIntent().getStringExtra("html");
|
||||
String current = getHtml();
|
||||
boolean dirty = !Objects.equals(prev, current) &&
|
||||
!(TextUtils.isEmpty(prev) && TextUtils.isEmpty(current));
|
||||
|
||||
if (dirty)
|
||||
new AlertDialog.Builder(ActivitySignature.this)
|
||||
.setTitle(R.string.title_ask_save)
|
||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
save();
|
||||
finish();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
finish();
|
||||
}
|
||||
})
|
||||
.show();
|
||||
else
|
||||
finish();
|
||||
|
||||
return true;
|
||||
}
|
||||
}, this);
|
||||
|
||||
if (savedInstanceState != null)
|
||||
etText.setRaw(savedInstanceState.getBoolean("fair:raw"));
|
||||
|
||||
|
|
Loading…
Reference in New Issue