diff --git a/app/src/main/java/app/fedilab/android/activities/FilterActivity.java b/app/src/main/java/app/fedilab/android/activities/FilterActivity.java
index 45991b3d..552debd3 100644
--- a/app/src/main/java/app/fedilab/android/activities/FilterActivity.java
+++ b/app/src/main/java/app/fedilab/android/activities/FilterActivity.java
@@ -120,6 +120,9 @@ public class FilterActivity extends BaseActivity implements FilterAdapter.Delete
case "thread":
popupAddFilterBinding.contextConversation.setChecked(true);
break;
+ case "account":
+ popupAddFilterBinding.contextProfiles.setChecked(true);
+ break;
}
}
popupAddFilterBinding.contextWholeWord.setChecked(filter.whole_word);
@@ -137,7 +140,7 @@ public class FilterActivity extends BaseActivity implements FilterAdapter.Delete
popupAddFilterBinding.addPhrase.setError(context.getString(R.string.cannot_be_empty));
return;
}
- if (!popupAddFilterBinding.contextConversation.isChecked() && !popupAddFilterBinding.contextHome.isChecked() && !popupAddFilterBinding.contextPublic.isChecked() && !popupAddFilterBinding.contextNotification.isChecked()) {
+ if (!popupAddFilterBinding.contextConversation.isChecked() && !popupAddFilterBinding.contextHome.isChecked() && !popupAddFilterBinding.contextPublic.isChecked() && !popupAddFilterBinding.contextNotification.isChecked() && !popupAddFilterBinding.contextProfiles.isChecked()) {
popupAddFilterBinding.contextDescription.setError(context.getString(R.string.cannot_be_empty));
return;
}
@@ -152,6 +155,8 @@ public class FilterActivity extends BaseActivity implements FilterAdapter.Delete
contextFilter.add("notifications");
if (popupAddFilterBinding.contextConversation.isChecked())
contextFilter.add("thread");
+ if (popupAddFilterBinding.contextProfiles.isChecked())
+ contextFilter.add("account");
filterSent.context = contextFilter;
filterSent.expires_at_sent = expire[0];
filterSent.phrase = popupAddFilterBinding.addPhrase.getText().toString();
diff --git a/app/src/main/java/app/fedilab/android/helper/TimelineHelper.java b/app/src/main/java/app/fedilab/android/helper/TimelineHelper.java
index ed1f39b9..06e48014 100644
--- a/app/src/main/java/app/fedilab/android/helper/TimelineHelper.java
+++ b/app/src/main/java/app/fedilab/android/helper/TimelineHelper.java
@@ -26,6 +26,7 @@ import androidx.lifecycle.ViewModelStoreOwner;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Date;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
@@ -91,63 +92,76 @@ public class TimelineHelper {
}
//If there are filters:
if (BaseMainActivity.mainFilters != null && BaseMainActivity.mainFilters.size() > 0 && statuses != null && statuses.size() > 0) {
+
+ //Loop through filters
for (Filter filter : BaseMainActivity.mainFilters) {
+ if (filter.expires_at != null && filter.expires_at.before(new Date())) {
+ //Expired filter
+ continue;
+ }
- for (String filterContext : filter.context) {
- if (filterTimeLineType.getValue().equalsIgnoreCase(filterContext)) {
- if (filter.whole_word) {
+ if (filterTimeLineType == Timeline.TimeLineEnum.HOME) {
+ if (!filter.context.contains("home")) continue;
+ } else if (filterTimeLineType == Timeline.TimeLineEnum.NOTIFICATION) {
+ if (!filter.context.contains("notification")) continue;
+ } else if (filterTimeLineType == Timeline.TimeLineEnum.CONTEXT) {
+ if (!filter.context.contains("thread")) continue;
+ } else if (filterTimeLineType == Timeline.TimeLineEnum.ACCOUNT_TIMELINE) {
+ if (!filter.context.contains("account")) continue;
+ } else {
+ if (!filter.context.contains("public")) continue;
+ }
- Pattern p = Pattern.compile("\\b(" + Pattern.quote(filter.phrase) + ")\\b", Pattern.CASE_INSENSITIVE);
- for (Status status : statuses) {
- String content;
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
- content = Html.fromHtml(status.reblog != null ? status.reblog.content : status.content, Html.FROM_HTML_MODE_LEGACY).toString();
- else
- content = Html.fromHtml(status.reblog != null ? status.reblog.content : status.content).toString();
-
- Matcher m = p.matcher(content);
- if (m.find()) {
- statusesToRemove.add(status);
- continue;
- }
- if (status.spoiler_text != null) {
- String spoilerText;
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
- spoilerText = Html.fromHtml(status.reblog != null ? status.reblog.spoiler_text : status.spoiler_text, Html.FROM_HTML_MODE_LEGACY).toString();
- else
- spoilerText = Html.fromHtml(status.reblog != null ? status.reblog.spoiler_text : status.spoiler_text).toString();
- Matcher ms = p.matcher(spoilerText);
- if (ms.find()) {
- statusesToRemove.add(status);
- }
- }
+ if (filter.whole_word) {
+ Pattern p = Pattern.compile("(^|\\W)(" + Pattern.quote(filter.phrase) + ")($|\\W)", Pattern.CASE_INSENSITIVE);
+ for (Status status : statuses) {
+ String content;
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
+ content = Html.fromHtml(status.reblog != null ? status.reblog.content : status.content, Html.FROM_HTML_MODE_LEGACY).toString();
+ else
+ content = Html.fromHtml(status.reblog != null ? status.reblog.content : status.content).toString();
+ Matcher m = p.matcher(content);
+ if (m.find()) {
+ statusesToRemove.add(status);
+ continue;
+ }
+ if (status.spoiler_text != null) {
+ String spoilerText;
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
+ spoilerText = Html.fromHtml(status.reblog != null ? status.reblog.spoiler_text : status.spoiler_text, Html.FROM_HTML_MODE_LEGACY).toString();
+ else
+ spoilerText = Html.fromHtml(status.reblog != null ? status.reblog.spoiler_text : status.spoiler_text).toString();
+ Matcher ms = p.matcher(spoilerText);
+ if (ms.find()) {
+ statusesToRemove.add(status);
}
- } else {
- for (Status status : statuses) {
- String content;
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
- content = Html.fromHtml(status.reblog != null ? status.reblog.content : status.content, Html.FROM_HTML_MODE_LEGACY).toString();
- else
- content = Html.fromHtml(status.reblog != null ? status.reblog.content : status.content).toString();
- if (content.contains(filter.phrase)) {
- statusesToRemove.add(status);
- continue;
- }
+ }
+ }
+ } else {
+ for (Status status : statuses) {
+ String content;
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
+ content = Html.fromHtml(status.reblog != null ? status.reblog.content : status.content, Html.FROM_HTML_MODE_LEGACY).toString();
+ else
+ content = Html.fromHtml(status.reblog != null ? status.reblog.content : status.content).toString();
+ if (content.contains(filter.phrase)) {
+ statusesToRemove.add(status);
+ continue;
+ }
- if (status.spoiler_text != null) {
- String spoilerText;
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
- spoilerText = Html.fromHtml(status.reblog != null ? status.reblog.spoiler_text : status.spoiler_text, Html.FROM_HTML_MODE_LEGACY).toString();
- else
- spoilerText = Html.fromHtml(status.reblog != null ? status.reblog.spoiler_text : status.spoiler_text).toString();
- if (spoilerText.contains(filter.phrase)) {
- statusesToRemove.add(status);
- }
- }
+ if (status.spoiler_text != null) {
+ String spoilerText;
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
+ spoilerText = Html.fromHtml(status.reblog != null ? status.reblog.spoiler_text : status.spoiler_text, Html.FROM_HTML_MODE_LEGACY).toString();
+ else
+ spoilerText = Html.fromHtml(status.reblog != null ? status.reblog.spoiler_text : status.spoiler_text).toString();
+ if (spoilerText.contains(filter.phrase)) {
+ statusesToRemove.add(status);
}
}
}
}
+
}
}
if (statuses != null) {
diff --git a/app/src/main/res/layout/popup_add_filter.xml b/app/src/main/res/layout/popup_add_filter.xml
index 7b8b8ed5..1aa85830 100644
--- a/app/src/main/res/layout/popup_add_filter.xml
+++ b/app/src/main/res/layout/popup_add_filter.xml
@@ -109,6 +109,20 @@
android:text="@string/context_conversation"
app:buttonTint="@color/cyanea_accent_dark_reference" />
+
+
+
+
+
Followed tags
Follow tag
Edit list
+ Profiles