فهرست منبع

[WallPadConfig]
1. App Ver. 갱신
- 2022.05.17.01
2. 모바일 기기 정보 동기화 작업중
- 필요 파일 추가

jslee(madeinlab) 2 سال پیش
والد
کامیت
259ad8dce1

+ 1 - 1
WallPadConfig/src/main/AndroidManifest.xml

@@ -1,7 +1,7 @@
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="kr.co.icontrols.wallpadconfig"
     android:versionCode="01"
-    android:versionName="2022.05.10.01">
+    android:versionName="2022.05.17.01">
 
     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
     <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

+ 115 - 12
WallPadConfig/src/main/java/kr/co/icontrols/wallpadconfig/MainActivity.java

@@ -27,6 +27,7 @@ import android.widget.ExpandableListView.OnGroupExpandListener;
 import android.widget.RelativeLayout;
 
 import com.artncore.WallPadDataMgr.WallpadDeviceSet;
+import com.artncore.WallPadDataMgr.WallpadMobileDeviceData;
 import com.artncore.WallPadDataMgr.WallpadStatusData;
 import com.artncore.WallPadDataMgr.wallpaddbmgr;
 import com.artncore.commons.API_Menu;
@@ -34,6 +35,7 @@ import com.artncore.commons.API_Menu.MenuListDataClass;
 import com.artncore.commons.API_Menu.MenuListDataClass.ChildIDMapping;
 import com.artncore.commons.define;
 import com.artncore.wallpadapi.WallPadAPI;
+import com.google.gson.Gson;
 import com.util.LogUtil;
 
 import org.json.JSONArray;
@@ -48,6 +50,7 @@ import java.net.Socket;
 import java.sql.Timestamp;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
+import java.util.List;
 
 import kr.co.icontrols.ReliefCall.ReliefCallInterface;
 import kr.co.icontrols.wallpadconfig.declare.Common;
@@ -113,7 +116,7 @@ public class MainActivity extends WpadActivity
     // Top Menu
     private WpadImageView TopBackground;
     private WpadTextView TopTitle;
-    private WpadImageView TopHomeBtn,TopBackBtn, TopMenuBtn, TopSetBtn;
+    private WpadImageView TopHomeBtn,TopBackBtn, TopMenuBtn, TopSetBtn, TopSyncBtn;
     private WpadImageView TopManualBtn;
     private WpadImageView BackBtn_InRoom;
 
@@ -279,6 +282,10 @@ public class MainActivity extends WpadActivity
         ViewRegistration(TopLayout, TopSetBtn, 1019, 0);
         setTopSetBtnVisible(false);
 
+        TopSyncBtn = new WpadImageView(this, TOUCH_KIND.BUTTON, 110, 110, R.drawable.topbar_icon_sync_normal, R.drawable.topbar_icon_sync_pressed, ID.main.button.SYNK);
+        ViewRegistration(TopLayout, TopSyncBtn, 1019, 0);
+        setTopSyncBtnVisible(false);
+
         TopManualBtn = new WpadImageView(this, TOUCH_KIND.BUTTON, 110, 110, R.drawable.topbar_icon_manual_normal, R.drawable.topbar_icon_manual_pressed, ID.main.button.MENUAL);
         setManualBtnVisible(getManualUse(), 1019);
 
@@ -647,6 +654,31 @@ public class MainActivity extends WpadActivity
         return true;
     }
 
+    /**
+     * TOP 모바일 동기화 버튼 활성화 & 비활성화
+     *
+     * @param bEnable - true : 활성화,  false : 비활성화
+     * @return (boolean) true : 성공,  false : 실패
+     */
+    public boolean setTopSyncBtnVisible(boolean bEnable) {
+        if (bEnable) {
+            if (TopSyncBtn.getVisibility() != View.VISIBLE) TopSyncBtn.setVisibility(View.VISIBLE);
+            TopSyncBtn.bringToFront();
+
+            if (TopSyncBtn.getVisibility() == View.VISIBLE) {
+                WpadUtil.ViewMove(TopManualBtn, 893, 0);
+            }
+        } else {
+            if (TopSyncBtn.getVisibility() != View.INVISIBLE)
+                TopSyncBtn.setVisibility(View.INVISIBLE);
+
+            if (TopSyncBtn.getVisibility() == View.INVISIBLE) {
+                WpadUtil.ViewMove(TopManualBtn, 1019, 0);
+            }
+        }
+        return true;
+    }
+
     /* ================================================================================================
     * [Manual Activity] Section
     ================================================================================================ */
