feat: added clearhistory button (#416)
This commit is contained in:
parent
124c8f5ed7
commit
899af3ee1a
5 changed files with 55 additions and 1 deletions
|
@ -183,6 +183,12 @@ class SearchAdapter(private val activity: SearchActivity, private val type: Stri
|
||||||
binding.searchByImage.setOnClickListener {
|
binding.searchByImage.setOnClickListener {
|
||||||
activity.startActivity(Intent(activity, ImageSearchActivity::class.java))
|
activity.startActivity(Intent(activity, ImageSearchActivity::class.java))
|
||||||
}
|
}
|
||||||
|
binding.clearHistory.setOnClickListener {
|
||||||
|
it.startAnimation(fadeOutAnimation())
|
||||||
|
it.visibility = View.GONE
|
||||||
|
searchHistoryAdapter.clearHistory()
|
||||||
|
}
|
||||||
|
updateClearHistoryVisibility()
|
||||||
fun searchTitle() {
|
fun searchTitle() {
|
||||||
activity.result.apply {
|
activity.result.apply {
|
||||||
search =
|
search =
|
||||||
|
@ -300,11 +306,17 @@ class SearchAdapter(private val activity: SearchActivity, private val type: Stri
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.searchResultLayout.visibility = View.VISIBLE
|
binding.searchResultLayout.visibility = View.VISIBLE
|
||||||
|
binding.clearHistory.visibility = View.GONE
|
||||||
binding.searchHistoryList.visibility = View.GONE
|
binding.searchHistoryList.visibility = View.GONE
|
||||||
binding.searchByImage.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 {
|
private fun fadeInAnimation(): Animation {
|
||||||
return AlphaAnimation(0f, 1f).apply {
|
return AlphaAnimation(0f, 1f).apply {
|
||||||
duration = 150
|
duration = 150
|
||||||
|
@ -375,4 +387,3 @@ class SearchAdapter(private val activity: SearchActivity, private val type: Stri
|
||||||
override fun getItemCount(): Int = chips.size
|
override fun getItemCount(): Int = chips.size
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,12 @@ class SearchHistoryAdapter(private val type: String, private val searchClicked:
|
||||||
PrefManager.setVal(historyType, searchHistory)
|
PrefManager.setVal(historyType, searchHistory)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun clearHistory() {
|
||||||
|
searchHistory?.clear()
|
||||||
|
PrefManager.setVal(historyType, searchHistory)
|
||||||
|
submitList(searchHistory?.toList())
|
||||||
|
}
|
||||||
|
|
||||||
override fun onCreateViewHolder(
|
override fun onCreateViewHolder(
|
||||||
parent: ViewGroup,
|
parent: ViewGroup,
|
||||||
viewType: Int
|
viewType: Int
|
||||||
|
|
10
app/src/main/res/drawable/ic_round_history_24.xml
Normal file
10
app/src/main/res/drawable/ic_round_history_24.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="?attr/colorControlNormal"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:viewportWidth="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M13.26,3C8.17,2.86 4,6.95 4,12L2.21,12c-0.45,0 -0.67,0.54 -0.35,0.85l2.79,2.8c0.2,0.2 0.51,0.2 0.71,0l2.79,-2.8c0.31,-0.31 0.09,-0.85 -0.36,-0.85L6,12c0,-3.9 3.18,-7.05 7.1,-7 3.72,0.05 6.85,3.18 6.9,6.9 0.05,3.91 -3.1,7.1 -7,7.1 -1.61,0 -3.1,-0.55 -4.28,-1.48 -0.4,-0.31 -0.96,-0.28 -1.32,0.08 -0.42,0.42 -0.39,1.13 0.08,1.49C9,20.29 10.91,21 13,21c5.05,0 9.14,-4.17 9,-9.26 -0.13,-4.69 -4.05,-8.61 -8.74,-8.74zM12.75,8c-0.41,0 -0.75,0.34 -0.75,0.75v3.68c0,0.35 0.19,0.68 0.49,0.86l3.12,1.85c0.36,0.21 0.82,0.09 1.03,-0.26 0.21,-0.36 0.09,-0.82 -0.26,-1.03l-2.88,-1.71v-3.4c0,-0.4 -0.34,-0.74 -0.75,-0.74z"/>
|
||||||
|
</vector>
|
|
@ -117,6 +117,32 @@
|
||||||
app:drawableTint="?attr/colorPrimary" />
|
app:drawableTint="?attr/colorPrimary" />
|
||||||
</androidx.cardview.widget.CardView>
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
|
<androidx.cardview.widget.CardView
|
||||||
|
android:id="@+id/clearHistory"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:padding="8dp"
|
||||||
|
app:boxStrokeColor="@color/text_input_layout_stroke_color"
|
||||||
|
app:cardBackgroundColor="@color/nav_bg"
|
||||||
|
app:cardCornerRadius="16dp"
|
||||||
|
app:contentPadding="4dp"
|
||||||
|
app:contentPaddingLeft="8dp"
|
||||||
|
app:contentPaddingRight="8dp"
|
||||||
|
tools:ignore="ContentDescription,TextContrastCheck">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:drawablePadding="4dp"
|
||||||
|
android:fontFamily="@font/poppins_bold"
|
||||||
|
android:text="@string/clear_history"
|
||||||
|
android:textColor="?attr/colorPrimary"
|
||||||
|
app:drawableStartCompat="@drawable/ic_round_history_24"
|
||||||
|
app:drawableTint="?attr/colorPrimary" />
|
||||||
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
<ani.dantotsu.FadingEdgeRecyclerView
|
<ani.dantotsu.FadingEdgeRecyclerView
|
||||||
android:id="@+id/searchChipRecycler"
|
android:id="@+id/searchChipRecycler"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
|
|
@ -961,6 +961,7 @@ Non quae tempore quo provident laudantium qui illo dolor vel quia dolor et exerc
|
||||||
<string name="install_addon">Install Add-on</string>
|
<string name="install_addon">Install Add-on</string>
|
||||||
<string name="download_addon_not_found">Add-on not found</string>
|
<string name="download_addon_not_found">Add-on not found</string>
|
||||||
<string name="image">Image</string>
|
<string name="image">Image</string>
|
||||||
|
<string name="clear_history">Clear History</string>
|
||||||
<string name="failed_ext_install_conflict">Failed to install extension due to conflict</string>
|
<string name="failed_ext_install_conflict">Failed to install extension due to conflict</string>
|
||||||
<string name="reading">READING</string>
|
<string name="reading">READING</string>
|
||||||
<string name="watching">WATCHING</string>
|
<string name="watching">WATCHING</string>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue