feat: Point out hidden features with tips

Uses TipKit (iOS 17 and later) for small one-time hints about
features that are easy to miss:

- Double tap a message to react (chat)
- Raise the phone to the ear / long press to transcribe (chat, when a
  voice message from somebody else is visible)
- Hold the microphone button or space bar to talk (call, after the
  microphone was muted for the first time)
- Hand gestures send reactions (call, when the camera recognizes them)
- Add the widgets to the Home Screen (conversation list, from the
  third time the app is opened)

A tip disappears for good once it was closed or the feature was used.
At most one tip is shown per day, and none during UI tests.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Frank Karlitschek <[email protected]>
This commit is contained in:
Frank KarlitschekandClaude Opus 5.5 committed 2026-10-25 21:43:06 +01:00
1 parent 9d699d48db
commit 2b664d9a90
7 files changed
+312

No files matched your search

+2
View File
@@ -55,6 +55,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate, PKPushRegistryDelegate {
NSLog("Configure App Settings")
_ = NCSettingsController.sharedInstance()
FeatureTips.configure()
// Perform cleanup only once in app lifecycle
DispatchQueue.global(qos: .background).asyncAfter(deadline: .now() + 10) {
autoreleasepool {
@@ -135,6 +135,8 @@ class CallViewController: UIViewController,
private var presentedScreenPeerId: String?
private var callController: NCCallController?
private weak var cameraController: NCCameraController?
private var pushToTalkTipPresenter: AnyObject? // TipPopoverPresenter, iOS 17 and later
private var gestureReactionsTipPresenter: AnyObject?
private var lastGestureReactionDate = Date.distantPast
private var chatViewController: ChatViewController?
private var chatNavigationController: UINavigationController?
@@ -450,6 +452,17 @@ class CallViewController: UIViewController,
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
// Shown once the microphone was muted for the first time
if #available(iOS 17.0, *), self.pushToTalkTipPresenter == nil {
let presenter = TipPopoverPresenter()
presenter.show(PushToTalkTip(), in: self) { [weak self] in
guard let self, !self.audioMuteButton.isHidden, self.audioMuteButton.isEnabled else { return nil }
return self.audioMuteButton
}
self.pushToTalkTipPresenter = presenter
}
UIDevice.current.isProximityMonitoringEnabled = true
UIApplication.shared.isIdleTimerDisabled = true
}
@@ -1453,6 +1466,21 @@ class CallViewController: UIViewController,
cameraController.localView = self.localVideoView
self.cameraController = cameraController
}
// Once the camera is running for a while, point out that hand gestures send reactions
DispatchQueue.main.asyncAfter(deadline: .now() + 8) { [weak self, weak cameraController] in
guard #available(iOS 17.0, *), let self, let cameraController, self.gestureReactionsTipPresenter == nil,
cameraController.recognizesGestureReactions(), !self.room.callReactions.isEmpty
else { return }
let presenter = TipPopoverPresenter()
presenter.show(GestureReactionsTip(), in: self) { [weak self] in
guard let self else { return nil }
return self.reactionButton.isHidden ? self.moreMenuButton : self.reactionButton
}
self.gestureReactionsTipPresenter = presenter
}
}
func callControllerDidDrawFirstLocalFrame(_ callController: NCCallController) {
@@ -2556,6 +2584,7 @@ class CallViewController: UIViewController,
DispatchQueue.main.async {
self.buttonFeedbackGenerator.impactOccurred()
self.pushToTalkActive = true
FeatureTips.pushToTalkUsed()
}
}
}
@@ -2654,6 +2683,12 @@ class CallViewController: UIViewController,
callController.enableAudio(!muted)
self.setAudioMuteButtonActive(!muted)
if muted, !self.pushToTalkActive {
DispatchQueue.main.async {
FeatureTips.microphoneMuted()
}
}
}
@IBAction func videoButtonPressed(_ sender: Any) {
@@ -2769,6 +2804,11 @@ class CallViewController: UIViewController,
hangingUp = true
if #available(iOS 17.0, *) {
(self.pushToTalkTipPresenter as? TipPopoverPresenter)?.stop()
(self.gestureReactionsTipPresenter as? TipPopoverPresenter)?.stop()
}
// Dismiss possible notifications
// swiftlint:disable:next notification_center_detachment
NotificationCenter.default.removeObserver(self)
@@ -3170,6 +3210,7 @@ class CallViewController: UIViewController,
DispatchQueue.main.async {
self.lastGestureReactionDate = Date()
FeatureTips.gestureReactionUsed()
callController.sendReaction(reaction)
if let account = self.room.account {
@@ -289,6 +289,13 @@ class NCCameraController: NSObject, AVCaptureVideoDataOutputSampleBufferDelegate
// MARK: - Gesture reactions
// Whether the camera recognizes hand gestures right now, which the user can turn off in Control Center
public func recognizesGestureReactions() -> Bool {
guard #available(iOS 17.0, *), let currentDevice else { return false }
return currentDevice.activeFormat.reactionEffectsSupported && AVCaptureDevice.reactionEffectGesturesEnabled
}
// The system can recognize hand gestures (e.g. thumbs up, two hands forming a heart) and renders an effect
// into the camera image. We send the matching call reaction as well, so everyone sees it, even without video.
private func observeReactionEffects(of device: AVCaptureDevice) {
@@ -1463,6 +1463,7 @@ import Toast
}
func didPressTranscribeVoiceMessage(for message: NCChatMessage) {
FeatureTips.voiceMessageFeatureUsed()
self.downloadFile(for: message) { [weak self] fileStatus in
self?.transcribeVoiceMessage(with: fileStatus)
}
@@ -35,6 +35,7 @@ import SwiftUI
private var isLeavingChat = false
private var chatViewPresentedTimestamp = Date().timeIntervalSince1970
private var tipPresenter: AnyObject? // TipPopoverPresenter, iOS 17 and later
private var doubleTapReactionGesture: UITapGestureRecognizer?
private var lastCelebrationTimestamp: TimeInterval = 0
@@ -675,6 +676,8 @@ import SwiftUI
self.updateRaiseToListen()
self.showChatTipIfNeeded()
if self.presentKeyboardOnAppear {
self.presentKeyboard(true)
self.presentKeyboardOnAppear = false
@@ -716,6 +719,43 @@ import SwiftUI
self.saveLastReadMessage()
self.stopVoiceMessagePlayer()
if #available(iOS 17.0, *) {
(self.tipPresenter as? TipPopoverPresenter)?.stop()
}
}
// MARK: - Tips
private func showChatTipIfNeeded() {
guard #available(iOS 17.0, *), !self.presentedInCall else { return }
let presenter = (self.tipPresenter as? TipPopoverPresenter) ?? TipPopoverPresenter()
self.tipPresenter = presenter
// Give the messages some time to load and settle
DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) { [weak self] in
guard let self, self.isVisible, let tableView = self.tableView else { return }
let otherMessageCells = (tableView.indexPathsForVisibleRows ?? []).reversed().compactMap { indexPath -> (NCChatMessage, BaseChatTableViewCell)? in
guard let message = self.message(for: indexPath), !message.isSystemMessage,
!(message.actorId == self.account.userId && message.actorType == "users"),
let cell = tableView.cellForRow(at: indexPath) as? BaseChatTableViewCell
else { return nil }
return (message, cell)
}
if let voiceMessageCell = otherMessageCells.first(where: { $0.0.isVoiceMessage })?.1 {
presenter.show(VoiceMessageTip(), in: self) { [weak voiceMessageCell] in
voiceMessageCell?.audioPlayerView
}
} else if self.room.canReact, let messageCell = otherMessageCells.first?.1 {
presenter.show(DoubleTapReactionTip(), in: self) { [weak messageCell] in
messageCell?.bubbleView
}
}
}
}
public override func viewDidDisappear(_ animated: Bool) {
@@ -1303,6 +1343,7 @@ import SwiftUI
// Raise to listen: holding the phone to the ear plays the newest voice message
if self.voiceMessagesPlayer?.isPlaying != true, let message = self.raiseToListenMessage() {
FeatureTips.voiceMessageFeatureUsed()
self.cellWants(toPlayAudioFile: message)
}
} else {
@@ -2394,6 +2435,7 @@ import SwiftUI
}
HapticFeedback.light()
FeatureTips.doubleTapReactionUsed()
self.addOrRemoveReaction(reaction: reaction, in: message)
}
@@ -44,6 +44,7 @@ class RoomsTableViewController: UITableViewController, CCCertificateDelegate, UI
private var newConversationButton: UIBarButtonItem?
private var filterButton: UIBarButtonItem?
private var settingsButton: UIBarButtonItem!
private var tipPresenter: AnyObject? // TipPopoverPresenter, iOS 17 and later
private var profileButton: UIButton!
private var activeUserStatus: NCUserStatus?
private var refreshRoomsTimer: Timer?
@@ -289,9 +290,24 @@ class RoomsTableViewController: UITableViewController, CCCertificateDelegate, UI
NotificationCenter.default.removeObserver(self)
}
private func showWidgetTipIfNeeded() {
FeatureTips.appOpened()
guard #available(iOS 17.0, *), self.tipPresenter == nil else { return }
let presenter = TipPopoverPresenter()
presenter.show(WidgetTip(), in: self) { [weak self] in
self?.settingsButton?.customView
}
self.tipPresenter = presenter
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
self.showWidgetTipIfNeeded()
adaptInterface(forAppState: NCConnectionController.shared.appState)
adaptInterface(forConnectionState: NCConnectionController.shared.connectionState)
@@ -0,0 +1,203 @@
//
// SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
// SPDX-License-Identifier: GPL-3.0-or-later
//
import SwiftUI
import TipKit
import UIKit
// Small one-time hints for features that are easy to miss, shown with TipKit (iOS 17 and later).
// TipKit makes sure a tip is only shown until it was closed or the feature was used, and not too often.
@available(iOS 17.0, *)
struct DoubleTapReactionTip: Tip {
var title: Text {
Text(NSLocalizedString("Double tap to react", comment: "Title of a tip"))
}
var message: Text? {
Text(NSLocalizedString("Double tap a message to add your favorite reaction.", comment: "Tip shown in a chat"))
}
var image: Image? {
Image(systemName: "hand.tap")
}
}
@available(iOS 17.0, *)
struct VoiceMessageTip: Tip {
var title: Text {
Text(NSLocalizedString("Listening to voice messages", comment: "Title of a tip"))
}
var message: Text? {
if UIDevice.current.userInterfaceIdiom == .phone {
return Text(NSLocalizedString("Raise your phone to your ear to listen. Long press a voice message to transcribe it.", comment: "Tip shown in a chat on iPhone"))
}
return Text(NSLocalizedString("Long press a voice message to transcribe it.", comment: "Tip shown in a chat"))
}
var image: Image? {
Image(systemName: "waveform")
}
}
@available(iOS 17.0, *)
struct PushToTalkTip: Tip {
// Only interesting for somebody who mutes the microphone
@Parameter
static var hasMutedMicrophone: Bool = false
var title: Text {
Text(NSLocalizedString("Hold to talk", comment: "Title of a tip"))
}
var message: Text? {
Text(NSLocalizedString("While muted, hold the microphone button or the space bar to talk.", comment: "Tip shown in a call"))
}
var image: Image? {
Image(systemName: "mic.fill")
}
var rules: [Rule] {
#Rule(Self.$hasMutedMicrophone) { $0 == true }
}
}
@available(iOS 17.0, *)
struct GestureReactionsTip: Tip {
var title: Text {
Text(NSLocalizedString("React with your hands", comment: "Title of a tip"))
}
var message: Text? {
Text(NSLocalizedString("Show a thumbs up or form a heart with your hands, and everyone in the call sees your reaction.", comment: "Tip shown in a call"))
}
var image: Image? {
Image(systemName: "hand.thumbsup.fill")
}
}
@available(iOS 17.0, *)
struct WidgetTip: Tip {
static let appOpened = Event(id: "appOpened")
var title: Text {
Text(NSLocalizedString("Add Talk to your Home Screen", comment: "Title of a tip"))
}
var message: Text? {
Text(NSLocalizedString("Widgets show your favorite conversations and unread messages at a glance.", comment: "Tip shown in the conversation list"))
}
var image: Image? {
Image(systemName: "square.grid.2x2")
}
// Not for the very first steps in the app
var rules: [Rule] {
#Rule(Self.appOpened) { $0.donations.count >= 3 }
}
}
enum FeatureTips {
static func configure() {
guard #available(iOS 17.0, *) else { return }
// UI tests should not be interrupted by tips
if NCUtils.isTestEnvironment {
Tips.hideAllTipsForTesting()
}
do {
try Tips.configure([.displayFrequency(.daily)])
} catch {
NCLog.log("Could not configure tips: \(error.localizedDescription)")
}
}
static func appOpened() {
guard #available(iOS 17.0, *) else { return }
Task {
await WidgetTip.appOpened.donate()
}
}
static func doubleTapReactionUsed() {
guard #available(iOS 17.0, *) else { return }
DoubleTapReactionTip().invalidate(reason: .actionPerformed)
}
static func voiceMessageFeatureUsed() {
guard #available(iOS 17.0, *) else { return }
VoiceMessageTip().invalidate(reason: .actionPerformed)
}
static func microphoneMuted() {
guard #available(iOS 17.0, *) else { return }
PushToTalkTip.hasMutedMicrophone = true
}
static func pushToTalkUsed() {
guard #available(iOS 17.0, *) else { return }
PushToTalkTip().invalidate(reason: .actionPerformed)
}
static func gestureReactionUsed() {
guard #available(iOS 17.0, *) else { return }
GestureReactionsTip().invalidate(reason: .actionPerformed)
}
}
// Presents a tip as a popover pointing at a view, as long as TipKit wants it to be shown.
// The view controllers keep it as AnyObject, as it is only available on iOS 17.
@available(iOS 17.0, *)
@MainActor
final class TipPopoverPresenter {
private var observationTask: Task<Void, Never>?
private weak var popoverController: TipUIPopoverViewController?
/// - Parameter sourceView: Called when the tip is about to be shown, returns nil when there's nothing to point at right now
func show<T: Tip>(_ tip: T, in viewController: UIViewController, pointingAt sourceView: @escaping () -> UIView?) {
self.stop()
observationTask = Task { @MainActor [weak self, weak viewController] in
for await shouldDisplay in tip.shouldDisplayUpdates {
guard let self, let viewController else { return }
if shouldDisplay {
guard self.popoverController == nil,
viewController.presentedViewController == nil,
viewController.view.window != nil,
let sourceView = sourceView(), sourceView.window != nil
else { continue }
let popoverController = TipUIPopoverViewController(tip, sourceItem: sourceView)
viewController.present(popoverController, animated: true)
self.popoverController = popoverController
} else if let popoverController = self.popoverController {
popoverController.dismiss(animated: true)
self.popoverController = nil
}
}
}
}
func stop() {
observationTask?.cancel()
observationTask = nil
if let popoverController, popoverController.presentingViewController != nil {
popoverController.dismiss(animated: false)
}
popoverController = nil
}
}