#include "wearable_log.h"
#include "ui_resource_image.h"
#include "common/image_cache_manager.h"
-
+#include "uicomponents/UIComponents.h"
+#include "ui_resource_image.h"
+#include <sstream>
+#include <sys/time.h>
namespace OHOS {
static constexpr uint16_t POINT_POSITION_X = 202;
static constexpr uint16_t POINT_POSITION_Y = 16;
{
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AmbientClockView::~AmbientClockView");
if (viewiInitStatus_) {
- mainSweepClock_->RemoveAll();
- delete secondHand_;
- secondHand_ = nullptr;
- delete minuteHand_;
- minuteHand_ = nullptr;
- delete hourHand_;
- hourHand_ = nullptr;
- delete hand24Hour_;
- hand24Hour_ = nullptr;
- delete bigCircle_;
- bigCircle_ = nullptr;
- delete medCircle_;
- medCircle_ = nullptr;
- delete smallCircle_;
- smallCircle_ = nullptr;
- Remove(mainSweepClock_);
- delete mainSweepClock_;
- mainSweepClock_ = nullptr;
+ // mainSweepClock_->RemoveAll();
+ // delete secondHand_;
+ // secondHand_ = nullptr;
+ // delete minuteHand_;
+ // minuteHand_ = nullptr;
+ // delete hourHand_;
+ // hourHand_ = nullptr;
+ // delete hand24Hour_;
+ // hand24Hour_ = nullptr;
+ // delete bigCircle_;
+ // bigCircle_ = nullptr;
+ // delete medCircle_;
+ // medCircle_ = nullptr;
+ // delete smallCircle_;
+ // smallCircle_ = nullptr;
+ // Remove(mainSweepClock_);
+ // delete mainSweepClock_;
+ // mainSweepClock_ = nullptr;
+
+ delete timerlabel;
+ timerlabel = nullptr;
}
}
bool AmbientClockView::InitView(void)
{
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AmbientClockView::InitView");
-
- mainSweepClock_ = new UISweepClock();
- if (mainSweepClock_ == nullptr) {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mainSweepClock new fail");
- return false;
+ //只显示时间 使用数字
+ if (timerlabel == nullptr) {
+ timerlabel = new UILabel();
}
- if (!InitSweepClock()) {
- return false;
- }
-
- Add(mainSweepClock_);
+ timerlabel->SetPosition(58, 108); // widget's left position and top position
+ timerlabel->Resize(350, 250); // widget's width and height
+ timerlabel->SetViewId("label1");// Set style
+ timerlabel->SetStyle(STYLE_TEXT_FONT, 130);
- mainSweepClock_->SetDragParentInstead(true);
- mainSweepClock_->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
+ // Set additional property
+ timerlabel->SetText("12:00");
+ timerlabel->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);
+ timerlabel->SetTextColor(Color::GetColorFromRGBA(0x69, 0x69, 0x69, 0xff));
+ timerlabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+ timerlabel->SetRollSpeed(0);
+ timerlabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 130);
- // {214, 3}: position x, y {14, 223}: center x, y
- mainSweepClock_->SetHandImage(UISweepClock::HandType::SECOND_HAND, *secondHand_,
- { POINT_POSITION_X, SECOND_POINT_POSITION_Y }, { POINT_CENTER_X, POINT_CENTER_Y });
- mainSweepClock_->SetHandImage(UISweepClock::HandType::MINUTE_HAND, *minuteHand_,
- { POINT_POSITION_X, POINT_POSITION_Y }, { POINT_CENTER_X, POINT_CENTER_Y });
- mainSweepClock_->SetHandImage(UISweepClock::HandType::HOUR_HAND, *hourHand_, { POINT_POSITION_X, POINT_POSITION_Y },
- { POINT_CENTER_X, POINT_CENTER_Y });
- mainSweepClock_->SetHandCircleImage(UISweepClock::HandType::SECOND_HAND, *smallCircle_,
- { SMALLCIRCLE_POSITION_X, SMALLCIRCLE_POSITION_Y });
- mainSweepClock_->SetHandCircleImage(UISweepClock::HandType::MINUTE_HAND, *medCircle_,
- { MEDCIRCLE_POSITION_X, MEDCIRCLE_POSITION_Y });
- mainSweepClock_->SetHandCircleImage(UISweepClock::HandType::HOUR_HAND, *bigCircle_,
- { BIGCIRCLE_POSITION_X, BIGCIRCLE_POSITION_Y });
+ Add(timerlabel);
- mainSweepClock_->SetInitTime24Hour(0, 0, 0);
- mainSweepClock_->SetWorkMode(UISweepClock::WorkMode::NORMAL);
- InitDateTime();
SetCoverable(true);
+
return true;
}
time_t seconds;
time(&seconds);
localtime_r(&seconds, &pTM);
- mainSweepClock_->SetTime24Hour(pTM.tm_hour, pTM.tm_min, pTM.tm_sec);
+ // mainSweepClock_->SetTime24Hour(pTM.tm_hour, pTM.tm_min, pTM.tm_sec);
}
void AmbientClockView::UpdateTime(void)
uint8_t realMinute = static_cast<uint8_t>(minute % MIN_TO_HOUR);
uint16_t realMilliSecond = static_cast<uint16_t>((second % MIN_TO_HOUR) *
SEC_TO_MILLI + uSecond / USEC_TO_MILLI);
- mainSweepClock_->SetSweepTime12Hour(realHour, realMinute, realMilliSecond, 1);
+
+ // if (timerlabel != nullptr) {
+ // std::stringstream ss;
+ // ss.fill('0');
+
+ // ss << std::setw(2) << realHour << ":";
+ // ss << std::setw(2) << realMinute;
+
+ // timerlabel->SetText(ss.str().c_str());
+ // }
+ if(timerlabel == nullptr)
+ return;
+
+ timerlabel->SetText((std::to_string(realHour) + ":" + std::to_string(realMinute)).c_str());
}
}
#include "securec.h"
#include "set_dial/include/SetDialModelC.h"
// #include "system/include/SystemLogModel.h"
+#include "graphic_service.h"
#include "wearable_log.h"
#include <algorithm>
#include <array>
#include <sys/stat.h>
#include <unistd.h>
#include <unordered_set>
-#include "graphic_service.h"
extern "C" {
void check_dial_space() { OHOS::SetDialModel::GetInstance().CheckDialSpace(); }
}
void SetDialModel::LoadAllDial() {
dialInfoList.clear();
size_t dialSize = dialInfoList.size();
+ size_t aodSize = aodDialInfoList.size();
// 加载默认表盘
LoadAllDialFromDefult();
// 加载自定义表盘
char dialId[128];
GetAllDialIDs(dialId, 128);
PrintRegisteredDials(registeredDials);
+
+ std::sort(aodDialInfoList.begin() + aodSize,
+ aodDialInfoList.end(),
+ [](const SetDialInfo &f, const SetDialInfo &n) { return f.dialName < n.dialName; });
}
/*加载离线表盘*/
void SetDialModel::LoadAllDialFromFs() {
SetDialInfo dialInfo{0};
int ret = ParseDialHeader(DOWNLOADDIAL, direntp->d_name, dialInfo);
if (ret == 0) {
- dialInfoList.push_back(dialInfo);
+ if (dialInfo.capability == DIAL_DISPLAY_CAPABILITY_NORMAL_ONLY) {
+ dialInfoList.push_back(dialInfo);
+ } else if (dialInfo.capability ==
+ DIAL_DISPLAY_CAPABILITY_AMBITIENT_ONLY) {
+ aodDialInfoList.push_back(dialInfo);
+ } else {
+ dialInfoList.push_back(dialInfo);
+ aodDialInfoList.push_back(dialInfo);
+ }
downloadnum++;
}
}
if (ret == 0) {
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Adding dial %s",
fullDialName.c_str());
- dialInfoList.push_back(dialInfo);
+ if (dialInfo.capability == DIAL_DISPLAY_CAPABILITY_NORMAL_ONLY) {
+ dialInfoList.push_back(dialInfo);
+ } else if (dialInfo.capability ==
+ DIAL_DISPLAY_CAPABILITY_AMBITIENT_ONLY) {
+ aodDialInfoList.push_back(dialInfo);
+ } else {
+ dialInfoList.push_back(dialInfo);
+ aodDialInfoList.push_back(dialInfo);
+ }
} else {
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
"ParseDialHeader is error for file %s",
dialInfo.dialFlag = 1;
dialInfo.id = 0;
+ dialInfo.resId = preInfo.imgId;
dialInfo.dialFullName = dialFullName;
dialInfo.dialName = preInfo.dialName;
dialInfo.description = preInfo.description;
dialInfo.preImageInfo = info;
+ dialInfo.capability = preInfo.capability;
fclose(fp);
return 0;
std::vector<SetDialInfo> &SetDialModel::GetDialInfo(void) {
return dialInfoList;
}
+std::vector<SetDialInfo>& SetDialModel::GetAmbientDialInfo(void)
+{
+ return aodDialInfoList;
+}
+void SetDialModel::ClearDialInfo(void)
+{
+ for (auto iter : dialInfoList) {
+ if (iter.dialFlag) {
+ ImageCacheManager::GetInstance().UnloadOneInMultiRes(iter.resId, iter.dialFullName);
+ } else {
+ ImageCacheManager::GetInstance().UnloadSingleRes(iter.imageFullName);
+ }
+ }
+ dialInfoList.clear();
+ aodDialInfoList.clear();
+}
uint8_t SetDialModel::GetPageIndex(void) {
uint8_t index = 0;
// 设置图像信息
dialInfo.preImageInfo = imageInfo;
- // 添加到表盘列表
dialInfoList.push_back(dialInfo);
// 注册到map
#endif /* __cplusplus */
#endif /* __cplusplus */
-
-uint8_t get_dial_num_()
-{
- return OHOS::SetDialModel::GetInstance().GetDialCount();
+uint8_t get_dial_num_() {
+ return OHOS::SetDialModel::GetInstance().GetDialCount();
}
-bool check_dial_freespace_(uint16_t id,uint32_t dial_size) {
- return OHOS::SetDialModel::GetInstance().CheckDialDownload(id,dial_size);
+bool check_dial_freespace_(uint16_t id, uint32_t dial_size) {
+ return OHOS::SetDialModel::GetInstance().CheckDialDownload(id, dial_size);
}
-void ble_get_dial_path_(char * buf,uint16_t id)
-{
- char *path= (char*)OHOS::SetDialModel::GetInstance().GetSaveDir(id,0).c_str();
- memcpy(buf,path,strlen(path)+1);
- return;
+void ble_get_dial_path_(char *buf, uint16_t id) {
+ char *path =
+ (char *)OHOS::SetDialModel::GetInstance().GetSaveDir(id, 0).c_str();
+ memcpy(buf, path, strlen(path) + 1);
+ return;
}
-void ble_save_dial_custom_(msg_recv_custom_dial_info_t *data)
-{
- OHOS:: DialLayout info;
- info.dialId=data->dial_uid;
- info.batteryDisplay=data->battery;
- info.timeDisplay=data->time;
- info.colorTypeSet=data->time_font;
- OHOS::SetDialModel::GetInstance().saveDialConfig(info);
+void ble_save_dial_custom_(msg_recv_custom_dial_info_t *data) {
+ OHOS::DialLayout info;
+ info.dialId = data->dial_uid;
+ info.batteryDisplay = data->battery;
+ info.timeDisplay = data->time;
+ info.colorTypeSet = data->time_font;
+ OHOS::SetDialModel::GetInstance().saveDialConfig(info);
}
-void ble_set_dial_by_id__(uint16_t id)
-{
- // printf("ble_set_dial_by_id_ %d\n",id);
- OHOS::SetDialModel::GetInstance().UpdateDialSetting(id);
-
+void ble_set_dial_by_id__(uint16_t id) {
+ // printf("ble_set_dial_by_id_ %d\n",id);
+ OHOS::SetDialModel::GetInstance().UpdateDialSetting(id);
}
-void ble_set_dial_by_id_(uint16_t id)
-{
- // printf("ble_set_dial_by_id %d\n",id);
- GraphicService::GetInstance()->PostGraphicEvent(
- std::bind(ble_set_dial_by_id__ ,id));
+void ble_set_dial_by_id_(uint16_t id) {
+ // printf("ble_set_dial_by_id %d\n",id);
+ GraphicService::GetInstance()->PostGraphicEvent(
+ std::bind(ble_set_dial_by_id__, id));
}
-void ble_get_custom_dial_(uint16_t id,char *buf)
-{
- const char *name=OHOS::SetDialModel::GetInstance().GetCustomName(id).c_str();
- memset_s(buf,32,0,32);
- memcpy_s(buf,32,name,strlen(name));
+void ble_get_custom_dial_(uint16_t id, char *buf) {
+ const char *name =
+ OHOS::SetDialModel::GetInstance().GetCustomName(id).c_str();
+ memset_s(buf, 32, 0, 32);
+ memcpy_s(buf, 32, name, strlen(name));
}
-uint16_t ble_get_dial_id_(void)
-{
- uint16_t id= OHOS::SetDialModel::GetInstance().GetCurrentDialID();
- return id;
+uint16_t ble_get_dial_id_(void) {
+ uint16_t id = OHOS::SetDialModel::GetInstance().GetCurrentDialID();
+ return id;
}
-bool ble_is_dial_install_by_id_(uint16_t id)
-{
- return OHOS::SetDialModel::GetInstance().IsDialInstalled(id);
+bool ble_is_dial_install_by_id_(uint16_t id) {
+ return OHOS::SetDialModel::GetInstance().IsDialInstalled(id);
}
////////////////////////////////////////////////////////
-int ble_get_dial_num_(void)
-{
- return OHOS::SetDialModel::GetInstance().GetDialCount();
+int ble_get_dial_num_(void) {
+ return OHOS::SetDialModel::GetInstance().GetDialCount();
}
-void ble_delete_dial__(uint16_t id)
-{
- OHOS::SetDialModel::GetInstance().UninstallDial(id);
+void ble_delete_dial__(uint16_t id) {
+ OHOS::SetDialModel::GetInstance().UninstallDial(id);
}
-bool ble_delete_dial_(uint16_t id)
-{
+bool ble_delete_dial_(uint16_t id) {
- if(id==OHOS::SetDialModel::GetInstance().GetCurrentDialID())
+ if (id == OHOS::SetDialModel::GetInstance().GetCurrentDialID())
return false;
- else
- {
- switch (id) {
- case OHOS::DEFAULT_DIAL_ID:
- case OHOS::MAX_DEFAULT_DIAL_ID:
- case OHOS::DEFAULT_DIAL_ID_0:
- case OHOS::DEFAULT_DIAL_ID_1:
- case OHOS::DEFAULT_DIAL_ID_2:
- case OHOS::DEFAULT_DIAL_ID_3:
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
- "UninstallDial: Default dial %d cannot be uninstalled", id);
- return false;
- }
- GraphicService::GetInstance()->PostGraphicEvent(
- std::bind(ble_delete_dial__,id));
- return true;
+ else {
+ switch (id) {
+ case OHOS::DEFAULT_DIAL_ID:
+ case OHOS::MAX_DEFAULT_DIAL_ID:
+ case OHOS::DEFAULT_DIAL_ID_0:
+ case OHOS::DEFAULT_DIAL_ID_1:
+ case OHOS::DEFAULT_DIAL_ID_2:
+ case OHOS::DEFAULT_DIAL_ID_3:
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+ "UninstallDial: Default dial %d cannot be uninstalled", id);
+ return false;
}
-
+ GraphicService::GetInstance()->PostGraphicEvent(
+ std::bind(ble_delete_dial__, id));
+ return true;
+ }
}
-int get_all_dial_id_( char * buf,uint16_t MAX_LEN)
-{
- return OHOS::SetDialModel::GetInstance().GetAllDialIDs(buf,MAX_LEN);
+int get_all_dial_id_(char *buf, uint16_t MAX_LEN) {
+ return OHOS::SetDialModel::GetInstance().GetAllDialIDs(buf, MAX_LEN);
}
-bool dial_file_save_(void )
-{
- return OHOS::SetDialModel::GetInstance().saveDialfile();
+bool dial_file_save_(void) {
+ return OHOS::SetDialModel::GetInstance().saveDialfile();
}
-void install_Register_dial__( char * name,uint16_t id)
-{
- OHOS::SetDialModel::GetInstance().RegisterDial(id,name,0);
-
+void install_Register_dial__(char *name, uint16_t id) {
+ OHOS::SetDialModel::GetInstance().RegisterDial(id, name, 0);
}
-void install_Register_dial_( char * name,uint16_t id)
-{
- GraphicService::GetInstance()->PostGraphicEvent(
- std::bind(install_Register_dial__,name ,id));
- return ;
-
+void install_Register_dial_(char *name, uint16_t id) {
+ GraphicService::GetInstance()->PostGraphicEvent(
+ std::bind(install_Register_dial__, name, id));
+ return;
}
extern bleInstruct_t_ bleInstruct_t;
-void ble_dial_init(void)
-{
- bleInstruct_t.get_dial_num_cb= get_dial_num_;
- bleInstruct_t.check_dial_freespace= check_dial_freespace_;
- bleInstruct_t.ble_get_dial_path= ble_get_dial_path_;
- bleInstruct_t. ble_save_dial_custom=ble_save_dial_custom_;
-
- bleInstruct_t. ble_set_dial_by_id=ble_set_dial_by_id_;
+void ble_dial_init(void) {
+ bleInstruct_t.get_dial_num_cb = get_dial_num_;
+ bleInstruct_t.check_dial_freespace = check_dial_freespace_;
+ bleInstruct_t.ble_get_dial_path = ble_get_dial_path_;
+ bleInstruct_t.ble_save_dial_custom = ble_save_dial_custom_;
+ bleInstruct_t.ble_set_dial_by_id = ble_set_dial_by_id_;
- bleInstruct_t. ble_get_custom_dial= ble_get_custom_dial_;
- bleInstruct_t. ble_get_dial_id = ble_get_dial_id_;
- bleInstruct_t. ble_is_dial_install_by_id =ble_is_dial_install_by_id_;
+ bleInstruct_t.ble_get_custom_dial = ble_get_custom_dial_;
+ bleInstruct_t.ble_get_dial_id = ble_get_dial_id_;
+ bleInstruct_t.ble_is_dial_install_by_id = ble_is_dial_install_by_id_;
////////////////////////////////////////////////////////
- bleInstruct_t. ble_get_dial_num=ble_get_dial_num_;
- bleInstruct_t. ble_delete_dial=ble_delete_dial_;
- bleInstruct_t. get_all_dial_id=get_all_dial_id_;
- bleInstruct_t. dial_file_save=dial_file_save_;
- bleInstruct_t.install_Register_dial= install_Register_dial_;
-
+ bleInstruct_t.ble_get_dial_num = ble_get_dial_num_;
+ bleInstruct_t.ble_delete_dial = ble_delete_dial_;
+ bleInstruct_t.get_all_dial_id = get_all_dial_id_;
+ bleInstruct_t.dial_file_save = dial_file_save_;
+ bleInstruct_t.install_Register_dial = install_Register_dial_;
}
#ifdef __cplusplus
#endif /* __cplusplus */
#endif /* __cplusplus */
-
#endif
} // namespace OHOS