2 次代碼提交 7a729d52cb ... ec3022827c

作者 SHA1 備註 提交日期
  Tony ec3022827c 1.购买天数和次数,重新获取过期时间和剩余次数 5 年之前
  Tony f2f58bbed6 1.添加调节音量 5 年之前
共有 35 個文件被更改,包括 2488 次插入197 次删除
  1. 93 0
      app/src/main/java/com/sunzee/adapter/WifiListAdapter.java
  2. 13 0
      app/src/main/java/com/sunzee/model/AppConstants.java
  3. 16 0
      app/src/main/java/com/sunzee/model/HideConstants.java
  4. 121 0
      app/src/main/java/com/sunzee/model/domain/WifiBean.java
  5. 31 0
      app/src/main/java/com/sunzee/model/message/NetMessageEvent.java
  6. 10 4
      app/src/main/java/com/sunzee/mvp/advertising/AdvertisingPresenter.java
  7. 100 0
      app/src/main/java/com/sunzee/mvp/other/OtherPresenter.java
  8. 94 0
      app/src/main/java/com/sunzee/receiver/NetworkConnectChangedReceiver.java
  9. 0 1
      app/src/main/java/com/sunzee/retrofit/ApiStores.java
  10. 51 7
      app/src/main/java/com/sunzee/service/MyIntentService.java
  11. 2 2
      app/src/main/java/com/sunzee/service/MyService.java
  12. 13 3
      app/src/main/java/com/sunzee/ui/activity/HomeActivity.java
  13. 86 0
      app/src/main/java/com/sunzee/ui/dialog/WifiDetailDialog.java
  14. 406 0
      app/src/main/java/com/sunzee/ui/dialog/WifiDialog.java
  15. 110 0
      app/src/main/java/com/sunzee/ui/dialog/WifiLinkDialog.java
  16. 10 0
      app/src/main/java/com/sunzee/ui/fragment/HomepageFragment.java
  17. 259 2
      app/src/main/java/com/sunzee/ui/fragment/OtherFragment.java
  18. 1 1
      app/src/main/java/com/sunzee/ui/view/CustomView.java
  19. 4 0
      app/src/main/java/com/sunzee/ui/view/CustomViewGrounp.java
  20. 24 0
      app/src/main/java/com/sunzee/utils/CollectionUtils.java
  21. 426 0
      app/src/main/java/com/sunzee/utils/WifiHelper.java
  22. 280 0
      app/src/main/java/com/sunzee/utils/WifiSupport.java
  23. 二進制
      app/src/main/res/drawable-hdpi/btn_xuanze.png
  24. 5 0
      app/src/main/res/drawable-hdpi/selector_net_bg.xml
  25. 二進制
      app/src/main/res/drawable-mdpi/btn_xuanze.png
  26. 二進制
      app/src/main/res/drawable-xhdpi/btn_xuanze.png
  27. 二進制
      app/src/main/res/drawable-xxhdpi/btn_xuanze.png
  28. 二進制
      app/src/main/res/drawable-xxxhdpi/btn_xuanze.png
  29. 二進制
      app/src/main/res/drawable/icon_wifi_right.png
  30. 48 0
      app/src/main/res/layout/dialog_et.xml
  31. 178 177
      app/src/main/res/layout/fragment_other.xml
  32. 1 0
      app/src/main/res/layout/navigation_layout.xml
  33. 60 0
      app/src/main/res/layout/wifi_list_activity.xml
  34. 45 0
      app/src/main/res/layout/wifi_list_recycle_item.xml
  35. 1 0
      app/src/main/res/values/strings.xml

+ 93 - 0
app/src/main/java/com/sunzee/adapter/WifiListAdapter.java

@@ -0,0 +1,93 @@
+package com.sunzee.adapter;
+
+import android.content.Context;
+import android.support.v7.widget.RecyclerView;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+import com.sunzee.R;
+import com.sunzee.model.AppConstants;
+import com.sunzee.model.domain.WifiBean;
+
+import java.util.List;
+
+
+public class WifiListAdapter extends RecyclerView.Adapter<WifiListAdapter.MyViewHolder> {
+
+    private Context mContext;
+    private List<WifiBean> resultList;
+    private onItemClickListener onItemClickListener;
+
+    public void setOnItemClickListener(WifiListAdapter.onItemClickListener onItemClickListener) {
+        this.onItemClickListener = onItemClickListener;
+    }
+
+    public WifiListAdapter(Context mContext, List<WifiBean> resultList) {
+        this.mContext = mContext;
+        this.resultList = resultList;
+    }
+
+
+    @Override
+    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+        View view = LayoutInflater.from(mContext).inflate(R.layout.wifi_list_recycle_item, parent, false);
+        MyViewHolder vh = new MyViewHolder(view);
+        return vh;
+    }
+
+    @Override
+    public void onBindViewHolder(MyViewHolder holder, final int position) {
+        final WifiBean bean = resultList.get(position);
+        holder.tvItemWifiName.setText(bean.getWifiName());
+        holder.tvItemWifiStatus.setText("("+bean.getState()+")");
+
+        //已连接或者正在连接状态的wifi都是处于集合中的首位,所以可以写出如下判断
+        if(position == 0  && (AppConstants.WIFI_STATE_ON_CONNECTING.equals(bean.getState()) || AppConstants.WIFI_STATE_CONNECT.equals(bean.getState()))){
+            holder.tvItemWifiName.setTextColor(mContext.getResources().getColor(R.color.homecolor1));
+            holder.tvItemWifiStatus.setTextColor(mContext.getResources().getColor(R.color.homecolor1));
+        }else{
+            holder.tvItemWifiName.setTextColor(mContext.getResources().getColor(R.color.gray_home));
+            holder.tvItemWifiStatus.setTextColor(mContext.getResources().getColor(R.color.gray_home));
+        }
+
+        holder.itemView.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View view) {
+                onItemClickListener.onItemClick(view,position,bean);
+            }
+        });
+    }
+
+    public void replaceAll(List<WifiBean> datas) {
+        if (resultList.size() > 0) {
+            resultList.clear();
+        }
+        resultList.addAll(datas);
+        notifyDataSetChanged();
+    }
+
+    @Override
+    public int getItemCount() {
+        return resultList.size();
+    }
+
+
+    static class MyViewHolder extends RecyclerView.ViewHolder{
+
+        TextView tvItemWifiName, tvItemWifiStatus;
+
+        public MyViewHolder(View itemView) {
+            super(itemView);
+            tvItemWifiName = (TextView) itemView.findViewById(R.id.tv_item_wifi_name);
+            tvItemWifiStatus = (TextView) itemView.findViewById(R.id.tv_item_wifi_status);
+        }
+
+    }
+
+    public interface onItemClickListener{
+        void onItemClick(View view, int postion, Object o);
+    }
+
+}

+ 13 - 0
app/src/main/java/com/sunzee/model/AppConstants.java

@@ -0,0 +1,13 @@
+package com.sunzee.model;
+
+
+public class AppConstants {
+
+    public static final String WIFI_STATE_CONNECT = "已连接";
+    public static final String WIFI_STATE_ON_CONNECTING = "正在连接";
+    public static final String WIFI_STATE_UNCONNECT = "未连接";
+
+    public static final String EXTRA_WIFI_BEAN= "wifi_bean";
+
+
+}

+ 16 - 0
app/src/main/java/com/sunzee/model/HideConstants.java

@@ -0,0 +1,16 @@
+package com.sunzee.model;
+
+/**
+ * TODO
+ *
+ * @author Kelly
+ * @version 1.0.0
+ * @filename HideConstants.java
+ * @time 2019/3/22 16:35
+ * @copyright(C) 2019 song
+ */
+public class HideConstants {
+    public static class Context {
+        public static final String ETHERNET_SERVICE = "ethernet";
+    }
+}

+ 121 - 0
app/src/main/java/com/sunzee/model/domain/WifiBean.java

@@ -0,0 +1,121 @@
+package com.sunzee.model.domain;
+
+import android.net.wifi.ScanResult;
+import android.os.Parcel;
+import android.os.Parcelable;
+
+/**
+ * @author whw
+ * @time 2019/5/16
+ * @Description wifi扫描后的实体
+ */
+public class WifiBean implements Comparable<WifiBean>, Parcelable {
+    private static final long serialVersionUID = -7060210544600464481L;
+
+    private String wifiName;
+    private String level;
+    private String state;  //已连接  正在连接  未连接 三种状态
+    private String capabilities;//加密方式
+
+    private ScanResult scanResult;//原生的对象ScanResult
+
+    public String getCapabilities() {
+        return capabilities;
+    }
+
+    public void setCapabilities(String capabilities) {
+        this.capabilities = capabilities;
+    }
+
+    public String getWifiName() {
+        return wifiName;
+    }
+
+    public void setWifiName(String wifiName) {
+        this.wifiName = wifiName;
+    }
+
+    public String getLevel() {
+        return level;
+    }
+
+    public void setLevel(String level) {
+        this.level = level;
+    }
+
+    public String getState() {
+        return state;
+    }
+
+    public void setState(String state) {
+        this.state = state;
+    }
+
+    @Override
+    public int compareTo(WifiBean o) {
+        int level1 = Integer.parseInt(getLevel());
+        int level2 = Integer.parseInt(o.getLevel());
+        if (level1 > level2) {//降序
+            return -1;
+        } else if (level1 == level2) {
+            return 0;
+        } else {
+            return 1;
+        }
+    }
+
+    @Override
+    public String toString() {
+        return "自定义WifiBean{" +
+                "wifiName='" + wifiName + '\'' +
+                ", level='" + level + '\'' +
+                ", state='" + state + '\'' +
+                ", capabilities='" + capabilities + '\'' +
+                ",\n 扫描点scanResult=" + scanResult +
+                '}';
+    }
+
+    public ScanResult getScanResult() {
+        return scanResult;
+    }
+
+    public void setScanResult(ScanResult scanResult) {
+        this.scanResult = scanResult;
+    }
+
+
+    @Override
+    public int describeContents() {
+        return 0;
+    }
+
+    @Override
+    public void writeToParcel(Parcel dest, int flags) {
+        dest.writeString(wifiName);
+        dest.writeString(level);
+        dest.writeString(state);
+        dest.writeString(capabilities);
+        dest.writeValue(scanResult);
+
+    }
+
+    public static final Creator<WifiBean> CREATOR = new Creator<WifiBean>() {
+
+        @Override
+        public WifiBean createFromParcel(Parcel source) {
+
+            WifiBean model = new WifiBean();
+            model.wifiName = source.readString();
+            model.level = source.readString();
+            model.state = source.readString();
+            model.capabilities = source.readString();
+            model.scanResult = (ScanResult) source.readValue(ScanResult.class.getClassLoader());
+            return model;
+        }
+
+        @Override
+        public WifiBean[] newArray(int size) {
+            return new WifiBean[size];
+        }
+    };
+}

+ 31 - 0
app/src/main/java/com/sunzee/model/message/NetMessageEvent.java

@@ -0,0 +1,31 @@
+package com.sunzee.model.message;
+
+/**
+ * @author whw
+ * @time 2019/5/8
+ * @Description 网络切换连接
+ */
+public class NetMessageEvent {
+
+    public enum Type {
+        //wifi
+        wifi,
+        //数据网络
+        mobile,
+
+    }
+
+    private Type type;
+
+    public NetMessageEvent(Type type) {
+        this.type = type;
+    }
+
+    public Type getType() {
+        return type;
+    }
+
+    public void setType(Type type) {
+        this.type = type;
+    }
+}

+ 10 - 4
app/src/main/java/com/sunzee/mvp/advertising/AdvertisingPresenter.java

@@ -64,6 +64,9 @@ public class AdvertisingPresenter extends BasePresenter<AdvertisingView> {
         }
         if (rightFileSize != 0) {
             mvpView.playLeft(playFileList);
+            for (File file : playFileList) {
+                Log.d(TAG, "play: " + file.getName());
+            }
         }
     }
 
