package kr.co.icontrols.wallpadaddservice; import android.Manifest; import android.annotation.SuppressLint; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.pm.PackageManager; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Color; import android.hardware.Camera; import android.media.MediaRecorder; import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.Message; import androidx.core.app.ActivityCompat; import androidx.core.content.ContextCompat; import android.util.Log; import android.view.Gravity; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.SurfaceHolder; import android.view.SurfaceView; import android.view.View; import android.view.animation.AccelerateInterpolator; import android.view.animation.Animation; import android.view.animation.TranslateAnimation; import android.widget.Button; import android.widget.ExpandableListView; import android.widget.ImageView; 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.define; import com.artncore.wallpadapi.Sdb_LivingRoomLightAPI; import com.artncore.wallpadapi.WallPadAPI; import com.techwin.neighbor.ipolis.PlayerSurfaceView; import com.util.LogUtil; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import kr.co.icontrols.v40ioctl.V40IF; import kr.co.icontrols.wallpadaddservice.declare.Common; import kr.co.icontrols.wallpadaddservice.declare.ID; import kr.co.icontrols.wallpadaddservice.screen.AutoPictureMainScreen; import kr.co.icontrols.wallpadaddservice.screen.AutoPictureSubShowScreen; import kr.co.icontrols.wallpadaddservice.screen.BandLocationListScreen; import kr.co.icontrols.wallpadaddservice.screen.BandLocationMainScreen; import kr.co.icontrols.wallpadaddservice.screen.CarGuestInfoScreen; import kr.co.icontrols.wallpadaddservice.screen.CarInfoMainScreen; import kr.co.icontrols.wallpadaddservice.screen.CarParkingAccessList; import kr.co.icontrols.wallpadaddservice.screen.CctvMainScreen; import kr.co.icontrols.wallpadaddservice.screen.ConfigNoiseLogMainScreen; import kr.co.icontrols.wallpadaddservice.screen.CostScreen; import kr.co.icontrols.wallpadaddservice.screen.ElecCarMainScreen; import kr.co.icontrols.wallpadaddservice.screen.LocalInfoScreen; import kr.co.icontrols.wallpadaddservice.screen.MemoMainScreen; import kr.co.icontrols.wallpadaddservice.screen.MemoMakeAudio; import kr.co.icontrols.wallpadaddservice.screen.MemoMakeDrawing; import kr.co.icontrols.wallpadaddservice.screen.MemoMakeVideo; import kr.co.icontrols.wallpadaddservice.screen.NoticeContentsScreen; import kr.co.icontrols.wallpadaddservice.screen.NoticeMainScreen; import kr.co.icontrols.wallpadaddservice.screen.RepairScreen; import kr.co.icontrols.wallpadaddservice.screen.SafeStreetLightMainScreen; import kr.co.icontrols.wallpadaddservice.screen.ScheduleMainScreen; import kr.co.icontrols.wallpadaddservice.screen.UCityScreen; import kr.co.icontrols.wallpadaddservice.screen.VoteScreen; import kr.co.icontrols.wallpadaddservice.screen.WeatherMainScreen; import kr.co.icontrols.wallpadaddservice.subwallpadscreen.WeatherScreen_SubWallPad; 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.WpadRelativeLayoutParams; 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; 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; } public static V40IF mV40IF = null; public static WpadSound mSound; private WallPadAPI wpapi = null; Sdb_LivingRoomLightAPI sdbLivingRoomLightAPI; private int OPERATION_MODE = Common.MODE; private WallpadStatusData wdb = null; // Layout private RelativeLayout AllLayout; private RelativeLayout TopLayout; private RelativeLayout MenuLayout; private RelativeLayout ScreenLayout; WpadImageView ScreenBackground; // Top private WpadImageView TopBackground; WpadTextView TopTitle; WpadImageView TopHomeBtn, TopBackBtn, TopMenuBtn, TopManualBtn; // Menu private WpadImageView MenuBackground; private WpadImageView MenuClose; private WpadTextView MenuTitle; private static ExpandableListView mListView; private Menu_AdptMain adptMain; private MenuListDataClass menuListDataClass; private Menu mMenu = null; private boolean MenuOpen = 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; private int mTempCurrentScreenId = -1; private static int mCurrentManualScreenId = -1; private static final int REQUEST_EXTERNAL_STORAGE = 100; private static final int REQUEST_ACCESS_COARSE_LOCATION = 101; public int nCardNum = 0; // 밴드위치인식 카드번호 // Screen private NoticeMainScreen noticeMainScreen = null; // 공지사항 private NoticeContentsScreen noticeContentsScreen = null; private WeatherMainScreen weatherMainScreen = null; // 날씨 private WeatherScreen_SubWallPad weatherSubScreen = null; // 서브월패드 날씨 private MemoMainScreen memoMainScreen = null; // 메모 private MemoMakeDrawing memoMainDrawingScreen = null; private MemoMakeAudio memoMainAudioScreen = null; private MemoMakeVideo memoMainVideoScreen = null; private AutoPictureMainScreen autoPictureMainScreen = null; // 전자액자 private AutoPictureSubShowScreen autoPictureSubShowScreen = null; private ScheduleMainScreen scheduleMainScreen = null; // 일정표 private CctvMainScreen cctvMainScreen = null; // CCTV private CarInfoMainScreen carInfoMainScreen = null; // 주차확인 private CarParkingAccessList carParkingAccessListScreen = null; private ElecCarMainScreen elecCarMainScreen = null; // 전기차충전 private ConfigNoiseLogMainScreen configNoiseLogMainScreen = null; private CarGuestInfoScreen carGuestInfoScreen = null; // 방문객 차량등록 private BandLocationMainScreen bandLocationMainScreen = null; // 위치확인 (단지지도) private BandLocationListScreen bandLocationListScreen = null; // 위치확인 (내역) private SafeStreetLightMainScreen safeStreetLightMainScreen = null; // 안전가로등 private RepairScreen repairScreen = null; // 보수신청 private VoteScreen voteScreen = null; // 주민투표 private LocalInfoScreen localInfoScreen = null; // 지역정보 private CostScreen costScreen = null; // 관리비조회 private UCityScreen uCityScreen = null; // u-city /* ================================================================================================ * [ Activity Life Cycle ] region ================================================================================================ */ @Override protected void onCreate(Bundle savedInstanceState) { Log.i(TAG, "[START - MainActivity]"); super.onCreate(savedInstanceState); // @ AutoScale 설정 WpadScale.setAutoScale(true); super.AppVersionLogOut(); // 1. 변수 초기화 DebugLogOutput("[Create] - Step1 : Data Create"); PopupActivityRun = false; ManualActivityRun = false; mContext = this; mSound = new WpadSound(this); mV40IF = new V40IF(); // 2. 자동 종료 셋팅 DebugLogOutput("[Create] - Step2 : Auto Finish Setting"); if (Common.FINISH_TIME_ENABLE) super.setFinishTimerCreate(Common.FINISH_TIME_SEC); // 3. API 호출 DebugLogOutput("[Create] - Step3 : API Call"); if (OPERATION_MODE == Common.MODE_NORMAL) { Log.d(TAG, "OperationMode = MODE_NORMAL"); try { wpapi = new WallPadAPI(this); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] - new WallPadAPI : " + e); } } else if (OPERATION_MODE == Common.MODE_BUSINESS_SAMPLE) { Log.d(TAG, "OperationMode = MODE_BUSINESS_SAMPLE"); } try { wdb = new WallpadStatusData(this); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[ExceptionError] - onCreate->WallpadStatusData Create : " + e); } // 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.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, 0, ID.top.image.BACKGROUND); ViewRegistration(TopLayout, TopBackground, 0, 0); TopTitle = new WpadTextView(this, false, 247 + 50, 80, Gravity.LEFT, Color.WHITE, Common.fontsize._44, true, ID.top.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.top.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.top.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.top.button.MENU); ViewRegistration(TopLayout, TopMenuBtn, 0, 0); TopManualBtn = new WpadImageView(this, TOUCH_KIND.BUTTON, 110, 110, R.drawable.topbar_icon_manual_normal, R.drawable.topbar_icon_manual_pressed, ID.top.button.MANUAL); setManualBtnVisible(getManualUse(), 1019); WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(mContext); int noiseUse = wallpadDeviceSet.Get_NoiseSensor_Use(); int cctvUse = wallpadDeviceSet.GetDeviceSetted("CCTV"); int parkingUse = wallpadDeviceSet.GetDeviceSetted("주차확인"); int carGuestUse = wallpadDeviceSet.GetDeviceSetted("방문객차량등록"); int bandLocUse = wallpadDeviceSet.GetDeviceSetted("밴드위치확인"); int elecCarUse = wallpadDeviceSet.GetDeviceSetted("전기차충전"); int safeStreetLightUse = wallpadDeviceSet.GetDeviceSetted("안전가로등"); boolean bNonInternetUse = wallpadDeviceSet.Get_NonInternetSupportUse(); wallpadDeviceSet.closeDB(); Log.d(TAG, "[onCreate] noiseUse [" + noiseUse + "], cctvUse [" + cctvUse + "], parkingUse [" + parkingUse + "], carGuestUse [" + carGuestUse + "], " + "bandLocUse [" + bandLocUse + "], elecCarUse [" + elecCarUse + "], bNonInternetUse [" + bNonInternetUse + "], safeStreetLightUse [" + safeStreetLightUse + "]"); // 6. Menu Loading DebugLogOutput("[Create] - Step6 : Menu Loading"); wallpaddbmgr WallpadDBMGR = new wallpaddbmgr(getApplicationContext()); WallpadDBMGR.DeleteMenuList(); ArrayList> mGroupList = new ArrayList>(); ArrayList mChildList = new ArrayList(); if (bNonInternetUse) { // 인터넷 미지원 mChildList.add(API_Menu.SubMenuAddService.Notice); mChildList.add(API_Menu.SubMenuAddService.Memo); } else { // 인터넷 지원 mChildList.add(API_Menu.SubMenuAddService.Notice); mChildList.add(API_Menu.SubMenuAddService.Weather); mChildList.add(API_Menu.SubMenuAddService.Memo); mChildList.add(API_Menu.SubMenuAddService.AutoPicture); mChildList.add(API_Menu.SubMenuAddService.Schedule); if (cctvUse == WallpadDeviceSet.DEV_DATA_ENABLE || cctvUse == WallpadDeviceSet.DEV_DATA_NONE) { mChildList.add(API_Menu.SubMenuAddService.Cctv); } if (parkingUse == WallpadDeviceSet.DEV_DATA_ENABLE || parkingUse == WallpadDeviceSet.DEV_DATA_NONE) { mChildList.add(API_Menu.SubMenuAddService.Parking); } mChildList.add(API_Menu.SubMenuAddService.ParkingList); if (noiseUse == 1) { mChildList.add(API_Menu.SubMenuAddService.InterlayerNoiseHistory); } if (carGuestUse == WallpadDeviceSet.DEV_DATA_ENABLE) { Log.d(TAG, "[onCreate] ====== 방문객차량등록 ======"); mChildList.add(API_Menu.SubMenuAddService.CarGuest); } if (bandLocUse == WallpadDeviceSet.DEV_DATA_ENABLE) { Log.d(TAG, "[onCreate] ====== 밴드위치확인 ======"); mChildList.add(API_Menu.SubMenuAddService.BandLocation); } if (elecCarUse == WallpadDeviceSet.DEV_DATA_ENABLE) { mChildList.add(API_Menu.SubMenuAddService.ElecCar); } if (safeStreetLightUse == WallpadDeviceSet.DEV_DATA_ENABLE) { Log.d(TAG, "[onCreate] ====== 안전가로등 ======"); mChildList.add(API_Menu.SubMenuAddService.SafeStreetLight); } } // mChildList.add(API_Menu.SubMenuAddService.Repair); // mChildList.add(API_Menu.SubMenuAddService.Vote); // mChildList.add(API_Menu.SubMenuAddService.LocalInfo); // mChildList.add(API_Menu.SubMenuAddService.Cost); // mChildList.add(API_Menu.SubMenuAddService.UCity); mGroupList.add(mChildList); WallpadDBMGR.SetMenuList(mGroupList); menuListDataClass = WallpadDBMGR.GetMenuList(); WallpadDBMGR.closeDB(); if (menuListDataClass == null) { Log.w(TAG, "[onCreate] menuListDataClass == null"); menuListDataClass = LoadDefaultMenuList(); } // 6-1. 메뉴 정보 가져옴 (메인화면에서 전달한 Intent 에서 가져온다.) mMenu = new Menu(); mMenu = super.getIntentParsingMenu(getIntent()); if (mMenu == null) { Log.w(TAG, "[onCreate] mMenu == null"); DefaultMenuListSetting(); } // 6-2. 메뉴 표시 mTempCurrentScreenId = mMenu.getStartId(); if (mTempCurrentScreenId == API_Menu.SubMenuAddService.Memo) { int nModelType = Version.getModelType(); if (nModelType == Version.MODEL_TYPE.IHN_D101 || nModelType == Version.MODEL_TYPE.IHN_D101_I || nModelType == Version.MODEL_TYPE.IHN_D101K || nModelType == Version.MODEL_TYPE.IHN_D101K_I || nModelType == Version.MODEL_TYPE.IHN_D101_I_OCF) { // IHN-D101 메모화면일 경우 스마트폰 조명제어 사용여부 설정 제어하기 위함 (거실에너지미터 BT-Wifi 모듈이 마이크에 무선 노이즈를 발생시키므로 - 영상/음성 메모) mWallPadApiCheckHandler.sendEmptyMessage(0); } else { setChangeScreen(mTempCurrentScreenId, false); } } else { if (mTempCurrentScreenId == API_Menu.SubMenuAddService.BandLocation) { Intent intent = getIntent(); nCardNum = intent.getIntExtra("CARD_NUM", 0); Log.d(TAG, "[onCreate] nCardNum [" + nCardNum + "]"); } setChangeScreen(mTempCurrentScreenId, false); } // 7. Draw DebugLogOutput("[Create] - Step7 : setContentView"); setContentView(AllLayout); // 8. Window ReSize DebugLogOutput("[Create] - Step8 : Window ReSize"); // 9. Check Permission DebugLogOutput("[Create] - Step9 : Permission Check"); boolean hasPermission = (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED); Log.d(TAG, "[onCreate] hasPermission: " + hasPermission); if (!hasPermission) { ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, REQUEST_EXTERNAL_STORAGE); } //퍼미션 추가 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { hasPermission = (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED); Log.d(TAG, "[onCreate] hasPermission: " + hasPermission); if (!hasPermission) { ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_COARSE_LOCATION}, REQUEST_ACCESS_COARSE_LOCATION); } } reg_Receiver(); // 폰트 TEST // Typeface fontType = Typeface.createFromAsset(this.getAssets(), "fonts/NotoSansCJKkr-Thin.otf"); // Typeface fontType = Typeface.createFromAsset(this.getAssets(), "fonts/NanumGothicCoding.ttf"); // TopTitle.setTypeface(fontType); } @Override protected void onResume() { DebugLogOutput("[onResume]"); setAudioMemoPlayVol(false); super.onResume(); if (wpapi != null) wpapi.Resume(); } @Override protected void onPause() { DebugLogOutput("[onPause]"); super.onPause(); if (wpapi != null) wpapi.Pause(); mediaStopRec(); ReleaseSurface(); } @Override protected void onDestroy() { DebugLogOutput("[onDestroy]"); setChangeScreen(mCurrentScreenId, true); unregisterReceiver(mWallPadAlertBR); unregisterReceiver(mWallPadJogBR); mSound.Release(); if (sdbLivingRoomLightAPI != null) { Log.d(TAG, "[onDestroy] sdbLivingRoomLightAPI.SetWifiModuleOnOff [TRUE]"); sdbLivingRoomLightAPI.SetWifiModuleOnOff(true); } if (wdb != null) wdb.closeDB(); if (mCameraOpenCheckHandler != null) { mCameraOpenCheckHandler.removeMessages(0); mCameraOpenCheckHandler.removeMessages(1); } if (mWallPadApiCheckHandler != null) { mWallPadApiCheckHandler.removeMessages(0); mWallPadApiCheckHandler.removeMessages(1); } super.setFinishTimerDestroy(); super.onDestroy(); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { Log.d(TAG, "[onActivityResult]"); super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_OK) { int screenId = data.getIntExtra("ChangeScreen", 0); Log.d(TAG, "ChangeScreen : " + screenId); setChangeScreen(screenId, false); } } @Override public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) { Log.d(TAG, "[onRequestPermissionsResult] requestCode: " + requestCode); super.onRequestPermissionsResult(requestCode, permissions, grantResults); switch (requestCode) { case REQUEST_EXTERNAL_STORAGE: { if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { Log.d(TAG, "[onRequestPermissionsResult] PERMISSION_GRANTED"); } else { Log.d(TAG, "[onRequestPermissionsResult] PERMISSION_NOT_GRANTED"); } return; } case REQUEST_ACCESS_COARSE_LOCATION: { if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { Log.d(TAG, "[onRequestPermissionsResult] PERMISSION_GRANTED"); } else { Log.d(TAG, "[onRequestPermissionsResult] PERMISSION_NOT_GRANTED"); } return; } } } @SuppressLint("HandlerLeak") protected Handler mWallPadApiCheckHandler = new Handler() { @SuppressLint("HandlerLeak") @Override public void handleMessage(Message msg) { if (msg.what == 0) { if (wpapi != null) { if (wpapi.Check_Connect()) mWallPadApiCheckHandler.sendEmptyMessageDelayed(1, 10); else mWallPadApiCheckHandler.sendEmptyMessageDelayed(0, 10); } } else if (msg.what == 1) { Log.d(TAG, "[mWallPadApiCheckHandler] Finish!! sdbLivingRoomLightAPI is connected!!"); setChangeScreen(mTempCurrentScreenId, false); sdbLivingRoomLightAPI = wpapi.Get_Sdb_LivingRoomLightAPI(); } } }; /* ================================================================================================ * [BroadcastReceiver] Section ================================================================================================ */ @Override protected void onBrReceive(Intent intent) { super.onBrReceive(intent); DebugLogOutput("[onBrReceive] Receive alert BR " + intent.getAction()); } /* ================================================================================================ * [Touch & Key Event] Section ================================================================================================ */ @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.top.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.top.button.BACK) { DebugLogOutput("onTouchEvent [BACK] BUTTON !!!"); mSound.Play(SND.effect.TOUCH_LATCHED); if (mCurrentScreenId == ID.screen.MemoMakeDrawing || mCurrentScreenId == ID.screen.MemoMakeAudio || mCurrentScreenId == ID.screen.MemoMakeVideo) { setChangeScreen(API_Menu.SubMenuAddService.Memo, false); } else if (mCurrentScreenId == ID.screen.AutoPictureShowScreen) { setChangeScreen(API_Menu.SubMenuAddService.AutoPicture, false); } else if (mCurrentScreenId == ID.screen.NoticeContentsScreen) { setChangeScreen(API_Menu.SubMenuAddService.Notice, false); } else if (mCurrentScreenId == ID.screen.BandLocationListScreen) { setChangeScreen(API_Menu.SubMenuAddService.BandLocation, false); } } else if (TargetId == ID.top.button.MENU) { DebugLogOutput("onTouchEvent [MENU] BUTTON !!!"); if (MenuOpen) { return; } mSound.Play(SND.effect.TOUCH_LATCHED); OpenMenuLayout(); } else if (TargetId == ID.menu.button.CLOSE) { DebugLogOutput("onTouchEvent [CLOSE] BUTTON"); if (MenuOpen) { mSound.Play(SND.effect.TOUCH_LATCHED); CloseMenuLayout(); } } else if (TargetId == ID.top.button.MANUAL) { DebugLogOutput("onTouchEvent [MANUAL] BUTTON mCurrentScreenId [" + mCurrentScreenId + "]"); mSound.Play(SND.effect.TOUCH_LATCHED); if (mCurrentScreenId == API_Menu.SubMenuAddService.Notice) { StartManual(ID.screen.ManualNoticeMainScreen); } else if (mCurrentScreenId == ID.screen.NoticeContentsScreen) { StartManual(ID.screen.ManualNoticeSubScreen); } else if (mCurrentScreenId == API_Menu.SubMenuAddService.Weather) { StartManual(ID.screen.ManualWeatherMainScreen); } else if (mCurrentScreenId == API_Menu.SubMenuAddService.Memo) { StartManual(ID.screen.ManualMemoMainScreen); } else if (mCurrentScreenId == ID.screen.MemoMakeDrawing) { StartManual(ID.screen.ManualDrawingMemoScreen); } else if (mCurrentScreenId == ID.screen.MemoMakeAudio) { StartManual(ID.screen.ManualAudioMemoScreen); } else if (mCurrentScreenId == ID.screen.MemoMakeVideo) { StartManual(ID.screen.ManualVideoMemoScreen); } else if (mCurrentScreenId == API_Menu.SubMenuAddService.AutoPicture) { StartManual(ID.screen.ManualAutoPictureMainScreen); } else if (mCurrentScreenId == ID.screen.AutoPictureShowScreen) { StartManual(ID.screen.ManualAutoPictureShowScreen); } else if (mCurrentScreenId == API_Menu.SubMenuAddService.Schedule) { StartManual(ID.screen.ManualScheduleMainScreen); } else if (mCurrentScreenId == API_Menu.SubMenuAddService.Cctv) { StartManual(ID.screen.ManualCCTVMainScreen); } else if (mCurrentScreenId == API_Menu.SubMenuAddService.ElecCar) { StartManual(ID.screen.ManualElecCarMainScreen); } else if (mCurrentScreenId == API_Menu.SubMenuAddService.Parking) { StartManual(ID.screen.ManualCarInfoMainScreen); } else if (mCurrentScreenId == API_Menu.SubMenuAddService.ParkingList) { StartManual(ID.screen.ManualCarInfoListScreen); } else if (mCurrentScreenId == API_Menu.SubMenuAddService.CarGuest) { StartManual(ID.screen.ManualCarGuestInfoScreen); } else if (mCurrentScreenId == API_Menu.SubMenuAddService.BandLocation) { StartManual(ID.screen.ManualBandLocationMainScreen); } else if (mCurrentScreenId == ID.screen.BandLocationListScreen) { StartManual(ID.screen.ManualBandLocationListScreen); } else if (mCurrentScreenId == ID.screen.SafeStreetLightMainScreen) { StartManual(ID.screen.ManualSafeStreetLightScreen); } } } } private static final int BTN_CALL_IHN1010 = 264; // H/W Key Event @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 ================================================================================================ */ public boolean setTopBackBtnVisible(boolean Enabled) { if (Enabled) { if (TopBackBtn.getVisibility() != View.VISIBLE) TopBackBtn.setVisibility(View.VISIBLE); TopBackBtn.bringToFront(); } else { if (TopBackBtn.getVisibility() != View.INVISIBLE) TopBackBtn.setVisibility(View.INVISIBLE); } return true; } public boolean setTopMenuBtnVisible(boolean Enabled) { if (Enabled) { if (TopMenuBtn.getVisibility() != View.VISIBLE) TopMenuBtn.setVisibility(View.VISIBLE); TopMenuBtn.bringToFront(); } else { if (TopMenuBtn.getVisibility() != View.INVISIBLE) TopMenuBtn.setVisibility(View.INVISIBLE); } return true; } public void setTopTitleText(String strText) { try { if (TopTitle != null) TopTitle.setText(strText); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] setTopTitleText(String strText)"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } public void setTopHomeBtnStatus(boolean bEnable) { try { if (TopHomeBtn != null) { // Log.d(TAG, "[setTopHomeBtnStatus] bEnable [" + bEnable + "]"); if (!bEnable) TopHomeBtn.setButtonEventOffEnable(R.drawable.topbar_icon_home_disabled); else TopHomeBtn.setButtonEventOffDisable(); } } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] setTopHomeBtnStatus(boolean bEnable)"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } public void setTopBackBtnStatus(boolean bEnable) { try { if (TopBackBtn != null) { // Log.d(TAG, "[setTopBackBtnStatus] bEnable [" + bEnable + "]"); if (!bEnable) TopBackBtn.setButtonEventOffEnable(R.drawable.topbar_icon_back_disabled); else TopBackBtn.setButtonEventOffDisable(); } } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] setTopBackBtnStatus(boolean bEnable)"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } public void setTopMenuBtnStatus(boolean bEnable) { try { if (TopMenuBtn != null) { if (!bEnable) TopMenuBtn.setButtonEventOffEnable(R.drawable.topbar_icon_menu_disabled); else TopMenuBtn.setButtonEventOffDisable(); } } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] setTopMenuBtnStatus(boolean bEnable)"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } public void setTopManualBtnStatus(boolean bEnable) { try { if (TopManualBtn != null) { if (!bEnable) TopManualBtn.setButtonEventOffEnable(R.drawable.topbar_icon_manual_disabled); else TopManualBtn.setButtonEventOffDisable(); } } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] setTopManualBtnStatus(boolean bEnable)"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } /* ================================================================================================ * [Popup Activity] Section ================================================================================================ */ public boolean StartPopup(int ScreenId) { if (getPopupActivityRun()) { 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; } } public boolean StartPopup(int ScreenId, Intent data) { if (getPopupActivityRun()) { 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; } } /* ================================================================================================ * [Manual Activity] Section ================================================================================================ */ public static ManualActivity mManualActivity; 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); overridePendingTransition(0, 0); startActivityForResult(intent, 0); return true; } } public boolean getManualUse() { 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; } } 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); } } 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 void finishManual(int screenId) { try { Log.d(TAG, "[finishManual] mCurrentManualScreenId [" + mCurrentManualScreenId +"], screenId [" + screenId +"]"); if (screenId == ID.screen.Manual_All) FinishManualActivity(); else { if (mCurrentManualScreenId != screenId) return; FinishManualActivity(); } } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] finishManual(int screenId)"); //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); } } /* ================================================================================================ * [Screen] Section ================================================================================================ */ @Override protected boolean onChangeScreen(int nScreenId) { super.onChangeScreen(nScreenId); return setChangeScreen(nScreenId, false); } private boolean setChangeScreen(int nScreenId, boolean OnlyRemove) { DebugLogOutput("setChangeScreen - " + "CurrentSelectDeviceId : " + mCurrentScreenId + " / NextLayoutId : " + nScreenId + " / OnlyRemove : " + OnlyRemove); if (mCurrentScreenId > 0) { ScreenLayout.removeAllViews(); super.setCurrentScreen(null); } if (OnlyRemove) return true; mCurrentScreenId = nScreenId; try { switch (nScreenId) { // Default Menu case API_Menu.SubMenuAddService.Notice: // 공지사항 setTitleText(API_Menu.SubMenuAddService.Name_Notice); noticeMainScreen = new NoticeMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE); super.setCurrentScreen(noticeMainScreen); break; case ID.screen.NoticeContentsScreen: // sub - 공지사항 내용 noticeContentsScreen = new NoticeContentsScreen(this, ScreenLayout, wpapi, OPERATION_MODE); super.setCurrentScreen(noticeContentsScreen); break; case API_Menu.SubMenuAddService.Weather: // 날씨 setTitleText(API_Menu.SubMenuAddService.Name_Weather); if (!getAsSubWallPad()) { // 메인월패드 weatherMainScreen = new WeatherMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE); super.setCurrentScreen(weatherMainScreen); } else { // 서브월패드 weatherSubScreen = new WeatherScreen_SubWallPad(this, ScreenLayout); super.setCurrentScreen(weatherSubScreen); } break; case API_Menu.SubMenuAddService.Memo: // 메모 setTitleText(API_Menu.SubMenuAddService.Name_Memo); memoMainScreen = new MemoMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE); super.setCurrentScreen(memoMainScreen); break; case ID.screen.MemoMakeDrawing: // sub - 그림메모 memoMainDrawingScreen = new MemoMakeDrawing(this, ScreenLayout, wpapi, OPERATION_MODE); super.setCurrentScreen(memoMainDrawingScreen); break; case ID.screen.MemoMakeAudio: // sub - 음성메모 memoMainAudioScreen = new MemoMakeAudio(this, ScreenLayout, wpapi, OPERATION_MODE); super.setCurrentScreen(memoMainAudioScreen); break; case ID.screen.MemoMakeVideo: // sub - 영상메모 memoMainVideoScreen = new MemoMakeVideo(this, ScreenLayout, wpapi, OPERATION_MODE); super.setCurrentScreen(memoMainVideoScreen); break; case API_Menu.SubMenuAddService.AutoPicture: // 전자액자 setTitleText(API_Menu.SubMenuAddService.Name_AutoPicture); autoPictureMainScreen = new AutoPictureMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE); super.setCurrentScreen(autoPictureMainScreen); break; case ID.screen.AutoPictureShowScreen: // sub - 전자액자시작 autoPictureSubShowScreen = new AutoPictureSubShowScreen(this, ScreenLayout, wpapi, OPERATION_MODE); super.setCurrentScreen(autoPictureSubShowScreen); break; case API_Menu.SubMenuAddService.Schedule: // 일정표 setTitleText(API_Menu.SubMenuAddService.Name_Schedule); scheduleMainScreen = new ScheduleMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE); super.setCurrentScreen(scheduleMainScreen); break; case API_Menu.SubMenuAddService.Cctv: // cctv setTitleText(API_Menu.SubMenuAddService.Name_Cctv); cctvMainScreen = new CctvMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE); super.setCurrentScreen(cctvMainScreen); break; case API_Menu.SubMenuAddService.Parking: // 주차확인 setTitleText(API_Menu.SubMenuAddService.Name_Parking); carInfoMainScreen = new CarInfoMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE); super.setCurrentScreen(carInfoMainScreen); break; case API_Menu.SubMenuAddService.ParkingList: // 차량출입내역 setTitleText(API_Menu.SubMenuAddService.Name_ParkingList); carParkingAccessListScreen = new CarParkingAccessList(this, ScreenLayout, wpapi, OPERATION_MODE); super.setCurrentScreen(carParkingAccessListScreen); break; case API_Menu.SubMenuAddService.ElecCar: // 전기차충전 setTitleText(API_Menu.SubMenuAddService.Name_ElecCar); elecCarMainScreen = new ElecCarMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE); super.setCurrentScreen(elecCarMainScreen); break; // Additional Menu case ID.screen.RepairScreen: // 보수신청 repairScreen = new RepairScreen(this, ScreenLayout, wpapi, OPERATION_MODE); super.setCurrentScreen(repairScreen); break; case ID.screen.VoteScreen: // 주민투표 voteScreen = new VoteScreen(this, ScreenLayout, wpapi, OPERATION_MODE); super.setCurrentScreen(voteScreen); break; case ID.screen.LocalInfoScreen: // 지역정보 localInfoScreen = new LocalInfoScreen(this, ScreenLayout, wpapi, OPERATION_MODE); super.setCurrentScreen(localInfoScreen); break; case ID.screen.CostInfoScreen: // 관리비조회 costScreen = new CostScreen(this, ScreenLayout, wpapi, OPERATION_MODE); super.setCurrentScreen(costScreen); break; case ID.screen.UCityScreen: // U-City uCityScreen = new UCityScreen(this, ScreenLayout, wpapi, OPERATION_MODE); super.setCurrentScreen(uCityScreen); break; case API_Menu.SubMenuAddService.InterlayerNoiseHistory: // 층간소음 내역 setTitleText(API_Menu.SubMenuAddService.Name_NoiseLog); configNoiseLogMainScreen = new ConfigNoiseLogMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE); super.setCurrentScreen(configNoiseLogMainScreen); break; case API_Menu.SubMenuAddService.CarGuest: // 방문객 차량등록 setTitleText(API_Menu.SubMenuAddService.Name_CarGuest); carGuestInfoScreen = new CarGuestInfoScreen(this, ScreenLayout, wpapi, OPERATION_MODE); super.setCurrentScreen(carGuestInfoScreen); break; case API_Menu.SubMenuAddService.BandLocation: // 밴드위치확인 setTitleText(API_Menu.SubMenuAddService.Name_BandLocation); bandLocationMainScreen = new BandLocationMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE); super.setCurrentScreen(bandLocationMainScreen); break; case ID.screen.BandLocationListScreen: bandLocationListScreen = new BandLocationListScreen(this, ScreenLayout, wpapi, OPERATION_MODE); super.setCurrentScreen(bandLocationListScreen); break; case API_Menu.SubMenuAddService.SafeStreetLight: // 안전가로등 setTitleText(API_Menu.SubMenuAddService.Name_SafeStreetLight); safeStreetLightMainScreen = new SafeStreetLightMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE); super.setCurrentScreen(safeStreetLightMainScreen); break; default: Log.e(TAG, "[Error] setChangeScreen - nScreenId Not found!!! (" + mCurrentScreenId + ")"); mCurrentScreenId = -1; return false; } } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[ExceptionError] - setChangeScreen->Screen Create : " + e); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); return false; } return true; } private void setTitleText(String setText) { if (setText != null) TopTitle.setText(setText); } /* ================================================================================================ * [Menu] Section ================================================================================================ */ // Default 메뉴 리스트 설정 private void DefaultMenuListSetting() { try { Log.d(TAG, "[DefaultMenuListSetting()]"); mMenu = new Menu(7); wallpaddbmgr WallpadDBMGR = new wallpaddbmgr(getApplicationContext()); WallpadDBMGR.DeleteMenuList(); ArrayList> mGroupList = new ArrayList>(); ArrayList mChildList = new ArrayList(); WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(mContext); boolean bNonInternetUse = wallpadDeviceSet.Get_NonInternetSupportUse(); wallpadDeviceSet.closeDB(); if (bNonInternetUse) { // 인터넷 미지원 mChildList.add(API_Menu.SubMenuAddService.Notice); mChildList.add(API_Menu.SubMenuAddService.Memo); } else { // 인터넷 지원 mChildList.add(API_Menu.SubMenuAddService.Notice); mChildList.add(API_Menu.SubMenuAddService.Weather); mChildList.add(API_Menu.SubMenuAddService.Memo); mChildList.add(API_Menu.SubMenuAddService.AutoPicture); mChildList.add(API_Menu.SubMenuAddService.Schedule); } mGroupList.add(mChildList); WallpadDBMGR.SetMenuList(mGroupList); menuListDataClass = WallpadDBMGR.GetMenuList(); WallpadDBMGR.closeDB(); mMenu.StartId = API_Menu.SubMenuAddService.Notice; mMenu.Opiton = -1; } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] DefaultMenuSetting()"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } // 메뉴 레이아웃 생성 private void OpenMenuLayout() { if (MenuOpen) { return; } if (menuListDataClass == null) { return; } //0. 현재 ID 및 리스트 불러오기 String Title = API_Menu.GetGroupNameByID(API_Menu.SubMenuAddService.BASE); String TempChildName = null; int ChooseGroup = 0; int ChooseChild = 0; for (int i = 0; i < menuListDataClass.arrayGroup.size(); i++) { if (menuListDataClass.arrayGroup.get(i).equals(Title)) { ChooseGroup = i; break; } } for (int i = 0; i < menuListDataClass.idMappingTable.length; i++) { if (menuListDataClass.idMappingTable[i].Id == mCurrentScreenId) { TempChildName = menuListDataClass.idMappingTable[i].Name; break; } else if ((ID.screen.MemoMakeDrawing == mCurrentScreenId) || (ID.screen.MemoMakeAudio == mCurrentScreenId) || (ID.screen.MemoMakeVideo == mCurrentScreenId)) { Title = API_Menu.SubMenuAddService.Name; TempChildName = API_Menu.SubMenuAddService.Name_Memo; break; } else if (ID.screen.NoticeContentsScreen == mCurrentScreenId) { Title = API_Menu.SubMenuAddService.Name; TempChildName = API_Menu.SubMenuAddService.Name_Notice; break; } else if (ID.screen.AutoPictureShowScreen == mCurrentScreenId) { Title = API_Menu.SubMenuAddService.Name; TempChildName = API_Menu.SubMenuAddService.Name_AutoPicture; break; } else if (ID.screen.BandLocationListScreen == mCurrentScreenId) { Title = API_Menu.SubMenuAddService.Name; TempChildName = API_Menu.SubMenuAddService.Name_BandLocation; } else if (ID.screen.SafeStreetLightMainScreen == mCurrentScreenId) { Title = API_Menu.SubMenuAddService.Name; TempChildName = API_Menu.SubMenuAddService.Name_SafeStreetLight; } } if (TempChildName == null) { Log.e(TAG, "[OpenMenuLayout] TempChildName == null"); return; } for (int i = 0; i < menuListDataClass.arrayChild.get(Title).size(); i++) { if (menuListDataClass.arrayChild.get(Title).get(i).equals(TempChildName)) { 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.menu.image.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.top.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.menu.button.CLOSE); 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.menu.view.LISTVIEW); 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, menuListDataClass.arrayGroup, menuListDataClass.arrayChild, ChooseGroup, ChooseChild); mListView.setAdapter(adptMain); //7. 선택된 그룹 열기 mListView.setSelectedGroup(ChooseGroup); mListView.expandGroup(ChooseGroup); // 8. 리스트뷰 터치 이벤트 등록 mListView.setOnTouchListener(new View.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 ExpandableListView.OnGroupClickListener() { @Override public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) { WpadActivity.setFinishTimerReset(); return false; } }); // 10. 차일드 터치 이벤트 등록 mListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() { @Override public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { WpadActivity.setFinishTimerReset(); return false; } }); // 11. 그룹 열리는 경우 이벤트 mListView.setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener() { @Override public void onGroupExpand(int groupPosition) { mSound.Play(SND.effect.TOUCH_LATCHED); WpadActivity.setFinishTimerReset(); } }); // 12. 그룹 닫히는 경우 이벤트 mListView.setOnGroupCollapseListener(new ExpandableListView.OnGroupCollapseListener() { @Override public void onGroupCollapse(int groupPosition) { mSound.Play(SND.effect.TOUCH_LATCHED); WpadActivity.setFinishTimerReset(); } }); // 13. MenuOpen True 설정 MenuOpen = true; } // 메뉴 layout 닫힘 처리 private void CloseMenuLayout() { if (!MenuOpen) { return; } TranslateAnimation anim = new TranslateAnimation(0, WpadScale.getWidth(-460), 0, 0); anim.setDuration(200); anim.setInterpolator(new AccelerateInterpolator()); anim.setAnimationListener(new Animation.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) { mListView.expandGroup(GroupId); } else { mListView.collapseGroup(GroupId); } } // Menu정보가 DB에 없을 경우 불러올 스크린 로딩 private MenuListDataClass LoadDefaultMenuList() { MenuListDataClass Temp_menuListDataClass = new MenuListDataClass(); Temp_menuListDataClass.SetArrayGroup(API_Menu.SubMenuAddService.Name); ArrayList arrayList = new ArrayList(); int ChildCount = 0; //[수정필요] //추가 또는 수정해야할 부분 1. - Menu정보가 DB에 없을 경우 불러올 스크린 종류(시작) arrayList.add(API_Menu.SubMenuAddService.Name_Schedule); ChildCount++; Temp_menuListDataClass.SetArrayChild(API_Menu.SubMenuAddService.Name, arrayList); //추가 또는 수정해야할 부분 1. - Menu정보가 DB에 없을 경우 불러올 스크린 종류(끝) Temp_menuListDataClass.idMappingTable = new MenuListDataClass.ChildIDMapping[ChildCount]; for (int i = 0; i < ChildCount; i++) { Temp_menuListDataClass.idMappingTable[i] = new MenuListDataClass.ChildIDMapping(); //추가 또는 수정해야할 부분 2. - 불러올 스크린의 Id를 임의로 입력(시작) if (arrayList.get(i).equals(API_Menu.SubMenuAddService.Name_Schedule)) { Temp_menuListDataClass.idMappingTable[i].Id = API_Menu.SubMenuAddService.Schedule; Temp_menuListDataClass.idMappingTable[i].Name = API_Menu.SubMenuAddService.Name_Schedule; } //추가 또는 수정해야할 부분 2. - 불러올 스크린의 Id를 임의로 입력(끝) } return Temp_menuListDataClass; } /** * 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) { Log.e(TAG, "[Exception] reg_Receiver"); //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) { mSound.Play(SND.effect.TOUCH_LATCHED); CloseMenuLayout(); if (menuListDataClass == null) { return; } String childName = menuListDataClass.arrayChild.get(menuListDataClass.arrayGroup.get(groupPosition)).get(childPosition); for (int i = 0; i < menuListDataClass.idMappingTable.length; i++) { if (menuListDataClass.idMappingTable[i].Name.equals(childName)) { API_Menu api_Menu = new API_Menu(); int TempId = api_Menu.GetMyGroupID(getApplicationContext().getPackageName()); int ChildId = menuListDataClass.idMappingTable[i].Id; int ChildGroupId = (ChildId / 1000) * 1000; Log.i(TAG, "Child Id :" + ChildId); if (TempId == 0) { return; } if (ChildGroupId == TempId) { boolean result = setChangeScreen(ChildId, false); if (!result) { setChangeScreen(mMenu.getStartId(), false); } WpadActivity.setFinishTimerReset(); } else { //외부 앱 호출 후, 본 APP Finish 필요 api_Menu.startSubScreenActivity(getApplicationContext(), menuListDataClass.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; } } } } } }; // 영상 private MediaRecorder m_mediaRecorder; private final String VIDEO_TEMP_PATH = define.BESTIN_LOCATION + "VideoRecorded.mp4"; private SurfaceHolder holder; private SurfaceView surface; public PlayerSurfaceView getTechWinSurfaceView() { PlayerSurfaceView mPlayerSurfaceView; mPlayerSurfaceView = (PlayerSurfaceView) findViewById(R.id.PlayerView); return mPlayerSurfaceView; } Camera wpCamera = null; public void mediaSurface() { Log.d(TAG, "[mediaSurface]"); try { if (surface != null) { Log.v(TAG, "[mediaSurface] surface isn't null"); surface.getHolder().removeCallback(wpVideoCallback); ScreenLayout.removeView(surface); } surface = new SurfaceView(this); holder = surface.getHolder(); WpadRelativeLayoutParams params = new WpadRelativeLayoutParams(720, 540); params.setMargins(Common.ImgPosition.GetX(95), Common.ImgPosition.GetY(112), 0, 0); ScreenLayout.addView(surface, params); surface.getHolder().addCallback(wpVideoCallback); surface.setZOrderOnTop(true); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] mediaSurface()"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } private SurfaceHolder.Callback wpVideoCallback = new SurfaceHolder.Callback() { @Override public void surfaceCreated(SurfaceHolder holder) { Log.d(TAG, "[wpVideoCallback.surfaceCreated]"); if (mV40IF != null) mV40IF.ctrlWallPadCamPower(true); try { boolean bAOS7 = false; if (Build.VERSION.SDK_INT > 23) bAOS7 = true; if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101) { Log.d(TAG, "[openCamera] Build.VERSION.SDK_INT [" + Build.VERSION.SDK_INT + "], bAOS7 [" + bAOS7 + "]"); if (bAOS7) { // AOS 7.1.1 wpCamera = Camera.open(Camera.CameraInfo.CAMERA_FACING_FRONT); // 확인완료 (JEFF, 2020.09.02) } else { // AOS 6.0 wpCamera = Camera.open(Camera.CameraInfo.CAMERA_FACING_FRONT); } } else { if (bAOS7) { /** * 확인완료 (JEFF, 2020.09.02) * IHN-1020B-I, IHN-D101-I, IHN-1010-I, IHN-HS101-I */ // AOS 7.1.1 if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020B_I && !getCompareBSPVersion("2020.09.08")) wpCamera = Camera.open(Camera.CameraInfo.CAMERA_FACING_BACK); else if (Version.getModelType() == Version.MODEL_TYPE.IHN_HS101_I && !getCompareBSPVersion("2020.06.11")) wpCamera = Camera.open(Camera.CameraInfo.CAMERA_FACING_BACK); else wpCamera = Camera.open(Camera.CameraInfo.CAMERA_FACING_FRONT); } else { /** * 확인완료 (JEFF, 2020.09.11) * IHN-1010, IHN-HS101 */ // AOS 6.0 wpCamera = Camera.open(Camera.CameraInfo.CAMERA_FACING_BACK); // 확인완료 (JEFF, 2020.09.02) } } Camera.Parameters params = wpCamera.getParameters(); params.setPictureSize(640, 480); wpCamera.setParameters(params); wpCamera.setPreviewDisplay(holder); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] wpVideoCallback.surfaceCreated()"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } @Override public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { Log.d(TAG, "[wpVideoCallback.surfaceChanged]"); wpCamera.startPreview(); } @Override public void surfaceDestroyed(SurfaceHolder holder) { Log.d(TAG, "[wpVideoCallback.surfaceDestroyed]"); if (mV40IF != null) mV40IF.ctrlWallPadCamPower(false); if (wpCamera != null) { wpCamera.stopPreview(); wpCamera.release(); wpCamera = null; } } }; public boolean getSmartIoTCameraUsage() { WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this.getApplicationContext()); try { if (mWallpadDeviceSet != null) { int[] anFrontCameraType = mWallpadDeviceSet.Get_RFDoorCAM_Info(); // 현관카메라 종류 mWallpadDeviceSet.closeDB(); // 현관카메라 종류 if (anFrontCameraType != null) { if ((anFrontCameraType[1] == WallpadDeviceSet.DOORTYPE_IOT_SMART)) return true; else return false; } else { Log.w(TAG, "[getSmartIoTCameraUsage] anFrontCameraType is null!!"); return false; } } else { Log.w(TAG, "[getSmartIoTCameraUsage] mWallpadDeviceSet is null!!"); } } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] getSmartIoTCameraUsage()"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } mWallpadDeviceSet.closeDB(); return false; } public void getV40MicGain() { try { Log.d(TAG, "[getV40MicGain]"); int nModelType = Version.getModelType(); if (nModelType == Version.MODEL_TYPE.IHN_D101 || nModelType == Version.MODEL_TYPE.IHN_D101_I || nModelType == Version.MODEL_TYPE.IHN_D101K || nModelType == Version.MODEL_TYPE.IHN_D101K_I || nModelType == Version.MODEL_TYPE.IHN_1010GL || nModelType == Version.MODEL_TYPE.IHN_1010GL_I || nModelType == Version.MODEL_TYPE.IHN_1010GL_I_2443ALT || nModelType == Version.MODEL_TYPE.IHN_1010GL_I_6410ALT || nModelType == Version.MODEL_TYPE.IHN_D101_I_OCF) { if (mV40IF != null) Log.d(TAG, "[getV40MicGain] getMICGain() [" + mV40IF.getMICGain() + "]"); } else Log.w(TAG, "[getV40MicGain] Not Supported MODEL!! MODEL_TYPE [" + nModelType + "]"); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] getV40MicGain()"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } public void setV40MicGain(int nValue) { try { Log.d(TAG, "[setV40MicGain] nValue [" + nValue + "]"); int nModelType = Version.getModelType(); if (nModelType == Version.MODEL_TYPE.IHN_D101 || nModelType == Version.MODEL_TYPE.IHN_D101_I || nModelType == Version.MODEL_TYPE.IHN_D101K || nModelType == Version.MODEL_TYPE.IHN_D101K_I || nModelType == Version.MODEL_TYPE.IHN_1010GL || nModelType == Version.MODEL_TYPE.IHN_1010GL_I || nModelType == Version.MODEL_TYPE.IHN_1010GL_I_2443ALT || nModelType == Version.MODEL_TYPE.IHN_1010GL_I_6410ALT || nModelType == Version.MODEL_TYPE.IHN_D101_I_OCF) { if (mV40IF != null) mV40IF.setMICGain(nValue); } else Log.w(TAG, "[setV40MicGain] Not Supported MODEL!! MODEL_TYPE [" + nModelType + "]"); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] setV40MicGain(int nValue)"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } public void mediaStartRecording() { try { if (m_mediaRecorder != null) { Log.d(TAG, "[mediaStartRecording] m_mediaRecorder isn't null!"); m_mediaRecorder.stop(); m_mediaRecorder.reset(); m_mediaRecorder.release(); m_mediaRecorder = null; } m_mediaRecorder = new MediaRecorder(); Log.d(TAG, "[mediaStartRecording] ====== setAudioSource ====="); mCameraOpenCheckHandler.sendEmptyMessage(0); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Throwable t) { //t.printStackTrace(); LogUtil.errorLogInfo("", TAG, t); Log.w("printStackTrace : ", t); } } public void mediaStopRec() { if (m_mediaRecorder != null) { m_mediaRecorder.stop(); m_mediaRecorder.reset(); m_mediaRecorder.release(); ScreenLayout.removeView(surface); m_mediaRecorder = null; if (mV40IF != null) mV40IF.ctrlWallPadCamPower(false); if (wpCamera != null) { wpCamera.stopPreview(); wpCamera.release(); wpCamera = null; } } } public void ReleaseSurface() { if (surface != null) { surface = null; } } private Handler mCameraOpenCheckHandler = new Handler() { @Override public void handleMessage(Message msg) { if (msg.what == 0) { if (wpCamera != null) mCameraOpenCheckHandler.sendEmptyMessageDelayed(1, 10); else mCameraOpenCheckHandler.sendEmptyMessageDelayed(0, 10); } else if (msg.what == 1) { // 영상 메모 녹화 시작!! Log.d(TAG, "[mCameraOpenCheckHandler.handleMessage] Handler finish!! [CAMERA OPEN]"); wpCamera.unlock(); m_mediaRecorder.setCamera(wpCamera); m_mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC); m_mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA); m_mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4); m_mediaRecorder.setVideoSize(640, 480); m_mediaRecorder.setVideoEncodingBitRate(1024 * 1024); m_mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT); m_mediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.DEFAULT); if (Build.VERSION.SDK_INT > 23) m_mediaRecorder.setVideoFrameRate(24); m_mediaRecorder.setOutputFile(VIDEO_TEMP_PATH); m_mediaRecorder.setPreviewDisplay(holder.getSurface()); try { Log.d(TAG, "[mediaStartRecording] m_mediaRecorder.prepare"); m_mediaRecorder.prepare(); } catch (IllegalStateException e) { Log.e(TAG, "[IllegalStateException] mediaStartRecording: " + e.toString()); } catch (IOException e) { Log.e(TAG, "[IOException] mediaStartRecording: " + e.toString()); } m_mediaRecorder.start(); } } }; public void DisplayImageCam(byte[] pData, int offset, int length, int nID) { Log.d("test", "DisplayImageCam1"); ImageView IV = (ImageView) findViewById(nID); Bitmap bMap = BitmapFactory.decodeByteArray(pData, offset, length); IV.setImageBitmap(bMap); } public enum MAINEVENT { BTN_HOME, BTN_BACK, BTN_MENU } public interface MainEventListener { public void onMainTouchEvent(MAINEVENT eEvent); } MainEventListener mMainEventListener; public void setMainEventListener(MainEventListener MEL) { mMainEventListener = MEL; } public void releaseMainEventListener() { mMainEventListener = null; } /** * 월패드 타입 판별 * @return bResult * false: 메인월패드 * true: 서브월패드 */ public boolean getAsSubWallPad() { boolean bResult = false; try { WallpadDeviceSet devSet = new WallpadDeviceSet(this); String[] DBinfo = devSet.GetSettingData("서브월패드"); devSet.closeDB(); if(DBinfo != null) { if (DBinfo[1].indexOf("사용함") > 0) bResult = true; else bResult = false; } } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e("Common", "[Exception] getAsSubWallPad()"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } Log.i(TAG, "[GetWallPadType] bResult [" + bResult + "]"); return bResult; } private void setAudioMemoPlayVol(boolean bMemoPlay) { try { Log.d(TAG, "[setAudioMemoPlayVol] bMemoPlay [" + bMemoPlay + "]"); if (bMemoPlay) MainActivity.mV40IF.setWallPadVolume_V40("0x0A00"); // FM8802 음량 올림 MainActivity.mV40IF.setWallPadVolume_V40("0x0100"); } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG, re); } catch (Exception e) { Log.e(TAG, "[Exception] sendHandlerMsgDelayed(int what, int arg1, int arg2, long delay"); //e.printStackTrace(); LogUtil.errorLogInfo("", TAG, e); } } /** * 절전모드에서 백라이트를 키는 경우, BSP에서 PowerManager 또는 속성값으로 상태를 구분하는데 * BSP 버전에 따라 상이하게 동작하므로 BSP 버전 구분하여 절전모드 판별 필요 * @return true: 기준 BSP 이후 버전, false: 기준 BSP 이전 버전 */ public static boolean getCompareBSPVersion(String version) { try { StringBuilder strBSPVersion = new StringBuilder(); StringBuffer sysInfoBuffer = new StringBuffer(); sysInfoBuffer.append(Build.DISPLAY); strBSPVersion.append(sysInfoBuffer.toString()); String result = strBSPVersion.toString(); Log.d(TAG, "[getCompareBSPVersion] result [" + result + "]"); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy.MM.dd"); Date date = simpleDateFormat.parse(result); Date standardDate = simpleDateFormat.parse(version); // 비교 기준 BSP 버전 if (date.compareTo(standardDate) >= 0) { Log.d(TAG, "[getCompareBSPVersion] BSP VERSION OVER!"); return true; } } catch (RuntimeException re) { LogUtil.errorLogInfo("", TAG,re); } catch (Exception e) { Log.e(TAG, "[Exception] getCompareBSPVersion"); LogUtil.errorLogInfo("", TAG, e); } return false; } }