From b75795836a851a13e54cc4efb597262fb448217c Mon Sep 17 00:00:00 2001
From: mac <user@users-MacBook-Pro.local>
Date: 星期三, 08 五月 2024 15:22:01 +0800
Subject: [PATCH] 2024年05月08日15:21:54

---
 app/src/main/java/com/hdl/photovoltaic/uni/HDLUniMP.java                         |   21 
 app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseSearchActivity.java  |   30 +-
 app/src/main/AndroidManifest.xml                                                 |    3 
 app/src/main/java/com/hdl/photovoltaic/ui/powerstation/DeviceSearchActivity.java |  393 ++++++++++++++++++++++++++++++
 app/src/main/res/layout/activity_device_search.xml                               |  168 ++++++++++++
 app/src/main/java/com/hdl/photovoltaic/other/HdlCommonLogic.java                 |   12 
 app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java                    |  103 +++++++
 app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseListFragment.java    |    9 
 8 files changed, 709 insertions(+), 30 deletions(-)

diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 7d121ee..f6c3993 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -77,6 +77,9 @@
         android:supportsRtl="true"
         android:theme="@style/Theme.PhotovoltaicDebug">
         <activity
+            android:name=".ui.powerstation.DeviceSearchActivity"
+            android:exported="false" />
+        <activity
             android:name=".ui.powerstation.HouseSearchActivity"
             android:exported="false" />
         <activity
diff --git a/app/src/main/java/com/hdl/photovoltaic/other/HdlCommonLogic.java b/app/src/main/java/com/hdl/photovoltaic/other/HdlCommonLogic.java
index 369ef0d..c866afe 100644
--- a/app/src/main/java/com/hdl/photovoltaic/other/HdlCommonLogic.java
+++ b/app/src/main/java/com/hdl/photovoltaic/other/HdlCommonLogic.java
@@ -2,17 +2,27 @@
 
 import android.content.Context;
 import android.graphics.Bitmap;
+import android.os.SystemClock;
 import android.text.TextUtils;
 import android.view.View;
 import android.widget.ImageView;
 import android.widget.TextView;
 
+import com.google.gson.JsonObject;
 import com.google.zxing.BarcodeFormat;
 import com.google.zxing.EncodeHintType;
 import com.google.zxing.common.BitMatrix;
 import com.google.zxing.qrcode.QRCodeWriter;
+import com.hdl.linkpm.sdk.user.HDLLinkPMUser;
+import com.hdl.photovoltaic.config.UserConfigManage;
 import com.hdl.photovoltaic.utils.GlideUtils;
 
