diff --git a/.classpath b/.classpath new file mode 100644 index 0000000000000000000000000000000000000000..51769745b2c3fa7f59c0b88bad65762059ee0812 --- /dev/null +++ b/.classpath @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/.project b/.project index c4ef03dbbcacbbdd770540d33dcd07a5bf2a2478..1bfb229f5667fb5dee3409237420bec2a18d1076 100644 --- a/.project +++ b/.project @@ -1,6 +1,6 @@ - GizOpenSourceGokit_Android + GOpenSourceGokit_Android diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000000000000000000000000000000000000..2d630ea1c586f5b340d58c1d355a2b55a4872697 --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +encoding//src/com/gizwits/opensource/appkit/ControlModule/GosDeviceControlActivity.java=UTF-8 +encoding/=UTF-8 diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000000000000000000000000000000000..b080d2ddc88fb0b4d7c93cd4d361c775525b4dbb --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,4 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 5830c1d9a59cace71e5f4c47933e1085f974e4dd..1695dec7aa6a4d13dd724d7566b8d6633f07970d 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1,313 +1,316 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/README.md b/README.md index 0a0507be1b951176a7e62d261a3d0d4a1c5ed21b..d8ef39248e3ddad0ead2c8109e6dd3375d29a21a 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,7 @@ -Gizwits GoKit App -============================== +# 机智云开源框架App工程 +================== - - 这是一款使用GizWifiSDK的开源代码示例APP,可以帮助开发者快速入手,使用GizWifiSDK开发连接机智云的物联APP。 + 此为Eclipse工程。Android Studio工程请去这里下载:https://github.com/gizwits/GOpenSource_AppKit_Android_AS 使用机智云开源APP之前,需要先在机智云开发平台创建您自己的产品和应用。 @@ -10,57 +9,161 @@ Gizwits GoKit App 具体申请流程请参见:http://docs.gizwits.com/hc/。 - 上述信息申请好之后,在代码中请找到"your_app_id"、"your_app_secret"、"your_product_key"字符串做相应的替换。 + 开源框架工程可通过修改配置文件配置开发者的个人应用信息,请参考使用说明中的 第5节 配置文件说明 进行替换。 - 使用QQ帐号登录、百度或极光推送功能之前,需要您先到相应网站申请QQ登录的AppID、百度或极光推送的AppKey,在配置文件中作相应的替换。 + 使用QQ、微信登录或百度或极光推送功能之前,需要您先到相应网站申请对应的应用信息,在配置文件中作相应的替换。 - 配置文件位置:assets/UIConfig.json +# GizWifiSDK 版本号 + + 2.04.04 + +# 功能介绍 + + 本文档为机智云物联网开源基础App套件使用说明,旨在为机智云物联网开发者提供一个快速开发模板,可在此工程基础上进行快速开发或参考相关代码进行开发。 + +## 目录结构说明: + + > libs:包括 GizWifiSDK 在内的的第三方库目录 + + > assets: 包含 UIConfig.json 配置文件 + + > GizOpenSourceModules:组成模块 + + >> GosApplication.java // SDK 在此启动 + + >> CommonModule // 公共方法类、资源文件读取类 + + >> ConfigModule // 设备配置模块,包含 AirLink 及 SoftAP + + >> UserModule // 用户模块,包含 用户登录、用户注册、找回密码 + + >> DeviceModule // 设备模块,包含 设备列表 + + >> ControlModule // 控制模块,包含 控制示例 + + >> SettingsModule // 设置模块,包含 设置菜单 及其 包含的子菜单项(关于等) + + >> PushModule // 推送模块,包含 百度和极光的推送SDK 集成封装 + + >> ThirdAccountModule // 第三方登录模块, 包含 第三方登录(QQ、微信等) + + >> view // 自定义控件 -GizWifiSDK 版本号 + >> utils // 工具类 - 2.01.01 + >> wxapi // 微信集成包 + >> zxing // 扫描二维码 -功能介绍 - GoKit主要展示如何使用GizWifiSDK,开发基于GAgent智能硬件APP。项目中用到了大部分主要SDK接口,供使用GizWifiSDK的开发者参 - 考。主要功能如下: + + +*** - ▪ 初始化SDK - ▪ 用户登录到云端 - ▪ 设备配置入网 - ▪ 搜索设备列表 - ▪ 绑定或解绑设备 - ▪ 设备登录 - ▪ 设备控制 +# 使用说明: +## 1. 默认程序入口 -项目依赖和安装 + 默认程序入口在 UserModule 中的 GosUserLoginActivity。 - ▪ GizWifiSDK的jar包和支持库 - 登录机智云官方网站http://gizwits.com的开发者中心,下载并解压最新版本的SDK。 - 下载后,将解压后的目录拷贝到复制到 Android 项目 libs 目录即可。 +## 2. 更改启动后的载入界面 + 如果要启动程序直接进入设备列表,可在 AndroidManifest.xml 文件中将 GosUserLoginActivity 的 属性调整到 GosDeviceListActivity 中: + + -GoKit硬件依赖 + + - GoKit项目调试,需要有调试设备的支持,您可以使用虚拟设备或者实体设备搭建调试环境。 + +## 3. 加载控制界面 + + 代码位于 GosDeviceListActivity 文件中的 handleMessage 方法 case TOCONTROL 中: + + case TOCONTROL: + intent = new Intent(GosDeviceListActivity.this, GosDeviceControlActivity.class); + Bundle bundle = new Bundle(); + bundle.putParcelable("GizWifiDevice", (GizWifiDevice) msg.obj); + intent.putExtras(bundle); + startActivity(intent); + break; + + 修改 GosDeviceControlActivity 类为开发者自己编写的控制界面的类即可。 + +## 4. 设置界面 + + 设置界面位于 SettingsModule 中的 GosSettiingsActivity,在 activity_gos_settings.xml 文件中添加相应布局后,再回到 GosSettiingsActivity 中实现交互事件即可: + + @Override + public void onClick(View v) { + switch (v.getId()) { + case R.id.llAbout: + intent = new Intent(GosSettiingsActivity.this, GosAboutActivity.class); + startActivity(intent); + break; + + default: + break; + } + + } + +## 5. 配置文件说明 + + 配置文件位置:assets/UIConfig.json + + 配置文件可对程序样式及机智云appid等进行配置。 + + 可配置参数有: + + app_id:机智云 app id + app_secret:机智云 app secret + product_key:机智云 product key + wifi_type_select:默认配置模块wifi模组选择功能是否开启 + tencent_app_id:qq登录 app id + wechat_app_id:微信登录 app id + wechat_app_secret:微信登录 app secret + push_type:推送类型 【0:关闭,1:极光,2:百度】 + bpush_app_key:百度推送 app key + openAPIDomain:openAPI 域名及端口,格式:api.gizwits.com”。要指定端口,格式为:”xxx.xxxxxxx.com:81&8443” + siteDomain:site 域名及端口,格式:“site.gizwits.com”。要指定端口,格式为:”xxx.xxxxxxx.com:81&8443” + pushDomain:推送绑定服务器 域名及端口,格式:“push.gizwits.com”。要指定端口,格式为:”xxx.xxxxxxx.com:81&8443” + buttonColor:按钮颜色 + buttonTextColor:按钮文字颜色 + navigationBarColor:导航栏颜色 + navigationBarTextColor:导航栏文字颜色 + configProgressViewColor:配置中界面 progress view 颜色 + addDeviceTitle:添加设备界面 导航栏标题文字 + qq:是否打开QQ登录【true:打开】 + wechat:是否打开微信登录【true:打开】 + anonymousLogin:是否打开匿名登录【true:打开】 + + 需要注意: + 1.极光推送的appid需要在AndroidManifest.xml 中填写见243行。 + 2.微信登录需要进行在腾讯api中设置自己的md5值否者无法正常运行 + 3.tencent_app_id需要在AndroidManifest.xml中89行填写 + + 具体细节可以参考【开源框架工程使用文档】:http://docs.gizwits.com/hc/kb/article/186638/ + +# 程序调试 + + 您可以使用虚拟设备或者实体设备搭建调试环境。 ▪ 虚拟设备 机智云官网提供GoKit虚拟设备的支持,链接地址: - http://site.gizwits.com/developer/product/631/virtualdevice + http://dev.gizwits.com/zh-cn/developer/product/ ▪ 实体设备 - GoKit开发板。您可以在机智云官方网站上免费预约申请(限量10000台),申请地址: - http://gizwits.com/zh-cn/gokit + GoKit开发板。您可以在机智云官方网站上免费预约申请,申请地址: + http://www.gizwits.com/zh-cn/gokit GoKit开发板提供MCU开源代码供智能硬件设计者参考,请去此处下载:https://github.com/gizwits/gokit-mcu - -问题反馈 +# 问题反馈 您可以给机智云的技术支持人员发送邮件,反馈您在使用过程中遇到的任何问题。 邮箱:club@gizwits.com + diff --git a/assets/UIConfig.json b/assets/UIConfig.json index 87045b6b141ba79fca83839f7863c6e62b6cc3e0..37c06bfd38725cd67a2cd79aa011de7e96055c9f 100644 --- a/assets/UIConfig.json +++ b/assets/UIConfig.json @@ -1,20 +1,23 @@ -{ +{ "app_id":"d59de30bf1024a08a757598419090ae6", "app_secret":"a3466b42d71041f290c066c674001e6a", "product_key":["6f3074fe43894547a4f1314bd7e3ae0b"], "wifi_type_select":true, - "tencent_app_id":"1105483220", - "wechat_app_id":"wxb9e63ae3605f3d57", - "wechat_app_secret":"e22e1eb59e3a1498dd20d3404768ae19", + "tencent_app_id":"your_tencent_app_id", + "wechat_app_id":"your_wechat_app_id", + "wechat_app_secret":"your_wechat_app_secret", "push_type":0, - "bpush_app_key":"", - "openAPI_URL":"", - "site_URL":"", - "push_URL":"", - "buttonColor":"FFFFFF", + "bpush_app_key":"your_bpush_api_key", + "openAPIDomain":"", + "siteDomain":"", + "pushDomain":"", + "buttonColor":"F8DC26", "buttonTextColor":"000000", - "navigationBarColor":"408DC9", + "navigationBarColor":"F8DC26", "navigationBarTextColor":"000000", "configProgressViewColor":"000000", - "addDeviceTitle":"设备" + "addDeviceTitle":"", + "qq": false, + "wechat": false, + "anonymousLogin": true } \ No newline at end of file diff --git a/libs/GizWifiSDK.jar b/libs/GizWifiSDK.jar index edda69defb7a0070cfad1104cea4428ad3370379..b7b4f703b8600906927f401dbc76d56f013c478b 100644 Binary files a/libs/GizWifiSDK.jar and b/libs/GizWifiSDK.jar differ diff --git a/libs/armeabi/.DS_Store b/libs/armeabi/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 Binary files /dev/null and b/libs/armeabi/.DS_Store differ diff --git a/libs/armeabi/libSDKLog.so b/libs/armeabi/libSDKLog.so index c1d85ca33177eca2c93d6ea8b892ce40991343bb..121957efb4e56f0461e43c14089286bb58564e02 100644 Binary files a/libs/armeabi/libSDKLog.so and b/libs/armeabi/libSDKLog.so differ diff --git a/libs/easylink2.0.jar b/libs/easylink2.0.jar new file mode 100644 index 0000000000000000000000000000000000000000..2fff8f8f7d6b55657113b8977fc7a96eae06b70c Binary files /dev/null and b/libs/easylink2.0.jar differ diff --git a/libs/easylink_only.jar b/libs/easylink_only.jar deleted file mode 100644 index 38a48cb3de07d5337d23e823d8778b9ab85088a0..0000000000000000000000000000000000000000 Binary files a/libs/easylink_only.jar and /dev/null differ diff --git a/libs/xUtils-2.6.14.jar b/libs/xUtils-2.6.14.jar new file mode 100644 index 0000000000000000000000000000000000000000..0e8d26f00e80e4df5d7115015be701620643658f Binary files /dev/null and b/libs/xUtils-2.6.14.jar differ diff --git a/project.properties b/project.properties new file mode 100644 index 0000000000000000000000000000000000000000..4ab125693c7c484a0252ee7eca9616e0f9b1ac67 --- /dev/null +++ b/project.properties @@ -0,0 +1,14 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system edit +# "ant.properties", and override values to adapt the script to your +# project structure. +# +# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): +#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt + +# Project target. +target=android-19 diff --git a/res/drawable-hdpi/gizwitslogo.png b/res/drawable-hdpi/gizwitslogo.png new file mode 100644 index 0000000000000000000000000000000000000000..10111c19b3cbc6339c86f379b7afa2f7e28ac573 Binary files /dev/null and b/res/drawable-hdpi/gizwitslogo.png differ diff --git a/res/drawable-hdpi/splashbackgroud.png b/res/drawable-hdpi/splashbackgroud.png new file mode 100644 index 0000000000000000000000000000000000000000..99d77daf34b262a0ff852f200938b94f98a94202 Binary files /dev/null and b/res/drawable-hdpi/splashbackgroud.png differ diff --git a/res/drawable-xhdpi/device_icon.png b/res/drawable-xhdpi/device_icon.png index 6d038997903f77225147e4cc66fd825f7fc71a64..f08cdde94b7a325ea6488eda571744d3cc441c6b 100644 Binary files a/res/drawable-xhdpi/device_icon.png and b/res/drawable-xhdpi/device_icon.png differ diff --git a/res/drawable-xhdpi/gokit_icon.png b/res/drawable-xhdpi/gokit_icon.png deleted file mode 100644 index f08cdde94b7a325ea6488eda571744d3cc441c6b..0000000000000000000000000000000000000000 Binary files a/res/drawable-xhdpi/gokit_icon.png and /dev/null differ diff --git a/res/drawable-xhdpi/mydefault.png b/res/drawable-xhdpi/mydefault.png new file mode 100644 index 0000000000000000000000000000000000000000..4c90f0ebccee078b51a763db936b2a36b31758fe Binary files /dev/null and b/res/drawable-xhdpi/mydefault.png differ diff --git a/res/drawable/background.xml b/res/drawable/background.xml new file mode 100644 index 0000000000000000000000000000000000000000..d464c79b50c9530f06689bd6863a41a3a3182ec4 --- /dev/null +++ b/res/drawable/background.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/res/drawable/img_ba_shape.xml b/res/drawable/img_bg_shape.xml similarity index 100% rename from res/drawable/img_ba_shape.xml rename to res/drawable/img_bg_shape.xml diff --git a/res/layout/activity_gos_airlink_choose_device_workwifi.xml b/res/layout/activity_gos_airlink_choose_device_workwifi.xml index d5bb9bb2579c14ad359e9498e5e879b0d34b7bbd..7b8239b8947816a47054f3f8bc52b9557bd85168 100644 --- a/res/layout/activity_gos_airlink_choose_device_workwifi.xml +++ b/res/layout/activity_gos_airlink_choose_device_workwifi.xml @@ -132,8 +132,7 @@ android:hint="@string/softPsw_hint" android:inputType="textPassword" android:textColorHint="@color/text_gray_light" - android:textSize="14sp" - android:typeface="normal" /> + android:textSize="14sp" /> - + > - - \ No newline at end of file + \ No newline at end of file diff --git a/res/layout/activity_gos_check_device_workwifi.xml b/res/layout/activity_gos_check_device_workwifi.xml index bbc9bd300c9e87c61d5193b6e5b42d63d7dd96f5..fe429afd4fe89f5f11cb35c0049f92923d327316 100644 --- a/res/layout/activity_gos_check_device_workwifi.xml +++ b/res/layout/activity_gos_check_device_workwifi.xml @@ -87,8 +87,7 @@ android:hint="@string/softPsw_hint" android:inputType="textPassword" android:textColorHint="@color/text_gray_light" - android:textSize="14sp" - android:typeface="normal" /> + android:textSize="14sp" /> - diff --git a/res/layout/activity_gos_config_failed.xml b/res/layout/activity_gos_config_failed.xml index b2fcd573b97d8cff381a6d42a726e77f6df8f956..85358df63b64c4d7bf8613fbca71a67ebdb88c9e 100644 --- a/res/layout/activity_gos_config_failed.xml +++ b/res/layout/activity_gos_config_failed.xml @@ -52,7 +52,7 @@ android:id="@+id/btnAgain" style="@style/ButtonStyle" android:layout_width="match_parent" - android:layout_height="50dp" + android:layout_height="40dp" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:layout_marginBottom="20dp" diff --git a/res/layout/activity_gos_forget_password.xml b/res/layout/activity_gos_forget_password.xml index 2659d7a9f448a6250bd82fdc7c80ad67b232d06c..bff0a989ee654582de911fe6f961013b0fff3bbc 100644 --- a/res/layout/activity_gos_forget_password.xml +++ b/res/layout/activity_gos_forget_password.xml @@ -116,8 +116,7 @@ android:inputType="textPassword" android:textColor="@color/black" android:textColorHint="@color/text_gray_light" - android:textSize="13sp" - android:typeface="normal" /> + android:textSize="13sp" /> + android:textSize="13sp" /> + android:textSize="14sp" /> - \ No newline at end of file diff --git a/res/layout/actvity_gos_airlink_ready.xml b/res/layout/actvity_gos_airlink_ready.xml index 4da9d4815c0c220bb2edb244e92851bd1a2af10c..b6c3a815c5bd5a001149ff4430c9f6a0e3778fc8 100644 --- a/res/layout/actvity_gos_airlink_ready.xml +++ b/res/layout/actvity_gos_airlink_ready.xml @@ -47,7 +47,7 @@ android:gravity="center_horizontal" android:text="@string/airlink_ready_message" /> - - + android:src="@drawable/device_icon" /> - - + \ No newline at end of file diff --git a/res/values-en/arrays_mode.xml b/res/values-en/arrays_mode.xml index 9a1ca9b8092684f546d0e676a80bf85f86713dc4..007ec53d3d8f367b3a82081e340063b2341657a8 100644 --- a/res/values-en/arrays_mode.xml +++ b/res/values-en/arrays_mode.xml @@ -2,16 +2,18 @@ + ESP MXCHIP HF RTK WM - ESP - QCT - TI + QCA + TI FSK MXCHIP3 BL + AtmelEE + Other \ No newline at end of file diff --git a/res/values-en/strings.xml b/res/values-en/strings.xml index 06adabe364a1919b3d85cdb0ae7e87ec780eb187..c9ef5f95c9a064052fa945dbd98c24353e38c947 100644 --- a/res/values-en/strings.xml +++ b/res/values-en/strings.xml @@ -176,6 +176,7 @@ failed waiting for device ready set device info + No response from device,Please check the running state of device Module type selection diff --git a/res/values/arrays_mode.xml b/res/values/arrays_mode.xml index 70b36f935c397599d20f7db1a3ffb38642de63d9..60af4b44411a42846c39399b3cbec1f41574a3bb 100644 --- a/res/values/arrays_mode.xml +++ b/res/values/arrays_mode.xml @@ -2,16 +2,18 @@ + 乐鑫 庆科 汉枫 瑞昱 联盛德 - 乐鑫 高通 TI 宇音天下 庆科V3 古北 + AtmelEE + 其他 \ No newline at end of file diff --git a/res/values/strings.xml b/res/values/strings.xml index 0e859b45926302455350d76696ae2834464fe8c1..c67f3e28cc53757c25446279acc5242dd0fb4e88 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -176,6 +176,7 @@ 设置失败 等待设备就绪 设置设备信息 + 设备无响应,请检查设备是否正常工作 模组类型选择 diff --git a/res/values/styles.xml b/res/values/styles.xml index f9328f6737aa71bb2a5de1098e51fd2ec1ed3ac9..e04155d8b699187a5db01b0abaf836bd34d1bddc 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -26,7 +26,7 @@ @@ -52,7 +52,7 @@ 15dp 15dp 20dp - @drawable/img_ba_shape + @drawable/img_bg_shape @color/black 18dp diff --git a/src/com/gizwits/opensource/gokit/CommonModule/GosBaseActivity.java b/src/com/gizwits/opensource/appkit/CommonModule/GosBaseActivity.java similarity index 98% rename from src/com/gizwits/opensource/gokit/CommonModule/GosBaseActivity.java rename to src/com/gizwits/opensource/appkit/CommonModule/GosBaseActivity.java index c99882cac23dc6853eeb0c3131a0192aaa781b6d..7c51a9ec700cbbcddf32649166ed2311883b4c6a 100644 --- a/src/com/gizwits/opensource/gokit/CommonModule/GosBaseActivity.java +++ b/src/com/gizwits/opensource/appkit/CommonModule/GosBaseActivity.java @@ -1,9 +1,8 @@ -package com.gizwits.opensource.gokit.CommonModule; +package com.gizwits.opensource.appkit.CommonModule; import java.util.ArrayList; import java.util.List; -import com.gizwits.gizwifisdk.enumration.GizWifiErrorCode; -import com.gizwits.opensource.gokit.R; + import android.app.ActionBar; import android.app.Activity; import android.app.AlertDialog; @@ -20,12 +19,16 @@ import android.text.Spannable; import android.text.SpannableString; import android.text.style.ForegroundColorSpan; import android.view.View; -import android.view.Window; import android.view.View.OnClickListener; +import android.view.Window; import android.widget.EditText; import android.widget.LinearLayout; import android.widget.TextView; +import com.gizwits.gizwifisdk.enumration.GizWifiErrorCode; +import com.gizwits.opensource.appkit.MessageCenter; +import com.gizwits.opensource.gokit.R; + public class GosBaseActivity extends Activity { /** 设备热点默认密码 */ @@ -52,11 +55,10 @@ public class GosBaseActivity extends Activity { /** 实现WXEntryActivity与GosUserLoginActivity共用 */ public static Handler baseHandler; - public static void setBaseHandler(Handler basehandler) { + public void setBaseHandler(Handler basehandler) { if (null != basehandler) { - GosBaseActivity.baseHandler = basehandler; + baseHandler = basehandler; } - } @Override @@ -71,7 +73,7 @@ public class GosBaseActivity extends Activity { } spf = getSharedPreferences(SPF_Name, Context.MODE_PRIVATE); - + MessageCenter.getInstance(getApplicationContext()); // 初始化 setProgressDialog(); } @@ -635,5 +637,4 @@ public class GosBaseActivity extends Activity { } }); } - } diff --git a/src/com/gizwits/opensource/gokit/CommonModule/GosDeploy.java b/src/com/gizwits/opensource/appkit/CommonModule/GosDeploy.java similarity index 85% rename from src/com/gizwits/opensource/gokit/CommonModule/GosDeploy.java rename to src/com/gizwits/opensource/appkit/CommonModule/GosDeploy.java index 89e66c3950e0f4b199c3dd9a1725f58660622a30..b2622386747b68feb419fe9051e842a88d451be9 100644 --- a/src/com/gizwits/opensource/gokit/CommonModule/GosDeploy.java +++ b/src/com/gizwits/opensource/appkit/CommonModule/GosDeploy.java @@ -1,6 +1,7 @@ -package com.gizwits.opensource.gokit.CommonModule; +package com.gizwits.opensource.appkit.CommonModule; import java.io.BufferedReader; +import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; @@ -14,8 +15,6 @@ import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; -import com.gizwits.opensource.gokit.R; - import android.content.Context; import android.content.res.AssetManager; import android.graphics.Color; @@ -24,20 +23,30 @@ import android.graphics.drawable.GradientDrawable; import android.text.TextUtils; import android.util.Log; import android.view.View; +import android.widget.Toast; + +import com.gizwits.opensource.gokit.R; +import com.gizwits.opensource.appkit.utils.AssetsUtils; public class GosDeploy { static Context context; - static HashMap infoMap; + public static HashMap infoMap; // 配置文件名称 private static final String fileName = "UIConfig.json"; + // 输出json的路径 + public static String fileOutName = null; + public GosDeploy(Context context) { super(); GosDeploy.context = context; - this.readJSON(); + + fileOutName = (context.getFilesDir().getAbsolutePath() + fileName); + copyJson(); + readJSON(); } /* @@ -77,13 +86,13 @@ public class GosDeploy { private static final String Bpush_App_Key = "bpush_app_key"; /** The API_URL Key */ - private static final String API_URL_Key = "openAPI_URL"; + private static final String API_URL_Key = "openAPIDomain"; /** The Site_URL Key */ - private static final String SITE_URL_Key = "site_URL"; + private static final String SITE_URL_Key = "siteDomain"; /** The GDMS_URL Key */ - private static final String GDMS_URL_Key = "push_URL"; + private static final String GDMS_URL_Key = "pushDomain"; /** The ButtonColor Key */ private static final String ButtonColor_Key = "buttonColor"; @@ -103,6 +112,15 @@ public class GosDeploy { /** The AddDeviceTitle Key */ private static final String AddDeviceTitle_Key = "addDeviceTitle"; + /** The QQ Key */ + private static final String QQ = "qq"; + + /** The Wechat Key */ + private static final String Wechat = "wechat"; + + /** The AnonymousLogin Key */ + private static final String AnonymousLogin = "anonymousLogin"; + /** The StatusBarStyle Key */ // private static final String StatusBarStyle_Key = "statusBarStyle"; @@ -132,6 +150,33 @@ public class GosDeploy { return infoMap.get(App_Secret_Key).toString(); } + /** + * 用来判断是否需要打开QQ登录 + * + * @return boolean + */ + public static boolean setQQ() { + return (Boolean) infoMap.get(QQ); + } + + /** + * 用来判断是否需要打开Wechat登录 + * + * @return boolean + */ + public static boolean setWechat() { + return (Boolean) infoMap.get(Wechat); + } + + /** + * 用来判断是否需要打开匿名登录 + * + * @return boolean + */ + public static boolean setAnonymousLogin() { + return (Boolean) infoMap.get(AnonymousLogin); + } + /** * 设置ProductKey * @@ -302,26 +347,26 @@ public class GosDeploy { * * @return */ - public static ConcurrentHashMap setCloudService() { + public static ConcurrentHashMap setCloudService() { String[] apiURl, siteURL, pushUrl; apiURl = setApiURL(); siteURL = setSiteURL(); pushUrl = setGDMSURL(); - ConcurrentHashMap cloudServiceMap = new ConcurrentHashMap(); + ConcurrentHashMap cloudServiceMap = new ConcurrentHashMap(); if (!TextUtils.isEmpty(apiURl[0])) { cloudServiceMap.put("openAPIDomain", apiURl[0]); - cloudServiceMap.put("openAPIPort", Integer.parseInt(apiURl[1])); + cloudServiceMap.put("openAPIPort", apiURl[1]); } if (!TextUtils.isEmpty(siteURL[0])) { cloudServiceMap.put("siteDomain", siteURL[0]); - cloudServiceMap.put("sitePort", Integer.parseInt(siteURL[1])); + cloudServiceMap.put("sitePort", siteURL[1]); } if (!TextUtils.isEmpty(pushUrl[0])) { cloudServiceMap.put("pushDomain", pushUrl[0]); - cloudServiceMap.put("pushPort", Integer.parseInt(pushUrl[1])); + cloudServiceMap.put("pushPort", pushUrl[1]); } return cloudServiceMap; @@ -377,7 +422,6 @@ public class GosDeploy { if (!TextUtils.isEmpty(NavigationBarColor_FromMap)) { navigationBarColor = Color.parseColor("#" + NavigationBarColor_FromMap); } - drawable.setColor(navigationBarColor); return drawable; @@ -419,6 +463,7 @@ public class GosDeploy { * @return */ public static String setAddDeviceTitle() { + String addDeviceTitle = "设备"; String AddDeviceTitle_FromMap = infoMap.get(AddDeviceTitle_Key).toString(); @@ -427,15 +472,16 @@ public class GosDeploy { } return addDeviceTitle; + } /** * 读取本地的JSON文件 */ private void readJSON() { - AssetManager assetManager = context.getAssets(); try { - InputStreamReader inputStreamReader = new InputStreamReader(assetManager.open(fileName), "UTF-8"); + FileInputStream input = new FileInputStream(fileOutName); + InputStreamReader inputStreamReader = new InputStreamReader(input, "UTF-8"); BufferedReader bufferedReader = new BufferedReader(inputStreamReader); String line; StringBuilder stringBuilder = new StringBuilder(); @@ -471,4 +517,13 @@ public class GosDeploy { } + // 拷贝json文件 + private void copyJson() { + try { + AssetsUtils.assetsDataToSD(fileOutName, fileName, context); + } catch (IOException e) { + e.printStackTrace(); + } + + } } diff --git a/src/com/gizwits/opensource/gokit/CommonModule/WifiAutoConnectManager.java b/src/com/gizwits/opensource/appkit/CommonModule/WifiAutoConnectManager.java similarity index 76% rename from src/com/gizwits/opensource/gokit/CommonModule/WifiAutoConnectManager.java rename to src/com/gizwits/opensource/appkit/CommonModule/WifiAutoConnectManager.java index bdc0afb96862bcc07ee1974cd03980e8e8c5dc0a..8c17004d19707cd0a48b9ed2369070155bff2034 100644 --- a/src/com/gizwits/opensource/gokit/CommonModule/WifiAutoConnectManager.java +++ b/src/com/gizwits/opensource/appkit/CommonModule/WifiAutoConnectManager.java @@ -1,4 +1,4 @@ -package com.gizwits.opensource.gokit.CommonModule; +package com.gizwits.opensource.appkit.CommonModule; import java.util.List; @@ -13,7 +13,8 @@ import android.util.Log; public class WifiAutoConnectManager { - private static final String TAG = WifiAutoConnectManager.class.getSimpleName(); + private static final String TAG = WifiAutoConnectManager.class + .getSimpleName(); WifiManager wifiManager; @@ -35,7 +36,8 @@ public class WifiAutoConnectManager { // 查看以前是否也配置过这个网络 private WifiConfiguration isExsits(String SSID) { - List existingConfigs = wifiManager.getConfiguredNetworks(); + List existingConfigs = wifiManager + .getConfiguredNetworks(); for (WifiConfiguration existingConfig : existingConfigs) { if (existingConfig.SSID.equals("\"" + SSID + "\"")) { return existingConfig; @@ -44,7 +46,8 @@ public class WifiAutoConnectManager { return null; } - private WifiConfiguration createWifiInfo(String SSID, String Password, WifiCipherType Type) { + private WifiConfiguration createWifiInfo(String SSID, String Password, + WifiCipherType Type) { WifiConfiguration config = new WifiConfiguration(); config.allowedAuthAlgorithms.clear(); config.allowedGroupCiphers.clear(); @@ -52,6 +55,7 @@ public class WifiAutoConnectManager { config.allowedPairwiseCiphers.clear(); config.allowedProtocols.clear(); config.SSID = "\"" + SSID + "\""; + // config.SSID = SSID; // nopass if (Type == WifiCipherType.WIFICIPHER_NOPASS) { // config.wepKeys[0] = ""; @@ -76,14 +80,17 @@ public class WifiAutoConnectManager { if (Type == WifiCipherType.WIFICIPHER_WPA) { config.preSharedKey = "\"" + Password + "\""; config.hiddenSSID = true; - config.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN); + config.allowedAuthAlgorithms + .set(WifiConfiguration.AuthAlgorithm.OPEN); config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP); config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK); - config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP); + config.allowedPairwiseCiphers + .set(WifiConfiguration.PairwiseCipher.TKIP); // 此处需要修改否则不能自动重联 // config.allowedProtocols.set(WifiConfiguration.Protocol.WPA); config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP); - config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP); + config.allowedPairwiseCiphers + .set(WifiConfiguration.PairwiseCipher.CCMP); config.status = WifiConfiguration.Status.ENABLED; } @@ -99,6 +106,13 @@ public class WifiAutoConnectManager { return bRet; } + // 关闭WIFI + private void closeWifi() { + if (wifiManager.isWifiEnabled()) { + wifiManager.setWifiEnabled(false); + } + } + class ConnectRunnable implements Runnable { private String ssid; @@ -124,27 +138,33 @@ public class WifiAutoConnectManager { Thread.sleep(100); } catch (InterruptedException ie) { + Log.e(TAG, ie.toString()); } } - WifiConfiguration wifiConfig = createWifiInfo(ssid, password, type); - // - if (wifiConfig == null) { - Log.d(TAG, "wifiConfig is null!"); - return; - } - WifiConfiguration tempConfig = isExsits(ssid); if (tempConfig != null) { - wifiManager.removeNetwork(tempConfig.networkId); + // wifiManager.removeNetwork(tempConfig.networkId); + + boolean b = wifiManager.enableNetwork(tempConfig.networkId, + true); + } else { + WifiConfiguration wifiConfig = createWifiInfo(ssid, password, + type); + // + if (wifiConfig == null) { + Log.d(TAG, "wifiConfig is null!"); + return; + } + + int netID = wifiManager.addNetwork(wifiConfig); + boolean enabled = wifiManager.enableNetwork(netID, true); + Log.d(TAG, "enableNetwork status enable=" + enabled); + boolean connected = wifiManager.reconnect(); + Log.d(TAG, "enableNetwork connected=" + connected); } - int netID = wifiManager.addNetwork(wifiConfig); - boolean enabled = wifiManager.enableNetwork(netID, true); - Log.d(TAG, "enableNetwork status enable=" + enabled); - boolean connected = wifiManager.reconnect(); - Log.d(TAG, "enableNetwork connected=" + connected); } } @@ -162,7 +182,8 @@ public class WifiAutoConnectManager { private static boolean isHex(String key) { for (int i = key.length() - 1; i >= 0; i--) { final char c = key.charAt(i); - if (!(c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f')) { + if (!(c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' + && c <= 'f')) { return false; } } @@ -173,7 +194,8 @@ public class WifiAutoConnectManager { // 获取ssid的加密方式 public static WifiCipherType getCipherType(Context context, String ssid) { - WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); + WifiManager wifiManager = (WifiManager) context + .getSystemService(Context.WIFI_SERVICE); List list = wifiManager.getScanResults(); @@ -185,10 +207,12 @@ public class WifiAutoConnectManager { if (!TextUtils.isEmpty(capabilities)) { - if (capabilities.contains("WPA") || capabilities.contains("wpa")) { + if (capabilities.contains("WPA") + || capabilities.contains("wpa")) { Log.i("hefeng", "wpa"); return WifiCipherType.WIFICIPHER_WPA; - } else if (capabilities.contains("WEP") || capabilities.contains("wep")) { + } else if (capabilities.contains("WEP") + || capabilities.contains("wep")) { Log.i("hefeng", "wep"); return WifiCipherType.WIFICIPHER_WEP; } else { diff --git a/src/com/gizwits/opensource/gokit/ConfigModule/GosAirlinkChooseDeviceWorkWiFiActivity.java b/src/com/gizwits/opensource/appkit/ConfigModule/GosAirlinkChooseDeviceWorkWiFiActivity.java similarity index 70% rename from src/com/gizwits/opensource/gokit/ConfigModule/GosAirlinkChooseDeviceWorkWiFiActivity.java rename to src/com/gizwits/opensource/appkit/ConfigModule/GosAirlinkChooseDeviceWorkWiFiActivity.java index 382e69b50c7971b94824954886c30db7b76463f4..dbf92ddb64f938279d3c9be3007d8864c355b8a4 100644 --- a/src/com/gizwits/opensource/gokit/ConfigModule/GosAirlinkChooseDeviceWorkWiFiActivity.java +++ b/src/com/gizwits/opensource/appkit/ConfigModule/GosAirlinkChooseDeviceWorkWiFiActivity.java @@ -1,11 +1,14 @@ -package com.gizwits.opensource.gokit.ConfigModule; +package com.gizwits.opensource.appkit.ConfigModule; import java.util.ArrayList; import java.util.List; -import com.gizwits.opensource.gokit.CommonModule.GosDeploy; -import com.gizwits.opensource.gokit.ConfigModule.GosModeListActivity.ModeListAdapter; -import com.gizwits.opensource.gokit.utils.NetUtils; +import org.json.JSONException; +import org.json.JSONObject; + +import com.gizwits.opensource.appkit.CommonModule.GosDeploy; +import com.gizwits.opensource.appkit.ConfigModule.GosModeListActivity.ModeListAdapter; +import com.gizwits.opensource.appkit.utils.NetUtils; import com.gizwits.opensource.gokit.R; import android.annotation.SuppressLint; import android.app.AlertDialog; @@ -37,7 +40,8 @@ import android.widget.Toast; import android.widget.CompoundButton.OnCheckedChangeListener; @SuppressLint("InflateParams") -public class GosAirlinkChooseDeviceWorkWiFiActivity extends GosConfigModuleBaseActivity implements OnClickListener { +public class GosAirlinkChooseDeviceWorkWiFiActivity extends + GosConfigModuleBaseActivity implements OnClickListener { private AlertDialog create; private ArrayList wifiList; @@ -76,14 +80,15 @@ public class GosAirlinkChooseDeviceWorkWiFiActivity extends GosConfigModuleBaseA ModeListAdapter modeListAdapter; /** The modeNum */ - static int modeNum = 4; + static int modeNum = 0; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_gos_airlink_choose_device_workwifi); // 设置ActionBar - String title = getString(R.string.add_device) + GosDeploy.setAddDeviceTitle(); + String title = getString(R.string.add_device) + + GosDeploy.setAddDeviceTitle(); setActionBar(true, true, title); initData(); @@ -95,17 +100,39 @@ public class GosAirlinkChooseDeviceWorkWiFiActivity extends GosConfigModuleBaseA protected void onResume() { super.onResume(); - tvMode.setText(modeList.get(modeNum)); - // 预设workSSID && workSSIDPsw - if (!TextUtils.isEmpty(workSSID)) { - etSSID.setText(workSSID); - if (checkworkSSIDUsed(workSSID)) { - if (!TextUtils.isEmpty(spf.getString("workSSIDPsw", ""))) { - etPsw.setText(spf.getString("workSSIDPsw", "")); + try { + tvMode.setText(modeList.get(modeNum)); + // 预设workSSID && workSSIDPsw + workSSID = NetUtils.getCurentWifiSSID(this); + String mypass = spf.getString("mypass", ""); + + if (!TextUtils.isEmpty(workSSID)) { + etSSID.setText(workSSID); + 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); } - } else { - etSSID.setText(NetUtils.getCurentWifiSSID(this)); + } catch (JSONException e) { + e.printStackTrace(); } } @@ -131,7 +158,8 @@ public class GosAirlinkChooseDeviceWorkWiFiActivity extends GosConfigModuleBaseA cbLaws.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override - public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + public void onCheckedChanged(CompoundButton buttonView, + boolean isChecked) { String psw = etPsw.getText().toString(); if (isChecked) { @@ -145,7 +173,7 @@ public class GosAirlinkChooseDeviceWorkWiFiActivity extends GosConfigModuleBaseA } private void initData() { - workSSID = spf.getString("workSSID", ""); + // workSSID = spf.getString("workSSID", ""); modeList = new ArrayList(); String[] modes = this.getResources().getStringArray(R.array.mode); @@ -162,12 +190,13 @@ public class GosAirlinkChooseDeviceWorkWiFiActivity extends GosConfigModuleBaseA workSSIDPsw = etPsw.getText().toString(); if (TextUtils.isEmpty(workSSID)) { - Toast.makeText(GosAirlinkChooseDeviceWorkWiFiActivity.this, R.string.choose_wifi_list_title, - toastTime).show(); + Toast.makeText(GosAirlinkChooseDeviceWorkWiFiActivity.this, + R.string.choose_wifi_list_title, toastTime).show(); return; } if (TextUtils.isEmpty(workSSIDPsw)) { - final Dialog dialog = new AlertDialog.Builder(this).setView(new EditText(this)).create(); + final Dialog dialog = new AlertDialog.Builder(this).setView( + new EditText(this)).create(); dialog.setCanceledOnTouchOutside(false); dialog.show(); @@ -200,8 +229,11 @@ public class GosAirlinkChooseDeviceWorkWiFiActivity extends GosConfigModuleBaseA break; case R.id.imgWiFiList: - AlertDialog.Builder dia = new AlertDialog.Builder(GosAirlinkChooseDeviceWorkWiFiActivity.this); - View view = View.inflate(GosAirlinkChooseDeviceWorkWiFiActivity.this, R.layout.alert_gos_wifi_list, null); + 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 rsList = NetUtils.getCurrentWifiScanResult(this); List localList = new ArrayList(); @@ -223,7 +255,8 @@ public class GosAirlinkChooseDeviceWorkWiFiActivity extends GosConfigModuleBaseA listview.setAdapter(adapter); listview.setOnItemClickListener(new OnItemClickListener() { @Override - public void onItemClick(AdapterView arg0, View arg1, int arg2, long arg3) { + public void onItemClick(AdapterView arg0, View arg1, + int arg2, long arg3) { ScanResult sResult = wifiList.get(arg2); String sSID = sResult.SSID; etSSID.setText(sSID); @@ -248,7 +281,29 @@ public class GosAirlinkChooseDeviceWorkWiFiActivity extends GosConfigModuleBaseA } private void toAirlinkReady() { - // TODO + // 需要记录所有配置过的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(); @@ -257,15 +312,11 @@ public class GosAirlinkChooseDeviceWorkWiFiActivity extends GosConfigModuleBaseA finish(); } - // 检查当前使用的WiFi是否曾经用过 - protected boolean checkworkSSIDUsed(String workSSID) { - if (spf.contains("workSSID")) { - if (spf.getString("workSSID", "").equals(workSSID)) { - return true; - } - } - return false; - } + /* + * // 检查当前使用的WiFi是否曾经用过 protected boolean checkworkSSIDUsed(String workSSID) + * { if (spf.contains("workSSID")) { if (spf.getString("workSSID", + * "").equals(workSSID)) { return true; } } return false; } + */ // 屏蔽掉返回键 @Override @@ -315,8 +366,9 @@ public class GosAirlinkChooseDeviceWorkWiFiActivity extends GosConfigModuleBaseA View view = convertView; Holder holder; if (view == null) { - view = LayoutInflater.from(GosAirlinkChooseDeviceWorkWiFiActivity.this) - .inflate(R.layout.item_gos_wifi_list, null); + view = LayoutInflater.from( + GosAirlinkChooseDeviceWorkWiFiActivity.this).inflate( + R.layout.item_gos_wifi_list, null); holder = new Holder(view); view.setTag(holder); } else { diff --git a/src/com/gizwits/opensource/gokit/ConfigModule/GosAirlinkConfigCountdownActivity.java b/src/com/gizwits/opensource/appkit/ConfigModule/GosAirlinkConfigCountdownActivity.java similarity index 78% rename from src/com/gizwits/opensource/gokit/ConfigModule/GosAirlinkConfigCountdownActivity.java rename to src/com/gizwits/opensource/appkit/ConfigModule/GosAirlinkConfigCountdownActivity.java index d69ace197b76a06f50be9f7deda35f82c20bba92..ccc9167daa75dcbf5c72e1ef1684152811556d11 100644 --- a/src/com/gizwits/opensource/gokit/ConfigModule/GosAirlinkConfigCountdownActivity.java +++ b/src/com/gizwits/opensource/appkit/ConfigModule/GosAirlinkConfigCountdownActivity.java @@ -1,17 +1,10 @@ -package com.gizwits.opensource.gokit.ConfigModule; +package com.gizwits.opensource.appkit.ConfigModule; import java.util.ArrayList; import java.util.List; import java.util.Timer; import java.util.TimerTask; -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.gokit.R; -import com.gizwits.opensource.gokit.view.RoundProgressBar; - import android.annotation.SuppressLint; import android.content.Intent; import android.os.Bundle; @@ -19,11 +12,22 @@ import android.os.Handler; import android.os.Message; import android.util.Log; import android.view.KeyEvent; +import android.view.ViewGroup.LayoutParams; +import android.view.WindowManager; +import android.widget.RelativeLayout; import android.widget.TextView; import android.widget.Toast; +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.gokit.R; +import com.gizwits.opensource.appkit.view.RoundProgressBar; + @SuppressLint("HandlerLeak") -public class GosAirlinkConfigCountdownActivity extends GosConfigModuleBaseActivity { +public class GosAirlinkConfigCountdownActivity extends + GosConfigModuleBaseActivity { /** The tv Time */ private TextView tvTimer; @@ -52,14 +56,23 @@ public class GosAirlinkConfigCountdownActivity extends GosConfigModuleBaseActivi // 设置ActionBar setActionBar(false, false, R.string.configcountDown_title); - initData(); initView(); + initData(); startAirlink(); } 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); } @@ -68,25 +81,28 @@ public class GosAirlinkConfigCountdownActivity extends GosConfigModuleBaseActivi workSSID = spf.getString("workSSID", ""); workSSIDPsw = spf.getString("workSSIDPsw", ""); modeDataList = new ArrayList(); + modeDataList.add(GizWifiGAgentType.GizGAgentESP); modeDataList.add(GizWifiGAgentType.GizGAgentMXCHIP); modeDataList.add(GizWifiGAgentType.GizGAgentHF); modeDataList.add(GizWifiGAgentType.GizGAgentRTK); modeDataList.add(GizWifiGAgentType.GizGAgentWM); - modeDataList.add(GizWifiGAgentType.GizGAgentESP); modeDataList.add(GizWifiGAgentType.GizGAgentQCA); 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(); - - modeList.add(modeDataList.get(GosAirlinkChooseDeviceWorkWiFiActivity.modeNum)); + + modeList.add(modeDataList + .get(GosAirlinkChooseDeviceWorkWiFiActivity.modeNum)); } private void startAirlink() { - GizWifiSDK.sharedInstance().setDeviceOnboarding(workSSID, workSSIDPsw, GizWifiConfigureMode.GizWifiAirLink, - null, 60, modeList); + GizWifiSDK.sharedInstance().setDeviceOnboarding(workSSID, workSSIDPsw, + GizWifiConfigureMode.GizWifiAirLink, null, 60, modeList); handler.sendEmptyMessage(handler_key.START_TIMER.ordinal()); } @@ -133,15 +149,17 @@ public class GosAirlinkConfigCountdownActivity extends GosConfigModuleBaseActivi break; case SUCCESSFUL: - Toast.makeText(GosAirlinkConfigCountdownActivity.this, R.string.configuration_successful, - toastTime).show(); + Toast.makeText(GosAirlinkConfigCountdownActivity.this, + R.string.configuration_successful, toastTime).show(); finish(); break; case FAILED: - Toast.makeText(GosAirlinkConfigCountdownActivity.this, msg.obj.toString(), - toastTime).show(); - Intent intent = new Intent(GosAirlinkConfigCountdownActivity.this, GosDeviceReadyActivity.class); + Toast.makeText(GosAirlinkConfigCountdownActivity.this, + msg.obj.toString(), toastTime).show(); + Intent intent = new Intent( + GosAirlinkConfigCountdownActivity.this, + GosDeviceReadyActivity.class); startActivity(intent); finish(); break; @@ -200,7 +218,8 @@ public class GosAirlinkConfigCountdownActivity extends GosConfigModuleBaseActivi * @param productKey * PK */ - protected void didSetDeviceOnboarding(GizWifiErrorCode result, String mac, String did, String productKey) { + protected void didSetDeviceOnboarding(GizWifiErrorCode result, String mac, + String did, String productKey) { if (GizWifiErrorCode.GIZ_SDK_DEVICE_CONFIG_IS_RUNNING == result) { return; } diff --git a/src/com/gizwits/opensource/gokit/ConfigModule/GosAirlinkReadyActivity.java b/src/com/gizwits/opensource/appkit/ConfigModule/GosAirlinkReadyActivity.java similarity index 94% rename from src/com/gizwits/opensource/gokit/ConfigModule/GosAirlinkReadyActivity.java rename to src/com/gizwits/opensource/appkit/ConfigModule/GosAirlinkReadyActivity.java index c5b3eeed1751106597c31209a7125e6fcfdf8294..ccd3567d80a6284731e7edc8947bea7dced56cfd 100644 --- a/src/com/gizwits/opensource/gokit/ConfigModule/GosAirlinkReadyActivity.java +++ b/src/com/gizwits/opensource/appkit/ConfigModule/GosAirlinkReadyActivity.java @@ -1,7 +1,7 @@ -package com.gizwits.opensource.gokit.ConfigModule; +package com.gizwits.opensource.appkit.ConfigModule; -import com.gizwits.opensource.gokit.CommonModule.GosDeploy; -import com.gizwits.opensource.gokit.view.GifView; +import com.gizwits.opensource.appkit.CommonModule.GosDeploy; +import com.gizwits.opensource.appkit.view.GifView; import com.gizwits.opensource.gokit.R; import android.content.Intent; diff --git a/src/com/gizwits/opensource/gokit/ConfigModule/GosCheckDeviceWorkWiFiActivity.java b/src/com/gizwits/opensource/appkit/ConfigModule/GosCheckDeviceWorkWiFiActivity.java similarity index 97% rename from src/com/gizwits/opensource/gokit/ConfigModule/GosCheckDeviceWorkWiFiActivity.java rename to src/com/gizwits/opensource/appkit/ConfigModule/GosCheckDeviceWorkWiFiActivity.java index 85144cfcd2ad7d16bc0522a562c5574829ff4bed..5b678a2fdb5961722466aa791e7e91a4f0a4a38e 100644 --- a/src/com/gizwits/opensource/gokit/ConfigModule/GosCheckDeviceWorkWiFiActivity.java +++ b/src/com/gizwits/opensource/appkit/ConfigModule/GosCheckDeviceWorkWiFiActivity.java @@ -1,10 +1,9 @@ -package com.gizwits.opensource.gokit.ConfigModule; +package com.gizwits.opensource.appkit.ConfigModule; import java.util.ArrayList; import java.util.List; - -import com.gizwits.opensource.gokit.CommonModule.GosDeploy; -import com.gizwits.opensource.gokit.utils.NetUtils; +import com.gizwits.opensource.appkit.CommonModule.GosDeploy; +import com.gizwits.opensource.appkit.utils.NetUtils; import com.gizwits.opensource.gokit.R; import android.annotation.SuppressLint; import android.app.AlertDialog; diff --git a/src/com/gizwits/opensource/gokit/ConfigModule/GosChooseDeviceActivity.java b/src/com/gizwits/opensource/appkit/ConfigModule/GosChooseDeviceActivity.java similarity index 98% rename from src/com/gizwits/opensource/gokit/ConfigModule/GosChooseDeviceActivity.java rename to src/com/gizwits/opensource/appkit/ConfigModule/GosChooseDeviceActivity.java index 2af6e7c62a759aded390c40e59439468d18c0bd9..9e7f3ae613323a31c411dac7479cb58723436581 100644 --- a/src/com/gizwits/opensource/gokit/ConfigModule/GosChooseDeviceActivity.java +++ b/src/com/gizwits/opensource/appkit/ConfigModule/GosChooseDeviceActivity.java @@ -1,11 +1,11 @@ -package com.gizwits.opensource.gokit.ConfigModule; +package com.gizwits.opensource.appkit.ConfigModule; import java.util.ArrayList; import java.util.Timer; import java.util.TimerTask; import com.gizwits.opensource.gokit.R; -import com.gizwits.opensource.gokit.utils.NetUtils; +import com.gizwits.opensource.appkit.utils.NetUtils; import android.annotation.SuppressLint; import android.content.Intent; diff --git a/src/com/gizwits/opensource/gokit/ConfigModule/GosConfigCountdownActivity.java b/src/com/gizwits/opensource/appkit/ConfigModule/GosConfigCountdownActivity.java similarity index 86% rename from src/com/gizwits/opensource/gokit/ConfigModule/GosConfigCountdownActivity.java rename to src/com/gizwits/opensource/appkit/ConfigModule/GosConfigCountdownActivity.java index 35084ca5ea01bf872bc79a2404153687686c2b22..d718f30c810a193105f66f9b5c27dfacb370a570 100644 --- a/src/com/gizwits/opensource/gokit/ConfigModule/GosConfigCountdownActivity.java +++ b/src/com/gizwits/opensource/appkit/ConfigModule/GosConfigCountdownActivity.java @@ -1,17 +1,8 @@ -package com.gizwits.opensource.gokit.ConfigModule; +package com.gizwits.opensource.appkit.ConfigModule; import java.util.Timer; import java.util.TimerTask; -import com.gizwits.gizwifisdk.api.GizWifiSDK; -import com.gizwits.gizwifisdk.enumration.GizWifiConfigureMode; -import com.gizwits.gizwifisdk.enumration.GizWifiErrorCode; -import com.gizwits.opensource.gokit.CommonModule.WifiAutoConnectManager; -import com.gizwits.opensource.gokit.CommonModule.WifiAutoConnectManager.WifiCipherType; -import com.gizwits.opensource.gokit.utils.NetUtils; -import com.gizwits.opensource.gokit.view.RoundProgressBar; -import com.gizwits.opensource.gokit.R; - import android.annotation.SuppressLint; import android.content.Context; import android.content.Intent; @@ -22,9 +13,21 @@ import android.os.Handler; import android.os.Message; import android.text.TextUtils; import android.view.KeyEvent; +import android.view.WindowManager; +import android.view.ViewGroup.LayoutParams; +import android.widget.RelativeLayout; import android.widget.TextView; import android.widget.Toast; +import com.gizwits.gizwifisdk.api.GizWifiSDK; +import com.gizwits.gizwifisdk.enumration.GizWifiConfigureMode; +import com.gizwits.gizwifisdk.enumration.GizWifiErrorCode; +import com.gizwits.opensource.gokit.R; +import com.gizwits.opensource.appkit.CommonModule.WifiAutoConnectManager; +import com.gizwits.opensource.appkit.CommonModule.WifiAutoConnectManager.WifiCipherType; +import com.gizwits.opensource.appkit.utils.NetUtils; +import com.gizwits.opensource.appkit.view.RoundProgressBar; + @SuppressLint("HandlerLeak") public class GosConfigCountdownActivity extends GosConfigModuleBaseActivity { @@ -84,6 +87,13 @@ public class GosConfigCountdownActivity extends GosConfigModuleBaseActivity { } private void initView() { + WindowManager wm = this.getWindowManager(); + int width = wm.getDefaultDisplay().getWidth(); + RelativeLayout cel_layout = (RelativeLayout) findViewById(R.id.layoutparms); + 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); @@ -94,7 +104,7 @@ public class GosConfigCountdownActivity extends GosConfigModuleBaseActivity { private void initData() { softSSID = getIntent().getStringExtra("softSSID"); - broadcase = new GosWifiChangeReciver(); + } private enum handler_key { @@ -194,8 +204,8 @@ public class GosConfigCountdownActivity extends GosConfigModuleBaseActivity { // 切换至设备热点 WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE); - WifiAutoConnectManager manager = new WifiAutoConnectManager(wifiManager); WifiCipherType cipherType = WifiAutoConnectManager.getCipherType(GosConfigCountdownActivity.this, softSSID); + WifiAutoConnectManager manager = new WifiAutoConnectManager(wifiManager); manager.connect(softSSID, SoftAP_PSW, cipherType); IntentFilter filter = new IntentFilter(); filter.addAction(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION); @@ -205,7 +215,7 @@ public class GosConfigCountdownActivity extends GosConfigModuleBaseActivity { final Timer mtimer = new Timer(); mtimer.schedule(new TimerTask() { - @Override + @Override public void run() { if (progressDialog.isShowing()) { progressDialog.cancel(); @@ -231,7 +241,11 @@ public class GosConfigCountdownActivity extends GosConfigModuleBaseActivity { isChecked = false; handler.sendEmptyMessage(handler_key.START_TIMER.ordinal()); } - registerReceiver(broadcase, filter); + if(broadcase==null){ + broadcase = new GosWifiChangeReciver(); + registerReceiver(broadcase, filter); + } + } } } @@ -253,7 +267,6 @@ public class GosConfigCountdownActivity extends GosConfigModuleBaseActivity { return; } if (timer != null) { - timer.cancel(); } Message message = new Message(); @@ -269,9 +282,13 @@ public class GosConfigCountdownActivity extends GosConfigModuleBaseActivity { @Override protected void onDestroy() { super.onDestroy(); - isChecked = false; - unregisterReceiver(broadcase); + + if(broadcase!=null){ + unregisterReceiver(broadcase); + broadcase = null; + } + } } diff --git a/src/com/gizwits/opensource/gokit/ConfigModule/GosConfigFailedActivity.java b/src/com/gizwits/opensource/appkit/ConfigModule/GosConfigFailedActivity.java similarity index 94% rename from src/com/gizwits/opensource/gokit/ConfigModule/GosConfigFailedActivity.java rename to src/com/gizwits/opensource/appkit/ConfigModule/GosConfigFailedActivity.java index 6e91a369ba81089db9aa2dbd682d2e7c6d86b246..482f1716300c60e3a275c2c51a228c10e8347f6d 100644 --- a/src/com/gizwits/opensource/gokit/ConfigModule/GosConfigFailedActivity.java +++ b/src/com/gizwits/opensource/appkit/ConfigModule/GosConfigFailedActivity.java @@ -1,7 +1,7 @@ -package com.gizwits.opensource.gokit.ConfigModule; +package com.gizwits.opensource.appkit.ConfigModule; +import com.gizwits.opensource.appkit.CommonModule.GosDeploy; import com.gizwits.opensource.gokit.R; -import com.gizwits.opensource.gokit.CommonModule.GosDeploy; import android.content.Intent; import android.os.Bundle; diff --git a/src/com/gizwits/opensource/gokit/ConfigModule/GosConfigModuleBaseActivity.java b/src/com/gizwits/opensource/appkit/ConfigModule/GosConfigModuleBaseActivity.java similarity index 96% rename from src/com/gizwits/opensource/gokit/ConfigModule/GosConfigModuleBaseActivity.java rename to src/com/gizwits/opensource/appkit/ConfigModule/GosConfigModuleBaseActivity.java index 9db666972f25e083e0e05c1586a1ecafaaa38063..f38a6d2b1f15102eece4a8df81148e0e23cd6552 100644 --- a/src/com/gizwits/opensource/gokit/ConfigModule/GosConfigModuleBaseActivity.java +++ b/src/com/gizwits/opensource/appkit/ConfigModule/GosConfigModuleBaseActivity.java @@ -1,12 +1,12 @@ -package com.gizwits.opensource.gokit.ConfigModule; +package com.gizwits.opensource.appkit.ConfigModule; import java.util.Timer; import com.gizwits.gizwifisdk.api.GizWifiSDK; import com.gizwits.gizwifisdk.enumration.GizWifiErrorCode; import com.gizwits.gizwifisdk.listener.GizWifiSDKListener; +import com.gizwits.opensource.appkit.CommonModule.GosBaseActivity; import com.gizwits.opensource.gokit.R; -import com.gizwits.opensource.gokit.CommonModule.GosBaseActivity; import android.app.AlertDialog; import android.app.Dialog; diff --git a/src/com/gizwits/opensource/gokit/ConfigModule/GosDeviceReadyActivity.java b/src/com/gizwits/opensource/appkit/ConfigModule/GosDeviceReadyActivity.java similarity index 96% rename from src/com/gizwits/opensource/gokit/ConfigModule/GosDeviceReadyActivity.java rename to src/com/gizwits/opensource/appkit/ConfigModule/GosDeviceReadyActivity.java index 6f23d0919d90c02b7f4c8aab697edbe991df402b..bbbc11fcef4bd00ec336954f56fd9a70f84066c7 100644 --- a/src/com/gizwits/opensource/gokit/ConfigModule/GosDeviceReadyActivity.java +++ b/src/com/gizwits/opensource/appkit/ConfigModule/GosDeviceReadyActivity.java @@ -1,7 +1,7 @@ -package com.gizwits.opensource.gokit.ConfigModule; +package com.gizwits.opensource.appkit.ConfigModule; +import com.gizwits.opensource.appkit.CommonModule.GosDeploy; import com.gizwits.opensource.gokit.R; -import com.gizwits.opensource.gokit.CommonModule.GosDeploy; import android.content.Intent; import android.os.Bundle; diff --git a/src/com/gizwits/opensource/gokit/ConfigModule/GosDeviceResetActivity.java b/src/com/gizwits/opensource/appkit/ConfigModule/GosDeviceResetActivity.java similarity index 95% rename from src/com/gizwits/opensource/gokit/ConfigModule/GosDeviceResetActivity.java rename to src/com/gizwits/opensource/appkit/ConfigModule/GosDeviceResetActivity.java index 29b793d50f5c9d8b8cdb4b4eae03aa10da9f63b1..a95fc06d9bd56f40efb0774985a91d98ff6a8394 100644 --- a/src/com/gizwits/opensource/gokit/ConfigModule/GosDeviceResetActivity.java +++ b/src/com/gizwits/opensource/appkit/ConfigModule/GosDeviceResetActivity.java @@ -1,7 +1,7 @@ -package com.gizwits.opensource.gokit.ConfigModule; +package com.gizwits.opensource.appkit.ConfigModule; -import com.gizwits.opensource.gokit.CommonModule.GosDeploy; -import com.gizwits.opensource.gokit.view.GifView; +import com.gizwits.opensource.appkit.CommonModule.GosDeploy; +import com.gizwits.opensource.appkit.view.GifView; import com.gizwits.opensource.gokit.R; import android.content.Intent; diff --git a/src/com/gizwits/opensource/gokit/ConfigModule/GosModeListActivity.java b/src/com/gizwits/opensource/appkit/ConfigModule/GosModeListActivity.java similarity index 98% rename from src/com/gizwits/opensource/gokit/ConfigModule/GosModeListActivity.java rename to src/com/gizwits/opensource/appkit/ConfigModule/GosModeListActivity.java index 9f8276fc581c94b63adb99bd9be4994f85c9f2d2..e5c33e88acd2238570406151d7f6a59ab88f3135 100644 --- a/src/com/gizwits/opensource/gokit/ConfigModule/GosModeListActivity.java +++ b/src/com/gizwits/opensource/appkit/ConfigModule/GosModeListActivity.java @@ -1,4 +1,4 @@ -package com.gizwits.opensource.gokit.ConfigModule; +package com.gizwits.opensource.appkit.ConfigModule; import java.util.ArrayList; import java.util.List; diff --git a/src/com/gizwits/opensource/gokit/ConfigModule/GosWifiChangeReciver.java b/src/com/gizwits/opensource/appkit/ConfigModule/GosWifiChangeReciver.java similarity index 80% rename from src/com/gizwits/opensource/gokit/ConfigModule/GosWifiChangeReciver.java rename to src/com/gizwits/opensource/appkit/ConfigModule/GosWifiChangeReciver.java index f94809b8042f1ec0a2f5c983917758093a5e9327..3bf6eea83172ea6dfee0b9274157ab01dbf9c80f 100644 --- a/src/com/gizwits/opensource/gokit/ConfigModule/GosWifiChangeReciver.java +++ b/src/com/gizwits/opensource/appkit/ConfigModule/GosWifiChangeReciver.java @@ -1,8 +1,8 @@ -package com.gizwits.opensource.gokit.ConfigModule; +package com.gizwits.opensource.appkit.ConfigModule; -import com.gizwits.opensource.gokit.CommonModule.GosBaseActivity; -import com.gizwits.opensource.gokit.CommonModule.WifiAutoConnectManager; -import com.gizwits.opensource.gokit.utils.NetUtils; +import com.gizwits.opensource.appkit.CommonModule.GosBaseActivity; +import com.gizwits.opensource.appkit.CommonModule.WifiAutoConnectManager; +import com.gizwits.opensource.appkit.utils.NetUtils; import android.content.BroadcastReceiver; import android.content.Context; diff --git a/src/com/gizwits/opensource/gokit/ControlModule/GosColorsListActivity.java b/src/com/gizwits/opensource/appkit/ControlModule/GosColorsListActivity.java similarity index 95% rename from src/com/gizwits/opensource/gokit/ControlModule/GosColorsListActivity.java rename to src/com/gizwits/opensource/appkit/ControlModule/GosColorsListActivity.java index 7ff985408e2e0ba16017138644d9219cc9e67af8..7a7f2830b8511e104dd3d018f8581bd3562d5cf9 100644 --- a/src/com/gizwits/opensource/gokit/ControlModule/GosColorsListActivity.java +++ b/src/com/gizwits/opensource/appkit/ControlModule/GosColorsListActivity.java @@ -1,4 +1,4 @@ -package com.gizwits.opensource.gokit.ControlModule; +package com.gizwits.opensource.appkit.ControlModule; import java.util.ArrayList; @@ -55,7 +55,7 @@ public class GosColorsListActivity extends GosControlModuleBaseActivity { @Override public void onItemClick(AdapterView arg0, View arg1, int arg2, long arg3) { spf.edit().putInt("COLOR", arg2).commit(); - GosDeviceControlActivity.isUpDateUi = false; + GosDeviceControlActivity.isSendCombinedColor = true; finish(); } }); diff --git a/src/com/gizwits/opensource/gokit/ControlModule/GosControlModuleBaseActivity.java b/src/com/gizwits/opensource/appkit/ControlModule/GosControlModuleBaseActivity.java similarity index 96% rename from src/com/gizwits/opensource/gokit/ControlModule/GosControlModuleBaseActivity.java rename to src/com/gizwits/opensource/appkit/ControlModule/GosControlModuleBaseActivity.java index de9e042493989e43947f1c79e75a10dee8961888..ddbc143b26c3a4f62609ebc97c450fde6f6bdda5 100644 --- a/src/com/gizwits/opensource/gokit/ControlModule/GosControlModuleBaseActivity.java +++ b/src/com/gizwits/opensource/appkit/ControlModule/GosControlModuleBaseActivity.java @@ -1,10 +1,10 @@ -package com.gizwits.opensource.gokit.ControlModule; +package com.gizwits.opensource.appkit.ControlModule; import com.gizwits.gizwifisdk.api.GizWifiDevice; import com.gizwits.gizwifisdk.enumration.GizWifiDeviceNetStatus; import com.gizwits.gizwifisdk.enumration.GizWifiErrorCode; import com.gizwits.gizwifisdk.listener.GizWifiDeviceListener; -import com.gizwits.opensource.gokit.CommonModule.GosBaseActivity; +import com.gizwits.opensource.appkit.CommonModule.GosBaseActivity; import android.view.MenuItem; diff --git a/src/com/gizwits/opensource/gokit/ControlModule/GosDeviceControlActivity.java b/src/com/gizwits/opensource/appkit/ControlModule/GosDeviceControlActivity.java similarity index 73% rename from src/com/gizwits/opensource/gokit/ControlModule/GosDeviceControlActivity.java rename to src/com/gizwits/opensource/appkit/ControlModule/GosDeviceControlActivity.java index 8e4f95bb5acdbff7b070bd27a7aa4e250c7a05ff..de9a6da3c3b970675f1775c110d43bd0847b5fc5 100644 --- a/src/com/gizwits/opensource/gokit/ControlModule/GosDeviceControlActivity.java +++ b/src/com/gizwits/opensource/appkit/ControlModule/GosDeviceControlActivity.java @@ -1,11 +1,7 @@ -package com.gizwits.opensource.gokit.ControlModule; +package com.gizwits.opensource.appkit.ControlModule; import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; import java.util.concurrent.ConcurrentHashMap; -import org.json.JSONException; -import org.json.JSONObject; import com.gizwits.gizwifisdk.api.GizWifiDevice; import com.gizwits.gizwifisdk.enumration.GizWifiDeviceNetStatus; @@ -53,9 +49,6 @@ public class GosDeviceControlActivity extends GosControlModuleBaseActivity imple /** The Constant LOG. */ protected static final int LOG = 3; - /** The Constant RESP. */ - protected static final int RESP = 4; - /** The Constant HARDWARE. */ protected static final int HARDWARE = 5; @@ -169,13 +162,10 @@ public class GosDeviceControlActivity extends GosControlModuleBaseActivity imple private GizWifiDevice mDevice; /** The device statu. */ - private HashMap deviceStatu; - - /** The First */ - // private boolean isFirst = true; + private ConcurrentHashMap deviceStatu; - /** The isUpDateUi */ - protected static boolean isUpDateUi = true; + /** 是否发送组合颜色命令 */ + protected static boolean isSendCombinedColor = false; /** The Title */ private String title; @@ -183,6 +173,42 @@ public class GosDeviceControlActivity extends GosControlModuleBaseActivity imple /** The colors list */ ArrayList colorsList; + private Runnable mRunnable = new Runnable() { + public void run() { + if (isDeviceCanBeControlled()) { + progressDialog.cancel(); + } else { + toastDeviceNoReadyAndExit(); + } + } + + }; + + /** The handler. */ + Handler handler = new Handler() { + public void handleMessage(Message msg) { + super.handleMessage(msg); + + switch (msg.what) { + case UPDATE_UI: + updateUI(); + break; + case LOG: + toastFaultsOrAlertsMessage(msg); + break; + case TOAST: + toastInfoMessage(msg); + break; + case HARDWARE: + showHardwareInfo((String) msg.obj); + break; + case DISCONNECT: + toastDeviceDisconnectAndExit(); + break; + } + } + }; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -200,16 +226,23 @@ public class GosDeviceControlActivity extends GosControlModuleBaseActivity imple protected void onResume() { super.onResume(); - if (!isUpDateUi) { - try { - sendJson(KEY_LIGHT_COLOR, spf.getInt("COLOR", 0)); - } catch (JSONException e) { - e.printStackTrace(); - } + if (isSendCombinedColor) { + sendCommand(KEY_LIGHT_COLOR, spf.getInt("COLOR", 0)); + tvColorText.setText(colorsList.get(spf.getInt("COLOR", 0))); + } else { + getStatusOfDevice(); } } + @Override + protected void onDestroy() { + super.onDestroy(); + handler.removeCallbacks(mRunnable); + mDevice.setSubscribe(false); + mDevice.setListener(null); + } + /** * 初始化控件. */ @@ -229,7 +262,6 @@ public class GosDeviceControlActivity extends GosControlModuleBaseActivity imple sbBlue = (SeekBar) findViewById(R.id.sb_blue); sbSpeed = (SeekBar) findViewById(R.id.sb_speed); - // redadd = (ImageView) findViewById(R.id.redadd); redsub = (ImageView) findViewById(R.id.redsub); greenadd = (ImageView) findViewById(R.id.greenadd); @@ -249,8 +281,6 @@ public class GosDeviceControlActivity extends GosControlModuleBaseActivity imple if (keyCode == KeyEvent.KEYCODE_BACK) { if (progressDialog.isShowing()) { GosDeviceControlActivity.this.finish(); - mDevice.setSubscribe(false); - mDevice.setListener(null); return true; } } @@ -258,7 +288,6 @@ public class GosDeviceControlActivity extends GosControlModuleBaseActivity imple return false; } }); - progressDialog.show(); } /** @@ -273,16 +302,11 @@ public class GosDeviceControlActivity extends GosControlModuleBaseActivity imple bluesub.setOnClickListener(this); speedadd.setOnClickListener(this); speedsub.setOnClickListener(this); - // swRed.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { - try { - sendJson(KEY_RED_SWITCH, swRed.isChecked()); - } catch (JSONException e) { - e.printStackTrace(); - } + sendCommand(KEY_RED_SWITCH, swRed.isChecked()); } }); llColor.setOnClickListener(new OnClickListener() { @@ -297,11 +321,7 @@ public class GosDeviceControlActivity extends GosControlModuleBaseActivity imple sbRed.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { @Override public void onStopTrackingTouch(SeekBar seekBar) { - try { - sendJson(KEY_LIGHT_RED, seekBar.getProgress()); - } catch (JSONException e) { - e.printStackTrace(); - } + sendCommand(KEY_LIGHT_RED, seekBar.getProgress()); } @Override @@ -319,11 +339,7 @@ public class GosDeviceControlActivity extends GosControlModuleBaseActivity imple @Override public void onStopTrackingTouch(SeekBar seekBar) { - try { - sendJson(KEY_LIGHT_BLUE, seekBar.getProgress()); - } catch (JSONException e) { - e.printStackTrace(); - } + sendCommand(KEY_LIGHT_BLUE, seekBar.getProgress()); } @Override @@ -341,11 +357,7 @@ public class GosDeviceControlActivity extends GosControlModuleBaseActivity imple @Override public void onStopTrackingTouch(SeekBar seekBar) { - try { - sendJson(KEY_LIGHT_GREEN, seekBar.getProgress()); - } catch (JSONException e) { - e.printStackTrace(); - } + sendCommand(KEY_LIGHT_GREEN, seekBar.getProgress()); } @Override @@ -362,11 +374,7 @@ public class GosDeviceControlActivity extends GosControlModuleBaseActivity imple sbSpeed.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { @Override public void onStopTrackingTouch(SeekBar seekBar) { - try { - sendJson(KEY_SPEED, seekBar.getProgress() - 5); - } catch (JSONException e) { - e.printStackTrace(); - } + sendCommand(KEY_SPEED, seekBar.getProgress() - 5); } @Override @@ -392,7 +400,7 @@ public class GosDeviceControlActivity extends GosControlModuleBaseActivity imple private void initDevice() { Intent intent = getIntent(); mDevice = (GizWifiDevice) intent.getParcelableExtra("GizWifiDevice"); - deviceStatu = new HashMap(); + deviceStatu = new ConcurrentHashMap(); if (TextUtils.isEmpty(mDevice.getAlias())) { title = mDevice.getProductName(); @@ -402,140 +410,112 @@ public class GosDeviceControlActivity extends GosControlModuleBaseActivity imple } /** - * 发送指令。格式为json。 - *

