diff --git a/app/src/main/java/eu/faircode/email/EditTextCompose.java b/app/src/main/java/eu/faircode/email/EditTextCompose.java index 2df020ec4c..a844e24d22 100644 --- a/app/src/main/java/eu/faircode/email/EditTextCompose.java +++ b/app/src/main/java/eu/faircode/email/EditTextCompose.java @@ -22,6 +22,7 @@ package eu.faircode.email; import android.content.ClipData; import android.content.ClipboardManager; import android.content.Context; +import android.content.SharedPreferences; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Build; @@ -44,6 +45,7 @@ import android.view.inputmethod.InputConnection; import androidx.core.view.inputmethod.EditorInfoCompat; import androidx.core.view.inputmethod.InputConnectionCompat; import androidx.core.view.inputmethod.InputContentInfoCompat; +import androidx.preference.PreferenceManager; import org.jsoup.nodes.Document; @@ -79,16 +81,17 @@ public class EditTextCompose extends FixedEditText { void init(Context context) { Helper.setKeyboardIncognitoMode(this, context); - if (BuildConfig.DEBUG && + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); + boolean undo_manager = prefs.getBoolean("undo_manager", false); + + if (undo_manager && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { setCustomInsertionActionModeCallback(new ActionMode.Callback() { @Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { - boolean undo = can(android.R.id.undo); - boolean redo = can(android.R.id.redo); - if (undo) + if (can(android.R.id.undo)) menu.add(Menu.CATEGORY_ALTERNATIVE, R.string.title_undo, 1, R.string.title_undo); - if (redo) + if (can(android.R.id.redo)) menu.add(Menu.CATEGORY_ALTERNATIVE, R.string.title_redo, 2, R.string.title_redo); return true; } diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java b/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java index 3d25b4a8c2..15b625a1ec 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java @@ -145,6 +145,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc private TextView tvChunkSize; private SeekBar sbChunkSize; private ImageButton ibSqliteCache; + private SwitchCompat swUndoManager; private SwitchCompat swWebViewLegacy; private SwitchCompat swModSeq; private SwitchCompat swExpunge; @@ -190,7 +191,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc "experiments", "crash_reports", "cleanup_attachments", "protocol", "debug", "log_level", "test1", "test2", "test3", "test4", "test5", "query_threads", "wal", "checkpoints", "sqlite_cache", - "chunk_size", "webview_legacy", + "chunk_size", "undo_manager", "webview_legacy", "use_modseq", "perform_expunge", "uid_expunge", "auth_plain", "auth_login", "auth_ntlm", "auth_sasl", "keep_alive_poll", "empty_pool", "idle_done", @@ -290,6 +291,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc ibSqliteCache = view.findViewById(R.id.ibSqliteCache); tvChunkSize = view.findViewById(R.id.tvChunkSize); sbChunkSize = view.findViewById(R.id.sbChunkSize); + swUndoManager = view.findViewById(R.id.swUndoManager); swWebViewLegacy = view.findViewById(R.id.swWebViewLegacy); swModSeq = view.findViewById(R.id.swModSeq); swExpunge = view.findViewById(R.id.swExpunge); @@ -884,6 +886,13 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc } }); + swUndoManager.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + prefs.edit().putBoolean("undo_manager", checked).apply(); + } + }); + swWebViewLegacy.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { @@ -1444,6 +1453,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc tvChunkSize.setText(getString(R.string.title_advanced_chunk_size, chunk_size)); sbChunkSize.setProgress(chunk_size); + swUndoManager.setChecked(prefs.getBoolean("undo_manager", false)); swWebViewLegacy.setChecked(prefs.getBoolean("webview_legacy", false)); swModSeq.setChecked(prefs.getBoolean("use_modseq", true)); swExpunge.setChecked(prefs.getBoolean("perform_expunge", true)); diff --git a/app/src/main/res/layout/fragment_options_misc.xml b/app/src/main/res/layout/fragment_options_misc.xml index c44e1ee11b..6eb6f3eda8 100644 --- a/app/src/main/res/layout/fragment_options_misc.xml +++ b/app/src/main/res/layout/fragment_options_misc.xml @@ -842,6 +842,18 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/tvChunkSize" /> + + Checkpoints Sqlite cache: %1$s %% - %2$s Chunk size: %1$d + Use Android\'s undo manager Old WebView behavior MODSEQ AUTO EXPUNGE