+import org.json.JSONObject;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.InetSocketAddress;
+import java.net.Socket;
 import java.util.Hashtable;
 
 /**
@@ -122,4 +132,6 @@
         }
     }
 
+
+
 }
diff --git a/app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java b/app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java
index cb6edc7..1975031 100644
--- a/app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java
+++ b/app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java
@@ -10,6 +10,7 @@
 import android.location.Location;
 import android.location.LocationManager;
 import android.os.IBinder;
+import android.provider.Settings;
 import android.text.TextUtils;
 
 import androidx.core.app.ActivityCompat;
@@ -68,9 +69,13 @@
 
 
 import java.io.File;
+import java.io.InputStream;
+import java.io.OutputStream;
 import java.lang.reflect.Type;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
+import java.net.InetSocketAddress;
+import java.net.Socket;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Objects;
@@ -278,18 +283,28 @@
                     }
                     break;
                     //褰撳墠wifi璇︽儏
-                    case HDLUniMP.UNI_EVENT_REPLY_WIFI_INFO: {
+                    case HDLUniMP.UNI_EVENT_REPLY_WIFI_PHONE_INFO: {
                         if (callback != null) {
                             uniCallbackData(mode_type, wifiUtils.getCurrentConnectWifiInfo(), callback);
                         }
                     }
                     break;
-                    //wifi杩炴帴
-                    case HDLUniMP.UNI_EVENT_REPLY_WIFI_CONNECT: {
+                    //閰嶇疆WiFi淇℃伅缁欓�嗗彉鍣�
+                    case HDLUniMP.UNI_EVENT_REPLY_WIFI_SET_DEVICE: {
+                        String mac = getKeyValue("mac", getKeyValue("data", data));//
+                        String wif_type = getKeyValue("wif_type", getKeyValue("data", data));//1锛氱儹鐐�,2锛氭棤绾縲ifi,3锛氫互澶綉
+                        String ssid = getKeyValue("ssid", getKeyValue("data", data));//
+                        String password = getKeyValue("password", getKeyValue("data", data));//
+                        startTcpThreadSendAccountAndPassword(mode_type, ssid, password, callback);
 
                     }
                     break;
-
+                    //鎵撳紑鎵嬫満Wifi璁剧疆鐣岄潰
+                    case HDLUniMP.UNI_EVENT_REPLY_OPEN_WIFI_SETTINGS: {
+                        Intent intent = new Intent(Settings.ACTION_WIFI_SETTINGS);
+                        HDLApp.getInstance().startActivity(intent);
+                    }
+                    break;
                 }
             } else if (HDLUniMP.UNI_EVENT_REPLY_OTA_MODEL.equals(topic)) {
                 //OTA鍗囩骇妯″潡
@@ -1629,6 +1644,84 @@
 
 
     /**
+     * 鍙戦�佽处鍙峰拰瀵嗙爜缁欓�嗗彉鍣�
+     *
+     * @param ssid     璐﹀彿
+     * @param password 瀵嗙爜
+     * @param callback uni鍥炶皟
+     */
+    public void startTcpThreadSendAccountAndPassword(String type, String ssid, String password, DCUniMPJSCallback callback) {
+        new Thread(
+                () -> {
+                    Socket socket = null;
+                    OutputStream outputStreamTcp = null;
+                    InputStream inputStreamTcp = null;
+                    try {
+                        socket = new Socket();
+                        socket.setTcpNoDelay(true);
+                        socket.setSoTimeout(10 * 1000);//10绉掕秴鏃�
+                        socket.connect(new InetSocketAddress("192.168.8.1", 8586));
+                        socket.setKeepAlive(true);
+//                        logMessage("tcp杩炴帴鐘舵�佹垚鍔�", 0, "");
+                        outputStreamTcp = socket.getOutputStream();
+                        JsonObject jsonObject = new JsonObject();
+                        jsonObject.addProperty("id", "102030");
+                        jsonObject.addProperty("ssid", ssid);
+                        jsonObject.addProperty("password", password);
+                        jsonObject.addProperty("server_addr", HDLLinkPMUser.getInstance().getHomeRegionUrl());
+                        jsonObject.addProperty("homeId", UserConfigManage.getInstance().getHomeId());
+                        String sendData = "Topic:/user/id/custom/wifi/set\r\n";
+                        sendData += "Length:" + jsonObject.toString().getBytes().length + "\r\n\r\n";
+                        sendData += jsonObject.toString();
+                        outputStreamTcp.write(sendData.getBytes());
+                        outputStreamTcp.flush();
+                        Thread.sleep(200);
+                        inputStreamTcp = socket.getInputStream();
+                        byte[] bytes = new byte[1204 * 2];
+                        int len = inputStreamTcp.read(bytes);
+                        if (len != -1) {
+                            String str = new String(bytes, 0, bytes.length);
+                            String[] strings = str.split("\r\n\r\n");
+                            String[] topicAndLength = strings[0].split("\r\n");
+                            String topic = topicAndLength[0];
+                            JSONObject json = new JSONObject(strings[1]);
+//                            logMessage("tcp鍥炲鏁版嵁", 0, strings[0] + "\r\n" + json.toString());
+                            if (topic.endsWith("wifi/set_reply") || topic.endsWith("wifi/result/notify")) {
+                                if (callback != null) {
+                                    uniCallbackData(type, json, callback);
+                                }
+                                if (json.has("mac")) { //鍥炲鎴愬姛鍐嶆嬁璁惧mac
+//                                    this.device_mac = json.getString("mac");
+//                                    this.isSucceedTcp = true;//琛ㄧず鎴愬姛
+                                }
+                            }
+                        }
+
+                    } catch (Exception ignored) {
+                    } finally {
+                        try {
+                            if (outputStreamTcp != null) {
+                                outputStreamTcp.close();
+                                outputStreamTcp = null;
+                            }
+                            if (inputStreamTcp != null) {
+                                inputStreamTcp.close();
+                                inputStreamTcp = null;
+                            }
+                            if (socket != null) {
+                                socket.close();
+                                socket = null;
+                            }
+
+                        } catch (Exception ignored) {
+                        }
+                    }
+                }
+        ).start();
+    }
+
+
+    /**
      * 鍙戦�乵odbus鍗忚鏁版嵁
      * 閫忎紶鍗忚
      * 涓嬪彂涓婚锛�/user/${gw_id}/custom/native/${driver}/down;
@@ -1731,7 +1824,7 @@
         HDLUniMP.UniCallBackBaseBean uniCallBackBaseBean = new HDLUniMP.UniCallBackBaseBean();
         try {
             uniCallBackBaseBean.setCode(code);
-            uniCallBackBaseBean.setMes(msg);
+            uniCallBackBaseBean.setMsg(msg);
             uniCallBackBaseBean.setData(obj);
             if (callback != null) {
                 callback.invoke(getJSONObject(uniCallBackBaseBean));
diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/powerstation/DeviceSearchActivity.java b/app/src/main/java/com/hdl/photovoltaic/ui/powerstation/DeviceSearchActivity.java
new file mode 100644
index 0000000..564b02a
--- /dev/null
+++ b/app/src/main/java/com/hdl/photovoltaic/ui/powerstation/DeviceSearchActivity.java
@@ -0,0 +1,393 @@
+package com.hdl.photovoltaic.ui.powerstation;
+
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
+
+import android.os.Bundle;
+import android.text.Editable;
+import android.text.TextUtils;
+import android.text.TextWatcher;
+import android.view.View;
+
+import com.google.gson.Gson;
+import com.google.gson.reflect.TypeToken;
+import com.hdl.linkpm.sdk.core.exception.HDLException;
+import com.hdl.photovoltaic.R;
+import com.hdl.photovoltaic.base.CustomBaseActivity;
+import com.hdl.photovoltaic.bean.PageNumberObject;
+import com.hdl.photovoltaic.databinding.ActivityDeviceSearchBinding;
+import com.hdl.photovoltaic.enums.ShowErrorMode;
+import com.hdl.photovoltaic.listener.CloudCallBeak;
+import com.hdl.photovoltaic.other.HdlDeviceLogic;
+import com.hdl.photovoltaic.other.HdlFileLogic;
+import com.hdl.photovoltaic.other.HdlLogLogic;
+import com.hdl.photovoltaic.other.HdlThreadLogic;
+import com.hdl.photovoltaic.ui.adapter.DeviceInfoAdapter;
+import com.hdl.photovoltaic.ui.adapter.SearchDeviceAdapter;
+import com.hdl.photovoltaic.ui.adapter.SearchHistoryAdapter;
+import com.hdl.photovoltaic.ui.bean.DeviceBean;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * 璁惧鎼滅储鐣岄潰
+ */
+public class DeviceSearchActivity extends CustomBaseActivity {
+
+
+    private ActivityDeviceSearchBinding viewBinding;
+
+    SearchDeviceAdapter searchDeviceAdapter;//璁惧閫傞厤鍣�
+    SearchHistoryAdapter searchHistoryAdapter;//鍘嗗彶璁板綍閫傞厤鍣�
+
+    private List<DeviceBean> deviceList = new ArrayList<>();
+
+    private int currentHouseListPage = 0; // 褰撳墠鐢电珯鍒楄〃椤电爜
+    private int currentHouseListTotal = 0; // 鐢电珯鍒楄〃鎬婚〉鐮�
+    private boolean isHouseLoadingMore = false; // 鏍囪鐢电珯鍒楄〃姝e湪鍔犺浇鏇村鏁版嵁
+
+    private String currSearchText;
+
+    List<String> searchHistoryTitleList = new ArrayList<>();
+
+    @Override
+    public Object getContentView() {
+        viewBinding = ActivityDeviceSearchBinding.inflate(getLayoutInflater());
+        return viewBinding.getRoot();
+    }
+
+    @Override
+    public void onBindView(Bundle savedInstanceState) {
+        setStatusBarTranslucent();
+        //鍘嗗彶璁板綍鏂囦欢澶瑰垱寤�
+        HdlFileLogic.getInstance().createFileDir(HdlFileLogic.getInstance().getCurrentUserRootPath());
+        //鍒濆鍖栨暟鎹�
+        initData();
+        //鍒濆鍖�
+        initView();
+        //鍒濆鍖栫晫闈㈢洃鍚櫒
+        initEvent();
+    }
+
+    private void initData() {
+        try {
+            String json = HdlFileLogic.getInstance().readFile(getHistoryFileNamePath());
+            if (TextUtils.isEmpty(json)) {
+                return;
+            }
+            searchHistoryTitleList = new Gson().fromJson(json, new TypeToken<List<String>>() {
+            }.getType());
+        } catch (Exception ignored) {
+        }
+    }
+
+
+    private void initEvent() {
+
+        //鍚庨��
+        viewBinding.backRl.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                finish();
+            }
+        });
+        viewBinding.powerStationSearchEt.addTextChangedListener(textWatcher);
+
+
+        //鎼滅储
+        viewBinding.powerStationSearchTv.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                //鎼滅储鍏抽敭瀛�
+                currSearchText = viewBinding.powerStationSearchEt.getText().toString().replace(" ", "");
+                if (TextUtils.isEmpty(currSearchText)) {
+                    HdlThreadLogic.toast(_mActivity, R.string.search_content_null);
+                    return;
+                }
+                viewBinding.historyListParent.setVisibility(View.GONE);
+                viewBinding.listParent.setVisibility(View.VISIBLE);
+                addSearchTextToList();
+                loadNextPageHouseList(true, 1, true);
+            }
+        });
+
+
+        //涓嬫媺绠ご棰滆壊
+        viewBinding.listSrl.setColorSchemeResources(R.color.text_FF245EC3);
+        //涓嬫媺璇诲彇
+        viewBinding.listSrl.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
+            @Override
+            public void onRefresh() {
+                viewBinding.listSrl.setRefreshing(false);
+                loadNextPageHouseList(true, 1, true);
+            }
+        });
+        //涓婃媺璇诲彇
+        viewBinding.listRcv.addOnScrollListener(new RecyclerView.OnScrollListener() {
+            @Override
+            public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
+                LinearLayoutManager layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
+                if (layoutManager == null) {
+                    return;
+                }
+                int visibleItemCount = layoutManager.getChildCount();
+                int totalItemCount = layoutManager.getItemCount();
+                int firstVisibleItemPosition = layoutManager.findFirstVisibleItemPosition();
+                if (visibleItemCount > 0 && visibleItemCount + firstVisibleItemPosition == totalItemCount) {
+                    if (!isHouseLoadingMore) {
+                        // 婊戝姩鍒颁簡搴曢儴锛屾墽琛岀浉搴旂殑鎿嶄綔
+                        HdlLogLogic.print("--->婊戝姩鍒颁簡搴曢儴");
+                        loadNextPageHouseList(false, ++currentHouseListPage, false);
+                    }
+                }
+            }
+        });
+        //娓呴櫎
+        viewBinding.powerStationClearIv.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                currSearchText = "";
+                viewBinding.powerStationSearchEt.setText("");
+                viewBinding.historyListParent.setVisibility(View.VISIBLE);
+                viewBinding.listParent.setVisibility(View.GONE);
+                searchHistoryAdapter.setList(searchHistoryTitleList);
+                clearData();
+            }
+        });
+        //鍒犻櫎
+        viewBinding.powerStationDelIv.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                searchHistoryTitleList = new ArrayList<>();
+                searchHistoryAdapter.setList(searchHistoryTitleList);
+                HdlFileLogic.getInstance().deleteFile(getHistoryFileNamePath());
+            }
+        });
+        //鍘嗗彶璁板綍鐐瑰嚮浜嬩欢
+        searchHistoryAdapter.setOnclickListener(new SearchHistoryAdapter.OnClickListener() {
+            @Override
+            public void onClick(int position, String title) {
+                viewBinding.powerStationSearchEt.setText(title);
+            }
+        });
+        //鐢电珯鐐瑰嚮鏄簨浠�
+        searchDeviceAdapter.setOnclickListener(new DeviceInfoAdapter.OnClickListener() {
+            @Override
+            public void onClick(int position, DeviceBean deviceBean) {
+
+            }
+        });
+
+    }
+
+    private void initView() {
+        viewBinding.historyListParent.setVisibility(View.VISIBLE);
+        viewBinding.listParent.setVisibility(View.GONE);
+        viewBinding.powerStationClearIv.setVisibility(View.GONE);
+        //鍒濆鍖栧巻鍙茶褰曢�傞厤鍣�
+        searchHistoryAdapter = new SearchHistoryAdapter(_mActivity);
+        viewBinding.historyListRcv.setLayoutManager(new LinearLayoutManager(_mActivity));
+        viewBinding.historyListRcv.setAdapter(searchHistoryAdapter);
+        searchHistoryAdapter.setList(searchHistoryTitleList);
+        //鍒濆鍖栫數绔欓�傞厤鍣�
+        searchDeviceAdapter = new SearchDeviceAdapter(_mActivity);
+        viewBinding.listRcv.setLayoutManager(new LinearLayoutManager(_mActivity));
+        viewBinding.listRcv.setAdapter(searchDeviceAdapter);
+    }
+
+
+    /**
+     * 杈撳叆鐢电珯鍚嶇О杩涜杩囨护
+     */
+    private final TextWatcher textWatcher = new TextWatcher() {
+        @Override
+        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+
+        }
+
+        @Override
+        public void onTextChanged(CharSequence s, int start, int before, int count) {
+        }
+
+        @Override
+        public void afterTextChanged(Editable s) {
+            String et = viewBinding.powerStationSearchEt.getText().toString().replace(" ", "");
+            if (TextUtils.isEmpty(et)) {
+                viewBinding.powerStationClearIv.setVisibility(View.GONE);
+            } else {
+                viewBinding.powerStationClearIv.setVisibility(View.VISIBLE);
+            }
+            viewBinding.powerStationSearchEt.setSelection(viewBinding.powerStationSearchEt.length());
+
+        }
+    };
+
+    /**
+     * 鐗╃悊鎸夐敭杩斿洖浜嬩欢
+     */
+    @Override
+    public void onBackPressed() {
+        super.onBackPressed();
+    }
+
+    @Override
+    protected void onDestroy() {
+        viewBinding.powerStationSearchEt.removeTextChangedListener(textWatcher);
+        if (searchHistoryTitleList.size() > 0) {
+            HdlFileLogic.getInstance().deleteFile(getHistoryFileNamePath());
+            HdlFileLogic.getInstance().appendFile(getHistoryFileNamePath(), new Gson().toJson(searchHistoryTitleList));
+        }
+        super.onDestroy();
+    }
+
+    /**
+     * 鍒锋柊UI锛堣澶囷級
+     *
+     * @param isRefreshing 琛ㄧず鏄笅鎷夊埛鏂扮殑
+     */
+    private void loadNextPageHouseList(boolean isRefreshing, long pageNo, boolean isClear) {
+
+        //鎼滅储鍏抽敭瀛�
+        if (TextUtils.isEmpty(currSearchText)) {
+            return;
+        }
+
+        if (isClear) {
+            clearData();
+        }
+        //绗竴椤佃鍙栨暟鎹己鍒惰鍙�
+        if (pageNo > 1 && currentHouseListPage > currentHouseListTotal) {
+            --currentHouseListPage;
+            //褰撳墠椤典笉鑳藉ぇ浜庢�婚〉鏁�
+            return;
+        }
+        isHouseLoadingMore = true;//鏍囪璇诲彇鐘舵��
+        if (isRefreshing) {
+            showLoading();
+        }
+
+        //鑾峰彇浜戠涓婅澶囧垪琛�
+        HdlDeviceLogic.getInstance().getPowerStationDeviceList(currSearchText, pageNo, 20, new CloudCallBeak<PageNumberObject<DeviceBean>>() {
+            @Override
+            public void onSuccess(PageNumberObject<DeviceBean> deviceClass) {
+                HdlThreadLogic.runMainThread(new Runnable() {
+                    @Override
+                    public void run() {
+                        if (isRefreshing) {
+                            hideLoading();
+                        }
+                        isHouseLoadingMore = false;
+                        if (deviceClass != null) {
+                            currentHouseListTotal = (int) deviceClass.getTotalPage();
+                            currentHouseListPage = (int) deviceClass.getPageNo();
+                            //鏇存柊缂撳瓨
+                            setDeviceList(deviceClass.getList());
+                            if (searchDeviceAdapter != null) {
+                                initData();
+                                //鏇存柊UI
+                                searchDeviceAdapter.setList(deviceList);
+                            }
+                        }
+                    }
+                }, _mActivity, ShowErrorMode.YES);
+
+            }
+
+            @Override
+            public void onFailure(HDLException e) {
+                HdlThreadLogic.runMainThread(new Runnable() {
+                    @Override
+                    public void run() {
+                        if (currentHouseListPage > 1) {
+                            --currentHouseListPage;
+                        }
+                        isHouseLoadingMore = false;
+                        if (isRefreshing) {
+                            hideLoading();
+                        }
+
+                    }
+                }, _mActivity, ShowErrorMode.YES);
+            }
+        });
+    }
+
+    private void clearData() {
+        if (deviceList != null && deviceList.size() > 0) {
+            deviceList.clear();
+        }
+    }
+
+    public void setDeviceList(List<DeviceBean> list) {
+        if (list == null || list.size() == 0) {
+            return;
+        }
+        if (this.deviceList.size() == 0) {
+            this.deviceList.addAll(list);
+            return;
+        }
+        for (int i = 0; i < list.size(); i++) {
+            this.setSingleDevice(list.get(i));
+        }
+    }
+
+    /**
+     * 娣诲姞璁惧鍒板垪琛ㄩ噷闈�
+     *
+     * @param deviceBean -璁惧瀵硅薄
+     */
+    public void setSingleDevice(DeviceBean deviceBean) {
+        try {
+            if (deviceBean == null) {
+                return;
+            }
+            boolean if_boolean = false;
+            for (int i = 0; i < deviceList.size(); i++) {
+                if (deviceList.get(i).getHomeId().equals(deviceBean.getHomeId())) {
+                    //瀛樺湪鏇挎崲
+                    deviceList.remove(i);
+                    deviceList.add(i, deviceBean);
+                    if_boolean = true;
+                    break;
+                }
+            }
+            if (!if_boolean) {
+                //娌℃湁娣诲姞
+                this.deviceList.add(deviceBean);
+            }
+        } catch (Exception e) {
+            String mes = e.getMessage();
+            HdlLogLogic.print("--->" + mes);
+        }
+    }
+
+    /**
+     * 娣诲姞鍘嗗彶璁板綍
+     */
+    private void addSearchTextToList() {
+        for (int i = 0; i < searchHistoryTitleList.size(); i++) {
+            if (searchHistoryTitleList.get(i).equals(currSearchText)) {
+                searchHistoryTitleList.remove(searchHistoryTitleList.get(i));
+            }
+        }
+        searchHistoryTitleList.add(currSearchText);
+        // 鍊掑簭鎺掑垪鏁版嵁(鎼滅储鏈�鍚庢帓鍦ㄥ墠闈�)
+        Collections.reverse(searchHistoryTitleList);
+        if (searchHistoryTitleList.size() > 10) {
+            //鍘嗗彶璁板綍涓嶈兘瓒呭嚭10
+            searchHistoryTitleList.remove(searchHistoryTitleList.get(11));
+        }
+
+    }
+
+    /**
+     * 鑾峰彇銆愭悳绱㈠巻鍙茶褰曟枃浠躲�戝叏璺緞
+     */
+    public String getHistoryFileNamePath() {
+        return HdlFileLogic.getInstance().getCurrentUserRootPath() + "/house_device.txt";
+    }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseListFragment.java b/app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseListFragment.java
index ec46796..0c4b333 100644
--- a/app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseListFragment.java
+++ b/app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseListFragment.java
@@ -369,6 +369,15 @@
                 }
             }
         });