@@ -84,7 +87,7 @@ public class AdvertisingPresenter extends BasePresenter<AdvertisingView> {
      * @return
      */
     private int rightVideoImageFile() {
-        showOut = Hawk.get("show_out", new HashMap<Integer, GetAdBean>());
+        showOut = Hawk.get("show_out", new HashMap<Integer, GetAdBean>());// 第一次为空。
         Log.d(TAG, "show_out rightVideoImageFile: " + showOut);
         this.allFiles = FileUtil.getAllFiles(Environment.getExternalStorageDirectory().getPath() + "/rightvideoimg/", "");
         //判断是否为空
@@ -138,7 +141,9 @@ public class AdvertisingPresenter extends BasePresenter<AdvertisingView> {
             LogUtil.d(TAG, "rightvideoimg showOUt initView: allPlayList为0");
             return 0;
         }
+        Log.d(TAG, "rightVideoImageFile: " + allPlayList.size());
         return setTimeRules();
+//        return allPlayList.size();
     }
 
     //真正要播放的文件
@@ -208,7 +213,7 @@ public class AdvertisingPresenter extends BasePresenter<AdvertisingView> {
             LogUtil.e(TAG, "playCorporationAd: 没有下载A屏文件");
             return 0;
         }
-        adBeans = Hawk.get("showAdA", new ArrayList<GetAdBean>());//为空
+        adBeans = Hawk.get("showAdA", new ArrayList<GetAdBean>());//todo 第一次为空,第一次为零。
         Log.d(TAG, "showAdA leftVideoImageFile: " + adBeans);
         if (adBeans == null || adBeans.size() <= 0) {
             LogUtil.e(TAG, "playCorporationAd: 没有下载A屏数据");
@@ -292,7 +297,7 @@ public class AdvertisingPresenter extends BasePresenter<AdvertisingView> {
         addSubscription(apiStores.getCleanTimeAndRemaining(params), new ApiCallback<HttpResult2<String>>() {
             @Override
             public void onSuccess(HttpResult2<String> model) {
-                Log.d(TAG, "onSuccess: " + model);
+                Log.d(TAG, "onSuccess11: " + model);
                 String overdueDate = model.getOverdueDate();
                 String remaining = model.getRemaining();
                 if (TextUtils.isEmpty(overdueDate)) {
@@ -405,13 +410,14 @@ public class AdvertisingPresenter extends BasePresenter<AdvertisingView> {
 
     /**
      * 上次局部清洗的蹲位有多少个
+     *
      * @param num 数量
      */
     public void sendPositionNum(int num) {
         Map<String, String> params = new HashMap<>();
         params.put("clientId", Heartbeat.deviceId + "");
         params.put("num", num + "");
-        Log.d(TAG, "sendPositionNum: "+num);
+        Log.d(TAG, "sendPositionNum: " + num);
         addSubscription(apiStores.sendPositionNum(params), new ApiCallback<HttpResult<String>>() {
 
             @Override

+ 100 - 0
app/src/main/java/com/sunzee/mvp/other/OtherPresenter.java

@@ -1,7 +1,15 @@
 package com.sunzee.mvp.other;
 
+import android.content.Context;
+import android.net.ConnectivityManager;
+import android.net.wifi.WifiManager;
+
 import com.sunzee.base.BasePresenter;
 
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
 /**
  * 其他页界面 presenter
  */
@@ -9,4 +17,96 @@ public class OtherPresenter extends BasePresenter<OtherView> {
     public OtherPresenter(OtherView view) {
         attachView(view);
     }
+
+    //设置是否打开Wifi
+    public void toggleWiFi(Context context, boolean enabled) {
+        WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
+        wifiManager.setWifiEnabled(enabled);
+    }
+
+    /**
+     * 设置是否打开移动网络
+     * <p>
+     * 但没有直接的API可调用,但是我们发现:
+     * 在ConnectivityManager中有一隐藏的方法setMobileDataEnabled()
+     * 源码如下:
+     * public void setMobileDataEnabled(boolean enabled) {
+     * try {
+     * mService.setMobileDataEnabled(enabled);
+     * } catch (RemoteException e) {
+     * }
+     * }
+     * <p>
+     * 这里的重点就是mService,查看其声明:
+     * private IConnectivityManager mService;
+     * 继续查看源码可知IConnectivityManager为了一个AIDL(接口interface IConnectivityManager)
+     * <p>
+     * <p>
+     * 调用过程:
+     * ConnectivityManager中有一隐藏的方法setMobileDataEnabled()
+     * 在setMobileDataEnabled()中调用了IConnectivityManager中的setMobileDataEnabled(boolean)
+     * <p>
+     * 所以我们首先需要反射出ConnectivityManager类的成员变量mService(IConnectivityManager类型)
+     */
+    public void toggleMobileData(Context context, boolean enabled) {
+        ConnectivityManager connectivityManager =
+                (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
+
+//ConnectivityManager类
+        Class<?> connectivityManagerClass = null;
+//ConnectivityManager类中的字段
+        Field connectivityManagerField = null;
+
+
+//IConnectivityManager接口
+        Class<?> iConnectivityManagerClass = null;
+//IConnectivityManager接口的对象
+        Object iConnectivityManagerObject = null;
+//IConnectivityManager接口的对象的方法
+        Method setMobileDataEnabledMethod = null;
+
+        try {
+//取得ConnectivityManager类
+            connectivityManagerClass = Class.forName(connectivityManager.getClass().getName());
+//取得ConnectivityManager类中的字段mService
+            connectivityManagerField = connectivityManagerClass.getDeclaredField("mService");
+//取消访问私有字段的合法性检查
+//该方法来自java.lang.reflect.AccessibleObject
+            connectivityManagerField.setAccessible(true);
+
+
+//实例化mService
+//该get()方法来自java.lang.reflect.Field
+//一定要注意该get()方法的参数:
+//它是mService所属类的对象
+//完整例子请参见:
+//http://blog.csdn.net/lfdfhl/article/details/13509839
+            iConnectivityManagerObject = connectivityManagerField.get(connectivityManager);
+//得到mService所属接口的Class
+            iConnectivityManagerClass = Class.forName(iConnectivityManagerObject.getClass().getName());
+//取得IConnectivityManager接口中的setMobileDataEnabled(boolean)方法
+//该方法来自java.lang.Class.getDeclaredMethod
+            setMobileDataEnabledMethod =
+                    iConnectivityManagerClass.getDeclaredMethod("setMobileDataEnabled", Boolean.TYPE);
+//取消访问私有方法的合法性检查
+//该方法来自java.lang.reflect.AccessibleObject
+            setMobileDataEnabledMethod.setAccessible(true);
+//调用setMobileDataEnabled方法
+            setMobileDataEnabledMethod.invoke(iConnectivityManagerObject, enabled);
+        } catch (ClassNotFoundException e) {
+            e.printStackTrace();
+        } catch (NoSuchFieldException e) {
+            e.printStackTrace();
+        } catch (SecurityException e) {
+            e.printStackTrace();
+        } catch (NoSuchMethodException e) {
+            e.printStackTrace();
+        } catch (IllegalArgumentException e) {
+            e.printStackTrace();
+        } catch (IllegalAccessException e) {
+            e.printStackTrace();
+        } catch (InvocationTargetException e) {
+            e.printStackTrace();
+        }
+    }
 }

+ 94 - 0
app/src/main/java/com/sunzee/receiver/NetworkConnectChangedReceiver.java

@@ -0,0 +1,94 @@
+package com.sunzee.receiver;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.net.ConnectivityManager;
+import android.net.NetworkInfo;
+import android.net.wifi.WifiManager;
+import android.os.Parcelable;
+import android.util.Log;
+
+import com.orhanobut.hawk.Hawk;
+import com.sunzee.model.domain.Name;
+import com.sunzee.model.message.NetMessageEvent;
+
+import org.greenrobot.eventbus.EventBus;
+
+
+/**
+ * @author whw
+ * @time 2019/5/8
+ * @Description 监听网络切换连接是否成功
+ */
+public class NetworkConnectChangedReceiver extends BroadcastReceiver {
+    private String getConnectionType(int type) {
+        String connType = "";
+        if (type == ConnectivityManager.TYPE_MOBILE) {
+            connType = "4G网络数据";
+        } else if (type == ConnectivityManager.TYPE_WIFI) {
+            connType = "WIFI网络";
+        }
+        return connType;
+    }
+
+    private String TAG = this.getClass().getSimpleName();
+
+    @Override
+    public void onReceive(Context context, Intent intent) {
+        if (WifiManager.WIFI_STATE_CHANGED_ACTION.equals(intent.getAction())) {// 监听wifi的打开与关闭,与wifi的连接无关
+            int wifiState = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE, 0);
+            Log.e(TAG, "wifiState:" + wifiState);
+            switch (wifiState) {
+                case WifiManager.WIFI_STATE_DISABLED:
+                    break;
+                case WifiManager.WIFI_STATE_DISABLING:
+                    break;
+            }
+        }
+        // 监听wifi的连接状态即是否连上了一个有效无线路由
+        if (WifiManager.NETWORK_STATE_CHANGED_ACTION.equals(intent.getAction())) {
+            Parcelable parcelableExtra = intent
+                    .getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
+            if (null != parcelableExtra) {
+                // 获取联网状态的NetWorkInfo对象
+                NetworkInfo networkInfo = (NetworkInfo) parcelableExtra;
+                //获取的State对象则代表着连接成功与否等状态
+                NetworkInfo.State state = networkInfo.getState();
+                //判断网络是否已经连接
+                boolean isConnected = state == NetworkInfo.State.CONNECTED;
+                Log.e(TAG, "isConnected:" + isConnected);
+                if (isConnected) {
+                } else {
+
+                }
+            }
+        }
+        // 监听网络连接,包括wifi和移动数据的打开和关闭,以及连接上可用的连接都会接到监听
+        if (ConnectivityManager.CONNECTIVITY_ACTION.equals(intent.getAction())) {
+            //获取联网状态的NetworkInfo对象
+            NetworkInfo info = intent
+                    .getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO);
+            if (info != null) {
+                //如果当前的网络连接成功并且网络连接可用
+                if (NetworkInfo.State.CONNECTED == info.getState() && info.isAvailable()) {
+                    if (info.getType() == ConnectivityManager.TYPE_WIFI
+                            || info.getType() == ConnectivityManager.TYPE_MOBILE) {
+                        Log.e(TAG, getConnectionType(info.getType()) + "连上");
+                        if (getConnectionType(info.getType()).equals("4G网络数据")) {
+                            Hawk.put(Name.NET_TYPE, 0);
+                            EventBus.getDefault().post(new NetMessageEvent(NetMessageEvent.Type.mobile));
+                        } else if (getConnectionType(info.getType()).equals("WIFI网络")) {
+                            Hawk.put(Name.NET_TYPE, 1);
+                            EventBus.getDefault().post(new NetMessageEvent(NetMessageEvent.Type.wifi));
+                        }
+
+                    }
+                } else {
+                    Log.e(TAG, getConnectionType(info.getType()) + "断开");
+                }
+            }
+        }
+    }
+}
+

+ 0 - 1
app/src/main/java/com/sunzee/retrofit/ApiStores.java

@@ -87,7 +87,6 @@ public interface ApiStores {
     @GET("api/app_alarmRecord/clean/getTime.htm")
     Observable<HttpResult<String>> getBackgroundTime();
 
-
     //可以清洗机器开始清洗了,向上面报告
     @GET("api/app_alarmRecord/clean/cleanReport.htm")
     Observable<HttpResult<String>> getCleanReport(@QueryMap Map<String, String> params);

+ 51 - 7
app/src/main/java/com/sunzee/service/MyIntentService.java

@@ -26,6 +26,7 @@ import com.sunzee.base.BaseApplication;
 import com.sunzee.model.Global;
 import com.sunzee.model.Heartbeat;
 import com.sunzee.model.HttpResult;
+import com.sunzee.model.HttpResult2;
 import com.sunzee.model.domain.GeTuiBean;
 import com.sunzee.model.domain.GetAdBean;
 import com.sunzee.model.domain.Name;
@@ -42,7 +43,9 @@ import org.greenrobot.eventbus.EventBus;
 import org.greenrobot.eventbus.Subscribe;
 import org.greenrobot.eventbus.ThreadMode;
 
+import java.text.SimpleDateFormat;
 import java.util.ArrayList;
+import java.util.Calendar;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -120,7 +123,7 @@ public class MyIntentService extends GTIntentService {
                 break;
             case "updateRule":
                 //更新定时清洗的任务
-                LogUtil.d(TAG, "onReceiveMessageData: updateRule");
+                LogUtil.d(TAG, "onReceiveMessageData: updateRule"+geTuiBean.getKind_data());
                 updataCleanRule(gson, geTuiBean, kind);
                 break;
             case "statusType":
@@ -138,8 +141,10 @@ public class MyIntentService extends GTIntentService {
                 updataParam(gson, geTuiBean, kind);
                 break;
             case "paySuccess":
-                // todo
-                Log.d(TAG, "onReceiveMessageData: " + gson + ":" + geTuiBean + ":" + kind);
+                // todo 客户支付成功了,我们需要获取它的日期事件
+                Log.d(TAG, "getKind: " + geTuiBean.getKind() + ";getKind_data:" + geTuiBean.getKind_data() + ":" );
+                Log.d(TAG, "getKind: "+geTuiBean.getNetTime()+";getWebTime:"+geTuiBean.getWebTime());
+                requestCleanTimeAndRemaining();
                 break;
             case "cleanPositionNum":
                 //局部清洗
@@ -149,13 +154,53 @@ public class MyIntentService extends GTIntentService {
 
     }
 
+    public void requestCleanTimeAndRemaining() {
+        Map<String, String> params = new HashMap<>();
+        params.put("clientId", Heartbeat.deviceId);
+        addSubscription(apiStores.getCleanTimeAndRemaining(params), new ApiCallback<HttpResult2<String>>() {
+            @Override
+            public void onSuccess(HttpResult2<String> model) {
+                Log.d(TAG, "onSuccess11: " + model);
+                String overdueDate = model.getOverdueDate();
+                String remaining = model.getRemaining();
+                if (TextUtils.isEmpty(overdueDate)) {
+                    //如果为空
+                    Hawk.put(Name.OVERDUE_DATE, null);
+                } else {
+                    try {
+                        Calendar calendar = Calendar.getInstance();
+                        calendar.setTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(overdueDate));
+                        Hawk.put(Name.OVERDUE_DATE, calendar.getTimeInMillis());
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                        Hawk.put(Name.OVERDUE_DATE, null);
+                    }
+                }
+                if (TextUtils.isEmpty(remaining)) {
+                    Hawk.put(Name.REMAINING, null);
+                } else {
+                    Hawk.put(Name.REMAINING, remaining);
+                }
+
+            }
+
+            @Override
+            public void onFailure(String msg) {
+                Log.d(TAG, "onFailure: " + msg);
+                //失败了。
+            }
+
+            @Override
+            public void onFinish() {
+            }
+        });
+    }
+
     private void cleanPositionNum(Gson gson, GeTuiBean geTuiBean, String kind) {
         //todo
-
         EventBus.getDefault().post(new ApiMessageEvent("cleanPositionNum",geTuiBean.getKind_data()));
     }
 
-
     private void updataCleanRule(Gson gson, GeTuiBean geTuiBean, String kind) {
         String times = geTuiBean.getKind_data();
         Log.d(TAG, "闹钟响了26onSuccess: " + times);
@@ -263,7 +308,7 @@ public class MyIntentService extends GTIntentService {
                 Log.d(TAG, "onSuccess: ");
                 String data = rule.getData();
                 //广告数据
-                ArrayList<GetAdBean> adBeans = Hawk.get("showAd", new ArrayList<GetAdBean>());
+                ArrayList<GetAdBean> adBeans = Hawk.get("showAd", new ArrayList<GetAdBean>());  //数据为空
                 Gson gson = new Gson();
                 Log.d(TAG, "onSuccess: 1" + adBeans);
                 List<TimeRuleBean> list = gson.fromJson(data, new TypeToken<List<TimeRuleBean>>() {
@@ -292,7 +337,6 @@ public class MyIntentService extends GTIntentService {
                 Log.d(TAG, "onSuccess: 3" + adRulesMap);
                 //保存对应的id对应的广告规则
                 Hawk.put("ad_rules_map", adRulesMap);
-                EventBus.getDefault().post(new ApiMessageEvent("pushTimeRule", null));
                 //发送设备id
                 deviceIdPostApi();
             }

+ 2 - 2
app/src/main/java/com/sunzee/service/MyService.java

@@ -729,6 +729,7 @@ public class MyService extends Service {
             Log.d(TAG, "event: " + getAdBeans);
             Hawk.put("show_sugar", showSugar);
             Hawk.put("show_out", showOut);
+            EventBus.getDefault().post(new ApiMessageEvent("pushTimeRule", null));
             LogUtil.d(TAG, "synAdSuccess:保存完成广告数据3" + getAdBeans.size());
             SharedPreferencesUtils.setParam(Name.SYSTEM_ID, Heartbeat.managerId);
             SharedPreferencesUtils.setParam(Name.CONNECT_STATE, 2);
@@ -841,7 +842,7 @@ public class MyService extends Service {
                 }
                 //保存对应的id对应的广告规则
                 Hawk.put("ad_rules_map", adRulesMap);
-
+                EventBus.getDefault().post(new ApiMessageEvent("pushTimeRule", null));// todo
 //                if (syncDialog != null) {
 //                    syncDialog.setAdRuleState(R.string.sync_success);
 //                    syncDialog.dismiss();
@@ -955,7 +956,6 @@ public class MyService extends Service {
                     }
                 } else if (messageEvent.getName().equals("M8")) {
                     mThreadPoolMyservice.stopSetM8();
-                    // todo向上面报告开始清洗了。
                 }
                 mPoolAdvanceParameter.stopAll();
                 mPoolAdvanceParameter.startALLRead();

+ 13 - 3
app/src/main/java/com/sunzee/ui/activity/HomeActivity.java

@@ -7,6 +7,7 @@ import android.net.Uri;
 import android.os.Build;
 import android.os.Bundle;
 import android.os.Environment;
+import android.os.Handler;
 import android.support.annotation.NonNull;
 import android.support.annotation.RequiresApi;
 import android.support.design.widget.NavigationView;
@@ -40,6 +41,7 @@ import com.sunzee.ui.dialog.CheckUpdatesDialog;
 import com.sunzee.ui.dialog.ShutdownDialog;
 import com.sunzee.utils.FileUtil;
 import com.sunzee.utils.HomePagerSimpleFactory;
+import com.sunzee.utils.LongClickUtils;
 import com.sunzee.utils.PreventSpeedClickUtil;
 import com.sunzee.utils.SharedPreferencesUtils;
 import com.sunzee.utils.ToastUtil;
@@ -71,6 +73,7 @@ public class HomeActivity extends MvpActivity<HomePresenter> implements HomeView
     private LinearLayout mLlBlack;
     private ImageView mIvShutownLogo;
     private PreventSpeedClickUtil mPreventSpeedClickUtil;
+    private TextView mTvVersion1;
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
@@ -88,12 +91,12 @@ public class HomeActivity extends MvpActivity<HomePresenter> implements HomeView
 
     private void initView() {
         mNavigationView = findViewById(R.id.bnv_main_navigationbar);
+        mTvVersion1 = findViewById(R.id.tv_version);
         mTvVersion = findViewById(R.id.tv_version);
         mTvUpdataAPK = findViewById(R.id.tv_updatapk);
         mLlBlack = findViewById(R.id.ll_black);
         mIvShutownLogo = findViewById(R.id.iv_shutown_logo);
         mNavigationView.setItemIconTintList(null);
-        mIvShutownLogo.setOnClickListener(this);
         mFragmentManager = getSupportFragmentManager();
         mTvConnectionSystem = findViewById(R.id.connection_system);
         mTvSystemId = findViewById(R.id.tv_system_id);
@@ -106,7 +109,6 @@ public class HomeActivity extends MvpActivity<HomePresenter> implements HomeView
         mPreventSpeedClickUtil = new PreventSpeedClickUtil();
     }
 
-
     private void initEvent() {
         mNavigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
             @Override
@@ -122,7 +124,15 @@ public class HomeActivity extends MvpActivity<HomePresenter> implements HomeView
         mTvConnectionSystem.setOnClickListener(this);
         mTvUpdataAPK.setOnClickListener(this);
         mLlBlack.setOnClickListener(this);
-
+        mIvShutownLogo.setOnClickListener(this);
+        //长按退出程序。
+        LongClickUtils.setLongClick(new Handler(), mTvVersion1, 3000, new View.OnLongClickListener() {
+            @Override
+            public boolean onLongClick(View v) {
+                finish();
+                return false;
+            }
+        });
     }
 
     @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)

+ 86 - 0
app/src/main/java/com/sunzee/ui/dialog/WifiDetailDialog.java

@@ -0,0 +1,86 @@
+package com.sunzee.ui.dialog;
+
+import android.app.Activity;
+import android.app.Dialog;
+import android.content.Context;
+import android.support.annotation.NonNull;
+import android.view.View;
+import android.widget.Button;
+import android.widget.TextView;
+
+import com.sunzee.R;
+
+/**
+ * @author whw
+ * @time 2019/3/13
+ * @Description 普通样式弹框
+ */
+public class WifiDetailDialog extends Dialog implements View.OnClickListener {
+
+    public static final int OK = 2;
+    public static final int NO = 3;
+    private final Context mContext;
+    private Button mBtnConfirm;
+    private Button mBtnCancel;
+    private TextView mTvTitle;
+    private TextView mTvContent;
+
+    public void setListener(WifiDialog.DialogClickListener2 listener) {
+        this.listener = listener;
+    }
+
+    private WifiDialog.DialogClickListener2 listener;
+
+
+    public WifiDetailDialog(@NonNull Context context) {
+        super(context, R.style.DialogBgD);//加载样式
+        mContext = context;
+        setContentView(R.layout.dialog_normal);
+        initView();
+        initEvent();
+    }
+
+    private void initEvent() {
+        mBtnCancel.setOnClickListener(this);
+        mBtnConfirm.setOnClickListener(this);
+    }
+
+    protected void initView() {
+        mBtnConfirm = findViewById(R.id.btn_confirm);
+        mBtnCancel = findViewById(R.id.btn_cancel);
+        mTvTitle = findViewById(R.id.tv_title);
+        mTvContent = findViewById(R.id.tv_content);
+    }
+
+
+    public void setTitle(String title) {
+        mTvTitle.setText(title);
+    }
+
+    public void setContent(String content) {
+        mTvContent.setText(content);
+    }
+
+    public void setBtnText(String titile) {
+        mBtnConfirm.setText(titile);
+    }
+
+    @Override
+    public void onClick(View v) {
+
+        switch (v.getId()) {
+            case R.id.btn_cancel:
+                dismiss();
+                break;
+        }
+        listener.onClickListener(v.getId());
+
+    }
+
+
+    public interface DialogClickListener {
+
+        void onClickListener(int type);
+
+    }
+}

+ 406 - 0
app/src/main/java/com/sunzee/ui/dialog/WifiDialog.java

@@ -0,0 +1,406 @@
+package com.sunzee.ui.dialog;
+
+import android.app.Activity;
+import android.app.Dialog;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.net.NetworkInfo;
+import android.net.wifi.ScanResult;
+import android.net.wifi.WifiConfiguration;
+import android.net.wifi.WifiInfo;
+import android.net.wifi.WifiManager;
+import android.support.annotation.NonNull;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import android.util.Log;
+import android.view.View;
+import android.widget.ProgressBar;
+
+import com.sunzee.R;
+import com.sunzee.adapter.WifiListAdapter;
+import com.sunzee.model.AppConstants;
+import com.sunzee.model.domain.WifiBean;
+import com.sunzee.utils.CollectionUtils;
+import com.sunzee.utils.ToastUtil;
+import com.sunzee.utils.UiUtil;
+import com.sunzee.utils.WifiHelper;
+import com.sunzee.utils.WifiSupport;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * @author whw
+ * @time 2019/3/13
+ * @Description wifi列表
+ */
+public class WifiDialog extends Dialog implements View.OnClickListener {
+
+
+    private RecyclerView mRecyListWifi;
+    private ProgressBar mPdWifiLoading;
+
+    public void setListener(DialogClickListener listener) {
+        this.listener = listener;
+    }
+
+    private DialogClickListener listener;
+
+    private final Context mContext;
+    private static final String TAG = "wifidialog";
+
+    List<WifiBean> realWifiList;
+
+    private WifiListAdapter adapter;
+
+    private WifiBroadcastReceiver wifiReceiver;
+
+    private int connectType = 0;//1:连接成功? 2 正在连接(如果wifi热点列表发生变需要该字段)
+
+    private WifiHelper mWifiHelper;
+    private boolean is_password_error;
+    private static final List<String> ignoreSsid = Arrays.asList("0x", "<unknown ssid>");
+
+    public WifiDialog(@NonNull Context context) {
+
+        super(context, R.style.DialogBgD);//加载样式
+        mContext = context;
+        setContentView(R.layout.wifi_list_activity);
+        initView();
+    }
+
+    protected void initView() {
+        mRecyListWifi = findViewById(R.id.recy_list_wifi);
+        mPdWifiLoading = findViewById(R.id.pb_wifi_loading);
+        realWifiList = new ArrayList<>();
+        hidingProgressBar();
+        initData();
+        initListener();
+    }
+
+    private void initData() {
+        mWifiHelper = new WifiHelper(getContext());
+        //开启wifi
+        mWifiHelper.openWifi();
+        //开始扫描
+        mWifiHelper.startScan();
+        adapter = new WifiListAdapter(getContext(), realWifiList);
+        mRecyListWifi.setLayoutManager(new LinearLayoutManager(getContext()));
+//        binding.recyListWifi.addItemDecoration(new RecycleViewDivider(mContext, LinearLayoutManager.VERTICAL));
+        mRecyListWifi.setAdapter(adapter);
+    }
+
+    private void initListener() {
+
+
+        adapter.setOnItemClickListener(new WifiListAdapter.onItemClickListener() {
+            @Override
+            public void onItemClick(View view, int postion, Object o) {
+                WifiBean wifiBean = realWifiList.get(postion);
+
+                if (wifiBean.getState().equals(AppConstants.WIFI_STATE_UNCONNECT) || wifiBean.getState().equals(AppConstants.WIFI_STATE_CONNECT)) {
+                    String capabilities = realWifiList.get(postion).getCapabilities();
+
+                    if (WifiSupport.getWifiCipher(capabilities) == WifiSupport.WifiCipherType.WIFICIPHER_NOPASS) {
+                        //无需密码
+                        WifiConfiguration tempConfig = WifiSupport.isExsits(wifiBean.getWifiName(), getContext());
+                        if (tempConfig == null) {
+                            WifiConfiguration exsits = WifiSupport.createWifiConfig(wifiBean.getWifiName(), null, WifiSupport.WifiCipherType.WIFICIPHER_NOPASS);
+                            WifiSupport.addNetWork(exsits, getContext());
+                        } else {
+                            WifiSupport.addNetWork(tempConfig, getContext());
+                        }
+                    } else if (wifiBean.getState().equals(AppConstants.WIFI_STATE_CONNECT)) {
+                        //已连接 显示详情和取消保存
+
+                        showWifiDetailDialog(wifiBean.getWifiName());
+
+                    } else {   //需要密码,弹出输入密码dialog
+                        noConfigurationWifi(postion);
+                    }
+                }
+            }
+        });
+    }
+
+    /**
+     * 之前没有配置wifi, 弹出输入密码界面
+     *
+     * @param position
+     */
+    private void noConfigurationWifi(int position) {
+        showDialog(realWifiList.get(position).getWifiName(), realWifiList.get(position).getCapabilities());
+    }
+
+    @Override
+    public void onClick(View v) {
+        switch (v.getId()) {
+            case R.id.btn_cancel:
+                dismiss();
+                break;
+        }
+
+
+    }
+
+    @Override
+    public void show() {
+        super.show();
+        //注册广播
+        wifiReceiver = new WifiBroadcastReceiver();
+        IntentFilter filter = new IntentFilter();
+        filter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);//监听wifi是开关变化的状态
+        filter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);//监听wifi连接状态广播,是否连接了一个有效路由
+        filter.addAction(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION);//监听wifi列表变化(开启一个热点或者关闭一个热点)
+        filter.addAction(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION);
+        getContext().registerReceiver(wifiReceiver, filter);
+    }
+
+
+    @Override
+    public void dismiss() {
+        super.dismiss();
+        getContext().unregisterReceiver(wifiReceiver);
+        listener.onClickListener(0, "");
+    }
+
+    /**
+     * 监听wifi状态
+     * 当都没有可用连接,系统会连接已经保存的网路
+     */
+    public class WifiBroadcastReceiver extends BroadcastReceiver {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            if (WifiManager.WIFI_STATE_CHANGED_ACTION.equals(intent.getAction())) {//wifi开关状态
+                int state = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE, 0);
+                switch (state) {
+                    /**
+                     * WIFI_STATE_DISABLED    WLAN已经关闭
+                     * WIFI_STATE_DISABLING   WLAN正在关闭
+                     * WIFI_STATE_ENABLED     WLAN已经打开
+                     * WIFI_STATE_ENABLING    WLAN正在打开
+                     * WIFI_STATE_UNKNOWN     未知
+                     */
+                    case WifiManager.WIFI_STATE_DISABLED: {
+                        Log.d(TAG, "已经关闭");
+//                        setSwitchState(false);
+                        break;
+                    }
+                    case WifiManager.WIFI_STATE_DISABLING: {
+                        Log.d(TAG, "正在关闭");
+                        break;
+                    }
+                    case WifiManager.WIFI_STATE_ENABLED: {
+                        Log.d(TAG, "已经打开");
+//                        setSwitchState(true);
+                        break;
+                    }
+                    case WifiManager.WIFI_STATE_ENABLING: {
+                        Log.d(TAG, "正在打开");
+                        break;
+                    }
+                    case WifiManager.WIFI_STATE_UNKNOWN: {
+                        Log.d(TAG, "未知状态");
+                        break;
+                    }
+                }
+            } else if (WifiManager.NETWORK_STATE_CHANGED_ACTION.equals(intent.getAction())) {//wifi连接网络状态变化
+
+                NetworkInfo info = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
+                Log.d(TAG, "wifi连接网络状态变化:" + info.toString());
+                if (NetworkInfo.State.DISCONNECTED == info.getState()) {//wifi断开连接
+                    WifiInfo connectedWifiInfo = mWifiHelper.getConnectionWifiInfo();
+
+                    Log.i(TAG, "wifi断开连接:" + connectedWifiInfo.getSSID());
+                    if (ignoreSsid.contains(connectedWifiInfo.getSSID())) {
+                        return;
+                    }
+                    hidingProgressBar();
+                    for (int i = 0; i < realWifiList.size(); i++) {//没连接上将 所有的连接状态都置为“未连接”
+                        realWifiList.get(i).setState(AppConstants.WIFI_STATE_UNCONNECT);
+                    }
+                    if (adapter != null) {
+                        adapter.notifyDataSetChanged();
+                    }
+                    wifiErrorConnect(connectedWifiInfo.getSSID());
+                } else if (NetworkInfo.State.CONNECTED == info.getState()) {//wifi连接上了
+                    Log.i(TAG, "wifi已连接");
+                    ToastUtil.showToast(UiUtil.getStringRes(R.string.wifi_connection_successful));
+                    hidingProgressBar();
+                    WifiInfo connectedWifiInfo = mWifiHelper.getConnectionWifiInfo();
+                    is_password_error = false;
+                    connectType = 1;
+                    wifiListSet(connectedWifiInfo.getSSID(), connectType);
+                } else if (NetworkInfo.State.CONNECTING == info.getState()) {//正在连接
+                    Log.i(TAG, "wifi正在连接");
+                    WifiInfo connectedWifiInfo = mWifiHelper.getConnectionWifiInfo();
+                    if (ignoreSsid.contains(connectedWifiInfo.getSSID())) {
+                        return;
+                    }
+                    showProgressBar();
+                    connectType = 2;
+                    wifiListSet(connectedWifiInfo.getSSID(), connectType);
+                }
+            } else if (WifiManager.SCAN_RESULTS_AVAILABLE_ACTION.equals(intent.getAction())) {  //扫描结果
+                Log.i(TAG, "网络列表变化了");//几秒回调一次
+                wifiListChange();
+            } else if (intent.getAction().equals(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION)) {//密码错误
+                int linkWifiResult = intent.getIntExtra(WifiManager.EXTRA_SUPPLICANT_ERROR, 123);
+                Log.e(TAG, "linkWifiResult:" + linkWifiResult);
+                if (linkWifiResult == WifiManager.ERROR_AUTHENTICATING) {
+                    ToastUtil.showToast(UiUtil.getStringRes(R.string.wifimmcw));
+                    Log.d(TAG, "wifi密码错误: ");
+                }
+            }
+
+        }
+    }
+
+    /**
+     * wifi连接失败,弹出输入框输入密码
+     *
+     * @param ssid
+     */
+    private void wifiErrorConnect(String ssid) {
+        if (is_password_error) {
+            return;
+        }
+        is_password_error = true;//只弹出一次
+        if (CollectionUtils.isNullOrEmpty(realWifiList)) {
+            return;
+        }
+        WifiBean wifiBean = null;
+        for (int i = 0; i < realWifiList.size(); i++) {
+            wifiBean = realWifiList.get(i);
+            if (("\"" + wifiBean.getWifiName() + "\"").equals(ssid)) {
+                Log.i(TAG, "列表存在改wifi:" + ssid);
+                break;
+            }
+        }
+    }
+
+    /**
+     * wifi列表改变
+     */
+    public void wifiListChange() {
+        convertScanResult();
+        WifiInfo connectedWifiInfo = mWifiHelper.getConnectionWifiInfo();
+        wifiListSet(connectedWifiInfo.getSSID(), connectType);
+    }
+
+    /**
+     * 获取wifi列表然后将bean转成自己定义的WifiBean
+     */
+    public void convertScanResult() {
+        List<ScanResult> scanResults = mWifiHelper.getFilterScanResult();
+        realWifiList.clear();
+        if (!CollectionUtils.isNullOrEmpty(scanResults)) {
+            for (int i = 0; i < scanResults.size(); i++) {
+                WifiBean wifiBean = new WifiBean();
+                ScanResult scanResult = scanResults.get(i);
+                wifiBean.setWifiName(scanResult.SSID);
+                wifiBean.setState(AppConstants.WIFI_STATE_UNCONNECT);   //只要获取都假设设置成未连接,真正的状态都通过广播来确定
+                wifiBean.setCapabilities(scanResult.capabilities);
+                wifiBean.setLevel(String.valueOf(mWifiHelper.getLevel(scanResult.level)));
+                wifiBean.setScanResult(scanResult);
+                realWifiList.add(wifiBean);
+            }
+        }
+    }
+
+
+    /**
+     * 将"已连接"或者"正在连接"的wifi热点放置在第一个位置
+     *
+     * @param wifiName
+     * @param type
+     */
+    public void wifiListSet(String wifiName, int type) {
+        int index = -1;
+        WifiBean wifiInfo = new WifiBean();
+        if (CollectionUtils.isNullOrEmpty(realWifiList)) {
+            return;
+        }
+        Collections.sort(realWifiList);//根据信号强度排序
+        for (int i = 0; i < realWifiList.size(); i++) {
+            WifiBean wifiBean = realWifiList.get(i);
+            if (index == -1 && ("\"" + wifiBean.getWifiName() + "\"").equals(wifiName)) {
+                index = i;
+                wifiInfo.setLevel(wifiBean.getLevel());
+                wifiInfo.setWifiName(wifiBean.getWifiName());
+                wifiInfo.setCapabilities(wifiBean.getCapabilities());
+                wifiInfo.setScanResult(wifiBean.getScanResult());
+                if (type == 1) {
+                    wifiInfo.setState(AppConstants.WIFI_STATE_CONNECT);
+                } else {
+                    wifiInfo.setState(AppConstants.WIFI_STATE_ON_CONNECTING);
+                }
+            }
+        }
+        if (index != -1) {
+            realWifiList.remove(index);
+            realWifiList.add(0, wifiInfo);
+            adapter.notifyDataSetChanged();
+        } else {
+            adapter.notifyDataSetChanged();
+        }
+    }
+
+
+    public void showProgressBar() {
+        mPdWifiLoading.setVisibility(View.VISIBLE);
+    }
+
+    public void hidingProgressBar() {
+        mPdWifiLoading.setVisibility(View.GONE);
+    }
+
+    private WifiLinkDialog dialog;
+
+    private void showDialog(String title, String capabilities) {
+        dialog = new WifiLinkDialog(mContext);
+        dialog.setTitle(title);
+        dialog.setCanceledOnTouchOutside(true);
+        dialog.setCapabilities(capabilities);
+        dialog.show();
+    }
+
+    private WifiDetailDialog wifiDetailDialog;
+
+    private void showWifiDetailDialog(String title) {
+        wifiDetailDialog = new WifiDetailDialog(mContext);
+        wifiDetailDialog.setTitle(title);
+        wifiDetailDialog.setContent(UiUtil.getStringRes(R.string.unsav_wifi));
+        wifiDetailDialog.setBtnText(UiUtil.getStringRes(R.string.unsav_wifi1));
+        wifiDetailDialog.setListener(new DialogClickListener2() {
+            @Override
+            public void onClickListener(int type) {
+                switch (type) {
+                    case R.id.btn_confirm:
+                        WifiInfo wifiInfo = mWifiHelper.getConnectionWifiInfo();
+                        WifiHelper wifiHelper = new WifiHelper(mContext);
+                        wifiHelper.removeWifiBySsid(wifiInfo.getSSID());
+                        wifiHelper.startScan();
+                        wifiDetailDialog.dismiss();
+                        break;
+                }
+            }
+        });
+        wifiDetailDialog.show();
+    }
+
+    public interface DialogClickListener {
+
+        void onClickListener(int type, String text);
+    }
+
+    public interface DialogClickListener2 {
+
+        void onClickListener(int type);
+
+    }
+}

+ 110 - 0
app/src/main/java/com/sunzee/ui/dialog/WifiLinkDialog.java

@@ -0,0 +1,110 @@
+package com.sunzee.ui.dialog;
+
+import android.app.Activity;
+import android.app.Dialog;
+import android.content.Context;
+import android.support.annotation.NonNull;
+import android.view.View;
+import android.view.inputmethod.InputMethodManager;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.TextView;
+
+import com.sunzee.R;
+import com.sunzee.utils.WifiHelper;
+
+/**
+ * @author whw
+ * @time 2019/3/13
+ * @Description 连接wifi
+ */
+public class WifiLinkDialog extends Dialog implements View.OnClickListener {
+
+
+    private String text_nameString = null;
+
+    private String capabilities;
+
+    private Context mContext;
+    private Button mBtnApplay;
+    private TextView mTvTitle;
+    private EditText mEtServerId;
+
+
+    public void setListener(DialogClickListener listener) {
+        this.listener = listener;
+    }
+
+    private DialogClickListener listener;
+
+    public WifiLinkDialog(@NonNull Context context) {
+        super(context, R.style.DialogBgD);//加载样式
+        mContext = context;
+        setContentView(R.layout.dialog_et);
+        initView();
+        initEvent();
+    }
+
+    private void initEvent() {
+        mBtnApplay.setOnClickListener(this);
+    }
+
+    protected void initView() {
+        mBtnApplay = findViewById(R.id.btn_apply);
+        mBtnApplay = findViewById(R.id.btn_apply);
+        mTvTitle = findViewById(R.id.tv_title);
+        mEtServerId = findViewById(R.id.et_server_id);
+    }
+
+    public void setTitle(String text){
+        text_nameString=text;
+        mTvTitle.setText(text_nameString);
+        mEtServerId.setHint(R.string.hint_pas);
+        mBtnApplay.setText(R.string.ljlj);
+    }
+
+
+
+    @Override
+    public void onClick(View v) {
+        switch (v.getId()){
+            case R.id.btn_apply:
+                String pwd = mEtServerId.getText().toString();
+                WifiHelper wifiHelper = new WifiHelper(getContext());
+                wifiHelper.connectWifi(text_nameString, pwd, capabilities);
+                hintKeyBoard();
+                dismiss();
+                break;
+        }
+
+    }
+
+    public void setCapabilities(String capabilities) {
+        this.capabilities = capabilities;
+    }
+
+    @Override
+    public void dismiss() {
+        super.dismiss();
+    }
+
+
+    public void hintKeyBoard() {
+        //拿到InputMethodManager
+        InputMethodManager imm = (InputMethodManager)mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
+        //如果window上view获取焦点 && view不为空
+        if(imm.isActive()&&getCurrentFocus()!=null) {
+            //拿到view的token 不为空
+            if (getCurrentFocus().getWindowToken() != null) {
+                //表示软键盘窗口总是隐藏,除非开始时以SHOW_FORCED显示。
+                imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
+            }
+        }
+    }
+
+    public interface DialogClickListener {
+
+        void onClickListener(int type,String text);
+    }
+
+}

+ 10 - 0
app/src/main/java/com/sunzee/ui/fragment/HomepageFragment.java

@@ -67,12 +67,22 @@ public class HomepageFragment extends MvpFragment<HomePagePresenter> implements
                     return;
                 }
                 Map<String, List<Float>> location = Hawk.get("location", null);
+                Log.d(TAG, "onClick: "+location);
                 if (location != null) {
+                    //给控件新位置,替换之前的位置。
                     for (String s : location.keySet()) {
+                        Log.d(TAG, "onClick: "+s );
                         if (integerMap.containsKey(s)) {
                             location.put(s, integerMap.get(s));
                         }
                     }
+                    //没有变化过位置的也加进去。
+                    for (String s : integerMap.keySet()) {
+                        Log.d(TAG, "onClick: "+s );
+                        if (!location.containsKey(s)) {
+                            location.put(s, integerMap.get(s));
+                        }
+                    }
                     Hawk.put("location", location);
                 } else {
                     Hawk.put("location", integerMap);

+ 259 - 2
app/src/main/java/com/sunzee/ui/fragment/OtherFragment.java

@@ -1,32 +1,209 @@
 package com.sunzee.ui.fragment;
 
+import android.content.Context;
+import android.content.IntentFilter;
+import android.media.AudioManager;
+import android.net.ConnectivityManager;
+import android.net.NetworkInfo;
+import android.net.wifi.WifiManager;
 import android.os.Bundle;
+import android.provider.Settings;
 import android.support.annotation.NonNull;
 import android.support.annotation.Nullable;
+import android.telephony.TelephonyManager;
+import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
+import android.view.Window;
+import android.view.WindowManager;
+import android.widget.RadioButton;
+import android.widget.SeekBar;
 
+import com.orhanobut.hawk.Hawk;
 import com.sunzee.R;
+import com.sunzee.base.BaseApplication;
 import com.sunzee.base.MvpFragment;
+import com.sunzee.model.domain.Name;
+import com.sunzee.model.message.NetMessageEvent;
 import com.sunzee.mvp.other.OtherPresenter;
 import com.sunzee.mvp.other.OtherView;
+import com.sunzee.receiver.NetworkConnectChangedReceiver;
+import com.sunzee.ui.dialog.WifiDialog;
+
+import org.greenrobot.eventbus.EventBus;
+import org.greenrobot.eventbus.Subscribe;
+import org.greenrobot.eventbus.ThreadMode;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
 
 /**
  * 其他页界面 fragment
+ * 1.4G和wifi的切换的功能
+ * 2.亮度
+ * 3.音量
+ * 4.机器联系人
+ * 5.长按退出程序
+ * 6.长按重启触摸屏。
  */
-public class OtherFragment extends MvpFragment<OtherPresenter> implements OtherView {
+public class OtherFragment extends MvpFragment<OtherPresenter> implements OtherView, SeekBar.OnSeekBarChangeListener, View.OnClickListener {
+
+    private SeekBar mSbLight;
+    private SeekBar mSbVoice;
+    private AudioManager am;
+    private static final String TAG = "OtherFragment";
+    private RadioButton mRbMobileNetWork;
+    private RadioButton mRbWifi;
+    private NetworkConnectChangedReceiver receiver;
 
     @Nullable
     @Override
     public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
         View inflate = inflater.inflate(R.layout.fragment_other, container, false);
+        initView(inflate);
+        initEvent();
         return inflate;
     }
 
+    private void initEvent() {
+        //如果进度条发生改变
+        mSbLight.setOnSeekBarChangeListener(this);
+        //如果进度条发生改变
+        mSbVoice.setOnSeekBarChangeListener(this);
+        mRbMobileNetWork.setOnClickListener(this);
+        mRbWifi.setOnClickListener(this);
+    }
+
+    private void initView(View inflate) {
+        mSbLight = inflate.findViewById(R.id.sb_light);
+        mSbVoice = inflate.findViewById(R.id.sb_voice);
+        mRbMobileNetWork = inflate.findViewById(R.id.rb_4g);
+        mRbWifi = inflate.findViewById(R.id.rb_wifi);
+    }
+
+    @Override
+    public void onStart() {
+        super.onStart();
+        EventBus.getDefault().register(this);
+        //每次界面刷新都需要重新获取音量和亮度
+        initSeekBar();
+        //初始化选择的网络:wifi还是移动4g
+        initNetwork();
+    }
+
+    @Override
+    public void onStop() {
+        super.onStop();
+        EventBus.getDefault().unregister(this);
+        getActivity().unregisterReceiver(receiver);
+    }
+
+    @Override
+    public void onDestroy() {
+        super.onDestroy();
+
+    }
+
+    /**
+     * 初始化网络类型
+     * 1.开启广播监听当前网络类型时
+     */
+    private void initNetwork() {
+        IntentFilter filter = new IntentFilter();
+        filter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);
+        filter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
+        filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
+        receiver = new NetworkConnectChangedReceiver();
+        getActivity().registerReceiver(receiver, filter);
+        int netType = Hawk.get(Name.NET_TYPE, -1);
+        if (netType == 0) {
+            mRbMobileNetWork.setChecked(true);
+        } else if (netType == 1) {
+            mRbWifi.setChecked(true);
+        }
+    }
+
+
+    //如果网络类型发生改变,那么就会到这里设置选中的一个方式。
+    @Subscribe(threadMode = ThreadMode.MAIN)
+    public void event(NetMessageEvent messageEvent) {
+        switch (messageEvent.getType()) {
+            case wifi:
+                mRbWifi.setChecked(true);
+                break;
+            case mobile:
+                mRbMobileNetWork.setChecked(true);
+                break;
+        }
+    }
+
+    private WifiDialog wifiDialog;
+    //避免重复触发点击事件
+    private boolean isCanClick = true;
+
+    private void showWifiDialog() {
+        if (wifiDialog == null) {
+            wifiDialog = new WifiDialog(this.getContext());
+        }
+        wifiDialog.setCanceledOnTouchOutside(true);
+        wifiDialog.setListener(new WifiDialog.DialogClickListener() {
+            @Override
+            public void onClickListener(int type, String text) {
+                int apnType = getAPNType(BaseApplication.getContext());
+                Log.d(TAG, "onClickListener: apnType " + apnType);
+                if (apnType == 1) {
+                    Log.d(TAG, "onClickListener: wifi");
+                    isCanClick = true;
+                    mRbWifi.setChecked(true);
+
+                } else if (apnType == 2 || apnType == 3) {
+                    Log.d(TAG, "onClickListener: dismiss 4g");
+                    isCanClick = false;
+                    mRbMobileNetWork.setChecked(true);
+
+
+                }
+            }
+        });
+        wifiDialog.show();
+    }
+
+    /**
+     * 获取网络状态 没有网络0:WIFI网络1:3G网络2:2G网络3
+     *
+     * @param context
+     * @return
+     */
+    public int getAPNType(Context context) {
+        int netType = 0;
+        ConnectivityManager connMgr = (ConnectivityManager) context
+                .getSystemService(Context.CONNECTIVITY_SERVICE);
+        NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
+        if (networkInfo == null) {
+            return netType;
+        }
+        int nType = networkInfo.getType();
+        if (nType == ConnectivityManager.TYPE_WIFI) {
+            netType = 1;// wifi
+        } else if (nType == ConnectivityManager.TYPE_MOBILE) {
+            int nSubType = networkInfo.getSubtype();
+            TelephonyManager mTelephony = (TelephonyManager) context
+                    .getSystemService(Context.TELEPHONY_SERVICE);
+            if (nSubType == TelephonyManager.NETWORK_TYPE_UMTS
+                    && !mTelephony.isNetworkRoaming()) {
+                netType = 2;// 3G
+            } else {
+                netType = 3;// 2G
+            }
+        }
+        return netType;
+    }
+
     @Override
     protected OtherPresenter createPresenter() {
-        return null;
+        return new OtherPresenter(this);
     }
 
     @Override
@@ -38,4 +215,84 @@ public class OtherFragment extends MvpFragment<OtherPresenter> implements OtherV
     public void hideLoading() {
 
     }
+
+    //------------------------------------------------ seekbar 数值改变的方法重写
+    @Override
+    public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
+        switch (seekBar.getId()) {
+            case R.id.sb_light:
+                //todo 测试不了,因为没有设备亮度可调。
+                int seekBarProgress = seekBar.getProgress();
+                changeAppBrightness(seekBarProgress);
+                break;
+            case R.id.sb_voice:
+                am.setStreamVolume(AudioManager.STREAM_MUSIC, progress, 0);
+                int currentVolume = am.getStreamVolume(AudioManager.STREAM_MUSIC);
+                seekBar.setProgress(currentVolume);
+                break;
+        }
+    }
+
+    @Override
+    public void onStartTrackingTouch(SeekBar seekBar) {
+    }
+
+    @Override
+    public void onStopTrackingTouch(SeekBar seekBar) {
+    }
+
+    //------------------------------------------------ seekbar 数值改变的方法重写
+
+    /**
+     * 获取系统亮度和音量,初始化。
+     */
+    private void initSeekBar() {
+        //设置最大值音量
+        am = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE);
+        int maxVolume = am.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
+        mSbVoice.setMax(maxVolume);
+        //设置当前音量
+        int currentVolume = am.getStreamVolume(AudioManager.STREAM_MUSIC);
+        mSbVoice.setProgress(currentVolume);
+        //亮度
+        mSbLight.setMax(255);
+        try {
+            int anInt = Settings.System.getInt(getContext().getContentResolver(), Settings.System.SCREEN_BRIGHTNESS);
+            mSbLight.setProgress(anInt);
+        } catch (Settings.SettingNotFoundException e) {
+            Log.d(TAG, "initSeekBar: 获取系统亮度失败");
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * 设置系统亮度
+     *
+     * @param brightness
+     */
+    public void changeAppBrightness(int brightness) {
+        Window window = getActivity().getWindow();
+        WindowManager.LayoutParams lp = window.getAttributes();
+        if (brightness == -1) {
+            lp.screenBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE;
+        } else {
+            lp.screenBrightness = (brightness <= 0 ? 1 : brightness) / 255f;
+        }
+        window.setAttributes(lp);
+    }
+
+    @Override
+    public void onClick(View v) {
+        switch (v.getId()) {
+            case R.id.rb_4g:
+                mvpPresenter.toggleWiFi(BaseApplication.getContext(), false);
+                mvpPresenter.toggleMobileData(BaseApplication.getContext(), true);
+                break;
+            case R.id.rb_wifi:
+                mvpPresenter.toggleMobileData(BaseApplication.getContext(), false);
+                mvpPresenter.toggleWiFi(BaseApplication.getContext(), true);
+                showWifiDialog();
+                break;
+        }
+    }
 }

+ 1 - 1
app/src/main/java/com/sunzee/ui/view/CustomView.java

@@ -65,7 +65,7 @@ public class CustomView extends TextView {
                 int mOffsetY = y - moveY;
                 Log.d(TAG, "mOffsetX: "+mOffsetX);
                 Log.d(TAG, "mOffsetY: "+mOffsetY);
-                if (mOffsetX>5||mOffsetY>5||mOffsetX<-5||mOffsetY<-5){
+                if (mOffsetX>2||mOffsetY>2||mOffsetX<-2||mOffsetY<-2){
                     ismove = true;
                     Log.d(TAG, "ACTION_MOVE: "+ismove);
                 }

+ 4 - 0
app/src/main/java/com/sunzee/ui/view/CustomViewGrounp.java

@@ -135,14 +135,18 @@ public class CustomViewGrounp extends ViewGroup implements CustomView.Informatio
     @Override
     public void setInformationLocationListener(View view, List<Float> list, boolean ismove) {
         this.ismove = ismove;
+        Log.d(TAG, "setInformationLocationListener: "+view.getId());
         switch (view.getId()) {
             case R.id.cv_0:
+                Log.d(TAG, "setInformationLocationListener: cv_0");
                 mIntegerMap1.put("0", list);
                 break;
             case R.id.cv_1:
+                Log.d(TAG, "setInformationLocationListener: cv_1");
                 mIntegerMap1.put("1", list);
                 break;
             case R.id.cv_2:
+                Log.d(TAG, "setInformationLocationListener: cv_2");
                 mIntegerMap1.put("2", list);
                 break;
             case R.id.cv_3:

+ 24 - 0
app/src/main/java/com/sunzee/utils/CollectionUtils.java

@@ -0,0 +1,24 @@
+package com.sunzee.utils;
+
+import java.util.Collection;
+
+/**
+ * @author whw
+ * @time 2019/5/16
+ * @Description 集合操作工具类
+ */
+public class CollectionUtils {
+
+    /**
+     * 判断集合是否为null或者0个元素
+     *
+     * @param c
+     * @return
+     */
+    public static boolean isNullOrEmpty(Collection c) {
+        if (null == c || c.isEmpty()) {
+            return true;
+        }
+        return false;
+    }
+}

+ 426 - 0
app/src/main/java/com/sunzee/utils/WifiHelper.java

@@ -0,0 +1,426 @@
+package com.sunzee.utils;
+
+import android.content.Context;
+import android.net.ConnectivityManager;
+import android.net.NetworkInfo;
+import android.net.wifi.ScanResult;
+import android.net.wifi.WifiConfiguration;
+import android.net.wifi.WifiInfo;
+import android.net.wifi.WifiManager;
+import android.text.TextUtils;
+import android.util.Log;
+
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+
+/**
+ * wifi操作辅助类
+ *
+ * @author Kelly
+ * @version 1.0.0
+ * @filename WifiHelper.java
+ * @time 2019/3/13 13:48
+ * @copyright(C) 2019 xxx有限公司
+ */
+public class WifiHelper {
+    private static final String TAG = "WifiHelper";
+    private Context context;
+
+    /**
+     * 定义一个WifiManager对象,提供Wifi管理的各种主要API,主要包含wifi的扫描、建立连接、配置信息等
+     */
+    private WifiManager mWifiManager;
+
+
+    public WifiHelper(Context context) {
+        this.context = context;
+        // 获得WifiManager对象
+        mWifiManager = (WifiManager) context
+                .getSystemService(Context.WIFI_SERVICE);
+    }
+
+
+    /**
+     * 打开wifi
+     */
+    public void openWifi() {
+        if (!mWifiManager.isWifiEnabled()) {
+            mWifiManager.setWifiEnabled(true);
+        }
+    }
+
+    /**
+     * 关闭wifi
+     */
+    public void closeWifi() {
+        mWifiManager.setWifiEnabled(false);
+    }
+
+    /**
+     * 判断wifi是否打开
+     *
+     * @return
+     */
+    public boolean isWifiEnabled() {
+        WifiManager wifimanager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
+        return wifimanager.isWifiEnabled();
+    }
+
+    /**
+     * wifi扫描
+     */
+    public void startScan() {
+        boolean scanResult = mWifiManager.startScan(); //最好检查下返回值,因为这个方法可能会调用失败
+        Log.i(TAG, "scanResult: " + scanResult);
+    }
+
+
+    /**
+     * 断开指定ID的网络
+     *
+     * @param netId
+     */
+    public void disConnectionWifi(int netId) {
+        mWifiManager.disableNetwork(netId);
+        mWifiManager.disconnect();
+    }
+
+
+    /**
+     * 判断当前是否已经连接
+     *
+     * @param ssid
+     * @return
+     */
+    public boolean isGivenWifiConnect(String ssid) {
+        return isWifiConnected() && getCurrentWifiSSID().equals(ssid);
+    }
+
+    /**
+     * 得到当前连接的WiFi  SSID
+     *
+     * @return
+     */
+    public String getCurrentWifiSSID() {
+        String ssid = mWifiManager.getConnectionInfo().getSSID();
+        if (ssid.substring(0, 1).equals("\"")
+                && ssid.substring(ssid.length() - 1).equals("\"")) {
+            ssid = ssid.substring(1, ssid.length() - 1);
+        }
+        return trimSSID(ssid);
+    }
+
+    /**
+     * 获取到的wifi名称前后可能带有引号
+     *
+     * @param ssid
+     * @return
+     */
+    public String trimSSID(String ssid) {
+        if (ssid.substring(0, 1).equals("\"")
+                && ssid.substring(ssid.length() - 1).equals("\"")) {
+            ssid = ssid.substring(1, ssid.length() - 1);
+        }
+        return ssid;
+    }
+
+
+    /**
+     * 是否处于wifi连接的状态
+     */
+    public boolean isWifiConnected() {
+        ConnectivityManager connManager = (ConnectivityManager) context
+                .getSystemService(Context.CONNECTIVITY_SERVICE);
+        NetworkInfo wifiNetworkInfo = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
+        if (wifiNetworkInfo.isConnected()) {
+            return true;
+        } else if (wifiNetworkInfo.isAvailable()) {
+            return true;
+        }
+        return false;
+    }
+
+
+    /**
+     * 连接wifi
+     *
+     * @param ssid         服务标志
+     * @param password     密码
+     * @param capabilities 安全性
+     * @return
+     */
+    public boolean connectWifi(String ssid, String password, String capabilities) {
+        WifiConfiguration mWifiConfiguration;
+        //检测指定SSID的WifiConfiguration 是否存在
+        WifiConfiguration tempConfig = isExsits(ssid);
+        boolean enabled;
+        if (tempConfig == null) {
+            //创建一个新的WifiConfiguration ,CreateWifiInfo()需要自己实现
+            mWifiConfiguration = createWifiInfo(ssid, password, getWifiCipherWay(capabilities));
+            int wcgID = mWifiManager.addNetwork(mWifiConfiguration);
+            enabled = mWifiManager.enableNetwork(wcgID, true);
+        } else {
+            //发现指定WiFi,并且这个WiFi以前连接成功过
+            mWifiConfiguration = tempConfig;
+            enabled = mWifiManager.enableNetwork(mWifiConfiguration.networkId, true);
+
+        }
+        Log.i(TAG, "enableNetwork:" + enabled);
+        if (enabled) { //若失败,则连接之前成功过的网络
+            boolean reconnect = mWifiManager.reconnect();
+            Log.i(TAG, "reconnect:" + reconnect);
+        }
+        return enabled;
+    }
+
+    /**
+     * 添加一个网络并连接
+     *
+     * @param ssid           服务标志
+     * @param password       密码
+     * @param wifiCipherType 安全性枚举
+     */
+    public void addNetwork(String ssid, String password, WifiCipherType wifiCipherType) {
+        switch (wifiCipherType) {
+            case WIFICIPHER_NOPASS:
+                connectWifi(ssid, password, "NONE");
+                break;
+            case WIFICIPHER_WPA:
+                connectWifi(ssid, password, "WPA");
+                break;
+            case WIFICIPHER_WEP:
+                connectWifi(ssid, password, "WEP");
+                break;
+            default:
+                break;
+        }
+    }
+
+
+    /**
+     * 移除某一个网络
+     *
+     * @param netId
+     */
+    private boolean removeNetwork(int netId) {
+        boolean removeNetwork = mWifiManager.removeNetwork(netId);
+        mWifiManager.saveConfiguration();
+        Log.i(TAG, "removeNetwork: " + removeNetwork);
+        return removeNetwork;
+    }
+
+    /**
+     * 忘记密码,并断开网路连接
+     *
+     * @param targetSsid
+     */
+    public void removeWifiBySsid(String targetSsid) {
+        Log.d(TAG, "try to removeWifiBySsid, targetSsid=" + targetSsid);
+        //返回已经配置的WifiConfiguration对象列表
+        List<WifiConfiguration> wifiConfigs = mWifiManager.getConfiguredNetworks();
+        for (WifiConfiguration wifiConfig : wifiConfigs) {
+            String ssid = wifiConfig.SSID;
+            if (ssid.equals(targetSsid)) {
+                Log.d(TAG, "removeWifiBySsid success, SSID = " + wifiConfig.SSID + " netId = " + String.valueOf(wifiConfig.networkId));
+                disConnectionWifi(wifiConfig.networkId);
+                removeNetwork(wifiConfig.networkId);
+            }
+        }
+    }
+
+
+    /**
+     * 创建一个wifi连接配置
+     *
+     * @param SSID
+     * @param Password
+     * @param Type
+     * @return
+     */
+    public WifiConfiguration createWifiInfo(String SSID, String Password,
+                                            WifiCipherType Type) {
+        WifiConfiguration config = new WifiConfiguration();
+        config.allowedAuthAlgorithms.clear();
+        config.allowedGroupCiphers.clear();
+        config.allowedKeyManagement.clear();
+        config.allowedPairwiseCiphers.clear();
+        config.allowedProtocols.clear();
+        config.SSID = "\"" + SSID + "\"";
+        WifiConfiguration tempConfig = this.isExsits(SSID);
+        if (tempConfig != null) {
+            mWifiManager.removeNetwork(tempConfig.networkId);
+        }
+
+        if (Type == WifiCipherType.WIFICIPHER_NOPASS) // WIFICIPHER_NOPASS
+        {
+            config.wepKeys[0] = "";
+            config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
+            config.wepTxKeyIndex = 0;
+        }
+        if (Type == WifiCipherType.WIFICIPHER_WEP) // WIFICIPHER_WEP
+        {
+            config.hiddenSSID = true;
+            config.wepKeys[0] = "\"" + Password + "\"";
+            config.allowedAuthAlgorithms
+                    .set(WifiConfiguration.AuthAlgorithm.SHARED);
+            config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
+            config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
+            config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40);
+            config.allowedGroupCiphers
+                    .set(WifiConfiguration.GroupCipher.WEP104);
+            config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
+            config.wepTxKeyIndex = 0;
+        }
+        if (Type == WifiCipherType.WIFICIPHER_WPA) // WIFICIPHER_WPA
+        {
+            config.preSharedKey = "\"" + Password + "\"";
+            config.hiddenSSID = true;
+            config.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN);
+            config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
+            config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
+            config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);
+            // config.allowedProtocols.set(WifiConfiguration.Protocol.WPA);
+            config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
+            config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);
+            config.status = WifiConfiguration.Status.ENABLED;
+        }
+        return config;
+    }
+
+
+    /**
+     * 查看以前是否也配置过这个网络
+     *
+     * @param ssid
+     * @return
+     */
+    public WifiConfiguration isExsits(String ssid) {
+        List<WifiConfiguration> existingConfigs = mWifiManager.getConfiguredNetworks();
+        for (WifiConfiguration existingConfig : existingConfigs) {
+            if (existingConfig.SSID.equals("\"" + ssid + "\"")) {
+                return existingConfig;
+            }
+        }
+        return null;
+    }
+
+    /**
+     * 加密方式枚举
+     */
+    public enum WifiCipherType {
+        WIFICIPHER_WEP, WIFICIPHER_WPA, WIFICIPHER_NOPASS, WIFICIPHER_INVALID
+    }
+
+
+    /**
+     * 判断wifi支持的加密方式
+     *
+     * @param capabilities
+     */
+    public WifiCipherType getWifiCipherWay(String capabilities) {
+        if (TextUtils.isEmpty(capabilities)) {
+            return WifiCipherType.WIFICIPHER_INVALID;//无效
+        } else if (capabilities.contains("WEP")) {
+            return WifiCipherType.WIFICIPHER_WEP;
+        } else if (capabilities.contains("WPA") || capabilities.contains("WPA2") || capabilities.contains("WPS")) {
+            return WifiCipherType.WIFICIPHER_WPA;
+        } else {
+            return WifiCipherType.WIFICIPHER_NOPASS;
+        }
+    }
+
+
+    /**
+     * 获得手机扫描到的所有wifi的信息
+     */
+    public List<ScanResult> getScanResults() {
+        return mWifiManager.getScanResults();
+    }
+
+
+    /**
+     * 以 SSID 为关键字,过滤掉信号弱的选项
+     *
+     * @param scanResults
+     * @return
+     */
+    public List<ScanResult> filterScanResult(List<ScanResult> scanResults) {
+        Map<String, ScanResult> linkedMap = new LinkedHashMap<>(scanResults.size());
+        for (ScanResult rst : scanResults) {
+            if (!TextUtils.isEmpty(rst.SSID)) {
+                if (linkedMap.containsKey(rst.SSID)) {
+                    if (rst.level > linkedMap.get(rst.SSID).level) {
+                        linkedMap.put(rst.SSID, rst);
+                    }
+                    continue;
+                }
+                linkedMap.put(rst.SSID, rst);
+            } else {
+                continue;
+            }
+        }
+        scanResults.clear();
+        scanResults.addAll(linkedMap.values());
+        return scanResults;
+    }
+
+    /**
+     * 获取过滤的wifi扫描列表(过滤重复项)
+     *
+     * @return
+     */
+    public List<ScanResult> getFilterScanResult() {
+        return filterScanResult(getScanResults());
+    }
+
+
+    /**
+     * 获取当前已连接上的wifi的信息
+     *
+     * @return
+     */
+    public WifiInfo getConnectionWifiInfo() {
+        // 取得WifiInfo对象
+        return mWifiManager.getConnectionInfo();
+    }
+
+    /**
+     * 获取已经保存的网络列表
+     */
+    public List<WifiConfiguration> getConfiguredNetworks() {
+        return mWifiManager.getConfiguredNetworks();
+    }
+
+    /**
+     * wifi ip地址转换
+     *
+     * @param i
+     * @return
+     */
+    public String intToIp(int i) {
+
+        return (i & 0xFF) + "." +
+                ((i >> 8) & 0xFF) + "." +
+                ((i >> 16) & 0xFF) + "." +
+                (i >> 24 & 0xFF);
+    }
+
+    /**
+     * 返回wifi level 等级
+     */
+    public int getLevel(int level) {
+        if (Math.abs(level) < 50) {
+            return 1;
+        } else if (Math.abs(level) < 75) {
+            return 2;
+        } else if (Math.abs(level) < 90) {
+            return 3;
+        } else {
+            return 4;
+        }
+    }
+
+
+}

+ 280 - 0
app/src/main/java/com/sunzee/utils/WifiSupport.java

@@ -0,0 +1,280 @@
+package com.sunzee.utils;
+
+import android.content.Context;
+import android.net.wifi.ScanResult;
+import android.net.wifi.WifiConfiguration;
+import android.net.wifi.WifiInfo;
+import android.net.wifi.WifiManager;
+import android.text.TextUtils;
+
+import com.sunzee.model.domain.WifiBean;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * Created by ${GuoZhaoHui} on 2017/11/27.
+ * Email:guozhaohui628@gmail.com
+ */
+
+public class WifiSupport {
+
+    private static final String TAG = "WifiSupport";
+
+    public enum WifiCipherType {
+        WIFICIPHER_WEP, WIFICIPHER_WPA, WIFICIPHER_NOPASS, WIFICIPHER_INVALID
+    }
+
+    public WifiSupport() {
+    }
+
+    public static List<ScanResult> getWifiScanResult(Context context) {
+        boolean b = context == null;
+        return ((WifiManager) context.getSystemService(Context.WIFI_SERVICE)).getScanResults();
+    }
+
+    public static boolean isWifiEnable(Context context) {
+        return ((WifiManager) context.getSystemService(Context.WIFI_SERVICE)).isWifiEnabled();
+    }
+
+    public static WifiInfo getConnectedWifiInfo(Context context) {
+        return ((WifiManager) context.getSystemService(Context.WIFI_SERVICE)).getConnectionInfo();
+    }
+
+    public static List getConfigurations(Context context) {
+        return ((WifiManager) context.getSystemService(Context.WIFI_SERVICE)).getConfiguredNetworks();
+    }
+
+
+    public static WifiConfiguration createWifiConfig(String SSID, String password, WifiCipherType type) {
+
+        WifiConfiguration config = new WifiConfiguration();
+        config.allowedAuthAlgorithms.clear();
+        config.allowedGroupCiphers.clear();
+        config.allowedKeyManagement.clear();
+        config.allowedPairwiseCiphers.clear();
+        config.allowedProtocols.clear();
+        config.SSID = "\"" + SSID + "\"";
+
+        if (type == WifiCipherType.WIFICIPHER_NOPASS) {
+//            config.wepKeys[0] = "";  //注意这里
+            config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
+//            config.wepTxKeyIndex = 0;
+        }
+
+        if (type == WifiCipherType.WIFICIPHER_WEP) {
+            config.preSharedKey = "\"" + password + "\"";
+            config.hiddenSSID = true;
+            config.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN);
+            config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
+            config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
+            config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40);
+            config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP104);
+            config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
+            config.wepTxKeyIndex = 0;
+        }
+
+        if (type == WifiCipherType.WIFICIPHER_WPA) {
+            config.preSharedKey = "\"" + password + "\"";
+            config.hiddenSSID = true;
+            config.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN);
+            config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
+            config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
+            config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
+            config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);
+            config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);
+            config.status = WifiConfiguration.Status.ENABLED;
+
+        }
+
+        return config;
+
+    }
+
+    /**
+     * 接入某个wifi热点
+     */
+    public static boolean addNetWork(WifiConfiguration config, Context context) {
+
+        WifiManager wifimanager = (WifiManager)context.getSystemService(Context.WIFI_SERVICE);
+
+        WifiInfo wifiinfo = wifimanager.getConnectionInfo();
+
+        if (null != wifiinfo) {
+            wifimanager.disableNetwork(wifiinfo.getNetworkId());
+        }
+
+        boolean result = false;
+
+        if (config.networkId > 0) {
+            result = wifimanager.enableNetwork(config.networkId, true);
+            wifimanager.updateNetwork(config);
+        } else {
+
+            int i = wifimanager.addNetwork(config);
+            result = false;
+
+            if (i > 0) {
+
+                wifimanager.saveConfiguration();
+                return wifimanager.enableNetwork(i, true);
+            }
+        }
+
+        return result;
+
+    }
+
+    /**
+     * 判断wifi热点支持的加密方式
+     */
+    public static WifiCipherType getWifiCipher(String s) {
+
+        if (s.isEmpty()) {
+            return WifiCipherType.WIFICIPHER_INVALID;
+        } else if (s.contains("WEP")) {
+            return WifiCipherType.WIFICIPHER_WEP;
+        } else if (s.contains("WPA") || s.contains("WPA2") || s.contains("WPS")) {
+            return WifiCipherType.WIFICIPHER_WPA;
+        } else {
+            return WifiCipherType.WIFICIPHER_NOPASS;
+        }
+    }
+
+    //查看以前是否也配置过这个网络
+    public static WifiConfiguration isExsits(String SSID, Context context) {
+        WifiManager wifimanager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
+        List<WifiConfiguration> existingConfigs = wifimanager.getConfiguredNetworks();
+        for (WifiConfiguration existingConfig : existingConfigs) {
+            if (existingConfig.SSID.equals("\"" + SSID + "\"")) {
+                return existingConfig;
+            }
+        }
+        return null;
+    }
+
+    // 打开WIFI
+    public static void openWifi(Context context) {
+        WifiManager wifimanager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
+        if (!wifimanager.isWifiEnabled()) {
+            wifimanager.setWifiEnabled(true);
+        }
+    }
+
+    // 关闭WIFI
+    public static void closeWifi(Context context) {
+        WifiManager wifimanager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
+        if (wifimanager.isWifiEnabled()) {
+            wifimanager.setWifiEnabled(false);
+        }
+    }
+
+    public static boolean isOpenWifi(Context context){
+        WifiManager wifimanager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
+        boolean b = wifimanager.isWifiEnabled();
+        return b;
+    }
+
+    /**
+     * 将idAddress转化成string类型的Id字符串
+     *
+     * @param idString
+     * @return
+     */
+    public static String getStringId(int idString) {
+        StringBuffer sb = new StringBuffer();
+        int b = (idString >> 0) & 0xff;
+        sb.append(b + ".");
+        b = (idString >> 8) & 0xff;
+        sb.append(b + ".");
+        b = (idString >> 16) & 0xff;
+        sb.append(b + ".");
+        b = (idString >> 24) & 0xff;
+        sb.append(b);
+        return sb.toString();
+    }
+
+    /**
+     * 设置安全性
+     *
+     * @param capabilities
+     * @return
+     */
+    public static String getCapabilitiesString(String capabilities) {
+        if (capabilities.contains("WEP")) {
+            return "WEP";
+        } else if (capabilities.contains("WPA") || capabilities.contains("WPA2") || capabilities.contains("WPS")) {
+            return "WPA/WPA2";
+        } else {
+            return "OPEN";
+        }
+    }
+
+    public static boolean getIsWifiEnabled(Context context) {
+        WifiManager wifimanager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
+        return wifimanager.isWifiEnabled();
+    }
+
+    public static void getReplace(Context context, List<WifiBean> list) {
+        WifiInfo wifi = WifiSupport.getConnectedWifiInfo(context);
+        List<WifiBean> listCopy = new ArrayList<>();
+        listCopy.addAll(list);
+        for (int i = 0; i < list.size(); i++) {
+            if (("\"" + list.get(i).getWifiName() + "\"").equals(wifi.getSSID())) {
+                listCopy.add(0, list.get(i));
+                listCopy.remove(i + 1);
+                listCopy.get(0).setState("已连接");
+            }
+        }
+        list.clear();
+        list.addAll(listCopy);
+    }
+    /**
+     * 去除同名WIFI
+     *
+     * @param oldSr 需要去除同名的列表
+     * @return 返回不包含同命的列表
+     */
+    public static List<ScanResult> noSameName(List<ScanResult> oldSr)
+    {
+        List<ScanResult> newSr = new ArrayList<ScanResult>();
+        for (ScanResult result : oldSr)
+        {
+            if (!TextUtils.isEmpty(result.SSID) && !containName(newSr, result.SSID))
+                newSr.add(result);
+        }
+        return newSr;
+    }
+    /**
+     * 判断一个扫描结果中,是否包含了某个名称的WIFI
+     * @param sr 扫描结果
+     * @param name 要查询的名称
+     * @return 返回true表示包含了该名称的WIFI,返回false表示不包含
+     */
+    public static boolean containName(List<ScanResult> sr, String name)
+    {
+        for (ScanResult result : sr)
+        {
+            if (!TextUtils.isEmpty(result.SSID) && result.SSID.equals(name))
+                return true;
+        }
+        return false;
+    }
+
+    /**
+     * 返回level 等级
+     */
+    public static int getLevel(int level){
+        if (Math.abs(level) < 50) {
+            return 1;
+        } else if (Math.abs(level) < 75) {
+            return 2;
+        } else if (Math.abs(level) < 90) {
+            return 3;
+        } else {
+            return 4;
+        }
+    }
+
+}

二進制
app/src/main/res/drawable-hdpi/btn_xuanze.png


+ 5 - 0
app/src/main/res/drawable-hdpi/selector_net_bg.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:state_checked="true" android:drawable="@drawable/btn_xuanze"></item>
+    <item android:state_checked="false" android:drawable="@drawable/shape_password_edit_rounded_rectangle"></item>
+</selector>

二進制
app/src/main/res/drawable-mdpi/btn_xuanze.png


二進制
app/src/main/res/drawable-xhdpi/btn_xuanze.png


二進制
app/src/main/res/drawable-xxhdpi/btn_xuanze.png


二進制
app/src/main/res/drawable-xxxhdpi/btn_xuanze.png


二進制
app/src/main/res/drawable/icon_wifi_right.png


+ 48 - 0
app/src/main/res/layout/dialog_et.xml

@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+    <LinearLayout
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_centerInParent="true"
+        android:background="@drawable/shape_btn_back"
+        android:gravity="center_horizontal"
+        android:orientation="vertical"
+        android:padding="@dimen/dp_10">
+
+        <TextView
+            android:id="@+id/tv_title"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:text="@string/apply_connect"
+            android:textColor="@color/logo_blue"
+            android:textSize="@dimen/dp_10" />
+
+        <EditText
+            android:id="@+id/et_server_id"
+            android:layout_width="@dimen/dp_162"
+            android:layout_height="@dimen/dp_22"
+            android:layout_marginTop="@dimen/dp_20"
+            android:background="@drawable/shape_system_edit_rounded_rectangle"
+            android:hint="@string/server_id"
+            android:paddingLeft="@dimen/dp_8"
+            android:textColor="@color/logo_blue"
+            android:textColorHint="@color/colorHint"
+            android:textSize="@dimen/dp_8" />
+
+
+        <Button
+            android:id="@+id/btn_apply"
+            android:layout_width="@dimen/dp_162"
+            android:layout_height="@dimen/dp_22"
+            android:layout_marginTop="@dimen/dp_10"
+            android:background="@drawable/shape_login_rounded_rectangle"
+            android:text="@string/apply_now"
+            android:textColor="@color/white"
+            android:textSize="@dimen/dp_10" />
+
+    </LinearLayout>
+</RelativeLayout>

+ 178 - 177
app/src/main/res/layout/fragment_other.xml

@@ -2,190 +2,191 @@
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
+    android:layout_margin="@dimen/dp_25"
     android:background="@drawable/shape_btn_back"
     android:focusable="true"
-    android:layout_margin="@dimen/dp_25"
     android:focusableInTouchMode="true"
     android:gravity="center">
 
-        <TextView
-
-            android:id="@+id/tv_net_choose"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_marginLeft="@dimen/dp_20"
-            android:layout_marginTop="@dimen/dp_40"
-            android:text="@string/network_selection"
-            android:textColor="@color/logo_blue"
-            android:textSize="@dimen/dp_12" />
-
-        <RadioGroup
-            android:id="@+id/rg_other"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_marginTop="@dimen/dp_20"
-            android:layout_toRightOf="@id/tv_net_choose"
-            android:orientation="horizontal">
-
-            <RadioButton
-                android:background="@drawable/shape_password_edit_rounded_rectangle"
-                android:id="@+id/rb_4g"
-                android:layout_width="@dimen/dp_94"
-                android:layout_height="@dimen/dp_50"
-                android:layout_marginLeft="@dimen/dp_30"
-                android:button="@null"
-                android:gravity="center"
-                android:text="4G"
-                android:textColor="@color/logo_blue"
-                android:textSize="@dimen/sp_12" />
-
-            <RadioButton
-                android:background="@drawable/shape_password_edit_rounded_rectangle"
-                android:id="@+id/rb_wifi"
-                android:layout_width="@dimen/dp_94"
-                android:layout_height="@dimen/dp_50"
-                android:layout_marginLeft="@dimen/dp_30"
-                android:button="@null"
-                android:gravity="center"
-                android:text="WIFI"
-                android:textColor="@color/logo_blue"
-                android:textSize="@dimen/sp_12" />
-        </RadioGroup>
-
-        <TextView
-            android:id="@+id/tv_screen_light"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_below="@id/tv_net_choose"
-            android:layout_marginLeft="@dimen/dp_20"
-            android:layout_marginTop="@dimen/dp_40"
-            android:text="@string/bright"
-            android:textColor="@color/logo_blue"
-            android:textSize="@dimen/dp_12" />
-
-        <SeekBar
-            android:id="@+id/sb_light"
-            android:layout_width="@dimen/dp_192"
-            android:layout_height="@dimen/dp_16"
-            android:layout_below="@id/tv_net_choose"
-            android:layout_marginLeft="@dimen/dp_20"
-            android:layout_marginTop="@dimen/dp_40"
-            android:layout_toRightOf="@id/tv_screen_light"
-            android:max="100"
-            android:maxHeight="@dimen/dp_8"
-            android:minHeight="@dimen/dp_8"
-            android:progressDrawable="@drawable/seekbar_progress_drawable"
-            android:splitTrack="false"
-            android:thumb="@drawable/shape_radio_thumb" />
-
-        <TextView
-            android:id="@+id/tv_system_voice"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_below="@id/tv_screen_light"
-            android:layout_marginLeft="@dimen/dp_20"
-            android:layout_marginTop="@dimen/dp_40"
-            android:text="@string/volume"
-            android:textColor="@color/logo_blue"
-            android:textSize="@dimen/dp_12" />
-
-        <SeekBar
-            android:id="@+id/sb_voice"
-            android:layout_width="@dimen/dp_192"
-            android:layout_height="@dimen/dp_16"
-            android:layout_below="@id/tv_screen_light"
-            android:layout_marginLeft="@dimen/dp_20"
-            android:layout_marginTop="@dimen/dp_40"
-            android:layout_toRightOf="@id/tv_system_voice"
-            android:max="100"
-            android:maxHeight="@dimen/dp_8"
-            android:minHeight="@dimen/dp_8"
-            android:progressDrawable="@drawable/seekbar_progress_drawable"
-            android:splitTrack="false"
-            android:thumb="@drawable/shape_radio_thumb" />
-
-        <TextView
-            android:id="@+id/tv_robot_contacts"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_below="@id/tv_system_voice"
-            android:layout_marginLeft="@dimen/dp_20"
-            android:layout_marginTop="@dimen/dp_40"
-            android:text="@string/contact"
-            android:textColor="@color/logo_blue"
-            android:textSize="@dimen/dp_12" />
-
-        <TextView
-            android:id="@+id/tv_contacts"
-            android:layout_width="@dimen/dp_52"
-            android:layout_height="@dimen/dp_22"
-            android:layout_below="@id/tv_system_voice"
-            android:layout_marginLeft="@dimen/dp_20"
-            android:layout_marginTop="@dimen/dp_40"
-            android:layout_toRightOf="@id/tv_robot_contacts"
-            android:background="@drawable/shape_lt_lb"
+    <TextView
+
+        android:id="@+id/tv_net_choose"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginLeft="@dimen/dp_20"
+        android:layout_marginTop="@dimen/dp_40"
+        android:text="@string/network_selection"
+        android:textColor="@color/logo_blue"
+        android:textSize="@dimen/dp_12" />
+
+    <RadioGroup
+        android:id="@+id/rg_other"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="@dimen/dp_20"
+        android:layout_toRightOf="@id/tv_net_choose"
+        android:orientation="horizontal">
+
+        <RadioButton
+            android:id="@+id/rb_4g"
+            android:layout_width="@dimen/dp_94"
+            android:layout_height="@dimen/dp_50"
+            android:layout_marginLeft="@dimen/dp_30"
+            android:background="@drawable/selector_net_bg"
+            android:button="@null"
+            android:checked="true"
             android:gravity="center"
-            android:text="@string/contact1"
-            android:textColor="@color/white"
-            android:textSize="@dimen/dp_8" />
-
-        <EditText
-
-            android:id="@+id/et_contract"
-            android:layout_width="@dimen/dp_70"
-            android:layout_height="@dimen/dp_22"
-            android:layout_below="@id/tv_system_voice"
-            android:layout_marginTop="@dimen/dp_40"
-            android:layout_toRightOf="@id/tv_contacts"
-            android:background="@drawable/shape_password_rounded_rectangle"
-            android:hint="请输入联系人"
-            android:paddingLeft="@dimen/dp_2"
-            android:textColor="@color/gray"
-            android:textColorHint="@color/gray"
-            android:textSize="@dimen/dp_7" />
-
-        <TextView
-            android:id="@+id/tv_way_contacts"
-            android:layout_width="@dimen/dp_52"
-            android:layout_height="@dimen/dp_22"
-            android:layout_below="@id/tv_system_voice"
-            android:layout_marginLeft="@dimen/dp_20"
-            android:layout_marginTop="@dimen/dp_40"
-            android:layout_toRightOf="@id/et_contract"
-            android:background="@drawable/shape_lt_lb"
+            android:text="4G"
+            android:textColor="@color/logo_blue"
+            android:textSize="@dimen/sp_12" />
+
+        <RadioButton
+            android:id="@+id/rb_wifi"
+            android:layout_width="@dimen/dp_94"
+            android:layout_height="@dimen/dp_50"
+            android:layout_marginLeft="@dimen/dp_30"
+            android:background="@drawable/selector_net_bg"
+            android:button="@null"
             android:gravity="center"
-            android:text="@string/contact_phone_number"
-            android:textColor="@color/white"
-            android:textSize="@dimen/dp_8" />
-
-        <EditText
-            android:id="@+id/et_way_contacts"
-            android:layout_width="@dimen/dp_70"
-            android:layout_height="@dimen/dp_22"
-            android:layout_below="@id/tv_system_voice"
-            android:layout_marginTop="@dimen/dp_40"
-            android:layout_toRightOf="@id/tv_way_contacts"
-            android:background="@drawable/shape_password_rounded_rectangle"
-            android:hint="@string/enter_contact_number"
-            android:inputType="number"
-            android:paddingLeft="@dimen/dp_2"
-            android:textColor="@color/gray"
-            android:textColorHint="@color/gray"
-            android:textSize="@dimen/dp_7" />
-
-        <Button
-            android:id="@+id/btn_contract_update"
-            android:layout_width="@dimen/dp_44"
-            android:layout_height="@dimen/dp_22"
-            android:layout_below="@id/tv_system_voice"
-            android:layout_marginLeft="@dimen/dp_15"
-            android:layout_marginTop="@dimen/dp_40"
-            android:layout_toRightOf="@id/et_way_contacts"
-            android:background="@drawable/shape_other_rounded_rectangle"
-            android:text="@string/update"
+            android:text="WIFI"
             android:textColor="@color/logo_blue"
-            android:textSize="@dimen/dp_8" />
-
-<!--    </RelativeLayot>-->
+            android:textSize="@dimen/sp_12" />
+    </RadioGroup>
+
+    <TextView
+        android:id="@+id/tv_screen_light"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_below="@id/tv_net_choose"
+        android:layout_marginLeft="@dimen/dp_20"
+        android:layout_marginTop="@dimen/dp_40"
+        android:text="@string/bright"
+        android:textColor="@color/logo_blue"
+        android:textSize="@dimen/dp_12" />
+
+    <SeekBar
+        android:id="@+id/sb_light"
+        android:layout_width="@dimen/dp_192"
+        android:layout_height="@dimen/dp_16"
+        android:layout_below="@id/tv_net_choose"
+        android:layout_marginLeft="@dimen/dp_20"
+        android:layout_marginTop="@dimen/dp_40"
+        android:layout_toRightOf="@id/tv_screen_light"
+        android:max="100"
+        android:maxHeight="@dimen/dp_8"
+        android:minHeight="@dimen/dp_8"
+        android:progressDrawable="@drawable/seekbar_progress_drawable"
+        android:splitTrack="false"
+        android:thumb="@drawable/shape_radio_thumb" />
+
+    <TextView
+        android:id="@+id/tv_system_voice"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_below="@id/tv_screen_light"
+        android:layout_marginLeft="@dimen/dp_20"
+        android:layout_marginTop="@dimen/dp_40"
+        android:text="@string/volume"
+        android:textColor="@color/logo_blue"
+        android:textSize="@dimen/dp_12" />
+
+    <SeekBar
+        android:id="@+id/sb_voice"
+        android:layout_width="@dimen/dp_192"
+        android:layout_height="@dimen/dp_16"
+        android:layout_below="@id/tv_screen_light"
+        android:layout_marginLeft="@dimen/dp_20"
+        android:layout_marginTop="@dimen/dp_40"
+        android:layout_toRightOf="@id/tv_system_voice"
+        android:max="100"
+        android:maxHeight="@dimen/dp_8"
+        android:minHeight="@dimen/dp_8"
+        android:progressDrawable="@drawable/seekbar_progress_drawable"
+        android:splitTrack="false"
+        android:thumb="@drawable/shape_radio_thumb" />
+
+    <TextView
+        android:id="@+id/tv_robot_contacts"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_below="@id/tv_system_voice"
+        android:layout_marginLeft="@dimen/dp_20"
+        android:layout_marginTop="@dimen/dp_40"
+        android:text="@string/contact"
+        android:textColor="@color/logo_blue"
+        android:textSize="@dimen/dp_12" />
+
+    <TextView
+        android:id="@+id/tv_contacts"
+        android:layout_width="@dimen/dp_52"
+        android:layout_height="@dimen/dp_22"
+        android:layout_below="@id/tv_system_voice"
+        android:layout_marginLeft="@dimen/dp_20"
+        android:layout_marginTop="@dimen/dp_40"
+        android:layout_toRightOf="@id/tv_robot_contacts"
+        android:background="@drawable/shape_lt_lb"
+        android:gravity="center"
+        android:text="@string/contact1"
+        android:textColor="@color/white"
+        android:textSize="@dimen/dp_8" />
+
+    <EditText
+
+        android:id="@+id/et_contract"
+        android:layout_width="@dimen/dp_70"
+        android:layout_height="@dimen/dp_22"
+        android:layout_below="@id/tv_system_voice"
+        android:layout_marginTop="@dimen/dp_40"
+        android:layout_toRightOf="@id/tv_contacts"
+        android:background="@drawable/shape_password_rounded_rectangle"
+        android:hint="请输入联系人"
+        android:paddingLeft="@dimen/dp_2"
+        android:textColor="@color/gray"
+        android:textColorHint="@color/gray"
+        android:textSize="@dimen/dp_7" />
+
+    <TextView
+        android:id="@+id/tv_way_contacts"
+        android:layout_width="@dimen/dp_52"
+        android:layout_height="@dimen/dp_22"
+        android:layout_below="@id/tv_system_voice"
+        android:layout_marginLeft="@dimen/dp_20"
+        android:layout_marginTop="@dimen/dp_40"
+        android:layout_toRightOf="@id/et_contract"
+        android:background="@drawable/shape_lt_lb"
+        android:gravity="center"
+        android:text="@string/contact_phone_number"
+        android:textColor="@color/white"
+        android:textSize="@dimen/dp_8" />
+
+    <EditText
+        android:id="@+id/et_way_contacts"
+        android:layout_width="@dimen/dp_70"
+        android:layout_height="@dimen/dp_22"
+        android:layout_below="@id/tv_system_voice"
+        android:layout_marginTop="@dimen/dp_40"
+        android:layout_toRightOf="@id/tv_way_contacts"
+        android:background="@drawable/shape_password_rounded_rectangle"
+        android:hint="@string/enter_contact_number"
+        android:inputType="number"
+        android:paddingLeft="@dimen/dp_2"
+        android:textColor="@color/gray"
+        android:textColorHint="@color/gray"
+        android:textSize="@dimen/dp_7" />
+
+    <Button
+        android:id="@+id/btn_contract_update"
+        android:layout_width="@dimen/dp_44"
+        android:layout_height="@dimen/dp_22"
+        android:layout_below="@id/tv_system_voice"
+        android:layout_marginLeft="@dimen/dp_15"
+        android:layout_marginTop="@dimen/dp_40"
+        android:layout_toRightOf="@id/et_way_contacts"
+        android:background="@drawable/shape_other_rounded_rectangle"
+        android:text="@string/update"
+        android:textColor="@color/logo_blue"
+        android:textSize="@dimen/dp_8" />
+
+    <!--    </RelativeLayot>-->
 
 </RelativeLayout>

+ 1 - 0
app/src/main/res/layout/navigation_layout.xml

@@ -13,6 +13,7 @@
         android:src="@drawable/login_logo" />
 
     <TextView
+        android:id="@+id/tv_restart"
         android:layout_width="@dimen/dp_50"
         android:layout_height="@dimen/dp_50"
         android:layout_marginTop="@dimen/dp_7"

+ 60 - 0
app/src/main/res/layout/wifi_list_activity.xml

@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+
+    <LinearLayout
+        android:layout_width="@dimen/dp_400"
+        android:layout_height="@dimen/dp_260"
+
+        android:background="@color/white"
+        android:orientation="vertical">
+
+
+        <RelativeLayout
+            android:layout_width="@dimen/dp_400"
+            android:layout_height="wrap_content"
+            android:background="@color/gray1">
+
+            <TextView
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_alignParentLeft="true"
+                android:layout_centerVertical="true"
+                android:layout_marginLeft="12dp"
+                android:layout_marginTop="9dp"
+                android:layout_marginBottom="9dp"
+                android:text="WiFi列表"
+                android:textColor="@color/gray_home" />
+
+            <ProgressBar
+                android:id="@+id/pb_wifi_loading"
+                style="@android:style/Widget.ProgressBar.Small"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_alignParentRight="true"
+                android:layout_centerVertical="true"
+                android:layout_marginRight="12dp" />
+
+        </RelativeLayout>
+
+        <LinearLayout
+            android:layout_width="@dimen/dp_400"
+            android:layout_height="match_parent"
+            android:orientation="vertical">
+
+            <android.support.v7.widget.RecyclerView
+                android:id="@+id/recy_list_wifi"
+                android:layout_width="match_parent"
+                android:layout_height="0dp"
+                android:layout_weight="1">
+
+
+            </android.support.v7.widget.RecyclerView>
+        </LinearLayout>
+
+    </LinearLayout>
+</RelativeLayout>

+ 45 - 0
app/src/main/res/layout/wifi_list_recycle_item.xml

@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:background="@color/white"
+    android:gravity="center_vertical"
+    android:layout_width="@dimen/dp_400"
+    android:layout_height="wrap_content">
+
+
+   <TextView
+
+       android:layout_centerVertical="true"
+       android:id="@+id/tv_item_wifi_name"
+       android:layout_marginLeft="@dimen/dp_12"
+       android:textSize="@dimen/sp_10"
+       android:layout_width="wrap_content"
+       android:layout_height="wrap_content" />
+
+   <TextView
+
+       android:id="@+id/tv_item_wifi_status"
+       android:textSize="@dimen/sp_8"
+       android:layout_centerVertical="true"
+       android:layout_toRightOf="@+id/tv_item_wifi_name"
+       android:layout_width="wrap_content"
+       android:layout_height="wrap_content" />
+
+
+   <ImageView
+       android:layout_marginTop="@dimen/dp_8"
+       android:layout_marginBottom="@dimen/dp_8"
+       android:src="@drawable/icon_wifi_right"
+       android:layout_marginRight="@dimen/dp_12"
+       android:layout_centerVertical="true"
+       android:layout_alignParentRight="true"
+       android:layout_width="@dimen/dp_14"
+       android:layout_height="@dimen/dp_14" />
+
+   <View
+       android:layout_alignParentBottom="true"
+       android:layout_width="match_parent"
+       android:layout_height="1dp"
+       android:background="@color/colorHint"/>
+
+</RelativeLayout>

+ 1 - 0
app/src/main/res/values/strings.xml

@@ -610,6 +610,7 @@
     <string name="zzz">制作中</string>
     <string name="ljsb">连接失败,请确保连接上系统id</string>
     <string name="wifimmcw">wifi密码错误</string>
+    <string name="wifi_connection_successful">wifi连接成功</string>
     <string name="glyid">输入管理id不能为空</string>
     <string name="bzc">暂不支持这个功能</string>
     <string name="shibai">切换4g失败</string>