PPartisan / RunDo

Adds Undo/Redo functionality to editable text fields in Android.
MIT License
13 stars 4 forks source link

After rotation (on resume), undo and redo are not working #6

Open sepulzera opened 4 years ago

sepulzera commented 4 years ago

Prerequisites:

I have an activity with a fragmentPager and fragments, compiled against SDK28. But i assume the bug could be reproduced with every activity using RunDo.

Description

Change the text of the linked EditText. Then rotate the device. The activity and thus RunDo(Support) get rebuild. But RunDo is in a broken state: neither undo nor redo will work. Even when changing the linked EditText's text again.

I think the bug is happening on this line: https://github.com/PPartisan/RunDo/blob/7b2bde8615824848d5646d6106124b39ec9b24a5/rundo/src/main/java/com/werdpressed/partisan/rundo/RunDoSupport.java#L82

RunDo gets instantiated with TRACKING_ENDED, what would work fine. https://github.com/PPartisan/RunDo/blob/7b2bde8615824848d5646d6106124b39ec9b24a5/rundo/src/main/java/com/werdpressed/partisan/rundo/RunDoSupport.java#L33-L41

But when resuming, it is set on TRACKING_STARTED, leaving RunDo in a somewhat illegal state.