fixes merge conflicts

This commit is contained in:
Vavassor 2017-05-11 18:58:38 -04:00
commit 66bac21236
5 changed files with 65 additions and 1 deletions

View file

@ -145,6 +145,11 @@ public class TimelineAdapter extends RecyclerView.Adapter implements AdapterItem
notifyItemRemoved(position);
}
public void clear() {
statuses.clear();
notifyDataSetChanged();
}
public void removeAllByAccountId(String accountId) {
for (int i = 0; i < statuses.size();) {
Status status = statuses.get(i);

View file

@ -43,6 +43,7 @@ import com.keylesspalace.tusky.util.Log;
import com.keylesspalace.tusky.util.TimelineReceiver;
import com.keylesspalace.tusky.util.ThemeUtils;
import java.util.Iterator;
import java.util.List;
import retrofit2.Call;
@ -73,6 +74,9 @@ public class TimelineFragment extends SFragment implements
private LinearLayoutManager layoutManager;
private EndlessOnScrollListener scrollListener;
private TabLayout.OnTabSelectedListener onTabSelectedListener;
private SharedPreferences preferences;
private boolean filterRemoveReplies;
private boolean filterRemoveReblogs;
private boolean hideFab;
private TimelineReceiver timelineReceiver;
@ -201,6 +205,8 @@ public class TimelineFragment extends SFragment implements
};
}
recyclerView.addOnScrollListener(scrollListener);
preferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
}
@Override
@ -292,7 +298,36 @@ public class TimelineFragment extends SFragment implements
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(null, null);
}
}
@Override
public void onResume() {
super.onResume();
setFiltersFromSettings();
}
public void onFetchTimelineSuccess(List<Status> statuses, String fromId) {
filterStatuses(statuses);
if (fromId != null) {
if (statuses.size() > 0 && !findStatus(statuses, fromId)) {
adapter.addItems(statuses);

View file

@ -160,6 +160,10 @@
<string name="pref_title_browser_settings">Browser</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_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_summary_large">%1$s, %2$s, %3$s and %4$d others</string>

View file

@ -21,6 +21,26 @@
android:title="@string/pref_title_custom_tabs"
android:defaultValue="true" />
</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">
<PreferenceScreen android:title="@string/pref_title_edit_notification_settings">

View file

@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
classpath 'com.android.tools.build:gradle:2.3.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files