Skip to content

Commit

Permalink
2.1.0. Added sound, focus on spinner.
Browse files Browse the repository at this point in the history
  • Loading branch information
VadVergasov committed Jul 23, 2019
1 parent e99cd5b commit f4fe420
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 35 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ SA_Report
Coverage_Report
.sign
reportASAN.txt
.package-stamp
.package-stamp
.vscode
3 changes: 2 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
-Trying to make icon in Popup.
-Progress bar currently available only on emulator. There is a bug in Tizen on real Samsung devices.
-Few minor fixes.
-Added sound of current system ringtone.
-Now spinner is in focus, so no clicks on screen now.
4 changes: 3 additions & 1 deletion inc/watercleaner.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@
#include <device/haptic.h>
#include <dlog.h>
#include <efl_extension.h>
#include <sound_manager.h>
#include <stdio.h>
#include <system_settings.h>
#include <time.h>
#include <player.h>

#ifdef LOG_TAG
#undef LOG_TAG
#endif
#define LOG_TAG "watercleaner"
#define LOG_TAG "Water Cleaner"

#if !defined(PACKAGE)
#define PACKAGE "com.vadvergasov.watercleaner"
Expand Down
106 changes: 75 additions & 31 deletions src/watercleaner.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,17 @@ typedef struct appdata {
Evas_Object *popup;
Evas_Object *circle_spinner;
Evas_Object *circle_progressbar;
Evas_Object *more_option;
Eext_Circle_Surface *surface;
player_h player;
} appdata_s;

appdata_s *ad;

Ecore_Timer *timer;

static void _timeout_cb(void *data, Evas_Object *obj, void *event_info) {
if (!obj) return;
if (!obj)
return;
evas_object_del(obj);
}

Expand All @@ -29,7 +30,7 @@ void ready_label(void *data) {
elm_object_style_set(ad->popup, "toast/circle");
elm_popup_orient_set(ad->popup, ELM_POPUP_ORIENT_BOTTOM);
evas_object_size_hint_weight_set(ad->popup, EVAS_HINT_EXPAND,
EVAS_HINT_EXPAND);
EVAS_HINT_EXPAND);
char *text = i18n_get_text("Ready");
char icon[100];
strcat(icon, app_get_resource_path());
Expand All @@ -50,6 +51,15 @@ void change_progress(void *data) {
ecore_timer_del(timer);
ready_label(NULL);
evas_object_hide(ad->circle_progressbar);
int error_code = 0;
error_code = player_stop(ad->player);
error_code = player_unprepare(ad->player);
error_code = player_destroy(ad->player);

if (error_code != PLAYER_ERROR_NONE) {
dlog_print(DLOG_ERROR, LOG_TAG,
"fail to destroy player: error code = %d", error_code);
}
return;
}
eext_circle_object_value_set(ad->circle_progressbar, value - 1);
Expand All @@ -62,12 +72,41 @@ static void device_vibrate(int duration, int feedback) {
if (device_haptic_vibrate(haptic_handle, duration, feedback,
&effect_handle) == DEVICE_ERROR_NONE) {
evas_object_show(ad->circle_progressbar);
timer = ecore_timer_add((double)duration / 100000.0,
timer = ecore_timer_add((double) duration / 100000.0,
change_progress, NULL);
}
}
}

static void device_sound() {
char* string;
system_settings_get_value_string(SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE,
&string);

int error_code = 0;
error_code = player_create(&ad->player);
if (error_code != PLAYER_ERROR_NONE) {
dlog_print(DLOG_ERROR, LOG_TAG, "failed to create");
}

player_set_looping(ad->player, true);
player_set_uri(ad->player, string);

error_code = player_prepare(ad->player);
if (error_code != PLAYER_ERROR_NONE) {
dlog_print(DLOG_ERROR, LOG_TAG,
"failed to prepare player: error code = %d", error_code);
}

error_code = player_start(ad->player);
if (error_code != PLAYER_ERROR_NONE) {
dlog_print(DLOG_ERROR, LOG_TAG,
"failed to start player: error code = %d", error_code);
}

dlog_print(DLOG_INFO, LOG_TAG, string);
}

