Add bg color change functionality 35/69535/7
authorRadoslaw Czerski <r.czerski@samsung.com>
Mon, 6 Jun 2016 10:55:25 +0000 (12:55 +0200)
committerLukasz Stanislawski <l.stanislaws@samsung.com>
Tue, 7 Jun 2016 13:51:03 +0000 (06:51 -0700)
Change-Id: I17ba3658837f3b00a924e332e9f3299c9ad32637
Signed-off-by: Radoslaw Czerski <r.czerski@samsung.com>
CMake/CMakeLists.txt
inc/bg_color.h [new file with mode: 0644]
inc/util.h
packaging/org.tizen.indicator.spec
project_def.prop
res/resource/color_classes.edc
res/resource/indicator_port.edc
src/bg_color.c [new file with mode: 0644]
src/main.c
src/util.c
tizen-manifest.xml

index 339d9436ccd0a98a2228e279cf2f9dad28af683c..6cfd4214dad800cb35e3499dfd1d1e2d3702a8ba 100644 (file)
@@ -44,6 +44,7 @@ pkg_check_modules(pkgs REQUIRED
        capi-network-tethering
        storage
        capi-base-utils-i18n
+       capi-message-port
 )
 
 FOREACH(flag ${pkgs_CFLAGS})
diff --git a/inc/bg_color.h b/inc/bg_color.h
new file mode 100644 (file)
index 0000000..ea76a69
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ *  Indicator
+ *
+ * Copyright (c) 2016 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 BG_COLOR_H_
+#define BG_COLOR_H_
+
+
+/*
+ * @brief Registers port for receiving messages from other applications.
+ * @remarks For now it is only used to change indicator background
+ *
+ * @param[in] data     pointer to struct appdata(passed to app_service callback of Indicator-win app as void*)
+ */
+void message_port_register(void *data);
+void message_port_unregister(void);
+
+#endif /* BG_COLOR_H_ */
index 072c71b5f19e395f7025e02e96db496f5b3bcbe6..0eefafccd4b6cfe33af493d4cd23cd5d88f9a253 100644 (file)
@@ -36,6 +36,13 @@ typedef enum {
        INDICATOR_ERROR_NO_DATA = -5,
 } indicator_error_e;
 
+typedef enum {
+       BG_COLOR_DEFAULT = 0,
+       BG_COLOR_CALL_INCOMING,
+       BG_COLOR_CALL_END,
+       BG_COLOR_CALL_ON_HOLD,
+} bg_color_e;
+
 typedef struct _Indicator_Data_Animation Indicator_Data_Animation;
 
 struct _Indicator_Data_Animation
@@ -45,6 +52,9 @@ struct _Indicator_Data_Animation
 };
 
 extern char *util_set_label_text_color(const char *txt);
+extern void util_bg_color_default_set(Evas_Object *layout);
+extern void util_bg_color_rgba_set(Evas_Object *layout, char r, char g, char b, char a);
+extern void util_bg_call_color_set(Evas_Object *layout, bg_color_e color);
 extern const char *util_get_icon_dir(void);
 extern void util_signal_emit(void* data, const char *emission, const char *source);
 extern void util_part_text_emit(void* data, const char *part, const char *text);
index 5e0bfa15a0685f81b62c443048131b68c56ddff9..78f62303380e37221be5ca960514745c28fbe002 100644 (file)
@@ -41,7 +41,7 @@ BuildRequires: pkgconfig(feedback)
 BuildRequires: pkgconfig(pkgmgr-info)
 BuildRequires: pkgconfig(edbus)
 BuildRequires: pkgconfig(efl-assist)
-BuildRequires: pkgconfig(message-port)
+BuildRequires: pkgconfig(capi-message-port)
 BuildRequires: pkgconfig(tzsh-indicator-service)
 BuildRequires: pkgconfig(libtzplatform-config)
 BuildRequires: pkgconfig(capi-system-device)
index 974632308c76dc1f7677ef50ef0dec7bbccac6e1..98f97cfe2400afb3d97ab68669af7e0e50f3b007 100644 (file)
@@ -9,7 +9,7 @@ type = app
 profile = mobile-3.0
 
 # C Sources
