diff --git a/tools/chatgui-android/app/src/main/java/com/utun/chat/ui/screens/ChatScreen.kt b/tools/chatgui-android/app/src/main/java/com/utun/chat/ui/screens/ChatScreen.kt index 1d8e401c..d0971719 100644 --- a/tools/chatgui-android/app/src/main/java/com/utun/chat/ui/screens/ChatScreen.kt +++ b/tools/chatgui-android/app/src/main/java/com/utun/chat/ui/screens/ChatScreen.kt @@ -107,6 +107,11 @@ fun ChatScreen( val streams by viewModel.streamSources.collectAsState() val watchSources = streams.filterNot { it.self } var chooseStream by remember(channel.id) { mutableStateOf(false) } + LaunchedEffect(channel.id, watchSources.size, streams.size) { + if (watchSources.isEmpty()) chooseStream = false + LogManager.addLog("INFO", "stream", "watch stream header channel=${channel.id} remote=${watchSources.size} " + + "ownExcluded=${streams.size - watchSources.size} visible=${watchSources.isNotEmpty()}") + } if (chooseStream) AlertDialog( onDismissRequest = { chooseStream = false }, title = { Text(stringResource(R.string.stream_choose_source)) }, @@ -201,13 +206,13 @@ fun ChatScreen( IconButton(onClick = onBack) { Icon(Icons.AutoMirrored.Filled.ArrowBack, stringResource(R.string.back)) } }, actions = { - IconButton(onClick = { + if (watchSources.isNotEmpty()) IconButton(onClick = { LogManager.addLog("INFO", "stream", "stream chooser channel=${channel.id} " + "remote=${watchSources.size} ownExcluded=${streams.size - watchSources.size}") chooseStream = true }) { BadgedBox(badge = { if (watchSources.size > 1) Badge { Text(watchSources.size.toString()) } }) { - Icon(Icons.Filled.LiveTv, stringResource(R.string.stream_available, watchSources.size), tint = Color(0xFFE53935)) + Icon(Icons.Filled.LiveTv, stringResource(R.string.stream_available, watchSources.size), tint = Color(0xFF4CAF50)) } } OwnStreamButton("channel=${channel.id}", onOwnStream) diff --git a/tools/chatgui/src/messagelist.cpp b/tools/chatgui/src/messagelist.cpp index 9874928a..181b5429 100644 --- a/tools/chatgui/src/messagelist.cpp +++ b/tools/chatgui/src/messagelist.cpp @@ -492,9 +492,9 @@ MessageList::MessageList(DbManager* db, AudioRecorder* recorder, QWidget *parent m_streamBtn = new QPushButton(header); m_streamBtn->setObjectName("streamButton"); QPixmap streamIcon(24, 24); streamIcon.fill(Qt::transparent); - { QPainter painter(&streamIcon); painter.setRenderHint(QPainter::Antialiasing); painter.setPen(QPen(QColor("#e53935"), 2)); + { QPainter painter(&streamIcon); painter.setRenderHint(QPainter::Antialiasing); painter.setPen(QPen(QColor("#4caf50"), 2)); painter.drawRoundedRect(QRectF(2, 6, 20, 14), 2, 2); painter.drawLine(8, 1, 12, 5); painter.drawLine(16, 1, 12, 5); - painter.setBrush(QColor("#e53935")); painter.drawEllipse(QPointF(12, 13), 3, 3); } + painter.setBrush(QColor("#4caf50")); painter.drawEllipse(QPointF(12, 13), 3, 3); } m_streamBtn->setIcon(QIcon(streamIcon)); m_streamBtn->setIconSize(QSize(24, 24)); m_streamBtn->hide(); m_streamBtn->setAccessibleName(QCoreApplication::translate("ChatGui", "Live streams")); m_streamBtn->setCursor(Qt::PointingHandCursor); @@ -1588,8 +1588,9 @@ void MessageList::watchStreams() { void MessageList::clearStreams() { m_streamSources.clear(); m_streamBtn->setText(QString()); - m_streamBtn->setVisible(!isDmChannel(m_currentChannelId) && m_currentChannelId.toULongLong() != 0); + m_streamBtn->hide(); m_streamBtn->setToolTip(QCoreApplication::translate("ChatGui", "Live streams")); + DEBUG_INFO(DEBUG_CATEGORY_STREAM, "desktop stream header cleared channel=%s visible=0", qPrintable(m_currentChannelId)); } /* Кнопка следует за локальным publisher, а не за запаздывающим/недоступным сетевым каталогом. */ @@ -1611,12 +1612,13 @@ void MessageList::onStreamSources(const uint8_t* data, int len) { if (!snapshot.valid) { DEBUG_WARN(DEBUG_CATEGORY_STREAM, "desktop source catalogue unavailable group=%llx", (unsigned long long)group); return; } - m_streamSources = std::move(snapshot.sources); m_streamBtn->show(); + m_streamSources = std::move(snapshot.sources); const auto remote = std::count_if(m_streamSources.begin(), m_streamSources.end(), [](const LiveStreamSource& source) { return !source.self; }); + m_streamBtn->setVisible(remote > 0); m_streamBtn->setText(remote > 1 ? QString::number(remote) : QString()); m_streamBtn->setToolTip(QCoreApplication::translate("ChatGui", "Live streams: %1").arg(remote)); - DEBUG_INFO(DEBUG_CATEGORY_STREAM, "desktop stream header group=%llx sources=%d remote=%d", - (unsigned long long)group, (int)m_streamSources.size(), (int)remote); + DEBUG_INFO(DEBUG_CATEGORY_STREAM, "desktop stream header group=%llx sources=%d remote=%d visible=%d", + (unsigned long long)group, (int)m_streamSources.size(), (int)remote, remote > 0); } bool MessageList::enableRadio() {