mirror of
https://github.com/TwidereProject/Twidere-Android
synced 2025-02-03 01:57:40 +01:00
improved exclude retweets from search
This commit is contained in:
parent
1359957e00
commit
0669cfe1e5
@ -311,4 +311,6 @@ public interface SharedPreferenceConstants {
|
||||
String KEY_BUG_REPORTS = "bug_reports";
|
||||
@Preference(type = BOOLEAN, hasDefault = true, defaultBoolean = false)
|
||||
String KEY_COMBINED_NOTIFICATIONS = "combined_notifications";
|
||||
@Preference(type = BOOLEAN, hasDefault = true, defaultBoolean = true)
|
||||
String TWITTER_OPTIMIZED_SEARCHES = "twitter_optimized_searches";
|
||||
}
|
||||
|
@ -102,7 +102,6 @@ public abstract class AbsStatusesFragment<Data> extends AbsContentListRecyclerVi
|
||||
}
|
||||
}
|
||||
};
|
||||
private SharedPreferences mPreferences;
|
||||
private PopupMenu mPopupMenu;
|
||||
private final OnScrollListener mOnScrollListener = new OnScrollListener() {
|
||||
@Override
|
||||
@ -136,11 +135,6 @@ public abstract class AbsStatusesFragment<Data> extends AbsContentListRecyclerVi
|
||||
mStatusesBusCallback = createMessageBusCallback();
|
||||
}
|
||||
|
||||
public SharedPreferences getSharedPreferences() {
|
||||
if (mPreferences != null) return mPreferences;
|
||||
return mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
}
|
||||
|
||||
public abstract boolean getStatuses(long[] accountIds, long[] maxIds, long[] sinceIds);
|
||||
|
||||
@Override
|
||||
@ -242,9 +236,8 @@ public abstract class AbsStatusesFragment<Data> extends AbsContentListRecyclerVi
|
||||
@Override
|
||||
public final void onLoadFinished(Loader<Data> loader, Data data) {
|
||||
final AbsStatusesAdapter<Data> adapter = getAdapter();
|
||||
final SharedPreferences preferences = getSharedPreferences();
|
||||
final boolean rememberPosition = preferences.getBoolean(KEY_REMEMBER_POSITION, false);
|
||||
final boolean readFromBottom = preferences.getBoolean(KEY_READ_FROM_BOTTOM, false);
|
||||
final boolean rememberPosition = mPreferences.getBoolean(KEY_REMEMBER_POSITION, false);
|
||||
final boolean readFromBottom = mPreferences.getBoolean(KEY_READ_FROM_BOTTOM, false);
|
||||
final long lastReadId;
|
||||
final int lastVisiblePos, lastVisibleTop;
|
||||
final String tag = getCurrentReadPositionTag();
|
||||
|
@ -21,7 +21,6 @@ package org.mariotaku.twidere.fragment.support;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.ContentObserver;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
@ -281,8 +280,7 @@ public abstract class CursorStatusesFragment extends AbsStatusesFragment<List<Pa
|
||||
protected abstract void updateRefreshState();
|
||||
|
||||
private String getSortOrder() {
|
||||
final SharedPreferences preferences = getSharedPreferences();
|
||||
final boolean sortById = preferences.getBoolean(KEY_SORT_TIMELINE_BY_ID, false);
|
||||
final boolean sortById = mPreferences.getBoolean(KEY_SORT_TIMELINE_BY_ID, false);
|
||||
return sortById ? Statuses.SORT_ORDER_STATUS_ID_DESC : Statuses.SORT_ORDER_TIMESTAMP_DESC;
|
||||
}
|
||||
}
|
||||
|
@ -178,9 +178,10 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
|
||||
final long statusId = args.getLong(EXTRA_STATUS_ID, -1);
|
||||
final long maxId = args.getLong(EXTRA_MAX_ID, -1);
|
||||
final long sinceId = args.getLong(EXTRA_SINCE_ID, -1);
|
||||
final boolean twitterOptimizedSearches = mPreferences.getBoolean(TWITTER_OPTIMIZED_SEARCHES);
|
||||
|
||||
final StatusRepliesLoader loader = new StatusRepliesLoader(getActivity(), accountId,
|
||||
screenName, statusId, maxId, sinceId, null, null, 0, true);
|
||||
screenName, statusId, maxId, sinceId, null, null, 0, true, twitterOptimizedSearches);
|
||||
loader.setComparator(ParcelableStatus.REVERSE_ID_COMPARATOR);
|
||||
return loader;
|
||||
}
|
||||
|
@ -40,8 +40,10 @@ public class StatusRepliesListFragment extends StatusesSearchFragment {
|
||||
final long maxId = args.getLong(EXTRA_MAX_ID, -1);
|
||||
final long sinceId = args.getLong(EXTRA_SINCE_ID, -1);
|
||||
final int tabPosition = args.getInt(EXTRA_TAB_POSITION, -1);
|
||||
final boolean twitterOptimizedSearches = mPreferences.getBoolean(TWITTER_OPTIMIZED_SEARCHES);
|
||||
return new StatusRepliesLoader(getActivity(), accountId, screenName, statusId, maxId,
|
||||
sinceId, getAdapterData(), getSavedStatusesFileArgs(), tabPosition, fromUser);
|
||||
sinceId, getAdapterData(), getSavedStatusesFileArgs(), tabPosition, fromUser,
|
||||
twitterOptimizedSearches);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -45,8 +45,9 @@ public class StatusesSearchFragment extends ParcelableStatusesFragment {
|
||||
final String query = args.getString(EXTRA_QUERY);
|
||||
final int tabPosition = args.getInt(EXTRA_TAB_POSITION, -1);
|
||||
final boolean makeGap = args.getBoolean(EXTRA_MAKE_GAP, true);
|
||||
final boolean twitterOptimizedSearches = mPreferences.getBoolean(TWITTER_OPTIMIZED_SEARCHES);
|
||||
return new TweetSearchLoader(getActivity(), accountId, query, sinceId, maxId, getAdapterData(),
|
||||
getSavedStatusesFileArgs(), tabPosition, fromUser, makeGap);
|
||||
getSavedStatusesFileArgs(), tabPosition, fromUser, makeGap, twitterOptimizedSearches);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -32,8 +32,8 @@ public class UserMentionsFragment extends StatusesSearchFragment {
|
||||
|
||||
@Override
|
||||
protected Loader<List<ParcelableStatus>> onCreateStatusesLoader(final Context context,
|
||||
final Bundle args,
|
||||
final boolean fromUser) {
|
||||
final Bundle args,
|
||||
final boolean fromUser) {
|
||||
if (args == null) return null;
|
||||
final String screenName = args.getString(EXTRA_SCREEN_NAME);
|
||||
final long accountId = args.getLong(EXTRA_ACCOUNT_ID, -1);
|
||||
@ -41,8 +41,10 @@ public class UserMentionsFragment extends StatusesSearchFragment {
|
||||
final long sinceId = args.getLong(EXTRA_SINCE_ID, -1);
|
||||
final int tabPosition = args.getInt(EXTRA_TAB_POSITION, -1);
|
||||
final boolean makeGap = args.getBoolean(EXTRA_MAKE_GAP, true);
|
||||
final boolean twitterOptimizedSearches = mPreferences.getBoolean(TWITTER_OPTIMIZED_SEARCHES);
|
||||
return new UserMentionsLoader(getActivity(), accountId, screenName, maxId, sinceId,
|
||||
getAdapterData(), getSavedStatusesFileArgs(), tabPosition, fromUser, makeGap);
|
||||
getAdapterData(), getSavedStatusesFileArgs(), tabPosition, fromUser, makeGap,
|
||||
twitterOptimizedSearches);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -41,9 +41,10 @@ public class StatusRepliesLoader extends UserMentionsLoader {
|
||||
|
||||
public StatusRepliesLoader(final Context context, final long accountId, final String screenName,
|
||||
final long statusId, final long maxId, final long sinceId, final List<ParcelableStatus> data,
|
||||
final String[] savedStatusesArgs, final int tabPosition, boolean fromUser) {
|
||||
final String[] savedStatusesArgs, final int tabPosition, boolean fromUser,
|
||||
boolean twitterOptimizedSearches) {
|
||||
super(context, accountId, screenName, maxId, sinceId, data, savedStatusesArgs, tabPosition,
|
||||
fromUser, false);
|
||||
fromUser, false, twitterOptimizedSearches);
|
||||
mInReplyToStatusId = statusId;
|
||||
}
|
||||
|
||||
|
@ -38,14 +38,16 @@ public class TweetSearchLoader extends TwitterAPIStatusesLoader {
|
||||
|
||||
private final String mQuery;
|
||||
private final boolean mGapEnabled;
|
||||
private final boolean mTwitterOptimizedSearches;
|
||||
|
||||
public TweetSearchLoader(final Context context, final long accountId, final String query,
|
||||
final long sinceId, final long maxId, final List<ParcelableStatus> data,
|
||||
final String[] savedStatusesArgs, final int tabPosition, boolean fromUser,
|
||||
boolean makeGap) {
|
||||
boolean makeGap, boolean twitterOptimizedSearches) {
|
||||
super(context, accountId, sinceId, maxId, data, savedStatusesArgs, tabPosition, fromUser);
|
||||
mQuery = query;
|
||||
mGapEnabled = makeGap;
|
||||
mTwitterOptimizedSearches = twitterOptimizedSearches;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@ -57,7 +59,10 @@ public class TweetSearchLoader extends TwitterAPIStatusesLoader {
|
||||
}
|
||||
|
||||
protected String processQuery(final String query) {
|
||||
return String.format("%s -RT", query);
|
||||
if (mTwitterOptimizedSearches) {
|
||||
return String.format("%s exclude:retweets", query);
|
||||
}
|
||||
return query;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -30,9 +30,9 @@ public class UserMentionsLoader extends TweetSearchLoader {
|
||||
public UserMentionsLoader(final Context context, final long accountId, final String screenName,
|
||||
final long maxId, final long sinceId, final List<ParcelableStatus> data,
|
||||
final String[] savedStatusesArgs, final int tabPosition, boolean fromUser,
|
||||
boolean makeGap) {
|
||||
boolean makeGap, boolean twitterOptimizedSearches) {
|
||||
super(context, accountId, screenName, sinceId, maxId, data, savedStatusesArgs, tabPosition,
|
||||
fromUser, makeGap);
|
||||
fromUser, makeGap, twitterOptimizedSearches);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -797,4 +797,6 @@
|
||||
<string name="cant_load_all_replies_message">Can\'t load all replies. <a href=\"#dialog\";>Why?</a></string>
|
||||
<string name="cant_load_all_replies_explanation">Due to Twitter\'s limitation to third party twitter apps, Twidere has no access to replies to a tweet, there\'s no guarantee that Twidere can load all replies to a tweet.</string>
|
||||
<string name="current_status">Current tweet</string>
|
||||
<string name="twitter_optimized_searches">Twitter optimized searches</string>
|
||||
<string name="twitter_optimized_searches_summary">Use special search terms to improve search results like exclude retweets</string>
|
||||
</resources>
|
@ -55,20 +55,26 @@
|
||||
<Preference
|
||||
android:fragment="org.mariotaku.twidere.fragment.KeyboardShortcutsFragment"
|
||||
android:title="@string/keyboard_shortcuts" />
|
||||
|
||||
<org.mariotaku.twidere.preference.MediaUploaderPreference
|
||||
android:defaultValue=""
|
||||
android:key="media_uploader"
|
||||
android:summary="%s"
|
||||
android:title="@string/image_uploader" />
|
||||
|
||||
<org.mariotaku.twidere.preference.TimelineSyncPreference
|
||||
android:defaultValue=""
|
||||
android:key="timeline_sync_service"
|
||||
android:summary="%s"
|
||||
android:title="@string/timeline_sync_service" />
|
||||
|
||||
<org.mariotaku.twidere.preference.AutoFixCheckBoxPreference
|
||||
android:defaultValue="true"
|
||||
android:key="twitter_optimized_searches"
|
||||
android:summary="@string/twitter_optimized_searches_summary"
|
||||
android:title="@string/twitter_optimized_searches" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<org.mariotaku.twidere.preference.MediaUploaderPreference
|
||||
android:defaultValue=""
|
||||
android:key="media_uploader"
|
||||
android:summary="%s"
|
||||
android:title="@string/image_uploader" />
|
||||
|
||||
<org.mariotaku.twidere.preference.TimelineSyncPreference
|
||||
android:defaultValue=""
|
||||
android:key="timeline_sync_service"
|
||||
android:summary="%s"
|
||||
android:title="@string/timeline_sync_service" />
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="category_safety"
|
||||
android:title="@string/safety">
|
||||
|
Loading…
x
Reference in New Issue
Block a user