diff --git a/app/src/main/java/ani/dantotsu/media/SearchAdapter.kt b/app/src/main/java/ani/dantotsu/media/SearchAdapter.kt
index ecf3692c63..21f0b68380 100644
--- a/app/src/main/java/ani/dantotsu/media/SearchAdapter.kt
+++ b/app/src/main/java/ani/dantotsu/media/SearchAdapter.kt
@@ -183,6 +183,12 @@ class SearchAdapter(private val activity: SearchActivity, private val type: Stri
binding.searchByImage.setOnClickListener {
activity.startActivity(Intent(activity, ImageSearchActivity::class.java))
}
+ binding.clearHistory.setOnClickListener {
+ it.startAnimation(fadeOutAnimation())
+ it.visibility = View.GONE
+ searchHistoryAdapter.clearHistory()
+ }
+ updateClearHistoryVisibility()
fun searchTitle() {
activity.result.apply {
search =
@@ -300,11 +306,17 @@ class SearchAdapter(private val activity: SearchActivity, private val type: Stri
}
binding.searchResultLayout.visibility = View.VISIBLE
+ binding.clearHistory.visibility = View.GONE
binding.searchHistoryList.visibility = View.GONE
binding.searchByImage.visibility = View.GONE
}
}
+ private fun updateClearHistoryVisibility() {
+ binding.clearHistory.visibility =
+ if (searchHistoryAdapter.itemCount > 0) View.VISIBLE else View.GONE
+ }
+
private fun fadeInAnimation(): Animation {
return AlphaAnimation(0f, 1f).apply {
duration = 150
@@ -375,4 +387,3 @@ class SearchAdapter(private val activity: SearchActivity, private val type: Stri
override fun getItemCount(): Int = chips.size
}
}
-
diff --git a/app/src/main/java/ani/dantotsu/media/SearchHistoryAdapter.kt b/app/src/main/java/ani/dantotsu/media/SearchHistoryAdapter.kt
index f1519e2b62..4e2988e361 100644
--- a/app/src/main/java/ani/dantotsu/media/SearchHistoryAdapter.kt
+++ b/app/src/main/java/ani/dantotsu/media/SearchHistoryAdapter.kt
@@ -49,6 +49,12 @@ class SearchHistoryAdapter(private val type: String, private val searchClicked:
PrefManager.setVal(historyType, searchHistory)
}
+ fun clearHistory() {
+ searchHistory?.clear()
+ PrefManager.setVal(historyType, searchHistory)
+ submitList(searchHistory?.toList())
+ }
+
override fun onCreateViewHolder(
parent: ViewGroup,
viewType: Int
diff --git a/app/src/main/res/drawable/ic_round_history_24.xml b/app/src/main/res/drawable/ic_round_history_24.xml
new file mode 100644
index 0000000000..1d5164d340
--- /dev/null
+++ b/app/src/main/res/drawable/ic_round_history_24.xml
@@ -0,0 +1,10 @@
+
+
+
diff --git a/app/src/main/res/layout/item_search_header.xml b/app/src/main/res/layout/item_search_header.xml
index dfd6083ca4..bd30343c5b 100644
--- a/app/src/main/res/layout/item_search_header.xml
+++ b/app/src/main/res/layout/item_search_header.xml
@@ -117,6 +117,32 @@
app:drawableTint="?attr/colorPrimary" />
+
+
+
+
+
Install Add-on
Add-on not found
Image
+ Clear History
Failed to install extension due to conflict
READING
WATCHING