mirror of
https://github.com/SimpleMobileTools/Simple-Dialer.git
synced 2025-03-20 13:20:19 +01:00
Merge pull request #452 from Naveen3Singh/dialpad_ltr
Disable RTL layout in dialpad and some other improvements
This commit is contained in:
commit
688ef819e6
@ -205,6 +205,7 @@ class CallActivity : SimpleActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
call_sim_id.setTextColor(getProperTextColor().getContrastColor())
|
call_sim_id.setTextColor(getProperTextColor().getContrastColor())
|
||||||
|
dialpad_input.disableKeyboard()
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("ClickableViewAccessibility")
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
|
@ -24,6 +24,7 @@ import com.simplemobiletools.commons.models.SimpleContact
|
|||||||
import com.simplemobiletools.dialer.R
|
import com.simplemobiletools.dialer.R
|
||||||
import com.simplemobiletools.dialer.adapters.ContactsAdapter
|
import com.simplemobiletools.dialer.adapters.ContactsAdapter
|
||||||
import com.simplemobiletools.dialer.extensions.*
|
import com.simplemobiletools.dialer.extensions.*
|
||||||
|
import com.simplemobiletools.dialer.helpers.DIALPAD_TONE_LENGTH_MS
|
||||||
import com.simplemobiletools.dialer.helpers.ToneGeneratorHelper
|
import com.simplemobiletools.dialer.helpers.ToneGeneratorHelper
|
||||||
import com.simplemobiletools.dialer.models.SpeedDial
|
import com.simplemobiletools.dialer.models.SpeedDial
|
||||||
import kotlinx.android.synthetic.main.activity_dialpad.*
|
import kotlinx.android.synthetic.main.activity_dialpad.*
|
||||||
@ -55,9 +56,9 @@ class DialpadActivity : SimpleActivity() {
|
|||||||
|
|
||||||
setupOptionsMenu()
|
setupOptionsMenu()
|
||||||
speedDialValues = config.getSpeedDialValues()
|
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) {
|
if (hasRussianLocale) {
|
||||||
initRussianChars()
|
initRussianChars()
|
||||||
@ -99,7 +100,7 @@ class DialpadActivity : SimpleActivity() {
|
|||||||
dialpad_input.requestFocus()
|
dialpad_input.requestFocus()
|
||||||
|
|
||||||
SimpleContactsHelper(this).getAvailableContacts(false) { gotContacts(it) }
|
SimpleContactsHelper(this).getAvailableContacts(false) { gotContacts(it) }
|
||||||
disableKeyboardPopping()
|
dialpad_input.disableKeyboard()
|
||||||
|
|
||||||
val properPrimaryColor = getProperPrimaryColor()
|
val properPrimaryColor = getProperPrimaryColor()
|
||||||
val callIconId = if (areMultipleSIMsAvailable()) {
|
val callIconId = if (areMultipleSIMsAvailable()) {
|
||||||
@ -179,10 +180,6 @@ class DialpadActivity : SimpleActivity() {
|
|||||||
dialpad_input.setText("")
|
dialpad_input.setText("")
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun disableKeyboardPopping() {
|
|
||||||
dialpad_input.showSoftInputOnFocus = false
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun gotContacts(newContacts: ArrayList<SimpleContact>) {
|
private fun gotContacts(newContacts: ArrayList<SimpleContact>) {
|
||||||
allContacts = newContacts
|
allContacts = newContacts
|
||||||
|
|
||||||
|
@ -24,3 +24,7 @@ private fun getCharKeyCode(char: Char) = when (char) {
|
|||||||
'+' -> KeyEvent.KEYCODE_PLUS
|
'+' -> KeyEvent.KEYCODE_PLUS
|
||||||
else -> KeyEvent.KEYCODE_POUND
|
else -> KeyEvent.KEYCODE_POUND
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun EditText.disableKeyboard() {
|
||||||
|
showSoftInputOnFocus = false
|
||||||
|
}
|
||||||
|
@ -5,4 +5,3 @@ import android.view.View
|
|||||||
|
|
||||||
val View.boundingBox
|
val View.boundingBox
|
||||||
get() = Rect().also { getGlobalVisibleRect(it) }
|
get() = Rect().also { getGlobalVisibleRect(it) }
|
||||||
|
|
||||||
|
@ -4,16 +4,20 @@ import android.content.Context
|
|||||||
import android.media.AudioManager
|
import android.media.AudioManager
|
||||||
import android.media.AudioManager.STREAM_DTMF
|
import android.media.AudioManager.STREAM_DTMF
|
||||||
import android.media.ToneGenerator
|
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 audioManager = context.getSystemService(Context.AUDIO_SERVICE) as AudioManager
|
||||||
private val toneGenerator = ToneGenerator(DIAL_TONE_STREAM_TYPE, TONE_RELATIVE_VOLUME)
|
private val toneGenerator = ToneGenerator(DIAL_TONE_STREAM_TYPE, TONE_RELATIVE_VOLUME)
|
||||||
|
private var toneStartTimeMs = 0L
|
||||||
|
|
||||||
private fun isSilent(): Boolean {
|
private fun isSilent(): Boolean {
|
||||||
return audioManager.ringerMode in arrayOf(AudioManager.RINGER_MODE_SILENT, AudioManager.RINGER_MODE_VIBRATE)
|
return audioManager.ringerMode in arrayOf(AudioManager.RINGER_MODE_SILENT, AudioManager.RINGER_MODE_VIBRATE)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun startTone(char: Char) {
|
fun startTone(char: Char) {
|
||||||
|
toneStartTimeMs = System.currentTimeMillis()
|
||||||
startTone(charToTone[char] ?: -1)
|
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 {
|
companion object {
|
||||||
const val TONE_RELATIVE_VOLUME = 80 // The DTMF tone volume relative to other sounds in the stream
|
const val TONE_RELATIVE_VOLUME = 80 // The DTMF tone volume relative to other sounds in the stream
|
||||||
|
@ -89,6 +89,7 @@
|
|||||||
android:layout_marginStart="@dimen/activity_margin"
|
android:layout_marginStart="@dimen/activity_margin"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:inputType="phone"
|
android:inputType="phone"
|
||||||
|
android:layoutDirection="ltr"
|
||||||
android:textCursorDrawable="@null"
|
android:textCursorDrawable="@null"
|
||||||
android:textSize="@dimen/dialpad_text_size"
|
android:textSize="@dimen/dialpad_text_size"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/dialpad_wrapper"
|
app:layout_constraintBottom_toTopOf="@+id/dialpad_wrapper"
|
||||||
@ -101,6 +102,7 @@
|
|||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_marginEnd="@dimen/activity_margin"
|
android:layout_marginEnd="@dimen/activity_margin"
|
||||||
android:background="?attr/selectableItemBackgroundBorderless"
|
android:background="?attr/selectableItemBackgroundBorderless"
|
||||||
|
android:layoutDirection="ltr"
|
||||||
android:paddingStart="@dimen/activity_margin"
|
android:paddingStart="@dimen/activity_margin"
|
||||||
android:paddingEnd="@dimen/activity_margin"
|
android:paddingEnd="@dimen/activity_margin"
|
||||||
android:src="@drawable/ic_clear_vector"
|
android:src="@drawable/ic_clear_vector"
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentBottom="true"
|
android:layout_alignParentBottom="true"
|
||||||
android:focusableInTouchMode="true"
|
android:focusableInTouchMode="true"
|
||||||
|
android:layoutDirection="ltr"
|
||||||
android:paddingTop="@dimen/medium_margin"
|
android:paddingTop="@dimen/medium_margin"
|
||||||
tools:ignore="HardcodedText">
|
tools:ignore="HardcodedText">
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user