mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-14 13:17:08 +02:00
parent
93605db690
commit
cbd2b8f428
5 changed files with 42 additions and 41 deletions
|
@ -559,6 +559,14 @@ HistoryWidget::HistoryWidget(
|
|||
Window::ActivateWindow(controller);
|
||||
});
|
||||
|
||||
Core::App().mediaDevices().recordAvailabilityValue(
|
||||
) | rpl::start_with_next([=](Webrtc::RecordAvailability value) {
|
||||
_recordAvailability = value;
|
||||
if (_list) {
|
||||
updateSendButtonType();
|
||||
}
|
||||
}, lifetime());
|
||||
|
||||
session().data().newItemAdded(
|
||||
) | rpl::start_with_next([=](not_null<HistoryItem*> item) {
|
||||
newItemAdded(item);
|
||||
|
@ -1091,11 +1099,12 @@ void HistoryWidget::initVoiceRecordBar() {
|
|||
!Core::App().settings().recordVideoMessages());
|
||||
updateSendButtonType();
|
||||
switch (_send->type()) {
|
||||
case Ui::SendButton::Type::Record:
|
||||
controller()->showToast(_canRecordVideoMessage
|
||||
case Ui::SendButton::Type::Record: {
|
||||
const auto can = Webrtc::RecordAvailability::VideoAndAudio;
|
||||
controller()->showToast((_recordAvailability == can)
|
||||
? tr::lng_record_voice_tip(tr::now)
|
||||
: tr::lng_record_hold_tip(tr::now));
|
||||
break;
|
||||
} break;
|
||||
case Ui::SendButton::Type::Round:
|
||||
controller()->showToast(tr::lng_record_video_tip(tr::now));
|
||||
break;
|
||||
|
@ -2335,7 +2344,7 @@ void HistoryWidget::showHistory(
|
|||
_contactStatus = nullptr;
|
||||
_businessBotStatus = nullptr;
|
||||
|
||||
updateRecordMediaState();
|
||||
Core::App().mediaDevices().refreshRecordAvailability();
|
||||
|
||||
if (peerId) {
|
||||
using namespace HistoryView;
|
||||
|
@ -4305,8 +4314,9 @@ auto HistoryWidget::computeSendButtonType() const {
|
|||
} else if (_isInlineBot) {
|
||||
return Type::Cancel;
|
||||
} else if (showRecordButton()) {
|
||||
return (Core::App().settings().recordVideoMessages()
|
||||
&& _canRecordVideoMessage)
|
||||
const auto both = Webrtc::RecordAvailability::VideoAndAudio;
|
||||
const auto video = Core::App().settings().recordVideoMessages();
|
||||
return (video && _recordAvailability == both)
|
||||
? Type::Round
|
||||
: Type::Record;
|
||||
}
|
||||
|
@ -4938,7 +4948,7 @@ bool HistoryWidget::isSearching() const {
|
|||
}
|
||||
|
||||
bool HistoryWidget::showRecordButton() const {
|
||||
return _canRecordAudioMessage
|
||||
return (_recordAvailability != Webrtc::RecordAvailability::None)
|
||||
&& !_voiceRecordBar->isListenState()
|
||||
&& !_voiceRecordBar->isRecordingByAnotherBar()
|
||||
&& !HasSendText(_field)
|
||||
|
@ -5541,15 +5551,6 @@ void HistoryWidget::inlineBotChanged() {
|
|||
}
|
||||
}
|
||||
|
||||
void HistoryWidget::updateRecordMediaState() {
|
||||
Media::Capture::instance()->check();
|
||||
_canRecordAudioMessage = Media::Capture::instance()->available();
|
||||
|
||||
const auto environment = &Core::App().mediaDevices();
|
||||
const auto type = Webrtc::DeviceType::Camera;
|
||||
_canRecordVideoMessage = !environment->devices(type).empty();
|
||||
}
|
||||
|
||||
void HistoryWidget::fieldResized() {
|
||||
moveFieldControls();
|
||||
updateHistoryGeometry();
|
||||
|
|
|
@ -81,6 +81,10 @@ namespace Ui::Emoji {
|
|||
class SuggestionsController;
|
||||
} // namespace Ui::Emoji
|
||||
|
||||
namespace Webrtc {
|
||||
enum class RecordAvailability : uchar;
|
||||
} // namespace Webrtc
|
||||
|
||||
namespace Window {
|
||||
class SessionController;
|
||||
} // namespace Window
|
||||
|
@ -499,7 +503,6 @@ private:
|
|||
bool replyToPreviousMessage();
|
||||
bool replyToNextMessage();
|
||||
[[nodiscard]] bool showSlowmodeError();
|
||||
void updateRecordMediaState();
|
||||
|
||||
void hideChildWidgets();
|
||||
void hideSelectorControlsAnimated();
|
||||
|
@ -758,8 +761,7 @@ private:
|
|||
mtpRequestId _inlineBotResolveRequestId = 0;
|
||||
bool _isInlineBot = false;
|
||||
|
||||
bool _canRecordVideoMessage = false;
|
||||
bool _canRecordAudioMessage = false;
|
||||
Webrtc::RecordAvailability _recordAvailability = {};
|
||||
|
||||
std::unique_ptr<HistoryView::ContactStatus> _contactStatus;
|
||||
std::unique_ptr<HistoryView::BusinessBotStatus> _businessBotStatus;
|
||||
|
|
|
@ -964,7 +964,6 @@ void ComposeControls::setHistory(SetHistoryArgs &&args) {
|
|||
initWebpageProcess();
|
||||
initWriteRestriction();
|
||||
initForwardProcess();
|
||||
updateRecordMediaState();
|
||||
updateBotCommandShown();
|
||||
updateLikeShown();
|
||||
updateMessagesTTLShown();
|
||||
|
@ -1519,7 +1518,7 @@ void ComposeControls::orderControls() {
|
|||
}
|
||||
|
||||
bool ComposeControls::showRecordButton() const {
|
||||
return _canRecordAudioMessage
|
||||
return (_recordAvailability != Webrtc::RecordAvailability::None)
|
||||
&& !_voiceRecordBar->isListenState()
|
||||
&& !_voiceRecordBar->isRecordingByAnotherBar()
|
||||
&& !HasSendText(_field)
|
||||
|
@ -2148,12 +2147,17 @@ void ComposeControls::initSendButton() {
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
SendMenu::SetupMenuAndShortcuts(
|
||||
_send.get(),
|
||||
_show,
|
||||
[=] { return sendButtonMenuDetails(); },
|
||||
sendAction);
|
||||
|
||||
Core::App().mediaDevices().recordAvailabilityValue(
|
||||
) | rpl::start_with_next([=](Webrtc::RecordAvailability value) {
|
||||
_recordAvailability = value;
|
||||
updateSendButtonType();
|
||||
}, _send->lifetime());
|
||||
}
|
||||
|
||||
void ComposeControls::initSendAsButton(not_null<PeerData*> peer) {
|
||||
|
@ -2430,11 +2434,12 @@ void ComposeControls::initVoiceRecordBar() {
|
|||
!Core::App().settings().recordVideoMessages());
|
||||
updateSendButtonType();
|
||||
switch (_send->type()) {
|
||||
case Ui::SendButton::Type::Record:
|
||||
_show->showToast(_canRecordVideoMessage
|
||||
case Ui::SendButton::Type::Record: {
|
||||
const auto both = Webrtc::RecordAvailability::VideoAndAudio;
|
||||
_show->showToast((_recordAvailability == both)
|
||||
? tr::lng_record_voice_tip(tr::now)
|
||||
: tr::lng_record_hold_tip(tr::now));
|
||||
break;
|
||||
} break;
|
||||
case Ui::SendButton::Type::Round:
|
||||
_show->showToast(tr::lng_record_video_tip(tr::now));
|
||||
break;
|
||||
|
@ -2465,15 +2470,6 @@ void ComposeControls::initVoiceRecordBar() {
|
|||
}, _wrap->lifetime());
|
||||
}
|
||||
|
||||
void ComposeControls::updateRecordMediaState() {
|
||||
::Media::Capture::instance()->check();
|
||||
_canRecordAudioMessage = ::Media::Capture::instance()->available();
|
||||
|
||||
const auto environment = &Core::App().mediaDevices();
|
||||
const auto type = Webrtc::DeviceType::Camera;
|
||||
_canRecordVideoMessage = !environment->devices(type).empty();
|
||||
}
|
||||
|
||||
void ComposeControls::updateWrappingVisibility() {
|
||||
const auto hidden = _hidden.current();
|
||||
const auto &restriction = _writeRestriction.current();
|
||||
|
@ -2509,8 +2505,9 @@ auto ComposeControls::computeSendButtonType() const {
|
|||
} else if (_isInlineBot) {
|
||||
return Type::Cancel;
|
||||
} else if (showRecordButton()) {
|
||||
return (Core::App().settings().recordVideoMessages()
|
||||
&& _canRecordVideoMessage)
|
||||
const auto both = Webrtc::RecordAvailability::VideoAndAudio;
|
||||
const auto video = Core::App().settings().recordVideoMessages();
|
||||
return (video && _recordAvailability == both)
|
||||
? Type::Round
|
||||
: Type::Record;
|
||||
}
|
||||
|
|
|
@ -76,6 +76,10 @@ namespace Main {
|
|||
class Session;
|
||||
} // namespace Main
|
||||
|
||||
namespace Webrtc {
|
||||
enum class RecordAvailability : uchar;
|
||||
} // namespace Webrtc
|
||||
|
||||
namespace Window {
|
||||
struct SectionShow;
|
||||
class SessionController;
|
||||
|
@ -278,7 +282,6 @@ private:
|
|||
bool updateSendAsButton();
|
||||
void updateAttachBotsMenu();
|
||||
void updateHeight();
|
||||
void updateRecordMediaState();
|
||||
void updateWrappingVisibility();
|
||||
void updateControlsVisibility();
|
||||
void updateControlsGeometry(QSize size);
|
||||
|
@ -437,9 +440,7 @@ private:
|
|||
bool _isInlineBot = false;
|
||||
bool _botCommandShown = false;
|
||||
bool _likeShown = false;
|
||||
|
||||
bool _canRecordVideoMessage = false;
|
||||
bool _canRecordAudioMessage = false;
|
||||
Webrtc::RecordAvailability _recordAvailability = {};
|
||||
|
||||
FullMsgId _editingId;
|
||||
std::shared_ptr<Data::PhotoMedia> _photoEditMedia;
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit fc726486ebd261283583b5cd5f6a97a18b2ab6ca
|
||||
Subproject commit 39af565818ca2fbc4029e23f798c3b440e367423
|
Loading…
Add table
Reference in a new issue