package kr.co.icontrols.ilp300_700.admin.setting;

import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.util.Log;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.View;
import android.widget.RelativeLayout;

import java.io.File;

import kr.co.icontrols.ilp300_700.MainActivity;
import kr.co.icontrols.ilp300_700.R;
import kr.co.icontrols.ilp300_700.global.Configure.ConfigValue;
import kr.co.icontrols.ilp300_700.global.Configure;
import kr.co.icontrols.ilp300_700.global.DataClasses.POSITION;
import kr.co.icontrols.ilp300_700.global.Declare;
import kr.co.icontrols.ilp300_700.global.Enumeration.DATAINPUTSCREEN;
import kr.co.icontrols.ilp300_700.global.Global;
import kr.co.icontrols.ilp300_700.global.ID;
import kr.co.icontrols.wallpadsupport.WpadImageView;
import kr.co.icontrols.wallpadsupport.WpadScreen;
import kr.co.icontrols.wallpadsupport.WpadTextView;

public class AdminSet_Setting_ResetSystem extends WpadScreen {

    String TAG = "AdminSet_Setting_ResetSystem";

    boolean bLOG = true;   // true, false
    boolean bLOG_DEBUG = false;   // true, false
    boolean bLOG_INFO = true;   // true, false
    Context mContext;
    WpadImageView Image_Background;
    WpadTextView Text_Title;
    WpadTextView Text_Line_01_Item;
    WpadTextView Text_Line_02_Item;
    WpadTextView Text_Line_03_Item;
    WpadTextView Text_Line_04_Item;
    WpadTextView Text_Line_05_Item;
    WpadTextView Text_Line_06_Item;
    WpadTextView Text_Line_07_Item;
    int TextColor_Normal = Color.WHITE;
    int TextColor_Highlight = Color.GREEN;
    int TextColor_Red = Color.RED;
    int nFontSize_Instruction = 28;
    boolean bFontNonBold = false;
    boolean bFontBold = true;
    String strText_Title = "시스템 초기화";
    String strText_Line_01_Item = "1] 설정값 초기화";
    String strText_Line_02_Item = "2] 공장 초기화";
    String strText_Line_03_Item = "3] 출입키 초기화";
    String strText_Line_04_Item = "- 설정값 초기화 -";
    String strText_Line_05_Item = "로비폰 기본정보를 제외한";
    String strText_Line_06_Item = "모든 설정정보를 초기화 합니다.";
    String strText_Line_07_Item = "설정은 '경비실'버튼을 누르세요.";
    public AdminSet_Setting_ResetSystem(Context context, RelativeLayout layout) {
        super(context, layout);
        try {
            LOG("------------------ [START - AdminSet_Setting_ResetSystem] -------------------");

            mContext = context;
            Initialize();

            Image_Background = new WpadImageView(context, 0, Declare.DeviceInfo.getScreenSizeFullW(ConfigValue.DEVICE_MODELTYPE), Declare.DeviceInfo.getScreenSizeFullH(ConfigValue.DEVICE_MODELTYPE), R.drawable.bg_back, 0, ID.SCREENS.ADMINSET_SETTING_RESETSYSTEM.ELEMENTS.IMAGES.BACKGROUND);
            ViewRegistration(layout, Image_Background, 0, 0);

            Text_Title = new WpadTextView(context, false, getPosition(ID.SCREENS.ADMINSET_SETTING_RESETSYSTEM.ELEMENTS.TEXTS.TITLE).W, getPosition(ID.SCREENS.ADMINSET_SETTING_RESETSYSTEM.ELEMENTS.TEXTS.TITLE).H, Gravity.CENTER, Color.WHITE, nFontSize_Instruction, bFontBold, ID.SCREENS.ADMINSET_SETTING_RESETSYSTEM.ELEMENTS.TEXTS.TITLE);
            ViewRegistration(layout, Text_Title, getPosition(ID.SCREENS.ADMINSET_SETTING_RESETSYSTEM.ELEMENTS.TEXTS.TITLE).X, getPosition(ID.SCREENS.ADMINSET_SETTING_RESETSYSTEM.ELEMENTS.TEXTS.TITLE).Y);
            Text_Title.setText(strText_Title);

            Text_Line_01_Item = new WpadTextView(context, false, getPosition(ID.SCREENS.ADMINSET_SETTING_RESETSYSTEM.ELEMENTS.TEXTS.LINE_01_Item).W, getPosition(ID.SCREENS.ADMINSET_SETTING_RESETSYSTEM.ELEMENTS.TEXTS.LINE_01_Item).H, Gravity.LEFT, Color.WHITE, nFontSize_Instruction, bFontNonBold, ID.SCREENS.ADMINSET_SETTING_RESETSYSTEM.ELEMENTS.TEXTS.LINE_01_Item);
            ViewRegistration(layout, Text_Line_01_Item, getPosition(ID.SCREENS.ADMINSET_SETTING_RESETSYSTEM.ELEMENTS.TEXTS.LINE_01_Item).X, getPosition(ID.SCREENS.ADMINSET_SETTING_RESETSYSTEM.ELEMENTS.TEXTS.LINE_01_Item).Y);
            Text_Line_01_Item.setText(strText_Line_01_Item);

            Text_Line_02_Item = new WpadTextView(context, false, getPosition(ID.SCREENS.ADMINSET_SETTING_RESETSYSTEM.ELEMENTS.TEXTS.LINE_02_Item).W, getPosition(ID.SCREENS.ADMINSET_SETTING_RESETSYSTEM.ELEMENTS.TEXTS.LINE_02_Item).H, Gravity.LEFT, Color.WHITE, nFontSize_Instruction, bFontNonBold, ID.SCREENS.ADMINSET_SETTING_RESETSYSTEM.ELEMENTS.TEXTS.LINE_02_Item);
            ViewRegistration(layout, Text_Line_02_Item, getPosition(ID.SCREENS.ADMINSET_SETTING_RESETSYSTEM.ELEMENTS.TEXTS.LINE_02_Item).X, getPosition(ID.SCREENS.ADMINSET_SETTING_RESETSYSTEM.ELEMENTS.TEXTS.LINE_02_Item).Y);
            Text_Line_02_Item.setText(strText_Line_02_Item);

            Text_Line_03_Item = new WpadTextView(context, false, getPosition(ID.SCREENS.ADMINSET_SETTING_RESETSYSTEM.ELEMENTS.TEXTS.LINE_03_Item).W, getPosition(ID.SCREENS.ADMINSET_SETTING_RESETSYSTEM.ELEMENTS.TEXTS.LINE_03_Item).H, Gravity.LEFT, Color.WHITE, nFontSize_Instruction, bFontNonBold, ID.SCREENS.ADMINSET_SETTING_RESETSYSTEM.ELEMENTS.TEXTS.LINE_03_Item);
            ViewRegistration(layout, Text_Line_03_Item, getPosition(ID.SCREENS.ADMINSET_SETTING_RESETSYSTEM.ELEMENTS.TEXTS.LINE_03_Item).X, getPosition(ID.SCREENS.ADMINSET_SETTING_RESETSYSTEM.ELEMENTS.TEXTS.LINE_03_Item).Y);
            Text_Line_03_Item.setText(strText_Line_03_Item);

            Text_Line_04_Item = new WpadTextView(context, false, getPosition(ID.SCREENS.ADMINSET_SETTING_RESETSYSTEM.ELEMENTS.TEXTS.LINE_04_Item).W, getPosition(ID.SCREENS.ADMINSET_SETTING_RESETSYSTEM.ELEMENTS.TEXTS.LINE_04_Item).H, Gravity.CENTER, Color.WHITE, nFontSize_Instruction, bFontNonBold, ID.SCREENS.ADMINSET_SETTING_RESETSYSTEM.ELEMENTS.TEXTS.LINE_04_Item);
            ViewRegistration(layout, Text_Line_04_Item, getPosition(ID.SCREENS.ADMINSET_SETTING_RESETSYSTEM.ELEMENTS.TEXTS.LINE_04_Item).X, getPosition(ID.SCREENS.ADMINSET_SETTING_RESETSYSTEM.ELEMENTS.TEXTS.LINE_04_Item).Y);
            Text_Line_04_Item.setText(strText_Line_04_Item);

            Text_Line_05_Item = new WpadTextView(context, false, getPosition(ID.SCREENS.ADMINSET_SETTING_RESETSYSTEM.ELEMENTS.TEXTS.LINE_05_Item).W, getPosition(ID.SCREENS.ADMINSET_SETTING_RESETSYSTEM.ELEMENTS.TEXTS.LINE_05_Item).H, Gravity.CENTER, Color.WHITE, nFontSize_Instruction, bFontNonBold, ID.SCREENS.ADMINSET_SETTING_RESETSYSTEM.ELEMENTS.TEXTS.LINE_05_Item);
            ViewRegistration(layout, Text_Line_05_Item, getPosition(ID.SCREENS.ADMINSET_SETTING_RESETSYSTEM.ELEMENTS.TEXTS.LINE_05_Item).X, getPosition(ID.SCREENS.ADMINSET_SETTING_RESETSYSTEM.ELEMENTS.TEXTS.LINE_05_Item).Y);
            Text_Line_05_Item.setText(strText_Line_05_Item);

            Text_Line_06_Item = new WpadTextView(context, false, getPosition(ID.SCREENS.ADMINSET_SETTING_RESETSYSTEM.ELEMENTS.TEXTS.LINE_06_Item).W, getPosition(ID.SCREENS.ADMINSET_SETTING_RESETSYSTEM.ELEMENTS.TEXTS.LINE_06_Item).H, Gravity.CENTER, Color.WHITE, nFontSize_Instruction, bFontNonBold, ID.SCREENS.ADMINSET_SETTING_RESETSYSTEM.ELEMENTS.TEXTS.LINE_06_Item);
            ViewRegistration(layout, Text_Line_06_Item, getPosition(ID.SCREENS.ADMINSET_SETTING_RESETSYSTEM.ELEMENTS.TEXTS.LINE_06_Item).X, getPosition(ID.SCREENS.ADMINSET_SETTING_RESETSYSTEM.ELEMENTS.TEXTS.LINE_06_Item).Y);
            Text_Line_06_Item.setText(strText_Line_06_Item);

            Text_Line_07_Item = new WpadTextView(context, false, getPosition(ID.SCREENS.ADMINSET_SETTING_RESETSYSTEM.ELEMENTS.TEXTS.LINE_07_Item).W, getPosition(ID.SCREENS.ADMINSET_SETTING_RESETSYSTEM.ELEMENTS.TEXTS.LINE_07_Item).H, Gravity.CENTER, Color.WHITE, nFontSize_Instruction, bFontNonBold, ID.SCREENS.ADMINSET_SETTING_RESETSYSTEM.ELEMENTS.TEXTS.LINE_07_Item);
            ViewRegistration(layout, Text_Line_07_Item, getPosition(ID.SCREENS.ADMINSET_SETTING_RESETSYSTEM.ELEMENTS.TEXTS.LINE_07_Item).X, getPosition(ID.SCREENS.ADMINSET_SETTING_RESETSYSTEM.ELEMENTS.TEXTS.LINE_07_Item).Y);
            Text_Line_07_Item.setText(strText_Line_07_Item);

            UpdateScreen();
            ((MainActivity) mContext).setAutoScreenChange(ID.SCREENS.Main, MainActivity.nAdminScreenTimeout);
        } catch (Exception e) {
            Log.e(TAG, "[Exception] AdminSet_Setting_ResetSystem(...) : " + e);
            e.printStackTrace();
        }
    }

