Merge pull request #452 from Naveen3Singh/dialpad_ltr

Disable RTL layout in dialpad and some other improvements
This commit is contained in:
Tibor Kaputa 2022-09-19 14:30:10 +02:00 committed by GitHub
commit 688ef819e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 27 additions and 10 deletions

View File

@ -205,6 +205,7 @@ class CallActivity : SimpleActivity() {
}
call_sim_id.setTextColor(getProperTextColor().getContrastColor())
dialpad_input.disableKeyboard()
}
@SuppressLint("ClickableViewAccessibility")

View File

@ -24,6 +24,7 @@ import com.simplemobiletools.commons.models.SimpleContact
import com.simplemobiletools.dialer.R
import com.simplemobiletools.dialer.adapters.ContactsAdapter
import com.simplemobiletools.dialer.extensions.*
import com.simplemobiletools.dialer.helpers.DIALPAD_TONE_LENGTH_MS
import com.simplemobiletools.dialer.helpers.ToneGeneratorHelper
import com.simplemobiletools.dialer.models.SpeedDial
import kotlinx.android.synthetic.main.activity_dialpad.*
@ -55,9 +56,9 @@ class DialpadActivity : SimpleActivity() {
setupOptionsMenu()
speedDialValues = config.getSpeedDialValues()
privateCursor = getMyContactsCursor(false, true)
privateCursor = getMyContactsCursor(favoritesOnly = false, withPhoneNumbersOnly = true)
toneGeneratorHelper = ToneGeneratorHelper(this)
toneGeneratorHelper = ToneGeneratorHelper(this, DIALPAD_TONE_LENGTH_MS)
if (hasRussianLocale) {
initRussianChars()
@ -99,7 +100,7 @@ class DialpadActivity : SimpleActivity() {
dialpad_input.requestFocus()
SimpleContactsHelper(this).getAvailableContacts(false) { gotContacts(it) }
disableKeyboardPopping()
dialpad_input.disableKeyboard()
val properPrimaryColor = getProperPrimaryColor()
val callIconId = if (areMultipleSIMsAvailable()) {
@ -179,10 +180,6 @@ class DialpadActivity : SimpleActivity() {
dialpad_input.setText("")
}
private fun disableKeyboardPopping() {
dialpad_input.showSoftInputOnFocus = false
}
private fun gotContacts(newContacts: ArrayList<SimpleContact>) {
allContacts = newContacts

View File

@ -24,3 +24,7 @@ private fun getCharKeyCode(char: Char) = when (char) {
'+' -> KeyEvent.KEYCODE_PLUS
else -> KeyEvent.KEYCODE_POUND
}
fun EditText.disableKeyboard() {
showSoftInputOnFocus = false
}

View File

@ -5,4 +5,3 @@ import android.view.View
val View.boundingBox
get() = Rect().also { getGlobalVisibleRect(it) }

View File

@ -4,16 +4,20 @@ import android.content.Context
import android.media.AudioManager
import android.media.AudioManager.STREAM_DTMF
import android.media.ToneGenerator
import android.os.Handler
import android.os.Looper
class ToneGeneratorHelper(context: Context) {
class ToneGeneratorHelper(context: Context, private val minToneLengthMs: Long) {
private val audioManager = context.getSystemService(Context.AUDIO_SERVICE) as AudioManager
private val toneGenerator = ToneGenerator(DIAL_TONE_STREAM_TYPE, TONE_RELATIVE_VOLUME)
private var toneStartTimeMs = 0L
private fun isSilent(): Boolean {
return audioManager.ringerMode in arrayOf(AudioManager.RINGER_MODE_SILENT, AudioManager.RINGER_MODE_VIBRATE)
}
fun startTone(char: Char) {
toneStartTimeMs = System.currentTimeMillis()
startTone(charToTone[char] ?: -1)
}
@ -23,7 +27,16 @@ class ToneGeneratorHelper(context: Context) {
}
}
fun stopTone() = toneGenerator.stopTone()
fun stopTone() {
val timeSinceStartMs = System.currentTimeMillis() - toneStartTimeMs
if (timeSinceStartMs < minToneLengthMs) {
Handler(Looper.getMainLooper()).postDelayed({
toneGenerator.stopTone()
}, minToneLengthMs - timeSinceStartMs)
} else {
toneGenerator.stopTone()
}
}
companion object {
const val TONE_RELATIVE_VOLUME = 80 // The DTMF tone volume relative to other sounds in the stream

View File

@ -89,6 +89,7 @@
android:layout_marginStart="@dimen/activity_margin"
android:gravity="center"
android:inputType="phone"
android:layoutDirection="ltr"
android:textCursorDrawable="@null"
android:textSize="@dimen/dialpad_text_size"
app:layout_constraintBottom_toTopOf="@+id/dialpad_wrapper"
@ -101,6 +102,7 @@
android:layout_height="0dp"
android:layout_marginEnd="@dimen/activity_margin"
android:background="?attr/selectableItemBackgroundBorderless"
android:layoutDirection="ltr"
android:paddingStart="@dimen/activity_margin"
android:paddingEnd="@dimen/activity_margin"
android:src="@drawable/ic_clear_vector"

View File

@ -7,6 +7,7 @@
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:focusableInTouchMode="true"
android:layoutDirection="ltr"
android:paddingTop="@dimen/medium_margin"
tools:ignore="HardcodedText">