-USER_SRCS = src/modules/information/video_play.c src/modules/information/earphone.c src/modules/information/toast_popup.c /src/modules/processing/call_divert.c src/modules/information/mp3_playing.c src/icon.c src/modules/modules.c src/modules/processing/transfer.c src/modules/processing/uploading.c src/modules/information/voice_recorder.c src/modules/information/noti.c src/modules/information/lowmem.c src/modules/information/fm_radio.c src/modules/setting/gps.c src/modules/processing/call.c src/modules/information/more_notify.c src/modules/setting/bluetooth.c src/tts.c src/modules/connection/connection.c src/modules/connection/wifi.c src/list.c src/modules/setting/nfc.c src/ticker.c src/modules/connection/dock.c src/main.c src/box.c src/modules/information/ext_storage.c src/modules/power/battery.c src/modules/connection/mobile_hotspot.c src/modules/home/search.c src/util.c src/modules/clock/clock.c src/modules/information/alarm.c src/modules/network/rssi.c src/modules/processing/downloading.c src/modules/setting/wifi-direct.c src/modules/connection/usb.c src/modules/setting/silent.c 
+USER_SRCS = src/modules/information/video_play.c src/modules/information/earphone.c src/bg_color.c src/modules/information/toast_popup.c /src/modules/processing/call_divert.c src/modules/information/mp3_playing.c src/icon.c src/modules/modules.c src/modules/processing/transfer.c src/modules/processing/uploading.c src/modules/information/voice_recorder.c src/modules/information/noti.c src/modules/information/lowmem.c src/modules/information/fm_radio.c src/modules/setting/gps.c src/modules/processing/call.c src/modules/information/more_notify.c src/modules/setting/bluetooth.c src/tts.c src/modules/connection/connection.c src/modules/connection/wifi.c src/list.c src/modules/setting/nfc.c src/ticker.c src/modules/connection/dock.c src/main.c src/box.c src/modules/information/ext_storage.c src/modules/power/battery.c src/modules/connection/mobile_hotspot.c src/modules/home/search.c src/util.c src/modules/clock/clock.c src/modules/information/alarm.c src/modules/network/rssi.c src/modules/processing/downloading.c src/modules/setting/wifi-direct.c src/modules/connection/usb.c src/modules/setting/silent.c 
 
 # EDC Sources
 USER_EDCS =  
index ba1a676dd350c321507264c9dd9c5053d5be1877..5441840b13a9f0f2bc72b19b01790ddbb56a2288 100644 (file)
@@ -68,4 +68,22 @@ color_classes {
                name: "ATO005";
                color: 76 76 76 255;
        }
+       color_class {
+               name: "W015L1";
+               color: 88 175 57 255;
+       }
+       color_class {
+               name: "F060L3";
+               color: 214 49 49 255;
+       }
+       color_class
+       {
+               name: "bg_custom";
+               color: 0 0 0 255;
+       }
+       color_class
+       {
+               name: "bg_default";
+               color: 0 0 0 0;
+       }
 }