    private void LOG(String log) {
        if (bLOG) Log.v(TAG, log);
    }

    private void LOG_DEBUG(String log) {
        if (bLOG_DEBUG) Log.d(TAG, log);
    }

    private void LOG_INFO(String log) {
        if (bLOG_INFO) Log.i(TAG, log);
    }

    protected void Initialize() {
        try {
            LOG("[Initialize] ===== START =====");
            Global.DataInputScreen = DATAINPUTSCREEN.DETAIL_01;
        } catch (Exception e) {
            Log.e(TAG, "[Exception] Initialize() : " + e);
            e.printStackTrace();
        }
    }

    @Override
    protected void onClose() {
        try {
            LOG("------------------ [onClose - AdminSet_Setting_ResetSystem] -------------------");
        } catch (Exception e) {
            Log.e(TAG, "[Exception] onClose() : " + e);
            e.printStackTrace();
        }
        super.onClose();
    }

    @Override
    protected void onBrReceive(Intent intent) {
        try {
            LOG("[onBrReceive] Intent : " + intent);
        } catch (Exception e) {
            Log.e(TAG, "[Exception] onBrReceive(...) : " + e);
            e.printStackTrace();
        }
        super.onBrReceive(intent);
    }

    @Override
    protected void onKeyDown(int keyCode, KeyEvent event) {
        try {
//            LOG("[onKeyDown] keyCode [" + keyCode + "], event [" + event + "]");
            if (keyCode == Declare.Button.NUMBER_01) {
                // 설정값 초기화
                if (Global.DataInputScreen == DATAINPUTSCREEN.DETAIL_01) {
                    Global.DataInputScreen = DATAINPUTSCREEN.DETAIL_02;
                }
            } else if (keyCode == Declare.Button.NUMBER_02) {
                // 공장 초기화
                if (Global.DataInputScreen == DATAINPUTSCREEN.DETAIL_01) {
                    Global.DataInputScreen = DATAINPUTSCREEN.DETAIL_03;
                }
            } else if (keyCode == Declare.Button.NUMBER_03) {
                // 출입키 초기화
                if (Global.DataInputScreen == DATAINPUTSCREEN.DETAIL_01) {
                    Global.DataInputScreen = DATAINPUTSCREEN.DETAIL_04;
                }
            } else if (keyCode == Declare.Button.CANCEL || keyCode == Declare.Button.TACT_CANCEL) {
                if (Global.DataInputScreen == DATAINPUTSCREEN.DETAIL_01) {
                    super.setChangeScreen(ID.SCREENS.AdminSet_Setting);
                } else if (Global.DataInputScreen == DATAINPUTSCREEN.DETAIL_02) {
                    Global.DataInputScreen = DATAINPUTSCREEN.DETAIL_01;
                } else if (Global.DataInputScreen == DATAINPUTSCREEN.DETAIL_03) {
                    Global.DataInputScreen = DATAINPUTSCREEN.DETAIL_01;
                } else if (Global.DataInputScreen == DATAINPUTSCREEN.DETAIL_04) {
                    Global.DataInputScreen = DATAINPUTSCREEN.DETAIL_01;
                }
            } else if (keyCode == Declare.Button.GUARD) {
                if (Global.DataInputScreen == DATAINPUTSCREEN.DETAIL_02) {
                    // 설정값 초기화 실행
                    if (setSettingReset()) MainActivity.mSound.PlayMent_lobby(R.raw.setting);
                    else MainActivity.mSound.PlayMent_lobby(R.raw.retryinput);
                } else if (Global.DataInputScreen == DATAINPUTSCREEN.DETAIL_03) {
                    // 공장 초기화 실행
                    MainActivity.mSound.PlayMent_lobby(R.raw.setting);
                    ((MainActivity) mContext).setFaceReset();
                    if (setFactoryMode()) super.setChangeScreen(ID.SCREENS.Reboot);
                } else if (Global.DataInputScreen == DATAINPUTSCREEN.DETAIL_04) {
                    // 키정보 초기화 실행
                    MainActivity.mSound.PlayMent_lobby(R.raw.setting);
                    if (resetAccessKeyInfo()) super.setChangeScreen(ID.SCREENS.Reboot);
                }
            }
            UpdateScreen();
        } catch (Exception e) {
            Log.e(TAG, "[Exception] onKeyDown(int keyCode, KeyEvent event)");
            e.printStackTrace();
        }
        super.onKeyDown(keyCode, event);
    }