- * 例如 {"entity0":{"attr2":74},"cmd":1} - * 其中entity0为gokit所代表的实体key,attr2代表led灯红色值,cmd为1时代表写入 - * 。以上命令代表改变gokit的led灯红色值为74. + * Description: + */ + private void getStatusOfDevice() { + // 设备是否可控 + if (isDeviceCanBeControlled()) { + // 可控则查询当前设备状态 + mDevice.getDeviceStatus(); + } else { + // 显示等待栏 + progressDialog.show(); + if (mDevice.isLAN()) { + // 小循环10s未连接上设备自动退出 + handler.postDelayed(mRunnable, 10000); + } else { + // 大循环20s未连接上设备自动退出 + handler.postDelayed(mRunnable, 20000); + } + } + } + + private boolean isDeviceCanBeControlled() { + return mDevice.getNetStatus() == GizWifiDeviceNetStatus.GizDeviceControlled; + } + + private void toastDeviceNoReadyAndExit() { + Toast.makeText(this, R.string.device_no_ready, Toast.LENGTH_SHORT).show(); + finish(); + } + + private void toastDeviceDisconnectAndExit() { + Toast.makeText(GosDeviceControlActivity.this, R.string.disconnect, Toast.LENGTH_SHORT).show(); + finish(); + } + + /** + * 发送指令 * * @param key - * 数据点对应的的json的key + * 数据点对应的标识名 * @param value * 需要改变的值 - * @throws JSONException - * the JSON exception */ - private void sendJson(String key, Object value) throws JSONException { + private void sendCommand(String key, Object value) { + int sn = 5; ConcurrentHashMap hashMap = new ConcurrentHashMap(); hashMap.put(key, value); - mDevice.write(hashMap, 0); + mDevice.write(hashMap, sn); Log.i("Apptest", hashMap.toString()); } - /** The handler. */ - Handler handler = new Handler() { - public void handleMessage(Message msg) { - super.handleMessage(msg); - - switch (msg.what) { - - case UPDATE_UI: - isUpDateUi = true; - tvColorText.setText(colorsList.get(Integer.parseInt(deviceStatu.get(KEY_LIGHT_COLOR).toString()))); - spf.edit().putInt("COLOR", Integer.parseInt(deviceStatu.get(KEY_LIGHT_COLOR).toString())).commit(); - - swRed.setChecked((Boolean) deviceStatu.get(KEY_RED_SWITCH)); - swInfrared.setChecked((Boolean) deviceStatu.get(KEY_INFRARED)); - tvBlue.setText(deviceStatu.get(KEY_LIGHT_BLUE).toString()); - tvGreen.setText(deviceStatu.get(KEY_LIGHT_GREEN).toString()); - tvRed.setText(deviceStatu.get(KEY_LIGHT_RED).toString()); - tvSpeed.setText(deviceStatu.get(KEY_SPEED).toString()); - tvTemplate.setText(deviceStatu.get(KEY_TEMPLATE).toString()); - tvHumidity.setText(deviceStatu.get(KEY_HUMIDITY).toString()); - if (deviceStatu.get(KEY_LIGHT_BLUE).toString() != null) { - sbBlue.setProgress(Integer.parseInt(deviceStatu.get(KEY_LIGHT_BLUE).toString())); - } else { - sbBlue.setProgress(0); - } - - if (deviceStatu.get(KEY_LIGHT_GREEN).toString() != null) { - sbGreen.setProgress(Integer.parseInt(deviceStatu.get(KEY_LIGHT_GREEN).toString())); - } else { - sbBlue.setProgress(0); - } + private void updateUI() { + isSendCombinedColor = false; + tvColorText.setText(colorsList.get(Integer.parseInt(deviceStatu.get(KEY_LIGHT_COLOR).toString()))); + spf.edit().putInt("COLOR", Integer.parseInt(deviceStatu.get(KEY_LIGHT_COLOR).toString())).commit(); + + swRed.setChecked((Boolean) deviceStatu.get(KEY_RED_SWITCH)); + swInfrared.setChecked((Boolean) deviceStatu.get(KEY_INFRARED)); + tvBlue.setText(deviceStatu.get(KEY_LIGHT_BLUE).toString()); + tvGreen.setText(deviceStatu.get(KEY_LIGHT_GREEN).toString()); + tvRed.setText(deviceStatu.get(KEY_LIGHT_RED).toString()); + tvSpeed.setText(deviceStatu.get(KEY_SPEED).toString()); + tvTemplate.setText(deviceStatu.get(KEY_TEMPLATE).toString()); + tvHumidity.setText(deviceStatu.get(KEY_HUMIDITY).toString()); + if (deviceStatu.get(KEY_LIGHT_BLUE).toString() != null) { + sbBlue.setProgress(Integer.parseInt(deviceStatu.get(KEY_LIGHT_BLUE).toString())); + } else { + sbBlue.setProgress(0); + } - if (deviceStatu.get(KEY_LIGHT_RED).toString() != null) { - sbRed.setProgress(Integer.parseInt(deviceStatu.get(KEY_LIGHT_RED).toString())); - } else { - sbBlue.setProgress(0); - } + if (deviceStatu.get(KEY_LIGHT_GREEN).toString() != null) { + sbGreen.setProgress(Integer.parseInt(deviceStatu.get(KEY_LIGHT_GREEN).toString())); + } else { + sbBlue.setProgress(0); + } - if (deviceStatu.get(KEY_SPEED).toString() != null) { - sbSpeed.setProgress(5 + Integer.parseInt(deviceStatu.get(KEY_SPEED).toString())); - } else { - sbSpeed.setProgress(5); - } - break; - case RESP: - String data = msg.obj.toString(); + if (deviceStatu.get(KEY_LIGHT_RED).toString() != null) { + sbRed.setProgress(Integer.parseInt(deviceStatu.get(KEY_LIGHT_RED).toString())); + } else { + sbBlue.setProgress(0); + } - try { - showDataInUI(data); - } catch (JSONException e) { - e.printStackTrace(); - } + if (deviceStatu.get(KEY_SPEED).toString() != null) { + sbSpeed.setProgress(5 + Integer.parseInt(deviceStatu.get(KEY_SPEED).toString())); + } else { + sbSpeed.setProgress(5); + } + } - break; - case LOG: - StringBuilder sb = new StringBuilder(); - JSONObject jsonObject; - int logText = 1; - try { - jsonObject = new JSONObject(msg.obj.toString()); - for (int i = 0; i < jsonObject.length(); i++) { - if (jsonObject.getBoolean(jsonObject.names().getString(i)) != false) { - sb.append(jsonObject.names().getString(i) + " " + logText + "\r\n"); - } - } - } catch (JSONException e) { - e.printStackTrace(); - } - if (sb.length() != 0) { - Toast.makeText(GosDeviceControlActivity.this, sb.toString(), Toast.LENGTH_SHORT).show(); - } - break; - case TOAST: - String info = msg.obj + ""; - Toast.makeText(GosDeviceControlActivity.this, info, Toast.LENGTH_SHORT).show(); - break; - case HARDWARE: - showHardwareInfo((String) msg.obj); - break; + private void toastFaultsOrAlertsMessage(Message msg) { + StringBuilder sb = new StringBuilder(); + ConcurrentHashMap map = (ConcurrentHashMap) msg.obj; - case DISCONNECT: - String disconnectText = (String) getText(R.string.disconnect); - Toast.makeText(GosDeviceControlActivity.this, disconnectText, Toast.LENGTH_SHORT).show(); - mDevice.setSubscribe(false); - mDevice.setListener(null); - finish(); - break; + for (String key : map.keySet()) { + if ((Boolean) map.get(key)) { + sb.append(key + "1" + "\r\n"); } - } - }; - /** - * Show data in ui. - * - * @param data - * the data - * @throws JSONException - * the JSON exception - */ - @SuppressWarnings("rawtypes") - private void showDataInUI(String data) throws JSONException { - Log.i("revjson", data); - JSONObject receive = new JSONObject(data); - Iterator actions = receive.keys(); - while (actions.hasNext()) { - String param = actions.next().toString(); - Object value = receive.get(param); - deviceStatu.put(param, value); + if (sb.length() != 0) { + Toast.makeText(GosDeviceControlActivity.this, sb.toString(), Toast.LENGTH_SHORT).show(); } - Message msg = new Message(); - msg.obj = data; - msg.what = UPDATE_UI; - handler.sendMessage(msg); + } + + private void toastInfoMessage(Message msg) { + String info = msg.obj + ""; + Toast.makeText(GosDeviceControlActivity.this, info, Toast.LENGTH_SHORT).show(); } /** @@ -549,8 +529,12 @@ public class GosDeviceControlActivity extends GosControlModuleBaseActivity imple .setPositiveButton(R.string.besure, null).show(); } + /* + * 设备上报数据回调 + */ protected void didReceiveData(GizWifiErrorCode result, GizWifiDevice device, java.util.concurrent.ConcurrentHashMap dataMap, int sn) { + if (result != GizWifiErrorCode.GIZ_SDK_SUCCESS) { Message msg = new Message(); msg.what = TOAST; @@ -560,13 +544,15 @@ public class GosDeviceControlActivity extends GosControlModuleBaseActivity imple if (dataMap.isEmpty()) { return; } + progressDialog.cancel(); if (dataMap.get("data") != null) { Log.i("Apptest", dataMap.get("data").toString()); Message msg = new Message(); msg.obj = dataMap.get("data"); - msg.what = RESP; + deviceStatu = (ConcurrentHashMap) dataMap.get("data"); + msg.what = UPDATE_UI; handler.sendMessage(msg); } @@ -589,6 +575,9 @@ public class GosDeviceControlActivity extends GosControlModuleBaseActivity imple } } + /* + * 获取设备硬件信息回调 + */ protected void didGetHardwareInfo(GizWifiErrorCode result, GizWifiDevice device, java.util.concurrent.ConcurrentHashMap hardwareInfo) { Log.i("Apptest", hardwareInfo.toString()); @@ -618,6 +607,9 @@ public class GosDeviceControlActivity extends GosControlModuleBaseActivity imple handler.sendMessage(msg); } + /* + * 设置设备信息回调 + */ protected void didSetCustomInfo(GizWifiErrorCode result, GizWifiDevice device) { progressDialog.cancel(); Message msg = new Message(); @@ -632,11 +624,18 @@ public class GosDeviceControlActivity extends GosControlModuleBaseActivity imple handler.sendMessage(msg); } + /* + * 设备状态改变回调,只有设备状态为可控才可以下发控制命令 + */ protected void didUpdateNetStatus(GizWifiDevice device, GizWifiDeviceNetStatus netStatus) { if (device == mDevice) { if (GizWifiDeviceNetStatus.GizDeviceUnavailable == netStatus || GizWifiDeviceNetStatus.GizDeviceOffline == netStatus) { handler.sendEmptyMessage(DISCONNECT); + } else { + handler.removeCallbacks(mRunnable); + progressDialog.cancel(); + mDevice.getDeviceStatus(); } } } @@ -648,88 +647,64 @@ public class GosDeviceControlActivity extends GosControlModuleBaseActivity imple int redNum1 = sbRed.getProgress(); if (redNum1 < 254) { redNum1++; - try { - sendJson(KEY_LIGHT_RED, redNum1); - } catch (JSONException e) { - e.printStackTrace(); - } + sendCommand(KEY_LIGHT_RED, redNum1); + sbRed.setProgress(redNum1); } break; case R.id.redsub: int redNum2 = sbRed.getProgress(); if (redNum2 > 0) { redNum2--; - try { - sendJson(KEY_LIGHT_RED, redNum2); - } catch (JSONException e) { - e.printStackTrace(); - } + sendCommand(KEY_LIGHT_RED, redNum2); + sbRed.setProgress(redNum2); } break; case R.id.greenadd: int greenNum1 = sbGreen.getProgress(); if (greenNum1 < 254) { greenNum1++; - try { - sendJson(KEY_LIGHT_GREEN, greenNum1); - } catch (JSONException e) { - e.printStackTrace(); - } + sendCommand(KEY_LIGHT_GREEN, greenNum1); + sbGreen.setProgress(greenNum1); } break; case R.id.greensub: int greenNum2 = sbGreen.getProgress(); if (greenNum2 > 0) { greenNum2--; - try { - sendJson(KEY_LIGHT_GREEN, greenNum2); - } catch (JSONException e) { - e.printStackTrace(); - } + sendCommand(KEY_LIGHT_GREEN, greenNum2); + sbGreen.setProgress(greenNum2); } break; case R.id.blueadd: int blueNum1 = sbBlue.getProgress(); if (blueNum1 < 254) { blueNum1++; - try { - sendJson(KEY_LIGHT_BLUE, blueNum1); - } catch (JSONException e) { - e.printStackTrace(); - } + sendCommand(KEY_LIGHT_BLUE, blueNum1); + sbBlue.setProgress(blueNum1); } break; case R.id.bluesub: int blueNum2 = sbBlue.getProgress(); if (blueNum2 > 0) { blueNum2--; - try { - sendJson(KEY_LIGHT_BLUE, blueNum2); - } catch (JSONException e) { - e.printStackTrace(); - } + sendCommand(KEY_LIGHT_BLUE, blueNum2); + sbBlue.setProgress(blueNum2); } break; case R.id.speedadd: int speedNum1 = sbSpeed.getProgress(); if (speedNum1 < 10) { speedNum1++; - try { - sendJson(KEY_SPEED, speedNum1 - 5); - } catch (JSONException e) { - e.printStackTrace(); - } + sendCommand(KEY_SPEED, speedNum1 - 5); + sbSpeed.setProgress(speedNum1); } break; case R.id.speedsub: int speedNum2 = sbSpeed.getProgress(); if (speedNum2 > 0) { speedNum2--; - try { - sendJson(KEY_SPEED, speedNum2 - 5); - } catch (JSONException e) { - e.printStackTrace(); - } + sendCommand(KEY_SPEED, speedNum2 - 5); + sbSpeed.setProgress(speedNum2); } break; default: @@ -751,8 +726,6 @@ public class GosDeviceControlActivity extends GosControlModuleBaseActivity imple super.onOptionsItemSelected(menu); switch (menu.getItemId()) { case android.R.id.home: - mDevice.setSubscribe(false); - mDevice.setListener(null); finish(); break; @@ -794,6 +767,9 @@ public class GosDeviceControlActivity extends GosControlModuleBaseActivity imple return new String(hexChars); } + /** + * Description:设置设备别名与备注 + */ private void setDeviceInfo() { final Dialog dialog = new AlertDialog.Builder(this).setView(new EditText(this)).create(); @@ -842,8 +818,6 @@ public class GosDeviceControlActivity extends GosControlModuleBaseActivity imple @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { - mDevice.setSubscribe(false); - mDevice.setListener(null); finish(); } return false; diff --git a/src/com/gizwits/opensource/gokit/DeviceModule/GosDeviceListActivity.java b/src/com/gizwits/opensource/appkit/DeviceModule/GosDeviceListActivity.java similarity index 93% rename from src/com/gizwits/opensource/gokit/DeviceModule/GosDeviceListActivity.java rename to src/com/gizwits/opensource/appkit/DeviceModule/GosDeviceListActivity.java index 2ce9eca7bd594e23d762c98c9f5b285555bd9a72..2027043445c177f9f07a3d67fc3e57cec6ee6b98 100644 --- a/src/com/gizwits/opensource/gokit/DeviceModule/GosDeviceListActivity.java +++ b/src/com/gizwits/opensource/appkit/DeviceModule/GosDeviceListActivity.java @@ -1,4 +1,4 @@ -package com.gizwits.opensource.gokit.DeviceModule; +package com.gizwits.opensource.appkit.DeviceModule; import java.util.ArrayList; import java.util.List; @@ -9,14 +9,14 @@ import com.gizwits.gizwifisdk.api.GizWifiDevice; import com.gizwits.gizwifisdk.api.GizWifiSDK; import com.gizwits.gizwifisdk.enumration.GizWifiDeviceNetStatus; import com.gizwits.gizwifisdk.enumration.GizWifiErrorCode; -import com.gizwits.opensource.gokit.CommonModule.GosDeploy; -import com.gizwits.opensource.gokit.ConfigModule.GosAirlinkChooseDeviceWorkWiFiActivity; -import com.gizwits.opensource.gokit.ConfigModule.GosCheckDeviceWorkWiFiActivity; -import com.gizwits.opensource.gokit.ControlModule.GosDeviceControlActivity; -import com.gizwits.opensource.gokit.PushModule.GosPushManager; -import com.gizwits.opensource.gokit.SettingsModule.GosSettiingsActivity; -import com.gizwits.opensource.gokit.utils.NetUtils; -import com.gizwits.opensource.gokit.view.SlideListView2; +import com.gizwits.opensource.appkit.CommonModule.GosDeploy; +import com.gizwits.opensource.appkit.ConfigModule.GosAirlinkChooseDeviceWorkWiFiActivity; +import com.gizwits.opensource.appkit.ConfigModule.GosCheckDeviceWorkWiFiActivity; +import com.gizwits.opensource.appkit.ControlModule.GosDeviceControlActivity; +import com.gizwits.opensource.appkit.PushModule.GosPushManager; +import com.gizwits.opensource.appkit.SettingsModule.GosSettiingsActivity; +import com.gizwits.opensource.appkit.utils.NetUtils; +import com.gizwits.opensource.appkit.view.SlideListView2; import com.gizwits.opensource.gokit.R; import android.annotation.SuppressLint; @@ -164,7 +164,7 @@ public class GosDeviceListActivity extends GosDeviceModuleBaseActivity implement GizWifiSDK.sharedInstance().getBoundDevices(uid, token, ProductKeyList); } - if (loginStatus == 0) { + if (loginStatus == 0&&GosDeploy.setAnonymousLogin()) { loginStatus = 3; GizWifiSDK.sharedInstance().userLoginAnonymous(); } @@ -172,7 +172,7 @@ public class GosDeviceListActivity extends GosDeviceModuleBaseActivity implement break; case UPDATALIST: - + progressDialog.cancel(); UpdateUI(); break; @@ -196,7 +196,7 @@ public class GosDeviceListActivity extends GosDeviceModuleBaseActivity implement case TOAST: - Toast.makeText(GosDeviceListActivity.this, msg.obj.toString(), toastTime).show(); + Toast.makeText(GosDeviceListActivity.this, msg.obj.toString(), 2000).show(); break; case SHOWDIALOG: @@ -297,6 +297,9 @@ public class GosDeviceListActivity extends GosDeviceModuleBaseActivity implement @Override protected void onResume() { super.onResume(); + + GosDeviceModuleBaseActivity.deviceslist=GizWifiSDK.sharedInstance().getDeviceList(); + UpdateUI(); // TODO GosMessageHandler.getSingleInstance().SetHandler(handler); if (boundMessage.size() != 0) { progressDialog.show(); @@ -307,9 +310,6 @@ public class GosDeviceListActivity extends GosDeviceModuleBaseActivity implement } else { Log.i("Apptest", "ListSize:" + boundMessage.size()); } - } else { - GosDeviceModuleBaseActivity.deviceslist = GizWifiSDK.sharedInstance().getDeviceList(); - UpdateUI(); } } @@ -318,7 +318,7 @@ public class GosDeviceListActivity extends GosDeviceModuleBaseActivity implement public void onPause() { super.onPause(); boundMessage.clear(); - // TODO GosMessageHandler.getSingleInstance().SetHandler(null); + GosMessageHandler.getSingleInstance().SetHandler(null); } @@ -430,7 +430,10 @@ public class GosDeviceListActivity extends GosDeviceModuleBaseActivity implement GosPushManager.pushBindService(token); } else { loginStatus = 0; - tryUserLoginAnonymous(); + if(GosDeploy.setAnonymousLogin()){ + tryUserLoginAnonymous(); + } + } } @@ -438,7 +441,7 @@ public class GosDeviceListActivity extends GosDeviceModuleBaseActivity implement progressDialog.cancel(); if (GizWifiErrorCode.GIZ_SDK_SUCCESS != result) { // String unBoundFailed = (String) getText(R.string.unbound_failed); - Toast.makeText(this, toastError(result), toastTime).show(); + Toast.makeText(this, toastError(result), 2000).show(); } } @@ -470,7 +473,7 @@ public class GosDeviceListActivity extends GosDeviceModuleBaseActivity implement protected void didChannelIDBind(GizWifiErrorCode result) { Log.i("Apptest", result.toString()); if (GizWifiErrorCode.GIZ_SDK_SUCCESS != result) { - Toast.makeText(this, toastError(result), toastTime).show(); + Toast.makeText(this, toastError(result), 2000).show(); } } @@ -484,10 +487,10 @@ public class GosDeviceListActivity extends GosDeviceModuleBaseActivity implement protected void didBindDevice(int error, String errorMessage, String did) { progressDialog.cancel(); if (error != 0) { - Toast.makeText(this, R.string.bound_failed + "\n" + errorMessage, toastTime).show(); + Toast.makeText(this, R.string.bound_failed + "\n" + errorMessage, 2000).show(); } else { - Toast.makeText(this, R.string.bound_successful, toastTime).show(); + Toast.makeText(this, R.string.bound_successful, 2000).show(); } }; @@ -501,10 +504,10 @@ public class GosDeviceListActivity extends GosDeviceModuleBaseActivity implement protected void didBindDevice(GizWifiErrorCode result, java.lang.String did) { progressDialog.cancel(); if (result != GizWifiErrorCode.GIZ_SDK_SUCCESS) { - Toast.makeText(this, toastError(result), toastTime).show(); + Toast.makeText(this, toastError(result), 2000).show(); } else { - Toast.makeText(this, R.string.add_successful, toastTime).show(); + Toast.makeText(this, R.string.add_successful, 2000).show(); } } @@ -575,7 +578,7 @@ public class GosDeviceListActivity extends GosDeviceModuleBaseActivity implement break; case R.id.action_addDevice: if (!checkNetwork(GosDeviceListActivity.this)) { - Toast.makeText(GosDeviceListActivity.this, R.string.network_error, toastTime).show(); + Toast.makeText(GosDeviceListActivity.this, R.string.network_error, 2000).show(); } else { intent = new Intent(GosDeviceListActivity.this, GosAirlinkChooseDeviceWorkWiFiActivity.class); startActivity(intent); @@ -656,7 +659,7 @@ public class GosDeviceListActivity extends GosDeviceModuleBaseActivity implement case R.id.imgNoDevice: case R.id.btnNoDevice: if (!checkNetwork(GosDeviceListActivity.this)) { - Toast.makeText(GosDeviceListActivity.this, R.string.network_error, toastTime).show(); + Toast.makeText(GosDeviceListActivity.this, R.string.network_error, 2000).show(); return; } intent = new Intent(GosDeviceListActivity.this, GosAirlinkChooseDeviceWorkWiFiActivity.class); @@ -721,7 +724,7 @@ public class GosDeviceListActivity extends GosDeviceModuleBaseActivity implement } } - Toast.makeText(this, doubleClick, toastTime).show(); + Toast.makeText(this, doubleClick, 2000).show(); tExit = new Timer(); tExit.schedule(new TimerTask() { @Override diff --git a/src/com/gizwits/opensource/gokit/DeviceModule/GosDeviceListAdapter.java b/src/com/gizwits/opensource/appkit/DeviceModule/GosDeviceListAdapter.java similarity index 98% rename from src/com/gizwits/opensource/gokit/DeviceModule/GosDeviceListAdapter.java rename to src/com/gizwits/opensource/appkit/DeviceModule/GosDeviceListAdapter.java index 567c4d616ecc8f90cd027be446112a7fb49dd88d..a5ebb38f165ddb7ecb0a19bec7f24b7cc9866c36 100644 --- a/src/com/gizwits/opensource/gokit/DeviceModule/GosDeviceListAdapter.java +++ b/src/com/gizwits/opensource/appkit/DeviceModule/GosDeviceListAdapter.java @@ -1,4 +1,4 @@ -package com.gizwits.opensource.gokit.DeviceModule; +package com.gizwits.opensource.appkit.DeviceModule; import java.util.List; diff --git a/src/com/gizwits/opensource/gokit/DeviceModule/GosDeviceModuleBaseActivity.java b/src/com/gizwits/opensource/appkit/DeviceModule/GosDeviceModuleBaseActivity.java similarity index 96% rename from src/com/gizwits/opensource/gokit/DeviceModule/GosDeviceModuleBaseActivity.java rename to src/com/gizwits/opensource/appkit/DeviceModule/GosDeviceModuleBaseActivity.java index b85b72e2a27aaf0f830e1f6eabb89b61a4e229bd..d9ae950b2a1f16ead689d4c9bacd89fe14d11586 100644 --- a/src/com/gizwits/opensource/gokit/DeviceModule/GosDeviceModuleBaseActivity.java +++ b/src/com/gizwits/opensource/appkit/DeviceModule/GosDeviceModuleBaseActivity.java @@ -1,4 +1,4 @@ -package com.gizwits.opensource.gokit.DeviceModule; +package com.gizwits.opensource.appkit.DeviceModule; import java.util.ArrayList; import java.util.List; @@ -8,7 +8,7 @@ import com.gizwits.gizwifisdk.api.GizWifiSDK; import com.gizwits.gizwifisdk.enumration.GizWifiErrorCode; import com.gizwits.gizwifisdk.listener.GizWifiDeviceListener; import com.gizwits.gizwifisdk.listener.GizWifiSDKListener; -import com.gizwits.opensource.gokit.CommonModule.GosBaseActivity; +import com.gizwits.opensource.appkit.CommonModule.GosBaseActivity; public class GosDeviceModuleBaseActivity extends GosBaseActivity { diff --git a/src/com/gizwits/opensource/gokit/DeviceModule/GosMessageHandler.java b/src/com/gizwits/opensource/appkit/DeviceModule/GosMessageHandler.java similarity index 73% rename from src/com/gizwits/opensource/gokit/DeviceModule/GosMessageHandler.java rename to src/com/gizwits/opensource/appkit/DeviceModule/GosMessageHandler.java index 89ecd02396de1175e49f9654e1998741355adc4c..878a25a2f19c72d5fb3929492e18a8b5b588ffd8 100644 --- a/src/com/gizwits/opensource/gokit/DeviceModule/GosMessageHandler.java +++ b/src/com/gizwits/opensource/appkit/DeviceModule/GosMessageHandler.java @@ -1,4 +1,4 @@ -package com.gizwits.opensource.gokit.DeviceModule; +package com.gizwits.opensource.appkit.DeviceModule; import java.util.ArrayList; import java.util.List; @@ -14,9 +14,9 @@ import android.os.Looper; import android.os.Message; import android.widget.RemoteViews; -import com.gizwits.opensource.gokit.CommonModule.GosBaseActivity; -import com.gizwits.opensource.gokit.ConfigModule.GosCheckDeviceWorkWiFiActivity; -import com.gizwits.opensource.gokit.utils.NetUtils; +import com.gizwits.opensource.appkit.CommonModule.GosBaseActivity; +import com.gizwits.opensource.appkit.ConfigModule.GosCheckDeviceWorkWiFiActivity; +import com.gizwits.opensource.appkit.utils.NetUtils; import com.gizwits.opensource.gokit.R; public class GosMessageHandler { @@ -71,19 +71,26 @@ public class GosMessageHandler { return; } newDeviceList.clear(); - List currentWifiScanResult = NetUtils.getCurrentWifiScanResult(mcContext); + List currentWifiScanResult = NetUtils + .getCurrentWifiScanResult(mcContext); int flog = 0; - 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++; - send(ssid, flog); + 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++; + send(ssid, flog); + } } } + if (mainHandler != null && newDeviceList.size() > 0) { mainHandler.sendEmptyMessage(SHOWDIALOG); } @@ -100,7 +107,8 @@ public class GosMessageHandler { title = (String) mcContext.getText(R.string.not_title); text = (String) mcContext.getText(R.string.not_text); // 创建一个启动其他Activity的Intent - Intent intent = new Intent(mcContext, GosCheckDeviceWorkWiFiActivity.class); + Intent intent = new Intent(mcContext, + GosCheckDeviceWorkWiFiActivity.class); intent.putExtra("softssid", ssid); PendingIntent pi = PendingIntent.getActivity(mcContext, 0, intent, 0); Notification notify = new Notification(); @@ -113,7 +121,8 @@ public class GosMessageHandler { notify.flags = Notification.FLAG_AUTO_CANCEL; // 构造通知内容布局 - RemoteViews rv = new RemoteViews(mcContext.getPackageName(), R.layout.view_gos_notification); + RemoteViews rv = new RemoteViews(mcContext.getPackageName(), + R.layout.view_gos_notification); // 设置通知内容的标题 rv.setTextViewText(R.id.tvContentTitle, title); // 设置通知内容 diff --git a/src/com/gizwits/opensource/appkit/GosApplication.java b/src/com/gizwits/opensource/appkit/GosApplication.java new file mode 100644 index 0000000000000000000000000000000000000000..e2be5ffe2c27a4a7079f65f4ff2ba07f10e12f74 --- /dev/null +++ b/src/com/gizwits/opensource/appkit/GosApplication.java @@ -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(); + + } +} diff --git a/src/com/gizwits/opensource/appkit/MessageCenter.java b/src/com/gizwits/opensource/appkit/MessageCenter.java new file mode 100644 index 0000000000000000000000000000000000000000..c493f3080b7d07ccfea81c567a3d9f2ef1d22450 --- /dev/null +++ b/src/com/gizwits/opensource/appkit/MessageCenter.java @@ -0,0 +1,69 @@ +package com.gizwits.opensource.appkit; + +import java.util.concurrent.ConcurrentHashMap; + +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.GosDeploy; +import com.gizwits.opensource.gokit.R; + +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); + String AppID = GosDeploy.setAppID(); + String AppSecret = GosDeploy.setAppSecret(); + if (TextUtils.isEmpty(AppID) || AppID.contains("your_app_id") || TextUtils.isEmpty(AppSecret) + || AppSecret.contains("your_app_secret")) { + 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 serverMap = new ConcurrentHashMap(); + + serverMap.put("openAPIInfo", TextUtils.isEmpty((String) GosDeploy.infoMap.get("openAPIDomain")) + ? "api.gizwits.com" : (String) GosDeploy.infoMap.get("openAPIDomain")); + serverMap.put("siteInfo", TextUtils.isEmpty((String) GosDeploy.infoMap.get("siteDomain")) + ? "site.gizwits.com" : (String) GosDeploy.infoMap.get("siteDomain")); + serverMap.put("pushInfo", (String) GosDeploy.infoMap.get("pushDomain")); + GizWifiSDK.sharedInstance().startWithAppID(c, AppID, GosDeploy.setProductKeyList(), serverMap, 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); + + }; + }; + +} \ No newline at end of file diff --git a/src/com/gizwits/opensource/gokit/PushModule/BaiDuPushReceiver.java b/src/com/gizwits/opensource/appkit/PushModule/BaiDuPushReceiver.java similarity index 96% rename from src/com/gizwits/opensource/gokit/PushModule/BaiDuPushReceiver.java rename to src/com/gizwits/opensource/appkit/PushModule/BaiDuPushReceiver.java index 1a65cc9c275c7fef036a2eb58510f21416116687..bf89c1e7f7e50764b658a528ba60b955463f8e52 100644 --- a/src/com/gizwits/opensource/gokit/PushModule/BaiDuPushReceiver.java +++ b/src/com/gizwits/opensource/appkit/PushModule/BaiDuPushReceiver.java @@ -1,4 +1,4 @@ -package com.gizwits.opensource.gokit.PushModule; +package com.gizwits.opensource.appkit.PushModule; import java.util.List; diff --git a/src/com/gizwits/opensource/gokit/PushModule/GosPushManager.java b/src/com/gizwits/opensource/appkit/PushModule/GosPushManager.java similarity index 90% rename from src/com/gizwits/opensource/gokit/PushModule/GosPushManager.java rename to src/com/gizwits/opensource/appkit/PushModule/GosPushManager.java index f082fbd03bb60edcac468f2b249d0d3d6bb02c39..00853dd1068ee20753128b3a55a882544a808562 100644 --- a/src/com/gizwits/opensource/gokit/PushModule/GosPushManager.java +++ b/src/com/gizwits/opensource/appkit/PushModule/GosPushManager.java @@ -1,15 +1,15 @@ -package com.gizwits.opensource.gokit.PushModule; +package com.gizwits.opensource.appkit.PushModule; import java.util.Set; import com.baidu.android.pushservice.PushConstants; import com.baidu.android.pushservice.PushManager; +import com.baidu.android.pushservice.PushSettings; import com.gizwits.gizwifisdk.api.GizWifiSDK; import com.gizwits.gizwifisdk.enumration.GizPushType; import com.gizwits.opensource.gokit.R; -import com.gizwits.opensource.gokit.CommonModule.GosBaseActivity; -import com.gizwits.opensource.gokit.CommonModule.GosDeploy; - +import com.gizwits.opensource.appkit.CommonModule.GosBaseActivity; +import com.gizwits.opensource.appkit.CommonModule.GosDeploy; import android.content.Context; import android.text.TextUtils; import android.util.Log; @@ -56,11 +56,14 @@ public class GosPushManager { } public void bDPush() { - String BDPushAppKey = GosDeploy.setBaiDuPushAppKey(); + final String BDPushAppKey = GosDeploy.setBaiDuPushAppKey(); 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); + } } diff --git a/src/com/gizwits/opensource/gokit/PushModule/JPushReceiver.java b/src/com/gizwits/opensource/appkit/PushModule/JPushReceiver.java similarity index 82% rename from src/com/gizwits/opensource/gokit/PushModule/JPushReceiver.java rename to src/com/gizwits/opensource/appkit/PushModule/JPushReceiver.java index 11a05a38419f1849bb10633e9223351e4182ec17..a85fd2fccddd454743fa04c472a2eeaf810f0bb1 100644 --- a/src/com/gizwits/opensource/gokit/PushModule/JPushReceiver.java +++ b/src/com/gizwits/opensource/appkit/PushModule/JPushReceiver.java @@ -1,4 +1,4 @@ -package com.gizwits.opensource.gokit.PushModule; +package com.gizwits.opensource.appkit.PushModule; import android.content.BroadcastReceiver; import android.content.Context; diff --git a/src/com/gizwits/opensource/gokit/SettingsModule/GosAboutActivity.java b/src/com/gizwits/opensource/appkit/SettingsModule/GosAboutActivity.java similarity index 93% rename from src/com/gizwits/opensource/gokit/SettingsModule/GosAboutActivity.java rename to src/com/gizwits/opensource/appkit/SettingsModule/GosAboutActivity.java index ccbf5e90093f8cb848d1a9808c40d5ed496dc3ba..c1d8063b1caf57de3da5d11bf9509dd4e0683624 100644 --- a/src/com/gizwits/opensource/gokit/SettingsModule/GosAboutActivity.java +++ b/src/com/gizwits/opensource/appkit/SettingsModule/GosAboutActivity.java @@ -1,8 +1,8 @@ -package com.gizwits.opensource.gokit.SettingsModule; +package com.gizwits.opensource.appkit.SettingsModule; import com.gizwits.gizwifisdk.api.GizWifiSDK; +import com.gizwits.opensource.appkit.CommonModule.GosBaseActivity; import com.gizwits.opensource.gokit.R; -import com.gizwits.opensource.gokit.CommonModule.GosBaseActivity; import android.app.ActionBar; import android.content.Context; diff --git a/src/com/gizwits/opensource/gokit/SettingsModule/GosSettiingsActivity.java b/src/com/gizwits/opensource/appkit/SettingsModule/GosSettiingsActivity.java similarity index 91% rename from src/com/gizwits/opensource/gokit/SettingsModule/GosSettiingsActivity.java rename to src/com/gizwits/opensource/appkit/SettingsModule/GosSettiingsActivity.java index 83e9279d05890b51a060fd94129ad5aaf390f409..08d827476ac25c2ce44355ab6b61fca5734933aa 100644 --- a/src/com/gizwits/opensource/gokit/SettingsModule/GosSettiingsActivity.java +++ b/src/com/gizwits/opensource/appkit/SettingsModule/GosSettiingsActivity.java @@ -1,7 +1,7 @@ -package com.gizwits.opensource.gokit.SettingsModule; +package com.gizwits.opensource.appkit.SettingsModule; +import com.gizwits.opensource.appkit.CommonModule.GosBaseActivity; import com.gizwits.opensource.gokit.R; -import com.gizwits.opensource.gokit.CommonModule.GosBaseActivity; import android.content.Intent; import android.os.Bundle; diff --git a/src/com/gizwits/opensource/gokit/ThirdAccountModule/BaseUiListener.java b/src/com/gizwits/opensource/appkit/ThirdAccountModule/BaseUiListener.java similarity index 88% rename from src/com/gizwits/opensource/gokit/ThirdAccountModule/BaseUiListener.java rename to src/com/gizwits/opensource/appkit/ThirdAccountModule/BaseUiListener.java index 158b39fba5817dcdc2550da4b865440bf9ab1bfc..b9c52fe6da0b296cdcbeb66f1bcee6d23045fff5 100644 --- a/src/com/gizwits/opensource/gokit/ThirdAccountModule/BaseUiListener.java +++ b/src/com/gizwits/opensource/appkit/ThirdAccountModule/BaseUiListener.java @@ -1,4 +1,4 @@ -package com.gizwits.opensource.gokit.ThirdAccountModule; +package com.gizwits.opensource.appkit.ThirdAccountModule; import org.json.JSONObject; diff --git a/src/com/gizwits/opensource/gokit/UserModule/GosForgetPasswordActivity.java b/src/com/gizwits/opensource/appkit/UserModule/GosForgetPasswordActivity.java similarity index 93% rename from src/com/gizwits/opensource/gokit/UserModule/GosForgetPasswordActivity.java rename to src/com/gizwits/opensource/appkit/UserModule/GosForgetPasswordActivity.java index 12f0edf4c88e19dd672b7db4138e0807d2b05172..0cb0d69d757c1002dd9c99f44b3b63469702c455 100644 --- a/src/com/gizwits/opensource/gokit/UserModule/GosForgetPasswordActivity.java +++ b/src/com/gizwits/opensource/appkit/UserModule/GosForgetPasswordActivity.java @@ -1,4 +1,4 @@ -package com.gizwits.opensource.gokit.UserModule; +package com.gizwits.opensource.appkit.UserModule; import java.util.Timer; import java.util.TimerTask; @@ -6,8 +6,8 @@ import java.util.TimerTask; 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 com.gizwits.opensource.gokit.R; -import com.gizwits.opensource.gokit.CommonModule.GosDeploy; import android.annotation.SuppressLint; import android.content.Context; @@ -46,7 +46,7 @@ public class GosForgetPasswordActivity extends GosUserModuleBaseActivity impleme /** The cb Laws */ private CheckBox cbLaws; - + /** The Button Drawable */ GradientDrawable drawable; @@ -150,7 +150,7 @@ public class GosForgetPasswordActivity extends GosUserModuleBaseActivity impleme cbLaws = (CheckBox) findViewById(R.id.cbLaws); // 配置文件部署 - drawable =(GradientDrawable) GosDeploy.setButtonBackgroundColor(); + drawable = (GradientDrawable) GosDeploy.setButtonBackgroundColor(); drawable.setCornerRadius(30); btnGetCode.setBackgroundDrawable(drawable); btnReset.setBackgroundDrawable(GosDeploy.setButtonBackgroundColor()); @@ -239,8 +239,10 @@ public class GosForgetPasswordActivity extends GosUserModuleBaseActivity impleme 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); + msg.obj = toastError(result);// sendFailed + "\n" + + // errorMessage;toastError(errorCode) handler.sendMessage(msg); } else { handler.sendEmptyMessage(handler_key.SENDSUCCESSFUL.ordinal()); @@ -257,8 +259,9 @@ public class GosForgetPasswordActivity extends GosUserModuleBaseActivity impleme 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); + msg.obj = toastError(result);// resetFailed + "\n" + errorMessage; handler.sendMessage(msg); } else { msg.what = handler_key.TOAST.ordinal(); diff --git a/src/com/gizwits/opensource/gokit/UserModule/GosRegisterUserActivity.java b/src/com/gizwits/opensource/appkit/UserModule/GosRegisterUserActivity.java similarity index 98% rename from src/com/gizwits/opensource/gokit/UserModule/GosRegisterUserActivity.java rename to src/com/gizwits/opensource/appkit/UserModule/GosRegisterUserActivity.java index 755d17820ef0f1414e566300a9d4a036c0f41b0b..022873cc99b27a43fe03c5e4ed90bb99e576dfd3 100644 --- a/src/com/gizwits/opensource/gokit/UserModule/GosRegisterUserActivity.java +++ b/src/com/gizwits/opensource/appkit/UserModule/GosRegisterUserActivity.java @@ -1,14 +1,12 @@ -package com.gizwits.opensource.gokit.UserModule; +package com.gizwits.opensource.appkit.UserModule; import java.util.Timer; import java.util.TimerTask; - 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 com.gizwits.opensource.gokit.R; -import com.gizwits.opensource.gokit.CommonModule.GosDeploy; - import android.annotation.SuppressLint; import android.content.Context; import android.graphics.drawable.GradientDrawable; diff --git a/src/com/gizwits/opensource/gokit/UserModule/GosUserLoginActivity.java b/src/com/gizwits/opensource/appkit/UserModule/GosUserLoginActivity.java similarity index 89% rename from src/com/gizwits/opensource/gokit/UserModule/GosUserLoginActivity.java rename to src/com/gizwits/opensource/appkit/UserModule/GosUserLoginActivity.java index 8c6bc50f3e813d4ff9c2dbc97747dad3273f80e3..9a81b9606d0508bac8cb4919133620acc1aa22d3 100644 --- a/src/com/gizwits/opensource/gokit/UserModule/GosUserLoginActivity.java +++ b/src/com/gizwits/opensource/appkit/UserModule/GosUserLoginActivity.java @@ -1,24 +1,11 @@ -package com.gizwits.opensource.gokit.UserModule; +package com.gizwits.opensource.appkit.UserModule; import java.util.Timer; import java.util.TimerTask; + import org.json.JSONException; import org.json.JSONObject; -import com.gizwits.gizwifisdk.api.GizWifiSDK; -import com.gizwits.gizwifisdk.enumration.GizThirdAccountType; -import com.gizwits.gizwifisdk.enumration.GizWifiErrorCode; -import com.gizwits.opensource.gokit.CommonModule.GosBaseActivity; -import com.gizwits.opensource.gokit.CommonModule.GosDeploy; -import com.gizwits.opensource.gokit.DeviceModule.GosDeviceListActivity; -import com.gizwits.opensource.gokit.PushModule.GosPushManager; -import com.gizwits.opensource.gokit.ThirdAccountModule.BaseUiListener; -import com.gizwits.opensource.gokit.GosApplication; -import com.gizwits.opensource.gokit.R; -import com.tencent.mm.sdk.modelmsg.SendAuth; -import com.tencent.mm.sdk.openapi.IWXAPI; -import com.tencent.mm.sdk.openapi.WXAPIFactory; -import com.tencent.tauth.IUiListener; -import com.tencent.tauth.Tencent; + import android.annotation.SuppressLint; import android.content.Intent; import android.os.Bundle; @@ -39,6 +26,23 @@ import android.widget.TextView; import android.widget.Toast; import cn.jpush.android.api.JPushInterface; +import com.gizwits.gizwifisdk.api.GizWifiSDK; +import com.gizwits.gizwifisdk.enumration.GizThirdAccountType; +import com.gizwits.gizwifisdk.enumration.GizWifiErrorCode; +import com.gizwits.opensource.appkit.GosApplication; +import com.gizwits.opensource.gokit.R; +import com.gizwits.opensource.appkit.CommonModule.GosBaseActivity; +import com.gizwits.opensource.appkit.CommonModule.GosDeploy; +import com.gizwits.opensource.appkit.DeviceModule.GosDeviceListActivity; +import com.gizwits.opensource.appkit.PushModule.GosPushManager; +import com.gizwits.opensource.appkit.ThirdAccountModule.BaseUiListener; +import com.gizwits.opensource.appkit.view.DotView; +import com.tencent.mm.sdk.modelmsg.SendAuth; +import com.tencent.mm.sdk.openapi.IWXAPI; +import com.tencent.mm.sdk.openapi.WXAPIFactory; +import com.tencent.tauth.IUiListener; +import com.tencent.tauth.Tencent; + @SuppressLint("HandlerLeak") public class GosUserLoginActivity extends GosUserModuleBaseActivity implements OnClickListener { @@ -83,12 +87,8 @@ public class GosUserLoginActivity extends GosUserModuleBaseActivity implements O /** The IUiListener */ IUiListener listener; - // The Intent Intent intent; - // // The String - // String name, psw; - /** The GizThirdAccountType */ public static GizThirdAccountType gizThirdAccountType; @@ -151,10 +151,10 @@ public class GosUserLoginActivity extends GosUserModuleBaseActivity implements O return; } } - if (GosApplication.flag!=0) { + if (GosApplication.flag != 0) { GosBaseActivity.noIDAlert(this, R.string.AppID_Toast); } - + // 在配置文件中选择推送类型(0:不开启推送,1:极光推送,2:百度推送。默认为0) gosPushManager = new GosPushManager(GosDeploy.setPushType(), this); @@ -169,23 +169,17 @@ public class GosUserLoginActivity extends GosUserModuleBaseActivity implements O protected void onResume() { super.onResume(); - etName.setText(""); - etPsw.setText(""); - etName.requestFocus(); JPushInterface.onResume(this); autoLogin(); } private void autoLogin() { - if (TextUtils.isEmpty(spf.getString("UserName", ""))) { - return; - } - if (TextUtils.isEmpty(spf.getString("PassWord", ""))) { + if (TextUtils.isEmpty(spf.getString("UserName", "")) || TextUtils.isEmpty(spf.getString("PassWord", ""))) { return; } - baseHandler.sendEmptyMessage(handler_key.AUTO_LOGIN.ordinal()); + baseHandler.sendEmptyMessageDelayed(handler_key.AUTO_LOGIN.ordinal(), 1000); } @Override @@ -203,15 +197,34 @@ public class GosUserLoginActivity extends GosUserModuleBaseActivity implements O tvPass = (TextView) findViewById(R.id.tvPass); cbLaws = (CheckBox) findViewById(R.id.cbLaws); + DotView DotView = (com.gizwits.opensource.appkit.view.DotView) findViewById(R.id.dotView1); llQQ = (LinearLayout) findViewById(R.id.llQQ); llWechat = (LinearLayout) findViewById(R.id.llWechat); - + String setTencentAppID = GosDeploy.setTencentAppID(); + String setWechatAppID = GosDeploy.setWechatAppID(); + // 判断腾讯和微信是否需要隐藏和显示 + setWechatOrTencentIsVisable(DotView); // 配置文件部署 btnLogin.setBackgroundDrawable(GosDeploy.setButtonBackgroundColor()); btnLogin.setTextColor(GosDeploy.setButtonTextColor()); } + protected void setWechatOrTencentIsVisable(DotView DotView) { + if (!GosDeploy.setWechat()) { + + llWechat.setVisibility(View.GONE); + } + if (!GosDeploy.setQQ()) { + + llQQ.setVisibility(View.GONE); + } + + if (!GosDeploy.setWechat() && !GosDeploy.setQQ()) { + DotView.setVisibility(View.GONE); + } + } + private void initEvent() { btnLogin.setOnClickListener(this); tvRegister.setOnClickListener(this); @@ -271,7 +284,6 @@ public class GosUserLoginActivity extends GosUserModuleBaseActivity implements O noIDAlert(this, R.string.TencentAPPID_Toast); return; } else { - Log.e("aaaaaaaaaaaaaaaaaaaaaaaaaaaaa", GosDeploy.setTencentAppID()); // 启动QQ登录SDK mTencent = Tencent.createInstance(GosDeploy.setTencentAppID(), this.getApplicationContext()); } @@ -284,7 +296,6 @@ public class GosUserLoginActivity extends GosUserModuleBaseActivity implements O gizThirdAccountType = GizThirdAccountType.GizThirdQQ; thirdUid = values.getString("openid").toString(); thirdToken = values.getString("access_token").toString(); - Log.e("AAAAAAAAAAAAAAAA", thirdToken); msg.what = handler_key.THRED_LOGIN.ordinal(); baseHandler.sendMessage(msg); } else { @@ -308,13 +319,15 @@ public class GosUserLoginActivity extends GosUserModuleBaseActivity implements O noIDAlert(this, R.string.WechatAppID_Toast); return; } else { + + // 设置与WXEntryActivity共用Handler + setBaseHandler(baseHandler); + // 启动微信登录SDK mIwxapi = WXAPIFactory.createWXAPI(this, wechatAppID, true); // 将应用的AppID注册到微信 mIwxapi.registerApp(wechatAppID); - // 设置与WXEntryActivity共用Handler - setBaseHandler(baseHandler); } if (!(mIwxapi.isWXAppInstalled() && mIwxapi.isWXAppSupportAPI())) { diff --git a/src/com/gizwits/opensource/gokit/UserModule/GosUserModuleBaseActivity.java b/src/com/gizwits/opensource/appkit/UserModule/GosUserModuleBaseActivity.java similarity index 96% rename from src/com/gizwits/opensource/gokit/UserModule/GosUserModuleBaseActivity.java rename to src/com/gizwits/opensource/appkit/UserModule/GosUserModuleBaseActivity.java index fd1376203e8dc668d727ebe002b7c3092ebb5659..569f784c7e9441d843d8d18c903e02cfba4b88c7 100644 --- a/src/com/gizwits/opensource/gokit/UserModule/GosUserModuleBaseActivity.java +++ b/src/com/gizwits/opensource/appkit/UserModule/GosUserModuleBaseActivity.java @@ -1,10 +1,9 @@ -package com.gizwits.opensource.gokit.UserModule; +package com.gizwits.opensource.appkit.UserModule; import com.gizwits.gizwifisdk.api.GizWifiSDK; import com.gizwits.gizwifisdk.enumration.GizWifiErrorCode; import com.gizwits.gizwifisdk.listener.GizWifiSDKListener; -import com.gizwits.opensource.gokit.CommonModule.GosBaseActivity; - +import com.gizwits.opensource.appkit.CommonModule.GosBaseActivity; import android.view.MenuItem; public class GosUserModuleBaseActivity extends GosBaseActivity { diff --git a/src/com/gizwits/opensource/appkit/utils/AssetsUtils.java b/src/com/gizwits/opensource/appkit/utils/AssetsUtils.java new file mode 100644 index 0000000000000000000000000000000000000000..e5922be9858126e65e0035ed3d4996bebbfb959f --- /dev/null +++ b/src/com/gizwits/opensource/appkit/utils/AssetsUtils.java @@ -0,0 +1,63 @@ +package com.gizwits.opensource.appkit.utils; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; + +import android.content.Context; + +import com.gizwits.opensource.appkit.CommonModule.GosDeploy; + +public class AssetsUtils { + + public static void assetsDataToSD(String fileOutPutName, + String fileInPutName, Context context) throws IOException { + InputStream myInput; + File file = new File(fileOutPutName); + /*if (!file.exists()) { + file.createNewFile(); + }else { + return; + }*/ + OutputStream myOutput = new FileOutputStream(fileOutPutName); + myInput = context.getAssets().open(fileInPutName); + byte[] buffer = new byte[1024]; + int length = myInput.read(buffer); + while (length > 0) { + myOutput.write(buffer, 0, length); + length = myInput.read(buffer); + } + + myOutput.flush(); + myInput.close(); + myOutput.close(); + } + + + + public static void saveFile(String str) { + String filePath = null; + + + filePath = GosDeploy.fileOutName; + try { + if(filePath!=null){ + File file = new File(filePath); + if (!file.exists()) { + File dir = new File(file.getParent()); + dir.mkdirs(); + file.createNewFile(); + } + FileOutputStream outStream = new FileOutputStream(file); + outStream.write(str.getBytes()); + outStream.close(); + } + + } catch (Exception e) { + e.printStackTrace(); + } +} + +} diff --git a/src/com/gizwits/opensource/gokit/utils/HTTPSTrustManager.java b/src/com/gizwits/opensource/appkit/utils/HTTPSTrustManager.java similarity index 98% rename from src/com/gizwits/opensource/gokit/utils/HTTPSTrustManager.java rename to src/com/gizwits/opensource/appkit/utils/HTTPSTrustManager.java index 4012a4ecd52cc96a99d381353584f082144e203a..16be05edff467f82643eeb44714306274f44ad34 100644 --- a/src/com/gizwits/opensource/gokit/utils/HTTPSTrustManager.java +++ b/src/com/gizwits/opensource/appkit/utils/HTTPSTrustManager.java @@ -1,4 +1,4 @@ -package com.gizwits.opensource.gokit.utils; +package com.gizwits.opensource.appkit.utils; import java.security.KeyManagementException; import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; diff --git a/src/com/gizwits/opensource/gokit/utils/JsonUtils.java b/src/com/gizwits/opensource/appkit/utils/JsonUtils.java similarity index 98% rename from src/com/gizwits/opensource/gokit/utils/JsonUtils.java rename to src/com/gizwits/opensource/appkit/utils/JsonUtils.java index 9ad09c93b34767fe83daaf702efe3336a136dcae..25e65295b185f8053dc0e260b04ad296a8e672b5 100644 --- a/src/com/gizwits/opensource/gokit/utils/JsonUtils.java +++ b/src/com/gizwits/opensource/appkit/utils/JsonUtils.java @@ -3,7 +3,7 @@ * @charset UTF-8 * @author xiongxunxiang */ -package com.gizwits.opensource.gokit.utils; +package com.gizwits.opensource.appkit.utils; import java.io.BufferedReader; import java.io.IOException; diff --git a/src/com/gizwits/opensource/gokit/utils/NetUtils.java b/src/com/gizwits/opensource/appkit/utils/NetUtils.java similarity index 95% rename from src/com/gizwits/opensource/gokit/utils/NetUtils.java rename to src/com/gizwits/opensource/appkit/utils/NetUtils.java index 9a6fb30fbbc0ba99da2555183a81f039b87eab87..f90001061161415cf41578c8be87f103375bac71 100644 --- a/src/com/gizwits/opensource/gokit/utils/NetUtils.java +++ b/src/com/gizwits/opensource/appkit/utils/NetUtils.java @@ -15,7 +15,7 @@ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.gizwits.opensource.gokit.utils; +package com.gizwits.opensource.appkit.utils; import java.util.List; @@ -127,10 +127,14 @@ public class NetUtils { if (context != null) { WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); WifiInfo wifiInfo = wifiManager.getConnectionInfo(); - ssid = wifiInfo.getSSID(); - if (ssid.substring(0, 1).equals("\"") && ssid.substring(ssid.length() - 1).equals("\"")) { - ssid = ssid.substring(1, ssid.length() - 1); + + if(wifiInfo!=null){ + ssid = wifiInfo.getSSID(); + if (ssid.substring(0, 1).equals("\"") && ssid.substring(ssid.length() - 1).equals("\"")) { + ssid = ssid.substring(1, ssid.length() - 1); + } } + } return ssid; } @@ -149,10 +153,13 @@ public class NetUtils { } static public String getConnectWifiSsid(Context c) { + String ssid = ""; WifiManager wifiManager = (WifiManager) c.getSystemService(Context.WIFI_SERVICE); WifiInfo wifiInfo = wifiManager.getConnectionInfo(); - - return wifiInfo.getSSID(); + if(wifiInfo!=null){ + ssid = wifiInfo.getSSID(); + } + return ssid; } // 以下是获得版本信息的工具方法 diff --git a/src/com/gizwits/opensource/gokit/utils/TrustAllSSLSocketFactory.java b/src/com/gizwits/opensource/appkit/utils/TrustAllSSLSocketFactory.java similarity index 98% rename from src/com/gizwits/opensource/gokit/utils/TrustAllSSLSocketFactory.java rename to src/com/gizwits/opensource/appkit/utils/TrustAllSSLSocketFactory.java index 8ad5d8c76844848c3e3105037142561bd6c68476..cb16e2aa08b907d479a421196cee2ef370a79110 100644 --- a/src/com/gizwits/opensource/gokit/utils/TrustAllSSLSocketFactory.java +++ b/src/com/gizwits/opensource/appkit/utils/TrustAllSSLSocketFactory.java @@ -1,4 +1,4 @@ -package com.gizwits.opensource.gokit.utils; +package com.gizwits.opensource.appkit.utils; import java.io.IOException; import java.lang.reflect.Field; diff --git a/src/com/gizwits/opensource/gokit/view/DotView.java b/src/com/gizwits/opensource/appkit/view/DotView.java similarity index 96% rename from src/com/gizwits/opensource/gokit/view/DotView.java rename to src/com/gizwits/opensource/appkit/view/DotView.java index ea938e24b29465f17179bb93ee4f8d02e53dc58f..31c2e41120d21431450bcda2f4978401103a943e 100644 --- a/src/com/gizwits/opensource/gokit/view/DotView.java +++ b/src/com/gizwits/opensource/appkit/view/DotView.java @@ -1,4 +1,4 @@ -package com.gizwits.opensource.gokit.view; +package com.gizwits.opensource.appkit.view; import com.gizwits.opensource.gokit.R; diff --git a/src/com/gizwits/opensource/gokit/view/GifView.java b/src/com/gizwits/opensource/appkit/view/GifView.java similarity index 99% rename from src/com/gizwits/opensource/gokit/view/GifView.java rename to src/com/gizwits/opensource/appkit/view/GifView.java index 0c9b74b41c085bb26bdfea894784fd71accef6ac..b6dcf9f2d8eb945e5459ba7a322816626855cda0 100644 --- a/src/com/gizwits/opensource/gokit/view/GifView.java +++ b/src/com/gizwits/opensource/appkit/view/GifView.java @@ -1,4 +1,4 @@ -package com.gizwits.opensource.gokit.view; +package com.gizwits.opensource.appkit.view; import com.gizwits.opensource.gokit.R; diff --git a/src/com/gizwits/opensource/gokit/view/RoundProgressBar.java b/src/com/gizwits/opensource/appkit/view/RoundProgressBar.java similarity index 98% rename from src/com/gizwits/opensource/gokit/view/RoundProgressBar.java rename to src/com/gizwits/opensource/appkit/view/RoundProgressBar.java index b17d7dd5944356afcdfc6b1070bd6f3d0478ceb2..73c92de5ef7f3517866e824a187d069c80142da0 100644 --- a/src/com/gizwits/opensource/gokit/view/RoundProgressBar.java +++ b/src/com/gizwits/opensource/appkit/view/RoundProgressBar.java @@ -1,7 +1,7 @@ -package com.gizwits.opensource.gokit.view; +package com.gizwits.opensource.appkit.view; +import com.gizwits.opensource.appkit.CommonModule.GosDeploy; import com.gizwits.opensource.gokit.R; -import com.gizwits.opensource.gokit.CommonModule.GosDeploy; import android.content.Context; import android.content.res.TypedArray; diff --git a/src/com/gizwits/opensource/gokit/view/SlideListView2.java b/src/com/gizwits/opensource/appkit/view/SlideListView2.java similarity index 99% rename from src/com/gizwits/opensource/gokit/view/SlideListView2.java rename to src/com/gizwits/opensource/appkit/view/SlideListView2.java index 14b712a8affc7174b9f07c3d009c6301cabca18a..b69d95a19fb42889edd9e24583042d7ee1ef1f63 100644 --- a/src/com/gizwits/opensource/gokit/view/SlideListView2.java +++ b/src/com/gizwits/opensource/appkit/view/SlideListView2.java @@ -1,4 +1,4 @@ -package com.gizwits.opensource.gokit.view; +package com.gizwits.opensource.appkit.view; import android.annotation.SuppressLint; import android.content.Context; diff --git a/src/com/gizwits/opensource/gokit/wxapi/WXEntryActivity.java b/src/com/gizwits/opensource/appkit/wxapi/WXEntryActivity.java similarity index 91% rename from src/com/gizwits/opensource/gokit/wxapi/WXEntryActivity.java rename to src/com/gizwits/opensource/appkit/wxapi/WXEntryActivity.java index d0dcb29453f87026e80b4782ab0a9a86492eddb8..071853b99e8b99e83029ddaf5bbb0102fe7eaf16 100644 --- a/src/com/gizwits/opensource/gokit/wxapi/WXEntryActivity.java +++ b/src/com/gizwits/opensource/appkit/wxapi/WXEntryActivity.java @@ -1,14 +1,14 @@ -package com.gizwits.opensource.gokit.wxapi; +package com.gizwits.opensource.appkit.wxapi; import java.io.IOException; import org.apache.http.client.ClientProtocolException; import org.json.JSONException; import org.json.JSONObject; import com.gizwits.gizwifisdk.enumration.GizThirdAccountType; -import com.gizwits.opensource.gokit.CommonModule.GosBaseActivity; -import com.gizwits.opensource.gokit.CommonModule.GosDeploy; -import com.gizwits.opensource.gokit.UserModule.GosUserLoginActivity; -import com.gizwits.opensource.gokit.utils.JsonUtils; +import com.gizwits.opensource.appkit.CommonModule.GosBaseActivity; +import com.gizwits.opensource.appkit.CommonModule.GosDeploy; +import com.gizwits.opensource.appkit.UserModule.GosUserLoginActivity; +import com.gizwits.opensource.appkit.utils.JsonUtils; import com.tencent.mm.sdk.modelbase.BaseReq; import com.tencent.mm.sdk.modelbase.BaseResp; import com.tencent.mm.sdk.modelmsg.SendAuth; diff --git a/src/com/gizwits/opensource/gokit/GosApplication.java b/src/com/gizwits/opensource/gokit/GosApplication.java deleted file mode 100644 index 926d5e405ae3723a96e8e8c4b0979af610d60397..0000000000000000000000000000000000000000 --- a/src/com/gizwits/opensource/gokit/GosApplication.java +++ /dev/null @@ -1,88 +0,0 @@ -package com.gizwits.opensource.gokit; - -import java.util.concurrent.ConcurrentHashMap; -import com.gizwits.gizwifisdk.api.GizWifiSDK; -import com.gizwits.gizwifisdk.enumration.GizEventType; -import com.gizwits.gizwifisdk.enumration.GizLogPrintLevel; -import com.gizwits.gizwifisdk.enumration.GizWifiErrorCode; -import com.gizwits.gizwifisdk.listener.GizWifiSDKListener; -import com.gizwits.opensource.gokit.CommonModule.GosDeploy; - -import android.annotation.SuppressLint; -import android.app.Application; -import android.os.Handler; -import android.text.TextUtils; -import android.util.Log; - -public class GosApplication extends Application { - - - - public static int flag = 0; - - GosDeploy gosDeploy; - - ConcurrentHashMap cloudServiceMap = new ConcurrentHashMap(); - - @SuppressLint("HandlerLeak") - Handler handler = new Handler() { - public void handleMessage(android.os.Message msg) { - - // 设置日志打印级别 (默认all且生成文件至SD卡) - GizWifiSDK.sharedInstance().setLogLevel(GizLogPrintLevel.GizLogPrintAll); - - cloudServiceMap = GosDeploy.setCloudService(); - - if (!cloudServiceMap.isEmpty()) { - // 设置云端服务 - GizWifiSDK.sharedInstance().setCloudService(cloudServiceMap); - } - - }; - }; - - GizWifiSDKListener gizWifiSDKListener = new GizWifiSDKListener() { - - public void didNotifyEvent(com.gizwits.gizwifisdk.enumration.GizEventType eventType, Object eventSource, - com.gizwits.gizwifisdk.enumration.GizWifiErrorCode eventID, String eventMessage) { - if (GizEventType.GizEventSDK == eventType && GizWifiErrorCode.GIZ_SDK_START_SUCCESS == eventID) { - - } else { - Log.e("Apptest", "SDK UN OPEN/n" + eventMessage); - } - }; - - public void didGetCurrentCloudService(GizWifiErrorCode result, - java.util.concurrent.ConcurrentHashMap cloudServiceInfo) { - - if (GizWifiErrorCode.GIZ_SDK_SUCCESS != result) { - Log.e("Apptest", "CloudService Error: " + result.toString()); - } - }; - }; - - public void onCreate() { - super.onCreate(); - - // 读取配置文件 - gosDeploy = new GosDeploy(this); - String AppID = GosDeploy.setAppID(); - String AppSecret = GosDeploy.setAppSecret(); - - if (TextUtils.isEmpty(AppID) || AppID.contains("your_app_id") || TextUtils.isEmpty(AppSecret) - || AppSecret.contains("your_app_secret")) { - if (flag == 0) { - - } - flag++; - } else { - - // 启动SDK - GizWifiSDK.sharedInstance().startWithAppID(getApplicationContext(), AppID); - - // 设置日志等级和云端服务 - handler.sendEmptyMessageDelayed(0, 3000); - - } - }; -} diff --git a/src/zxing/CaptureActivity.java b/src/zxing/CaptureActivity.java index 0fbb6c9d00408fd32add0ffd2587ec6420c16922..d83d91eba4ae3c70375af82d73f2d5eb771bc471 100644 --- a/src/zxing/CaptureActivity.java +++ b/src/zxing/CaptureActivity.java @@ -42,9 +42,8 @@ import android.view.animation.TranslateAnimation; import android.widget.Button; import android.widget.ImageView; import android.widget.RelativeLayout; - +import com.gizwits.opensource.appkit.DeviceModule.GosDeviceListActivity; import com.gizwits.opensource.gokit.R; -import com.gizwits.opensource.gokit.DeviceModule.GosDeviceListActivity; import com.google.zxing.Result; /**