mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-29 00:10:32 +05:30
Merge pull request #4001 from Bnyro/master
Preference to disable search suggestions
This commit is contained in:
commit
1e607edec2
@ -40,6 +40,7 @@ object PreferenceKeys {
|
||||
const val PLAYLISTS_ORDER = "playlists_order"
|
||||
const val PLAYLIST_SORT_ORDER = "playlist_sort_order"
|
||||
const val HOME_TAB_CONTENT = "home_tab_content"
|
||||
const val SEARCH_SUGGESTIONS = "search_suggestions"
|
||||
|
||||
/**
|
||||
* Instance
|
||||
|
@ -12,9 +12,11 @@ import androidx.lifecycle.lifecycleScope
|
||||
import androidx.lifecycle.repeatOnLifecycle
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.github.libretube.api.RetrofitInstance
|
||||
import com.github.libretube.constants.PreferenceKeys
|
||||
import com.github.libretube.databinding.FragmentSearchBinding
|
||||
import com.github.libretube.db.DatabaseHolder.Database
|
||||
import com.github.libretube.extensions.TAG
|
||||
import com.github.libretube.helpers.PreferenceHelper
|
||||
import com.github.libretube.ui.activities.MainActivity
|
||||
import com.github.libretube.ui.adapters.SearchHistoryAdapter
|
||||
import com.github.libretube.ui.adapters.SearchSuggestionsAdapter
|
||||
@ -60,12 +62,12 @@ class SearchFragment : Fragment() {
|
||||
}
|
||||
|
||||
private fun showData(query: String?) {
|
||||
// fetch the search or history
|
||||
// fetch search suggestions if enabled or show the search history
|
||||
binding.historyEmpty.visibility = View.GONE
|
||||
binding.suggestionsRecycler.visibility = View.VISIBLE
|
||||
if (query.isNullOrEmpty()) {
|
||||
showHistory()
|
||||
} else {
|
||||
} else if (PreferenceHelper.getBoolean(PreferenceKeys.SEARCH_SUGGESTIONS, true)) {
|
||||
fetchSuggestions(query)
|
||||
}
|
||||
}
|
||||
|
10
app/src/main/res/drawable/ic_suggestions.xml
Normal file
10
app/src/main/res/drawable/ic_suggestions.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:tint="?colorControlNormal"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M17.41,6.59L15,5.5l2.41,-1.09L18.5,2l1.09,2.41L22,5.5l-2.41,1.09L18.5,9L17.41,6.59zM21.28,12.72L20.5,11l-0.78,1.72L18,13.5l1.72,0.78L20.5,16l0.78,-1.72L23,13.5L21.28,12.72zM16.24,14.37l1.94,1.47l-2.5,4.33l-2.24,-0.94c-0.2,0.13 -0.42,0.26 -0.64,0.37L12.5,22h-5l-0.3,-2.41c-0.22,-0.11 -0.43,-0.23 -0.64,-0.37l-2.24,0.94l-2.5,-4.33l1.94,-1.47C3.75,14.25 3.75,14.12 3.75,14s0,-0.25 0.01,-0.37l-1.94,-1.47l2.5,-4.33l2.24,0.94c0.2,-0.13 0.42,-0.26 0.64,-0.37L7.5,6h5l0.3,2.41c0.22,0.11 0.43,0.23 0.64,0.37l2.24,-0.94l2.5,4.33l-1.94,1.47c0.01,0.12 0.01,0.24 0.01,0.37S16.25,14.25 16.24,14.37zM13,14c0,-1.66 -1.34,-3 -3,-3s-3,1.34 -3,3s1.34,3 3,3S13,15.66 13,14z" />
|
||||
</vector>
|
@ -430,6 +430,7 @@
|
||||
<string name="import_format_freetube">FreeTube</string>
|
||||
<string name="import_format_youtube_csv">YouTube (CSV)</string>
|
||||
<string name="home_tab_content">Home tab content</string>
|
||||
<string name="show_search_suggestions">Show search suggestions</string>
|
||||
|
||||
<!-- Notification channel strings -->
|
||||
<string name="download_channel_name">Download Service</string>
|
||||
|
@ -36,6 +36,12 @@
|
||||
app:key="auto_rotation"
|
||||
app:title="@string/auto_rotation" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="true"
|
||||
android:icon="@drawable/ic_suggestions"
|
||||
app:key="search_suggestions"
|
||||
app:title="@string/show_search_suggestions" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="true"
|
||||
android:icon="@drawable/ic_list"
|
||||
|
Loading…
x
Reference in New Issue
Block a user