Added answer/decline keyboard shortcuts to CallActivity

This commit is contained in:
Sylvain Berfini 2025-12-03 10:27:21 +01:00
parent 7817e6603c
commit e173e402c2
2 changed files with 56 additions and 1 deletions

View file

@ -14,6 +14,7 @@ Group changes to describe their impact on the project, as follows:
### Added ### Added
- Added the ability to edit/delete chat messages sent less than 24 hours ago. - Added the ability to edit/delete chat messages sent less than 24 hours ago.
- Added keyboard shortcuts on IncomingCallFragment: Ctrl + Shift + A to answer the call, Ctrl + Shift + D to decline it
- Added PDF preview in conversation (message bubble & documents list) - Added PDF preview in conversation (message bubble & documents list)
- Added hover effect when using a mouse (useful for tablets or devices with desktop mode) - Added hover effect when using a mouse (useful for tablets or devices with desktop mode)
- Support right click on some items to open bottom sheet/menu - Support right click on some items to open bottom sheet/menu
@ -35,6 +36,7 @@ Group changes to describe their impact on the project, as follows:
- Removing an account will also remove all related data in the local database (auth info, call logs, conversations, meetings, etc...) - Removing an account will also remove all related data in the local database (auth info, call logs, conversations, meetings, etc...)
- Hide SIP address/phone number picker dialog if contact has exactly one SIP address matching both the app default domain & the currently selected account domain - Hide SIP address/phone number picker dialog if contact has exactly one SIP address matching both the app default domain & the currently selected account domain
- Improved UI on tablets with screen sw600dp and higher, will look more like our desktop app - Improved UI on tablets with screen sw600dp and higher, will look more like our desktop app
- Improved navigation within app when using a keyboard
- Now loading media/documents contents in conversation by chunks (instead of all of them at once) - Now loading media/documents contents in conversation by chunks (instead of all of them at once)
- Simplified audio device name in settings - Simplified audio device name in settings
- Reworked some settings (moved calls related ones from advanced settings to advanced calls settings) - Reworked some settings (moved calls related ones from advanced settings to advanced calls settings)
@ -43,6 +45,10 @@ Group changes to describe their impact on the project, as follows:
- Made numpad buttons larger by changing their shape - Made numpad buttons larger by changing their shape
- All LDAP fields are mandatory now - All LDAP fields are mandatory now
- Permission fragment will only show missing ones - Permission fragment will only show missing ones
- Added more info into StartupListener logs
### Fixed
- No audio focus & wrong audio manager mode when TelecomManager isn't supported by device
## [6.0.20] - 2025-11-21 ## [6.0.20] - 2025-11-21

View file

@ -25,6 +25,10 @@ import android.content.pm.PackageManager
import android.content.res.Resources import android.content.res.Resources
import android.graphics.Color import android.graphics.Color
import android.os.Bundle import android.os.Bundle
import android.view.KeyEvent
import android.view.KeyboardShortcutGroup
import android.view.KeyboardShortcutInfo
import android.view.Menu
import androidx.activity.SystemBarStyle import androidx.activity.SystemBarStyle
import androidx.activity.enableEdgeToEdge import androidx.activity.enableEdgeToEdge
import androidx.activity.result.contract.ActivityResultContracts import androidx.activity.result.contract.ActivityResultContracts
@ -66,6 +70,7 @@ import org.linphone.ui.call.viewmodel.CallsViewModel
import org.linphone.ui.call.viewmodel.CurrentCallViewModel import org.linphone.ui.call.viewmodel.CurrentCallViewModel
import org.linphone.ui.call.viewmodel.SharedCallViewModel import org.linphone.ui.call.viewmodel.SharedCallViewModel
import org.linphone.ui.main.MainActivity import org.linphone.ui.main.MainActivity
import org.linphone.utils.AppUtils
@UiThread @UiThread
class CallActivity : GenericActivity() { class CallActivity : GenericActivity() {
@ -408,7 +413,51 @@ class CallActivity : GenericActivity() {
} }
} }
@UiThread override fun onProvideKeyboardShortcuts(
data: MutableList<KeyboardShortcutGroup?>?,
menu: Menu?,
deviceId: Int
) {
super.onProvideKeyboardShortcuts(data, menu, deviceId)
val keyboardShortcutGroup = KeyboardShortcutGroup(
"Answer/Decline incoming call",
listOf(
KeyboardShortcutInfo(
AppUtils.getString(R.string.call_action_answer),
KeyEvent.KEYCODE_A,
KeyEvent.META_CTRL_ON or KeyEvent.META_SHIFT_ON
),
KeyboardShortcutInfo(
AppUtils.getString(R.string.call_action_decline),
KeyEvent.KEYCODE_D,
KeyEvent.META_CTRL_ON or KeyEvent.META_SHIFT_ON
)
)
)
data?.add(keyboardShortcutGroup)
Log.i("$TAG Incoming call answer/decline shortcuts added")
}
override fun onKeyShortcut(keyCode: Int, event: KeyEvent?): Boolean {
if (event?.isCtrlPressed == true && event.isShiftPressed) {
val navController = findNavController(R.id.call_nav_container)
if (navController.currentDestination?.id == R.id.incomingCallFragment) {
when (keyCode) {
KeyEvent.KEYCODE_A -> {
Log.i("$TAG Answer incoming call shortcut triggered")
callViewModel.answer()
}
KeyEvent.KEYCODE_D -> {
Log.i("$TAG Decline incoming call shortcut triggered")
callViewModel.hangUp()
}
}
}
}
return true
}
fun goToMainActivity() { fun goToMainActivity() {
if (isPipSupported && callViewModel.isVideoEnabled.value == true) { if (isPipSupported && callViewModel.isVideoEnabled.value == true) {
Log.i("$TAG User is going back to MainActivity, try entering PiP mode") Log.i("$TAG User is going back to MainActivity, try entering PiP mode")