@@ -950,6 +982,12 @@ public class MainActivity extends WpadActivity
                 if (mCurrentScreenId == API_Menu.SubMenuConfig.MobileDeviceReg)
                     StartPopup(ID.screen.PopupRemoteCallUserSetting);
             }
+            else if (TargetId == ID.main.button.SYNK)
+            {
+                Sound().Play(SND.effect.TOUCH_LATCHED);
+                if (mCurrentScreenId == API_Menu.SubMenuConfig.MobileDeviceReg)
+                    StartPopup(ID.screen.PopupMobileSync);
+            }
             else if(TargetId == ID.main.button.BACK_INROOM)
             {
                 DebugLogOutput("onTouchEvent [BACK_INROOM] BUTTON !!!");
@@ -1145,6 +1183,26 @@ public class MainActivity extends WpadActivity
                 Log.e(TAG, "[Exception Error] [onActivityResult] - data.getExtras().get");
             }
         }
+        else if(resultCode == ID.popupMobileSync.ResultCode.OK)
+        {
+            try
+            {
+                //모바일 동기화 작업을 여기서 해준다.
+                WallpadMobileDeviceData wallpadMobileDeviceData = new WallpadMobileDeviceData(mContext);
+                List<WallpadMobileDeviceData.MobileDeviceClass> DataList = wallpadMobileDeviceData.GetMobileDeviceData();
+                wallpadMobileDeviceData.closeDB();
+                for(int i=1; i<4; i++) {
+                    requestMultiControl(syncHandler, Common.JSON.MENU.MOBILE, JSON.REASON.MobileSync, i, DataList);
+                }
+            }
+            catch (RuntimeException re) {
+                LogUtil.errorLogInfo("", TAG, re);
+            }
+            catch (Exception  e)
+            {
+                Log.e(TAG, "[Exception Error] [onActivityResult] - data.getExtras().get");
+            }
+        }
     }
 
 
@@ -1190,6 +1248,7 @@ public class MainActivity extends WpadActivity
         mCurrentScreenId = nScreenId;
         setTopBackBtnVisible(false);
         setTopSetBtnVisible(false);
+        setTopSyncBtnVisible(false);
 
         // 2. 새로운 Layout 표시
         try
@@ -1277,7 +1336,7 @@ public class MainActivity extends WpadActivity
                 case API_Menu.SubMenuConfig.MobileDeviceReg:
                     SetTitleText(API_Menu.SubMenuConfig.Name_MobileDeviceReg);
                     configMobileDeviceAddScreen = new ConfigMobileDeviceAddScreen(this, ScreenLayout, mWallPadAPI, OPERATION_MODE);
-                    // setTopBackBtnVisible(true);
+                    setTopSyncBtnVisible(true);
                     super.setCurrentScreen(configMobileDeviceAddScreen);
                     break;
 
@@ -1959,22 +2018,30 @@ public class MainActivity extends WpadActivity
     class ClientThread extends Thread {
         private Handler handler;
         private String  value1;
-        private String  value2;
+        private String  valueID;
         private int menu, reason, state, position;
         private int roomNumber;
 
-        public ClientThread(Handler handler, int menu, int reason, int position, String value1, String value2) {
+        List<WallpadMobileDeviceData.MobileDeviceClass> dataList;
+
+        public ClientThread(Handler handler, int menu, int reason, int position, String value1, String valueID) {
             this.handler = handler;
             this.menu = menu;
             this.reason = reason;
             this.position = position;
             this.value1 = value1;
-            this.value2 = value2;
+            this.valueID = valueID;
+        }
+
+        public ClientThread(Handler handler, int menu, int reason, int position, List<WallpadMobileDeviceData.MobileDeviceClass> dataList) {
+            this.handler = handler;
+            this.menu = menu;
+            this.reason = reason;
+            this.position = position;
+            this.dataList = dataList;
         }
 
         public void run() {
-            //String host = "10.1.1.1";
-            //String host = "10.1.1." + position;
             String host = "10.1."+position+".1";
             int port = 9998;
             String json = "";
@@ -1991,13 +2058,19 @@ public class MainActivity extends WpadActivity
                 if (menu == JSON.MENU.PASSWORD) {
                     jsonObject.accumulate("number", value1);
                 }
-                //모바일 기기 등록
+                //모바일 기기 등록/삭제
                 else if (menu == JSON.MENU.MOBILE) {
                     if(reason == JSON.REASON.MobileRegister) {
                         jsonObject.accumulate("name", value1);
-                        jsonObject.accumulate("id", value2);
+                        jsonObject.accumulate("id", valueID);
                     } else if(reason == JSON.REASON.MobileDelete) {
-                        jsonObject.accumulate("id", value2);
+                        jsonObject.accumulate("id", valueID);
+                    } else if(reason == JSON.REASON.MobileSync) {
+                        JSONArray jArray = new JSONArray();
+                        for (int i=0; i<dataList.size(); i++) {
+                            jArray.put(dataList.get(i).Name + "|" + dataList.get(i).Uid);
+                        }
+                        jsonObject.accumulate("arrayData", jArray);
                     }
                 }
             } catch (JSONException e) {
@@ -2056,9 +2129,39 @@ public class MainActivity extends WpadActivity
         }
     }
 
-    public void requestMultiControl(Handler handler, int menu, int reason, int position, String value1, String value2) {
+    @SuppressLint("HandlerLeak")
+    final Handler syncHandler = new Handler() {
+        Gson gson = new Gson();
+
+        @Override
+        public void handleMessage(Message msg) {
+            switch (msg.what) {
+                case 1000:
+                    try {
+                        Bundle bundle = msg.getData();
+                        String response = bundle.getString("response");
+                        Log.d("syncHandler", "response=" + response);
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                    }
+                    break;
+                default:
+                    break;
+            }
+        }
+    };
+
+
+    public void requestMultiControl(Handler handler, int menu, int reason, int position, String value1, String valueID) {
+        if(position!=ho) {
+            ClientThread thread = new ClientThread(handler, menu, reason, position, value1, valueID);
+            thread.start();
+        }
+    }
+
+    public void requestMultiControl(Handler handler, int menu, int reason, int position, List<WallpadMobileDeviceData.MobileDeviceClass> dataList) {
         if(position!=ho) {
-            ClientThread thread = new ClientThread(handler, menu, reason, position, value1, value2);
+            ClientThread thread = new ClientThread(handler, menu, reason, position, dataList);
             thread.start();
         }
     }

+ 10 - 0
WallPadConfig/src/main/java/kr/co/icontrols/wallpadconfig/PopupActivity.java

@@ -32,6 +32,7 @@ import kr.co.icontrols.wallpadconfig.screen.PopupAsCall;
 import kr.co.icontrols.wallpadconfig.screen.PopupMobileDeviceAdd;
 import kr.co.icontrols.wallpadconfig.screen.PopupMobileDeviceDel;
 import kr.co.icontrols.wallpadconfig.screen.PopupMobileDeviceInit;
+import kr.co.icontrols.wallpadconfig.screen.PopupMobileSync;
 import kr.co.icontrols.wallpadconfig.screen.PopupNameSet;
 //import kr.co.icontrols.wallpadconfig.screen.PopupNoiseLog;
 import kr.co.icontrols.wallpadconfig.screen.PopupNoticeReboot;
@@ -120,6 +121,8 @@ public class PopupActivity extends WpadActivity
     private PopupWIFIConnect popupWIFIconnect;
 
     private PopupRemoteCtrlSmartlight popupRemoteCtrlSmartlight;
+    private PopupMobileSync popupMobileSync;
+
 
     public WallpadStatusData GetDBObj()
     {
@@ -601,6 +604,13 @@ public class PopupActivity extends WpadActivity
                     FinishTime = Common.FINISH_TIME_POPUP_NORMAL_SEC;
                     break;
 
+                case ID.screen.PopupMobileSync:
+                    popupMobileSync = new PopupMobileSync(mContext, AllLayout);
+                    super.setCurrentScreen(popupMobileSync);
+                    Style = Common.POPUP_STYLE_NOMAL;
+                    FinishTime = Common.FINISH_TIME_POPUP_NORMAL_SEC;
+                    break;
+
                 case ID.screen.PopupRemoteCtrlSmartlight:
                     popupRemoteCtrlSmartlight = new PopupRemoteCtrlSmartlight(mContext, AllLayout, wpapi, OPERATION_MODE);
                     super.setCurrentScreen(popupRemoteCtrlSmartlight);

+ 4 - 1
WallPadConfig/src/main/java/kr/co/icontrols/wallpadconfig/declare/Common.java

@@ -234,7 +234,8 @@ public final class Common
             public final static int GAS      	= MENU_BASE + 6;
             public final static int COOKTOP  	= MENU_BASE + 7;
             public final static int PASSWORD  	= MENU_BASE + 8;
-            public final static int MOBILE 	= MENU_BASE + 9;
+            public final static int MOBILE 	    = MENU_BASE + 9;
+            public final static int DEVICE_INFO 	    = MENU_BASE + 10;
         }
 
         public static final class REASON
@@ -244,6 +245,8 @@ public final class Common
             public final static int PassWordChange      = 2;
             public final static int MobileRegister      = 3;
             public final static int MobileDelete        = 4;
+            public final static int DeviceInfo          = 5;
+            public final static int MobileSync          = 6;
         }
 
         public static final class KIND

+ 40 - 1
WallPadConfig/src/main/java/kr/co/icontrols/wallpadconfig/declare/ID.java

@@ -80,7 +80,8 @@ public final class ID
 
         public final static int PopupWIFIConnect                                = 40000;     // 방문객원격통화 사용자관리 팝업
 
-        public final static int PopupRemoteCtrlSmartlight                                = 41000;     // 원격제어 스마트 조명 유의사항 알림 팝업
+        public final static int PopupRemoteCtrlSmartlight                       = 41000;     // 원격제어 스마트 조명 유의사항 알림 팝업
+        public final static int PopupMobileSync                                 = 42000;     // 모바일 기기 동기화 확인 팝업
     }
 
     /* ==========================================================================
@@ -115,6 +116,7 @@ public final class ID
             public final static int MENUAL      = BASE + 204;
             public final static int BACK_INROOM = BASE + 205;
             public final static int SETTING     = BASE + 206;
+            public final static int SYNK        = BASE + 207;
 
         }
         public static final class text
@@ -1537,6 +1539,43 @@ public final class ID
         }
     }
 
+    /* ==========================================================================
+     * PopupMobileSync
+     * ========================================================================== */
+    public static final class popupMobileSync
+    {
+        final static int BASE = screen.PopupMobileSync;
+
+        public static final class layout
+        {
+        }
+        public static final class image
+        {
+            public final static int BACKGROUND        = BASE + 100;
+            public final static int TITLE             = BASE + 101;
+            public final static int IMAGE             = BASE + 102;
+
+            public final static int STATUS            = BASE + 106;
+        }
+        public static final class button
+        {
+            public final static int OK                = BASE + 200;
+            public final static int CANCEL            = BASE + 201;
+            public final static int CLOSE             = BASE + 202;
+        }
+        public static final class text
+        {
+            public final static int TITLE             = BASE + 300;
+            public final static int TEXT1             = BASE + 301;
+            public final static int TEXT2             = BASE + 302;
+        }
+        public static final class ResultCode
+        {
+            public final static int OK                = BASE + 400;
+            public final static int CANCEL            = BASE + 401;
+        }
+    }
+
 
     /* ==========================================================================
      * InRoomSensorID