ManualActivity.java 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. package kr.co.icontrols.wallpadconfig;
  2. import android.annotation.SuppressLint;
  3. import android.content.Context;
  4. import android.content.Intent;
  5. import android.os.Bundle;
  6. import android.os.Handler;
  7. import android.os.Message;
  8. import android.util.Log;
  9. import android.view.KeyEvent;
  10. import android.view.MotionEvent;
  11. import android.view.View;
  12. import android.widget.RelativeLayout;
  13. import com.artncore.WallPadDataMgr.WallpadStatusData;
  14. import com.artncore.wallpadapi.WallPadAPI;
  15. import com.util.LogUtil;
  16. import kr.co.icontrols.wallpadconfig.declare.Common;
  17. import kr.co.icontrols.wallpadconfig.declare.ID;
  18. import kr.co.icontrols.wallpadconfig.manual.Lcd_Clean_MANUAL;
  19. import kr.co.icontrols.wallpadconfig.manual.MobileDeviceReg_MANUAL;
  20. import kr.co.icontrols.wallpadconfig.manual.Morning_Call_MANUAL;
  21. import kr.co.icontrols.wallpadconfig.manual.Pwd_Change_MANUAL;
  22. import kr.co.icontrols.wallpadconfig.manual.RFCard_MANUAL;
  23. import kr.co.icontrols.wallpadconfig.manual.ReliefCallPreset_MANUAL;
  24. import kr.co.icontrols.wallpadconfig.manual.RemoteCallUserSet_MANUAL;
  25. import kr.co.icontrols.wallpadconfig.manual.SettingMain_MANUAL;
  26. import kr.co.icontrols.wallpadconfig.manual.Setting_Pop_NameSet_MANUAL;
  27. import kr.co.icontrols.wallpadconfig.manual.Smartkey_MANUAL;
  28. import kr.co.icontrols.wallpadconfig.manual.Time_Setting_MANUAL;
  29. import kr.co.icontrols.wallpadconfig.manual.WebCtrPwd_MANUAL;
  30. import kr.co.icontrols.wallpadsupport.WpadActivity;
  31. import kr.co.icontrols.wallpadsupport.WpadScale;
  32. public class ManualActivity extends WpadActivity {
  33. static final String TAG = "ManualActivity";
  34. private static Context mContext = null;
  35. private static boolean mCreateComplete = false;
  36. public RelativeLayout AllLayout;
  37. // Manual Screen
  38. SettingMain_MANUAL settingMain_manual;
  39. Setting_Pop_NameSet_MANUAL setting_pop_nameSet_manual;
  40. Lcd_Clean_MANUAL lcd_clean_manual;
  41. Pwd_Change_MANUAL pwd_change_manual;
  42. Morning_Call_MANUAL morning_call_manual;
  43. Time_Setting_MANUAL time_setting_manual;
  44. ReliefCallPreset_MANUAL reliefCallPreset_manual;
  45. Smartkey_MANUAL smartkey_manual;
  46. RFCard_MANUAL rfCard_manual;
  47. MobileDeviceReg_MANUAL mobileDeviceReg_manual;
  48. WebCtrPwd_MANUAL webCtrPwd_manual;
  49. RemoteCallUserSet_MANUAL remoteCallUser_manual;
  50. private WallPadAPI wpapi = null;
  51. private WallpadStatusData wdb = null;
  52. private int OPERATION_MODE = Common.MODE;
  53. private int mCurrentScreenId = -1;
  54. private int mTempCurrentScreenId = -1;
  55. public String SettingData_Str = "";
  56. public int now_page = 0;
  57. public int total_page = 0;
  58. public static Context getContext() {
  59. return mContext;
  60. }
  61. protected static boolean getCreateComplete() {
  62. return mCreateComplete;
  63. }
  64. private void setStaticVariablesInit() {
  65. mContext = null;
  66. mCreateComplete = false;
  67. if (AllLayout != null) {
  68. AllLayout.removeAllViews();
  69. AllLayout = null;
  70. }
  71. }
  72. /* ================================================================================================
  73. * [ Activity Life Cycle ] region
  74. ================================================================================================ */
  75. @Override
  76. protected void onCreate(Bundle savedInstanceState)
  77. {
  78. Log.d(TAG, "[ManualActivity] START!!!!");
  79. super.onCreate(savedInstanceState);
  80. MainActivity.mManualActivity = this;
  81. setStaticVariablesInit();
  82. mContext = this;
  83. if (OPERATION_MODE == Common.MODE_NOMAL)
  84. {
  85. Log.d(TAG, "OPERATION_MODE = MODE_NORMAL");
  86. wpapi = new WallPadAPI(this);
  87. }
  88. else if (OPERATION_MODE == Common.MODE_BUSINESS_SAMPLE)
  89. {
  90. Log.d(TAG, "OPERATION_MODE = MODE_BUSINESS_SAMPLE");
  91. }
  92. try
  93. {
  94. wdb = new WallpadStatusData(this);
  95. }
  96. catch (RuntimeException re) {
  97. LogUtil.errorLogInfo("", TAG, re);
  98. }
  99. catch (Exception e) {
  100. Log.e(TAG, "[Error] - WallpadStatusData Create : " + e);
  101. }
  102. AllLayout = new RelativeLayout(this);
  103. super.setAllLayoutRegistration(AllLayout);
  104. Intent intent = getIntent();
  105. int ScreenId = intent.getIntExtra("ScreenId", -1);
  106. SettingData_Str = intent.getStringExtra("SettingData");
  107. now_page = intent.getIntExtra("NowPage", 0);
  108. total_page = intent.getIntExtra("TotalPage", 0);
  109. Log.d(TAG, "ScreenId = " + ScreenId);
  110. if (ScreenId < 0)
  111. {
  112. Log.e(TAG, "[Error] ScreenId Out of range (" + ScreenId + ")");
  113. finish();
  114. }
  115. else
  116. {
  117. mCreateComplete = true;
  118. if (OPERATION_MODE == Common.MODE_NOMAL)
  119. {
  120. Log.d(TAG, "[setChangeScreen] OPERATION_MODE == Common.MODE_NORMAL");
  121. mTempCurrentScreenId = ScreenId;
  122. mWallPadApiCheckHandler.sendEmptyMessage(0);
  123. }
  124. else
  125. {
  126. if (!setChangeScreen(ScreenId, false))
  127. {
  128. Log.e(TAG, "[Error] setChangeScreen false...");
  129. finish();
  130. }
  131. }
  132. }
  133. }
  134. @Override
  135. protected void onDestroy()
  136. {
  137. setChangeScreen(mCurrentScreenId, true);
  138. setStaticVariablesInit();
  139. MainActivity.setManualActivityRun(false);
  140. PopupActivity.setManualActivityRun(false);
  141. mCreateComplete = false;
  142. if (wdb != null) wdb.closeDB();
  143. super.onDestroy();
  144. }
  145. @Override
  146. protected void onResume()
  147. {
  148. super.onResume();
  149. if (wpapi != null) wpapi.Resume();
  150. }
  151. @Override
  152. protected void onPause()
  153. {
  154. super.onPause();
  155. if (wpapi != null) wpapi.Pause();
  156. }
  157. /* ================================================================================================
  158. * [BroadcastReceiver] Section
  159. ================================================================================================ */
  160. @Override
  161. protected void onBrReceive(Intent intent)
  162. {
  163. super.onBrReceive(intent);
  164. Log.d(TAG, "Receive alert BR " + intent.getAction());
  165. }
  166. /* ================================================================================================
  167. * [Touch & Key Event] Section
  168. ================================================================================================ */
  169. @Override
  170. public boolean onTouchEvent(MotionEvent event) {
  171. return super.onTouchEvent(event);
  172. }
  173. @Override
  174. protected void onTouchEvent(View v, MotionEvent event) {
  175. super.onTouchEvent(v, event);
  176. }
  177. @Override
  178. public boolean dispatchTouchEvent(MotionEvent ev) {
  179. return super.dispatchTouchEvent(ev);
  180. }
  181. /* ================================================================================================
  182. * [Screen] Section
  183. ================================================================================================ */
  184. @Override
  185. public boolean onKeyDown(int keyCode, KeyEvent event)
  186. {
  187. Log.d(TAG, "onKeyDown - " + " / keyCode : " + keyCode + " / Action : " + event.getAction());
  188. return super.onKeyDown(keyCode, event);
  189. }
  190. @Override
  191. protected boolean onChangeScreen(int nScreenId)
  192. {
  193. super.onChangeScreen(nScreenId);
  194. return setChangeScreen(nScreenId, false);
  195. }
  196. private boolean setChangeScreen(int screenId, boolean onlyRemove)
  197. {
  198. Log.d(TAG, "setChangeLayout - " + "CurrentScreenId : " + mCurrentScreenId + " / NextLayoutId : " + screenId + " / OnlyRemove : " + onlyRemove);
  199. if (!getCreateComplete())
  200. {
  201. Log.w(TAG, "[setChangeScreen] setChangeLayout - CreateComplete is false !!!");
  202. return false;
  203. }
  204. if (mCurrentScreenId > 0)
  205. {
  206. AllLayout.removeAllViews();
  207. super.setCurrentScreen(null);
  208. }
  209. if (onlyRemove) return true;
  210. // 새로운 Layout 표시
  211. int style = Common.MANUAL_STYLE_NORMAL;
  212. int finishTime = Common.FINISH_TIME_MANUAL_SEC;
  213. try {
  214. Log.d(TAG, "[setChangeScreen] screenId: " + screenId);
  215. switch (screenId)
  216. {
  217. case ID.MANUAL.MANUAL_SettingMain:
  218. settingMain_manual = new SettingMain_MANUAL(mContext, AllLayout, wpapi, SettingData_Str, now_page, total_page);
  219. super.setCurrentScreen(settingMain_manual);
  220. break;
  221. case ID.MANUAL.MANUAL_SettingNameSet:
  222. setting_pop_nameSet_manual = new Setting_Pop_NameSet_MANUAL(mContext, AllLayout, wpapi);
  223. super.setCurrentScreen(setting_pop_nameSet_manual);
  224. break;
  225. case ID.MANUAL.MANUAL_SettingAsCall:
  226. //setting_pop_nameSet_manual = new Setting_Pop_NameSet_MANUAL(mContext, AllLayout, wpapi);
  227. //super.setCurrentScreen(setting_pop_nameSet_manual);
  228. break;
  229. case ID.MANUAL.MANUAL_CleanLcdMain:
  230. lcd_clean_manual = new Lcd_Clean_MANUAL(mContext, AllLayout, wpapi);
  231. super.setCurrentScreen(lcd_clean_manual);
  232. break;
  233. case ID.MANUAL.MANUAL_PWD_CHANGE:
  234. pwd_change_manual = new Pwd_Change_MANUAL(mContext, AllLayout, wpapi);
  235. super.setCurrentScreen(pwd_change_manual);
  236. break;
  237. case ID.MANUAL.MANUAL_MORNINGCALL:
  238. morning_call_manual = new Morning_Call_MANUAL(mContext, AllLayout, wpapi);
  239. super.setCurrentScreen(morning_call_manual);
  240. break;
  241. case ID.MANUAL.MANUAL_TIMESETTING:
  242. time_setting_manual = new Time_Setting_MANUAL(mContext, AllLayout, wpapi);
  243. super.setCurrentScreen(time_setting_manual);
  244. break;
  245. case ID.MANUAL.MANUAL_RFCARD:
  246. rfCard_manual = new RFCard_MANUAL(mContext, AllLayout, wpapi);
  247. super.setCurrentScreen(rfCard_manual);
  248. break;
  249. case ID.MANUAL.MANUAL_SMARTKEY:
  250. smartkey_manual = new Smartkey_MANUAL(mContext, AllLayout, wpapi);
  251. super.setCurrentScreen(smartkey_manual);
  252. break;
  253. case ID.MANUAL.MANUAL_MOBILEDEVREG:
  254. mobileDeviceReg_manual = new MobileDeviceReg_MANUAL(mContext, AllLayout, wpapi);
  255. super.setCurrentScreen(mobileDeviceReg_manual);
  256. break;
  257. case ID.MANUAL.MANUAL_RELIEFCALLPRESET:
  258. reliefCallPreset_manual = new ReliefCallPreset_MANUAL(mContext, AllLayout);
  259. super.setCurrentScreen(reliefCallPreset_manual);
  260. break;
  261. case ID.MANUAL.MANUAL_POPWEBCTRPWD:
  262. webCtrPwd_manual = new WebCtrPwd_MANUAL(mContext, AllLayout);
  263. super.setCurrentScreen(webCtrPwd_manual);
  264. break;
  265. case ID.MANUAL.MANUAL_REMOTECALLUSERSET:
  266. remoteCallUser_manual = new RemoteCallUserSet_MANUAL(mContext, AllLayout);
  267. super.setCurrentScreen(remoteCallUser_manual);
  268. break;
  269. default:
  270. break;
  271. }
  272. }
  273. catch (RuntimeException re) {
  274. LogUtil.errorLogInfo("", TAG, re);
  275. mCurrentScreenId = -1;
  276. return false;
  277. }
  278. catch (Exception e) {
  279. Log.e(TAG, "[Exception] - setChangeScreen->Screen Create: " + e.toString());
  280. //e.printStackTrace();
  281. LogUtil.errorLogInfo("", TAG, e);
  282. mCurrentScreenId = -1;
  283. return false;
  284. }
  285. // style(Window Sizing) Setting
  286. int screenWidth = WpadScale.getWidth(Common.getManualScreenSize_W(style));
  287. int screenHeight = WpadScale.getHeight(Common.getManualScreenSize_H(style));
  288. if ((screenWidth <= 0) || (screenHeight <= 0))
  289. {
  290. Log.e(TAG, "[Error] Style UnDefined !!! (" + style + ")");
  291. return false;
  292. }
  293. RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(screenWidth, screenHeight);
  294. AllLayout.setLayoutParams(params);
  295. setContentView(AllLayout);
  296. super.WindowReSize(screenWidth, screenHeight, false);
  297. // FinishTimer Setting
  298. if ((Common.FINISH_TIME_ENABLE) && (finishTime > 0)) super.setFinishTimerCreate(finishTime);
  299. mCurrentScreenId = screenId;
  300. return true;
  301. }
  302. @SuppressLint("HandlerLeak")
  303. protected Handler mWallPadApiCheckHandler = new Handler()
  304. {
  305. @SuppressLint("HandlerLeak")
  306. @Override
  307. public void handleMessage(Message msg)
  308. {
  309. if (msg.what == 0)
  310. {
  311. if (wpapi != null)
  312. {
  313. if (wpapi.Check_Connect())
  314. mWallPadApiCheckHandler.sendEmptyMessageDelayed(1, 10);
  315. else mWallPadApiCheckHandler.sendEmptyMessageDelayed(0, 10);
  316. }
  317. }
  318. else if (msg.what == 1)
  319. {
  320. setChangeScreen(mTempCurrentScreenId, false);
  321. }
  322. }
  323. };
  324. }