--- /dev/null
+/*
+ * 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 */
--- /dev/null
+/*
+ * 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);
+}
+++ /dev/null
-/*
- * 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 */
+++ /dev/null
-/*
- * 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);
-}
--- /dev/null
+/*
+ * 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 */
#include "Ui/GenlistCheckItem.h"
+#define PART_LOG_TIME "elm.text.sub.end"
+
namespace Logs
{
namespace Model
*/
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;
#include "Ui/View.h"
#include "Logs/Model/LogProvider.h"
+#include <system_settings.h>
namespace Ui
{
*/
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);
*/
LogGroup *getLogGroup() const;
+ /**
+ * @brief Update record
+ */
+ void update();
+
/**
* @return Remove log from database
*/
*/
const LogGroupList &getLogGroupList();
+ /**
+ * @brief Reset log group list
+ */
+ void resetLogGroups();
+
/**
* @brief Set new log callback
* @param[in] callback New Log callback
--- /dev/null
+/*
+ * 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;
+}
#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"
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();
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);
}
#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;
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)
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();
+ }
});
}
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);
}
m_Group->removeLog(this);
}
contacts_record_destroy(m_LogRecord, true);
- if (m_ContactRecord != nullptr) {
+ if (m_ContactRecord) {
contacts_record_destroy(m_ContactRecord, true);
}
}
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;
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;
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
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());
return m_Groups;
}
+void LogProvider::resetLogGroups()
+{
+ m_Groups.clear();
+ fillGroupList(m_Logs, m_Groups);
+}
+
void LogProvider::setInsertCallback(InsertCallback callback)
{
m_InsertCallback = std::move(callback);
void LogProvider::onLogChanged(const char *viewUri)
{
LogList newLogList;
-
fillList(newLogList);
LogIterator newIt = newLogList.begin();
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*/
}