forked from mirrors/linphone-iphone
Prevent Audio memo download in service extension + auto download them in app if configured as such
This commit is contained in:
parent
abea256244
commit
776be65518
2 changed files with 35 additions and 1 deletions
|
|
@ -646,6 +646,7 @@ class MultilineMessageCell: SwipeCollectionViewCell, UICollectionViewDataSource,
|
||||||
recordingDurationTextView.text = recordingDuration(filePathRecording)
|
recordingDurationTextView.text = recordingDuration(filePathRecording)
|
||||||
|
|
||||||
recordingPlayButton.onClickAction = {
|
recordingPlayButton.onClickAction = {
|
||||||
|
self.downloadAudioMemoIfNeeded(message: message)
|
||||||
self.playRecordedMessage(voiceRecorder: filePathRecording, recordingPlayButton: recordingPlayButton, recordingStopButton: recordingStopButton, recordingWaveView: recordingWaveView, message: message)
|
self.playRecordedMessage(voiceRecorder: filePathRecording, recordingPlayButton: recordingPlayButton, recordingStopButton: recordingStopButton, recordingWaveView: recordingWaveView, message: message)
|
||||||
}
|
}
|
||||||
recordingStopButton.onClickAction = {
|
recordingStopButton.onClickAction = {
|
||||||
|
|
@ -661,9 +662,27 @@ class MultilineMessageCell: SwipeCollectionViewCell, UICollectionViewDataSource,
|
||||||
NSLayoutConstraint.activate(recordingWaveConstraints)
|
NSLayoutConstraint.activate(recordingWaveConstraints)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Core.get().autoDownloadVoiceRecordingsEnabled) {
|
||||||
|
downloadAudioMemoIfNeeded(message: message)
|
||||||
|
}
|
||||||
|
|
||||||
recordingView.isHidden = false
|
recordingView.isHidden = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func downloadAudioMemoIfNeeded(message: ChatMessage) {
|
||||||
|
if let audioContent = message.contents.filter({$0.isVoiceRecording}).first {
|
||||||
|
if (audioContent.filePath == nil || !FileUtil.fileExistsAndIsNotEmpty(path: audioContent.filePath!)) {
|
||||||
|
audioContent.filePath = LinphoneManager.imagesDirectory() + audioContent.name!;
|
||||||
|
if message.downloadContent(content: audioContent) {
|
||||||
|
Log.i("Started downloading voice memo")
|
||||||
|
} else {
|
||||||
|
Log.i("An error occured downloading voice memo")
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func initReplyView(){
|
func initReplyView(){
|
||||||
//Reply - Contents
|
//Reply - Contents
|
||||||
|
|
||||||
|
|
@ -1806,7 +1825,7 @@ class MultilineMessageCell: SwipeCollectionViewCell, UICollectionViewDataSource,
|
||||||
AudioPlayer.sharedModel.fileChanged.value = voiceRecorder
|
AudioPlayer.sharedModel.fileChanged.value = voiceRecorder
|
||||||
recordingPlayButton.isHidden = true
|
recordingPlayButton.isHidden = true
|
||||||
recordingStopButton.isHidden = false
|
recordingStopButton.isHidden = false
|
||||||
|
|
||||||
AudioPlayer.startSharedPlayer(voiceRecorder)
|
AudioPlayer.startSharedPlayer(voiceRecorder)
|
||||||
isPlayingVoiceRecording = true
|
isPlayingVoiceRecording = true
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -233,6 +233,21 @@ class NotificationService: UNNotificationServiceExtension {
|
||||||
NotificationService.logDelegate = try! LinphoneLoggingServiceManager(config: config!, log: NotificationService.log, domain: "msgNotificationService")
|
NotificationService.logDelegate = try! LinphoneLoggingServiceManager(config: config!, log: NotificationService.log, domain: "msgNotificationService")
|
||||||
}
|
}
|
||||||
lc = try! Factory.Instance.createSharedCoreWithConfig(config: config!, systemContext: nil, appGroupId: APP_GROUP_ID, mainCore: false)
|
lc = try! Factory.Instance.createSharedCoreWithConfig(config: config!, systemContext: nil, appGroupId: APP_GROUP_ID, mainCore: false)
|
||||||
|
|
||||||
|
|
||||||
|
// Disable auto downloads in service extension
|
||||||
|
|
||||||
|
// Save config values
|
||||||
|
let configMaxSizeForAutoDownloadIncomingFiles = config?.getInt(section: "app", key: "auto_download_incoming_files_max_size", defaultValue: -1)
|
||||||
|
let configAutoDownloadVoiceRecordingsEnabled = config?.getBool(section: "app", key: "auto_download_incoming_voice_recordings", defaultValue: true)
|
||||||
|
|
||||||
|
// Disable downloads in service extension (API calls below will set the core attributes value + config)
|
||||||
|
lc?.maxSizeForAutoDownloadIncomingFiles = -1
|
||||||
|
lc?.autoDownloadVoiceRecordingsEnabled = false
|
||||||
|
|
||||||
|
// restore the config values for the app
|
||||||
|
config?.setInt(section: "app", key: "auto_download_incoming_files_max_size", value: configMaxSizeForAutoDownloadIncomingFiles!)
|
||||||
|
config?.setBool(section: "app", key: "auto_download_incoming_voice_recordings", value: configAutoDownloadVoiceRecordingsEnabled!)
|
||||||
}
|
}
|
||||||
|
|
||||||
func stopCore() {
|
func stopCore() {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue