From 0eaccadef8ede65f26a50a61c92d86980399e5f9 Mon Sep 17 00:00:00 2001 From: David Idmansour Date: Fri, 22 Jun 2018 10:22:12 +0200 Subject: [PATCH 01/15] hello world rich notification --- linphone.xcodeproj/project.pbxproj | 278 ++++++++++++++++++ .../Base.lproj/MainInterface.storyboard | 43 +++ richNotifications/Info.plist | 38 +++ .../NotificationViewController.h | 12 + .../NotificationViewController.m | 29 ++ 5 files changed, 400 insertions(+) create mode 100644 richNotifications/Base.lproj/MainInterface.storyboard create mode 100644 richNotifications/Info.plist create mode 100644 richNotifications/NotificationViewController.h create mode 100644 richNotifications/NotificationViewController.m diff --git a/linphone.xcodeproj/project.pbxproj b/linphone.xcodeproj/project.pbxproj index 5c654eff9..af13eb8f6 100755 --- a/linphone.xcodeproj/project.pbxproj +++ b/linphone.xcodeproj/project.pbxproj @@ -70,6 +70,11 @@ 5E31290C20D7A37E00CF3AAE /* latestChatroomsWidget.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 5E31290020D7A37E00CF3AAE /* latestChatroomsWidget.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; 5E31291320D7AAA100CF3AAE /* avatar.png in Resources */ = {isa = PBXBuildFile; fileRef = 633FEBE61D3CD5570014B822 /* avatar.png */; }; 5E31291A20D7AAAD00CF3AAE /* chat_group_avatar.png in Resources */ = {isa = PBXBuildFile; fileRef = 8C2A81941F87B8000012A66B /* chat_group_avatar.png */; }; + 5E58962420DCE5700030868C /* UserNotifications.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8C73477B1D9BA3A00022EE8C /* UserNotifications.framework */; }; + 5E58962620DCE5700030868C /* UserNotificationsUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E58962520DCE5700030868C /* UserNotificationsUI.framework */; }; + 5E58962A20DCE5700030868C /* NotificationViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E58962920DCE5700030868C /* NotificationViewController.m */; }; + 5E58962D20DCE5700030868C /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 5E58962B20DCE5700030868C /* MainInterface.storyboard */; }; + 5E58963120DCE5710030868C /* richNotifications.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 5E58962320DCE5700030868C /* richNotifications.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; 5EEE8F9B20C80C23006E4176 /* NotificationCenter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5EF0C33820C806A5005081B0 /* NotificationCenter.framework */; }; 5EEE8F9F20C80C23006E4176 /* TodayViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 5EEE8F9E20C80C23006E4176 /* TodayViewController.m */; }; 5EEE8FA220C80C23006E4176 /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 5EEE8FA020C80C23006E4176 /* MainInterface.storyboard */; }; @@ -834,6 +839,13 @@ remoteGlobalIDString = 5E3128FF20D7A37E00CF3AAE; remoteInfo = latestChatroomsWidget; }; + 5E58962F20DCE5710030868C /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 29B97313FDCFA39411CA2CEA /* Project object */; + proxyType = 1; + remoteGlobalIDString = 5E58962220DCE5700030868C; + remoteInfo = richNotifications; + }; 5EEE8FA420C80C23006E4176 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 29B97313FDCFA39411CA2CEA /* Project object */; @@ -923,6 +935,7 @@ 61AE365620C00B370089D9D3 /* linphoneExtension.appex in Embed App Extensions */, 5E31290C20D7A37E00CF3AAE /* latestChatroomsWidget.appex in Embed App Extensions */, 5EEE8FA620C80C23006E4176 /* latestCallsWidget.appex in Embed App Extensions */, + 5E58963120DCE5710030868C /* richNotifications.appex in Embed App Extensions */, ); name = "Embed App Extensions"; runOnlyForDeploymentPostprocessing = 0; @@ -1070,6 +1083,12 @@ 5E31290420D7A37E00CF3AAE /* TodayViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TodayViewController.m; sourceTree = ""; }; 5E31290720D7A37E00CF3AAE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/MainInterface.storyboard; sourceTree = ""; }; 5E31290920D7A37E00CF3AAE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 5E58962320DCE5700030868C /* richNotifications.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = richNotifications.appex; sourceTree = BUILT_PRODUCTS_DIR; }; + 5E58962520DCE5700030868C /* UserNotificationsUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UserNotificationsUI.framework; path = System/Library/Frameworks/UserNotificationsUI.framework; sourceTree = SDKROOT; }; + 5E58962820DCE5700030868C /* NotificationViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NotificationViewController.h; sourceTree = ""; }; + 5E58962920DCE5700030868C /* NotificationViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NotificationViewController.m; sourceTree = ""; }; + 5E58962C20DCE5700030868C /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/MainInterface.storyboard; sourceTree = ""; }; + 5E58962E20DCE5710030868C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 5EEE8F9A20C80C23006E4176 /* latestCallsWidget.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = latestCallsWidget.appex; sourceTree = BUILT_PRODUCTS_DIR; }; 5EEE8F9D20C80C23006E4176 /* TodayViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TodayViewController.h; sourceTree = ""; }; 5EEE8F9E20C80C23006E4176 /* TodayViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TodayViewController.m; sourceTree = ""; }; @@ -2058,6 +2077,15 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 5E58962020DCE5700030868C /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 5E58962620DCE5700030868C /* UserNotificationsUI.framework in Frameworks */, + 5E58962420DCE5700030868C /* UserNotifications.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 5EEE8F9720C80C23006E4176 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -2273,6 +2301,7 @@ 61AE364B20C00B370089D9D3 /* linphoneExtension.appex */, 5EEE8F9A20C80C23006E4176 /* latestCallsWidget.appex */, 5E31290020D7A37E00CF3AAE /* latestChatroomsWidget.appex */, + 5E58962320DCE5700030868C /* richNotifications.appex */, ); name = Products; sourceTree = ""; @@ -2390,6 +2419,7 @@ 61AE364C20C00B370089D9D3 /* linphoneExtension */, 5EEE8F9C20C80C23006E4176 /* latestCallsWidget */, 5E31290220D7A37E00CF3AAE /* latestChatroomsWidget */, + 5E58962720DCE5700030868C /* richNotifications */, 29B97323FDCFA39411CA2CEA /* Frameworks */, F0938158188E629800A55DFA /* iTunesArtwork */, 63058A0C1B4E821E00EFAE36 /* LiblinphoneTester */, @@ -2481,6 +2511,7 @@ 2264B6D111200342002C2C53 /* SystemConfiguration.framework */, 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */, 5EF0C33820C806A5005081B0 /* NotificationCenter.framework */, + 5E58962520DCE5700030868C /* UserNotificationsUI.framework */, ); name = Frameworks; sourceTree = ""; @@ -2497,6 +2528,17 @@ path = latestChatroomsWidget; sourceTree = ""; }; + 5E58962720DCE5700030868C /* richNotifications */ = { + isa = PBXGroup; + children = ( + 5E58962820DCE5700030868C /* NotificationViewController.h */, + 5E58962920DCE5700030868C /* NotificationViewController.m */, + 5E58962B20DCE5700030868C /* MainInterface.storyboard */, + 5E58962E20DCE5710030868C /* Info.plist */, + ); + path = richNotifications; + sourceTree = ""; + }; 5EEE8F9C20C80C23006E4176 /* latestCallsWidget */ = { isa = PBXGroup; children = ( @@ -3314,6 +3356,7 @@ 61AE365520C00B370089D9D3 /* PBXTargetDependency */, 5EEE8FA520C80C23006E4176 /* PBXTargetDependency */, 5E31290B20D7A37E00CF3AAE /* PBXTargetDependency */, + 5E58963020DCE5710030868C /* PBXTargetDependency */, ); name = linphone; productName = linphone; @@ -3337,6 +3380,23 @@ productReference = 5E31290020D7A37E00CF3AAE /* latestChatroomsWidget.appex */; productType = "com.apple.product-type.app-extension"; }; + 5E58962220DCE5700030868C /* richNotifications */ = { + isa = PBXNativeTarget; + buildConfigurationList = 5E58963C20DCE5710030868C /* Build configuration list for PBXNativeTarget "richNotifications" */; + buildPhases = ( + 5E58961F20DCE5700030868C /* Sources */, + 5E58962020DCE5700030868C /* Frameworks */, + 5E58962120DCE5700030868C /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = richNotifications; + productName = richNotifications; + productReference = 5E58962320DCE5700030868C /* richNotifications.appex */; + productType = "com.apple.product-type.app-extension"; + }; 5EEE8F9920C80C23006E4176 /* latestCallsWidget */ = { isa = PBXNativeTarget; buildConfigurationList = 5EEE8FA720C80C24006E4176 /* Build configuration list for PBXNativeTarget "latestCallsWidget" */; @@ -3462,6 +3522,11 @@ }; }; }; + 5E58962220DCE5700030868C = { + CreatedOnToolsVersion = 9.4; + DevelopmentTeam = Z2V957B3D6; + ProvisioningStyle = Automatic; + }; 5EEE8F9920C80C23006E4176 = { CreatedOnToolsVersion = 9.4; DevelopmentTeam = Z2V957B3D6; @@ -3536,6 +3601,7 @@ 61AE364A20C00B370089D9D3 /* linphoneExtension */, 5EEE8F9920C80C23006E4176 /* latestCallsWidget */, 5E3128FF20D7A37E00CF3AAE /* latestChatroomsWidget */, + 5E58962220DCE5700030868C /* richNotifications */, ); }; /* End PBXProject section */ @@ -4134,6 +4200,14 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 5E58962120DCE5700030868C /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 5E58962D20DCE5700030868C /* MainInterface.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 5EEE8F9820C80C23006E4176 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -4382,6 +4456,14 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 5E58961F20DCE5700030868C /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 5E58962A20DCE5700030868C /* NotificationViewController.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 5EEE8F9620C80C23006E4176 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -4441,6 +4523,11 @@ target = 5E3128FF20D7A37E00CF3AAE /* latestChatroomsWidget */; targetProxy = 5E31290A20D7A37E00CF3AAE /* PBXContainerItemProxy */; }; + 5E58963020DCE5710030868C /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 5E58962220DCE5700030868C /* richNotifications */; + targetProxy = 5E58962F20DCE5710030868C /* PBXContainerItemProxy */; + }; 5EEE8FA520C80C23006E4176 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 5EEE8F9920C80C23006E4176 /* latestCallsWidget */; @@ -4487,6 +4574,14 @@ name = MainInterface.storyboard; sourceTree = ""; }; + 5E58962B20DCE5700030868C /* MainInterface.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 5E58962C20DCE5700030868C /* Base */, + ); + name = MainInterface.storyboard; + sourceTree = ""; + }; 5EEE8FA020C80C23006E4176 /* MainInterface.storyboard */ = { isa = PBXVariantGroup; children = ( @@ -5554,6 +5649,178 @@ }; name = DistributionAdhoc; }; + 5E58963220DCE5710030868C /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + CODE_SIGN_STYLE = Automatic; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + DEVELOPMENT_TEAM = Z2V957B3D6; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + INFOPLIST_FILE = richNotifications/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; + MTL_ENABLE_DEBUG_INFO = YES; + PRODUCT_BUNDLE_IDENTIFIER = org.linphone.phone.richNotifications; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE = ""; + PROVISIONING_PROFILE_SPECIFIER = ""; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 5E58963320DCE5710030868C /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + CODE_SIGN_STYLE = Automatic; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DEVELOPMENT_TEAM = Z2V957B3D6; + ENABLE_NS_ASSERTIONS = NO; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + INFOPLIST_FILE = richNotifications/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; + MTL_ENABLE_DEBUG_INFO = NO; + PRODUCT_BUNDLE_IDENTIFIER = org.linphone.phone.richNotifications; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE = ""; + PROVISIONING_PROFILE_SPECIFIER = ""; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 5E58963420DCE5710030868C /* Distribution */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + CODE_SIGN_STYLE = Automatic; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DEVELOPMENT_TEAM = Z2V957B3D6; + ENABLE_NS_ASSERTIONS = NO; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + INFOPLIST_FILE = richNotifications/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; + MTL_ENABLE_DEBUG_INFO = NO; + PRODUCT_BUNDLE_IDENTIFIER = org.linphone.phone.richNotifications; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE = ""; + PROVISIONING_PROFILE_SPECIFIER = ""; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Distribution; + }; + 5E58963520DCE5710030868C /* DistributionAdhoc */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + CODE_SIGN_STYLE = Automatic; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DEVELOPMENT_TEAM = Z2V957B3D6; + ENABLE_NS_ASSERTIONS = NO; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + INFOPLIST_FILE = richNotifications/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; + MTL_ENABLE_DEBUG_INFO = NO; + PRODUCT_BUNDLE_IDENTIFIER = org.linphone.phone.richNotifications; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE = ""; + PROVISIONING_PROFILE_SPECIFIER = ""; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = DistributionAdhoc; + }; 5EEE8FA820C80C24006E4176 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -6558,6 +6825,17 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Debug; }; + 5E58963C20DCE5710030868C /* Build configuration list for PBXNativeTarget "richNotifications" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 5E58963220DCE5710030868C /* Debug */, + 5E58963320DCE5710030868C /* Release */, + 5E58963420DCE5710030868C /* Distribution */, + 5E58963520DCE5710030868C /* DistributionAdhoc */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Debug; + }; 5EEE8FA720C80C24006E4176 /* Build configuration list for PBXNativeTarget "latestCallsWidget" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/richNotifications/Base.lproj/MainInterface.storyboard b/richNotifications/Base.lproj/MainInterface.storyboard new file mode 100644 index 000000000..b596d3278 --- /dev/null +++ b/richNotifications/Base.lproj/MainInterface.storyboard @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/richNotifications/Info.plist b/richNotifications/Info.plist new file mode 100644 index 000000000..8c44b9e62 --- /dev/null +++ b/richNotifications/Info.plist @@ -0,0 +1,38 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleDisplayName + richNotifications + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + XPC! + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + NSExtension + + NSExtensionAttributes + + UNNotificationExtensionCategory + msg_cat + UNNotificationExtensionInitialContentSizeRatio + 1 + + NSExtensionMainStoryboard + MainInterface + NSExtensionPointIdentifier + com.apple.usernotifications.content-extension + + + diff --git a/richNotifications/NotificationViewController.h b/richNotifications/NotificationViewController.h new file mode 100644 index 000000000..6bc345f56 --- /dev/null +++ b/richNotifications/NotificationViewController.h @@ -0,0 +1,12 @@ +// +// NotificationViewController.h +// richNotifications +// +// Created by David Idmansour on 22/06/2018. +// + +#import + +@interface NotificationViewController : UIViewController + +@end diff --git a/richNotifications/NotificationViewController.m b/richNotifications/NotificationViewController.m new file mode 100644 index 000000000..8a738e4b1 --- /dev/null +++ b/richNotifications/NotificationViewController.m @@ -0,0 +1,29 @@ +// +// NotificationViewController.m +// richNotifications +// +// Created by David Idmansour on 22/06/2018. +// + +#import "NotificationViewController.h" +#import +#import + +@interface NotificationViewController () + +@property IBOutlet UILabel *label; + +@end + +@implementation NotificationViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + // Do any required interface initialization here. +} + +- (void)didReceiveNotification:(UNNotification *)notification { + self.label.text = notification.request.content.body; +} + +@end From ee3643f7dfb375d834463a924afebd1883b68335 Mon Sep 17 00:00:00 2001 From: David Idmansour Date: Fri, 22 Jun 2018 11:48:59 +0200 Subject: [PATCH 02/15] disabled default notification display --- richNotifications/Info.plist | 2 ++ 1 file changed, 2 insertions(+) diff --git a/richNotifications/Info.plist b/richNotifications/Info.plist index 8c44b9e62..f6e516e4d 100644 --- a/richNotifications/Info.plist +++ b/richNotifications/Info.plist @@ -24,6 +24,8 @@ NSExtensionAttributes + UNNotificationExtensionDefaultContentHidden + UNNotificationExtensionCategory msg_cat UNNotificationExtensionInitialContentSizeRatio From 9e6c045a35fb4dea47238c34b5ce0125372084ef Mon Sep 17 00:00:00 2001 From: David Idmansour Date: Tue, 26 Jun 2018 11:41:31 +0200 Subject: [PATCH 03/15] save text messages data to notification user info --- Classes/LinphoneManager.m | 30 ++++++++- .../Base.lproj/MainInterface.storyboard | 61 +++++++++---------- .../NotificationViewController.h | 2 +- .../NotificationViewController.m | 34 +++++++++-- 4 files changed, 90 insertions(+), 37 deletions(-) diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index 485fde3d9..8d7eb4494 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -1230,7 +1230,35 @@ static void linphone_iphone_popup_password_request(LinphoneCore *lc, LinphoneAut } content.sound = [UNNotificationSound soundNamed:@"msg.caf"]; content.categoryIdentifier = @"msg_cat"; - content.userInfo = @{@"from" : from, @"peer_addr" : peer_uri, @"local_addr" : local_uri, @"CallId" : callID}; + NSMutableArray *msgs = [NSMutableArray array]; + bctbx_list_t *history = linphone_chat_room_get_history(room, 3); + while (history) { + NSMutableDictionary *msgData = [NSMutableDictionary dictionary]; + LinphoneChatMessage *msg = history->data; + bool_t isOutgoing = linphone_chat_message_is_outgoing(msg); + bool_t isFileTransfer = linphone_chat_message_is_file_transfer(msg); + const LinphoneAddress *fromAddress = linphone_chat_message_get_from_address(msg); + NSString *displayNameDate = [NSString stringWithFormat:@"%@ - %@", [LinphoneUtils timeToString:linphone_chat_message_get_time(msg) + withFormat:LinphoneDateChatBubble], + [FastAddressBook displayNameForAddress:fromAddress]]; + UIImage *fromImage = [UIImage resizeImage:[FastAddressBook imageForAddress:fromAddress] + withMaxWidth:200 + andMaxHeight:200]; + NSData *fromImageData = UIImageJPEGRepresentation(fromImage, 1); + [msgData setObject:displayNameDate forKey:@"displayNameDate"]; + [msgData setObject:[NSNumber numberWithBool:isFileTransfer] forKey:@"isFileTransfer"]; + [msgData setObject:fromImageData forKey:@"fromImageData"]; + if (isFileTransfer) { + // TODO + } else { + const char *textMsg = linphone_chat_message_get_text_content(msg); + [msgData setObject:[NSString stringWithUTF8String:textMsg] forKey:@"msg"]; + } + [msgData setObject:[NSNumber numberWithBool:isOutgoing] forKey:@"isOutgoing"]; + [msgs addObject:msgData]; + history = bctbx_list_next(history); + } + content.userInfo = @{@"from" : from, @"peer_addr" : peer_uri, @"local_addr" : local_uri, @"CallId" : callID, @"msgs" : msgs}; content.accessibilityLabel = @"Message notif"; UNNotificationRequest *req = [UNNotificationRequest requestWithIdentifier:@"call_request" content:content trigger:NULL]; [[UNUserNotificationCenter currentNotificationCenter] diff --git a/richNotifications/Base.lproj/MainInterface.storyboard b/richNotifications/Base.lproj/MainInterface.storyboard index b596d3278..7bfc6b3a5 100644 --- a/richNotifications/Base.lproj/MainInterface.storyboard +++ b/richNotifications/Base.lproj/MainInterface.storyboard @@ -1,43 +1,42 @@ - + + + + - - + + - + - - - + + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/richNotifications/NotificationViewController.h b/richNotifications/NotificationViewController.h index 6bc345f56..f96beffbd 100644 --- a/richNotifications/NotificationViewController.h +++ b/richNotifications/NotificationViewController.h @@ -7,6 +7,6 @@ #import -@interface NotificationViewController : UIViewController +@interface NotificationViewController : UITableViewController @end diff --git a/richNotifications/NotificationViewController.m b/richNotifications/NotificationViewController.m index 8a738e4b1..e40e6ae9f 100644 --- a/richNotifications/NotificationViewController.m +++ b/richNotifications/NotificationViewController.m @@ -11,11 +11,12 @@ @interface NotificationViewController () -@property IBOutlet UILabel *label; - @end -@implementation NotificationViewController +@implementation NotificationViewController { + @private + NSArray *msgs; +} - (void)viewDidLoad { [super viewDidLoad]; @@ -23,7 +24,32 @@ } - (void)didReceiveNotification:(UNNotification *)notification { - self.label.text = notification.request.content.body; + msgs = [[[[notification request] content] userInfo] objectForKey:@"msgs"]; + printf("Taille tab : %d\n", (unsigned int)msgs.count); + [self.tableView reloadData]; +} + +#pragma mark - UITableViewDataSource Functions + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { + return 1; +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + return msgs.count; +} + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + BOOL isOutgoing = ((NSNumber *)[msgs[indexPath.row] objectForKey:@"isOutgoing"]).boolValue; + NSString *display = ((NSString *)[msgs[indexPath.row] objectForKey:@"displayNameDate"]); + NSString *msgText = ((NSString *)[msgs[indexPath.row] objectForKey:@"msg"]); + NSData *imageData = [msgs[indexPath.row] objectForKey:@"fromImageData"]; + printf("Message %s de %s : %s\n", isOutgoing ? "sortant" : "entrant", + display.UTF8String, + msgText.UTF8String); + printf("Taille de l'image de profil : %d\n", (unsigned int)imageData.length); + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"notificationCell" forIndexPath:indexPath]; + return cell; } @end From 7e0634cfedf03b903632bbbc115a450790b4b32b Mon Sep 17 00:00:00 2001 From: David Idmansour Date: Tue, 26 Jun 2018 13:51:42 +0200 Subject: [PATCH 04/15] basic ui --- Classes/LinphoneManager.m | 7 +-- linphone.xcodeproj/project.pbxproj | 6 +++ .../Base.lproj/MainInterface.storyboard | 54 +++++++++++++++++-- richNotifications/NotificationTableViewCell.h | 15 ++++++ richNotifications/NotificationTableViewCell.m | 25 +++++++++ .../NotificationViewController.m | 13 ++++- 6 files changed, 112 insertions(+), 8 deletions(-) create mode 100644 richNotifications/NotificationTableViewCell.h create mode 100644 richNotifications/NotificationTableViewCell.m diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index 8d7eb4494..62c0ae85c 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -1230,8 +1230,9 @@ static void linphone_iphone_popup_password_request(LinphoneCore *lc, LinphoneAut } content.sound = [UNNotificationSound soundNamed:@"msg.caf"]; content.categoryIdentifier = @"msg_cat"; + // save data to user info for rich notification content NSMutableArray *msgs = [NSMutableArray array]; - bctbx_list_t *history = linphone_chat_room_get_history(room, 3); + bctbx_list_t *history = linphone_chat_room_get_history(room, 4); while (history) { NSMutableDictionary *msgData = [NSMutableDictionary dictionary]; LinphoneChatMessage *msg = history->data; @@ -1250,9 +1251,9 @@ static void linphone_iphone_popup_password_request(LinphoneCore *lc, LinphoneAut [msgData setObject:fromImageData forKey:@"fromImageData"]; if (isFileTransfer) { // TODO + [msgData setObject:[UIChatBubbleTextCell TextMessageForChat:msg] forKey:@"msg"]; } else { - const char *textMsg = linphone_chat_message_get_text_content(msg); - [msgData setObject:[NSString stringWithUTF8String:textMsg] forKey:@"msg"]; + [msgData setObject:[UIChatBubbleTextCell TextMessageForChat:msg] forKey:@"msg"]; } [msgData setObject:[NSNumber numberWithBool:isOutgoing] forKey:@"isOutgoing"]; [msgs addObject:msgData]; diff --git a/linphone.xcodeproj/project.pbxproj b/linphone.xcodeproj/project.pbxproj index af13eb8f6..ced062366 100755 --- a/linphone.xcodeproj/project.pbxproj +++ b/linphone.xcodeproj/project.pbxproj @@ -64,6 +64,7 @@ 570742671D5A63DB004B9C84 /* StoreKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 570742661D5A63DB004B9C84 /* StoreKit.framework */; }; 5E10ED4820D00630002BF6FE /* avatar.png in Resources */ = {isa = PBXBuildFile; fileRef = 633FEBE61D3CD5570014B822 /* avatar.png */; }; 5E10ED4920D006C9002BF6FE /* chat_group_avatar.png in Resources */ = {isa = PBXBuildFile; fileRef = 8C2A81941F87B8000012A66B /* chat_group_avatar.png */; }; + 5E223A9920E244B400D06A36 /* NotificationTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E223A9820E244B400D06A36 /* NotificationTableViewCell.m */; }; 5E31290120D7A37E00CF3AAE /* NotificationCenter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5EF0C33820C806A5005081B0 /* NotificationCenter.framework */; }; 5E31290520D7A37E00CF3AAE /* TodayViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E31290420D7A37E00CF3AAE /* TodayViewController.m */; }; 5E31290820D7A37E00CF3AAE /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 5E31290620D7A37E00CF3AAE /* MainInterface.storyboard */; }; @@ -1077,6 +1078,8 @@ 570742601D5A09B8004B9C84 /* ShopView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShopView.h; sourceTree = ""; }; 570742631D5A1860004B9C84 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/ShopView.strings; sourceTree = ""; }; 570742661D5A63DB004B9C84 /* StoreKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = StoreKit.framework; path = System/Library/Frameworks/StoreKit.framework; sourceTree = SDKROOT; }; + 5E223A9720E244B400D06A36 /* NotificationTableViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NotificationTableViewCell.h; sourceTree = ""; }; + 5E223A9820E244B400D06A36 /* NotificationTableViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NotificationTableViewCell.m; sourceTree = ""; }; 5E30780420D8F00D00256DAE /* latestChatroomsWidget.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = latestChatroomsWidget.entitlements; sourceTree = ""; }; 5E31290020D7A37E00CF3AAE /* latestChatroomsWidget.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = latestChatroomsWidget.appex; sourceTree = BUILT_PRODUCTS_DIR; }; 5E31290320D7A37E00CF3AAE /* TodayViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TodayViewController.h; sourceTree = ""; }; @@ -2535,6 +2538,8 @@ 5E58962920DCE5700030868C /* NotificationViewController.m */, 5E58962B20DCE5700030868C /* MainInterface.storyboard */, 5E58962E20DCE5710030868C /* Info.plist */, + 5E223A9720E244B400D06A36 /* NotificationTableViewCell.h */, + 5E223A9820E244B400D06A36 /* NotificationTableViewCell.m */, ); path = richNotifications; sourceTree = ""; @@ -4460,6 +4465,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 5E223A9920E244B400D06A36 /* NotificationTableViewCell.m in Sources */, 5E58962A20DCE5700030868C /* NotificationViewController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/richNotifications/Base.lproj/MainInterface.storyboard b/richNotifications/Base.lproj/MainInterface.storyboard index 7bfc6b3a5..67240e5cd 100644 --- a/richNotifications/Base.lproj/MainInterface.storyboard +++ b/richNotifications/Base.lproj/MainInterface.storyboard @@ -13,18 +13,66 @@ - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/richNotifications/NotificationTableViewCell.h b/richNotifications/NotificationTableViewCell.h new file mode 100644 index 000000000..0f15fa177 --- /dev/null +++ b/richNotifications/NotificationTableViewCell.h @@ -0,0 +1,15 @@ +// +// NotificationTableViewCell.h +// richNotifications +// +// Created by David Idmansour on 26/06/2018. +// + +#import + +@interface NotificationTableViewCell : UITableViewCell +@property (weak, nonatomic) IBOutlet UIImageView *contactImage; +@property (weak, nonatomic) IBOutlet UILabel *nameDate; +@property (weak, nonatomic) IBOutlet UITextView *msgText; + +@end diff --git a/richNotifications/NotificationTableViewCell.m b/richNotifications/NotificationTableViewCell.m new file mode 100644 index 000000000..fb1853143 --- /dev/null +++ b/richNotifications/NotificationTableViewCell.m @@ -0,0 +1,25 @@ +// +// NotificationTableViewCell.m +// richNotifications +// +// Created by David Idmansour on 26/06/2018. +// + +#import "NotificationTableViewCell.h" + +@implementation NotificationTableViewCell + +- (void)awakeFromNib { + [super awakeFromNib]; + // Initialization code + _contactImage.layer.cornerRadius = _contactImage.frame.size.height / 2; + _contactImage.clipsToBounds = YES; +} + +- (void)setSelected:(BOOL)selected animated:(BOOL)animated { + [super setSelected:selected animated:animated]; + + // Configure the view for the selected state +} + +@end diff --git a/richNotifications/NotificationViewController.m b/richNotifications/NotificationViewController.m index e40e6ae9f..014b6178d 100644 --- a/richNotifications/NotificationViewController.m +++ b/richNotifications/NotificationViewController.m @@ -6,6 +6,7 @@ // #import "NotificationViewController.h" +#import "NotificationTableViewCell.h" #import #import @@ -25,7 +26,6 @@ - (void)didReceiveNotification:(UNNotification *)notification { msgs = [[[[notification request] content] userInfo] objectForKey:@"msgs"]; - printf("Taille tab : %d\n", (unsigned int)msgs.count); [self.tableView reloadData]; } @@ -48,8 +48,17 @@ display.UTF8String, msgText.UTF8String); printf("Taille de l'image de profil : %d\n", (unsigned int)imageData.length); - UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"notificationCell" forIndexPath:indexPath]; + NotificationTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"notificationCell" forIndexPath:indexPath]; + cell.contactImage.image = [UIImage imageWithData:imageData]; + cell.nameDate.text = display; + cell.msgText.text = msgText; return cell; } +#pragma mark - UITableViewDelegate Functions + +- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { + return 100; +} + @end From 7cc12f25ee60c8a5b7e368a9f283e98b14fe3920 Mon Sep 17 00:00:00 2001 From: David Idmansour Date: Wed, 27 Jun 2018 10:28:21 +0200 Subject: [PATCH 05/15] scroll to last message, imdm --- Classes/LinphoneManager.m | 2 ++ .../Base.lproj/MainInterface.storyboard | 12 ++++++++- richNotifications/NotificationTableViewCell.h | 1 + .../NotificationViewController.m | 26 ++++++++++++++++--- 4 files changed, 37 insertions(+), 4 deletions(-) diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index 62c0ae85c..f91a3ebf1 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -1236,6 +1236,7 @@ static void linphone_iphone_popup_password_request(LinphoneCore *lc, LinphoneAut while (history) { NSMutableDictionary *msgData = [NSMutableDictionary dictionary]; LinphoneChatMessage *msg = history->data; + const char *state = linphone_chat_message_state_to_string(linphone_chat_message_get_state(msg)); bool_t isOutgoing = linphone_chat_message_is_outgoing(msg); bool_t isFileTransfer = linphone_chat_message_is_file_transfer(msg); const LinphoneAddress *fromAddress = linphone_chat_message_get_from_address(msg); @@ -1246,6 +1247,7 @@ static void linphone_iphone_popup_password_request(LinphoneCore *lc, LinphoneAut withMaxWidth:200 andMaxHeight:200]; NSData *fromImageData = UIImageJPEGRepresentation(fromImage, 1); + [msgData setObject:[NSString stringWithUTF8String:state] forKey:@"state"]; [msgData setObject:displayNameDate forKey:@"displayNameDate"]; [msgData setObject:[NSNumber numberWithBool:isFileTransfer] forKey:@"isFileTransfer"]; [msgData setObject:fromImageData forKey:@"fromImageData"]; diff --git a/richNotifications/Base.lproj/MainInterface.storyboard b/richNotifications/Base.lproj/MainInterface.storyboard index 67240e5cd..e06903ce7 100644 --- a/richNotifications/Base.lproj/MainInterface.storyboard +++ b/richNotifications/Base.lproj/MainInterface.storyboard @@ -38,17 +38,26 @@ - + + + + + @@ -70,6 +79,7 @@ + diff --git a/richNotifications/NotificationTableViewCell.h b/richNotifications/NotificationTableViewCell.h index 0f15fa177..3a6767f92 100644 --- a/richNotifications/NotificationTableViewCell.h +++ b/richNotifications/NotificationTableViewCell.h @@ -11,5 +11,6 @@ @property (weak, nonatomic) IBOutlet UIImageView *contactImage; @property (weak, nonatomic) IBOutlet UILabel *nameDate; @property (weak, nonatomic) IBOutlet UITextView *msgText; +@property (weak, nonatomic) IBOutlet UILabel *imdm; @end diff --git a/richNotifications/NotificationViewController.m b/richNotifications/NotificationViewController.m index 014b6178d..29cd6b8b7 100644 --- a/richNotifications/NotificationViewController.m +++ b/richNotifications/NotificationViewController.m @@ -16,17 +16,28 @@ @implementation NotificationViewController { @private - NSArray *msgs; + NSMutableArray *msgs; } - (void)viewDidLoad { [super viewDidLoad]; + self.tableView.scrollEnabled = TRUE; // Do any required interface initialization here. } - (void)didReceiveNotification:(UNNotification *)notification { - msgs = [[[[notification request] content] userInfo] objectForKey:@"msgs"]; + if (msgs) + [msgs addObject:[((NSArray *)[[[[notification request] content] userInfo] objectForKey:@"msgs"]) lastObject]]; + else + msgs = [NSMutableArray arrayWithArray:[[[[notification request] content] userInfo] objectForKey:@"msgs"]]; [self.tableView reloadData]; + [self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForItem:msgs.count - 1 + inSection:0] + atScrollPosition:UITableViewScrollPositionBottom + animated:YES]; + NSLog(@"Content length : %f", self.tableView.contentSize.height); + NSLog(@"Number of rows : %d", (unsigned int)[self tableView:self.tableView numberOfRowsInSection:0]); + [self.view.superview bringSubviewToFront:self.tableView]; } #pragma mark - UITableViewDataSource Functions @@ -43,8 +54,9 @@ BOOL isOutgoing = ((NSNumber *)[msgs[indexPath.row] objectForKey:@"isOutgoing"]).boolValue; NSString *display = ((NSString *)[msgs[indexPath.row] objectForKey:@"displayNameDate"]); NSString *msgText = ((NSString *)[msgs[indexPath.row] objectForKey:@"msg"]); + NSString *imdm = ((NSString *)[msgs[indexPath.row] objectForKey:@"state"]); NSData *imageData = [msgs[indexPath.row] objectForKey:@"fromImageData"]; - printf("Message %s de %s : %s\n", isOutgoing ? "sortant" : "entrant", + printf("%s : %s : %s\n", isOutgoing ? "sortant" : "entrant", display.UTF8String, msgText.UTF8String); printf("Taille de l'image de profil : %d\n", (unsigned int)imageData.length); @@ -52,6 +64,14 @@ cell.contactImage.image = [UIImage imageWithData:imageData]; cell.nameDate.text = display; cell.msgText.text = msgText; + if (!isOutgoing) + cell.imdm.hidden = YES; + if ([imdm isEqualToString:@"LinphoneChatMessageStateDelivered"]) + cell.imdm.text = NSLocalizedString(@"Delivered", nil); + else if ([imdm isEqualToString:@"LinphoneChatMessageStateDisplayed"]) + cell.imdm.text = NSLocalizedString(@"Read", nil); + else + cell.imdm.text = imdm; return cell; } From 9d2226c7db233ed81fc90ee6bd97545f439b9a7c Mon Sep 17 00:00:00 2001 From: David Idmansour Date: Wed, 27 Jun 2018 11:48:21 +0200 Subject: [PATCH 06/15] ui cell color --- Classes/LinphoneManager.m | 5 +-- linphone.xcodeproj/project.pbxproj | 4 +++ .../Base.lproj/MainInterface.storyboard | 34 +++++++++++++++---- richNotifications/NotificationTableViewCell.h | 2 ++ richNotifications/NotificationTableViewCell.m | 1 + .../NotificationViewController.m | 1 + 6 files changed, 38 insertions(+), 9 deletions(-) diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index f91a3ebf1..51be144cf 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -1252,8 +1252,9 @@ static void linphone_iphone_popup_password_request(LinphoneCore *lc, LinphoneAut [msgData setObject:[NSNumber numberWithBool:isFileTransfer] forKey:@"isFileTransfer"]; [msgData setObject:fromImageData forKey:@"fromImageData"]; if (isFileTransfer) { - // TODO - [msgData setObject:[UIChatBubbleTextCell TextMessageForChat:msg] forKey:@"msg"]; + LinphoneContent *file = linphone_chat_message_get_file_transfer_information(msg); + const char *filename = linphone_content_get_name(file); + [msgData setObject:[NSString stringWithUTF8String:filename] forKey:@"msg"]; } else { [msgData setObject:[UIChatBubbleTextCell TextMessageForChat:msg] forKey:@"msg"]; } diff --git a/linphone.xcodeproj/project.pbxproj b/linphone.xcodeproj/project.pbxproj index ced062366..93deb1815 100755 --- a/linphone.xcodeproj/project.pbxproj +++ b/linphone.xcodeproj/project.pbxproj @@ -71,6 +71,8 @@ 5E31290C20D7A37E00CF3AAE /* latestChatroomsWidget.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 5E31290020D7A37E00CF3AAE /* latestChatroomsWidget.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; 5E31291320D7AAA100CF3AAE /* avatar.png in Resources */ = {isa = PBXBuildFile; fileRef = 633FEBE61D3CD5570014B822 /* avatar.png */; }; 5E31291A20D7AAAD00CF3AAE /* chat_group_avatar.png in Resources */ = {isa = PBXBuildFile; fileRef = 8C2A81941F87B8000012A66B /* chat_group_avatar.png */; }; + 5E3391EC20E387E000F66299 /* color_A.png in Resources */ = {isa = PBXBuildFile; fileRef = 633FEC701D3CD5570014B822 /* color_A.png */; }; + 5E3391F320E387E700F66299 /* color_D.png in Resources */ = {isa = PBXBuildFile; fileRef = 633FEC721D3CD5570014B822 /* color_D.png */; }; 5E58962420DCE5700030868C /* UserNotifications.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8C73477B1D9BA3A00022EE8C /* UserNotifications.framework */; }; 5E58962620DCE5700030868C /* UserNotificationsUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E58962520DCE5700030868C /* UserNotificationsUI.framework */; }; 5E58962A20DCE5700030868C /* NotificationViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E58962920DCE5700030868C /* NotificationViewController.m */; }; @@ -4209,7 +4211,9 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 5E3391F320E387E700F66299 /* color_D.png in Resources */, 5E58962D20DCE5700030868C /* MainInterface.storyboard in Resources */, + 5E3391EC20E387E000F66299 /* color_A.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/richNotifications/Base.lproj/MainInterface.storyboard b/richNotifications/Base.lproj/MainInterface.storyboard index e06903ce7..75085b067 100644 --- a/richNotifications/Base.lproj/MainInterface.storyboard +++ b/richNotifications/Base.lproj/MainInterface.storyboard @@ -18,15 +18,15 @@ - - + + - + - + - - + + + + + + + + + + + + + + + + + + + @@ -97,4 +114,7 @@ + + + diff --git a/richNotifications/NotificationTableViewCell.h b/richNotifications/NotificationTableViewCell.h index 3a6767f92..063836e34 100644 --- a/richNotifications/NotificationTableViewCell.h +++ b/richNotifications/NotificationTableViewCell.h @@ -12,5 +12,7 @@ @property (weak, nonatomic) IBOutlet UILabel *nameDate; @property (weak, nonatomic) IBOutlet UITextView *msgText; @property (weak, nonatomic) IBOutlet UILabel *imdm; +@property (weak, nonatomic) IBOutlet UIImageView *background; +@property (weak, nonatomic) IBOutlet UIImageView *bottomBarColor; @end diff --git a/richNotifications/NotificationTableViewCell.m b/richNotifications/NotificationTableViewCell.m index fb1853143..36e80404f 100644 --- a/richNotifications/NotificationTableViewCell.m +++ b/richNotifications/NotificationTableViewCell.m @@ -14,6 +14,7 @@ // Initialization code _contactImage.layer.cornerRadius = _contactImage.frame.size.height / 2; _contactImage.clipsToBounds = YES; + [self.contentView sendSubviewToBack:_background]; } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { diff --git a/richNotifications/NotificationViewController.m b/richNotifications/NotificationViewController.m index 29cd6b8b7..49d4a333b 100644 --- a/richNotifications/NotificationViewController.m +++ b/richNotifications/NotificationViewController.m @@ -61,6 +61,7 @@ msgText.UTF8String); printf("Taille de l'image de profil : %d\n", (unsigned int)imageData.length); NotificationTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"notificationCell" forIndexPath:indexPath]; + cell.background.image = cell.bottomBarColor.image = [UIImage imageNamed:isOutgoing ? @"color_A" : @"color_D.png"]; cell.contactImage.image = [UIImage imageWithData:imageData]; cell.nameDate.text = display; cell.msgText.text = msgText; From 59d81cd2ef37c74d7ab4323eaa49793571dc7c10 Mon Sep 17 00:00:00 2001 From: David Idmansour Date: Wed, 27 Jun 2018 17:06:46 +0200 Subject: [PATCH 07/15] aligned chat bubbles & width and height of bubbles depend on message length --- Classes/LinphoneManager.m | 3 +++ .../Base.lproj/MainInterface.storyboard | 16 ++++++++-------- richNotifications/NotificationTableViewCell.h | 3 +++ richNotifications/NotificationTableViewCell.m | 16 ++++++++++++++++ richNotifications/NotificationViewController.m | 18 +++++++++++++----- 5 files changed, 43 insertions(+), 13 deletions(-) diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index 51be144cf..871fae6f4 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -1256,6 +1256,9 @@ static void linphone_iphone_popup_password_request(LinphoneCore *lc, LinphoneAut const char *filename = linphone_content_get_name(file); [msgData setObject:[NSString stringWithUTF8String:filename] forKey:@"msg"]; } else { + CGSize msgSize = [UIChatBubbleTextCell ViewSizeForMessage:msg withWidth:375]; + [msgData setObject:[NSNumber numberWithFloat:msgSize.width] forKey:@"width"]; + [msgData setObject:[NSNumber numberWithFloat:msgSize.height] forKey:@"height"]; [msgData setObject:[UIChatBubbleTextCell TextMessageForChat:msg] forKey:@"msg"]; } [msgData setObject:[NSNumber numberWithBool:isOutgoing] forKey:@"isOutgoing"]; diff --git a/richNotifications/Base.lproj/MainInterface.storyboard b/richNotifications/Base.lproj/MainInterface.storyboard index 75085b067..de6f3da83 100644 --- a/richNotifications/Base.lproj/MainInterface.storyboard +++ b/richNotifications/Base.lproj/MainInterface.storyboard @@ -26,25 +26,25 @@ - + - - + + @@ -87,8 +87,8 @@ - - + + diff --git a/richNotifications/NotificationTableViewCell.h b/richNotifications/NotificationTableViewCell.h index 063836e34..534c10f0c 100644 --- a/richNotifications/NotificationTableViewCell.h +++ b/richNotifications/NotificationTableViewCell.h @@ -14,5 +14,8 @@ @property (weak, nonatomic) IBOutlet UILabel *imdm; @property (weak, nonatomic) IBOutlet UIImageView *background; @property (weak, nonatomic) IBOutlet UIImageView *bottomBarColor; +@property BOOL isOutgoing; +@property float width; +@property float height; @end diff --git a/richNotifications/NotificationTableViewCell.m b/richNotifications/NotificationTableViewCell.m index 36e80404f..79b64f1b1 100644 --- a/richNotifications/NotificationTableViewCell.m +++ b/richNotifications/NotificationTableViewCell.m @@ -23,4 +23,20 @@ // Configure the view for the selected state } +- (void)layoutSubviews { + [super layoutSubviews]; + CGRect bubbleFrame = self.contentView.frame; + int origin_x; + + bubbleFrame.size = CGSizeMake(_width, _height); + + origin_x = (_isOutgoing ? self.frame.size.width - bubbleFrame.size.width - 5 : 5); + + bubbleFrame.origin.x = origin_x; + self.contentView.frame = bubbleFrame; + + _msgText.textContainerInset = UIEdgeInsetsZero; + _msgText.textContainer.lineFragmentPadding = 0; +} + @end diff --git a/richNotifications/NotificationViewController.m b/richNotifications/NotificationViewController.m index 49d4a333b..9ba2fa616 100644 --- a/richNotifications/NotificationViewController.m +++ b/richNotifications/NotificationViewController.m @@ -37,7 +37,6 @@ animated:YES]; NSLog(@"Content length : %f", self.tableView.contentSize.height); NSLog(@"Number of rows : %d", (unsigned int)[self tableView:self.tableView numberOfRowsInSection:0]); - [self.view.superview bringSubviewToFront:self.tableView]; } #pragma mark - UITableViewDataSource Functions @@ -65,21 +64,30 @@ cell.contactImage.image = [UIImage imageWithData:imageData]; cell.nameDate.text = display; cell.msgText.text = msgText; + cell.isOutgoing = isOutgoing; + cell.width = ((NSNumber *)[msgs[indexPath.row] objectForKey:@"width"]).floatValue; + cell.height = ((NSNumber *)[msgs[indexPath.row] objectForKey:@"height"]).floatValue; + cell.nameDate.textColor = [UIColor colorWithPatternImage:cell.background.image]; + cell.msgText.textColor = [UIColor darkGrayColor]; if (!isOutgoing) cell.imdm.hidden = YES; - if ([imdm isEqualToString:@"LinphoneChatMessageStateDelivered"]) + if ([imdm isEqualToString:@"LinphoneChatMessageStateDelivered"]) { cell.imdm.text = NSLocalizedString(@"Delivered", nil); - else if ([imdm isEqualToString:@"LinphoneChatMessageStateDisplayed"]) + cell.imdm.textColor = [UIColor grayColor]; + } else if ([imdm isEqualToString:@"LinphoneChatMessageStateDisplayed"]) { cell.imdm.text = NSLocalizedString(@"Read", nil); - else + cell.imdm.textColor = [UIColor colorWithRed:(24 / 255.0) green:(167 / 255.0) blue:(175 / 255.0) alpha:1.0]; + } else cell.imdm.text = imdm; + printf("Taille label : %f\n", cell.nameDate.font.pointSize); + printf("Taille field : %f\n", cell.msgText.font.pointSize); return cell; } #pragma mark - UITableViewDelegate Functions - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { - return 100; + return ((NSNumber *)[msgs[indexPath.row] objectForKey:@"height"]).floatValue + 5; } @end From feb2a9a461257ab2cd787d3c63f5a69e7f5997a6 Mon Sep 17 00:00:00 2001 From: David Idmansour Date: Thu, 28 Jun 2018 09:31:00 +0200 Subject: [PATCH 08/15] added imdm icon --- linphone.xcodeproj/project.pbxproj | 6 +++ .../Base.lproj/MainInterface.storyboard | 43 +++++++++++++------ richNotifications/NotificationTableViewCell.h | 1 + .../NotificationViewController.m | 9 +++- 4 files changed, 44 insertions(+), 15 deletions(-) diff --git a/linphone.xcodeproj/project.pbxproj b/linphone.xcodeproj/project.pbxproj index 93deb1815..e7ceca8a3 100755 --- a/linphone.xcodeproj/project.pbxproj +++ b/linphone.xcodeproj/project.pbxproj @@ -71,6 +71,9 @@ 5E31290C20D7A37E00CF3AAE /* latestChatroomsWidget.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 5E31290020D7A37E00CF3AAE /* latestChatroomsWidget.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; 5E31291320D7AAA100CF3AAE /* avatar.png in Resources */ = {isa = PBXBuildFile; fileRef = 633FEBE61D3CD5570014B822 /* avatar.png */; }; 5E31291A20D7AAAD00CF3AAE /* chat_group_avatar.png in Resources */ = {isa = PBXBuildFile; fileRef = 8C2A81941F87B8000012A66B /* chat_group_avatar.png */; }; + 5E32944520E4C29000BBA896 /* chat_delivered.png in Resources */ = {isa = PBXBuildFile; fileRef = 244523AC1E8266CC0037A187 /* chat_delivered.png */; }; + 5E32944C20E4C29300BBA896 /* chat_error.png in Resources */ = {isa = PBXBuildFile; fileRef = 244523AD1E8266CC0037A187 /* chat_error.png */; }; + 5E32944D20E4C29700BBA896 /* chat_read.png in Resources */ = {isa = PBXBuildFile; fileRef = 244523AE1E8266CC0037A187 /* chat_read.png */; }; 5E3391EC20E387E000F66299 /* color_A.png in Resources */ = {isa = PBXBuildFile; fileRef = 633FEC701D3CD5570014B822 /* color_A.png */; }; 5E3391F320E387E700F66299 /* color_D.png in Resources */ = {isa = PBXBuildFile; fileRef = 633FEC721D3CD5570014B822 /* color_D.png */; }; 5E58962420DCE5700030868C /* UserNotifications.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8C73477B1D9BA3A00022EE8C /* UserNotifications.framework */; }; @@ -4211,6 +4214,9 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 5E32944C20E4C29300BBA896 /* chat_error.png in Resources */, + 5E32944D20E4C29700BBA896 /* chat_read.png in Resources */, + 5E32944520E4C29000BBA896 /* chat_delivered.png in Resources */, 5E3391F320E387E700F66299 /* color_D.png in Resources */, 5E58962D20DCE5700030868C /* MainInterface.storyboard in Resources */, 5E3391EC20E387E000F66299 /* color_A.png in Resources */, diff --git a/richNotifications/Base.lproj/MainInterface.storyboard b/richNotifications/Base.lproj/MainInterface.storyboard index de6f3da83..3ad8ffb45 100644 --- a/richNotifications/Base.lproj/MainInterface.storyboard +++ b/richNotifications/Base.lproj/MainInterface.storyboard @@ -26,10 +26,10 @@ - + - + - + + + + + + + + + + + + + + + + - - - + + @@ -82,13 +96,13 @@ - + - + @@ -97,6 +111,7 @@ + diff --git a/richNotifications/NotificationTableViewCell.h b/richNotifications/NotificationTableViewCell.h index 534c10f0c..58fb529cb 100644 --- a/richNotifications/NotificationTableViewCell.h +++ b/richNotifications/NotificationTableViewCell.h @@ -14,6 +14,7 @@ @property (weak, nonatomic) IBOutlet UILabel *imdm; @property (weak, nonatomic) IBOutlet UIImageView *background; @property (weak, nonatomic) IBOutlet UIImageView *bottomBarColor; +@property (weak, nonatomic) IBOutlet UIImageView *imdmImage; @property BOOL isOutgoing; @property float width; @property float height; diff --git a/richNotifications/NotificationViewController.m b/richNotifications/NotificationViewController.m index 9ba2fa616..19d4e0075 100644 --- a/richNotifications/NotificationViewController.m +++ b/richNotifications/NotificationViewController.m @@ -37,6 +37,9 @@ animated:YES]; NSLog(@"Content length : %f", self.tableView.contentSize.height); NSLog(@"Number of rows : %d", (unsigned int)[self tableView:self.tableView numberOfRowsInSection:0]); + [self.view.superview bringSubviewToFront:self.tableView]; + self.tableView.bounds = CGRectMake(self.tableView.bounds.origin.x, self.tableView.bounds.origin.y, self.tableView.contentSize.width, self.tableView.contentSize.height); + NSLog(@"View length : %f", self.tableView.bounds.size.height); } #pragma mark - UITableViewDataSource Functions @@ -69,14 +72,18 @@ cell.height = ((NSNumber *)[msgs[indexPath.row] objectForKey:@"height"]).floatValue; cell.nameDate.textColor = [UIColor colorWithPatternImage:cell.background.image]; cell.msgText.textColor = [UIColor darkGrayColor]; - if (!isOutgoing) + if (!isOutgoing) { cell.imdm.hidden = YES; + cell.imdmImage.hidden = YES; + } if ([imdm isEqualToString:@"LinphoneChatMessageStateDelivered"]) { cell.imdm.text = NSLocalizedString(@"Delivered", nil); cell.imdm.textColor = [UIColor grayColor]; + cell.imdmImage.image = [UIImage imageNamed:@"chat_delivered.png"]; } else if ([imdm isEqualToString:@"LinphoneChatMessageStateDisplayed"]) { cell.imdm.text = NSLocalizedString(@"Read", nil); cell.imdm.textColor = [UIColor colorWithRed:(24 / 255.0) green:(167 / 255.0) blue:(175 / 255.0) alpha:1.0]; + cell.imdmImage.image = [UIImage imageNamed:@"chat_read.png"]; } else cell.imdm.text = imdm; printf("Taille label : %f\n", cell.nameDate.font.pointSize); From 1753ddc032cae13bfbe9087372215bd22e77565f Mon Sep 17 00:00:00 2001 From: David Idmansour Date: Thu, 28 Jun 2018 14:36:17 +0200 Subject: [PATCH 09/15] chat bubbles size calculated based on notification view size --- Classes/LinphoneManager.m | 3 -- richNotifications/NotificationTableViewCell.h | 5 +- richNotifications/NotificationTableViewCell.m | 52 +++++++++++++++++++ .../NotificationViewController.m | 12 +++-- 4 files changed, 64 insertions(+), 8 deletions(-) diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index 871fae6f4..51be144cf 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -1256,9 +1256,6 @@ static void linphone_iphone_popup_password_request(LinphoneCore *lc, LinphoneAut const char *filename = linphone_content_get_name(file); [msgData setObject:[NSString stringWithUTF8String:filename] forKey:@"msg"]; } else { - CGSize msgSize = [UIChatBubbleTextCell ViewSizeForMessage:msg withWidth:375]; - [msgData setObject:[NSNumber numberWithFloat:msgSize.width] forKey:@"width"]; - [msgData setObject:[NSNumber numberWithFloat:msgSize.height] forKey:@"height"]; [msgData setObject:[UIChatBubbleTextCell TextMessageForChat:msg] forKey:@"msg"]; } [msgData setObject:[NSNumber numberWithBool:isOutgoing] forKey:@"isOutgoing"]; diff --git a/richNotifications/NotificationTableViewCell.h b/richNotifications/NotificationTableViewCell.h index 58fb529cb..2300cf3b4 100644 --- a/richNotifications/NotificationTableViewCell.h +++ b/richNotifications/NotificationTableViewCell.h @@ -10,7 +10,7 @@ @interface NotificationTableViewCell : UITableViewCell @property (weak, nonatomic) IBOutlet UIImageView *contactImage; @property (weak, nonatomic) IBOutlet UILabel *nameDate; -@property (weak, nonatomic) IBOutlet UITextView *msgText; +@property (strong, nonatomic) IBOutlet UITextView *msgText; @property (weak, nonatomic) IBOutlet UILabel *imdm; @property (weak, nonatomic) IBOutlet UIImageView *background; @property (weak, nonatomic) IBOutlet UIImageView *bottomBarColor; @@ -19,4 +19,7 @@ @property float width; @property float height; +- (CGSize)ViewSizeForMessage:(NSString *)chat withWidth:(int)width; +- (CGSize)ViewHeightForMessage:(NSString *)messageText withWidth:(int)width; + @end diff --git a/richNotifications/NotificationTableViewCell.m b/richNotifications/NotificationTableViewCell.m index 79b64f1b1..b1b2160e3 100644 --- a/richNotifications/NotificationTableViewCell.m +++ b/richNotifications/NotificationTableViewCell.m @@ -39,4 +39,56 @@ _msgText.textContainer.lineFragmentPadding = 0; } +#pragma mark - Bubble size computing + +- (CGSize)computeBoundingBox:(NSString *)text size:(CGSize)size font:(UIFont *)font { + if (!text || text.length == 0) + return CGSizeMake(0, 0); + + return [text boundingRectWithSize:size + options:(NSStringDrawingUsesLineFragmentOrigin | + NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesFontLeading) + attributes:@{ + NSFontAttributeName : font + } + context:nil].size; +} + +static const CGFloat CELL_MIN_HEIGHT = 60.0f; +static const CGFloat CELL_MIN_WIDTH = 190.0f; +static const CGFloat CELL_MESSAGE_X_MARGIN = 78 + 10.0f; +static const CGFloat CELL_MESSAGE_Y_MARGIN = 52; // 44; + +- (CGSize)ViewHeightForMessage:(NSString *)messageText withWidth:(int)width { + static UIFont *messageFont = nil; + + if (!messageFont) { + messageFont = _msgText.font; + } + CGSize size; + size = [self computeBoundingBox:messageText + size:CGSizeMake(width - CELL_MESSAGE_X_MARGIN - 4, CGFLOAT_MAX) + font:messageFont]; + + size.width = MAX(size.width + CELL_MESSAGE_X_MARGIN, CELL_MIN_WIDTH); + size.height = MAX(size.height + CELL_MESSAGE_Y_MARGIN, CELL_MIN_HEIGHT); + return size; +} +- (CGSize)ViewSizeForMessage:(NSString *)chat withWidth:(int)width { + static UIFont *dateFont = nil; + static CGSize dateViewSize; + + if (!dateFont) { + dateFont = _nameDate.font; + dateViewSize = _nameDate.frame.size; + dateViewSize.width = CGFLOAT_MAX; + } + + CGSize messageSize = [self ViewHeightForMessage:chat withWidth:width]; + CGSize dateSize = [self computeBoundingBox:_nameDate.text size:dateViewSize font:dateFont]; + messageSize.width = MAX(MAX(messageSize.width, MIN(dateSize.width + CELL_MESSAGE_X_MARGIN, width)), CELL_MIN_WIDTH); + + return messageSize; +} + @end diff --git a/richNotifications/NotificationViewController.m b/richNotifications/NotificationViewController.m index 19d4e0075..49f0175ce 100644 --- a/richNotifications/NotificationViewController.m +++ b/richNotifications/NotificationViewController.m @@ -38,7 +38,6 @@ NSLog(@"Content length : %f", self.tableView.contentSize.height); NSLog(@"Number of rows : %d", (unsigned int)[self tableView:self.tableView numberOfRowsInSection:0]); [self.view.superview bringSubviewToFront:self.tableView]; - self.tableView.bounds = CGRectMake(self.tableView.bounds.origin.x, self.tableView.bounds.origin.y, self.tableView.contentSize.width, self.tableView.contentSize.height); NSLog(@"View length : %f", self.tableView.bounds.size.height); } @@ -68,8 +67,9 @@ cell.nameDate.text = display; cell.msgText.text = msgText; cell.isOutgoing = isOutgoing; - cell.width = ((NSNumber *)[msgs[indexPath.row] objectForKey:@"width"]).floatValue; - cell.height = ((NSNumber *)[msgs[indexPath.row] objectForKey:@"height"]).floatValue; + CGSize size = [cell ViewSizeForMessage:msgText withWidth:self.view.bounds.size.width - 10]; + cell.width = size.width; + cell.height = size.height; cell.nameDate.textColor = [UIColor colorWithPatternImage:cell.background.image]; cell.msgText.textColor = [UIColor darkGrayColor]; if (!isOutgoing) { @@ -94,7 +94,11 @@ #pragma mark - UITableViewDelegate Functions - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { - return ((NSNumber *)[msgs[indexPath.row] objectForKey:@"height"]).floatValue + 5; + NotificationTableViewCell *cell = [[NotificationTableViewCell alloc] init]; + cell.msgText = [[UITextView alloc] init]; + cell.msgText.text = ((NSString *)[msgs[indexPath.row] objectForKey:@"msg"]); + cell.msgText.font = [UIFont systemFontOfSize:17]; + return [cell ViewHeightForMessage:cell.msgText.text withWidth:self.view.bounds.size.width - 10].height + 5; } @end From b31dfadfa48ec50d2132bcc0340377321be24246 Mon Sep 17 00:00:00 2001 From: David Idmansour Date: Thu, 28 Jun 2018 15:03:51 +0200 Subject: [PATCH 10/15] fixed outgoing file transfer messages --- Classes/LinphoneManager.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index 51be144cf..271c3ad2c 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -1238,7 +1238,7 @@ static void linphone_iphone_popup_password_request(LinphoneCore *lc, LinphoneAut LinphoneChatMessage *msg = history->data; const char *state = linphone_chat_message_state_to_string(linphone_chat_message_get_state(msg)); bool_t isOutgoing = linphone_chat_message_is_outgoing(msg); - bool_t isFileTransfer = linphone_chat_message_is_file_transfer(msg); + bool_t isFileTransfer = (linphone_chat_message_get_file_transfer_information(msg) != NULL); const LinphoneAddress *fromAddress = linphone_chat_message_get_from_address(msg); NSString *displayNameDate = [NSString stringWithFormat:@"%@ - %@", [LinphoneUtils timeToString:linphone_chat_message_get_time(msg) withFormat:LinphoneDateChatBubble], From 421212f2f1eba3d8a4ebc41e33d333f4f36b7cd6 Mon Sep 17 00:00:00 2001 From: David Idmansour Date: Thu, 28 Jun 2018 16:32:37 +0200 Subject: [PATCH 11/15] changed imdm text --- richNotifications/NotificationViewController.m | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/richNotifications/NotificationViewController.m b/richNotifications/NotificationViewController.m index 49f0175ce..fe8b3895b 100644 --- a/richNotifications/NotificationViewController.m +++ b/richNotifications/NotificationViewController.m @@ -31,6 +31,7 @@ else msgs = [NSMutableArray arrayWithArray:[[[[notification request] content] userInfo] objectForKey:@"msgs"]]; [self.tableView reloadData]; + [self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForItem:msgs.count - 1 inSection:0] atScrollPosition:UITableViewScrollPositionBottom @@ -76,7 +77,7 @@ cell.imdm.hidden = YES; cell.imdmImage.hidden = YES; } - if ([imdm isEqualToString:@"LinphoneChatMessageStateDelivered"]) { + if ([imdm isEqualToString:@"LinphoneChatMessageStateDelivered"] || [imdm isEqualToString:@"LinphoneChatMessageStateDeliveredToUser"]) { cell.imdm.text = NSLocalizedString(@"Delivered", nil); cell.imdm.textColor = [UIColor grayColor]; cell.imdmImage.image = [UIImage imageNamed:@"chat_delivered.png"]; @@ -84,8 +85,12 @@ cell.imdm.text = NSLocalizedString(@"Read", nil); cell.imdm.textColor = [UIColor colorWithRed:(24 / 255.0) green:(167 / 255.0) blue:(175 / 255.0) alpha:1.0]; cell.imdmImage.image = [UIImage imageNamed:@"chat_read.png"]; + } else if ([imdm isEqualToString:@"LinphoneChatMessageStateNotDelivered"] || [imdm isEqualToString:@"LinphoneChatMessageStateFileTransferError"]) { + cell.imdm.text = NSLocalizedString(@"Error", nil); + cell.imdm.textColor = [UIColor redColor]; + cell.imdmImage.image = [UIImage imageNamed:@"chat_error.png"]; } else - cell.imdm.text = imdm; + cell.imdm.hidden = YES; printf("Taille label : %f\n", cell.nameDate.font.pointSize); printf("Taille field : %f\n", cell.msgText.font.pointSize); return cell; From afd3d7a880d97b7880edd6eb68f2abee11eb8e9b Mon Sep 17 00:00:00 2001 From: David Idmansour Date: Fri, 29 Jun 2018 14:12:12 +0200 Subject: [PATCH 12/15] adapt view controller size to content size --- Classes/LinphoneManager.m | 2 +- .../Base.lproj/MainInterface.storyboard | 16 ++++---- richNotifications/NotificationTableViewCell.h | 1 - .../NotificationViewController.m | 38 +++++++++++++------ 4 files changed, 35 insertions(+), 22 deletions(-) diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index 271c3ad2c..7f94a5faa 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -1232,7 +1232,7 @@ static void linphone_iphone_popup_password_request(LinphoneCore *lc, LinphoneAut content.categoryIdentifier = @"msg_cat"; // save data to user info for rich notification content NSMutableArray *msgs = [NSMutableArray array]; - bctbx_list_t *history = linphone_chat_room_get_history(room, 4); + bctbx_list_t *history = linphone_chat_room_get_history(room, 6); while (history) { NSMutableDictionary *msgData = [NSMutableDictionary dictionary]; LinphoneChatMessage *msg = history->data; diff --git a/richNotifications/Base.lproj/MainInterface.storyboard b/richNotifications/Base.lproj/MainInterface.storyboard index 3ad8ffb45..f50b1b59d 100644 --- a/richNotifications/Base.lproj/MainInterface.storyboard +++ b/richNotifications/Base.lproj/MainInterface.storyboard @@ -18,15 +18,15 @@ - - + + - + - + - + - + - + - + diff --git a/richNotifications/NotificationTableViewCell.h b/richNotifications/NotificationTableViewCell.h index 2300cf3b4..77b74e1d3 100644 --- a/richNotifications/NotificationTableViewCell.h +++ b/richNotifications/NotificationTableViewCell.h @@ -20,6 +20,5 @@ @property float height; - (CGSize)ViewSizeForMessage:(NSString *)chat withWidth:(int)width; -- (CGSize)ViewHeightForMessage:(NSString *)messageText withWidth:(int)width; @end diff --git a/richNotifications/NotificationViewController.m b/richNotifications/NotificationViewController.m index fe8b3895b..99807e97c 100644 --- a/richNotifications/NotificationViewController.m +++ b/richNotifications/NotificationViewController.m @@ -26,20 +26,34 @@ } - (void)didReceiveNotification:(UNNotification *)notification { + static float initialHeight = -1; + if (initialHeight < 0) + initialHeight = self.tableView.frame.size.height; + printf("Initial height : %f\n", initialHeight); if (msgs) [msgs addObject:[((NSArray *)[[[[notification request] content] userInfo] objectForKey:@"msgs"]) lastObject]]; else msgs = [NSMutableArray arrayWithArray:[[[[notification request] content] userInfo] objectForKey:@"msgs"]]; [self.tableView reloadData]; - - [self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForItem:msgs.count - 1 - inSection:0] - atScrollPosition:UITableViewScrollPositionBottom - animated:YES]; + float height = 0; + for (int i = 0 ; i < self->msgs.count ; i++) { + height += [self tableView:self.tableView heightForRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:0]]; + } + if (height > initialHeight) { + CGRect frame = self.tableView.frame; + frame.size.height = height; + frame.origin = CGPointMake(0, 0); + self.tableView.frame = frame; + self.tableView.bounds = frame; + self.preferredContentSize = CGSizeMake(self.preferredContentSize.width, height); + } + printf("Height : %f\n", height); NSLog(@"Content length : %f", self.tableView.contentSize.height); NSLog(@"Number of rows : %d", (unsigned int)[self tableView:self.tableView numberOfRowsInSection:0]); - [self.view.superview bringSubviewToFront:self.tableView]; - NSLog(@"View length : %f", self.tableView.bounds.size.height); + NSLog(@"View bounds length : %f", self.tableView.bounds.size.height); + NSLog(@"View frame length : %f", self.tableView.frame.size.height); + NSLog(@"View bounds y : %f", self.tableView.bounds.origin.y); + NSLog(@"View frame y : %f", self.tableView.frame.origin.y); } #pragma mark - UITableViewDataSource Functions @@ -73,10 +87,7 @@ cell.height = size.height; cell.nameDate.textColor = [UIColor colorWithPatternImage:cell.background.image]; cell.msgText.textColor = [UIColor darkGrayColor]; - if (!isOutgoing) { - cell.imdm.hidden = YES; - cell.imdmImage.hidden = YES; - } + cell.imdm.hidden = cell.imdmImage.hidden = !isOutgoing; if ([imdm isEqualToString:@"LinphoneChatMessageStateDelivered"] || [imdm isEqualToString:@"LinphoneChatMessageStateDeliveredToUser"]) { cell.imdm.text = NSLocalizedString(@"Delivered", nil); cell.imdm.textColor = [UIColor grayColor]; @@ -93,6 +104,9 @@ cell.imdm.hidden = YES; printf("Taille label : %f\n", cell.nameDate.font.pointSize); printf("Taille field : %f\n", cell.msgText.font.pointSize); + printf("%d\n", (unsigned int)indexPath.row); + printf("X : %f\n", cell.frame.origin.x); + printf("Y : %f\n", cell.frame.origin.y); return cell; } @@ -103,7 +117,7 @@ cell.msgText = [[UITextView alloc] init]; cell.msgText.text = ((NSString *)[msgs[indexPath.row] objectForKey:@"msg"]); cell.msgText.font = [UIFont systemFontOfSize:17]; - return [cell ViewHeightForMessage:cell.msgText.text withWidth:self.view.bounds.size.width - 10].height + 5; + return [cell ViewSizeForMessage:cell.msgText.text withWidth:self.view.bounds.size.width - 10].height + 5; } @end From 2054659f8f33421675f48c0a76fb426ce114e15a Mon Sep 17 00:00:00 2001 From: David Idmansour Date: Mon, 2 Jul 2018 10:35:01 +0200 Subject: [PATCH 13/15] static view dimensions & scroll to bottom when new message received --- .../NotificationViewController.m | 33 +++++++++---------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/richNotifications/NotificationViewController.m b/richNotifications/NotificationViewController.m index 99807e97c..0fb12407e 100644 --- a/richNotifications/NotificationViewController.m +++ b/richNotifications/NotificationViewController.m @@ -26,28 +26,27 @@ } - (void)didReceiveNotification:(UNNotification *)notification { - static float initialHeight = -1; - if (initialHeight < 0) - initialHeight = self.tableView.frame.size.height; - printf("Initial height : %f\n", initialHeight); +// static float initialHeight = -1; +// if (initialHeight < 0) +// initialHeight = self.tableView.frame.size.height; if (msgs) [msgs addObject:[((NSArray *)[[[[notification request] content] userInfo] objectForKey:@"msgs"]) lastObject]]; else msgs = [NSMutableArray arrayWithArray:[[[[notification request] content] userInfo] objectForKey:@"msgs"]]; [self.tableView reloadData]; - float height = 0; - for (int i = 0 ; i < self->msgs.count ; i++) { - height += [self tableView:self.tableView heightForRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:0]]; - } - if (height > initialHeight) { - CGRect frame = self.tableView.frame; - frame.size.height = height; - frame.origin = CGPointMake(0, 0); - self.tableView.frame = frame; - self.tableView.bounds = frame; - self.preferredContentSize = CGSizeMake(self.preferredContentSize.width, height); - } - printf("Height : %f\n", height); + [self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:msgs.count - 1 inSection:0] atScrollPosition:UITableViewScrollPositionBottom animated:YES]; +// float height = 0; +// for (int i = 0 ; i < self->msgs.count ; i++) { +// height += [self tableView:self.tableView heightForRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:0]]; +// } +// if (height > initialHeight) { +// CGRect frame = self.tableView.frame; +// frame.size.height = height; +// frame.origin = CGPointMake(0, 0); +// self.tableView.frame = frame; +// self.tableView.bounds = frame; +// self.preferredContentSize = CGSizeMake(self.preferredContentSize.width, height); +// } NSLog(@"Content length : %f", self.tableView.contentSize.height); NSLog(@"Number of rows : %d", (unsigned int)[self tableView:self.tableView numberOfRowsInSection:0]); NSLog(@"View bounds length : %f", self.tableView.bounds.size.height); From dfc9dfed50bcc9de19793f0ae6417fdc9e0e8438 Mon Sep 17 00:00:00 2001 From: David Idmansour Date: Mon, 2 Jul 2018 10:43:32 +0200 Subject: [PATCH 14/15] cleaned code --- richNotifications/NotificationTableViewCell.m | 6 +++--- richNotifications/NotificationViewController.m | 18 +++--------------- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/richNotifications/NotificationTableViewCell.m b/richNotifications/NotificationTableViewCell.m index b1b2160e3..26fe0f188 100644 --- a/richNotifications/NotificationTableViewCell.m +++ b/richNotifications/NotificationTableViewCell.m @@ -26,13 +26,13 @@ - (void)layoutSubviews { [super layoutSubviews]; CGRect bubbleFrame = self.contentView.frame; - int origin_x; + int originX; bubbleFrame.size = CGSizeMake(_width, _height); - origin_x = (_isOutgoing ? self.frame.size.width - bubbleFrame.size.width - 5 : 5); + originX = (_isOutgoing ? self.frame.size.width - bubbleFrame.size.width - 5 : 5); - bubbleFrame.origin.x = origin_x; + bubbleFrame.origin.x = originX; self.contentView.frame = bubbleFrame; _msgText.textContainerInset = UIEdgeInsetsZero; diff --git a/richNotifications/NotificationViewController.m b/richNotifications/NotificationViewController.m index 0fb12407e..69aa955a8 100644 --- a/richNotifications/NotificationViewController.m +++ b/richNotifications/NotificationViewController.m @@ -47,12 +47,6 @@ // self.tableView.bounds = frame; // self.preferredContentSize = CGSizeMake(self.preferredContentSize.width, height); // } - NSLog(@"Content length : %f", self.tableView.contentSize.height); - NSLog(@"Number of rows : %d", (unsigned int)[self tableView:self.tableView numberOfRowsInSection:0]); - NSLog(@"View bounds length : %f", self.tableView.bounds.size.height); - NSLog(@"View frame length : %f", self.tableView.frame.size.height); - NSLog(@"View bounds y : %f", self.tableView.bounds.origin.y); - NSLog(@"View frame y : %f", self.tableView.frame.origin.y); } #pragma mark - UITableViewDataSource Functions @@ -71,11 +65,8 @@ NSString *msgText = ((NSString *)[msgs[indexPath.row] objectForKey:@"msg"]); NSString *imdm = ((NSString *)[msgs[indexPath.row] objectForKey:@"state"]); NSData *imageData = [msgs[indexPath.row] objectForKey:@"fromImageData"]; - printf("%s : %s : %s\n", isOutgoing ? "sortant" : "entrant", - display.UTF8String, - msgText.UTF8String); - printf("Taille de l'image de profil : %d\n", (unsigned int)imageData.length); NotificationTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"notificationCell" forIndexPath:indexPath]; + cell.background.image = cell.bottomBarColor.image = [UIImage imageNamed:isOutgoing ? @"color_A" : @"color_D.png"]; cell.contactImage.image = [UIImage imageWithData:imageData]; cell.nameDate.text = display; @@ -87,6 +78,7 @@ cell.nameDate.textColor = [UIColor colorWithPatternImage:cell.background.image]; cell.msgText.textColor = [UIColor darkGrayColor]; cell.imdm.hidden = cell.imdmImage.hidden = !isOutgoing; + if ([imdm isEqualToString:@"LinphoneChatMessageStateDelivered"] || [imdm isEqualToString:@"LinphoneChatMessageStateDeliveredToUser"]) { cell.imdm.text = NSLocalizedString(@"Delivered", nil); cell.imdm.textColor = [UIColor grayColor]; @@ -101,11 +93,7 @@ cell.imdmImage.image = [UIImage imageNamed:@"chat_error.png"]; } else cell.imdm.hidden = YES; - printf("Taille label : %f\n", cell.nameDate.font.pointSize); - printf("Taille field : %f\n", cell.msgText.font.pointSize); - printf("%d\n", (unsigned int)indexPath.row); - printf("X : %f\n", cell.frame.origin.x); - printf("Y : %f\n", cell.frame.origin.y); + return cell; } From 1e413edd8bf291dc77ee55e966ca2f1b2f29dba6 Mon Sep 17 00:00:00 2001 From: David Idmansour Date: Mon, 2 Jul 2018 13:35:18 +0200 Subject: [PATCH 15/15] update changelog --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a779fd05..ad2b43bb7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,14 @@ Group changes to describe their impact on the project, as follows: Fixed for any bug fixes. Security to invite users to upgrade in case of vulnerabilities. +## [Unreleased] + +### Added +- Latest Calls widget +- Latest Chatrooms widget +- Homescreen quick action : New message +- Rich message notifications with Linphone UI + ## [4.0] - 2018-06-11 ### Added