From 4cee86ff4056efb0b2fe843d2ab782e465cd7fa6 Mon Sep 17 00:00:00 2001 From: "polu.sandeep" Date: Tue, 12 Jan 2016 14:31:17 +0900 Subject: [PATCH] Fixed UI and unread message count issues. Change-Id: Ic8b685c1cef9a35b9ab707797f8e4e4d038398a6 --- TelegramTizen/src/telegramtizen.c | 5 +++++ TelegramTizen/src/tg_db_wrapper.c | 27 ++++++++++++++------------- TelegramTizen/src/tg_messaging_view.c | 13 +++++++++---- tg-engine-service/src/tg_db_wrapper.c | 25 ++++++++++++++++++++++--- 4 files changed, 50 insertions(+), 20 deletions(-) diff --git a/TelegramTizen/src/telegramtizen.c b/TelegramTizen/src/telegramtizen.c index 335feb2..7302af9 100644 --- a/TelegramTizen/src/telegramtizen.c +++ b/TelegramTizen/src/telegramtizen.c @@ -3904,6 +3904,11 @@ app_pause(void *data) appdata_s *app_data = data; if (app_data) { app_data->s_app_visible_state = APP_STATE_IN_BACKGROUND; + int unread_msg_cnt = get_number_of_unread_messages(); + int err = badge_set_count(TELEGRAM_APP_ID, unread_msg_cnt); + if (BADGE_ERROR_NONE != err) { + + } } } diff --git a/TelegramTizen/src/tg_db_wrapper.c b/TelegramTizen/src/tg_db_wrapper.c index 4514234..27827b3 100644 --- a/TelegramTizen/src/tg_db_wrapper.c +++ b/TelegramTizen/src/tg_db_wrapper.c @@ -1624,31 +1624,32 @@ int get_unread_message_count(char* table_name) char unread_str[50]; sprintf(unread_str, "%d", 1); - char out_str[50]; - sprintf(out_str, "%d", 0); -#if 0 - char service_str[50]; - sprintf(service_str, "%d", 1); - where_clause = (char*)malloc(strlen(MESSAGE_INFO_TABLE_UNREAD) + strlen(" = ") + strlen(unread_str) + strlen(" AND ") + strlen(MESSAGE_INFO_TABLE_OUT_MSG) + strlen(" = ") + strlen(out_str) + strlen(" OR ") + strlen(MESSAGE_INFO_TABLE_SERVICE) + strlen(" = ") + strlen(service_str) + 1); + where_clause = (char*)malloc(strlen(MESSAGE_INFO_TABLE_UNREAD) + strlen(" = ") + strlen(unread_str) + strlen(" AND ") + strlen(MESSAGE_INFO_TABLE_OUT_MSG) + strlen(" = ") + strlen(unread_str) + strlen(" AND ") + strlen(MESSAGE_INFO_TABLE_SERVICE) + strlen(" = ") + strlen(unread_str) + 1); strcpy(where_clause, MESSAGE_INFO_TABLE_UNREAD); strcat(where_clause, " = "); strcat(where_clause, unread_str); strcat(where_clause, " AND "); strcat(where_clause, MESSAGE_INFO_TABLE_OUT_MSG); - strcat(where_clause, " = "); - strcat(where_clause, out_str); - strcat(where_clause, " OR "); + strcat(where_clause, " != "); + strcat(where_clause, unread_str); + strcat(where_clause, " AND "); strcat(where_clause, MESSAGE_INFO_TABLE_SERVICE); - strcat(where_clause, " = "); - strcat(where_clause, service_str); -#endif + strcat(where_clause, " < "); + strcat(where_clause, unread_str); + - where_clause = (char*)malloc(strlen(MESSAGE_INFO_TABLE_UNREAD) + strlen(" = ") + strlen(unread_str) + 1); +#if 0 + where_clause = (char*)malloc(strlen(MESSAGE_INFO_TABLE_UNREAD) + strlen(" = ") + strlen(unread_str) + strlen(" AND ") + strlen(MESSAGE_INFO_TABLE_OUT_MSG) + strlen(" != ") + strlen(unread_str) + 1); strcpy(where_clause, MESSAGE_INFO_TABLE_UNREAD); strcat(where_clause, " = "); strcat(where_clause, unread_str); + strcat(where_clause, " AND "); + strcat(where_clause, MESSAGE_INFO_TABLE_OUT_MSG); + strcat(where_clause, " != "); + strcat(where_clause, unread_str); +#endif num_of_rows = get_number_of_rows(table_name, where_clause); free(where_clause); diff --git a/TelegramTizen/src/tg_messaging_view.c b/TelegramTizen/src/tg_messaging_view.c index 08de9e1..190a02b 100644 --- a/TelegramTizen/src/tg_messaging_view.c +++ b/TelegramTizen/src/tg_messaging_view.c @@ -1421,10 +1421,12 @@ static void _create_image_item(tg_message_s *msg, Evas_Object *entry, char *imag if (img_path && strstr(img_path, ".webp") != NULL) { img_item = get_image_from_path(img_path, entry); } else { - if (msg->media_type == tgl_message_media_document) { - img_item = get_gif_image_from_path(img_path, entry, key); - } else { - img_item = get_image_from_path(img_path, entry); + if (img_path) { + if (msg->media_type == tgl_message_media_document) { + img_item = get_gif_image_from_path(img_path, entry, key); + } else { + img_item = get_image_from_path(img_path, entry); + } } } @@ -3377,6 +3379,9 @@ static void on_media_attach_clicked(void *data, Evas_Object *obj, const char *em ret = attach_panel_create(ad->conform, &attach_panel); + if (!attach_panel) { + return; + } attach_panel_add_content_category(attach_panel, ATTACH_PANEL_CONTENT_CATEGORY_IMAGE, NULL); attach_panel_add_content_category(attach_panel, ATTACH_PANEL_CONTENT_CATEGORY_CAMERA, NULL); attach_panel_add_content_category(attach_panel, ATTACH_PANEL_CONTENT_CATEGORY_VOICE, NULL); diff --git a/tg-engine-service/src/tg_db_wrapper.c b/tg-engine-service/src/tg_db_wrapper.c index 7068507..6049f71 100644 --- a/tg-engine-service/src/tg_db_wrapper.c +++ b/tg-engine-service/src/tg_db_wrapper.c @@ -5144,13 +5144,32 @@ int get_unread_message_count(char* table_name) char unread_str[50]; sprintf(unread_str, "%d", 1); - char out_str[50]; - sprintf(out_str, "%d", 0); - where_clause = (char*)malloc(strlen(MESSAGE_INFO_TABLE_UNREAD) + strlen(" = ") + strlen(unread_str) + 1); + + where_clause = (char*)malloc(strlen(MESSAGE_INFO_TABLE_UNREAD) + strlen(" = ") + strlen(unread_str) + strlen(" AND ") + strlen(MESSAGE_INFO_TABLE_OUT_MSG) + strlen(" = ") + strlen(unread_str) + strlen(" AND ") + strlen(MESSAGE_INFO_TABLE_SERVICE) + strlen(" = ") + strlen(unread_str) + 1); strcpy(where_clause, MESSAGE_INFO_TABLE_UNREAD); strcat(where_clause, " = "); strcat(where_clause, unread_str); + strcat(where_clause, " AND "); + strcat(where_clause, MESSAGE_INFO_TABLE_OUT_MSG); + strcat(where_clause, " != "); + strcat(where_clause, unread_str); + strcat(where_clause, " AND "); + strcat(where_clause, MESSAGE_INFO_TABLE_SERVICE); + strcat(where_clause, " < "); + strcat(where_clause, unread_str); + + +#if 0 + where_clause = (char*)malloc(strlen(MESSAGE_INFO_TABLE_UNREAD) + strlen(" = ") + strlen(unread_str) + strlen(" AND ") + strlen(MESSAGE_INFO_TABLE_OUT_MSG) + strlen(" != ") + strlen(unread_str) + 1); + strcpy(where_clause, MESSAGE_INFO_TABLE_UNREAD); + strcat(where_clause, " = "); + strcat(where_clause, unread_str); + strcat(where_clause, " AND "); + strcat(where_clause, MESSAGE_INFO_TABLE_OUT_MSG); + strcat(where_clause, " != "); + strcat(where_clause, unread_str); +#endif num_of_rows = get_number_of_rows(table_name, where_clause); free(where_clause); -- 2.7.4