navibar.cc 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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. else if (themeInt == 3) {
  52. mBgPainterPtr->setBackgroundPic("/navibar/bg-green.png");
  53. mHelpButtonPtr->setButtonStatusPic(ZK_CONTROL_STATUS_NORMAL, "/button/square_green2.png");
  54. navibarButtonColor = greenDeepColour;
  55. mHomeButtonPtr->setTextColor(navibarButtonColor);
  56. }
  57. }
  58. void goHome() {
  59. mHomeButtonPtr->setBackgroundPic("button/elliptic_white.png");
  60. mHomeButtonPtr->setTextColor(navibarButtonColor);
  61. mHealthCareButtonPtr->setBackgroundPic("");
  62. mHealthCareButtonPtr->setTextColor(whiteColour);
  63. mMoreButtonPtr->setBackgroundPic("");
  64. mMoreButtonPtr->setTextColor(whiteColour);
  65. EASYUICONTEXT->openActivity("mainActivity");
  66. EASYUICONTEXT->closeActivity("moreActivity");
  67. EASYUICONTEXT->closeActivity("medicalCareActivity");
  68. }
  69. void goMore() {
  70. mHomeButtonPtr->setBackgroundPic("");
  71. mHomeButtonPtr->setTextColor(whiteColour);
  72. mHealthCareButtonPtr->setBackgroundPic("");
  73. mHealthCareButtonPtr->setTextColor(whiteColour);
  74. mMoreButtonPtr->setBackgroundPic("button/elliptic_white.png");
  75. mMoreButtonPtr->setTextColor(navibarButtonColor);
  76. EASYUICONTEXT->openActivity("moreActivity");
  77. EASYUICONTEXT->closeActivity("mainActivity");
  78. EASYUICONTEXT->closeActivity("medicalCareActivity");
  79. }
  80. void goCare() {
  81. mHomeButtonPtr->setBackgroundPic("");
  82. mHomeButtonPtr->setTextColor(whiteColour);
  83. mHealthCareButtonPtr->setBackgroundPic("button/elliptic_white.png");
  84. mHealthCareButtonPtr->setTextColor(navibarButtonColor);
  85. mMoreButtonPtr->setBackgroundPic("");
  86. mMoreButtonPtr->setTextColor(whiteColour);
  87. EASYUICONTEXT->openActivity("medicalCareActivity");
  88. EASYUICONTEXT->closeActivity("mainActivity");
  89. EASYUICONTEXT->closeActivity("moreActivity");
  90. }
  91. void callBedButtonSetVisible() {
  92. if (mnavibarPtr == NULL) {
  93. return;
  94. }
  95. int roomCallBed = StoragePreferences::getInt(STORE_ROOM_CALL_BED, 1);
  96. if (!roomCallBed) {
  97. // 如果roomCallBed是0的话,那就隐藏
  98. mCallBedButtonPtr->setVisible(roomCallBed);
  99. mCallBedPicPainterPtr->setVisible(roomCallBed);
  100. mHelpButtonPtr->setPosition(LayoutPosition(10, 822, 77, 77));
  101. mHelpPicPainterPtr->setPosition(LayoutPosition(35, 834, 32, 26));
  102. mCallNurseButtonPtr->setPosition(LayoutPosition(10, 909, 77, 77));
  103. mCallNursePicPainterPtr->setPosition(LayoutPosition(34, 919, 27, 27));
  104. }
  105. else {
  106. // 如果roomCallBed是1的话,那就显示
  107. mCallBedButtonPtr->setVisible(roomCallBed);
  108. mCallBedPicPainterPtr->setVisible(roomCallBed);
  109. mHelpButtonPtr->setPosition(LayoutPosition(10, 735, 77, 77));
  110. mHelpPicPainterPtr->setPosition(LayoutPosition(33, 747, 32, 26));
  111. mCallNurseButtonPtr->setPosition(LayoutPosition(10, 822, 77, 77));
  112. mCallNursePicPainterPtr->setPosition(LayoutPosition(35, 834, 27, 27));
  113. }
  114. }
  115. /**
  116. * 注册定时器
  117. * 填充数组用于注册定时器
  118. * 注意:id不能重复
  119. */
  120. static S_ACTIVITY_TIMEER REGISTER_ACTIVITY_TIMER_TAB[] = {
  121. //{0, 6000}, //定时器id=0, 时间间隔6秒
  122. //{1, 1000},
  123. };
  124. /**
  125. * 当界面构造时触发
  126. */
  127. static void onUI_init(){
  128. //Tips :添加 UI初始化的显示代码到这里,如:mText1->setText("123");
  129. callBedButtonSetVisible();
  130. setNavibarTheme();
  131. }
  132. /*
  133. * 当界面完全退出时触发
  134. */
  135. static void onUI_quit() {
  136. }
  137. /**
  138. * 串口数据回调接口
  139. */
  140. static void onProtocolDataUpdate(const SProtocolData &data) {
  141. //串口数据回调接口
  142. }
  143. /**
  144. * 定时器触发函数
  145. * 不建议在此函数中写耗时操作,否则将影响UI刷新
  146. * 参数: id
  147. * 当前所触发定时器的id,与注册时的id相同
  148. * 返回值: true
  149. * 继续运行当前定时器
  150. * false
  151. * 停止运行当前定时器
  152. */
  153. static bool onUI_Timer(int id){
  154. switch (id) {
  155. default:
  156. break;
  157. }
  158. return true;
  159. }
  160. /**
  161. * 有新的触摸事件时触发
  162. * 参数:ev
  163. * 新的触摸事件
  164. * 返回值:true
  165. * 表示该触摸事件在此被拦截,系统不再将此触摸事件传递到控件上
  166. * false
  167. * 触摸事件将继续传递到控件上
  168. */
  169. static bool onnavibarActivityTouchEvent(const MotionEvent &ev) {
  170. switch (ev.mActionStatus) {
  171. case MotionEvent::E_ACTION_DOWN://触摸按下
  172. //LOGD("时刻 = %ld 坐标 x = %d, y = %d", ev.mEventTime, ev.mX, ev.mY);
  173. break;
  174. case MotionEvent::E_ACTION_MOVE://触摸滑动
  175. break;
  176. case MotionEvent::E_ACTION_UP: //触摸抬起
  177. break;
  178. default:
  179. break;
  180. }
  181. return false;
  182. }
  183. static bool onButtonClick_HomeButton(ZKButton *pButton) {
  184. LOGD(" ButtonClick HomeButton !!!\n");
  185. if (getAuthItId() != 0) {
  186. Intent* intent = new Intent();
  187. intent->putExtra(functionWindows, "logoutMedicalCare");
  188. intent->putExtra(goActivity, "home");
  189. EASYUICONTEXT->openActivity("functionActivity", intent);
  190. } else {
  191. goHome();
  192. }
  193. return false;
  194. }
  195. static bool onButtonClick_HealthCareButton(ZKButton *pButton) {
  196. LOGD(" ButtonClick HealthCareButton !!!\n");
  197. goCare();
  198. return false;
  199. }
  200. static bool onButtonClick_MoreButton(ZKButton *pButton) {
  201. LOGD(" ButtonClick MoreButton !!!\n");
  202. if (getAuthItId() != 0) {
  203. Intent* intent = new Intent();
  204. intent->putExtra(functionWindows, "logoutMedicalCare");
  205. intent->putExtra(goActivity, "more");
  206. EASYUICONTEXT->openActivity("functionActivity", intent);
  207. } else {
  208. goMore();
  209. }
  210. return false;
  211. }
  212. static bool onButtonClick_HelpButton(ZKButton *pButton) {
  213. LOGD(" ButtonClick HelpButton !!!\n");
  214. TcpModel tcpModel;
  215. tcpModel.type = TcpType::REINFORCE;
  216. tcpModel.action = ReinforceAction::CALL;
  217. tcpModel.from_id = StoragePreferences::getInt(STORE_DEVICE_ID,0);
  218. tcpModel.to_id = 0;
  219. sendTcpModel(tcpModel);
  220. Intent* intent = new Intent();
  221. intent->putExtra(functionWindows, "help");
  222. EASYUICONTEXT->openActivity("functionActivity", intent);
  223. return false;
  224. }
  225. static bool onButtonClick_CallNurseButton(ZKButton *pButton) {
  226. LOGD(" ButtonClick CallNurseButton !!!\n");
  227. if (StoragePreferences::getString(STORE_SIGNAL_TYPE, SIGNAL_TYPE) == "SIP"){
  228. int port = StoragePreferences::getInt(SIP_REG_PORT, SIP_REG_PORT_DEFAULT);
  229. std::string domain = StoragePreferences::getString(SIP_REG_DOMAIN, SIP_REG_DOMAIN_DEFAULT);
  230. std::string od_number = StoragePreferences::getString(SIP_REG_DOOR_ACCOUNT, SIP_REG_DOOR_ACCOUNT_DEFAULT);
  231. std::string od_number_uri = URI(od_number, domain, port);
  232. LOGD("od_number_uri: %s", od_number_uri.c_str());
  233. GetTelephone()->MakeCall(od_number_uri);
  234. } else {
  235. Intent* intent = new Intent();
  236. intent->putExtra(isOutgoing, "true");
  237. intent->putExtra(audioOnly, "true");
  238. EASYUICONTEXT->openActivity("callActivity", intent);
  239. }
  240. return false;
  241. }
  242. static bool onButtonClick_CallBedButton(ZKButton *pButton) {
  243. LOGD(" ButtonClick CallBedButton !!!\n");
  244. Intent* intent = new Intent();
  245. intent->putExtra(functionWindows, "callBed");
  246. EASYUICONTEXT->openActivity("functionActivity", intent);
  247. return false;
  248. }