static void win_delete_request_cb(void *data, Evas_Object *obj,
void *event_info) {
ui_app_exit();
Expand All @@ -80,6 +119,7 @@ static void win_back_cb(void *data, Evas_Object *obj, void *event_info) {

void clicked_cb(appdata_s *data, Evas_Object *obj, void *event_info) {
double val = elm_spinner_value_get(ad->spinner);
device_sound();
device_vibrate(val * 1000, 100);
}

Expand All @@ -89,9 +129,9 @@ static void create_base_gui(appdata_s *ad) {
elm_win_autodel_set(ad->win, EINA_TRUE);

if (elm_win_wm_rotation_supported_get(ad->win)) {
int rots[4] = {0, 90, 180, 270};
int rots[4] = { 0, 90, 180, 270 };
elm_win_wm_rotation_available_rotations_set(ad->win,
(const int *)(&rots), 4);
(const int *) (&rots), 4);
}

evas_object_smart_callback_add(ad->win, "delete,request",
Expand All @@ -101,7 +141,7 @@ static void create_base_gui(appdata_s *ad) {

ad->conformant = elm_conformant_add(ad->win);
evas_object_size_hint_align_set(ad->conformant, EVAS_HINT_FILL,
EVAS_HINT_FILL);
EVAS_HINT_FILL);
elm_win_resize_object_add(ad->win, ad->conformant);
evas_object_show(ad->conformant);

Expand All @@ -110,7 +150,7 @@ static void create_base_gui(appdata_s *ad) {
evas_object_show(ad->grid);

ad->time = elm_label_add(ad->grid);
elm_grid_pack(ad->grid, ad->time, 30, 25, 40, 10);
elm_grid_pack(ad->grid, ad->time, 30, 20, 40, 10);
char t[50] = "<align=center>";
strcat(t, i18n_get_text("Time"));
strcat(t, "</align>");
Expand All @@ -119,17 +159,17 @@ static void create_base_gui(appdata_s *ad) {

ad->surface = eext_circle_surface_conformant_add(ad->conformant);

ad->circle_progressbar =
eext_circle_object_progressbar_add(ad->grid, ad->surface);
ad->circle_progressbar = eext_circle_object_progressbar_add(ad->grid,
ad->surface);
eext_circle_object_value_min_max_set(ad->circle_progressbar, 0, 100);
eext_circle_object_value_set(ad->circle_progressbar, 100);
elm_grid_pack(ad->grid, ad->circle_progressbar, 30, 35, 40, 10);

ad->spinner = elm_spinner_add(ad->grid);
elm_grid_pack(ad->grid, ad->spinner, 30, 35, 40, 10);
elm_grid_pack(ad->grid, ad->spinner, 30, 40, 40, 10);
elm_object_style_set(ad->spinner, "circle");
ad->circle_spinner =
eext_circle_object_spinner_add(ad->spinner, ad->surface);
ad->circle_spinner = eext_circle_object_spinner_add(ad->spinner,
ad->surface);
elm_spinner_min_max_set(ad->spinner, 1, 60);
elm_spinner_value_set(ad->spinner, 5);
eext_circle_object_spinner_angle_set(ad->circle_spinner, 6);
Expand All @@ -138,6 +178,10 @@ static void create_base_gui(appdata_s *ad) {
eext_circle_object_color_set(ad->circle_spinner, 0, 0, 0, 0);
evas_object_show(ad->spinner);

elm_object_focus_allow_set(ad->circle_spinner, EINA_TRUE);

elm_object_focus_set(ad->circle_spinner, EINA_TRUE);

ad->label = elm_label_add(ad->grid);
elm_grid_pack(ad->grid, ad->label, 35, 45, 30, 10);
evas_object_show(ad->label);
Expand All @@ -158,13 +202,17 @@ static bool app_create(void *data) {
return true;
}

static void app_control(app_control_h app_control, void *data) {}
static void app_control(app_control_h app_control, void *data) {
}

static void app_pause(void *data) {}
static void app_pause(void *data) {
}

static void app_resume(void *data) {}
static void app_resume(void *data) {
}

static void app_terminate(void *data) {}
static void app_terminate(void *data) {
}

static void ui_app_lang_changed(app_event_info_h event_info, void *user_data) {
char *locale = NULL;
Expand All @@ -177,31 +225,27 @@ static void ui_app_lang_changed(app_event_info_h event_info, void *user_data) {
return;
}

static void ui_app_orient_changed(app_event_info_h event_info,
void *user_data) {
static void ui_app_orient_changed(app_event_info_h event_info, void *user_data) {
create_base_gui(ad);
return;
}

static void ui_app_region_changed(app_event_info_h event_info,
void *user_data) {}
static void ui_app_region_changed(app_event_info_h event_info, void *user_data) {
}

static void ui_app_low_battery(app_event_info_h event_info, void *user_data) {}
static void ui_app_low_battery(app_event_info_h event_info, void *user_data) {
}

static void ui_app_low_memory(app_event_info_h event_info, void *user_data) {}
static void ui_app_low_memory(app_event_info_h event_info, void *user_data) {
}

int main(int argc, char *argv[]) {
appdata_s ad = {
0,
};
appdata_s ad = { 0, };
int ret = 0;

ui_app_lifecycle_callback_s event_callback = {
0,
};
ui_app_lifecycle_callback_s event_callback = { 0, };
app_event_handler_h handlers[5] = {
NULL,
};
NULL, };

event_callback.create = app_create;
event_callback.terminate = app_terminate;
Expand Down
2 changes: 1 addition & 1 deletion tizen-manifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<manifest xmlns="http://tizen.org/ns/packages" api-version="2.3.2" package="com.vadvergasov.watercleaner" version="2.0.0">
<manifest xmlns="http://tizen.org/ns/packages" api-version="2.3.2" package="com.vadvergasov.watercleaner" version="2.1.0">
<author email="[email protected]">VadVergasov</author>
<description>This app will help you to clean the watches after swimming.</description>
<profile name="wearable"/>
Expand Down

0 comments on commit f4fe420

Please sign in to comment.