ConfigMobileDeviceAddScreen.java 59 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391
  1. package kr.co.icontrols.wallpadconfig.screen;
  2. import android.annotation.SuppressLint;
  3. import android.app.Activity;
  4. import android.content.BroadcastReceiver;
  5. import android.content.Context;
  6. import android.content.Intent;
  7. import android.content.IntentFilter;
  8. import android.graphics.Color;
  9. import android.os.AsyncTask;
  10. import android.os.Bundle;
  11. import android.os.Handler;
  12. import android.os.Message;
  13. import android.os.PowerManager;
  14. import android.util.Log;
  15. import android.view.Gravity;
  16. import android.view.MotionEvent;
  17. import android.view.View;
  18. import android.view.WindowManager;
  19. import android.widget.RelativeLayout;
  20. import android.widget.Toast;
  21. import com.artncore.WallPadDataMgr.WallPadRemoteCallUserData;
  22. import com.artncore.WallPadDataMgr.WallPadRemoteCallUserData.RemoteCallUserClass;
  23. import com.artncore.WallPadDataMgr.WallpadMobileDeviceData;
  24. import com.artncore.WallPadDataMgr.WallpadMobileDeviceData.MobileDeviceClass;
  25. import com.artncore.commons.define;
  26. import com.artncore.wallpadapi.WallPadAPI;
  27. import com.artncore.wallpadimap.RetProci;
  28. import com.google.gson.Gson;
  29. import com.util.LogUtil;
  30. import org.json.JSONException;
  31. import org.json.JSONObject;
  32. import java.io.IOException;
  33. import java.net.InetAddress;
  34. import java.net.UnknownHostException;
  35. import java.util.ArrayList;
  36. import java.util.List;
  37. import kr.co.icontrols.wallpadconfig.MainActivity;
  38. import kr.co.icontrols.wallpadconfig.R;
  39. import kr.co.icontrols.wallpadconfig.data.ResultData;
  40. import kr.co.icontrols.wallpadconfig.declare.Common;
  41. import kr.co.icontrols.wallpadconfig.declare.ID;
  42. import kr.co.icontrols.wallpadconfig.imap.iMAPDeleteNewMobileDevice;
  43. import kr.co.icontrols.wallpadsupport.WpadActivity;
  44. import kr.co.icontrols.wallpadsupport.WpadImageView;
  45. import kr.co.icontrols.wallpadsupport.WpadImageView.TOUCH_KIND;
  46. import kr.co.icontrols.wallpadsupport.WpadScreen;
  47. import kr.co.icontrols.wallpadsupport.WpadSound.SND;
  48. import kr.co.icontrols.wallpadsupport.WpadTextView;
  49. /**
  50. * @description
  51. * 월패드 [설정->모바일 기기] 화면 이다.<br>
  52. * 등록된 리스트 뷰어<br>
  53. * 을(를) 여기서 처리한다.
  54. */
  55. public class ConfigMobileDeviceAddScreen extends WpadScreen
  56. {
  57. private final String TAG = "ConfigMobileDevAdd";
  58. private Context mContext;
  59. private final boolean DEBUG_LOG_ON = true;
  60. private void DebugLogOutput(String s) { if(DEBUG_LOG_ON) Log.d(TAG, s); }
  61. // =================================================================================================
  62. // [[ Declaration ]] region
  63. // =================================================================================================
  64. // [Image]
  65. private WpadImageView Background;
  66. private WpadImageView ChartBg;
  67. private WpadImageView ChartPageBg;
  68. // [Button]
  69. private WpadImageView RegBtn; // [등록] 버튼
  70. private WpadImageView DelBtn; // [삭제] 버튼
  71. private WpadImageView AllDelBtn; // [전체삭제] 버튼
  72. private WpadImageView NextBtn; // [리스트NEXT] 버튼
  73. private WpadImageView BeforeBtn; // [리스트BEFORE] 버튼
  74. // [Text]
  75. private WpadTextView ListNumText; // [리스트 - 순번] 텍스트
  76. private WpadTextView ListKindText; // [리스트 - 명칭] 텍스트
  77. private WpadTextView ListDateText; // [리스트 - 등록일시] 텍스트
  78. private WpadTextView ListPageText; // [리스트 - 페이지] 텍스트
  79. // [기타]
  80. // [Package]
  81. /**
  82. * 차트의 구조를 정의한다.
  83. */
  84. private class ChartView
  85. {
  86. public final static int ROWS_COUNT = 5; // 행의 개수
  87. private int CurEnabledIndex;
  88. public int getCurEnabledIndex() { return CurEnabledIndex; }
  89. private ListView [] listView = null;
  90. /**
  91. * 차트의 행 요소의 좌표를 정의한다.
  92. */
  93. private int [][] mPos = new int [][]
  94. {
  95. {48, 112}, {48, 204}, {48, 294}, {48, 384}, {48, 474}, {48, 564}
  96. };
  97. /**
  98. * 클래스 생성자
  99. */
  100. private ChartView()
  101. {
  102. CurEnabledIndex = -1;
  103. listView = new ListView[ROWS_COUNT];
  104. for(int i=0 ; i<ROWS_COUNT ; i++)
  105. {
  106. DebugLogOutput("[" + i + "]");
  107. int left = Common.CtrlMarginLEFT(mPos[i][0]);
  108. int top = Common.CtrlMarginTOP(mPos[i][1]);
  109. DebugLogOutput("[" + i + "] - " + "left : " + left + " / top : " + top);
  110. listView[i] = new ListView(left, top, i);
  111. }
  112. CurEnabledIndex = -1;
  113. }
  114. /**
  115. * 해당 index 를 활성화 시킨다. (이전 활성화된 index는 비활성화 시킨다)
  116. *
  117. * @param index - 활성화 시킬 index (범위 : 0 ~ 4)
  118. * @return (boolean) true : 성공, false : 실패
  119. */
  120. private boolean Enable(int index)
  121. {
  122. if( (index < 0) || (index >= ROWS_COUNT) )
  123. {
  124. return false;
  125. }
  126. if(listView == null)
  127. {
  128. return false;
  129. }
  130. if(listView.length <= index)
  131. {
  132. return false;
  133. }
  134. if(CurEnabledIndex >= 0)
  135. {
  136. listView[CurEnabledIndex].Enable(false);
  137. }
  138. listView[index].Enable(true);
  139. CurEnabledIndex = index;
  140. return true;
  141. }
  142. /**
  143. * 현재 index 를 비활성화 시킨다.
  144. */
  145. private void Disable()
  146. {
  147. if(CurEnabledIndex >= 0)
  148. {
  149. listView[CurEnabledIndex].Enable(false);
  150. }
  151. CurEnabledIndex = -1;
  152. }
  153. /**
  154. * 데이터를 입력시킨다.
  155. *
  156. * @param index - (int) 입력 시킬 index (범위 : 0 ~ 4)
  157. * @param Num - (int) 번호란에 넣을 숫자 (0일 경우에는 모든데이터를 삭제하고 버튼이벤트를 OFF시킴)
  158. * @param Name - (String) 내용
  159. * @param RegDate - (String) 날짜
  160. *
  161. * @return (boolean) true : 성공, false : 실패
  162. */
  163. private boolean Input(int index, int Num, String Name, String RegDate)
  164. {
  165. if( (index < 0) || (index >= ROWS_COUNT) )
  166. {
  167. Log.e(TAG, "[ChartView.Input] index Out of range (" + index + ")");
  168. return false;
  169. }
  170. if(listView == null)
  171. {
  172. Log.e(TAG, "[ChartView.Input] listView is null !!!");
  173. return false;
  174. }
  175. if(listView.length <= index)
  176. {
  177. Log.e(TAG, "[ChartView.Input] index Out of range#2 (" + index + ")");
  178. return false;
  179. }
  180. if(Num == 0)
  181. {
  182. listView[index].NumText.setText("");
  183. listView[index].ContentsText.setText("");
  184. listView[index].DateText.setText("");
  185. listView[index].AreaBtn.setButtonEventOffEnable();
  186. }
  187. else
  188. {
  189. if(Name == null)
  190. {
  191. Log.e(TAG, "[ChartView.Input] Name is null !!!");
  192. return false;
  193. }
  194. if(RegDate == null)
  195. {
  196. Log.e(TAG, "[ChartView.Input] RegDate is null !!!");
  197. return false;
  198. }
  199. try
  200. {
  201. listView[index].NumText.setText(String.format("%d", Num));
  202. //명칭 가장 앞에 '_' 붙는 것 제거
  203. if(Name.startsWith("_")) Name = Name.substring(1);
  204. listView[index].ContentsText.setText(Name);
  205. listView[index].DateText.setText(RegDate);
  206. listView[index].AreaBtn.setButtonEventOffDisable();
  207. }
  208. catch (RuntimeException re) {
  209. LogUtil.errorLogInfo("", TAG, re);
  210. return false;
  211. }
  212. catch (Exception e) {
  213. Log.e(TAG, "[ChartView.Input] - [Exception Error]");
  214. //e.printStackTrace();
  215. LogUtil.errorLogInfo("", TAG, e);
  216. return false;
  217. }
  218. }
  219. return true;
  220. }
  221. /**
  222. * 개별 LIST의 View 구조를 정의한다.
  223. */
  224. private class ListView
  225. {
  226. private int ThisIndex; // 행 인덱스
  227. public WpadImageView AreaBtn; // 버튼
  228. public WpadTextView NumText; // 번호
  229. public WpadTextView ContentsText; // 내용
  230. public WpadTextView DateText; // 일시
  231. /**
  232. * 생성자
  233. * @param left - (int) 좌측마진
  234. * @param top - (int) 상측마진
  235. * @param index - (int) 인덱스
  236. */
  237. private ListView(int left, int top, int index)
  238. {
  239. NumText = new WpadTextView(getContext(), false, 110, 88, Gravity.CENTER, Color.WHITE, Common.fontsize._36, false, ID.configMobileDeviceAddScreen.text.LIST_NUM_1 + index);
  240. ViewRegistration(getLayout(), NumText, left+44, top);
  241. ContentsText = new WpadTextView(getContext(), false, 399, 88, Gravity.CENTER, Color.WHITE, Common.fontsize._36, false, ID.configMobileDeviceAddScreen.text.LIST_CARD_1 + index);
  242. ViewRegistration(getLayout(), ContentsText, left+152, top);
  243. DateText = new WpadTextView(getContext(), false, 399, 88, Gravity.CENTER, Color.WHITE, Common.fontsize._36, false, ID.configMobileDeviceAddScreen.text.LIST_CARD_1 + index);
  244. ViewRegistration(getLayout(), DateText, left+550, top);
  245. ThisIndex = index;
  246. int highsize = 88;
  247. if(ThisIndex == 4) highsize = 88;
  248. AreaBtn = new WpadImageView(getContext(), TOUCH_KIND.BUTTON_M, 910, highsize, 0, 0, ID.configMobileDeviceAddScreen.button.LIST1 + index);
  249. ViewRegistration(getLayout(), AreaBtn, left + 49, top);
  250. }
  251. /**
  252. * 본 행을 활성화 /비활성화 시킨다.
  253. *
  254. * @param OnOff - (boolean) true : 활성화, false : 비활성화
  255. */
  256. private void Enable(boolean OnOff)
  257. {
  258. int TextColor = Color.WHITE;
  259. if(OnOff)
  260. {
  261. TextColor = Color.WHITE;
  262. if(ThisIndex == 4) AreaBtn.setImageResource(R.drawable.bg_mobilereg_chart_line_enable);
  263. else AreaBtn.setImageResource(R.drawable.bg_mobilereg_chart_line_enable);
  264. }
  265. else
  266. {
  267. AreaBtn.setImageResource(0);
  268. }
  269. NumText.setTextColor(TextColor);
  270. ContentsText.setTextColor(TextColor);
  271. DateText.setTextColor(TextColor);
  272. NumText.bringToFront();
  273. ContentsText.bringToFront();
  274. DateText.bringToFront();
  275. }
  276. }
  277. }
  278. private ChartView chartView = null;
  279. // [Variables]
  280. //private int OPERATION_MODE = -1; // 동작모드
  281. private WallpadMobileDeviceData wallpadMobileDeviceData = null;
  282. private WallPadRemoteCallUserData wallPadRemoteCallUserData = null;
  283. private class DATA
  284. {
  285. private int CurPageIdx;
  286. private int MaxPageIdx;
  287. private List<MobileDeviceClass> DataList;
  288. public DATA()
  289. {
  290. CurPageIdx = 0;
  291. MaxPageIdx = 0;
  292. DataList = null;
  293. }
  294. }
  295. private DATA mData = null;
  296. private WallPadAPI mWpapi = null;
  297. private iMAPDeleteNewMobileDevice imapDeleteNewMobileDevice;
  298. private int nRemoteCallUserCnt = 0; // 방문객원격통화 사용자 수
  299. private final static int MAX_MOBILE_USER_CNT = 100; // 모바일 기기 최대 등록 개수
  300. @SuppressLint("HandlerLeak")
  301. final Handler handler = new Handler() {
  302. Gson gson = new Gson();
  303. @Override
  304. public void handleMessage(Message msg) {
  305. switch (msg.what) {
  306. case 1000:
  307. try {
  308. Bundle bundle = msg.getData();
  309. String response = bundle.getString("response");
  310. JSONObject jsonObject = new JSONObject(response);
  311. ResultData resultData = gson.fromJson(jsonObject.toString(), ResultData.class);
  312. if(resultData.getType().equals("mobileResponse")&&resultData.getResult().equals("ok")) {
  313. //제어 명령을 내리고 제대로 응답이 오면 필요시 상태를 다시 조회해서 UI 갱신하도록 한다.
  314. }
  315. } catch (JSONException e) {
  316. e.printStackTrace();
  317. }
  318. break;
  319. default:
  320. break;
  321. }
  322. }
  323. };
  324. // =================================================================================================
  325. // [[ Create & Close ]] region
  326. // =================================================================================================
  327. /**
  328. * ConfigSmartKeyMainScreen 클래스 생성자
  329. *
  330. * @param context - 부모 context
  331. * @param layout - 사용할 main layout
  332. * @param wpapi - 상속받은 WallPadAPI
  333. * @param operationMode - 동작모드
  334. */
  335. public ConfigMobileDeviceAddScreen(Context context, RelativeLayout layout, WallPadAPI wpapi, int operationMode)
  336. {
  337. super(context, layout);
  338. mContext = context;
  339. Log.i(TAG, "[START - Screen] --------------------------------------------");
  340. // 1. Data Create
  341. DebugLogOutput("[Create] - Step1 : Data Create");
  342. //OPERATION_MODE = operationMode;
  343. mData = new DATA();
  344. mWpapi = wpapi;
  345. // 2. Device API Load & Update
  346. DebugLogOutput("[Create] - Step2 : Device API Load & Update");
  347. if(DB_Open()) DB_Load();
  348. // 3. Image Create
  349. DebugLogOutput("[Create] - Step3 : Image Create");
  350. Background = new WpadImageView(context, TOUCH_KIND.NONE, 1280, 690, R.drawable.bg_body, 0, ID.configMobileDeviceAddScreen.image.BACKGROUND);
  351. ViewRegistration(layout, Background, Common.ImgPosion.GetX(0), Common.ImgPosion.GetY(110));
  352. ChartBg = new WpadImageView(context, TOUCH_KIND.NONE, 912, 542, R.drawable.bg_mobilereg_chart, 0, ID.configMobileDeviceAddScreen.image.CHART_BG);
  353. ViewRegistration(layout, ChartBg, Common.ImgPosion.GetX(48), Common.ImgPosion.GetY(112));
  354. if (MainActivity.bRemoteCallUse) {
  355. ((MainActivity) context).setTopSetBtnVisible(true);
  356. ((MainActivity) context).setManualBtnVisible(((MainActivity) context).getManualUse(), 893); // 방문객원격통화 사용할 경우
  357. if (wallPadRemoteCallUserData != null) nRemoteCallUserCnt = wallPadRemoteCallUserData.GetRemoteCallUserCnt();
  358. Log.d(TAG, "[ConfigMobileDeviceAddScreen] nRemoteCallUserCnt [" + nRemoteCallUserCnt + "]");
  359. if (nRemoteCallUserCnt < 1) initRemoteCallLib(); // 방문객원격통화 사용자가 없을 경우 초기화를 진행한다. (서비스 구동시 Registraiton을 했지만 서버가 나중에 연결되어 월패드가 등록이 되지 않는 경우 대비)
  360. }
  361. /*ChartPageBg = new WpadImageView(context, TOUCH_KIND.NONE, 75, 62, R.drawable.call_list_btn_page, 0, ID.configMobileDeviceAddScreen.image.BACKGROUND);
  362. ViewRegistration(layout, ChartPageBg, Common.CtrlMarginLEFT(795), Common.CtrlMarginTOP(538));*/
  363. // 4. Button Create
  364. DebugLogOutput("[Create] - Step4 : Button Create");
  365. RegBtn = new WpadImageView(context, TOUCH_KIND.BUTTON, 230, 181, R.drawable.btn_mobilereg_reg_normal, R.drawable.btn_mobilereg_reg_pressed, ID.configMobileDeviceAddScreen.button.REG);
  366. ViewRegistration(layout, RegBtn, Common.ImgPosion.GetX(1002), Common.ImgPosion.GetY(110));
  367. RegBtn.setTouchDelayMs(Common.BTN_DELAY_SHOWPOPUP);
  368. DelBtn = new WpadImageView(context, TOUCH_KIND.BUTTON, 230, 181, R.drawable.btn_mobilereg_del_normal, R.drawable.btn_mobilereg_del_pressed, ID.configMobileDeviceAddScreen.button.DEL);
  369. ViewRegistration(layout, DelBtn, Common.ImgPosion.GetX(1002), Common.ImgPosion.GetY(291));
  370. DelBtn.setTouchDelayMs(Common.BTN_DELAY_SHOWPOPUP);
  371. AllDelBtn = new WpadImageView(context, TOUCH_KIND.BUTTON, 230, 181, R.drawable.btn_mobilereg_alldel_normal, R.drawable.btn_mobilereg_alldel_pressed, ID.configMobileDeviceAddScreen.button.ALLDEL);
  372. ViewRegistration(layout, AllDelBtn, Common.ImgPosion.GetX(1002), Common.ImgPosion.GetY(473));
  373. AllDelBtn.setTouchDelayMs(Common.BTN_DELAY_SHOWPOPUP);
  374. /*NextBtn = new WpadImageView(context, TOUCH_KIND.BUTTON, 110, 62, R.drawable.call_list_btn_arrow_up_normal, R.drawable.call_list_btn_arrow_up_pressed, ID.configMobileDeviceAddScreen.button.NEXT);
  375. ViewRegistration(layout, NextBtn, Common.CtrlMarginLEFT(685), Common.CtrlMarginTOP(538));
  376. NextBtn.setTouchDelayMs(100);
  377. BeforeBtn = new WpadImageView(context, TOUCH_KIND.BUTTON, 110, 62, R.drawable.call_list_btn_arrow_down_normal, R.drawable.call_list_btn_arrow_down_pressed, ID.configMobileDeviceAddScreen.button.BEFORE);
  378. ViewRegistration(layout, BeforeBtn, Common.CtrlMarginLEFT(870), Common.CtrlMarginTOP(538));
  379. BeforeBtn.setTouchDelayMs(100);*/
  380. BeforeBtn = new WpadImageView(context, TOUCH_KIND.BUTTON, 110, 110, R.drawable.add_notice_btn_up_normal, R.drawable.add_notice_btn_up_pressed, ID.configMobileDeviceAddScreen.button.BEFORE);
  381. ViewRegistration(layout, BeforeBtn, Common.ImgPosion.GetX(262), Common.ImgPosion.GetY(670));
  382. NextBtn = new WpadImageView(context, TOUCH_KIND.BUTTON, 110, 110, R.drawable.add_notice_btn_down_normal, R.drawable.add_notice_btn_down_pressed, ID.configMobileDeviceAddScreen.button.NEXT);
  383. ViewRegistration(layout, NextBtn, Common.ImgPosion.GetX(636), Common.ImgPosion.GetY(670));
  384. ListPageText = new WpadTextView(context, false, 264, 110, Gravity.CENTER, Color.WHITE, Common.fontsize._36, false, ID.configMobileDeviceAddScreen.text.LIST_PAGE);
  385. ViewRegistration(layout, ListPageText, Common.ImgPosion.GetX(372), Common.ImgPosion.GetY(670));
  386. // 5. Text Create
  387. DebugLogOutput("[Create] - Step5 : Text Create");
  388. ListNumText = new WpadTextView(context, false, 110, 88, Gravity.CENTER, Color.WHITE, Common.fontsize._36, true, ID.configMobileDeviceAddScreen.text.LIST_NUM);
  389. ViewRegistration(layout, ListNumText, Common.ImgPosion.GetX(48), Common.ImgPosion.GetY(114));
  390. ListKindText = new WpadTextView(context, false, 399, 88, Gravity.CENTER, Color.WHITE, Common.fontsize._36, true, ID.configMobileDeviceAddScreen.text.LIST_KIND);
  391. ViewRegistration(layout, ListKindText, Common.ImgPosion.GetX(160), Common.ImgPosion.GetY(114));
  392. ListDateText = new WpadTextView(context, false, 399, 88, Gravity.CENTER, Color.WHITE, Common.fontsize._36, true, ID.configMobileDeviceAddScreen.text.LIST_DATE);
  393. ViewRegistration(layout, ListDateText, Common.ImgPosion.GetX(561), Common.ImgPosion.GetY(114));
  394. ListNumText.setText("순번");
  395. ListKindText.setText("모바일기기 별칭");
  396. ListDateText.setText("등록 일시");
  397. // 6. Package Create
  398. DebugLogOutput("[Create] - Step6 : Package Create");
  399. chartView = new ChartView();
  400. // 7. Draw_Update
  401. DebugLogOutput("[Create] - Step7 : Draw_Update");
  402. // 7.1. update
  403. Draw_Update();
  404. if(mData.DataList.size() > 0) chartView.Enable(0);
  405. // 8. BR 등록
  406. if (MainActivity.bRemoteCallUse) registerBRReceiver();
  407. //doPingTest("10.1.1.2", "10.1.1.3");
  408. }
  409. /**
  410. * 본 스크린 종료시 호출됨
  411. */
  412. @Override
  413. protected void onClose()
  414. {
  415. super.onClose();
  416. DB_Close();
  417. if (MainActivity.bRemoteCallUse) unregisterBRReceiver();
  418. Log.i(TAG, "[END - Screen] ********************************************");
  419. }
  420. /**
  421. * 팝업종료시 데이터가 있을시 호출됨
  422. */
  423. @Override
  424. protected void onPopupResult(Intent intent)
  425. {
  426. DebugLogOutput("onPopupResult - ************");
  427. if(intent != null)
  428. {
  429. int Screen = intent.getIntExtra("SCREEN", -1);
  430. DebugLogOutput("onPopupResult - Screen(" + Screen + ")");
  431. if((Screen == ID.screen.PopupMobileDeviceAdd) || (Screen == ID.screen.PopupMobileDeviceDel))
  432. {
  433. // 자동종료 타이머 생성
  434. super.setFinishTimerCreate(Common.FINISH_TIME_SEC);
  435. // LCD 를 Normal 상태로 변경하는 기능
  436. /*PowerManager pm = (PowerManager) ((MainActivity)(getContext())).getSystemService(Context.POWER_SERVICE);
  437. pm.userActivity(1, true);*/
  438. ((Activity)this.getContext()).getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  439. // 카드등록 팝업
  440. boolean Refresh = intent.getBooleanExtra("REFRESH", false);
  441. if(Refresh)
  442. {
  443. DB_Load();
  444. if (Screen == ID.screen.PopupMobileDeviceDel) {
  445. if (MainActivity.bRemoteCallUse) {
  446. String strPhoneKey = intent.getStringExtra("DEL_PHONEKEY");
  447. deleteRemoteCallUser(strPhoneKey);
  448. }
  449. //모바일이 삭제되면 월패드 간 공유 되어야 한다.
  450. for(int i=1; i<4; i++) {
  451. String delID = intent.getStringExtra("DEL_ID");
  452. ((MainActivity) mContext).requestMultiControl(handler, Common.JSON.MENU.MOBILE, Common.JSON.REASON.MobileDelete, i, "", delID);
  453. }
  454. }
  455. else{
  456. //모바일이 등록되면 월패드 간 공유 되어야 한다.
  457. List<MobileDeviceClass> DataList = wallpadMobileDeviceData.GetMobileDeviceData();
  458. int size = mData.DataList.size()-1;
  459. for(int i=1; i<4; i++) {
  460. String delID = intent.getStringExtra("DEL_ID");
  461. ((MainActivity) mContext).requestMultiControl(handler, Common.JSON.MENU.MOBILE, Common.JSON.REASON.MobileRegister, i, DataList.get(size).Name, DataList.get(size).Uid);
  462. }
  463. }
  464. int size = mData.DataList.size();
  465. if(size > 0)
  466. {
  467. mData.CurPageIdx = mData.MaxPageIdx;
  468. int EnableIdx = (mData.DataList.size()-1) - (mData.CurPageIdx * ChartView.ROWS_COUNT);
  469. chartView.Enable(EnableIdx);
  470. }
  471. else chartView.Disable();
  472. Draw_Update();
  473. }
  474. }
  475. }
  476. }
  477. // =================================================================================================
  478. // [[ BroadcastReceiver ]] region
  479. // =================================================================================================
  480. /**
  481. * 부모 Activity 에서 BroadcastReceiver 을 수신받을시 호출됨
  482. */
  483. @Override
  484. protected void onBrReceive(Intent intent)
  485. {
  486. super.onBrReceive(intent);
  487. String ActionName = intent.getAction();
  488. DebugLogOutput("[[[[ onBrReceive ]]]] ActionName = " + ActionName);
  489. }
  490. private final int PING_TIMEOUT = 1000;
  491. private String pingResult = "fail";
  492. private class PingTestTask extends AsyncTask<Object, Void, String[]> {
  493. @Override
  494. protected String[] doInBackground(Object... params) {
  495. pingResult = "";
  496. String type = (String)params[0];
  497. String testIP1 = (String)params[1];
  498. String testIP2 = (String)params[2];
  499. String arrResult[] = new String[2];
  500. StringBuilder result = new StringBuilder();
  501. try {
  502. InetAddress ia = InetAddress.getByName(testIP1);
  503. if(ia.isReachable(PING_TIMEOUT) == true) {
  504. result.append("success");
  505. } else {
  506. result.append("fail");
  507. }
  508. InetAddress ia2 = InetAddress.getByName(testIP2);
  509. if(ia2.isReachable(PING_TIMEOUT) == true) {
  510. result.append("success");
  511. } else {
  512. result.append("fail");
  513. }
  514. } catch (UnknownHostException e){
  515. result.append("fail");
  516. } catch (IOException e) {
  517. result.append("fail");
  518. } catch (IllegalArgumentException e) {
  519. result.append("fail");
  520. }
  521. arrResult[0] = type;
  522. arrResult[1] = result.toString();
  523. return arrResult;
  524. }
  525. @Override
  526. protected void onPostExecute(String[] arrResult) {
  527. if (arrResult[1].contains("fail")) {
  528. Sound().Play(SND.effect.TOUCH_LATCHED);
  529. ((MainActivity) (getContext())).StartPopup(ID.screen.PopupMobileNetworkCheck);
  530. return;
  531. }
  532. if (arrResult[0].contains("reg")) {
  533. if (mData.DataList.size() >= MAX_MOBILE_USER_CNT) {
  534. // 등록개수가 최대 개수(100개) 이상
  535. Sound().Play(SND.effect.WARNING005);
  536. Toast.makeText(getContext(), "모바일 기기는 " + MAX_MOBILE_USER_CNT + "대를 초과할 수 없습니다.", Toast.LENGTH_SHORT).show();
  537. } else {
  538. Sound().Play(SND.effect.TOUCH_LATCHED);
  539. boolean bRet = ((MainActivity) (getContext())).StartPopup(ID.screen.PopupMobileDeviceAdd);
  540. if (bRet) {
  541. // 자동종료 타이머 삭제
  542. bRet = ((MainActivity) mContext).setFinishTimerDestroyFromScreen();
  543. DebugLogOutput("setFinishTimerDestroy = " + bRet);
  544. // LCD 항상 켜져 있게 하는 기능
  545. /*PowerManager pm = (PowerManager) ((MainActivity)(getContext())).getSystemService(Context.POWER_SERVICE);
  546. pm.userActivity(2, true);*/
  547. ((Activity) mContext).getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  548. }
  549. }
  550. }
  551. else if (arrResult[0].contentEquals("del")) {
  552. Intent data = new Intent();
  553. int Number = (chartView.getCurEnabledIndex() + 1) + (mData.CurPageIdx * ChartView.ROWS_COUNT);
  554. data.putExtra("DEL_TYPE", 1); // 개별삭제
  555. data.putExtra("DEL_NAME", mData.DataList.get(Number - 1).Name); // 개별 NAME
  556. data.putExtra("DEL_UID", mData.DataList.get(Number - 1).Uid); // 개별 UID
  557. // Log.d(TAG, "[onTouchEvent] Number [" + Number + "]");
  558. // 방문객원격통화 사용자 DB에서 삭제
  559. if (MainActivity.bRemoteCallUse) {
  560. if (mData.DataList.get(Number - 1).Name.contains("remotecall_")) {
  561. if (wallPadRemoteCallUserData != null) {
  562. nRemoteCallUserCnt = wallPadRemoteCallUserData.GetRemoteCallUserCnt();
  563. Log.d(TAG, "[onTouchEvent] nRemoteCallUserCnt [" + nRemoteCallUserCnt + "]");
  564. if (nRemoteCallUserCnt > 0) {
  565. List<RemoteCallUserClass> dataList = wallPadRemoteCallUserData.GetRemoteCallUserData();
  566. if (dataList != null) {
  567. for (int i = 0; i < dataList.size(); i++) {
  568. // Log.d(TAG, "[onTouchEvent] dataList.get(" + i + ").Name = " + dataList.get(i).Name);
  569. // Log.d(TAG, "[onTouchEvent] mData.DataList.get(" + (Number - 1) + ").Name = " + mData.DataList.get(Number - 1).Name);
  570. if (mData.DataList.get(Number - 1).Name.equals("remotecall_".concat(dataList.get(i).Name))) {
  571. String targetPhoneKey = dataList.get(i).PhoneKey; // 삭제할 방문객원격통화 사용자의 phonekey
  572. Log.d(TAG, "[onTouchEvent] targetPhoneKey [" + targetPhoneKey + "]");
  573. data.putExtra("DEL_PHONEKEY", targetPhoneKey);
  574. }
  575. }
  576. }
  577. }
  578. }
  579. }
  580. }
  581. ((MainActivity) (getContext())).StartPopup(ID.screen.PopupMobileDeviceDel, data);
  582. // 자동종료 타이머 삭제
  583. boolean bRet = ((MainActivity) mContext).setFinishTimerDestroyFromScreen();
  584. DebugLogOutput("setFinishTimerDestroy = " + bRet);
  585. // LCD 항상 켜져 있게 하는 기능
  586. // PowerManager pm = (PowerManager) ((MainActivity)(getContext())).getSystemService(Context.POWER_SERVICE);
  587. // pm.userActivity(2, true);
  588. ((Activity) mContext).getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  589. }
  590. else if (arrResult[0].contentEquals("alldel")) {
  591. if (mData == null) return;
  592. if (mData.DataList == null) return;
  593. int size = mData.DataList.size();
  594. if (size == 0) {
  595. // [INIT]
  596. DebugLogOutput("onTouchEvent [ALLDEL] - INIT BUTTON !!!");
  597. Sound().Play(SND.effect.TOUCH_LATCHED);
  598. ((MainActivity) (getContext())).StartPopup(ID.screen.PopupMobileDeviceInit);
  599. } else if (size > 0) {
  600. // [전체 삭제]
  601. DebugLogOutput("onTouchEvent [ALLDEL] DELETE BUTTON !!!");
  602. Sound().Play(SND.effect.TOUCH_LATCHED);
  603. Intent data = new Intent();
  604. data.putExtra("DEL_TYPE", 2); //전체삭제
  605. // 제휴사 삭제를 구분하기 위한 용도로 추가함 yskim
  606. String KindName = "";
  607. for (int i = 0; i < mData.DataList.size(); i++) {
  608. KindName += mData.DataList.get(i).Name;
  609. KindName += "_";
  610. }
  611. data.putExtra("DEL_NAME", KindName); // 개별 NAME
  612. ((MainActivity) (getContext())).StartPopup(ID.screen.PopupMobileDeviceDel, data);
  613. // 자동종료 타이머 삭제
  614. boolean bRet = ((MainActivity) mContext).setFinishTimerDestroyFromScreen();
  615. DebugLogOutput("setFinishTimerDestroy = " + bRet);
  616. // 방문객원격통화 사용자 DB 전체 삭제
  617. if (MainActivity.bRemoteCallUse) {
  618. if (wallPadRemoteCallUserData != null)
  619. wallPadRemoteCallUserData.DeleteAllRemoteCallUserInfo();
  620. }
  621. // LCD 항상 켜져 있게 하는 기능
  622. ((Activity) mContext).getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  623. }
  624. }
  625. }
  626. }
  627. // testIP로 ping test를 수행
  628. private void doPingTest2(String type, String IP1, String IP2) {
  629. new PingTestTask().execute(type, IP1, IP2);
  630. }
  631. // =================================================================================================
  632. // [[ Touch & Key Event ]] region
  633. // =================================================================================================
  634. /**
  635. * 본 클래스에서 등록한 [WpadImageView] [WpadTextView] 의 TouchEvent 가 있을시 호출됨
  636. */
  637. @Override
  638. protected void onTouchEvent(View v, MotionEvent event)
  639. {
  640. super.onTouchEvent(v, event);
  641. int TargetId = v.getId();
  642. int MoveEvent = event.getAction();
  643. if(MoveEvent == MotionEvent.ACTION_UP)
  644. {
  645. if(TargetId == ID.configMobileDeviceAddScreen.button.REG)
  646. {
  647. // [등록]
  648. DebugLogOutput("onTouchEvent [REG] BUTTON !!!");
  649. if(((MainActivity)getContext()).myIP.equals("10.1.1.1")) {
  650. doPingTest2("reg", "10.1.2.1", "10.1.3.1");
  651. /*
  652. if (mData.DataList.size() >= MAX_MOBILE_USER_CNT) {
  653. // 등록개수가 최대 개수(100개) 이상
  654. Sound().Play(SND.effect.WARNING005);
  655. Toast.makeText(getContext(), "모바일 기기는 " + MAX_MOBILE_USER_CNT + "대를 초과할 수 없습니다.", Toast.LENGTH_SHORT).show();
  656. } else {
  657. Sound().Play(SND.effect.TOUCH_LATCHED);
  658. boolean bRet = ((MainActivity) (getContext())).StartPopup(ID.screen.PopupMobileDeviceAdd);
  659. if (bRet) {
  660. // 자동종료 타이머 삭제
  661. bRet = super.setFinishTimerDestroy();
  662. DebugLogOutput("setFinishTimerDestroy = " + bRet);
  663. // LCD 항상 켜져 있게 하는 기능
  664. ((Activity) this.getContext()).getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  665. }
  666. }
  667. */
  668. } else {
  669. Sound().Play(SND.effect.TOUCH_LATCHED);
  670. ((MainActivity)(getContext())).StartPopup(ID.screen.PopupMobileNotUseConfirm);
  671. }
  672. }
  673. else if(TargetId == ID.configMobileDeviceAddScreen.button.DEL)
  674. {
  675. // [삭제]
  676. DebugLogOutput("onTouchEvent [DEL] BUTTON !!!");
  677. Sound().Play(SND.effect.TOUCH_LATCHED);
  678. if(((MainActivity)getContext()).myIP.equals("10.1.1.1")) {
  679. doPingTest2("del", "10.1.2.1", "10.1.3.1");
  680. /*
  681. Intent data = new Intent();
  682. int Number = (chartView.getCurEnabledIndex() + 1) + (mData.CurPageIdx * ChartView.ROWS_COUNT);
  683. data.putExtra("DEL_TYPE", 1); // 개별삭제
  684. data.putExtra("DEL_NAME", mData.DataList.get(Number - 1).Name); // 개별 NAME
  685. data.putExtra("DEL_UID", mData.DataList.get(Number - 1).Uid); // 개별 UID
  686. // Log.d(TAG, "[onTouchEvent] Number [" + Number + "]");
  687. // 방문객원격통화 사용자 DB에서 삭제
  688. if (MainActivity.bRemoteCallUse) {
  689. if (mData.DataList.get(Number - 1).Name.contains("remotecall_")) {
  690. if (wallPadRemoteCallUserData != null) {
  691. nRemoteCallUserCnt = wallPadRemoteCallUserData.GetRemoteCallUserCnt();
  692. Log.d(TAG, "[onTouchEvent] nRemoteCallUserCnt [" + nRemoteCallUserCnt + "]");
  693. if (nRemoteCallUserCnt > 0) {
  694. List<RemoteCallUserClass> dataList = wallPadRemoteCallUserData.GetRemoteCallUserData();
  695. if (dataList != null) {
  696. for (int i = 0; i < dataList.size(); i++) {
  697. // Log.d(TAG, "[onTouchEvent] dataList.get(" + i + ").Name = " + dataList.get(i).Name);
  698. // Log.d(TAG, "[onTouchEvent] mData.DataList.get(" + (Number - 1) + ").Name = " + mData.DataList.get(Number - 1).Name);
  699. if (mData.DataList.get(Number - 1).Name.equals("remotecall_".concat(dataList.get(i).Name))) {
  700. String targetPhoneKey = dataList.get(i).PhoneKey; // 삭제할 방문객원격통화 사용자의 phonekey
  701. Log.d(TAG, "[onTouchEvent] targetPhoneKey [" + targetPhoneKey + "]");
  702. data.putExtra("DEL_PHONEKEY", targetPhoneKey);
  703. }
  704. }
  705. }
  706. }
  707. }
  708. }
  709. }
  710. ((MainActivity) (getContext())).StartPopup(ID.screen.PopupMobileDeviceDel, data);
  711. // 자동종료 타이머 삭제
  712. boolean bRet = super.setFinishTimerDestroy();
  713. DebugLogOutput("setFinishTimerDestroy = " + bRet);
  714. // LCD 항상 켜져 있게 하는 기능
  715. ((Activity) this.getContext()).getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  716. */
  717. } else {
  718. ((MainActivity)(getContext())).StartPopup(ID.screen.PopupMobileNotUseConfirm);
  719. }
  720. }
  721. else if(TargetId == ID.configMobileDeviceAddScreen.button.ALLDEL)
  722. {
  723. if(((MainActivity)getContext()).myIP.equals("10.1.3.1")) {
  724. doPingTest2("alldel", "10.1.2.1", "10.1.3.1");
  725. /*
  726. if (mData == null) return;
  727. if (mData.DataList == null) return;
  728. int size = mData.DataList.size();
  729. if (size == 0) {
  730. // [INIT]
  731. DebugLogOutput("onTouchEvent [ALLDEL] - INIT BUTTON !!!");
  732. Sound().Play(SND.effect.TOUCH_LATCHED);
  733. ((MainActivity) (getContext())).StartPopup(ID.screen.PopupMobileDeviceInit);
  734. } else if (size > 0) {
  735. // [전체 삭제]
  736. DebugLogOutput("onTouchEvent [ALLDEL] DELETE BUTTON !!!");
  737. Sound().Play(SND.effect.TOUCH_LATCHED);
  738. Intent data = new Intent();
  739. data.putExtra("DEL_TYPE", 2); //전체삭제
  740. // 제휴사 삭제를 구분하기 위한 용도로 추가함 yskim
  741. String KindName = "";
  742. for (int i = 0; i < mData.DataList.size(); i++) {
  743. KindName += mData.DataList.get(i).Name;
  744. KindName += "_";
  745. }
  746. data.putExtra("DEL_NAME", KindName); // 개별 NAME
  747. ((MainActivity) (getContext())).StartPopup(ID.screen.PopupMobileDeviceDel, data);
  748. // 자동종료 타이머 삭제
  749. boolean bRet = super.setFinishTimerDestroy();
  750. DebugLogOutput("setFinishTimerDestroy = " + bRet);
  751. // 방문객원격통화 사용자 DB 전체 삭제
  752. if (MainActivity.bRemoteCallUse) {
  753. if (wallPadRemoteCallUserData != null)
  754. wallPadRemoteCallUserData.DeleteAllRemoteCallUserInfo();
  755. }
  756. // LCD 항상 켜져 있게 하는 기능
  757. ((Activity) this.getContext()).getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  758. */
  759. } else {
  760. Sound().Play(SND.effect.TOUCH_LATCHED);
  761. ((MainActivity)(getContext())).StartPopup(ID.screen.PopupMobileNotUseConfirm);
  762. }
  763. }
  764. else if((TargetId == ID.configMobileDeviceAddScreen.button.NEXT) || (TargetId == ID.configMobileDeviceAddScreen.button.BEFORE))
  765. {
  766. // [LIST NEXT]
  767. DebugLogOutput("onTouchEvent [NEXT] BUTTON !!!");
  768. if(mData.MaxPageIdx > 0)
  769. {
  770. Sound().Play(SND.effect.TOUCH_LATCHED);
  771. if(++mData.CurPageIdx > mData.MaxPageIdx) mData.CurPageIdx = 0;
  772. chartView.Enable(0);
  773. Draw_Update();
  774. }
  775. }
  776. else if((TargetId >= ID.configMobileDeviceAddScreen.button.LIST1) && (TargetId <= ID.configMobileDeviceAddScreen.button.LIST5))
  777. {
  778. // [LIST1 ~ LIST5]
  779. int index = TargetId - ID.configMobileDeviceAddScreen.button.LIST1;
  780. DebugLogOutput("onTouchEvent [LIST" + (index+1) + "] BUTTON !!!");
  781. if(chartView.getCurEnabledIndex() != index)
  782. {
  783. Sound().Play(SND.effect.TOUCH_LATCHED);
  784. chartView.Enable(index);
  785. }
  786. }
  787. }
  788. }
  789. // =================================================================================================
  790. // [[ Draw ]] region
  791. // =================================================================================================
  792. /**
  793. * 변경되는 이미지를 다시 그린다.
  794. *
  795. */
  796. private void Draw_Update()
  797. {
  798. // 1. 범위체크
  799. if(mData == null) return;
  800. if(mData.DataList == null) return;
  801. // 2. 차트 데이터 업데이트
  802. Draw_ChartUpdate();
  803. // 3. 데이터가 없을시 [삭제] , [전체삭제] 버튼을 비활성화 한다.
  804. if(mData.DataList.size() == 0)
  805. {
  806. DelBtn.setButtonEventOffEnable(R.drawable.btn_mobilereg_del_disabled);
  807. //AllDelBtn.setButtonEventOffEnable(R.drawable.btn_mobilereg_alldel_disabled);
  808. ListPageText.setText("");
  809. // 전체삭제 버튼 아래쪽에 "초기화" 문구 추가해주기
  810. }
  811. else
  812. {
  813. DelBtn.setButtonEventOffDisable();
  814. //AllDelBtn.setButtonEventOffDisable();
  815. // 전체삭제-초기화 문구 안보이게 함
  816. }
  817. // 4. 총 페이지 수에 따라서, NEXT 버튼의 활성화/비활성화 설정
  818. if(mData.MaxPageIdx == 0)
  819. {
  820. BeforeBtn.setButtonEventOffEnable(R.drawable.add_notice_btn_up_disable);
  821. NextBtn.setButtonEventOffEnable(R.drawable.add_notice_btn_down_disable);
  822. }
  823. else
  824. {
  825. NextBtn.setButtonEventOffDisable();
  826. BeforeBtn.setButtonEventOffDisable();
  827. }
  828. }
  829. /**
  830. * 차트에 텍스트 데이터 및 포인터를 업데이트 한다.
  831. */
  832. private void Draw_ChartUpdate()
  833. {
  834. // 1. 범위체크
  835. if(chartView == null) return;
  836. if(mData.DataList == null) return;
  837. int size = mData.DataList.size();
  838. int index = 0;
  839. for(int i=0 ; i<ChartView.ROWS_COUNT ; i++)
  840. {
  841. index = i + (mData.CurPageIdx * ChartView.ROWS_COUNT);
  842. if(index < size)
  843. {
  844. try
  845. {
  846. chartView.Input(i, index+1, mData.DataList.get(index).Name,
  847. mData.DataList.get(index).regdate);
  848. }
  849. catch (RuntimeException re) {
  850. LogUtil.errorLogInfo("", TAG, re);
  851. chartView.Input(i, 0, null, null);
  852. }
  853. catch (Exception e) {
  854. Log.e(TAG, "[ExceptionError] - Draw_ChartUpdate : " + e);
  855. chartView.Input(i, 0, null, null);
  856. //e.printStackTrace();
  857. LogUtil.errorLogInfo("", TAG, e);
  858. }
  859. }
  860. else chartView.Input(i, 0, null, null);
  861. }
  862. if(size > 0)
  863. {
  864. if(chartView.CurEnabledIndex < 0) chartView.CurEnabledIndex = 0;
  865. ListPageText.setText((mData.CurPageIdx + 1) + "/" + (mData.MaxPageIdx+1));
  866. }
  867. }
  868. /**
  869. * 방문객원격통화 라이브러리를 초기화한다.
  870. */
  871. private void initRemoteCallLib() {
  872. try {
  873. // 통화App 방문객원격통화 서비스로 사용자 초기화 BR 전송
  874. Intent intent = new Intent();
  875. intent.setAction(Common.BR.VISITOR_REMOTE_CALL);
  876. intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_EVENT_REMOTECALL_USER_INITIALIZE);
  877. getContext().sendBroadcast(intent);
  878. } catch (RuntimeException re) {
  879. LogUtil.errorLogInfo("", TAG, re);
  880. } catch (Exception e) {
  881. Log.e(TAG, "[Exception] initRemoteCallLib()");
  882. //e.printStackTrace();
  883. LogUtil.errorLogInfo("", TAG, e);
  884. }
  885. }
  886. /**
  887. * 방문객원격통화 사용자를 삭제한다.
  888. */
  889. private void deleteRemoteCallUser(String strPhoneKey) {
  890. try {
  891. Log.d(TAG, "[deleteRemoteCallUser] strPhoneKey [" + strPhoneKey + "]");
  892. if (strPhoneKey != null) {
  893. // 방문객원격통화 사용자 DB 삭제
  894. if (wallPadRemoteCallUserData != null) {
  895. wallPadRemoteCallUserData.DeleteRemoteCallUserPhoneKey(strPhoneKey);
  896. // 사용자 삭제할 경우 통화 App 방문객원격통화 서버로 사용자 PhoneKey 전송
  897. Intent sendIntent = new Intent();
  898. sendIntent.setAction(Common.BR.VISITOR_REMOTE_CALL);
  899. sendIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_EVENT_REMOTECALL_USER_DELETE);
  900. sendIntent.putExtra(define.NOTIBR_REMOTECALL_USER_DELETE_PHONEKEY, strPhoneKey);
  901. getContext().sendBroadcast(sendIntent);
  902. nRemoteCallUserCnt = wallPadRemoteCallUserData.GetRemoteCallUserCnt();
  903. Log.d(TAG, "[deleteCallUser] nRemoteCallUserCnt [" + nRemoteCallUserCnt + "]");
  904. }
  905. }
  906. } catch (RuntimeException re) {
  907. LogUtil.errorLogInfo("", TAG, re);
  908. } catch (Exception e) {
  909. Log.e(TAG, "[Exception] deleteCallUser(String strPhoneKey)");
  910. //e.printStackTrace();
  911. LogUtil.errorLogInfo("", TAG, e);
  912. }
  913. }
  914. private void deleteRemoteCallUser(String strPhoneKey, String strUid) {
  915. try {
  916. Log.d(TAG, "[deleteRemoteCallUser] strPhoneKey [" + strPhoneKey + "], strUid [" + strUid + "]");
  917. if (strPhoneKey != null) {
  918. // 방문객원격통화 사용자 DB 삭제
  919. if (wallPadRemoteCallUserData != null) {
  920. wallPadRemoteCallUserData.DeleteRemoteCallUserPhoneKey(strPhoneKey);
  921. // 사용자 삭제할 경우 통화 App 방문객원격통화 서버로 사용자 PhoneKey 전송
  922. Intent sendIntent = new Intent();
  923. sendIntent.setAction(Common.BR.VISITOR_REMOTE_CALL);
  924. sendIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_EVENT_REMOTECALL_USER_DELETE);
  925. sendIntent.putExtra(define.NOTIBR_REMOTECALL_USER_DELETE_PHONEKEY, strPhoneKey);
  926. getContext().sendBroadcast(sendIntent);
  927. nRemoteCallUserCnt = wallPadRemoteCallUserData.GetRemoteCallUserCnt();
  928. Log.d(TAG, "[deleteRemoteCallUser] nRemoteCallUserCnt [" + nRemoteCallUserCnt + "]");
  929. DB_Delete(strUid);
  930. DB_Load();
  931. Draw_Update();
  932. if (mData.DataList.size() > 0) chartView.Enable(0);
  933. else chartView.Disable();
  934. }
  935. }
  936. } catch (RuntimeException re) {
  937. LogUtil.errorLogInfo("", TAG, re);
  938. } catch (Exception e) {
  939. Log.e(TAG, "[Exception] deleteCallUser(String strPhoneKey, String strUid)");
  940. //e.printStackTrace();
  941. LogUtil.errorLogInfo("", TAG, e);
  942. }
  943. }
  944. // 모바일 기기 사용자 목록 중 방문객원격통화 사용자만 삭제
  945. private void deleteAllRemoteCallUser(final String sPhoneKey, String sName, final String sUid) {
  946. try {
  947. Log.d(TAG, "[deleteAllRemoteCallUser] nRemoteCallUserCnt [" + nRemoteCallUserCnt + "], sPhoneKey [" + sPhoneKey + "], sName[" + sName + "], sUid [" + sUid + "]");
  948. if (imapDeleteNewMobileDevice == null) imapDeleteNewMobileDevice = new iMAPDeleteNewMobileDevice(getContext());
  949. imapDeleteNewMobileDevice.DoWork(sName, sUid);
  950. imapDeleteNewMobileDevice.SetRetCtr(new RetProci() {
  951. @Override
  952. public void ProcSuccess() {
  953. DebugLogOutput("[deleteAllRemoteCallUser] - ProcSuccess");
  954. deleteRemoteCallUser(sPhoneKey, sUid);
  955. }
  956. @Override
  957. public void ProcError() {
  958. DebugLogOutput("[deleteAllRemoteCallUser] - ProcError");
  959. }
  960. @Override
  961. public void ProcDoing() {
  962. DebugLogOutput("[deleteAllRemoteCallUser] - ProcDoing");
  963. }
  964. });
  965. } catch (RuntimeException re) {
  966. LogUtil.errorLogInfo("", TAG, re);
  967. } catch (Exception e) {
  968. Log.e(TAG, "[Exception] deleteAllRemoteCallUser()");
  969. //e.printStackTrace();
  970. LogUtil.errorLogInfo("", TAG, e);
  971. }
  972. }
  973. // BR 관련
  974. private void registerBRReceiver() {
  975. try {
  976. IntentFilter filter = new IntentFilter();
  977. filter.addAction(Common.BR.VISITOR_REMOTE_CALL);
  978. getContext().registerReceiver(mRemoteCallBR, filter, null, null);
  979. } catch (RuntimeException re) {
  980. LogUtil.errorLogInfo("", TAG, re);
  981. } catch (Exception e) {
  982. Log.e(TAG, "[Exception] registerBRReceiver()");
  983. //e.printStackTrace();
  984. LogUtil.errorLogInfo("", TAG, e);
  985. }
  986. }
  987. private void unregisterBRReceiver() {
  988. try {
  989. if (mRemoteCallBR != null) {
  990. getContext().unregisterReceiver(mRemoteCallBR);
  991. }
  992. } catch (RuntimeException re) {
  993. LogUtil.errorLogInfo("", TAG, re);
  994. } catch (Exception e) {
  995. Log.e(TAG, "[Exception] unregisterBRReceiver()");
  996. //e.printStackTrace();
  997. LogUtil.errorLogInfo("", TAG, e);
  998. }
  999. }
  1000. BroadcastReceiver mRemoteCallBR = new BroadcastReceiver() {
  1001. @Override
  1002. public void onReceive(Context context, Intent intent) {
  1003. try {
  1004. String strAction = intent.getAction();
  1005. if (strAction.equals(Common.BR.VISITOR_REMOTE_CALL)) {
  1006. // 방문객 원격통화 관리 팝업에서 초기화 실행할 경우 모바일 기기 리스트에서도 삭제
  1007. boolean bRefresh = intent.getBooleanExtra("REFRESH", false);
  1008. // Log.d(TAG, "[mRemoteCallBR.onReceive] bRefresh [" + bRefresh + "]");
  1009. if (bRefresh) {
  1010. boolean bInitialize = intent.getBooleanExtra("INITIALIZE", false);
  1011. // Log.d(TAG, "[mRemoteCallBR.onReceive] bInitialize [" + bInitialize + "]");
  1012. if (bInitialize) {
  1013. for (int i = 0; i < mData.DataList.size(); i++) {
  1014. String sName = mData.DataList.get(i).Name;
  1015. if (sName.contains("remotecall_")) { // 통합서버에서 사용자 별칭에 서비스가 태깅되어 전달됨
  1016. Log.d(TAG, "[mRemoteCallBR.onReceive] sName [" + sName + "]");
  1017. initRemoteCallLib();
  1018. ArrayList<String> phoneKey = intent.getStringArrayListExtra("REMOTECALLUSER_PHONEKEY");
  1019. ArrayList<String> name = intent.getStringArrayListExtra("REMOTECALLUSER_NAME");
  1020. if (phoneKey != null && name != null) {
  1021. for (int j = 0; j < name.size(); j++) {
  1022. // Log.d(TAG, "[mRemoteCallBR.onReceive] mData.DataList.get(" + i + ").Name = " + mData.DataList.get(i).Name);
  1023. // Log.d(TAG, "[mRemoteCallBR.onReceive] name.get(" + j + ") = " + name.get(j));
  1024. if (mData.DataList.get(i).Name.equals("remotecall_".concat(name.get(j)))) {
  1025. deleteAllRemoteCallUser(phoneKey.get(j), name.get(j), mData.DataList.get(i).Uid); // imap 통신하여 사용자 삭제
  1026. Thread.sleep(1000);
  1027. }
  1028. }
  1029. }
  1030. }
  1031. }
  1032. }
  1033. }
  1034. }
  1035. } catch (RuntimeException re) {
  1036. LogUtil.errorLogInfo("", TAG, re);
  1037. } catch (Exception e) {
  1038. Log.e(TAG, "[Exception] mRemoteCallBR.onReceive()");
  1039. //e.printStackTrace();
  1040. LogUtil.errorLogInfo("", TAG, e);
  1041. }
  1042. }
  1043. };
  1044. // =================================================================================================
  1045. // [[ Device ]] region
  1046. // =================================================================================================
  1047. // =================================================================================================
  1048. // [[ DB ]] region
  1049. // =================================================================================================
  1050. /*
  1051. * DB 를 연결한다.
  1052. *
  1053. * @return (boolean) true : 성공, false : 실패
  1054. */
  1055. private boolean DB_Open()
  1056. {
  1057. try
  1058. {
  1059. wallpadMobileDeviceData = new WallpadMobileDeviceData(getContext());
  1060. if (MainActivity.bRemoteCallUse) {
  1061. wallPadRemoteCallUserData = new WallPadRemoteCallUserData(getContext());
  1062. }
  1063. }
  1064. catch (RuntimeException re) {
  1065. LogUtil.errorLogInfo("", TAG, re);
  1066. wallpadMobileDeviceData = null;
  1067. wallPadRemoteCallUserData = null;
  1068. return false;
  1069. }
  1070. catch (Exception e) {
  1071. Log.e(TAG, "[DB_Open] [ExceptionError] - new wallpadMobileDeviceData / wallPadRemoteCallUserData");
  1072. wallpadMobileDeviceData = null;
  1073. wallPadRemoteCallUserData = null;
  1074. //e.printStackTrace();
  1075. LogUtil.errorLogInfo("", TAG, e);
  1076. return false;
  1077. }
  1078. return true;
  1079. }
  1080. /**
  1081. * DB 를 닫는다.
  1082. *
  1083. * @return (boolean) true : 성공, false : 실패
  1084. */
  1085. private boolean DB_Close()
  1086. {
  1087. try
  1088. {
  1089. if(wallpadMobileDeviceData != null) wallpadMobileDeviceData.closeDB();
  1090. if(wallPadRemoteCallUserData != null) wallPadRemoteCallUserData.closeDB();
  1091. }
  1092. catch (RuntimeException re) {
  1093. LogUtil.errorLogInfo("", TAG, re);
  1094. wallpadMobileDeviceData = null;
  1095. wallPadRemoteCallUserData = null;
  1096. return false;
  1097. }
  1098. catch (Exception e) {
  1099. Log.e(TAG, "[DB_Close] [ExceptionError] - closeDB wallpadMobileDeviceData");
  1100. wallpadMobileDeviceData = null;
  1101. wallPadRemoteCallUserData = null;
  1102. //e.printStackTrace();
  1103. LogUtil.errorLogInfo("", TAG, e);
  1104. return false;
  1105. }
  1106. return true;
  1107. }
  1108. /*
  1109. /**
  1110. * DB 데이터를 읽어온다.
  1111. *
  1112. * @return (boolean) true : 성공, false : 실패
  1113. */
  1114. private boolean DB_Load()
  1115. {
  1116. DebugLogOutput("[DB_Load] Start");
  1117. if(wallpadMobileDeviceData == null)
  1118. {
  1119. Log.w(TAG, "[DB_Load] wallpadMobileDeviceData is null !!!");
  1120. return false;
  1121. }
  1122. if (MainActivity.bRemoteCallUse) {
  1123. if (wallPadRemoteCallUserData == null) {
  1124. Log.w(TAG, "[DB_Load] wallPadRemoteCallUserData is null !!!");
  1125. return false;
  1126. }
  1127. }
  1128. try
  1129. {
  1130. mData.DataList = wallpadMobileDeviceData.GetMobileDeviceData();
  1131. }
  1132. catch (RuntimeException re) {
  1133. LogUtil.errorLogInfo("", TAG, re);
  1134. return false;
  1135. }
  1136. catch (Exception e) {
  1137. Log.e(TAG, "[ExceptionError] - DB_Load -> GetMobileDeviceData : " + e);
  1138. //e.printStackTrace();
  1139. LogUtil.errorLogInfo("", TAG, e);
  1140. return false;
  1141. }
  1142. if(mData.DataList == null)
  1143. {
  1144. Log.w(TAG, "[DB_Load] mData.DataList is null !!!");
  1145. mData.DataList = new ArrayList<MobileDeviceClass>();
  1146. return false;
  1147. }
  1148. int size = mData.DataList.size( );
  1149. if(size <= ChartView.ROWS_COUNT) mData.MaxPageIdx = 0;
  1150. else mData.MaxPageIdx = (size-1) / ChartView.ROWS_COUNT;
  1151. if(mData.CurPageIdx > mData.MaxPageIdx) mData.CurPageIdx = 0;
  1152. // Debug Msg
  1153. DebugLogOutput(wallpadMobileDeviceData.ToDebugMobileDeviceData(mData.DataList));
  1154. DebugLogOutput("[DB_Load] OK!!!");
  1155. return true;
  1156. }
  1157. /**
  1158. * DB 에 해당 인덱스 데이터를 삭제한다.
  1159. *
  1160. * @param Uid - 삭제할 Uid
  1161. *
  1162. * @return (boolean) true : 성공, false : 실패
  1163. */
  1164. private boolean DB_Delete(String Uid)
  1165. {
  1166. if(Uid == null) return false;
  1167. if(wallpadMobileDeviceData == null) return false;
  1168. if(mData.DataList == null) return false;
  1169. try
  1170. {
  1171. wallpadMobileDeviceData.DeleteEachUid(Uid);
  1172. }
  1173. catch (RuntimeException re) {
  1174. LogUtil.errorLogInfo("", TAG, re);
  1175. return false;
  1176. }
  1177. catch (Exception e) {
  1178. Log.e(TAG, "[ExceptionError] - wallpadMobileDeviceData.DeleteEachUid");
  1179. //e.printStackTrace();
  1180. LogUtil.errorLogInfo("", TAG, e);
  1181. return false;
  1182. }
  1183. return true;
  1184. }
  1185. /**
  1186. * DB 에 데이터를 모두 삭제한다.
  1187. *
  1188. * @return (boolean) true : 성공, false : 실패
  1189. */
  1190. private boolean DB_DeleteAll()
  1191. {
  1192. if(wallpadMobileDeviceData == null) return false;
  1193. try
  1194. {
  1195. wallpadMobileDeviceData.UnRegisterAll();
  1196. }
  1197. catch (RuntimeException re) {
  1198. LogUtil.errorLogInfo("", TAG, re);
  1199. return false;
  1200. }
  1201. catch (Exception e) {
  1202. Log.e(TAG, "[ExceptionError] - wallpadSmartKeyRegData.UnRegisterAll");
  1203. //e.printStackTrace();
  1204. LogUtil.errorLogInfo("", TAG, e);
  1205. return false;
  1206. }
  1207. return true;
  1208. }
  1209. }