12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391 |
- package kr.co.icontrols.wallpadconfig.screen;
- import android.annotation.SuppressLint;
- import android.app.Activity;
- import android.content.BroadcastReceiver;
- import android.content.Context;
- import android.content.Intent;
- import android.content.IntentFilter;
- import android.graphics.Color;
- import android.os.AsyncTask;
- import android.os.Bundle;
- import android.os.Handler;
- import android.os.Message;
- import android.os.PowerManager;
- import android.util.Log;
- import android.view.Gravity;
- import android.view.MotionEvent;
- import android.view.View;
- import android.view.WindowManager;
- import android.widget.RelativeLayout;
- import android.widget.Toast;
- import com.artncore.WallPadDataMgr.WallPadRemoteCallUserData;
- import com.artncore.WallPadDataMgr.WallPadRemoteCallUserData.RemoteCallUserClass;
- import com.artncore.WallPadDataMgr.WallpadMobileDeviceData;
- import com.artncore.WallPadDataMgr.WallpadMobileDeviceData.MobileDeviceClass;
- import com.artncore.commons.define;
- import com.artncore.wallpadapi.WallPadAPI;
- import com.artncore.wallpadimap.RetProci;
- import com.google.gson.Gson;
- import com.util.LogUtil;
- import org.json.JSONException;
- import org.json.JSONObject;
- import java.io.IOException;
- import java.net.InetAddress;
- import java.net.UnknownHostException;
- import java.util.ArrayList;
- import java.util.List;
- import kr.co.icontrols.wallpadconfig.MainActivity;
- import kr.co.icontrols.wallpadconfig.R;
- import kr.co.icontrols.wallpadconfig.data.ResultData;
- import kr.co.icontrols.wallpadconfig.declare.Common;
- import kr.co.icontrols.wallpadconfig.declare.ID;
- import kr.co.icontrols.wallpadconfig.imap.iMAPDeleteNewMobileDevice;
- import kr.co.icontrols.wallpadsupport.WpadActivity;
- import kr.co.icontrols.wallpadsupport.WpadImageView;
- import kr.co.icontrols.wallpadsupport.WpadImageView.TOUCH_KIND;
- import kr.co.icontrols.wallpadsupport.WpadScreen;
- import kr.co.icontrols.wallpadsupport.WpadSound.SND;
- import kr.co.icontrols.wallpadsupport.WpadTextView;
- /**
- * @description
- * 월패드 [설정->모바일 기기] 화면 이다.<br>
- * 등록된 리스트 뷰어<br>
- * 을(를) 여기서 처리한다.
- */
- public class ConfigMobileDeviceAddScreen extends WpadScreen
- {
- private final String TAG = "ConfigMobileDevAdd";
- private Context mContext;
- private final boolean DEBUG_LOG_ON = true;
- private void DebugLogOutput(String s) { if(DEBUG_LOG_ON) Log.d(TAG, s); }
- // =================================================================================================
- // [[ Declaration ]] region
- // =================================================================================================
- // [Image]
- private WpadImageView Background;
- private WpadImageView ChartBg;
- private WpadImageView ChartPageBg;
- // [Button]
- private WpadImageView RegBtn; // [등록] 버튼
- private WpadImageView DelBtn; // [삭제] 버튼
- private WpadImageView AllDelBtn; // [전체삭제] 버튼
- private WpadImageView NextBtn; // [리스트NEXT] 버튼
- private WpadImageView BeforeBtn; // [리스트BEFORE] 버튼
- // [Text]
- private WpadTextView ListNumText; // [리스트 - 순번] 텍스트
- private WpadTextView ListKindText; // [리스트 - 명칭] 텍스트
- private WpadTextView ListDateText; // [리스트 - 등록일시] 텍스트
- private WpadTextView ListPageText; // [리스트 - 페이지] 텍스트
- // [기타]
- // [Package]
- /**
- * 차트의 구조를 정의한다.
- */
- private class ChartView
- {
- public final static int ROWS_COUNT = 5; // 행의 개수
- private int CurEnabledIndex;
- public int getCurEnabledIndex() { return CurEnabledIndex; }
- private ListView [] listView = null;
- /**
- * 차트의 행 요소의 좌표를 정의한다.
- */
- private int [][] mPos = new int [][]
- {
- {48, 112}, {48, 204}, {48, 294}, {48, 384}, {48, 474}, {48, 564}
- };
- /**
- * 클래스 생성자
- */
- private ChartView()
- {
- CurEnabledIndex = -1;
- listView = new ListView[ROWS_COUNT];
- for(int i=0 ; i<ROWS_COUNT ; i++)
- {
- DebugLogOutput("[" + i + "]");
- int left = Common.CtrlMarginLEFT(mPos[i][0]);
- int top = Common.CtrlMarginTOP(mPos[i][1]);
- DebugLogOutput("[" + i + "] - " + "left : " + left + " / top : " + top);
- listView[i] = new ListView(left, top, i);
- }
- CurEnabledIndex = -1;
- }
- /**
- * 해당 index 를 활성화 시킨다. (이전 활성화된 index는 비활성화 시킨다)
- *
- * @param index - 활성화 시킬 index (범위 : 0 ~ 4)
- * @return (boolean) true : 성공, false : 실패
- */
- private boolean Enable(int index)
- {
- if( (index < 0) || (index >= ROWS_COUNT) )
- {
- return false;
- }
- if(listView == null)
- {
- return false;
- }
- if(listView.length <= index)
- {
- return false;
- }
- if(CurEnabledIndex >= 0)
- {
- listView[CurEnabledIndex].Enable(false);
- }
- listView[index].Enable(true);
- CurEnabledIndex = index;
- return true;
- }
- /**
- * 현재 index 를 비활성화 시킨다.
- */
- private void Disable()
- {
- if(CurEnabledIndex >= 0)
- {
- listView[CurEnabledIndex].Enable(false);
- }
- CurEnabledIndex = -1;
- }
- /**
- * 데이터를 입력시킨다.
- *
- * @param index - (int) 입력 시킬 index (범위 : 0 ~ 4)
- * @param Num - (int) 번호란에 넣을 숫자 (0일 경우에는 모든데이터를 삭제하고 버튼이벤트를 OFF시킴)
- * @param Name - (String) 내용
- * @param RegDate - (String) 날짜
- *
- * @return (boolean) true : 성공, false : 실패
- */
- private boolean Input(int index, int Num, String Name, String RegDate)
- {
- if( (index < 0) || (index >= ROWS_COUNT) )
- {
- Log.e(TAG, "[ChartView.Input] index Out of range (" + index + ")");
- return false;
- }
- if(listView == null)
- {
- Log.e(TAG, "[ChartView.Input] listView is null !!!");
- return false;
- }
- if(listView.length <= index)
- {
- Log.e(TAG, "[ChartView.Input] index Out of range#2 (" + index + ")");
- return false;
- }
- if(Num == 0)
- {
- listView[index].NumText.setText("");
- listView[index].ContentsText.setText("");
- listView[index].DateText.setText("");
- listView[index].AreaBtn.setButtonEventOffEnable();
- }
- else
- {
- if(Name == null)
- {
- Log.e(TAG, "[ChartView.Input] Name is null !!!");
- return false;
- }
- if(RegDate == null)
- {
- Log.e(TAG, "[ChartView.Input] RegDate is null !!!");
- return false;
- }
- try
- {
- listView[index].NumText.setText(String.format("%d", Num));
- //명칭 가장 앞에 '_' 붙는 것 제거
- if(Name.startsWith("_")) Name = Name.substring(1);
- listView[index].ContentsText.setText(Name);
- listView[index].DateText.setText(RegDate);
- listView[index].AreaBtn.setButtonEventOffDisable();
- }
- catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return false;
- }
- catch (Exception e) {
- Log.e(TAG, "[ChartView.Input] - [Exception Error]");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return false;
- }
- }
- return true;
- }
- /**
- * 개별 LIST의 View 구조를 정의한다.
- */
- private class ListView
- {
- private int ThisIndex; // 행 인덱스
- public WpadImageView AreaBtn; // 버튼
- public WpadTextView NumText; // 번호
- public WpadTextView ContentsText; // 내용
- public WpadTextView DateText; // 일시
- /**
- * 생성자
- * @param left - (int) 좌측마진
- * @param top - (int) 상측마진
- * @param index - (int) 인덱스
- */
- private ListView(int left, int top, int index)
- {
- NumText = new WpadTextView(getContext(), false, 110, 88, Gravity.CENTER, Color.WHITE, Common.fontsize._36, false, ID.configMobileDeviceAddScreen.text.LIST_NUM_1 + index);
- ViewRegistration(getLayout(), NumText, left+44, top);
- ContentsText = new WpadTextView(getContext(), false, 399, 88, Gravity.CENTER, Color.WHITE, Common.fontsize._36, false, ID.configMobileDeviceAddScreen.text.LIST_CARD_1 + index);
- ViewRegistration(getLayout(), ContentsText, left+152, top);
- DateText = new WpadTextView(getContext(), false, 399, 88, Gravity.CENTER, Color.WHITE, Common.fontsize._36, false, ID.configMobileDeviceAddScreen.text.LIST_CARD_1 + index);
- ViewRegistration(getLayout(), DateText, left+550, top);
- ThisIndex = index;
- int highsize = 88;
- if(ThisIndex == 4) highsize = 88;
- AreaBtn = new WpadImageView(getContext(), TOUCH_KIND.BUTTON_M, 910, highsize, 0, 0, ID.configMobileDeviceAddScreen.button.LIST1 + index);
- ViewRegistration(getLayout(), AreaBtn, left + 49, top);
- }
- /**
- * 본 행을 활성화 /비활성화 시킨다.
- *
- * @param OnOff - (boolean) true : 활성화, false : 비활성화
- */
- private void Enable(boolean OnOff)
- {
- int TextColor = Color.WHITE;
- if(OnOff)
- {
- TextColor = Color.WHITE;
- if(ThisIndex == 4) AreaBtn.setImageResource(R.drawable.bg_mobilereg_chart_line_enable);
- else AreaBtn.setImageResource(R.drawable.bg_mobilereg_chart_line_enable);
- }
- else
- {
- AreaBtn.setImageResource(0);
- }
- NumText.setTextColor(TextColor);
- ContentsText.setTextColor(TextColor);
- DateText.setTextColor(TextColor);
- NumText.bringToFront();
- ContentsText.bringToFront();
- DateText.bringToFront();
- }
- }
- }
- private ChartView chartView = null;
- // [Variables]
- //private int OPERATION_MODE = -1; // 동작모드
- private WallpadMobileDeviceData wallpadMobileDeviceData = null;
- private WallPadRemoteCallUserData wallPadRemoteCallUserData = null;
- private class DATA
- {
- private int CurPageIdx;
- private int MaxPageIdx;
- private List<MobileDeviceClass> DataList;
- public DATA()
- {
- CurPageIdx = 0;
- MaxPageIdx = 0;
- DataList = null;
- }
- }
- private DATA mData = null;
- private WallPadAPI mWpapi = null;
- private iMAPDeleteNewMobileDevice imapDeleteNewMobileDevice;
- private int nRemoteCallUserCnt = 0; // 방문객원격통화 사용자 수
- private final static int MAX_MOBILE_USER_CNT = 100; // 모바일 기기 최대 등록 개수
- @SuppressLint("HandlerLeak")
- final Handler handler = new Handler() {
- Gson gson = new Gson();
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case 1000:
- try {
- Bundle bundle = msg.getData();
- String response = bundle.getString("response");
- JSONObject jsonObject = new JSONObject(response);
- ResultData resultData = gson.fromJson(jsonObject.toString(), ResultData.class);
- if(resultData.getType().equals("mobileResponse")&&resultData.getResult().equals("ok")) {
- //제어 명령을 내리고 제대로 응답이 오면 필요시 상태를 다시 조회해서 UI 갱신하도록 한다.
- }
- } catch (JSONException e) {
- e.printStackTrace();
- }
- break;
- default:
- break;
- }
- }
- };
- // =================================================================================================
- // [[ Create & Close ]] region
- // =================================================================================================
- /**
- * ConfigSmartKeyMainScreen 클래스 생성자
- *
- * @param context - 부모 context
- * @param layout - 사용할 main layout
- * @param wpapi - 상속받은 WallPadAPI
- * @param operationMode - 동작모드
- */
- public ConfigMobileDeviceAddScreen(Context context, RelativeLayout layout, WallPadAPI wpapi, int operationMode)
- {
- super(context, layout);
- mContext = context;
- Log.i(TAG, "[START - Screen] --------------------------------------------");
- // 1. Data Create
- DebugLogOutput("[Create] - Step1 : Data Create");
- //OPERATION_MODE = operationMode;
- mData = new DATA();
- mWpapi = wpapi;
- // 2. Device API Load & Update
- DebugLogOutput("[Create] - Step2 : Device API Load & Update");
- if(DB_Open()) DB_Load();
- // 3. Image Create
- DebugLogOutput("[Create] - Step3 : Image Create");
- Background = new WpadImageView(context, TOUCH_KIND.NONE, 1280, 690, R.drawable.bg_body, 0, ID.configMobileDeviceAddScreen.image.BACKGROUND);
- ViewRegistration(layout, Background, Common.ImgPosion.GetX(0), Common.ImgPosion.GetY(110));
- ChartBg = new WpadImageView(context, TOUCH_KIND.NONE, 912, 542, R.drawable.bg_mobilereg_chart, 0, ID.configMobileDeviceAddScreen.image.CHART_BG);
- ViewRegistration(layout, ChartBg, Common.ImgPosion.GetX(48), Common.ImgPosion.GetY(112));
- if (MainActivity.bRemoteCallUse) {
- ((MainActivity) context).setTopSetBtnVisible(true);
- ((MainActivity) context).setManualBtnVisible(((MainActivity) context).getManualUse(), 893); // 방문객원격통화 사용할 경우
- if (wallPadRemoteCallUserData != null) nRemoteCallUserCnt = wallPadRemoteCallUserData.GetRemoteCallUserCnt();
- Log.d(TAG, "[ConfigMobileDeviceAddScreen] nRemoteCallUserCnt [" + nRemoteCallUserCnt + "]");
- if (nRemoteCallUserCnt < 1) initRemoteCallLib(); // 방문객원격통화 사용자가 없을 경우 초기화를 진행한다. (서비스 구동시 Registraiton을 했지만 서버가 나중에 연결되어 월패드가 등록이 되지 않는 경우 대비)
- }
- /*ChartPageBg = new WpadImageView(context, TOUCH_KIND.NONE, 75, 62, R.drawable.call_list_btn_page, 0, ID.configMobileDeviceAddScreen.image.BACKGROUND);
- ViewRegistration(layout, ChartPageBg, Common.CtrlMarginLEFT(795), Common.CtrlMarginTOP(538));*/
- // 4. Button Create
- DebugLogOutput("[Create] - Step4 : Button Create");
- 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);
- ViewRegistration(layout, RegBtn, Common.ImgPosion.GetX(1002), Common.ImgPosion.GetY(110));
- RegBtn.setTouchDelayMs(Common.BTN_DELAY_SHOWPOPUP);
- 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);
- ViewRegistration(layout, DelBtn, Common.ImgPosion.GetX(1002), Common.ImgPosion.GetY(291));
- DelBtn.setTouchDelayMs(Common.BTN_DELAY_SHOWPOPUP);
- 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);
- ViewRegistration(layout, AllDelBtn, Common.ImgPosion.GetX(1002), Common.ImgPosion.GetY(473));
- AllDelBtn.setTouchDelayMs(Common.BTN_DELAY_SHOWPOPUP);
- /*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);
- ViewRegistration(layout, NextBtn, Common.CtrlMarginLEFT(685), Common.CtrlMarginTOP(538));
- NextBtn.setTouchDelayMs(100);
- 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);
- ViewRegistration(layout, BeforeBtn, Common.CtrlMarginLEFT(870), Common.CtrlMarginTOP(538));
- BeforeBtn.setTouchDelayMs(100);*/
- 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);
- ViewRegistration(layout, BeforeBtn, Common.ImgPosion.GetX(262), Common.ImgPosion.GetY(670));
- 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);
- ViewRegistration(layout, NextBtn, Common.ImgPosion.GetX(636), Common.ImgPosion.GetY(670));
- ListPageText = new WpadTextView(context, false, 264, 110, Gravity.CENTER, Color.WHITE, Common.fontsize._36, false, ID.configMobileDeviceAddScreen.text.LIST_PAGE);
- ViewRegistration(layout, ListPageText, Common.ImgPosion.GetX(372), Common.ImgPosion.GetY(670));
- // 5. Text Create
- DebugLogOutput("[Create] - Step5 : Text Create");
- ListNumText = new WpadTextView(context, false, 110, 88, Gravity.CENTER, Color.WHITE, Common.fontsize._36, true, ID.configMobileDeviceAddScreen.text.LIST_NUM);
- ViewRegistration(layout, ListNumText, Common.ImgPosion.GetX(48), Common.ImgPosion.GetY(114));
- ListKindText = new WpadTextView(context, false, 399, 88, Gravity.CENTER, Color.WHITE, Common.fontsize._36, true, ID.configMobileDeviceAddScreen.text.LIST_KIND);
- ViewRegistration(layout, ListKindText, Common.ImgPosion.GetX(160), Common.ImgPosion.GetY(114));
- ListDateText = new WpadTextView(context, false, 399, 88, Gravity.CENTER, Color.WHITE, Common.fontsize._36, true, ID.configMobileDeviceAddScreen.text.LIST_DATE);
- ViewRegistration(layout, ListDateText, Common.ImgPosion.GetX(561), Common.ImgPosion.GetY(114));
- ListNumText.setText("순번");
- ListKindText.setText("모바일기기 별칭");
- ListDateText.setText("등록 일시");
- // 6. Package Create
- DebugLogOutput("[Create] - Step6 : Package Create");
- chartView = new ChartView();
- // 7. Draw_Update
- DebugLogOutput("[Create] - Step7 : Draw_Update");
- // 7.1. update
- Draw_Update();
- if(mData.DataList.size() > 0) chartView.Enable(0);
- // 8. BR 등록
- if (MainActivity.bRemoteCallUse) registerBRReceiver();
- //doPingTest("10.1.1.2", "10.1.1.3");
- }
- /**
- * 본 스크린 종료시 호출됨
- */
- @Override
- protected void onClose()
- {
- super.onClose();
- DB_Close();
- if (MainActivity.bRemoteCallUse) unregisterBRReceiver();
- Log.i(TAG, "[END - Screen] ********************************************");
- }
- /**
- * 팝업종료시 데이터가 있을시 호출됨
- */
- @Override
- protected void onPopupResult(Intent intent)
- {
- DebugLogOutput("onPopupResult - ************");
- if(intent != null)
- {
- int Screen = intent.getIntExtra("SCREEN", -1);
- DebugLogOutput("onPopupResult - Screen(" + Screen + ")");
- if((Screen == ID.screen.PopupMobileDeviceAdd) || (Screen == ID.screen.PopupMobileDeviceDel))
- {
- // 자동종료 타이머 생성
- super.setFinishTimerCreate(Common.FINISH_TIME_SEC);
- // LCD 를 Normal 상태로 변경하는 기능
- /*PowerManager pm = (PowerManager) ((MainActivity)(getContext())).getSystemService(Context.POWER_SERVICE);
- pm.userActivity(1, true);*/
- ((Activity)this.getContext()).getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
- // 카드등록 팝업
- boolean Refresh = intent.getBooleanExtra("REFRESH", false);
- if(Refresh)
- {
- DB_Load();
- if (Screen == ID.screen.PopupMobileDeviceDel) {
- if (MainActivity.bRemoteCallUse) {
- String strPhoneKey = intent.getStringExtra("DEL_PHONEKEY");
- deleteRemoteCallUser(strPhoneKey);
- }
- //모바일이 삭제되면 월패드 간 공유 되어야 한다.
- for(int i=1; i<4; i++) {
- String delID = intent.getStringExtra("DEL_ID");
- ((MainActivity) mContext).requestMultiControl(handler, Common.JSON.MENU.MOBILE, Common.JSON.REASON.MobileDelete, i, "", delID);
- }
- }
- else{
- //모바일이 등록되면 월패드 간 공유 되어야 한다.
- List<MobileDeviceClass> DataList = wallpadMobileDeviceData.GetMobileDeviceData();
- int size = mData.DataList.size()-1;
- for(int i=1; i<4; i++) {
- String delID = intent.getStringExtra("DEL_ID");
- ((MainActivity) mContext).requestMultiControl(handler, Common.JSON.MENU.MOBILE, Common.JSON.REASON.MobileRegister, i, DataList.get(size).Name, DataList.get(size).Uid);
- }
- }
- int size = mData.DataList.size();
- if(size > 0)
- {
- mData.CurPageIdx = mData.MaxPageIdx;
- int EnableIdx = (mData.DataList.size()-1) - (mData.CurPageIdx * ChartView.ROWS_COUNT);
- chartView.Enable(EnableIdx);
- }
- else chartView.Disable();
- Draw_Update();
- }
- }
- }
- }
- // =================================================================================================
- // [[ BroadcastReceiver ]] region
- // =================================================================================================
- /**
- * 부모 Activity 에서 BroadcastReceiver 을 수신받을시 호출됨
- */
- @Override
- protected void onBrReceive(Intent intent)
- {
- super.onBrReceive(intent);
- String ActionName = intent.getAction();
- DebugLogOutput("[[[[ onBrReceive ]]]] ActionName = " + ActionName);
- }
- private final int PING_TIMEOUT = 1000;
- private String pingResult = "fail";
- private class PingTestTask extends AsyncTask<Object, Void, String[]> {
- @Override
- protected String[] doInBackground(Object... params) {
- pingResult = "";
- String type = (String)params[0];
- String testIP1 = (String)params[1];
- String testIP2 = (String)params[2];
- String arrResult[] = new String[2];
- StringBuilder result = new StringBuilder();
- try {
- InetAddress ia = InetAddress.getByName(testIP1);
- if(ia.isReachable(PING_TIMEOUT) == true) {
- result.append("success");
- } else {
- result.append("fail");
- }
- InetAddress ia2 = InetAddress.getByName(testIP2);
- if(ia2.isReachable(PING_TIMEOUT) == true) {
- result.append("success");
- } else {
- result.append("fail");
- }
- } catch (UnknownHostException e){
- result.append("fail");
- } catch (IOException e) {
- result.append("fail");
- } catch (IllegalArgumentException e) {
- result.append("fail");
- }
- arrResult[0] = type;
- arrResult[1] = result.toString();
- return arrResult;
- }
- @Override
- protected void onPostExecute(String[] arrResult) {
- if (arrResult[1].contains("fail")) {
- Sound().Play(SND.effect.TOUCH_LATCHED);
- ((MainActivity) (getContext())).StartPopup(ID.screen.PopupMobileNetworkCheck);
- return;
- }
- if (arrResult[0].contains("reg")) {
- if (mData.DataList.size() >= MAX_MOBILE_USER_CNT) {
- // 등록개수가 최대 개수(100개) 이상
- Sound().Play(SND.effect.WARNING005);
- Toast.makeText(getContext(), "모바일 기기는 " + MAX_MOBILE_USER_CNT + "대를 초과할 수 없습니다.", Toast.LENGTH_SHORT).show();
- } else {
- Sound().Play(SND.effect.TOUCH_LATCHED);
- boolean bRet = ((MainActivity) (getContext())).StartPopup(ID.screen.PopupMobileDeviceAdd);
- if (bRet) {
- // 자동종료 타이머 삭제
- bRet = ((MainActivity) mContext).setFinishTimerDestroyFromScreen();
- DebugLogOutput("setFinishTimerDestroy = " + bRet);
- // LCD 항상 켜져 있게 하는 기능
- /*PowerManager pm = (PowerManager) ((MainActivity)(getContext())).getSystemService(Context.POWER_SERVICE);
- pm.userActivity(2, true);*/
- ((Activity) mContext).getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
- }
- }
- }
- else if (arrResult[0].contentEquals("del")) {
- Intent data = new Intent();
- int Number = (chartView.getCurEnabledIndex() + 1) + (mData.CurPageIdx * ChartView.ROWS_COUNT);
- data.putExtra("DEL_TYPE", 1); // 개별삭제
- data.putExtra("DEL_NAME", mData.DataList.get(Number - 1).Name); // 개별 NAME
- data.putExtra("DEL_UID", mData.DataList.get(Number - 1).Uid); // 개별 UID
- // Log.d(TAG, "[onTouchEvent] Number [" + Number + "]");
- // 방문객원격통화 사용자 DB에서 삭제
- if (MainActivity.bRemoteCallUse) {
- if (mData.DataList.get(Number - 1).Name.contains("remotecall_")) {
- if (wallPadRemoteCallUserData != null) {
- nRemoteCallUserCnt = wallPadRemoteCallUserData.GetRemoteCallUserCnt();
- Log.d(TAG, "[onTouchEvent] nRemoteCallUserCnt [" + nRemoteCallUserCnt + "]");
- if (nRemoteCallUserCnt > 0) {
- List<RemoteCallUserClass> dataList = wallPadRemoteCallUserData.GetRemoteCallUserData();
- if (dataList != null) {
- for (int i = 0; i < dataList.size(); i++) {
- // Log.d(TAG, "[onTouchEvent] dataList.get(" + i + ").Name = " + dataList.get(i).Name);
- // Log.d(TAG, "[onTouchEvent] mData.DataList.get(" + (Number - 1) + ").Name = " + mData.DataList.get(Number - 1).Name);
- if (mData.DataList.get(Number - 1).Name.equals("remotecall_".concat(dataList.get(i).Name))) {
- String targetPhoneKey = dataList.get(i).PhoneKey; // 삭제할 방문객원격통화 사용자의 phonekey
- Log.d(TAG, "[onTouchEvent] targetPhoneKey [" + targetPhoneKey + "]");
- data.putExtra("DEL_PHONEKEY", targetPhoneKey);
- }
- }
- }
- }
- }
- }
- }
- ((MainActivity) (getContext())).StartPopup(ID.screen.PopupMobileDeviceDel, data);
- // 자동종료 타이머 삭제
- boolean bRet = ((MainActivity) mContext).setFinishTimerDestroyFromScreen();
- DebugLogOutput("setFinishTimerDestroy = " + bRet);
- // LCD 항상 켜져 있게 하는 기능
- // PowerManager pm = (PowerManager) ((MainActivity)(getContext())).getSystemService(Context.POWER_SERVICE);
- // pm.userActivity(2, true);
- ((Activity) mContext).getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
- }
- else if (arrResult[0].contentEquals("alldel")) {
- if (mData == null) return;
- if (mData.DataList == null) return;
- int size = mData.DataList.size();
- if (size == 0) {
- // [INIT]
- DebugLogOutput("onTouchEvent [ALLDEL] - INIT BUTTON !!!");
- Sound().Play(SND.effect.TOUCH_LATCHED);
- ((MainActivity) (getContext())).StartPopup(ID.screen.PopupMobileDeviceInit);
- } else if (size > 0) {
- // [전체 삭제]
- DebugLogOutput("onTouchEvent [ALLDEL] DELETE BUTTON !!!");
- Sound().Play(SND.effect.TOUCH_LATCHED);
- Intent data = new Intent();
- data.putExtra("DEL_TYPE", 2); //전체삭제
- // 제휴사 삭제를 구분하기 위한 용도로 추가함 yskim
- String KindName = "";
- for (int i = 0; i < mData.DataList.size(); i++) {
- KindName += mData.DataList.get(i).Name;
- KindName += "_";
- }
- data.putExtra("DEL_NAME", KindName); // 개별 NAME
- ((MainActivity) (getContext())).StartPopup(ID.screen.PopupMobileDeviceDel, data);
- // 자동종료 타이머 삭제
- boolean bRet = ((MainActivity) mContext).setFinishTimerDestroyFromScreen();
- DebugLogOutput("setFinishTimerDestroy = " + bRet);
- // 방문객원격통화 사용자 DB 전체 삭제
- if (MainActivity.bRemoteCallUse) {
- if (wallPadRemoteCallUserData != null)
- wallPadRemoteCallUserData.DeleteAllRemoteCallUserInfo();
- }
- // LCD 항상 켜져 있게 하는 기능
- ((Activity) mContext).getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
- }
- }
- }
- }
- // testIP로 ping test를 수행
- private void doPingTest2(String type, String IP1, String IP2) {
- new PingTestTask().execute(type, IP1, IP2);
- }
- // =================================================================================================
- // [[ Touch & Key Event ]] region
- // =================================================================================================
- /**
- * 본 클래스에서 등록한 [WpadImageView] [WpadTextView] 의 TouchEvent 가 있을시 호출됨
- */
- @Override
- protected void onTouchEvent(View v, MotionEvent event)
- {
- super.onTouchEvent(v, event);
- int TargetId = v.getId();
- int MoveEvent = event.getAction();
- if(MoveEvent == MotionEvent.ACTION_UP)
- {
- if(TargetId == ID.configMobileDeviceAddScreen.button.REG)
- {
- // [등록]
- DebugLogOutput("onTouchEvent [REG] BUTTON !!!");
- if(((MainActivity)getContext()).myIP.equals("10.1.1.1")) {
- doPingTest2("reg", "10.1.2.1", "10.1.3.1");
- /*
- if (mData.DataList.size() >= MAX_MOBILE_USER_CNT) {
- // 등록개수가 최대 개수(100개) 이상
- Sound().Play(SND.effect.WARNING005);
- Toast.makeText(getContext(), "모바일 기기는 " + MAX_MOBILE_USER_CNT + "대를 초과할 수 없습니다.", Toast.LENGTH_SHORT).show();
- } else {
- Sound().Play(SND.effect.TOUCH_LATCHED);
- boolean bRet = ((MainActivity) (getContext())).StartPopup(ID.screen.PopupMobileDeviceAdd);
- if (bRet) {
- // 자동종료 타이머 삭제
- bRet = super.setFinishTimerDestroy();
- DebugLogOutput("setFinishTimerDestroy = " + bRet);
- // LCD 항상 켜져 있게 하는 기능
- ((Activity) this.getContext()).getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
- }
- }
- */
- } else {
- Sound().Play(SND.effect.TOUCH_LATCHED);
- ((MainActivity)(getContext())).StartPopup(ID.screen.PopupMobileNotUseConfirm);
- }
- }
- else if(TargetId == ID.configMobileDeviceAddScreen.button.DEL)
- {
- // [삭제]
- DebugLogOutput("onTouchEvent [DEL] BUTTON !!!");
- Sound().Play(SND.effect.TOUCH_LATCHED);
- if(((MainActivity)getContext()).myIP.equals("10.1.1.1")) {
- doPingTest2("del", "10.1.2.1", "10.1.3.1");
- /*
- Intent data = new Intent();
- int Number = (chartView.getCurEnabledIndex() + 1) + (mData.CurPageIdx * ChartView.ROWS_COUNT);
- data.putExtra("DEL_TYPE", 1); // 개별삭제
- data.putExtra("DEL_NAME", mData.DataList.get(Number - 1).Name); // 개별 NAME
- data.putExtra("DEL_UID", mData.DataList.get(Number - 1).Uid); // 개별 UID
- // Log.d(TAG, "[onTouchEvent] Number [" + Number + "]");
- // 방문객원격통화 사용자 DB에서 삭제
- if (MainActivity.bRemoteCallUse) {
- if (mData.DataList.get(Number - 1).Name.contains("remotecall_")) {
- if (wallPadRemoteCallUserData != null) {
- nRemoteCallUserCnt = wallPadRemoteCallUserData.GetRemoteCallUserCnt();
- Log.d(TAG, "[onTouchEvent] nRemoteCallUserCnt [" + nRemoteCallUserCnt + "]");
- if (nRemoteCallUserCnt > 0) {
- List<RemoteCallUserClass> dataList = wallPadRemoteCallUserData.GetRemoteCallUserData();
- if (dataList != null) {
- for (int i = 0; i < dataList.size(); i++) {
- // Log.d(TAG, "[onTouchEvent] dataList.get(" + i + ").Name = " + dataList.get(i).Name);
- // Log.d(TAG, "[onTouchEvent] mData.DataList.get(" + (Number - 1) + ").Name = " + mData.DataList.get(Number - 1).Name);
- if (mData.DataList.get(Number - 1).Name.equals("remotecall_".concat(dataList.get(i).Name))) {
- String targetPhoneKey = dataList.get(i).PhoneKey; // 삭제할 방문객원격통화 사용자의 phonekey
- Log.d(TAG, "[onTouchEvent] targetPhoneKey [" + targetPhoneKey + "]");
- data.putExtra("DEL_PHONEKEY", targetPhoneKey);
- }
- }
- }
- }
- }
- }
- }
- ((MainActivity) (getContext())).StartPopup(ID.screen.PopupMobileDeviceDel, data);
- // 자동종료 타이머 삭제
- boolean bRet = super.setFinishTimerDestroy();
- DebugLogOutput("setFinishTimerDestroy = " + bRet);
- // LCD 항상 켜져 있게 하는 기능
- ((Activity) this.getContext()).getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
- */
- } else {
- ((MainActivity)(getContext())).StartPopup(ID.screen.PopupMobileNotUseConfirm);
- }
- }
- else if(TargetId == ID.configMobileDeviceAddScreen.button.ALLDEL)
- {
- if(((MainActivity)getContext()).myIP.equals("10.1.3.1")) {
- doPingTest2("alldel", "10.1.2.1", "10.1.3.1");
- /*
- if (mData == null) return;
- if (mData.DataList == null) return;
- int size = mData.DataList.size();
- if (size == 0) {
- // [INIT]
- DebugLogOutput("onTouchEvent [ALLDEL] - INIT BUTTON !!!");
- Sound().Play(SND.effect.TOUCH_LATCHED);
- ((MainActivity) (getContext())).StartPopup(ID.screen.PopupMobileDeviceInit);
- } else if (size > 0) {
- // [전체 삭제]
- DebugLogOutput("onTouchEvent [ALLDEL] DELETE BUTTON !!!");
- Sound().Play(SND.effect.TOUCH_LATCHED);
- Intent data = new Intent();
- data.putExtra("DEL_TYPE", 2); //전체삭제
- // 제휴사 삭제를 구분하기 위한 용도로 추가함 yskim
- String KindName = "";
- for (int i = 0; i < mData.DataList.size(); i++) {
- KindName += mData.DataList.get(i).Name;
- KindName += "_";
- }
- data.putExtra("DEL_NAME", KindName); // 개별 NAME
- ((MainActivity) (getContext())).StartPopup(ID.screen.PopupMobileDeviceDel, data);
- // 자동종료 타이머 삭제
- boolean bRet = super.setFinishTimerDestroy();
- DebugLogOutput("setFinishTimerDestroy = " + bRet);
- // 방문객원격통화 사용자 DB 전체 삭제
- if (MainActivity.bRemoteCallUse) {
- if (wallPadRemoteCallUserData != null)
- wallPadRemoteCallUserData.DeleteAllRemoteCallUserInfo();
- }
- // LCD 항상 켜져 있게 하는 기능
- ((Activity) this.getContext()).getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
- */
- } else {
- Sound().Play(SND.effect.TOUCH_LATCHED);
- ((MainActivity)(getContext())).StartPopup(ID.screen.PopupMobileNotUseConfirm);
- }
- }
- else if((TargetId == ID.configMobileDeviceAddScreen.button.NEXT) || (TargetId == ID.configMobileDeviceAddScreen.button.BEFORE))
- {
- // [LIST NEXT]
- DebugLogOutput("onTouchEvent [NEXT] BUTTON !!!");
- if(mData.MaxPageIdx > 0)
- {
- Sound().Play(SND.effect.TOUCH_LATCHED);
- if(++mData.CurPageIdx > mData.MaxPageIdx) mData.CurPageIdx = 0;
- chartView.Enable(0);
- Draw_Update();
- }
- }
- else if((TargetId >= ID.configMobileDeviceAddScreen.button.LIST1) && (TargetId <= ID.configMobileDeviceAddScreen.button.LIST5))
- {
- // [LIST1 ~ LIST5]
- int index = TargetId - ID.configMobileDeviceAddScreen.button.LIST1;
- DebugLogOutput("onTouchEvent [LIST" + (index+1) + "] BUTTON !!!");
- if(chartView.getCurEnabledIndex() != index)
- {
- Sound().Play(SND.effect.TOUCH_LATCHED);
- chartView.Enable(index);
- }
- }
- }
- }
- // =================================================================================================
- // [[ Draw ]] region
- // =================================================================================================
- /**
- * 변경되는 이미지를 다시 그린다.
- *
- */
- private void Draw_Update()
- {
- // 1. 범위체크
- if(mData == null) return;
- if(mData.DataList == null) return;
- // 2. 차트 데이터 업데이트
- Draw_ChartUpdate();
- // 3. 데이터가 없을시 [삭제] , [전체삭제] 버튼을 비활성화 한다.
- if(mData.DataList.size() == 0)
- {
- DelBtn.setButtonEventOffEnable(R.drawable.btn_mobilereg_del_disabled);
- //AllDelBtn.setButtonEventOffEnable(R.drawable.btn_mobilereg_alldel_disabled);
- ListPageText.setText("");
- // 전체삭제 버튼 아래쪽에 "초기화" 문구 추가해주기
- }
- else
- {
- DelBtn.setButtonEventOffDisable();
- //AllDelBtn.setButtonEventOffDisable();
- // 전체삭제-초기화 문구 안보이게 함
- }
- // 4. 총 페이지 수에 따라서, NEXT 버튼의 활성화/비활성화 설정
- if(mData.MaxPageIdx == 0)
- {
- BeforeBtn.setButtonEventOffEnable(R.drawable.add_notice_btn_up_disable);
- NextBtn.setButtonEventOffEnable(R.drawable.add_notice_btn_down_disable);
- }
- else
- {
- NextBtn.setButtonEventOffDisable();
- BeforeBtn.setButtonEventOffDisable();
- }
- }
- /**
- * 차트에 텍스트 데이터 및 포인터를 업데이트 한다.
- */
- private void Draw_ChartUpdate()
- {
- // 1. 범위체크
- if(chartView == null) return;
- if(mData.DataList == null) return;
- int size = mData.DataList.size();
- int index = 0;
- for(int i=0 ; i<ChartView.ROWS_COUNT ; i++)
- {
- index = i + (mData.CurPageIdx * ChartView.ROWS_COUNT);
- if(index < size)
- {
- try
- {
- chartView.Input(i, index+1, mData.DataList.get(index).Name,
- mData.DataList.get(index).regdate);
- }
- catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- chartView.Input(i, 0, null, null);
- }
- catch (Exception e) {
- Log.e(TAG, "[ExceptionError] - Draw_ChartUpdate : " + e);
- chartView.Input(i, 0, null, null);
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- else chartView.Input(i, 0, null, null);
- }
- if(size > 0)
- {
- if(chartView.CurEnabledIndex < 0) chartView.CurEnabledIndex = 0;
- ListPageText.setText((mData.CurPageIdx + 1) + "/" + (mData.MaxPageIdx+1));
- }
- }
- /**
- * 방문객원격통화 라이브러리를 초기화한다.
- */
- private void initRemoteCallLib() {
- try {
- // 통화App 방문객원격통화 서비스로 사용자 초기화 BR 전송
- Intent intent = new Intent();
- intent.setAction(Common.BR.VISITOR_REMOTE_CALL);
- intent.putExtra(define.NOTIBR_KIND, define.NOTIFY_EVENT_REMOTECALL_USER_INITIALIZE);
- getContext().sendBroadcast(intent);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] initRemoteCallLib()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- /**
- * 방문객원격통화 사용자를 삭제한다.
- */
- private void deleteRemoteCallUser(String strPhoneKey) {
- try {
- Log.d(TAG, "[deleteRemoteCallUser] strPhoneKey [" + strPhoneKey + "]");
- if (strPhoneKey != null) {
- // 방문객원격통화 사용자 DB 삭제
- if (wallPadRemoteCallUserData != null) {
- wallPadRemoteCallUserData.DeleteRemoteCallUserPhoneKey(strPhoneKey);
- // 사용자 삭제할 경우 통화 App 방문객원격통화 서버로 사용자 PhoneKey 전송
- Intent sendIntent = new Intent();
- sendIntent.setAction(Common.BR.VISITOR_REMOTE_CALL);
- sendIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_EVENT_REMOTECALL_USER_DELETE);
- sendIntent.putExtra(define.NOTIBR_REMOTECALL_USER_DELETE_PHONEKEY, strPhoneKey);
- getContext().sendBroadcast(sendIntent);
- nRemoteCallUserCnt = wallPadRemoteCallUserData.GetRemoteCallUserCnt();
- Log.d(TAG, "[deleteCallUser] nRemoteCallUserCnt [" + nRemoteCallUserCnt + "]");
- }
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] deleteCallUser(String strPhoneKey)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- private void deleteRemoteCallUser(String strPhoneKey, String strUid) {
- try {
- Log.d(TAG, "[deleteRemoteCallUser] strPhoneKey [" + strPhoneKey + "], strUid [" + strUid + "]");
- if (strPhoneKey != null) {
- // 방문객원격통화 사용자 DB 삭제
- if (wallPadRemoteCallUserData != null) {
- wallPadRemoteCallUserData.DeleteRemoteCallUserPhoneKey(strPhoneKey);
- // 사용자 삭제할 경우 통화 App 방문객원격통화 서버로 사용자 PhoneKey 전송
- Intent sendIntent = new Intent();
- sendIntent.setAction(Common.BR.VISITOR_REMOTE_CALL);
- sendIntent.putExtra(define.NOTIBR_KIND, define.NOTIFY_EVENT_REMOTECALL_USER_DELETE);
- sendIntent.putExtra(define.NOTIBR_REMOTECALL_USER_DELETE_PHONEKEY, strPhoneKey);
- getContext().sendBroadcast(sendIntent);
- nRemoteCallUserCnt = wallPadRemoteCallUserData.GetRemoteCallUserCnt();
- Log.d(TAG, "[deleteRemoteCallUser] nRemoteCallUserCnt [" + nRemoteCallUserCnt + "]");
- DB_Delete(strUid);
- DB_Load();
- Draw_Update();
- if (mData.DataList.size() > 0) chartView.Enable(0);
- else chartView.Disable();
- }
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] deleteCallUser(String strPhoneKey, String strUid)");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- // 모바일 기기 사용자 목록 중 방문객원격통화 사용자만 삭제
- private void deleteAllRemoteCallUser(final String sPhoneKey, String sName, final String sUid) {
- try {
- Log.d(TAG, "[deleteAllRemoteCallUser] nRemoteCallUserCnt [" + nRemoteCallUserCnt + "], sPhoneKey [" + sPhoneKey + "], sName[" + sName + "], sUid [" + sUid + "]");
- if (imapDeleteNewMobileDevice == null) imapDeleteNewMobileDevice = new iMAPDeleteNewMobileDevice(getContext());
- imapDeleteNewMobileDevice.DoWork(sName, sUid);
- imapDeleteNewMobileDevice.SetRetCtr(new RetProci() {
- @Override
- public void ProcSuccess() {
- DebugLogOutput("[deleteAllRemoteCallUser] - ProcSuccess");
- deleteRemoteCallUser(sPhoneKey, sUid);
- }
- @Override
- public void ProcError() {
- DebugLogOutput("[deleteAllRemoteCallUser] - ProcError");
- }
- @Override
- public void ProcDoing() {
- DebugLogOutput("[deleteAllRemoteCallUser] - ProcDoing");
- }
- });
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] deleteAllRemoteCallUser()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- // BR 관련
- private void registerBRReceiver() {
- try {
- IntentFilter filter = new IntentFilter();
- filter.addAction(Common.BR.VISITOR_REMOTE_CALL);
- getContext().registerReceiver(mRemoteCallBR, filter, null, null);
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] registerBRReceiver()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- private void unregisterBRReceiver() {
- try {
- if (mRemoteCallBR != null) {
- getContext().unregisterReceiver(mRemoteCallBR);
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] unregisterBRReceiver()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- BroadcastReceiver mRemoteCallBR = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- try {
- String strAction = intent.getAction();
- if (strAction.equals(Common.BR.VISITOR_REMOTE_CALL)) {
- // 방문객 원격통화 관리 팝업에서 초기화 실행할 경우 모바일 기기 리스트에서도 삭제
- boolean bRefresh = intent.getBooleanExtra("REFRESH", false);
- // Log.d(TAG, "[mRemoteCallBR.onReceive] bRefresh [" + bRefresh + "]");
- if (bRefresh) {
- boolean bInitialize = intent.getBooleanExtra("INITIALIZE", false);
- // Log.d(TAG, "[mRemoteCallBR.onReceive] bInitialize [" + bInitialize + "]");
- if (bInitialize) {
- for (int i = 0; i < mData.DataList.size(); i++) {
- String sName = mData.DataList.get(i).Name;
- if (sName.contains("remotecall_")) { // 통합서버에서 사용자 별칭에 서비스가 태깅되어 전달됨
- Log.d(TAG, "[mRemoteCallBR.onReceive] sName [" + sName + "]");
- initRemoteCallLib();
- ArrayList<String> phoneKey = intent.getStringArrayListExtra("REMOTECALLUSER_PHONEKEY");
- ArrayList<String> name = intent.getStringArrayListExtra("REMOTECALLUSER_NAME");
- if (phoneKey != null && name != null) {
- for (int j = 0; j < name.size(); j++) {
- // Log.d(TAG, "[mRemoteCallBR.onReceive] mData.DataList.get(" + i + ").Name = " + mData.DataList.get(i).Name);
- // Log.d(TAG, "[mRemoteCallBR.onReceive] name.get(" + j + ") = " + name.get(j));
- if (mData.DataList.get(i).Name.equals("remotecall_".concat(name.get(j)))) {
- deleteAllRemoteCallUser(phoneKey.get(j), name.get(j), mData.DataList.get(i).Uid); // imap 통신하여 사용자 삭제
- Thread.sleep(1000);
- }
- }
- }
- }
- }
- }
- }
- }
- } catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- } catch (Exception e) {
- Log.e(TAG, "[Exception] mRemoteCallBR.onReceive()");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- }
- }
- };
- // =================================================================================================
- // [[ Device ]] region
- // =================================================================================================
- // =================================================================================================
- // [[ DB ]] region
- // =================================================================================================
- /*
- * DB 를 연결한다.
- *
- * @return (boolean) true : 성공, false : 실패
- */
- private boolean DB_Open()
- {
- try
- {
- wallpadMobileDeviceData = new WallpadMobileDeviceData(getContext());
- if (MainActivity.bRemoteCallUse) {
- wallPadRemoteCallUserData = new WallPadRemoteCallUserData(getContext());
- }
- }
- catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- wallpadMobileDeviceData = null;
- wallPadRemoteCallUserData = null;
- return false;
- }
- catch (Exception e) {
- Log.e(TAG, "[DB_Open] [ExceptionError] - new wallpadMobileDeviceData / wallPadRemoteCallUserData");
- wallpadMobileDeviceData = null;
- wallPadRemoteCallUserData = null;
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return false;
- }
- return true;
- }
- /**
- * DB 를 닫는다.
- *
- * @return (boolean) true : 성공, false : 실패
- */
- private boolean DB_Close()
- {
- try
- {
- if(wallpadMobileDeviceData != null) wallpadMobileDeviceData.closeDB();
- if(wallPadRemoteCallUserData != null) wallPadRemoteCallUserData.closeDB();
- }
- catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- wallpadMobileDeviceData = null;
- wallPadRemoteCallUserData = null;
- return false;
- }
- catch (Exception e) {
- Log.e(TAG, "[DB_Close] [ExceptionError] - closeDB wallpadMobileDeviceData");
- wallpadMobileDeviceData = null;
- wallPadRemoteCallUserData = null;
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return false;
- }
- return true;
- }
- /*
- /**
- * DB 데이터를 읽어온다.
- *
- * @return (boolean) true : 성공, false : 실패
- */
- private boolean DB_Load()
- {
- DebugLogOutput("[DB_Load] Start");
- if(wallpadMobileDeviceData == null)
- {
- Log.w(TAG, "[DB_Load] wallpadMobileDeviceData is null !!!");
- return false;
- }
- if (MainActivity.bRemoteCallUse) {
- if (wallPadRemoteCallUserData == null) {
- Log.w(TAG, "[DB_Load] wallPadRemoteCallUserData is null !!!");
- return false;
- }
- }
- try
- {
- mData.DataList = wallpadMobileDeviceData.GetMobileDeviceData();
- }
- catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return false;
- }
- catch (Exception e) {
- Log.e(TAG, "[ExceptionError] - DB_Load -> GetMobileDeviceData : " + e);
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return false;
- }
- if(mData.DataList == null)
- {
- Log.w(TAG, "[DB_Load] mData.DataList is null !!!");
- mData.DataList = new ArrayList<MobileDeviceClass>();
- return false;
- }
- int size = mData.DataList.size( );
- if(size <= ChartView.ROWS_COUNT) mData.MaxPageIdx = 0;
- else mData.MaxPageIdx = (size-1) / ChartView.ROWS_COUNT;
- if(mData.CurPageIdx > mData.MaxPageIdx) mData.CurPageIdx = 0;
- // Debug Msg
- DebugLogOutput(wallpadMobileDeviceData.ToDebugMobileDeviceData(mData.DataList));
- DebugLogOutput("[DB_Load] OK!!!");
- return true;
- }
- /**
- * DB 에 해당 인덱스 데이터를 삭제한다.
- *
- * @param Uid - 삭제할 Uid
- *
- * @return (boolean) true : 성공, false : 실패
- */
- private boolean DB_Delete(String Uid)
- {
- if(Uid == null) return false;
- if(wallpadMobileDeviceData == null) return false;
- if(mData.DataList == null) return false;
- try
- {
- wallpadMobileDeviceData.DeleteEachUid(Uid);
- }
- catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return false;
- }
- catch (Exception e) {
- Log.e(TAG, "[ExceptionError] - wallpadMobileDeviceData.DeleteEachUid");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return false;
- }
- return true;
- }
- /**
- * DB 에 데이터를 모두 삭제한다.
- *
- * @return (boolean) true : 성공, false : 실패
- */
- private boolean DB_DeleteAll()
- {
- if(wallpadMobileDeviceData == null) return false;
- try
- {
- wallpadMobileDeviceData.UnRegisterAll();
- }
- catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- return false;
- }
- catch (Exception e) {
- Log.e(TAG, "[ExceptionError] - wallpadSmartKeyRegData.UnRegisterAll");
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- return false;
- }
- return true;
- }
- }
|