mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-10 12:47:26 +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, () -> {});
|
DeleteRecentSearchQuery.deleteRecentSearchQueryListener(mRedditDataRoomDatabase, recentSearchQuery, () -> {});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
recyclerView.setVisibility(View.VISIBLE);
|
||||||
recyclerView.setNestedScrollingEnabled(false);
|
recyclerView.setNestedScrollingEnabled(false);
|
||||||
recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||||
recyclerView.setAdapter(adapter);
|
recyclerView.setAdapter(adapter);
|
||||||
mRecentSearchQueryViewModel = new ViewModelProvider(this,
|
|
||||||
new RecentSearchQueryViewModel.Factory(mRedditDataRoomDatabase, mAccountName))
|
|
||||||
.get(RecentSearchQueryViewModel.class);
|
|
||||||
|
|
||||||
mRecentSearchQueryViewModel.getAllRecentSearchQueries().observe(this, recentSearchQueries -> {
|
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.ENABLE_SEARCH_HISTORY, true)) {
|
||||||
if (recentSearchQueries != null && !recentSearchQueries.isEmpty()) {
|
mRecentSearchQueryViewModel = new ViewModelProvider(this,
|
||||||
divider.setVisibility(View.VISIBLE);
|
new RecentSearchQueryViewModel.Factory(mRedditDataRoomDatabase, mAccountName))
|
||||||
recentSummaryTextView.setVisibility(View.VISIBLE);
|
.get(RecentSearchQueryViewModel.class);
|
||||||
} else {
|
|
||||||
divider.setVisibility(View.GONE);
|
mRecentSearchQueryViewModel.getAllRecentSearchQueries().observe(this, recentSearchQueries -> {
|
||||||
recentSummaryTextView.setVisibility(View.GONE);
|
if (recentSearchQueries != null && !recentSearchQueries.isEmpty()) {
|
||||||
}
|
divider.setVisibility(View.VISIBLE);
|
||||||
adapter.setRecentSearchQueries(recentSearchQueries);
|
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();
|
}).attach();
|
||||||
fixViewPager2Sensitivity(viewPager2);
|
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,
|
InsertRecentSearchQuery.insertRecentSearchQueryListener(mRedditDataRoomDatabase, mAccountName,
|
||||||
mQuery, () -> mInsertSearchQuerySuccess = true);
|
mQuery, () -> mInsertSearchQuerySuccess = true);
|
||||||
}
|
}
|
||||||
|
@ -146,6 +146,7 @@ public class SharedPreferencesUtils {
|
|||||||
public static final int SWIPE_ACITON_DOWNVOTE = 1;
|
public static final int SWIPE_ACITON_DOWNVOTE = 1;
|
||||||
public static final String LANGUAGE = "language";
|
public static final String LANGUAGE = "language";
|
||||||
public static final String LANGUAGE_DEFAULT_VALUE = "auto";
|
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_TABS_SHARED_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit.main_page_tabs";
|
||||||
public static final String MAIN_PAGE_TAB_COUNT = "_main_page_tab_count";
|
public static final String MAIN_PAGE_TAB_COUNT = "_main_page_tab_count";
|
||||||
|
@ -89,7 +89,8 @@
|
|||||||
<View
|
<View
|
||||||
android:id="@+id/divider_search_activity"
|
android:id="@+id/divider_search_activity"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1dp" />
|
android:layout_height="1dp"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/recent_summary_text_view_search_activity"
|
android:id="@+id/recent_summary_text_view_search_activity"
|
||||||
@ -103,7 +104,8 @@
|
|||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/recycler_view_search_activity"
|
android:id="@+id/recycler_view_search_activity"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
@ -508,6 +508,7 @@
|
|||||||
<string name="settings_swipe_action_swipe_right_title">Swipe Right</string>
|
<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_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_language_title">Language</string>
|
||||||
|
<string name="settings_enable_search_history">Enable Search History</string>
|
||||||
|
|
||||||
<string name="no_link_available">Cannot get the link</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:title="@string/settings_respect_subreddit_recommended_comment_sort_type_title"
|
||||||
app:summary="@string/settings_respect_subreddit_recommended_comment_sort_type_summary" />
|
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
|
<ListPreference
|
||||||
app:defaultValue="auto"
|
app:defaultValue="auto"
|
||||||
app:entries="@array/settings_language"
|
app:entries="@array/settings_language"
|
||||||
|
Loading…
Reference in New Issue
Block a user