+        //璁惧娣绘悳绱�
+        viewBinding.deviceSearchCl.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                Intent intent = new Intent();
+                intent.setClass(_mActivity, DeviceSearchActivity.class);
+                startActivity(intent);
+            }
+        });
 
     }
 
diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseSearchActivity.java b/app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseSearchActivity.java
index 2131a6f..a84f2c0 100644
--- a/app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseSearchActivity.java
+++ b/app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseSearchActivity.java
@@ -51,7 +51,7 @@
 
     private String currSearchText;
 
-    List<String> SearchHistoryTitleList = new ArrayList<>();
+    List<String> searchHistoryTitleList = new ArrayList<>();
 
     @Override
     public Object getContentView() {
@@ -78,7 +78,7 @@
             if (TextUtils.isEmpty(json)) {
                 return;
             }
-            SearchHistoryTitleList = new Gson().fromJson(json, new TypeToken<List<String>>() {
+            searchHistoryTitleList = new Gson().fromJson(json, new TypeToken<List<String>>() {
             }.getType());
         } catch (Exception ignored) {
         }
@@ -153,7 +153,7 @@
                 viewBinding.powerStationSearchEt.setText("");
                 viewBinding.historyListParent.setVisibility(View.VISIBLE);
                 viewBinding.listParent.setVisibility(View.GONE);
-                searchHistoryAdapter.setList(SearchHistoryTitleList);
+                searchHistoryAdapter.setList(searchHistoryTitleList);
                 clearData();
             }
         });
