File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
app/src/main/java/it/niedermann/owncloud/notes/edit Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -68,6 +68,7 @@ public void run() {
6868 };
6969 private TextWatcher textWatcher ;
7070 private boolean keyboardShown = false ;
71+ private int lastSelection = -1 ;
7172
7273 @ Override
7374 public void onCreate (@ Nullable Bundle savedInstanceState ) {
@@ -151,6 +152,19 @@ public void afterTextChanged(final Editable s) {
151152 }
152153 }
153154 };
155+
156+ if (savedInstanceState != null ) {
157+ lastSelection = savedInstanceState .getInt ("lastSelection" , -1 );
158+ }
159+ }
160+
161+ @ Override
162+ public void onSaveInstanceState (@ NonNull Bundle outState ) {
163+ super .onSaveInstanceState (outState );
164+
165+ if (binding != null && binding .editContent .hasFocus ()) {
166+ outState .putInt ("lastSelection" , binding .editContent .getSelectionStart ());
167+ }
154168 }
155169
156170 @ Override
@@ -178,6 +192,10 @@ protected void onNoteLoaded(Note note) {
178192 if (sp .getBoolean (getString (R .string .pref_key_font ), false )) {
179193 binding .editContent .setTypeface (Typeface .MONOSPACE );
180194 }
195+
196+ if (lastSelection > 0 && binding .editContent .length () >= lastSelection ) {
197+ binding .editContent .setSelection (lastSelection );
198+ }
181199 }
182200
183201 private void openSoftKeyboard () {
You can’t perform that action at this time.
0 commit comments