summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPrachi Kumar <prachi.kumar@samsung.com>2019-10-22 02:00:18 +0530
committerAmritanshu Pandia <a.pandia1@samsung.com>2019-11-01 06:27:19 +0000
commit073846c8b7f71d36ed2b3d9a3f04b63edc5bd7de (patch)
tree6aae229325ccaf97d109f44b69b3e53ed4ecb043
parentbc143aec86023e0a47f42fb2f7dd8d4f55327c03 (diff)
downloadhomescreen-efl-073846c8b7f71d36ed2b3d9a3f04b63edc5bd7de.tar.gz
homescreen-efl-073846c8b7f71d36ed2b3d9a3f04b63edc5bd7de.tar.bz2
homescreen-efl-073846c8b7f71d36ed2b3d9a3f04b63edc5bd7de.zip
- Displays more than one widget on a single page if possible. - Update the position of default widgets in db. - Delete extra default widgets from the db. Change-Id: I5f7bf80eb1a567762915420f29c121866f679667
-rwxr-xr-xinc/cluster_data.h5
-rwxr-xr-xinc/cluster_db.h2
-rwxr-xr-xinc/cluster_view.h5
-rwxr-xr-xsrc/cluster_data.c47
-rwxr-xr-xsrc/cluster_db.c73
-rwxr-xr-xsrc/cluster_view.c41
6 files changed, 123 insertions, 50 deletions
diff --git a/inc/cluster_data.h b/inc/cluster_data.h
index e105f86..14142f8 100755
--- a/inc/cluster_data.h
+++ b/inc/cluster_data.h
@@ -39,6 +39,7 @@ typedef struct {
void cluster_data_init(void);
Eina_List *cluster_data_get_widget_list(void);
+Eina_List *cluster_data_get_extra_widget_list(void);
int cluster_data_get_page_count();
void cluster_data_set_page_count(int count);
@@ -48,4 +49,8 @@ void cluster_data_insert(widget_data_t *item);
void cluster_data_delete(widget_data_t *item);
void cluster_data_update(widget_data_t *item);
+void cluster_data_delete_extra_widget(widget_data_t *item);
+
+void update_init_default_widget_data_to_db(void);
+
#endif /* __CLUSTER_DATA_H__ */
diff --git a/inc/cluster_db.h b/inc/cluster_db.h
index 478db3d..3f6d2e1 100755
--- a/inc/cluster_db.h
+++ b/inc/cluster_db.h
@@ -29,6 +29,6 @@ bool cluster_db_delete(widget_data_t *item);
bool cluster_db_get_list(Eina_List **cluster_list);
bool move_external_cluster_db(void);
-int cluster_db_get_row_count(void);
+bool cluster_db_get_init_list(Eina_List **cluster_list,Eina_List **extra_widget_list);
#endif /* __CLUSTER_DB_H__ */
diff --git a/inc/cluster_view.h b/inc/cluster_view.h
index b49fd71..763c4b4 100755
--- a/inc/cluster_view.h
+++ b/inc/cluster_view.h
@@ -40,8 +40,11 @@ void cluster_view_lang_changed(homescreen_view_t view_type);
view_state_t cluster_view_get_state(void);
bool cluster_view_set_state(view_state_t state);
void cluster_view_delete_widget(widget_data_t *item);
-bool cluster_view_add_widget(widget_data_t *item, bool scroll);
+bool cluster_view_add_widget(widget_data_t *item, bool scroll, bool show_popup);
void cluster_view_edit_on_done(cluster_page_t *page);
void cluster_view_get_access_object_list(Eina_List **list);
+void __cluster_view_init_cluster_data(void);
+void __cluster_view_create_cluster(void);
+
#endif /* __CLUSTER_VIEW_H__ */
diff --git a/src/cluster_data.c b/src/cluster_data.c
index 3d4f581..9c847b7 100755
--- a/src/cluster_data.c
+++ b/src/cluster_data.c
@@ -32,31 +32,51 @@ static struct {
.data_list = NULL
};
+static struct {
+ Eina_List *data_list;
+} extra_widget_data_s = {
+ .data_list = NULL
+};
+
static void __cluster_data_item_free(widget_data_t *item);
static void __cluster_data_insert_default_data(void);
void cluster_data_init(void)
{
- if (move_external_cluster_db()) {
- int page_count = cluster_db_get_row_count();
- if (page_count > CLUSTER_MAX_PAGE) {
- page_count = CLUSTER_MAX_PAGE;
- }
- cluster_data_set_page_count(page_count);
- }
- if (cluster_db_create()) {
- /* Do not show default calendar widget for common profile */
- //__cluster_data_insert_default_data();
+ if (move_external_cluster_db() || cluster_db_create()) {
cluster_data_set_page_count(1);
+ __cluster_view_init_cluster_data();
+ cluster_db_get_init_list(&cluster_data_s.data_list, &extra_widget_data_s.data_list);
+ update_init_default_widget_data_to_db();
+ return;
}
cluster_db_get_list(&cluster_data_s.data_list);
+ __cluster_view_create_cluster();
}
+void update_init_default_widget_data_to_db(void)
+{
+ Eina_List *widget_list = cluster_data_get_widget_list();
+ Eina_List *extra_widget_list = cluster_data_get_extra_widget_list();
+ Eina_List *find_list;
+ widget_data_t *item = NULL;
+ EINA_LIST_FOREACH(widget_list, find_list, item) {
+ cluster_data_update(item);
+ }
+ EINA_LIST_FOREACH(extra_widget_list, find_list, item) {
+ cluster_data_delete_extra_widget(item);
+ }
+}
Eina_List *cluster_data_get_widget_list(void)
{
return cluster_data_s.data_list;
}
+Eina_List *cluster_data_get_extra_widget_list(void)
+{
+ return extra_widget_data_s.data_list;
+}
+
int cluster_data_get_page_count()
{
int result = -1;
@@ -89,7 +109,7 @@ void cluster_data_insert_widget(const char* pkg_name, const char *label, const c
new_item->period = 0.0;
new_item->allow_duplicate = 1;
- if (!cluster_view_add_widget(new_item, true)) {
+ if (!cluster_view_add_widget(new_item, true, true)) {
cluster_view_delete_widget(new_item);
__cluster_data_item_free(new_item);
return ;
@@ -119,6 +139,11 @@ void cluster_data_update(widget_data_t *item)
cluster_db_update(item);
}
+void cluster_data_delete_extra_widget(widget_data_t *item)
+{
+ cluster_db_delete(item);
+}
+
static void __cluster_data_insert_default_data(void)
{
/* org.tizen.gallery.widget
diff --git a/src/cluster_db.c b/src/cluster_db.c
index be8bd4b..7b83422 100755
--- a/src/cluster_db.c
+++ b/src/cluster_db.c
@@ -19,6 +19,7 @@
#include "cluster_db.h"
#include "cluster_data.h"
+#include "cluster_view.h"
#include "util.h"
#include "conf.h"
@@ -87,19 +88,38 @@ bool move_external_cluster_db(void)
return false;
}
Eina_Bool ret_val = EINA_TRUE;
- char externel_db_path[MAX_SIZE];
+ char external_db_path[MAX_SIZE];
char *res_path = app_get_resource_path();
if (!res_path) {
__E("Resource Path not found");
return false;
}
- snprintf(externel_db_path, MAX_SIZE, "%s%s", res_path, "data/.cluster-data.db");
+ snprintf(external_db_path, MAX_SIZE, "%s%s", res_path, "data/.cluster-data.db");
free(res_path);
- ret_val = ecore_file_mv(externel_db_path, db_path);
+ ret_val = ecore_file_mv(external_db_path, db_path);
if (!ret_val) {
__E("Failed to move External cluster DB");
return false;
}
+ __D("External cluster DB moved");
+
+ char * query = "SELECT * FROM clusters;";
+ sqlite3_stmt *stmt;
+
+ if (!__cluster_db_open()) {
+ __E("Unable to open external cluster db");
+ __E("Removing external cluster db");
+ ecore_file_remove(db_path);
+ return false;
+ }
+
+ int ret = sqlite3_prepare_v2(cluster_db, query, strlen(query), &stmt, NULL);
+ if (ret != SQLITE_OK) {
+ __E("sqlite error : QUERY_CLUSTER_DB : %s", sqlite3_errmsg(cluster_db));
+ __E("Removing external cluster db");
+ ecore_file_remove(db_path);
+ return false;
+ }
return true;
}
@@ -151,13 +171,8 @@ bool cluster_db_get_list(Eina_List **cluster_list)
__E("sqlite error : QUERY_CLUSTER_DB");
return false;
}
- int page_count = 0;
const char *str = NULL;
while (sqlite3_step(stmt) == SQLITE_ROW) {
- page_count += 1;
- if (page_count > CLUSTER_MAX_PAGE) {
- break;
- }
widget_data_t *item = (widget_data_t *)malloc(sizeof(widget_data_t));
memset(item, 0, sizeof(widget_data_t));
@@ -180,30 +195,46 @@ bool cluster_db_get_list(Eina_List **cluster_list)
return true;
}
-int cluster_db_get_row_count(void)
+bool cluster_db_get_init_list(Eina_List **cluster_list, Eina_List **extra_widget_list)
{
- /* Incase of error or if DB is empty function returns 1 to create blank page */
-
- char *query = "SELECT COUNT(*) FROM clusters;";
+ char * query = "SELECT * FROM clusters;";
sqlite3_stmt *stmt;
if (!__cluster_db_open())
- return 1;
+ return false;
int ret = sqlite3_prepare_v2(cluster_db, query, strlen(query), &stmt, NULL);
if (ret != SQLITE_OK) {
- __E("sqlite error : COUNT_QUERY_CLUSTER_DB");
- return 1;
+ __E("sqlite error : QUERY_CLUSTER_DB");
+ return false;
}
+ const char *str = NULL;
+ while (sqlite3_step(stmt) == SQLITE_ROW) {
+ widget_data_t *item = (widget_data_t *)malloc(sizeof(widget_data_t));
+ memset(item, 0, sizeof(widget_data_t));
- int count = 0;
- if (sqlite3_step(stmt) == SQLITE_ROW) {
- count = sqlite3_column_int(stmt,0);
+ item->db_id = sqlite3_column_int(stmt, COL_DB_ID);
+ item->page_idx = sqlite3_column_int(stmt, COL_PAGE_INDEX);
+ item->pos_y = sqlite3_column_int(stmt, COL_POS_Y);
+ item->pos_x = sqlite3_column_int(stmt, COL_POS_X);
+ str = (const char *) sqlite3_column_text(stmt, COL_PKG_NAME);
+ item->pkg_name = (!str || !strlen(str)) ? NULL : strdup(str);
+ str = (const char *) sqlite3_column_text(stmt, COL_WIDGET_LABEL);
+ item->widget_label = (!str || !strlen(str)) ? NULL : strdup(str);
+ str = (const char *) sqlite3_column_text(stmt, COL_CONTENT_INFO);
+ item->content_info = (!str || !strlen(str) || strncmp(str, "(null)", strlen("(null)")) == 0 ) ? NULL : strdup(str);
+ item->type = sqlite3_column_int(stmt, COL_TYPE);
+ item->period = sqlite3_column_double(stmt, COL_PERIOD);
+ item->allow_duplicate = sqlite3_column_int(stmt, COL_ALLOW_DUPLICATE);
+ if(cluster_view_add_widget(item,true,false)) {
+ *cluster_list = eina_list_append(*cluster_list, item);
+ }
+ else {
+ *extra_widget_list = eina_list_append(*extra_widget_list, item);
+ }
}
sqlite3_finalize(stmt);
- if (count >= 1)
- return count;
- return 1;
+ return true;
}
bool cluster_db_update(widget_data_t *item)
diff --git a/src/cluster_view.c b/src/cluster_view.c
index a9fbd3b..23ce454 100755
--- a/src/cluster_view.c
+++ b/src/cluster_view.c
@@ -117,7 +117,6 @@ static void __clsuter_view_scroller_up_cb(void *data, Evas *e, Evas_Object *obj,
static void __clsuter_view_scroller_move_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
static Eina_Bool __cluster_view_scroller_long_press_time_cb(void *data);
-static void __cluster_view_create_cluster(void);
static void __cluster_view_create_menu(void);
static void __cluster_view_menu_edit_cb(void *data, Evas_Object *obj, void *event_info);
static void __cluster_view_menu_add_widget_cb(void *data, Evas_Object *obj, void *event_info);
@@ -195,7 +194,6 @@ void cluster_view_init(void)
widget_viewer_init(cluster_view_s.win);
cluster_data_init();
- __cluster_view_create_cluster();
__cluster_view_create_menu();
}
@@ -276,7 +274,17 @@ Evas_Object *__cluster_view_create_base_gui(Evas_Object *win)
return cluster_view_s.scroller;
}
-static void __cluster_view_create_cluster(void)
+void __cluster_view_init_cluster_data(void)
+{
+ int page_count = cluster_data_get_page_count();
+ cluster_view_s.current_page = CLUSTER_HOME_PAGE;
+
+ while (page_count--) {
+ __cluster_view_page_new();
+ }
+}
+
+void __cluster_view_create_cluster(void)
{
Eina_List *widget_list = cluster_data_get_widget_list();
int page_count = cluster_data_get_page_count();
@@ -581,7 +589,7 @@ static Eina_Bool __cluster_view_add_widget_scroll_timer_cb(void *data)
}
#endif
-bool cluster_view_add_widget(widget_data_t *item, bool scroll)
+bool cluster_view_add_widget(widget_data_t *item, bool scroll, bool show_popup)
{
bool set_on = false;
@@ -606,17 +614,18 @@ bool cluster_view_add_widget(widget_data_t *item, bool scroll)
if (!set_on) {
if (cluster_view_s.page_count >= CLUSTER_MAX_PAGE) {
- __E("cluster page is max.");
-
- Evas_Smart_Cb func[3] = { NULL, NULL, NULL };
- void *data[3] = { NULL, NULL, NULL };
- char btn_text[3][STR_MAX] = { "", "", "" };
- char title_text[STR_MAX] = { "" };
- char popup_text[STR_MAX] = { "" };
- snprintf(btn_text[0], sizeof(btn_text[0]), "%s", _("IDS_CAM_SK_OK"));
- snprintf(title_text, sizeof(title_text), "%s", _("IDS_HS_HEADER_UNABLE_TO_ADD_WIDGET_ABB"));
- snprintf(popup_text, sizeof(popup_text), "%s", _("IDS_HS_POP_UNABLE_TO_ADD_THIS_HOME_BOX_TO_THE_HOME_SCREEN_THERE_IS_NOT_ENOUGH_SPACE_ON_THE_HOME_SCREEN_MSG"));
- popup_show(1, func, data, btn_text, title_text, popup_text);
+ if (show_popup) {
+ __E("cluster page is max.");
+ Evas_Smart_Cb func[3] = { NULL, NULL, NULL };
+ void *data[3] = { NULL, NULL, NULL };
+ char btn_text[3][STR_MAX] = { "", "", "" };
+ char title_text[STR_MAX] = { "" };
+ char popup_text[STR_MAX] = { "" };
+ snprintf(btn_text[0], sizeof(btn_text[0]), "%s", _("IDS_CAM_SK_OK"));
+ snprintf(title_text, sizeof(title_text), "%s", _("IDS_HS_HEADER_UNABLE_TO_ADD_WIDGET_ABB"));
+ snprintf(popup_text, sizeof(popup_text), "%s", _("IDS_HS_POP_UNABLE_TO_ADD_THIS_HOME_BOX_TO_THE_HOME_SCREEN_THERE_IS_NOT_ENOUGH_SPACE_ON_THE_HOME_SCREEN_MSG"));
+ popup_show(1, func, data, btn_text, title_text, popup_text);
+ }
return false;
}
@@ -1656,7 +1665,7 @@ static void __cluster_view_edit_move_anim_done(void *data)
page = (cluster_page_t *)eina_list_nth(cluster_view_s.page_list, cluster_view_s.current_page);
if (!cluster_page_set_widget(page, cluster_view_s.picked_widget)) {
- cluster_view_add_widget(cluster_view_s.picked_widget, true);
+ cluster_view_add_widget(cluster_view_s.picked_widget, true, true);
}
}