@@ -161,8 +161,8 @@
         viewBinding.powerStationDelIv.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
-                SearchHistoryTitleList = new ArrayList<>();
-                searchHistoryAdapter.setList(SearchHistoryTitleList);
+                searchHistoryTitleList = new ArrayList<>();
+                searchHistoryAdapter.setList(searchHistoryTitleList);
                 HdlFileLogic.getInstance().deleteFile(getHistoryFileNamePath());
             }
         });
@@ -191,7 +191,7 @@
         searchHistoryAdapter = new SearchHistoryAdapter(_mActivity);
         viewBinding.historyListRcv.setLayoutManager(new LinearLayoutManager(_mActivity));
         viewBinding.historyListRcv.setAdapter(searchHistoryAdapter);
-        searchHistoryAdapter.setList(SearchHistoryTitleList);
+        searchHistoryAdapter.setList(searchHistoryTitleList);
         //鍒濆鍖栫數绔欓�傞厤鍣�
         searchHouseAdapter = new SearchHouseAdapter(_mActivity);
         viewBinding.listRcv.setLayoutManager(new LinearLayoutManager(_mActivity));
@@ -236,9 +236,9 @@
     @Override
     protected void onDestroy() {
         viewBinding.powerStationSearchEt.removeTextChangedListener(textWatcher);
-        if (SearchHistoryTitleList.size() > 0) {
+        if (searchHistoryTitleList.size() > 0) {
             HdlFileLogic.getInstance().deleteFile(getHistoryFileNamePath());
-            HdlFileLogic.getInstance().appendFile(getHistoryFileNamePath(), new Gson().toJson(SearchHistoryTitleList));
+            HdlFileLogic.getInstance().appendFile(getHistoryFileNamePath(), new Gson().toJson(searchHistoryTitleList));
         }
         super.onDestroy();
     }
@@ -368,17 +368,17 @@
      * 娣诲姞鍘嗗彶璁板綍
      */
     private void addSearchTextToList() {
-        for (int i = 0; i < SearchHistoryTitleList.size(); i++) {
-            if (SearchHistoryTitleList.get(i).equals(currSearchText)) {
-                SearchHistoryTitleList.remove(SearchHistoryTitleList.get(i));
+        for (int i = 0; i < searchHistoryTitleList.size(); i++) {
+            if (searchHistoryTitleList.get(i).equals(currSearchText)) {
+                searchHistoryTitleList.remove(searchHistoryTitleList.get(i));
             }
         }
-        SearchHistoryTitleList.add(currSearchText);
+        searchHistoryTitleList.add(currSearchText);
         // 鍊掑簭鎺掑垪鏁版嵁(鎼滅储鏈�鍚庢帓鍦ㄥ墠闈�)
-        Collections.reverse(SearchHistoryTitleList);
-        if (SearchHistoryTitleList.size() > 10) {
+        Collections.reverse(searchHistoryTitleList);
+        if (searchHistoryTitleList.size() > 10) {
             //鍘嗗彶璁板綍涓嶈兘瓒呭嚭10
-            SearchHistoryTitleList.remove(SearchHistoryTitleList.get(11));
+            searchHistoryTitleList.remove(searchHistoryTitleList.get(11));
         }
 
     }
diff --git a/app/src/main/java/com/hdl/photovoltaic/uni/HDLUniMP.java b/app/src/main/java/com/hdl/photovoltaic/uni/HDLUniMP.java
index fe46256..9c08e08 100644
--- a/app/src/main/java/com/hdl/photovoltaic/uni/HDLUniMP.java
+++ b/app/src/main/java/com/hdl/photovoltaic/uni/HDLUniMP.java
@@ -97,8 +97,9 @@
     /*********Wifi妯″潡*********/ //鍗敠瀹氫箟
     public final static String UNI_EVENT_REPLY_WIFI_MODEL = "uni_wifi_model";//wifi妯″潡(澶х被)
     public final static String UNI_EVENT_REPLY_WIFI_LIST = "list";//鑾峰彇wifi鍒楄〃
-    public final static String UNI_EVENT_REPLY_WIFI_INFO = "info";//鑾峰彇褰撳墠wifi淇℃伅
-    public final static String UNI_EVENT_REPLY_WIFI_CONNECT = "connect";//杩炴帴wifi
+    public final static String UNI_EVENT_REPLY_WIFI_PHONE_INFO = "wifi_phone_info";//鑾峰彇褰撳墠wifi淇℃伅
+    public final static String UNI_EVENT_REPLY_WIFI_SET_DEVICE = "wifi_set_device";//璁剧疆wifi缁欒澶�
+    public final static String UNI_EVENT_REPLY_OPEN_WIFI_SETTINGS = "open_wifi_settings";//璋冪敤鎵撳紑鎵嬫満Wifi璁剧疆鐣岄潰
     //endregion
 
     //region --------銆愬師鐢熴�戜富鍔ㄥ彂閫佸埌銆愬皬绋嬪簭銆�--------
@@ -135,18 +136,18 @@
     public static class UniCallBackBaseBean implements Serializable {
 
         private int code;//鐘舵�佺爜
-        private String mes;//淇℃伅鎻忚堪
+        private String msg;//淇℃伅鎻忚堪
         private String type;//鍔熻兘绫诲瀷
         private Object data;//闄勫姞json鏁版嵁
 
-        public UniCallBackBaseBean(int code, String mes) {
+        public UniCallBackBaseBean(int code, String msg) {
             this.code = code;
-            this.mes = mes;
+            this.msg = msg;
         }
 
         public UniCallBackBaseBean() {
             this.code = 0;
-            this.mes = "鎴愬姛";
+            this.msg = "鎴愬姛";
         }
 
 
@@ -158,12 +159,12 @@
             this.code = code;
         }
 
-        public String getMes() {
-            return mes == null ? "" : mes;
+        public String getMsg() {
+            return msg == null ? "" : msg;
         }
 
-        public void setMes(String mes) {
-            this.mes = mes;
+        public void setMsg(String msg) {
+            this.msg = msg;
         }
 
         public Object getData() {
diff --git a/app/src/main/res/layout/activity_device_search.xml b/app/src/main/res/layout/activity_device_search.xml
new file mode 100644
index 0000000..bf4544d
--- /dev/null
+++ b/app/src/main/res/layout/activity_device_search.xml
@@ -0,0 +1,168 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:background="@color/text_F5F7FA"
+    tools:context=".ui.powerstation.DeviceSearchActivity">
+
+    <!--鎼滅储-->
+    <RelativeLayout
+        android:id="@+id/power_station_search_cl"
+        android:layout_width="match_parent"
+        android:layout_height="@dimen/dp_35"
+        android:layout_marginTop="@dimen/dp_48"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintTop_toTopOf="parent">
+
+        <RelativeLayout
+            android:id="@+id/back_rl"
+            android:layout_width="@dimen/dp_50"
+            android:layout_height="match_parent">
+
+            <ImageView
+                android:id="@+id/power_station_back_iv"
+                android:layout_width="@dimen/dp_10"
+                android:layout_height="@dimen/dp_17"
+                android:layout_alignParentStart="true"
+                android:layout_centerVertical="true"
+                android:layout_marginStart="@dimen/dp_16"
+                android:src="@drawable/search_back" />
+        </RelativeLayout>
+
+
+        <RelativeLayout
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:layout_marginStart="@dimen/dp_7"
+            android:layout_marginEnd="@dimen/dp_21"
+            android:layout_toStartOf="@+id/power_station_search_tv"
+            android:layout_toEndOf="@+id/back_rl"
+            android:background="@drawable/search_bj_ff05000000">
+
+            <ImageView
+                android:id="@+id/power_station_search_iv"
+                android:layout_width="@dimen/dp_18"
+                android:layout_height="@dimen/dp_18"
+                android:layout_alignParentStart="true"
+                android:layout_centerVertical="true"
+                android:layout_marginStart="@dimen/dp_13"
+                android:src="@drawable/search_path" />
+
+            <EditText
+                android:id="@+id/power_station_search_et"
+                android:layout_width="0dp"
+                android:layout_height="match_parent"
+                android:layout_alignParentEnd="true"
+                android:layout_centerVertical="true"
+                android:layout_marginStart="@dimen/dp_11"
+                android:layout_marginEnd="@dimen/dp_40"
+                android:layout_toEndOf="@+id/power_station_search_iv"
+                android:background="@null"
+                android:gravity="start|center_vertical"
+                android:hint="Search the power station"
+                android:textColor="@color/text_90000000"
+                android:textColorHint="@color/text_40000000"
+                android:textSize="@dimen/text_14" />
+
+            <ImageView
+                android:id="@+id/power_station_clear_iv"
+                android:layout_width="@dimen/dp_20"
+                android:layout_height="@dimen/dp_20"
+                android:layout_alignParentEnd="true"
+                android:layout_centerVertical="true"
+                android:layout_marginEnd="@dimen/dp_13"
+                android:src="@drawable/clear" />
+        </RelativeLayout>
+
+        <TextView
+            android:id="@+id/power_station_search_tv"
+            android:layout_width="wrap_content"
+            android:layout_height="match_parent"
+            android:layout_alignParentEnd="true"
+            android:layout_centerVertical="true"
+            android:layout_marginEnd="@dimen/dp_21"
+            android:gravity="center"
+            android:text="@string/search"
+            android:textColor="@color/text_90000000"
+            android:textSize="@dimen/text_16" />
+
+
+    </RelativeLayout>
+
+    <androidx.constraintlayout.widget.ConstraintLayout
+        android:id="@+id/history_list_parent"
+        android:layout_width="match_parent"
+        android:layout_height="0dp"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintTop_toBottomOf="@+id/power_station_search_cl">
+
+        <TextView
+            android:id="@+id/history_list_title_tv"
+            android:layout_width="wrap_content"
+            android:layout_height="@dimen/dp_23"
+            android:layout_marginStart="@dimen/dp_16"
+            android:layout_marginTop="@dimen/dp_23"
+            android:layout_marginEnd="@dimen/dp_21"
+            android:text="@string/history_search"
+            android:textColor="@color/text_90000000"
+            android:textSize="@dimen/text_16"
+            android:textStyle="bold"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintTop_toTopOf="parent" />
+
+        <ImageView
+            android:id="@+id/power_station_del_iv"
+            android:layout_width="@dimen/dp_26"
+            android:layout_height="@dimen/dp_26"
+            android:layout_marginTop="@dimen/dp_21"
+            android:layout_marginEnd="@dimen/dp_16"
+            android:src="@drawable/history_del"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintTop_toTopOf="parent" />
+
+        <androidx.recyclerview.widget.RecyclerView
+            android:id="@+id/history_list_rcv"
+            android:layout_width="match_parent"
+            android:layout_height="0dp"
+            android:layout_marginTop="67dp"
+            app:layout_constraintBottom_toBottomOf="parent"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintTop_toTopOf="parent" />
+
+    </androidx.constraintlayout.widget.ConstraintLayout>
+
+    <androidx.constraintlayout.widget.ConstraintLayout
+        android:id="@+id/list_parent"
+        android:layout_width="match_parent"
+        android:layout_height="0dp"
+        android:layout_marginTop="@dimen/dp_30"
+        android:visibility="gone"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintTop_toBottomOf="@+id/power_station_search_cl">
+
+        <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
+            android:id="@+id/list_srl"
+            android:layout_width="match_parent"
+            android:layout_height="0dp"
+            app:layout_constraintBottom_toBottomOf="parent"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintTop_toTopOf="parent">
+
+            <androidx.recyclerview.widget.RecyclerView
+                android:id="@+id/list_rcv"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent" />
+        </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
+
+    </androidx.constraintlayout.widget.ConstraintLayout>
+
+</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file

--
Gitblit v1.8.0