    protected void updateVisibility() {
//        LOG("[UpdateVisibility] ===== START =====");
        try {
            if (Global.DataInputScreen == DATAINPUTSCREEN.DETAIL_01) {
                Text_Line_01_Item.setVisibility(View.VISIBLE);
                Text_Line_02_Item.setVisibility(View.VISIBLE);
                Text_Line_03_Item.setVisibility(View.VISIBLE);
                Text_Line_04_Item.setVisibility(View.INVISIBLE);
                Text_Line_05_Item.setVisibility(View.INVISIBLE);
                Text_Line_06_Item.setVisibility(View.INVISIBLE);
                Text_Line_07_Item.setVisibility(View.INVISIBLE);
            } else if (Global.DataInputScreen == DATAINPUTSCREEN.DETAIL_02 || Global.DataInputScreen == DATAINPUTSCREEN.DETAIL_03 || Global.DataInputScreen == DATAINPUTSCREEN.DETAIL_04) {
                Text_Line_01_Item.setVisibility(View.INVISIBLE);
                Text_Line_02_Item.setVisibility(View.INVISIBLE);
                Text_Line_03_Item.setVisibility(View.INVISIBLE);
                Text_Line_04_Item.setVisibility(View.VISIBLE);
                Text_Line_05_Item.setVisibility(View.VISIBLE);
                Text_Line_06_Item.setVisibility(View.VISIBLE);
                Text_Line_07_Item.setVisibility(View.VISIBLE);
            }
        } catch (Exception e) {
            Log.e(TAG, "[Exception] UpdateVisibility()");
            e.printStackTrace();
        }
    }

