TizenRefApp-5796 Time should be shown as hour and minute in local time setting 87/60287/7
authorIryna Ferenchak <i.ferenchak@samsung.com>
Tue, 1 Mar 2016 09:10:19 +0000 (11:10 +0200)
committerIryna Ferenchak <i.ferenchak@samsung.com>
Tue, 1 Mar 2016 09:10:19 +0000 (11:10 +0200)
Change-Id: I47d6cfa40ea616dba8f876e02396403cec606c6c
Signed-off-by: Iryna Ferenchak <i.ferenchak@samsung.com>
14 files changed:
lib-apps-common/inc/Ui/RadioPopup.h [new file with mode: 0644]
lib-apps-common/src/Ui/RadioPopup.cpp [new file with mode: 0644]
lib-common/inc/Ui/RadioPopup.h [deleted file]
lib-common/src/Ui/RadioPopup.cpp [deleted file]
lib-logs/inc/Logs/Common/Utils.h [new file with mode: 0644]
lib-logs/inc/Logs/List/LogItem.h
lib-logs/inc/Logs/List/LogsView.h
lib-logs/inc/Logs/Model/Log.h
lib-logs/inc/Logs/Model/LogProvider.h
lib-logs/src/Logs/Common/Utils.cpp [new file with mode: 0644]
lib-logs/src/Logs/List/LogItem.cpp
lib-logs/src/Logs/List/LogsView.cpp
lib-logs/src/Logs/Model/Log.cpp
lib-logs/src/Logs/Model/LogProvider.cpp

diff --git a/lib-apps-common/inc/Ui/RadioPopup.h b/lib-apps-common/inc/Ui/RadioPopup.h
new file mode 100644 (file)
index 0000000..90bb0dc
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef UI_RADIO_POPUP_H
+#define UI_RADIO_POPUP_H
+
+#include "Ui/ListPopup.h"
+#include <string>
+
+namespace Ui
+{
+       /**
+        * @brief Radio popup
+        */
+       class EXPORT_API RadioPopup : public ListPopup
+       {
+       public:
+               RadioPopup();
+
+               /**
+                * @brief Set selected item
+                * @param[in]   value     Selected item value
+                */
+               void setSelectedItem(int value);
+
+       private:
+               virtual Evas_Object *onCreate(Evas_Object *parent) override;
+               virtual Evas_Object *getItemContent(void *data, const char *part) override;
+               virtual void onItemSelected(void *data) override;
+
+               Evas_Object *m_RadioGroup;
+       };
+}
+#endif /* UI_RADIO_POPUP_H */
diff --git a/lib-apps-common/src/Ui/RadioPopup.cpp b/lib-apps-common/src/Ui/RadioPopup.cpp
new file mode 100644 (file)
index 0000000..72b06dc
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "Ui/RadioPopup.h"
+
+using namespace Ui;
+
+RadioPopup::RadioPopup()
+       : m_RadioGroup(nullptr)
+{
+}
+
+void RadioPopup::setSelectedItem(int value)
+{
+       elm_radio_value_set(m_RadioGroup, value);
+}
+
+Evas_Object *RadioPopup::onCreate(Evas_Object *parent)
+{
+       Evas_Object *popup = ListPopup::onCreate(parent);
+
+       m_RadioGroup = elm_radio_add(popup);
+       elm_radio_state_value_set(m_RadioGroup, -1);
+
+       return popup;
+}
+
+Evas_Object *RadioPopup::getItemContent(void *data, const char *part)
+{
+       if (strcmp(part, "elm.swallow.end") == 0) {
+               Evas_Object *radio = elm_radio_add(getEvasObject());
+               elm_radio_group_add(radio, m_RadioGroup);
+               elm_radio_state_value_set(radio, (long) data);
+               return radio;
+       }
+
+       return nullptr;
+}
+
+void RadioPopup::onItemSelected(void *data)
+{
+       setSelectedItem((long) data);
+}
diff --git a/lib-common/inc/Ui/RadioPopup.h b/lib-common/inc/Ui/RadioPopup.h
deleted file mode 100644 (file)
index 90bb0dc..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#ifndef UI_RADIO_POPUP_H
-#define UI_RADIO_POPUP_H
-
-#include "Ui/ListPopup.h"
-#include <string>
-
-namespace Ui
-{
-       /**
-        * @brief Radio popup
-        */
-       class EXPORT_API RadioPopup : public ListPopup
-       {
-       public:
-               RadioPopup();
-
-               /**
-                * @brief Set selected item
-                * @param[in]   value     Selected item value
-                */
-               void setSelectedItem(int value);
-
-       private:
-               virtual Evas_Object *onCreate(Evas_Object *parent) override;
-               virtual Evas_Object *getItemContent(void *data, const char *part) override;
-               virtual void onItemSelected(void *data) override;
-
-               Evas_Object *m_RadioGroup;
-       };
-}
-#endif /* UI_RADIO_POPUP_H */
diff --git a/lib-common/src/Ui/RadioPopup.cpp b/lib-common/src/Ui/RadioPopup.cpp
deleted file mode 100644 (file)
index 72b06dc..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include "Ui/RadioPopup.h"
-
-using namespace Ui;
-
-RadioPopup::RadioPopup()
-       : m_RadioGroup(nullptr)
-{
-}
-
-void RadioPopup::setSelectedItem(int value)
-{
-       elm_radio_value_set(m_RadioGroup, value);
-}
-
-Evas_Object *RadioPopup::onCreate(Evas_Object *parent)
-{
-       Evas_Object *popup = ListPopup::onCreate(parent);
-
-       m_RadioGroup = elm_radio_add(popup);
-       elm_radio_state_value_set(m_RadioGroup, -1);
-
-       return popup;
-}
-
-Evas_Object *RadioPopup::getItemContent(void *data, const char *part)
-{
-       if (strcmp(part, "elm.swallow.end") == 0) {
-               Evas_Object *radio = elm_radio_add(getEvasObject());
-               elm_radio_group_add(radio, m_RadioGroup);
-               elm_radio_state_value_set(radio, (long) data);
-               return radio;
-       }
-
-       return nullptr;
-}
-
-void RadioPopup::onItemSelected(void *data)
-{
-       setSelectedItem((long) data);
-}
diff --git a/lib-logs/inc/Logs/Common/Utils.h b/lib-logs/inc/Logs/Common/Utils.h
new file mode 100644 (file)
index 0000000..1bd08c8
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef LOGS_COMMON_UTILS_H
+#define LOGS_COMMON_UTILS_H
+
+#include <time.h>
+#include <string>
+
+namespace Logs
+{
+       namespace Common
+       {
+               /**
+                * @brief Convert tm to string
+                * @param[in]   time   Time to convert
+                * @return string.
+                */
+               std::string formatTime(const tm &time);
+       }
+}
+
+#endif /* LOGS_COMMON_UTILS_H */
index d8d28b68e06b874177c57c25dfe0bffb3a01f6f0..7d404ffc99b0e2c697e1ccbe11e27f87923ee4e6 100644 (file)
@@ -20,6 +20,8 @@
 
 #include "Ui/GenlistCheckItem.h"
 
