123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387 |
- package kr.co.icontrols.wallpadconfig;
- import android.annotation.SuppressLint;
- import android.content.Context;
- import android.content.Intent;
- import android.os.Bundle;
- import android.os.Handler;
- import android.os.Message;
- import android.util.Log;
- import android.view.KeyEvent;
- import android.view.MotionEvent;
- import android.view.View;
- import android.widget.RelativeLayout;
- import com.artncore.WallPadDataMgr.WallpadStatusData;
- import com.artncore.wallpadapi.WallPadAPI;
- import com.util.LogUtil;
- import kr.co.icontrols.wallpadconfig.declare.Common;
- import kr.co.icontrols.wallpadconfig.declare.ID;
- import kr.co.icontrols.wallpadconfig.manual.Lcd_Clean_MANUAL;
- import kr.co.icontrols.wallpadconfig.manual.MobileDeviceReg_MANUAL;
- import kr.co.icontrols.wallpadconfig.manual.Morning_Call_MANUAL;
- import kr.co.icontrols.wallpadconfig.manual.Pwd_Change_MANUAL;
- import kr.co.icontrols.wallpadconfig.manual.RFCard_MANUAL;
- import kr.co.icontrols.wallpadconfig.manual.ReliefCallPreset_MANUAL;
- import kr.co.icontrols.wallpadconfig.manual.RemoteCallUserSet_MANUAL;
- import kr.co.icontrols.wallpadconfig.manual.SettingMain_MANUAL;
- import kr.co.icontrols.wallpadconfig.manual.Setting_Pop_NameSet_MANUAL;
- import kr.co.icontrols.wallpadconfig.manual.Smartkey_MANUAL;
- import kr.co.icontrols.wallpadconfig.manual.Time_Setting_MANUAL;
- import kr.co.icontrols.wallpadconfig.manual.WebCtrPwd_MANUAL;
- import kr.co.icontrols.wallpadsupport.WpadActivity;
- import kr.co.icontrols.wallpadsupport.WpadScale;
- public class ManualActivity extends WpadActivity {
- static final String TAG = "ManualActivity";
- private static Context mContext = null;
- private static boolean mCreateComplete = false;
- public RelativeLayout AllLayout;
- // Manual Screen
- SettingMain_MANUAL settingMain_manual;
- Setting_Pop_NameSet_MANUAL setting_pop_nameSet_manual;
- Lcd_Clean_MANUAL lcd_clean_manual;
- Pwd_Change_MANUAL pwd_change_manual;
- Morning_Call_MANUAL morning_call_manual;
- Time_Setting_MANUAL time_setting_manual;
- ReliefCallPreset_MANUAL reliefCallPreset_manual;
- Smartkey_MANUAL smartkey_manual;
- RFCard_MANUAL rfCard_manual;
- MobileDeviceReg_MANUAL mobileDeviceReg_manual;
- WebCtrPwd_MANUAL webCtrPwd_manual;
- RemoteCallUserSet_MANUAL remoteCallUser_manual;
- private WallPadAPI wpapi = null;
- private WallpadStatusData wdb = null;
- private int OPERATION_MODE = Common.MODE;
- private int mCurrentScreenId = -1;
- private int mTempCurrentScreenId = -1;
- public String SettingData_Str = "";
- public int now_page = 0;
- public int total_page = 0;
- public static Context getContext() {
- return mContext;
- }
- protected static boolean getCreateComplete() {
- return mCreateComplete;
- }
- private void setStaticVariablesInit() {
- mContext = null;
- mCreateComplete = false;
- if (AllLayout != null) {
- AllLayout.removeAllViews();
- AllLayout = null;
- }
- }
- /* ================================================================================================
- * [ Activity Life Cycle ] region
- ================================================================================================ */
- @Override
- protected void onCreate(Bundle savedInstanceState)
- {
- Log.d(TAG, "[ManualActivity] START!!!!");
- super.onCreate(savedInstanceState);
- MainActivity.mManualActivity = this;
- setStaticVariablesInit();
- mContext = this;
- if (OPERATION_MODE == Common.MODE_NOMAL)
- {
- Log.d(TAG, "OPERATION_MODE = MODE_NORMAL");
- wpapi = new WallPadAPI(this);
- }
- else if (OPERATION_MODE == Common.MODE_BUSINESS_SAMPLE)
- {
- Log.d(TAG, "OPERATION_MODE = MODE_BUSINESS_SAMPLE");
- }
- try
- {
- wdb = new WallpadStatusData(this);
- }
- catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- }
- catch (Exception e) {
- Log.e(TAG, "[Error] - WallpadStatusData Create : " + e);
- }
- AllLayout = new RelativeLayout(this);
- super.setAllLayoutRegistration(AllLayout);
- Intent intent = getIntent();
- int ScreenId = intent.getIntExtra("ScreenId", -1);
- SettingData_Str = intent.getStringExtra("SettingData");
- now_page = intent.getIntExtra("NowPage", 0);
- total_page = intent.getIntExtra("TotalPage", 0);
- Log.d(TAG, "ScreenId = " + ScreenId);
- if (ScreenId < 0)
- {
- Log.e(TAG, "[Error] ScreenId Out of range (" + ScreenId + ")");
- finish();
- }
- else
- {
- mCreateComplete = true;
- if (OPERATION_MODE == Common.MODE_NOMAL)
- {
- Log.d(TAG, "[setChangeScreen] OPERATION_MODE == Common.MODE_NORMAL");
- mTempCurrentScreenId = ScreenId;
- mWallPadApiCheckHandler.sendEmptyMessage(0);
- }
- else
- {
- if (!setChangeScreen(ScreenId, false))
- {
- Log.e(TAG, "[Error] setChangeScreen false...");
- finish();
- }
- }
- }
- }
- @Override
- protected void onDestroy()
- {
- setChangeScreen(mCurrentScreenId, true);
- setStaticVariablesInit();
- MainActivity.setManualActivityRun(false);
- PopupActivity.setManualActivityRun(false);
- mCreateComplete = false;
- if (wdb != null) wdb.closeDB();
- super.onDestroy();
- }
- @Override
- protected void onResume()
- {
- super.onResume();
- if (wpapi != null) wpapi.Resume();
- }
- @Override
- protected void onPause()
- {
- super.onPause();
- if (wpapi != null) wpapi.Pause();
- }
- /* ================================================================================================
- * [BroadcastReceiver] Section
- ================================================================================================ */
- @Override
- protected void onBrReceive(Intent intent)
- {
- super.onBrReceive(intent);
- Log.d(TAG, "Receive alert BR " + intent.getAction());
- }
- /* ================================================================================================
- * [Touch & Key Event] Section
- ================================================================================================ */
- @Override
- public boolean onTouchEvent(MotionEvent event) {
- return super.onTouchEvent(event);
- }
- @Override
- protected void onTouchEvent(View v, MotionEvent event) {
- super.onTouchEvent(v, event);
- }
- @Override
- public boolean dispatchTouchEvent(MotionEvent ev) {
- return super.dispatchTouchEvent(ev);
- }
- /* ================================================================================================
- * [Screen] Section
- ================================================================================================ */
- @Override
- public boolean onKeyDown(int keyCode, KeyEvent event)
- {
- Log.d(TAG, "onKeyDown - " + " / keyCode : " + keyCode + " / Action : " + event.getAction());
- return super.onKeyDown(keyCode, event);
- }
- @Override
- protected boolean onChangeScreen(int nScreenId)
- {
- super.onChangeScreen(nScreenId);
- return setChangeScreen(nScreenId, false);
- }
- private boolean setChangeScreen(int screenId, boolean onlyRemove)
- {
- Log.d(TAG, "setChangeLayout - " + "CurrentScreenId : " + mCurrentScreenId + " / NextLayoutId : " + screenId + " / OnlyRemove : " + onlyRemove);
- if (!getCreateComplete())
- {
- Log.w(TAG, "[setChangeScreen] setChangeLayout - CreateComplete is false !!!");
- return false;
- }
- if (mCurrentScreenId > 0)
- {
- AllLayout.removeAllViews();
- super.setCurrentScreen(null);
- }
- if (onlyRemove) return true;
- // 새로운 Layout 표시
- int style = Common.MANUAL_STYLE_NORMAL;
- int finishTime = Common.FINISH_TIME_MANUAL_SEC;
- try {
- Log.d(TAG, "[setChangeScreen] screenId: " + screenId);
- switch (screenId)
- {
- case ID.MANUAL.MANUAL_SettingMain:
- settingMain_manual = new SettingMain_MANUAL(mContext, AllLayout, wpapi, SettingData_Str, now_page, total_page);
- super.setCurrentScreen(settingMain_manual);
- break;
- case ID.MANUAL.MANUAL_SettingNameSet:
- setting_pop_nameSet_manual = new Setting_Pop_NameSet_MANUAL(mContext, AllLayout, wpapi);
- super.setCurrentScreen(setting_pop_nameSet_manual);
- break;
- case ID.MANUAL.MANUAL_SettingAsCall:
- //setting_pop_nameSet_manual = new Setting_Pop_NameSet_MANUAL(mContext, AllLayout, wpapi);
- //super.setCurrentScreen(setting_pop_nameSet_manual);
- break;
- case ID.MANUAL.MANUAL_CleanLcdMain:
- lcd_clean_manual = new Lcd_Clean_MANUAL(mContext, AllLayout, wpapi);
- super.setCurrentScreen(lcd_clean_manual);
- break;
- case ID.MANUAL.MANUAL_PWD_CHANGE:
- pwd_change_manual = new Pwd_Change_MANUAL(mContext, AllLayout, wpapi);
- super.setCurrentScreen(pwd_change_manual);
- break;
- case ID.MANUAL.MANUAL_MORNINGCALL:
- morning_call_manual = new Morning_Call_MANUAL(mContext, AllLayout, wpapi);
- super.setCurrentScreen(morning_call_manual);
- break;
- case ID.MANUAL.MANUAL_TIMESETTING:
- time_setting_manual = new Time_Setting_MANUAL(mContext, AllLayout, wpapi);
- super.setCurrentScreen(time_setting_manual);
- break;
- case ID.MANUAL.MANUAL_RFCARD:
- rfCard_manual = new RFCard_MANUAL(mContext, AllLayout, wpapi);
- super.setCurrentScreen(rfCard_manual);
- break;
- case ID.MANUAL.MANUAL_SMARTKEY:
- smartkey_manual = new Smartkey_MANUAL(mContext, AllLayout, wpapi);
- super.setCurrentScreen(smartkey_manual);
- break;
- case ID.MANUAL.MANUAL_MOBILEDEVREG:
- mobileDeviceReg_manual = new MobileDeviceReg_MANUAL(mContext, AllLayout, wpapi);
- super.setCurrentScreen(mobileDeviceReg_manual);
- break;
- case ID.MANUAL.MANUAL_RELIEFCALLPRESET:
- reliefCallPreset_manual = new ReliefCallPreset_MANUAL(mContext, AllLayout);
- super.setCurrentScreen(reliefCallPreset_manual);
- break;
- case ID.MANUAL.MANUAL_POPWEBCTRPWD:
- webCtrPwd_manual = new WebCtrPwd_MANUAL(mContext, AllLayout);
- super.setCurrentScreen(webCtrPwd_manual);
- break;
- case ID.MANUAL.MANUAL_REMOTECALLUSERSET:
- remoteCallUser_manual = new RemoteCallUserSet_MANUAL(mContext, AllLayout);
- super.setCurrentScreen(remoteCallUser_manual);
- break;
- default:
- break;
- }
- }
- catch (RuntimeException re) {
- LogUtil.errorLogInfo("", TAG, re);
- mCurrentScreenId = -1;
- return false;
- }
- catch (Exception e) {
- Log.e(TAG, "[Exception] - setChangeScreen->Screen Create: " + e.toString());
- //e.printStackTrace();
- LogUtil.errorLogInfo("", TAG, e);
- mCurrentScreenId = -1;
- return false;
- }
- // style(Window Sizing) Setting
- int screenWidth = WpadScale.getWidth(Common.getManualScreenSize_W(style));
- int screenHeight = WpadScale.getHeight(Common.getManualScreenSize_H(style));
- if ((screenWidth <= 0) || (screenHeight <= 0))
- {
- Log.e(TAG, "[Error] Style UnDefined !!! (" + style + ")");
- return false;
- }
- RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(screenWidth, screenHeight);
- AllLayout.setLayoutParams(params);
- setContentView(AllLayout);
- super.WindowReSize(screenWidth, screenHeight, false);
- // FinishTimer Setting
- if ((Common.FINISH_TIME_ENABLE) && (finishTime > 0)) super.setFinishTimerCreate(finishTime);
- mCurrentScreenId = screenId;
- return true;
- }
- @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)
- {
- setChangeScreen(mTempCurrentScreenId, false);
- }
- }
- };
- }
|