    protected void UpdateScreen() {
        try {
//          LOG("[updateScreen] ===== START =====");

            updateVisibility();

            if (Global.DataInputScreen == DATAINPUTSCREEN.DETAIL_01) {
                strText_Title = "시스템 초기화";
                strText_Line_01_Item = "1] 설정값 초기화";
                strText_Line_02_Item = "2] 공장 초기화";
                strText_Line_03_Item = "3] 출입키 초기화";

                Text_Title.setText(strText_Title);
                Text_Line_01_Item.setText(strText_Line_01_Item);
                Text_Line_02_Item.setText(strText_Line_02_Item);
                Text_Line_03_Item.setText(strText_Line_03_Item);

                Text_Title.setTextColor(TextColor_Normal);
                Text_Line_01_Item.setTextColor(TextColor_Normal);
                Text_Line_02_Item.setTextColor(TextColor_Normal);
                Text_Line_03_Item.setTextColor(TextColor_Normal);
            } else if (Global.DataInputScreen == DATAINPUTSCREEN.DETAIL_02) {
                strText_Title = "경   고";
                strText_Line_04_Item = "- 설정값 초기화 -";
                strText_Line_05_Item = "로비폰 기본정보를 제외한";
                strText_Line_06_Item = "모든 설정정보를 초기화 합니다.";
                strText_Line_07_Item = "설정은 '경비실'버튼을 누르세요.";

                Text_Title.setText(strText_Title);
                Text_Line_04_Item.setText(strText_Line_04_Item);
                Text_Line_05_Item.setText(strText_Line_05_Item);
                Text_Line_06_Item.setText(strText_Line_06_Item);
                Text_Line_07_Item.setText(strText_Line_07_Item);

                Text_Title.setTextColor(TextColor_Red);
                Text_Line_04_Item.setTextColor(TextColor_Highlight);
                Text_Line_05_Item.setTextColor(TextColor_Highlight);
                Text_Line_06_Item.setTextColor(TextColor_Highlight);
                Text_Line_07_Item.setTextColor(TextColor_Highlight);
            } else if (Global.DataInputScreen == DATAINPUTSCREEN.DETAIL_03) {
                strText_Title = "경   고";
                strText_Line_04_Item = "- 공장 초기화 -";
                strText_Line_05_Item = "로비폰 모든 설정값을";
                strText_Line_06_Item = "공장출하시 상태로 되돌립니다.";
                strText_Line_07_Item = "설정은 '경비실'버튼을 누르세요.";

                Text_Title.setText(strText_Title);
                Text_Line_04_Item.setText(strText_Line_04_Item);
                Text_Line_05_Item.setText(strText_Line_05_Item);
                Text_Line_06_Item.setText(strText_Line_06_Item);
                Text_Line_07_Item.setText(strText_Line_07_Item);

                Text_Title.setTextColor(TextColor_Red);
                Text_Line_04_Item.setTextColor(TextColor_Highlight);
                Text_Line_05_Item.setTextColor(TextColor_Highlight);
                Text_Line_06_Item.setTextColor(TextColor_Highlight);
                Text_Line_07_Item.setTextColor(TextColor_Highlight);
            } else if (Global.DataInputScreen == DATAINPUTSCREEN.DETAIL_04) {
                strText_Title = "경   고";
                strText_Line_04_Item = "- 키정보 초기화 -";
                strText_Line_05_Item = "로비폰의 모든 출입키 및";
                strText_Line_06_Item = "카드정보를 삭제합니다.";
                strText_Line_07_Item = "설정은 '경비실'버튼을 누르세요.";

                Text_Title.setText(strText_Title);
                Text_Line_04_Item.setText(strText_Line_04_Item);
                Text_Line_05_Item.setText(strText_Line_05_Item);
                Text_Line_06_Item.setText(strText_Line_06_Item);
                Text_Line_07_Item.setText(strText_Line_07_Item);

                Text_Title.setTextColor(TextColor_Red);
                Text_Line_04_Item.setTextColor(TextColor_Highlight);
                Text_Line_05_Item.setTextColor(TextColor_Highlight);
                Text_Line_06_Item.setTextColor(TextColor_Highlight);
                Text_Line_07_Item.setTextColor(TextColor_Highlight);
            }
        } catch (Exception e) {
            Log.e(TAG, "[Exception] updateScreen()");
            e.printStackTrace();
        }
    }

