diff --git a/Linphone/GeneratedGit.swift b/Linphone/GeneratedGit.swift index 3c6ae57f7..e00dcda90 100644 --- a/Linphone/GeneratedGit.swift +++ b/Linphone/GeneratedGit.swift @@ -2,6 +2,6 @@ import Foundation public enum AppGitInfo { public static let branch = "master" - public static let commit = "23f521113" + public static let commit = "d39e4a0e3" public static let tag = "6.1.0-alpha" } diff --git a/Linphone/Localizable/en.lproj/Localizable.strings b/Linphone/Localizable/en.lproj/Localizable.strings index a57a96485..d9764e85b 100644 --- a/Linphone/Localizable/en.lproj/Localizable.strings +++ b/Linphone/Localizable/en.lproj/Localizable.strings @@ -461,6 +461,8 @@ "operation_in_progress_overlay" = "Operation in progress, please wait"; "or" = "or"; "password" = "Password"; +"pending_notification_for_other_accounts_single" = "1 notification for other account(s)"; +"pending_notification_for_other_accounts_multiple" = "%@ notifications for other account(s)"; "Personnalize your profil mode" ="Personnalize your profil mode"; "phone_number" = "Phone number"; "picker_categories" = "Categories"; diff --git a/Linphone/Localizable/fr.lproj/Localizable.strings b/Linphone/Localizable/fr.lproj/Localizable.strings index 0193718c2..682daf555 100644 --- a/Linphone/Localizable/fr.lproj/Localizable.strings +++ b/Linphone/Localizable/fr.lproj/Localizable.strings @@ -461,6 +461,8 @@ "operation_in_progress_overlay" = "Opération en cours, merci de patienter..."; "or" = "ou"; "password" = "Mot de passe"; +"pending_notification_for_other_accounts_single" = "1 notification en attente"; +"pending_notification_for_other_accounts_multiple" = "%@ notifications en attente"; "Personnalize your profil mode" = "Personnalize your profil mode"; "phone_number" = "Numéro de téléphone"; "picker_categories" = "Catégories"; diff --git a/Linphone/UI/Main/ContentView.swift b/Linphone/UI/Main/ContentView.swift index c4f01de7b..7e160ad17 100644 --- a/Linphone/UI/Main/ContentView.swift +++ b/Linphone/UI/Main/ContentView.swift @@ -143,6 +143,47 @@ struct ContentView: View { .background(Color.redDanger500) } + if accountProfileViewModel.nonDefaultAccountNotificationsCount > 0 && (!telecomManager.callInProgress || (telecomManager.callInProgress && !telecomManager.callDisplayed)) { + HStack { + Image("bell-simple") + .renderingMode(.template) + .resizable() + .foregroundStyle(.white) + .frame(width: 26, height: 26) + .padding(.leading, 10) + + if accountProfileViewModel.nonDefaultAccountNotificationsCount > 1 { + Text(String(format: String(localized: "pending_notification_for_other_accounts_multiple"), accountProfileViewModel.nonDefaultAccountNotificationsCount.description)) + .default_text_style_white(styleSize: 16) + } else { + Text(String(localized: "pending_notification_for_other_accounts_single")) + .default_text_style_white(styleSize: 16) + } + + Spacer() + + Button( + action: { + withAnimation { + accountProfileViewModel.nonDefaultAccountNotificationsCount = 0 + } + }, label: { + Image("x") + .renderingMode(.template) + .resizable() + .foregroundStyle(.white) + .frame(width: 26, height: 26) + .padding(.trailing, 10) + } + ) + + } + .frame(maxWidth: .infinity) + .frame(height: 40) + .padding(.horizontal, 10) + .background(Color.gray) + } + if sharedMainViewModel.waitingMessageCount > 0 && (!telecomManager.callInProgress || (telecomManager.callInProgress && !telecomManager.callDisplayed)) { HStack { Image("voicemail") diff --git a/Linphone/UI/Main/Fragments/SideMenu.swift b/Linphone/UI/Main/Fragments/SideMenu.swift index 98276346e..974ec8ffc 100644 --- a/Linphone/UI/Main/Fragments/SideMenu.swift +++ b/Linphone/UI/Main/Fragments/SideMenu.swift @@ -46,6 +46,7 @@ struct SideMenu: View { .onTapGesture { self.menuClose() } + VStack { VStack { HStack { @@ -173,7 +174,16 @@ struct SideMenu: View { } .frame(maxWidth: .infinity, alignment: .leading) .padding(.leading, safeAreaInsets.leading) - .padding(.top, TelecomManager.shared.callInProgress ? 0 : safeAreaInsets.top) + .padding( + .top, + TelecomManager.shared.callInProgress + || accountProfileViewModel.accountError + || accountProfileViewModel.nonDefaultAccountNotificationsCount > 0 + || SharedMainViewModel.shared.waitingMessageCount > 0 + || !SharedMainViewModel.shared.fileUrlsToShare.isEmpty + ? 0 + : safeAreaInsets.top + ) } .frame(maxWidth: .infinity, maxHeight: .infinity) } diff --git a/Linphone/UI/Main/Settings/ViewModel/AccountProfileViewModel.swift b/Linphone/UI/Main/Settings/ViewModel/AccountProfileViewModel.swift index 5a83b3acb..743d05bb4 100644 --- a/Linphone/UI/Main/Settings/ViewModel/AccountProfileViewModel.swift +++ b/Linphone/UI/Main/Settings/ViewModel/AccountProfileViewModel.swift @@ -30,9 +30,11 @@ class AccountProfileViewModel: ObservableObject { @Published var accountModelIndex: Int? = 0 @Published var defaultAccountModelIndex: Int? = 0 @Published var accountError: Bool = false + @Published var nonDefaultAccountNotificationsCount: Int = 0 init() { SharedMainViewModel.shared.getDialPlansList() + computeNonDefaultAccountNotificationsCount() } func saveChangesWhenLeaving() { @@ -180,4 +182,25 @@ class AccountProfileViewModel: ObservableObject { } } } + + func computeNonDefaultAccountNotificationsCount() { + CoreContext.shared.doOnCoreQueue { core in + var count = 0 + core.accountList.forEach { accountTmp in + if let defaultAccount = core.defaultAccount?.params?.identityAddress, let accountAddress = accountTmp.params?.identityAddress, !defaultAccount.equal(address2: accountAddress) { + count += accountTmp.unreadChatMessageCount + accountTmp.missedCallsCount + } + } + + if count > 0 { + Log.info("\(AccountProfileViewModel.TAG) Found \(count) pending notifications for other account(s)") + } else { + Log.info("\(AccountProfileViewModel.TAG) No pending notification found for other account(s)") + } + + DispatchQueue.main.async { + self.nonDefaultAccountNotificationsCount = count + } + } + } }