Add regular expression feed filtering (#557)

* Initial implementation of regex feed filtering

Mimics Mastodon web's functionality, but in a simpler form; a single
regular expression is shared across the home, local and federated feeds.

Strings are currently only provided in English and will need to be
translated.

* Fix buggy behaviour on filter regex update

* Validate regex filter input

Fixes buggy behaviour on inputting a regular expression feed filter by
testing the expression continuously as the user types, displaying an
error and disabling the 'OK' button of the dialog at any time it's not a
valid regular expression. Disables spelling suggestions in the input to
make the experience less frustrating and error prone.

Also fixes some generally buggy behaviour upon preference change,
specifically in cases where no Matcher was set prior to a new pattern
being set, which would cause the app to crash.

* Apply regex filter to spoiler text

* Get rid of empty catch block in regex filter code

* Make regex filter error string translatable
This commit is contained in:
Gareth Murphy 2018-04-05 21:58:44 +01:00 committed by Konrad Pozniak
commit 6d6c9575c4
4 changed files with 68 additions and 1 deletions

View file

@ -17,8 +17,10 @@
<string name="error_media_upload_image_or_video">Images and videos cannot both be attached to the same status.</string>
<string name="error_media_upload_sending">The upload failed.</string>
<string name="error_report_too_few_statuses">At least one status must be reported.</string>
<string name="error_invalid_regex">Invalid regular expression</string>
<string name="title_home">Home</string>
<string name="title_advanced">Advanced</string>
<string name="title_notifications">Notifications</string>
<string name="title_public_local">Local</string>
<string name="title_public_federated">Federated</string>
@ -177,6 +179,7 @@
<string name="pref_title_status_tabs">Tabs</string>
<string name="pref_title_show_boosts">Show boosts</string>
<string name="pref_title_show_replies">Show replies</string>
<string name="pref_title_filter_regex">Filter out by regular expressions</string>
<string name="pref_title_show_media_preview">Show media previews</string>
<string name="pref_title_proxy_settings">Proxy</string>
<string name="pref_title_http_proxy_settings">HTTP proxy</string>