242 lines
7.3 KiB
C
Executable File
242 lines
7.3 KiB
C
Executable File
/**
|
||
* @file setting.c
|
||
*
|
||
*/
|
||
|
||
/*********************
|
||
* INCLUDES
|
||
*********************/
|
||
#include "stdio.h"
|
||
#include "lvgl/lvgl.h"
|
||
#include "xos_app_conf.h"
|
||
#include "setting.h"
|
||
#include "unistd.h"
|
||
#ifdef XOS_USE_APP_MANAGER
|
||
#include "appcommon.h"
|
||
#include "appmanager.h"
|
||
#endif
|
||
#include "lvgl/src/misc/lv_ll.h"
|
||
#include "xos_misc.h"
|
||
#include "back_button.h"
|
||
#include "lang/xos_strid.h"
|
||
#ifdef CONFIG_XOS_USE_APP_AICAMERA
|
||
#include "../aicamera/config/conf.h"
|
||
#endif
|
||
#if CONFIG_XOS_USE_APP_AUDIO_PLAYER
|
||
#include "../prebuilts/audioplayer/inc/audioplayer_service.h"
|
||
#endif
|
||
#include "losplayer.h"
|
||
#include "menu_view.h"
|
||
#include "xos_string_ids.h"
|
||
#include "app_path_conf.h"
|
||
|
||
#if XOS_USE_APP_SETTING != 0
|
||
/**********************
|
||
* GLOBAL VARIABLES
|
||
**********************/
|
||
lv_app_setting_t g_app_setting = { NULL, NULL, NULL, false };
|
||
int setting_volume = 0;
|
||
static menu_info *setting_menu;
|
||
|
||
/**********************
|
||
* STATIC PROTOTYPES
|
||
**********************/
|
||
void setting_date_time_create_cb(lv_event_t *e);
|
||
void setting_reset_create_cb(lv_event_t *e);
|
||
void setting_shutdown_create_cb(lv_event_t *e);
|
||
void setting_upgrade_create_cb(lv_event_t *e);
|
||
void setting_about_create_cb(lv_event_t *e);
|
||
void setting_time_zone_create_cb(lv_event_t *e);
|
||
void setting_volume_create_cb(lv_event_t *e, char* value);
|
||
void setting_brightness_create_cb(char *tag, char *value, lv_event_t *e);
|
||
void setting_language_create_cb(lv_event_t *e, char* value);
|
||
void setting_wifi_connection_create_cb(lv_event_t *e, char* value);
|
||
|
||
void setting_entry(menu_info *menu)
|
||
{
|
||
#ifdef CONFIG_XOS_USE_APP_AICAMERA
|
||
#if defined(CONFIG_PRODUCT_KIDCAMERA) || defined(CONFIG_PRODUCT_MOMOTALK)
|
||
menu_view_create(menu, NULL, GetTextRes(STRID_LAUNCH_LAUNCHER_APP_SETTINGS), "setting");
|
||
#else
|
||
menu_view_create(menu, k_path_bg, GetTextRes(STRID_LAUNCH_LAUNCHER_APP_SETTINGS), "setting");
|
||
#endif
|
||
#else
|
||
menu_view_create(menu, NULL, GetTextRes(STRID_LAUNCH_LAUNCHER_APP_SETTINGS), "setting");
|
||
#endif
|
||
}
|
||
|
||
void setting_date_time_create_cb(lv_event_t *e)
|
||
{
|
||
XOS_LOGI("%s %d \n", __func__, __LINE__);
|
||
#if XOS_USE_APP_SETTING_DATE != 0
|
||
extern void setting_date_time_create_btn_action(lv_event_t *event);
|
||
setting_date_time_create_btn_action(e);
|
||
#endif
|
||
}
|
||
|
||
void setting_reset_create_cb(lv_event_t *e)
|
||
{
|
||
XOS_LOGI("%s %d \n", __func__, __LINE__);
|
||
#if XOS_USE_APP_SETTING_RESET != 0
|
||
extern void setting_reset_create_btn_action(lv_event_t *event);
|
||
setting_reset_create_btn_action(e);
|
||
#endif
|
||
}
|
||
|
||
void setting_shutdown_create_cb(lv_event_t *e)
|
||
{
|
||
XOS_LOGI("%s %d \n", __func__, __LINE__);
|
||
#if XOS_USE_APP_SETTING_ABOUT != 0
|
||
extern void setting_shutdown_create_btn_action(lv_event_t *event);
|
||
setting_shutdown_create_btn_action(e);
|
||
#endif
|
||
}
|
||
|
||
void setting_upgrade_create_cb(lv_event_t *e)
|
||
{
|
||
XOS_LOGI("%s %d \n", __func__, __LINE__);
|
||
#if XOS_USE_APP_SETTING_UPGRADE != 0
|
||
extern void setting_upgrade_create_btn_action(lv_event_t *event);
|
||
setting_upgrade_create_btn_action(e);
|
||
#endif
|
||
}
|
||
|
||
void setting_about_create_cb(lv_event_t *e)
|
||
{
|
||
XOS_LOGI("%s %d \n", __func__, __LINE__);
|
||
#if XOS_USE_APP_SETTING_SHUTDOWN != 0
|
||
extern void setting_about_create_btn_action(lv_event_t *event);
|
||
setting_about_create_btn_action(e);
|
||
#endif
|
||
}
|
||
|
||
void setting_time_zone_create_cb(lv_event_t *e)
|
||
{
|
||
XOS_LOGI("%s %d \n", __func__, __LINE__);
|
||
}
|
||
|
||
void setting_volume_create_cb(lv_event_t *e, char* value)
|
||
{
|
||
#ifdef CONFIG_XOS_FWK_PLAYER
|
||
#if CONFIG_XOS_USE_APP_AUDIO_PLAYER
|
||
if (0 == strcmp(value, "ID_CAMERA_HIGH")) {
|
||
audioplayer_service_set_volume_level(VOLUME_LEVEL_HIGH);
|
||
} else if (0 == strcmp(value, "ID_CAMERA_MID")) {
|
||
audioplayer_service_set_volume_level(VOLUME_LEVEL_MEDIUM);
|
||
} else if (0 == strcmp(value, "ID_CAMERA_LOW")) {
|
||
audioplayer_service_set_volume_level(VOLUME_LEVEL_LOW);
|
||
} else if (0 == strcmp(value, "ID_CAMERA_CLOSE")) {
|
||
audioplayer_service_set_volume_level(VOLUME_LEVEL_MUTE);
|
||
}
|
||
#else
|
||
if (0 == strcmp(value, "ID_CAMERA_HIGH")) {
|
||
xos_player_set_volume_level(NULL, VOLUME_LEVEL_HIGH);
|
||
} else if (0 == strcmp(value, "ID_CAMERA_MID")) {
|
||
xos_player_set_volume_level(NULL, VOLUME_LEVEL_MEDIUM);
|
||
} else if (0 == strcmp(value, "ID_CAMERA_LOW")) {
|
||
xos_player_set_volume_level(NULL, VOLUME_LEVEL_LOW);
|
||
} else if (0 == strcmp(value, "ID_CAMERA_CLOSE")) {
|
||
xos_player_set_volume_level(NULL, VOLUME_LEVEL_MUTE);
|
||
}
|
||
#endif
|
||
#endif
|
||
XOS_LOGI("%s %d \n", __func__, __LINE__);
|
||
}
|
||
|
||
void setting_format_create_cb(lv_event_t *e, char* value)
|
||
{
|
||
if (0 == strcmp(value, "ID_CAMERA_YES")) {
|
||
XOS_LOGI("用户选择格式化SD卡...\n");
|
||
#if !defined(BUILD_SIMULATOR) || BUILD_SIMULATOR == 0
|
||
extern int qm_format_sd();
|
||
int ret = qm_format_sd(); // 调用qm_format_sd执行SD卡格式化
|
||
if(ret == 0) {
|
||
XOS_LOGI("SD卡格式化成功!");
|
||
} else {
|
||
XOS_LOGI("SD卡格式化失败!");
|
||
}
|
||
#endif
|
||
} else if (0 == strcmp(value, "ID_CAMERA_NO")) {
|
||
XOS_LOGI("用户选择不格式化SD卡。\n");
|
||
}
|
||
|
||
XOS_LOGI("%s %d \n", __func__, __LINE__);
|
||
}
|
||
|
||
void setting_brightness_create_cb(char *tag, char *value, lv_event_t *e)
|
||
{
|
||
extern void setting_brightness_action(char *tag, char *value, lv_event_t *e);
|
||
setting_brightness_action(tag, value, e);
|
||
}
|
||
|
||
void setting_language_create_cb(lv_event_t *e, char* value)
|
||
{
|
||
XOS_LOGU("%s %d \n", __func__, __LINE__);
|
||
XOS_LOGU("language:%s \n", value);
|
||
extern lv_obj_t * setting_language_view_create(lv_obj_t * parent);
|
||
setting_language_view_create(lv_scr_act());
|
||
}
|
||
|
||
void setting_wifi_connection_create_cb(lv_event_t *e, char* value)
|
||
{
|
||
XOS_LOGU("%s %d \n", __func__, __LINE__);
|
||
XOS_LOGU("wifi connection\n");
|
||
#if XOS_USE_APP_SETTING_WIFI != 0
|
||
extern void setting_wifi_create_btn_action(lv_event_t *event);
|
||
setting_wifi_create_btn_action(e);
|
||
#endif
|
||
}
|
||
|
||
void setting_write_item(const char *item_id, int option_index) {
|
||
menu_param param = {0};
|
||
param.json_path = k_path_setting_json;
|
||
setting_menu = menu_init(¶m);
|
||
|
||
menu_update_item(setting_menu, item_id, option_index);
|
||
}
|
||
|
||
int setting_read_item(const char *item_id, int option_index, char *item_val) {
|
||
menu_param param = {0};
|
||
param.json_path = k_path_setting_json;
|
||
setting_menu = menu_init(¶m);
|
||
|
||
return menu_get_item_value(setting_menu, item_id, item_val);
|
||
}
|
||
|
||
char* setting_get_item_type(const char *item_id) {
|
||
menu_param param = {0};
|
||
param.json_path = k_path_setting_json;
|
||
setting_menu = menu_init(¶m);
|
||
|
||
return menu_get_item_type(setting_menu, item_id);
|
||
}
|
||
|
||
#ifdef XOS_USE_APP_MANAGER
|
||
static app_data_ptr los_setting_ui_init(void *start_data) {
|
||
menu_param* param = (menu_param*)start_data;
|
||
setting_menu = menu_init(param);
|
||
setting_entry(setting_menu);
|
||
menu_view_t *menu_view = menu_get_view();
|
||
g_app_setting.parent = menu_view->parent;
|
||
g_app_setting.panel = menu_view->panel;
|
||
g_app_setting.list = menu_view->list;
|
||
return NULL;
|
||
}
|
||
|
||
void setting_init(void) {
|
||
qua_app_ops *ops = malloc(sizeof(qua_app_ops));
|
||
if (ops) {
|
||
memset(ops, 0x0, sizeof(qua_app_ops));
|
||
ops->on_create = los_setting_ui_init;
|
||
app_manager_register("setting", ops);
|
||
free(ops);
|
||
}
|
||
settting_menu_img_table_init();
|
||
extern void xos_menu_text_table_init(void);
|
||
xos_menu_text_table_init();
|
||
}
|
||
#endif
|
||
|
||
#endif /*XOS_USE_APP_SETTING*/
|
||
|