mirror of
https://github.com/nextcloud/notes-android.git
synced 2024-11-21 12:25:57 +03:00
Restore selection
This commit is contained in:
parent
ab6c78ec80
commit
b7d56765de
1 changed files with 18 additions and 0 deletions
|
@ -68,6 +68,7 @@ public class NoteEditFragment extends SearchableBaseNoteFragment {
|
|||
};
|
||||
private TextWatcher textWatcher;
|
||||
private boolean keyboardShown = false;
|
||||
private int lastSelection = -1;
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
|
@ -151,6 +152,19 @@ public class NoteEditFragment extends SearchableBaseNoteFragment {
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
lastSelection = savedInstanceState.getInt("lastSelection", -1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
|
||||
if (binding.editContent != null && binding.editContent.hasFocus()) {
|
||||
outState.putInt("lastSelection", binding.editContent.getSelectionStart());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -178,6 +192,10 @@ public class NoteEditFragment extends SearchableBaseNoteFragment {
|
|||
if (sp.getBoolean(getString(R.string.pref_key_font), false)) {
|
||||
binding.editContent.setTypeface(Typeface.MONOSPACE);
|
||||
}
|
||||
|
||||
if (lastSelection > 0 && binding.editContent.length() >= lastSelection) {
|
||||
binding.editContent.setSelection(lastSelection);
|
||||
}
|
||||
}
|
||||
|
||||
private void openSoftKeyboard() {
|
||||
|
|
Loading…
Reference in a new issue