Share filters with web client (#956)

* First step toward synchronized content filters

* Add simple filter management UI

* Remove old regex filter UI

* More cleanup

* Escape filter phrases when applying them via regex

* Apply code review feedback

* Fix live timeline update when filters change
This commit is contained in:
Levi Bard 2019-03-20 19:25:26 +01:00 committed by Konrad Pozniak
commit 5135daad2c
13 changed files with 439 additions and 91 deletions

View file

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/activityFilters"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.keylesspalace.tusky.FiltersActivity">
<include layout="@layout/toolbar_basic" />
<ListView
android:id="@+id/filtersView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/filter_floating_add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:contentDescription="@string/filter_addition_dialog_title"
app:layout_anchor="@id/filtersView"
app:layout_anchorGravity="bottom|end"
android:src="@drawable/ic_plus_24dp"
/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View file

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="16dp">
<EditText
android:id="@+id/phraseEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingEnd="24dp"
android:paddingStart="24dp"
android:hint="@string/filter_add_description"
app:layout_constraintTop_toTopOf="parent"
/>
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -199,6 +199,7 @@
<string name="pref_title_appearance_settings">Appearance</string>
<string name="pref_title_app_theme">App Theme</string>
<string name="pref_title_timelines">Timelines</string>
<string name="pref_title_timeline_filters">Filters</string>
<string-array name="app_theme_names">
<item>Dark</item>
@ -216,7 +217,6 @@
<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">Download media previews</string>
<string name="pref_title_proxy_settings">Proxy</string>
<string name="pref_title_http_proxy_settings">HTTP proxy</string>
@ -319,6 +319,14 @@
<string name="replying_to">Replying to @%s</string>
<string name="load_more_placeholder_text">load more</string>
<string name="pref_title_public_filter_keywords">Public timelines</string>
<string name="pref_title_thread_filter_keywords">Conversations</string>
<string name="filter_addition_dialog_title">Add filter</string>
<string name="filter_edit_dialog_title">Edit filter</string>
<string name="filter_dialog_remove_button">Remove</string>
<string name="filter_dialog_update_button">Update</string>
<string name="filter_add_description">Phrase to filter</string>
<string name="add_account_name">Add Account</string>
<string name="add_account_description">Add new Mastodon Account</string>

View file

@ -45,7 +45,23 @@
<SwitchPreference
android:key="alwaysShowSensitiveMedia"
android:title="@string/pref_title_alway_show_sensitive_media" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/pref_title_timeline_filters">
<Preference
android:key="publicFilters"
android:title="@string/pref_title_public_filter_keywords"
/>
<Preference
android:key="notificationFilters"
android:title="@string/title_notifications"
/>
<Preference
android:key="homeFilters"
android:title="@string/title_home"
/>
<Preference
android:key="threadFilters"
android:title="@string/pref_title_thread_filter_keywords"
/>
</PreferenceCategory>
</PreferenceScreen>

View file

@ -17,15 +17,4 @@
android:title="@string/pref_title_show_replies"
app:iconSpaceReserved="false" />
</PreferenceCategory>
<PreferenceCategory
android:title="@string/title_advanced"
app:iconSpaceReserved="false">
<Preference
android:inputType="textNoSuggestions"
android:key="tabFilterRegex"
android:title="@string/pref_title_filter_regex"
app:iconSpaceReserved="false" />
</PreferenceCategory>
</PreferenceScreen>