mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Added backspace button in numpad
This commit is contained in:
parent
c8ea1bcd8c
commit
d51f25ea88
5 changed files with 54 additions and 0 deletions
|
|
@ -147,6 +147,21 @@ class StartCallFragment : GenericFragment() {
|
|||
viewModel.applyFilter(trimmed)
|
||||
}
|
||||
|
||||
viewModel.removedCharacterAtCurrentPositionEvent.observe(viewLifecycleOwner) {
|
||||
it.consume {
|
||||
val selectionStart = binding.searchBar.selectionStart
|
||||
val selectionEnd = binding.searchBar.selectionEnd
|
||||
if (selectionStart > 0) {
|
||||
binding.searchBar.text =
|
||||
binding.searchBar.text?.delete(
|
||||
selectionStart - 1,
|
||||
selectionEnd
|
||||
)
|
||||
binding.searchBar.setSelection(selectionStart - 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.appendDigitToSearchBarEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { digit ->
|
||||
val newValue = "${binding.searchBar.text}$digit"
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import org.linphone.core.tools.Log
|
|||
|
||||
class NumpadModel @UiThread constructor(
|
||||
private val onDigitClicked: (value: String) -> (Unit),
|
||||
private val onBackspaceClicked: () -> (Unit),
|
||||
private val onCallClicked: () -> (Unit)
|
||||
) {
|
||||
companion object {
|
||||
|
|
@ -42,6 +43,12 @@ class NumpadModel @UiThread constructor(
|
|||
return true
|
||||
}
|
||||
|
||||
@UiThread
|
||||
fun onBackspaceClicked() {
|
||||
Log.i("$TAG Clicked on backspace")
|
||||
onBackspaceClicked.invoke()
|
||||
}
|
||||
|
||||
@UiThread
|
||||
fun onCallClicked() {
|
||||
Log.i("$TAG Starting call")
|
||||
|
|
|
|||
|
|
@ -59,6 +59,10 @@ class StartCallViewModel @UiThread constructor() : ViewModel() {
|
|||
MutableLiveData<Event<String>>()
|
||||
}
|
||||
|
||||
val removedCharacterAtCurrentPositionEvent: MutableLiveData<Event<Boolean>> by lazy {
|
||||
MutableLiveData<Event<Boolean>>()
|
||||
}
|
||||
|
||||
val requestKeyboardVisibilityChangedEvent: MutableLiveData<Event<Boolean>> by lazy {
|
||||
MutableLiveData<Event<Boolean>>()
|
||||
}
|
||||
|
|
@ -103,6 +107,10 @@ class StartCallViewModel @UiThread constructor() : ViewModel() {
|
|||
// Don't do that, cursor will stay at start
|
||||
// searchFilter.value = "${searchFilter.value.orEmpty()}$digit"
|
||||
},
|
||||
{
|
||||
// OnBackspaceClicked
|
||||
removedCharacterAtCurrentPositionEvent.value = Event(true)
|
||||
},
|
||||
{ // OnCallClicked
|
||||
val suggestion = searchFilter.value.orEmpty()
|
||||
if (suggestion.isNotEmpty()) {
|
||||
|
|
|
|||
9
app/src/main/res/drawable/backspace_fill.xml
Normal file
9
app/src/main/res/drawable/backspace_fill.xml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="256"
|
||||
android:viewportHeight="256">
|
||||
<path
|
||||
android:pathData="M216,40H68.53a16.12,16.12 0,0 0,-13.72 7.77L9.14,123.88a8,8 0,0 0,0 8.24l45.67,76.11h0A16.11,16.11 0,0 0,68.53 216H216a16,16 0,0 0,16 -16V56A16,16 0,0 0,216 40ZM165.66,146.34a8,8 0,0 1,-11.32 11.32L136,139.31l-18.35,18.35a8,8 0,0 1,-11.31 -11.32L124.69,128l-18.35,-18.34a8,8 0,1 1,11.31 -11.32L136,116.69l18.34,-18.35a8,8 0,0 1,11.32 11.32L147.31,128Z"
|
||||
android:fillColor="#4e6074"/>
|
||||
</vector>
|
||||
|
|
@ -185,6 +185,21 @@
|
|||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/backspace"
|
||||
android:onClick="@{() -> model.onBackspaceClicked()}"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginBottom="21dp"
|
||||
android:src="@drawable/backspace_fill"
|
||||
android:padding="20dp"
|
||||
android:elevation="3dp"
|
||||
app:layout_constraintTop_toBottomOf="@id/flow"
|
||||
app:layout_constraintStart_toEndOf="@id/call"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</layout>
|
||||
Loading…
Add table
Reference in a new issue