navibar.cc 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. #pragma once
  2. #include "uart/ProtocolSender.h"
  3. #include <sys/reboot.h>
  4. #include "app/Activity.h"
  5. #include "service/BusinessConfig.h"
  6. #include "net/NetManager.h"
  7. #include "core/sip_config.h"
  8. #include "core/utilities.h"
  9. /*
  10. *此文件由GUI工具生成
  11. *文件功能:用于处理用户的逻辑相应代码
  12. *功能说明:
  13. *========================onButtonClick_XXXX
  14. 当页面中的按键按下后系统会调用对应的函数,XXX代表GUI工具里面的[标识]名称,
  15. 如Button1,当返回值为false的时候系统将不再处理这个按键,返回true的时候系统将会继续处理此按键。比如SYS_BACK.
  16. *========================onSlideWindowItemClick_XXXX(int index)
  17. 当页面中存在滑动窗口并且用户点击了滑动窗口的图标后系统会调用此函数,XXX代表GUI工具里面的[标识]名称,
  18. 如slideWindow1;index 代表按下图标的偏移值
  19. *========================onSeekBarChange_XXXX(int progress)
  20. 当页面中存在滑动条并且用户改变了进度后系统会调用此函数,XXX代表GUI工具里面的[标识]名称,
  21. 如SeekBar1;progress 代表当前的进度值
  22. *========================ogetListItemCount_XXXX()
  23. 当页面中存在滑动列表的时候,更新的时候系统会调用此接口获取列表的总数目,XXX代表GUI工具里面的[标识]名称,
  24. 如List1;返回值为当前列表的总条数
  25. *========================oobtainListItemData_XXXX(ZKListView::ZKListItem *pListItem, int index)
  26. 当页面中存在滑动列表的时候,更新的时候系统会调用此接口获取列表当前条目下的内容信息,XXX代表GUI工具里面的[标识]名称,
  27. 如List1;pListItem 是贴图中的单条目对象,index是列表总目的偏移量。具体见函数说明
  28. *========================常用接口===============
  29. *LOGD(...) 打印调试信息的接口
  30. *mTextXXX->setText("****") 在控件TextXXX上显示文字****
  31. *mButton1->setSelected(true); 将控件mButton1设置为选中模式,图片会切换成选中图片,按钮文字会切换为选中后的颜色
  32. *mSeekBar->setProgress(12) 在控件mSeekBar上将进度调整到12
  33. *mListView1->refreshListView() 让mListView1 重新刷新,当列表数据变化后调用
  34. *mDashbroadView1->setTargetAngle(120) 在控件mDashbroadView1上指针显示角度调整到120度
  35. */
  36. static uint32_t navibarButtonColor = buleDeepColour;
  37. void setNavibarTheme() {
  38. int themeInt = StoragePreferences::getInt(STORE_THEME, defaultThemeInt);
  39. if (themeInt == 1) {
  40. mBgPainterPtr->setBackgroundPic("/navibar/bg.png");
  41. mHelpButtonPtr->setButtonStatusPic(ZK_CONTROL_STATUS_NORMAL, "/button/square_bule.png");
  42. navibarButtonColor = buleDeepColour;
  43. mHomeButtonPtr->setTextColor(navibarButtonColor);
  44. }
  45. else if (themeInt == 2) {
  46. mBgPainterPtr->setBackgroundPic("/navibar/bg-pink.png");
  47. mHelpButtonPtr->setButtonStatusPic(ZK_CONTROL_STATUS_NORMAL, "/button/square_pink.png");
  48. navibarButtonColor = redDeepColour;
  49. mHomeButtonPtr->setTextColor(navibarButtonColor);
  50. }
  51. }
  52. void goHome() {
  53. mHomeButtonPtr->setBackgroundPic("button/elliptic_white.png");
  54. mHomeButtonPtr->setTextColor(navibarButtonColor);
  55. mHealthCareButtonPtr->setBackgroundPic("");
  56. mHealthCareButtonPtr->setTextColor(whiteColour);
  57. mMoreButtonPtr->setBackgroundPic("");
  58. mMoreButtonPtr->setTextColor(whiteColour);
  59. EASYUICONTEXT->openActivity("mainActivity");
  60. EASYUICONTEXT->closeActivity("moreActivity");
  61. EASYUICONTEXT->closeActivity("medicalCareActivity");
  62. }
  63. void goMore() {
  64. mHomeButtonPtr->setBackgroundPic("");
  65. mHomeButtonPtr->setTextColor(whiteColour);
  66. mHealthCareButtonPtr->setBackgroundPic("");
  67. mHealthCareButtonPtr->setTextColor(whiteColour);
  68. mMoreButtonPtr->setBackgroundPic("button/elliptic_white.png");
  69. mMoreButtonPtr->setTextColor(navibarButtonColor);
  70. EASYUICONTEXT->openActivity("moreActivity");
  71. // EASYUICONTEXT->closeActivity("mainActivity");
  72. EASYUICONTEXT->closeActivity("medicalCareActivity");
  73. }
  74. void goCare() {
  75. mHomeButtonPtr->setBackgroundPic("");
  76. mHomeButtonPtr->setTextColor(whiteColour);
  77. mHealthCareButtonPtr->setBackgroundPic("button/elliptic_white.png");
  78. mHealthCareButtonPtr->setTextColor(navibarButtonColor);
  79. mMoreButtonPtr->setBackgroundPic("");
  80. mMoreButtonPtr->setTextColor(whiteColour);
  81. EASYUICONTEXT->openActivity("medicalCareActivity");
  82. // EASYUICONTEXT->closeActivity("mainActivity");
  83. EASYUICONTEXT->closeActivity("moreActivity");
  84. }
  85. //void callBedButtonSetVisible() {
  86. // if (mnavibarPtr == NULL) {
  87. // return;
  88. // }
  89. //
  90. // int roomCallBed = StoragePreferences::getInt(STORE_ROOM_CALL_BED, 1);
  91. // if (!roomCallBed) {
  92. // // 如果roomCallBed是0的话,那就隐藏
  93. // mCallBedButtonPtr->setVisible(roomCallBed);
  94. // mCallBedPicPainterPtr->setVisible(roomCallBed);
  95. //
  96. // mHelpButtonPtr->setPosition(LayoutPosition(11, 374, 96, 96));
  97. // mHelpPicPainterPtr->setPosition(LayoutPosition(46, 396, 27, 27));
  98. // mCallNurseButtonPtr->setPosition(LayoutPosition(11, 482, 96, 96));
  99. // mCallNursePicPainterPtr->setPosition(LayoutPosition(45, 504, 29, 27));
  100. //
  101. // }
  102. // else {
  103. // // 如果roomCallBed是1的话,那就显示
  104. // mCallBedButtonPtr->setVisible(roomCallBed);
  105. // mCallBedPicPainterPtr->setVisible(roomCallBed);
  106. //
  107. // mHelpButtonPtr->setPosition(LayoutPosition(11, 265, 96, 96));
  108. // mHelpPicPainterPtr->setPosition(LayoutPosition(43, 287, 32, 26));
  109. // mCallNurseButtonPtr->setPosition(LayoutPosition(11, 374, 96, 96));
  110. // mCallNursePicPainterPtr->setPosition(LayoutPosition(46, 396, 27, 27));
  111. // }
  112. //}
  113. /**
  114. * 注册定时器
  115. * 填充数组用于注册定时器
  116. * 注意:id不能重复
  117. */
  118. static S_ACTIVITY_TIMEER REGISTER_ACTIVITY_TIMER_TAB[] = {
  119. //{0, 6000}, //定时器id=0, 时间间隔6秒
  120. //{1, 1000},
  121. };
  122. /**
  123. * 当界面构造时触发
  124. */
  125. static void onUI_init(){
  126. //Tips :添加 UI初始化的显示代码到这里,如:mText1->setText("123");
  127. // callBedButtonSetVisible();
  128. setNavibarTheme();
  129. }
  130. /*
  131. * 当界面完全退出时触发
  132. */
  133. static void onUI_quit() {
  134. }
  135. /**
  136. * 串口数据回调接口
  137. */
  138. static void onProtocolDataUpdate(const SProtocolData &data) {
  139. //串口数据回调接口
  140. }
  141. /**
  142. * 定时器触发函数
  143. * 不建议在此函数中写耗时操作,否则将影响UI刷新
  144. * 参数: id
  145. * 当前所触发定时器的id,与注册时的id相同
  146. * 返回值: true
  147. * 继续运行当前定时器
  148. * false
  149. * 停止运行当前定时器
  150. */
  151. static bool onUI_Timer(int id){
  152. switch (id) {
  153. default:
  154. break;
  155. }
  156. return true;
  157. }
  158. /**
  159. * 有新的触摸事件时触发
  160. * 参数:ev
  161. * 新的触摸事件
  162. * 返回值:true
  163. * 表示该触摸事件在此被拦截,系统不再将此触摸事件传递到控件上
  164. * false
  165. * 触摸事件将继续传递到控件上
  166. */
  167. static bool onnavibarActivityTouchEvent(const MotionEvent &ev) {
  168. switch (ev.mActionStatus) {
  169. case MotionEvent::E_ACTION_DOWN://触摸按下
  170. //LOGD("时刻 = %ld 坐标 x = %d, y = %d", ev.mEventTime, ev.mX, ev.mY);
  171. break;
  172. case MotionEvent::E_ACTION_MOVE://触摸滑动
  173. break;
  174. case MotionEvent::E_ACTION_UP: //触摸抬起
  175. break;
  176. default:
  177. break;
  178. }
  179. return false;
  180. }
  181. static bool onButtonClick_HomeButton(ZKButton *pButton) {
  182. LOGD(" ButtonClick HomeButton !!!\n");
  183. if (getAuthItId() != 0) {
  184. Intent* intent = new Intent();
  185. intent->putExtra(functionWindows, "logoutMedicalCare");
  186. intent->putExtra(goActivity, "home");
  187. EASYUICONTEXT->openActivity("functionActivity", intent);
  188. } else {
  189. goHome();
  190. }
  191. return false;
  192. }
  193. static bool onButtonClick_HealthCareButton(ZKButton *pButton) {
  194. LOGD(" ButtonClick HealthCareButton !!!\n");
  195. goCare();
  196. return false;
  197. }
  198. static bool onButtonClick_MoreButton(ZKButton *pButton) {
  199. LOGD(" ButtonClick MoreButton !!!\n");
  200. if (getAuthItId() != 0) {
  201. Intent* intent = new Intent();
  202. intent->putExtra(functionWindows, "logoutMedicalCare");
  203. intent->putExtra(goActivity, "more");
  204. EASYUICONTEXT->openActivity("functionActivity", intent);
  205. } else {
  206. goMore();
  207. }
  208. return false;
  209. }
  210. static bool onButtonClick_HelpButton(ZKButton *pButton) {
  211. LOGD(" ButtonClick HelpButton !!!\n");
  212. TcpModel tcpModel;
  213. tcpModel.type = TcpType::REINFORCE;
  214. tcpModel.action = ReinforceAction::CALL;
  215. tcpModel.from_id = StoragePreferences::getInt(STORE_DEVICE_ID,0);
  216. tcpModel.to_id = 0;
  217. sendTcpModel(tcpModel);
  218. Intent* intent = new Intent();
  219. intent->putExtra(functionWindows, "help");
  220. EASYUICONTEXT->openActivity("functionActivity", intent);
  221. return false;
  222. }
  223. static bool onButtonClick_CallNurseButton(ZKButton *pButton) {
  224. LOGD(" ButtonClick CallNurseButton !!!\n");
  225. if (StoragePreferences::getString(STORE_SIGNAL_TYPE, SIGNAL_TYPE) == "SIP"){
  226. int port = StoragePreferences::getInt(SIP_REG_PORT, SIP_REG_PORT_DEFAULT);
  227. std::string domain = StoragePreferences::getString(SIP_REG_DOMAIN, SIP_REG_DOMAIN_DEFAULT);
  228. std::string od_number = StoragePreferences::getString(SIP_REG_DOOR_ACCOUNT, SIP_REG_DOOR_ACCOUNT_DEFAULT);
  229. std::string od_number_uri = URI(od_number, domain, port);
  230. LOGD("od_number_uri: %s", od_number_uri.c_str());
  231. GetTelephone()->MakeCall(od_number_uri);
  232. } else {
  233. Intent* intent = new Intent();
  234. intent->putExtra(callActivityType, "fromCall");
  235. EASYUICONTEXT->openActivity("callActivity", intent);
  236. }
  237. return false;
  238. }
  239. static bool onButtonClick_CallCancelButton(ZKButton *pButton) {
  240. LOGD(" ButtonClick CallCancelButton !!!\n");
  241. // 发送tcp, tcp_type = VOICE, tcp_action = CANCEL_BY_DOOR
  242. TcpModel tcpModel;
  243. tcpModel.tid = base::format("t%d",TimeHelper::getCurrentTime());
  244. tcpModel.type = TcpType::VOICE;
  245. tcpModel.action = VoiceAction::CANCEL_BY_DOOR;
  246. tcpModel.from_id = StoragePreferences::getInt(STORE_DEVICE_ID,0);
  247. std::string req = getTcpModelString(tcpModel);
  248. LOGD("TCP VOICE : %s",req.c_str());
  249. //回调注册
  250. TcpCallback callback;
  251. callback.tid = tcpModel.tid;
  252. callback.jsonStr = req;
  253. callback.onSuccess = [](Json::Value json){
  254. LOGD("side callback success");
  255. return 0;
  256. };
  257. callback.onFalied = [](Json::Value json){
  258. LOGD("side callback failed");
  259. return 0;
  260. };
  261. TcpClient::instance()->sendMsgWithCb(req.c_str(), callback);
  262. return false;
  263. }