mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-29 04:17:12 +01:00
Add an option to disable search history.
This commit is contained in:
parent
58a19c9ad1
commit
805017233b
@ -226,23 +226,27 @@ public class SearchActivity extends BaseActivity {
|
||||
DeleteRecentSearchQuery.deleteRecentSearchQueryListener(mRedditDataRoomDatabase, recentSearchQuery, () -> {});
|
||||
}
|
||||
});
|
||||
recyclerView.setVisibility(View.VISIBLE);
|
||||
recyclerView.setNestedScrollingEnabled(false);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||
recyclerView.setAdapter(adapter);
|
||||
mRecentSearchQueryViewModel = new ViewModelProvider(this,
|
||||
new RecentSearchQueryViewModel.Factory(mRedditDataRoomDatabase, mAccountName))
|
||||
.get(RecentSearchQueryViewModel.class);
|
||||
|
||||
mRecentSearchQueryViewModel.getAllRecentSearchQueries().observe(this, recentSearchQueries -> {
|
||||
if (recentSearchQueries != null && !recentSearchQueries.isEmpty()) {
|
||||
divider.setVisibility(View.VISIBLE);
|
||||
recentSummaryTextView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
divider.setVisibility(View.GONE);
|
||||
recentSummaryTextView.setVisibility(View.GONE);
|
||||
}
|
||||
adapter.setRecentSearchQueries(recentSearchQueries);
|
||||
});
|
||||
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.ENABLE_SEARCH_HISTORY, true)) {
|
||||
mRecentSearchQueryViewModel = new ViewModelProvider(this,
|
||||
new RecentSearchQueryViewModel.Factory(mRedditDataRoomDatabase, mAccountName))
|
||||
.get(RecentSearchQueryViewModel.class);
|
||||
|
||||
mRecentSearchQueryViewModel.getAllRecentSearchQueries().observe(this, recentSearchQueries -> {
|
||||
if (recentSearchQueries != null && !recentSearchQueries.isEmpty()) {
|
||||
divider.setVisibility(View.VISIBLE);
|
||||
recentSummaryTextView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
divider.setVisibility(View.GONE);
|
||||
recentSummaryTextView.setVisibility(View.GONE);
|
||||
}
|
||||
adapter.setRecentSearchQueries(recentSearchQueries);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -251,7 +251,7 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
|
||||
}).attach();
|
||||
fixViewPager2Sensitivity(viewPager2);
|
||||
|
||||
if (mAccountName != null && !mInsertSearchQuerySuccess && mQuery != null) {
|
||||
if (mAccountName != null && mSharedPreferences.getBoolean(SharedPreferencesUtils.ENABLE_SEARCH_HISTORY, true) && !mInsertSearchQuerySuccess && mQuery != null) {
|
||||
InsertRecentSearchQuery.insertRecentSearchQueryListener(mRedditDataRoomDatabase, mAccountName,
|
||||
mQuery, () -> mInsertSearchQuerySuccess = true);
|
||||
}
|
||||
|
@ -146,6 +146,7 @@ public class SharedPreferencesUtils {
|
||||
public static final int SWIPE_ACITON_DOWNVOTE = 1;
|
||||
public static final String LANGUAGE = "language";
|
||||
public static final String LANGUAGE_DEFAULT_VALUE = "auto";
|
||||
public static final String ENABLE_SEARCH_HISTORY = "enable_search_history";
|
||||
|
||||
public static final String MAIN_PAGE_TABS_SHARED_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit.main_page_tabs";
|
||||
public static final String MAIN_PAGE_TAB_COUNT = "_main_page_tab_count";
|
||||
|
@ -89,7 +89,8 @@
|
||||
<View
|
||||
android:id="@+id/divider_search_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp" />
|
||||
android:layout_height="1dp"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/recent_summary_text_view_search_activity"
|
||||
@ -103,7 +104,8 @@
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recycler_view_search_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
@ -508,6 +508,7 @@
|
||||
<string name="settings_swipe_action_swipe_right_title">Swipe Right</string>
|
||||
<string name="settings_swipe_action_info_summary">Not applicable to post feed with more than 1 column or post detail.</string>
|
||||
<string name="settings_language_title">Language</string>
|
||||
<string name="settings_enable_search_history">Enable Search History</string>
|
||||
|
||||
<string name="no_link_available">Cannot get the link</string>
|
||||
|
||||
|
@ -25,6 +25,12 @@
|
||||
app:title="@string/settings_respect_subreddit_recommended_comment_sort_type_title"
|
||||
app:summary="@string/settings_respect_subreddit_recommended_comment_sort_type_summary" />
|
||||
|
||||
<SwitchPreference
|
||||
app:defaultValue="true"
|
||||
app:key="enable_search_history"
|
||||
app:title="@string/settings_enable_search_history"
|
||||
app:summary="@string/only_for_logged_in_user" />
|
||||
|
||||
<ListPreference
|
||||
app:defaultValue="auto"
|
||||
app:entries="@array/settings_language"
|
||||
|
Loading…
Reference in New Issue
Block a user