index cc1015a55c93ad62d2deba79a4742f996ef147b6..aef5742ef7d89df368619293279c5ab53dd48a53 100644 (file)
@@ -33,6 +33,21 @@ collections {
                name: "indicator";
                script {
                        public bg_set, badge_set, theme, changepad, changebg, changeHomePad;
+                       public message(Msg_Type:type, id, ...)
+                       {
+                               if (type == MSG_INT_SET && id == 1)
+                               {
+                                       new r, g, b, a;
+
+                                       r = getarg(2);
+                                       g = getarg(3);
+                                       b = getarg(4);
+                                       a = getarg(5);
+
+                                       set_state(PART:"background", "bg_custom", 0.0);
+                                       set_color_class("bg_custom", r, g, b, a);
+                               }
+                       }
                }
                styles
                {
@@ -87,7 +102,27 @@ collections {
                                description {
                                        state: "default" 0.0;
                                        min: 0 INDICATOR_HEIGHT;
-                                       color: 0 0 0 0;
+                                       color_class: "bg_default";
+                               }
+                               description {
+                                       state: "bg_custom" 0.0;
+                                       inherit: "default";
+                                       color_class: "bg_custom";
+                               }
+                               description {
+                                       state: "incoming_call" 0.0;
+                                       inherit: "default";
+                                       color_class: "W015L1";
+                               }
+                               description {
+                                       state: "end_call" 0.0;
+                                       inherit: "default";
+                                       color_class: "F060L3";
+                               }
+                               description {
+                                       state: "on_hold" 0.0;
+                                       inherit: "default";
+                                       color_class: "AO007";
                                }
                        }
                        part {
@@ -1343,6 +1378,42 @@ collections {
                         * BG and CLOCK
                         *
                         **********************************************************/
+
+                       program {
+                               name: "bg_color_default";
+                               action: STATE_SET "default" 0.0;
+                               signal: "bg.color.default";
+                               source: "indicator.prog";
+                               target: "background";
+                       }
+
+                       program {
+                               name: "bg_color_call_incoming";
+                               signal: "bg.color.call.incoming";
+                               source: "indicator.prog";
+                               script {
+                                       set_state(PART:"background", "incoming_call", 0.0);
+                               }
+                       }
+
+                       program {
+                               name: "bg_color_call_end";
+                               signal: "bg.color.call.end";
+                               source: "indicator.prog";
+                               script {
+                                       set_state(PART:"background", "end_call", 0.0);
+                               }
+                       }
+
+                       program {
+                               name: "bg_color_call_on_hold";
+                               signal: "bg.color.call.onhold";
+                               source: "indicator.prog";
+                               script {
+                                       set_state(PART:"background", "on_hold", 0.0);
+                               }
+                       }
+
                        program {
                                name: "bg_opaque";
                                action: STATE_SET "default" 0.0;
@@ -1855,4 +1926,4 @@ collections {
 
                }
        }
-}
\ No newline at end of file
+}
diff --git a/src/bg_color.c b/src/bg_color.c
new file mode 100644 (file)
index 0000000..fb329c5
--- /dev/null
@@ -0,0 +1,160 @@
+/*
+ *  Indicator
+ *
+ * Copyright (c) 2016 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 "indicator.h"
+#include "log.h"
+#include "util.h"
+#include "main.h"
+
+#include <message_port.h>
+#include <bundle.h>
+
+#define KEY_INDICATOR_BG "indicator/bg/color"
+
+/*
+ * Values for KEY_INDICATOR_BG key
+ */
+#define VALUE_INDICATOR_BG_RGB "indicator/bg/color/rgb"
+#define KEY_VALUE_INDICATOR_BG_CALL "indicator/bg/color/call"
+
+/*
+ * Keys that are set if KEY_INDICATOR_BG is paired with VALUE_INDICATOR_BG_RGB
+ */
+#define KEY_R "bg/r"
+#define KEY_G "bg/g"
+#define KEY_B "bg/b"
+#define KEY_A "bg/a"
+
+/*
+ * Values for KEY_VALUE_INDICATOR_BG_CALL key
+ */
+#define VALUE_CALL_INCOMING_CALL "call/during_call"
+#define VALUE_CALL_ON_HOLD "call/on_hold"
+#define VALUE_CALL_END_CALL "call/end_call"
+#define VALUE_CALL_IDLE "call/idle"
+
+
+static int port_id;
+
+
+static void set_bg_for_call(struct appdata *ad, bundle *message)
+{
+       _D("set_bg_for_call");
+
+       char *call_state;
+       int ret;
+
+       ret = bundle_get_str(message, KEY_VALUE_INDICATOR_BG_CALL, &call_state);
+       retm_if(ret != BUNDLE_ERROR_NONE, "bundle_get_type failed[%d]:%s", ret, get_error_message(ret));
+
+       if (!strcmp(call_state, VALUE_CALL_INCOMING_CALL)) {
+               util_bg_call_color_set(ad->win.layout, BG_COLOR_CALL_INCOMING);
+       } else if (!strcmp(call_state, VALUE_CALL_ON_HOLD)) {
+               util_bg_call_color_set(ad->win.layout, BG_COLOR_CALL_ON_HOLD);
+       } else if (!strcmp(call_state, VALUE_CALL_END_CALL)) {
+               util_bg_call_color_set(ad->win.layout, BG_COLOR_CALL_END);
+       } else if (!strcmp(call_state, VALUE_CALL_IDLE)) {
+               util_bg_color_default_set(ad->win.layout);
+       } else {
+               _E("Invalid value!");
+       }
+}
+
+
+static void validate_and_set_bg_rgba(int rgba_r, int rgba_g, int rgba_b, int rgba_a)
+{
+       _D("validate_and_set_bg");
+
+       retm_if(rgba_r < 0 || rgba_r > 255, "R component of RGBA color scheme is invalid");
+       retm_if(rgba_g < 0 || rgba_g > 255, "G component of RGBA color scheme is invalid");
+       retm_if(rgba_b < 0 || rgba_b > 255, "B component of RGBA color scheme is invalid");
+       retm_if(rgba_a < 0 || rgba_a > 255, "A component of RGBA color scheme is invalid");
+}
+
+
+static void set_bg_rgba(struct appdata *ad, bundle *message)
+{
+       _D("set_bg_rgba");
+
+       void *rgba_r;
+       void *rgba_g;
+       void *rgba_b;
+       void *rgba_a;
+       int ret;
+       size_t size;
+
+       ret = bundle_get_byte(message, KEY_R, &rgba_r, &size);
+       retm_if(ret != BUNDLE_ERROR_NONE, "bundle_get_byte failed[%d]:%s", ret, get_error_message(ret));
+       ret = bundle_get_byte(message, KEY_G, &rgba_g, &size);
+       retm_if(ret != BUNDLE_ERROR_NONE, "bundle_get_byte failed[%d]:%s", ret, get_error_message(ret));
+       ret = bundle_get_byte(message, KEY_B, &rgba_b, &size);
+       retm_if(ret != BUNDLE_ERROR_NONE, "bundle_get_byte failed[%d]:%s", ret, get_error_message(ret));
+       ret = bundle_get_byte(message, KEY_A, &rgba_a, &size);
+       retm_if(ret != BUNDLE_ERROR_NONE, "bundle_get_byte failed[%d]:%s", ret, get_error_message(ret));
+
+       validate_and_set_bg_rgba(*(int *)rgba_r, *(int *)rgba_g, *(int *)rgba_b, *(int *)rgba_a);
+
+       util_bg_color_rgba_set(ad->win.layout, *(int *)rgba_r, *(int *)rgba_g, *(int *)rgba_b, *(int *)rgba_a);
+}
+
+
+static void message_port_cb(int trusted_local_port_id, const char *remote_app_id,
+               const char *remote_port, bool trusted_remote_port, bundle *message, void *data)
+{
+       _D("message_port_cb");
+
+       retm_if(!trusted_remote_port, "The remote port is untrusted");
+       int ret;
+       char *value;
+
+       struct appdata *ad;
+
+       ret_if(!data);
+       ad = data;
+
+       ret = bundle_get_str(message, KEY_INDICATOR_BG, &value);
+       retm_if(ret != BUNDLE_ERROR_NONE, "bundle_get_type failed[%d]:%s", ret, get_error_message(ret));
+
+       if (!strcmp(value, KEY_VALUE_INDICATOR_BG_CALL))
+               set_bg_for_call(ad, message);
+
+       else if (!strcmp(value, VALUE_INDICATOR_BG_RGB))
+               set_bg_rgba(ad, message);
+}
+
+
+void message_port_register(void *data)
+{
+       _D("message_port_register");
+
+       port_id = message_port_register_trusted_local_port("indicator/bg/color", message_port_cb, data);
+       retm_if(port_id < MESSAGE_PORT_ERROR_NONE,
+                       "message_port_register_trusted_local_port failed[%d]:%s", port_id, get_error_message(port_id));
+}
+
+
+void message_port_unregister(void)
+{
+       _D("message_port_unregister");
+       int ret;
+
+       ret = message_port_unregister_trusted_local_port(port_id);
+       retm_if(ret != MESSAGE_PORT_ERROR_NONE, "message_port_unregister_trusted_local_port failed[%d]:%s", ret, get_error_message(ret));
+
+}
index 92e67e025552cf4d99924fd82dd4d36e9cd34de3..efb4702d8f3eda1893bed14283e2bfd0315e8d1a 100644 (file)
@@ -47,6 +47,7 @@
 #include "log.h"
 #include "indicator.h"
 #include "ticker.h"
+#include "bg_color.h"
 
 #define GRP_NAME "indicator"
 #define WIN_TITLE "Illume Indicator"
@@ -704,8 +705,6 @@ static void _create_window(struct appdata *ad)
        ad->win.win = elm_win_add(NULL, "indicator", ELM_WIN_SOCKET_IMAGE);
        ret_if(!(ad->win.win));
 
-       elm_win_alpha_set(ad->win.win, EINA_TRUE);
-
        dummy_win = elm_win_add(NULL, "indicator_dummy", ELM_WIN_BASIC);
        if (dummy_win) {
                elm_win_screen_size_get(dummy_win, NULL, NULL, &ad->win.port_w, &ad->win.land_w);
@@ -1093,6 +1092,7 @@ static void app_terminate(void *data)
        modules_fini(data);
        ticker_fini(ad);
        indicator_toast_popup_fini();
+       message_port_unregister();
 #ifdef _SUPPORT_SCREEN_READER2
        indicator_service_tts_fini(data);
 #endif
@@ -1130,6 +1130,7 @@ static void app_service(app_control_h service, void *data)
 #endif
        feedback_initialize();
        indicator_toast_popup_init(data);
+       message_port_register(data);
        if (INDICATOR_ERROR_NONE != ticker_init(ad)) {
                _E("Ticker cannot initialize");
        }
index c1f48906b57406eaec30401591a7649b107afc08..bc7037cb87b18d1a3da0bc1ed05f96fcef3cda0b 100644 (file)
@@ -114,6 +114,51 @@ char *util_set_label_text_color(const char *txt)
        return ret_str;
 }
 
+void util_bg_color_rgba_set(Evas_Object *layout, char r, char g, char b, char a)
+{
+       Edje_Message_Int_Set *msg;
+
+       ret_if(!layout);
+
+       msg = malloc(sizeof(*msg) + 3 * sizeof(int));
+
+       msg->count = 4;
+       msg->val[0] = r;
+       msg->val[1] = g;
+       msg->val[2] = b;
+       msg->val[3] = a;
+
+       edje_object_message_send(elm_layout_edje_get(layout), EDJE_MESSAGE_INT_SET, 1, msg);
+       free(msg);
+}
+
+void util_bg_color_default_set(Evas_Object *layout)
+{
+       ret_if(!layout);
+
+       elm_layout_signal_emit(layout, "bg.color.default", "indicator.prog");
+}
+
+void util_bg_call_color_set(Evas_Object *layout, bg_color_e color)
+{
+       ret_if(!layout);
+
+       switch (color) {
+               case BG_COLOR_CALL_INCOMING:
+                       elm_layout_signal_emit(layout, "bg.color.call.incoming", "indicator.prog");
+                       break;
+               case BG_COLOR_CALL_END:
+                       elm_layout_signal_emit(layout, "bg.color.call.end", "indicator.prog");
+                       break;
+               case BG_COLOR_CALL_ON_HOLD:
+                       elm_layout_signal_emit(layout, "bg.color.call.onhold", "indicator.prog");
+                       break;
+               default:
+                       util_bg_color_default_set(layout);
+                       break;
+       }
+}
+
 const char *util_get_icon_dir(void)
 {
        return util_get_res_file_path(DEFAULT_DIR);
index a715721439060b43b6ad76fd7f3e60c78abbcf83..c7932c66f373241715bfe4bec3f52e91aa095b55 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<manifest xmlns="http://tizen.org/ns/packages" api-version="3.0" package="org.tizen.indicator" version="1.0.0">
+<manifest xmlns="http://tizen.org/ns/packages" api-version="3.0" install-location="internal-only" package="org.tizen.indicator" version="1.0.0">
     <profile name="mobile"/>
-    <ui-application appid="org.tizen.indicator" exec="indicator-win" launch_mode="single" on-boot="true" multiple="false" nodisplay="true" taskmanage="false" type="capp">
+    <ui-application appid="org.tizen.indicator" exec="indicator-win" process-pool="true" launch_mode="single" on-boot="true" multiple="false" nodisplay="true" taskmanage="false" type="capp">
         <label>indicator-win</label>
     </ui-application>
     <privileges>