    public POSITION getPosition(int nID) {
//        LOG("[getPosition] ===== START =====");
        POSITION position = new POSITION();
        position.SetPosition(0, 0, 480, 272);
        try {
            switch (nID) {
                case ID.SCREENS.ADMINSET_SETTING_RESETSYSTEM.ELEMENTS.IMAGES.BACKGROUND:
                    position.SetPosition(0, 0, 480, 272);
                    return position;

                case ID.SCREENS.ADMINSET_SETTING_RESETSYSTEM.ELEMENTS.TEXTS.TITLE:
                    position.SetPosition(0, 24, 480, 40);
                    return position;

                case ID.SCREENS.ADMINSET_SETTING_RESETSYSTEM.ELEMENTS.TEXTS.LINE_01_Item:
                    position.SetPosition(30, 84, 420, 40);
                    return position;

                case ID.SCREENS.ADMINSET_SETTING_RESETSYSTEM.ELEMENTS.TEXTS.LINE_02_Item:
                    position.SetPosition(30, 134, 420, 40);
                    return position;

                case ID.SCREENS.ADMINSET_SETTING_RESETSYSTEM.ELEMENTS.TEXTS.LINE_03_Item:
                    position.SetPosition(30, 184, 420, 40);
                    return position;

                case ID.SCREENS.ADMINSET_SETTING_RESETSYSTEM.ELEMENTS.TEXTS.LINE_04_Item:
                    position.SetPosition(0, 73, 480, 40);
                    return position;

                case ID.SCREENS.ADMINSET_SETTING_RESETSYSTEM.ELEMENTS.TEXTS.LINE_05_Item:
                    position.SetPosition(0, 122, 480, 40);
                    return position;

                case ID.SCREENS.ADMINSET_SETTING_RESETSYSTEM.ELEMENTS.TEXTS.LINE_06_Item:
                    position.SetPosition(0, 171, 480, 40);
                    return position;

                case ID.SCREENS.ADMINSET_SETTING_RESETSYSTEM.ELEMENTS.TEXTS.LINE_07_Item:
                    position.SetPosition(0, 220, 480, 40);
                    return position;

                default:
                    return position;
            }
        } catch (Exception e) {
            Log.e(TAG, "[Exception] getPosition(int nID)");
            e.printStackTrace();
            return position;
        }
    }

