MainActivity.java 81 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842
  1. package kr.co.icontrols.wallpadaddservice;
  2. import android.Manifest;
  3. import android.annotation.SuppressLint;
  4. import android.content.BroadcastReceiver;
  5. import android.content.Context;
  6. import android.content.Intent;
  7. import android.content.IntentFilter;
  8. import android.content.pm.PackageManager;
  9. import android.graphics.Bitmap;
  10. import android.graphics.BitmapFactory;
  11. import android.graphics.Color;
  12. import android.hardware.Camera;
  13. import android.media.MediaRecorder;
  14. import android.os.Build;
  15. import android.os.Bundle;
  16. import android.os.Handler;
  17. import android.os.Message;
  18. import androidx.core.app.ActivityCompat;
  19. import androidx.core.content.ContextCompat;
  20. import android.util.Log;
  21. import android.view.Gravity;
  22. import android.view.KeyEvent;
  23. import android.view.MotionEvent;
  24. import android.view.SurfaceHolder;
  25. import android.view.SurfaceView;
  26. import android.view.View;
  27. import android.view.animation.AccelerateInterpolator;
  28. import android.view.animation.Animation;
  29. import android.view.animation.TranslateAnimation;
  30. import android.widget.Button;
  31. import android.widget.ExpandableListView;
  32. import android.widget.ImageView;
  33. import android.widget.RelativeLayout;
  34. import com.artncore.WallPadDataMgr.WallpadDeviceSet;
  35. import com.artncore.WallPadDataMgr.WallpadStatusData;
  36. import com.artncore.WallPadDataMgr.wallpaddbmgr;
  37. import com.artncore.commons.API_Menu;
  38. import com.artncore.commons.API_Menu.MenuListDataClass;
  39. import com.artncore.commons.define;
  40. import com.artncore.wallpadapi.Sdb_LivingRoomLightAPI;
  41. import com.artncore.wallpadapi.WallPadAPI;
  42. import com.techwin.neighbor.ipolis.PlayerSurfaceView;
  43. import com.util.LogUtil;
  44. import java.io.IOException;
  45. import java.text.SimpleDateFormat;
  46. import java.util.ArrayList;
  47. import java.util.Date;
  48. import kr.co.icontrols.v40ioctl.V40IF;
  49. import kr.co.icontrols.wallpadaddservice.declare.Common;
  50. import kr.co.icontrols.wallpadaddservice.declare.ID;
  51. import kr.co.icontrols.wallpadaddservice.screen.AutoPictureMainScreen;
  52. import kr.co.icontrols.wallpadaddservice.screen.AutoPictureSubShowScreen;
  53. import kr.co.icontrols.wallpadaddservice.screen.BandLocationListScreen;
  54. import kr.co.icontrols.wallpadaddservice.screen.BandLocationMainScreen;
  55. import kr.co.icontrols.wallpadaddservice.screen.CarGuestInfoScreen;
  56. import kr.co.icontrols.wallpadaddservice.screen.CarInfoMainScreen;
  57. import kr.co.icontrols.wallpadaddservice.screen.CarParkingAccessList;
  58. import kr.co.icontrols.wallpadaddservice.screen.CctvMainScreen;
  59. import kr.co.icontrols.wallpadaddservice.screen.ConfigNoiseLogMainScreen;
  60. import kr.co.icontrols.wallpadaddservice.screen.CostScreen;
  61. import kr.co.icontrols.wallpadaddservice.screen.ElecCarMainScreen;
  62. import kr.co.icontrols.wallpadaddservice.screen.LocalInfoScreen;
  63. import kr.co.icontrols.wallpadaddservice.screen.MemoMainScreen;
  64. import kr.co.icontrols.wallpadaddservice.screen.MemoMakeAudio;
  65. import kr.co.icontrols.wallpadaddservice.screen.MemoMakeDrawing;
  66. import kr.co.icontrols.wallpadaddservice.screen.MemoMakeVideo;
  67. import kr.co.icontrols.wallpadaddservice.screen.NoticeContentsScreen;
  68. import kr.co.icontrols.wallpadaddservice.screen.NoticeMainScreen;
  69. import kr.co.icontrols.wallpadaddservice.screen.RepairScreen;
  70. import kr.co.icontrols.wallpadaddservice.screen.SafeStreetLightMainScreen;
  71. import kr.co.icontrols.wallpadaddservice.screen.ScheduleMainScreen;
  72. import kr.co.icontrols.wallpadaddservice.screen.UCityScreen;
  73. import kr.co.icontrols.wallpadaddservice.screen.VoteScreen;
  74. import kr.co.icontrols.wallpadaddservice.screen.WeatherMainScreen;
  75. import kr.co.icontrols.wallpadaddservice.subwallpadscreen.WeatherScreen_SubWallPad;
  76. import kr.co.icontrols.wallpadsupport.Version;
  77. import kr.co.icontrols.wallpadsupport.WpadActivity;
  78. import kr.co.icontrols.wallpadsupport.WpadImageView;
  79. import kr.co.icontrols.wallpadsupport.WpadImageView.TOUCH_KIND;
  80. import kr.co.icontrols.wallpadsupport.WpadRelativeLayoutParams;
  81. import kr.co.icontrols.wallpadsupport.WpadScale;
  82. import kr.co.icontrols.wallpadsupport.WpadSound;
  83. import kr.co.icontrols.wallpadsupport.WpadSound.SND;
  84. import kr.co.icontrols.wallpadsupport.WpadTextView;
  85. import kr.co.icontrols.wallpadsupport.WpadUtil;
  86. public class MainActivity extends WpadActivity {
  87. private final static String TAG = "MainActivity";
  88. private final boolean DEBUG_LOG_ON = true;
  89. private void DebugLogOutput(String s) {
  90. if (DEBUG_LOG_ON) Log.d(TAG, s);
  91. }
  92. // =================================================================================================
  93. // [ Declaration ] region
  94. // =================================================================================================
  95. protected Context mContext = null;
  96. public Context getContext() {
  97. return mContext;
  98. }
  99. public static V40IF mV40IF = null;
  100. public static WpadSound mSound;
  101. private WallPadAPI wpapi = null;
  102. Sdb_LivingRoomLightAPI sdbLivingRoomLightAPI;
  103. private int OPERATION_MODE = Common.MODE;
  104. private WallpadStatusData wdb = null;
  105. // Layout
  106. private RelativeLayout AllLayout;
  107. private RelativeLayout TopLayout;
  108. private RelativeLayout MenuLayout;
  109. private RelativeLayout ScreenLayout;
  110. WpadImageView ScreenBackground;
  111. // Top
  112. private WpadImageView TopBackground;
  113. WpadTextView TopTitle;
  114. WpadImageView TopHomeBtn, TopBackBtn, TopMenuBtn, TopManualBtn;
  115. // Menu
  116. private WpadImageView MenuBackground;
  117. private WpadImageView MenuClose;
  118. private WpadTextView MenuTitle;
  119. private static ExpandableListView mListView;
  120. private Menu_AdptMain adptMain;
  121. private MenuListDataClass menuListDataClass;
  122. private Menu mMenu = null;
  123. private boolean MenuOpen = false;
  124. // PopupActivityRun
  125. private static boolean PopupActivityRun = false;
  126. public static boolean getPopupActivityRun() {
  127. return PopupActivityRun;
  128. }
  129. public static void setPopupActivityRun(boolean run) {
  130. PopupActivityRun = run;
  131. }
  132. // CurrentScreenId
  133. private int mCurrentScreenId = -1;
  134. private int mTempCurrentScreenId = -1;
  135. private static int mCurrentManualScreenId = -1;
  136. private static final int REQUEST_EXTERNAL_STORAGE = 100;
  137. private static final int REQUEST_ACCESS_COARSE_LOCATION = 101;
  138. public int nCardNum = 0; // 밴드위치인식 카드번호
  139. // Screen
  140. private NoticeMainScreen noticeMainScreen = null; // 공지사항
  141. private NoticeContentsScreen noticeContentsScreen = null;
  142. private WeatherMainScreen weatherMainScreen = null; // 날씨
  143. private WeatherScreen_SubWallPad weatherSubScreen = null; // 서브월패드 날씨
  144. private MemoMainScreen memoMainScreen = null; // 메모
  145. private MemoMakeDrawing memoMainDrawingScreen = null;
  146. private MemoMakeAudio memoMainAudioScreen = null;
  147. private MemoMakeVideo memoMainVideoScreen = null;
  148. private AutoPictureMainScreen autoPictureMainScreen = null; // 전자액자
  149. private AutoPictureSubShowScreen autoPictureSubShowScreen = null;
  150. private ScheduleMainScreen scheduleMainScreen = null; // 일정표
  151. private CctvMainScreen cctvMainScreen = null; // CCTV
  152. private CarInfoMainScreen carInfoMainScreen = null; // 주차확인
  153. private CarParkingAccessList carParkingAccessListScreen = null;
  154. private ElecCarMainScreen elecCarMainScreen = null; // 전기차충전
  155. private ConfigNoiseLogMainScreen configNoiseLogMainScreen = null;
  156. private CarGuestInfoScreen carGuestInfoScreen = null; // 방문객 차량등록
  157. private BandLocationMainScreen bandLocationMainScreen = null; // 위치확인 (단지지도)
  158. private BandLocationListScreen bandLocationListScreen = null; // 위치확인 (내역)
  159. private SafeStreetLightMainScreen safeStreetLightMainScreen = null; // 안전가로등
  160. private RepairScreen repairScreen = null; // 보수신청
  161. private VoteScreen voteScreen = null; // 주민투표
  162. private LocalInfoScreen localInfoScreen = null; // 지역정보
  163. private CostScreen costScreen = null; // 관리비조회
  164. private UCityScreen uCityScreen = null; // u-city
  165. /* ================================================================================================
  166. * [ Activity Life Cycle ] region
  167. ================================================================================================ */
  168. @Override
  169. protected void onCreate(Bundle savedInstanceState) {
  170. Log.i(TAG, "[START - MainActivity]");
  171. super.onCreate(savedInstanceState);
  172. // @ AutoScale 설정
  173. WpadScale.setAutoScale(true);
  174. super.AppVersionLogOut();
  175. // 1. 변수 초기화
  176. DebugLogOutput("[Create] - Step1 : Data Create");
  177. PopupActivityRun = false;
  178. ManualActivityRun = false;
  179. mContext = this;
  180. mSound = new WpadSound(this);
  181. mV40IF = new V40IF();
  182. // 2. 자동 종료 셋팅
  183. DebugLogOutput("[Create] - Step2 : Auto Finish Setting");
  184. if (Common.FINISH_TIME_ENABLE) super.setFinishTimerCreate(Common.FINISH_TIME_SEC);
  185. // 3. API 호출
  186. DebugLogOutput("[Create] - Step3 : API Call");
  187. if (OPERATION_MODE == Common.MODE_NORMAL) {
  188. Log.d(TAG, "OperationMode = MODE_NORMAL");
  189. try {
  190. wpapi = new WallPadAPI(this);
  191. } catch (RuntimeException re) {
  192. LogUtil.errorLogInfo("", TAG, re);
  193. } catch (Exception e) {
  194. Log.e(TAG, "[Exception] - new WallPadAPI : " + e);
  195. }
  196. } else if (OPERATION_MODE == Common.MODE_BUSINESS_SAMPLE) {
  197. Log.d(TAG, "OperationMode = MODE_BUSINESS_SAMPLE");
  198. }
  199. try {
  200. wdb = new WallpadStatusData(this);
  201. } catch (RuntimeException re) {
  202. LogUtil.errorLogInfo("", TAG, re);
  203. } catch (Exception e) {
  204. Log.e(TAG, "[ExceptionError] - onCreate->WallpadStatusData Create : " + e);
  205. }
  206. // 4. Layout registration
  207. DebugLogOutput("[Create] - Step4 : Layout registration");
  208. // 4-1. mainLayout
  209. AllLayout = new RelativeLayout(this);
  210. RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(WpadScale.getWidthPixels(), WpadScale.getHeightPixels());
  211. AllLayout.setLayoutParams(params);
  212. AllLayout.setId(ID.main.layout.ALL);
  213. super.setAllLayoutRegistration(AllLayout);
  214. // 4-2. TopLayout
  215. TopLayout = new RelativeLayout(this);
  216. WpadUtil.LayoutRegistration(AllLayout, TopLayout, 1280, 110, 0, 0, ID.main.layout.TOP);
  217. // 4-4. ScreenLayout
  218. ScreenLayout = new RelativeLayout(this);
  219. WpadUtil.LayoutRegistration(AllLayout, ScreenLayout, 1280, 690, 0, 110, ID.main.layout.SCREEN);
  220. ScreenBackground = new WpadImageView(this, TOUCH_KIND.NONE, 1280, 690, R.drawable.bg_body, R.drawable.bg_body, ID.main.image.BACKGROUND);
  221. ViewRegistration(ScreenLayout, ScreenBackground, 0, 0);
  222. // 5. Top Menu - ImageView registration
  223. DebugLogOutput("[Create] - Step5 : Top Menu - ImageView registration");
  224. TopBackground = new WpadImageView(this, TOUCH_KIND.NONE, 1280, 110, R.drawable.bg_topbar, 0, ID.top.image.BACKGROUND);
  225. ViewRegistration(TopLayout, TopBackground, 0, 0);
  226. TopTitle = new WpadTextView(this, false, 247 + 50, 80, Gravity.LEFT, Color.WHITE, Common.fontsize._44, true, ID.top.text.TITLE);
  227. ViewRegistration(TopLayout, TopTitle, 133, 15);
  228. 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);
  229. ViewRegistration(TopLayout, TopHomeBtn, 1145, 0);
  230. 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);
  231. ViewRegistration(TopLayout, TopBackBtn, 1019, 0);
  232. setTopBackBtnVisible(false);
  233. 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);
  234. ViewRegistration(TopLayout, TopMenuBtn, 0, 0);
  235. 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);
  236. setManualBtnVisible(getManualUse(), 1019);
  237. WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(mContext);
  238. int noiseUse = wallpadDeviceSet.Get_NoiseSensor_Use();
  239. int cctvUse = wallpadDeviceSet.GetDeviceSetted("CCTV");
  240. int parkingUse = wallpadDeviceSet.GetDeviceSetted("주차확인");
  241. int carGuestUse = wallpadDeviceSet.GetDeviceSetted("방문객차량등록");
  242. int bandLocUse = wallpadDeviceSet.GetDeviceSetted("밴드위치확인");
  243. int elecCarUse = wallpadDeviceSet.GetDeviceSetted("전기차충전");
  244. int safeStreetLightUse = wallpadDeviceSet.GetDeviceSetted("안전가로등");
  245. boolean bNonInternetUse = wallpadDeviceSet.Get_NonInternetSupportUse();
  246. wallpadDeviceSet.closeDB();
  247. Log.d(TAG, "[onCreate] noiseUse [" + noiseUse + "], cctvUse [" + cctvUse + "], parkingUse [" + parkingUse + "], carGuestUse [" + carGuestUse + "], " +
  248. "bandLocUse [" + bandLocUse + "], elecCarUse [" + elecCarUse + "], bNonInternetUse [" + bNonInternetUse + "], safeStreetLightUse [" + safeStreetLightUse + "]");
  249. // 6. Menu Loading
  250. DebugLogOutput("[Create] - Step6 : Menu Loading");
  251. wallpaddbmgr WallpadDBMGR = new wallpaddbmgr(getApplicationContext());
  252. WallpadDBMGR.DeleteMenuList();
  253. ArrayList<ArrayList<Integer>> mGroupList = new ArrayList<ArrayList<Integer>>();
  254. ArrayList<Integer> mChildList = new ArrayList<Integer>();
  255. if (bNonInternetUse) {
  256. // 인터넷 미지원
  257. mChildList.add(API_Menu.SubMenuAddService.Notice);
  258. mChildList.add(API_Menu.SubMenuAddService.Memo);
  259. } else {
  260. // 인터넷 지원
  261. mChildList.add(API_Menu.SubMenuAddService.Notice);
  262. mChildList.add(API_Menu.SubMenuAddService.Weather);
  263. mChildList.add(API_Menu.SubMenuAddService.Memo);
  264. mChildList.add(API_Menu.SubMenuAddService.AutoPicture);
  265. mChildList.add(API_Menu.SubMenuAddService.Schedule);
  266. if (cctvUse == WallpadDeviceSet.DEV_DATA_ENABLE || cctvUse == WallpadDeviceSet.DEV_DATA_NONE) {
  267. mChildList.add(API_Menu.SubMenuAddService.Cctv);
  268. }
  269. if (parkingUse == WallpadDeviceSet.DEV_DATA_ENABLE || parkingUse == WallpadDeviceSet.DEV_DATA_NONE) {
  270. mChildList.add(API_Menu.SubMenuAddService.Parking);
  271. }
  272. mChildList.add(API_Menu.SubMenuAddService.ParkingList);
  273. if (noiseUse == 1) {
  274. mChildList.add(API_Menu.SubMenuAddService.InterlayerNoiseHistory);
  275. }
  276. if (carGuestUse == WallpadDeviceSet.DEV_DATA_ENABLE) {
  277. Log.d(TAG, "[onCreate] ====== 방문객차량등록 ======");
  278. mChildList.add(API_Menu.SubMenuAddService.CarGuest);
  279. }
  280. if (bandLocUse == WallpadDeviceSet.DEV_DATA_ENABLE) {
  281. Log.d(TAG, "[onCreate] ====== 밴드위치확인 ======");
  282. mChildList.add(API_Menu.SubMenuAddService.BandLocation);
  283. }
  284. if (elecCarUse == WallpadDeviceSet.DEV_DATA_ENABLE) {
  285. mChildList.add(API_Menu.SubMenuAddService.ElecCar);
  286. }
  287. if (safeStreetLightUse == WallpadDeviceSet.DEV_DATA_ENABLE) {
  288. Log.d(TAG, "[onCreate] ====== 안전가로등 ======");
  289. mChildList.add(API_Menu.SubMenuAddService.SafeStreetLight);
  290. }
  291. }
  292. // mChildList.add(API_Menu.SubMenuAddService.Repair);
  293. // mChildList.add(API_Menu.SubMenuAddService.Vote);
  294. // mChildList.add(API_Menu.SubMenuAddService.LocalInfo);
  295. // mChildList.add(API_Menu.SubMenuAddService.Cost);
  296. // mChildList.add(API_Menu.SubMenuAddService.UCity);
  297. mGroupList.add(mChildList);
  298. WallpadDBMGR.SetMenuList(mGroupList);
  299. menuListDataClass = WallpadDBMGR.GetMenuList();
  300. WallpadDBMGR.closeDB();
  301. if (menuListDataClass == null) {
  302. Log.w(TAG, "[onCreate] menuListDataClass == null");
  303. menuListDataClass = LoadDefaultMenuList();
  304. }
  305. // 6-1. 메뉴 정보 가져옴 (메인화면에서 전달한 Intent 에서 가져온다.)
  306. mMenu = new Menu();
  307. mMenu = super.getIntentParsingMenu(getIntent());
  308. if (mMenu == null) {
  309. Log.w(TAG, "[onCreate] mMenu == null");
  310. DefaultMenuListSetting();
  311. }
  312. // 6-2. 메뉴 표시
  313. mTempCurrentScreenId = mMenu.getStartId();
  314. if (mTempCurrentScreenId == API_Menu.SubMenuAddService.Memo) {
  315. int nModelType = Version.getModelType();
  316. if (nModelType == Version.MODEL_TYPE.IHN_D101 || nModelType == Version.MODEL_TYPE.IHN_D101_I
  317. || nModelType == Version.MODEL_TYPE.IHN_D101K || nModelType == Version.MODEL_TYPE.IHN_D101K_I
  318. || nModelType == Version.MODEL_TYPE.IHN_D101_I_OCF) {
  319. // IHN-D101 메모화면일 경우 스마트폰 조명제어 사용여부 설정 제어하기 위함 (거실에너지미터 BT-Wifi 모듈이 마이크에 무선 노이즈를 발생시키므로 - 영상/음성 메모)
  320. mWallPadApiCheckHandler.sendEmptyMessage(0);
  321. }
  322. else {
  323. setChangeScreen(mTempCurrentScreenId, false);
  324. }
  325. } else {
  326. if (mTempCurrentScreenId == API_Menu.SubMenuAddService.BandLocation) {
  327. Intent intent = getIntent();
  328. nCardNum = intent.getIntExtra("CARD_NUM", 0);
  329. Log.d(TAG, "[onCreate] nCardNum [" + nCardNum + "]");
  330. }
  331. setChangeScreen(mTempCurrentScreenId, false);
  332. }
  333. // 7. Draw
  334. DebugLogOutput("[Create] - Step7 : setContentView");
  335. setContentView(AllLayout);
  336. // 8. Window ReSize
  337. DebugLogOutput("[Create] - Step8 : Window ReSize");
  338. // 9. Check Permission
  339. DebugLogOutput("[Create] - Step9 : Permission Check");
  340. boolean hasPermission = (ContextCompat.checkSelfPermission(this,
  341. Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED);
  342. Log.d(TAG, "[onCreate] hasPermission: " + hasPermission);
  343. if (!hasPermission) {
  344. ActivityCompat.requestPermissions(this,
  345. new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
  346. REQUEST_EXTERNAL_STORAGE);
  347. }
  348. //퍼미션 추가
  349. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
  350. hasPermission = (ContextCompat.checkSelfPermission(this,
  351. Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED);
  352. Log.d(TAG, "[onCreate] hasPermission: " + hasPermission);
  353. if (!hasPermission) {
  354. ActivityCompat.requestPermissions(this,
  355. new String[]{Manifest.permission.ACCESS_COARSE_LOCATION},
  356. REQUEST_ACCESS_COARSE_LOCATION);
  357. }
  358. }
  359. reg_Receiver();
  360. // 폰트 TEST
  361. // Typeface fontType = Typeface.createFromAsset(this.getAssets(), "fonts/NotoSansCJKkr-Thin.otf");
  362. // Typeface fontType = Typeface.createFromAsset(this.getAssets(), "fonts/NanumGothicCoding.ttf");
  363. // TopTitle.setTypeface(fontType);
  364. }
  365. @Override
  366. protected void onResume() {
  367. DebugLogOutput("[onResume]");
  368. setAudioMemoPlayVol(false);
  369. super.onResume();
  370. if (wpapi != null) wpapi.Resume();
  371. }
  372. @Override
  373. protected void onPause() {
  374. DebugLogOutput("[onPause]");
  375. super.onPause();
  376. if (wpapi != null) wpapi.Pause();
  377. mediaStopRec();
  378. ReleaseSurface();
  379. }
  380. @Override
  381. protected void onDestroy() {
  382. DebugLogOutput("[onDestroy]");
  383. setChangeScreen(mCurrentScreenId, true);
  384. unregisterReceiver(mWallPadAlertBR);
  385. unregisterReceiver(mWallPadJogBR);
  386. mSound.Release();
  387. if (sdbLivingRoomLightAPI != null) {
  388. Log.d(TAG, "[onDestroy] sdbLivingRoomLightAPI.SetWifiModuleOnOff [TRUE]");
  389. sdbLivingRoomLightAPI.SetWifiModuleOnOff(true);
  390. }
  391. if (wdb != null) wdb.closeDB();
  392. if (mCameraOpenCheckHandler != null) {
  393. mCameraOpenCheckHandler.removeMessages(0);
  394. mCameraOpenCheckHandler.removeMessages(1);
  395. }
  396. if (mWallPadApiCheckHandler != null) {
  397. mWallPadApiCheckHandler.removeMessages(0);
  398. mWallPadApiCheckHandler.removeMessages(1);
  399. }
  400. super.setFinishTimerDestroy();
  401. super.onDestroy();
  402. }
  403. @Override
  404. protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  405. Log.d(TAG, "[onActivityResult]");
  406. super.onActivityResult(requestCode, resultCode, data);
  407. if (resultCode == RESULT_OK) {
  408. int screenId = data.getIntExtra("ChangeScreen", 0);
  409. Log.d(TAG, "ChangeScreen : " + screenId);
  410. setChangeScreen(screenId, false);
  411. }
  412. }
  413. @Override
  414. public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
  415. Log.d(TAG, "[onRequestPermissionsResult] requestCode: " + requestCode);
  416. super.onRequestPermissionsResult(requestCode, permissions, grantResults);
  417. switch (requestCode) {
  418. case REQUEST_EXTERNAL_STORAGE: {
  419. if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
  420. Log.d(TAG, "[onRequestPermissionsResult] PERMISSION_GRANTED");
  421. } else {
  422. Log.d(TAG, "[onRequestPermissionsResult] PERMISSION_NOT_GRANTED");
  423. }
  424. return;
  425. }
  426. case REQUEST_ACCESS_COARSE_LOCATION: {
  427. if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
  428. Log.d(TAG, "[onRequestPermissionsResult] PERMISSION_GRANTED");
  429. } else {
  430. Log.d(TAG, "[onRequestPermissionsResult] PERMISSION_NOT_GRANTED");
  431. }
  432. return;
  433. }
  434. }
  435. }
  436. @SuppressLint("HandlerLeak")
  437. protected Handler mWallPadApiCheckHandler = new Handler() {
  438. @SuppressLint("HandlerLeak")
  439. @Override
  440. public void handleMessage(Message msg) {
  441. if (msg.what == 0) {
  442. if (wpapi != null) {
  443. if (wpapi.Check_Connect())
  444. mWallPadApiCheckHandler.sendEmptyMessageDelayed(1, 10);
  445. else mWallPadApiCheckHandler.sendEmptyMessageDelayed(0, 10);
  446. }
  447. } else if (msg.what == 1) {
  448. Log.d(TAG, "[mWallPadApiCheckHandler] Finish!! sdbLivingRoomLightAPI is connected!!");
  449. setChangeScreen(mTempCurrentScreenId, false);
  450. sdbLivingRoomLightAPI = wpapi.Get_Sdb_LivingRoomLightAPI();
  451. }
  452. }
  453. };
  454. /* ================================================================================================
  455. * [BroadcastReceiver] Section
  456. ================================================================================================ */
  457. @Override
  458. protected void onBrReceive(Intent intent) {
  459. super.onBrReceive(intent);
  460. DebugLogOutput("[onBrReceive] Receive alert BR " + intent.getAction());
  461. }
  462. /* ================================================================================================
  463. * [Touch & Key Event] Section
  464. ================================================================================================ */
  465. @Override
  466. protected void onTouchEvent(View v, MotionEvent event) {
  467. super.onTouchEvent(v, event);
  468. int TargetId = v.getId();
  469. int MoveEvent = event.getAction();
  470. if (MoveEvent == MotionEvent.ACTION_UP) {
  471. if (TargetId == ID.top.button.HOME) {
  472. DebugLogOutput("onTouchEvent [HOME] BUTTON !!!");
  473. Sound().Play(SND.effect.TOUCH_LATCHED);
  474. Intent intent = new Intent();
  475. intent.putExtra("Finish_Kind", "HomeButton");
  476. setResult(RESULT_OK, intent);
  477. finish();
  478. } else if (TargetId == ID.top.button.BACK) {
  479. DebugLogOutput("onTouchEvent [BACK] BUTTON !!!");
  480. mSound.Play(SND.effect.TOUCH_LATCHED);
  481. if (mCurrentScreenId == ID.screen.MemoMakeDrawing || mCurrentScreenId == ID.screen.MemoMakeAudio || mCurrentScreenId == ID.screen.MemoMakeVideo) {
  482. setChangeScreen(API_Menu.SubMenuAddService.Memo, false);
  483. } else if (mCurrentScreenId == ID.screen.AutoPictureShowScreen) {
  484. setChangeScreen(API_Menu.SubMenuAddService.AutoPicture, false);
  485. } else if (mCurrentScreenId == ID.screen.NoticeContentsScreen) {
  486. setChangeScreen(API_Menu.SubMenuAddService.Notice, false);
  487. } else if (mCurrentScreenId == ID.screen.BandLocationListScreen) {
  488. setChangeScreen(API_Menu.SubMenuAddService.BandLocation, false);
  489. }
  490. } else if (TargetId == ID.top.button.MENU) {
  491. DebugLogOutput("onTouchEvent [MENU] BUTTON !!!");
  492. if (MenuOpen) {
  493. return;
  494. }
  495. mSound.Play(SND.effect.TOUCH_LATCHED);
  496. OpenMenuLayout();
  497. } else if (TargetId == ID.menu.button.CLOSE) {
  498. DebugLogOutput("onTouchEvent [CLOSE] BUTTON");
  499. if (MenuOpen) {
  500. mSound.Play(SND.effect.TOUCH_LATCHED);
  501. CloseMenuLayout();
  502. }
  503. } else if (TargetId == ID.top.button.MANUAL) {
  504. DebugLogOutput("onTouchEvent [MANUAL] BUTTON mCurrentScreenId [" + mCurrentScreenId + "]");
  505. mSound.Play(SND.effect.TOUCH_LATCHED);
  506. if (mCurrentScreenId == API_Menu.SubMenuAddService.Notice) {
  507. StartManual(ID.screen.ManualNoticeMainScreen);
  508. } else if (mCurrentScreenId == ID.screen.NoticeContentsScreen) {
  509. StartManual(ID.screen.ManualNoticeSubScreen);
  510. } else if (mCurrentScreenId == API_Menu.SubMenuAddService.Weather) {
  511. StartManual(ID.screen.ManualWeatherMainScreen);
  512. } else if (mCurrentScreenId == API_Menu.SubMenuAddService.Memo) {
  513. StartManual(ID.screen.ManualMemoMainScreen);
  514. } else if (mCurrentScreenId == ID.screen.MemoMakeDrawing) {
  515. StartManual(ID.screen.ManualDrawingMemoScreen);
  516. } else if (mCurrentScreenId == ID.screen.MemoMakeAudio) {
  517. StartManual(ID.screen.ManualAudioMemoScreen);
  518. } else if (mCurrentScreenId == ID.screen.MemoMakeVideo) {
  519. StartManual(ID.screen.ManualVideoMemoScreen);
  520. } else if (mCurrentScreenId == API_Menu.SubMenuAddService.AutoPicture) {
  521. StartManual(ID.screen.ManualAutoPictureMainScreen);
  522. } else if (mCurrentScreenId == ID.screen.AutoPictureShowScreen) {
  523. StartManual(ID.screen.ManualAutoPictureShowScreen);
  524. } else if (mCurrentScreenId == API_Menu.SubMenuAddService.Schedule) {
  525. StartManual(ID.screen.ManualScheduleMainScreen);
  526. } else if (mCurrentScreenId == API_Menu.SubMenuAddService.Cctv) {
  527. StartManual(ID.screen.ManualCCTVMainScreen);
  528. } else if (mCurrentScreenId == API_Menu.SubMenuAddService.ElecCar) {
  529. StartManual(ID.screen.ManualElecCarMainScreen);
  530. } else if (mCurrentScreenId == API_Menu.SubMenuAddService.Parking) {
  531. StartManual(ID.screen.ManualCarInfoMainScreen);
  532. } else if (mCurrentScreenId == API_Menu.SubMenuAddService.ParkingList) {
  533. StartManual(ID.screen.ManualCarInfoListScreen);
  534. } else if (mCurrentScreenId == API_Menu.SubMenuAddService.CarGuest) {
  535. StartManual(ID.screen.ManualCarGuestInfoScreen);
  536. } else if (mCurrentScreenId == API_Menu.SubMenuAddService.BandLocation) {
  537. StartManual(ID.screen.ManualBandLocationMainScreen);
  538. } else if (mCurrentScreenId == ID.screen.BandLocationListScreen) {
  539. StartManual(ID.screen.ManualBandLocationListScreen);
  540. } else if (mCurrentScreenId == ID.screen.SafeStreetLightMainScreen) {
  541. StartManual(ID.screen.ManualSafeStreetLightScreen);
  542. }
  543. }
  544. }
  545. }
  546. private static final int BTN_CALL_IHN1010 = 264;
  547. // H/W Key Event
  548. @Override
  549. public boolean onKeyDown(int keyCode, KeyEvent event) {
  550. Log.i(TAG, "[onKeyDown] keyCode : " + keyCode + ", Action : " + event.getAction());
  551. return super.onKeyDown(keyCode, event);
  552. }
  553. /* ================================================================================================
  554. * [TOP - Back] Section
  555. ================================================================================================ */
  556. public boolean setTopBackBtnVisible(boolean Enabled) {
  557. if (Enabled) {
  558. if (TopBackBtn.getVisibility() != View.VISIBLE) TopBackBtn.setVisibility(View.VISIBLE);
  559. TopBackBtn.bringToFront();
  560. } else {
  561. if (TopBackBtn.getVisibility() != View.INVISIBLE)
  562. TopBackBtn.setVisibility(View.INVISIBLE);
  563. }
  564. return true;
  565. }
  566. public boolean setTopMenuBtnVisible(boolean Enabled) {
  567. if (Enabled) {
  568. if (TopMenuBtn.getVisibility() != View.VISIBLE) TopMenuBtn.setVisibility(View.VISIBLE);
  569. TopMenuBtn.bringToFront();
  570. } else {
  571. if (TopMenuBtn.getVisibility() != View.INVISIBLE)
  572. TopMenuBtn.setVisibility(View.INVISIBLE);
  573. }
  574. return true;
  575. }
  576. public void setTopTitleText(String strText) {
  577. try {
  578. if (TopTitle != null)
  579. TopTitle.setText(strText);
  580. } catch (RuntimeException re) {
  581. LogUtil.errorLogInfo("", TAG, re);
  582. } catch (Exception e) {
  583. Log.e(TAG, "[Exception] setTopTitleText(String strText)");
  584. //e.printStackTrace();
  585. LogUtil.errorLogInfo("", TAG, e);
  586. }
  587. }
  588. public void setTopHomeBtnStatus(boolean bEnable) {
  589. try {
  590. if (TopHomeBtn != null) {
  591. // Log.d(TAG, "[setTopHomeBtnStatus] bEnable [" + bEnable + "]");
  592. if (!bEnable)
  593. TopHomeBtn.setButtonEventOffEnable(R.drawable.topbar_icon_home_disabled);
  594. else TopHomeBtn.setButtonEventOffDisable();
  595. }
  596. } catch (RuntimeException re) {
  597. LogUtil.errorLogInfo("", TAG, re);
  598. } catch (Exception e) {
  599. Log.e(TAG, "[Exception] setTopHomeBtnStatus(boolean bEnable)");
  600. //e.printStackTrace();
  601. LogUtil.errorLogInfo("", TAG, e);
  602. }
  603. }
  604. public void setTopBackBtnStatus(boolean bEnable) {
  605. try {
  606. if (TopBackBtn != null) {
  607. // Log.d(TAG, "[setTopBackBtnStatus] bEnable [" + bEnable + "]");
  608. if (!bEnable)
  609. TopBackBtn.setButtonEventOffEnable(R.drawable.topbar_icon_back_disabled);
  610. else TopBackBtn.setButtonEventOffDisable();
  611. }
  612. } catch (RuntimeException re) {
  613. LogUtil.errorLogInfo("", TAG, re);
  614. } catch (Exception e) {
  615. Log.e(TAG, "[Exception] setTopBackBtnStatus(boolean bEnable)");
  616. //e.printStackTrace();
  617. LogUtil.errorLogInfo("", TAG, e);
  618. }
  619. }
  620. public void setTopMenuBtnStatus(boolean bEnable) {
  621. try {
  622. if (TopMenuBtn != null) {
  623. if (!bEnable)
  624. TopMenuBtn.setButtonEventOffEnable(R.drawable.topbar_icon_menu_disabled);
  625. else TopMenuBtn.setButtonEventOffDisable();
  626. }
  627. } catch (RuntimeException re) {
  628. LogUtil.errorLogInfo("", TAG, re);
  629. } catch (Exception e) {
  630. Log.e(TAG, "[Exception] setTopMenuBtnStatus(boolean bEnable)");
  631. //e.printStackTrace();
  632. LogUtil.errorLogInfo("", TAG, e);
  633. }
  634. }
  635. public void setTopManualBtnStatus(boolean bEnable) {
  636. try {
  637. if (TopManualBtn != null) {
  638. if (!bEnable)
  639. TopManualBtn.setButtonEventOffEnable(R.drawable.topbar_icon_manual_disabled);
  640. else TopManualBtn.setButtonEventOffDisable();
  641. }
  642. } catch (RuntimeException re) {
  643. LogUtil.errorLogInfo("", TAG, re);
  644. } catch (Exception e) {
  645. Log.e(TAG, "[Exception] setTopManualBtnStatus(boolean bEnable)");
  646. //e.printStackTrace();
  647. LogUtil.errorLogInfo("", TAG, e);
  648. }
  649. }
  650. /* ================================================================================================
  651. * [Popup Activity] Section
  652. ================================================================================================ */
  653. public boolean StartPopup(int ScreenId) {
  654. if (getPopupActivityRun()) {
  655. return ((WpadActivity) (PopupActivity.getContext())).ChangeScreen(ScreenId);
  656. } else {
  657. setPopupActivityRun(true);
  658. Intent intent = new Intent(mContext, PopupActivity.class);
  659. intent.putExtra("ScreenId", ScreenId);
  660. overridePendingTransition(0, 0);
  661. startActivityForResult(intent, 0);
  662. return true;
  663. }
  664. }
  665. public boolean StartPopup(int ScreenId, Intent data) {
  666. if (getPopupActivityRun()) {
  667. return false;
  668. } else {
  669. setPopupActivityRun(true);
  670. Intent intent = new Intent(mContext, PopupActivity.class);
  671. intent.putExtra("ScreenId", ScreenId);
  672. intent.putExtra("PopupScreenDataIntent", data);
  673. overridePendingTransition(0, 0);
  674. startActivityForResult(intent, 0);
  675. return true;
  676. }
  677. }
  678. /* ================================================================================================
  679. * [Manual Activity] Section
  680. ================================================================================================ */
  681. public static ManualActivity mManualActivity;
  682. private static boolean ManualActivityRun = false;
  683. public static boolean getManualActivityRun() {
  684. Log.d(TAG, "[getManualActivityRun] ManualActivityRun: " + ManualActivityRun);
  685. return ManualActivityRun;
  686. }
  687. public static void setManualActivityRun(boolean run) {
  688. ManualActivityRun = run;
  689. if (!ManualActivityRun) resetCurrentManualScreenID();
  690. }
  691. public boolean StartManual(int screenId) {
  692. Log.d(TAG, "[StartManual] screenId [" + screenId + "], mCurrentManualScreenId [" + mCurrentManualScreenId + "]");
  693. if (getManualActivityRun()) {
  694. mCurrentManualScreenId = screenId;
  695. return ((WpadActivity) (ManualActivity.getContext())).ChangeScreen(screenId);
  696. } else {
  697. if (mCurrentManualScreenId == screenId) return false;
  698. mCurrentManualScreenId = screenId;
  699. setManualActivityRun(true);
  700. Intent intent = new Intent(mContext, ManualActivity.class);
  701. intent.putExtra("ScreenId", screenId);
  702. overridePendingTransition(0, 0);
  703. startActivityForResult(intent, 0);
  704. return true;
  705. }
  706. }
  707. public boolean getManualUse() {
  708. WallpadDeviceSet devSet = new WallpadDeviceSet(mContext);
  709. String[] DBinfo = devSet.GetSettingData("매뉴얼");
  710. devSet.closeDB();
  711. if (DBinfo != null) {
  712. if (DBinfo[1].indexOf("사용함") > 0) {
  713. Log.d(TAG, "[getManualUse] Use Manual");
  714. return true;
  715. } else {
  716. // 미사용
  717. Log.d(TAG, "[getManualUse] Not Use Manual [1]");
  718. return false;
  719. }
  720. } else {
  721. // 미사용
  722. Log.d(TAG, "[getManualUse] Not Use Manual [2]");
  723. return false;
  724. }
  725. }
  726. public void setManualBtnVisible(boolean bEnable, int marginLeft) {
  727. try {
  728. Log.d(TAG, "[setManualBtnVisible] bEnable [" + bEnable + "], marginLeft [" + marginLeft + "]");
  729. if (bEnable) TopManualBtn.setVisibility(View.VISIBLE);
  730. else TopManualBtn.setVisibility(View.INVISIBLE);
  731. TopLayout.removeView(TopManualBtn);
  732. ViewRegistration(TopLayout, TopManualBtn, marginLeft, 0);
  733. } catch (RuntimeException re) {
  734. LogUtil.errorLogInfo("", TAG, re);
  735. } catch (Exception e) {
  736. Log.e(TAG, "[Exception] setManualBtnVisible(boolean bEnable)");
  737. //e.printStackTrace();
  738. LogUtil.errorLogInfo("", TAG, e);
  739. }
  740. }
  741. public static void resetCurrentManualScreenID() {
  742. try {
  743. mCurrentManualScreenId = -1;
  744. } catch (RuntimeException re) {
  745. LogUtil.errorLogInfo("", TAG, re);
  746. } catch (Exception e) {
  747. Log.e(TAG, "[Exception] resetCurrentManualScreenID()");
  748. //e.printStackTrace();
  749. LogUtil.errorLogInfo("", TAG, e);
  750. }
  751. }
  752. public void finishManual(int screenId) {
  753. try {
  754. Log.d(TAG, "[finishManual] mCurrentManualScreenId [" + mCurrentManualScreenId +"], screenId [" + screenId +"]");
  755. if (screenId == ID.screen.Manual_All) FinishManualActivity();
  756. else {
  757. if (mCurrentManualScreenId != screenId) return;
  758. FinishManualActivity();
  759. }
  760. } catch (RuntimeException re) {
  761. LogUtil.errorLogInfo("", TAG, re);
  762. } catch (Exception e) {
  763. Log.e(TAG, "[Exception] finishManual(int screenId)");
  764. //e.printStackTrace();
  765. LogUtil.errorLogInfo("", TAG, e);
  766. }
  767. }
  768. public static void FinishManualActivity() {
  769. Log.i(TAG, "[FinishManualActivity]");
  770. try {
  771. if (mManualActivity != null) {
  772. mCurrentManualScreenId = -1;
  773. mManualActivity.finish();
  774. }
  775. } catch (RuntimeException re) {
  776. LogUtil.errorLogInfo("", TAG, re);
  777. } catch (Exception e) {
  778. Log.e(TAG, "[Exception] FinishManualActivity()");
  779. //e.printStackTrace();
  780. LogUtil.errorLogInfo("", TAG, e);
  781. }
  782. }
  783. /* ================================================================================================
  784. * [Screen] Section
  785. ================================================================================================ */
  786. @Override
  787. protected boolean onChangeScreen(int nScreenId) {
  788. super.onChangeScreen(nScreenId);
  789. return setChangeScreen(nScreenId, false);
  790. }
  791. private boolean setChangeScreen(int nScreenId, boolean OnlyRemove) {
  792. DebugLogOutput("setChangeScreen - " + "CurrentSelectDeviceId : " + mCurrentScreenId
  793. + " / NextLayoutId : " + nScreenId + " / OnlyRemove : " + OnlyRemove);
  794. if (mCurrentScreenId > 0) {
  795. ScreenLayout.removeAllViews();
  796. super.setCurrentScreen(null);
  797. }
  798. if (OnlyRemove) return true;
  799. mCurrentScreenId = nScreenId;
  800. try {
  801. switch (nScreenId) {
  802. // Default Menu
  803. case API_Menu.SubMenuAddService.Notice: // 공지사항
  804. setTitleText(API_Menu.SubMenuAddService.Name_Notice);
  805. noticeMainScreen = new NoticeMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE);
  806. super.setCurrentScreen(noticeMainScreen);
  807. break;
  808. case ID.screen.NoticeContentsScreen: // sub - 공지사항 내용
  809. noticeContentsScreen = new NoticeContentsScreen(this, ScreenLayout, wpapi, OPERATION_MODE);
  810. super.setCurrentScreen(noticeContentsScreen);
  811. break;
  812. case API_Menu.SubMenuAddService.Weather: // 날씨
  813. setTitleText(API_Menu.SubMenuAddService.Name_Weather);
  814. if (!getAsSubWallPad()) {
  815. // 메인월패드
  816. weatherMainScreen = new WeatherMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE);
  817. super.setCurrentScreen(weatherMainScreen);
  818. } else {
  819. // 서브월패드
  820. weatherSubScreen = new WeatherScreen_SubWallPad(this, ScreenLayout);
  821. super.setCurrentScreen(weatherSubScreen);
  822. }
  823. break;
  824. case API_Menu.SubMenuAddService.Memo: // 메모
  825. setTitleText(API_Menu.SubMenuAddService.Name_Memo);
  826. memoMainScreen = new MemoMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE);
  827. super.setCurrentScreen(memoMainScreen);
  828. break;
  829. case ID.screen.MemoMakeDrawing: // sub - 그림메모
  830. memoMainDrawingScreen = new MemoMakeDrawing(this, ScreenLayout, wpapi, OPERATION_MODE);
  831. super.setCurrentScreen(memoMainDrawingScreen);
  832. break;
  833. case ID.screen.MemoMakeAudio: // sub - 음성메모
  834. memoMainAudioScreen = new MemoMakeAudio(this, ScreenLayout, wpapi, OPERATION_MODE);
  835. super.setCurrentScreen(memoMainAudioScreen);
  836. break;
  837. case ID.screen.MemoMakeVideo: // sub - 영상메모
  838. memoMainVideoScreen = new MemoMakeVideo(this, ScreenLayout, wpapi, OPERATION_MODE);
  839. super.setCurrentScreen(memoMainVideoScreen);
  840. break;
  841. case API_Menu.SubMenuAddService.AutoPicture: // 전자액자
  842. setTitleText(API_Menu.SubMenuAddService.Name_AutoPicture);
  843. autoPictureMainScreen = new AutoPictureMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE);
  844. super.setCurrentScreen(autoPictureMainScreen);
  845. break;
  846. case ID.screen.AutoPictureShowScreen: // sub - 전자액자시작
  847. autoPictureSubShowScreen = new AutoPictureSubShowScreen(this, ScreenLayout, wpapi, OPERATION_MODE);
  848. super.setCurrentScreen(autoPictureSubShowScreen);
  849. break;
  850. case API_Menu.SubMenuAddService.Schedule: // 일정표
  851. setTitleText(API_Menu.SubMenuAddService.Name_Schedule);
  852. scheduleMainScreen = new ScheduleMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE);
  853. super.setCurrentScreen(scheduleMainScreen);
  854. break;
  855. case API_Menu.SubMenuAddService.Cctv: // cctv
  856. setTitleText(API_Menu.SubMenuAddService.Name_Cctv);
  857. cctvMainScreen = new CctvMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE);
  858. super.setCurrentScreen(cctvMainScreen);
  859. break;
  860. case API_Menu.SubMenuAddService.Parking: // 주차확인
  861. setTitleText(API_Menu.SubMenuAddService.Name_Parking);
  862. carInfoMainScreen = new CarInfoMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE);
  863. super.setCurrentScreen(carInfoMainScreen);
  864. break;
  865. case API_Menu.SubMenuAddService.ParkingList: // 차량출입내역
  866. setTitleText(API_Menu.SubMenuAddService.Name_ParkingList);
  867. carParkingAccessListScreen = new CarParkingAccessList(this, ScreenLayout, wpapi, OPERATION_MODE);
  868. super.setCurrentScreen(carParkingAccessListScreen);
  869. break;
  870. case API_Menu.SubMenuAddService.ElecCar: // 전기차충전
  871. setTitleText(API_Menu.SubMenuAddService.Name_ElecCar);
  872. elecCarMainScreen = new ElecCarMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE);
  873. super.setCurrentScreen(elecCarMainScreen);
  874. break;
  875. // Additional Menu
  876. case ID.screen.RepairScreen: // 보수신청
  877. repairScreen = new RepairScreen(this, ScreenLayout, wpapi, OPERATION_MODE);
  878. super.setCurrentScreen(repairScreen);
  879. break;
  880. case ID.screen.VoteScreen: // 주민투표
  881. voteScreen = new VoteScreen(this, ScreenLayout, wpapi, OPERATION_MODE);
  882. super.setCurrentScreen(voteScreen);
  883. break;
  884. case ID.screen.LocalInfoScreen: // 지역정보
  885. localInfoScreen = new LocalInfoScreen(this, ScreenLayout, wpapi, OPERATION_MODE);
  886. super.setCurrentScreen(localInfoScreen);
  887. break;
  888. case ID.screen.CostInfoScreen: // 관리비조회
  889. costScreen = new CostScreen(this, ScreenLayout, wpapi, OPERATION_MODE);
  890. super.setCurrentScreen(costScreen);
  891. break;
  892. case ID.screen.UCityScreen: // U-City
  893. uCityScreen = new UCityScreen(this, ScreenLayout, wpapi, OPERATION_MODE);
  894. super.setCurrentScreen(uCityScreen);
  895. break;
  896. case API_Menu.SubMenuAddService.InterlayerNoiseHistory: // 층간소음 내역
  897. setTitleText(API_Menu.SubMenuAddService.Name_NoiseLog);
  898. configNoiseLogMainScreen = new ConfigNoiseLogMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE);
  899. super.setCurrentScreen(configNoiseLogMainScreen);
  900. break;
  901. case API_Menu.SubMenuAddService.CarGuest: // 방문객 차량등록
  902. setTitleText(API_Menu.SubMenuAddService.Name_CarGuest);
  903. carGuestInfoScreen = new CarGuestInfoScreen(this, ScreenLayout, wpapi, OPERATION_MODE);
  904. super.setCurrentScreen(carGuestInfoScreen);
  905. break;
  906. case API_Menu.SubMenuAddService.BandLocation: // 밴드위치확인
  907. setTitleText(API_Menu.SubMenuAddService.Name_BandLocation);
  908. bandLocationMainScreen = new BandLocationMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE);
  909. super.setCurrentScreen(bandLocationMainScreen);
  910. break;
  911. case ID.screen.BandLocationListScreen:
  912. bandLocationListScreen = new BandLocationListScreen(this, ScreenLayout, wpapi, OPERATION_MODE);
  913. super.setCurrentScreen(bandLocationListScreen);
  914. break;
  915. case API_Menu.SubMenuAddService.SafeStreetLight: // 안전가로등
  916. setTitleText(API_Menu.SubMenuAddService.Name_SafeStreetLight);
  917. safeStreetLightMainScreen = new SafeStreetLightMainScreen(this, ScreenLayout, wpapi, OPERATION_MODE);
  918. super.setCurrentScreen(safeStreetLightMainScreen);
  919. break;
  920. default:
  921. Log.e(TAG, "[Error] setChangeScreen - nScreenId Not found!!! (" + mCurrentScreenId + ")");
  922. mCurrentScreenId = -1;
  923. return false;
  924. }
  925. } catch (RuntimeException re) {
  926. LogUtil.errorLogInfo("", TAG, re);
  927. } catch (Exception e) {
  928. Log.e(TAG, "[ExceptionError] - setChangeScreen->Screen Create : " + e);
  929. //e.printStackTrace();
  930. LogUtil.errorLogInfo("", TAG, e);
  931. return false;
  932. }
  933. return true;
  934. }
  935. private void setTitleText(String setText) {
  936. if (setText != null) TopTitle.setText(setText);
  937. }
  938. /* ================================================================================================
  939. * [Menu] Section
  940. ================================================================================================ */
  941. // Default 메뉴 리스트 설정
  942. private void DefaultMenuListSetting() {
  943. try {
  944. Log.d(TAG, "[DefaultMenuListSetting()]");
  945. mMenu = new Menu(7);
  946. wallpaddbmgr WallpadDBMGR = new wallpaddbmgr(getApplicationContext());
  947. WallpadDBMGR.DeleteMenuList();
  948. ArrayList<ArrayList<Integer>> mGroupList = new ArrayList<ArrayList<Integer>>();
  949. ArrayList<Integer> mChildList = new ArrayList<Integer>();
  950. WallpadDeviceSet wallpadDeviceSet = new WallpadDeviceSet(mContext);
  951. boolean bNonInternetUse = wallpadDeviceSet.Get_NonInternetSupportUse();
  952. wallpadDeviceSet.closeDB();
  953. if (bNonInternetUse) {
  954. // 인터넷 미지원
  955. mChildList.add(API_Menu.SubMenuAddService.Notice);
  956. mChildList.add(API_Menu.SubMenuAddService.Memo);
  957. } else {
  958. // 인터넷 지원
  959. mChildList.add(API_Menu.SubMenuAddService.Notice);
  960. mChildList.add(API_Menu.SubMenuAddService.Weather);
  961. mChildList.add(API_Menu.SubMenuAddService.Memo);
  962. mChildList.add(API_Menu.SubMenuAddService.AutoPicture);
  963. mChildList.add(API_Menu.SubMenuAddService.Schedule);
  964. }
  965. mGroupList.add(mChildList);
  966. WallpadDBMGR.SetMenuList(mGroupList);
  967. menuListDataClass = WallpadDBMGR.GetMenuList();
  968. WallpadDBMGR.closeDB();
  969. mMenu.StartId = API_Menu.SubMenuAddService.Notice;
  970. mMenu.Opiton = -1;
  971. } catch (RuntimeException re) {
  972. LogUtil.errorLogInfo("", TAG, re);
  973. } catch (Exception e) {
  974. Log.e(TAG, "[Exception] DefaultMenuSetting()");
  975. //e.printStackTrace();
  976. LogUtil.errorLogInfo("", TAG, e);
  977. }
  978. }
  979. // 메뉴 레이아웃 생성
  980. private void OpenMenuLayout() {
  981. if (MenuOpen) {
  982. return;
  983. }
  984. if (menuListDataClass == null) {
  985. return;
  986. }
  987. //0. 현재 ID 및 리스트 불러오기
  988. String Title = API_Menu.GetGroupNameByID(API_Menu.SubMenuAddService.BASE);
  989. String TempChildName = null;
  990. int ChooseGroup = 0;
  991. int ChooseChild = 0;
  992. for (int i = 0; i < menuListDataClass.arrayGroup.size(); i++) {
  993. if (menuListDataClass.arrayGroup.get(i).equals(Title)) {
  994. ChooseGroup = i;
  995. break;
  996. }
  997. }
  998. for (int i = 0; i < menuListDataClass.idMappingTable.length; i++) {
  999. if (menuListDataClass.idMappingTable[i].Id == mCurrentScreenId) {
  1000. TempChildName = menuListDataClass.idMappingTable[i].Name;
  1001. break;
  1002. } else if ((ID.screen.MemoMakeDrawing == mCurrentScreenId) || (ID.screen.MemoMakeAudio == mCurrentScreenId) || (ID.screen.MemoMakeVideo == mCurrentScreenId)) {
  1003. Title = API_Menu.SubMenuAddService.Name;
  1004. TempChildName = API_Menu.SubMenuAddService.Name_Memo;
  1005. break;
  1006. } else if (ID.screen.NoticeContentsScreen == mCurrentScreenId) {
  1007. Title = API_Menu.SubMenuAddService.Name;
  1008. TempChildName = API_Menu.SubMenuAddService.Name_Notice;
  1009. break;
  1010. } else if (ID.screen.AutoPictureShowScreen == mCurrentScreenId) {
  1011. Title = API_Menu.SubMenuAddService.Name;
  1012. TempChildName = API_Menu.SubMenuAddService.Name_AutoPicture;
  1013. break;
  1014. } else if (ID.screen.BandLocationListScreen == mCurrentScreenId) {
  1015. Title = API_Menu.SubMenuAddService.Name;
  1016. TempChildName = API_Menu.SubMenuAddService.Name_BandLocation;
  1017. } else if (ID.screen.SafeStreetLightMainScreen == mCurrentScreenId) {
  1018. Title = API_Menu.SubMenuAddService.Name;
  1019. TempChildName = API_Menu.SubMenuAddService.Name_SafeStreetLight;
  1020. }
  1021. }
  1022. if (TempChildName == null) {
  1023. Log.e(TAG, "[OpenMenuLayout] TempChildName == null");
  1024. return;
  1025. }
  1026. for (int i = 0; i < menuListDataClass.arrayChild.get(Title).size(); i++) {
  1027. if (menuListDataClass.arrayChild.get(Title).get(i).equals(TempChildName)) {
  1028. ChooseChild = i;
  1029. break;
  1030. }
  1031. }
  1032. //1. 기존 화면 투명도 변경
  1033. TopLayout.setAlpha(0.5f);
  1034. ScreenLayout.setAlpha(0.5f);
  1035. //2. Layout 생성 및 처리 이벤트 등록
  1036. MenuLayout = new RelativeLayout(this);
  1037. WpadUtil.LayoutRegistration(AllLayout, MenuLayout, 1280, 800, 0, 0, ID.main.layout.MENU);
  1038. MenuLayout.setOnTouchListener(new Button.OnTouchListener() {
  1039. @Override
  1040. public boolean onTouch(View v, MotionEvent event) {
  1041. if (event.getAction() == MotionEvent.ACTION_UP) {
  1042. setFinishTimerReset();
  1043. CloseMenuLayout();
  1044. }
  1045. return true;
  1046. }
  1047. });
  1048. //3. 배경 이미지 생성 및 에니메이션 등록
  1049. MenuBackground = new WpadImageView(this, TOUCH_KIND.BUTTON, 460, 800, R.drawable.bg_menu, R.drawable.bg_menu, ID.menu.image.BACKGROUND);
  1050. TranslateAnimation anim = new TranslateAnimation(WpadScale.getWidth(-460), 0, 0, 0);
  1051. anim.setDuration(200);
  1052. anim.setInterpolator(new AccelerateInterpolator());
  1053. MenuLayout.setAnimation(anim);
  1054. ViewRegistration(MenuLayout, MenuBackground, 0, 0);
  1055. //4. 타이틀 등록
  1056. MenuTitle = new WpadTextView(this, false, 247, 80, Gravity.LEFT, Color.WHITE, Common.fontsize._44, true, ID.top.text.TITLE);
  1057. ViewRegistration(MenuLayout, MenuTitle, 133, 15);
  1058. MenuTitle.setText(Title);
  1059. //5. 종료 버튼 등록
  1060. 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);
  1061. MenuClose.setTouchDelayMs(1000);
  1062. ViewRegistration(MenuLayout, MenuClose, 380, 15);
  1063. //6. 리스트뷰 초기화 및 등록
  1064. mListView = new ExpandableListView(this);
  1065. ExpandableListView.LayoutParams params = new ExpandableListView.LayoutParams(WpadScale.getWidth(460), WpadScale.getHeight(690));
  1066. mListView.setLayoutParams(params);
  1067. mListView.setX(WpadScale.getWidth(0));
  1068. mListView.setY(WpadScale.getHeight(112));
  1069. mListView.setBackgroundColor(Color.BLACK);
  1070. mListView.setId(ID.menu.view.LISTVIEW);
  1071. mListView.setGroupIndicator(null);
  1072. mListView.setDividerHeight(0);
  1073. mListView.setDivider(null);
  1074. mListView.setFocusable(true);
  1075. mListView.setSmoothScrollbarEnabled(true);
  1076. mListView.setTranscriptMode(android.widget.AbsListView.TRANSCRIPT_MODE_DISABLED);
  1077. mListView.setScrollbarFadingEnabled(true);
  1078. MenuLayout.addView(mListView);
  1079. adptMain = new Menu_AdptMain(this, menuListDataClass.arrayGroup, menuListDataClass.arrayChild, ChooseGroup, ChooseChild);
  1080. mListView.setAdapter(adptMain);
  1081. //7. 선택된 그룹 열기
  1082. mListView.setSelectedGroup(ChooseGroup);
  1083. mListView.expandGroup(ChooseGroup);
  1084. // 8. 리스트뷰 터치 이벤트 등록
  1085. mListView.setOnTouchListener(new View.OnTouchListener() {
  1086. @Override
  1087. public boolean onTouch(View v, MotionEvent event) {
  1088. if ((event.getAction() == MotionEvent.ACTION_DOWN) ||
  1089. (event.getAction() == MotionEvent.ACTION_UP)) {
  1090. WpadActivity.setFinishTimerReset();
  1091. }
  1092. return false;
  1093. }
  1094. });
  1095. // 9. 그룹 터치 이벤트 등록
  1096. mListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
  1097. @Override
  1098. public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
  1099. WpadActivity.setFinishTimerReset();
  1100. return false;
  1101. }
  1102. });
  1103. // 10. 차일드 터치 이벤트 등록
  1104. mListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
  1105. @Override
  1106. public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
  1107. WpadActivity.setFinishTimerReset();
  1108. return false;
  1109. }
  1110. });
  1111. // 11. 그룹 열리는 경우 이벤트
  1112. mListView.setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener() {
  1113. @Override
  1114. public void onGroupExpand(int groupPosition) {
  1115. mSound.Play(SND.effect.TOUCH_LATCHED);
  1116. WpadActivity.setFinishTimerReset();
  1117. }
  1118. });
  1119. // 12. 그룹 닫히는 경우 이벤트
  1120. mListView.setOnGroupCollapseListener(new ExpandableListView.OnGroupCollapseListener() {
  1121. @Override
  1122. public void onGroupCollapse(int groupPosition) {
  1123. mSound.Play(SND.effect.TOUCH_LATCHED);
  1124. WpadActivity.setFinishTimerReset();
  1125. }
  1126. });
  1127. // 13. MenuOpen True 설정
  1128. MenuOpen = true;
  1129. }
  1130. // 메뉴 layout 닫힘 처리
  1131. private void CloseMenuLayout() {
  1132. if (!MenuOpen) {
  1133. return;
  1134. }
  1135. TranslateAnimation anim = new TranslateAnimation(0, WpadScale.getWidth(-460), 0, 0);
  1136. anim.setDuration(200);
  1137. anim.setInterpolator(new AccelerateInterpolator());
  1138. anim.setAnimationListener(new Animation.AnimationListener() {
  1139. @Override
  1140. public void onAnimationStart(Animation animation) {
  1141. MenuOpen = false;
  1142. }
  1143. @Override
  1144. public void onAnimationRepeat(Animation animation) {
  1145. }
  1146. @Override
  1147. public void onAnimationEnd(Animation animation) {
  1148. AllLayout.removeView(MenuLayout);
  1149. TopLayout.setAlpha(1.0f);
  1150. ScreenLayout.setAlpha(1.0f);
  1151. }
  1152. });
  1153. MenuLayout.startAnimation(anim);
  1154. }
  1155. // 메뉴 그룹 터치시 처리 (Menu_AdptMain에서 호출)
  1156. public static void SetListViewGroupExpand_Collapse(int GroupId, boolean ExpandEnable) {
  1157. if (ExpandEnable) {
  1158. mListView.expandGroup(GroupId);
  1159. } else {
  1160. mListView.collapseGroup(GroupId);
  1161. }
  1162. }
  1163. // Menu정보가 DB에 없을 경우 불러올 스크린 로딩
  1164. private MenuListDataClass LoadDefaultMenuList() {
  1165. MenuListDataClass Temp_menuListDataClass = new MenuListDataClass();
  1166. Temp_menuListDataClass.SetArrayGroup(API_Menu.SubMenuAddService.Name);
  1167. ArrayList<String> arrayList = new ArrayList<String>();
  1168. int ChildCount = 0;
  1169. //[수정필요]
  1170. //추가 또는 수정해야할 부분 1. - Menu정보가 DB에 없을 경우 불러올 스크린 종류(시작)
  1171. arrayList.add(API_Menu.SubMenuAddService.Name_Schedule);
  1172. ChildCount++;
  1173. Temp_menuListDataClass.SetArrayChild(API_Menu.SubMenuAddService.Name, arrayList);
  1174. //추가 또는 수정해야할 부분 1. - Menu정보가 DB에 없을 경우 불러올 스크린 종류(끝)
  1175. Temp_menuListDataClass.idMappingTable = new MenuListDataClass.ChildIDMapping[ChildCount];
  1176. for (int i = 0; i < ChildCount; i++) {
  1177. Temp_menuListDataClass.idMappingTable[i] = new MenuListDataClass.ChildIDMapping();
  1178. //추가 또는 수정해야할 부분 2. - 불러올 스크린의 Id를 임의로 입력(시작)
  1179. if (arrayList.get(i).equals(API_Menu.SubMenuAddService.Name_Schedule)) {
  1180. Temp_menuListDataClass.idMappingTable[i].Id = API_Menu.SubMenuAddService.Schedule;
  1181. Temp_menuListDataClass.idMappingTable[i].Name = API_Menu.SubMenuAddService.Name_Schedule;
  1182. }
  1183. //추가 또는 수정해야할 부분 2. - 불러올 스크린의 Id를 임의로 입력(끝)
  1184. }
  1185. return Temp_menuListDataClass;
  1186. }
  1187. /**
  1188. * Menu Event intent filter 등록
  1189. **/
  1190. private void reg_Receiver() {
  1191. try {
  1192. IntentFilter filter = new IntentFilter();
  1193. filter.addAction("MENU_EVENT");
  1194. registerReceiver(mWallPadAlertBR, filter);
  1195. filter = new IntentFilter();
  1196. filter.addAction(define.NOTIFY_DAIL);
  1197. filter.addAction("WALLPAD_DIAL_GLOBALSCREEN_TOUCH");
  1198. registerReceiver(mWallPadJogBR, filter);
  1199. } catch (RuntimeException re) {
  1200. LogUtil.errorLogInfo("", TAG, re);
  1201. } catch (Exception e) {
  1202. Log.e(TAG, "[Exception] reg_Receiver");
  1203. //e.printStackTrace();
  1204. LogUtil.errorLogInfo("", TAG, e);
  1205. }
  1206. }
  1207. /**
  1208. * 조그버튼 입력 받을 시 처리
  1209. **/
  1210. BroadcastReceiver mWallPadJogBR = new BroadcastReceiver() {
  1211. @Override
  1212. public void onReceive(Context context, Intent intent) {
  1213. WpadActivity.setFinishTimerReset();
  1214. }
  1215. };
  1216. // 메뉴에서 버튼 터치 처리
  1217. BroadcastReceiver mWallPadAlertBR = new BroadcastReceiver() {
  1218. @Override
  1219. public void onReceive(Context context, Intent intent) {
  1220. int groupPosition = intent.getIntExtra("groupPosition", -1);
  1221. int childPosition = intent.getIntExtra("childPosition", -1);
  1222. Log.i(TAG, "groupPosition :" + groupPosition + ", childPosition :" + childPosition);
  1223. if ((groupPosition >= 0) && (childPosition >= 0)) {
  1224. if (MenuOpen) {
  1225. mSound.Play(SND.effect.TOUCH_LATCHED);
  1226. CloseMenuLayout();
  1227. if (menuListDataClass == null) {
  1228. return;
  1229. }
  1230. String childName = menuListDataClass.arrayChild.get(menuListDataClass.arrayGroup.get(groupPosition)).get(childPosition);
  1231. for (int i = 0; i < menuListDataClass.idMappingTable.length; i++) {
  1232. if (menuListDataClass.idMappingTable[i].Name.equals(childName)) {
  1233. API_Menu api_Menu = new API_Menu();
  1234. int TempId = api_Menu.GetMyGroupID(getApplicationContext().getPackageName());
  1235. int ChildId = menuListDataClass.idMappingTable[i].Id;
  1236. int ChildGroupId = (ChildId / 1000) * 1000;
  1237. Log.i(TAG, "Child Id :" + ChildId);
  1238. if (TempId == 0) {
  1239. return;
  1240. }
  1241. if (ChildGroupId == TempId) {
  1242. boolean result = setChangeScreen(ChildId, false);
  1243. if (!result) {
  1244. setChangeScreen(mMenu.getStartId(), false);
  1245. }
  1246. WpadActivity.setFinishTimerReset();
  1247. } else {
  1248. //외부 앱 호출 후, 본 APP Finish 필요
  1249. api_Menu.startSubScreenActivity(getApplicationContext(),
  1250. menuListDataClass.idMappingTable[i].Id, API_Menu.MENU_START_OPTION_1, api_Menu.GetAPK_Name_ByID(ChildGroupId));
  1251. Intent mIntent = new Intent();
  1252. mIntent.putExtra("Finish_Kind", "HomeButton");
  1253. MainActivity.this.setResult(RESULT_OK, mIntent);
  1254. finish();
  1255. }
  1256. break;
  1257. }
  1258. }
  1259. }
  1260. }
  1261. }
  1262. };
  1263. // 영상
  1264. private MediaRecorder m_mediaRecorder;
  1265. private final String VIDEO_TEMP_PATH = define.BESTIN_LOCATION + "VideoRecorded.mp4";
  1266. private SurfaceHolder holder;
  1267. private SurfaceView surface;
  1268. public PlayerSurfaceView getTechWinSurfaceView() {
  1269. PlayerSurfaceView mPlayerSurfaceView;
  1270. mPlayerSurfaceView = (PlayerSurfaceView) findViewById(R.id.PlayerView);
  1271. return mPlayerSurfaceView;
  1272. }
  1273. Camera wpCamera = null;
  1274. public void mediaSurface() {
  1275. Log.d(TAG, "[mediaSurface]");
  1276. try {
  1277. if (surface != null) {
  1278. Log.v(TAG, "[mediaSurface] surface isn't null");
  1279. surface.getHolder().removeCallback(wpVideoCallback);
  1280. ScreenLayout.removeView(surface);
  1281. }
  1282. surface = new SurfaceView(this);
  1283. holder = surface.getHolder();
  1284. WpadRelativeLayoutParams params = new WpadRelativeLayoutParams(720, 540);
  1285. params.setMargins(Common.ImgPosition.GetX(95), Common.ImgPosition.GetY(112), 0, 0);
  1286. ScreenLayout.addView(surface, params);
  1287. surface.getHolder().addCallback(wpVideoCallback);
  1288. surface.setZOrderOnTop(true);
  1289. } catch (RuntimeException re) {
  1290. LogUtil.errorLogInfo("", TAG, re);
  1291. } catch (Exception e) {
  1292. Log.e(TAG, "[Exception] mediaSurface()");
  1293. //e.printStackTrace();
  1294. LogUtil.errorLogInfo("", TAG, e);
  1295. }
  1296. }
  1297. private SurfaceHolder.Callback wpVideoCallback = new SurfaceHolder.Callback() {
  1298. @Override
  1299. public void surfaceCreated(SurfaceHolder holder) {
  1300. Log.d(TAG, "[wpVideoCallback.surfaceCreated]");
  1301. if (mV40IF != null) mV40IF.ctrlWallPadCamPower(true);
  1302. try {
  1303. boolean bAOS7 = false;
  1304. if (Build.VERSION.SDK_INT > 23) bAOS7 = true;
  1305. if (Version.getModelType() == Version.MODEL_TYPE.IHN_D101) {
  1306. Log.d(TAG, "[openCamera] Build.VERSION.SDK_INT [" + Build.VERSION.SDK_INT + "], bAOS7 [" + bAOS7 + "]");
  1307. if (bAOS7) {
  1308. // AOS 7.1.1
  1309. wpCamera = Camera.open(Camera.CameraInfo.CAMERA_FACING_FRONT); // 확인완료 (JEFF, 2020.09.02)
  1310. }
  1311. else {
  1312. // AOS 6.0
  1313. wpCamera = Camera.open(Camera.CameraInfo.CAMERA_FACING_FRONT);
  1314. }
  1315. }
  1316. else {
  1317. if (bAOS7) {
  1318. /**
  1319. * 확인완료 (JEFF, 2020.09.02)
  1320. * IHN-1020B-I, IHN-D101-I, IHN-1010-I, IHN-HS101-I
  1321. */
  1322. // AOS 7.1.1
  1323. if (Version.getModelType() == Version.MODEL_TYPE.IHN_1020B_I && !getCompareBSPVersion("2020.09.08")) wpCamera = Camera.open(Camera.CameraInfo.CAMERA_FACING_BACK);
  1324. else if (Version.getModelType() == Version.MODEL_TYPE.IHN_HS101_I && !getCompareBSPVersion("2020.06.11")) wpCamera = Camera.open(Camera.CameraInfo.CAMERA_FACING_BACK);
  1325. else wpCamera = Camera.open(Camera.CameraInfo.CAMERA_FACING_FRONT);
  1326. }
  1327. else {
  1328. /**
  1329. * 확인완료 (JEFF, 2020.09.11)
  1330. * IHN-1010, IHN-HS101
  1331. */
  1332. // AOS 6.0
  1333. wpCamera = Camera.open(Camera.CameraInfo.CAMERA_FACING_BACK); // 확인완료 (JEFF, 2020.09.02)
  1334. }
  1335. }
  1336. Camera.Parameters params = wpCamera.getParameters();
  1337. params.setPictureSize(640, 480);
  1338. wpCamera.setParameters(params);
  1339. wpCamera.setPreviewDisplay(holder);
  1340. } catch (RuntimeException re) {
  1341. LogUtil.errorLogInfo("", TAG, re);
  1342. } catch (Exception e) {
  1343. Log.e(TAG, "[Exception] wpVideoCallback.surfaceCreated()");
  1344. //e.printStackTrace();
  1345. LogUtil.errorLogInfo("", TAG, e);
  1346. }
  1347. }
  1348. @Override
  1349. public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
  1350. Log.d(TAG, "[wpVideoCallback.surfaceChanged]");
  1351. wpCamera.startPreview();
  1352. }
  1353. @Override
  1354. public void surfaceDestroyed(SurfaceHolder holder) {
  1355. Log.d(TAG, "[wpVideoCallback.surfaceDestroyed]");
  1356. if (mV40IF != null) mV40IF.ctrlWallPadCamPower(false);
  1357. if (wpCamera != null) {
  1358. wpCamera.stopPreview();
  1359. wpCamera.release();
  1360. wpCamera = null;
  1361. }
  1362. }
  1363. };
  1364. public boolean getSmartIoTCameraUsage() {
  1365. WallpadDeviceSet mWallpadDeviceSet = new WallpadDeviceSet(this.getApplicationContext());
  1366. try {
  1367. if (mWallpadDeviceSet != null) {
  1368. int[] anFrontCameraType = mWallpadDeviceSet.Get_RFDoorCAM_Info(); // 현관카메라 종류
  1369. mWallpadDeviceSet.closeDB();
  1370. // 현관카메라 종류
  1371. if (anFrontCameraType != null) {
  1372. if ((anFrontCameraType[1] == WallpadDeviceSet.DOORTYPE_IOT_SMART)) return true;
  1373. else return false;
  1374. }
  1375. else {
  1376. Log.w(TAG, "[getSmartIoTCameraUsage] anFrontCameraType is null!!");
  1377. return false;
  1378. }
  1379. }
  1380. else {
  1381. Log.w(TAG, "[getSmartIoTCameraUsage] mWallpadDeviceSet is null!!");
  1382. }
  1383. } catch (RuntimeException re) {
  1384. LogUtil.errorLogInfo("", TAG, re);
  1385. } catch (Exception e) {
  1386. Log.e(TAG, "[Exception] getSmartIoTCameraUsage()");
  1387. //e.printStackTrace();
  1388. LogUtil.errorLogInfo("", TAG, e);
  1389. }
  1390. mWallpadDeviceSet.closeDB();
  1391. return false;
  1392. }
  1393. public void getV40MicGain() {
  1394. try {
  1395. Log.d(TAG, "[getV40MicGain]");
  1396. int nModelType = Version.getModelType();
  1397. if (nModelType == Version.MODEL_TYPE.IHN_D101 || nModelType == Version.MODEL_TYPE.IHN_D101_I
  1398. || nModelType == Version.MODEL_TYPE.IHN_D101K || nModelType == Version.MODEL_TYPE.IHN_D101K_I
  1399. || nModelType == Version.MODEL_TYPE.IHN_1010GL || nModelType == Version.MODEL_TYPE.IHN_1010GL_I
  1400. || nModelType == Version.MODEL_TYPE.IHN_1010GL_I_2443ALT || nModelType == Version.MODEL_TYPE.IHN_1010GL_I_6410ALT
  1401. || nModelType == Version.MODEL_TYPE.IHN_D101_I_OCF) {
  1402. if (mV40IF != null) Log.d(TAG, "[getV40MicGain] getMICGain() [" + mV40IF.getMICGain() + "]");
  1403. } else Log.w(TAG, "[getV40MicGain] Not Supported MODEL!! MODEL_TYPE [" + nModelType + "]");
  1404. } catch (RuntimeException re) {
  1405. LogUtil.errorLogInfo("", TAG, re);
  1406. } catch (Exception e) {
  1407. Log.e(TAG, "[Exception] getV40MicGain()");
  1408. //e.printStackTrace();
  1409. LogUtil.errorLogInfo("", TAG, e);
  1410. }
  1411. }
  1412. public void setV40MicGain(int nValue) {
  1413. try {
  1414. Log.d(TAG, "[setV40MicGain] nValue [" + nValue + "]");
  1415. int nModelType = Version.getModelType();
  1416. if (nModelType == Version.MODEL_TYPE.IHN_D101 || nModelType == Version.MODEL_TYPE.IHN_D101_I
  1417. || nModelType == Version.MODEL_TYPE.IHN_D101K || nModelType == Version.MODEL_TYPE.IHN_D101K_I
  1418. || nModelType == Version.MODEL_TYPE.IHN_1010GL || nModelType == Version.MODEL_TYPE.IHN_1010GL_I
  1419. || nModelType == Version.MODEL_TYPE.IHN_1010GL_I_2443ALT || nModelType == Version.MODEL_TYPE.IHN_1010GL_I_6410ALT
  1420. || nModelType == Version.MODEL_TYPE.IHN_D101_I_OCF) {
  1421. if (mV40IF != null) mV40IF.setMICGain(nValue);
  1422. } else Log.w(TAG, "[setV40MicGain] Not Supported MODEL!! MODEL_TYPE [" + nModelType + "]");
  1423. } catch (RuntimeException re) {
  1424. LogUtil.errorLogInfo("", TAG, re);
  1425. } catch (Exception e) {
  1426. Log.e(TAG, "[Exception] setV40MicGain(int nValue)");
  1427. //e.printStackTrace();
  1428. LogUtil.errorLogInfo("", TAG, e);
  1429. }
  1430. }
  1431. public void mediaStartRecording() {
  1432. try {
  1433. if (m_mediaRecorder != null) {
  1434. Log.d(TAG, "[mediaStartRecording] m_mediaRecorder isn't null!");
  1435. m_mediaRecorder.stop();
  1436. m_mediaRecorder.reset();
  1437. m_mediaRecorder.release();
  1438. m_mediaRecorder = null;
  1439. }
  1440. m_mediaRecorder = new MediaRecorder();
  1441. Log.d(TAG, "[mediaStartRecording] ====== setAudioSource =====");
  1442. mCameraOpenCheckHandler.sendEmptyMessage(0);
  1443. } catch (RuntimeException re) {
  1444. LogUtil.errorLogInfo("", TAG, re);
  1445. } catch (Throwable t) {
  1446. //t.printStackTrace();
  1447. LogUtil.errorLogInfo("", TAG, t);
  1448. Log.w("printStackTrace : ", t);
  1449. }
  1450. }
  1451. public void mediaStopRec() {
  1452. if (m_mediaRecorder != null) {
  1453. m_mediaRecorder.stop();
  1454. m_mediaRecorder.reset();
  1455. m_mediaRecorder.release();
  1456. ScreenLayout.removeView(surface);
  1457. m_mediaRecorder = null;
  1458. if (mV40IF != null) mV40IF.ctrlWallPadCamPower(false);
  1459. if (wpCamera != null) {
  1460. wpCamera.stopPreview();
  1461. wpCamera.release();
  1462. wpCamera = null;
  1463. }
  1464. }
  1465. }
  1466. public void ReleaseSurface() {
  1467. if (surface != null) {
  1468. surface = null;
  1469. }
  1470. }
  1471. private Handler mCameraOpenCheckHandler = new Handler() {
  1472. @Override
  1473. public void handleMessage(Message msg) {
  1474. if (msg.what == 0) {
  1475. if (wpCamera != null) mCameraOpenCheckHandler.sendEmptyMessageDelayed(1, 10);
  1476. else mCameraOpenCheckHandler.sendEmptyMessageDelayed(0, 10);
  1477. } else if (msg.what == 1) {
  1478. // 영상 메모 녹화 시작!!
  1479. Log.d(TAG, "[mCameraOpenCheckHandler.handleMessage] Handler finish!! [CAMERA OPEN]");
  1480. wpCamera.unlock();
  1481. m_mediaRecorder.setCamera(wpCamera);
  1482. m_mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
  1483. m_mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
  1484. m_mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
  1485. m_mediaRecorder.setVideoSize(640, 480);
  1486. m_mediaRecorder.setVideoEncodingBitRate(1024 * 1024);
  1487. m_mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
  1488. m_mediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.DEFAULT);
  1489. if (Build.VERSION.SDK_INT > 23) m_mediaRecorder.setVideoFrameRate(24);
  1490. m_mediaRecorder.setOutputFile(VIDEO_TEMP_PATH);
  1491. m_mediaRecorder.setPreviewDisplay(holder.getSurface());
  1492. try {
  1493. Log.d(TAG, "[mediaStartRecording] m_mediaRecorder.prepare");
  1494. m_mediaRecorder.prepare();
  1495. } catch (IllegalStateException e) {
  1496. Log.e(TAG, "[IllegalStateException] mediaStartRecording: " + e.toString());
  1497. } catch (IOException e) {
  1498. Log.e(TAG, "[IOException] mediaStartRecording: " + e.toString());
  1499. }
  1500. m_mediaRecorder.start();
  1501. }
  1502. }
  1503. };
  1504. public void DisplayImageCam(byte[] pData, int offset, int length, int nID) {
  1505. Log.d("test", "DisplayImageCam1");
  1506. ImageView IV = (ImageView) findViewById(nID);
  1507. Bitmap bMap = BitmapFactory.decodeByteArray(pData, offset, length);
  1508. IV.setImageBitmap(bMap);
  1509. }
  1510. public enum MAINEVENT {
  1511. BTN_HOME,
  1512. BTN_BACK,
  1513. BTN_MENU
  1514. }
  1515. public interface MainEventListener {
  1516. public void onMainTouchEvent(MAINEVENT eEvent);
  1517. }
  1518. MainEventListener mMainEventListener;
  1519. public void setMainEventListener(MainEventListener MEL) {
  1520. mMainEventListener = MEL;
  1521. }
  1522. public void releaseMainEventListener() {
  1523. mMainEventListener = null;
  1524. }
  1525. /**
  1526. * 월패드 타입 판별
  1527. * @return bResult
  1528. * false: 메인월패드
  1529. * true: 서브월패드
  1530. */
  1531. public boolean getAsSubWallPad() {
  1532. boolean bResult = false;
  1533. try {
  1534. WallpadDeviceSet devSet = new WallpadDeviceSet(this);
  1535. String[] DBinfo = devSet.GetSettingData("서브월패드");
  1536. devSet.closeDB();
  1537. if(DBinfo != null) {
  1538. if (DBinfo[1].indexOf("사용함") > 0) bResult = true;
  1539. else bResult = false;
  1540. }
  1541. } catch (RuntimeException re) {
  1542. LogUtil.errorLogInfo("", TAG, re);
  1543. } catch (Exception e) {
  1544. Log.e("Common", "[Exception] getAsSubWallPad()");
  1545. //e.printStackTrace();
  1546. LogUtil.errorLogInfo("", TAG, e);
  1547. }
  1548. Log.i(TAG, "[GetWallPadType] bResult [" + bResult + "]");
  1549. return bResult;
  1550. }
  1551. private void setAudioMemoPlayVol(boolean bMemoPlay) {
  1552. try {
  1553. Log.d(TAG, "[setAudioMemoPlayVol] bMemoPlay [" + bMemoPlay + "]");
  1554. if (bMemoPlay) MainActivity.mV40IF.setWallPadVolume_V40("0x0A00"); // FM8802 음량 올림
  1555. MainActivity.mV40IF.setWallPadVolume_V40("0x0100");
  1556. } catch (RuntimeException re) {
  1557. LogUtil.errorLogInfo("", TAG, re);
  1558. } catch (Exception e) {
  1559. Log.e(TAG, "[Exception] sendHandlerMsgDelayed(int what, int arg1, int arg2, long delay");
  1560. //e.printStackTrace();
  1561. LogUtil.errorLogInfo("", TAG, e);
  1562. }
  1563. }
  1564. /**
  1565. * 절전모드에서 백라이트를 키는 경우, BSP에서 PowerManager 또는 속성값으로 상태를 구분하는데
  1566. * BSP 버전에 따라 상이하게 동작하므로 BSP 버전 구분하여 절전모드 판별 필요
  1567. * @return true: 기준 BSP 이후 버전, false: 기준 BSP 이전 버전
  1568. */
  1569. public static boolean getCompareBSPVersion(String version) {
  1570. try {
  1571. StringBuilder strBSPVersion = new StringBuilder();
  1572. StringBuffer sysInfoBuffer = new StringBuffer();
  1573. sysInfoBuffer.append(Build.DISPLAY);
  1574. strBSPVersion.append(sysInfoBuffer.toString());
  1575. String result = strBSPVersion.toString();
  1576. Log.d(TAG, "[getCompareBSPVersion] result [" + result + "]");
  1577. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy.MM.dd");
  1578. Date date = simpleDateFormat.parse(result);
  1579. Date standardDate = simpleDateFormat.parse(version); // 비교 기준 BSP 버전
  1580. if (date.compareTo(standardDate) >= 0) {
  1581. Log.d(TAG, "[getCompareBSPVersion] BSP VERSION OVER!");
  1582. return true;
  1583. }
  1584. } catch (RuntimeException re) {
  1585. LogUtil.errorLogInfo("", TAG,re);
  1586. } catch (Exception e) {
  1587. Log.e(TAG, "[Exception] getCompareBSPVersion");
  1588. LogUtil.errorLogInfo("", TAG, e);
  1589. }
  1590. return false;
  1591. }
  1592. }