mirror of
https://github.com/SimpleMobileTools/Simple-Dialer.git
synced 2025-06-05 21:49:23 +02:00
Make it possible to disable proximity sensor during calls
There are phones out there with broken proximity sensors that always report near, which causes every dialer app to turn off the screen unconditionally during calls. As an owner of such a phone, this has been driving me crazy. This commit adds a new setting to disable the proximity sensor. By default, this is turned off, preserving the current behaviour.
This commit is contained in:
@ -342,7 +342,7 @@ class CallActivity : SimpleActivity() {
|
||||
}
|
||||
|
||||
private fun initProximitySensor() {
|
||||
if (proximityWakeLock == null || proximityWakeLock?.isHeld == false) {
|
||||
if (!config.disableProximitySensor && (proximityWakeLock == null || proximityWakeLock?.isHeld == false)) {
|
||||
val powerManager = getSystemService(Context.POWER_SERVICE) as PowerManager
|
||||
proximityWakeLock = powerManager.newWakeLock(PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK, "com.simplemobiletools.dialer.pro:wake_lock")
|
||||
proximityWakeLock!!.acquire(10 * MINUTE_SECONDS * 1000L)
|
||||
|
@ -37,6 +37,7 @@ class SettingsActivity : SimpleActivity() {
|
||||
setupGroupSubsequentCalls()
|
||||
setupStartNameWithSurname()
|
||||
setupShowCallConfirmation()
|
||||
setupDisableProximitySensor()
|
||||
updateTextColors(settings_holder)
|
||||
invalidateOptionsMenu()
|
||||
}
|
||||
@ -169,4 +170,12 @@ class SettingsActivity : SimpleActivity() {
|
||||
config.showCallConfirmation = settings_show_call_confirmation.isChecked
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupDisableProximitySensor() {
|
||||
settings_disable_proximity_sensor.isChecked = config.disableProximitySensor
|
||||
settings_disable_proximity_sensor_holder.setOnClickListener {
|
||||
settings_disable_proximity_sensor.toggle()
|
||||
config.disableProximitySensor = settings_disable_proximity_sensor.isChecked
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -47,4 +47,8 @@ class Config(context: Context) : BaseConfig(context) {
|
||||
var openDialPadAtLaunch: Boolean
|
||||
get() = prefs.getBoolean(OPEN_DIAL_PAD_AT_LAUNCH, false)
|
||||
set(openDialPad) = prefs.edit().putBoolean(OPEN_DIAL_PAD_AT_LAUNCH, openDialPad).apply()
|
||||
|
||||
var disableProximitySensor: Boolean
|
||||
get() = prefs.getBoolean(DISABLE_PROXIMITY_SENSOR, false)
|
||||
set(disableProximitySensor) = prefs.edit().putBoolean(DISABLE_PROXIMITY_SENSOR, disableProximitySensor).apply()
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ const val SPEED_DIAL = "speed_dial"
|
||||
const val REMEMBER_SIM_PREFIX = "remember_sim_"
|
||||
const val GROUP_SUBSEQUENT_CALLS = "group_subsequent_calls"
|
||||
const val OPEN_DIAL_PAD_AT_LAUNCH = "open_dial_pad_at_launch"
|
||||
const val DISABLE_PROXIMITY_SENSOR = "disable_proximity_sensor"
|
||||
|
||||
const val CONTACTS_TAB_MASK = 1
|
||||
const val FAVORITES_TAB_MASK = 2
|
||||
|
Reference in New Issue
Block a user