+#define PART_LOG_TIME           "elm.text.sub.end"
+
 namespace Logs
 {
        namespace Model
@@ -80,11 +82,6 @@ namespace Logs
                         */
                        Model::LogGroup *getGroup() const;
 
-                       /**
-                        * @brief Remove group
-                        */
-                       void removeGroup();
-
                private:
                        virtual char *getText(Evas_Object *parent, const char *part) override;
                        virtual Evas_Object *getContent(Evas_Object *parent, const char *part) override;
index 9e3a8302a5562b1ac2f78e57f647e3030708ec23..5fe07b9ed9d6191c23fe87601446934f49af50e4 100644 (file)
@@ -20,6 +20,7 @@
 
 #include "Ui/View.h"
 #include "Logs/Model/LogProvider.h"
+#include <system_settings.h>
 
 namespace Ui
 {
@@ -56,11 +57,14 @@ namespace Logs
                         */
                        LogsView(FilterType filterType = FilterAll);
 
+                       virtual ~LogsView() override;
+
                private:
                        virtual Evas_Object *onCreate(Evas_Object *parent) override;
                        virtual void onPageAttached() override;
                        virtual void onMenuPressed() override;
 
+                       void onSettingsChanged(system_settings_key_e key);
                        void onSelectViewBy();
                        void fillGenlist();
                        bool shouldDisplayLogs(const Model::LogGroup &group);
index a53644aea73b5e5bfda67ab0f2c0c726f97a914b..477738fc58ffb4a8dceec37ff873156ab7bf23ed 100644 (file)
@@ -87,6 +87,11 @@ namespace Logs
                         */
                        LogGroup *getLogGroup() const;
 
+                       /**
+                        * @brief Update record
+                        */
+                       void update();
+
                        /**
                         * @return Remove log from database
                         */
index 4b4dec9036f2a3f4afb7a0e83179e25c7e17ae9a..100e788c827fe7c6322ad2b928a3ab71efdf77b4 100644 (file)
@@ -83,6 +83,11 @@ namespace Logs
                         */
                        const LogGroupList &getLogGroupList();
 
+                       /**
+                        * @brief Reset log group list
+                        */
+                       void resetLogGroups();
+
                        /**
                         * @brief Set new log callback
                         * @param[in]    callback    New Log callback
diff --git a/lib-logs/src/Logs/Common/Utils.cpp b/lib-logs/src/Logs/Common/Utils.cpp
new file mode 100644 (file)
index 0000000..1dc933b
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "Logs/Common/Utils.h"
+#include <system_settings.h>
+
+using namespace Logs;
+
+#define BUFFER_SIZE 32
+
+std::string Common::formatTime(const tm &time)
+{
+       char buffer[BUFFER_SIZE];
+       bool is24Hours = false;
+
+       system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, &is24Hours);
+       strftime(buffer, sizeof(buffer), is24Hours ? "%R" : "%I:%M %p", &time);
+
+       return buffer;
+}
index a5c5c1dd3322f2299870df4ca1ca0c72099d880c..98051bd59d8009f1c0c0d2efb6ba82222af827c1 100644 (file)
@@ -20,6 +20,7 @@
 #include "Logs/Model/LogGroup.h"
 #include "Logs/Details/DetailsView.h"
 #include "Utils/Callback.h"
+#include "Logs/Common/Utils.h"
 
 #include "App/Path.h"
 #include "Ui/Scale.h"
 
 #define BUFFER_SIZE             32
 #define LOG_TYPE_SIZE           50
+#define LOG_TIME_TEXT_SIZE      22
 
 #define PART_LOG_NAME           "elm.text"
 #define PART_LOG_NUMBER         "elm.text.sub"
 #define PART_LOG_COUNT          "elm.text.end"
-#define PART_LOG_TYPE           "elm.text.sub.end"
 
 #define PART_PERSON_THUMBNAIL   "elm.swallow.icon"
 #define PART_END                "elm.swallow.end"
@@ -87,11 +88,6 @@ LogGroup *LogItem::getGroup() const
        return m_Group;
 }
 
-void LogItem::removeGroup()
-{
-       m_Group->remove();
-}
-
 char *LogItem::getText(Evas_Object *parent, const char *part)
 {
        const Log *log = m_Group->getLogList().back();
@@ -112,10 +108,9 @@ char *LogItem::getText(Evas_Object *parent, const char *part)
                char buffer[BUFFER_SIZE];
                snprintf(buffer, sizeof(buffer), "(%zu)", m_Group->getLogList().size());
                return strdup(buffer);
-       } else if (strcmp(part, PART_LOG_TYPE) == 0) {
-               tm date = log->getTime();
+       } else if (strcmp(part, PART_LOG_TIME) == 0) {
                char buffer[BUFFER_SIZE];
-               strftime(buffer, sizeof(buffer), "%X", &date);
+               snprintf(buffer, sizeof(buffer), "<font_size=%d>%s</font_size>", LOG_TIME_TEXT_SIZE, Logs::Common::formatTime(log->getTime()).c_str());
                return strdup(buffer);
        }
 
index 3d2f699bc81e8e052593ca051b73d3c9baab7597..f4eac72449db6ce5094eb7148797e6d2d97bcd44 100644 (file)
@@ -25,6 +25,9 @@
 #include "Ui/Navigator.h"
 #include "Ui/RadioPopup.h"
 
+#include "Utils/Logger.h"
+#include "Utils/Callback.h"
+
 using namespace Logs::Model;
 using namespace Logs::List;
 using namespace Logs::Details;
@@ -36,6 +39,28 @@ LogsView::LogsView(FilterType filterType)
          m_Mode(ItemMode::Default),
          m_FilterType(filterType)
 {
+       system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, makeCallbackWithLastParam(&LogsView::onSettingsChanged), this);
+       system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY, makeCallbackWithLastParam(&LogsView::onSettingsChanged), this);
+       system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_TIME_CHANGED, makeCallbackWithLastParam(&LogsView::onSettingsChanged), this);
+}
+
+LogsView::~LogsView()
+{
+       system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR);
+       system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY);
+       system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_TIME_CHANGED);
+}
+
+void LogsView::onSettingsChanged(system_settings_key_e key)
+{
+       if (key == SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY ||
+                       key == SYSTEM_SETTINGS_KEY_TIME_CHANGED) {
+               elm_genlist_clear(m_Genlist->getEvasObject());
+               m_LogProvider.resetLogGroups();
+               fillGenlist();
+       } else {
+               m_Genlist->update(PART_LOG_TIME, ELM_GENLIST_ITEM_FIELD_TEXT);
+       }
 }
 
 Evas_Object *LogsView::onCreate(Evas_Object *parent)
@@ -81,13 +106,15 @@ void LogsView::onSelectViewBy()
        Ui::RadioPopup *popup = new Ui::RadioPopup();
        popup->create(getEvasObject());
        popup->setTitle("IDS_CLOG_OPT_VIEW_BY");
-       popup->setSelectedItem(m_FilterType);
        popup->addItem("IDS_LOGS_BODY_ALL_CALLS", (void *) FilterAll);
        popup->addItem("IDS_LOGS_OPT_MISSED_CALLS", (void *) FilterMissed);
+       popup->setSelectedItem(m_FilterType);
        popup->setSelectedCallback([this](void *data) {
-               elm_genlist_clear(m_Genlist->getEvasObject());
-               m_FilterType = (FilterType)(long)data;
-               fillGenlist();
+               if (m_FilterType != (FilterType)(long)data) {
+                       elm_genlist_clear(m_Genlist->getEvasObject());
+                       m_FilterType = (FilterType)(long)data;
+                       fillGenlist();
+               }
        });
 }
 
@@ -100,12 +127,15 @@ void LogsView::fillGenlist()
        LogGroupItem *groupItem = nullptr;
 
        for (auto &&group : m_LogProvider.getLogGroupList()) {
-
                if (shouldDisplayLogs(*group)) {
                        groupItem = insertLogItem(group.get(), groupItem);
                }
        }
 
+       if (!elm_genlist_items_count(m_Genlist->getEvasObject())) {
+               return;
+       }
+
        groupItem = dynamic_cast<LogGroupItem *>(m_Genlist->getFirstItem());
        groupItem->scrollTo(ELM_GENLIST_ITEM_SCROLLTO_TOP);
 }
index 014130ad5df2b6c844da3861755dfcdc3f950727..3176eeb02cae24337969fe1628a070ceb7d38dc4 100644 (file)
@@ -32,7 +32,7 @@ Log::~Log()
                m_Group->removeLog(this);
        }
        contacts_record_destroy(m_LogRecord, true);
-       if (m_ContactRecord != nullptr) {
+       if (m_ContactRecord) {
                contacts_record_destroy(m_ContactRecord, true);
        }
 }
@@ -40,7 +40,7 @@ Log::~Log()
 const char *Log::getName() const
 {
        char *name = nullptr;
-       if (m_ContactRecord != nullptr) {
+       if (m_ContactRecord) {
                contacts_record_get_str_p(m_ContactRecord, _contacts_person.display_name, &name);
        }
        return name;
@@ -56,7 +56,7 @@ const char *Log::getNumber() const
 const char *Log::getImagePath() const
 {
        char *path = nullptr;
-       if (m_ContactRecord != nullptr) {
+       if (m_ContactRecord) {
                contacts_record_get_str_p(m_ContactRecord, _contacts_person.image_thumbnail_path, &path);
        }
        return path;
@@ -76,10 +76,7 @@ tm Log::getTime() const
        contacts_record_get_int(m_LogRecord, _contacts_phone_log.log_time, &time);
 
        time_t logTime = time;
-       struct tm logDate;
-
-       localtime_r(&logTime, &logDate);
-       return logDate;
+       return *localtime(&logTime);
 }
 
 int Log::getId() const
@@ -116,6 +113,13 @@ LogGroup *Log::getLogGroup() const
        return m_Group;
 }
 
+void Log::update()
+{
+       int id = getId();
+       contacts_record_destroy(m_LogRecord, true);
+       contacts_db_get_record(_contacts_phone_log._uri, id, &m_LogRecord);
+}
+
 void Log::remove()
 {
        contacts_db_delete_record(_contacts_phone_log._uri, getId());
index 43f365e4ebb54be80b060a3d93b0825ca42415c6..2af95e9a7db205c60055fcfd877900ae527c9d7f 100644 (file)
@@ -48,6 +48,12 @@ const LogProvider::LogGroupList &LogProvider::getLogGroupList()
        return m_Groups;
 }
 
+void LogProvider::resetLogGroups()
+{
+       m_Groups.clear();
+       fillGroupList(m_Logs, m_Groups);
+}
+
 void LogProvider::setInsertCallback(InsertCallback callback)
 {
        m_InsertCallback = std::move(callback);
@@ -148,7 +154,6 @@ contacts_list_h LogProvider::fetchLogList()
 void LogProvider::onLogChanged(const char *viewUri)
 {
        LogList newLogList;
-
        fillList(newLogList);
 
        LogIterator newIt = newLogList.begin();
@@ -267,14 +272,5 @@ void LogProvider::addNewLogs(LogIterator &newIt, LogList &newLogList)
 
 void LogProvider::onContactChanged(const char *viewUri)
 {
-       contacts_list_h changes = nullptr;
-       contacts_db_get_changes_by_version(_contacts_contact_updated_info._uri, 0, m_DbVersion, &changes, &m_DbVersion);
-
-       contacts_record_h record = nullptr;
-       CONTACTS_LIST_FOREACH(changes, record) {
-               /*
-                * TODO
-                */
-       }
-       contacts_list_destroy(changes, true);
+/* TODO*/
 }