    private boolean setFactoryMode() {
        try {
            String DATABASE_LOCATION = "/sdcard/BESTIN/DATABASE";
            return deleteDirectory(DATABASE_LOCATION);
        } catch (Exception e) {
            Log.e(TAG, "[Exception] setFactoryMode()");
            e.printStackTrace();
            return false;
        }
    }

    private boolean deleteDirectory(String strPath) {
        try {
            LOG("[deleteDirectory] strPath = " + strPath);
            File mFile = new File(strPath);
            if (!mFile.exists()) {
                LOG_INFO("[deleteDirectory] Directory is not exist!! Path = " + strPath);
                return false;
            }
            if (!mFile.isDirectory()) {
                LOG_INFO("[deleteDirectory] Given path is not directory!! Path = " + strPath);
                return false;
            }

            File[] mFileList = new File(strPath).listFiles();
            if (1 > mFileList.length) {
                LOG_INFO("[deleteDirectory] There is no files!!");
                return false;
            }

            for (int i = 0; i < mFileList.length; i++) {
                LOG_INFO("[deleteDirectory] Filename to delete -> " + mFileList[i].getName());
                if (!mFileList[i].delete()) {
                    LOG_INFO("[deleteDirectory] Fail to delete a file!! -> " + mFileList[i].getName());
                    return false;
                }
            }
            LOG_INFO("[deleteDirectory] ===== OK ======");
            return true;
        } catch (Exception e) {
            Log.e(TAG, "[Exception] deleteDirectory(strPath, strExtention)");
            e.printStackTrace();
            return false;
        }
    }

