Added clear field button on start call filter

This commit is contained in:
Sylvain Berfini 2023-08-29 14:38:19 +02:00
parent 26c79e6740
commit 544ae39a95
14 changed files with 60 additions and 26 deletions

View file

@ -29,4 +29,9 @@ class StartCallViewModel @UiThread constructor() : ViewModel() {
val emptyContactsList = MutableLiveData<Boolean>()
val emptySuggestionsList = MutableLiveData<Boolean>()
@UiThread
fun clearFilter() {
searchFilter.value = ""
}
}

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true"
android:drawable="@drawable/shape_edit_text_focused_background" />
<item android:state_enabled="false"
android:drawable="@drawable/shape_edit_text_disabled_background" />
<item
android:drawable="@drawable/shape_edit_text_background" />
</selector>

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners android:radius="24dp" />
<corners android:radius="63dp" />
<solid android:color="@color/white"/>
<size android:height="48dp" android:width="234dp" />
<stroke android:width="1dp" android:color="@color/gray_9" />
</shape>

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners android:radius="63dp" />
<solid android:color="@color/white"/>
<stroke android:width="1dp" android:color="@color/primary_color" />
</shape>

View file

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners android:radius="28dp" />
<solid android:color="@color/gray_2"/>
</shape>

View file

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners android:radius="28dp" />
<solid android:color="@color/gray_6"/>
</shape>

View file

@ -113,7 +113,7 @@
android:textSize="14sp"
android:textColor="@color/gray_9"
android:maxLines="1"
android:background="@drawable/shape_edit_text_background"
android:background="@drawable/edit_text_background"
android:inputType="text|textPersonName"
app:layout_constraintTop_toBottomOf="@id/first_name_label"
app:layout_constraintStart_toStartOf="parent"

View file

@ -80,7 +80,7 @@
android:text="@={viewModel.username, default=`johndoe`}"
android:textSize="14sp"
android:textColor="@color/gray_9"
android:background="@drawable/shape_edit_text_background"
android:background="@drawable/edit_text_background"
app:layout_constraintTop_toBottomOf="@id/username_label"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
@ -111,7 +111,7 @@
android:text="@={viewModel.password, default=`johndoe`}"
android:textSize="14sp"
android:textColor="@color/gray_9"
android:background="@drawable/shape_edit_text_background"
android:background="@drawable/edit_text_background"
android:inputType="@{viewModel.showPassword ? InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD : InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD, default=textPassword}"
app:layout_constraintTop_toBottomOf="@id/password_label"
app:layout_constraintStart_toStartOf="parent"

View file

@ -73,7 +73,7 @@
android:text="John Doe"
android:textSize="14sp"
android:textColor="@color/gray_9"
android:background="@drawable/shape_edit_text_background"
android:background="@drawable/edit_text_background"
app:layout_constraintTop_toBottomOf="@id/username_label"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
@ -104,7 +104,7 @@
android:text="+33 6 01 02 03 04 05"
android:textSize="14sp"
android:textColor="@color/gray_9"
android:background="@drawable/shape_edit_text_background"
android:background="@drawable/edit_text_background"
app:layout_constraintTop_toBottomOf="@id/phone_number_label"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
@ -135,7 +135,7 @@
android:text="John Doe"
android:textSize="14sp"
android:textColor="@color/gray_9"
android:background="@drawable/shape_edit_text_background"
android:background="@drawable/edit_text_background"
android:inputType="textPassword"
android:drawableEnd="@drawable/eye"
android:drawableTint="@color/gray_1"

View file

@ -47,6 +47,16 @@
app:layout_constraintStart_toEndOf="@id/back"
app:layout_constraintTop_toTopOf="parent"/>
<View
android:id="@+id/background"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@color/gray_7"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/title"
app:layout_constraintBottom_toBottomOf="parent" />
<androidx.appcompat.widget.AppCompatEditText
style="@style/default_text_style"
android:id="@+id/search_bar"
@ -62,7 +72,7 @@
android:drawableStart="@drawable/magnifying_glass"
android:drawablePadding="10dp"
android:drawableTint="@color/gray_9"
android:background="@drawable/shape_search_square_background"
android:background="@drawable/edit_text_background"
android:hint="Search contact or history call"
android:text="@={viewModel.searchFilter}"
android:textSize="14sp"
@ -71,6 +81,20 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/title" />
<ImageView
android:onClick="@{() -> viewModel.clearFilter()}"
android:id="@+id/clear_field"
android:visibility="@{viewModel.searchFilter.length() > 0 ? View.VISIBLE : View.GONE, default=gone}"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="15dp"
android:src="@drawable/x"
app:tint="@color/gray_9"
app:layout_constraintTop_toTopOf="@id/search_bar"
app:layout_constraintBottom_toBottomOf="@id/search_bar"
app:layout_constraintEnd_toEndOf="@id/search_bar"/>
<!-- margin start must be half the size of the group_call_icon below -->
<View
android:id="@+id/gradient_background"

View file

@ -44,7 +44,7 @@
android:text="@={model.value}"
android:textSize="14sp"
android:textColor="@color/gray_9"
android:background="@drawable/shape_edit_text_background"
android:background="@drawable/edit_text_background"
android:maxLines="1"
android:inputType="@{model.isSip ? InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS : InputType.TYPE_CLASS_PHONE}"
app:layout_constraintTop_toBottomOf="@id/label"

View file

@ -141,7 +141,7 @@
android:textSize="14sp"
android:textColor="@color/gray_9"
android:maxLines="1"
android:background="@drawable/shape_edit_text_background"
android:background="@drawable/edit_text_background"
android:inputType="text|textPersonName"
app:layout_constraintTop_toBottomOf="@id/first_name_label"
app:layout_constraintStart_toStartOf="parent"
@ -175,7 +175,7 @@
android:textSize="14sp"
android:textColor="@color/gray_9"
android:maxLines="1"
android:background="@drawable/shape_edit_text_background"
android:background="@drawable/edit_text_background"
android:inputType="text|textPersonName"
app:layout_constraintTop_toBottomOf="@id/last_name_label"
app:layout_constraintStart_toStartOf="parent"
@ -229,7 +229,7 @@
android:textSize="14sp"
android:textColor="@color/gray_9"
android:maxLines="1"
android:background="@drawable/shape_edit_text_background"
android:background="@drawable/edit_text_background"
android:inputType="text"
app:layout_constraintTop_toBottomOf="@id/company_label"
app:layout_constraintStart_toStartOf="parent"
@ -264,7 +264,7 @@
android:textSize="14sp"
android:textColor="@color/gray_9"
android:maxLines="1"
android:background="@drawable/shape_edit_text_background"
android:background="@drawable/edit_text_background"
android:inputType="text"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/job_title_label"

View file

@ -181,7 +181,7 @@
android:paddingBottom="5dp"
android:maxLines="5"
android:textSize="14sp"
android:background="@drawable/shape_edittext_white_background"
android:background="@drawable/edit_text_background"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@id/attach_file"
app:layout_constraintEnd_toStartOf="@id/voice_message"/>

View file

@ -90,7 +90,7 @@
android:padding="10dp"
android:drawableStart="@drawable/magnifying_glass"
android:drawablePadding="10dp"
android:background="@drawable/shape_search_square_background"
android:background="@drawable/edit_text_background"
android:hint="Rechercher des contacts"
android:text="@={viewModel.filter}"
android:textSize="14sp"