From 92209665bea9b5c737b2004eefe0a7236dd1dbb4 Mon Sep 17 00:00:00 2001 From: hyunho Date: Thu, 29 Mar 2018 16:06:00 +0900 Subject: [PATCH] Remove auto selection for design elements Change-Id: I56c35a8f5f45c69eaccce55228bb1ec5f5d9cb15 Signed-off-by: hyunho --- unittest/src/test_complication.cc | 3 +- unittest/src/test_editor.cc | 4 +-- .../design-element-implementation.h | 3 -- watchface-complication/design-element.cc | 34 +++------------------- .../include/watchface-editable.h | 2 +- watchface-complication/watchface-editable.cc | 5 ++-- 6 files changed, 11 insertions(+), 40 deletions(-) diff --git a/unittest/src/test_complication.cc b/unittest/src/test_complication.cc index b1ed4b4..ca048f5 100644 --- a/unittest/src/test_complication.cc +++ b/unittest/src/test_complication.cc @@ -70,7 +70,8 @@ TEST_F(WC, Create) TEST_F(WC, GetEditableId) { - EXPECT_EQ(WC::complication->GetEditableId(), 0); + EXPECT_EQ(WC::complication->SetEditableId(1), 0); + EXPECT_EQ(WC::complication->GetEditableId(), 1); } TEST_F(WC, GetGeo) diff --git a/unittest/src/test_editor.cc b/unittest/src/test_editor.cc index ebde610..91cc48d 100644 --- a/unittest/src/test_editor.cc +++ b/unittest/src/test_editor.cc @@ -71,7 +71,7 @@ TEST_F(WE, EditPreview) ReceivedEditable* re = new ReceivedEditable(std::string(reinterpret_cast(raw_data))); IEditable* ed = static_cast(re); - EXPECT_EQ(WE::editor->EditPreview(*ed, cur_data_idx), -1); + EXPECT_EQ(WE::editor->EditPreview(*ed, cur_data_idx), COMPLICATION_ERROR_EDIT_NOT_READY); delete re; } @@ -131,7 +131,7 @@ int _editable_list_foreach_cb(const editable_h handle, void *user_data) { TEST_F(WEL, EditPreview) { IEditable* ed = static_cast(WEL::received); - EXPECT_EQ(editor_edit_preview(ed, 0), -1); + EXPECT_EQ(editor_edit_preview(ed, 0), COMPLICATION_ERROR_EDIT_NOT_READY); } TEST_F(WEL, EditReady) diff --git a/watchface-complication/design-element-implementation.h b/watchface-complication/design-element-implementation.h index 84df8df..0043873 100755 --- a/watchface-complication/design-element-implementation.h +++ b/watchface-complication/design-element-implementation.h @@ -41,13 +41,10 @@ class DesignElement::Impl { Impl(Impl && other) = default; Impl& operator=(Impl const& other) = default; Impl& operator=(Impl && other) = default; - void RestoreStateOrSetDefault(); - private: DesignElement* parent_; int id_ = -1; - int default_data_idx_; int cur_data_idx_; int last_data_idx_; std::list> candidates_list_; diff --git a/watchface-complication/design-element.cc b/watchface-complication/design-element.cc index 7460868..565c62d 100755 --- a/watchface-complication/design-element.cc +++ b/watchface-complication/design-element.cc @@ -31,49 +31,23 @@ namespace watchface_complication { -DesignElement::DesignElement(int id, int default_data_idx, +DesignElement::DesignElement(int id, int cur_data_idx, std::list> candidates_list, std::shared_ptr geo) - : impl_(new Impl(this, id, default_data_idx, std::move(candidates_list), geo)) { + : impl_(new Impl(this, id, cur_data_idx, std::move(candidates_list), geo)) { } DesignElement::~DesignElement() { LOGE("design element destroy %d", impl_->id_); } DesignElement::Impl::Impl(DesignElement* parent, int id, - int default_data_idx, + int cur_data_idx, std::list> candidates_list, std::shared_ptr geo) - : parent_(parent), id_(id), default_data_idx_(default_data_idx), + : parent_(parent), id_(id), cur_data_idx_(cur_data_idx), candidates_list_(std::move(candidates_list)), geo_(geo) { - RestoreStateOrSetDefault(); -} - -void DesignElement::Impl::RestoreStateOrSetDefault() { - std::unique_ptr setting_data = - EditablesManager::GetInst().LoadSetting(id_); - - cur_data_idx_ = default_data_idx_; - last_data_idx_ = cur_data_idx_; - if (setting_data == nullptr) { - LOGI("no setting data"); - return; - } - - int idx = 0; - for (auto& i : candidates_list_) { - Bundle& data = *(i.get()); - if (strcmp(data.ToString(), (setting_data.get())->ToString()) == 0) { - LOGI("restore default value idx : %d", idx); - cur_data_idx_ = idx; - break; - } - idx++; - } - last_data_idx_ = cur_data_idx_; - LOGI("cur data idx : %d", cur_data_idx_); } int DesignElement::GetEditableId() { diff --git a/watchface-complication/include/watchface-editable.h b/watchface-complication/include/watchface-editable.h index 1e6d220..757663a 100755 --- a/watchface-complication/include/watchface-editable.h +++ b/watchface-complication/include/watchface-editable.h @@ -59,7 +59,7 @@ typedef int (*on_edit_ready)(editable_container_h handle, const char *editor_appid, void *user_data); int editable_add_design_element(editable_container_h handle, int editable_id, - int default_data_idx, GList *candiates_list, + int cur_data_idx, GList *candiates_list, editable_geo geo, const char *editable_name); int editable_get_editable_name(const editable_h handle, const char **editable_name); diff --git a/watchface-complication/watchface-editable.cc b/watchface-complication/watchface-editable.cc index c70664f..c6fb954 100755 --- a/watchface-complication/watchface-editable.cc +++ b/watchface-complication/watchface-editable.cc @@ -130,7 +130,7 @@ class EditablesContainerStub : public EditablesContainer { static EditablesContainerStub *__container; extern "C" EXPORT_API int editable_add_design_element(editable_container_h handle, - int edit_id, int default_data_idx, GList* candiatelist, editable_geo geo, + int edit_id, int cur_data_idx, GList* candiatelist, editable_geo geo, const char* editable_name) { if (handle == NULL || candiatelist == NULL || editable_name == NULL) return COMPLICATION_ERROR_INVALID_PARAMETER; @@ -155,8 +155,7 @@ extern "C" EXPORT_API int editable_add_design_element(editable_container_h handl LOGE("ID already exist"); return COMPLICATION_ERROR_EXIST_ID; } - auto de = std::shared_ptr(new DesignElement(edit_id, - default_data_idx, + auto de = std::shared_ptr(new DesignElement(edit_id, cur_data_idx, std::move(new_list), std::shared_ptr( new IEditable::Geometry(0, 0, 100, 100)))); -- 2.7.4