From b40d8ab47600bab6bb5a4ccfac415e365d4dbc89 Mon Sep 17 00:00:00 2001 From: Guillaume BIENKOWSKI Date: Thu, 6 Aug 2015 09:24:06 +0200 Subject: [PATCH] Add the option to show the user's message in notifications --- Classes/LinphoneAppDelegate.m | 2 +- Classes/LinphoneCoreSettingsStore.m | 4 ++ Classes/LinphoneManager.m | 10 +++- Resources/ar.lproj/Localizable.strings | Bin 30968 -> 31018 bytes Resources/en.lproj/Localizable.strings | Bin 31690 -> 31740 bytes Resources/fr.lproj/Localizable.strings | Bin 33028 -> 33078 bytes Resources/ru.lproj/Localizable.strings | Bin 32186 -> 32236 bytes Settings/InAppSettings.bundle/Advanced.plist | 46 ++++++++++-------- .../en.lproj/Advanced.strings | 5 +- Tools/i18n_generate_strings_files.sh | 2 + 10 files changed, 45 insertions(+), 24 deletions(-) diff --git a/Classes/LinphoneAppDelegate.m b/Classes/LinphoneAppDelegate.m index fe20e12c3..cf246ea2d 100644 --- a/Classes/LinphoneAppDelegate.m +++ b/Classes/LinphoneAppDelegate.m @@ -297,7 +297,7 @@ LOGE(@"PushNotification: does not have call-id yet, fix it !"); } - if ([loc_key isEqualToString:@"IM_MSG"]) { + if ([loc_key isEqualToString:@"IM_MSG"] || [loc_key isEqualToString:@"IM_FULLMSG"]) { [[PhoneMainView instance] changeCurrentView:[ChatViewController compositeViewDescription]]; diff --git a/Classes/LinphoneCoreSettingsStore.m b/Classes/LinphoneCoreSettingsStore.m index d983e88d3..173bfcb58 100644 --- a/Classes/LinphoneCoreSettingsStore.m +++ b/Classes/LinphoneCoreSettingsStore.m @@ -325,6 +325,8 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args); forKey:@"start_at_boot_preference"]; [self setBool:[lm lpConfigBoolForKey:@"autoanswer_notif_preference" withDefault:NO] forKey:@"autoanswer_notif_preference"]; + [self setBool:[lm lpConfigBoolForKey:@"show_msg_in_notif" withDefault:NO] + forKey:@"show_msg_in_notif"]; [self setBool:[lm lpConfigBoolForKey:@"enable_first_login_view_preference" withDefault:NO] forKey:@"enable_first_login_view_preference"]; LinphoneAddress *parsed = linphone_core_get_primary_contact_parsed(lc); @@ -765,6 +767,8 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args); [lm lpConfigSetInt:[self integerForKey:@"start_at_boot_preference"] forKey:@"start_at_boot_preference"]; [lm lpConfigSetInt:[self integerForKey:@"autoanswer_notif_preference"] forKey:@"autoanswer_notif_preference"]; + [lm lpConfigSetInt:[self integerForKey:@"show_msg_in_notif"] forKey:@"show_msg_in_notif"]; + BOOL firstloginview = [self boolForKey:@"enable_first_login_view_preference"]; [lm lpConfigSetInt:firstloginview forKey:@"enable_first_login_view_preference"]; diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index a73ce1cf3..438ca1f50 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -901,6 +901,8 @@ static void linphone_iphone_registration_state(LinphoneCore *lc, LinphoneProxyCo NSString *remote_uri = [NSString stringWithUTF8String:c_address]; const char *call_id = linphone_chat_message_get_custom_header(msg, "Call-ID"); NSString *callID = [NSString stringWithUTF8String:call_id]; + const char* chat = linphone_chat_message_get_text(msg); + if( chat == NULL) chat = ""; ms_free(c_address); @@ -915,6 +917,8 @@ static void linphone_iphone_registration_state(LinphoneCore *lc, LinphoneProxyCo linphone_address_new([address cStringUsingEncoding:[NSString defaultCStringEncoding]]); address = [NSString stringWithUTF8String:linphone_address_get_username(linphoneAddress)]; linphone_address_destroy(linphoneAddress); + } else { + address = @(linphone_address_get_username(remoteAddress)); } } if (address == nil) { @@ -928,7 +932,11 @@ static void linphone_iphone_registration_state(LinphoneCore *lc, LinphoneProxyCo if ([[UIDevice currentDevice].systemVersion floatValue] >= 8) { notif.category = @"incoming_msg"; } - notif.alertBody = [NSString stringWithFormat:NSLocalizedString(@"IM_MSG", nil), address]; + if ( [[LinphoneManager instance] lpConfigBoolForKey:@"show_msg_in_notif"] ){ + notif.alertBody = [NSString stringWithFormat:NSLocalizedString(@"IM_FULLMSG", nil), address, @(chat)]; + } else { + notif.alertBody = [NSString stringWithFormat:NSLocalizedString(@"IM_MSG", nil), address]; + } notif.alertAction = NSLocalizedString(@"Show", nil); notif.soundName = @"msg.caf"; notif.userInfo = @{ @"from" : address, @"from_addr" : remote_uri, @"call-id" : callID }; diff --git a/Resources/ar.lproj/Localizable.strings b/Resources/ar.lproj/Localizable.strings index 315cda811c0e35cea4d55498f6be3dcb85cf5369..7e78a66541921dcb7e4bb981472a28beaa56c174 100644 GIT binary patch delta 60 zcmezIk#W^0#tmJDYDx^A489EU3~mge3_d{U%Mi@q&Y;Agz+el+N(`zD4h&WdlQ#&& NO)_WM{J>Dc9RS+_4od(4 delta 14 WcmZ4WiSfrr#tmJDoA(&zxdQ+^Tn9)1 diff --git a/Resources/en.lproj/Localizable.strings b/Resources/en.lproj/Localizable.strings index c9e1b2b283a2fdddbd65797ef8548df7fd0583ed..3f3682ccc680d39b87ba7169b77ba8027094d68d 100644 GIT binary patch delta 56 zcmX^0o$=3i#tj8Vs!9x=489EU3~mge3_d{U%Mi@q&Y;Agz+el+N(`zD4h&Y4-y0-u JK4Qe?2>`FR4axuj delta 18 acmezKo$=In#tj8Vlm8fmZ2o4%<_Q2}KM6(v diff --git a/Resources/fr.lproj/Localizable.strings b/Resources/fr.lproj/Localizable.strings index 80a3c5ce68351ab7d2acfc33eb383bf93f588804..31d53a8ca3c2a77df029c74b3a3d66bd61307d8f 100644 GIT binary patch delta 62 zcmZo^V%pZkw1LG`TZzGw!IvSP!Hpr5!3PL^8G;$y8I%|l7;J%9i9waYfx!yM0@9No Mn#FF8GF{~j0D~e7s{jB1 delta 18 Zcmdni#MIKnw1LHRa)m|M<{r~k-T*^%2QB~r diff --git a/Resources/ru.lproj/Localizable.strings b/Resources/ru.lproj/Localizable.strings index 36ef11b63a4fe714a3a80f7c173851b9fd2484ec..22272ae24ea4fa4afd248b34cfedb5c225802058 100644 GIT binary patch delta 56 zcmdn>oAJ$W#tn~*Rh1Y#8GISy8Qd5`8GL}ymm!$Jok58~fx#Atl^9eR92l%7CmJPg JHZy7Q1OU4I4T}H( delta 18 acmaF!n{n4~#tn~*C+8W3Y|b!g@dN;20|^HJ diff --git a/Settings/InAppSettings.bundle/Advanced.plist b/Settings/InAppSettings.bundle/Advanced.plist index ca86b640e..ab7621b1f 100644 --- a/Settings/InAppSettings.bundle/Advanced.plist +++ b/Settings/InAppSettings.bundle/Advanced.plist @@ -36,6 +36,32 @@ Type IASKButtonSpecifier + + Title + Notifications + Type + PSGroupSpecifier + + + DefaultValue + + Key + show_msg_in_notif + Title + Show message in notification + Type + PSToggleSwitchSpecifier + + + DefaultValue + + Key + autoanswer_notif_preference + Title + Auto-answer after notification + Type + PSToggleSwitchSpecifier + Title Other @@ -52,16 +78,6 @@ Type PSToggleSwitchSpecifier - - DefaultValue - - Key - backgroundmode_preference - Title - Background mode - Type - PSToggleSwitchSpecifier - DefaultValue @@ -72,16 +88,6 @@ Type PSToggleSwitchSpecifier - - DefaultValue - - Key - autoanswer_notif_preference - Title - Auto-answer after notification - Type - PSToggleSwitchSpecifier - DefaultValue diff --git a/Settings/InAppSettings.bundle/en.lproj/Advanced.strings b/Settings/InAppSettings.bundle/en.lproj/Advanced.strings index b43a5407d..d056b28b9 100644 --- a/Settings/InAppSettings.bundle/en.lproj/Advanced.strings +++ b/Settings/InAppSettings.bundle/en.lproj/Advanced.strings @@ -2,11 +2,12 @@ "Debug" = "Debug"; "Send Logs" = "Send Logs"; "Clear Logs" = "Clear Logs"; +"Notifications" = "Notifications"; +"Show message in notification" = "Show message in notification"; +"Auto-answer after notification" = "Auto-answer after notification"; "Other" = "Other"; "Animations" = "Animations"; -"Background mode" = "Background mode"; "Start at boot" = "Start at boot"; -"Auto-answer after notification" = "Auto-answer after notification"; "First login view" = "First login view"; "Expire" = "Expire"; "Primary account" = "Primary account"; diff --git a/Tools/i18n_generate_strings_files.sh b/Tools/i18n_generate_strings_files.sh index 6c18305cb..931cb4831 100755 --- a/Tools/i18n_generate_strings_files.sh +++ b/Tools/i18n_generate_strings_files.sh @@ -41,12 +41,14 @@ function generate_localizable_from_sources { iconv -f utf-16 -t utf-8 $localizable_en > $localizable_en.tmp IC_MSG_EN=$(sed -nE 's/"IC_MSG" = "(.*)";/\1/p' $localizable_en.tmp) IM_MSG_EN=$(sed -nE 's/"IM_MSG" = "(.*)";/\1/p' $localizable_en.tmp) + IM_FULLMSG_EN=$(sed -nE 's/"IM_FULLMSG_EN" = "(.*)";/\1/p' $localizable_en.tmp) rm -f $localizable_en $localizable_en.tmp find $root_directory/Classes -name '*.m' | xargs genstrings -u -a -o $(dirname $localizable_en) iconv -f utf-16LE -t utf-8 $localizable_en > $localizable_en.tmp sed -i.bak "s/= \"IC_MSG\";/= \"$IC_MSG_EN\";/" $localizable_en.tmp sed -i.bak "s/= \"IM_MSG\";/= \"$IM_MSG_EN\";/" $localizable_en.tmp + sed -i.bak "s/= \"IM_FULLMSG_EN\";/= \"$IM_FULLMSG_EN\";/" $localizable_en.tmp iconv -f utf-8 -t utf-16LE $localizable_en.tmp > $localizable_en rm $localizable_en.tmp.bak $localizable_en.tmp }