TrianguloY / URLCheck

Android app by TrianguloY: URLCheck
Other
969 stars 57 forks source link

Add a delay before analysing URLs #356

Closed CloneWith closed 1 week ago

CloneWith commented 6 months ago

Problem

When typing in the URL textbox, the URL view updates every time a character was typed.

This would lead to problems such as the log file and the history list is too long, or performance issues especially when a bunch of characters got deleted by pressing the Backspace key (instead of select and delete), which is common among mobile device users.

Suggestion

We can add a delay feature to the textbox, which let the application to wait for a while (maybe around 0.5 seconds) to let users complete their changes before analysing the URL and adding it to the log and history.

Alternative

We can also use an event to trigger the update of the view, such as:

Acknowledgements

TrianguloY commented 6 months ago

There is in fact special logic that marks some url changes (currently used only by the input text module) as "modifications of the previous url". But I think only the history module uses it to "replace" the previous url with that one.

You can easily test this by editing a url (writing or deleting characters quickly) and checking the history list (middle "clock" button). Only the last url will appear.

The issue with this approach is that, since it is a "modify the past" approach, modules in general can't react to it (they don't know if there will be a next input or not) so I also agree that replacing it with a "only send modifications after a small period of inactivity" should be done. The main reasons I haven't done that yet is that it will require a background task (which I still don't properly know how to implement) and I personally like that it updates automatically.

As for your suggestions, the button approach could work perfectly with #100, and I'm not sure now how to detect the keyboard hiding, but detecting focus out of the textbox should be perfectly possible. Detecting a line break is a bit more problematic (what if the original text has one?) but you should be able to detect the "apply" keyboard button easily instead.

TrianguloY commented 1 week ago

Forgot to update this.

This was finally implemented in 6ae815ec084885396c42023def81c3164bd81e8e as a full popup that is opened when the url is clicked (also, the keyboard is automatically shown and the cursor is placed exactly where you clicked, or selecting the full url if you long clicked). This popup contains buttons for accept or cancel the url edit, thus solving the issue of 'triggering updates (in particular, the new automations) for each character.