Allow to hide self boosts and self replies

This commit is contained in:
Thomas 2023-08-15 17:22:07 +02:00
parent 302b3e47d4
commit 92d52bbecf
5 changed files with 72 additions and 3 deletions

View File

@ -208,7 +208,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
public static List<Filter> mainFilters;
public static List<app.fedilab.android.mastodon.client.entities.api.Account> filteredAccounts;
public static boolean filterFetched;
public static boolean show_boosts, show_replies, show_dms, show_art_nsfw;
public static boolean show_boosts, show_replies, show_dms, show_art_nsfw, show_self_boosts, show_self_replies;
public static String regex_home, regex_local, regex_public;
public static BaseAccount currentAccount;
public static iconLauncher mLauncher = iconLauncher.BUBBLES;
@ -1206,7 +1206,9 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
currentUserID = currentAccount.user_id;
show_boosts = sharedpreferences.getBoolean(getString(R.string.SET_SHOW_BOOSTS) + currentUserID + currentInstance, true);
show_self_boosts = sharedpreferences.getBoolean(getString(R.string.SET_SHOW_SELF_BOOSTS) + currentUserID + currentInstance, true);
show_replies = sharedpreferences.getBoolean(getString(R.string.SET_SHOW_REPLIES) + currentUserID + currentInstance, true);
show_self_replies = sharedpreferences.getBoolean(getString(R.string.SET_SHOW_SELF_REPLIES) + currentUserID + currentInstance, true);
show_dms = sharedpreferences.getBoolean(getString(R.string.SET_SHOW_DMS) + currentUserID + currentInstance, true);
regex_home = sharedpreferences.getString(getString(R.string.SET_FILTER_REGEX_HOME) + currentUserID + currentInstance, null);
regex_local = sharedpreferences.getString(getString(R.string.SET_FILTER_REGEX_LOCAL) + currentUserID + currentInstance, null);
@ -1538,16 +1540,22 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
.inflate(R.menu.option_filter_toots, popup.getMenu());
Menu menu = popup.getMenu();
final MenuItem itemShowBoosts = menu.findItem(R.id.action_show_boosts);
final MenuItem itemShowSelfBoosts = menu.findItem(R.id.action_show_self_boosts);
final MenuItem itemShowDMs = menu.findItem(R.id.action_show_dms);
final MenuItem itemShowReplies = menu.findItem(R.id.action_show_replies);
final MenuItem itemShowSelfReplies = menu.findItem(R.id.action_show_self_replies);
final MenuItem itemFilter = menu.findItem(R.id.action_filter);
if (!showExtendedFilter) {
itemShowBoosts.setVisible(false);
itemShowReplies.setVisible(false);
itemShowSelfBoosts.setVisible(false);
itemShowSelfReplies.setVisible(false);
itemShowDMs.setVisible(false);
} else {
itemShowBoosts.setVisible(true);
itemShowReplies.setVisible(true);
itemShowSelfBoosts.setVisible(true);
itemShowSelfReplies.setVisible(true);
itemShowDMs.setVisible(true);
}
@ -1563,6 +1571,8 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
itemShowBoosts.setChecked(show_boosts);
itemShowReplies.setChecked(show_replies);
itemShowSelfBoosts.setChecked(show_self_boosts);
itemShowSelfReplies.setChecked(show_self_replies);
itemShowDMs.setChecked(show_dms);
if (show_filtered != null && show_filtered.length() > 0) {
itemFilter.setTitle(show_filtered);
@ -1599,11 +1609,21 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
editor.putBoolean(getString(R.string.SET_SHOW_BOOSTS) + currentUserID + currentInstance, show_boosts);
itemShowBoosts.setChecked(show_boosts);
editor.apply();
} else if (itemId == R.id.action_show_self_boosts) {
show_self_boosts = !show_self_boosts;
editor.putBoolean(getString(R.string.SET_SHOW_SELF_BOOSTS) + currentUserID + currentInstance, show_self_boosts);
itemShowSelfBoosts.setChecked(show_self_boosts);
editor.apply();
} else if (itemId == R.id.action_show_replies) {
show_replies = !show_replies;
editor.putBoolean(getString(R.string.SET_SHOW_REPLIES) + currentUserID + currentInstance, show_replies);
itemShowReplies.setChecked(show_replies);
editor.apply();
} else if (itemId == R.id.action_show_self_replies) {
show_self_replies = !show_self_replies;
editor.putBoolean(getString(R.string.SET_SHOW_SELF_REPLIES) + currentUserID + currentInstance, show_self_replies);
itemShowSelfReplies.setChecked(show_self_replies);
editor.apply();
} else if (itemId == R.id.action_show_dms) {
show_dms = !show_dms;
editor.putBoolean(getString(R.string.SET_SHOW_DMS) + currentUserID + currentInstance, show_dms);

View File

@ -21,6 +21,8 @@ import static app.fedilab.android.BaseMainActivity.currentUserID;
import static app.fedilab.android.BaseMainActivity.show_boosts;
import static app.fedilab.android.BaseMainActivity.show_dms;
import static app.fedilab.android.BaseMainActivity.show_replies;
import static app.fedilab.android.BaseMainActivity.show_self_boosts;
import static app.fedilab.android.BaseMainActivity.show_self_replies;
import android.annotation.SuppressLint;
import android.content.SharedPreferences;
@ -633,16 +635,22 @@ public class PinnedTimelineHelper {
.inflate(R.menu.option_filter_toots, popup.getMenu());
Menu menu = popup.getMenu();
final MenuItem itemShowBoosts = menu.findItem(R.id.action_show_boosts);
final MenuItem itemShowSelfBoosts = menu.findItem(R.id.action_show_self_boosts);
final MenuItem itemShowReplies = menu.findItem(R.id.action_show_replies);
final MenuItem itemShowSelfReplies = menu.findItem(R.id.action_show_self_replies);
final MenuItem itemShowDMs = menu.findItem(R.id.action_show_dms);
final MenuItem itemFilter = menu.findItem(R.id.action_filter);
if (!showExtendedFilter) {
itemShowBoosts.setVisible(false);
itemShowReplies.setVisible(false);
itemShowSelfBoosts.setVisible(false);
itemShowSelfReplies.setVisible(false);
itemShowDMs.setVisible(false);
} else {
itemShowBoosts.setVisible(true);
itemShowReplies.setVisible(true);
itemShowSelfBoosts.setVisible(true);
itemShowSelfReplies.setVisible(true);
itemShowDMs.setVisible(true);
}
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(activity);
@ -657,6 +665,8 @@ public class PinnedTimelineHelper {
itemShowBoosts.setChecked(show_boosts);
itemShowReplies.setChecked(show_replies);
itemShowSelfBoosts.setChecked(show_self_boosts);
itemShowSelfReplies.setChecked(show_self_replies);
itemShowDMs.setChecked(show_dms);
if (show_filtered != null && show_filtered.length() > 0) {
itemFilter.setTitle(show_filtered);
@ -692,11 +702,21 @@ public class PinnedTimelineHelper {
editor.putBoolean(activity.getString(R.string.SET_SHOW_BOOSTS) + currentUserID + currentInstance, show_boosts);
itemShowBoosts.setChecked(show_boosts);
editor.apply();
} else if (itemId == R.id.action_show_self_boosts) {
show_self_boosts = !show_self_boosts;
editor.putBoolean(activity.getString(R.string.SET_SHOW_SELF_BOOSTS) + currentUserID + currentInstance, show_self_boosts);
itemShowSelfBoosts.setChecked(show_self_boosts);
editor.apply();
} else if (itemId == R.id.action_show_replies) {
show_replies = !show_replies;
editor.putBoolean(activity.getString(R.string.SET_SHOW_REPLIES) + currentUserID + currentInstance, show_replies);
itemShowReplies.setChecked(show_replies);
editor.apply();
} else if (itemId == R.id.action_show_self_replies) {
show_self_replies = !show_self_replies;
editor.putBoolean(activity.getString(R.string.SET_SHOW_SELF_REPLIES) + currentUserID + currentInstance, show_self_replies);
itemShowSelfReplies.setChecked(show_self_replies);
editor.apply();
} else if (itemId == R.id.action_show_dms) {
show_dms = !show_dms;
editor.putBoolean(activity.getString(R.string.SET_SHOW_DMS) + currentUserID + currentInstance, show_dms);

View File

@ -24,6 +24,8 @@ import static app.fedilab.android.BaseMainActivity.regex_public;
import static app.fedilab.android.BaseMainActivity.show_boosts;
import static app.fedilab.android.BaseMainActivity.show_dms;
import static app.fedilab.android.BaseMainActivity.show_replies;
import static app.fedilab.android.BaseMainActivity.show_self_boosts;
import static app.fedilab.android.BaseMainActivity.show_self_replies;
import static app.fedilab.android.mastodon.activities.ContextActivity.expand;
import static app.fedilab.android.mastodon.helper.Helper.ARG_TIMELINE_REFRESH_ALL;
import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_ID;
@ -215,16 +217,26 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
return status.media_attachments != null && status.media_attachments.size() > 0;
}
private static boolean isVisible(Timeline.TimeLineEnum timelineType, Status status) {
private static boolean isVisible(Timeline.TimeLineEnum timelineType, Status status, List<Status> statusList) {
if (timelineType == Timeline.TimeLineEnum.HOME && !show_boosts && status.reblog != null) {
return false;
}
if (timelineType == Timeline.TimeLineEnum.HOME && !show_self_boosts && status.reblog != null && status.reblog.account.id.equals(status.account.id)) {
return false;
}
if (timelineType == Timeline.TimeLineEnum.HOME && !show_dms && status.visibility.equalsIgnoreCase("direct")) {
return false;
}
if (timelineType == Timeline.TimeLineEnum.HOME && !show_replies && status.in_reply_to_id != null) {
return false;
}
if (timelineType == Timeline.TimeLineEnum.HOME && !show_self_replies && status.in_reply_to_id != null) {
Status statusToFind = new Status();
statusToFind.id = status.in_reply_to_id;
if (statusList.contains(statusToFind)) {
return false;
}
}
if (timelineType == Timeline.TimeLineEnum.HOME && regex_home != null && !regex_home.trim().equals("")) {
try {
Pattern filterPattern = Pattern.compile("(" + regex_home + ")", Pattern.CASE_INSENSITIVE);
@ -2927,7 +2939,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
}
}
} else {
if (isVisible(timelineType, statusList.get(position))) {
if (isVisible(timelineType, statusList.get(position), statusList)) {
if (visiblePixelfed && isVisiblePixelfed(statusList.get(position)) && timelineType != Timeline.TimeLineEnum.UNKNOWN) {
return STATUS_PIXELFED;
} else {

View File

@ -15,6 +15,19 @@
android:title="@string/show_replies"
app:actionViewClass="android.widget.CheckBox"
app:showAsAction="always" />
<item
android:id="@+id/action_show_self_boosts"
android:checkable="true"
android:title="@string/show_self_boosts"
app:actionViewClass="android.widget.CheckBox"
app:showAsAction="always"
tools:ignore="AlwaysShowAction" />
<item
android:id="@+id/action_show_self_replies"
android:checkable="true"
android:title="@string/show_self_replies"
app:actionViewClass="android.widget.CheckBox"
app:showAsAction="always" />
<item
android:id="@+id/action_show_dms"
android:checkable="true"

View File

@ -48,6 +48,8 @@
<string name="reblog">Boosts</string>
<string name="show_boosts">Show boosts</string>
<string name="show_replies">Show replies</string>
<string name="show_self_boosts">Show self boosts</string>
<string name="show_self_replies">Show self replies</string>
<string name="show_privates">Show direct messages</string>
<string name="action_open_in_web">Open in browser</string>
<string name="translate">Translate</string>
@ -1043,7 +1045,9 @@
<string name="SET_TIMELINES_IN_A_LIST" translatable="false">SET_TIMELINES_IN_A_LIST</string>
<string name="SET_LED_COLOUR_VAL_N" translatable="false">SET_LED_COLOUR_VAL_N</string>
<string name="SET_SHOW_BOOSTS" translatable="false">SET_SHOW_BOOSTS</string>
<string name="SET_SHOW_SELF_BOOSTS" translatable="false">SET_SHOW_SELF_BOOSTS</string>
<string name="SET_SHOW_REPLIES" translatable="false">SET_SHOW_REPLIES</string>
<string name="SET_SHOW_SELF_REPLIES" translatable="false">SET_SHOW_SELF_REPLIES</string>
<string name="SET_SHOW_DMS" translatable="false">SET_SHOW_DMS</string>
<string name="SET_DISABLE_ANIMATED_EMOJI" translatable="false">SET_DISABLE_ANIMATED_EMOJI</string>