Skip to content

Commit cea4adb

Browse files
Honk2naveensingh
andauthored
feat: add backspace button to dialpad (#291)
Added Delete buton to the right Co-authored-by: Naveen Singh <36371707+naveensingh@users.noreply.github.com>
1 parent 5f91264 commit cea4adb

2 files changed

Lines changed: 33 additions & 6 deletions

File tree

app/src/main/kotlin/org/fossify/phone/activities/CallActivity.kt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import android.os.Looper
1313
import android.os.PowerManager
1414
import android.telecom.Call
1515
import android.telecom.CallAudioState
16+
import android.view.KeyEvent
1617
import android.view.MotionEvent
1718
import android.view.View
1819
import android.view.WindowManager
@@ -216,6 +217,8 @@ class CallActivity : SimpleActivity() {
216217
dialpad0Holder.setOnLongClickListener { dialpadPressed('+'); true }
217218
dialpadAsteriskHolder.setOnClickListener { dialpadPressed('*') }
218219
dialpadHashtagHolder.setOnClickListener { dialpadPressed('#') }
220+
dialpadClearChar.setOnClickListener { clearChar(it) }
221+
dialpadClearChar.setOnLongClickListener { clearInput() }
219222
}
220223

221224
dialpadWrapper.setBackgroundColor(
@@ -226,7 +229,7 @@ class CallActivity : SimpleActivity() {
226229
}
227230
)
228231

229-
arrayOf(dialpadClose, callSimImage).forEach {
232+
arrayOf(dialpadClose, callSimImage, dialpadClearChar).forEach {
230233
it.applyColorFilter(getProperTextColor())
231234
}
232235

@@ -877,4 +880,13 @@ class CallActivity : SimpleActivity() {
877880
view.applyColorFilter(getProperBackgroundColor().getContrastColor())
878881
}
879882
}
883+
884+
private fun clearChar(view: View) {
885+
binding.dialpadInput.dispatchKeyEvent(binding.dialpadInput.getKeyEvent(KeyEvent.KEYCODE_DEL))
886+
}
887+
888+
private fun clearInput(): Boolean {
889+
binding.dialpadInput.setText("");
890+
return true;
891+
}
880892
}

app/src/main/res/layout/activity_call.xml

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -446,21 +446,37 @@
446446
android:layout_width="match_parent"
447447
android:layout_height="wrap_content">
448448

449+
<ImageView
450+
android:id="@+id/dialpad_close"
451+
android:layout_width="@dimen/normal_icon_size"
452+
android:layout_height="@dimen/normal_icon_size"
453+
android:layout_alignTop="@+id/dialpad_input"
454+
android:layout_alignBottom="@+id/dialpad_input"
455+
android:layout_alignParentStart="true"
456+
android:layout_centerVertical="true"
457+
android:layout_marginStart="@dimen/activity_margin"
458+
android:background="?attr/selectableItemBackgroundBorderless"
459+
android:contentDescription="@string/hide_dialpad"
460+
android:elevation="@dimen/medium_margin"
461+
android:padding="@dimen/medium_margin"
462+
android:src="@drawable/ic_cross_vector" />
463+
449464
<org.fossify.commons.views.MyEditText
450465
android:id="@+id/dialpad_input"
451466
android:layout_width="match_parent"
452467
android:layout_height="wrap_content"
453-
android:layout_marginStart="@dimen/dialpad_button_size"
468+
android:layout_marginStart="@dimen/medium_margin"
454469
android:layout_marginEnd="@dimen/medium_margin"
455-
android:layout_toStartOf="@+id/dialpad_close"
470+
android:layout_toEndOf="@id/dialpad_close"
471+
android:layout_toStartOf="@+id/dialpad_clear_char"
456472
android:gravity="center"
457473
android:inputType="phone"
458474
android:textCursorDrawable="@null"
459475
android:textSize="@dimen/dialpad_text_size"
460476
tools:ignore="SpUsage" />
461477

462478
<ImageView
463-
android:id="@+id/dialpad_close"
479+
android:id="@+id/dialpad_clear_char"
464480
android:layout_width="@dimen/normal_icon_size"
465481
android:layout_height="@dimen/normal_icon_size"
466482
android:layout_alignTop="@+id/dialpad_input"
@@ -469,10 +485,9 @@
469485
android:layout_centerVertical="true"
470486
android:layout_marginEnd="@dimen/activity_margin"
471487
android:background="?attr/selectableItemBackgroundBorderless"
472-
android:contentDescription="@string/hide_dialpad"
473488
android:elevation="@dimen/medium_margin"
474489
android:padding="@dimen/medium_margin"
475-
android:src="@drawable/ic_cross_vector" />
490+
android:src="@drawable/ic_clear_vector" />
476491

477492
</RelativeLayout>
478493

0 commit comments

Comments
 (0)