    private boolean setSettingReset() {
        try {
            LOG("[setSettingReset] ===== START =====");
            Configure.initUserConfigValues();
            Configure.setDBConfigValues();
            Configure.getDBConfigValues();
            return true;
        } catch (Exception e) {
            Log.e(TAG, "[Exception] setSettingReset()");
            e.printStackTrace();
            return false;
        }
    }

    private boolean resetAccessKeyInfo() {
        try {
            // 출입카드 DB를 삭제한다.
            if (MainActivity.RFKeySTD_RESI_DBManager != null) {
                if (!MainActivity.RFKeySTD_RESI_DBManager.closeDatabase()) return false;
                if (!MainActivity.RFKeySTD_RESI_DBManager.deleteDBFile()) return false;
            }

            if (MainActivity.RFKeySTD_ADMINDONG_DBManager != null) {
                if (!MainActivity.RFKeySTD_ADMINDONG_DBManager.closeDatabase()) return false;
                if (!MainActivity.RFKeySTD_ADMINDONG_DBManager.deleteDBFile()) return false;
            }

            if (MainActivity.RFKeySTD_ADMINENTIRE_DBManager != null) {
                if (!MainActivity.RFKeySTD_ADMINENTIRE_DBManager.closeDatabase()) return false;
                if (!MainActivity.RFKeySTD_ADMINENTIRE_DBManager.deleteDBFile()) return false;
            }

            if (MainActivity.RFKeyDBManager != null) {
                if (!MainActivity.RFKeyDBManager.closeDatabase()) return false;
                if (!MainActivity.RFKeyDBManager.deleteDBFile()) return false;
            }
            return true;
        } catch (Exception e) {
            Log.e(TAG, "[Exception] resetAccessKeyInfo()");
            e.printStackTrace();
            return false;
        }
    }


}