package kr.co.icontrols.wallpadconfig; import android.annotation.SuppressLint; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.graphics.Color; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.util.Log; import android.view.Gravity; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.View; import android.view.View.OnTouchListener; import android.view.animation.AccelerateInterpolator; import android.view.animation.Animation; import android.view.animation.Animation.AnimationListener; import android.view.animation.TranslateAnimation; import android.widget.Button; import android.widget.ExpandableListView; import android.widget.ExpandableListView.OnGroupClickListener; import android.widget.ExpandableListView.OnGroupCollapseListener; import android.widget.ExpandableListView.OnGroupExpandListener; import android.widget.RelativeLayout; import com.artncore.WallPadDataMgr.WallpadDeviceSet; import com.artncore.WallPadDataMgr.WallpadStatusData; import com.artncore.WallPadDataMgr.wallpaddbmgr; import com.artncore.commons.API_Menu; import com.artncore.commons.API_Menu.MenuListDataClass; import com.artncore.commons.API_Menu.MenuListDataClass.ChildIDMapping; import com.artncore.commons.define; import com.artncore.wallpadapi.WallPadAPI; import com.util.LogUtil; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import java.io.File; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.net.InetSocketAddress; import java.net.Socket; import java.sql.Timestamp; import java.text.SimpleDateFormat; import java.util.ArrayList; import kr.co.icontrols.ReliefCall.ReliefCallInterface; import kr.co.icontrols.wallpadconfig.declare.Common; import kr.co.icontrols.wallpadconfig.declare.Common.JSON; import kr.co.icontrols.wallpadconfig.declare.ID; import kr.co.icontrols.wallpadconfig.screen.ConfigCleanLcdMainScreen; import kr.co.icontrols.wallpadconfig.screen.ConfigHSPlatformDeviceListScreen; import kr.co.icontrols.wallpadconfig.screen.ConfigInKakaoiMainScreen; import kr.co.icontrols.wallpadconfig.screen.ConfigInRoomSensorMainScreen; import kr.co.icontrols.wallpadconfig.screen.ConfigInWifiMainScreen; import kr.co.icontrols.wallpadconfig.screen.ConfigMobileDeviceAddScreen; import kr.co.icontrols.wallpadconfig.screen.ConfigMoningCallMainScreen; import kr.co.icontrols.wallpadconfig.screen.ConfigPwChangeMainScreen; import kr.co.icontrols.wallpadconfig.screen.ConfigRfCardMainScreen; import kr.co.icontrols.wallpadconfig.screen.ConfigSettingMainScreen; import kr.co.icontrols.wallpadconfig.screen.ConfigSmartKeyMainScreen; import kr.co.icontrols.wallpadconfig.screen.ConfigTimeSetScreen; import kr.co.icontrols.wallpadsupport.Version; 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.WpadScale; import kr.co.icontrols.wallpadsupport.WpadSound; import kr.co.icontrols.wallpadsupport.WpadSound.SND; import kr.co.icontrols.wallpadsupport.WpadTextView; import kr.co.icontrols.wallpadsupport.WpadUtil; import static android.content.Intent.ACTION_TIME_TICK; import static kr.co.icontrols.wallpadconfig.screen.ConfigInRoomSensorMainScreen.SELECT_START_TIME; /** * @description * 월패드 [설정기능] 메인화면 이다.
* 상단의 Top 메뉴, [홈] [돌아가기]
* 좌측의 Tab 메뉴, [환경설정] [화면청소] [비밀번호변경] ... 등 선택 메뉴
* 를 여기서 처리한다. */ public class MainActivity extends WpadActivity { private final static String TAG = "MainActivity"; private final boolean DEBUG_LOG_ON = true; private void DebugLogOutput(String s) { if(DEBUG_LOG_ON) Log.d(TAG, s); } // ================================================================================================= // [[ Declaration ]] region // ================================================================================================= protected Context mContext = null; public Context getContext() { return mContext; } private WallPadAPI mWallPadAPI = null; private int OPERATION_MODE = Common.MODE; private WallpadStatusData wdb = null; public static ReliefCallInterface mReliefCallIF; // 안심통화 솔루션 라이브러리 // Layout private RelativeLayout AllLayout; // 화면 전체 private RelativeLayout TopLayout; // 상단 메뉴 private RelativeLayout ScreenLayout; // 메인 화면 private RelativeLayout MenuLayout; // 메뉴 화면 // Top Menu private WpadImageView TopBackground; private WpadTextView TopTitle; private WpadImageView TopHomeBtn,TopBackBtn, TopMenuBtn, TopSetBtn; private WpadImageView TopManualBtn; private WpadImageView BackBtn_InRoom; // Main private WpadImageView ScreenBackground; // Menu private WpadImageView MenuBackground; private WpadImageView MenuClose; private WpadTextView MenuTitle; private static ExpandableListView mListView; private Menu_AdptMain adptMain; private MenuListDataClass menueListDataClass; private Menu mMenu = null; //WPadAPI의 Menu class private boolean MenuOpen = false; private int mTempCurrentScreenId = -1; public static boolean bRemoteCallUse = false; // 방문객원격통화 사용 설정 유무 // PopupActivityRun private static boolean PopupActivityRun = false; public static boolean getPopupActivityRun() { return PopupActivityRun; } public static void setPopupActivityRun(boolean run) { PopupActivityRun = run; } // CurrentScreenId private int mCurrentScreenId = -1; public static WpadSound mSound; // Screen private ConfigSettingMainScreen configSettingMainScreen = null; private ConfigCleanLcdMainScreen configCleanLcdMainScreen = null; private ConfigPwChangeMainScreen configPwChangeMainScreen = null; //private ConfigSkinChangeScreen configGLESkinChangeMainScreen = null; private ConfigMoningCallMainScreen configMoningCallMainScreen = null; private ConfigSmartKeyMainScreen configSmartKeyMainScreen = null; private ConfigRfCardMainScreen configRfCardMainScreen = null; private ConfigTimeSetScreen configTimeSetScreen = null; //private ConfigHandicappedModeScreen configHandicappedModeScreen = null; //private ConfigNoiseLogMainScreen configNoiseLogMainScreen = null; private ConfigMobileDeviceAddScreen configMobileDeviceAddScreen = null; private ConfigInRoomSensorMainScreen configInRoomSensorMainScreen = null; private ConfigHSPlatformDeviceListScreen configHSPlatformDeviceListScreen = null; //Wifi private ConfigInWifiMainScreen configWifiMainScreen = null; private ConfigInKakaoiMainScreen configInKakaoiMainScreen = null; public WallpadStatusData GetDBObj() { return wdb; } public static int mCurrentManualScreenId = -1; // ================================================================================================= // [[ Activity Life Cycle ]] region // ================================================================================================= /** * Activity Constructors */ @Override protected void onCreate(Bundle savedInstanceState) { Log.i(TAG, "-------------------------------------------------------------"); Log.i(TAG, "------------------ [START - MainActivity] -------------------"); Log.i(TAG, "-------------------------------------------------------------"); super.onCreate(savedInstanceState); // @ AutoScale 설정 WpadScale.setAutoScale(true); super.AppVersionLogOut(); // [APP Version] + [WallPadSupport Lib Version] 을 로그로 출력한다. Log.i("Version", "<><><><> WallPadAPI Version = [" + define.WALLPADAPI_VERSION + "] " + "<><><><>"); // 1. 변수 초기화 DebugLogOutput("[Create] - Step1 : Data Create"); PopupActivityRun = false; mContext = this; mSound = new WpadSound(this); // 2. 자동 종료 셋팅 DebugLogOutput("[Create] - Step2 : Auto Finish Setting"); // 2-1. 자동종료 타이머 셋팅 if(Common.FINISH_TIME_ENABLE) super.setFinishTimerCreate(Common.FINISH_TIME_SEC); // 3. API 호출 DebugLogOutput("[Create] - Step3 : API Call"); // 3.1. mWallPadAPI 생성 if (OPERATION_MODE == Common.MODE_NOMAL) { mTempCurrentScreenId = API_Menu.SubMenuConfig.Configuration; Log.d(TAG, "OperationMode = MODE_NOMAL"); try { mWallPadAPI = new WallPadAPI(this); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch(Exception e) { Log.e(TAG, "[ExceptionError] - new WallPadAPI : " + e); } } else if (OPERATION_MODE == Common.MODE_BUSINESS_SAMPLE) { Log.d(TAG, "OperationMode = MODE_BUSINESS_SAMPLE"); } try { wdb = new WallpadStatusData(this); wallpaddbmgr.AddressSet addc = wdb.getAddressMGR(); //DB에서 동호 정보 받아옴 //동, 호, ip 정보 저장 myIP = addc.IPAddress; myHo = addc.Ho; ho = Integer.valueOf(myHo.substring(0,1)); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[ExceptionError] - onCreate->WallpadStatusData Create : " + e); } CheckIsFolderMake(); // 4. Layout registration DebugLogOutput("[Create] - Step4 : Layout registration"); // 4-1. mainLayout AllLayout = new RelativeLayout(this); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(WpadScale.getWidthPixels(), WpadScale.getHeightPixels()); AllLayout.setLayoutParams(params); AllLayout.setId(ID.main.layout.ALL); super.setAllLayoutRegistration(AllLayout); // 4-2. TopLayout TopLayout = new RelativeLayout(this); WpadUtil.LayoutRegistration(AllLayout, TopLayout, 1280, 110, 0, 0, ID.main.layout.TOP); // 4-4. ScreenLayout ScreenLayout = new RelativeLayout(this); WpadUtil.LayoutRegistration(AllLayout, ScreenLayout, 1280, 690, 0, 110, ID.main.layout.SCREEN); ScreenBackground = new WpadImageView(this, TOUCH_KIND.NONE, 1280, 690, R.drawable.bg_body, R.drawable.bg_body, ID.main.image.SCREEN_BACKGROUND); ViewRegistration(ScreenLayout, ScreenBackground, 0, 0); // 5. Top Menu - ImageView registration DebugLogOutput("[Create] - Step5 : Top Menu - ImageView registration"); TopBackground = new WpadImageView(this, TOUCH_KIND.NONE, 1280, 110, R.drawable.bg_topbar, R.drawable.bg_topbar, ID.main.image.TOP_BACKGROUND); ViewRegistration(TopLayout, TopBackground, 0, 0); TopTitle = new WpadTextView(this, false, 247+180, 80, Gravity.LEFT, Color.WHITE, Common.fontsize._44, true, ID.main.text.TITLE); ViewRegistration(TopLayout, TopTitle, 133, 15); TopHomeBtn = new WpadImageView(this, TOUCH_KIND.BUTTON, 110, 110, R.drawable.topbar_icon_home_normal, R.drawable.topbar_icon_home_pressed, ID.main.button.HOME); ViewRegistration(TopLayout, TopHomeBtn, 1145, 0); TopBackBtn = new WpadImageView(this, TOUCH_KIND.BUTTON, 110, 110, R.drawable.topbar_icon_back_normal, R.drawable.topbar_icon_back_pressed, ID.main.button.BACK); ViewRegistration(TopLayout, TopBackBtn, 1019, 0); setTopBackBtnVisible(false); TopMenuBtn = new WpadImageView(this, TOUCH_KIND.BUTTON, 110, 110, R.drawable.topbar_icon_menu_normal, R.drawable.topbar_icon_menu_pressed, ID.main.button.MENU); ViewRegistration(TopLayout, TopMenuBtn, 0, 0); TopSetBtn = new WpadImageView(this, TOUCH_KIND.BUTTON, 110, 110, R.drawable.topbar_icon_set_normal, R.drawable.topbar_icon_set_pressed, ID.main.button.SETTING); ViewRegistration(TopLayout, TopSetBtn, 1019, 0); setTopSetBtnVisible(false); TopManualBtn = new WpadImageView(this, TOUCH_KIND.BUTTON, 110, 110, R.drawable.topbar_icon_manual_normal, R.drawable.topbar_icon_manual_pressed, ID.main.button.MENUAL); setManualBtnVisible(getManualUse(), 1019); BackBtn_InRoom = new WpadImageView(this, TOUCH_KIND.BUTTON, 110, 110, R.drawable.topbar_icon_back_normal, R.drawable.topbar_icon_back_pressed, ID.main.button.BACK_INROOM); ViewRegistration(TopLayout, BackBtn_InRoom, 1020, 0); Set_BackBtn_InroomVisible(false); WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(mContext); int[] DoorCamKind = wallpadDeviceSet.Get_RFDoorCAM_Info(); // 현관카메라 종류 파악 //int noiseUse = wallpadDeviceSet.Get_NoiseSensor_Use(); int mobileAuth = wallpadDeviceSet.Get_MobileAppAuth_Use(); bRemoteCallUse = wallpadDeviceSet.Get_RemoteCall_Use() > 0 ? true : false; int inroomDetectUse = wallpadDeviceSet.Get_InnerRoomDetectSensor_Use(); int[] naKeyType = wallpadDeviceSet.Get_BLESmartKey_Info(); // 출입키 종류 boolean bHSPlatform = wallpadDeviceSet.Get_HS_PlatformUse(); // 효성플랫폼 연동 wallpadDeviceSet.closeDB(); int DcamSetting = 0; if (DoorCamKind.length == 2) { if (DoorCamKind[0] == 1) { // 사용함 if (DoorCamKind[1] == WallpadDeviceSet.DOORTYPE_SMARTKEY) { DcamSetting = WallpadDeviceSet.DOORTYPE_SMARTKEY; } else if (DoorCamKind[1] == WallpadDeviceSet.DOORTYPE_SMARTKEY_EXTERNAL) { DcamSetting = WallpadDeviceSet.DOORTYPE_SMARTKEY_EXTERNAL; } else if (DoorCamKind[1] == WallpadDeviceSet.DOORTYPE_RFCAM) { DcamSetting = WallpadDeviceSet.DOORTYPE_RFCAM; } else if (DoorCamKind[1] == WallpadDeviceSet.DOORTYPE_IOT_SMART) { DcamSetting = WallpadDeviceSet.DOORTYPE_IOT_SMART; } else if (DoorCamKind[1] == WallpadDeviceSet.DOORTYPE_HYOSUNG_SMART) { DcamSetting = WallpadDeviceSet.DOORTYPE_HYOSUNG_SMART; } else if (DoorCamKind[1] == WallpadDeviceSet.DOORTYPE_DAEWOO_SMART) { DcamSetting = WallpadDeviceSet.DOORTYPE_DAEWOO_SMART; } else if (DoorCamKind[1] == WallpadDeviceSet.DOORTYPE_HDCAM) { DcamSetting = WallpadDeviceSet.DOORTYPE_HDCAM; } else { //DOORTYPE_BASIC DcamSetting = WallpadDeviceSet.DOORTYPE_BASIC; } } } // 6. Menu Loading // 6-1. 메뉴 정보를 가져온다 (DB에서 가져온다) wallpaddbmgr WallpadDBMGR = new wallpaddbmgr(getApplicationContext()); //test WallpadDBMGR.DeleteMenuList(); ArrayList> mGroupList = null; ArrayList mChildList = null; mGroupList = new ArrayList>(); mChildList = new ArrayList(); mChildList.add(API_Menu.SubMenuConfig.Configuration); mChildList.add(API_Menu.SubMenuConfig.CleanLcd); mChildList.add(API_Menu.SubMenuConfig.PassWordChange); //mChildList.add(API_Menu.SubMenuConfig.SkinChange); //mChildList.add(API_Menu.SubMenuConfig.MorningCall); mChildList.add(API_Menu.SubMenuConfig.TimeSetting); Log.w(TAG, "[Create] DcamSetting = " + DcamSetting); if ((DcamSetting == WallpadDeviceSet.DOORTYPE_SMARTKEY) || (DcamSetting == WallpadDeviceSet.DOORTYPE_SMARTKEY_EXTERNAL) || (DcamSetting == WallpadDeviceSet.DOORTYPE_IOT_SMART) ) { if (naKeyType[1] == WallpadDeviceSet.BLESMARTKEY_BAND) mChildList.add(API_Menu.SubMenuConfig.SmartBand); else { //mChildList.add(API_Menu.SubMenuConfig.SmartKey); Log.w(TAG, "[Create] Smart IoT Doorcam suppots only Smartband(BLE)!!"); } } else if (DcamSetting == WallpadDeviceSet.DOORTYPE_RFCAM) { mChildList.add(API_Menu.SubMenuConfig.RfCard); } else { Log.w(TAG, "[Create] DcamSetting is not available!!! -> " + DcamSetting); } /*if(noiseUse == 1) { mChildList.add(API_Menu.SubMenuConfig.NoiseLog); }*/ Log.w(TAG, "[Create] mobileAuth = " + mobileAuth); if (mobileAuth == 1) { mChildList.add(API_Menu.SubMenuConfig.MobileDeviceReg); } else { Log.w(TAG, "[Create] mobileAuth is not available!!! -> " + mobileAuth); } Log.w(TAG, "[Create] inroomDetectUse = " + inroomDetectUse); if (inroomDetectUse == 1) { mChildList.add(API_Menu.SubMenuConfig.InRoomDetectSet); } else { Log.w(TAG, "[Create] inroomDetectUse is not available!!! -> " + inroomDetectUse); } //mChildList.add(API_Menu.SubMenuConfig.HandicappedPerson); //이진규 //카카오 홈 판단 여부 체크 WallpadDeviceSet wdst_ = new WallpadDeviceSet(getApplicationContext()); boolean kakaohomeuse = wdst_.Get_KakaoUse(); wdst_.closeDB(); if (kakaohomeuse) { mChildList.add(API_Menu.SubMenuConfig.KakaoHome); mChildList.add(API_Menu.SubMenuConfig.Wifi); } mGroupList.add(mChildList); if (bHSPlatform) { mChildList.add(API_Menu.SubMenuConfig.HSPlatformDevice); } else { Log.w(TAG, "[Create] bHSPlatform is not available!!! -> " + bHSPlatform); } for (int i = 0; i < mGroupList.size(); i++) { Log.i(TAG, "[Create] mGroupList.get(" + i + ") = " + mGroupList.get(i)); } WallpadDBMGR.SetMenuList(mGroupList); menueListDataClass = WallpadDBMGR.GetMenuList(); WallpadDBMGR.closeDB(); Log.i(TAG, "[Create] menueListDataClass.arrayChild = " + menueListDataClass.arrayChild.toString()); // for (int i = 0; i < menueListDataClass.arrayChild.size(); i++) { // Log.i(TAG, "[Create] mGroupList.get(" + i + ") = " + menueListDataClass.arrayChild.toString()); // } if (menueListDataClass == null) { Log.e(TAG, "[Create] menueListDataClass == null, Load Default List"); menueListDataClass = LoadDefaultMenuList(); } // 6-2. 시작 화면을 main APP으로 부터 받아서 처리한다. Log.i(TAG, "[Create] OPERATION_MODE is " + OPERATION_MODE); mMenu = new Menu(); mMenu = super.getIntentParsingMenu(getIntent()); if (mMenu == null) { //mWallPadApiCheckHandler.sendEmptyMessage(0); //setChangeScreen(API_Menu.SubMenuConfig.Configuration, false); Log.i(TAG, "[Create] mMenu = null"); if(CheckIntent()) { mTempCurrentScreenId = API_Menu.SubMenuConfig.Configuration; SetTitleText(API_Menu.SubMenuConfig.Name_Configuration); mWallPadApiCheckHandler.sendEmptyMessage(0); StartPopup(ID.screen.PopupWIFIConnect); } else { if (OPERATION_MODE == Common.MODE_NOMAL) { mTempCurrentScreenId = API_Menu.SubMenuConfig.Configuration; SetTitleText(API_Menu.SubMenuConfig.Name_Configuration); mWallPadApiCheckHandler.sendEmptyMessage(0); } else { setChangeScreen(API_Menu.SubMenuConfig.Configuration, false); } } } else { /*boolean result = setChangeScreen(mMenu.getStartId(), false); if(result == false) { mWallPadApiCheckHandler.sendEmptyMessage(0); //setChangeScreen(API_Menu.SubMenuConfig.Configuration, false); }*/ Log.i(TAG, "[Create] mMenu != null"); if (OPERATION_MODE == Common.MODE_NOMAL) { mTempCurrentScreenId = API_Menu.SubMenuConfig.Configuration; SetTitleText(API_Menu.SubMenuConfig.Name_Configuration); mWallPadApiCheckHandler.sendEmptyMessage(0); mTempCurrentScreenId = mMenu.getStartId(); setTitleName(mTempCurrentScreenId); mWallPadApiCheckHandler.sendEmptyMessage(0); } else { boolean result = setChangeScreen(mMenu.getStartId(), false); Log.i(TAG, "[Create] Menu Sample result = " + result); if (result == false) { setChangeScreen(API_Menu.SubMenuConfig.Configuration, false); } } } // 7. Draw DebugLogOutput("[Create] - Step7 : setContentView"); setContentView(AllLayout); // 8. Window ReSize DebugLogOutput("[Create] - Step8 : Window ReSize"); //super.WindowReSize(Common.SCREEN_SIZE_MAIN_W, Common.SCREEN_SIZE_MAIN_H, false); // 9. BR Receiver 등록(메뉴에서 다른 화면이 눌린 경우 BR처리) reg_Receiver(); registerKaKaOIBR(); WallpadDeviceSet wdst = new WallpadDeviceSet(getContext()); int[] lights = wdst.Get_Light_info(); wdst.closeDB(); for(int i = 0; i < lights.length; i++) { Log.i(TAG, "lights[" + i + "] = " + lights[i] + " ########################"); } String str = String.format("%.0f", 0.7); str += " kWh"; Log.i(TAG, "[Create] - DOT str = " + str + " ########################"); WallpadStatusData wsd = new WallpadStatusData(getContext()); String welcomeSaved = wsd.Get_WelcomeLight_Selected(); wsd.closeDB(); Log.i(TAG, "welcomeSaved = " + welcomeSaved + " $$$$$$$$$$$$$$$$$$$$$$$$$$"); // 안심통화 솔루션 라이브러리 import // if (getReliefCallUse()) { // Log.i(TAG, "[onCreate] --------------- ReliefCallInterface ---------------"); // mReliefCallIF = new ReliefCallInterface(); // } // 거주자 안전확인 서비스 사용여부 확인하고, 화면 WallPadSupport Lib.에 관련 설정을 한다. getResidentSafetyCheckSetting(); Log.i(TAG, "End onCreate -------------------------------------------------"); } //kr.co.icontrols.WIFIScreen 등록 BroadcastReceiver kakaoBroadCastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if(intent.getAction().equals("kr.co.icontrols.WIFIScreen")) { // mTempCurrentScreenId = API_Menu.SubMenuConfig.Configuration; // SetTitleText(API_Menu.SubMenuConfig.Name_Configuration); mWallPadApiCheckHandler.sendEmptyMessage(0); StartPopup(ID.screen.PopupWIFIConnect); } } }; private void registerKaKaOIBR() { try { IntentFilter filter = new IntentFilter(); filter.addAction("kr.co.icontrols.WIFIScreen"); mContext.registerReceiver(kakaoBroadCastReceiver, filter); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] registerMainActivityBR()"); LogUtil.errorLogInfo("", TAG, e); } } /** * 카카오에서 환경설정을 호출하는 경우 */ private boolean CheckIntent() { boolean result = false; //카카오 홈에서 WIFI를 호출하는 경우 Intent received_intent = getIntent(); if(received_intent!=null) { result = received_intent.getBooleanExtra("WIFI", false); } return result; } /** * (평생코드) WallPadAPI 초기생성시 Connect 에 시간이 걸리며,
* WallPadAPI 초기화후 바로 Get_GasValveController 등을 사용하여 API 를 가져올수 없기에,
* 본 딜레이 코드를 임시로 적용한다. */ @SuppressLint("HandlerLeak") protected Handler mWallPadApiCheckHandler = new Handler() { @SuppressLint("HandlerLeak") @Override public void handleMessage(Message msg) { if (msg.what == 0) { if (mWallPadAPI != null) { Log.w(TAG, "[mWallPadApiCheckHandler] WallPad API Loading!!!"); if (mWallPadAPI.Check_Connect()) { Log.d(TAG, "[mWallPadApiCheckHandler] WallPad API Connected!!"); mWallPadApiCheckHandler.sendEmptyMessageDelayed(1, 10); } else { Log.w(TAG, "[mWallPadApiCheckHandler] WallPad API not Connected, yet!!"); mWallPadApiCheckHandler.sendEmptyMessageDelayed(0, 10); } } } else if (msg.what == 1) { Log.d(TAG, "[mWallPadApiCheckHandler] WallPad API Loaded!!"); boolean bChangeScreen = setChangeScreen(mTempCurrentScreenId, false); Log.d(TAG, "[mWallPadApiCheckHandler] bChangeScreen [" + bChangeScreen + "]"); if (bChangeScreen == false) { setChangeScreen(API_Menu.SubMenuConfig.Configuration, false); } } //새로 추가한 부분 if (msg.what == 3) { if (mWallPadAPI != null) { Log.w(TAG, "[mWallPadApiCheckHandler] WallPad API Loading!!!"); if (mWallPadAPI.Check_Connect()) { Log.d(TAG, "[mWallPadApiCheckHandler] WallPad API Connected!!"); mWallPadApiCheckHandler.sendEmptyMessageDelayed(1, 10); } else { Log.w(TAG, "[mWallPadApiCheckHandler] WallPad API not Connected, yet!!"); mWallPadApiCheckHandler.sendEmptyMessageDelayed(0, 10); } } } else { Log.d(TAG, "[mWallPadApiCheckHandler] Not expected value!! Handler stop!! msg.what [" + msg.what +"]"); } } }; /** * TOP 설정 버튼 활성화 & 비활성화 * * @param bEnable - true : 활성화, false : 비활성화 * @return (boolean) true : 성공, false : 실패 */ public boolean setTopSetBtnVisible(boolean bEnable) { if (bEnable) { if (TopSetBtn.getVisibility() != View.VISIBLE) TopSetBtn.setVisibility(View.VISIBLE); TopSetBtn.bringToFront(); if (TopSetBtn.getVisibility() == View.VISIBLE) { WpadUtil.ViewMove(TopManualBtn, 893, 0); } } else { if (TopSetBtn.getVisibility() != View.INVISIBLE) TopSetBtn.setVisibility(View.INVISIBLE); if (TopSetBtn.getVisibility() == View.INVISIBLE) { WpadUtil.ViewMove(TopManualBtn, 1019, 0); } } return true; } /* ================================================================================================ * [Manual Activity] Section ================================================================================================ */ public static ManualActivity mManualActivity; public void setManualBtnVisible(boolean bEnable, int marginLeft) { try { Log.d(TAG, "[setManualBtnVisible] bEnable [" + bEnable + "], marginLeft [" + marginLeft + "]"); if (bEnable) TopManualBtn.setVisibility(View.VISIBLE); else TopManualBtn.setVisibility(View.INVISIBLE); TopLayout.removeView(TopManualBtn); ViewRegistration(TopLayout, TopManualBtn, marginLeft, 0); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] setManualBtnVisible(boolean bEnable)"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } /** * 매뉴얼 버튼 사용 유무 * @return boolean 타입 - true: 사용, false: 미사용 */ public boolean getManualUse() { try { WallpadDeviceSet devSet = new WallpadDeviceSet(mContext); String[] DBinfo = devSet.GetSettingData("매뉴얼"); devSet.closeDB(); if (DBinfo != null) { if (DBinfo[1].indexOf("사용함") > 0) { Log.d(TAG, "[getManualUse] Use Manual"); return true; } else { // 미사용 Log.d(TAG, "[getManualUse] Not Use Manual [1]"); return false; } } else { // 미사용 Log.d(TAG, "[getManualUse] Not Use Manual [2]"); return false; } } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception ex) { Log.e(TAG, "[getManualUse] - Exception !!!"); //ex.printStackTrace(); LogUtil.errorLogInfo("", TAG, ex); } return false; } // ManualActivityRun private static boolean ManualActivityRun = false; public static boolean getManualActivityRun() { Log.d(TAG, "[getManualActivityRun] ManualActivityRun: " + ManualActivityRun); return ManualActivityRun; } public static void setManualActivityRun(boolean run) { ManualActivityRun = run; if (!ManualActivityRun) resetCurrentManualScreenID(); } public boolean StartManual(int screenId) { Log.d(TAG, "[StartManual] ScreenId [" + screenId + "], mCurrentManualScreenId [" + mCurrentManualScreenId + "]"); if (getManualActivityRun()) { mCurrentManualScreenId = screenId; return ((WpadActivity) (ManualActivity.getContext())).ChangeScreen(screenId); } else { if (mCurrentManualScreenId == screenId) return false; mCurrentManualScreenId = screenId; setManualActivityRun(true); Intent intent = new Intent(mContext, ManualActivity.class); intent.putExtra("ScreenId", screenId); if(mCurrentScreenId == API_Menu.SubMenuConfig.Configuration) { intent.putExtra("SettingData", configSettingMainScreen.setting_manual_str); intent.putExtra("NowPage", configSettingMainScreen.m_CurPage); intent.putExtra("TotalPage", configSettingMainScreen.m_ToTalPage); } overridePendingTransition(0, 0); startActivityForResult(intent, 0); return true; } } public static void resetCurrentManualScreenID() { try { mCurrentManualScreenId = -1; } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] resetCurrentManualScreenID()"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } public static void FinishManualActivity() { Log.i(TAG, "[FinishManualActivity]"); try { if (mManualActivity != null) { mCurrentManualScreenId = -1; mManualActivity.finish(); } } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] FinishManualActivity()"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } /** * onDestroy */ @Override protected void onDestroy() { // 혹시 돌고 있을수 있는 핸들러를 종료한다. // mWallPadApiCheckHandler.sendEmptyMessageDelayed(99, 0); setChangeScreen(mCurrentScreenId, true); if (wdb != null) wdb.closeDB(); this.unregisterReceiver(mWallPadAlertBR); this.unregisterReceiver(mWallPadJogBR); this.unregisterReceiver(kakaoBroadCastReceiver); mSound.Release(); super.setFinishTimerDestroy(); super.onDestroy(); Log.i(TAG, "*************************************************************"); Log.i(TAG, "****************** [END - MainActivity] *******************"); Log.i(TAG, "*************************************************************"); } /** * onResume */ @Override protected void onResume() { super.onResume(); if (mWallPadAPI != null) mWallPadAPI.Resume(); DebugLogOutput("@@@@@@@@ [onResume] @@@@@@@@"); } /** * onPause */ @Override protected void onPause() { // 혹시 돌고 있을수 있는 핸들러를 종료한다. mWallPadApiCheckHandler.sendEmptyMessageDelayed(99, 0); if (mWallPadAPI != null) mWallPadAPI.Pause(); DebugLogOutput("@@@@@@@@ [onPause] @@@@@@@@"); super.onPause(); } /* ================================================================================================ * [BroadcastReceiver] Section ================================================================================================ */ /** * BroadcastReceiver.onReceive for [WpadActivity] */ @Override protected void onBrReceive(Intent intent) { super.onBrReceive(intent); DebugLogOutput("Receive BR " + intent.getAction()); } /* ================================================================================================ * [Touch & Key Event] Section ================================================================================================ */ /** * TouchEvent for [WpadActivity] */ @Override protected void onTouchEvent(View v, MotionEvent event) { super.onTouchEvent(v, event); int TargetId = v.getId(); int MoveEvent = event.getAction(); //DebugLogOutput("onTouch - " + "id : " + v.getId() + " / Action : " + event.getAction()); if(MoveEvent == MotionEvent.ACTION_UP) { if(TargetId == ID.main.button.HOME) { DebugLogOutput("onTouchEvent [HOME] BUTTON !!!"); Sound().Play(SND.effect.TOUCH_LATCHED); Intent intent = new Intent(); intent.putExtra("Finish_Kind", "HomeButton"); setResult(RESULT_OK, intent); finish(); } else if(TargetId == ID.main.button.BACK) { DebugLogOutput("onTouchEvent [BACK] BUTTON !!!"); Sound().Play(SND.effect.TOUCH_LATCHED); /** *[수정필요]Back Button 필요한 화면은 아래 부분 추가 후 사용 필요 * **/ /* if((mCurrentScreenId == API_Menu.SubMenuConfig.SmartKey) || (mCurrentScreenId == API_Menu.SubMenuConfig.RfCard)||(mCurrentScreenId == API_Menu.SubMenuConfig.CleanLcd) ||(mCurrentScreenId == API_Menu.SubMenuConfig.MorningCall)||(mCurrentScreenId == API_Menu.SubMenuConfig.PassWordChange)||(mCurrentScreenId == API_Menu.SubMenuConfig.TimeSetting)) { setChangeScreen(API_Menu.SubMenuConfig.Configuration, false); }*/ } else if(TargetId == ID.main.button.MENU) { DebugLogOutput("onTouchEvent [MENU] BUTTON !!!"); if(MenuOpen == true) { return; } Sound().Play(SND.effect.TOUCH_LATCHED); OpenMenuLayout(); } else if (TargetId == ID.main.button.MENUCLOSE) { if(MenuOpen == true) { Sound().Play(SND.effect.TOUCH_LATCHED); CloseMenuLayout(); } } else if (TargetId == ID.main.button.MENUAL) { Log.i(TAG, "onTouchEvent [MANUAL] BUTTON [mCurrentScreenId = " + mCurrentScreenId + "]"); Sound().Play(SND.effect.TOUCH_LATCHED); if(mCurrentScreenId == API_Menu.SubMenuConfig.Configuration) { StartManual(ID.MANUAL.MANUAL_SettingMain); } else if(mCurrentScreenId == API_Menu.SubMenuConfig.CleanLcd) { StartManual(ID.MANUAL.MANUAL_CleanLcdMain); } else if(mCurrentScreenId == API_Menu.SubMenuConfig.PassWordChange) { StartManual(ID.MANUAL.MANUAL_PWD_CHANGE); } else if(mCurrentScreenId == API_Menu.SubMenuConfig.MorningCall) { StartManual(ID.MANUAL.MANUAL_MORNINGCALL); } else if(mCurrentScreenId == API_Menu.SubMenuConfig.TimeSetting) { StartManual(ID.MANUAL.MANUAL_TIMESETTING); } else if(mCurrentScreenId == API_Menu.SubMenuConfig.RfCard) { StartManual(ID.MANUAL.MANUAL_RFCARD); } else if(mCurrentScreenId == API_Menu.SubMenuConfig.SmartKey) { StartManual(ID.MANUAL.MANUAL_SMARTKEY); } else if(mCurrentScreenId == API_Menu.SubMenuConfig.MobileDeviceReg) { StartManual(ID.MANUAL.MANUAL_MOBILEDEVREG); } else if(mCurrentScreenId == API_Menu.SubMenuConfig.InRoomDetectSet) { /*StartManual(ID.MANUAL.MANUAL_MOBILEDEVREG);*/ } // else if(mCurrentScreenId == API_Menu.SubMenuConfig.HSPlatformDevice) { StartManual(ID.MANUAL.MANUAL_HSPLATFORMDEVICE); } // TODO 추후 매뉴얼 작업 필요 } else if (TargetId == ID.main.button.SETTING) { Sound().Play(SND.effect.TOUCH_LATCHED); if (mCurrentScreenId == API_Menu.SubMenuConfig.MobileDeviceReg) StartPopup(ID.screen.PopupRemoteCallUserSetting); } else if(TargetId == ID.main.button.BACK_INROOM) { DebugLogOutput("onTouchEvent [BACK_INROOM] BUTTON !!!"); Sound().Play(SND.effect.TOUCH_LATCHED); Set_BackBtn_InroomVisible(false); try { // 시나리오 선택화면으로 복귀. configInRoomSensorMainScreen.NowScreenMode = ConfigInRoomSensorMainScreen.ScreenMode.MODE_SCENARIO_SELECT; configInRoomSensorMainScreen.NowSelectedTimeArea = SELECT_START_TIME; configInRoomSensorMainScreen.Info_NowSelected = null; configInRoomSensorMainScreen.DrawUpdate(configInRoomSensorMainScreen.NowScreenMode); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } } } /** * H/W Key Event */ private static final int BTN_CALL_IHN1010 = 264; @Override public boolean onKeyDown(int keyCode, KeyEvent event) { Log.i(TAG, "[onKeyDown] keyCode : " + keyCode + ", Action : " + event.getAction()); return super.onKeyDown(keyCode, event); } /* ================================================================================================ * [TOP - Back] Section ================================================================================================ */ /** * TOP 돌아가기 버튼 활성화 & 비활성화 * * @param Enabled - true : 활성화, false : 비활성화 * @return (boolean) true : 성공, false : 실패 */ public boolean setTopBackBtnVisible(boolean Enabled) { if(Enabled == true) { if(TopBackBtn.getVisibility() != View.VISIBLE) TopBackBtn.setVisibility(View.VISIBLE); TopBackBtn.bringToFront(); } else { if(TopBackBtn.getVisibility() != View.INVISIBLE) TopBackBtn.setVisibility(View.INVISIBLE); } return true; } /* ================================================================================================ * [Popup Activity] Section ================================================================================================ */ /** * Popup Activity 를 시작시킨다. * * @param ScreenId - 팝업시작시 Screen ID * @return (boolean) true : 성공, false : 실패 */ public boolean StartPopup(int ScreenId) { if(getPopupActivityRun() == true) { return ((WpadActivity)(PopupActivity.getContext())).ChangeScreen(ScreenId); } else { setPopupActivityRun(true); Intent intent = new Intent(mContext, PopupActivity.class); intent.putExtra("ScreenId", ScreenId); overridePendingTransition(0, 0); startActivityForResult(intent, 0); return true; } } /** * Wifi 아이디 정보와 비밀번호 정보를 넘겨주기 위해 추가 * @param ScreenId * @param capabilities * @return */ public boolean StartWifiSetting(int ScreenId,String SSID, String capabilities) { if(getPopupActivityRun() == true) { Intent intent = new Intent(mContext, PopupActivity.class); intent.putExtra("ScreenId", ScreenId); intent.putExtra("SSID", SSID); intent.putExtra("WIFISSID", capabilities); return ((WpadActivity)(PopupActivity.getContext())).ChangeScreen(ScreenId); } else { setPopupActivityRun(true); Intent intent = new Intent(mContext, PopupActivity.class); intent.putExtra("ScreenId", ScreenId); intent.putExtra("SSID", SSID); intent.putExtra("WIFISSID", capabilities); overridePendingTransition(0, 0); startActivityForResult(intent, 0); return true; } } /** * Popup Activity 를 시작시킨다. (시작시 Intent Type 데이터를 전달한다) * * @param ScreenId - 팝업시작시 Screen ID * @param data - 전달할 데이터 * @return (boolean) true : 성공, false : 실패 */ public boolean StartPopup(int ScreenId, Intent data) { if(getPopupActivityRun() == true) { return false; } else { setPopupActivityRun(true); Intent intent = new Intent(mContext, PopupActivity.class); intent.putExtra("ScreenId", ScreenId); intent.putExtra("PopupScreenDataIntent", data); overridePendingTransition(0, 0); startActivityForResult(intent, 0); return true; } } /** * Activity Result Reception */ @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); Log.d(TAG, "@@@@@@@@ [onActivityResult] @@@@@@@@"); if(resultCode == RESULT_OK) { try { // PopupActivity 에서 FinishTimer 로 인하여 종료가 되었을 경우 // MainActivity 도 즉시 종료시킨다. String code = (String) data.getExtras().get("Finish_Kind"); Log.d(TAG, "Finish_Kind : " + code); boolean runWIFI = (boolean) data.getBooleanExtra("KAKAOUSE", false); if(runWIFI) { if(mTempCurrentScreenId!=API_Menu.SubMenuConfig.Wifi) { mTempCurrentScreenId = API_Menu.SubMenuConfig.Wifi; SetTitleText(API_Menu.SubMenuConfig.Name_Wifi); mWallPadApiCheckHandler.sendEmptyMessage(3); } } else { if(code.equals("FinishTimer") == true) { Log.d(TAG, "FinishTimer finish"); finish(); } } } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception Error] [onActivityResult] - data.getExtras().get"); } } } /* ================================================================================================ * [Screen] Section ================================================================================================ */ /** * Screen 에서 Screen 변경을 요청할 경우 호출된다.
* Override 사용하여 Screen 변경을 처리한다.
* * @param nScreenId - 변경할 Screen ID * @return (boolean) true : 성공, false : 실패 */ @Override protected boolean onChangeScreen(int nScreenId) { super.onChangeScreen(nScreenId); return setChangeScreen(nScreenId, false); } /** * Screen 등록자
* ScreenLayout 에 현재 Screen 을 삭제하고, 새로운 Screen 을 등록시킨다. * * @param nScreenId - 변경할 Screen ID * @param OnlyRemove - 현재 Screen 을 삭제만 할 경우 (onDestroy 에서 사용) * @return (boolean) true : 성공, false : 실패 */ private boolean setChangeScreen(int nScreenId, boolean OnlyRemove) { DebugLogOutput("setChangeScreen - " + "CurrentSelectDeviceId : " + mCurrentScreenId + " / NextLayoutId : " + nScreenId + " / OnlyRemove : " + OnlyRemove); // 1. 현재 Layout 삭제 if(mCurrentScreenId > 0) { ScreenLayout.removeAllViews(); super.setCurrentScreen(null); } if(OnlyRemove) return true; mCurrentScreenId = nScreenId; setTopBackBtnVisible(false); setTopSetBtnVisible(false); // 2. 새로운 Layout 표시 try { switch(nScreenId) { /** * [수정필요] * Back Button 필요한 화면은 setTopBackBtnVisible(true) 호출 필요 * 추가 또는 수정해야할 부분 1. - 스크린 별 layout 생성 * **/ case API_Menu.SubMenuConfig.Configuration: SetTitleText(API_Menu.SubMenuConfig.Name_Configuration); configSettingMainScreen = new ConfigSettingMainScreen(this, ScreenLayout, mWallPadAPI, OPERATION_MODE); super.setCurrentScreen(configSettingMainScreen); break; case API_Menu.SubMenuConfig.CleanLcd: SetTitleText(API_Menu.SubMenuConfig.Name_CleanLcd); configCleanLcdMainScreen = new ConfigCleanLcdMainScreen(this, ScreenLayout, mWallPadAPI, OPERATION_MODE); //setTopBackBtnVisible(true); super.setCurrentScreen(configCleanLcdMainScreen); break; case API_Menu.SubMenuConfig.PassWordChange: SetTitleText(API_Menu.SubMenuConfig.Name_PassWordChange); configPwChangeMainScreen = new ConfigPwChangeMainScreen(this, ScreenLayout, mWallPadAPI, OPERATION_MODE); //setTopBackBtnVisible(true); super.setCurrentScreen(configPwChangeMainScreen); break; /*case API_Menu.SubMenuConfig.SkinChange: SetTitleText(API_Menu.SubMenuConfig.Name_SkinChange); configGLESkinChangeMainScreen = new ConfigSkinChangeScreen(this, ScreenLayout, mWallPadAPI, OPERATION_MODE); super.setCurrentScreen(configGLESkinChangeMainScreen); break;*/ case API_Menu.SubMenuConfig.MorningCall: SetTitleText(API_Menu.SubMenuConfig.Name_MorningCall); configMoningCallMainScreen = new ConfigMoningCallMainScreen(this, ScreenLayout, mWallPadAPI, OPERATION_MODE); //setTopBackBtnVisible(true); super.setCurrentScreen(configMoningCallMainScreen); break; case API_Menu.SubMenuConfig.SmartKey: SetTitleText(API_Menu.SubMenuConfig.Name_SmartKey); configSmartKeyMainScreen = new ConfigSmartKeyMainScreen(this, ScreenLayout, mWallPadAPI, OPERATION_MODE); super.setCurrentScreen(configSmartKeyMainScreen); break; case API_Menu.SubMenuConfig.SmartBand: SetTitleText(API_Menu.SubMenuConfig.Name_SmartBand); configSmartKeyMainScreen = new ConfigSmartKeyMainScreen(this, ScreenLayout, mWallPadAPI, OPERATION_MODE); super.setCurrentScreen(configSmartKeyMainScreen); break; case API_Menu.SubMenuConfig.RfCard: SetTitleText(API_Menu.SubMenuConfig.Name_RfCard); configRfCardMainScreen = new ConfigRfCardMainScreen(this, ScreenLayout, mWallPadAPI, OPERATION_MODE); super.setCurrentScreen(configRfCardMainScreen); break; case API_Menu.SubMenuConfig.TimeSetting: SetTitleText(API_Menu.SubMenuConfig.Name_TimeSetting); configTimeSetScreen = new ConfigTimeSetScreen(this, ScreenLayout, mWallPadAPI, OPERATION_MODE); // setTopBackBtnVisible(true); super.setCurrentScreen(configTimeSetScreen); break; /*case API_Menu.SubMenuConfig.NoiseLog: SetTitleText(API_Menu.SubMenuConfig.Name_NoiseLog); configNoiseLogMainScreen = new ConfigNoiseLogMainScreen(this, ScreenLayout, mWallPadAPI, OPERATION_MODE); // setTopBackBtnVisible(true); super.setCurrentScreen(configNoiseLogMainScreen); break;*/ /*case API_Menu.SubMenuConfig.HandicappedPerson: SetTitleText(API_Menu.SubMenuConfig.Name_Handicapped); configHandicappedModeScreen = new ConfigHandicappedModeScreen(this, ScreenLayout, mWallPadAPI, OPERATION_MODE); // setTopBackBtnVisible(true); super.setCurrentScreen(configHandicappedModeScreen); break;*/ case API_Menu.SubMenuConfig.MobileDeviceReg: SetTitleText(API_Menu.SubMenuConfig.Name_MobileDeviceReg); configMobileDeviceAddScreen = new ConfigMobileDeviceAddScreen(this, ScreenLayout, mWallPadAPI, OPERATION_MODE); // setTopBackBtnVisible(true); super.setCurrentScreen(configMobileDeviceAddScreen); break; case API_Menu.SubMenuConfig.InRoomDetectSet: SetTitleText(API_Menu.SubMenuConfig.Name_InRoomDetectSetting); configInRoomSensorMainScreen = new ConfigInRoomSensorMainScreen(this, ScreenLayout, mWallPadAPI, OPERATION_MODE); super.setCurrentScreen(configInRoomSensorMainScreen); break; case API_Menu.SubMenuConfig.KakaoHome: SetTitleText(API_Menu.SubMenuConfig.Name_KakaoHome); configInKakaoiMainScreen = new ConfigInKakaoiMainScreen(this, ScreenLayout, mWallPadAPI, OPERATION_MODE); super.setCurrentScreen(configSettingMainScreen); break; //Wifi 화면 case API_Menu.SubMenuConfig.Wifi: SetTitleText(API_Menu.SubMenuConfig.Name_Wifi); configWifiMainScreen = new ConfigInWifiMainScreen(this, ScreenLayout, mWallPadAPI, OPERATION_MODE); super.setCurrentScreen(configWifiMainScreen); break; case API_Menu.SubMenuConfig.HSPlatformDevice: SetTitleText(API_Menu.SubMenuConfig.Name_HSPlatformDevice); configHSPlatformDeviceListScreen = new ConfigHSPlatformDeviceListScreen(this, ScreenLayout, mWallPadAPI, OPERATION_MODE); super.setCurrentScreen(configHSPlatformDeviceListScreen); break; //추가 또는 수정해야할 부분 1. - 스크린 별 layout 생성 default: Log.e(TAG, "[Error] setChangeScreen - nScreenId Not found!!! (" + mCurrentScreenId + ")"); //mCurrentScreenId = -1; return false; } } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); return false; } catch(Exception e) { Log.e(TAG, "[ExceptionError] - setChangeScreen->Screen Create : " + e); return false; } return true; } private void CheckIsFolderMake() { File folderCheck = new File(Common.BESTIN_ROOT); if( folderCheck.isDirectory() == false ) { boolean bRet = folderCheck.mkdir(); Log.d(TAG, "[SKIN_PATH] ---------Common.BESTIN_ROOT----mkdir------" + bRet); } folderCheck = new File(Common.SKIN_PATH); if( folderCheck.isDirectory() == false ) { boolean bRet = folderCheck.mkdir(); Log.d(TAG, "[SKIN_PATH] ---------Common.SKIN_PATH----mkdir------" + bRet); } folderCheck = new File(Common.USERSKIN_PATH ); if( folderCheck.isDirectory() == false ) { boolean bRet = folderCheck.mkdir(); Log.d(TAG, "[SKIN_PATH] ---------Common.USERSKIN_PATH----mkdir------" + bRet); } } /** * 상단 타이틀 텍스트 수정 * @param SetText 수정할 타이틀 이름 * **/ private void SetTitleText(String SetText) { if(SetText != null) { TopTitle.setText(SetText); } } /* ================================================================================================ * [Menu Layout] Section ================================================================================================ */ /** * 메뉴 레이아웃 생성 * **/ private void OpenMenuLayout() { try { Log.i(TAG, "[OpenMenuLayout] ========== START =========="); if (MenuOpen == true) { return; } if (menueListDataClass == null) { return; } //0. 현재 ID 및 리스트 불러오기 String Title = API_Menu.GetGroupNameByID((mCurrentScreenId / 1000) * 1000); Log.i(TAG, "[OpenMenuLayout] Title = " + Title + ", mCurrentScreenId = " + mCurrentScreenId); String TempChildName = null; int ChooseGroup = 0; int ChooseChild = 0; for (int i = 0; i < menueListDataClass.arrayGroup.size(); i++) { Log.i(TAG, "[OpenMenuLayout] menueListDataClass.arrayGroup.get(" + i + ") = " + menueListDataClass.arrayGroup.get(i)); if (menueListDataClass.arrayGroup.get(i).equals(Title)) { ChooseGroup = i; break; } } Log.i(TAG, "[OpenMenuLayout] menueListDataClass.idMappingTable.length = " + menueListDataClass.idMappingTable.length); for (int i = 0; i < menueListDataClass.idMappingTable.length; i++) { Log.i(TAG, "[OpenMenuLayout] menueListDataClass.idMappingTable[" + i + "].Id = " + menueListDataClass.idMappingTable[i].Id); if (menueListDataClass.idMappingTable[i].Id == mCurrentScreenId) { TempChildName = menueListDataClass.idMappingTable[i].Name; break; } } if (TempChildName == null) { Log.w(TAG, "[OpenMenuLayout] TempChildName is null!!!"); return; } for (int i = 0; i < menueListDataClass.arrayChild.get(Title).size(); i++) { Log.i(TAG, "[OpenMenuLayout] menueListDataClass.arrayChild.get(Title).get(" + i + ") = " + menueListDataClass.arrayChild.get(Title).get(i) + ", TempChildName = " + TempChildName); if (menueListDataClass.arrayChild.get(Title).get(i).equals(TempChildName) == true) { ChooseChild = i; break; } } //1. 기존 화면 투명도 변경 TopLayout.setAlpha(0.5f); ScreenLayout.setAlpha(0.5f); //2. Layout 생성 및 처리 이벤트 등록 MenuLayout = new RelativeLayout(this); WpadUtil.LayoutRegistration(AllLayout, MenuLayout, 1280, 800, 0, 0, ID.main.layout.MENU); MenuLayout.setOnTouchListener(new Button.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_UP) { setFinishTimerReset(); CloseMenuLayout(); } return true; } }); //3. 배경 이미지 생성 및 에니메이션 등록 MenuBackground = new WpadImageView(this, TOUCH_KIND.BUTTON, 460, 800, R.drawable.bg_menu, R.drawable.bg_menu, ID.main.image.TAB_BACKGROUND); TranslateAnimation anim = new TranslateAnimation(WpadScale.getWidth(-460), 0, 0, 0); anim.setDuration(200); anim.setInterpolator(new AccelerateInterpolator()); MenuLayout.setAnimation(anim); ViewRegistration(MenuLayout, MenuBackground, 0, 0); //4. 타이틀 등록 MenuTitle = new WpadTextView(this, false, 247, 80, Gravity.LEFT, Color.WHITE, Common.fontsize._44, true, ID.main.text.TITLE); ViewRegistration(MenuLayout, MenuTitle, 133, 15); MenuTitle.setText(Title); //5. 종료 버튼 등록 MenuClose = new WpadImageView(this, TOUCH_KIND.BUTTON, 80, 80, R.drawable.topbar_icon_close_normal, R.drawable.topbar_icon_close_pressed, ID.main.button.MENUCLOSE); MenuClose.setTouchDelayMs(1000); ViewRegistration(MenuLayout, MenuClose, 380, 15); //6. 리스트뷰 초기화 및 등록 mListView = new ExpandableListView(this); ExpandableListView.LayoutParams params = new ExpandableListView.LayoutParams(WpadScale.getWidth(460), WpadScale.getHeight(690)); mListView.setLayoutParams(params); mListView.setX(WpadScale.getWidth(0)); mListView.setY(WpadScale.getHeight(112)); mListView.setBackgroundColor(Color.BLACK); mListView.setId(ID.main.liveview.lv); mListView.setGroupIndicator(null); mListView.setDividerHeight(0); mListView.setDivider(null); mListView.setFocusable(true); mListView.setSmoothScrollbarEnabled(true); mListView.setTranscriptMode(android.widget.AbsListView.TRANSCRIPT_MODE_DISABLED); mListView.setScrollbarFadingEnabled(true); MenuLayout.addView(mListView); adptMain = new Menu_AdptMain(this, menueListDataClass.arrayGroup, menueListDataClass.arrayChild, ChooseGroup, ChooseChild); mListView.setAdapter(adptMain); //7. 선택된 그룹 열기 mListView.setSelectedGroup(ChooseGroup); mListView.expandGroup(ChooseGroup); // 8. 리스트뷰 터치 이벤트 등록 mListView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if((event.getAction() == MotionEvent.ACTION_DOWN) || (event.getAction() == MotionEvent.ACTION_UP)) { WpadActivity.setFinishTimerReset(); } return false; }}); // 9. 그룹 터치 이벤트 등록 mListView.setOnGroupClickListener(new OnGroupClickListener() { @Override public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) { DebugLogOutput("group click = " + groupPosition); WpadActivity.setFinishTimerReset(); return false; } }); // 10. 차일드 터치 이벤트 등록 /* mListView.setOnChildClickListener(new OnChildClickListener() { @Override public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { DebugLogOutput("onChildClick"); DebugLogOutput("groupPosition = " + groupPosition); DebugLogOutput("childPosition = " + childPosition); WpadActivity.setFinishTimerReset(); return false; } }); */ // 11. 그룹 열리는 경우 이벤트 mListView.setOnGroupExpandListener(new OnGroupExpandListener() { @Override public void onGroupExpand(int groupPosition) { DebugLogOutput("groupPosition Open Event = " + groupPosition); Sound().Play(SND.effect.TOUCH_LATCHED); WpadActivity.setFinishTimerReset(); } }); // 12. 그룹 닫히는 경우 이벤트 mListView.setOnGroupCollapseListener(new OnGroupCollapseListener() { @Override public void onGroupCollapse(int groupPosition) { DebugLogOutput("groupPosition Close Event = " + groupPosition); Sound().Play(SND.effect.TOUCH_LATCHED); WpadActivity.setFinishTimerReset(); } }); // 13. MenuOpen True 설정 MenuOpen = true; } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] OpenMenuLayout()"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } /** * 메뉴 layout 닫힘 처리 * **/ private void CloseMenuLayout() { if(MenuOpen == false) { return; } TranslateAnimation anim = new TranslateAnimation(0, WpadScale.getWidth(-460), 0, 0); anim.setDuration(200); anim.setInterpolator(new AccelerateInterpolator()); anim.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation animation) { MenuOpen = false; } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { AllLayout.removeView(MenuLayout); TopLayout.setAlpha(1.0f); ScreenLayout.setAlpha(1.0f); } }); MenuLayout.startAnimation(anim); } /** * 메뉴 그룹 터치시 처리 (Menu_AdptMain에서 호출) * **/ public static void SetListViewGroupExpand_Collapse(int GroupID, boolean ExpandEnable) { if(ExpandEnable == true) { mListView.expandGroup(GroupID); } else { mListView.collapseGroup(GroupID); } } /** * Menu정보가 DB에 없을 경우 불러올 스크린 로딩 * @return MenuListDataClass 타입의 초기정보 * **/ private MenuListDataClass LoadDefaultMenuList() { MenuListDataClass Temp_menueListDataClass = new MenuListDataClass(); Temp_menueListDataClass.SetArrayGroup(API_Menu.SubMenuConfig.Name); ArrayList arrayList = new ArrayList(); int ChildCount = 0; //[수정필요] //추가 또는 수정해야할 부분 1. - Menu정보가 DB에 없을 경우 불러올 스크린 종류(시작) arrayList.add(API_Menu.SubMenuConfig.Name_Configuration); ChildCount++; arrayList.add(API_Menu.SubMenuConfig.Name_CleanLcd); ChildCount++; //추가 또는 수정해야할 부분 1. - Menu정보가 DB에 없을 경우 불러올 스크린 종류(끝) Temp_menueListDataClass.SetArrayChild(API_Menu.SubMenuConfig.Name, arrayList); Temp_menueListDataClass.idMappingTable = new ChildIDMapping[ChildCount]; for (int i = 0; i < ChildCount; i++) { Temp_menueListDataClass.idMappingTable[i] = new ChildIDMapping(); //[수정필요] //추가 또는 수정해야할 부분 2. - 불러올 스크린의 ID를 임의로 입력(시작) if(arrayList.get(i).equals(API_Menu.SubMenuConfig.Name_Configuration) == true) { Temp_menueListDataClass.idMappingTable[i].Id = API_Menu.SubMenuConfig.Configuration; Temp_menueListDataClass.idMappingTable[i].Name = API_Menu.SubMenuConfig.Name_Configuration; } else if(arrayList.get(i).equals(API_Menu.SubMenuConfig.Name_CleanLcd) == true) { Temp_menueListDataClass.idMappingTable[i].Id = API_Menu.SubMenuConfig.CleanLcd; Temp_menueListDataClass.idMappingTable[i].Name = API_Menu.SubMenuConfig.Name_CleanLcd; } //추가 또는 수정해야할 부분 2. - 불러올 스크린의 ID를 임의로 입력(끝) } return Temp_menueListDataClass; } /** * Menu Event intent filter 등록 **/ private void reg_Receiver() { try { IntentFilter filter = new IntentFilter(); filter.addAction("MENU_EVENT"); registerReceiver(mWallPadAlertBR, filter); filter = new IntentFilter(); filter.addAction(define.NOTIFY_DAIL); filter.addAction("WALLPAD_DIAL_GLOBALSCREEN_TOUCH"); registerReceiver(mWallPadJogBR, filter); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } /** * 조그버튼 입력 받을 시 처리 **/ BroadcastReceiver mWallPadJogBR = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { WpadActivity.setFinishTimerReset(); } }; /** * 메뉴에서 버튼 터치 처리 * **/ BroadcastReceiver mWallPadAlertBR = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { int groupPosition = intent.getIntExtra("groupPosition", -1); int childPosition = intent.getIntExtra("childPosition", -1); Log.i(TAG, "groupPosition :" +groupPosition + ", childPosition :" + childPosition); if((groupPosition >= 0) && (childPosition >= 0)) { if(MenuOpen == true) { Sound().Play(SND.effect.TOUCH_LATCHED); CloseMenuLayout(); if(menueListDataClass == null) { return; } String childName = menueListDataClass.arrayChild.get(menueListDataClass.arrayGroup.get(groupPosition)).get(childPosition); for (int i = 0; i < menueListDataClass.idMappingTable.length; i++) { if(menueListDataClass.idMappingTable[i].Name.equals(childName) == true) { API_Menu api_Menu = new API_Menu(); int TempID = api_Menu.GetMyGroupID(getApplicationContext().getPackageName()); int ChildID = menueListDataClass.idMappingTable[i].Id; int ChildGroupID = (ChildID / 1000) * 1000; Log.i(TAG, "Child ID :" + ChildID); if(TempID == 0) { return; } if(ChildGroupID == TempID) { //해당 APP내에서 스크린 전환 필요 //[수정필요] /*boolean result = setChangeScreen(ChildID, false); if(result == false) { setChangeScreen(API_Menu.SubMenuConfig.Configuration, false); } WpadActivity.setFinishTimerReset();*/ if (OPERATION_MODE == Common.MODE_NOMAL) { mTempCurrentScreenId = ChildID; mWallPadApiCheckHandler.sendEmptyMessage(0); } else { boolean result = setChangeScreen(ChildID, false); if(result == false) { setChangeScreen(API_Menu.SubMenuConfig.Configuration, false); } } WpadActivity.setFinishTimerReset(); } else { //외부 앱 호출 후, 본 APP Finish 필요 api_Menu.startSubScreenActivity(getApplicationContext(), menueListDataClass.idMappingTable[i].Id, API_Menu.MENU_START_OPTION_1, api_Menu.GetAPK_Name_ByID(ChildGroupID)); Intent mIntent = new Intent(); mIntent.putExtra("Finish_Kind", "HomeButton"); MainActivity.this.setResult(RESULT_OK, mIntent); finish(); } break; } } } } } }; /** * @param nScreenId - 변경할 Screen ID * @return (boolean) true : 성공, false : 실패 **/ private boolean setTitleName(int nScreenId) { boolean ret = false; Log.d(TAG, "setTitleName " + nScreenId); switch (nScreenId) { case API_Menu.SubMenuConfig.Configuration: SetTitleText(API_Menu.SubMenuConfig.Name_Configuration); ret = true; break; case API_Menu.SubMenuConfig.CleanLcd: SetTitleText(API_Menu.SubMenuConfig.Name_CleanLcd); ret = true; break; case API_Menu.SubMenuConfig.PassWordChange: SetTitleText(API_Menu.SubMenuConfig.Name_PassWordChange); ret = true; break; case API_Menu.SubMenuConfig.SkinChange: SetTitleText(API_Menu.SubMenuConfig.Name_SkinChange); ret = true; break; case API_Menu.SubMenuConfig.MorningCall: SetTitleText(API_Menu.SubMenuConfig.Name_MorningCall); ret = true; break; case API_Menu.SubMenuConfig.SmartKey: SetTitleText(API_Menu.SubMenuConfig.Name_SmartKey); ret = true; break; case API_Menu.SubMenuConfig.SmartBand: SetTitleText(API_Menu.SubMenuConfig.Name_SmartBand); ret = true; break; case API_Menu.SubMenuConfig.RfCard: SetTitleText(API_Menu.SubMenuConfig.Name_RfCard); ret = true; break; case API_Menu.SubMenuConfig.TimeSetting: SetTitleText(API_Menu.SubMenuConfig.Name_TimeSetting); ret = true; break; case API_Menu.SubMenuConfig.HandicappedPerson: SetTitleText(API_Menu.SubMenuConfig.Name_Handicapped); ret = true; break; case API_Menu.SubMenuConfig.RemoteCallUser: SetTitleText(API_Menu.SubMenuConfig.Name_RemoteCallUser); ret = true; break; default: Log.e(TAG, "[Error] setChangeScreen - nScreenId Not found!!! (" + mCurrentScreenId + ")"); //mCurrentScreenId = -1; SetTitleText(API_Menu.SubMenuConfig.Name_Configuration); ret = false; break; } return ret; } // 안심통화 사용유무 public boolean getReliefCallUse() { try { String RELIEF_CALL = "안심통화"; WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(mContext); if (mWallpadDeviceSet != null) { String[] astrReliefCall = mWallpadDeviceSet.GetSettingData(RELIEF_CALL); mWallpadDeviceSet.closeDB(); if (astrReliefCall != null) { if (astrReliefCall[1].contains(RELIEF_CALL)) { if (astrReliefCall[1].contains("사용함")) return true; } } } } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] getReliefCallUse()"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } return false; } /** * 재실센서 시나리오 선택화면 돌아가기 버튼 활성화 & 비활성화 * * @param Enabled - true : 활성화, false : 비활성화 * @return (boolean) true : 성공, false : 실패 */ public boolean Set_BackBtn_InroomVisible(boolean Enabled) { if(Enabled == true) { if(BackBtn_InRoom.getVisibility() != View.VISIBLE) BackBtn_InRoom.setVisibility(View.VISIBLE); BackBtn_InRoom.bringToFront(); if(TopManualBtn.getVisibility() == View.VISIBLE) { WpadUtil.ViewMove(TopManualBtn, 893, 0); } } else { if(BackBtn_InRoom.getVisibility() != View.INVISIBLE) BackBtn_InRoom.setVisibility(View.INVISIBLE); if(TopManualBtn.getVisibility() == View.VISIBLE) { WpadUtil.ViewMove(TopManualBtn, 1019, 0); } } return true; } public boolean GetEasyModeUXUse() { try { WallpadDeviceSet deviceSet = new WallpadDeviceSet(this.getContext()); boolean EasymodeSupport = deviceSet.Get_EasyModeUX_Support(); deviceSet.closeDB(); WallpadStatusData data = new WallpadStatusData(this.getContext()); boolean EasyModeUse = data.GetEasyModeUxUse(); data.closeDB(); Log.d(TAG, "[GetEasyModeUXUse] EasymodeSupport" + EasymodeSupport + "], bUse [" + EasyModeUse + "]"); return EasymodeSupport & EasyModeUse; } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] GetEasyModeUXUse()"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } return false; } public static int nResidentSafetyCheckSetting = WallpadDeviceSet.RESIDENT_SAFETY_CHECK_DISABLE; private void getResidentSafetyCheckSetting() { try { WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(getApplicationContext()); nResidentSafetyCheckSetting = mWallpadDeviceSet.getResidentSafetyCheck(); mWallpadDeviceSet.closeDB(); Log.e(TAG, "[getResidentSafetyCheckSetting] nResidentSafetyCheckSetting: " + nResidentSafetyCheckSetting); if (nResidentSafetyCheckSetting == WallpadDeviceSet.RESIDENT_SAFETY_CHECK_ENABLE) Version.setResidentSafety(); else Version.unsetResidentSafety(); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] getResidentSafetyCheckSetting()"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } /** * 멀티제어 관련. * * */ int mMultiAddress; String myIP = "NONE"; String myHo = "NONE"; int ho = 0; public String millToDate(long mills) { String pattern = "yyyy-MM-dd'T'HH:mm:ss"; SimpleDateFormat formatter = new SimpleDateFormat(pattern); String date = (String) formatter.format(new Timestamp(mills)); return date; } class ClientThread extends Thread { private Handler handler; private String value1; private String value2; private int menu, reason, state, position; private int roomNumber; public ClientThread(Handler handler, int menu, int reason, int position, String value1, String value2) { this.handler = handler; this.menu = menu; this.reason = reason; this.position = position; this.value1 = value1; this.value2 = value2; } public void run() { //String host = "10.1.1.1"; //String host = "10.1.1." + position; String host = "10.1."+position+".1"; int port = 9998; String json = ""; JSONObject jsonObject = new JSONObject(); try { jsonObject.accumulate("type", "request"); jsonObject.accumulate("timestamp", millToDate(System.currentTimeMillis())); jsonObject.accumulate("wallpadip", myIP); jsonObject.accumulate("menu", menu); jsonObject.accumulate("reason", reason); jsonObject.accumulate("position", position); //비밀번호 변경 if (menu == JSON.MENU.PASSWORD) { jsonObject.accumulate("number", value1); } //모바일 기기 등록 else if (menu == JSON.MENU.MOBILE) { if(reason == JSON.REASON.MobileRegister) { jsonObject.accumulate("name", value1); jsonObject.accumulate("id", value2); } else if(reason == JSON.REASON.MobileDelete) { jsonObject.accumulate("id", value2); } } } catch (JSONException e) { e.printStackTrace(); } // convert JSONObject to JSON to String json = jsonObject.toString(); try { Socket socket = new Socket(); InetSocketAddress ipep = new InetSocketAddress(host, port); // 방법 2 socket.connect(ipep); ObjectOutputStream outputStream = new ObjectOutputStream(socket.getOutputStream()); outputStream.writeObject(json); Log.d("ClientThread", "서버로 보냄."); ObjectInputStream inputStream = new ObjectInputStream(socket.getInputStream()); StringBuffer stb = new StringBuffer(); String data; while (true) { try { socket.setSoTimeout(5000); data = (String) inputStream.readObject(); if (data == null) { break; } stb.append(data); } catch (Exception e) { if (socket != null) { socket.close(); } if (inputStream != null) { inputStream.close(); } if (outputStream != null) { outputStream.close(); } break; } } final String response = String.valueOf(stb); Log.d("ClientThread", "response=" + response); final String finalResponse = response; Message message = handler.obtainMessage(); message.what = 1000; Bundle bundle = new Bundle(); bundle.putString("response", finalResponse); message.setData(bundle); handler.sendMessage(message); } catch (Exception e) { e.printStackTrace(); } } } public void requestMultiControl(Handler handler, int menu, int reason, int position, String value1, String value2) { if(position!=ho) { ClientThread thread = new ClientThread(handler, menu, reason, position, value1, value2); thread.start(); } } }