Merge branch 'issue_133' of https://github.com/raphaelm/Tusky into raphaelm-issue_133
This commit is contained in:
commit
9bb8c96f00
5 changed files with 65 additions and 0 deletions
|
@ -142,6 +142,11 @@ class TimelineAdapter extends RecyclerView.Adapter implements AdapterItemRemover
|
||||||
notifyItemRemoved(position);
|
notifyItemRemoved(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void clear() {
|
||||||
|
statuses.clear();
|
||||||
|
notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
void removeAllByAccountId(String accountId) {
|
void removeAllByAccountId(String accountId) {
|
||||||
for (int i = 0; i < statuses.size();) {
|
for (int i = 0; i < statuses.size();) {
|
||||||
Status status = statuses.get(i);
|
Status status = statuses.get(i);
|
||||||
|
|
|
@ -33,6 +33,7 @@ import android.view.ViewGroup;
|
||||||
|
|
||||||
import com.keylesspalace.tusky.entity.Status;
|
import com.keylesspalace.tusky.entity.Status;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
|
@ -64,6 +65,9 @@ public class TimelineFragment extends SFragment implements
|
||||||
private LinearLayoutManager layoutManager;
|
private LinearLayoutManager layoutManager;
|
||||||
private EndlessOnScrollListener scrollListener;
|
private EndlessOnScrollListener scrollListener;
|
||||||
private TabLayout.OnTabSelectedListener onTabSelectedListener;
|
private TabLayout.OnTabSelectedListener onTabSelectedListener;
|
||||||
|
private SharedPreferences preferences;
|
||||||
|
private boolean filterRemoveReplies;
|
||||||
|
private boolean filterRemoveReblogs;
|
||||||
private boolean hideFab;
|
private boolean hideFab;
|
||||||
|
|
||||||
public static TimelineFragment newInstance(Kind kind) {
|
public static TimelineFragment newInstance(Kind kind) {
|
||||||
|
@ -189,6 +193,8 @@ public class TimelineFragment extends SFragment implements
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
recyclerView.addOnScrollListener(scrollListener);
|
recyclerView.addOnScrollListener(scrollListener);
|
||||||
|
|
||||||
|
preferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -288,7 +294,36 @@ public class TimelineFragment extends SFragment implements
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void filterStatuses(List<Status> statuses) {
|
||||||
|
Iterator<Status> it = statuses.iterator();
|
||||||
|
while (it.hasNext()) {
|
||||||
|
Status status = it.next();
|
||||||
|
if ((status.inReplyToId != null && filterRemoveReplies) || (status.reblog != null && filterRemoveReblogs)) {
|
||||||
|
it.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setFiltersFromSettings() {
|
||||||
|
boolean oldRemoveReplies = filterRemoveReplies;
|
||||||
|
boolean oldRemoveReblogs = filterRemoveReblogs;
|
||||||
|
filterRemoveReplies = (kind == Kind.HOME && !preferences.getBoolean("tabFilterHomeReplies", true));
|
||||||
|
filterRemoveReblogs = (kind == Kind.HOME && !preferences.getBoolean("tabFilterHomeBoosts", true));
|
||||||
|
|
||||||
|
if (adapter.getItemCount() > 1 && (oldRemoveReblogs != filterRemoveReblogs || oldRemoveReplies != filterRemoveReplies)) {
|
||||||
|
adapter.clear();
|
||||||
|
sendFetchTimelineRequest();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
setFiltersFromSettings();
|
||||||
|
}
|
||||||
|
|
||||||
public void onFetchTimelineSuccess(List<Status> statuses, String fromId) {
|
public void onFetchTimelineSuccess(List<Status> statuses, String fromId) {
|
||||||
|
filterStatuses(statuses);
|
||||||
if (fromId != null) {
|
if (fromId != null) {
|
||||||
if (statuses.size() > 0 && !findStatus(statuses, fromId)) {
|
if (statuses.size() > 0 && !findStatus(statuses, fromId)) {
|
||||||
adapter.addItems(statuses);
|
adapter.addItems(statuses);
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
app:layout_scrollFlags="scroll|exitUntilCollapsed"
|
app:layout_scrollFlags="scroll|exitUntilCollapsed"
|
||||||
app:contentScrim="?attr/toolbar_background_color"
|
app:contentScrim="?attr/toolbar_background_color"
|
||||||
|
app:collapsedTitleTextAppearance="?attr/android:textColorPrimary"
|
||||||
android:fitsSystemWindows="true"
|
android:fitsSystemWindows="true"
|
||||||
app:titleEnabled="false">
|
app:titleEnabled="false">
|
||||||
|
|
||||||
|
|
|
@ -156,6 +156,10 @@
|
||||||
<string name="pref_title_browser_settings">Browser</string>
|
<string name="pref_title_browser_settings">Browser</string>
|
||||||
<string name="pref_title_custom_tabs">Use Chrome Custom Tabs</string>
|
<string name="pref_title_custom_tabs">Use Chrome Custom Tabs</string>
|
||||||
<string name="pref_title_hide_follow_button">Hide follow button while scrolling</string>
|
<string name="pref_title_hide_follow_button">Hide follow button while scrolling</string>
|
||||||
|
<string name="pref_title_status_filter">Toot filtering</string>
|
||||||
|
<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="notification_mention_format">%s mentioned you</string>
|
<string name="notification_mention_format">%s mentioned you</string>
|
||||||
<string name="notification_summary_large">%1$s, %2$s, %3$s and %4$d others</string>
|
<string name="notification_summary_large">%1$s, %2$s, %3$s and %4$d others</string>
|
||||||
|
|
|
@ -21,6 +21,26 @@
|
||||||
android:title="@string/pref_title_custom_tabs"
|
android:title="@string/pref_title_custom_tabs"
|
||||||
android:defaultValue="true" />
|
android:defaultValue="true" />
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
<PreferenceCategory android:title="@string/pref_title_status_filter">
|
||||||
|
<PreferenceScreen android:title="@string/pref_title_status_tabs">
|
||||||
|
|
||||||
|
<PreferenceCategory
|
||||||
|
android:dependency="notificationsEnabled"
|
||||||
|
android:title="@string/title_home">
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:key="tabFilterHomeBoosts"
|
||||||
|
android:title="@string/pref_title_show_boosts"
|
||||||
|
android:defaultValue="true" />
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:key="tabFilterHomeReplies"
|
||||||
|
android:title="@string/pref_title_show_replies"
|
||||||
|
android:defaultValue="true" />
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
</PreferenceScreen>
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory android:title="@string/pref_title_notification_settings">
|
<PreferenceCategory android:title="@string/pref_title_notification_settings">
|
||||||
<PreferenceScreen android:title="@string/pref_title_edit_notification_settings">
|
<PreferenceScreen android:title="@string/pref_title_edit_notification_settings">
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue