set background image 08/145408/5
authorYoungHun Cho <hoon.cho@samsung.com>
Tue, 22 Aug 2017 08:09:32 +0000 (17:09 +0900)
committerYoungHun Cho <hoon.cho@samsung.com>
Wed, 23 Aug 2017 05:37:56 +0000 (14:37 +0900)
Change-Id: I0e74a6021c278101da3a1eb981b02ec836e75b36

12 files changed:
CMakeLists.txt
inc/apps/apps_view.h
inc/apps/apps_view_edje_conf.h
res/edje/circle/apps_base_layout_circle.edc
res/image/BG_preview_00.png [new file with mode: 0644]
src/apps/apps_control_manager.c
src/apps/apps_view_circle.c
test/feature_test/feature_test.c
test/feature_test/feature_test.h
test/feature_test/group_feature_apps_backgroud.c [new file with mode: 0755]
test/test_function.h
test/unit/unit_assert.c

index b1c361c79366545f87ecfb2a44bce8b08b8ef43c..40d550cf174e1a8643118b792584f8ebf320040a 100755 (executable)
@@ -238,6 +238,7 @@ ADD_EXECUTABLE(${PROJECT_NAME}
        test/feature_test/group_feature_moments_center_layout_show.c
        test/feature_test/group_feature_apps_focus_text.c
        test/feature_test/group_feature_apps_auto_open_app.c
+       test/feature_test/group_feature_apps_backgroud.c
 
        test/unit/unit_assert.c
        test/unit/unit.c
index 5dd1864922e5f0bedaacb529563456f58d0954d0..f7f8384b3a89c498085abc24f252bccefec0d068 100755 (executable)
@@ -56,5 +56,8 @@ void apps_view_deregister_page_changed_cb(void(*page_changed_cb)(void *data));
 void apps_view_occupy_touch_callback(APPS_VIEW_CALLBACK *callback);
 APPS_ICON_INFO *apps_view_get_focus_app_info(void);
 void apps_view_reload_page(void);
+void apps_view_set_wallpaper_path(const char * path);
+const char * apps_view_get_wallpaper_path(void);
+
 
 #endif
index c510925a4335b2e872ae8cd04e7a161924bdb140..5376c440406f86a9122dcc06c13a767515dbd409 100755 (executable)
@@ -21,6 +21,7 @@
 #define SIZE_SETTER "size_setter"
 #define BASE_GRID "base_grid"
 
+#define APPS_BACKGROUND "apps_background"
 #define APPS_FOCUS_TEXT "apps_focus_text"
 #define APPS_INDICATOR "apps_indicator"
 #define APPS_INDICATOR_LAYOUT "apps_indicator_layout"
index 4751b491b944990c25b224dd684699cf51a71ee4..d698918625d59265e67002bc5af54cebb480c905 100755 (executable)
@@ -32,7 +32,7 @@ collections {
                name: BASE_LAYOUT;
                parts {
                        part {
-                               name: SIZE_SETTER;
+                               name: APPS_BACKGROUND;
                                type: SWALLOW;
                                mouse_events: 0;
                                repeat_events: 0;
@@ -48,8 +48,8 @@ collections {
                                type: TEXTBLOCK;
                                description {
                                        state: "default" 0.0;
-                                       rel1 { relative: 0.291 0.291; to: SIZE_SETTER; }
-                                       rel2 { relative: 0.708 0.708; to: SIZE_SETTER; }
+                                       rel1 { relative: 0.291 0.291; to: APPS_BACKGROUND; }
+                                       rel2 { relative: 0.708 0.708; to: APPS_BACKGROUND; }
                                        color: 255 255 255 255;
                                        visible: 1;
                                        fixed: 1 1;
diff --git a/res/image/BG_preview_00.png b/res/image/BG_preview_00.png
new file mode 100644 (file)
index 0000000..4beefcd
Binary files /dev/null and b/res/image/BG_preview_00.png differ
index 14db828d34e1ba66829d7580f18bcdf145b94781..df8f3ee89b9fcb0c19d2eb0a6bb3d7f12eae27d5 100755 (executable)
@@ -16,6 +16,7 @@
 
 #include <app.h>
 #include <badge.h>
+#include <system_settings.h>
 
 #include "log.h"
 #include "apps/apps.h"
@@ -56,6 +57,7 @@ static bool __create_apps_state(void);
 static void __destroy_apps_state(void);
 static void __add_window_focused_cb(void);
 static void __add_window_unfocused_cb(void);
+static void __add_wallpaper_changed_cb(void);
 static void __view_focused_cb(void *data, Evas_Object *obj, void *event_info);
 static void __view_unfocused_cb(void *data, Evas_Object *obj, void *event_info);
 static void __back_key_cb(void *data);
@@ -103,6 +105,8 @@ ERROR_E apps_init(void)
        __add_window_focused_cb();
        __add_window_unfocused_cb();
 
+       __add_wallpaper_changed_cb();
+
        if (apps_rotary_event_handler_init(s_info.main_win) == EINA_FALSE) {
                _E("failed to initialize rotary event");
                return ERROR_FAILED;
@@ -312,6 +316,21 @@ static void __view_unfocused_cb(void *data, Evas_Object *obj, void *event_info)
        apps_rotary_event_handler_activated_set(EINA_FALSE);
 }
 
+static void __wallpaper_changed_cb(system_settings_key_e key, void *data)
+{
+       char *buf = NULL;
+       system_settings_get_value_string(SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, &buf);
+
+       apps_view_set_wallpaper_path(buf);
+}
+
+static void __add_wallpaper_changed_cb(void)
+{
+       system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, __wallpaper_changed_cb, NULL);
+
+       __wallpaper_changed_cb(SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, NULL);
+}
+
 static void __back_key_cb(void *data)
 {
        if (s_info.current_state != NULL) {
index f9a43a95fa50cfce1cf75c36f3a0fb2644d28b5e..0ede5ae630fc553e5fecc0156ce90d30debe6bbc 100755 (executable)
@@ -15,6 +15,7 @@
  */
 
 #include <math.h>
+
 #include "animator.h"
 #include "apps/apps_view.h"
 #include "apps/apps_view_icon.h"
 #include "screen_reader_handler.h"
 #include "util.h"
 #include "log.h"
+#include "app_log.h"
 
 #define AUTO_OPEN_TIME 3.0
 
 static struct __view_circle_s {
        Evas_Object *base_layout;
+       Evas_Object *background;
        Evas_Object *focus_point;
        bool is_enable_focus_text;
        APPS_VIEW_CALLBACK *callback;
        Ecore_Timer *auto_open_timer;
 } s_info = {
        .base_layout = NULL,
+       .background = NULL,
        .focus_point = NULL,
        .is_enable_focus_text = true,
        .callback = NULL,
@@ -52,6 +56,7 @@ double ICON_ANGLE[APPS_ICON_COUNT_PER_PAGE] = {
 
 #define BASE_LAYOUT_EDJE EDJE_DIR"/circle/apps_base_layout_circle.edj"
 #define FOCUS_POINT_IMAGE_PATH IMAGE_DIR"/b_home_screen_focus_point.png"
+#define DEFAULT_WALLPAPER_IMAGE_PATH IMAGE_DIR"/BG_preview_00.png"
 
 void __apps_view_circle_init(void);
 Evas_Object *__apps_view_circle_create_base_layout(Evas_Object* base_win);
@@ -65,7 +70,7 @@ void __apps_view_circle_focus_text_press(void);
 void __apps_view_circle_focus_text_release(void);
 void __apps_view_circle_get_access_focus_text(Eina_List **list);
 
-static Evas_Object *__create_size_setter(Evas_Object *layout, COLOR color);
+static Evas_Object *__create_background(Evas_Object *layout, const char * path);
 static Evas_Object *__create_focus_point(Evas_Object *layout);
 static void __set_focus_text(char *label);
 static void __move_focus_next(void);
@@ -259,6 +264,32 @@ void apps_view_occupy_touch_callback(APPS_VIEW_CALLBACK *callback)
        __apps_view_circle_icon_set_touch_callback(callback);
 }
 
+void apps_view_set_wallpaper_path(const char * path)
+{
+       Evas_Object * background = elm_object_part_content_unset(s_info.base_layout, APPS_BACKGROUND);
+       if (background) {
+               evas_object_del(background);
+       }
+
+       s_info.background = __create_background(s_info.base_layout, path);
+       if (s_info.background == NULL) {
+               _E("Failed to create background");
+               return ;
+       }
+
+       elm_object_part_content_set(s_info.base_layout, APPS_BACKGROUND, s_info.background);
+}
+
+const char * apps_view_get_wallpaper_path(void)
+{
+       const char * path = NULL;
+       if (s_info.background) {
+               elm_image_file_get(s_info.background, &path, NULL);
+       }
+
+       return path;
+}
+
 void __apps_view_circle_init(void)
 {
        apps_data_set_focus_page(0);
@@ -270,7 +301,6 @@ Evas_Object *__apps_view_circle_create_base_layout(Evas_Object* base_win)
        _D("%s", __func__);
 
        Evas_Object *layout = NULL;
-       Evas_Object *size_setter = NULL;
 
        layout = elm_layout_add(base_win);
        if (layout == NULL) {
@@ -287,12 +317,12 @@ Evas_Object *__apps_view_circle_create_base_layout(Evas_Object* base_win)
        elm_win_resize_object_add(base_win, layout);
        evas_object_hide(layout);
 
-       size_setter = __create_size_setter(layout, DARK_BG);
-       if (size_setter == NULL) {
-               _E("Failed to create size setter");
+       s_info.background = __create_background(layout, NULL);
+       if (s_info.background == NULL) {
+               _E("Failed to create background");
                goto __fail;
        }
-       elm_object_part_content_set(layout, SIZE_SETTER, size_setter);
+       elm_object_part_content_set(layout, APPS_BACKGROUND, s_info.background);
 
        s_info.focus_point = __create_focus_point(layout);
        if (s_info.focus_point == NULL) {
@@ -306,7 +336,7 @@ Evas_Object *__apps_view_circle_create_base_layout(Evas_Object* base_win)
 
 __fail:
        destroy_evas_object(s_info.focus_point);
-       destroy_evas_object(size_setter);
+       destroy_evas_object(s_info.background);
        destroy_evas_object(layout);
 
        s_info.focus_point = NULL;
@@ -422,21 +452,31 @@ void __apps_view_circle_get_access_focus_text(Eina_List **list)
        return;
 }
 
-static Evas_Object *__create_size_setter(Evas_Object *layout, COLOR color)
+static Evas_Object *__create_background(Evas_Object *layout, const char * path)
 {
-       Evas_Object *rect = NULL;
+       Evas_Object * background = NULL;
 
-       rect = evas_object_rectangle_add(evas_object_evas_get(layout));
-       if (rect == NULL) {
+       background = elm_image_add(layout);
+       if (background == NULL) {
+               _E("Failed to add background");
                return NULL;
        }
 
-       evas_object_size_hint_min_set(rect, WINDOW_W, WINDOW_H);
-       evas_object_size_hint_weight_set(rect, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-       evas_object_size_hint_align_set(rect, EVAS_HINT_FILL, EVAS_HINT_FILL);
-       evas_object_color_set(rect, color.r, color.g, color.b, color.a);
+       if (path == NULL || !ecore_file_can_read(path)) {
+               path = util_get_res_file_path(DEFAULT_WALLPAPER_IMAGE_PATH);
+       }
 
-       return rect;
+       if (elm_image_file_set(background, path, "bg") == EINA_FALSE) {
+               _E("Failed to set background image file");
+               evas_object_del(background);
+               return NULL;
+       }
+
+       evas_object_size_hint_min_set(background, WINDOW_W, WINDOW_H);
+       evas_object_size_hint_weight_set(background, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       evas_object_size_hint_align_set(background, EVAS_HINT_FILL, EVAS_HINT_FILL);
+
+       return background;
 }
 
 static Evas_Object *__create_focus_point(Evas_Object *layout)
@@ -621,5 +661,10 @@ void __t__set_focus_text(char *label)
        __set_focus_text(label);
 }
 
+Evas_Object * __t__apps_view_get_background(void)
+{
+       return s_info.background;
+}
+
 #endif
 
index 0c9067f65ff3a9654d9f1ca64e99db0073416ea5..75c4bfd354bf61f589130088405e3bf84fcfad0e 100755 (executable)
@@ -41,6 +41,7 @@ void feature_test(void)
        TEST_GROUP_ADD("group_feature_moments_center_layout_show", group_feature_moments_center_layout_show);
        TEST_GROUP_ADD("group_feature_apps_focus_text", group_feature_apps_focus_text);
        TEST_GROUP_ADD("group_feature_apps_auto_open_app", group_feature_apps_auto_open_app);
+       TEST_GROUP_ADD("group_feature_apps_backgroud", group_feature_apps_backgroud);
 
        TEST_RUN(__test_complete_cb);
 }
index c886f3df99fe0cfdd04ecf37ce3f9d0d82b27f60..7d746c4b69ae0301c558320ffb62a7aab66a067c 100755 (executable)
@@ -38,6 +38,7 @@ void group_feature_moments_control_button_status_behavior(unit_group_t * group);
 void group_feature_moments_center_layout_show(unit_group_t * group);
 void group_feature_apps_focus_text(unit_group_t * group);
 void group_feature_apps_auto_open_app(unit_group_t * group);
+void group_feature_apps_backgroud(unit_group_t * group);
 
 
 #endif
diff --git a/test/feature_test/group_feature_apps_backgroud.c b/test/feature_test/group_feature_apps_backgroud.c
new file mode 100755 (executable)
index 0000000..444b7e3
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * 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 "test.h"
+#if TEST_MODE
+
+#include "feature_test.h"
+#include "../test_function.h"
+#include "apps/apps.h"
+#include "apps/apps_view.h"
+#include "util.h"
+
+#include <system_settings.h>
+#include <Elementary.h>
+#include <vconf.h>
+
+#define DEFAULT_WALLPAPER_IMAGE_PATH IMAGE_DIR"/BG_preview_00.png"
+
+static struct {
+       unit_group_t * group;
+} s_info = {
+       .group = NULL,
+};
+
+static void __set_up(void)
+{
+       apps_show();
+
+       ecore_timer_add(0.5, s_info.group->set_up_complete, s_info.group);
+}
+
+static void __tear_down(void)
+{
+       apps_hide();
+
+       ecore_timer_add(0.5, s_info.group->tear_down_complete, s_info.group);
+}
+
+static unit_case_func_t __continue_set_image(void * data)
+{
+       const char * buf = apps_view_get_wallpaper_path();
+       TEST_ASSERT_EQUAL_STRING((char*)data, buf);
+
+       TEST_CASE_DONE(s_info.group);
+}
+
+const char * PATH_1 = "/opt/usr/home/owner/share/wallpaper/BG_preview_01.png";
+const char * PATH_2 = "/opt/usr/home/owner/share/wallpaper/BG_preview_02.png";
+
+static unit_case_func_t __case_set_image(void * data)
+{
+       apps_view_set_wallpaper_path((char *)data);
+
+       TEST_CASE_CONTINUE(2.0, __continue_set_image, data);
+}
+
+static unit_case_func_t __continue_check_default_image(void * data)
+{
+       const char * buf = apps_view_get_wallpaper_path();
+       TEST_ASSERT_EQUAL_STRING(util_get_res_file_path(DEFAULT_WALLPAPER_IMAGE_PATH), buf);
+
+       TEST_CASE_DONE(s_info.group);
+}
+
+static unit_case_func_t __case_check_default_image(void * data)
+{
+       apps_view_set_wallpaper_path((char *)data);
+
+       TEST_CASE_CONTINUE(2.0, __continue_check_default_image, data);
+}
+
+void group_feature_apps_backgroud(unit_group_t * group)
+{
+       s_info.group = group;
+       s_info.group->set_up = __set_up;
+       s_info.group->tear_down = __tear_down;
+
+       TEST_CASE_ADD(s_info.group, __case_set_image, (void*)PATH_1);
+       TEST_CASE_ADD(s_info.group, __case_set_image, (void*)PATH_2);
+       TEST_CASE_ADD(s_info.group, __case_check_default_image, (void*)"dummy_path");
+
+       TEST_GROUP_RUN(s_info.group);
+}
+
+#endif
+
+
index 7c48752e187a4e4619e37e6839b5577e524a15e2..96d2752b6c72299cb76cc323ffdb061b6055fb0d 100755 (executable)
@@ -94,6 +94,8 @@ extern void __t__set_focus_text(char *label);
 extern void __t__ccw_cb(void *data);
 extern void __t__cw_cb(void *data);
 
+extern Evas_Object * __t__apps_view_get_background(void);
+
 #endif
 
 #endif
index 819eb85dd2e9134fc2a356001eedd9f7979b94e5..474e43754497e95d2243f590881ae6e64b208cdd 100755 (executable)
@@ -60,7 +60,9 @@ bool unit_assert_equal_double(const double expected_value, const double input_va
 
 bool unit_assert_equal_string(const char * expected_value, const char * input_value, const char * func, const int line)
 {
-       if (strcmp(expected_value, input_value)) {
+       if (expected_value == NULL && input_value == NULL) return true;
+
+       if (expected_value == NULL || input_value == NULL || strcmp(expected_value, input_value)) {
                unit_group_t * group = unit_get_current_group();
                if (group) __T("[%d of %s]", group->current_case, group->name);
                __T("%s (%d) FAIL, Expected %s was %s", func, line, expected_value, input_value);