@ -0,0 +1,56 @@
|
||||
{
|
||||
"appInfo": {
|
||||
"cloudService": {
|
||||
"api": "api.gizwits.com:80",
|
||||
"site": "site.gizwits.com:80"
|
||||
},
|
||||
"gizwitsInfo": {
|
||||
"appId": "30fe77f49f4c4b50a3affd72aa221da1",
|
||||
"appSecret": "162abf698315470da96673397cd567be"
|
||||
},
|
||||
"productInfo": [{
|
||||
"productKey": "d58cf41924734241ac775eedef11dbce",
|
||||
"productSecret": "4092fdf9dd6e4c4286010dffcfe4118e"
|
||||
}],
|
||||
"tencentInfo": {
|
||||
"appId": "your_tencent_app_id"
|
||||
},
|
||||
"weChatInfo": {
|
||||
"appId": "your_wechat_app_id",
|
||||
"appSecret": "your_wechat_app_secret"
|
||||
},
|
||||
"pushInfo": {
|
||||
"jpushAppKey": "your_jpush_app_key",
|
||||
"bpushAppKey": "your_bpush_app_key"
|
||||
}
|
||||
},
|
||||
"templateSelect": {
|
||||
"deviceList": {
|
||||
"unbindDevice": true,
|
||||
"displayMac": true
|
||||
}
|
||||
},
|
||||
"functionConfig": {
|
||||
"bindDevice_qrcode": true,
|
||||
"deviceOnboarding": {
|
||||
"config_softap": true,
|
||||
"config_airlink": true,
|
||||
"wifiModuleType": []
|
||||
},
|
||||
"login_anonymous": true,
|
||||
"login_qq": false,
|
||||
"login_weChat": false,
|
||||
"register_phoneUser": true,
|
||||
"resetPassword_phoneUser": true,
|
||||
"personalCenter_changePassword": true,
|
||||
"push_baidu": false,
|
||||
"push_jiguang": false
|
||||
},
|
||||
"viewConfig": {
|
||||
"viewColor": {
|
||||
"background": "FBDA51",
|
||||
"contrast": "333333"
|
||||
},
|
||||
"statusBarStyle": "default"
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 459 KiB |
After Width: | Height: | Size: 415 KiB |
After Width: | Height: | Size: 339 KiB |
After Width: | Height: | Size: 376 KiB |
After Width: | Height: | Size: 128 KiB |
After Width: | Height: | Size: 156 KiB |
After Width: | Height: | Size: 170 KiB |
After Width: | Height: | Size: 167 KiB |
After Width: | Height: | Size: 314 KiB |
After Width: | Height: | Size: 153 KiB |
After Width: | Height: | Size: 156 KiB |
After Width: | Height: | Size: 162 KiB |
After Width: | Height: | Size: 1.3 MiB |
@ -0,0 +1,220 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>模组类型选择技巧</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h3>模组类型选择技巧</h3>
|
||||
<hr>
|
||||
<h4>模组常见类型</h4>
|
||||
|
||||
<table border="1">
|
||||
<!-- 表头-->
|
||||
<tr>
|
||||
<th>品牌</th>
|
||||
<th>型号</th>
|
||||
<th>图片</th>
|
||||
</tr>
|
||||
|
||||
<!-- 乐鑫-->
|
||||
<tr>
|
||||
<td>乐鑫(ESP-8266)</td>
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td>ESP-07S</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>ESP-12S</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>ESP-12F</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<img src="image/ESP-07S.png" width="100" height="80">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<img src="image/ESP-12S.png" width="100" height="80">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<img src="image/ESP-12F.png" width="100" height="80">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<!-- 庆科 -->
|
||||
<tr>
|
||||
<td>庆科</td>
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td>EMW3162</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<img src="image/EMW3162.png" width="100" height="80">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- 汉枫 -->
|
||||
<tr>
|
||||
<td>汉枫</td>
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td>HF-LPB100</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>HF-LPB120</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>HF-LPT120</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>HF-LPT220</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<img src="image/HF-LPB100.png" width="100" height="80">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<img src="image/HF-LPB120.png" width="100" height="80">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<img src="image/HF-LPT120.png" width="100" height="80">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<img src="image/HF-LPT220.png" width="100" height="80">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- 瑞昱(Realtek) -->
|
||||
<tr>
|
||||
<td>瑞昱Realtek</td>
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td>RTL8711AM</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<img src="image/RTL8711AM.png" width="100" height="80">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- 联盛德 -->
|
||||
<tr>
|
||||
<td>联盛德</td>
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td>TLN13SP01</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<img src="image/TLN13P01.png" width="100" height="80">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- 高通 -->
|
||||
<tr>
|
||||
<td>高通</td>
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td>QCA4004</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<img src="image/QCA4004.png" width="100" height="80">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- TI -->
|
||||
<tr>
|
||||
<td>TI</td>
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td>CC3200</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<img src="image/CC3200.png" width="100" height="80">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan='3'>
|
||||
我们将会持续更新,为您带来更多的帮助参考信息。
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,220 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Module Type Choose Tips</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h3>Module Type Choose Tips</h3>
|
||||
<hr>
|
||||
<h4>Module Type</h4>
|
||||
|
||||
<table border="1">
|
||||
<!-- table head-->
|
||||
<tr>
|
||||
<th>Brand</th>
|
||||
<th>Type</th>
|
||||
<th>Picture</th>
|
||||
</tr>
|
||||
|
||||
<!-- ESP-->
|
||||
<tr>
|
||||
<td>ESP(ESP-8266)</td>
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td>ESP-07S</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>ESP-12S</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>ESP-12F</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<img src="image/ESP-07S.png" width="100" height="80">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<img src="image/ESP-12S.png" width="100" height="80">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<img src="image/ESP-12F.png" width="100" height="80">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<!-- MXCHIP -->
|
||||
<tr>
|
||||
<td>MXCHIP</td>
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td>EMW3162</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<img src="image/EMW3162.png" width="100" height="80">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- HF -->
|
||||
<tr>
|
||||
<td>HF</td>
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td>HF-LPB100</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>HF-LPB120</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>HF-LPT120</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>HF-LPT220</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<img src="image/HF-LPB100.png" width="100" height="80">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<img src="image/HF-LPB120.png" width="100" height="80">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<img src="image/HF-LPT120.png" width="100" height="80">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<img src="image/HF-LPT220.png" width="100" height="80">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- RTK Realtek -->
|
||||
<tr>
|
||||
<td>RTK(Realtek)</td>
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td>RTL8711AM</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<img src="image/RTL8711AM.png" width="100" height="80">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- WM -->
|
||||
<tr>
|
||||
<td>WM</td>
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td>TLN13SP01</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<img src="image/TLN13P01.png" width="100" height="80">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- QCA -->
|
||||
<tr>
|
||||
<td>QCA</td>
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td>QCA4004</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<img src="image/QCA4004.png" width="100" height="80">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- TI -->
|
||||
<tr>
|
||||
<td>TI</td>
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td>CC3200</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<img src="image/CC3200.png" width="100" height="80">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan='3'>
|
||||
The content will be update continually, please follow it.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,34 @@
|
||||
package com.gizwits.opensource.appkit.CommonModule;
|
||||
|
||||
import android.net.wifi.ScanResult;
|
||||
|
||||
import com.gizwits.gizwifisdk.api.GizDeviceSharingInfo;
|
||||
import com.gizwits.gizwifisdk.api.GizUserInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GosConstant {
|
||||
|
||||
// 设备热点默认前缀
|
||||
public static final String SoftAP_Start = "XPG-GAgent";
|
||||
|
||||
public static final String SSIDPsw = "#10v3#";
|
||||
public static boolean isOpenHot = false;
|
||||
/**
|
||||
* 0 使用旧接口 setDeviceOnboarding
|
||||
* 1 配网绑定接口 setDeviceOnboardingByBind
|
||||
* 2 域名配网接口 setDeviceOnboardingDeploy false
|
||||
* 3 域名配网接口 setDeviceOnboardingDeploy true
|
||||
*/
|
||||
public static int mNew = 0;
|
||||
public static List<ScanResult> ssidList = new ArrayList<ScanResult>();
|
||||
public static int nowPager = -1;
|
||||
public static List<GizUserInfo> mybindUsers = new ArrayList<GizUserInfo>();
|
||||
public static boolean isEdit = false;
|
||||
|
||||
public static List<GizDeviceSharingInfo> mydeviceSharingInfos = new ArrayList<GizDeviceSharingInfo>();
|
||||
public static List<GizDeviceSharingInfo> newmydeviceSharingInfos = new ArrayList<GizDeviceSharingInfo>();
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package com.gizwits.opensource.appkit.CommonModule;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
public class NoScrollViewPager extends ViewPager {
|
||||
private boolean noScroll = false;
|
||||
|
||||
public NoScrollViewPager(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public NoScrollViewPager(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public void setNoScroll(boolean noScroll) {
|
||||
this.noScroll = noScroll;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scrollTo(int x, int y) {
|
||||
super.scrollTo(x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent arg0) {
|
||||
/* return false;//super.onTouchEvent(arg0); */
|
||||
if (noScroll)
|
||||
return false;
|
||||
else
|
||||
return super.onTouchEvent(arg0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(MotionEvent arg0) {
|
||||
if (noScroll)
|
||||
return false;
|
||||
else
|
||||
return super.onInterceptTouchEvent(arg0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCurrentItem(int item, boolean smoothScroll) {
|
||||
super.setCurrentItem(item, smoothScroll);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCurrentItem(int item) {
|
||||
super.setCurrentItem(item);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
package com.gizwits.opensource.appkit.CommonModule;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gizwits.opensource.appkit.R;
|
||||
|
||||
|
||||
public class TipsDialog extends Dialog implements
|
||||
View.OnClickListener {
|
||||
|
||||
private Button btnSure;
|
||||
private TextView tvTips;
|
||||
|
||||
public TipsDialog(Context context) {
|
||||
super(context);
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
getWindow().setBackgroundDrawableResource(R.drawable.shape_button2);
|
||||
setContentView(R.layout.dialog_tips);
|
||||
initView();
|
||||
setCancelable(false);
|
||||
|
||||
}
|
||||
|
||||
public TipsDialog(Context context, String txt) {
|
||||
this(context);
|
||||
|
||||
tvTips.setText(txt);
|
||||
}
|
||||
|
||||
public TipsDialog(Context context, int res) {
|
||||
this(context);
|
||||
|
||||
tvTips.setText(res);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private void initView() {
|
||||
btnSure = (Button) findViewById(R.id.btnSure);
|
||||
tvTips = (TextView) findViewById(R.id.tvTips);
|
||||
|
||||
btnSure.setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.btnSure:
|
||||
cancel();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,505 @@
|
||||
package com.gizwits.opensource.appkit.ConfigModule;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.location.LocationManager;
|
||||
import android.net.wifi.ScanResult;
|
||||
import android.net.wifi.WifiInfo;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.text.TextUtils;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.gizwits.opensource.appkit.R;
|
||||
import com.gizwits.opensource.appkit.CommonModule.GosDeploy;
|
||||
import com.gizwits.opensource.appkit.DeviceModule.GosMainActivity;
|
||||
import com.gizwits.opensource.appkit.utils.NetUtils;
|
||||
import com.gizwits.opensource.appkit.utils.ToolUtils;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@SuppressLint("InflateParams")
|
||||
public class GosAirlinkChooseDeviceWorkWiFiActivity extends GosConfigModuleBaseActivity implements OnClickListener {
|
||||
|
||||
private AlertDialog create;
|
||||
private ArrayList<ScanResult> wifiList;
|
||||
|
||||
private static final int REQUEST_EXTERNAL_STORAGE = 1;
|
||||
private static String[] PERMISSIONS_STORAGE = {
|
||||
"android.permission.ACCESS_FINE_LOCATION",
|
||||
"android.permission.ACCESS_COARSE_LOCATION"};
|
||||
/**
|
||||
* wifi信息
|
||||
*/
|
||||
public WifiInfo wifiInfo;
|
||||
|
||||
/**
|
||||
* The et SSID
|
||||
*/
|
||||
private EditText etSSID;
|
||||
|
||||
/**
|
||||
* The et Psw
|
||||
*/
|
||||
private EditText etPsw;
|
||||
|
||||
/**
|
||||
* The btn Next
|
||||
*/
|
||||
private Button btnNext;
|
||||
|
||||
/** The ll ChooseMode */
|
||||
//private LinearLayout llChooseMode;
|
||||
|
||||
/**
|
||||
* The cb Laws
|
||||
*/
|
||||
private CheckBox cbLaws;
|
||||
|
||||
/** The tv Mode */
|
||||
//private TextView tvMode;
|
||||
|
||||
/**
|
||||
* The rl WiFiList
|
||||
*/
|
||||
private RelativeLayout rlWiFiList;
|
||||
|
||||
/**
|
||||
* 配置用参数
|
||||
*/
|
||||
private String workSSID, workSSIDPsw;
|
||||
|
||||
/**
|
||||
* The data
|
||||
*/
|
||||
List<String> modeList;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_gos_airlink_choose_device_workwifi);
|
||||
// 设置ActionBar
|
||||
setToolBar(true, getString(R.string.choose_wifi));
|
||||
|
||||
initData();
|
||||
initView();
|
||||
ininEvent();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
try {
|
||||
// 预设workSSID && workSSIDPsw
|
||||
workSSID = NetUtils.getCurentWifiSSID(this);
|
||||
String mypass = spf.getString("mypass", "");
|
||||
|
||||
if (!TextUtils.isEmpty(workSSID)) {
|
||||
etSSID.setText(workSSID);
|
||||
etSSID.setSelection(workSSID.length());
|
||||
if (!TextUtils.isEmpty(mypass)) {
|
||||
JSONObject obj = new JSONObject(mypass);
|
||||
|
||||
if (obj.has(workSSID)) {
|
||||
String pass = obj.getString(workSSID);
|
||||
etPsw.setText(pass);
|
||||
} else {
|
||||
etPsw.setText("");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
etSSID.setText(NetUtils.getCurentWifiSSID(this));
|
||||
}
|
||||
|
||||
// 当没有任何文字的时候设置为明文显示
|
||||
// if (TextUtils.isEmpty(etPsw.getText().toString())) {
|
||||
// cbLaws.setChecked(true);
|
||||
// etPsw.setInputType(0x90);
|
||||
// } else {
|
||||
// etPsw.setInputType(0x81);
|
||||
// cbLaws.setChecked(false);
|
||||
// }
|
||||
} catch(JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
//tvMode = (TextView) findViewById(R.id.tvMode);
|
||||
etSSID = (EditText) findViewById(R.id.etSSID);
|
||||
|
||||
etPsw = (EditText) findViewById(R.id.etPsw);
|
||||
cbLaws = (CheckBox) findViewById(R.id.cbLaws);
|
||||
btnNext = (Button) findViewById(R.id.btnNext);
|
||||
//llChooseMode = (LinearLayout) findViewById(R.id.llChooseMode);
|
||||
rlWiFiList = (RelativeLayout) findViewById(R.id.rlWiFiList);
|
||||
|
||||
// 配置文件部署
|
||||
btnNext.setBackgroundDrawable(GosDeploy.appConfig_BackgroundColor());
|
||||
btnNext.setTextColor(GosDeploy.appConfig_Contrast());
|
||||
// llChooseMode.setVisibility(GosDeploy.setModuleSelectOn());
|
||||
|
||||
//llChooseMode.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
|
||||
private void ininEvent() {
|
||||
btnNext.setOnClickListener(this);
|
||||
rlWiFiList.setOnClickListener(this);
|
||||
//llChooseMode.setOnClickListener(this);
|
||||
|
||||
cbLaws.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
String psw = etPsw.getText().toString();
|
||||
|
||||
if (isChecked) {
|
||||
etPsw.setInputType(0x90);
|
||||
} else {
|
||||
etPsw.setInputType(0x81);
|
||||
}
|
||||
etPsw.setSelection(psw.length());
|
||||
}
|
||||
});
|
||||
|
||||
//检测是否有位置定位的权限
|
||||
int permission = ActivityCompat.checkSelfPermission(GosAirlinkChooseDeviceWorkWiFiActivity.this,
|
||||
"android.permission.ACCESS_FINE_LOCATION");
|
||||
if (permission != PackageManager.PERMISSION_GRANTED) {
|
||||
try {
|
||||
// 没有写的权限,去申请写的权限,会弹出对话框
|
||||
ActivityCompat.requestPermissions(GosAirlinkChooseDeviceWorkWiFiActivity.this, PERMISSIONS_STORAGE, REQUEST_EXTERNAL_STORAGE);
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
modeList = new ArrayList<String>();
|
||||
String[] modes = this.getResources().getStringArray(R.array.mode);
|
||||
for (String string : modes) {
|
||||
modeList.add(string);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.btnNext:
|
||||
if (ToolUtils.noDoubleClick()) {
|
||||
workSSID = etSSID.getText().toString();
|
||||
workSSIDPsw = etPsw.getText().toString();
|
||||
|
||||
if (TextUtils.isEmpty(workSSID)) {
|
||||
Toast.makeText(GosAirlinkChooseDeviceWorkWiFiActivity.this, R.string.choose_wifi_list_title, toastTime)
|
||||
.show();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!workSSID.equals(NetUtils.getCurentWifiSSID(this))) {
|
||||
final Dialog dialog1 = new AlertDialog.Builder(this, R.style.alert_dialog_style)
|
||||
.setView(new EditText(this)).create();
|
||||
dialog1.setCanceledOnTouchOutside(false);
|
||||
dialog1.show();
|
||||
|
||||
Window window = dialog1.getWindow();
|
||||
window.setContentView(R.layout.alert_gos_wifi);
|
||||
|
||||
LinearLayout llNo, llSure;
|
||||
llNo = (LinearLayout) window.findViewById(R.id.llNo);
|
||||
llSure = (LinearLayout) window.findViewById(R.id.llSure);
|
||||
|
||||
llNo.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
dialog1.cancel();
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
llSure.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (dialog1.isShowing()) {
|
||||
dialog1.cancel();
|
||||
}
|
||||
isEmptyAlert();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
isEmptyAlert();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case R.id.rlWiFiList:
|
||||
AlertDialog.Builder dia = new AlertDialog.Builder(GosAirlinkChooseDeviceWorkWiFiActivity.this);
|
||||
View view = View.inflate(GosAirlinkChooseDeviceWorkWiFiActivity.this, R.layout.alert_gos_wifi_list, null);
|
||||
ListView listview = (ListView) view.findViewById(R.id.wifi_list);
|
||||
List<ScanResult> rsList = NetUtils.getCurrentWifiScanResult(this);
|
||||
List<String> localList = new ArrayList<String>();
|
||||
localList.clear();
|
||||
wifiList = new ArrayList<ScanResult>();
|
||||
wifiList.clear();
|
||||
for (ScanResult sss : rsList) {
|
||||
if (sss.SSID.contains(SoftAP_Start)) {
|
||||
} else {
|
||||
if (localList.toString().contains(sss.SSID)) {
|
||||
} else {
|
||||
localList.add(sss.SSID);
|
||||
wifiList.add(sss);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (wifiList.size() == 0) {
|
||||
LocationManager locManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
|
||||
if (!locManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
|
||||
// 未打开位置开关,可能导致定位失败或定位不准,提示用户或做相应处理
|
||||
Toast.makeText(this, getString(R.string.open), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
}
|
||||
WifiListAdapter adapter = new WifiListAdapter(wifiList);
|
||||
listview.setAdapter(adapter);
|
||||
listview.setOnItemClickListener(new OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
|
||||
ScanResult sResult = wifiList.get(arg2);
|
||||
String sSID = sResult.SSID;
|
||||
etSSID.setText(sSID);
|
||||
etSSID.setSelection(sSID.length());
|
||||
etPsw.setText("");
|
||||
create.dismiss();
|
||||
}
|
||||
});
|
||||
dia.setView(view);
|
||||
create = dia.create();
|
||||
create.show();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private static final String TAG = "GosAirlinkChooseDevice";
|
||||
|
||||
private void toAirlinkReady() {
|
||||
// 需要记录所有配置过的wifi和密码
|
||||
|
||||
try {
|
||||
String mypass = spf.getString("mypass", "");
|
||||
if (TextUtils.isEmpty(mypass)) {
|
||||
JSONObject mUserAndPass = new JSONObject();
|
||||
mUserAndPass.put(workSSID, workSSIDPsw);
|
||||
spf.edit().putString("mypass", mUserAndPass.toString()).commit();
|
||||
} else {
|
||||
JSONObject obj = new JSONObject(mypass);
|
||||
obj.put(workSSID, workSSIDPsw);
|
||||
spf.edit().putString("mypass", obj.toString()).commit();
|
||||
}
|
||||
} catch(JSONException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
spf.edit().putString("workSSID", workSSID).commit();
|
||||
spf.edit().putString("workSSIDPsw", workSSIDPsw).commit();
|
||||
//wifiModuleType-false-start wifiModuleType-true-start
|
||||
if (GosDeploy.appConfig_WifiModuleType().size() == 0) {
|
||||
//wifiModuleType-false-end
|
||||
Intent intent = new Intent(this, GosModeListActivity2.class);
|
||||
startActivity(intent);
|
||||
//wifiModuleType-false-start
|
||||
} else {
|
||||
//wifiModuleType-true-end
|
||||
List<Integer> moduleTypes = GosDeploy.appConfig_WifiModuleType();
|
||||
JSONArray array = new JSONArray();
|
||||
for (int type : moduleTypes) {
|
||||
if (type == 4) {
|
||||
type = 0;
|
||||
} else if (type < 4) {
|
||||
type = type + 1;
|
||||
} else if (type == 12) {
|
||||
type = 6;
|
||||
} else if (type >= 6 && type < 12) {
|
||||
type = type + 1;
|
||||
}
|
||||
array.put(type);
|
||||
}
|
||||
spf.edit().putString("modulestyles", array.toString()).commit();
|
||||
Intent intent = new Intent(this, GosAirlinkReadyActivity.class);
|
||||
startActivity(intent);
|
||||
//wifiModuleType-true-start
|
||||
}
|
||||
//wifiModuleType-false-end wifiModuleType-true-end
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* // 检查当前使用的WiFi是否曾经用过 protected boolean checkworkSSIDUsed(String workSSID)
|
||||
* { if (spf.contains("workSSID")) { if (spf.getString("workSSID",
|
||||
* "").equals(workSSID)) { return true; } } return false; }
|
||||
*/
|
||||
|
||||
// 屏蔽掉返回键
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
Intent intent = new Intent(this, GosMainActivity.class);
|
||||
startActivity(intent);
|
||||
//quitAlert(this, intent);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
Intent intent = new Intent(this, GosMainActivity.class);
|
||||
startActivity(intent);
|
||||
//quitAlert(this, intent);
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private void isEmptyAlert() {
|
||||
if (TextUtils.isEmpty(workSSIDPsw)) {
|
||||
final Dialog dialog = new AlertDialog.Builder(this, R.style.alert_dialog_style)
|
||||
.setView(new EditText(this)).create();
|
||||
dialog.setCanceledOnTouchOutside(false);
|
||||
dialog.show();
|
||||
|
||||
Window window = dialog.getWindow();
|
||||
window.setContentView(R.layout.alert_gos_empty);
|
||||
WindowManager.LayoutParams layoutParams = window.getAttributes();
|
||||
layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
|
||||
window.setAttributes(layoutParams);
|
||||
LinearLayout llNo, llSure;
|
||||
llNo = (LinearLayout) window.findViewById(R.id.llNo);
|
||||
llSure = (LinearLayout) window.findViewById(R.id.llSure);
|
||||
|
||||
llNo.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
dialog.cancel();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
llSure.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
if (dialog.isShowing()) {
|
||||
dialog.cancel();
|
||||
}
|
||||
toAirlinkReady();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
toAirlinkReady();
|
||||
}
|
||||
}
|
||||
|
||||
class WifiListAdapter extends BaseAdapter {
|
||||
|
||||
ArrayList<ScanResult> xpgList;
|
||||
|
||||
public WifiListAdapter(ArrayList<ScanResult> list) {
|
||||
this.xpgList = list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return xpgList.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
View view = convertView;
|
||||
Holder holder;
|
||||
if (view == null) {
|
||||
view = LayoutInflater.from(GosAirlinkChooseDeviceWorkWiFiActivity.this)
|
||||
.inflate(R.layout.item_gos_wifi_list, null);
|
||||
holder = new Holder(view);
|
||||
view.setTag(holder);
|
||||
} else {
|
||||
holder = (Holder) view.getTag();
|
||||
}
|
||||
|
||||
String ssid = xpgList.get(position).SSID;
|
||||
holder.getTextView().setText(ssid);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Holder {
|
||||
View view;
|
||||
|
||||
public Holder(View view) {
|
||||
this.view = view;
|
||||
}
|
||||
|
||||
TextView textView;
|
||||
|
||||
public TextView getTextView() {
|
||||
if (textView == null) {
|
||||
textView = (TextView) view.findViewById(R.id.SSID_text);
|
||||
}
|
||||
return textView;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,310 @@
|
||||
package com.gizwits.opensource.appkit.ConfigModule;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup.LayoutParams;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.gizwits.opensource.appkit.R;
|
||||
import com.gizwits.gizwifisdk.api.GizWifiSDK;
|
||||
import com.gizwits.gizwifisdk.enumration.GizWifiConfigureMode;
|
||||
import com.gizwits.gizwifisdk.enumration.GizWifiErrorCode;
|
||||
import com.gizwits.gizwifisdk.enumration.GizWifiGAgentType;
|
||||
import com.gizwits.opensource.appkit.CommonModule.GosConstant;
|
||||
import com.gizwits.opensource.appkit.CommonModule.GosDeploy;
|
||||
import com.gizwits.opensource.appkit.DeviceModule.GosMainActivity;
|
||||
import com.gizwits.opensource.appkit.view.RoundProgressBar;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import static com.gizwits.gizwifisdk.enumration.GizWifiErrorCode.GIZ_SDK_ONBOARDING_STOPPED;
|
||||
|
||||
@SuppressLint("HandlerLeak")
|
||||
public class GosAirlinkConfigCountdownActivity extends
|
||||
GosConfigModuleBaseActivity {
|
||||
|
||||
/** The tv Time */
|
||||
//private TextView tvTimer;
|
||||
|
||||
/**
|
||||
* The rpb Config
|
||||
*/
|
||||
private RoundProgressBar rpbConfig;
|
||||
|
||||
/**
|
||||
* 倒计时
|
||||
*/
|
||||
int secondleft = 60;
|
||||
|
||||
/**
|
||||
* The timer
|
||||
*/
|
||||
Timer timer;
|
||||
|
||||
/**
|
||||
* 配置用参数
|
||||
*/
|
||||
String workSSID, workSSIDPsw;
|
||||
|
||||
|
||||
List<GizWifiGAgentType> modeList, modeDataList;
|
||||
private TextView tvLeft;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_gos_airlink_config_countdown);
|
||||
// 设置ActionBar
|
||||
setToolBar(false, R.string.search_join);
|
||||
initView();
|
||||
initData();
|
||||
startAirlink();
|
||||
tvLeft = (TextView) findViewById(R.id.tvLeft);
|
||||
tvLeft.setVisibility(View.VISIBLE);
|
||||
SpannableString ssTitle = new SpannableString(this.getString(R.string.cancel));
|
||||
ssTitle.setSpan(new ForegroundColorSpan(GosDeploy.appConfig_Contrast()), 0, ssTitle.length(),
|
||||
Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
tvLeft.setText(ssTitle);
|
||||
tvLeft.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(GosAirlinkConfigCountdownActivity.this, GosMainActivity.class);
|
||||
quitAlert(GosAirlinkConfigCountdownActivity.this, intent, getString(R.string.cancel_configuration));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
WindowManager wm = this.getWindowManager();
|
||||
int width = wm.getDefaultDisplay().getWidth();
|
||||
|
||||
RelativeLayout cel_layout = (RelativeLayout) findViewById(R.id.params);
|
||||
LayoutParams params = cel_layout.getLayoutParams();
|
||||
params.height = width;
|
||||
params.width = width;
|
||||
cel_layout.setLayoutParams(params);
|
||||
//tvTimer = (TextView) findViewById(R.id.tvTimer);
|
||||
|
||||
rpbConfig = (RoundProgressBar) findViewById(R.id.rpbConfig);
|
||||
|
||||
}
|
||||
|
||||
private static final String TAG = "GosAirlinkConfigCountdo";
|
||||
|
||||
private void initData() {
|
||||
workSSID = spf.getString("workSSID", "");
|
||||
workSSIDPsw = spf.getString("workSSIDPsw", "");
|
||||
modeDataList = new ArrayList<GizWifiGAgentType>();
|
||||
modeDataList.add(GizWifiGAgentType.GizGAgentESP);
|
||||
modeDataList.add(GizWifiGAgentType.GizGAgentMXCHIP);
|
||||
modeDataList.add(GizWifiGAgentType.GizGAgentHF);
|
||||
modeDataList.add(GizWifiGAgentType.GizGAgentRTK);
|
||||
modeDataList.add(GizWifiGAgentType.GizGAgentWM);
|
||||
modeDataList.add(GizWifiGAgentType.GizGAgentQCA);
|
||||
modeDataList.add(GizWifiGAgentType.GizGAgentFlyLink);
|
||||
modeDataList.add(GizWifiGAgentType.GizGAgentTI);
|
||||
modeDataList.add(GizWifiGAgentType.GizGAgentFSK);
|
||||
modeDataList.add(GizWifiGAgentType.GizGAgentMXCHIP3);
|
||||
modeDataList.add(GizWifiGAgentType.GizGAgentBL);
|
||||
modeDataList.add(GizWifiGAgentType.GizGAgentAtmelEE);
|
||||
modeDataList.add(GizWifiGAgentType.GizGAgentOther);
|
||||
modeList = new ArrayList<GizWifiGAgentType>();
|
||||
|
||||
String types = spf.getString("modulestyles", null);
|
||||
if (types != null) {
|
||||
try {
|
||||
JSONArray array = new JSONArray(types);
|
||||
for (int i = 0; i < array.length(); i++) {
|
||||
int type = (Integer) array.get(i);
|
||||
modeList.add(modeDataList.get(type));
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void startAirlink() {
|
||||
String nullStr = null;
|
||||
switch (GosConstant.mNew) {
|
||||
case 0:
|
||||
GizWifiSDK.sharedInstance().setDeviceOnboarding(workSSID, workSSIDPsw,
|
||||
GizWifiConfigureMode.GizWifiAirLink, null, 60, modeList);
|
||||
break;
|
||||
case 1:
|
||||
GizWifiSDK.sharedInstance().setDeviceOnboardingByBind(workSSID, workSSIDPsw,
|
||||
GizWifiConfigureMode.GizWifiAirLink, null, 60, modeList);
|
||||
break;
|
||||
case 2:
|
||||
GizWifiSDK.sharedInstance().setDeviceOnboardingDeploy(
|
||||
workSSID,
|
||||
workSSIDPsw,
|
||||
GizWifiConfigureMode.GizWifiAirLink,
|
||||
nullStr,
|
||||
60,
|
||||
modeList,
|
||||
false
|
||||
);
|
||||
break;
|
||||
case 3:
|
||||
GizWifiSDK.sharedInstance().setDeviceOnboardingDeploy(
|
||||
workSSID,
|
||||
workSSIDPsw,
|
||||
GizWifiConfigureMode.GizWifiAirLink,
|
||||
nullStr,
|
||||
60,
|
||||
modeList,
|
||||
true
|
||||
);
|
||||
break;
|
||||
}
|
||||
handler.sendEmptyMessage(handler_key.START_TIMER.ordinal());
|
||||
}
|
||||
|
||||
private enum handler_key {
|
||||
|
||||
/**
|
||||
* 倒计时提示
|
||||
*/
|
||||
TIMER_TEXT,
|
||||
|
||||
/**
|
||||
* 倒计时开始
|
||||
*/
|
||||
START_TIMER,
|
||||
|
||||
/**
|
||||
* 配置成功
|
||||
*/
|
||||
SUCCESSFUL,
|
||||
|
||||
/**
|
||||
* 配置失败
|
||||
*/
|
||||
FAILED,
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The handler.
|
||||
*/
|
||||
Handler handler = new Handler() {
|
||||
public void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
handler_key key = handler_key.values()[msg.what];
|
||||
switch (key) {
|
||||
|
||||
case START_TIMER:
|
||||
isStartTimer();
|
||||
break;
|
||||
|
||||
case SUCCESSFUL:
|
||||
Toast.makeText(GosAirlinkConfigCountdownActivity.this,
|
||||
R.string.configuration_successful, toastTime).show();
|
||||
Intent intent1 = new Intent(GosAirlinkConfigCountdownActivity.this, GosMainActivity.class);
|
||||
startActivity(intent1);
|
||||
break;
|
||||
|
||||
case FAILED:
|
||||
if (GosDeploy.appConfig_Config_Softap()) {
|
||||
Toast.makeText(GosAirlinkConfigCountdownActivity.this,
|
||||
getString(R.string.configuration_timeout), toastTime).show();
|
||||
Intent intent = new Intent(
|
||||
GosAirlinkConfigCountdownActivity.this,
|
||||
GosDeviceReadyActivity.class);
|
||||
/** 判断是否是从一键配置界面传过去的 */
|
||||
intent.putExtra("isAirLink", true);
|
||||
startActivity(intent);
|
||||
} else {
|
||||
Intent intent = new Intent(
|
||||
GosAirlinkConfigCountdownActivity.this,
|
||||
GosConfigFailedActivity.class);
|
||||
/** 判断是否是从一键配置界面传过去的 */
|
||||
intent.putExtra("isAirLink", true);
|
||||
startActivity(intent);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// 屏蔽掉返回键
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
Intent intent = new Intent(GosAirlinkConfigCountdownActivity.this, GosMainActivity.class);
|
||||
//quitAlert(this, intent);
|
||||
quitAlert(this, intent, getString(R.string.cancel_configuration));
|
||||
overridePendingTransition(android.R.anim.slide_in_left, android.R.anim.slide_out_right);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// 倒计时
|
||||
public void isStartTimer() {
|
||||
|
||||
secondleft = 60;
|
||||
timer = new Timer();
|
||||
timer.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
secondleft--;
|
||||
rpbConfig.setProgress((60 - secondleft) * (100 / 60.0));
|
||||
}
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设备配置回调
|
||||
*
|
||||
* @param result 错误码
|
||||
* @param mac MAC
|
||||
* @param did DID
|
||||
* @param productKey PK
|
||||
*/
|
||||
protected void didSetDeviceOnboarding(GizWifiErrorCode result, String mac,
|
||||
String did, String productKey) {
|
||||
if (GizWifiErrorCode.GIZ_SDK_DEVICE_CONFIG_IS_RUNNING == result) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (timer != null) {
|
||||
timer.cancel();
|
||||
}
|
||||
Message message = new Message();
|
||||
if (result == GizWifiErrorCode.GIZ_SDK_SUCCESS) {
|
||||
message.what = handler_key.SUCCESSFUL.ordinal();
|
||||
} else if (result == GIZ_SDK_ONBOARDING_STOPPED) {
|
||||
|
||||
} else {
|
||||
message.what = handler_key.FAILED.ordinal();
|
||||
message.obj = toastError(result);
|
||||
}
|
||||
Log.i("Apptest", result.toString());
|
||||
handler.sendMessage(message);
|
||||
}
|
||||
}
|
@ -0,0 +1,132 @@
|
||||
package com.gizwits.opensource.appkit.ConfigModule;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.text.SpannableString;
|
||||
import android.text.Spanned;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gizwits.opensource.appkit.R;
|
||||
import com.gizwits.opensource.appkit.CommonModule.GosDeploy;
|
||||
import com.gizwits.opensource.appkit.utils.AssetsUtils;
|
||||
import com.gizwits.opensource.appkit.utils.ToolUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GosAirlinkReadyActivity extends GosConfigModuleBaseActivity implements OnClickListener {
|
||||
|
||||
|
||||
/**
|
||||
* The tv Ready
|
||||
*/
|
||||
TextView tvReady;
|
||||
|
||||
|
||||
/**
|
||||
* The btn Next
|
||||
*/
|
||||
Button btnNext;
|
||||
|
||||
TextView tvDeviceTip;
|
||||
|
||||
private int sum = 0;
|
||||
|
||||
//private TextView moudlechoose;
|
||||
|
||||
private List<String> modeList;
|
||||
private ImageView ivReady;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.actvity_gos_airlink_ready);
|
||||
// 设置ActionBar
|
||||
setToolBar(true, R.string.airlink_ready_title);
|
||||
|
||||
initData();
|
||||
initView();
|
||||
initEvent();
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
// workSSID = spf.getString("workSSID", "");
|
||||
|
||||
modeList = new ArrayList<String>();
|
||||
String[] modes = this.getResources().getStringArray(R.array.mode);
|
||||
for (String string : modes) {
|
||||
modeList.add(string);
|
||||
}
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
tvReady = (TextView) findViewById(R.id.tvReady);
|
||||
btnNext = (Button) findViewById(R.id.btnNext);
|
||||
tvDeviceTip = (TextView) findViewById(R.id.tvDeviceTip);
|
||||
ivReady = (ImageView) findViewById(R.id.ivReady);
|
||||
SpannableString spannableString = new SpannableString(getString(R.string.common_ready_message));
|
||||
if (AssetsUtils.isZh(this)) {
|
||||
spannableString.setSpan(new ForegroundColorSpan(Color.parseColor("#007AFF")), 9, 14, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
} else {
|
||||
spannableString.setSpan(new ForegroundColorSpan(Color.parseColor("#007AFF")), 28, 45, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
}
|
||||
|
||||
tvReady.setText(spannableString);
|
||||
|
||||
// 配置文件部署
|
||||
btnNext.setBackgroundDrawable(GosDeploy.appConfig_BackgroundColor());
|
||||
btnNext.setTextColor(GosDeploy.appConfig_Contrast());
|
||||
}
|
||||
|
||||
private void initEvent() {
|
||||
btnNext.setOnClickListener(this);
|
||||
tvDeviceTip.setOnClickListener(this);
|
||||
ivReady.setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.btnNext:
|
||||
if (ToolUtils.noDoubleClick()) {
|
||||
sum = 0;
|
||||
Intent intent = new Intent(this, GosAirlinkConfigCountdownActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
sum = 0;
|
||||
this.finish();
|
||||
//overridePendingTransition(android.R.anim.slide_in_left, android.R.anim.slide_out_right);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
// Intent intent = new Intent(this, GosAirlinkChooseDeviceWorkWiFiActivity.class);
|
||||
// startActivity(intent);
|
||||
// overridePendingTransition(android.R.anim.slide_in_left, android.R.anim.slide_out_right);
|
||||
// this.finish();
|
||||
// return true;
|
||||
// }
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,279 @@
|
||||
package com.gizwits.opensource.appkit.ConfigModule;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.location.LocationManager;
|
||||
import android.net.wifi.ScanResult;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.gizwits.opensource.appkit.R;
|
||||
import com.gizwits.gizwifisdk.log.SDKLog;
|
||||
import com.gizwits.opensource.appkit.CommonModule.GosConstant;
|
||||
import com.gizwits.opensource.appkit.utils.AssetsUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
@SuppressLint({"InflateParams", "HandlerLeak"})
|
||||
public class GosChooseDeviceActivity extends GosConfigModuleBaseActivity implements OnClickListener {
|
||||
|
||||
/**
|
||||
* The tv Nodevice
|
||||
*/
|
||||
TextView tvNodevice;
|
||||
|
||||
/**
|
||||
* The list View
|
||||
*/
|
||||
ListView listView;
|
||||
|
||||
/**
|
||||
* 系统WiFi集合
|
||||
*/
|
||||
ArrayList<ScanResult> list;
|
||||
|
||||
/**
|
||||
* 设备热点集合
|
||||
*/
|
||||
ArrayList<ScanResult> softList;
|
||||
|
||||
/**
|
||||
* 适配器
|
||||
*/
|
||||
Myadapter myadapter;
|
||||
|
||||
/**
|
||||
* 计时器
|
||||
*/
|
||||
Timer timer;
|
||||
|
||||
int flag = 0;
|
||||
|
||||
private enum handler_key {
|
||||
|
||||
/**
|
||||
* 刷新列表
|
||||
*/
|
||||
UPDATALIST,
|
||||
|
||||
}
|
||||
|
||||
Handler handler = new Handler() {
|
||||
public void handleMessage(android.os.Message msg) {
|
||||
super.handleMessage(msg);
|
||||
handler_key key = handler_key.values()[msg.what];
|
||||
switch (key) {
|
||||
// 更新列表
|
||||
case UPDATALIST:
|
||||
initData();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_gos_choose_device);
|
||||
// 设置ActionBar
|
||||
setToolBar(true, R.string.choosedevice);
|
||||
|
||||
initView();
|
||||
initEvent();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
startTimer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
timer.cancel();
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
// list = new ArrayList<ScanResult>();
|
||||
list = (ArrayList<ScanResult>) GosConstant.ssidList;
|
||||
//list = (ArrayList<ScanResult>) NetUtils.getCurrentWifiScanResult(GosChooseDeviceActivity.this);
|
||||
softList = new ArrayList<ScanResult>();
|
||||
ScanResult scanResult;
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
scanResult = list.get(i);
|
||||
if (scanResult.SSID.length() > SoftAP_Start.length()) {
|
||||
if (scanResult.SSID.contains(SoftAP_Start)) {
|
||||
softList.add(scanResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
myadapter = new Myadapter(softList);
|
||||
listView.setAdapter(myadapter);
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
tvNodevice = (TextView) findViewById(R.id.nodevice);
|
||||
listView = (ListView) findViewById(R.id.list_view);
|
||||
}
|
||||
|
||||
private void initEvent() {
|
||||
tvNodevice.setOnClickListener(this);
|
||||
|
||||
listView.setOnItemClickListener(new OnItemClickListener() {
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
Intent intent = new Intent(GosChooseDeviceActivity.this, GosConfigCountdownActivity.class);
|
||||
intent.putExtra("softSSID", softList.get(position).SSID);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.nodevice:
|
||||
if (list == null) {
|
||||
LocationManager locManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
|
||||
if (!locManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
|
||||
// 未打开位置开关,可能导致定位失败或定位不准,提示用户或做相应处理
|
||||
Toast.makeText(this, getString(R.string.open), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
} else if (list.size() == 0) {
|
||||
LocationManager locManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
|
||||
if (!locManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
|
||||
// 未打开位置开关,可能导致定位失败或定位不准,提示用户或做相应处理
|
||||
Toast.makeText(this, getString(R.string.open), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
}
|
||||
finish();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void startTimer() {
|
||||
timer = new Timer();
|
||||
timer.schedule(new TimerTask() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
handler.sendEmptyMessage(handler_key.UPDATALIST.ordinal());
|
||||
}
|
||||
}, 0, 3000);
|
||||
}
|
||||
|
||||
class Myadapter extends BaseAdapter {
|
||||
|
||||
ArrayList<ScanResult> softList;
|
||||
|
||||
public Myadapter(ArrayList<ScanResult> list) {
|
||||
this.softList = list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return softList.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
View view = convertView;
|
||||
Holder holder;
|
||||
if (view == null) {
|
||||
view = LayoutInflater.from(GosChooseDeviceActivity.this).inflate(R.layout.item_gos_wifi_device, null);
|
||||
holder = new Holder(view);
|
||||
view.setTag(holder);
|
||||
} else {
|
||||
|
||||
holder = (Holder) view.getTag();
|
||||
}
|
||||
String ssid = softList.get(position).SSID;
|
||||
|
||||
// String itemStart = (String) getText(R.string.itemtext_start);
|
||||
// String itemEnd = (String) getText(R.string.itemtext_end);
|
||||
String s = "";
|
||||
if (AssetsUtils.isZh(GosChooseDeviceActivity.this)) {
|
||||
s = getString(R.string.device) + ssid.substring(ssid.length() - 4);
|
||||
} else {
|
||||
s = getString(R.string.device) + " " + ssid.substring(ssid.length() - 4);
|
||||
}
|
||||
holder.getTextView().setText(s);
|
||||
|
||||
return view;
|
||||
}
|
||||
}
|
||||
|
||||
class Holder {
|
||||
View view;
|
||||
|
||||
public Holder(View view) {
|
||||
this.view = view;
|
||||
}
|
||||
|
||||
TextView textView;
|
||||
|
||||
public TextView getTextView() {
|
||||
if (textView == null) {
|
||||
textView = (TextView) view.findViewById(R.id.SSID_text);
|
||||
}
|
||||
return textView;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
finish();
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// 屏蔽掉返回键
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
finish();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -0,0 +1,465 @@
|
||||
package com.gizwits.opensource.appkit.ConfigModule;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.location.LocationManager;
|
||||
import android.net.wifi.ScanResult;
|
||||
import android.net.wifi.WifiInfo;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.text.TextUtils;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.gizwits.opensource.appkit.CommonModule.GosConstant;
|
||||
import com.gizwits.opensource.appkit.CommonModule.GosDeploy;
|
||||
import com.gizwits.opensource.appkit.DeviceModule.GosMainActivity;
|
||||
import com.gizwits.opensource.appkit.R;
|
||||
import com.gizwits.opensource.appkit.utils.NetUtils;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GosChooseDeviceWorkWiFiActivity extends GosConfigModuleBaseActivity
|
||||
implements OnClickListener, OnItemClickListener {
|
||||
|
||||
private AlertDialog create;
|
||||
private ArrayList<ScanResult> wifiList;
|
||||
|
||||
private static final int REQUEST_EXTERNAL_STORAGE = 1;
|
||||
private static String[] PERMISSIONS_STORAGE = {
|
||||
"android.permission.ACCESS_FINE_LOCATION",
|
||||
"android.permission.ACCESS_COARSE_LOCATION"};
|
||||
|
||||
/**
|
||||
* wifi信息
|
||||
*/
|
||||
public WifiInfo wifiInfo;
|
||||
|
||||
/**
|
||||
* The et SSID
|
||||
*/
|
||||
private EditText etSSID;
|
||||
|
||||
/**
|
||||
* The et Psw
|
||||
*/
|
||||
private EditText etPsw;
|
||||
|
||||
/**
|
||||
* The btn Next
|
||||
*/
|
||||
private Button btnNext;
|
||||
|
||||
/**
|
||||
* The cb Laws
|
||||
*/
|
||||
private CheckBox cbLaws;
|
||||
|
||||
/**
|
||||
* The img WiFiList
|
||||
*/
|
||||
private RelativeLayout rlWiFiList;
|
||||
|
||||
/**
|
||||
* 配置用参数
|
||||
*/
|
||||
private String softSSID, workSSID, workSSIDPsw;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_gos_choose_device_workwifi);
|
||||
// 设置ActionBar
|
||||
setToolBar(true, R.string.choose_wifi);
|
||||
|
||||
initData();
|
||||
initView();
|
||||
ininEvent();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
etSSID = (EditText) findViewById(R.id.etSSID);
|
||||
etPsw = (EditText) findViewById(R.id.etPsw);
|
||||
btnNext = (Button) findViewById(R.id.btnNext);
|
||||
cbLaws = (CheckBox) findViewById(R.id.cbLaws);
|
||||
rlWiFiList = (RelativeLayout) findViewById(R.id.rlWiFiList);
|
||||
// 配置文件部署
|
||||
btnNext.setBackgroundDrawable(GosDeploy.appConfig_BackgroundColor());
|
||||
btnNext.setTextColor(GosDeploy.appConfig_Contrast());
|
||||
if (!TextUtils.isEmpty(workSSID)) {
|
||||
etSSID.setText(workSSID);
|
||||
etSSID.setSelection(workSSID.length());
|
||||
if (checkworkSSIDUsed(workSSID)) {
|
||||
if (!TextUtils.isEmpty(spf.getString("workSSIDPsw", ""))) {
|
||||
etPsw.setText(spf.getString("workSSIDPsw", ""));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void ininEvent() {
|
||||
|
||||
btnNext.setOnClickListener(this);
|
||||
rlWiFiList.setOnClickListener(this);
|
||||
|
||||
cbLaws.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
String psw = etPsw.getText().toString();
|
||||
|
||||
if (isChecked) {
|
||||
etPsw.setInputType(0x90);
|
||||
} else {
|
||||
etPsw.setInputType(0x81);
|
||||
}
|
||||
etPsw.setSelection(psw.length());
|
||||
}
|
||||
});
|
||||
|
||||
//检测是否有位置定位的权限
|
||||
int permission = ActivityCompat.checkSelfPermission(GosChooseDeviceWorkWiFiActivity.this,
|
||||
"android.permission.ACCESS_FINE_LOCATION");
|
||||
if (permission != PackageManager.PERMISSION_GRANTED) {
|
||||
try {
|
||||
// 没有写的权限,去申请写的权限,会弹出对话框
|
||||
ActivityCompat.requestPermissions(GosChooseDeviceWorkWiFiActivity.this, PERMISSIONS_STORAGE, REQUEST_EXTERNAL_STORAGE);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
//softSSID = getIntent().getStringExtra("softssid");
|
||||
workSSID = spf.getString("workSSID", "");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
try {
|
||||
// 预设workSSID && workSSIDPsw
|
||||
workSSID = NetUtils.getCurentWifiSSID(this);
|
||||
String mypass = spf.getString("mypass", "");
|
||||
|
||||
if (!TextUtils.isEmpty(workSSID)) {
|
||||
etSSID.setText(workSSID);
|
||||
etSSID.setSelection(workSSID.length());
|
||||
if (!TextUtils.isEmpty(mypass)) {
|
||||
JSONObject obj = new JSONObject(mypass);
|
||||
|
||||
if (obj.has(workSSID)) {
|
||||
String pass = obj.getString(workSSID);
|
||||
etPsw.setText(pass);
|
||||
} else {
|
||||
etPsw.setText("");
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
etSSID.setText(NetUtils.getCurentWifiSSID(this));
|
||||
}
|
||||
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
Intent intent = new Intent(this, GosMainActivity.class);
|
||||
startActivity(intent);
|
||||
//quitAlert(this, intent);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.btnNext:
|
||||
workSSID = etSSID.getText().toString();
|
||||
workSSIDPsw = etPsw.getText().toString();
|
||||
|
||||
if (TextUtils.isEmpty(workSSID)) {
|
||||
Toast.makeText(GosChooseDeviceWorkWiFiActivity.this, R.string.choose_wifi_list_title,
|
||||
Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
if (TextUtils.isEmpty(workSSIDPsw)) {
|
||||
final Dialog dialog = new AlertDialog.Builder(this, R.style.alert_dialog_style)
|
||||
.setView(new EditText(this)).create();
|
||||
dialog.setCanceledOnTouchOutside(false);
|
||||
dialog.show();
|
||||
|
||||
Window window = dialog.getWindow();
|
||||
window.setContentView(R.layout.alert_gos_empty);
|
||||
WindowManager.LayoutParams layoutParams = window.getAttributes();
|
||||
layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
|
||||
window.setAttributes(layoutParams);
|
||||
LinearLayout llNo, llSure;
|
||||
llNo = (LinearLayout) window.findViewById(R.id.llNo);
|
||||
llSure = (LinearLayout) window.findViewById(R.id.llSure);
|
||||
|
||||
llNo.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
dialog.cancel();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
llSure.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
if (dialog.isShowing()) {
|
||||
dialog.cancel();
|
||||
}
|
||||
Intent intent = null;
|
||||
//wifiModuleType-false-start wifiModuleType-true-start
|
||||
if (GosDeploy.appConfig_WifiModuleType().size() == 0) {
|
||||
//wifiModuleType-false-end
|
||||
intent = new Intent(GosChooseDeviceWorkWiFiActivity.this,
|
||||
GosModeListActivity2.class);
|
||||
//wifiModuleType-false-start
|
||||
} else {
|
||||
//wifiModuleType-true-end
|
||||
List<Integer> moduleTypes = GosDeploy.appConfig_WifiModuleType();
|
||||
JSONArray array = new JSONArray();
|
||||
for (int type : moduleTypes) {
|
||||
if (type == 4) {
|
||||
type = 0;
|
||||
} else if (type < 4) {
|
||||
type = type + 1;
|
||||
} else if (type == 12) {
|
||||
type = 6;
|
||||
} else if (type >= 6 && type < 12) {
|
||||
type = type + 1;
|
||||
}
|
||||
array.put(type);
|
||||
}
|
||||
spf.edit().putString("modulestyles", array.toString()).commit();
|
||||
intent = new Intent(GosChooseDeviceWorkWiFiActivity.this,
|
||||
GosDeviceReadyActivity.class);
|
||||
//wifiModuleType-true-start
|
||||
}
|
||||
//wifiModuleType-false-end wifiModuleType-true-end
|
||||
spf.edit().putString("workSSID", workSSID).commit();
|
||||
spf.edit().putString("workSSIDPsw", workSSIDPsw).commit();
|
||||
intent.putExtra("isAirlink", false);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Intent intent = null;
|
||||
//wifiModuleType-false-start wifiModuleType-true-start
|
||||
if (GosDeploy.appConfig_WifiModuleType().size() == 0) {
|
||||
//wifiModuleType-false-end
|
||||
intent = new Intent(GosChooseDeviceWorkWiFiActivity.this,
|
||||
GosModeListActivity2.class);
|
||||
//wifiModuleType-false-start
|
||||
} else {
|
||||
//wifiModuleType-true-end
|
||||
List<Integer> moduleTypes = GosDeploy.appConfig_WifiModuleType();
|
||||
JSONArray array = new JSONArray();
|
||||
for (int type : moduleTypes) {
|
||||
if (type == 4) {
|
||||
type = 0;
|
||||
} else if (type < 4) {
|
||||
type = type + 1;
|
||||
} else if (type == 12) {
|
||||
type = 6;
|
||||
} else if (type >= 6 && type < 12) {
|
||||
type = type + 1;
|
||||
}
|
||||
array.put(type);
|
||||
}
|
||||
spf.edit().putString("modulestyles", array.toString()).commit();
|
||||
intent = new Intent(GosChooseDeviceWorkWiFiActivity.this,
|
||||
GosDeviceReadyActivity.class);
|
||||
//wifiModuleType-true-start
|
||||
}
|
||||
//wifiModuleType-false-end wifiModuleType-true-end
|
||||
spf.edit().putString("workSSID", workSSID).commit();
|
||||
spf.edit().putString("workSSIDPsw", workSSIDPsw).commit();
|
||||
/** 判断是否是从一键配置界面传过去的 */
|
||||
intent.putExtra("isAirlink", false);
|
||||
startActivity(intent);
|
||||
}
|
||||
break;
|
||||
|
||||
case R.id.rlWiFiList:
|
||||
AlertDialog.Builder dia = new AlertDialog.Builder(GosChooseDeviceWorkWiFiActivity.this);
|
||||
View view = View.inflate(GosChooseDeviceWorkWiFiActivity.this, R.layout.alert_gos_wifi_list, null);
|
||||
ListView listview = (ListView) view.findViewById(R.id.wifi_list);
|
||||
List<ScanResult> rsList = NetUtils.getCurrentWifiScanResult(this);
|
||||
List<String> localList = new ArrayList<String>();
|
||||
localList.clear();
|
||||
wifiList = new ArrayList<ScanResult>();
|
||||
wifiList.clear();
|
||||
|
||||
for (ScanResult sss : rsList) {
|
||||
if (sss.SSID.contains(GosConstant.SoftAP_Start)) {
|
||||
|
||||
} else {
|
||||
if (localList.toString().contains(sss.SSID)) {
|
||||
} else {
|
||||
localList.add(sss.SSID);
|
||||
wifiList.add(sss);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (wifiList.size() == 0) {
|
||||
LocationManager locManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
|
||||
if (!locManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
|
||||
// 未打开位置开关,可能导致定位失败或定位不准,提示用户或做相应处理
|
||||
Toast.makeText(this, getString(R.string.open), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
WifiListAdapter adapter = new WifiListAdapter(wifiList);
|
||||
listview.setAdapter(adapter);
|
||||
listview.setOnItemClickListener(this);
|
||||
dia.setView(view);
|
||||
create = dia.create();
|
||||
create.show();
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
|
||||
|
||||
ScanResult sResult = wifiList.get(arg2);
|
||||
String sSID = sResult.SSID;
|
||||
etSSID.setText(sSID);
|
||||
etSSID.setSelection(sSID.length());
|
||||
etPsw.setText("");
|
||||
create.dismiss();
|
||||
}
|
||||
|
||||
// 检查当前使用的WiFi是否曾经用过
|
||||
protected boolean checkworkSSIDUsed(String workSSID) {
|
||||
if (spf.contains("workSSID")) {
|
||||
if (spf.getString("workSSID", "").equals(workSSID)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// 屏蔽掉返回键
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
Intent intent = new Intent(this, GosMainActivity.class);
|
||||
startActivity(intent);
|
||||
//quitAlert(this, intent);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
class WifiListAdapter extends BaseAdapter {
|
||||
|
||||
ArrayList<ScanResult> xpgList;
|
||||
|
||||
public WifiListAdapter(ArrayList<ScanResult> list) {
|
||||
this.xpgList = list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return xpgList.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@SuppressLint("InflateParams")
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
View view = convertView;
|
||||
Holder holder;
|
||||
if (view == null) {
|
||||
view = LayoutInflater.from(GosChooseDeviceWorkWiFiActivity.this).inflate(R.layout.item_gos_wifi_list,
|
||||
null);
|
||||
holder = new Holder(view);
|
||||
view.setTag(holder);
|
||||
} else {
|
||||
holder = (Holder) view.getTag();
|
||||
}
|
||||
String ssid = xpgList.get(position).SSID;
|
||||
holder.getTextView().setText(ssid);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Holder {
|
||||
View view;
|
||||
|
||||
public Holder(View view) {
|
||||
this.view = view;
|
||||
}
|
||||
|
||||
TextView textView;
|
||||
|
||||
public TextView getTextView() {
|
||||
if (textView == null) {
|
||||
textView = (TextView) view.findViewById(R.id.SSID_text);
|
||||
}
|
||||
return textView;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package com.gizwits.opensource.appkit.ConfigModule;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
|
||||
import com.gizwits.opensource.appkit.R;
|
||||
import com.gizwits.opensource.appkit.utils.AssetsUtils;
|
||||
|
||||
|
||||
/**
|
||||
* Created by admin on 2017/6/15.
|
||||
*/
|
||||
|
||||
public class GosChooseModuleHelpActivity extends com.gizwits.opensource.appkit.ConfigModule.GosConfigModuleBaseActivity {
|
||||
private WebView webHelp;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_gos_choose_module_help);
|
||||
initView();
|
||||
initEvent();
|
||||
}
|
||||
|
||||
private void initEvent() {
|
||||
setToolBar(true, getString(R.string.module_help));
|
||||
WebSettings wSet = webHelp.getSettings();
|
||||
wSet.setJavaScriptEnabled(true);
|
||||
if (AssetsUtils.isZh(this)) {
|
||||
webHelp.loadUrl("file:///android_asset/moduleTypeInfo.html");
|
||||
} else {
|
||||
webHelp.loadUrl("file:///android_asset/moduleTypeInfoEnglish.html");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
webHelp = (WebView) findViewById(R.id.webHelp);
|
||||
}
|
||||
}
|
@ -0,0 +1,118 @@
|
||||
package com.gizwits.opensource.appkit.ConfigModule;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gizwits.opensource.appkit.R;
|
||||
import com.gizwits.opensource.appkit.CommonModule.GosDeploy;
|
||||
import com.gizwits.opensource.appkit.DeviceModule.GosMainActivity;
|
||||
import com.gizwits.opensource.appkit.utils.ToolUtils;
|
||||
|
||||
public class GosConfigFailedActivity extends GosConfigModuleBaseActivity implements OnClickListener {
|
||||
|
||||
/**
|
||||
* The btn Again
|
||||
*/
|
||||
Button btnAgain;
|
||||
|
||||
/**
|
||||
* The soft SSID
|
||||
*/
|
||||
String softSSID;
|
||||
|
||||
/**
|
||||
* The data
|
||||
*/
|
||||
String promptText, cancelBesureText, beSureText, cancelText;
|
||||
private boolean isAirLink;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_gos_config_failed);
|
||||
// 设置ActionBar
|
||||
setToolBar(false, R.string.join_failed_title);
|
||||
TextView tvLeft = (TextView) findViewById(R.id.tvLeft);
|
||||
tvLeft.setVisibility(View.VISIBLE);
|
||||
SpannableString ssTitle = new SpannableString(this.getString(R.string.cancel));
|
||||
ssTitle.setSpan(new ForegroundColorSpan(GosDeploy.appConfig_Contrast()), 0, ssTitle.length(),
|
||||
Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
tvLeft.setText(ssTitle);
|
||||
tvLeft.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(GosConfigFailedActivity.this, GosMainActivity.class);
|
||||
quitAlert(GosConfigFailedActivity.this, intent);
|
||||
}
|
||||
});
|
||||
initView();
|
||||
initEvent();
|
||||
initData();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
btnAgain = (Button) findViewById(R.id.btnAgain);
|
||||
|
||||
// 配置文件部署
|
||||
btnAgain.setBackgroundDrawable(GosDeploy.appConfig_BackgroundColor());
|
||||
btnAgain.setTextColor(GosDeploy.appConfig_Contrast());
|
||||
}
|
||||
|
||||
private void initEvent() {
|
||||
btnAgain.setOnClickListener(this);
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
/** 判断是否是从一键配置界面传过去的 */
|
||||
isAirLink = getIntent().getBooleanExtra("isAirLink", false);
|
||||
promptText = (String) getText(R.string.prompt);
|
||||
cancelBesureText = (String) getText(R.string.cancel_besure);
|
||||
beSureText = (String) getText(R.string.besure);
|
||||
cancelText = (String) getText(R.string.cancel);
|
||||
}
|
||||
|
||||
// 屏蔽掉返回键
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
Intent intent = new Intent(GosConfigFailedActivity.this, GosMainActivity.class);
|
||||
quitAlert(this, intent);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.btnAgain:
|
||||
if (ToolUtils.noDoubleClick()) {
|
||||
if (isAirLink) {
|
||||
//config_airlink-false-start
|
||||
Intent intent = new Intent(this, GosAirlinkChooseDeviceWorkWiFiActivity.class);
|
||||
startActivity(intent);
|
||||
//config_airlink-false-end
|
||||
} else {
|
||||
// config_softap-false-start
|
||||
Intent intent = new Intent(this, GosChooseDeviceWorkWiFiActivity.class);
|
||||
startActivity(intent);
|
||||
// config_softap-false-end
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,139 @@
|
||||
package com.gizwits.opensource.appkit.ConfigModule;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.text.SpannableString;
|
||||
import android.text.Spanned;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gizwits.opensource.appkit.CommonModule.GosDeploy;
|
||||
import com.gizwits.opensource.appkit.DeviceModule.GosMainActivity;
|
||||
import com.gizwits.opensource.appkit.R;
|
||||
import com.gizwits.opensource.appkit.utils.AssetsUtils;
|
||||
import com.gizwits.opensource.appkit.utils.ToolUtils;
|
||||
|
||||
public class GosDeviceReadyActivity extends GosConfigModuleBaseActivity implements OnClickListener {
|
||||
|
||||
/**
|
||||
* The tv Ready
|
||||
*/
|
||||
TextView tvReady;
|
||||
|
||||
/**
|
||||
* The tv DeviceTip
|
||||
*/
|
||||
TextView tvDeviceTips;
|
||||
|
||||
/**
|
||||
* The btn Next
|
||||
*/
|
||||
Button btnNext;
|
||||
|
||||
private int sum = 0;
|
||||
/**
|
||||
* The flag
|
||||
*/
|
||||
boolean flag = false;
|
||||
|
||||
boolean isAirLink = false;
|
||||
private ImageView ivReady;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_gos_device_ready);
|
||||
// 设置ActionBar
|
||||
setToolBar(true, R.string.model_confirmation);
|
||||
/** 判断是否是从一键配置界面传过去的 */
|
||||
isAirLink = getIntent().getBooleanExtra("isAirLink", false);
|
||||
|
||||
initView();
|
||||
initEvent();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
tvReady = (TextView) findViewById(R.id.tvReady);
|
||||
tvDeviceTips = (TextView) findViewById(R.id.tvDeviceTip);
|
||||
btnNext = (Button) findViewById(R.id.btnNext);
|
||||
ivReady = (ImageView) findViewById(R.id.ivReady);
|
||||
SpannableString spannableString = new SpannableString(getString(R.string.common_ready_message));
|
||||
if (AssetsUtils.isZh(this)) {
|
||||
spannableString.setSpan(new ForegroundColorSpan(Color.parseColor("#FF9500")), 9, 14, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
} else {
|
||||
spannableString.setSpan(new ForegroundColorSpan(Color.parseColor("#FF9500")), 28, 45, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
}
|
||||
|
||||
tvReady.setText(spannableString);
|
||||
|
||||
// 配置文件部署
|
||||
btnNext.setBackgroundDrawable(GosDeploy.appConfig_BackgroundColor());
|
||||
btnNext.setTextColor(GosDeploy.appConfig_Contrast());
|
||||
|
||||
}
|
||||
|
||||
private void initEvent() {
|
||||
btnNext.setOnClickListener(this);
|
||||
tvDeviceTips.setOnClickListener(this);
|
||||
ivReady.setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
|
||||
case R.id.btnNext:
|
||||
if (ToolUtils.noDoubleClick()) {
|
||||
sum = 0;
|
||||
Intent intent2 = new Intent(GosDeviceReadyActivity.this, GosChooseDeviceActivity.class);
|
||||
startActivity(intent2);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 屏蔽掉返回键
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
sum = 0;
|
||||
if (isAirLink) {
|
||||
Intent intent = new Intent(GosDeviceReadyActivity.this, GosMainActivity.class);
|
||||
startActivity(intent);
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
sum = 0;
|
||||
if (isAirLink) {
|
||||
Intent intent = new Intent(GosDeviceReadyActivity.this, GosMainActivity.class);
|
||||
startActivity(intent);
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,143 @@
|
||||
package com.gizwits.opensource.appkit.ConfigModule;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gizwits.opensource.appkit.R;
|
||||
import com.gizwits.opensource.appkit.CommonModule.GosDeploy;
|
||||
|
||||
public class GosDeviceResetActivity extends GosConfigModuleBaseActivity implements OnClickListener {
|
||||
|
||||
/**
|
||||
* The cb Select
|
||||
*/
|
||||
CheckBox cbSelect;
|
||||
|
||||
/**
|
||||
* The tv Select
|
||||
*/
|
||||
TextView tvSelect;
|
||||
|
||||
/**
|
||||
* The btn Next
|
||||
*/
|
||||
Button btnNext;
|
||||
|
||||
/**
|
||||
* The flag
|
||||
*/
|
||||
String flag;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.actvity_gos_device_reset);
|
||||
// 设置ActionBar
|
||||
setToolBar(true, R.string.reset_device);
|
||||
|
||||
initView();
|
||||
initEvent();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
cbSelect = (CheckBox) findViewById(R.id.cbSelect);
|
||||
tvSelect = (TextView) findViewById(R.id.tvSelect);
|
||||
btnNext = (Button) findViewById(R.id.btnNext);
|
||||
|
||||
|
||||
/** 加载标志位 */
|
||||
flag = getIntent().getStringExtra("flag").toString();
|
||||
|
||||
// 配置文件部署
|
||||
btnNext.setBackgroundDrawable(GosDeploy.appConfig_BackgroundColor());
|
||||
btnNext.setTextColor(GosDeploy.appConfig_Contrast());
|
||||
|
||||
}
|
||||
|
||||
private void initEvent() {
|
||||
btnNext.setOnClickListener(this);
|
||||
tvSelect.setOnClickListener(this);
|
||||
btnNext.setClickable(false);
|
||||
btnNext.setBackgroundResource(R.drawable.btn_next_shape_gray);
|
||||
|
||||
cbSelect.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
if (isChecked) {
|
||||
btnNext.setBackgroundDrawable(GosDeploy.appConfig_BackgroundColor());
|
||||
btnNext.setClickable(true);
|
||||
} else {
|
||||
btnNext.setBackgroundResource(R.drawable.btn_next_shape_gray);
|
||||
btnNext.setClickable(false);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.btnNext:
|
||||
if (TextUtils.isEmpty(flag)) {
|
||||
Intent intent = new Intent(GosDeviceResetActivity.this, GosChooseDeviceActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
finish();
|
||||
|
||||
break;
|
||||
|
||||
case R.id.tvSelect:
|
||||
if (cbSelect.isChecked()) {
|
||||
cbSelect.setChecked(false);
|
||||
} else {
|
||||
cbSelect.setChecked(true);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
if (TextUtils.isEmpty(flag)) {
|
||||
Intent intent = new Intent(GosDeviceResetActivity.this, GosDeviceReadyActivity.class);
|
||||
startActivity(intent);
|
||||
overridePendingTransition(android.R.anim.slide_in_left, android.R.anim.slide_out_right);
|
||||
}
|
||||
this.finish();
|
||||
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
if (TextUtils.isEmpty(flag)) {
|
||||
Intent intent = new Intent(GosDeviceResetActivity.this, GosDeviceReadyActivity.class);
|
||||
startActivity(intent);
|
||||
overridePendingTransition(android.R.anim.slide_in_left, android.R.anim.slide_out_right);
|
||||
}
|
||||
this.finish();
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,222 @@
|
||||
package com.gizwits.opensource.appkit.ConfigModule;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.gizwits.opensource.appkit.R;
|
||||
import com.gizwits.opensource.appkit.CommonModule.GosDeploy;
|
||||
import com.gizwits.opensource.appkit.utils.ToolUtils;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GosModeListActivity extends GosConfigModuleBaseActivity {
|
||||
|
||||
/**
|
||||
* The lv Mode
|
||||
*/
|
||||
ListView lvMode;
|
||||
|
||||
/**
|
||||
* The data
|
||||
*/
|
||||
List<String> modeList;
|
||||
|
||||
/**
|
||||
* The Adapter
|
||||
*/
|
||||
ModeListAdapter modeListAdapter;
|
||||
|
||||
List<Integer> list = new ArrayList<Integer>();
|
||||
|
||||
private Button btnOk;
|
||||
|
||||
private boolean isAirlink = true;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_gos_modelist);
|
||||
// 设置ActionBar
|
||||
setToolBar(true, R.string.choose_mode_start);
|
||||
final Drawable add = getResources().getDrawable(R.drawable.config_help_button);
|
||||
int color = GosDeploy.appConfig_Contrast();
|
||||
add.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
|
||||
mToolbar.setOverflowIcon(add);
|
||||
initData();
|
||||
initView();
|
||||
initEvent();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
lvMode = (ListView) findViewById(R.id.lvMode);
|
||||
|
||||
lvMode.setAdapter(modeListAdapter);// 初始化
|
||||
|
||||
btnOk = (Button) findViewById(R.id.btnOk);
|
||||
btnOk.setBackgroundDrawable(GosDeploy.appConfig_BackgroundColor());
|
||||
btnOk.setTextColor(GosDeploy.appConfig_Contrast());
|
||||
|
||||
}
|
||||
|
||||
private void initEvent() {
|
||||
|
||||
lvMode.setOnItemClickListener(new OnItemClickListener() {
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
|
||||
modeListAdapter.selectIndex = arg2;
|
||||
modeListAdapter.notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
|
||||
btnOk.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (ToolUtils.noDoubleClick()) {
|
||||
if (modeListAdapter.selectIndex == 100) {
|
||||
Toast.makeText(GosModeListActivity.this, getString(R.string.selece_module_type), toastTime).show();
|
||||
} else {
|
||||
JSONArray array = new JSONArray();
|
||||
array.put(modeListAdapter.selectIndex);
|
||||
spf.edit().putString("modulestyles", array.toString()).commit();
|
||||
if (isAirlink) {
|
||||
// config_airlink-false-start
|
||||
Intent intent = new Intent(GosModeListActivity.this, GosAirlinkReadyActivity.class);
|
||||
startActivity(intent);
|
||||
// config_airlink-false-end
|
||||
} else {
|
||||
//config_softap-false-start
|
||||
Intent intent = new Intent(GosModeListActivity.this, GosDeviceReadyActivity.class);
|
||||
startActivity(intent);
|
||||
//config_softap-false-end
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
isAirlink = getIntent().getBooleanExtra("isAirlink", true);
|
||||
modeList = new ArrayList<String>();
|
||||
String[] modes = this.getResources().getStringArray(R.array.mode);
|
||||
for (String string : modes) {
|
||||
modeList.add(string);
|
||||
}
|
||||
modeListAdapter = new ModeListAdapter(this, modeList);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.module_style, menu);
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
class ModeListAdapter extends BaseAdapter {
|
||||
|
||||
Context context;
|
||||
List<String> modeList;
|
||||
int selectIndex = 100;
|
||||
|
||||
public ModeListAdapter(Context context, List<String> modeList) {
|
||||
super();
|
||||
this.context = context;
|
||||
this.modeList = modeList;
|
||||
if (spf.getString("modulestyles", null) != null) {
|
||||
try {
|
||||
JSONArray array = new JSONArray(spf.getString("modulestyles", null));
|
||||
for (int i = 0; i < array.length(); i++) {
|
||||
selectIndex = Integer.parseInt(array.get(i).toString());
|
||||
}
|
||||
} catch(JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return modeList.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
if (null == convertView) {
|
||||
convertView = View.inflate(context, R.layout.item_gos_mode_list, null);
|
||||
}
|
||||
|
||||
TextView tvModeText = (TextView) convertView.findViewById(R.id.tvModeText);
|
||||
|
||||
String modeText = modeList.get(position);
|
||||
tvModeText.setText(modeText);
|
||||
|
||||
ImageView ivChoosed = (ImageView) convertView.findViewById(R.id.ivChoosed);
|
||||
if (selectIndex == position) {
|
||||
ivChoosed.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
ivChoosed.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
|
||||
return convertView;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
this.finish();
|
||||
overridePendingTransition(android.R.anim.slide_in_left, android.R.anim.slide_out_right);
|
||||
break;
|
||||
case R.id.module_help:
|
||||
if (ToolUtils.noDoubleClick()) {
|
||||
startActivity(new Intent(GosModeListActivity.this, GosChooseModuleHelpActivity.class));
|
||||
}
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
// Intent intent = new Intent(this, GosAirlinkChooseDeviceWorkWiFiActivity.class);
|
||||
// startActivity(intent);
|
||||
// overridePendingTransition(android.R.anim.slide_in_left, android.R.anim.slide_out_right);
|
||||
// this.finish();
|
||||
// return true;
|
||||
// }
|
||||
|
||||
}
|
@ -0,0 +1,219 @@
|
||||
package com.gizwits.opensource.appkit.ConfigModule;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.gizwits.opensource.appkit.R;
|
||||
import com.gizwits.opensource.appkit.CommonModule.GosDeploy;
|
||||
import com.gizwits.opensource.appkit.utils.ToolUtils;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GosModeListActivity2 extends GosConfigModuleBaseActivity {
|
||||
|
||||
/**
|
||||
* The lv Mode
|
||||
*/
|
||||
ListView lvMode;
|
||||
|
||||
/**
|
||||
* The data
|
||||
*/
|
||||
List<String> modeList;
|
||||
|
||||
/**
|
||||
* The Adapter
|
||||
*/
|
||||
ModeListAdapter modeListAdapter;
|
||||
|
||||
List<Integer> list = new ArrayList<Integer>();
|
||||
|
||||
private Button btnOk;
|
||||
private boolean isAirlink = true;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_gos_modelist);
|
||||
// 设置ActionBar
|
||||
setToolBar(true, R.string.choose_mode_start);
|
||||
initData();
|
||||
initView();
|
||||
initEvent();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
lvMode = (ListView) findViewById(R.id.lvMode);
|
||||
|
||||
lvMode.setAdapter(modeListAdapter);// 初始化
|
||||
|
||||
btnOk = (Button) findViewById(R.id.btnOk);
|
||||
btnOk.setBackgroundDrawable(GosDeploy.appConfig_BackgroundColor());
|
||||
btnOk.setTextColor(GosDeploy.appConfig_Contrast());
|
||||
}
|
||||
|
||||
private void initEvent() {
|
||||
|
||||
lvMode.setOnItemClickListener(new OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
|
||||
boolean isRemove = false;
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
if (list.get(i) == arg2) {
|
||||
list.remove(i);
|
||||
isRemove = true;
|
||||
}
|
||||
}
|
||||
if (!isRemove) {
|
||||
list.add(arg2);
|
||||
}
|
||||
modeListAdapter.notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
btnOk.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (ToolUtils.noDoubleClick()) {
|
||||
if (list.size() == 0) {
|
||||
Toast.makeText(GosModeListActivity2.this, getString(R.string.selece_module_type), toastTime).show();
|
||||
} else {
|
||||
JSONArray array = new JSONArray();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
array.put(list.get(i));
|
||||
}
|
||||
Log.e("TAG", "onClick: " + array.toString());
|
||||
spf.edit().putString("modulestyles", array.toString()).commit();
|
||||
if (isAirlink) {
|
||||
// config_airlink-false-start
|
||||
Intent intent = new Intent(GosModeListActivity2.this, GosAirlinkReadyActivity.class);
|
||||
startActivity(intent);
|
||||
// config_airlink-false-end
|
||||
} else {
|
||||
//config_softap-false-start
|
||||
Intent intent = new Intent(GosModeListActivity2.this, GosDeviceReadyActivity.class);
|
||||
startActivity(intent);
|
||||
//config_softap-false-end
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
isAirlink = getIntent().getBooleanExtra("isAirlink", true);
|
||||
String modules = spf.getString("modulestyles", null);
|
||||
if (modules != null) {
|
||||
try {
|
||||
JSONArray array = new JSONArray(modules);
|
||||
for (int i = 0; i < array.length(); i++) {
|
||||
int type = (Integer) array.get(i);
|
||||
list.add(type);
|
||||
}
|
||||
} catch(JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
modeList = new ArrayList<String>();
|
||||
String[] modes = this.getResources().getStringArray(R.array.mode);
|
||||
for (String string : modes) {
|
||||
modeList.add(string);
|
||||
}
|
||||
modeListAdapter = new ModeListAdapter(this, modeList);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.module_style, menu);
|
||||
MenuItem menuItem = menu.findItem(R.id.module_help);
|
||||
menuItem.setIcon(ToolUtils.editIcon(getResources(), R.drawable.config_help_button));
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
class ModeListAdapter extends BaseAdapter {
|
||||
|
||||
Context context;
|
||||
List<String> modeList;
|
||||
|
||||
public ModeListAdapter(Context context, List<String> modeList) {
|
||||
super();
|
||||
this.context = context;
|
||||
this.modeList = modeList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return modeList.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
if (null == convertView) {
|
||||
convertView = View.inflate(context, R.layout.item_gos_mode_list, null);
|
||||
}
|
||||
|
||||
TextView tvModeText = (TextView) convertView.findViewById(R.id.tvModeText);
|
||||
|
||||
String modeText = modeList.get(position);
|
||||
tvModeText.setText(modeText);
|
||||
|
||||
ImageView ivChoosed = (ImageView) convertView.findViewById(R.id.ivChoosed);
|
||||
if (list.contains(position)) {
|
||||
ivChoosed.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
ivChoosed.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
return convertView;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
this.finish();
|
||||
overridePendingTransition(android.R.anim.slide_in_left, android.R.anim.slide_out_right);
|
||||
break;
|
||||
case R.id.module_help:
|
||||
if (ToolUtils.noDoubleClick()) {
|
||||
startActivity(new Intent(GosModeListActivity2.this, GosChooseModuleHelpActivity.class));
|
||||
}
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package com.gizwits.opensource.appkit.ConfigModule;
|
||||
|
||||
import com.gizwits.opensource.appkit.CommonModule.GosBaseActivity;
|
||||
import com.gizwits.opensource.appkit.utils.NetUtils;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.wifi.WifiManager;
|
||||
|
||||
|
||||
public class GosWifiChangeReciver extends BroadcastReceiver {
|
||||
|
||||
SharedPreferences spf;
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
|
||||
spf = context.getSharedPreferences(GosBaseActivity.SPF_Name, Context.MODE_PRIVATE);
|
||||
|
||||
String wifiname = spf.getString("workSSID", "");
|
||||
String wifipass = spf.getString("workSSIDPsw", "");
|
||||
String connectWifiSsid = NetUtils.getConnectWifiSsid(context);
|
||||
if (connectWifiSsid != null && connectWifiSsid.contains(GosBaseActivity.SoftAP_Start)) {
|
||||
} else {
|
||||
if (connectWifiSsid.contains(wifiname)) {
|
||||
return;
|
||||
}
|
||||
WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
|
||||
WifiAutoConnectManager manager = new WifiAutoConnectManager(wifiManager);
|
||||
manager.connect(wifiname, wifipass, WifiAutoConnectManager.getCipherType(context, wifiname));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,735 @@
|
||||
package com.gizwits.opensource.appkit.DeviceModule;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
|
||||
import com.gizwits.opensource.appkit.R;
|
||||
import com.gizwits.gizwifisdk.enumration.GizWifiErrorCode;
|
||||
|
||||
/**
|
||||
* author: smile .
|
||||
* date: On 2018/6/7
|
||||
*/
|
||||
public class GosBaseFragment extends Fragment {
|
||||
/**
|
||||
* 存储器
|
||||
*/
|
||||
public SharedPreferences spf;
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
spf = getActivity().getSharedPreferences("set", Context.MODE_PRIVATE);
|
||||
}
|
||||
public String toastError(GizWifiErrorCode errorCode) {
|
||||
String errorString = (String) getText(R.string.UNKNOWN_ERROR);
|
||||
switch (errorCode) {
|
||||
case GIZ_SDK_SUCCESS:
|
||||
errorString=(String)getText(R.string.GIZ_SDK_SUCCESS);
|
||||
break;
|
||||
case GIZ_SDK_PARAM_FORM_INVALID:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_PARAM_FORM_INVALID);
|
||||
break;
|
||||
case GIZ_SDK_CLIENT_NOT_AUTHEN:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_CLIENT_NOT_AUTHEN);
|
||||
break;
|
||||
case GIZ_SDK_CLIENT_VERSION_INVALID:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_CLIENT_VERSION_INVALID);
|
||||
break;
|
||||
case GIZ_SDK_UDP_PORT_BIND_FAILED:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_UDP_PORT_BIND_FAILED);
|
||||
break;
|
||||
case GIZ_SDK_DAEMON_EXCEPTION:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_DAEMON_EXCEPTION);
|
||||
break;
|
||||
case GIZ_SDK_PARAM_INVALID:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_PARAM_INVALID);
|
||||
break;
|
||||
case GIZ_SDK_APPID_LENGTH_ERROR:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_APPID_LENGTH_ERROR);
|
||||
break;
|
||||
case GIZ_SDK_LOG_PATH_INVALID:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_LOG_PATH_INVALID);
|
||||
break;
|
||||
case GIZ_SDK_LOG_LEVEL_INVALID:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_LOG_LEVEL_INVALID);
|
||||
break;
|
||||
case GIZ_SDK_UID_INVALID:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_UID_INVALID);
|
||||
break;
|
||||
case GIZ_SDK_TOKEN_INVALID:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_TOKEN_INVALID);
|
||||
break;
|
||||
case GIZ_SDK_USER_NOT_LOGIN:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_USER_NOT_LOGIN);
|
||||
break;
|
||||
case GIZ_SDK_APPID_INVALID:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_APPID_INVALID);
|
||||
break;
|
||||
case GIZ_SDK_APP_SECRET_INVALID:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_APP_SECRET_INVALID);
|
||||
break;
|
||||
case GIZ_SDK_PRODUCT_KEY_INVALID:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_PRODUCT_KEY_INVALID);
|
||||
break;
|
||||
case GIZ_SDK_PRODUCT_SECRET_INVALID:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_PRODUCT_SECRET_INVALID);
|
||||
break;
|
||||
case GIZ_SDK_DEVICE_NOT_IN_LAN:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_DEVICE_NOT_IN_LAN);
|
||||
break;
|
||||
case GIZ_SDK_PRODUCTKEY_NOT_IN_SPECIAL_LIST:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_PRODUCTKEY_NOT_IN_SPECIAL_LIST);
|
||||
break;
|
||||
case GIZ_SDK_PRODUCTKEY_NOT_RELATED_WITH_APPID:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_PRODUCTKEY_NOT_RELATED_WITH_APPID);
|
||||
break;
|
||||
case GIZ_SDK_NO_AVAILABLE_DEVICE:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_NO_AVAILABLE_DEVICE);
|
||||
break;
|
||||
case GIZ_SDK_DEVICE_CONFIG_SEND_FAILED:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_DEVICE_CONFIG_SEND_FAILED);
|
||||
break;
|
||||
case GIZ_SDK_DEVICE_CONFIG_IS_RUNNING:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_DEVICE_CONFIG_IS_RUNNING);
|
||||
break;
|
||||
case GIZ_SDK_DEVICE_CONFIG_TIMEOUT:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_DEVICE_CONFIG_TIMEOUT);
|
||||
break;
|
||||
case GIZ_SDK_DEVICE_DID_INVALID:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_DEVICE_DID_INVALID);
|
||||
break;
|
||||
case GIZ_SDK_DEVICE_MAC_INVALID:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_DEVICE_MAC_INVALID);
|
||||
break;
|
||||
case GIZ_SDK_SUBDEVICE_INVALID:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_SUBDEVICE_INVALID);
|
||||
break;
|
||||
case GIZ_SDK_DEVICE_PASSCODE_INVALID:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_DEVICE_PASSCODE_INVALID);
|
||||
break;
|
||||
case GIZ_SDK_DEVICE_NOT_CENTERCONTROL:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_DEVICE_NOT_CENTERCONTROL);
|
||||
break;
|
||||
case GIZ_SDK_DEVICE_NOT_SUBSCRIBED:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_DEVICE_NOT_SUBSCRIBED);
|
||||
break;
|
||||
case GIZ_SDK_DEVICE_NO_RESPONSE:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_DEVICE_NO_RESPONSE);
|
||||
break;
|
||||
case GIZ_SDK_DEVICE_NOT_READY:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_DEVICE_NOT_READY);
|
||||
break;
|
||||
case GIZ_SDK_DEVICE_NOT_BINDED:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_DEVICE_NOT_BINDED);
|
||||
break;
|
||||
case GIZ_SDK_DEVICE_CONTROL_WITH_INVALID_COMMAND:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_DEVICE_CONTROL_WITH_INVALID_COMMAND);
|
||||
break;
|
||||
// case GIZ_SDK_DEVICE_CONTROL_FAILED:
|
||||
// errorString= (String) getText(R.string.GIZ_SDK_DEVICE_CONTROL_FAILED);
|
||||
// break;
|
||||
case GIZ_SDK_DEVICE_GET_STATUS_FAILED:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_DEVICE_GET_STATUS_FAILED);
|
||||
break;
|
||||
case GIZ_SDK_DEVICE_CONTROL_VALUE_TYPE_ERROR:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_DEVICE_CONTROL_VALUE_TYPE_ERROR);
|
||||
break;
|
||||
case GIZ_SDK_DEVICE_CONTROL_VALUE_OUT_OF_RANGE:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_DEVICE_CONTROL_VALUE_OUT_OF_RANGE);
|
||||
break;
|
||||
case GIZ_SDK_DEVICE_CONTROL_NOT_WRITABLE_COMMAND:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_DEVICE_CONTROL_NOT_WRITABLE_COMMAND);
|
||||
break;
|
||||
case GIZ_SDK_BIND_DEVICE_FAILED:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_BIND_DEVICE_FAILED);
|
||||
break;
|
||||
case GIZ_SDK_UNBIND_DEVICE_FAILED:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_UNBIND_DEVICE_FAILED);
|
||||
break;
|
||||
case GIZ_SDK_DNS_FAILED:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_DNS_FAILED);
|
||||
break;
|
||||
case GIZ_SDK_M2M_CONNECTION_SUCCESS:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_M2M_CONNECTION_SUCCESS);
|
||||
break;
|
||||
case GIZ_SDK_SET_SOCKET_NON_BLOCK_FAILED:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_SET_SOCKET_NON_BLOCK_FAILED);
|
||||
break;
|
||||
case GIZ_SDK_CONNECTION_TIMEOUT:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_CONNECTION_TIMEOUT);
|
||||
break;
|
||||
case GIZ_SDK_CONNECTION_REFUSED:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_CONNECTION_REFUSED);
|
||||
break;
|
||||
case GIZ_SDK_CONNECTION_ERROR:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_CONNECTION_ERROR);
|
||||
break;
|
||||
case GIZ_SDK_CONNECTION_CLOSED:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_CONNECTION_CLOSED);
|
||||
break;
|
||||
case GIZ_SDK_SSL_HANDSHAKE_FAILED:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_SSL_HANDSHAKE_FAILED);
|
||||
break;
|
||||
case GIZ_SDK_DEVICE_LOGIN_VERIFY_FAILED:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_DEVICE_LOGIN_VERIFY_FAILED);
|
||||
break;
|
||||
case GIZ_SDK_INTERNET_NOT_REACHABLE:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_INTERNET_NOT_REACHABLE);
|
||||
break;
|
||||
case GIZ_SDK_M2M_CONNECTION_FAILED:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_M2M_CONNECTION_FAILED);
|
||||
break;
|
||||
case GIZ_SDK_HTTP_SERVER_NOT_SUPPORT_API:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_HTTP_SERVER_NOT_SUPPORT_API);
|
||||
break;
|
||||
case GIZ_SDK_HTTP_ANSWER_FORMAT_ERROR:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_HTTP_ANSWER_FORMAT_ERROR);
|
||||
break;
|
||||
case GIZ_SDK_HTTP_ANSWER_PARAM_ERROR:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_HTTP_ANSWER_PARAM_ERROR);
|
||||
break;
|
||||
case GIZ_SDK_HTTP_SERVER_NO_ANSWER:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_HTTP_SERVER_NO_ANSWER);
|
||||
break;
|
||||
case GIZ_SDK_HTTP_REQUEST_FAILED:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_HTTP_REQUEST_FAILED);
|
||||
break;
|
||||
case GIZ_SDK_OTHERWISE:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_OTHERWISE);
|
||||
break;
|
||||
case GIZ_SDK_MEMORY_MALLOC_FAILED:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_MEMORY_MALLOC_FAILED);
|
||||
break;
|
||||
case GIZ_SDK_THREAD_CREATE_FAILED:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_THREAD_CREATE_FAILED);
|
||||
break;
|
||||
case GIZ_SDK_JSON_OBJECT_CREATE_FAILED:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_JSON_OBJECT_CREATE_FAILED);
|
||||
break;
|
||||
case GIZ_SDK_JSON_PARSE_FAILED:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_JSON_PARSE_FAILED);
|
||||
break;
|
||||
case GIZ_SDK_SCHEDULER_CREATE_FAILED:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_SCHEDULER_CREATE_FAILED);
|
||||
break;
|
||||
case GIZ_SDK_SCHEDULER_DELETE_FAILED:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_SCHEDULER_DELETE_FAILED);
|
||||
break;
|
||||
case GIZ_SDK_SCHEDULER_EDIT_FAILED:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_SCHEDULER_EDIT_FAILED);
|
||||
break;
|
||||
case GIZ_SDK_SCHEDULER_LIST_UPDATE_FAILED:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_SCHEDULER_LIST_UPDATE_FAILED);
|
||||
break;
|
||||
case GIZ_SDK_SCHEDULER_TASK_EDIT_FAILED:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_SCHEDULER_TASK_EDIT_FAILED);
|
||||
break;
|
||||
case GIZ_SDK_SCHEDULER_TASK_LIST_UPDATE_FAILED:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_SCHEDULER_TASK_LIST_UPDATE_FAILED);
|
||||
break;
|
||||
case GIZ_SDK_SCHEDULER_ID_INVALID:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_SCHEDULER_ID_INVALID);
|
||||
break;
|
||||
case GIZ_SDK_SCHEDULER_ENABLE_DISABLE_FAILED:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_SCHEDULER_ENABLE_DISABLE_FAILED);
|
||||
break;
|
||||
case GIZ_SDK_SCHEDULER_STATUS_UPDATE_FAILED:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_SCHEDULER_STATUS_UPDATE_FAILED);
|
||||
break;
|
||||
case GIZ_SDK_GROUP_ID_INVALID:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_GROUP_ID_INVALID);
|
||||
break;
|
||||
case GIZ_SDK_GROUP_FAILED_DELETE_DEVICE:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_GROUP_FAILED_DELETE_DEVICE);
|
||||
break;
|
||||
case GIZ_SDK_GROUP_FAILED_ADD_DEVICE:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_GROUP_FAILED_ADD_DEVICE);
|
||||
break;
|
||||
case GIZ_SDK_GROUP_PRODUCTKEY_INVALID:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_GROUP_PRODUCTKEY_INVALID);
|
||||
break;
|
||||
case GIZ_SDK_GROUP_CREATE_FAILED:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_GROUP_CREATE_FAILED);
|
||||
break;
|
||||
case GIZ_SDK_GROUP_DELETE_FAILED:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_GROUP_FAILED_DELETE_DEVICE);
|
||||
break;
|
||||
case GIZ_SDK_GROUP_EDIT_FAILED:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_GROUP_EDIT_FAILED);
|
||||
break;
|
||||
case GIZ_SDK_GROUP_LIST_UPDATE_FAILED:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_GROUP_GET_DEVICE_FAILED);
|
||||
break;
|
||||
case GIZ_SDK_SCENE_CREATE_FAILED:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_SCENE_CREATE_FAILED);
|
||||
break;
|
||||
case GIZ_SDK_SCENE_DELETE_FAILED:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_SCENE_DELETE_FAILED);
|
||||
break;
|
||||
case GIZ_SDK_SCENE_EDIT_FAILED:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_SCENE_EDIT_FAILED);
|
||||
break;
|
||||
case GIZ_SDK_SCENE_LIST_UPDATE_FAILED:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_SCENE_LIST_UPDATE_FAILED);
|
||||
break;
|
||||
case GIZ_SDK_SCENE_ITEM_LIST_EDIT_FAILED:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_SCENE_ITEM_LIST_EDIT_FAILED);
|
||||
break;
|
||||
case GIZ_SDK_SCENE_ITEM_LIST_UPDATE_FAILED:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_SCENE_ITEM_LIST_UPDATE_FAILED);
|
||||
break;
|
||||
case GIZ_SDK_SCENE_ID_INVALID:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_SCENE_ID_INVALID);
|
||||
break;
|
||||
case GIZ_SDK_SCENE_RUN_FAILED:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_SCENE_RUN_FAILED);
|
||||
break;
|
||||
case GIZ_SDK_SCENE_STATUS_UPDATE_FAILED:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_SCENE_STATUS_UPDATE_FAILED);
|
||||
break;
|
||||
case GIZ_SDK_JOINT_ACTION_CREATE_FAILED:
|
||||
errorString= (String) getText(R.string.GIZ_SDK_JOINT_ACTION_CREATE_FAILED);
|
||||
break;
|
||||
case GIZ_SDK_JOINT_ACTION_DELETE_FAILED:
|
||||
errorString= (String) getText(R.string.GIZ_SDK_JOINT_ACTION_DELETE_FAILED);
|
||||
break;
|
||||
case GIZ_SDK_JOINT_ACTION_VER_UNSUPPORTED:
|
||||
errorString= (String) getText(R.string.GIZ_SDK_JOINT_ACTION_VER_UNSUPPORTED);
|
||||
break;
|
||||
// case GIZ_SDK_JOINT_ACTION_INVALID_CONDITION_TYPE:
|
||||
// errorString= (String) getText(R.string.GIZ_SDK_JOINT_ACTION_INVALID_CONDITION_TYPE);
|
||||
// break;
|
||||
// case GIZ_SDK_JOINT_ACTION_INVALID_RESULT_EVENT_TYPE:
|
||||
// errorString= (String) getText(R.string.GIZ_SDK_JOINT_ACTION_INVALID_RESULT_EVENT_TYPE);
|
||||
// break;
|
||||
case GIZ_SDK_DATAPOINT_NOT_DOWNLOAD:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_DATAPOINT_NOT_DOWNLOAD);
|
||||
break;
|
||||
case GIZ_SDK_DATAPOINT_SERVICE_UNAVAILABLE:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_DATAPOINT_SERVICE_UNAVAILABLE);
|
||||
break;
|
||||
case GIZ_SDK_DATAPOINT_PARSE_FAILED:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_DATAPOINT_PARSE_FAILED);
|
||||
break;
|
||||
// case GIZ_SDK_NOT_INITIALIZED:
|
||||
// errorString= (String) getText(R.string.GIZ_SDK_SDK_NOT_INITIALIZED);
|
||||
// break;
|
||||
case GIZ_SDK_APK_CONTEXT_IS_NULL:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_APK_CONTEXT_IS_NULL);
|
||||
break;
|
||||
case GIZ_SDK_APK_PERMISSION_NOT_SET:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_APK_PERMISSION_NOT_SET);
|
||||
break;
|
||||
case GIZ_SDK_CHMOD_DAEMON_REFUSED:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_CHMOD_DAEMON_REFUSED);
|
||||
break;
|
||||
case GIZ_SDK_EXEC_DAEMON_FAILED:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_EXEC_DAEMON_FAILED);
|
||||
break;
|
||||
case GIZ_SDK_EXEC_CATCH_EXCEPTION:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_EXEC_CATCH_EXCEPTION);
|
||||
break;
|
||||
case GIZ_SDK_APPID_IS_EMPTY:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_APPID_IS_EMPTY);
|
||||
break;
|
||||
case GIZ_SDK_UNSUPPORTED_API:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_UNSUPPORTED_API);
|
||||
break;
|
||||
case GIZ_SDK_REQUEST_TIMEOUT:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_REQUEST_TIMEOUT);
|
||||
break;
|
||||
case GIZ_SDK_DAEMON_VERSION_INVALID:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_DAEMON_VERSION_INVALID);
|
||||
break;
|
||||
case GIZ_SDK_PHONE_NOT_CONNECT_TO_SOFTAP_SSID:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_PHONE_NOT_CONNECT_TO_SOFTAP_SSID);
|
||||
break;
|
||||
case GIZ_SDK_DEVICE_CONFIG_SSID_NOT_MATCHED:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_DEVICE_CONFIG_SSID_NOT_MATCHED);
|
||||
break;
|
||||
case GIZ_SDK_NOT_IN_SOFTAPMODE:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_NOT_IN_SOFTAPMODE);
|
||||
break;
|
||||
// case GIZ_SDK_PHONE_WIFI_IS_UNAVAILABLE:
|
||||
// errorString= (String)getText(R.string.GIZ_SDK_PHONE_WIFI_IS_UNAVAILABLE);
|
||||
// break;
|
||||
case GIZ_SDK_RAW_DATA_TRANSMIT:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_RAW_DATA_TRANSMIT);
|
||||
break;
|
||||
case GIZ_SDK_PRODUCT_IS_DOWNLOADING:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_PRODUCT_IS_DOWNLOADING);
|
||||
break;
|
||||
case GIZ_SDK_START_SUCCESS:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_START_SUCCESS);
|
||||
break;
|
||||
case GIZ_SDK_NEED_UPDATE_TO_LATEST:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_NEED_UPDATE_TO_LATEST);
|
||||
break;
|
||||
case GIZ_SDK_ONBOARDING_STOPPED:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_ONBOARDING_STOPPED);
|
||||
break;
|
||||
case GIZ_SDK_ONBOARDING_WIFI_IS_5G:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_ONBOARDING_WIFI_IS_5G);
|
||||
break;
|
||||
case GIZ_SDK_OTA_FIRMWARE_IS_LATEST:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_OTA_FIRMWARE_IS_LATEST);
|
||||
break;
|
||||
case GIZ_SDK_OTA_FIRMWARE_CHECK_UPDATE_FAILED:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_OTA_FIRMWARE_CHECK_UPDATE_FAILED);
|
||||
break;
|
||||
case GIZ_SDK_OTA_FIRMWARE_DOWNLOAD_OK:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_OTA_FIRMWARE_DOWNLOAD_OK);
|
||||
break;
|
||||
case GIZ_SDK_OTA_FIRMWARE_DOWNLOAD_FAILED:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_OTA_FIRMWARE_DOWNLOAD_FAILED);
|
||||
break;
|
||||
case GIZ_SDK_OTA_DEVICE_BUSY_IN_UPGRADE:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_OTA_DEVICE_BUSY_IN_UPGRADE);
|
||||
break;
|
||||
case GIZ_SDK_OTA_PUSH_FAILED:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_OTA_PUSH_FAILED);
|
||||
break;
|
||||
case GIZ_SDK_OTA_FIRMWARE_VERSION_TOO_LOW:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_OTA_FIRMWARE_VERSION_TOO_LOW);
|
||||
break;
|
||||
case GIZ_SDK_OTA_FIRMWARE_CHECK_FAILED:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_OTA_FIRMWARE_CHECK_FAILED);
|
||||
break;
|
||||
case GIZ_SDK_OTA_UPGRADE_FAILED:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_OTA_UPGRADE_FAILED);
|
||||
break;
|
||||
case GIZ_SDK_OTA_FIRMWARE_VERIFY_SUCCESS:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_OTA_FIRMWARE_VERIFY_SUCCESS);
|
||||
break;
|
||||
case GIZ_SDK_OTA_DEVICE_NOT_SUPPORT:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_OTA_DEVICE_NOT_SUPPORT);
|
||||
break;
|
||||
case GIZ_SDK_WS_HANDSHAKE_FAILED:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_WS_HANDSHAKE_FAILED);
|
||||
break;
|
||||
case GIZ_SDK_WS_LOGIN_FAILED:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_WS_LOGIN_FAILED);
|
||||
break;
|
||||
// case GIZ_SDK_WS_DEVICE_SUBSCRIBE_FAILED:
|
||||
// errorString = (String) getText(R.string.GIZ_SDK_WS_DEVICE_SUBSCRIBE_FAILED);
|
||||
// break;
|
||||
// case GIZ_SDK_WS_DEVICE_UNSUBSCRIBE_FAILED:
|
||||
// errorString = (String) getText(R.string.GIZ_SDK_WS_DEVICE_UNSUBSCRIBE_FAILED);
|
||||
// break;
|
||||
case GIZ_SITE_PRODUCTKEY_INVALID:
|
||||
errorString = (String) getText(R.string.GIZ_SITE_PRODUCTKEY_INVALID);
|
||||
break;
|
||||
case GIZ_SITE_DATAPOINTS_NOT_DEFINED:
|
||||
errorString = (String) getText(R.string.GIZ_SITE_DATAPOINTS_NOT_DEFINED);
|
||||
break;
|
||||
case GIZ_SITE_DATAPOINTS_NOT_MALFORME:
|
||||
errorString = (String) getText(R.string.GIZ_SITE_DATAPOINTS_NOT_MALFORME);
|
||||
break;
|
||||
case GIZ_OPENAPI_MAC_ALREADY_REGISTERED:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_MAC_ALREADY_REGISTERED);
|
||||
break;
|
||||
case GIZ_OPENAPI_PRODUCT_KEY_INVALID:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_PRODUCT_KEY_INVALID);
|
||||
break;
|
||||
case GIZ_OPENAPI_APPID_INVALID:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_APPID_INVALID);
|
||||
break;
|
||||
case GIZ_OPENAPI_TOKEN_INVALID:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_TOKEN_INVALID);
|
||||
break;
|
||||
case GIZ_OPENAPI_USER_NOT_EXIST:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_USER_NOT_EXIST);
|
||||
break;
|
||||
case GIZ_OPENAPI_TOKEN_EXPIRED:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_TOKEN_EXPIRED);
|
||||
break;
|
||||
case GIZ_OPENAPI_M2M_ID_INVALID:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_M2M_ID_INVALID);
|
||||
break;
|
||||
case GIZ_OPENAPI_SERVER_ERROR:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_SERVER_ERROR);
|
||||
break;
|
||||
case GIZ_OPENAPI_CODE_EXPIRED:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_CODE_EXPIRED);
|
||||
break;
|
||||
case GIZ_OPENAPI_CODE_INVALID:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_CODE_INVALID);
|
||||
break;
|
||||
case GIZ_OPENAPI_SANDBOX_SCALE_QUOTA_EXHAUSTED:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_SANDBOX_SCALE_QUOTA_EXHAUSTED);
|
||||
break;
|
||||
case GIZ_OPENAPI_PRODUCTION_SCALE_QUOTA_EXHAUSTED:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_PRODUCTION_SCALE_QUOTA_EXHAUSTED);
|
||||
break;
|
||||
case GIZ_OPENAPI_PRODUCT_HAS_NO_REQUEST_SCALE:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_PRODUCT_HAS_NO_REQUEST_SCALE);
|
||||
break;
|
||||
case GIZ_OPENAPI_DEVICE_NOT_FOUND:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_DEVICE_NOT_FOUND);
|
||||
break;
|
||||
case GIZ_OPENAPI_FORM_INVALID:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_FORM_INVALID);
|
||||
break;
|
||||
case GIZ_OPENAPI_DID_PASSCODE_INVALID:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_DID_PASSCODE_INVALID);
|
||||
break;
|
||||
case GIZ_OPENAPI_DEVICE_NOT_BOUND:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_DEVICE_NOT_BOUND);
|
||||
break;
|
||||
case GIZ_OPENAPI_PHONE_UNAVALIABLE:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_PHONE_UNAVALIABLE);
|
||||
break;
|
||||
case GIZ_OPENAPI_USERNAME_UNAVALIABLE:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_USERNAME_UNAVALIABLE);
|
||||
break;
|
||||
case GIZ_OPENAPI_USERNAME_PASSWORD_ERROR:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_USERNAME_PASSWORD_ERROR);
|
||||
break;
|
||||
case GIZ_OPENAPI_SEND_COMMAND_FAILED:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_SEND_COMMAND_FAILED);
|
||||
break;
|
||||
case GIZ_OPENAPI_EMAIL_UNAVALIABLE:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_EMAIL_UNAVALIABLE);
|
||||
break;
|
||||
case GIZ_OPENAPI_DEVICE_DISABLED:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_DEVICE_DISABLED);
|
||||
break;
|
||||
case GIZ_OPENAPI_FAILED_NOTIFY_M2M:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_FAILED_NOTIFY_M2M);
|
||||
break;
|
||||
case GIZ_OPENAPI_ATTR_INVALID:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_ATTR_INVALID);
|
||||
break;
|
||||
case GIZ_OPENAPI_USER_INVALID:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_USER_INVALID);
|
||||
break;
|
||||
case GIZ_OPENAPI_FIRMWARE_NOT_FOUND:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_FIRMWARE_NOT_FOUND);
|
||||
break;
|
||||
case GIZ_OPENAPI_JD_PRODUCT_NOT_FOUND:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_JD_PRODUCT_NOT_FOUND);
|
||||
break;
|
||||
case GIZ_OPENAPI_DATAPOINT_DATA_NOT_FOUND:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_DATAPOINT_DATA_NOT_FOUND);
|
||||
break;
|
||||
case GIZ_OPENAPI_SCHEDULER_NOT_FOUND:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_SCHEDULER_NOT_FOUND);
|
||||
break;
|
||||
case GIZ_OPENAPI_QQ_OAUTH_KEY_INVALID:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_QQ_OAUTH_KEY_INVALID);
|
||||
break;
|
||||
case GIZ_OPENAPI_OTA_SERVICE_OK_BUT_IN_IDLE:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_OTA_SERVICE_OK_BUT_IN_IDLE);
|
||||
break;
|
||||
case GIZ_OPENAPI_BT_FIRMWARE_UNVERIFIED:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_BT_FIRMWARE_UNVERIFIED);
|
||||
break;
|
||||
case GIZ_OPENAPI_BT_FIRMWARE_NOTHING_TO_UPGRADE:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_SAVE_KAIROSDB_ERROR);
|
||||
break;
|
||||
case GIZ_OPENAPI_SAVE_KAIROSDB_ERROR:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_SAVE_KAIROSDB_ERROR);
|
||||
break;
|
||||
case GIZ_OPENAPI_EVENT_NOT_DEFINED:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_EVENT_NOT_DEFINED);
|
||||
break;
|
||||
case GIZ_OPENAPI_SEND_SMS_FAILED:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_SEND_SMS_FAILED);
|
||||
break;
|
||||
// case GIZ_OPENAPI_APPLICATION_AUTH_INVALID:
|
||||
// errorString= (String)
|
||||
// getText(R.string.GIZ_OPENAPI_APPLICATION_AUTH_INVALID);
|
||||
// break;
|
||||
case GIZ_OPENAPI_NOT_ALLOWED_CALL_API:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_NOT_ALLOWED_CALL_API);
|
||||
break;
|
||||
case GIZ_OPENAPI_BAD_QRCODE_CONTENT:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_BAD_QRCODE_CONTENT);
|
||||
break;
|
||||
case GIZ_OPENAPI_REQUEST_THROTTLED:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_REQUEST_THROTTLED);
|
||||
break;
|
||||
case GIZ_OPENAPI_DEVICE_OFFLINE:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_DEVICE_OFFLINE);
|
||||
break;
|
||||
case GIZ_OPENAPI_TIMESTAMP_INVALID:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_TIMESTAMP_INVALID);
|
||||
break;
|
||||
case GIZ_OPENAPI_SIGNATURE_INVALID:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_SIGNATURE_INVALID);
|
||||
break;
|
||||
case GIZ_OPENAPI_DEPRECATED_API:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_DEPRECATED_API);
|
||||
break;
|
||||
case GIZ_OPENAPI_REGISTER_IS_BUSY:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_REGISTER_IS_BUSY);
|
||||
break;
|
||||
case GIZ_OPENAPI_ALTER_PASSWORD_FAILED:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_ALTER_PASSWORD_FAILED);
|
||||
break;
|
||||
case GIZ_OPENAPI_APPID_PK_NOT_RELATION:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_APPID_PK_NOT_RELATION);
|
||||
break;
|
||||
case GIZ_OPENAPI_CALL_INNER_FAILED:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_CALL_INNER_FAILED);
|
||||
break;
|
||||
case GIZ_OPENAPI_DEVICE_SHARING_NOT_ENABLED:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_DEVICE_SHARING_NOT_ENABLED);
|
||||
break;
|
||||
case GIZ_OPENAPI_NOT_FIRST_USER_OF_DEVICE:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_NOT_FIRST_USER_OF_DEVICE);
|
||||
break;
|
||||
case GIZ_OPENAPI_PRODUCT_KEY_AUTHEN_FAULT:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_PRODUCT_KEY_AUTHEN_FAULT);
|
||||
break;
|
||||
case GIZ_OPENAPI_BUSY_NOW:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_BUSY_NOW);
|
||||
break;
|
||||
case GIZ_OPENAPI_TWITTER_CONSUMER_KEY_INVALID:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_TWITTER_CONSUMER_KEY_INVALID);
|
||||
break;
|
||||
case GIZ_OPENAPI_NOT_ALLOW_WEEK_PASSWORD:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_NOT_ALLOW_WEEK_PASSWORD);
|
||||
break;
|
||||
// case GIZ_OPENAPI_CODE_NOT_EXIST:
|
||||
// errorString = (String) getText(R.string.GIZ_OPENAPI_CODE_NOT_EXIST);
|
||||
// break;
|
||||
// case GIZ_OPENAPI_EMAIL_NOT_ACTIVE:
|
||||
// errorString = (String) getText(R.string.GIZ_OPENAPI_EMAIL_NOT_ACTIVE);
|
||||
// break;
|
||||
// case GIZ_OPENAPI_EMAIL_NOT_ENABLE:
|
||||
// errorString = (String) getText(R.string.GIZ_OPENAPI_EMAIL_NOT_ENABLE);
|
||||
// break;
|
||||
// case GIZ_OPENAPI_DEVICE_REGISTER_NOT_FOUND:
|
||||
// errorString = (String) getText(R.string.GIZ_OPENAPI_DEVICE_REGISTER_NOT_FOUND);
|
||||
// break;
|
||||
case GIZ_OPENAPI_CANNOT_SHARE_TO_SELF:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_CANNOT_SHARE_TO_SELF);
|
||||
break;
|
||||
case GIZ_OPENAPI_ONLY_OWNER_CAN_SHARE:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_ONLY_OWNER_CAN_SHARE);
|
||||
break;
|
||||
case GIZ_OPENAPI_NOT_FOUND_GUEST:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_NOT_FOUND_GUEST);
|
||||
break;
|
||||
case GIZ_OPENAPI_GUEST_ALREADY_BOUND:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_GUEST_ALREADY_BOUND);
|
||||
break;
|
||||
case GIZ_OPENAPI_NOT_FOUND_SHARING_INFO:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_NOT_FOUND_SHARING_INFO);
|
||||
break;
|
||||
case GIZ_OPENAPI_NOT_FOUND_THE_MESSAGE:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_NOT_FOUND_THE_MESSAGE);
|
||||
break;
|
||||
case GIZ_OPENAPI_SHARING_IS_WAITING_FOR_ACCEPT:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_SHARING_IS_WAITING_FOR_ACCEPT);
|
||||
break;
|
||||
case GIZ_OPENAPI_SHARING_IS_EXPIRED:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_SHARING_IS_EXPIRED);
|
||||
break;
|
||||
case GIZ_OPENAPI_SHARING_IS_COMPLETED:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_SHARING_IS_COMPLETED);
|
||||
break;
|
||||
case GIZ_OPENAPI_INVALID_SHARING_BECAUSE_UNBINDING:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_INVALID_SHARING_BECAUSE_UNBINDING);
|
||||
break;
|
||||
case GIZ_OPENAPI_ONLY_OWNER_CAN_BIND:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_ONLY_OWNER_CAN_BIND);
|
||||
break;
|
||||
case GIZ_OPENAPI_ONLY_OWNER_CAN_OPERATE:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_ONLY_OWNER_CAN_OPERATE);
|
||||
break;
|
||||
case GIZ_OPENAPI_SHARING_ALREADY_CANCELLED:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_SHARING_ALREADY_CANCELLED);
|
||||
break;
|
||||
case GIZ_OPENAPI_OWNER_CANNOT_UNBIND_SELF:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_OWNER_CANNOT_UNBIND_SELF);
|
||||
break;
|
||||
case GIZ_OPENAPI_ONLY_GUEST_CAN_CHECK_QRCODE:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_ONLY_GUEST_CAN_CHECK_QRCODE);
|
||||
break;
|
||||
case GIZ_OPENAPI_MESSAGE_ALREADY_DELETED:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_MESSAGE_ALREADY_DELETED);
|
||||
break;
|
||||
case GIZ_OPENAPI_BINDING_NOTIFY_FAILED:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_BINDING_NOTIFY_FAILED);
|
||||
break;
|
||||
case GIZ_OPENAPI_ONLY_SELF_CAN_MODIFY_ALIAS:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_ONLY_SELF_CAN_MODIFY_ALIAS);
|
||||
break;
|
||||
case GIZ_OPENAPI_ONLY_RECEIVER_CAN_MARK_MESSAGE:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_ONLY_RECEIVER_CAN_MARK_MESSAGE);
|
||||
break;
|
||||
case GIZ_OPENAPI_GUEST_NOT_BIND:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_GUEST_NOT_BIND);
|
||||
break;
|
||||
case GIZ_OPENAPI_CANNOT_TRANSFER_OWNER_TO_SELF:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_CANNOT_TRANSFER_OWNER_TO_SELF);
|
||||
break;
|
||||
case GIZ_OPENAPI_TRANSFER_OWNER_TO_LIMIT_GUEST:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_TRANSFER_OWNER_TO_LIMIT_GUEST);
|
||||
break;
|
||||
case GIZ_OPENAPI_RESERVED:
|
||||
errorString = (String) getText(R.string.GIZ_OPENAPI_RESERVED);
|
||||
break;
|
||||
case GIZ_PUSHAPI_BODY_JSON_INVALID:
|
||||
errorString = (String) getText(R.string.GIZ_PUSHAPI_BODY_JSON_INVALID);
|
||||
break;
|
||||
case GIZ_PUSHAPI_DATA_NOT_EXIST:
|
||||
errorString = (String) getText(R.string.GIZ_PUSHAPI_DATA_NOT_EXIST);
|
||||
break;
|
||||
case GIZ_PUSHAPI_NO_CLIENT_CONFIG:
|
||||
errorString = (String) getText(R.string.GIZ_PUSHAPI_NO_CLIENT_CONFIG);
|
||||
break;
|
||||
case GIZ_PUSHAPI_NO_SERVER_DATA:
|
||||
errorString = (String) getText(R.string.GIZ_PUSHAPI_NO_SERVER_DATA);
|
||||
break;
|
||||
case GIZ_PUSHAPI_GIZWITS_APPID_EXIST:
|
||||
errorString = (String) getText(R.string.GIZ_PUSHAPI_GIZWITS_APPID_EXIST);
|
||||
break;
|
||||
case GIZ_PUSHAPI_PARAM_ERROR:
|
||||
errorString = (String) getText(R.string.GIZ_PUSHAPI_PARAM_ERROR);
|
||||
break;
|
||||
case GIZ_PUSHAPI_AUTH_KEY_INVALID:
|
||||
errorString = (String) getText(R.string.GIZ_PUSHAPI_AUTH_KEY_INVALID);
|
||||
break;
|
||||
case GIZ_PUSHAPI_APPID_OR_TOKEN_ERROR:
|
||||
errorString = (String) getText(R.string.GIZ_PUSHAPI_APPID_OR_TOKEN_ERROR);
|
||||
break;
|
||||
case GIZ_PUSHAPI_TYPE_PARAM_ERROR:
|
||||
errorString = (String) getText(R.string.GIZ_PUSHAPI_TYPE_PARAM_ERROR);
|
||||
break;
|
||||
case GIZ_PUSHAPI_ID_PARAM_ERROR:
|
||||
errorString = (String) getText(R.string.GIZ_PUSHAPI_ID_PARAM_ERROR);
|
||||
break;
|
||||
case GIZ_PUSHAPI_APPKEY_SECRETKEY_INVALID:
|
||||
errorString = (String) getText(R.string.GIZ_PUSHAPI_APPKEY_SECRETKEY_INVALID);
|
||||
break;
|
||||
case GIZ_PUSHAPI_CHANNELID_ERROR_INVALID:
|
||||
errorString = (String) getText(R.string.GIZ_PUSHAPI_CHANNELID_ERROR_INVALID);
|
||||
break;
|
||||
case GIZ_PUSHAPI_PUSH_ERROR:
|
||||
errorString = (String) getText(R.string.GIZ_PUSHAPI_PUSH_ERROR);
|
||||
break;
|
||||
case GIZ_SDK_SUBDEVICE_ADD_FAILED:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_ADD_SUBDEVICE_FAILED);
|
||||
break;
|
||||
|
||||
case GIZ_SDK_SUBDEVICE_DELETE_FAILED:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_DELETE_SUBDEVICE_FAILED);
|
||||
break;
|
||||
|
||||
case GIZ_SDK_SUBDEVICE_LIST_UPDATE_FAILED:
|
||||
errorString = (String) getText(R.string.GIZ_SDK_GET_SUBDEVICES_FAILED);
|
||||
break;
|
||||
default:
|
||||
errorString = (String) getText(R.string.UNKNOWN_ERROR);
|
||||
break;
|
||||
}
|
||||
return errorString;
|
||||
}
|
||||
}
|
@ -0,0 +1,311 @@
|
||||
package com.gizwits.opensource.appkit.DeviceModule;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.Switch;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.gizwits.gizwifisdk.api.GizWifiCentralControlDevice;
|
||||
import com.gizwits.gizwifisdk.api.GizWifiDevice;
|
||||
import com.gizwits.gizwifisdk.enumration.GizDeviceSharingUserRole;
|
||||
import com.gizwits.gizwifisdk.enumration.GizWifiDeviceNetStatus;
|
||||
import com.gizwits.opensource.appkit.CommonModule.GosDeploy;
|
||||
import com.gizwits.opensource.appkit.R;
|
||||
import com.gizwits.opensource.appkit.sharingdevice.addSharedActivity;
|
||||
import com.gizwits.opensource.appkit.utils.AssetsUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.gizwits.gizwifisdk.enumration.GizWifiDeviceType.GizDeviceCenterControl;
|
||||
|
||||
|
||||
@SuppressLint("InflateParams")
|
||||
public class GosDeviceListAdapter extends BaseAdapter {
|
||||
|
||||
private static final String TAG = "GosDeviceListAdapter";
|
||||
Handler handler = new Handler();
|
||||
SharedPreferences spf;
|
||||
protected static final int UNBOUND = 99;
|
||||
protected static final int SHARE = 100;
|
||||
|
||||
public void setHandler(Handler handler) {
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
Context context;
|
||||
List<GizWifiDevice> deviceList;
|
||||
|
||||
public GosDeviceListAdapter(Context context, List<GizWifiDevice> deviceList) {
|
||||
super();
|
||||
this.context = context;
|
||||
this.deviceList = deviceList;
|
||||
}
|
||||
|
||||
public void setSpf(SharedPreferences spf) {
|
||||
this.spf = spf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return deviceList.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
View view = convertView;
|
||||
Holder holder;
|
||||
|
||||
if (view == null) {
|
||||
view = LayoutInflater.from(context).inflate(
|
||||
R.layout.item_gos_device_list, null);
|
||||
holder = new Holder(view);
|
||||
view.setTag(holder);
|
||||
} else {
|
||||
holder = (Holder) view.getTag();
|
||||
}
|
||||
final GizWifiDevice device = deviceList.get(position);
|
||||
|
||||
String deviceAlias = device.getAlias();
|
||||
String devicePN = device.getProductName();
|
||||
|
||||
GizDeviceSharingUserRole role = device.getSharingRole();
|
||||
|
||||
if (role != null) {
|
||||
if (role.name().equals("GizDeviceSharingSpecial") || role.name().equals("GizDeviceSharingOwner")) {
|
||||
holder.getDelete2().setVisibility(View.VISIBLE);
|
||||
holder.getDelete1().setVisibility(View.VISIBLE);
|
||||
holder.getDevice().setPadding(0, 0, AssetsUtils.diptopx(context, -181), 0);
|
||||
} else {
|
||||
holder.getDelete1().setVisibility(View.GONE);
|
||||
holder.getDelete2().setVisibility(View.VISIBLE);
|
||||
holder.getDevice().setPadding(0, 0, AssetsUtils.diptopx(context, -91), 0);
|
||||
}
|
||||
}
|
||||
GizWifiCentralControlDevice centralControlDevice = null;
|
||||
holder.getTvDeviceMac().setVisibility(View.GONE);
|
||||
holder.getTvDeviceMac().setVisibility(View.VISIBLE);
|
||||
holder.getTvDeviceMac().setText(device.getMacAddress());
|
||||
|
||||
if (device.getNetStatus() == GizWifiDeviceNetStatus.GizDeviceOnline
|
||||
|| device.getNetStatus() == GizWifiDeviceNetStatus.GizDeviceControlled) {
|
||||
|
||||
if (device.isLAN()) {
|
||||
holder.getLlLeft().setImageResource(R.drawable.common_device_lan_online);
|
||||
} else {
|
||||
holder.getLlLeft().setImageResource(R.drawable.common_device_remote_online);
|
||||
}
|
||||
holder.getImgRight().setVisibility(View.VISIBLE);
|
||||
|
||||
if (device.isBind()) {// 已绑定设备
|
||||
if (device.getProductType() == GizDeviceCenterControl) {
|
||||
if (device instanceof GizWifiCentralControlDevice) {
|
||||
centralControlDevice = (GizWifiCentralControlDevice) device;
|
||||
}
|
||||
}
|
||||
if (centralControlDevice != null) {
|
||||
if (centralControlDevice.getSubDeviceList().size() != 0) {
|
||||
holder.getTvDeviceMac().setVisibility(View.VISIBLE);
|
||||
if (AssetsUtils.isZh(context)) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("已连接");
|
||||
sb.append(centralControlDevice.getSubDeviceList().size());
|
||||
sb.append("个设备");
|
||||
holder.getTvDeviceMac().setText(sb.toString());
|
||||
} else {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append(centralControlDevice.getSubDeviceList().size());
|
||||
sb.append(" devices connected");
|
||||
holder.getTvDeviceMac().setText(sb.toString());
|
||||
}
|
||||
if (AssetsUtils.isZh(context)) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append(centralControlDevice.getMacAddress());
|
||||
sb.append(" 已连接");
|
||||
sb.append(centralControlDevice.getSubDeviceList().size());
|
||||
sb.append("个设备");
|
||||
holder.getTvDeviceMac().setText(sb.toString());
|
||||
} else {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append(centralControlDevice.getMacAddress());
|
||||
sb.append(" ");
|
||||
sb.append(centralControlDevice.getSubDeviceList().size());
|
||||
sb.append(" devices connected");
|
||||
holder.getTvDeviceMac().setText(sb.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
//这里会出现箭头不显示的状态
|
||||
// holder.getImgRight().setVisibility(View.VISIBLE);
|
||||
|
||||
} else {// 未绑定设备
|
||||
holder.getDelete2().setVisibility(View.GONE);
|
||||
holder.getDevice().setPadding(0, 0, AssetsUtils.diptopx(context, 0), 0);
|
||||
}
|
||||
} else {// 设备不在线
|
||||
holder.getSbDeviceStatus().setClickable(false);
|
||||
holder.getImgRight().setVisibility(View.GONE);
|
||||
if (device.isLAN()) {
|
||||
holder.getLlLeft().setImageResource(R.drawable.common_device_lan_offline);
|
||||
} else {
|
||||
holder.getLlLeft().setImageResource(R.drawable.common_device_remote_offline);
|
||||
}
|
||||
}
|
||||
if (TextUtils.isEmpty(deviceAlias)) {
|
||||
List<Map<String, Object>> list = GosDeploy.appConfig_DeviceInfo();
|
||||
boolean isName = true;
|
||||
for (Map<String, Object> map : list) {
|
||||
if (map.containsKey("productKey")) {
|
||||
if (device.getProductKey().equals(map.get("productKey"))) {
|
||||
if (AssetsUtils.isZh(context)) {
|
||||
if (map.containsKey("productNameCH")) {
|
||||
isName = false;
|
||||
holder.getTvDeviceName().setText(map.get("productNameCH").toString());
|
||||
}
|
||||
} else {
|
||||
if (map.containsKey("productNameEN")) {
|
||||
isName = false;
|
||||
holder.getTvDeviceName().setText(map.get("productNameEN").toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isName) {
|
||||
holder.getTvDeviceName().setText(devicePN);
|
||||
}
|
||||
} else {
|
||||
holder.getTvDeviceName().setText(deviceAlias);
|
||||
}
|
||||
holder.getDelete2().setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Message message = new Message();
|
||||
message.what = UNBOUND;
|
||||
message.obj = device.getDid().toString();
|
||||
handler.sendMessage(message);
|
||||
|
||||
}
|
||||
});
|
||||
holder.getDelete1().setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Message message = new Message();
|
||||
message.what = SHARE;
|
||||
message.obj = device.getDid().toString();
|
||||
handler.sendMessage(message);
|
||||
|
||||
if (!TextUtils.isEmpty(spf.getString("UserName", "")) && !TextUtils.isEmpty(spf.getString("PassWord", ""))) {
|
||||
Intent intent = new Intent(context, addSharedActivity.class);
|
||||
intent.putExtra("productname", device.getProductName());
|
||||
intent.putExtra("did", device.getDid());
|
||||
context.startActivity(intent);
|
||||
} else {
|
||||
Toast.makeText(context, context.getString(R.string.please_login), 2000).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
return view;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Holder {
|
||||
View view;
|
||||
|
||||
public Holder(View view) {
|
||||
this.view = view;
|
||||
}
|
||||
|
||||
private TextView tvDeviceMac, tvDeviceStatus, tvDeviceName;
|
||||
|
||||
private RelativeLayout delete1, delete2, device;
|
||||
|
||||
private ImageView imgRight;
|
||||
|
||||
private ImageView lvLeft;
|
||||
|
||||
private Switch sbDeviceStatus;
|
||||
|
||||
public ImageView getLlLeft() {
|
||||
if (null == lvLeft) {
|
||||
lvLeft = (ImageView) view.findViewById(R.id.imgLeft);
|
||||
}
|
||||
return lvLeft;
|
||||
}
|
||||
|
||||
public ImageView getImgRight() {
|
||||
if (null == imgRight) {
|
||||
imgRight = (ImageView) view.findViewById(R.id.imgRight);
|
||||
}
|
||||
return imgRight;
|
||||
}
|
||||
|
||||
public RelativeLayout getDevice() {
|
||||
if (null == device) {
|
||||
device = (RelativeLayout) view.findViewById(R.id.rl_device);
|
||||
}
|
||||
return device;
|
||||
}
|
||||
|
||||
public RelativeLayout getDelete2() {
|
||||
if (null == delete2) {
|
||||
delete2 = (RelativeLayout) view.findViewById(R.id.delete2);
|
||||
}
|
||||
return delete2;
|
||||
}
|
||||
|
||||
public RelativeLayout getDelete1() {
|
||||
if (null == delete1) {
|
||||
delete1 = (RelativeLayout) view.findViewById(R.id.delete1);
|
||||
}
|
||||
return delete1;
|
||||
}
|
||||
|
||||
public TextView getTvDeviceMac() {
|
||||
if (null == tvDeviceMac) {
|
||||
tvDeviceMac = (TextView) view.findViewById(R.id.tvDeviceMac);
|
||||
}
|
||||
return tvDeviceMac;
|
||||
}
|
||||
|
||||
|
||||
public TextView getTvDeviceName() {
|
||||
if (null == tvDeviceName) {
|
||||
tvDeviceName = (TextView) view.findViewById(R.id.tvDeviceName);
|
||||
}
|
||||
return tvDeviceName;
|
||||
}
|
||||
|
||||
public Switch getSbDeviceStatus() {
|
||||
if (null == sbDeviceStatus) {
|
||||
sbDeviceStatus = (Switch) view.findViewById(R.id.sbDeviceStatus);
|
||||
}
|
||||
return sbDeviceStatus;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,108 @@
|
||||
package com.gizwits.opensource.appkit.DeviceModule;
|
||||
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.wifi.ScanResult;
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.widget.RemoteViews;
|
||||
|
||||
import com.gizwits.opensource.appkit.R;
|
||||
import com.gizwits.opensource.appkit.CommonModule.GosBaseActivity;
|
||||
import com.gizwits.opensource.appkit.CommonModule.GosConstant;
|
||||
import com.gizwits.opensource.appkit.utils.NetUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GosMessageHandler {
|
||||
|
||||
NotificationManager nm;
|
||||
|
||||
protected static final int SHOWDIALOG = 999;
|
||||
|
||||
private Context mcContext;
|
||||
|
||||
private ArrayList<String> newDeviceList = new ArrayList<String>();
|
||||
|
||||
private Handler mainHandler;
|
||||
// 做一个单例
|
||||
private static GosMessageHandler mInstance = new GosMessageHandler();
|
||||
|
||||
public static GosMessageHandler getSingleInstance() {
|
||||
return mInstance;
|
||||
}
|
||||
|
||||
public void SetHandler(Handler handler) {
|
||||
this.mainHandler = handler;
|
||||
}
|
||||
|
||||
public void StartLooperWifi(Context context) {
|
||||
this.mcContext = context;
|
||||
HandlerThread looperwifi = new HandlerThread("looperwifi");
|
||||
looperwifi.start();
|
||||
looper = new MyLooperHandler(looperwifi.getLooper());
|
||||
looper.post(mRunnable);
|
||||
}
|
||||
|
||||
class MyLooperHandler extends Handler {
|
||||
public MyLooperHandler(Looper looper) {
|
||||
super(looper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 子线程实现
|
||||
*/
|
||||
private Runnable mRunnable = new Runnable() {
|
||||
|
||||
public void run() {
|
||||
if (mcContext == null) {
|
||||
return;
|
||||
}
|
||||
newDeviceList.clear();
|
||||
List<ScanResult> currentWifiScanResult = NetUtils
|
||||
.getCurrentWifiScanResult(mcContext);
|
||||
GosConstant.ssidList = currentWifiScanResult;
|
||||
int flog = 0;
|
||||
if (currentWifiScanResult != null) {
|
||||
for (ScanResult scanResult : currentWifiScanResult) {
|
||||
String ssid = scanResult.SSID;
|
||||
// 获取系统的NotificationManager服务
|
||||
nm = (NotificationManager) mcContext
|
||||
.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
if (ssid.contains(GosBaseActivity.SoftAP_Start)
|
||||
&& ssid.length() > GosBaseActivity.SoftAP_Start.length()
|
||||
&& !newDeviceList.toString().contains(ssid)) {
|
||||
newDeviceList.add(ssid);
|
||||
flog++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mainHandler != null && newDeviceList.size() > 0) {
|
||||
mainHandler.sendEmptyMessage(SHOWDIALOG);
|
||||
}
|
||||
|
||||
looper.postDelayed(mRunnable, 2000);
|
||||
}
|
||||
};
|
||||
private MyLooperHandler looper;
|
||||
|
||||
|
||||
public ArrayList<String> getNewDeviceList() {
|
||||
return newDeviceList;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,136 @@
|
||||
package com.gizwits.opensource.appkit.DeviceModule;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gizwits.opensource.appkit.R;
|
||||
import com.gizwits.opensource.appkit.SettingsModule.GosAboutActivity;
|
||||
import com.gizwits.opensource.appkit.UserModule.GosUserManager;
|
||||
import com.gizwits.opensource.appkit.sharingdevice.SharedDeviceListAcitivity;
|
||||
|
||||
public class GosSettiingsFragment extends GosBaseFragment implements OnClickListener {
|
||||
|
||||
private static final int SETTINGS = 123;
|
||||
/**
|
||||
* The ll About
|
||||
*/
|
||||
private LinearLayout llAbout;
|
||||
|
||||
/**
|
||||
* The Intent
|
||||
*/
|
||||
Intent intent;
|
||||
|
||||
private LinearLayout usermanager;
|
||||
|
||||
private RelativeLayout lllogin;
|
||||
private LinearLayout llDeviceShared;
|
||||
|
||||
private TextView phoneusername;
|
||||
private View allView;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
allView = inflater.inflate(R.layout.activity_gos_settings, container, false);
|
||||
initView();
|
||||
initEvent();
|
||||
return allView;
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
llAbout = (LinearLayout) allView.findViewById(R.id.llAbout);
|
||||
usermanager = (LinearLayout) allView.findViewById(R.id.usermanager);
|
||||
lllogin = (RelativeLayout) allView.findViewById(R.id.lllogin);
|
||||
phoneusername = (TextView) allView.findViewById(R.id.phoneusername);
|
||||
llDeviceShared = (LinearLayout) allView.findViewById(R.id.deviceshared);
|
||||
}
|
||||
|
||||
private void initEvent() {
|
||||
llAbout.setOnClickListener(this);
|
||||
usermanager.setOnClickListener(this);
|
||||
lllogin.setOnClickListener(this);
|
||||
llDeviceShared.setOnClickListener(this);
|
||||
|
||||
if (!TextUtils.isEmpty(spf.getString("UserName", "")) && !TextUtils.isEmpty(spf.getString("PassWord", ""))) {
|
||||
usermanager.setVisibility(View.VISIBLE);
|
||||
lllogin.setVisibility(View.GONE);
|
||||
phoneusername.setText(spf.getString("UserName", ""));
|
||||
} else if (TextUtils.isEmpty(spf.getString("UserName", "")) && TextUtils.isEmpty(spf.getString("PassWord", ""))
|
||||
&& !TextUtils.isEmpty(spf.getString("thirdUid", ""))) {
|
||||
usermanager.setVisibility(View.VISIBLE);
|
||||
String uid = spf.getString("thirdUid", "");
|
||||
|
||||
lllogin.setVisibility(View.GONE);
|
||||
String myuid = uid.substring(0, 2) + "***" + uid.substring(uid.length() - 4, uid.length());
|
||||
phoneusername.setText(myuid);
|
||||
} else {
|
||||
usermanager.setVisibility(View.GONE);
|
||||
lllogin.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.llAbout:
|
||||
intent = new Intent(getContext(), GosAboutActivity.class);
|
||||
startActivity(intent);
|
||||
llAbout.setEnabled(false);
|
||||
llAbout.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
llAbout.setEnabled(true);
|
||||
}
|
||||
}, 1000);
|
||||
break;
|
||||
|
||||
case R.id.usermanager:
|
||||
intent = null;
|
||||
if (intent == null) {
|
||||
intent = new Intent(getContext(), GosUserManager.class);
|
||||
}
|
||||
startActivityForResult(intent, SETTINGS);
|
||||
usermanager.setEnabled(false);
|
||||
usermanager.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
usermanager.setEnabled(true);
|
||||
}
|
||||
}, 1000);
|
||||
break;
|
||||
case R.id.lllogin:
|
||||
lllogin.setEnabled(false);
|
||||
lllogin.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
lllogin.setEnabled(true);
|
||||
}
|
||||
}, 1000);
|
||||
getActivity().finish();
|
||||
break;
|
||||
case R.id.deviceshared:
|
||||
Intent deviceshared1 = new Intent(getContext(), SharedDeviceListAcitivity.class);
|
||||
startActivity(deviceshared1);
|
||||
llDeviceShared.setEnabled(false);
|
||||
llDeviceShared.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
llDeviceShared.setEnabled(true);
|
||||
}
|
||||
}, 1000);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,136 @@
|
||||
package com.gizwits.opensource.appkit.DeviceModule;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.gizwits.gizwifisdk.api.GizDeviceSharing;
|
||||
import com.gizwits.gizwifisdk.api.GizMessage;
|
||||
import com.gizwits.gizwifisdk.enumration.GizMessageStatus;
|
||||
import com.gizwits.gizwifisdk.enumration.GizMessageType;
|
||||
import com.gizwits.gizwifisdk.enumration.GizWifiErrorCode;
|
||||
import com.gizwits.gizwifisdk.listener.GizDeviceSharingListener;
|
||||
import com.gizwits.opensource.appkit.R;
|
||||
import com.gizwits.opensource.appkit.sharingdevice.MsgNoticeActivity;
|
||||
import com.gizwits.opensource.appkit.sharingdevice.deviceSharedMessageActivity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
//personalCenter_deviceSharing-false-start
|
||||
//personalCenter_deviceSharing-false-end
|
||||
|
||||
public class MessageCenterFragment extends GosBaseFragment {
|
||||
|
||||
|
||||
private LinearLayout llGizwitsmes;
|
||||
//personalCenter_deviceSharing-false-start
|
||||
private View redpoint;
|
||||
private LinearLayout llDevicesShared;
|
||||
//personalCenter_deviceSharing-false-end
|
||||
private View allView;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
allView = inflater.inflate(R.layout.activity_gos_message, container, false);
|
||||
initView();
|
||||
initEvent();
|
||||
return allView;
|
||||
}
|
||||
|
||||
//界面可见时再加载数据
|
||||
@Override
|
||||
public void setUserVisibleHint(boolean isVisibleToUser) {
|
||||
super.setUserVisibleHint(isVisibleToUser);
|
||||
if (isVisibleToUser) {
|
||||
//请求网络数据
|
||||
//personalCenter_deviceSharing-false-start
|
||||
String token = spf.getString("Token", "");
|
||||
GizDeviceSharing.queryMessageList(token, GizMessageType.GizMessageSharing);
|
||||
//GizDeviceSharing.queryMessageList(token, GizMessageType.GizMessageSystem);
|
||||
|
||||
GizDeviceSharing.setListener(new GizDeviceSharingListener() {
|
||||
|
||||
@Override
|
||||
public void didQueryMessageList(GizWifiErrorCode result, List<GizMessage> messageList) {
|
||||
super.didQueryMessageList(result, messageList);
|
||||
|
||||
if (messageList.size() > 0) {
|
||||
isShowRedPoint(messageList);
|
||||
} else {
|
||||
redpoint.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if (result.ordinal() != 0) {
|
||||
Toast.makeText(getContext(), toastError(result), 2).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
//personalCenter_deviceSharing-false-end
|
||||
}
|
||||
}
|
||||
|
||||
//personalCenter_deviceSharing-false-start
|
||||
private void isShowRedPoint(List<GizMessage> messageList) {
|
||||
|
||||
boolean isshow = false;
|
||||
redpoint.setVisibility(View.GONE);
|
||||
for (int i = 0; i < messageList.size(); i++) {
|
||||
|
||||
GizMessage gizMessage = messageList.get(i);
|
||||
GizMessageStatus status = gizMessage.getStatus();
|
||||
if (status.ordinal() == 0) {
|
||||
isshow = true;
|
||||
redpoint.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
//personalCenter_deviceSharing-false-end
|
||||
|
||||
private void initView() {
|
||||
llGizwitsmes = (LinearLayout) allView.findViewById(R.id.gizwitsmes);
|
||||
//personalCenter_deviceSharing-false-start
|
||||
// 判断当前的view 是否需要显示这个红点
|
||||
redpoint = allView.findViewById(R.id.redpoint);
|
||||
llDevicesShared = (LinearLayout) allView.findViewById(R.id.deviceshared);
|
||||
//personalCenter_deviceSharing-false-end
|
||||
}
|
||||
|
||||
private void initEvent() {
|
||||
llGizwitsmes.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// 跳转到机智云公告页面
|
||||
Intent intent = new Intent(getContext(), MsgNoticeActivity.class);
|
||||
startActivity(intent);
|
||||
llGizwitsmes.setEnabled(false);
|
||||
llGizwitsmes.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
llGizwitsmes.setEnabled(true);
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
});
|
||||
//personalCenter_deviceSharing-false-start
|
||||
llDevicesShared.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent tent = new Intent(getContext(), deviceSharedMessageActivity.class);
|
||||
startActivity(tent);
|
||||
llDevicesShared.setEnabled(false);
|
||||
llDevicesShared.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
llDevicesShared.setEnabled(true);
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
});
|
||||
//personalCenter_deviceSharing-false-end
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.gizwits.opensource.appkit;
|
||||
|
||||
import android.app.Application;
|
||||
public class GosApplication extends Application {
|
||||
|
||||
public static int flag = 0;
|
||||
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,112 @@
|
||||
package com.gizwits.opensource.appkit;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.text.TextUtils;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.gizwits.gizwifisdk.api.GizWifiSDK;
|
||||
import com.gizwits.gizwifisdk.enumration.GizLogPrintLevel;
|
||||
import com.gizwits.opensource.appkit.CommonModule.GosConstant;
|
||||
import com.gizwits.opensource.appkit.CommonModule.GosDeploy;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class MessageCenter {
|
||||
private static MessageCenter mCenter;
|
||||
int flag = 0;
|
||||
|
||||
GosDeploy gosDeploy;
|
||||
|
||||
private int SETCLOUD = 1111;
|
||||
|
||||
private MessageCenter(Context c) {
|
||||
if (mCenter == null) {
|
||||
init(c);
|
||||
}
|
||||
}
|
||||
|
||||
private void init(Context c) {
|
||||
gosDeploy = new GosDeploy(c);
|
||||
//config-all-start
|
||||
if (GosDeploy.appConfig_UseOnboardingDeploy()) {
|
||||
if (GosDeploy.appConfig_OnboardingBind()) {
|
||||
GosConstant.mNew = 3;
|
||||
} else {
|
||||
GosConstant.mNew = 2;
|
||||
}
|
||||
} else {
|
||||
if (GosDeploy.appConfig_OnboardingBind()) {
|
||||
GosConstant.mNew = 1;
|
||||
} else {
|
||||
GosConstant.mNew = 0;
|
||||
}
|
||||
}
|
||||
//config-all-end
|
||||
String AppID = GosDeploy.appConfig_GizwitsInfoAppID();
|
||||
String AppSecret = GosDeploy.appConfig_GizwitsInfoAppSecret();
|
||||
List<ConcurrentHashMap<String, String>> productInfoList = GosDeploy.appConfig_ProductInfoList();
|
||||
if (productInfoList.size() == 0) {
|
||||
productInfoList = null;
|
||||
}
|
||||
|
||||
if (AppID == null || AppSecret == null || TextUtils.isEmpty(AppID) || AppID.contains("BeJson")
|
||||
|| TextUtils.isEmpty(AppSecret) || AppSecret.contains("BeJson")
|
||||
|| AppID.length() != 32 || AppSecret.length() != 32) {
|
||||
String AppID_Toast = c.getString(R.string.AppID_Toast);
|
||||
if (flag == 0) {
|
||||
Toast.makeText(c, AppID_Toast, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
flag++;
|
||||
} else {
|
||||
// 启动SDK
|
||||
ConcurrentHashMap<String, String> serverMap = new ConcurrentHashMap<String, String>();
|
||||
ConcurrentHashMap<String, String> appInfo = new ConcurrentHashMap<String, String>();
|
||||
appInfo.put("appId", AppID);
|
||||
appInfo.put("appSecret", AppSecret);
|
||||
|
||||
String api = GosDeploy.appConfig_CloudServiceApi();
|
||||
String site = GosDeploy.appConfig_CloudServiceSite();
|
||||
String push = GosDeploy.appConfig_CloudServicePush();
|
||||
Pattern pattern = Pattern.compile("(^[a-zA-Z0-9\\-]{1,}\\.[a-zA-Z0-9]{1,}\\.[a-zA-Z0-9]{1,}\\:(\\d){1,}\\&(\\d){1,}$)|(^[a-zA-Z0-9\\-]{1,}\\.[a-zA-Z0-9]{1,}\\.[a-zA-Z0-9]{1,}$)");
|
||||
Pattern pattern1 = Pattern.compile("(^([1-9]|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3}\\:(\\d){1,}\\&(\\d){1,}$)|(^([1-9]|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3}$)");
|
||||
if (api != null) {
|
||||
if (pattern.matcher(api).matches() || pattern1.matcher(api).matches()) {
|
||||
serverMap.put("openAPIInfo", api);
|
||||
if (site != null) {
|
||||
serverMap.put("siteInfo", site);
|
||||
}
|
||||
if (push != null && !push.isEmpty()) {
|
||||
serverMap.put("pushInfo", GosDeploy.appConfig_CloudServicePush());
|
||||
}
|
||||
GizWifiSDK.sharedInstance().startWithAppInfo(c, appInfo, productInfoList, serverMap, false);
|
||||
} else {
|
||||
GizWifiSDK.sharedInstance().startWithAppInfo(c, appInfo,
|
||||
productInfoList, null, false);
|
||||
}
|
||||
} else {
|
||||
GizWifiSDK.sharedInstance().startWithAppInfo(c, appInfo,
|
||||
productInfoList, null, false);
|
||||
}
|
||||
}
|
||||
hand.sendEmptyMessageDelayed(SETCLOUD, 3000);
|
||||
}
|
||||
|
||||
public static MessageCenter getInstance(Context c) {
|
||||
if (mCenter == null) {
|
||||
mCenter = new MessageCenter(c);
|
||||
}
|
||||
return mCenter;
|
||||
}
|
||||
|
||||
Handler hand = new Handler() {
|
||||
public void handleMessage(android.os.Message msg) {
|
||||
GizWifiSDK.sharedInstance().setLogLevel(
|
||||
GizLogPrintLevel.GizLogPrintAll);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
package com.gizwits.opensource.appkit.PushModule;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.baidu.android.pushservice.PushMessageReceiver;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BaiDuPushReceiver extends PushMessageReceiver {
|
||||
|
||||
// BaiDuPush_Channel_ID(此处需要在百度推送的Receiver里赋值)
|
||||
public static String BaiDuPush_Channel_ID;
|
||||
|
||||
@Override
|
||||
public void onBind(Context arg0, int arg1, String arg2, String arg3, String arg4, String arg5) {
|
||||
// TODO Auto-generated method stub
|
||||
BaiDuPush_Channel_ID = arg4;
|
||||
Log.i("Apptest", BaiDuPush_Channel_ID + "---");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDelTags(Context arg0, int arg1, List<String> arg2, List<String> arg3, String arg4) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onListTags(Context arg0, int arg1, List<String> arg2, String arg3) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessage(Context arg0, String arg1, String arg2) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNotificationArrived(Context arg0, String arg1, String arg2, String arg3) {
|
||||
// TODO Auto-generated method stub
|
||||
String notifyString = "通知到达 onNotificationArrived title=\"" + arg1
|
||||
+ "\" description=\"" + arg2 + "\" customContent="
|
||||
+ arg3;
|
||||
Log.i(TAG, notifyString);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNotificationClicked(Context arg0, String arg1, String arg2, String arg3) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSetTags(Context arg0, int arg1, List<String> arg2, List<String> arg3, String arg4) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnbind(Context arg0, int arg1, String arg2) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,136 @@
|
||||
package com.gizwits.opensource.appkit.PushModule;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
//push_baidu-false-start
|
||||
import com.baidu.android.pushservice.PushConstants;
|
||||
import com.baidu.android.pushservice.PushManager;
|
||||
import com.baidu.android.pushservice.PushSettings;
|
||||
//push_baidu-false-end
|
||||
import com.gizwits.opensource.appkit.R;
|
||||
import com.gizwits.gizwifisdk.api.GizWifiSDK;
|
||||
import com.gizwits.gizwifisdk.enumration.GizPushType;
|
||||
import com.gizwits.opensource.appkit.CommonModule.GosBaseActivity;
|
||||
import com.gizwits.opensource.appkit.CommonModule.GosDeploy;
|
||||
|
||||
import java.util.Set;
|
||||
//push_jiguang-false-start
|
||||
import cn.jpush.android.api.JPushInterface;
|
||||
import cn.jpush.android.api.TagAliasCallback;
|
||||
//push_jiguang-false-end
|
||||
|
||||
|
||||
public class GosPushManager {
|
||||
|
||||
static GizPushType gizPushType;
|
||||
|
||||
static Context context;
|
||||
|
||||
public GosPushManager(int PushType, Context context) {
|
||||
super();
|
||||
GosPushManager.context = context;
|
||||
//push_jiguang-false-start
|
||||
if (PushType == 1) {
|
||||
GosPushManager.gizPushType = GizPushType.GizPushJiGuang;
|
||||
jPush();
|
||||
}
|
||||
//push_jiguang-false-end
|
||||
//push_baidu-false-start
|
||||
if (PushType == 2) {
|
||||
GosPushManager.gizPushType = GizPushType.GizPushBaiDu;
|
||||
bDPush();
|
||||
}
|
||||
//push_baidu-false-end
|
||||
}
|
||||
|
||||
/**
|
||||
* Channel_ID
|
||||
*/
|
||||
public static String Channel_ID;
|
||||
|
||||
//push_jiguang-false-start
|
||||
|
||||
/**
|
||||
* 此方法完成了初始化JPush SDK等功能 但仍需在MainActivity的onResume和onPause添加相应方法
|
||||
* JPushInterface.onResume(context); JPushInterface.onPause(context);
|
||||
*/
|
||||
public void jPush() {
|
||||
// 设置JPush调试模式
|
||||
JPushInterface.setDebugMode(true);
|
||||
// 初始化JPushSDK
|
||||
JPushInterface.init(context);
|
||||
}
|
||||
//push_jiguang-false-end
|
||||
|
||||
//push_baidu-false-start
|
||||
public void bDPush() {
|
||||
final String BDPushAppKey = GosDeploy.appConfig_BpushAppKey();
|
||||
if (BDPushAppKey != null) {
|
||||
if (TextUtils.isEmpty(BDPushAppKey) || BDPushAppKey.contains("your_bpush_api_key")) {
|
||||
GosBaseActivity.noIDAlert(context, R.string.BDPushAppID_Toast);
|
||||
} else {
|
||||
PushManager.startWork(context, PushConstants.LOGIN_TYPE_API_KEY, BDPushAppKey);
|
||||
PushSettings.enableDebugMode(context, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
//push_baidu-false-end
|
||||
|
||||
/**
|
||||
* 向云端绑定推送
|
||||
*
|
||||
* @param userId
|
||||
* @param token
|
||||
*/
|
||||
public static void pushBindService(String userId, String token) {
|
||||
//push_jiguang-false-start
|
||||
if (GizPushType.GizPushJiGuang == gizPushType) {
|
||||
// 获取JPush的RegistrationID,即Channel_ID
|
||||
Channel_ID = JPushInterface.getRegistrationID(context);
|
||||
// 设定JPush类型
|
||||
JPushInterface.setAlias(context, Channel_ID, new TagAliasCallback() {
|
||||
@Override
|
||||
public void gotResult(int arg0, String arg1, Set<String> arg2) {
|
||||
if (arg0 == 0) {
|
||||
Log.i("Apptest", "Alias: " + arg1);
|
||||
} else {
|
||||
Log.i("Apptest", "Result: " + arg0);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
//push_jiguang-false-end
|
||||
//push_baidu-false-start
|
||||
if (GizPushType.GizPushBaiDu == gizPushType) {
|
||||
// 获取BDPush的Channel_ID
|
||||
Channel_ID = BaiDuPushReceiver.BaiDuPush_Channel_ID;
|
||||
Log.e("Manager", "pushBindService----: " + Channel_ID);
|
||||
}
|
||||
//push_baidu-false-end
|
||||
// TODO 绑定推送
|
||||
GizWifiSDK.sharedInstance().channelIDBind(token, Channel_ID, userId, gizPushType);
|
||||
}
|
||||
|
||||
public static void pushUnBindService(String token) {
|
||||
if (token.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
//push_jiguang-false-start
|
||||
if (GizPushType.GizPushJiGuang == gizPushType) {
|
||||
// 获取JPush的RegistrationID,即Channel_ID
|
||||
Channel_ID = JPushInterface.getRegistrationID(context);
|
||||
}
|
||||
//push_jiguang-false-end
|
||||
//push_baidu-false-start
|
||||
if (GizPushType.GizPushBaiDu == gizPushType) {
|
||||
// 获取BDPush的Channel_ID
|
||||
Channel_ID = BaiDuPushReceiver.BaiDuPush_Channel_ID;
|
||||
}
|
||||
//push_baidu-false-end
|
||||
// TODO 绑定推送
|
||||
//Log.i("Apptest", Channel_ID + "\n" + gizPushType.toString() + "\n" + token);
|
||||
GizWifiSDK.sharedInstance().channelIDUnBind(token, Channel_ID);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,135 @@
|
||||
package com.gizwits.opensource.appkit.SettingsModule;
|
||||
|
||||
import android.app.ActionBar;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gizwits.opensource.appkit.R;
|
||||
import com.gizwits.gizwifisdk.api.GizWifiSDK;
|
||||
import com.gizwits.opensource.appkit.CommonModule.GosBaseActivity;
|
||||
import com.gizwits.opensource.appkit.CommonModule.GosDeploy;
|
||||
import com.gizwits.opensource.appkit.utils.AssetsUtils;
|
||||
|
||||
public class GosAboutActivity extends GosBaseActivity {
|
||||
|
||||
/**
|
||||
* The tv SDKVersion.
|
||||
*/
|
||||
TextView tv_SDKVersion;
|
||||
|
||||
/**
|
||||
* the tv appCode
|
||||
*/
|
||||
TextView tv_AppVersion;
|
||||
|
||||
/**
|
||||
* The ActionBar
|
||||
*/
|
||||
ActionBar actionBar;
|
||||
private LinearLayout llApp;
|
||||
private LinearLayout llSDK;
|
||||
private LinearLayout llAbout;
|
||||
private TextView tvAbout;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_gos_about);
|
||||
// 设置ActionBar
|
||||
setToolBar(true, R.string.about);
|
||||
|
||||
initView();
|
||||
initEvent();
|
||||
}
|
||||
|
||||
private void initEvent() {
|
||||
if (!GosDeploy.appConfig_ShowAPPVersion() && !GosDeploy.appConfig_ShowSDKVersion()) {
|
||||
llApp.setVisibility(View.VISIBLE);
|
||||
llSDK.setVisibility(View.VISIBLE);
|
||||
llAbout.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
if (!GosDeploy.appConfig_ShowAPPVersion()) {
|
||||
llApp.setVisibility(View.GONE);
|
||||
}
|
||||
if (!GosDeploy.appConfig_ShowSDKVersion()) {
|
||||
llSDK.setVisibility(View.GONE);
|
||||
}
|
||||
if (GosDeploy.appConfig_AboutInfoCH() != null) {
|
||||
if (GosDeploy.appConfig_AboutInfoEN() != null) {
|
||||
if (AssetsUtils.isZh(this)) {
|
||||
tvAbout.setText(GosDeploy.appConfig_AboutInfoCH());
|
||||
} else {
|
||||
tvAbout.setText(GosDeploy.appConfig_AboutInfoEN());
|
||||
}
|
||||
} else {
|
||||
tvAbout.setText(GosDeploy.appConfig_AboutInfoCH());
|
||||
}
|
||||
llAbout.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
if (GosDeploy.appConfig_AboutInfoEN() != null) {
|
||||
tvAbout.setText(GosDeploy.appConfig_AboutInfoEN());
|
||||
llAbout.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
llAbout.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Inits the view.
|
||||
*/
|
||||
private void initView() {
|
||||
llApp = (LinearLayout) findViewById(R.id.llAPP);
|
||||
llSDK = (LinearLayout) findViewById(R.id.llSDK);
|
||||
llAbout = (LinearLayout) findViewById(R.id.llAbout);
|
||||
tvAbout = (TextView) findViewById(R.id.tvAbout);
|
||||
tv_SDKVersion = (TextView) findViewById(R.id.versionCode);
|
||||
tv_AppVersion = (TextView) findViewById(R.id.appCode);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
tv_SDKVersion.setText(GizWifiSDK.sharedInstance().getVersion().toString());
|
||||
tv_AppVersion.setText(getAppVersionName(this));
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回当前程序版本名
|
||||
*/
|
||||
public static String getAppVersionName(Context context) {
|
||||
String versionName = "";
|
||||
try {
|
||||
// ---get the package info---
|
||||
PackageManager pm = context.getPackageManager();
|
||||
PackageInfo pi = pm.getPackageInfo(context.getPackageName(), 0);
|
||||
versionName = pi.versionName;
|
||||
if (versionName == null || versionName.length() <= 0) {
|
||||
return "";
|
||||
}
|
||||
} catch(Exception e) {
|
||||
Log.i("Apptest", "Exception", e);
|
||||
}
|
||||
return versionName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
this.finish();
|
||||
break;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package com.gizwits.opensource.appkit.ThirdAccountModule;
|
||||
|
||||
import com.tencent.tauth.IUiListener;
|
||||
import com.tencent.tauth.UiError;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class BaseUiListener implements IUiListener {
|
||||
|
||||
@Override
|
||||
public void onCancel() {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete(Object arg0) {
|
||||
doComplete((JSONObject)arg0);
|
||||
}
|
||||
|
||||
protected void doComplete(JSONObject values) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(UiError arg0) {
|
||||
// TODO Auto-generated method stu
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,226 @@
|
||||
package com.gizwits.opensource.appkit.UserModule;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.text.method.HideReturnsTransformationMethod;
|
||||
import android.text.method.PasswordTransformationMethod;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.gizwits.opensource.appkit.R;
|
||||
import com.gizwits.gizwifisdk.api.GizWifiSDK;
|
||||
import com.gizwits.gizwifisdk.listener.GizWifiSDKListener;
|
||||
import com.gizwits.opensource.appkit.CommonModule.GosBaseActivity;
|
||||
import com.gizwits.opensource.appkit.CommonModule.GosDeploy;
|
||||
|
||||
public class GosChangeUserPasswordActivity extends GosBaseActivity {
|
||||
|
||||
private EditText oldpass;
|
||||
private EditText newpass;
|
||||
private EditText confrimpass;
|
||||
private Button btnConfirm;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setContentView(R.layout.activity_gos_change_password);
|
||||
setToolBar(true, R.string.edit_password);
|
||||
initView();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
// TODO Auto-generated method stub
|
||||
super.onResume();
|
||||
|
||||
GizWifiSDK.sharedInstance().setListener(listener);
|
||||
}
|
||||
|
||||
GizWifiSDKListener listener = new GizWifiSDKListener() {
|
||||
|
||||
public void didChangeUserPassword(
|
||||
com.gizwits.gizwifisdk.enumration.GizWifiErrorCode result) {
|
||||
|
||||
if (result.getResult() == 0) {
|
||||
Toast.makeText(GosChangeUserPasswordActivity.this,
|
||||
getResources().getString(R.string.passsuccess), 2000)
|
||||
.show();
|
||||
|
||||
finish();
|
||||
|
||||
spf.edit().putString("PassWord", newpass.getText().toString())
|
||||
.commit();
|
||||
} else {
|
||||
|
||||
if (result.getResult() == 9020) {
|
||||
Toast.makeText(GosChangeUserPasswordActivity.this,
|
||||
getResources().getString(R.string.oldpasserror),
|
||||
2000).show();
|
||||
} else {
|
||||
Toast.makeText(GosChangeUserPasswordActivity.this,
|
||||
getResources().getString(R.string.passerror), 2000)
|
||||
.show();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
;
|
||||
};
|
||||
private CheckBox oldcheck;
|
||||
private CheckBox newcheck;
|
||||
private CheckBox concheck;
|
||||
|
||||
private void initView() {
|
||||
btnConfirm = (Button) findViewById(R.id.btnLogin);
|
||||
oldpass = (EditText) findViewById(R.id.oldpass);
|
||||
newpass = (EditText) findViewById(R.id.newpass);
|
||||
confrimpass = (EditText) findViewById(R.id.confrimpass);
|
||||
confrimpass.setTransformationMethod(PasswordTransformationMethod
|
||||
.getInstance());
|
||||
oldpass.setTransformationMethod(PasswordTransformationMethod
|
||||
.getInstance());
|
||||
newpass.setTransformationMethod(PasswordTransformationMethod
|
||||
.getInstance());
|
||||
|
||||
oldcheck = (CheckBox) findViewById(R.id.oldcheck);
|
||||
newcheck = (CheckBox) findViewById(R.id.newcheck);
|
||||
concheck = (CheckBox) findViewById(R.id.concheck);
|
||||
// 配置文件部署
|
||||
oldcheck.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView,
|
||||
boolean isChecked) {
|
||||
String psw = oldpass.getText().toString();
|
||||
|
||||
if (isChecked) {
|
||||
// oldpass.setInputType(0x90);
|
||||
oldpass.setTransformationMethod(HideReturnsTransformationMethod
|
||||
.getInstance());
|
||||
} else {
|
||||
// oldpass.setInputType(0x81);
|
||||
oldpass.setTransformationMethod(PasswordTransformationMethod
|
||||
.getInstance());
|
||||
}
|
||||
oldpass.setSelection(psw.length());
|
||||
}
|
||||
});
|
||||
|
||||
newcheck.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView,
|
||||
boolean isChecked) {
|
||||
String psw = newpass.getText().toString();
|
||||
|
||||
if (isChecked) {
|
||||
// newpass.setInputType(0x90);
|
||||
newpass.setTransformationMethod(HideReturnsTransformationMethod
|
||||
.getInstance());
|
||||
} else {
|
||||
// newpass.setInputType(0x81);
|
||||
newpass.setTransformationMethod(PasswordTransformationMethod
|
||||
.getInstance());
|
||||
}
|
||||
newpass.setSelection(psw.length());
|
||||
}
|
||||
});
|
||||
|
||||
concheck.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView,
|
||||
boolean isChecked) {
|
||||
String psw = confrimpass.getText().toString();
|
||||
|
||||
if (isChecked) {
|
||||
// confrimpass.setInputType(0x90);
|
||||
confrimpass
|
||||
.setTransformationMethod(HideReturnsTransformationMethod
|
||||
.getInstance());
|
||||
} else {
|
||||
// confrimpass.setInputType(0x81);
|
||||
confrimpass
|
||||
.setTransformationMethod(PasswordTransformationMethod
|
||||
.getInstance());
|
||||
}
|
||||
confrimpass.setSelection(psw.length());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void confirm(View v) {
|
||||
|
||||
if (TextUtils.isEmpty(oldpass.getText().toString())
|
||||
|| TextUtils.isEmpty(newpass.getText().toString())
|
||||
|| TextUtils.isEmpty(confrimpass.getText().toString())) {
|
||||
|
||||
if (TextUtils.isEmpty(oldpass.getText().toString())) {
|
||||
|
||||
Toast.makeText(
|
||||
this,
|
||||
getResources().getString(
|
||||
R.string.enter_current_password), 2000).show();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (TextUtils.isEmpty(newpass.getText().toString())) {
|
||||
Toast.makeText(this,
|
||||
getResources().getString(R.string.enter_new_password),
|
||||
2000).show();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (TextUtils.isEmpty(confrimpass.getText().toString())) {
|
||||
Toast.makeText(
|
||||
this,
|
||||
getResources()
|
||||
.getString(R.string.re_enter_new_password),
|
||||
2000).show();
|
||||
return;
|
||||
}
|
||||
|
||||
} else {
|
||||
//oldpass.getText().length() < 6 ||
|
||||
if (newpass.getText().length() < 6 || confrimpass.getText().length() < 6) {
|
||||
Toast.makeText(this,
|
||||
getResources().getString(R.string.toast_psw_short),
|
||||
2000).show();
|
||||
}
|
||||
|
||||
String npass = newpass.getText().toString();
|
||||
String cpass = confrimpass.getText().toString();
|
||||
if (npass.equals(cpass)) {
|
||||
GizWifiSDK.sharedInstance().changeUserPassword(
|
||||
spf.getString("Token", ""),
|
||||
oldpass.getText().toString(), npass);
|
||||
} else {
|
||||
Toast.makeText(this,
|
||||
getResources().getString(R.string.nosamepass), 2000)
|
||||
.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
|
||||
finish();
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,385 @@
|
||||
package com.gizwits.opensource.appkit.UserModule;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.text.InputType;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.gizwits.opensource.appkit.R;
|
||||
import com.gizwits.gizwifisdk.api.GizWifiSDK;
|
||||
import com.gizwits.gizwifisdk.enumration.GizUserAccountType;
|
||||
import com.gizwits.gizwifisdk.enumration.GizWifiErrorCode;
|
||||
import com.gizwits.opensource.appkit.CommonModule.GosDeploy;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
||||
@SuppressLint("HandlerLeak")
|
||||
public class GosForgetPasswordActivity extends GosUserModuleBaseActivity implements
|
||||
OnClickListener {
|
||||
|
||||
/**
|
||||
* The et Name
|
||||
*/
|
||||
private EditText etName;
|
||||
/**
|
||||
* The ll phone
|
||||
*/
|
||||
private LinearLayout llPhone;
|
||||
|
||||
/**
|
||||
* The btn GetCode
|
||||
*/
|
||||
private TextView tvGetCode;
|
||||
|
||||
/**
|
||||
* The et Code
|
||||
*/
|
||||
private EditText etCode;
|
||||
|
||||
/**
|
||||
* The et Psw
|
||||
*/
|
||||
private EditText etPsw;
|
||||
|
||||
/**
|
||||
* The et ConfirmPsw
|
||||
*/
|
||||
private EditText etConfirmPsw;
|
||||
/**
|
||||
* 验证码重发倒计时
|
||||
*/
|
||||
int secondleft = 60;
|
||||
|
||||
/**
|
||||
* The timer.
|
||||
*/
|
||||
Timer timer;
|
||||
//resetPassword_phoneUser-false-end
|
||||
/**
|
||||
* The btn Register
|
||||
*/
|
||||
private Button btnReset;
|
||||
|
||||
/**
|
||||
* 数据变量
|
||||
*/
|
||||
String name, code, psw, confirmpsw;
|
||||
|
||||
|
||||
private enum handler_key {
|
||||
//resetPassword_phoneUser-false-start
|
||||
/**
|
||||
* 获取验证码.
|
||||
*/
|
||||
GETCODE,
|
||||
|
||||
/**
|
||||
* 手机验证码发送成功.
|
||||
*/
|
||||
SENDSUCCESSFUL,
|
||||
|
||||
/**
|
||||
* 倒计时通知
|
||||
*/
|
||||
TICK_TIME,
|
||||
//resetPassword_phoneUser-false-end
|
||||
|
||||
/**
|
||||
* 提示信息
|
||||
*/
|
||||
TOAST,
|
||||
|
||||
/**
|
||||
* 重置密码
|
||||
*/
|
||||
RESET,
|
||||
}
|
||||
|
||||
Handler handler = new Handler() {
|
||||
public void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
handler_key key = handler_key.values()[msg.what];
|
||||
switch (key) {
|
||||
//resetPassword_phoneUser-false-start
|
||||
case GETCODE:
|
||||
progressDialog.show();
|
||||
String AppSecret = GosDeploy.appConfig_GizwitsInfoAppSecret();
|
||||
GizWifiSDK.sharedInstance().requestSendPhoneSMSCode(AppSecret,
|
||||
msg.obj.toString());
|
||||
break;
|
||||
case SENDSUCCESSFUL:
|
||||
etName.setEnabled(false);
|
||||
etName.setTextColor(getResources().getColor(
|
||||
R.color.text_gray_light));
|
||||
isStartTimer();
|
||||
|
||||
break;
|
||||
|
||||
case TICK_TIME:
|
||||
String getCodeAgain = getString(R.string.getcode_again);
|
||||
String timerMessage = getString(R.string.timer_message);
|
||||
secondleft--;
|
||||
if (secondleft <= 0) {
|
||||
timer.cancel();
|
||||
tvGetCode.setTextColor(getResources().getColor(R.color.tomato));
|
||||
tvGetCode.setEnabled(true);
|
||||
tvGetCode.setText(getCodeAgain);
|
||||
} else {
|
||||
tvGetCode.setText(secondleft + timerMessage);
|
||||
}
|
||||
break;
|
||||
//resetPassword_phoneUser-false-end
|
||||
case TOAST:
|
||||
String successfulText = (String) getText(R.string.reset_successful);
|
||||
Toast.makeText(GosForgetPasswordActivity.this, msg.obj + "",
|
||||
toastTime).show();
|
||||
if (msg.obj.toString().equals(successfulText)) {
|
||||
// spf.edit().putString("UserName", name).commit();
|
||||
// spf.edit().putString("PassWord", psw).commit();
|
||||
isclean = true;
|
||||
//resetPassword_phoneUser-false-start
|
||||
if (llPhone.getVisibility() == View.GONE) {
|
||||
//resetPassword_phoneUser-false-end
|
||||
Intent intent = new Intent(GosForgetPasswordActivity.this, GosSendEmailPasswordActivity.class);
|
||||
startActivity(intent);
|
||||
spf.edit().putString("Email", name).commit();
|
||||
//resetPassword_phoneUser-false-start
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
//resetPassword_phoneUser-false-end
|
||||
}
|
||||
break;
|
||||
case RESET:
|
||||
progressDialog.show();
|
||||
GizWifiSDK.sharedInstance().resetPassword(name, code, psw,
|
||||
GizUserAccountType.GizUserPhone);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_gos_forget_password);
|
||||
// 设置ActionBar
|
||||
setToolBar(true, R.string.forget_pass);
|
||||
|
||||
initView();
|
||||
initEvent();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
etName = (EditText) findViewById(R.id.etName);
|
||||
//resetPassword_phoneUser-false-start
|
||||
llPhone = (LinearLayout) findViewById(R.id.llPhone);
|
||||
tvGetCode = (TextView) findViewById(R.id.tvGetCode);
|
||||
etCode = (EditText) findViewById(R.id.etCode);
|
||||
etPsw = (EditText) findViewById(R.id.etPsw);
|
||||
etConfirmPsw = (EditText) findViewById(R.id.etConfirmPsw);
|
||||
//resetPassword_phoneUser-false-end
|
||||
btnReset = (Button) findViewById(R.id.btnReset);
|
||||
setPhoneOrEmailIsVisable();
|
||||
}
|
||||
|
||||
private void setPhoneOrEmailIsVisable() {
|
||||
//resetPassword_phoneUser-true-start resetPassword_phoneUser-false-start
|
||||
if (GosDeploy.appConfig_ResetPassword_PhoneUser()) {
|
||||
//resetPassword_phoneUser-true-end
|
||||
etName.setHint(getResources().getString(R.string.name_phone));
|
||||
llPhone.setVisibility(View.VISIBLE);
|
||||
etName.setInputType(InputType.TYPE_CLASS_PHONE);
|
||||
btnReset.setText(getResources().getString(R.string.reset));
|
||||
//resetPassword_phoneUser-true-start
|
||||
} else {
|
||||
//resetPassword_phoneUser-false-end
|
||||
//resetPassword_phoneUser-false-start
|
||||
}
|
||||
//resetPassword_phoneUser-true-end resetPassword_phoneUser-false-end
|
||||
}
|
||||
|
||||
private void initEvent() {
|
||||
|
||||
final Timer etTimer = new Timer();
|
||||
etTimer.schedule(new TimerTask() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
etName.requestFocus();
|
||||
InputMethodManager imm = (InputMethodManager) etName
|
||||
.getContext().getSystemService(
|
||||
Context.INPUT_METHOD_SERVICE);
|
||||
imm.toggleSoftInput(0, InputMethodManager.SHOW_FORCED);
|
||||
etTimer.cancel();
|
||||
|
||||
}
|
||||
}, 500);
|
||||
//resetPassword_phoneUser-false-start
|
||||
tvGetCode.setOnClickListener(this);
|
||||
//resetPassword_phoneUser-false-end
|
||||
btnReset.setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
//resetPassword_phoneUser-false-start
|
||||
case R.id.tvGetCode:
|
||||
name = etName.getText().toString();
|
||||
if (TextUtils.isEmpty(name)) {
|
||||
Toast.makeText(GosForgetPasswordActivity.this,
|
||||
R.string.toast_name_wrong, toastTime).show();
|
||||
return;
|
||||
}
|
||||
Message msg = new Message();
|
||||
msg.obj = name;
|
||||
msg.what = handler_key.GETCODE.ordinal();
|
||||
handler.sendMessage(msg);
|
||||
break;
|
||||
//resetPassword_phoneUser-false-end
|
||||
case R.id.btnReset:
|
||||
name = etName.getText().toString();
|
||||
//resetPassword_phoneUser-false-start
|
||||
code = etCode.getText().toString();
|
||||
psw = etPsw.getText().toString();
|
||||
confirmpsw = etConfirmPsw.getText().toString();
|
||||
if (TextUtils.isEmpty(name)) {
|
||||
Toast.makeText(GosForgetPasswordActivity.this,
|
||||
R.string.toast_name_wrong, toastTime).show();
|
||||
return;
|
||||
}
|
||||
|
||||
if (llPhone.getVisibility() == View.VISIBLE) {
|
||||
if (code.length() != 6) {
|
||||
Toast.makeText(GosForgetPasswordActivity.this, R.string.no_getcode, toastTime).show();
|
||||
return;
|
||||
}
|
||||
if (TextUtils.isEmpty(psw)) {
|
||||
Toast.makeText(GosForgetPasswordActivity.this,
|
||||
R.string.toast_psw_wrong, toastTime).show();
|
||||
return;
|
||||
}
|
||||
if (psw.length() < 6) {
|
||||
Toast.makeText(GosForgetPasswordActivity.this,
|
||||
R.string.toast_psw_short, toastTime).show();
|
||||
return;
|
||||
}
|
||||
if (!psw.equals(confirmpsw)) {
|
||||
Toast.makeText(GosForgetPasswordActivity.this, R.string.toast_psw_confirm_failed, toastTime).show();
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
//resetPassword_phoneUser-false-end
|
||||
if (!name.contains("@")) {
|
||||
Toast.makeText(GosForgetPasswordActivity.this, R.string.toase_name_email_fault, toastTime).show();
|
||||
return;
|
||||
}
|
||||
//resetPassword_phoneUser-false-start
|
||||
}
|
||||
//resetPassword_phoneUser-false-end
|
||||
|
||||
/*
|
||||
* if (psw.length() < 6) {
|
||||
* Toast.makeText(GosForgetPasswordActivity.this,
|
||||
* R.string.toast_psw_short, toastTime).show(); return; }
|
||||
*/
|
||||
handler.sendEmptyMessage(handler_key.RESET.ordinal());
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 倒计时
|
||||
*/
|
||||
public void isStartTimer() {
|
||||
tvGetCode.setEnabled(false);
|
||||
tvGetCode.setTextColor(getResources().getColor(R.color.hint_color));
|
||||
secondleft = 60;
|
||||
timer = new Timer();
|
||||
timer.schedule(new TimerTask() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
handler.sendEmptyMessage(handler_key.TICK_TIME.ordinal());
|
||||
}
|
||||
}, 1000, 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* 手机验证码回调
|
||||
*/
|
||||
@Override
|
||||
protected void didRequestSendPhoneSMSCode(GizWifiErrorCode result,
|
||||
String token) {
|
||||
if (progressDialog != null) {
|
||||
progressDialog.cancel();
|
||||
}
|
||||
Message msg = new Message();
|
||||
if (GizWifiErrorCode.GIZ_SDK_SUCCESS != result) {
|
||||
// String sendFailed = (String) getText(R.string.send_failed);
|
||||
msg.what = handler_key.TOAST.ordinal();
|
||||
msg.obj = toastError(result);// sendFailed + "\n" +
|
||||
// errorMessage;toastError(errorCode)
|
||||
handler.sendMessage(msg);
|
||||
} else {
|
||||
handler.sendEmptyMessage(handler_key.SENDSUCCESSFUL.ordinal());
|
||||
msg.what = handler_key.TOAST.ordinal();
|
||||
String sendSuccessful = (String) getText(R.string.send_successful);
|
||||
msg.obj = sendSuccessful;
|
||||
handler.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
//resetPassword_phoneUser-false-end
|
||||
|
||||
/**
|
||||
* 重置密码回调
|
||||
*/
|
||||
@Override
|
||||
public void didChangeUserPassword(GizWifiErrorCode result) {
|
||||
if (progressDialog != null) {
|
||||
progressDialog.cancel();
|
||||
}
|
||||
Message msg = new Message();
|
||||
if (GizWifiErrorCode.GIZ_SDK_SUCCESS != result) {
|
||||
// String resetFailed = (String) getText(R.string.reset_failed);
|
||||
msg.what = handler_key.TOAST.ordinal();
|
||||
msg.obj = toastError(result);// resetFailed + "\n" + errorMessage;
|
||||
handler.sendMessage(msg);
|
||||
} else {
|
||||
msg.what = handler_key.TOAST.ordinal();
|
||||
String resetSuccessful = (String) getText(R.string.reset_successful);
|
||||
msg.obj = resetSuccessful;
|
||||
handler.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
progressDialog = null;
|
||||
}
|
||||
}
|
@ -0,0 +1,359 @@
|
||||
package com.gizwits.opensource.appkit.UserModule;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.text.InputType;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.gizwits.opensource.appkit.R;
|
||||
import com.gizwits.gizwifisdk.api.GizWifiSDK;
|
||||
import com.gizwits.gizwifisdk.enumration.GizUserAccountType;
|
||||
import com.gizwits.gizwifisdk.enumration.GizWifiErrorCode;
|
||||
import com.gizwits.opensource.appkit.CommonModule.GosDeploy;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@SuppressLint("HandlerLeak")
|
||||
public class GosRegisterUserActivity extends GosUserModuleBaseActivity implements OnClickListener, AdapterView.OnItemSelectedListener {
|
||||
|
||||
/**
|
||||
* The et Name
|
||||
*/
|
||||
private EditText etName;
|
||||
//register_phoneUser-false-start
|
||||
/**
|
||||
* The ll code
|
||||
*/
|
||||
private LinearLayout llCode;
|
||||
|
||||
/**
|
||||
* The btn GetCode
|
||||
*/
|
||||
private TextView tvGetCode;
|
||||
|
||||
/**
|
||||
* The et Code
|
||||
*/
|
||||
private EditText etCode;
|
||||
/**
|
||||
* 验证码重发倒计时
|
||||
*/
|
||||
int secondleft = 60;
|
||||
|
||||
/**
|
||||
* The timer.
|
||||
*/
|
||||
Timer timer;
|
||||
|
||||
//register_phoneUser-false-end
|
||||
/**
|
||||
* The et Psw
|
||||
*/
|
||||
private EditText etPsw;
|
||||
|
||||
/**
|
||||
* The et ConfirmPsw
|
||||
*/
|
||||
private EditText etConfirmPsw;
|
||||
|
||||
/**
|
||||
* The btn Rrgister
|
||||
*/
|
||||
private Button btnRrgister;
|
||||
|
||||
/**
|
||||
* 数据变量
|
||||
*/
|
||||
String name, code, psw, confirmpsw;
|
||||
|
||||
private int usertype = 0;
|
||||
|
||||
private enum handler_key {
|
||||
//register_phoneUser-false-start
|
||||
/**
|
||||
* 获取验证码.
|
||||
*/
|
||||
GETCODE,
|
||||
/**
|
||||
* 手机验证码发送成功.
|
||||
*/
|
||||
SENDSUCCESSFUL,
|
||||
//register_phoneUser-false-end
|
||||
|
||||
/**
|
||||
* 提示信息
|
||||
*/
|
||||
TOAST,
|
||||
/**
|
||||
* 倒计时通知
|
||||
*/
|
||||
TICK_TIME,
|
||||
|
||||
/**
|
||||
* 注册
|
||||
*/
|
||||
REGISTER,
|
||||
}
|
||||
|
||||
Handler handler = new Handler() {
|
||||
public void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
handler_key key = handler_key.values()[msg.what];
|
||||
switch (key) {
|
||||
//register_phoneUser-false-start
|
||||
case GETCODE:
|
||||
progressDialog.show();
|
||||
String AppSecret = GosDeploy.appConfig_GizwitsInfoAppSecret();
|
||||
GizWifiSDK.sharedInstance().requestSendPhoneSMSCode(AppSecret, msg.obj.toString());
|
||||
break;
|
||||
case SENDSUCCESSFUL:
|
||||
etName.setEnabled(false);
|
||||
etName.setTextColor(getResources().getColor(R.color.text_gray_light));
|
||||
isStartTimer();
|
||||
break;
|
||||
case TICK_TIME:
|
||||
String getCodeAgain = getString(R.string.getcode_again);
|
||||
String timerMessage = getString(R.string.timer_message);
|
||||
secondleft--;
|
||||
if (secondleft <= 0) {
|
||||
timer.cancel();
|
||||
tvGetCode.setTextColor(getResources().getColor(R.color.tomato));
|
||||
tvGetCode.setEnabled(true);
|
||||
tvGetCode.setText(getCodeAgain);
|
||||
} else {
|
||||
tvGetCode.setText(secondleft + timerMessage);
|
||||
}
|
||||
break;
|
||||
//register_phoneUser-false-end
|
||||
case TOAST:
|
||||
Toast.makeText(GosRegisterUserActivity.this, msg.obj.toString(), toastTime).show();
|
||||
String successfulText = (String) getText(R.string.register_successful);
|
||||
|
||||
if (msg.obj.toString().equals(successfulText)) {
|
||||
spf.edit().putString("UserName", name).commit();
|
||||
spf.edit().putString("PassWord", psw).commit();
|
||||
isclean = true;
|
||||
finish();
|
||||
}
|
||||
break;
|
||||
case REGISTER:
|
||||
progressDialog.show();
|
||||
GizWifiSDK.sharedInstance().registerUser(name, psw, code, GizUserAccountType.GizUserPhone);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_gos_register_user);
|
||||
// 设置ActionBar
|
||||
setToolBar(true, R.string.register);
|
||||
initView();
|
||||
initEvent();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
etName = (EditText) findViewById(R.id.etName);
|
||||
//register_phoneUser-false-start
|
||||
tvGetCode = (TextView) findViewById(R.id.tvGetCode);
|
||||
etCode = (EditText) findViewById(R.id.etCode);
|
||||
llCode = (LinearLayout) findViewById(R.id.llCode);
|
||||
//register_phoneUser-false-end
|
||||
etPsw = (EditText) findViewById(R.id.etPsw);
|
||||
etConfirmPsw = (EditText) findViewById(R.id.etConfirmPsw);
|
||||
btnRrgister = (Button) findViewById(R.id.btnRrgister);
|
||||
setPhoneOrEmailOrNormalIsVisable();
|
||||
}
|
||||
|
||||
private void setPhoneOrEmailOrNormalIsVisable() {
|
||||
etName.setHint(getResources().getString(R.string.name_phone));
|
||||
usertype = 0;
|
||||
}
|
||||
|
||||
|
||||
private void initEvent() {
|
||||
final Timer etTimer = new Timer();
|
||||
etTimer.schedule(new TimerTask() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
etName.requestFocus();
|
||||
InputMethodManager imm = (InputMethodManager) etName.getContext()
|
||||
.getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm.toggleSoftInput(0, InputMethodManager.SHOW_FORCED);
|
||||
etTimer.cancel();
|
||||
|
||||
}
|
||||
}, 500);
|
||||
//register_phoneUser-false-start
|
||||
tvGetCode.setOnClickListener(this);
|
||||
//register_phoneUser-false-end
|
||||
btnRrgister.setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
//register_phoneUser-false-start
|
||||
case R.id.tvGetCode:
|
||||
name = etName.getText().toString();
|
||||
if (TextUtils.isEmpty(name)) {
|
||||
Toast.makeText(GosRegisterUserActivity.this, R.string.toast_name_wrong, toastTime).show();
|
||||
return;
|
||||
}
|
||||
Message msg = new Message();
|
||||
msg.obj = name;
|
||||
msg.what = handler_key.GETCODE.ordinal();
|
||||
handler.sendMessage(msg);
|
||||
break;
|
||||
//register_phoneUser-false-end
|
||||
case R.id.btnRrgister:
|
||||
name = etName.getText().toString();
|
||||
//register_phoneUser-false-start
|
||||
code = etCode.getText().toString();
|
||||
//register_phoneUser-false-end
|
||||
psw = etPsw.getText().toString();
|
||||
confirmpsw = etConfirmPsw.getText().toString();
|
||||
if (TextUtils.isEmpty(name)) {
|
||||
Toast.makeText(GosRegisterUserActivity.this, R.string.toast_name_wrong, toastTime).show();
|
||||
return;
|
||||
}
|
||||
if (usertype == 0) {
|
||||
if (code.length() != 6) {
|
||||
Toast.makeText(GosRegisterUserActivity.this, R.string.no_getcode, toastTime).show();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (TextUtils.isEmpty(psw)) {
|
||||
Toast.makeText(GosRegisterUserActivity.this, R.string.toast_psw_wrong, toastTime).show();
|
||||
return;
|
||||
}
|
||||
|
||||
if (psw.length() < 6) {
|
||||
Toast.makeText(GosRegisterUserActivity.this, R.string.toast_psw_short, toastTime).show();
|
||||
return;
|
||||
}
|
||||
|
||||
if (TextUtils.isEmpty(confirmpsw)) {
|
||||
Toast.makeText(GosRegisterUserActivity.this, R.string.toast_psw_confirm, toastTime).show();
|
||||
return;
|
||||
}
|
||||
if (!psw.equals(confirmpsw)) {
|
||||
Toast.makeText(GosRegisterUserActivity.this, R.string.toast_psw_confirm_failed, toastTime).show();
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* if (psw.length() < 6) {
|
||||
* Toast.makeText(GosRegisterUserActivity.this,
|
||||
* R.string.toast_psw_short, toastTime).show(); return; }
|
||||
*/
|
||||
handler.sendEmptyMessage(handler_key.REGISTER.ordinal());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
etName.setText("");
|
||||
etName.setEnabled(true);
|
||||
etName.setTextColor(getResources().getColor(R.color.text_color));
|
||||
//register_phoneUser-false-start
|
||||
etCode.setText("");
|
||||
//register_phoneUser-false-end
|
||||
etPsw.setText("");
|
||||
etConfirmPsw.setText("");
|
||||
etName.setHint(getResources().getString(R.string.name_phone));
|
||||
llCode.setVisibility(View.VISIBLE);
|
||||
etName.setInputType(InputType.TYPE_CLASS_PHONE);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> parent) {
|
||||
|
||||
}
|
||||
//register_phoneUser-false-start
|
||||
|
||||
/**
|
||||
* 手机验证码回调
|
||||
*/
|
||||
@Override
|
||||
protected void didRequestSendPhoneSMSCode(GizWifiErrorCode result, String token) {
|
||||
progressDialog.cancel();
|
||||
Message msg = new Message();
|
||||
if (GizWifiErrorCode.GIZ_SDK_SUCCESS != result) {
|
||||
msg.what = handler_key.TOAST.ordinal();
|
||||
msg.obj = toastError(result);
|
||||
handler.sendMessage(msg);
|
||||
} else {
|
||||
handler.sendEmptyMessage(handler_key.SENDSUCCESSFUL.ordinal());
|
||||
msg.what = handler_key.TOAST.ordinal();
|
||||
String sendSuccessful = (String) getText(R.string.send_successful);
|
||||
msg.obj = sendSuccessful;
|
||||
handler.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 倒计时
|
||||
*/
|
||||
public void isStartTimer() {
|
||||
tvGetCode.setEnabled(false);
|
||||
tvGetCode.setTextColor(getResources().getColor(R.color.hint_color));
|
||||
secondleft = 60;
|
||||
timer = new Timer();
|
||||
timer.schedule(new TimerTask() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
handler.sendEmptyMessage(handler_key.TICK_TIME.ordinal());
|
||||
}
|
||||
}, 1000, 1000);
|
||||
}
|
||||
//register_phoneUser-false-end
|
||||
|
||||
/**
|
||||
* 用户注册回调
|
||||
*/
|
||||
@Override
|
||||
protected void didRegisterUser(GizWifiErrorCode result, String uid, String token) {
|
||||
progressDialog.cancel();
|
||||
if (GizWifiErrorCode.GIZ_SDK_SUCCESS != result) {
|
||||
Message msg = new Message();
|
||||
msg.what = handler_key.TOAST.ordinal();
|
||||
msg.obj = toastError(result);
|
||||
handler.sendMessage(msg);
|
||||
} else {
|
||||
Message msg = new Message();
|
||||
msg.what = handler_key.TOAST.ordinal();
|
||||
String registerSuccessful = (String) getText(R.string.register_successful);
|
||||
msg.obj = registerSuccessful;
|
||||
handler.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
package com.gizwits.opensource.appkit.UserModule;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.SpannableString;
|
||||
import android.text.Spanned;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gizwits.opensource.appkit.R;
|
||||
import com.gizwits.opensource.appkit.CommonModule.GosBaseActivity;
|
||||
|
||||
|
||||
public class GosSendEmailPasswordActivity extends GosBaseActivity {
|
||||
|
||||
private TextView tvEmail;
|
||||
private Button btnReturn;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_gos_send_email_password);
|
||||
// 设置ActionBar
|
||||
setToolBar(true, R.string.forget_pass);
|
||||
initView();
|
||||
initEvent();
|
||||
}
|
||||
|
||||
private static final String TAG = "GosSendEmailPasswordAct";
|
||||
|
||||
private void initView() {
|
||||
tvEmail = (TextView) findViewById(R.id.tvEmail);
|
||||
btnReturn = (Button) findViewById(R.id.btnReturn);
|
||||
}
|
||||
|
||||
private void initEvent() {
|
||||
String email = spf.getString("Email", "xxx@xxx.xx");
|
||||
String s = getResources().getString(R.string.send_email_pass);
|
||||
//字符串截取
|
||||
String bb = s.substring(10, 20);
|
||||
//字符串替换
|
||||
String cc = s.replace(bb, email);
|
||||
SpannableString spannableString = new SpannableString(cc);
|
||||
spannableString.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.tomato)), 10, 10 + email.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
tvEmail.setText(spannableString);
|
||||
btnReturn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(GosSendEmailPasswordActivity.this, GosUserLoginActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
this.finish();
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,163 @@
|
||||
package com.gizwits.opensource.appkit.UserModule;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gizwits.opensource.appkit.CommonModule.GosBaseActivity;
|
||||
import com.gizwits.opensource.appkit.CommonModule.GosDeploy;
|
||||
import com.gizwits.opensource.appkit.DeviceModule.GosDeviceListFragment;
|
||||
import com.gizwits.opensource.appkit.PushModule.GosPushManager;
|
||||
import com.gizwits.opensource.appkit.R;
|
||||
|
||||
//push-all-start
|
||||
//push-all-end
|
||||
|
||||
public class GosUserManager extends GosBaseActivity {
|
||||
|
||||
private static final int GOSUSERMANAGER = 234;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_gos_usermanager);
|
||||
setToolBar(true, R.string.user_management);
|
||||
initView();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
TextView phoneusernumber = (TextView) findViewById(R.id.phoneusernumber);
|
||||
//personalCenter_changePassword-false-start
|
||||
LinearLayout changeuserpassword = (LinearLayout) findViewById(R.id.changeuserpassword);
|
||||
if (!GosDeploy.appConfig_PersonalCenter_ChangePassword()) {
|
||||
changeuserpassword.setVisibility(View.GONE);
|
||||
}
|
||||
//personalCenter_changePassword-false-end
|
||||
if (!TextUtils.isEmpty(spf.getString("UserName", ""))) {
|
||||
phoneusernumber.setText(spf.getString("UserName", ""));
|
||||
} else {
|
||||
//personalCenter_changePassword-false-start
|
||||
String uid = spf.getString("thirdUid", "");
|
||||
if (!TextUtils.isEmpty(uid) && uid.length() != 0) {
|
||||
String myuid = uid.substring(0, 2) + "***" + uid.substring(uid.length() - 4, uid.length());
|
||||
phoneusernumber.setText(myuid);
|
||||
changeuserpassword.setVisibility(View.GONE);
|
||||
}
|
||||
//personalCenter_changePassword-false-end
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void userlogout(View v) {
|
||||
setResult(GOSUSERMANAGER);
|
||||
logoutToClean();
|
||||
|
||||
Intent intent = new Intent(GosUserManager.this, GosUserLoginActivity.class);
|
||||
quitAlert(intent, getString(R.string.exit_login));
|
||||
|
||||
}
|
||||
|
||||
//personalCenter_changePassword-false-start
|
||||
public void changeuserpassword(View v) {
|
||||
Intent tent = new Intent(this, GosChangeUserPasswordActivity.class);
|
||||
startActivity(tent);
|
||||
}
|
||||
//personalCenter_changePassword-false-end
|
||||
|
||||
private void logoutToClean() {
|
||||
//push-all-start
|
||||
GosPushManager.pushUnBindService(spf.getString("Token", ""));
|
||||
//push-all-end
|
||||
spf.edit().putString("UserName", "").commit();
|
||||
isclean = true;
|
||||
spf.edit().putString("PassWord", "").commit();
|
||||
spf.edit().putString("Uid", "").commit();
|
||||
spf.edit().putString("Token", "").commit();
|
||||
|
||||
spf.edit().putString("thirdUid", "").commit();
|
||||
|
||||
if (GosDeviceListFragment.loginStatus == 1) {
|
||||
GosDeviceListFragment.loginStatus = 0;
|
||||
} else {
|
||||
GosDeviceListFragment.loginStatus = 4;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
isclean = false;
|
||||
finish();
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
isclean = false;
|
||||
finish();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 推出提示
|
||||
*
|
||||
* @param
|
||||
*/
|
||||
protected void quitAlert(final Intent intent, String content) {
|
||||
final Dialog dialog = new AlertDialog.Builder(this, R.style.alert_dialog_style)
|
||||
.setView(new EditText(this)).create();
|
||||
dialog.setCanceledOnTouchOutside(false);
|
||||
dialog.show();
|
||||
|
||||
Window window = dialog.getWindow();
|
||||
window.setContentView(R.layout.alert_gos_quit);
|
||||
WindowManager.LayoutParams layoutParams = window.getAttributes();
|
||||
layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
|
||||
window.setAttributes(layoutParams);
|
||||
TextView tvContent;
|
||||
LinearLayout llNo, llSure;
|
||||
llNo = (LinearLayout) window.findViewById(R.id.llNo);
|
||||
llSure = (LinearLayout) window.findViewById(R.id.llSure);
|
||||
tvContent = (TextView) window.findViewById(R.id.tv_prompt);
|
||||
|
||||
tvContent.setText(content);
|
||||
|
||||
llNo.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
dialog.cancel();
|
||||
}
|
||||
});
|
||||
|
||||
llSure.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
dialog.cancel();
|
||||
|
||||
startActivity(intent);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
package com.gizwits.opensource.appkit.sharingdevice;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.MenuItem;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gizwits.opensource.appkit.CommonModule.GosBaseActivity;
|
||||
import com.gizwits.opensource.appkit.R;
|
||||
|
||||
|
||||
/**
|
||||
* Created by Sunny on 2015年6月25日
|
||||
*
|
||||
* @author Sunny
|
||||
*/
|
||||
public class MsgNoticeActivity extends GosBaseActivity {
|
||||
|
||||
private ListView lvNotice;
|
||||
private TextView tvNoNotice;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_notice);
|
||||
|
||||
// setActionBar(true, true, R.string.msg_xnotice);
|
||||
initView();
|
||||
// initData();
|
||||
}
|
||||
|
||||
private void initView(){
|
||||
lvNotice=(ListView) findViewById(R.id.lvNotice);
|
||||
tvNoNotice=(TextView) findViewById(R.id.tvNoNotice);
|
||||
}
|
||||
|
||||
// private void initData(){
|
||||
// NoticeDBService dbService= new NoticeDBService(this);
|
||||
// ArrayList<NoticeBean> lsNotice=dbService.getNoticeList();
|
||||
//
|
||||
// if(lsNotice!=null&&lsNotice.size()>0){
|
||||
// lvNotice.setVisibility(View.VISIBLE);
|
||||
// tvNoNotice.setVisibility(View.GONE);
|
||||
//
|
||||
// NoticeAdapter na=new NoticeAdapter(this, lsNotice);
|
||||
// lvNotice.setAdapter(na);
|
||||
// }else{
|
||||
// lvNotice.setVisibility(View.GONE);
|
||||
// tvNoNotice.setVisibility(View.VISIBLE);
|
||||
// }
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
// initData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
public boolean onOptionsItemSelected(MenuItem menu) {
|
||||
super.onOptionsItemSelected(menu);
|
||||
switch (menu.getItemId()) {
|
||||
case android.R.id.home:
|
||||
finish();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
finish();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,233 @@
|
||||
package com.gizwits.opensource.appkit.sharingdevice;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentStatePagerAdapter;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.gizwits.gizwifisdk.api.GizDeviceSharing;
|
||||
import com.gizwits.gizwifisdk.api.GizDeviceSharingInfo;
|
||||
import com.gizwits.gizwifisdk.enumration.GizDeviceSharingType;
|
||||
import com.gizwits.gizwifisdk.enumration.GizWifiErrorCode;
|
||||
import com.gizwits.gizwifisdk.listener.GizDeviceSharingListener;
|
||||
import com.gizwits.opensource.appkit.CommonModule.GosBaseActivity;
|
||||
import com.gizwits.opensource.appkit.CommonModule.GosConstant;
|
||||
import com.gizwits.opensource.appkit.CommonModule.NoScrollViewPager;
|
||||
import com.gizwits.opensource.appkit.R;
|
||||
import com.gizwits.opensource.appkit.utils.DateUtil;
|
||||
import com.gizwits.opensource.appkit.view.ViewPagerIndicator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
public class SharedDeviceListAcitivity extends GosBaseActivity {
|
||||
|
||||
private List<String> tabList;
|
||||
private List<Fragment> myfragmentlist;
|
||||
private String token;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setContentView(R.layout.activity_gos_shared_device_list);
|
||||
|
||||
setToolBar(true, R.string.sharedlist);
|
||||
initData();
|
||||
initView();
|
||||
}
|
||||
|
||||
// 初始化tab标签中应该显示的文字
|
||||
private void initData() {
|
||||
|
||||
token = spf.getString("Token", "");
|
||||
|
||||
myfragmentlist = new ArrayList<Fragment>();
|
||||
|
||||
SharedFragment ment1 = new SharedFragment();
|
||||
|
||||
InvitedFragment ment2 = new InvitedFragment();
|
||||
|
||||
|
||||
myfragmentlist.add(ment1);
|
||||
myfragmentlist.add(ment2);
|
||||
|
||||
tabList = new ArrayList<String>();
|
||||
tabList.add(getResources().getString(R.string.shared));
|
||||
tabList.add(getResources().getString(R.string.invited));
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
|
||||
ViewPagerIndicator indicator = (ViewPagerIndicator) findViewById(
|
||||
R.id.vpi_indicator);
|
||||
|
||||
indicator.setVisibleTabCount(2);
|
||||
indicator.setTabItemTitles(tabList);
|
||||
NoScrollViewPager vp_shared = (NoScrollViewPager) findViewById(R.id.vp_shared_list);
|
||||
|
||||
vp_shared.setNoScroll(true);
|
||||
|
||||
vp_shared.setAdapter(new myFragmentAdapter(getSupportFragmentManager()));
|
||||
|
||||
indicator.setViewPager(vp_shared, 0);
|
||||
|
||||
indicator.setOnPageChangeListener(new ViewPagerIndicator.PageChangeListener() {
|
||||
|
||||
@Override
|
||||
public void onPageSelected(int position) {
|
||||
GosConstant.nowPager = position;
|
||||
|
||||
switch (GosConstant.nowPager) {
|
||||
case 0:
|
||||
|
||||
break;
|
||||
|
||||
case 1:
|
||||
GizDeviceSharing.getDeviceSharingInfos(token, GizDeviceSharingType.GizDeviceSharingToMe, null);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageScrollStateChanged(int state) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
class myFragmentAdapter extends FragmentStatePagerAdapter {
|
||||
|
||||
public myFragmentAdapter(FragmentManager fm) {
|
||||
super(fm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Fragment getItem(int arg0) {
|
||||
|
||||
if (arg0 == 0) {
|
||||
SharedFragment shared = new SharedFragment();
|
||||
|
||||
return shared;
|
||||
} else {
|
||||
InvitedFragment shared = (InvitedFragment) myfragmentlist.get(arg0);
|
||||
|
||||
return shared;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
finish();
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
// TODO Auto-generated method stub
|
||||
super.onResume();
|
||||
|
||||
initListener();
|
||||
}
|
||||
|
||||
// 初始化接口数据
|
||||
private void initListener() {
|
||||
|
||||
GizDeviceSharing.setListener(new GizDeviceSharingListener() {
|
||||
|
||||
@Override
|
||||
public void didGetDeviceSharingInfos(GizWifiErrorCode result, String deviceID,
|
||||
List<GizDeviceSharingInfo> deviceSharingInfos) {
|
||||
super.didGetDeviceSharingInfos(result, deviceID, deviceSharingInfos);
|
||||
|
||||
|
||||
if (deviceSharingInfos != null) {
|
||||
Collections.sort(deviceSharingInfos, new Comparator<GizDeviceSharingInfo>() {
|
||||
|
||||
@Override
|
||||
public int compare(GizDeviceSharingInfo arg0, GizDeviceSharingInfo arg1) {
|
||||
|
||||
String updatedAt = DateUtil.utc2Local(arg0.getUpdatedAt());
|
||||
String updatedAt2 = DateUtil.utc2Local(arg1.getUpdatedAt());
|
||||
|
||||
int diff = (int) DateUtil.getDiff(updatedAt2, updatedAt);
|
||||
|
||||
return diff;
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
GosConstant.newmydeviceSharingInfos = deviceSharingInfos;
|
||||
|
||||
InvitedFragment fragment = (InvitedFragment) myfragmentlist.get(1);
|
||||
TextView myview = fragment.getmyview();
|
||||
if (deviceSharingInfos.size() == 0) {
|
||||
|
||||
myview.setVisibility(View.VISIBLE);
|
||||
myview.setText(getResources().getString(R.string.no_guest_users));
|
||||
} else {
|
||||
myview.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
InvitedFragment.myadapter getmyadapter = fragment.getmyadapter();
|
||||
getmyadapter.notifyDataSetChanged();
|
||||
|
||||
if (result.ordinal() != 0) {
|
||||
Toast.makeText(SharedDeviceListAcitivity.this, toastError(result), 2).show();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void didAcceptDeviceSharing(GizWifiErrorCode result, int sharingID) {
|
||||
super.didAcceptDeviceSharing(result, sharingID);
|
||||
|
||||
if (result.ordinal() != 0) {
|
||||
Toast.makeText(SharedDeviceListAcitivity.this, toastError(result), 2).show();
|
||||
}
|
||||
|
||||
GizDeviceSharing.getDeviceSharingInfos(token, GizDeviceSharingType.GizDeviceSharingToMe, null);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,282 @@
|
||||
package com.gizwits.opensource.appkit.sharingdevice;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Bundle;
|
||||
import android.os.Message;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentStatePagerAdapter;
|
||||
import android.view.MenuItem;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.gizwits.gizwifisdk.api.GizDeviceSharing;
|
||||
import com.gizwits.gizwifisdk.api.GizDeviceSharingInfo;
|
||||
import com.gizwits.gizwifisdk.api.GizUserInfo;
|
||||
import com.gizwits.gizwifisdk.enumration.GizDeviceSharingType;
|
||||
import com.gizwits.gizwifisdk.enumration.GizWifiErrorCode;
|
||||
import com.gizwits.gizwifisdk.listener.GizDeviceSharingListener;
|
||||
import com.gizwits.opensource.appkit.CommonModule.GosBaseActivity;
|
||||
import com.gizwits.opensource.appkit.CommonModule.GosConstant;
|
||||
import com.gizwits.opensource.appkit.CommonModule.NoScrollViewPager;
|
||||
import com.gizwits.opensource.appkit.R;
|
||||
import com.gizwits.opensource.appkit.utils.DateUtil;
|
||||
import com.gizwits.opensource.appkit.view.ViewPagerIndicator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
public class SharedDeviceManagerActivity extends GosBaseActivity {
|
||||
|
||||
private List<String> tabList;
|
||||
private String productname;
|
||||
private String deviceid;
|
||||
private List<Fragment> myfragmentlist;
|
||||
private int viewPagerSelected = 0;
|
||||
private boolean isgetsharing;
|
||||
private String token;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setContentView(R.layout.activity_gos_shared_device_list);
|
||||
|
||||
setToolBar(true, R.string.sharedmanager);
|
||||
GosConstant.isEdit = false;
|
||||
initData();
|
||||
initView();
|
||||
token = spf.getString("Token", "");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
GizDeviceSharing.setListener(new GizDeviceSharingListener() {
|
||||
|
||||
@Override
|
||||
public void didSharingDevice(GizWifiErrorCode result, String deviceID, int sharingID, Bitmap QRCodeImage) {
|
||||
super.didSharingDevice(result, deviceID, sharingID, QRCodeImage);
|
||||
|
||||
if (result.ordinal() != 0) {
|
||||
Toast.makeText(SharedDeviceManagerActivity.this, toastError(result), 1).show();
|
||||
}
|
||||
GizDeviceSharing.getDeviceSharingInfos(token, GizDeviceSharingType.GizDeviceSharingByMe, deviceid);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void didModifySharingInfo(GizWifiErrorCode result, int sharingID) {
|
||||
super.didModifySharingInfo(result, sharingID);
|
||||
|
||||
if (result.ordinal() != 0) {
|
||||
Toast.makeText(SharedDeviceManagerActivity.this, toastError(result), 1).show();
|
||||
}
|
||||
GizDeviceSharing.getDeviceSharingInfos(token, GizDeviceSharingType.GizDeviceSharingByMe, deviceid);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void didGetDeviceSharingInfos(GizWifiErrorCode result, String deviceID,
|
||||
List<GizDeviceSharingInfo> deviceSharingInfos) {
|
||||
super.didGetDeviceSharingInfos(result, deviceID, deviceSharingInfos);
|
||||
|
||||
if (deviceSharingInfos != null) {
|
||||
Collections.sort(deviceSharingInfos, new Comparator<GizDeviceSharingInfo>() {
|
||||
|
||||
@Override
|
||||
public int compare(GizDeviceSharingInfo arg0, GizDeviceSharingInfo arg1) {
|
||||
|
||||
String updatedAt = DateUtil.utc2Local(arg0.getUpdatedAt());
|
||||
String updatedAt2 = DateUtil.utc2Local(arg1.getUpdatedAt());
|
||||
|
||||
int diff = (int) DateUtil.getDiff(updatedAt2, updatedAt);
|
||||
|
||||
return diff;
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
GosConstant.mydeviceSharingInfos = deviceSharingInfos;
|
||||
SharedStateFragment fragment = (SharedStateFragment) myfragmentlist.get(0);
|
||||
Message msg = new Message();
|
||||
msg.what = 1;
|
||||
fragment.handler.sendMessage(msg);
|
||||
SharedUserFragment fragment1 = (SharedUserFragment) myfragmentlist.get(1);
|
||||
Message msg1 = new Message();
|
||||
msg1.what = 1;
|
||||
fragment1.handler.sendMessage(msg1);
|
||||
if (result.ordinal() != 0) {
|
||||
Toast.makeText(SharedDeviceManagerActivity.this, toastError(result), 1).show();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void didGetBindingUsers(GizWifiErrorCode result, String deviceID, List<GizUserInfo> bindUsers) {
|
||||
super.didGetBindingUsers(result, deviceID, bindUsers);
|
||||
GosConstant.mybindUsers = bindUsers;
|
||||
SharedUserFragment fragment = (SharedUserFragment) myfragmentlist.get(1);
|
||||
SharedUserFragment.myadapter getmyadapter = fragment.getmyadapter();
|
||||
|
||||
if (getmyadapter != null) {
|
||||
getmyadapter.notifyDataSetChanged();
|
||||
}
|
||||
if (result.ordinal() != 0) {
|
||||
Toast.makeText(SharedDeviceManagerActivity.this, toastError(result), 1).show();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void didUnbindUser(GizWifiErrorCode result, String deviceID, String guestUID) {
|
||||
// TODO Auto-generated method stub
|
||||
super.didUnbindUser(result, deviceID, guestUID);
|
||||
|
||||
GizDeviceSharing.getBindingUsers(token, deviceid);
|
||||
|
||||
if (result.ordinal() != 0) {
|
||||
Toast.makeText(SharedDeviceManagerActivity.this, toastError(result), 1).show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void didRevokeDeviceSharing(GizWifiErrorCode result, int sharingID) {
|
||||
// TODO Auto-generated method stub
|
||||
super.didRevokeDeviceSharing(result, sharingID);
|
||||
|
||||
if (result.ordinal() == 0) {
|
||||
GizDeviceSharing.getDeviceSharingInfos(token, GizDeviceSharingType.GizDeviceSharingByMe, deviceid);
|
||||
} else {
|
||||
|
||||
Toast.makeText(SharedDeviceManagerActivity.this, toastError(result), 1).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
// 初始化tab标签中应该显示的文字
|
||||
private void initData() {
|
||||
productname = getIntent().getStringExtra("productname");
|
||||
deviceid = getIntent().getStringExtra("deviceid");
|
||||
isgetsharing = getIntent().getBooleanExtra("isgetsharing", false);
|
||||
|
||||
tabList = new ArrayList<String>();
|
||||
tabList.add(getResources().getString(R.string.sharedstated));
|
||||
tabList.add(getResources().getString(R.string.boundusers));
|
||||
|
||||
SharedStateFragment shared = new SharedStateFragment();
|
||||
|
||||
SharedUserFragment shared1 = new SharedUserFragment();
|
||||
|
||||
myfragmentlist = new ArrayList<Fragment>();
|
||||
|
||||
myfragmentlist.add(shared);
|
||||
myfragmentlist.add(shared1);
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
|
||||
ViewPagerIndicator indicator = (ViewPagerIndicator) findViewById(
|
||||
R.id.vpi_indicator);
|
||||
|
||||
indicator.setVisibleTabCount(2);
|
||||
indicator.setTabItemTitles(tabList);
|
||||
NoScrollViewPager vp_shared = (NoScrollViewPager) findViewById(
|
||||
R.id.vp_shared_list);
|
||||
|
||||
vp_shared.setNoScroll(true);
|
||||
|
||||
vp_shared.setAdapter(new myFragmentAdapter(getSupportFragmentManager()));
|
||||
|
||||
indicator.setViewPager(vp_shared, 0);
|
||||
indicator.setOnPageChangeListener(new ViewPagerIndicator.PageChangeListener() {
|
||||
|
||||
@Override
|
||||
public void onPageSelected(int position) {
|
||||
|
||||
viewPagerSelected = position;
|
||||
|
||||
if (position == 0 && isgetsharing) {
|
||||
SharedPreferences spf = getSharedPreferences("set", Context.MODE_PRIVATE);
|
||||
String token = spf.getString("Token", "");
|
||||
GizDeviceSharing.getDeviceSharingInfos(token, GizDeviceSharingType.GizDeviceSharingByMe, deviceid);
|
||||
|
||||
} else if (position == 1 && isgetsharing) {
|
||||
SharedStateFragment fragment3 = (SharedStateFragment) myfragmentlist.get(0);
|
||||
Message msg = new Message();
|
||||
msg.what = 2;
|
||||
fragment3.handler.sendMessage(msg);
|
||||
SharedPreferences spf = getSharedPreferences("set", Context.MODE_PRIVATE);
|
||||
String token = spf.getString("Token", "");
|
||||
GizDeviceSharing.getBindingUsers(token, deviceid);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageScrollStateChanged(int state) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
class myFragmentAdapter extends FragmentStatePagerAdapter {
|
||||
|
||||
public myFragmentAdapter(FragmentManager fm) {
|
||||
super(fm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Fragment getItem(int arg0) {
|
||||
|
||||
Bundle b = new Bundle();
|
||||
b.putString("productname", productname);
|
||||
b.putString("deviceid", deviceid);
|
||||
|
||||
Fragment fragment = myfragmentlist.get(arg0);
|
||||
|
||||
fragment.setArguments(b);
|
||||
|
||||
return fragment;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return myfragmentlist.size();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
|
||||
finish();
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
// 刷新menu的方法
|
||||
private void refreshMenu() {
|
||||
// 核心是Activity这个方法
|
||||
supportInvalidateOptionsMenu();
|
||||
}
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
package com.gizwits.opensource.appkit.sharingdevice;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.gizwits.opensource.appkit.CommonModule.GosBaseActivity;
|
||||
import com.gizwits.opensource.appkit.R;
|
||||
|
||||
|
||||
public class addSharedActivity extends GosBaseActivity {
|
||||
|
||||
private String productname;
|
||||
private String did;
|
||||
private LinearLayout devicetwoshared;
|
||||
private LinearLayout usershared;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setContentView(R.layout.activity_gos_addshared);
|
||||
setToolBar(true, R.string.addshared);
|
||||
|
||||
initData();
|
||||
initView();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
usershared = (LinearLayout) findViewById(R.id.usershared);
|
||||
devicetwoshared = (LinearLayout) findViewById(R.id.devicetwoshared);
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
Intent tent = getIntent();
|
||||
productname = tent.getStringExtra("productname");
|
||||
did = tent.getStringExtra("did");
|
||||
}
|
||||
|
||||
// personalCenter_deviceSharing_qrcode-false-start
|
||||
// 二维码分享
|
||||
public void devicetwoshared(View v) {
|
||||
Intent tent = new Intent(this, twoSharedActivity.class);
|
||||
tent.putExtra("productname", productname);
|
||||
tent.putExtra("did", did);
|
||||
startActivity(tent);
|
||||
|
||||
devicetwoshared.setEnabled(false);
|
||||
devicetwoshared.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
devicetwoshared.setEnabled(true);
|
||||
}
|
||||
}, 1000);
|
||||
|
||||
}
|
||||
//personalCenter_deviceSharing_qrcode-false-end
|
||||
|
||||
// 用户账号分享
|
||||
|
||||
public void usershared(View v) {
|
||||
|
||||
Intent tent = new Intent(this, userSharedActivity.class);
|
||||
tent.putExtra("productname", productname);
|
||||
tent.putExtra("did", did);
|
||||
startActivity(tent);
|
||||
|
||||
usershared.setEnabled(false);
|
||||
usershared.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
usershared.setEnabled(true);
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
this.finish();
|
||||
break;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
@ -0,0 +1,276 @@
|
||||
package com.gizwits.opensource.appkit.sharingdevice;
|
||||
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gizwits.gizwifisdk.api.GizDeviceSharing;
|
||||
import com.gizwits.gizwifisdk.api.GizMessage;
|
||||
import com.gizwits.gizwifisdk.enumration.GizMessageStatus;
|
||||
import com.gizwits.gizwifisdk.enumration.GizMessageType;
|
||||
import com.gizwits.gizwifisdk.enumration.GizWifiErrorCode;
|
||||
import com.gizwits.gizwifisdk.listener.GizDeviceSharingListener;
|
||||
import com.gizwits.opensource.appkit.CommonModule.GosBaseActivity;
|
||||
import com.gizwits.opensource.appkit.R;
|
||||
import com.gizwits.opensource.appkit.utils.DateUtil;
|
||||
import com.gizwits.opensource.appkit.view.SlideListView2;
|
||||
import com.gizwits.opensource.appkit.view.VerticalSwipeRefreshLayout;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
public class deviceSharedMessageActivity extends GosBaseActivity implements SwipeRefreshLayout.OnRefreshListener {
|
||||
|
||||
private List<GizMessage> mymessageList = new ArrayList<GizMessage>();
|
||||
private myadapter myadapter;
|
||||
private String token;
|
||||
private String myid = "";
|
||||
private int myposition = -1;
|
||||
// 删除时需要用到的对话框
|
||||
private ProgressDialog progressDialog;
|
||||
private TextView tvNoMessage;
|
||||
private VerticalSwipeRefreshLayout mSwipeLayout;
|
||||
|
||||
Handler handler = new Handler() {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
switch (msg.what) {
|
||||
case 1:
|
||||
mSwipeLayout.setRefreshing(false);
|
||||
GizDeviceSharing.queryMessageList(token, GizMessageType.GizMessageSharing);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_device_shared_message_list);
|
||||
setToolBar(true, R.string.devicesharedmess);
|
||||
initView();
|
||||
initData();
|
||||
initProgressBar();
|
||||
}
|
||||
|
||||
private void initProgressBar() {
|
||||
progressDialog = new ProgressDialog(this);
|
||||
String loadingText = getString(R.string.loadingtext);
|
||||
progressDialog.setMessage(loadingText);
|
||||
progressDialog.setCanceledOnTouchOutside(false);
|
||||
}
|
||||
|
||||
// 初始化分享设备的数据
|
||||
private void initData() {
|
||||
//
|
||||
// GizDeviceSharing.setListener(new GizDeviceSharingListener() {
|
||||
//
|
||||
// @Override
|
||||
// public void didQueryMessageList(GizWifiErrorCode result,
|
||||
// List<GizMessage> messageList) {
|
||||
// super.didQueryMessageList(result, messageList);
|
||||
//
|
||||
// mymessageList = messageList;
|
||||
// myadapter.notifyDataSetChanged();
|
||||
// }
|
||||
//
|
||||
// });
|
||||
token = spf.getString("Token", "");
|
||||
GizDeviceSharing.queryMessageList(token, GizMessageType.GizMessageSharing);
|
||||
// GizDeviceSharing.queryMessageList(token,
|
||||
// GizMessageType.GizMessageSystem);
|
||||
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
|
||||
SlideListView2 devicelist = (SlideListView2) findViewById(R.id.devicelist);
|
||||
tvNoMessage = (TextView) findViewById(R.id.tvNoMessage);
|
||||
devicelist.initSlideMode(SlideListView2.MOD_RIGHT);
|
||||
|
||||
myadapter = new myadapter();
|
||||
devicelist.setAdapter(myadapter);
|
||||
|
||||
// 下拉刷新
|
||||
|
||||
mSwipeLayout = (VerticalSwipeRefreshLayout) findViewById(R.id.id_swipe_ly);
|
||||
|
||||
mSwipeLayout.setOnRefreshListener(this);
|
||||
mSwipeLayout.setColorSchemeResources(android.R.color.holo_blue_bright, android.R.color.holo_green_light,
|
||||
android.R.color.holo_orange_light, android.R.color.holo_red_light);
|
||||
|
||||
devicelist.setOnItemClickListener(new OnItemClickListener() {
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
|
||||
|
||||
View redpoint = arg1.findViewById(R.id.redpoint);
|
||||
|
||||
if (redpoint.getVisibility() == 0) {
|
||||
redpoint.setVisibility(View.GONE);
|
||||
GizMessage gizMessage = mymessageList.get(arg2);
|
||||
|
||||
GizDeviceSharing.markMessageStatus(token, gizMessage.getId(), GizMessageStatus.GizMessageRead);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
Message msg = new Message();
|
||||
msg.what = 1;
|
||||
handler.sendMessageDelayed(msg, 2000);
|
||||
}
|
||||
|
||||
class myadapter extends BaseAdapter {
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
|
||||
return mymessageList.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int arg0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int arg0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(final int arg0, View arg1, ViewGroup arg2) {
|
||||
|
||||
View view = View.inflate(deviceSharedMessageActivity.this, R.layout.activity_device_item, null);
|
||||
|
||||
TextView mess = (TextView) view.findViewById(R.id.mess);
|
||||
TextView timemess = (TextView) view.findViewById(R.id.timemess);
|
||||
|
||||
View redpoint = view.findViewById(R.id.redpoint);
|
||||
|
||||
RelativeLayout delete2 = (RelativeLayout) view.findViewById(R.id.delete2);
|
||||
|
||||
delete2.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View c) {
|
||||
GizMessage gizMessage = mymessageList.get(arg0);
|
||||
|
||||
String id = gizMessage.getId();
|
||||
myid = id;
|
||||
myposition = arg0;
|
||||
GizDeviceSharing.markMessageStatus(token, gizMessage.getId(), GizMessageStatus.GizMessageDeleted);
|
||||
progressDialog.show();
|
||||
}
|
||||
});
|
||||
|
||||
GizMessage gizMessage = mymessageList.get(arg0);
|
||||
|
||||
mess.setText(gizMessage.getContent());
|
||||
|
||||
timemess.setText(DateUtil.utc2Local(gizMessage.getUpdatedAt()));
|
||||
|
||||
int ordinal = gizMessage.getStatus().ordinal();
|
||||
|
||||
if (ordinal == 0) {
|
||||
redpoint.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
redpoint.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
finish();
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
//GizDeviceSharing.queryMessageList
|
||||
|
||||
GizDeviceSharing.setListener(new GizDeviceSharingListener() {
|
||||
|
||||
@Override
|
||||
public void didMarkMessageStatus(GizWifiErrorCode result, String messageID) {
|
||||
super.didMarkMessageStatus(result, messageID);
|
||||
|
||||
if (result.ordinal() == 0 && myid.equals(messageID)) {
|
||||
|
||||
if (mymessageList.size() > myposition && myposition != -1) {
|
||||
|
||||
GizDeviceSharing.queryMessageList(token, GizMessageType.GizMessageSharing);
|
||||
}
|
||||
} else {
|
||||
|
||||
if (progressDialog != null && progressDialog.isShowing()) {
|
||||
progressDialog.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void didQueryMessageList(GizWifiErrorCode result, List<GizMessage> messageList) {
|
||||
super.didQueryMessageList(result, messageList);
|
||||
|
||||
if (messageList != null) {
|
||||
Collections.sort(messageList, new Comparator<GizMessage>() {
|
||||
|
||||
@Override
|
||||
public int compare(GizMessage arg0, GizMessage arg1) {
|
||||
|
||||
String updatedAt = DateUtil.utc2Local(arg0.getUpdatedAt());
|
||||
String updatedAt2 = DateUtil.utc2Local(arg1.getUpdatedAt());
|
||||
|
||||
int diff = (int) DateUtil.getDiff(updatedAt2, updatedAt);
|
||||
|
||||
return diff;
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
if (progressDialog.isShowing()) {
|
||||
progressDialog.cancel();
|
||||
}
|
||||
mymessageList = messageList;
|
||||
if (mymessageList.size() != 0) {
|
||||
tvNoMessage.setVisibility(View.GONE);
|
||||
}
|
||||
myadapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,235 @@
|
||||
package com.gizwits.opensource.appkit.sharingdevice;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.gizwits.gizwifisdk.api.GizDeviceSharing;
|
||||
import com.gizwits.gizwifisdk.enumration.GizWifiErrorCode;
|
||||
import com.gizwits.gizwifisdk.listener.GizDeviceSharingListener;
|
||||
import com.gizwits.opensource.appkit.CommonModule.GosBaseActivity;
|
||||
import com.gizwits.opensource.appkit.R;
|
||||
import com.gizwits.opensource.appkit.utils.DateUtil;
|
||||
|
||||
public class gosZxingDeviceSharingActivity extends GosBaseActivity {
|
||||
|
||||
private String code;
|
||||
private int time = 15;
|
||||
private String[] split2s;
|
||||
private String tip;
|
||||
private TextView tiptext;
|
||||
private String token;
|
||||
private Button yes;
|
||||
private Button no;
|
||||
private TextView zxingtext;
|
||||
private String whoshared;
|
||||
private String[] splits;
|
||||
private String userName;
|
||||
private String productName;
|
||||
private String deviceAlias;
|
||||
private String expiredAt;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setContentView(R.layout.gos_devicesharing_zxing_activity);
|
||||
setToolBar(true, R.string.QR_code);
|
||||
initData();
|
||||
initView();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
|
||||
zxingtext = (TextView) findViewById(R.id.zxingtext);
|
||||
|
||||
yes = (Button) findViewById(R.id.yes);
|
||||
|
||||
no = (Button) findViewById(R.id.no);
|
||||
|
||||
whoshared = getResources().getString(R.string.whoshared);
|
||||
|
||||
splits = whoshared.split("xxx");
|
||||
// [, 向你共享, ,你接受并绑定设备吗?]
|
||||
whoshared = userName + splits[1] + productName + splits[splits.length - 1];
|
||||
zxingtext.setText(whoshared);
|
||||
|
||||
String timeByFormat = DateUtil.getCurTimeByFormat("yyyy-MM-dd HH:mm:ss");
|
||||
expiredAt = DateUtil.utc2Local(expiredAt);
|
||||
long diff = DateUtil.getDiff(expiredAt, timeByFormat);
|
||||
if (diff >= 0) {
|
||||
double c = diff / 60.0;
|
||||
time = (int) Math.ceil(c);
|
||||
} else {
|
||||
tiptext.setText(getResources().getString(R.string.requestoutoftime));
|
||||
yes.setClickable(false);
|
||||
yes.setTextColor(getResources().getColor(R.color.gray));
|
||||
return;
|
||||
}
|
||||
tiptext = (TextView) findViewById(R.id.tiptext);
|
||||
tip = getResources().getString(R.string.tipthings);
|
||||
split2s = tip.split("xx");
|
||||
|
||||
tip = split2s[0] + time + split2s[1];
|
||||
|
||||
tiptext.setText(tip);
|
||||
|
||||
hand.sendEmptyMessageDelayed(1, diff % 60 * 1000);
|
||||
|
||||
yes.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
GizDeviceSharing.acceptDeviceSharingByQRCode(spf.getString("Token", ""), code);
|
||||
}
|
||||
});
|
||||
|
||||
no.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
|
||||
Intent intent = getIntent();
|
||||
code = intent.getStringExtra("code");
|
||||
userName = intent.getStringExtra("userName");
|
||||
productName = intent.getStringExtra("productName");
|
||||
deviceAlias = intent.getStringExtra("deviceAlias");
|
||||
expiredAt = intent.getStringExtra("expiredAt");
|
||||
|
||||
token = spf.getString("Token", "");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
if (time > 0) {
|
||||
tip = split2s[0] + time + split2s[1];
|
||||
|
||||
tiptext.setText(tip);
|
||||
} else {
|
||||
tiptext.setText(getResources().getString(R.string.requestoutoftime));
|
||||
yes.setClickable(false);
|
||||
yes.setTextColor(getResources().getColor(R.color.gray));
|
||||
}
|
||||
|
||||
GizDeviceSharing.setListener(new GizDeviceSharingListener() {
|
||||
|
||||
@Override
|
||||
public void didAcceptDeviceSharing(GizWifiErrorCode result, int sharingID) {
|
||||
super.didAcceptDeviceSharing(result, sharingID);
|
||||
if (result.ordinal() == 0) {
|
||||
finish();
|
||||
} else {
|
||||
Toast.makeText(gosZxingDeviceSharingActivity.this, toastError(result), 1).show();
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void didAcceptDeviceSharingByQRCode(GizWifiErrorCode result) {
|
||||
super.didAcceptDeviceSharingByQRCode(result);
|
||||
if (result.ordinal() == 0) {
|
||||
Toast.makeText(gosZxingDeviceSharingActivity.this, "success", 1).show();
|
||||
|
||||
finish();
|
||||
} else {
|
||||
Toast.makeText(gosZxingDeviceSharingActivity.this, toastError(result), 1).show();
|
||||
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void didCheckDeviceSharingInfoByQRCode(GizWifiErrorCode result, String userName, String productName,
|
||||
String deviceAlias, String expiredAt) {
|
||||
super.didCheckDeviceSharingInfoByQRCode(result, userName, productName, deviceAlias, expiredAt);
|
||||
|
||||
int errorcode = result.ordinal();
|
||||
|
||||
if (8041 <= errorcode && errorcode <= 8050 || errorcode == 8308) {
|
||||
tiptext.setVisibility(View.GONE);
|
||||
yes.setClickable(false);
|
||||
no.setClickable(false);
|
||||
yes.setTextColor(getResources().getColor(R.color.gray));
|
||||
no.setTextColor(getResources().getColor(R.color.gray));
|
||||
zxingtext.setText(getResources().getString(R.string.sorry));
|
||||
} else if (errorcode != 0) {
|
||||
tiptext.setVisibility(View.GONE);
|
||||
yes.setClickable(false);
|
||||
no.setClickable(false);
|
||||
yes.setTextColor(getResources().getColor(R.color.gray));
|
||||
no.setTextColor(getResources().getColor(R.color.gray));
|
||||
zxingtext.setText(getResources().getString(R.string.verysorry));
|
||||
} else {
|
||||
tiptext.setVisibility(View.VISIBLE);
|
||||
yes.setClickable(true);
|
||||
no.setClickable(true);
|
||||
yes.setTextColor(getResources().getColor(R.color.text_color));
|
||||
no.setTextColor(getResources().getColor(R.color.text_color));
|
||||
|
||||
whoshared = userName + splits[1] + productName + splits[splits.length - 1];
|
||||
zxingtext.setText(whoshared);
|
||||
|
||||
String timeByFormat = DateUtil.getCurTimeByFormat("yyyy-MM-dd HH:mm:ss");
|
||||
expiredAt = DateUtil.utc2Local(expiredAt);
|
||||
long diff = DateUtil.getDiff(expiredAt, timeByFormat);
|
||||
|
||||
if (diff >= 0) {
|
||||
time = (int) Math.ceil(diff / 60);
|
||||
} else {
|
||||
|
||||
}
|
||||
Toast.makeText(gosZxingDeviceSharingActivity.this, diff % 60 + "", 1).show();
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
Handler hand = new Handler() {
|
||||
public void handleMessage(android.os.Message msg) {
|
||||
|
||||
time = time - 1;
|
||||
|
||||
if (time > 0) {
|
||||
tip = split2s[0] + time + split2s[1];
|
||||
|
||||
tiptext.setText(tip);
|
||||
hand.sendEmptyMessageDelayed(1, 60000);
|
||||
} else {
|
||||
tiptext.setText(getResources().getString(R.string.requestoutoftime));
|
||||
yes.setClickable(false);
|
||||
yes.setTextColor(getResources().getColor(R.color.gray));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
;
|
||||
};
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
this.finish();
|
||||
break;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,175 @@
|
||||
package com.gizwits.opensource.appkit.sharingdevice;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gizwits.gizwifisdk.api.GizDeviceSharing;
|
||||
import com.gizwits.gizwifisdk.enumration.GizDeviceSharingWay;
|
||||
import com.gizwits.gizwifisdk.enumration.GizWifiErrorCode;
|
||||
import com.gizwits.gizwifisdk.listener.GizDeviceSharingListener;
|
||||
import com.gizwits.opensource.appkit.CommonModule.GosBaseActivity;
|
||||
import com.gizwits.opensource.appkit.R;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
public class twoSharedActivity extends GosBaseActivity {
|
||||
|
||||
private String productname;
|
||||
private String did;
|
||||
private ImageView myimage;
|
||||
private TextView timeout;
|
||||
private TextView bottomtext;
|
||||
private int time = 15;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setContentView(R.layout.activity_gos_two_shared);
|
||||
|
||||
setToolBar(true, R.string.scan_code_sharing);
|
||||
|
||||
initData();
|
||||
initView();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
TextView usersharedtext = (TextView) findViewById(R.id.usersharedtext);
|
||||
|
||||
myimage = (ImageView) findViewById(R.id.myimageview);
|
||||
|
||||
timeout = (TextView) findViewById(R.id.timeout);
|
||||
|
||||
timeout2 = splits[0] + time + splits[1];
|
||||
|
||||
timeout.setText(timeout2);
|
||||
|
||||
bottomtext = (TextView) findViewById(R.id.bottomtext);
|
||||
|
||||
usersharedtext.setText(getResources().getString(R.string.shared) + " " + productname
|
||||
+ getResources().getString(R.string.friends));
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
|
||||
Intent tent = getIntent();
|
||||
productname = tent.getStringExtra("productname");
|
||||
did = tent.getStringExtra("did");
|
||||
|
||||
timeout2 = getResources().getString(R.string.zxingtimeout);
|
||||
splits = timeout2.split("15");
|
||||
GizDeviceSharing.sharingDevice(spf.getString("Token", ""), did, GizDeviceSharingWay.GizDeviceSharingByQRCode,
|
||||
null, null);
|
||||
|
||||
}
|
||||
|
||||
private void startTimer() {
|
||||
timer = new Timer();
|
||||
timer.schedule(new TimerTask() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
time = time - 1;
|
||||
hand.sendEmptyMessage(1);
|
||||
}
|
||||
}, 60000, 60000);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
if (time > 0) {
|
||||
timeout2 = splits[0] + time + splits[1];
|
||||
|
||||
timeout.setText(timeout2);
|
||||
} else {
|
||||
timeout.setText(getResources().getString(R.string.twofailed));
|
||||
}
|
||||
GizDeviceSharing.setListener(new GizDeviceSharingListener() {
|
||||
|
||||
@Override
|
||||
public void didSharingDevice(GizWifiErrorCode result, String deviceID, int sharingID,
|
||||
Bitmap QRCodeImage) {
|
||||
super.didSharingDevice(result, deviceID, sharingID, QRCodeImage);
|
||||
|
||||
if (QRCodeImage != null) {
|
||||
myimage.setImageBitmap(QRCodeImage);
|
||||
bottomtext.setVisibility(View.VISIBLE);
|
||||
|
||||
// hand.sendEmptyMessageDelayed(1, 60000);
|
||||
startTimer();
|
||||
} else {
|
||||
int errorcode = result.ordinal();
|
||||
|
||||
if (8041 <= errorcode && errorcode <= 8050 || errorcode == 8308) {
|
||||
|
||||
timeout.setText(getResources().getString(R.string.twosharedtimeout));
|
||||
bottomtext.setVisibility(View.GONE);
|
||||
|
||||
} else {
|
||||
timeout.setText(getResources().getString(R.string.sharedfailed));
|
||||
bottomtext.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
|
||||
finish();
|
||||
break;
|
||||
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
Handler hand = new Handler() {
|
||||
public void handleMessage(android.os.Message msg) {
|
||||
|
||||
// time = time - 1;
|
||||
|
||||
if (time > 0) {
|
||||
timeout2 = splits[0] + time + splits[1];
|
||||
|
||||
timeout.setText(timeout2);
|
||||
// hand.sendEmptyMessageDelayed(1, 60000);
|
||||
} else {
|
||||
timeout.setText(getResources().getString(R.string.twofailed));
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
// TODO Auto-generated method stub
|
||||
super.onDestroy();
|
||||
|
||||
time = 15;
|
||||
|
||||
hand.removeMessages(1);
|
||||
if (timer != null) {
|
||||
timer.cancel();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private String timeout2;
|
||||
private String[] splits;
|
||||
private Timer timer;
|
||||
}
|
@ -0,0 +1,145 @@
|
||||
package com.gizwits.opensource.appkit.sharingdevice;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.gizwits.gizwifisdk.api.GizDeviceSharing;
|
||||
import com.gizwits.gizwifisdk.enumration.GizDeviceSharingWay;
|
||||
import com.gizwits.gizwifisdk.enumration.GizUserAccountType;
|
||||
import com.gizwits.gizwifisdk.enumration.GizWifiErrorCode;
|
||||
import com.gizwits.gizwifisdk.listener.GizDeviceSharingListener;
|
||||
import com.gizwits.opensource.appkit.CommonModule.GosBaseActivity;
|
||||
import com.gizwits.opensource.appkit.CommonModule.GosDeploy;
|
||||
import com.gizwits.opensource.appkit.CommonModule.TipsDialog;
|
||||
import com.gizwits.opensource.appkit.R;
|
||||
|
||||
public class userSharedActivity extends GosBaseActivity {
|
||||
|
||||
private String productname;
|
||||
private EditText username;
|
||||
private int chooseitem = 0;
|
||||
private String did;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
// TODO Auto-generated method stub
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_gos_user_shared);
|
||||
|
||||
setToolBar(true, R.string.account_shared);
|
||||
|
||||
initData();
|
||||
initView();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
TextView usersharedtext = (TextView) findViewById(R.id.usersharedtext);
|
||||
Button button = (Button) findViewById(R.id.button);
|
||||
button.setBackgroundDrawable(GosDeploy.appConfig_BackgroundColor());
|
||||
button.setTextColor(GosDeploy.appConfig_Contrast());
|
||||
|
||||
username = (EditText) findViewById(R.id.username);
|
||||
usersharedtext.setText(
|
||||
getResources().getString(R.string.shared) + productname + getResources().getString(R.string.friends));
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
|
||||
Intent tent = getIntent();
|
||||
productname = tent.getStringExtra("productname");
|
||||
did = tent.getStringExtra("did");
|
||||
}
|
||||
|
||||
public void usershared(View v) {
|
||||
|
||||
final String usernametext = username.getText().toString();
|
||||
if (TextUtils.isEmpty(usernametext)) {
|
||||
|
||||
// Toast.makeText(this,
|
||||
// getResources().getString(R.string.toast_name_empet), 0).show();
|
||||
|
||||
TipsDialog dia = new TipsDialog(this, getResources().getString(R.string.toast_name_empet));
|
||||
dia.show();
|
||||
return;
|
||||
}
|
||||
|
||||
SharedPreferences spf = getSharedPreferences("set", Context.MODE_PRIVATE);
|
||||
String token = spf.getString("Token", "");
|
||||
if (usernametext.length() < 32) {
|
||||
if (usernametext.matches("[0-9]+")) {
|
||||
GizDeviceSharing.sharingDevice(token, did, GizDeviceSharingWay.GizDeviceSharingByNormal, usernametext,
|
||||
GizUserAccountType.GizUserPhone);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
if (usernametext.contains("@")) {
|
||||
GizDeviceSharing.sharingDevice(token, did, GizDeviceSharingWay.GizDeviceSharingByNormal, usernametext,
|
||||
GizUserAccountType.GizUserEmail);
|
||||
return;
|
||||
}
|
||||
if (usernametext.length() == 32) {
|
||||
if (usernametext.matches("[a-zA-Z0-9]+")) {
|
||||
GizDeviceSharing.sharingDevice(token, did, GizDeviceSharingWay.GizDeviceSharingByNormal, usernametext,
|
||||
GizUserAccountType.GizUserOther);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
Toast.makeText(this, getString(R.string.account_incorrect), Toast.LENGTH_LONG).show();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
GizDeviceSharing.setListener(new GizDeviceSharingListener() {
|
||||
|
||||
@Override
|
||||
public void didSharingDevice(GizWifiErrorCode result, String deviceID, int sharingID,
|
||||
Bitmap QRCodeImage) {
|
||||
super.didSharingDevice(result, deviceID, sharingID, QRCodeImage);
|
||||
|
||||
if (result.ordinal() == 0) {
|
||||
Toast.makeText(userSharedActivity.this, getResources().getString(R.string.alawyssend), 1).show();
|
||||
finish();
|
||||
} else if (result == GizWifiErrorCode.GIZ_OPENAPI_GUEST_ALREADY_BOUND) {
|
||||
Toast.makeText(userSharedActivity.this, getResources().getString(R.string.account_shared2), toastTime).show();
|
||||
} else if (result == GizWifiErrorCode.GIZ_OPENAPI_NOT_FOUND_GUEST) {
|
||||
Toast.makeText(userSharedActivity.this, getResources().getString(R.string.user_not_exist), toastTime).show();
|
||||
} else if (result == GizWifiErrorCode.GIZ_OPENAPI_CANNOT_SHARE_TO_SELF) {
|
||||
Toast.makeText(userSharedActivity.this, getResources().getString(R.string.not_shared_self), toastTime).show();
|
||||
} else {
|
||||
Toast.makeText(userSharedActivity.this, getResources().getString(R.string.send_failed1), 2).show();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
|
||||
finish();
|
||||
break;
|
||||
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
package com.gizwits.opensource.appkit.utils;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class HexStrUtils {
|
||||
|
||||
public static byte[] hexStringToBytes(String hexString) {
|
||||
if (hexString == null || hexString.equals("")) {
|
||||
return null;
|
||||
}
|
||||
hexString = hexString.toUpperCase(Locale.getDefault());
|
||||
int length = hexString.length() / 2;
|
||||
char[] hexChars = hexString.toCharArray();
|
||||
byte[] d = new byte[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
int pos = i * 2;
|
||||
d[i] = (byte) (charToByte(hexChars[pos]) << 4 | charToByte(hexChars[pos + 1]));
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
private static byte charToByte(char c) {
|
||||
return (byte) "0123456789ABCDEF".indexOf(c);
|
||||
}
|
||||
|
||||
/**
|
||||
* 数组转换成十六进制字符串
|
||||
*
|
||||
* @param byte[]
|
||||
* @return HexString
|
||||
*/
|
||||
public static final String bytesToHexString(byte[] bArray) {
|
||||
if (bArray == null) {
|
||||
return "";
|
||||
}
|
||||
StringBuffer sb = new StringBuffer(bArray.length);
|
||||
String sTemp;
|
||||
for (int i = 0; i < bArray.length; i++) {
|
||||
sTemp = Integer.toHexString(0xFF & bArray[i]);
|
||||
if (sTemp.length() < 2)
|
||||
sb.append(0);
|
||||
sb.append(sTemp.toUpperCase(Locale.getDefault()));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static final String splitBytesString(String byteString) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < byteString.length(); i++) {
|
||||
sb.append(byteString.charAt(i));
|
||||
if (sb.length() % 3 == 0 && sb.charAt(sb.length() - 1) != ' ') {
|
||||
sb.insert(sb.length() - 1, ' ');
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
package com.gizwits.opensource.appkit.utils;
|
||||
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.v4.graphics.drawable.DrawableCompat;
|
||||
|
||||
public class SkxDrawableHelper {
|
||||
|
||||
/**
|
||||
* 对目标Drawable 进行着色
|
||||
*
|
||||
* @param drawable 目标Drawable
|
||||
* @param color 着色的颜色值
|
||||
* @return 着色处理后的Drawable
|
||||
*/
|
||||
public static Drawable tintDrawable(Drawable drawable, int color) {
|
||||
// 获取此drawable的共享状态实例
|
||||
Drawable wrappedDrawable = getCanTintDrawable(drawable);
|
||||
// 进行着色
|
||||
DrawableCompat.setTint(wrappedDrawable, color);
|
||||
return wrappedDrawable;
|
||||
}
|
||||
|
||||
/**
|
||||
* 对目标Drawable 进行着色。
|
||||
* 通过ColorStateList 指定单一颜色
|
||||
*
|
||||
* @param drawable 目标Drawable
|
||||
* @param color 着色值
|
||||
* @return 着色处理后的Drawable
|
||||
*/
|
||||
public static Drawable tintListDrawable(Drawable drawable, int color) {
|
||||
return tintListDrawable(drawable, ColorStateList.valueOf(color));
|
||||
}
|
||||
|
||||
/**
|
||||
* 对目标Drawable 进行着色
|
||||
*
|
||||
* @param drawable 目标Drawable
|
||||
* @param colors 着色值
|
||||
* @return 着色处理后的Drawable
|
||||
*/
|
||||
public static Drawable tintListDrawable( Drawable drawable, ColorStateList colors) {
|
||||
Drawable wrappedDrawable = getCanTintDrawable(drawable);
|
||||
// 进行着色
|
||||
DrawableCompat.setTintList(wrappedDrawable, colors);
|
||||
return wrappedDrawable;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取可以进行tint 的Drawable
|
||||
* <p>
|
||||
* 对原drawable进行重新实例化 newDrawable()
|
||||
* 包装 warp()
|
||||
* 可变操作 mutate()
|
||||
*
|
||||
* @param drawable 原始drawable
|
||||
* @return 可着色的drawable
|
||||
*/
|
||||
private static Drawable getCanTintDrawable(Drawable drawable) {
|
||||
// 获取此drawable的共享状态实例
|
||||
Drawable.ConstantState state = drawable.getConstantState();
|
||||
// 对drawable 进行重新实例化、包装、可变操作
|
||||
return DrawableCompat.wrap(state == null ? drawable : state.newDrawable()).mutate();
|
||||
}
|
||||
}
|
@ -0,0 +1,146 @@
|
||||
package com.gizwits.opensource.appkit.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.gizwits.opensource.appkit.CommonModule.GosDeploy;
|
||||
import com.gizwits.opensource.appkit.R;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by admin on 2017/7/25.
|
||||
*/
|
||||
|
||||
public class ToolUtils {
|
||||
public static float getHue(int color) {
|
||||
float[] HSV = new float[3];
|
||||
Color.colorToHSV(color, HSV);
|
||||
return (HSV[0] * 255 / 360);
|
||||
}
|
||||
|
||||
public static int getInnerColor(float hue) {
|
||||
float[] HSV = new float[3];
|
||||
HSV[0] = hue * 360 / 255;
|
||||
HSV[1] = 255;
|
||||
HSV[2] = 255;
|
||||
return Color.HSVToColor(HSV);
|
||||
}
|
||||
|
||||
private static long lastClickTime = 0;
|
||||
public static final int MIN_CLICK_DELAY_TIME = 800;
|
||||
|
||||
public static boolean noDoubleClick() {
|
||||
long currentTime = Calendar.getInstance().getTimeInMillis();
|
||||
if (currentTime - lastClickTime > MIN_CLICK_DELAY_TIME) {
|
||||
lastClickTime = currentTime;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static List<Map<String, Object>> parseJson(Context context, String str) throws JSONException {
|
||||
if (str == null || str.equals("")) {
|
||||
Toast.makeText(context, context.getString(R.string.download_fail), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
JSONObject uiJsonObject = new JSONObject(str);
|
||||
JSONObject jsonObject = uiJsonObject.has("object") ? uiJsonObject.getJSONObject("object") : null;
|
||||
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
|
||||
if (uiJsonObject != null) {
|
||||
JSONArray sessionJsonArrays = uiJsonObject.getJSONArray("sections");
|
||||
if (sessionJsonArrays != null) {
|
||||
for (int i = 0; i < sessionJsonArrays.length(); i++) {
|
||||
JSONObject session = sessionJsonArrays.getJSONObject(i);
|
||||
JSONArray elementjJsonArray = session.getJSONArray("elements");
|
||||
if (elementjJsonArray != null) {
|
||||
for (int j = 0; j < elementjJsonArray.length(); j++) {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
JSONObject elementObject = elementjJsonArray.getJSONObject(j);
|
||||
String type = elementObject.getString("type");
|
||||
String title = elementObject.has("title") ? elementObject.getString("title") : "";
|
||||
map.put("title", title);
|
||||
map.put("type", type);
|
||||
String value = null;
|
||||
if (type.equals("QBooleanElement")) {
|
||||
value = elementObject.has("boolValue") ? elementObject.getString("boolValue") : "";
|
||||
} else if (type.equals("QFloatElement")) {
|
||||
value = elementObject.has("value") ? elementObject.getString("value") : "";
|
||||
}
|
||||
map.put("value", value);
|
||||
list.add(map);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public static Drawable editIconAlpha(Resources res, int id) {
|
||||
int color = GosDeploy.appConfig_Contrast();
|
||||
Drawable drawable = SkxDrawableHelper.tintDrawable(res.getDrawable(id), color);
|
||||
drawable.setAlpha(60);
|
||||
return drawable;
|
||||
}
|
||||
|
||||
public static Drawable editIcon(Resources res, int id) {
|
||||
int color = GosDeploy.appConfig_Contrast();
|
||||
return SkxDrawableHelper.tintDrawable(res.getDrawable(id), color);
|
||||
}
|
||||
|
||||
public static int editTextAlpha() {
|
||||
int color = GosDeploy.appConfig_Contrast();
|
||||
int red = Color.red(color);
|
||||
int green = Color.green(color);
|
||||
int blue = Color.blue(color);
|
||||
int color1 = Color.argb(160, red, green, blue);
|
||||
return color1;
|
||||
}
|
||||
|
||||
public static int editStatusBarColor(int color) {
|
||||
int red = Color.red(color);
|
||||
int green = Color.green(color);
|
||||
int blue = Color.blue(color);
|
||||
int color1 = Color.argb(255, red, green, blue);
|
||||
return color1;
|
||||
}
|
||||
// // 需要点击几次 就设置几
|
||||
// static long[] mHits = null;
|
||||
// //public static boolean mShow = false;
|
||||
//
|
||||
// public static void onDisplaySettingButton() {
|
||||
// if (mHits == null) {
|
||||
// mHits = new long[5];
|
||||
// }
|
||||
// System.arraycopy(mHits, 1, mHits, 0, mHits.length - 1);//把从第二位至最后一位之间的数字复制到第一位至倒数第一位
|
||||
// mHits[mHits.length - 1] = SystemClock.uptimeMillis();//记录一个时间
|
||||
// if (SystemClock.uptimeMillis() - mHits[0] <= 1000) {//一秒内连续点击。
|
||||
// mHits = null; //这里说明一下,我们在进来以后需要还原状态,否则如果点击过快,第六次,第七次 都会不断进来触发该效果。重新开始计数即可
|
||||
//// if (mShow) {
|
||||
//// mShow = false;
|
||||
//// } else {
|
||||
//// mShow = true;
|
||||
//// }
|
||||
// mShow = true;
|
||||
// Log.e("Tool", "onDisplaySettingButton: 连点五次进入deploy模式");
|
||||
// //这里一般会把mShow存储到sp中。
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,210 @@
|
||||
package com.gizwits.opensource.appkit.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.inputmethodservice.Keyboard;
|
||||
import android.inputmethodservice.KeyboardView;
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.util.TypedValue;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
|
||||
/**
|
||||
* Created by xud on 2017/3/2.
|
||||
*/
|
||||
|
||||
public abstract class BaseKeyboard extends Keyboard implements KeyboardView.OnKeyboardActionListener {
|
||||
|
||||
private EditText mEditText;
|
||||
|
||||
private View mNextFocusView;
|
||||
|
||||
private KeyStyle mKeyStyle;
|
||||
|
||||
protected Context mContext;
|
||||
|
||||
public BaseKeyboard(Context context, int xmlLayoutResId) {
|
||||
super(context, xmlLayoutResId);
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
public BaseKeyboard(Context context, int xmlLayoutResId, int modeId, int width, int height) {
|
||||
super(context, xmlLayoutResId, modeId, width, height);
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
public BaseKeyboard(Context context, int xmlLayoutResId, int modeId) {
|
||||
super(context, xmlLayoutResId, modeId);
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
public BaseKeyboard(Context context, int layoutTemplateResId, CharSequence characters, int columns, int horizontalPadding) {
|
||||
super(context, layoutTemplateResId, characters, columns, horizontalPadding);
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
public void setEditText(EditText editText) {
|
||||
mEditText = editText;
|
||||
}
|
||||
|
||||
public void setNextFocusView(View nextFocusView) {
|
||||
mNextFocusView = nextFocusView;
|
||||
}
|
||||
|
||||
public void setKeyStyle(KeyStyle keyStyle) {
|
||||
mKeyStyle = keyStyle;
|
||||
}
|
||||
|
||||
public EditText getEditText() {
|
||||
return mEditText;
|
||||
}
|
||||
|
||||
public View getNextFocusView() {
|
||||
return mNextFocusView;
|
||||
}
|
||||
|
||||
public KeyStyle getKeyStyle() {
|
||||
return mKeyStyle;
|
||||
}
|
||||
|
||||
public int getKeyCode( int redId) {
|
||||
return mContext.getResources().getInteger(redId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPress(int primaryCode) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRelease(int primaryCode) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onKey(int primaryCode, int[] keyCodes) {
|
||||
if (null != mEditText && mEditText.hasFocus() && !handleSpecialKey(primaryCode)) {
|
||||
Editable editable = mEditText.getText();
|
||||
int start = mEditText.getSelectionStart();
|
||||
int end = mEditText.getSelectionEnd();
|
||||
if (end > start) {
|
||||
editable.delete(start, end);
|
||||
}
|
||||
if (primaryCode == KEYCODE_DELETE) {
|
||||
if (!TextUtils.isEmpty(editable)) {
|
||||
if (start > 0) {
|
||||
editable.delete(start - 1, start);
|
||||
}
|
||||
}
|
||||
} else if (primaryCode == KEYCODE_CANCEL) {
|
||||
hideKeyboard();
|
||||
} else {
|
||||
editable.insert(start, Character.toString((char) primaryCode));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onText(CharSequence text) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void swipeLeft() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void swipeRight() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void swipeDown() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void swipeUp() {
|
||||
|
||||
}
|
||||
|
||||
public void hideKeyboard() {
|
||||
if (mNextFocusView != null) {
|
||||
mNextFocusView.requestFocus();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param primaryCode
|
||||
* @return true if handle the key
|
||||
* false no handle and dispatch
|
||||
*/
|
||||
public abstract boolean handleSpecialKey(int primaryCode);
|
||||
|
||||
public interface KeyStyle {
|
||||
|
||||
public Drawable getKeyBackound(Key key);
|
||||
|
||||
public Float getKeyTextSize(Key key);
|
||||
|
||||
public Integer getKeyTextColor(Key key);
|
||||
|
||||
public CharSequence getKeyLabel(Key key);
|
||||
}
|
||||
|
||||
public Padding getPadding() {
|
||||
return new Padding(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
public static class DefaultKeyStyle implements KeyStyle {
|
||||
|
||||
@Override
|
||||
public Drawable getKeyBackound(Key key) {
|
||||
return key.iconPreview;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Float getKeyTextSize(Key key) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getKeyTextColor(Key key) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getKeyLabel(Key key) {
|
||||
return key.label;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Padding {
|
||||
public int top;
|
||||
public int left;
|
||||
public int bottom;
|
||||
public int right;
|
||||
|
||||
/**
|
||||
* px
|
||||
*
|
||||
* @param top
|
||||
* @param left
|
||||
* @param bottom
|
||||
* @param right
|
||||
*/
|
||||
public Padding(int top, int left, int bottom, int right) {
|
||||
this.top = top;
|
||||
this.left = left;
|
||||
this.bottom = bottom;
|
||||
this.right = right;
|
||||
}
|
||||
}
|
||||
|
||||
public float convertSpToPixels(Context context, float sp) {
|
||||
float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, sp, context.getResources().getDisplayMetrics());
|
||||
return px;
|
||||
}
|
||||
}
|
@ -0,0 +1,202 @@
|
||||
package com.gizwits.opensource.appkit.view;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.inputmethodservice.Keyboard;
|
||||
import android.inputmethodservice.KeyboardView;
|
||||
import android.os.Build;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.EditText;
|
||||
|
||||
import com.gizwits.opensource.appkit.utils.ReflectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by xud on 2017/3/2.
|
||||
*/
|
||||
|
||||
public class BaseKeyboardView extends KeyboardView {
|
||||
|
||||
private static final String TAG = "BaseKeyboardView";
|
||||
private Drawable rKeyBackground;
|
||||
private int rLabelTextSize;
|
||||
private int rKeyTextSize;
|
||||
private int rKeyTextColor;
|
||||
private float rShadowRadius;
|
||||
private int rShadowColor;
|
||||
|
||||
private Rect rClipRegion;
|
||||
private Keyboard.Key rInvalidatedKey;
|
||||
|
||||
public BaseKeyboardView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init(context, attrs, 0, 0);
|
||||
}
|
||||
|
||||
public BaseKeyboardView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init(context, attrs, defStyleAttr, 0);
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
public BaseKeyboardView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
init(context, attrs, defStyleAttr, defStyleRes);
|
||||
}
|
||||
|
||||
private void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
rKeyBackground = (Drawable) ReflectionUtils.getFieldValue(this, "mKeyBackground");
|
||||
rLabelTextSize = (Integer) ReflectionUtils.getFieldValue(this, "mLabelTextSize");
|
||||
rKeyTextSize = (Integer) ReflectionUtils.getFieldValue(this, "mKeyTextSize");
|
||||
rKeyTextColor = (Integer) ReflectionUtils.getFieldValue(this, "mKeyTextColor");
|
||||
rShadowColor = (Integer) ReflectionUtils.getFieldValue(this, "mShadowColor");
|
||||
rShadowRadius = (Float) ReflectionUtils.getFieldValue(this, "mShadowRadius");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDraw(Canvas canvas) {
|
||||
//说明CustomKeyboardView只针对CustomBaseKeyboard键盘进行重绘,
|
||||
// 且CustomBaseKeyboard必需有设置CustomKeyStyle的回调接口实现, 才进行重绘, 这才有意义
|
||||
if (null == getKeyboard() || !(getKeyboard() instanceof BaseKeyboard) || null == ((BaseKeyboard) getKeyboard()).getKeyStyle()) {
|
||||
super.onDraw(canvas);
|
||||
return;
|
||||
}
|
||||
rClipRegion = (Rect) ReflectionUtils.getFieldValue(this, "mClipRegion");
|
||||
rInvalidatedKey = (Keyboard.Key) ReflectionUtils.getFieldValue(this, "mInvalidatedKey");
|
||||
super.onDraw(canvas);
|
||||
onRefreshKey(canvas);
|
||||
}
|
||||
|
||||
/**
|
||||
* onRefreshKey是对父类的private void onBufferDraw()进行的重写. 只是在对key的绘制过程中进行了重新设置.
|
||||
*
|
||||
* @param canvas
|
||||
*/
|
||||
private void onRefreshKey(Canvas canvas) {
|
||||
final Paint paint = (Paint) ReflectionUtils.getFieldValue(this, "mPaint");
|
||||
final Rect padding = (Rect) ReflectionUtils.getFieldValue(this, "mPadding");
|
||||
|
||||
paint.setColor(rKeyTextColor);
|
||||
final int kbdPaddingLeft = getPaddingLeft();
|
||||
final int kbdPaddingTop = getPaddingTop();
|
||||
Drawable keyBackground = null;
|
||||
|
||||
final Rect clipRegion = rClipRegion;
|
||||
final Keyboard.Key invalidKey = rInvalidatedKey;
|
||||
boolean drawSingleKey = false;
|
||||
if (invalidKey != null && canvas.getClipBounds(clipRegion)) {
|
||||
// Is clipRegion completely contained within the invalidated key?
|
||||
if (invalidKey.x + kbdPaddingLeft - 1 <= clipRegion.left &&
|
||||
invalidKey.y + kbdPaddingTop - 1 <= clipRegion.top &&
|
||||
invalidKey.x + invalidKey.width + kbdPaddingLeft + 1 >= clipRegion.right &&
|
||||
invalidKey.y + invalidKey.height + kbdPaddingTop + 1 >= clipRegion.bottom) {
|
||||
drawSingleKey = true;
|
||||
}
|
||||
}
|
||||
|
||||
//拿到当前键盘被弹起的输入源 和 键盘为每个key的定制实现customKeyStyle
|
||||
EditText etCur = ((BaseKeyboard) getKeyboard()).getEditText();
|
||||
BaseKeyboard.KeyStyle customKeyStyle = ((BaseKeyboard) getKeyboard()).getKeyStyle();
|
||||
|
||||
List<Keyboard.Key> keys = getKeyboard().getKeys();
|
||||
final int keyCount = keys.size();
|
||||
//canvas.drawColor(0x00000000, PorterDuff.Mode.CLEAR);
|
||||
for (int i = 0; i < keyCount; i++) {
|
||||
final Keyboard.Key key = keys.get(i);
|
||||
if (drawSingleKey && invalidKey != key) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//获取为Key自定义的背景, 若没有定制, 使用KeyboardView的默认属性keyBackground设置
|
||||
keyBackground = customKeyStyle.getKeyBackound(key);
|
||||
if (null == keyBackground) {
|
||||
keyBackground = rKeyBackground;
|
||||
}
|
||||
|
||||
int[] drawableState = key.getCurrentDrawableState();
|
||||
keyBackground.setState(drawableState);
|
||||
|
||||
//获取为Key自定义的Label, 若没有定制, 使用xml布局中指定的
|
||||
CharSequence keyLabel = customKeyStyle.getKeyLabel(key);
|
||||
if (null == keyLabel) {
|
||||
keyLabel = key.label;
|
||||
}
|
||||
// Switch the character to uppercase if shift is pressed
|
||||
String label = keyLabel == null ? null : adjustCase(keyLabel).toString();
|
||||
|
||||
final Rect bounds = keyBackground.getBounds();
|
||||
if (key.width != bounds.right ||
|
||||
key.height != bounds.bottom) {
|
||||
keyBackground.setBounds(0, 0, key.width, key.height);
|
||||
}
|
||||
canvas.translate(key.x + kbdPaddingLeft, key.y + kbdPaddingTop);
|
||||
keyBackground.draw(canvas);
|
||||
|
||||
if (label != null) {
|
||||
//获取为Key的Label的字体大小, 若没有定制, 使用KeyboardView的默认属性keyTextSize设置
|
||||
Float customKeyTextSize = customKeyStyle.getKeyTextSize(key);
|
||||
// For characters, use large font. For labels like "Done", use small font.
|
||||
if (null != customKeyTextSize) {
|
||||
paint.setTextSize(customKeyTextSize);
|
||||
paint.setTypeface(Typeface.DEFAULT);
|
||||
//paint.setTypeface(Typeface.DEFAULT_BOLD);
|
||||
} else {
|
||||
if (label.length() > 1 && key.codes.length < 2) {
|
||||
paint.setTextSize(rLabelTextSize);
|
||||
paint.setTypeface(Typeface.DEFAULT);
|
||||
//paint.setTypeface(Typeface.DEFAULT_BOLD);
|
||||
} else {
|
||||
paint.setTextSize(rKeyTextSize);
|
||||
paint.setTypeface(Typeface.DEFAULT);
|
||||
//paint.setTypeface(Typeface.DEFAULT);
|
||||
}
|
||||
}
|
||||
|
||||
//获取为Key的Label的字体颜色, 若没有定制, 使用KeyboardView的默认属性keyTextColor设置
|
||||
Integer customKeyTextColor = customKeyStyle.getKeyTextColor(key);
|
||||
if (null != customKeyTextColor) {
|
||||
paint.setColor(customKeyTextColor);
|
||||
} else {
|
||||
paint.setColor(rKeyTextColor);
|
||||
}
|
||||
// Draw a drop shadow for the text
|
||||
paint.setShadowLayer(rShadowRadius, 0, 0, rShadowColor);
|
||||
// Draw the text
|
||||
canvas.drawText(label,
|
||||
(key.width - padding.left - padding.right) / 2
|
||||
+ padding.left,
|
||||
(key.height - padding.top - padding.bottom) / 2
|
||||
+ (paint.getTextSize() - paint.descent()) / 2 + padding.top,
|
||||
paint);
|
||||
// Turn off drop shadow
|
||||
paint.setShadowLayer(0, 0, 0, 0);
|
||||
} else if (key.icon != null) {
|
||||
final int drawableX = (key.width - padding.left - padding.right
|
||||
- key.icon.getIntrinsicWidth()) / 2 + padding.left;
|
||||
final int drawableY = (key.height - padding.top - padding.bottom
|
||||
- key.icon.getIntrinsicHeight()) / 2 + padding.top;
|
||||
canvas.translate(drawableX, drawableY);
|
||||
key.icon.setBounds(0, 0,
|
||||
key.icon.getIntrinsicWidth(), key.icon.getIntrinsicHeight());
|
||||
key.icon.draw(canvas);
|
||||
canvas.translate(-drawableX, -drawableY);
|
||||
}
|
||||
canvas.translate(-key.x - kbdPaddingLeft, -key.y - kbdPaddingTop);
|
||||
}
|
||||
rInvalidatedKey = null;
|
||||
}
|
||||
|
||||
private CharSequence adjustCase(CharSequence label) {
|
||||
if (getKeyboard().isShifted() && label != null && label.length() < 3
|
||||
&& Character.isLowerCase(label.charAt(0))) {
|
||||
label = label.toString().toUpperCase();
|
||||
}
|
||||
return label;
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
package com.gizwits.opensource.appkit.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Paint.Style;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
|
||||
import com.gizwits.opensource.appkit.R;
|
||||
|
||||
|
||||
public class DotView extends View {
|
||||
private Paint p;
|
||||
private int width;
|
||||
private int height;
|
||||
private int dash;
|
||||
|
||||
public DotView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init(context);
|
||||
}
|
||||
|
||||
public DotView(Context context) {
|
||||
super(context);
|
||||
init(context);
|
||||
}
|
||||
private void init(Context context){
|
||||
p = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
p.setStyle(Style.FILL);
|
||||
p.setColor(context.getResources().getColor(R.color.line_gray));
|
||||
|
||||
final float scale = context.getResources().getDisplayMetrics().density;
|
||||
dash=(int) (3 * scale + 0.5f);
|
||||
}
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
|
||||
if(width>10){
|
||||
for(int i=0;i<width;i+=dash){
|
||||
canvas.drawLine(i, 0, i+=dash, 0, p);
|
||||
}
|
||||
}
|
||||
super.onDraw(canvas);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSizeChanged(int w, int h, int oldw, int oldh) {
|
||||
super.onSizeChanged(w, h, oldw, oldh);
|
||||
width=w;
|
||||
height=h;
|
||||
p.setStrokeWidth(height);
|
||||
this.postInvalidate();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
package com.gizwits.opensource.appkit.view;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.widget.EditText;
|
||||
|
||||
public class HexWatcher implements TextWatcher {
|
||||
private EditText _text;
|
||||
|
||||
public HexWatcher(EditText _text) {
|
||||
this._text = _text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
if (s == null || s.length() == 0)
|
||||
return;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
if (s.charAt(i) == ' ' && i < s.length() - 1) {
|
||||
continue;
|
||||
} else {
|
||||
sb.append(s.charAt(i));
|
||||
if (sb.length() % 3 == 0 && sb.charAt(sb.length() - 1) != ' ') {
|
||||
sb.insert(sb.length() - 1, ' ');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!sb.toString().equals(s.toString())) {
|
||||
int index = start + 1;
|
||||
if (sb.charAt(start) == ' ') {
|
||||
if (before == 0) {
|
||||
index++;
|
||||
} else {
|
||||
index--;
|
||||
}
|
||||
} else {
|
||||
if (before == 1) {
|
||||
index--;
|
||||
}
|
||||
}
|
||||
_text.setText(sb.toString().toUpperCase(Locale.getDefault()));
|
||||
_text.setSelection(index);
|
||||
}
|
||||
|
||||
// _text.removeTextChangedListener(this);
|
||||
// _text.setText(s.toString().toUpperCase(Locale.getDefault()));
|
||||
// _text.addTextChangedListener(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
}
|
||||
|
||||
}
|