Skip to content

Commit

Permalink
Merge pull request #4497 from nextcloud/add_clear_icon
Browse files Browse the repository at this point in the history
Add clear icon for search view in open conversations
  • Loading branch information
mahibi authored Dec 13, 2024
2 parents 10203b5 + bda0531 commit f41efd9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class ListOpenConversationsActivity : BaseActivity() {
setContentView(binding.root)
setupSystemColors()
viewThemeUtils.platform.colorImageView(binding.searchOpenConversations, ColorRole.ON_SURFACE)
viewThemeUtils.platform.colorEditText(binding.searchEdit)
viewThemeUtils.material.colorTextInputLayout(binding.textInputLayout)

val user = currentUserProvider.currentUser.blockingGet()

Expand All @@ -68,7 +68,7 @@ class ListOpenConversationsActivity : BaseActivity() {
searching = !searching
handleSearchUI(searching)
}
binding.searchEdit.doOnTextChanged { text, _, _, count ->
binding.editText.doOnTextChanged { text, _, _, count ->
adapter.filter(text.toString())
}

Expand All @@ -78,11 +78,11 @@ class ListOpenConversationsActivity : BaseActivity() {
private fun handleSearchUI(show: Boolean) {
if (show) {
binding.searchOpenConversations.visibility = View.GONE
binding.searchEdit.visibility = View.VISIBLE
binding.searchEdit.showKeyboardAndFocus()
binding.textInputLayout.visibility = View.VISIBLE
binding.editText.showKeyboardAndFocus()
} else {
binding.searchOpenConversations.visibility = View.VISIBLE
binding.searchEdit.visibility = View.GONE
binding.textInputLayout.visibility = View.GONE
}
}

Expand Down
22 changes: 19 additions & 3 deletions app/src/main/res/layout/activity_open_conversations.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
Expand Down Expand Up @@ -38,13 +39,28 @@
android:layout_marginHorizontal="@dimen/standard_margin"
android:src="@drawable/ic_search_white_24dp" />

<com.google.android.material.textfield.TextInputEditText
android:id="@+id/search_edit"
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/textInputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:endIconMode="clear_text"
app:boxBackgroundMode="none"
android:visibility="gone"
/>
tools:visibility="visible"
app:hintEnabled="false"
app:endIconTint="@color/icon_on_bg_default"
android:layout_marginEnd = "8dp">

<com.google.android.material.textfield.TextInputEditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/nc_search"
android:textColorHint="@color/low_emphasis_text"
android:textColor = "@color/high_emphasis_text"/>
</com.google.android.material.textfield.TextInputLayout>
</com.google.android.material.appbar.MaterialToolbar>

</com.google.android.material.appbar.AppBarLayout>

<androidx.recyclerview.widget.RecyclerView
Expand Down

0 comments on commit f41efd9

Please sign in to comment.