mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 06:10:31 +05:30
Added Search History Toggle and Clear in Settings
This commit is contained in:
parent
41d644f6d4
commit
ab97ccee85
@ -136,7 +136,8 @@ class SearchFragment : Fragment() {
|
|||||||
GlobalScope.launch {
|
GlobalScope.launch {
|
||||||
fetchSuggestions(s.toString(), autoTextView)
|
fetchSuggestions(s.toString(), autoTextView)
|
||||||
delay(1000)
|
delay(1000)
|
||||||
addtohistory(s.toString())
|
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireContext())
|
||||||
|
if (sharedPreferences.getBoolean("search_history_toggle", true)) addtohistory(s.toString())
|
||||||
fetchSearch(s.toString())
|
fetchSearch(s.toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import android.content.pm.PackageManager
|
|||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.system.Os.remove
|
||||||
import android.text.TextUtils
|
import android.text.TextUtils
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.View
|
import android.view.View
|
||||||
@ -224,6 +225,13 @@ class SettingsActivity : AppCompatActivity(),
|
|||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val clearHistory = findPreference<Preference>("clear_history")
|
||||||
|
clearHistory?.setOnPreferenceClickListener {
|
||||||
|
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireContext())
|
||||||
|
sharedPreferences.edit().remove("search_history").commit()
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
val about = findPreference<Preference>("about")
|
val about = findPreference<Preference>("about")
|
||||||
about?.setOnPreferenceClickListener {
|
about?.setOnPreferenceClickListener {
|
||||||
val uri = Uri.parse("https://libre-tube.github.io/")
|
val uri = Uri.parse("https://libre-tube.github.io/")
|
||||||
|
10
app/src/main/res/drawable/ic_trash.xml
Normal file
10
app/src/main/res/drawable/ic_trash.xml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:height="24dp"
|
||||||
|
android:tint="?attr/colorControlNormal"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:width="24dp">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M6,19c0,1.1 0.9,2 2,2h8c1.1,0 2,-0.9 2,-2L18,7L6,7v12zM8.46,11.88l1.41,-1.41L12,12.59l2.12,-2.12 1.41,1.41L13.41,14l2.12,2.12 -1.41,1.41L12,15.41l-2.12,2.12 -1.41,-1.41L10.59,14l-2.13,-2.12zM15.5,4l-1,-1h-5l-1,1L5,4v2h14L19,4z"/>
|
||||||
|
</vector>
|
@ -77,4 +77,7 @@
|
|||||||
<string name="all">All</string>
|
<string name="all">All</string>
|
||||||
<string name="playlists">Playlists</string>
|
<string name="playlists">Playlists</string>
|
||||||
<string name="okay">Ok</string>
|
<string name="okay">Ok</string>
|
||||||
|
<string name="history">History</string>
|
||||||
|
<string name="search_history">Search History</string>
|
||||||
|
<string name="clear_history">Clear History</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -93,6 +93,21 @@
|
|||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
<PreferenceCategory app:title="@string/history">
|
||||||
|
|
||||||
|
<SwitchPreference
|
||||||
|
app:title="@string/search_history"
|
||||||
|
app:key="search_history_toggle"
|
||||||
|
android:defaultValue="true"
|
||||||
|
android:icon="@drawable/ic_history" />
|
||||||
|
|
||||||
|
<Preference
|
||||||
|
app:title="@string/clear_history"
|
||||||
|
app:key="clear_history"
|
||||||
|
android:icon="@drawable/ic_trash" />
|
||||||
|
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory app:title="@string/about">
|
<PreferenceCategory app:title="@string/about">
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
|
Loading…
Reference in New Issue
Block a user