代码提交。
This commit is contained in:
commit
02e9633de5
|
@ -0,0 +1,11 @@
|
||||||
|
*.iml
|
||||||
|
.gradle
|
||||||
|
/local.properties
|
||||||
|
/.idea/workspace.xml
|
||||||
|
/.idea/libraries
|
||||||
|
.DS_Store
|
||||||
|
/build
|
||||||
|
/captures
|
||||||
|
.externalNativeBuild
|
||||||
|
.idea
|
||||||
|
.apk
|
|
@ -0,0 +1,72 @@
|
||||||
|
apply plugin: 'com.android.library'
|
||||||
|
repositories {
|
||||||
|
flatDir {
|
||||||
|
dirs 'libs'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
android {
|
||||||
|
compileSdkVersion 29
|
||||||
|
buildToolsVersion "29.0.1"
|
||||||
|
defaultConfig {
|
||||||
|
minSdkVersion 21
|
||||||
|
targetSdkVersion 26
|
||||||
|
javaCompileOptions {
|
||||||
|
annotationProcessorOptions {
|
||||||
|
arguments = [moduleName: project.getName()]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
buildTypes {
|
||||||
|
release {
|
||||||
|
minifyEnabled false
|
||||||
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||||
|
}
|
||||||
|
debug {
|
||||||
|
minifyEnabled false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sourceSets {
|
||||||
|
main.res.srcDirs = ['src/main/res',
|
||||||
|
'src/main/res/lc',
|
||||||
|
'src/main/res/lc/drawable',
|
||||||
|
'src/main/res/lc/drawable-hdpi',
|
||||||
|
'src/main/res/lc/drawable-xhdpi',
|
||||||
|
'src/main/res/lc/drawable-xxhdpi',
|
||||||
|
'src/main/res/lc/anim',
|
||||||
|
'src/main/res/lc/color',
|
||||||
|
'src/main/res/lc/values',
|
||||||
|
'src/main/res/lc/values-en',
|
||||||
|
'src/main/res/lc/layout']
|
||||||
|
}
|
||||||
|
android {
|
||||||
|
lintOptions {
|
||||||
|
abortOnError false
|
||||||
|
}
|
||||||
|
resourcePrefix "demo_"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
provided fileTree(include: ['*.jar'], dir: 'libs')
|
||||||
|
// provided fileTree(include: ['*.aar'], dir: 'libs')
|
||||||
|
|
||||||
|
api project(':third-zxing')
|
||||||
|
api "org.greenrobot:eventbus:3.0.0"
|
||||||
|
api 'com.google.code.gson:gson:2.8.1'
|
||||||
|
|
||||||
|
api "com.android.support:recyclerview-v7:27.1.1"
|
||||||
|
api "com.android.support:support-v4:27.1.1"
|
||||||
|
api "com.android.support:appcompat-v7:27.1.1"
|
||||||
|
api "com.android.support:cardview-v7:27.1.1"
|
||||||
|
api "com.android.support:design:27.1.1"
|
||||||
|
api 'com.android.support.constraint:constraint-layout:1.1.0'
|
||||||
|
|
||||||
|
api files('libs/PullToRefreshListView-release.aar')
|
||||||
|
api files('libs/DHMobileToolset-1.1.1.aar')
|
||||||
|
api files('libs/DHScanner-1.0.7.aar')
|
||||||
|
|
||||||
|
}
|
||||||
|
configurations {
|
||||||
|
all*.exclude group: 'com.google.zxing'
|
||||||
|
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,21 @@
|
||||||
|
# Add project specific ProGuard rules here.
|
||||||
|
# You can control the set of applied configuration files using the
|
||||||
|
# proguardFiles setting in build.gradle.
|
||||||
|
#
|
||||||
|
# For more details, see
|
||||||
|
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||||
|
|
||||||
|
# If your project uses WebView with JS, uncomment the following
|
||||||
|
# and specify the fully qualified class name to the JavaScript interface
|
||||||
|
# class:
|
||||||
|
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||||
|
# public *;
|
||||||
|
#}
|
||||||
|
|
||||||
|
# Uncomment this to preserve the line number information for
|
||||||
|
# debugging stack traces.
|
||||||
|
#-keepattributes SourceFile,LineNumberTable
|
||||||
|
|
||||||
|
# If you keep the line number information, uncomment this to
|
||||||
|
# hide the original source file name.
|
||||||
|
#-renamesourcefileattribute SourceFile
|
|
@ -0,0 +1,107 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
package="com.mm.android.deviceaddmodule">
|
||||||
|
<!-- Required 一些系统要求的权限,如访问网络等 -->
|
||||||
|
<uses-permission android:name="android.permission.INTERNET" /> <!--网络访问-->
|
||||||
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <!--允许程序写入外部存储,如SD卡上写文件,抓图、录制等-->
|
||||||
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <!--程序可以读取设备外部存储空间(内置SDcard和外置SDCard)的文件,我的文件等-->
|
||||||
|
<uses-permission android:name="android.permission.USE_CREDENTIALS" /> <!--允许程序请求验证从AccountManager???-->
|
||||||
|
<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" /> <!--允许改变WiFi多播状态???-->
|
||||||
|
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /> <!--允许程序显示系统窗口,应该已经不适用了???-->
|
||||||
|
<uses-permission android:name="android.permission.RECORD_AUDIO" /> <!--允许程序录制声音通过手机或耳机的麦克,对讲、自定义报警音等-->
|
||||||
|
<uses-permission android:name="android.permission.CAMERA" /> <!--允许程序访问摄像头进行拍照,二维码扫描补光、拍照上传图片等-->
|
||||||
|
<uses-permission android:name="android.permission.FLASHLIGHT" /> <!--允许访问闪光灯,二维码扫描补光-->
|
||||||
|
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> <!--允许程序修改声音设置信息,声波配对,自动调大音量。需求变更之后应该不需要了???-->
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <!--允许程序获取当前WiFi接入的状态以及WLAN热点的信息,设备添加何种配网流程使用-->
|
||||||
|
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> <!--允许程序改变WiFi状态,配网等-->
|
||||||
|
<uses-feature android:name="android.hardware.camera" />
|
||||||
|
<uses-feature android:name="android.hardware.camera.autofocus" />
|
||||||
|
<!-- 硬件加速对X5视频播放非常重要,建议开启 -->
|
||||||
|
<uses-permission android:name="android.permission.READ_SETTINGS" /> <!--允许程序读取系统设置,声波配对获取当前系统音量等-->
|
||||||
|
<!-- Optional for location -->
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <!--允许一个程序访问CellID或 WiFi热点来获取粗略的位置,登陆、设备添加等-->
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <!--允许一个程序访问CellID或 WiFi热点来获取精确的位置,登陆、设备添加等???-->
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" /> <!--允许应用程序访问额外的位置提供命令,登陆、设备添加等???-->
|
||||||
|
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /> <!--允许程序改变网络状态,如是否联网,配网???-->
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
|
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" /> <!--允许应用程序请求安装包。针对API大于22必须持有该许可使用ACTION_INSTALL_PACKAGE应用。应该没在用???-->
|
||||||
|
<uses-permission android:name="android.permission.VIBRATE" />
|
||||||
|
<application
|
||||||
|
android:allowBackup="true"
|
||||||
|
android:supportsRtl="true"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
tools:replace="android:allowBackup,android:label,android:supportsRtl">
|
||||||
|
<service android:name=".services.TimeFilterService"/>
|
||||||
|
<receiver android:name=".receiver.SucceedClickReceiver"/>
|
||||||
|
<receiver android:name=".receiver.TimeoutClickReceiver"/>
|
||||||
|
<activity
|
||||||
|
android:name=".LcnDeviceAddActivity"
|
||||||
|
android:configChanges="orientation|keyboardHidden|screenSize|locale"
|
||||||
|
android:exported="false"
|
||||||
|
android:label="@string/mobile_common_device"
|
||||||
|
android:screenOrientation="portrait"
|
||||||
|
android:windowSoftInputMode="adjustPan|stateHidden"
|
||||||
|
android:theme="@style/AppTheme.NoActionBar"/>
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".device_wifi.DeviceWifiListActivity"
|
||||||
|
android:configChanges="orientation|keyboardHidden|screenSize|locale"
|
||||||
|
android:exported="false"
|
||||||
|
android:screenOrientation="portrait"
|
||||||
|
android:windowSoftInputMode="adjustPan|stateHidden"
|
||||||
|
android:theme="@style/AppTheme.NoActionBar"/>
|
||||||
|
<activity
|
||||||
|
android:name=".device_wifi.DeviceWifiPasswordActivity"
|
||||||
|
android:configChanges="orientation|keyboardHidden|screenSize|locale"
|
||||||
|
android:exported="false"
|
||||||
|
android:screenOrientation="portrait"
|
||||||
|
android:windowSoftInputMode="adjustPan|stateHidden"
|
||||||
|
android:theme="@style/AppTheme.NoActionBar"/>
|
||||||
|
<activity
|
||||||
|
android:name=".device_wifi.ErrorTipActivity"
|
||||||
|
android:configChanges="orientation|keyboardHidden|screenSize|locale"
|
||||||
|
android:exported="false"
|
||||||
|
android:screenOrientation="portrait"
|
||||||
|
android:windowSoftInputMode="adjustPan|stateHidden"
|
||||||
|
android:theme="@style/AppTheme.NoActionBar"/>
|
||||||
|
<activity
|
||||||
|
android:name=".device_wifi.HiddenWifiActivity"
|
||||||
|
android:configChanges="orientation|keyboardHidden|screenSize|locale"
|
||||||
|
android:exported="false"
|
||||||
|
android:screenOrientation="portrait"
|
||||||
|
android:windowSoftInputMode="adjustPan|stateHidden"
|
||||||
|
android:theme="@style/AppTheme.NoActionBar"/>
|
||||||
|
|
||||||
|
<service android:name=".SeachDeviceService"/>
|
||||||
|
|
||||||
|
<meta-data
|
||||||
|
android:name="meta-data4type"
|
||||||
|
android:value="@string/client_type"
|
||||||
|
tools:replace="android:value" />
|
||||||
|
<meta-data
|
||||||
|
android:name="meta-data4host"
|
||||||
|
android:value="@string/host" />
|
||||||
|
<meta-data
|
||||||
|
android:name="meta-ishttps"
|
||||||
|
android:value="false" />
|
||||||
|
<provider
|
||||||
|
android:name="android.support.v4.content.FileProvider"
|
||||||
|
android:authorities="${applicationId}.fileprovider"
|
||||||
|
android:exported="false"
|
||||||
|
android:grantUriPermissions="true">
|
||||||
|
<meta-data
|
||||||
|
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||||
|
android:resource="@xml/file_paths" />
|
||||||
|
</provider>
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".mobilecommon.base.ProgressActivity"
|
||||||
|
android:configChanges="orientation|keyboardHidden|screenSize|locale"
|
||||||
|
android:exported="false"
|
||||||
|
android:launchMode="singleInstance"
|
||||||
|
android:screenOrientation="portrait"
|
||||||
|
android:theme="@style/translucent" />
|
||||||
|
</application>
|
||||||
|
|
||||||
|
</manifest>
|
|
@ -0,0 +1,194 @@
|
||||||
|
<resources>
|
||||||
|
<string name="!QAZXSW@"></string>
|
||||||
|
<string name="0000aaaa"></string>
|
||||||
|
<string name="0123456oo"></string>
|
||||||
|
<string name="123a123a"></string>
|
||||||
|
<string name="123admin"></string>
|
||||||
|
<string name="1qaz2wsx"></string>
|
||||||
|
<string name="1qaz2wsx3edc"></string>
|
||||||
|
<string name="1qazXSW@"></string>
|
||||||
|
<string name="1qazxsw2"></string>
|
||||||
|
<string name="88809778a"></string>
|
||||||
|
<string name="ADMIN!@#"></string>
|
||||||
|
<string name="ADMIN!@#$"></string>
|
||||||
|
<string name="ROOT!@#$"></string>
|
||||||
|
<string name="TEST!@#$"></string>
|
||||||
|
<string name="TEST!@#$%"></string>
|
||||||
|
<string name="a1234567"></string>
|
||||||
|
<string name="a123456a"></string>
|
||||||
|
<string name="aa123123"></string>
|
||||||
|
<string name="admin123"></string>
|
||||||
|
<string name="admin1234"></string>
|
||||||
|
<string name="admin12345"></string>
|
||||||
|
<string name="admin123456"></string>
|
||||||
|
<string name="admin12345678"></string>
|
||||||
|
<string name="admin1314"></string>
|
||||||
|
<string name="admin222"></string>
|
||||||
|
<string name="admin234"></string>
|
||||||
|
<string name="admin333"></string>
|
||||||
|
<string name="admin444"></string>
|
||||||
|
<string name="admin456"></string>
|
||||||
|
<string name="admin555"></string>
|
||||||
|
<string name="admin888"></string>
|
||||||
|
<string name="admin@(eyou)"></string>
|
||||||
|
<string name="bs88132756"></string>
|
||||||
|
<string name="content2pub"></string>
|
||||||
|
<string name="dlr123456"></string>
|
||||||
|
<string name="eyou_admin"></string>
|
||||||
|
<string name="fujun740115"></string>
|
||||||
|
<string name="gbk88259894"></string>
|
||||||
|
<string name="gsqajj88259588"></string>
|
||||||
|
<string name="hz@123456"></string>
|
||||||
|
<string name="kqjd123456"></string>
|
||||||
|
<string name="pass123456"></string>
|
||||||
|
<string name="qq123456"></string>
|
||||||
|
<string name="qwer1234"></string>
|
||||||
|
<string name="qwer@1234"></string>
|
||||||
|
<string name="syf123456"></string>
|
||||||
|
<string name="test1314"></string>
|
||||||
|
<string name="wangda716"></string>
|
||||||
|
<string name="wood0410"></string>
|
||||||
|
<string name="xwl671118"></string>
|
||||||
|
<string name="zzb88259815"></string>
|
||||||
|
<string name="admin@123"></string>
|
||||||
|
<string name="Test@123"></string>
|
||||||
|
<string name="Test1234"></string>
|
||||||
|
<string name="p@assword"></string>
|
||||||
|
<string name="wang1234"></string>
|
||||||
|
<string name="trustno1"></string>
|
||||||
|
<string name="passw0rd"></string>
|
||||||
|
<string name="1qa2ws3ed"></string>
|
||||||
|
<string name="!QAZASDF"></string>
|
||||||
|
<string name="6t5r4e3w2q"></string>
|
||||||
|
<string name="power123"></string>
|
||||||
|
<string name="!@#qweASD0"></string>
|
||||||
|
<string name="abcd4321"></string>
|
||||||
|
<string name="abcd54321"></string>
|
||||||
|
<string name="aa12345678"></string>
|
||||||
|
<string name="1230!@#$"></string>
|
||||||
|
<string name="123!@#abc"></string>
|
||||||
|
<string name="1q2w3e4r5t6y"></string>
|
||||||
|
<string name="q1w2e3r4t5"></string>
|
||||||
|
<string name="1234!@#$"></string>
|
||||||
|
<string name="!@#123456!@#"></string>
|
||||||
|
<string name="qwe123456qwe"></string>
|
||||||
|
<string name="abc777888"></string>
|
||||||
|
<string name="abc888999"></string>
|
||||||
|
<string name="abcabcd1234"></string>
|
||||||
|
<string name="abc!@#456"></string>
|
||||||
|
<string name="qq7758520"></string>
|
||||||
|
<string name="qq5201314"></string>
|
||||||
|
<string name="qq1314520"></string>
|
||||||
|
<string name="qweqwer12345"></string>
|
||||||
|
<string name="12345qwert"></string>
|
||||||
|
<string name="1q2w3e4r"></string>
|
||||||
|
<string name="aaaaa22222"></string>
|
||||||
|
<string name="aaaaa33333"></string>
|
||||||
|
<string name="aaaaa44444"></string>
|
||||||
|
<string name="aaaaa55555"></string>
|
||||||
|
<string name="aaaaa66666"></string>
|
||||||
|
<string name="aaaaa77777"></string>
|
||||||
|
<string name="aaaaa88888"></string>
|
||||||
|
<string name="aaaaa99999"></string>
|
||||||
|
<string name="aaaaa00000"></string>
|
||||||
|
<string name="bbbbb11111"></string>
|
||||||
|
<string name="bbbbb22222"></string>
|
||||||
|
<string name="bbbbb33333"></string>
|
||||||
|
<string name="bbbbb44444"></string>
|
||||||
|
<string name="bbbbb55555"></string>
|
||||||
|
<string name="bbbbb66666"></string>
|
||||||
|
<string name="bbbbb77777"></string>
|
||||||
|
<string name="bbbbb88888"></string>
|
||||||
|
<string name="bbbbb99999"></string>
|
||||||
|
<string name="bbbbb00000"></string>
|
||||||
|
<string name="admin88888"></string>
|
||||||
|
<string name="admin66666"></string>
|
||||||
|
<string name="00EEEE9E4BA2"></string>
|
||||||
|
<string name="0027193A2F60"></string>
|
||||||
|
<string name="00EEEE9E4B"></string>
|
||||||
|
<string name="0027193A2F"></string>
|
||||||
|
<string name="a1b2c3d4e5"></string>
|
||||||
|
<string name="a123456789"></string>
|
||||||
|
<string name="b123456789"></string>
|
||||||
|
<string name="c123456789"></string>
|
||||||
|
<string name="d123456789"></string>
|
||||||
|
<string name="e123456789"></string>
|
||||||
|
<string name="f123456789"></string>
|
||||||
|
<string name="g123456789"></string>
|
||||||
|
<string name="h123456789"></string>
|
||||||
|
<string name="i123456789"></string>
|
||||||
|
<string name="j123456789"></string>
|
||||||
|
<string name="k123456789"></string>
|
||||||
|
<string name="l123456789"></string>
|
||||||
|
<string name="m123456789"></string>
|
||||||
|
<string name="n123456789"></string>
|
||||||
|
<string name="o123456789"></string>
|
||||||
|
<string name="p123456789"></string>
|
||||||
|
<string name="q123456789"></string>
|
||||||
|
<string name="r123456789"></string>
|
||||||
|
<string name="s123456789"></string>
|
||||||
|
<string name="t123456789"></string>
|
||||||
|
<string name="u123456789"></string>
|
||||||
|
<string name="v123456789"></string>
|
||||||
|
<string name="w123456789"></string>
|
||||||
|
<string name="x123456789"></string>
|
||||||
|
<string name="y123456789"></string>
|
||||||
|
<string name="z123456789"></string>
|
||||||
|
<string name="password1"></string>
|
||||||
|
<string name="password11"></string>
|
||||||
|
<string name="password12"></string>
|
||||||
|
<string name="password22"></string>
|
||||||
|
<string name="password00"></string>
|
||||||
|
<string name="password99"></string>
|
||||||
|
<string name="password66"></string>
|
||||||
|
<string name="password88"></string>
|
||||||
|
<string name="password68"></string>
|
||||||
|
<string name="alpha-wlan"></string>
|
||||||
|
<string name="link3a2f6o"></string>
|
||||||
|
<string name="LINK3A2F60"></string>
|
||||||
|
<string name="abcd123456"></string>
|
||||||
|
<string name="62696e676f"></string>
|
||||||
|
<string name="25802580ab"></string>
|
||||||
|
<string name="abcd1234"></string>
|
||||||
|
<string name="abcde12345"></string>
|
||||||
|
<string name="aaaaa11111"></string>
|
||||||
|
<string name="1A2B3C4D5E"></string>
|
||||||
|
<string name="64696E6777"></string>
|
||||||
|
<string name="113414129A"></string>
|
||||||
|
<string name="123456789a"></string>
|
||||||
|
<string name="123456789b"></string>
|
||||||
|
<string name="123456789c"></string>
|
||||||
|
<string name="123456789d"></string>
|
||||||
|
<string name="123456789e"></string>
|
||||||
|
<string name="123456789f"></string>
|
||||||
|
<string name="123456789g"></string>
|
||||||
|
<string name="123456789h"></string>
|
||||||
|
<string name="123456789i"></string>
|
||||||
|
<string name="123456789j"></string>
|
||||||
|
<string name="123456789k"></string>
|
||||||
|
<string name="123456789l"></string>
|
||||||
|
<string name="123456789m"></string>
|
||||||
|
<string name="123456789n"></string>
|
||||||
|
<string name="123456789o"></string>
|
||||||
|
<string name="123456789p"></string>
|
||||||
|
<string name="123456789q"></string>
|
||||||
|
<string name="123456789r"></string>
|
||||||
|
<string name="123456789s"></string>
|
||||||
|
<string name="123456789t"></string>
|
||||||
|
<string name="123456789u"></string>
|
||||||
|
<string name="123456789v"></string>
|
||||||
|
<string name="123456789w"></string>
|
||||||
|
<string name="123456789x"></string>
|
||||||
|
<string name="123456789y"></string>
|
||||||
|
<string name="123456789z"></string>
|
||||||
|
<string name="12345ABCDE"></string>
|
||||||
|
<string name="admin3388"></string>
|
||||||
|
<string name="admin8888"></string>
|
||||||
|
<string name="admin4488"></string>
|
||||||
|
<string name="admin4567"></string>
|
||||||
|
<string name="y888888888"></string>
|
||||||
|
<string name="%username%"></string>
|
||||||
|
<string name="!@#$%^&"></string>
|
||||||
|
<string name="eeee9e4ba2"></string>
|
||||||
|
<string name="1234qwer"></string>
|
||||||
|
</resources>
|
|
@ -0,0 +1,68 @@
|
||||||
|
package com.mm.android.deviceaddmodule;
|
||||||
|
|
||||||
|
import android.app.Application;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
public class CommonParam implements Serializable {
|
||||||
|
private Application context;
|
||||||
|
private String userId;
|
||||||
|
private String appId;
|
||||||
|
private String appSecret;
|
||||||
|
|
||||||
|
private String envirment= "";
|
||||||
|
|
||||||
|
public String getEnvirment() {
|
||||||
|
return envirment;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnvirment(String envirment) {
|
||||||
|
this.envirment = envirment;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Application getContext() {
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContext(Application context) {
|
||||||
|
this.context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAppId() {
|
||||||
|
return appId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAppId(String appId) {
|
||||||
|
this.appId = appId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAppSecret() {
|
||||||
|
return appSecret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAppSecret(String appSecret) {
|
||||||
|
this.appSecret = appSecret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUserId() {
|
||||||
|
return userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserId(String userId) {
|
||||||
|
this.userId = userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void checkParam() throws Exception {
|
||||||
|
if (context == null) {
|
||||||
|
throw new Exception("context must not null");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (appId == null || appId.isEmpty()) {
|
||||||
|
throw new Exception("appId must not empty");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (appSecret == null || appSecret.isEmpty()) {
|
||||||
|
throw new Exception("appSecret must not empty");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,145 @@
|
||||||
|
package com.mm.android.deviceaddmodule;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
|
||||||
|
import com.lechange.opensdk.api.InitParams;
|
||||||
|
import com.lechange.opensdk.api.LCOpenSDK_Api;
|
||||||
|
import com.lechange.opensdk.device.LCOpenSDK_DeviceInit;
|
||||||
|
import com.mm.android.deviceaddmodule.device_wifi.CurWifiInfo;
|
||||||
|
import com.mm.android.deviceaddmodule.device_wifi.DeviceWifiListActivity;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.AppConsume.BusinessException;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.AppConsume.EnvironmentConfig;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.entity.device.DHDevice;
|
||||||
|
import com.mm.android.deviceaddmodule.openapi.CONST;
|
||||||
|
import com.mm.android.deviceaddmodule.openapi.DeviceAddOpenApiManager;
|
||||||
|
import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator;
|
||||||
|
import com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache;
|
||||||
|
import com.nostra13.universalimageloader.core.DisplayImageOptions;
|
||||||
|
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||||
|
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
|
||||||
|
import com.nostra13.universalimageloader.core.assist.QueueProcessingType;
|
||||||
|
import com.nostra13.universalimageloader.core.download.BaseImageDownloader;
|
||||||
|
import com.zxing.ContextHelper;
|
||||||
|
|
||||||
|
import static com.mm.android.deviceaddmodule.device_wifi.DeviceConstant.IntentCode.DEVICE_SETTING_WIFI_LIST;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加设备组件 唯一入口
|
||||||
|
*/
|
||||||
|
public class LCDeviceEngine {
|
||||||
|
private boolean sdkHasInit = false;
|
||||||
|
private volatile static LCDeviceEngine lcDeviceEngine;
|
||||||
|
public String accessToken;
|
||||||
|
private Throwable throwable;
|
||||||
|
public CommonParam commonParam;
|
||||||
|
public String userId = "";
|
||||||
|
|
||||||
|
public static LCDeviceEngine newInstance() {
|
||||||
|
if (lcDeviceEngine == null) {
|
||||||
|
synchronized (LCDeviceEngine.class) {
|
||||||
|
if (lcDeviceEngine == null) {
|
||||||
|
lcDeviceEngine = new LCDeviceEngine();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return lcDeviceEngine;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean init(CommonParam commonParam, String token) throws Throwable {
|
||||||
|
this.commonParam = commonParam;
|
||||||
|
this.accessToken = token;
|
||||||
|
this.userId = "";
|
||||||
|
this.sdkHasInit = false;
|
||||||
|
if (commonParam == null) {
|
||||||
|
throw new Exception("commonParam must not null");
|
||||||
|
}
|
||||||
|
//参数校验
|
||||||
|
commonParam.checkParam();
|
||||||
|
//初始化参数
|
||||||
|
initParam(commonParam);
|
||||||
|
//获取开放平台token
|
||||||
|
// initToken(token);
|
||||||
|
if (TextUtils.isEmpty(accessToken)) {
|
||||||
|
throw throwable;
|
||||||
|
}
|
||||||
|
//组件初始化
|
||||||
|
//LCOpenSDK_Api.setHost(CONST.HOST.replace("https://", ""), accessToken);
|
||||||
|
InitParams initParams = new InitParams(commonParam.getContext(), CONST.HOST.replace("https://", ""), accessToken);
|
||||||
|
LCOpenSDK_Api.initOpenApi(initParams);
|
||||||
|
LCOpenSDK_DeviceInit.getInstance();
|
||||||
|
sdkHasInit = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addDevice(Activity activity) throws Exception {
|
||||||
|
if (!sdkHasInit) {
|
||||||
|
throw new Exception("not init");
|
||||||
|
}
|
||||||
|
//开启添加页面
|
||||||
|
activity.startActivity(new Intent(commonParam.getContext(), LcnDeviceAddActivity.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean deviceOnlineChangeNet(Activity activity, DHDevice device, CurWifiInfo wifiInfo) {
|
||||||
|
if (!sdkHasInit) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
//开启设备在线配网
|
||||||
|
Intent intent = new Intent(commonParam.getContext(), DeviceWifiListActivity.class);
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putSerializable("DHDEVICE_INFO", device);
|
||||||
|
bundle.putSerializable("DEVICE_CURRENT_WIFI_INFO", wifiInfo);
|
||||||
|
intent.putExtras(bundle);
|
||||||
|
activity.startActivityForResult(intent, DEVICE_SETTING_WIFI_LIST);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String initToken(final String token) {
|
||||||
|
/*Thread thread = new Thread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
// accessToken = DeviceAddOpenApiManager.getToken();
|
||||||
|
accessToken = token;
|
||||||
|
} catch (BusinessException e) {
|
||||||
|
throwable = new Throwable(e.errorDescription);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
thread.start();
|
||||||
|
thread.join(4000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
throwable = e;
|
||||||
|
}*/
|
||||||
|
return token;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initParam(CommonParam commonParam) throws Exception {
|
||||||
|
userId = TextUtils.isEmpty(commonParam.getUserId()) ? commonParam.getAppId() : commonParam.getUserId();
|
||||||
|
//传入参数 AppId SecretKey 环境切换
|
||||||
|
CONST.makeEnv(commonParam.getEnvirment(), commonParam.getAppId(), commonParam.getAppSecret());
|
||||||
|
ContextHelper.init(commonParam.getContext());
|
||||||
|
new EnvironmentConfig.Builder().setContext(commonParam.getContext()).build();
|
||||||
|
initImageLoader(commonParam.getContext());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initImageLoader(Context context) {
|
||||||
|
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context)
|
||||||
|
.threadPriority(Thread.NORM_PRIORITY - 2).threadPoolSize(3)
|
||||||
|
.tasksProcessingOrder(QueueProcessingType.LIFO)
|
||||||
|
.memoryCache(new LruMemoryCache((int) (Runtime.getRuntime().maxMemory() / 16)))
|
||||||
|
.memoryCacheExtraOptions(600, 400)
|
||||||
|
.diskCacheExtraOptions(600, 400, null).diskCacheSize(50 * 1024 * 1024)
|
||||||
|
.diskCacheFileNameGenerator(new Md5FileNameGenerator())
|
||||||
|
.imageDownloader(new BaseImageDownloader(context))
|
||||||
|
.defaultDisplayImageOptions(DisplayImageOptions.createSimple())
|
||||||
|
.writeDebugLogs()
|
||||||
|
.build();
|
||||||
|
ImageLoader.getInstance().init(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,527 @@
|
||||||
|
package com.mm.android.deviceaddmodule;
|
||||||
|
|
||||||
|
import android.Manifest;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
import com.company.NetSDK.DEVICE_NET_INFO_EX;
|
||||||
|
import com.mm.android.deviceaddmodule.contract.DeviceAddConstract;
|
||||||
|
import com.mm.android.deviceaddmodule.event.DeviceAddEvent;
|
||||||
|
import com.mm.android.deviceaddmodule.helper.DeviceAddHelper;
|
||||||
|
import com.mm.android.deviceaddmodule.helper.PageNavigationHelper;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.AppConsume.ProviderManager;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.base.BaseFragment;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.base.BaseFragmentActivity;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.base.DefaultPermissionListener;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.common.LCConfiguration;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.common.PermissionHelper;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.dialog.LCAlertDialog;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.entity.deviceadd.DeviceAddInfo;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.eventbus.event.BaseEvent;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.eventbus.event.CommonEvent;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.utils.LogUtil;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.widget.CommonTitle;
|
||||||
|
import com.mm.android.deviceaddmodule.model.DeviceAddModel;
|
||||||
|
import com.mm.android.deviceaddmodule.p_ap.ApBindSuccessFragment;
|
||||||
|
import com.mm.android.deviceaddmodule.p_ap.ApPairFragment;
|
||||||
|
import com.mm.android.deviceaddmodule.p_bindsuccess.BindSuccessFragment;
|
||||||
|
import com.mm.android.deviceaddmodule.p_cloudconnect.CloudConnectFragment;
|
||||||
|
import com.mm.android.deviceaddmodule.p_devlogin.DevLoginFragment;
|
||||||
|
import com.mm.android.deviceaddmodule.p_devlogin.DevSecCodeFragment;
|
||||||
|
import com.mm.android.deviceaddmodule.p_errortip.ErrorTipFragment;
|
||||||
|
import com.mm.android.deviceaddmodule.p_init.InitFragment;
|
||||||
|
import com.mm.android.deviceaddmodule.p_init.SecurityCheckFragment;
|
||||||
|
import com.mm.android.deviceaddmodule.p_softap.DevWifiListFragment;
|
||||||
|
import com.mm.android.deviceaddmodule.p_softap.oversea.SoftApResultFragment;
|
||||||
|
import com.mm.android.deviceaddmodule.p_wiredwireless.SmartConfigFragment;
|
||||||
|
import com.mm.android.deviceaddmodule.p_wiredwireless.WifiPwdFragment;
|
||||||
|
import com.mm.android.deviceaddmodule.presenter.DeviceAddPresenter;
|
||||||
|
import com.mm.android.deviceaddmodule.views.popwindow.BasePopWindow;
|
||||||
|
import com.mm.android.deviceaddmodule.views.popwindow.PopWindowFactory;
|
||||||
|
|
||||||
|
import org.greenrobot.eventbus.EventBus;
|
||||||
|
|
||||||
|
import static android.Manifest.permission.ACCESS_COARSE_LOCATION;
|
||||||
|
import static com.mm.android.deviceaddmodule.mobilecommon.common.Constants.PERMISSION_REQUEST_ID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加设备主界面,各功能模块以Fragment形式依附于此类
|
||||||
|
*/
|
||||||
|
public class LcnDeviceAddActivity extends BaseFragmentActivity implements DeviceAddConstract.View, CommonTitle.OnTitleClickListener {
|
||||||
|
public static final String TAG = "LcnDeviceAddActivity";
|
||||||
|
private CommonTitle mTitle; //标题栏
|
||||||
|
DeviceAddConstract.Presenter mPresenter;
|
||||||
|
private final String STOP_ADD_DIALOG = "stop_add_dialog";
|
||||||
|
LCAlertDialog mLCAlertDialog;
|
||||||
|
PopWindowFactory mPopWindowFactory;
|
||||||
|
BasePopWindow mMoreOptionPopWindow, mLoadingPopWindow, mTypeChosePopWindow;
|
||||||
|
private DefaultPermissionListener defaultPermissionListener;
|
||||||
|
private PermissionHelper permissionHelper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_device_lcadd);
|
||||||
|
initView();
|
||||||
|
initData();
|
||||||
|
}
|
||||||
|
|
||||||
|
//接收EventBus消息
|
||||||
|
@Override
|
||||||
|
public void onMessageEvent(BaseEvent event) {
|
||||||
|
super.onMessageEvent(event);
|
||||||
|
if (event instanceof DeviceAddEvent) {
|
||||||
|
String code = event.getCode();
|
||||||
|
if (DeviceAddEvent.CONFIG_PAGE_NAVIGATION_ACTION.equals(code)) {
|
||||||
|
mPresenter.dispatchPageNavigation();
|
||||||
|
} else if (DeviceAddEvent.CHANGE_TO_WIRELESS_ACTION.equals(code)) {
|
||||||
|
mPresenter.changeToWireless();
|
||||||
|
} else if (DeviceAddEvent.CHANGE_TO_WIRED_ACTION.equals(code)) {
|
||||||
|
mPresenter.changeToWired();
|
||||||
|
} else if (DeviceAddEvent.CHANGE_TO_SOFTAP_ACTION.equals(code)) {
|
||||||
|
mPresenter.changeToSoftAp();
|
||||||
|
} else if (DeviceAddEvent.TITLE_MODE_ACTION.equals(code)) {
|
||||||
|
Bundle bundle = ((DeviceAddEvent) event).getBundle();
|
||||||
|
String titleMode = bundle.getString(DeviceAddEvent.KEY.TITLE_MODE);
|
||||||
|
mPresenter.setCurTitleMode(titleMode);
|
||||||
|
dispatchTitle(titleMode);
|
||||||
|
} else if (DeviceAddEvent.SHOW_LOADING_VIEW_ACTION.equals(code)) {
|
||||||
|
synchronized (LcnDeviceAddActivity.this) {
|
||||||
|
if (mLoadingPopWindow != null && !this.isFinishing()) {
|
||||||
|
if (!mLoadingPopWindow.isShowing()) {
|
||||||
|
mLoadingPopWindow.showAsDropDown(mTitle);
|
||||||
|
}
|
||||||
|
} else if (!this.isFinishing() && hasWindowFocus()) {
|
||||||
|
mLoadingPopWindow = mPopWindowFactory.createPopWindow(this, mTitle, PopWindowFactory.PopWindowType.LOADING);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (DeviceAddEvent.DISMISS_LOADING_VIEW_ACTION.equals(code)) {
|
||||||
|
synchronized (LcnDeviceAddActivity.this) {
|
||||||
|
LogUtil.debugLog(TAG, "LoadingDismiss-->" + mLoadingPopWindow);
|
||||||
|
if (mLoadingPopWindow != null) {
|
||||||
|
mLoadingPopWindow.dismiss();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (DeviceAddEvent.DESTROY_ACTION.equals(code)) {
|
||||||
|
destroy();
|
||||||
|
} else if (DeviceAddEvent.OFFLINE_CONFIG_SUCCESS_ACTION.equals(code)) {
|
||||||
|
offlineConfigSucceed();
|
||||||
|
} else if (DeviceAddEvent.SOFTAP_REFRSH_WIFI_LIST_DISABLE_ACTION.equals(code)) {
|
||||||
|
mTitle.setEnabled(false, CommonTitle.ID_RIGHT);
|
||||||
|
} else if (DeviceAddEvent.SOFTAP_REFRSH_WIFI_LIST_ENABLE_ACTION.equals(code)) {
|
||||||
|
mTitle.setEnabled(true, CommonTitle.ID_RIGHT);
|
||||||
|
} else if (DeviceAddEvent.SHOW_TYPE_CHOSE_ACTION.equals(code)) {
|
||||||
|
mTypeChosePopWindow = mPopWindowFactory.createPopWindow(this, mTitle, PopWindowFactory.PopWindowType.CHOSETYPE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//初始化页面布局
|
||||||
|
private void initView() {
|
||||||
|
mPopWindowFactory = new PopWindowFactory();
|
||||||
|
initTitle();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initTitle() {
|
||||||
|
mTitle = findViewById(R.id.title);
|
||||||
|
mTitle.initView(R.drawable.mobile_common_title_back, 0, R.string.add_device_title);
|
||||||
|
mTitle.setOnTitleClickListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
//初始化页面数据
|
||||||
|
private void initData() {
|
||||||
|
mPresenter = new DeviceAddPresenter(this);
|
||||||
|
mPresenter.dispatchIntentData(getIntent());
|
||||||
|
permissionHelper = new PermissionHelper(this);
|
||||||
|
defaultPermissionListener = new DefaultPermissionListener() {
|
||||||
|
@Override
|
||||||
|
public void onGranted() {
|
||||||
|
mPresenter.getGPSLocation();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onDenied() {
|
||||||
|
mPresenter.getGPSLocation();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
permissionHelper.requestPermissions(new String[]{
|
||||||
|
ACCESS_COARSE_LOCATION,
|
||||||
|
Manifest.permission.CAMERA,
|
||||||
|
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||||
|
Manifest.permission.READ_EXTERNAL_STORAGE}, defaultPermissionListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
//动态权限申请回调
|
||||||
|
@Override
|
||||||
|
public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
|
||||||
|
if (requestCode == PERMISSION_REQUEST_ID) {
|
||||||
|
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||||
|
if (defaultPermissionListener != null) {
|
||||||
|
defaultPermissionListener.onGranted();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (defaultPermissionListener != null && permissionHelper != null) {
|
||||||
|
if (!defaultPermissionListener.onDenied()) { //返回false,默认处理,向用户说明权限的必要性并引导
|
||||||
|
permissionHelper.gotoSettingPage(permissions, defaultPermissionListener);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
mPresenter = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
final Fragment curFragment = getSupportFragmentManager().findFragmentById(R.id.content);
|
||||||
|
if (curFragment != null) {
|
||||||
|
curFragment.onActivityResult(requestCode, resultCode, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBackPressed() {
|
||||||
|
goBack();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void goBack() {
|
||||||
|
final Fragment curFragment = getSupportFragmentManager().findFragmentById(R.id.content);
|
||||||
|
int entryCount = getSupportFragmentManager().getBackStackEntryCount();
|
||||||
|
boolean isWifiOfflineMode = DeviceAddModel.newInstance().getDeviceInfoCache().isWifiOfflineMode();
|
||||||
|
if (curFragment == null
|
||||||
|
|| entryCount <= 0
|
||||||
|
|| (isWifiOfflineMode && entryCount == 1)
|
||||||
|
|| curFragment instanceof ApBindSuccessFragment) {
|
||||||
|
if (mLoadingPopWindow != null) {
|
||||||
|
mLoadingPopWindow.dismiss();
|
||||||
|
}
|
||||||
|
if (curFragment instanceof ApBindSuccessFragment) {
|
||||||
|
if (ProviderManager.getAppProvider().getAppType() == LCConfiguration.APP_LECHANGE_OVERSEA) {
|
||||||
|
showStopDevAddDialog(true);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
destroy();
|
||||||
|
} else {
|
||||||
|
if (curFragment instanceof CloudConnectFragment
|
||||||
|
|| curFragment instanceof InitFragment
|
||||||
|
|| curFragment instanceof DevLoginFragment
|
||||||
|
|| curFragment instanceof DevSecCodeFragment
|
||||||
|
|| curFragment instanceof SmartConfigFragment
|
||||||
|
|| curFragment instanceof DevWifiListFragment
|
||||||
|
|| curFragment instanceof SoftApResultFragment
|
||||||
|
|| curFragment instanceof SecurityCheckFragment
|
||||||
|
|| curFragment instanceof ApPairFragment) {//以上界面退出需二次确认
|
||||||
|
showStopDevAddDialog(curFragment instanceof ApPairFragment);
|
||||||
|
} else {
|
||||||
|
if (!((BaseFragment) curFragment).onBackPressed()) {//子类未消耗返回事件
|
||||||
|
if (curFragment instanceof ErrorTipFragment) {
|
||||||
|
showStopDevAddDialog(false);
|
||||||
|
return;
|
||||||
|
} else if (curFragment instanceof BindSuccessFragment) {
|
||||||
|
destroy();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (mLoadingPopWindow != null) {
|
||||||
|
mLoadingPopWindow.dismiss();
|
||||||
|
}
|
||||||
|
|
||||||
|
//从输入wifi密码页面返回,统一回到电源页面
|
||||||
|
if (curFragment instanceof WifiPwdFragment) {
|
||||||
|
getSupportFragmentManager().popBackStackImmediate(PageNavigationHelper.TIP_POWER_FRAGMENT_TAG, 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
getSupportFragmentManager().popBackStack(); //退回到上个界面
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void dispatchTitle(String titleMode) {
|
||||||
|
mTitle.setVisibleRight(View.VISIBLE);
|
||||||
|
if (DeviceAddHelper.TitleMode.MORE.name().equals(titleMode)
|
||||||
|
|| DeviceAddHelper.TitleMode.MORE2.name().equals(titleMode)
|
||||||
|
|| DeviceAddHelper.TitleMode.MORE3.name().equals(titleMode)
|
||||||
|
|| DeviceAddHelper.TitleMode.MORE4.name().equals(titleMode)) {
|
||||||
|
mTitle.setIconRight(R.drawable.common_icon_nav_more);
|
||||||
|
} else if (DeviceAddHelper.TitleMode.REFRESH.name().equals(titleMode)) {
|
||||||
|
mTitle.setIconRight(R.drawable.common_image_nav_refresh_selector);
|
||||||
|
} else if (DeviceAddHelper.TitleMode.SHARE.name().equals(titleMode)) {
|
||||||
|
mTitle.setTitleCenter(R.string.mobile_common_device);
|
||||||
|
mTitle.setIconRight(R.drawable.mobile_common_share_selector);
|
||||||
|
boolean isOversea = ProviderManager.getAppProvider().getAppType() == LCConfiguration.APP_LECHANGE_OVERSEA;
|
||||||
|
boolean canBeShare = mPresenter.canBeShare();
|
||||||
|
mTitle.setVisibleRight(isOversea && canBeShare ? View.VISIBLE : View.GONE);
|
||||||
|
} else if (DeviceAddHelper.TitleMode.FREE_CLOUD_STORAGE.name().equals(titleMode)) {
|
||||||
|
mTitle.setVisibleLeft(View.GONE);
|
||||||
|
mTitle.setVisibleRight(View.GONE);
|
||||||
|
} else if (DeviceAddHelper.TitleMode.MODIFY_DEVICE_NAME.name().equals(titleMode)) {
|
||||||
|
mTitle.setTitleCenter(R.string.mobile_common_modify_device_pwd);
|
||||||
|
mTitle.setVisibleRight(View.GONE);
|
||||||
|
} else {
|
||||||
|
mTitle.setIconRight(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 停止添加流程提示框
|
||||||
|
*/
|
||||||
|
private void showStopDevAddDialog(final boolean isExitApAdd) {
|
||||||
|
dismissLCAlertDialog();
|
||||||
|
LCAlertDialog.Builder builder = new LCAlertDialog.Builder(this);
|
||||||
|
builder.setTitle(R.string.add_device_confrim_to_quit);
|
||||||
|
builder.setMessage(R.string.add_device_not_complete_tip);
|
||||||
|
builder.setCancelButton(R.string.common_cancel, null);
|
||||||
|
builder.setConfirmButton(R.string.common_confirm,
|
||||||
|
new LCAlertDialog.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(LCAlertDialog dialog, int which,
|
||||||
|
boolean isChecked) {
|
||||||
|
destroy();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
mLCAlertDialog = builder.create();
|
||||||
|
mLCAlertDialog.show(getSupportFragmentManager(),
|
||||||
|
STOP_ADD_DIALOG);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void dismissLCAlertDialog() {
|
||||||
|
if (mLCAlertDialog != null && mLCAlertDialog.isVisible()) {
|
||||||
|
mLCAlertDialog.dismissAllowingStateLoss();
|
||||||
|
mLCAlertDialog = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCommonTitleClick(int id) {
|
||||||
|
final Fragment curFragment = getSupportFragmentManager().findFragmentById(R.id.content);
|
||||||
|
switch (id) {
|
||||||
|
case CommonTitle.ID_LEFT:
|
||||||
|
goBack();
|
||||||
|
break;
|
||||||
|
case CommonTitle.ID_RIGHT: {
|
||||||
|
if (mPresenter.getCurTitleMode().equals(DeviceAddHelper.TitleMode.MORE.name())) {
|
||||||
|
mMoreOptionPopWindow = mPopWindowFactory.createPopWindow(this, mTitle, PopWindowFactory.PopWindowType.OPTION1);
|
||||||
|
} else if (mPresenter.getCurTitleMode().equals(DeviceAddHelper.TitleMode.MORE2.name())) {
|
||||||
|
mMoreOptionPopWindow = mPopWindowFactory.createPopWindow(this, mTitle, PopWindowFactory.PopWindowType.OPTION2);
|
||||||
|
} else if (mPresenter.getCurTitleMode().equals(DeviceAddHelper.TitleMode.MORE3.name())) {
|
||||||
|
mMoreOptionPopWindow = mPopWindowFactory.createPopWindow(this, mTitle, PopWindowFactory.PopWindowType.OPTION3);
|
||||||
|
} else if (mPresenter.getCurTitleMode().equals(DeviceAddHelper.TitleMode.MORE4.name())) {
|
||||||
|
mMoreOptionPopWindow = mPopWindowFactory.createPopWindow(this, mTitle, PopWindowFactory.PopWindowType.OPTION4);
|
||||||
|
} else if (mPresenter.getCurTitleMode().equals(DeviceAddHelper.TitleMode.REFRESH.name())) {
|
||||||
|
EventBus.getDefault().post(new DeviceAddEvent(DeviceAddEvent.SOFTAP_REFRSH_WIFI_LIST));
|
||||||
|
} else if (mPresenter.getCurTitleMode().equals(DeviceAddHelper.TitleMode.SHARE.name())) {
|
||||||
|
mPresenter.getDeviceShareInfo();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Context getContextInfo() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isViewActive() {
|
||||||
|
return !isActivityDestory();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void showToastInfo(String msg) {
|
||||||
|
toast(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void showToastInfo(int msgId) {
|
||||||
|
toast(msgId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void showProgressDialog() {
|
||||||
|
EventBus.getDefault().post(new DeviceAddEvent(DeviceAddEvent.SHOW_LOADING_VIEW_ACTION));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void cancelProgressDialog() {
|
||||||
|
EventBus.getDefault().post(new DeviceAddEvent(DeviceAddEvent.DISMISS_LOADING_VIEW_ACTION));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setTitle(int titleId) {
|
||||||
|
mTitle.setTitleCenter(titleId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void goScanPage() {
|
||||||
|
PageNavigationHelper.gotoScanPage(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void goDispatchPage() {
|
||||||
|
PageNavigationHelper.gotoDispatchPage(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void goHubPairPage(String sn, String hubType) {
|
||||||
|
PageNavigationHelper.gotoHubGuide1Page(this, sn, hubType);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void goApConfigPage(boolean hasSelecteGateway) {
|
||||||
|
final Fragment curFragment = getSupportFragmentManager().findFragmentById(R.id.content);
|
||||||
|
PageNavigationHelper.gotoGatewayListPage(curFragment, hasSelecteGateway);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void goTypeChoosePage() {
|
||||||
|
final Fragment curFragment = getSupportFragmentManager().findFragmentById(R.id.content);
|
||||||
|
PageNavigationHelper.gotoTypeChoosePage(curFragment);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void goWiredwirelessPage(boolean isWifi) {
|
||||||
|
final Fragment curFragment = getSupportFragmentManager().findFragmentById(R.id.content);
|
||||||
|
PageNavigationHelper.gotoPowerTipPage(curFragment, isWifi);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void goWiredwirelessPageNoAnim(boolean isWifi) {
|
||||||
|
final Fragment curFragment = getSupportFragmentManager().findFragmentById(R.id.content);
|
||||||
|
PageNavigationHelper.gotoPowerTipPageNoAnim(curFragment, isWifi);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void goSoftApPage() {
|
||||||
|
final Fragment curFragment = getSupportFragmentManager().findFragmentById(R.id.content);
|
||||||
|
PageNavigationHelper.gotoSoftApTipPage(curFragment);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void goSoftApPageNoAnim() {
|
||||||
|
final Fragment curFragment = getSupportFragmentManager().findFragmentById(R.id.content);
|
||||||
|
PageNavigationHelper.gotoSoftApTipPageNoAnim(curFragment);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void goNBPage() {
|
||||||
|
final Fragment curFragment = getSupportFragmentManager().findFragmentById(R.id.content);
|
||||||
|
PageNavigationHelper.gotoNBTipPage(curFragment);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void goIMEIInputPage() {
|
||||||
|
final Fragment curFragment = getSupportFragmentManager().findFragmentById(R.id.content);
|
||||||
|
PageNavigationHelper.gotoIMEIInputPage(curFragment);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void goNotSupportBindTipPage() {
|
||||||
|
final Fragment curFragment = getSupportFragmentManager().findFragmentById(R.id.content);
|
||||||
|
PageNavigationHelper.gotoErrorTipPage(curFragment, DeviceAddHelper.ErrorCode.DEVICE_BIND_ERROR_NOT_SUPPORT_TO_BIND);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void goLocationPage() {
|
||||||
|
final Fragment curFragment = getSupportFragmentManager().findFragmentById(R.id.content);
|
||||||
|
PageNavigationHelper.gotoLocationTipPage(curFragment);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void goOfflineConfigPage(String sn, String devModelName, String imei) {
|
||||||
|
PageNavigationHelper.gotoOfflineConfigPage(this, sn, devModelName, imei);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void gotoDeviceSharePage(String sn) {
|
||||||
|
PageNavigationHelper.gotoDeviceSharePage(this, sn);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void goInitPage(DEVICE_NET_INFO_EX device_net_info_ex) {
|
||||||
|
final Fragment curFragment = getSupportFragmentManager().findFragmentById(R.id.content);
|
||||||
|
PageNavigationHelper.gotoInitPage(curFragment, device_net_info_ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void goCloudConnetPage() {
|
||||||
|
Fragment curFragment = getSupportFragmentManager().findFragmentById(R.id.content);
|
||||||
|
PageNavigationHelper.gotoCloudConnectPage(curFragment);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void completeAction(boolean isAp) {
|
||||||
|
|
||||||
|
DeviceAddInfo deviceAddInfo = DeviceAddModel.newInstance().getDeviceInfoCache();
|
||||||
|
boolean isDeviceDetail = deviceAddInfo.isDeviceDetail();
|
||||||
|
|
||||||
|
String code = CommonEvent.AP_PAIR_SUCCEED_2_MAIN_ACTION;
|
||||||
|
if (isDeviceDetail) {
|
||||||
|
code = CommonEvent.AP_PAIR_SUCCEED_2_MID_ACTION;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isAp && deviceAddInfo.getGatewayInfo() != null) {
|
||||||
|
String deviceId = deviceAddInfo.getGatewayInfo().getSn();
|
||||||
|
String apId = deviceAddInfo.getDeviceSn();
|
||||||
|
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putString(LCConfiguration.Device_ID, deviceId);
|
||||||
|
bundle.putString(LCConfiguration.AP_ID, apId);
|
||||||
|
CommonEvent commonEvent = new CommonEvent(code);
|
||||||
|
commonEvent.setBundle(bundle);
|
||||||
|
EventBus.getDefault().post(commonEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
destroy();
|
||||||
|
|
||||||
|
if (!isDeviceDetail) {
|
||||||
|
ProviderManager.getDeviceAddCustomProvider().goHomePage(getContextInfo());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 跳转到蓝牙模块
|
||||||
|
*/
|
||||||
|
public void gotoAddBleLockPage(Bundle bundle) {
|
||||||
|
PageNavigationHelper.gotoAddBleLockPage(bundle);
|
||||||
|
destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 主动释放资源、结束activity,而不依赖于onDestroy方法来释放资源(onDestroy方法时机不可控)
|
||||||
|
private void destroy() {
|
||||||
|
finish();
|
||||||
|
mPresenter.uninit();
|
||||||
|
if (mLoadingPopWindow != null) {
|
||||||
|
if (mLoadingPopWindow.isShowing()) {
|
||||||
|
mLoadingPopWindow.dismiss();
|
||||||
|
}
|
||||||
|
mLoadingPopWindow = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 离线配网成功,返回上一级页面
|
||||||
|
private void offlineConfigSucceed() {
|
||||||
|
setResult(RESULT_OK);
|
||||||
|
finish();
|
||||||
|
mPresenter.uninit();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,182 @@
|
||||||
|
package com.mm.android.deviceaddmodule;
|
||||||
|
|
||||||
|
import android.app.Service;
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.IntentFilter;
|
||||||
|
import android.os.Binder;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.IBinder;
|
||||||
|
import android.os.Message;
|
||||||
|
|
||||||
|
import com.company.NetSDK.CB_fSearchDevicesCB;
|
||||||
|
import com.company.NetSDK.DEVICE_NET_INFO_EX;
|
||||||
|
import com.company.NetSDK.INetSDK;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.AppConsume.ProviderManager;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.common.LCConfiguration;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.entity.deviceadd.DeviceAddInfo;
|
||||||
|
import com.mm.android.deviceaddmodule.model.DeviceAddModel;
|
||||||
|
|
||||||
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
|
||||||
|
public class SeachDeviceService extends Service {
|
||||||
|
public static final int SEND_START = 1;
|
||||||
|
public static final String TAG = "SeachDeviceService";
|
||||||
|
|
||||||
|
private long mLRet;
|
||||||
|
|
||||||
|
private CopyOnWriteArrayList<SearchDeviceManager.ISearchDeviceListener> mListenerList;
|
||||||
|
long lastReceiveTime = 0;
|
||||||
|
private BroadcastReceiver mReceiver;
|
||||||
|
Handler handler = new Handler() {
|
||||||
|
@Override
|
||||||
|
public void handleMessage(Message msg) {
|
||||||
|
super.handleMessage(msg);
|
||||||
|
if (!SearchDeviceManager.getInstance().mIsExist) return;
|
||||||
|
if (System.currentTimeMillis() - lastReceiveTime > 2000) {
|
||||||
|
handler.removeMessages(SEND_START);
|
||||||
|
handler.removeCallbacks(searchRunnable);
|
||||||
|
handler.postDelayed(searchRunnable, 500); //若2S内没有再搜索到设备,则重新开始搜索
|
||||||
|
} else {
|
||||||
|
handler.removeMessages(SEND_START);
|
||||||
|
handler.sendEmptyMessageDelayed(SEND_START, 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Runnable searchRunnable = new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
SearchDeviceManager.getInstance().removeInvalidDevice();
|
||||||
|
if (mLRet != 0) {
|
||||||
|
stopSearchDevices();
|
||||||
|
}
|
||||||
|
mLRet = INetSDK.StartSearchDevices(new CB_fSearchDevicesCB() {
|
||||||
|
@Override
|
||||||
|
public void invoke(DEVICE_NET_INFO_EX device_net_info_ex) {
|
||||||
|
lastReceiveTime = System.currentTimeMillis();
|
||||||
|
if (device_net_info_ex != null) {
|
||||||
|
String szSerialNo = new String(device_net_info_ex.szSerialNo).trim();
|
||||||
|
if (device_net_info_ex.iIPVersion == 4 && mListenerList != null) {
|
||||||
|
for (int i = 0; i < mListenerList.size(); i++) {
|
||||||
|
SearchDeviceManager.ISearchDeviceListener listener = mListenerList.get(i);
|
||||||
|
if (listener != null) {
|
||||||
|
listener.onDeviceSearched(szSerialNo, device_net_info_ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (System.currentTimeMillis() - lastReceiveTime > 500) {
|
||||||
|
handler.removeMessages(SEND_START);
|
||||||
|
handler.removeCallbacks(searchRunnable);
|
||||||
|
handler.postDelayed(searchRunnable, 2000); //若2S内没有再搜索到设备,则重新开始搜索
|
||||||
|
} else {
|
||||||
|
handler.removeMessages(SEND_START);
|
||||||
|
handler.sendEmptyMessageDelayed(SEND_START, 500);
|
||||||
|
}
|
||||||
|
if (mLRet == 0) {
|
||||||
|
DeviceAddInfo deviceAddInfo = DeviceAddModel.newInstance().getDeviceInfoCache();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate() {
|
||||||
|
super.onCreate();
|
||||||
|
mListenerList = new CopyOnWriteArrayList<>();
|
||||||
|
// 注册广播监听器监听网络变化
|
||||||
|
IntentFilter intentFilter = new IntentFilter();
|
||||||
|
intentFilter.addAction(LCConfiguration.CONNECTIVITY_CHAGET_ACTION);
|
||||||
|
mReceiver = new Broadcast();
|
||||||
|
registerReceiver(mReceiver, intentFilter);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IBinder onBind(Intent intent) {
|
||||||
|
return new SearchDeviceBinder();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 局域网内搜索设备信息
|
||||||
|
*/
|
||||||
|
private void startSearchDevices() {
|
||||||
|
handler.removeCallbacks(searchRunnable);
|
||||||
|
handler.post(searchRunnable);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 停止搜索
|
||||||
|
*/
|
||||||
|
private void stopSearchDevicesAsync() {
|
||||||
|
handler.removeCallbacks(searchRunnable);
|
||||||
|
if (mLRet != 0) {
|
||||||
|
ProviderManager.getDeviceAddProvider().stopSearchDevicesAsync(mLRet, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void stopSearchDevices() {
|
||||||
|
handler.removeCallbacks(searchRunnable);
|
||||||
|
if (mLRet != 0) {
|
||||||
|
DeviceAddInfo deviceAddInfo = DeviceAddModel.newInstance().getDeviceInfoCache();
|
||||||
|
ProviderManager.getDeviceAddProvider().stopSearchDevices(mLRet, deviceAddInfo.getRequestId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void registerListener(SearchDeviceManager.ISearchDeviceListener listener) {
|
||||||
|
if (mListenerList != null && !mListenerList.contains(listener)) {
|
||||||
|
mListenerList.add(listener);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void unRegisterListener(SearchDeviceManager.ISearchDeviceListener listener) {
|
||||||
|
if (mListenerList != null && mListenerList.contains(listener)) {
|
||||||
|
mListenerList.remove(listener);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
unregisterReceiver(mReceiver);
|
||||||
|
stopSearchDevicesAsync();
|
||||||
|
if (mListenerList != null) {
|
||||||
|
mListenerList.clear();
|
||||||
|
}
|
||||||
|
mListenerList = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class SearchDeviceBinder extends Binder {
|
||||||
|
|
||||||
|
public void startSearchDevices() {
|
||||||
|
SeachDeviceService.this.startSearchDevices();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stopSearchDevicesAsync() {
|
||||||
|
SeachDeviceService.this.stopSearchDevicesAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stopSearchDevices() {
|
||||||
|
SeachDeviceService.this.stopSearchDevices();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void registerListener(SearchDeviceManager.ISearchDeviceListener listener) {
|
||||||
|
SeachDeviceService.this.registerListener(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void unRegisterListener(SearchDeviceManager.ISearchDeviceListener listener) {
|
||||||
|
SeachDeviceService.this.unRegisterListener(listener);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class Broadcast extends BroadcastReceiver {
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
if (LCConfiguration.CONNECTIVITY_CHAGET_ACTION.equals(intent.getAction())) {
|
||||||
|
SearchDeviceManager.getInstance().clearDevice();
|
||||||
|
startSearchDevices();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,224 @@
|
||||||
|
package com.mm.android.deviceaddmodule;
|
||||||
|
|
||||||
|
import android.content.ComponentName;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.ServiceConnection;
|
||||||
|
import android.os.IBinder;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import com.company.NetSDK.CB_fSDKLogCallBack;
|
||||||
|
import com.company.NetSDK.DEVICE_NET_INFO_EX;
|
||||||
|
import com.mm.android.deviceaddmodule.entity.DeviceNetInfo;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.AppConsume.ProviderManager;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.utils.LogUtil;
|
||||||
|
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 搜索局域网内设备信息的管理类
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class SearchDeviceManager {
|
||||||
|
private static final String TAG = "SeachDeviceService";
|
||||||
|
|
||||||
|
private static volatile SearchDeviceManager sInstance;
|
||||||
|
private volatile ConcurrentHashMap<String, DeviceNetInfo> mDeviceNetInfos = new ConcurrentHashMap<>();
|
||||||
|
private SeachDeviceService.SearchDeviceBinder searchDevice;
|
||||||
|
private ISearchDeviceListener mListener;
|
||||||
|
boolean mIsConnected; //service是否已连接
|
||||||
|
private LogCallBack mLogCallBack;
|
||||||
|
|
||||||
|
|
||||||
|
private SearchDeviceManager() {
|
||||||
|
mListener = new SearchDeviceImpl();
|
||||||
|
mDeviceNetInfos = new ConcurrentHashMap<>();
|
||||||
|
mLogCallBack = new LogCallBack();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SearchDeviceManager getInstance() {
|
||||||
|
if (sInstance == null) {
|
||||||
|
synchronized (SearchDeviceManager.class) {
|
||||||
|
if (sInstance == null) {
|
||||||
|
sInstance = new SearchDeviceManager();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void connnectService() {
|
||||||
|
|
||||||
|
if(!mIsConnected){
|
||||||
|
Intent intent = new Intent(ProviderManager.getAppProvider().getAppContext(), SeachDeviceService.class);
|
||||||
|
mIsConnected = ProviderManager.getAppProvider().getAppContext().bindService(intent, mBinderPoolConnection, Context.BIND_AUTO_CREATE);
|
||||||
|
}
|
||||||
|
if(!mIsExist)mIsExist = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ServiceConnection mBinderPoolConnection = new ServiceConnection() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onServiceDisconnected(ComponentName arg0) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onServiceConnected(ComponentName arg0, IBinder arg1) {
|
||||||
|
LogUtil.debugLog(TAG, "onServiceConnected");
|
||||||
|
|
||||||
|
searchDevice = (SeachDeviceService.SearchDeviceBinder) arg1;
|
||||||
|
|
||||||
|
if (searchDevice != null) {
|
||||||
|
try {
|
||||||
|
searchDevice.linkToDeath(mBinderPoolDeathRecipient, 0);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
registerListener(mListener);
|
||||||
|
startSearch();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private IBinder.DeathRecipient mBinderPoolDeathRecipient = new IBinder.DeathRecipient() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void binderDied() {
|
||||||
|
LogUtil.debugLog(TAG, "binderDied");
|
||||||
|
if (searchDevice != null) {
|
||||||
|
searchDevice.unlinkToDeath(mBinderPoolDeathRecipient, 0);
|
||||||
|
searchDevice = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
connnectService();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public void registerListener(ISearchDeviceListener listener) {
|
||||||
|
if (searchDevice != null) {
|
||||||
|
searchDevice.registerListener(listener);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void unRegisterListener(ISearchDeviceListener listener) {
|
||||||
|
if (searchDevice != null) {
|
||||||
|
searchDevice.unRegisterListener(listener);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void stopSearch() {
|
||||||
|
if (searchDevice != null) {
|
||||||
|
searchDevice.stopSearchDevicesAsync();
|
||||||
|
if(mIsConnected){
|
||||||
|
ProviderManager.getAppProvider().getAppContext().unbindService(mBinderPoolConnection);
|
||||||
|
mIsConnected = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized DEVICE_NET_INFO_EX getDeviceNetInfo(String snCode) {
|
||||||
|
if (TextUtils.isEmpty(snCode))
|
||||||
|
return null;
|
||||||
|
if (mDeviceNetInfos != null&&mDeviceNetInfos.get(snCode)!=null) {
|
||||||
|
return mDeviceNetInfos.get(snCode).getDevNetInfoEx();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 搜索
|
||||||
|
*/
|
||||||
|
public synchronized void startSearch() {
|
||||||
|
removeInvalidDevice();
|
||||||
|
|
||||||
|
if (searchDevice != null) {
|
||||||
|
connnectService();
|
||||||
|
searchDevice.startSearchDevices();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void clearDevice() {
|
||||||
|
if (mDeviceNetInfos != null) {
|
||||||
|
mDeviceNetInfos.clear();
|
||||||
|
LogUtil.debugLog(TAG, "clear");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 列表中移除无效的设备信息
|
||||||
|
*/
|
||||||
|
public synchronized void removeInvalidDevice() {
|
||||||
|
if (mDeviceNetInfos != null) {
|
||||||
|
LogUtil.debugLog(TAG, "removeInvalidDevice: " + mDeviceNetInfos);
|
||||||
|
for (Map.Entry<String, DeviceNetInfo> entry : mDeviceNetInfos.entrySet()) {
|
||||||
|
if (entry.getValue() != null) {
|
||||||
|
if (!entry.getValue().isValid()) {
|
||||||
|
// 移除无效的DeviceNetInfo
|
||||||
|
mDeviceNetInfos.remove(entry.getKey());
|
||||||
|
LogUtil.debugLog(TAG, "remove: " + entry.getKey());
|
||||||
|
} else {
|
||||||
|
// 将标志位重置
|
||||||
|
entry.getValue().setValid(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LogUtil.debugLog(TAG, "removeInvalidDevice: " + mDeviceNetInfos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
volatile boolean mIsExist = false;
|
||||||
|
/**
|
||||||
|
* 释放资源
|
||||||
|
*/
|
||||||
|
public synchronized void checkSearchDeviceServiceDestory() {
|
||||||
|
stopSearch();
|
||||||
|
unRegisterListener(mListener);
|
||||||
|
clearDevice();
|
||||||
|
mIsExist = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized boolean checkSearchDeviceServiceIsExist() {
|
||||||
|
return mIsExist;
|
||||||
|
}
|
||||||
|
|
||||||
|
private class SearchDeviceImpl implements ISearchDeviceListener {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDeviceSearched(String sncode, DEVICE_NET_INFO_EX info) {
|
||||||
|
if (mDeviceNetInfos != null) {
|
||||||
|
DeviceNetInfo deviceNetInfo=new DeviceNetInfo(info);
|
||||||
|
mDeviceNetInfos.put(sncode, deviceNetInfo);
|
||||||
|
LogUtil.debugLog(TAG, "onDeviceSearched: " + mDeviceNetInfos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface ISearchDeviceListener {
|
||||||
|
void onDeviceSearched(String sncode, DEVICE_NET_INFO_EX info);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class LogCallBack implements CB_fSDKLogCallBack{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int invoke(byte[] bytes, int length) {
|
||||||
|
String netSDKLog = new String(bytes).trim();
|
||||||
|
LogUtil.debugLog(TAG, netSDKLog);
|
||||||
|
|
||||||
|
String type = "";
|
||||||
|
String content = "";
|
||||||
|
try {
|
||||||
|
JSONObject jsonObject = new JSONObject(netSDKLog);
|
||||||
|
type = jsonObject.optString("type");
|
||||||
|
content = jsonObject.optString("log");
|
||||||
|
LogUtil.debugLog(TAG, "type : " + type + " content : " + content);
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,53 @@
|
||||||
|
package com.mm.android.deviceaddmodule.adapter;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.CheckBox;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.mm.android.deviceaddmodule.R;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.base.adapter.CommonAdapter;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.common.ViewHolder;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.entity.device.DHDevice;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 网关设备列表适配器
|
||||||
|
*/
|
||||||
|
public class GatewayListAdapter extends CommonAdapter<DHDevice> {
|
||||||
|
private int mSelectPosition=-1;
|
||||||
|
public GatewayListAdapter(List<DHDevice> list, Context context) {
|
||||||
|
super(R.layout.gateway_list_item, list, context);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void convert(ViewHolder viewHolder, final DHDevice entity,
|
||||||
|
final int position, ViewGroup parent) {
|
||||||
|
CheckBox checkBox = (CheckBox) viewHolder
|
||||||
|
.findViewById(R.id.checkbox);
|
||||||
|
TextView deviceName = (TextView) viewHolder
|
||||||
|
.findViewById(R.id.device_name);
|
||||||
|
|
||||||
|
deviceName.setText(entity.getName());
|
||||||
|
if (entity.isOnline()) {
|
||||||
|
deviceName.setTextColor(mContext.getResources().getColor(R.color.c2));
|
||||||
|
} else {
|
||||||
|
deviceName.setTextColor(mContext.getResources().getColor(R.color.c5));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mSelectPosition == position)
|
||||||
|
checkBox.setChecked(true);
|
||||||
|
else
|
||||||
|
checkBox.setChecked(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSelectPosition(int selectPosition){
|
||||||
|
mSelectPosition = selectPosition;
|
||||||
|
notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSelectPosition() {
|
||||||
|
return mSelectPosition;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
package com.mm.android.deviceaddmodule.adapter;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.mm.android.deviceaddmodule.R;
|
||||||
|
import com.mm.android.deviceaddmodule.entity.WlanInfo;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.base.adapter.CommonAdapter;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.common.ViewHolder;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
public class WifiListAdapter extends CommonAdapter<WlanInfo> {
|
||||||
|
public WifiListAdapter(int layout, List<WlanInfo> list, Context mContext) {
|
||||||
|
super(layout, list, mContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void convert(ViewHolder viewHolder, WlanInfo entity,
|
||||||
|
final int position, ViewGroup parent) {
|
||||||
|
TextView wlanName = (TextView) viewHolder.findViewById(R.id.wlan_name);
|
||||||
|
ImageView wlanStrength = (ImageView) viewHolder.findViewById(R.id.wlan_len);
|
||||||
|
ImageView wlanAuthMode = (ImageView) viewHolder.findViewById(R.id.wlan_mode);
|
||||||
|
|
||||||
|
wlanName.setText(entity.getWlanSSID()); //设置wifi名
|
||||||
|
|
||||||
|
int quality = entity.getWlanQuality(); //获取wifi信号
|
||||||
|
|
||||||
|
if (quality < 15) {
|
||||||
|
int singalDrawable=entity.getWlanAuthMode() == 0 && entity.getWlanEncrAlgr() == 0?R.drawable.devicedetail_wifi_nosingal:R.drawable.devicedetail_wifi_nosingal_lock;
|
||||||
|
wlanStrength.setImageResource(singalDrawable);
|
||||||
|
} else if (quality < 45) {
|
||||||
|
int singalDrawable=entity.getWlanAuthMode() == 0 && entity.getWlanEncrAlgr() == 0?R.drawable.devicedetail_wifi_1singal:R.drawable.devicedetail_wifi_1singal_lock;
|
||||||
|
wlanStrength.setImageResource(singalDrawable);
|
||||||
|
} else if (quality < 75) {
|
||||||
|
int singalDrawable=entity.getWlanAuthMode() == 0 && entity.getWlanEncrAlgr() == 0?R.drawable.devicedetail_wifi_2singal:R.drawable.devicedetail_wifi_2singal_lock;
|
||||||
|
wlanStrength.setImageResource(singalDrawable);
|
||||||
|
} else {
|
||||||
|
int singalDrawable=entity.getWlanAuthMode() == 0 && entity.getWlanEncrAlgr() == 0?R.drawable.devicedetail_wifi_3singal:R.drawable.devicedetail_wifi_3singal_lock;
|
||||||
|
wlanStrength.setImageResource(singalDrawable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,85 @@
|
||||||
|
package com.mm.android.deviceaddmodule.base;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.inputmethod.InputMethodManager;
|
||||||
|
|
||||||
|
import com.mm.android.deviceaddmodule.event.DeviceAddEvent;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.base.BaseFragment;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.utils.LogUtil;
|
||||||
|
|
||||||
|
import org.greenrobot.eventbus.EventBus;
|
||||||
|
|
||||||
|
public abstract class BaseDevAddFragment extends BaseFragment {
|
||||||
|
|
||||||
|
protected boolean isDestoryView;
|
||||||
|
|
||||||
|
protected abstract void initView(View view);
|
||||||
|
|
||||||
|
protected abstract void initData();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
|
||||||
|
super.onViewCreated(view, savedInstanceState);
|
||||||
|
isDestoryView = false;
|
||||||
|
LogUtil.debugLog("lcxw-fragment",getClass().getSimpleName()+ "--->onViewCreated");
|
||||||
|
initView(view);
|
||||||
|
initData();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroyView() {
|
||||||
|
super.onDestroyView();
|
||||||
|
isDestoryView = true;
|
||||||
|
hideSoftKeyboard();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void hideSoftKeyboard() {
|
||||||
|
if (getActivity() == null) return ;
|
||||||
|
InputMethodManager im = (InputMethodManager) getActivity()
|
||||||
|
.getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
|
if (im.isActive() || getActivity().getCurrentFocus() != null) {
|
||||||
|
im.hideSoftInputFromWindow(getActivity().findViewById(android.R.id.content)
|
||||||
|
.getWindowToken(), 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDestoryView() {
|
||||||
|
return isDestoryView;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Context getContextInfo() {
|
||||||
|
return getActivity();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isViewActive() {
|
||||||
|
return !isDestoryView();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showToastInfo(String msg) {
|
||||||
|
toast(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showToastInfo(int msgId) {
|
||||||
|
toast(msgId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showToastInfo(int msgId, String msg) {
|
||||||
|
if (!TextUtils.isEmpty(msg)) {
|
||||||
|
toast(msg);
|
||||||
|
} else {
|
||||||
|
toast(msgId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showProgressDialog() {
|
||||||
|
EventBus.getDefault().post(new DeviceAddEvent(DeviceAddEvent.SHOW_LOADING_VIEW_ACTION));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cancelProgressDialog() {
|
||||||
|
EventBus.getDefault().post(new DeviceAddEvent(DeviceAddEvent.DISMISS_LOADING_VIEW_ACTION));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,88 @@
|
||||||
|
package com.mm.android.deviceaddmodule.base;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.CheckBox;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.mm.android.deviceaddmodule.R;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 引导提示页基类
|
||||||
|
**/
|
||||||
|
public abstract class BaseTipFragment extends BaseDevAddFragment implements View.OnClickListener {
|
||||||
|
protected ImageView mTipImg;
|
||||||
|
protected TextView mTipTxt, mTipTxt2, mHelpTxt, mNextBtn;
|
||||||
|
protected CheckBox mConfirmCheck;
|
||||||
|
protected View mView;
|
||||||
|
|
||||||
|
protected abstract void nextAction(); //下一步操作
|
||||||
|
|
||||||
|
protected abstract void helpAction(); //帮助操作
|
||||||
|
|
||||||
|
protected abstract void init(); //初始化view及Data
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
// Inflate the layout for this fragment
|
||||||
|
if (mView != null) {
|
||||||
|
ViewGroup parent = (ViewGroup) mView.getParent();
|
||||||
|
if (parent != null) {
|
||||||
|
parent.removeView(mView);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
mView = inflater.inflate(R.layout.fragment_base_tip, container, false);
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
return mView;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initView(View view) {
|
||||||
|
mTipImg = view.findViewById(R.id.tip_img);
|
||||||
|
mTipTxt = view.findViewById(R.id.tip_txt);
|
||||||
|
mTipTxt2 = view.findViewById(R.id.tip_txt2);
|
||||||
|
mHelpTxt = view.findViewById(R.id.help_tip);
|
||||||
|
mNextBtn = view.findViewById(R.id.tv_next);
|
||||||
|
mConfirmCheck = view.findViewById(R.id.cb_confirm);
|
||||||
|
mNextBtn.setOnClickListener(this);
|
||||||
|
mConfirmCheck.setOnClickListener(this);
|
||||||
|
mHelpTxt.setOnClickListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
//提示图平铺
|
||||||
|
protected void tipImageMatch(){
|
||||||
|
RelativeLayout.LayoutParams params= (RelativeLayout.LayoutParams) mTipImg.getLayoutParams();
|
||||||
|
params.height= RelativeLayout.LayoutParams.WRAP_CONTENT;
|
||||||
|
params.width=RelativeLayout.LayoutParams.MATCH_PARENT;
|
||||||
|
params.setMargins(0,0,0,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initData() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
int id = v.getId();
|
||||||
|
if (id == R.id.tv_next) {
|
||||||
|
nextAction();
|
||||||
|
} else if (id == R.id.cb_confirm) {
|
||||||
|
mNextBtn.setEnabled(mConfirmCheck.isChecked());
|
||||||
|
} else if (id == R.id.help_tip) {
|
||||||
|
helpAction();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,78 @@
|
||||||
|
package com.mm.android.deviceaddmodule.base;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.IntentFilter;
|
||||||
|
import android.net.NetworkInfo;
|
||||||
|
import android.net.wifi.WifiInfo;
|
||||||
|
import android.net.wifi.WifiManager;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Parcelable;
|
||||||
|
|
||||||
|
import com.dahua.mobile.utility.network.DHWifiUtil;
|
||||||
|
import com.mm.android.deviceaddmodule.helper.DeviceAddHelper;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.entity.deviceadd.DeviceAddInfo;
|
||||||
|
import com.mm.android.deviceaddmodule.model.DeviceAddModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主要用于监听wifi状态的变化,变化的话就解除绑定,连接上后还是我们的那个的话就重新绑定
|
||||||
|
*/
|
||||||
|
public abstract class BaseWifiListenerFragment extends BaseDevAddFragment {
|
||||||
|
protected DHWifiUtil mDHWifiUtil;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
mDHWifiUtil = new DHWifiUtil(getContext().getApplicationContext());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected IntentFilter createBroadCast() {
|
||||||
|
IntentFilter filter = new IntentFilter();
|
||||||
|
filter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
|
||||||
|
return filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onReceive(Context context, Intent intent) {
|
||||||
|
String action = intent.getAction();
|
||||||
|
if (WifiManager.NETWORK_STATE_CHANGED_ACTION.equals(action)) {
|
||||||
|
Parcelable parcelable = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
|
||||||
|
if (parcelable != null) {
|
||||||
|
NetworkInfo networkInfo = (NetworkInfo) parcelable;
|
||||||
|
NetworkInfo.State state = networkInfo.getState();
|
||||||
|
if (state == NetworkInfo.State.DISCONNECTED) {
|
||||||
|
DeviceAddHelper.clearNetWork();
|
||||||
|
} else if (state == NetworkInfo.State.CONNECTED) {
|
||||||
|
DeviceAddInfo deviceAddInfo = DeviceAddModel.newInstance().getDeviceInfoCache();
|
||||||
|
String mSsid = deviceAddInfo.getSsid();
|
||||||
|
String mCurrentSsid = getCurrentWifiInfo();
|
||||||
|
if (mCurrentSsid!=null){
|
||||||
|
String mTempStr = mCurrentSsid.startsWith("\"") ? mCurrentSsid : "\""+mCurrentSsid+"\"";
|
||||||
|
String mTempStrCache = "\"" + mSsid + "\"";
|
||||||
|
if (mTempStr.equals(mTempStrCache)){
|
||||||
|
DeviceAddHelper.bindNetwork(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getCurrentWifiInfo(){
|
||||||
|
WifiInfo wifiInfo = mDHWifiUtil.getCurrentWifiInfo();
|
||||||
|
return wifiInfo!=null?wifiInfo.getSSID():null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroyView() {
|
||||||
|
super.onDestroyView();
|
||||||
|
unRegisterBroadCast();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package com.mm.android.deviceaddmodule.base;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MVP模式P层接口
|
||||||
|
*/
|
||||||
|
public interface IBasePresenter {
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.mm.android.deviceaddmodule.base;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MVP模式V层接口
|
||||||
|
**/
|
||||||
|
public interface IBaseView<T extends IBasePresenter> {
|
||||||
|
Context getContextInfo();
|
||||||
|
boolean isViewActive(); //View层是否处于活动状态
|
||||||
|
//Toast
|
||||||
|
void showToastInfo(String msg);
|
||||||
|
void showToastInfo(int msgId);
|
||||||
|
void showProgressDialog();
|
||||||
|
void cancelProgressDialog();
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.mm.android.deviceaddmodule.contract;
|
||||||
|
|
||||||
|
import com.mm.android.deviceaddmodule.base.IBasePresenter;
|
||||||
|
import com.mm.android.deviceaddmodule.base.IBaseView;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.entity.AddApResult;
|
||||||
|
|
||||||
|
public interface ApBindSuccessConstract {
|
||||||
|
interface Presenter extends IBasePresenter {
|
||||||
|
void modifyApName();
|
||||||
|
void setData(AddApResult addApResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
interface View extends IBaseView<Presenter> {
|
||||||
|
String getApName();
|
||||||
|
void setApName(String name);
|
||||||
|
void setApImg(String img);
|
||||||
|
void completeAction();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.mm.android.deviceaddmodule.contract;
|
||||||
|
|
||||||
|
import com.mm.android.deviceaddmodule.base.IBasePresenter;
|
||||||
|
import com.mm.android.deviceaddmodule.base.IBaseView;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.entity.AddApResult;
|
||||||
|
|
||||||
|
public interface ApPairConstract {
|
||||||
|
interface Presenter extends IBasePresenter {
|
||||||
|
void pair();
|
||||||
|
void stopPair();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
interface View extends IBaseView<Presenter> {
|
||||||
|
void goErrorTipPage();
|
||||||
|
void goApBindSuccessPage(AddApResult addApResult);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
package com.mm.android.deviceaddmodule.contract;
|
||||||
|
|
||||||
|
import com.mm.android.deviceaddmodule.base.IBasePresenter;
|
||||||
|
import com.mm.android.deviceaddmodule.base.IBaseView;
|
||||||
|
|
||||||
|
public interface BaseSoftApTipConstract {
|
||||||
|
interface Presenter extends IBasePresenter {
|
||||||
|
boolean isLastTipPage(); //是否为最后一页引导页
|
||||||
|
void dealWithUnknownSsid();
|
||||||
|
boolean isWifiConnect();
|
||||||
|
void verifyWifiOrLocationPermission();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
interface View extends IBaseView<Presenter> {
|
||||||
|
void updateTipImage(String imageUrl);
|
||||||
|
void updateTipTxt(String tipInfo);
|
||||||
|
void updateResetTxt(String resetTxt);
|
||||||
|
void goErrorTipPage();
|
||||||
|
void applyLocationPermission();
|
||||||
|
void gotoSoftApTipConnectWifiPage();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
package com.mm.android.deviceaddmodule.contract;
|
||||||
|
|
||||||
|
import com.mm.android.deviceaddmodule.base.IBasePresenter;
|
||||||
|
import com.mm.android.deviceaddmodule.base.IBaseView;
|
||||||
|
|
||||||
|
|
||||||
|
public interface BindSuccessConstract {
|
||||||
|
interface Presenter extends IBasePresenter {
|
||||||
|
void refreshDevice(boolean isExit);
|
||||||
|
|
||||||
|
void modifyDevName();
|
||||||
|
|
||||||
|
void getDevName();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
interface View extends IBaseView<Presenter> {
|
||||||
|
|
||||||
|
void updateDevImg(String img);
|
||||||
|
|
||||||
|
String getDevName();
|
||||||
|
|
||||||
|
void setDevName(String name);
|
||||||
|
|
||||||
|
void completeAction();
|
||||||
|
|
||||||
|
void deviceName(String name);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
package com.mm.android.deviceaddmodule.contract;
|
||||||
|
|
||||||
|
import com.mm.android.deviceaddmodule.base.IBasePresenter;
|
||||||
|
import com.mm.android.deviceaddmodule.base.IBaseView;
|
||||||
|
|
||||||
|
public interface CloudConnectConstract {
|
||||||
|
interface Presenter extends IBasePresenter {
|
||||||
|
void bindDevice();
|
||||||
|
|
||||||
|
void getDeviceInfo();
|
||||||
|
|
||||||
|
void recyle();
|
||||||
|
|
||||||
|
boolean isWifiOfflineConfiMode(); //是否为离线配置模式
|
||||||
|
|
||||||
|
void notifyMiddleTimeUp();
|
||||||
|
|
||||||
|
void startConnectTiming(); //开始连接云
|
||||||
|
|
||||||
|
void stopConnectTiming(); //结束连接
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
interface View extends IBaseView<DeviceAddConstract.Presenter> {
|
||||||
|
void goBindSuceesPage(); //绑定成功页
|
||||||
|
|
||||||
|
void goDevLoginPage(); //设备登录页
|
||||||
|
|
||||||
|
void goDevSecCodePage(); //设备安全码页
|
||||||
|
|
||||||
|
void goErrorTipPage(); //错误提示页
|
||||||
|
|
||||||
|
void goErrorTipPage(int errorCode); //错误提示页
|
||||||
|
|
||||||
|
void goBindDevicePage(); //绑定设备页
|
||||||
|
|
||||||
|
void completeAction(); //流程结束
|
||||||
|
|
||||||
|
void setCountDownTime(int time); //设置倒计时时间
|
||||||
|
|
||||||
|
void setMiddleTime(int time); //设置中间时间
|
||||||
|
|
||||||
|
void goOtherUserBindTipPage(); //设备被他人绑定提示页
|
||||||
|
|
||||||
|
void goNotSupportBuindTipPage(); //设备不支持被绑定
|
||||||
|
|
||||||
|
void goMainbind(String sn, String code, String encryptPwd); //返回主项目添加
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.mm.android.deviceaddmodule.contract;
|
||||||
|
|
||||||
|
import com.mm.android.deviceaddmodule.base.IBasePresenter;
|
||||||
|
import com.mm.android.deviceaddmodule.base.IBaseView;
|
||||||
|
|
||||||
|
public interface DevLoginConstract {
|
||||||
|
interface Presenter extends IBasePresenter {
|
||||||
|
void devLogin();
|
||||||
|
}
|
||||||
|
|
||||||
|
interface View extends IBaseView<Presenter> {
|
||||||
|
String getDevicePassword(); //从输入框中获取设备密码
|
||||||
|
|
||||||
|
void goSoftAPWifiListPage(); //软AP添加wifi选择页
|
||||||
|
|
||||||
|
void goDeviceBindPage(); //进入设备绑定页
|
||||||
|
|
||||||
|
void goBindSuceesPage(); //进入绑定成功页
|
||||||
|
|
||||||
|
void goOtherUserBindTipPage(); //进入其他用户绑定提示页
|
||||||
|
|
||||||
|
void goErrorTipPage(int errorCode); //错误提示页
|
||||||
|
|
||||||
|
void completeAction(); //完成退出
|
||||||
|
|
||||||
|
void goDevLoginPage(); //设备登录页
|
||||||
|
|
||||||
|
void goDevSecCodePage(); //设备安全码页
|
||||||
|
|
||||||
|
void goMainbind(String sn, String code, String encryptPwd); //返回主项目添加
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
package com.mm.android.deviceaddmodule.contract;
|
||||||
|
|
||||||
|
import com.mm.android.deviceaddmodule.base.IBasePresenter;
|
||||||
|
import com.mm.android.deviceaddmodule.base.IBaseView;
|
||||||
|
|
||||||
|
public interface DevSecCodeConstract {
|
||||||
|
interface Presenter extends IBasePresenter {
|
||||||
|
void validate();
|
||||||
|
}
|
||||||
|
|
||||||
|
interface View extends IBaseView<Presenter> {
|
||||||
|
String getDeviceSecCode(); //从输入框中获取设备安全码
|
||||||
|
|
||||||
|
void goErrorTipPage(int errorCode); //错误提示页
|
||||||
|
|
||||||
|
void goBindSuceesPage(); //进入绑定成功页
|
||||||
|
|
||||||
|
void goOtherUserBindTipPage();
|
||||||
|
|
||||||
|
void completeAction(); //完成退出
|
||||||
|
|
||||||
|
void goDevLoginPage(); //设备登录页
|
||||||
|
|
||||||
|
void goDevSecCodePage(); //设备安全码页
|
||||||
|
|
||||||
|
void goMainbind(String sn, String code, String encryptPwd); //返回主项目添加
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
package com.mm.android.deviceaddmodule.contract;
|
||||||
|
|
||||||
|
import com.mm.android.deviceaddmodule.base.IBasePresenter;
|
||||||
|
import com.mm.android.deviceaddmodule.base.IBaseView;
|
||||||
|
import com.mm.android.deviceaddmodule.entity.WlanInfo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface DevWifiListConstract {
|
||||||
|
interface Presenter extends IBasePresenter {
|
||||||
|
boolean isDevSupport5G();
|
||||||
|
void getWifiList();
|
||||||
|
}
|
||||||
|
|
||||||
|
interface View extends IBaseView<Presenter> {
|
||||||
|
void updateWifiList(List<WlanInfo> list);
|
||||||
|
void goWifiPwdPage(WlanInfo wlanInfo, boolean isNotNeedLogin);
|
||||||
|
void goHiddenWifiPwdPage(boolean isNotNeedLogin);
|
||||||
|
void goDevLoginPage();
|
||||||
|
void showListView();
|
||||||
|
void showErrorInfoView();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,75 @@
|
||||||
|
package com.mm.android.deviceaddmodule.contract;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import com.company.NetSDK.DEVICE_NET_INFO_EX;
|
||||||
|
import com.mm.android.deviceaddmodule.base.IBasePresenter;
|
||||||
|
import com.mm.android.deviceaddmodule.base.IBaseView;
|
||||||
|
|
||||||
|
public interface DeviceAddConstract {
|
||||||
|
interface Presenter extends IBasePresenter {
|
||||||
|
String getCurTitleMode();
|
||||||
|
|
||||||
|
void setCurTitleMode(String titleMode);
|
||||||
|
|
||||||
|
void dispatchIntentData(Intent intent);
|
||||||
|
|
||||||
|
void getGPSLocation(); //获取gps信息
|
||||||
|
|
||||||
|
void dispatchPageNavigation(); //添加流程页跳转
|
||||||
|
|
||||||
|
void uninit(); //释放相关资源
|
||||||
|
|
||||||
|
void getDeviceShareInfo();
|
||||||
|
|
||||||
|
boolean canBeShare();
|
||||||
|
|
||||||
|
void changeToWireless();
|
||||||
|
void changeToWired();
|
||||||
|
void changeToSoftAp();
|
||||||
|
void changeToNB();
|
||||||
|
}
|
||||||
|
|
||||||
|
interface View extends IBaseView<Presenter> {
|
||||||
|
void setTitle(int titleId); //设置标题
|
||||||
|
|
||||||
|
void goScanPage(); //扫描页
|
||||||
|
|
||||||
|
void goDispatchPage(); //分发页
|
||||||
|
|
||||||
|
void goHubPairPage(String sn, String hubType); //hub电池相机引导页
|
||||||
|
|
||||||
|
void goApConfigPage(boolean hasSelecteGateway); //跳转至配件添加页
|
||||||
|
|
||||||
|
void goWiredwirelessPage(boolean isWifi); //跳转至有线/无线添加
|
||||||
|
|
||||||
|
void goWiredwirelessPageNoAnim(boolean isWifi); //跳转至有线/无线添加
|
||||||
|
|
||||||
|
void goSoftApPage(); //跳转至软AP添加
|
||||||
|
|
||||||
|
void goSoftApPageNoAnim(); //跳转至软AP添加
|
||||||
|
|
||||||
|
void goNBPage(); //跳转至NB添加
|
||||||
|
|
||||||
|
void goOfflineConfigPage(String sn, String devModelName, String imei); //跳转到离线配网页面
|
||||||
|
|
||||||
|
void gotoDeviceSharePage(String sn); //跳转设备分享页面
|
||||||
|
|
||||||
|
void gotoAddBleLockPage(Bundle bundle);
|
||||||
|
|
||||||
|
void goInitPage(DEVICE_NET_INFO_EX device_net_info_ex);
|
||||||
|
|
||||||
|
void goCloudConnetPage();
|
||||||
|
|
||||||
|
void goTypeChoosePage();
|
||||||
|
|
||||||
|
void completeAction(boolean isAp);
|
||||||
|
|
||||||
|
void goLocationPage(); //跳转至设备本地配网添加
|
||||||
|
|
||||||
|
void goIMEIInputPage(); //跳转至输入imei页
|
||||||
|
|
||||||
|
void goNotSupportBindTipPage(); //跳转到不支持绑定的设备页面
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package com.mm.android.deviceaddmodule.contract;
|
||||||
|
|
||||||
|
import com.mm.android.deviceaddmodule.base.IBasePresenter;
|
||||||
|
import com.mm.android.deviceaddmodule.base.IBaseView;
|
||||||
|
|
||||||
|
public interface DispatchContract {
|
||||||
|
interface Presenter extends IBasePresenter {
|
||||||
|
boolean isManualInputPage(); //是否为手动输入设备序列号页面
|
||||||
|
boolean isSnInValid(String sn);
|
||||||
|
boolean isScCodeInValid(String scCode);
|
||||||
|
void dispatchResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
interface View extends IBaseView<ScanContract.Presenter> {
|
||||||
|
void goTypeChoosePage(); //跳转到设备类型选择页
|
||||||
|
void goNotSupportBindTipPage(); //跳转到不支持绑定的设备页面
|
||||||
|
void goOtherUserBindTipPage(); //跳转至设备被其他用户绑定提示页
|
||||||
|
void showAddBoxTip(); //盒子添加提示
|
||||||
|
void goCloudConnectPage(); //跳转至云平台连接页
|
||||||
|
void goDeviceLoginPage(); //跳转至设备登录页
|
||||||
|
void goSecCodePage(); //跳转至安全码验证页
|
||||||
|
void goDeviceBindPage(); //跳转至设备绑定页
|
||||||
|
void goIMEIInputPage(); //跳转至输入imei页
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package com.mm.android.deviceaddmodule.contract;
|
||||||
|
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
|
||||||
|
import com.mm.android.deviceaddmodule.base.IBasePresenter;
|
||||||
|
import com.mm.android.deviceaddmodule.base.IBaseView;
|
||||||
|
|
||||||
|
public interface ErrorTipConstract {
|
||||||
|
interface Presenter extends IBasePresenter {
|
||||||
|
void dispatchError(int errorCode);
|
||||||
|
boolean isResetPage(); //通用错误页,及没有按钮
|
||||||
|
boolean isUserBindTipPage(); //是否为设备绑定提示页
|
||||||
|
boolean isUserBindTipPageByBind();//绑定时提示设备被其他用户绑定
|
||||||
|
}
|
||||||
|
|
||||||
|
interface View extends IBaseView<Presenter> {
|
||||||
|
Fragment getParent();
|
||||||
|
void updateInfo(String info,String img,boolean isNeedMatch);
|
||||||
|
void updateInfo(int infoId,int tip2Id,String img,boolean isNeedMatch);
|
||||||
|
void updateInfo(int infoId,String img,boolean isNeedMatch);
|
||||||
|
void hideTipTxt();
|
||||||
|
void hideHelp();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
package com.mm.android.deviceaddmodule.contract;
|
||||||
|
|
||||||
|
import com.mm.android.deviceaddmodule.base.IBasePresenter;
|
||||||
|
import com.mm.android.deviceaddmodule.base.IBaseView;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.entity.device.DHDevice;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface GatewayListConstract {
|
||||||
|
interface Presenter extends IBasePresenter {
|
||||||
|
List<DHDevice> getGatewayData(boolean selectedGateway);
|
||||||
|
int gatewaySize();
|
||||||
|
void dispatchCurSelect(int pos);
|
||||||
|
int getSelectedpos();
|
||||||
|
}
|
||||||
|
|
||||||
|
interface View extends IBaseView<Presenter> {
|
||||||
|
void goTipPage();
|
||||||
|
void setApSn(String apSn);
|
||||||
|
void setApImg(String img);
|
||||||
|
void setSelectedPos(int pos);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
package com.mm.android.deviceaddmodule.contract;
|
||||||
|
|
||||||
|
import com.mm.android.deviceaddmodule.base.IBasePresenter;
|
||||||
|
import com.mm.android.deviceaddmodule.base.IBaseView;
|
||||||
|
|
||||||
|
|
||||||
|
public interface HiddenWifiPwdConstract {
|
||||||
|
interface Presenter extends IBasePresenter {
|
||||||
|
|
||||||
|
void setIsNotNeedLogin(boolean isNotNeedLogin);
|
||||||
|
String getCurWifiName();
|
||||||
|
void updateWifiCache();
|
||||||
|
void connectWifi();
|
||||||
|
boolean isDevSupport5G();
|
||||||
|
}
|
||||||
|
|
||||||
|
interface View extends IBaseView<Presenter> {
|
||||||
|
String getWifiPwd();
|
||||||
|
String getWifiSSID();
|
||||||
|
void goCloudConnectPage();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.mm.android.deviceaddmodule.contract;
|
||||||
|
|
||||||
|
import com.mm.android.deviceaddmodule.base.IBasePresenter;
|
||||||
|
import com.mm.android.deviceaddmodule.base.IBaseView;
|
||||||
|
|
||||||
|
public interface HubApGuide1Constract {
|
||||||
|
interface Presenter extends IBasePresenter {
|
||||||
|
void checkDevIntroductionInfo(String deviceModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
interface View extends IBaseView<Presenter> {
|
||||||
|
void updateTip(String tipImg, String tipTxt,String helpTxt);
|
||||||
|
void showInfoView();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package com.mm.android.deviceaddmodule.contract;
|
||||||
|
|
||||||
|
import com.company.NetSDK.DEVICE_NET_INFO_EX;
|
||||||
|
import com.mm.android.deviceaddmodule.base.IBasePresenter;
|
||||||
|
import com.mm.android.deviceaddmodule.base.IBaseView;
|
||||||
|
|
||||||
|
public interface InitContract {
|
||||||
|
interface Presenter extends IBasePresenter {
|
||||||
|
void setDeviceEX(DEVICE_NET_INFO_EX deviceEX);
|
||||||
|
void playTipSound(); //播放提示音频
|
||||||
|
void startDevInitByIp(); //设备单播初始化
|
||||||
|
void startDevInit(); //设备组播初始化
|
||||||
|
boolean isPwdValid(); //密码是否有效
|
||||||
|
void checkDevice();
|
||||||
|
void recyle();
|
||||||
|
}
|
||||||
|
|
||||||
|
interface View extends IBaseView<Presenter> {
|
||||||
|
int getMusicRes(); //获取音频资源
|
||||||
|
String getInitPwd(); //获取设备密码
|
||||||
|
void goSoftAPWifiListPage(); //软AP添加wifi选择页
|
||||||
|
void goConnectCloudPage(); //进入连接云平台页
|
||||||
|
void goErrorTipPage();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
package com.mm.android.deviceaddmodule.contract;
|
||||||
|
|
||||||
|
public interface ManualInputConstract extends ScanContract {
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
package com.mm.android.deviceaddmodule.contract;
|
||||||
|
|
||||||
|
import com.mm.android.deviceaddmodule.base.IBasePresenter;
|
||||||
|
import com.mm.android.deviceaddmodule.base.IBaseView;
|
||||||
|
|
||||||
|
public interface OfflineConfigConstract {
|
||||||
|
interface Presenter extends IBasePresenter {
|
||||||
|
void resetCache();
|
||||||
|
void getDeviceInfo(String deviceSn, String deviceModelName, String imeiCode); //从服务获取设备信息
|
||||||
|
}
|
||||||
|
|
||||||
|
interface View extends IBaseView<Presenter> {
|
||||||
|
void onGetDeviceInfoError();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
package com.mm.android.deviceaddmodule.contract;
|
||||||
|
|
||||||
|
import com.mm.android.deviceaddmodule.base.IBasePresenter;
|
||||||
|
import com.mm.android.deviceaddmodule.base.IBaseView;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.AppConsume.ScanResult;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 二维码扫描契约类,定义二维码扫描页面相关View层和Presenter层的接口
|
||||||
|
**/
|
||||||
|
public interface ScanContract {
|
||||||
|
interface Presenter extends IBasePresenter{
|
||||||
|
ScanResult parseScanStr(String scanStr, String sc); //解析扫描到的二维码
|
||||||
|
void getDeviceInfo(String deviceSn, String deviceCodeModel); //从服务获取设备信息
|
||||||
|
boolean isManualInputPage(); //是否为手动输入设备序列号页面
|
||||||
|
boolean isSnInValid(String sn);
|
||||||
|
void recyle();
|
||||||
|
void resetCache();
|
||||||
|
boolean isScCodeInValid(String scCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
interface View extends IBaseView<Presenter>{
|
||||||
|
void goTypeChoosePage(); //跳转到设备类型选择页
|
||||||
|
void goNotSupportBindTipPage(); //跳转到不支持绑定的设备页面
|
||||||
|
void goOtherUserBindTipPage(); //跳转至设备被其他用户绑定提示页
|
||||||
|
void showAddBoxTip(); //盒子添加提示,维持乐橙逻辑
|
||||||
|
void goCloudConnectPage(); //跳转至云平台连接页
|
||||||
|
void goDeviceLoginPage(); //跳转至设备登录页
|
||||||
|
void goSecCodePage(); //跳转至安全码验证页
|
||||||
|
void goDeviceBindPage(); //跳转至设备绑定页
|
||||||
|
void goIMEIInputPage(); //跳转至输入imei页
|
||||||
|
void goMainbind(String sn, String code, String encryptPwd); //返回主项目添加
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.mm.android.deviceaddmodule.contract;
|
||||||
|
|
||||||
|
import com.company.NetSDK.DEVICE_NET_INFO_EX;
|
||||||
|
import com.mm.android.deviceaddmodule.base.IBasePresenter;
|
||||||
|
import com.mm.android.deviceaddmodule.base.IBaseView;
|
||||||
|
|
||||||
|
public interface SecurityCheckConstract {
|
||||||
|
interface Presenter extends IBasePresenter {
|
||||||
|
void checkDevice();
|
||||||
|
void recyle();
|
||||||
|
}
|
||||||
|
|
||||||
|
interface View extends IBaseView<Presenter> {
|
||||||
|
void goInitPage(DEVICE_NET_INFO_EX device_net_info_ex);
|
||||||
|
void goErrorTipPage();
|
||||||
|
void goDevLoginPage(); //设备登录页
|
||||||
|
void goSoftApWifiListPage(boolean isNotNeedLogin);
|
||||||
|
void goCloudConnetPage();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
package com.mm.android.deviceaddmodule.contract;
|
||||||
|
|
||||||
|
import com.company.NetSDK.DEVICE_NET_INFO_EX;
|
||||||
|
import com.mm.android.deviceaddmodule.base.IBasePresenter;
|
||||||
|
import com.mm.android.deviceaddmodule.base.IBaseView;
|
||||||
|
|
||||||
|
public interface SmartConfigConstract {
|
||||||
|
interface Presenter extends IBasePresenter {
|
||||||
|
void startSmartConfig(); //开始smartconfig配对线程,和声波配对
|
||||||
|
void recyle(); //回收资源
|
||||||
|
|
||||||
|
String getConfigMode();
|
||||||
|
|
||||||
|
void stopAudio();
|
||||||
|
|
||||||
|
void playAudio();
|
||||||
|
|
||||||
|
void pauseAudio();
|
||||||
|
|
||||||
|
void releaseAudio();
|
||||||
|
|
||||||
|
void wifiPwdErrorClick();
|
||||||
|
}
|
||||||
|
|
||||||
|
interface View extends IBaseView<Presenter> {
|
||||||
|
void goDevInitPage(DEVICE_NET_INFO_EX device_net_info_ex); //进入设备初始化页
|
||||||
|
void goConnectCloudPage(); //进入连接云平台页
|
||||||
|
void goDevLoginPage(); //P2P设备进入设备登录页
|
||||||
|
void goConfigTimeoutPage(); //配置超时页
|
||||||
|
void goWfiPwdPage();
|
||||||
|
void stopCountDown();
|
||||||
|
void updateTip2Txt(boolean isSupportSoundWave, boolean isSupportSoundWaveV2);
|
||||||
|
|
||||||
|
void hideTipWifiPwdErrorTxt(boolean isOversea);
|
||||||
|
void completeAction();
|
||||||
|
void goBindDevicePage();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package com.mm.android.deviceaddmodule.contract;
|
||||||
|
|
||||||
|
import com.mm.android.deviceaddmodule.base.IBasePresenter;
|
||||||
|
import com.mm.android.deviceaddmodule.base.IBaseView;
|
||||||
|
import com.mm.android.deviceaddmodule.entity.WlanInfo;
|
||||||
|
|
||||||
|
public interface SoftApWifiPwdConstract {
|
||||||
|
interface Presenter extends IBasePresenter {
|
||||||
|
void setWlanInfo(WlanInfo wlanInfo);
|
||||||
|
void setIsNotNeedLogin(boolean isNotNeedLogin);
|
||||||
|
boolean isDevSupport5G();
|
||||||
|
String getCurWifiName();
|
||||||
|
void updateWifiCache();
|
||||||
|
String getSavedWifiPwd();
|
||||||
|
void connectWifi();
|
||||||
|
boolean getSavedWifiCheckBoxStatus();
|
||||||
|
}
|
||||||
|
|
||||||
|
interface View extends IBaseView<Presenter> {
|
||||||
|
String getWifiPwd();
|
||||||
|
boolean isSavePwdChecked();
|
||||||
|
void goCloudConnectPage();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.mm.android.deviceaddmodule.contract;
|
||||||
|
|
||||||
|
import com.mm.android.deviceaddmodule.base.IBasePresenter;
|
||||||
|
import com.mm.android.deviceaddmodule.base.IBaseView;
|
||||||
|
|
||||||
|
public interface TimeoutConstract {
|
||||||
|
interface Presenter extends IBasePresenter {
|
||||||
|
void setErrorData(int errorCode, String timeoutDevtypeModel);
|
||||||
|
|
||||||
|
void dispatchAction1();
|
||||||
|
}
|
||||||
|
|
||||||
|
interface View extends IBaseView<Presenter> {
|
||||||
|
//A类型
|
||||||
|
void showAView();
|
||||||
|
|
||||||
|
void goScanPage();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.mm.android.deviceaddmodule.contract;
|
||||||
|
|
||||||
|
import com.mm.android.deviceaddmodule.base.IBasePresenter;
|
||||||
|
import com.mm.android.deviceaddmodule.base.IBaseView;
|
||||||
|
|
||||||
|
public interface TipSoftApConnectWifiConstract {
|
||||||
|
interface Presenter extends IBasePresenter {
|
||||||
|
void copyWifiPwd();
|
||||||
|
void connectWifiAction(boolean isFirst); //开始连接设备热点
|
||||||
|
void dispatchHotConnected(); //处理热点连接,判断当前wifi是否已连接至热点
|
||||||
|
String getHotSSID(); //获取热点ssid
|
||||||
|
}
|
||||||
|
|
||||||
|
interface View extends IBaseView<Presenter> {
|
||||||
|
void updateWifiName(String wifiName);
|
||||||
|
void updateConnectFailedTipText(String wifiName, String wifiPwd, boolean isSupportAddBySc, boolean isManualInput);
|
||||||
|
void goSecurityCheckPage();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.mm.android.deviceaddmodule.contract;
|
||||||
|
|
||||||
|
import com.company.NetSDK.DEVICE_NET_INFO_EX;
|
||||||
|
import com.mm.android.deviceaddmodule.base.IBasePresenter;
|
||||||
|
import com.mm.android.deviceaddmodule.base.IBaseView;
|
||||||
|
|
||||||
|
public interface TipWifiConnectConstract {
|
||||||
|
interface Presenter extends IBasePresenter {
|
||||||
|
void searchDevice();
|
||||||
|
void stopSearchDevice();
|
||||||
|
String getConfigMode();
|
||||||
|
}
|
||||||
|
|
||||||
|
interface View extends IBaseView<Presenter> {
|
||||||
|
void goDevInitPage(DEVICE_NET_INFO_EX device_net_info_ex); //进入设备初始化页
|
||||||
|
void goWifiConfigPage(); //进入配网页
|
||||||
|
void goCloudConnectPage(); //进入云连接页
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.mm.android.deviceaddmodule.contract;
|
||||||
|
|
||||||
|
import com.mm.android.deviceaddmodule.base.IBasePresenter;
|
||||||
|
import com.mm.android.deviceaddmodule.base.IBaseView;
|
||||||
|
|
||||||
|
public interface TypeChooseConstract {
|
||||||
|
interface Presenter extends IBasePresenter {
|
||||||
|
void getDeviceInfoSync(String deviceModelName);
|
||||||
|
void checkDevIntroductionInfo(String deviceModelName);
|
||||||
|
void resetDevPwdCache(); //回到设备选择页,清空设备密码缓存
|
||||||
|
}
|
||||||
|
|
||||||
|
interface View extends IBaseView<Presenter> {
|
||||||
|
void showSearchError();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.mm.android.deviceaddmodule.contract;
|
||||||
|
|
||||||
|
import com.mm.android.deviceaddmodule.base.IBasePresenter;
|
||||||
|
import com.mm.android.deviceaddmodule.base.IBaseView;
|
||||||
|
|
||||||
|
public interface WifiPwdConstract {
|
||||||
|
interface Presenter extends IBasePresenter {
|
||||||
|
boolean isDevSupport5G();
|
||||||
|
|
||||||
|
String getCurWifiName();
|
||||||
|
|
||||||
|
void updateWifiCache();
|
||||||
|
|
||||||
|
String getSavedWifiPwd();
|
||||||
|
|
||||||
|
boolean getSavedWifiCheckBoxStatus();
|
||||||
|
|
||||||
|
String getConfigMode();
|
||||||
|
}
|
||||||
|
|
||||||
|
interface View extends IBaseView<Presenter> {
|
||||||
|
String getWifiPwd();
|
||||||
|
|
||||||
|
boolean isSavePwdChecked();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
package com.mm.android.deviceaddmodule.device_wifi;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Handler;
|
||||||
|
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.base.mvp.IBasePresenter;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.base.mvp.IBaseView;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.common.HandlerManager;
|
||||||
|
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Presenter基类,所有Presenter继承自此类
|
||||||
|
*/
|
||||||
|
public abstract class BasePresenter<T extends IBaseView> implements IBasePresenter {
|
||||||
|
protected WeakReference<T> mView;
|
||||||
|
private HandlerManager mHandlerManager;
|
||||||
|
public BasePresenter(T view) {
|
||||||
|
mView = new WeakReference<>(view);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Handler addHandler(Handler handler){
|
||||||
|
if(mHandlerManager == null){
|
||||||
|
mHandlerManager = new HandlerManager();
|
||||||
|
}
|
||||||
|
return mHandlerManager.addHandler(handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void clearHandlers(){
|
||||||
|
if(mHandlerManager != null){
|
||||||
|
mHandlerManager.clearHandlers();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void unInit() {
|
||||||
|
clearHandlers();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dispatchIntentData(Intent intent) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,70 @@
|
||||||
|
package com.mm.android.deviceaddmodule.device_wifi;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前连接Wifi状态信息
|
||||||
|
*/
|
||||||
|
public class CurWifiInfo implements Serializable {
|
||||||
|
public static class Response {
|
||||||
|
public CurWifiInfo data;
|
||||||
|
|
||||||
|
public void parseData(JsonObject json) {
|
||||||
|
Gson gson = new Gson();
|
||||||
|
this.data = gson.fromJson(json.toString(), CurWifiInfo.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//当前有无连接热点
|
||||||
|
private boolean linkEnable;
|
||||||
|
//若连接了热点,填热点的名称;若未连接,填空
|
||||||
|
private String ssid;
|
||||||
|
//强度, 0最弱,5最强
|
||||||
|
private int intensity;
|
||||||
|
//强度,单位为dbm
|
||||||
|
private String sigStrength;
|
||||||
|
//WIFI认证模式
|
||||||
|
private String auth;
|
||||||
|
|
||||||
|
public boolean isLinkEnable() {
|
||||||
|
return linkEnable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLinkEnable(boolean linkEnable) {
|
||||||
|
this.linkEnable = linkEnable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSsid() {
|
||||||
|
return ssid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSsid(String ssid) {
|
||||||
|
this.ssid = ssid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getIntensity() {
|
||||||
|
return intensity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIntensity(int intensity) {
|
||||||
|
this.intensity = intensity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSigStrength() {
|
||||||
|
return sigStrength;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSigStrength(String sigStrength) {
|
||||||
|
this.sigStrength = sigStrength;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAuth() {
|
||||||
|
return auth;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuth(String auth) {
|
||||||
|
this.auth = auth;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
package com.mm.android.deviceaddmodule.device_wifi;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备管理常量类
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class DeviceConstant {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Intent跳转的key常量或者一些常量key值
|
||||||
|
*/
|
||||||
|
public interface IntentKey {
|
||||||
|
String DEVICE_CURRENT_WIFI_INFO = "DEVICE_CURRENT_WIFI_INFO";
|
||||||
|
String DEVICE_WIFI_CONFIG_INFO = "DEVICE_WIFI_CONFIG_INFO";
|
||||||
|
String DHDEVICE_INFO = "DHDEVICE_INFO";
|
||||||
|
String DHDEVICE_UNBIND = "DHDEVICE_UNBIND";
|
||||||
|
String DHDEVICE_NEW_NAME = "DHDEVICE_NEW_NAME";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Intent跳转请求码返回码常量
|
||||||
|
*/
|
||||||
|
public interface IntentCode {
|
||||||
|
int DEVICE_SETTING_WIFI_OPERATE = 208;
|
||||||
|
int DEVICE_SETTING_WIFI_LIST = 209;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,213 @@
|
||||||
|
package com.mm.android.deviceaddmodule.device_wifi;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.AdapterView;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.ListView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.mm.android.deviceaddmodule.R;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.base.mvp.BaseManagerFragmentActivity;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.common.LCConfiguration;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.widget.CommonTitle;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.mm.android.deviceaddmodule.device_wifi.ErrorTipActivity.ERROR_PARAMS;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备wifi列表界面
|
||||||
|
*/
|
||||||
|
public class DeviceWifiListActivity<T extends DeviceWifiListConstract.Presenter> extends BaseManagerFragmentActivity<T> implements DeviceWifiListConstract.View,
|
||||||
|
CommonTitle.OnTitleClickListener, AdapterView.OnItemClickListener{
|
||||||
|
|
||||||
|
protected DeviceWifiListAdapter mAdapter;
|
||||||
|
protected ListView mList;
|
||||||
|
protected TextView mCurWifiSSIDTv;
|
||||||
|
protected ImageView mCurWifiQualityIv;
|
||||||
|
protected LinearLayout mNo5GLl;
|
||||||
|
protected TextView mNo5GTv;
|
||||||
|
protected TextView deviceWifi;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initLayout() {
|
||||||
|
setContentView(R.layout.activity_device_wifi_list);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected View initTitle() {
|
||||||
|
CommonTitle title = (CommonTitle) findViewById(R.id.device_wifi_list_title);
|
||||||
|
title.initView(R.drawable.mobile_common_title_back, R.drawable.common_title_refresh_selector, R.string.mobile_common_network_config);
|
||||||
|
title.setOnTitleClickListener(this);
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initView() {
|
||||||
|
super.initView();
|
||||||
|
mList = (ListView) findViewById(R.id.device_wifi_list);
|
||||||
|
mCurWifiSSIDTv = (TextView) findViewById(R.id.wifi_ssid);
|
||||||
|
mCurWifiQualityIv = (ImageView) findViewById(R.id.wifi_quality_icon);
|
||||||
|
mNo5GLl = findViewById(R.id.device_wifi_no_5g);
|
||||||
|
mNo5GTv = findViewById(R.id.tv_5g_tip);
|
||||||
|
|
||||||
|
mNo5GTv.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
Intent intent = new Intent(DeviceWifiListActivity.this, ErrorTipActivity.class);
|
||||||
|
intent.putExtra(ERROR_PARAMS,1);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
deviceWifi = findViewById(R.id.device_wifi_list_text);
|
||||||
|
deviceWifi.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
Intent intent = new Intent(DeviceWifiListActivity.this, ErrorTipActivity.class);
|
||||||
|
intent.putExtra(ERROR_PARAMS,2);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
mList.setOnItemClickListener(this);
|
||||||
|
View view = LayoutInflater.from(this).inflate(R.layout.item_wifi_list_more, null);
|
||||||
|
view.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
Intent intent = new Intent(DeviceWifiListActivity.this, HiddenWifiActivity.class);
|
||||||
|
intent.putExtra(LCConfiguration.Device_ID,mPresenter.getDHDevice().getDeviceId());
|
||||||
|
intent.putExtra(LCConfiguration.SUPPORT_5G,mPresenter.isSupport5G(mPresenter.getDHDevice().getWifiTransferMode()));
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
mList.addFooterView(view,null,true);
|
||||||
|
mAdapter = new DeviceWifiListAdapter(R.layout.include_device_wifi_list_item, new ArrayList<WifiInfo>(), this);
|
||||||
|
mList.setAdapter(mAdapter);
|
||||||
|
|
||||||
|
new Handler().postDelayed(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (!isActivityDestory()) {
|
||||||
|
mPresenter.getDeviceWifiListAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initPresenter() {
|
||||||
|
mPresenter = (T) new DeviceWifiListPresenter(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initData() {
|
||||||
|
mPresenter.dispatchIntentData(getIntent());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCommonTitleClick(int id) {
|
||||||
|
switch (id) {
|
||||||
|
case CommonTitle.ID_LEFT:
|
||||||
|
Intent intent = new Intent();
|
||||||
|
intent.putExtra(DeviceConstant.IntentKey.DEVICE_CURRENT_WIFI_INFO, mPresenter.getCurWifiInfo());
|
||||||
|
setResult(RESULT_OK, intent);
|
||||||
|
DeviceWifiListActivity.this.finish();
|
||||||
|
break;
|
||||||
|
case CommonTitle.ID_RIGHT:
|
||||||
|
mPresenter.getDeviceWifiListAsync();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
|
Intent intent = new Intent(this,DeviceWifiPasswordActivity.class);
|
||||||
|
intent.putExtra(DeviceConstant.IntentKey.DEVICE_WIFI_CONFIG_INFO,mPresenter.getWifiInfo(position));
|
||||||
|
intent.putExtra(LCConfiguration.Device_ID,mPresenter.getDHDevice().getDeviceId());
|
||||||
|
intent.putExtra(LCConfiguration.SUPPORT_5G,mPresenter.isSupport5G(mPresenter.getDHDevice().getWifiTransferMode()));
|
||||||
|
startActivityForResult(intent,DeviceConstant.IntentCode.DEVICE_SETTING_WIFI_OPERATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void refreshListView(List<WifiInfo> wifiInfos) {
|
||||||
|
if (mAdapter != null){
|
||||||
|
mAdapter.clearData();
|
||||||
|
mAdapter.addData(wifiInfos);
|
||||||
|
mAdapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoadSucceed(boolean isEmpty,boolean isError) {
|
||||||
|
if (isEmpty) {
|
||||||
|
findViewById(R.id.device_wifi_list_empty_view).setVisibility(View.VISIBLE);
|
||||||
|
findViewById(R.id.device_wifi_list_layout).setVisibility(View.GONE);
|
||||||
|
mNo5GLl.setVisibility(View.GONE);
|
||||||
|
((TextView) findViewById(R.id.device_wifi_list_empty_view)).setText(isError?R.string.mobile_common_get_info_failed:R.string.device_manager_wifi_list_empty);
|
||||||
|
} else {
|
||||||
|
if (!mPresenter.isSupport5G(mPresenter.getDHDevice().getWifiTransferMode())) {
|
||||||
|
mNo5GLl.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
findViewById(R.id.device_wifi_list_empty_view).setVisibility(View.GONE);
|
||||||
|
findViewById(R.id.device_wifi_list_layout).setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateCurWifiLayout(CurWifiInfo curWifiInfo) {
|
||||||
|
if (curWifiInfo == null || !curWifiInfo.isLinkEnable() || TextUtils.isEmpty(curWifiInfo.getSsid())) {
|
||||||
|
findViewById(R.id.device_wifi_list_connected).setVisibility(View.GONE);
|
||||||
|
findViewById(R.id.device_wifi_list_connected_info).setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
|
findViewById(R.id.device_wifi_list_connected).setVisibility(View.VISIBLE);
|
||||||
|
findViewById(R.id.device_wifi_list_connected_info).setVisibility(View.VISIBLE);
|
||||||
|
mCurWifiSSIDTv.setText(curWifiInfo.getSsid());
|
||||||
|
mCurWifiQualityIv.setVisibility(View.VISIBLE);
|
||||||
|
if (curWifiInfo.getIntensity() < 2) {
|
||||||
|
mCurWifiQualityIv.setImageResource("OPEN".equalsIgnoreCase(curWifiInfo.getAuth())
|
||||||
|
? R.drawable.devicedetail_wifi_nosingal : R.drawable.devicedetail_wifi_nosingal_lock);
|
||||||
|
} else if (curWifiInfo.getIntensity() < 3) {
|
||||||
|
mCurWifiQualityIv.setImageResource("OPEN".equalsIgnoreCase(curWifiInfo.getAuth())
|
||||||
|
? R.drawable.devicedetail_wifi_1singal : R.drawable.devicedetail_wifi_1singal_lock);
|
||||||
|
} else if (curWifiInfo.getIntensity() < 4) {
|
||||||
|
mCurWifiQualityIv.setImageResource("OPEN".equalsIgnoreCase(curWifiInfo.getAuth())
|
||||||
|
? R.drawable.devicedetail_wifi_2singal : R.drawable.devicedetail_wifi_2singal_lock);
|
||||||
|
} else {
|
||||||
|
mCurWifiQualityIv.setImageResource("OPEN".equalsIgnoreCase(curWifiInfo.getAuth())
|
||||||
|
? R.drawable.devicedetail_wifi_3singal : R.drawable.devicedetail_wifi_3singal_lock);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void viewFinish() {
|
||||||
|
DeviceWifiListActivity.this.finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
if (requestCode == DeviceConstant.IntentCode.DEVICE_SETTING_WIFI_OPERATE && resultCode == Activity.RESULT_OK
|
||||||
|
&& data != null) {
|
||||||
|
CurWifiInfo curWifiInfo = (CurWifiInfo) data.getSerializableExtra(DeviceConstant.IntentKey.DEVICE_CURRENT_WIFI_INFO);
|
||||||
|
Intent intent = new Intent();
|
||||||
|
intent.putExtra(DeviceConstant.IntentKey.DEVICE_CURRENT_WIFI_INFO, curWifiInfo);
|
||||||
|
setResult(RESULT_OK, intent);
|
||||||
|
DeviceWifiListActivity.this.finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBackPressed() {
|
||||||
|
Intent intent = new Intent();
|
||||||
|
intent.putExtra(DeviceConstant.IntentKey.DEVICE_CURRENT_WIFI_INFO, mPresenter.getCurWifiInfo());
|
||||||
|
setResult(RESULT_OK, intent);
|
||||||
|
super.onBackPressed();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
package com.mm.android.deviceaddmodule.device_wifi;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.mm.android.deviceaddmodule.R;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.base.adapter.CommonAdapter;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.common.ViewHolder;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class DeviceWifiListAdapter extends CommonAdapter<WifiInfo> {
|
||||||
|
|
||||||
|
public DeviceWifiListAdapter(int layout, List<WifiInfo> list, Context context) {
|
||||||
|
super(layout, list, context);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void convert(ViewHolder viewHolder, WifiInfo entity,
|
||||||
|
final int position, ViewGroup parent) {
|
||||||
|
TextView wifiSSID = (TextView) viewHolder.findViewById(R.id.wifi_ssid);
|
||||||
|
ImageView wifiQualityIcon = (ImageView) viewHolder.findViewById(R.id.wifi_quality_icon);
|
||||||
|
|
||||||
|
wifiSSID.setText(entity.getSsid()); //设置wifi名
|
||||||
|
int quality = entity.getIntensity(); //获取wifi信号
|
||||||
|
|
||||||
|
if (quality < 2) {
|
||||||
|
wifiQualityIcon.setImageResource("OPEN".equalsIgnoreCase(entity.getAuth())
|
||||||
|
? R.drawable.devicedetail_wifi_nosingal : R.drawable.devicedetail_wifi_nosingal_lock);
|
||||||
|
} else if (quality < 3) {
|
||||||
|
wifiQualityIcon.setImageResource("OPEN".equalsIgnoreCase(entity.getAuth())
|
||||||
|
? R.drawable.devicedetail_wifi_1singal : R.drawable.devicedetail_wifi_1singal_lock);
|
||||||
|
} else if (quality < 4) {
|
||||||
|
wifiQualityIcon.setImageResource("OPEN".equalsIgnoreCase(entity.getAuth())
|
||||||
|
? R.drawable.devicedetail_wifi_2singal : R.drawable.devicedetail_wifi_2singal_lock);
|
||||||
|
} else {
|
||||||
|
wifiQualityIcon.setImageResource("OPEN".equalsIgnoreCase(entity.getAuth())
|
||||||
|
? R.drawable.devicedetail_wifi_3singal : R.drawable.devicedetail_wifi_3singal_lock);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package com.mm.android.deviceaddmodule.device_wifi;
|
||||||
|
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.base.mvp.IBasePresenter;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.base.mvp.IBaseView;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.entity.device.DHDevice;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface DeviceWifiListConstract {
|
||||||
|
interface Presenter extends IBasePresenter {
|
||||||
|
void getDeviceWifiListAsync();
|
||||||
|
WifiInfo getWifiInfo(int position);
|
||||||
|
CurWifiInfo getCurWifiInfo();
|
||||||
|
boolean isSupport5G(String wifiMode);
|
||||||
|
DHDevice getDHDevice();
|
||||||
|
}
|
||||||
|
|
||||||
|
interface View extends IBaseView {
|
||||||
|
void refreshListView(List<WifiInfo> wlanInfos);
|
||||||
|
void onLoadSucceed(boolean isEmpty, boolean isError);
|
||||||
|
void updateCurWifiLayout(CurWifiInfo curWifiInfo);
|
||||||
|
void viewFinish();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,199 @@
|
||||||
|
package com.mm.android.deviceaddmodule.device_wifi;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Message;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
|
||||||
|
import com.mm.android.deviceaddmodule.LCDeviceEngine;
|
||||||
|
import com.mm.android.deviceaddmodule.R;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.AppConsume.BusinessException;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.AppConsume.BusinessRunnable;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.AppConsume.DHBaseHandler;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.base.LCBusinessHandler;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.businesstip.HandleMessageCode;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.entity.device.DHDevice;
|
||||||
|
import com.mm.android.deviceaddmodule.openapi.DeviceAddOpenApiManager;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class DeviceWifiListPresenter<T extends DeviceWifiListConstract.View>
|
||||||
|
extends BasePresenter<T> implements DeviceWifiListConstract.Presenter {
|
||||||
|
|
||||||
|
protected DHDevice mDHDevice;
|
||||||
|
protected CurWifiInfo mCurWifiInfo;
|
||||||
|
protected List<WifiInfo> mWifiInfos;
|
||||||
|
protected LCBusinessHandler mGetWifiConfigHandler;
|
||||||
|
protected boolean mIsLoading = false;
|
||||||
|
|
||||||
|
public DeviceWifiListPresenter(T view) {
|
||||||
|
super(view);
|
||||||
|
initModel();
|
||||||
|
mWifiInfos = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void initModel() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dispatchIntentData(Intent intent) {
|
||||||
|
if (intent != null && intent.getExtras() != null) {
|
||||||
|
Bundle bundle = intent.getExtras();
|
||||||
|
mDHDevice = (DHDevice) bundle.getSerializable(DeviceConstant.IntentKey.DHDEVICE_INFO);
|
||||||
|
if (bundle.containsKey(DeviceConstant.IntentKey.DEVICE_CURRENT_WIFI_INFO))
|
||||||
|
mCurWifiInfo = (CurWifiInfo) bundle.getSerializable(DeviceConstant.IntentKey.DEVICE_CURRENT_WIFI_INFO);
|
||||||
|
}
|
||||||
|
if (mDHDevice == null)
|
||||||
|
mView.get().viewFinish();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void unInit() {
|
||||||
|
if (mGetWifiConfigHandler != null) {
|
||||||
|
mGetWifiConfigHandler.cancle();
|
||||||
|
mGetWifiConfigHandler.removeCallbacksAndMessages(null);
|
||||||
|
mGetWifiConfigHandler = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void getDeviceWifiListAsync() {
|
||||||
|
if (mIsLoading)
|
||||||
|
return;
|
||||||
|
if (mGetWifiConfigHandler != null) {
|
||||||
|
mGetWifiConfigHandler.cancle();
|
||||||
|
mGetWifiConfigHandler = null;
|
||||||
|
}
|
||||||
|
mGetWifiConfigHandler = new DHBaseHandler<T>(mView) {
|
||||||
|
@Override
|
||||||
|
public void onStart() {
|
||||||
|
mView.get().showProgressDialog();
|
||||||
|
mIsLoading = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCompleted() {
|
||||||
|
mView.get().cancelProgressDialog();
|
||||||
|
mIsLoading = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleBusinessFinally(Message msg) {
|
||||||
|
if (msg.what == HandleMessageCode.HMC_SUCCESS) {
|
||||||
|
WifiConfig wifiConfig = (WifiConfig) msg.obj;
|
||||||
|
if (wifiConfig != null && wifiConfig.isEnable()) {
|
||||||
|
List<WifiInfo> wifiInfos = processWifiInfos(wifiConfig.getwLan());
|
||||||
|
mWifiInfos.clear();
|
||||||
|
mWifiInfos.addAll(wifiInfos);
|
||||||
|
mView.get().refreshListView(mWifiInfos);
|
||||||
|
mView.get().onLoadSucceed(mWifiInfos.isEmpty(), false);
|
||||||
|
mView.get().updateCurWifiLayout(mCurWifiInfo);
|
||||||
|
} else {
|
||||||
|
mView.get().onLoadSucceed(true, false);
|
||||||
|
mView.get().updateCurWifiLayout(mCurWifiInfo);
|
||||||
|
mView.get().showToastInfo(mView.get().getContextInfo().getString(R.string.device_manager_wifi_disable));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
mView.get().onLoadSucceed(true, true);
|
||||||
|
mView.get().updateCurWifiLayout(null);
|
||||||
|
mView.get().showToastInfo(mView.get().getContextInfo().getString(R.string.mobile_common_get_info_failed));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
new BusinessRunnable(mGetWifiConfigHandler) {
|
||||||
|
@Override
|
||||||
|
public void doBusiness() throws BusinessException {
|
||||||
|
try {
|
||||||
|
WifiConfig response = DeviceAddOpenApiManager.wifiAround(LCDeviceEngine.newInstance().accessToken, mDHDevice.getDeviceId());
|
||||||
|
mGetWifiConfigHandler.obtainMessage(HandleMessageCode.HMC_SUCCESS, response).sendToTarget();
|
||||||
|
} catch (BusinessException e) {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WifiInfo getWifiInfo(int position) {
|
||||||
|
if (position >= mWifiInfos.size())
|
||||||
|
return null;
|
||||||
|
return mWifiInfos.get(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSupport5G(String wifiMode) {
|
||||||
|
if (!TextUtils.isEmpty(wifiMode)) {
|
||||||
|
return wifiMode.toUpperCase().contains("5GHZ");
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CurWifiInfo getCurWifiInfo() {
|
||||||
|
return mCurWifiInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DHDevice getDHDevice() {
|
||||||
|
return mDHDevice;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理去掉相同的wifi,和当前已连接的wifi
|
||||||
|
*
|
||||||
|
* @param wifiInfos
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected List<WifiInfo> processWifiInfos(List<WifiInfo> wifiInfos) {
|
||||||
|
List<WifiInfo> tems = new ArrayList<>();
|
||||||
|
if (mCurWifiInfo == null) {
|
||||||
|
mCurWifiInfo = new CurWifiInfo();
|
||||||
|
}
|
||||||
|
if (wifiInfos == null || wifiInfos.isEmpty())
|
||||||
|
return tems;
|
||||||
|
// 获取当前连接的wifi
|
||||||
|
for (WifiInfo wifiInfo : wifiInfos) {
|
||||||
|
if (WifiInfo.Status.connected.equalsIgnoreCase(wifiInfo.getLinkStatus())) {
|
||||||
|
mCurWifiInfo.setIntensity(wifiInfo.getIntensity());
|
||||||
|
mCurWifiInfo.setSsid(wifiInfo.getSsid());
|
||||||
|
mCurWifiInfo.setAuth(wifiInfo.getAuth());
|
||||||
|
mCurWifiInfo.setLinkEnable(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (WifiInfo wifiInfo : wifiInfos) {
|
||||||
|
boolean isContains = false;
|
||||||
|
for (WifiInfo tem : tems) {
|
||||||
|
if (wifiInfo.getSsid() != null && wifiInfo.getSsid().equalsIgnoreCase(tem.getSsid())) {
|
||||||
|
isContains = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isContains) {
|
||||||
|
//已包含,去重
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mCurWifiInfo.getSsid() == null) {
|
||||||
|
//当前热点为空
|
||||||
|
tems.add(wifiInfo);
|
||||||
|
} else if (!mCurWifiInfo.getSsid().equalsIgnoreCase(wifiInfo.getSsid())) {
|
||||||
|
//当前热点不为空,去除当前已连接wifi
|
||||||
|
tems.add(wifiInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return tems;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDevSupport5G() {
|
||||||
|
String wifiMode = "";
|
||||||
|
if (!TextUtils.isEmpty(wifiMode)) {
|
||||||
|
return wifiMode.toUpperCase().contains("5GHZ");
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,155 @@
|
||||||
|
package com.mm.android.deviceaddmodule.device_wifi;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.text.Editable;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import android.text.TextWatcher;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.inputmethod.InputMethodManager;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.mm.android.deviceaddmodule.R;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.base.mvp.BaseManagerFragmentActivity;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.widget.ClearPasswordEditText;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.widget.CommonTitle;
|
||||||
|
|
||||||
|
import static com.mm.android.deviceaddmodule.device_wifi.ErrorTipActivity.ERROR_PARAMS;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备wifi列表界面
|
||||||
|
*/
|
||||||
|
public class DeviceWifiPasswordActivity<T extends DeviceWifiPasswordConstract.Presenter>
|
||||||
|
extends BaseManagerFragmentActivity<T> implements DeviceWifiPasswordConstract.View,
|
||||||
|
CommonTitle.OnTitleClickListener, View.OnClickListener {
|
||||||
|
|
||||||
|
protected TextView mWifiSSIDTv;
|
||||||
|
protected Button mDoneBtn;
|
||||||
|
protected ClearPasswordEditText mWifiPasswordEdt;
|
||||||
|
private TextView mSaveWifiPwdCheckbox;
|
||||||
|
private ImageView mWifiImg;
|
||||||
|
private TextView m5GWifiTipTv;
|
||||||
|
|
||||||
|
private final TextWatcher mTextWatcher = new TextWatcher() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTextChanged(CharSequence s, int arg1, int arg2, int arg3) {
|
||||||
|
mWifiPasswordEdt.removeTextChangedListener(mTextWatcher);
|
||||||
|
String str = Utils4DeviceManager.wifiPwdFilter(s.toString());
|
||||||
|
if (!str.equals(s.toString())) {
|
||||||
|
mWifiPasswordEdt.setText(str);
|
||||||
|
mWifiPasswordEdt.setSelection(str.length());
|
||||||
|
}
|
||||||
|
mWifiPasswordEdt.addTextChangedListener(mTextWatcher);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterTextChanged(Editable arg0) {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initLayout() {
|
||||||
|
setContentView(R.layout.activity_device_wifi_password);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected View initTitle() {
|
||||||
|
CommonTitle title = (CommonTitle) findViewById(R.id.device_wifi_password_title);
|
||||||
|
title.initView(R.drawable.mobile_common_title_back, 0, R.string.mobile_common_network_config);
|
||||||
|
title.setOnTitleClickListener(this);
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initView() {
|
||||||
|
super.initView();
|
||||||
|
|
||||||
|
mWifiSSIDTv = (TextView) findViewById(R.id.device_wifi_ssid);
|
||||||
|
mDoneBtn = (Button) findViewById(R.id.device_wifi_password_done_btn);
|
||||||
|
mWifiPasswordEdt = (ClearPasswordEditText) findViewById(R.id.device_wifi_password);
|
||||||
|
mWifiSSIDTv.setText(mPresenter.getWifiSSID());
|
||||||
|
mDoneBtn.setOnClickListener(this);
|
||||||
|
mWifiPasswordEdt.addTextChangedListener(mTextWatcher);
|
||||||
|
mSaveWifiPwdCheckbox = (TextView) findViewById(R.id.wifi_pwd_check);
|
||||||
|
mSaveWifiPwdCheckbox.setOnClickListener(this);
|
||||||
|
String savePassword = mPresenter.getSavedWifiPassword();
|
||||||
|
boolean wifiCheckBoxStatus = mPresenter.getSavedWifiCheckBoxStatus();
|
||||||
|
if (!TextUtils.isEmpty(savePassword)) {
|
||||||
|
mWifiPasswordEdt.setText(savePassword);
|
||||||
|
mWifiPasswordEdt.setSelection(savePassword.length());
|
||||||
|
}
|
||||||
|
mSaveWifiPwdCheckbox.setSelected(wifiCheckBoxStatus);
|
||||||
|
mWifiImg = (ImageView) findViewById(R.id.wifi_img);
|
||||||
|
mWifiImg.setImageResource(mPresenter.getSupport5G() ? R.drawable.adddevice_icon_wifipassword_nosupport5g : R.drawable.adddevice_icon_wifipassword_nosupport5g);
|
||||||
|
m5GWifiTipTv = findViewById(R.id.tv_5g_tip);
|
||||||
|
m5GWifiTipTv.setOnClickListener(this);
|
||||||
|
m5GWifiTipTv.setVisibility(mPresenter.getSupport5G() ? View.GONE : View.VISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initPresenter() {
|
||||||
|
mPresenter = (T) new DeviceWifiPasswordPresenter<>(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initData() {
|
||||||
|
mPresenter.dispatchIntentData(getIntent());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCommonTitleClick(int id) {
|
||||||
|
switch (id) {
|
||||||
|
case CommonTitle.ID_LEFT:
|
||||||
|
DeviceWifiPasswordActivity.this.finish();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getWifiPassword() {
|
||||||
|
return mWifiPasswordEdt.getText().toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSavePwdChecked() {
|
||||||
|
return mSaveWifiPwdCheckbox.isSelected();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onWifiOperateSucceed(CurWifiInfo curWifiInfo) {
|
||||||
|
DeviceWifiPasswordActivity.this.finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
int viewId = view.getId();
|
||||||
|
if (viewId == R.id.device_wifi_password_done_btn) {
|
||||||
|
InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(
|
||||||
|
Context.INPUT_METHOD_SERVICE);
|
||||||
|
inputMethodManager.hideSoftInputFromWindow(mWifiPasswordEdt.getWindowToken(), 0);
|
||||||
|
mWifiPasswordEdt.postDelayed(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
mPresenter.updateWifiCache();
|
||||||
|
mPresenter.wifiOperate();
|
||||||
|
}
|
||||||
|
}, 100);
|
||||||
|
} else if (viewId == R.id.wifi_pwd_check) {
|
||||||
|
view.setSelected(!view.isSelected());
|
||||||
|
if (!view.isSelected()) {
|
||||||
|
mPresenter.updateWifiCache();
|
||||||
|
}
|
||||||
|
} else if (viewId == R.id.tv_5g_tip) {
|
||||||
|
Intent intent = new Intent(this, ErrorTipActivity.class);
|
||||||
|
intent.putExtra(ERROR_PARAMS, 1);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.mm.android.deviceaddmodule.device_wifi;
|
||||||
|
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.base.mvp.IBasePresenter;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.base.mvp.IBaseView;
|
||||||
|
|
||||||
|
public interface DeviceWifiPasswordConstract {
|
||||||
|
interface Presenter extends IBasePresenter {
|
||||||
|
void wifiOperate();
|
||||||
|
String getWifiSSID();
|
||||||
|
void updateWifiCache();
|
||||||
|
String getSavedWifiPassword();
|
||||||
|
boolean getSavedWifiCheckBoxStatus();
|
||||||
|
boolean getSupport5G();
|
||||||
|
}
|
||||||
|
|
||||||
|
interface View extends IBaseView {
|
||||||
|
String getWifiPassword();
|
||||||
|
boolean isSavePwdChecked();
|
||||||
|
void onWifiOperateSucceed(CurWifiInfo curWifiInfo);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,104 @@
|
||||||
|
package com.mm.android.deviceaddmodule.device_wifi;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Handler;
|
||||||
|
|
||||||
|
import com.mm.android.deviceaddmodule.LCDeviceEngine;
|
||||||
|
import com.mm.android.deviceaddmodule.R;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.AppConsume.BusinessException;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.AppConsume.BusinessRunnable;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.AppConsume.DHBaseHandler;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.businesstip.HandleMessageCode;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.common.LCConfiguration;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.utils.PreferencesHelper;
|
||||||
|
import com.mm.android.deviceaddmodule.openapi.DeviceAddOpenApiManager;
|
||||||
|
|
||||||
|
public class DeviceWifiPasswordPresenter<T extends DeviceWifiPasswordConstract.View> extends BasePresenter<T> implements DeviceWifiPasswordConstract.Presenter {
|
||||||
|
|
||||||
|
public String WIFI_SAVE_PREFIX = LCDeviceEngine.newInstance().userId + "_WIFI_ADD_";
|
||||||
|
public String WIFI_CHECKBOX_SAVE_PREFIX = LCDeviceEngine.newInstance().userId + "_WIFI_CHECKBOX_ADD_";
|
||||||
|
|
||||||
|
protected String mDeviceId;
|
||||||
|
protected WifiInfo mWifiInfo;
|
||||||
|
private DHBaseHandler mWifiOperateHandler;
|
||||||
|
protected boolean support5G = false;
|
||||||
|
|
||||||
|
public DeviceWifiPasswordPresenter(T view) {
|
||||||
|
super(view);
|
||||||
|
initModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void initModel() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dispatchIntentData(Intent intent) {
|
||||||
|
if (intent != null && intent.getExtras() != null) {
|
||||||
|
mDeviceId = intent.getStringExtra(LCConfiguration.Device_ID);
|
||||||
|
mWifiInfo = (WifiInfo) intent.getSerializableExtra(DeviceConstant.IntentKey.DEVICE_WIFI_CONFIG_INFO);
|
||||||
|
support5G = intent.getBooleanExtra(LCConfiguration.SUPPORT_5G, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getSupport5G() {
|
||||||
|
return support5G;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateWifiCache() {
|
||||||
|
if (mView.get().isSavePwdChecked()) {
|
||||||
|
PreferencesHelper.getInstance(mView.get().getContextInfo()).set(WIFI_SAVE_PREFIX + mWifiInfo.getSsid(), mView.get().getWifiPassword());
|
||||||
|
PreferencesHelper.getInstance(mView.get().getContextInfo()).set(WIFI_CHECKBOX_SAVE_PREFIX + mWifiInfo.getSsid(), true);
|
||||||
|
} else {
|
||||||
|
PreferencesHelper.getInstance(mView.get().getContextInfo()).set(WIFI_SAVE_PREFIX + mWifiInfo.getSsid(), "");
|
||||||
|
PreferencesHelper.getInstance(mView.get().getContextInfo()).set(WIFI_CHECKBOX_SAVE_PREFIX + mWifiInfo.getSsid(), false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSavedWifiPassword() {
|
||||||
|
return PreferencesHelper.getInstance(mView.get().getContextInfo()).getString(WIFI_SAVE_PREFIX + mWifiInfo.getSsid());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getSavedWifiCheckBoxStatus() {
|
||||||
|
return PreferencesHelper.getInstance(mView.get().getContextInfo()).getBoolean(WIFI_CHECKBOX_SAVE_PREFIX + mWifiInfo.getSsid());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void wifiOperate() {
|
||||||
|
new BusinessRunnable(mWifiOperateHandler) {
|
||||||
|
@Override
|
||||||
|
public void doBusiness() throws BusinessException {
|
||||||
|
try {
|
||||||
|
DeviceAddOpenApiManager.controlDeviceWifi(LCDeviceEngine.newInstance().accessToken, mDeviceId, mWifiInfo.getSsid(), mWifiInfo.getBSSID(), true, mView.get().getWifiPassword());
|
||||||
|
mWifiOperateHandler.obtainMessage(HandleMessageCode.HMC_SUCCESS, true).sendToTarget();
|
||||||
|
} catch (BusinessException e) {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
mView.get().showToastInfo(R.string.device_manager_wifi_connetting_tip);
|
||||||
|
Handler mHandler = new Handler();
|
||||||
|
mHandler.postDelayed(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
mView.get().onWifiOperateSucceed(null);
|
||||||
|
}
|
||||||
|
}, 3000);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getWifiSSID() {
|
||||||
|
if (mWifiInfo == null)
|
||||||
|
return "";
|
||||||
|
return mWifiInfo.getSsid();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void unInit() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,87 @@
|
||||||
|
package com.mm.android.deviceaddmodule.device_wifi;
|
||||||
|
|
||||||
|
import android.graphics.Paint;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.mm.android.deviceaddmodule.R;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.AppConsume.ProviderManager;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.base.mvp.BaseManagerFragmentActivity;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.common.PermissionHelper;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.widget.CommonTitle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备wifi列表界面
|
||||||
|
*/
|
||||||
|
public class ErrorTipActivity extends BaseManagerFragmentActivity implements CommonTitle.OnTitleClickListener {
|
||||||
|
|
||||||
|
public static String ERROR_PARAMS = "error_params";
|
||||||
|
|
||||||
|
private ImageView imageView;
|
||||||
|
private TextView textView;
|
||||||
|
private TextView textView1;
|
||||||
|
private TextView mHelpLinkTxt,mHelpPhoneTv;
|
||||||
|
int errorcode;
|
||||||
|
|
||||||
|
private PermissionHelper mPermissionHelper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initLayout() {
|
||||||
|
setContentView(R.layout.activity_error_tip);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected View initTitle() {
|
||||||
|
CommonTitle title = (CommonTitle) findViewById(R.id.error_tip_title);
|
||||||
|
title.initView(R.drawable.mobile_common_title_back, 0, R.string.mobile_common_network_config);
|
||||||
|
title.setOnTitleClickListener(this);
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initView() {
|
||||||
|
super.initView();
|
||||||
|
imageView = findViewById(R.id.tip_img);
|
||||||
|
textView = findViewById(R.id.tip_txt);
|
||||||
|
textView1 = findViewById(R.id.tip_txt_1);
|
||||||
|
mHelpLinkTxt = findViewById(R.id.help_link);
|
||||||
|
mHelpLinkTxt.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
ProviderManager.getDeviceAddCustomProvider().goFAQWebview(ErrorTipActivity.this);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
mHelpPhoneTv = findViewById(R.id.tv_help_phone);
|
||||||
|
mHelpPhoneTv.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG);
|
||||||
|
mHelpPhoneTv.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (errorcode == 1) {
|
||||||
|
imageView.setBackgroundResource(R.drawable.adddevice_icon_wifiexplain);
|
||||||
|
textView1.setVisibility(View.VISIBLE);
|
||||||
|
textView.setText(R.string.add_device_tip_not_support_5g_1);
|
||||||
|
} else if (errorcode == 2) {
|
||||||
|
imageView.setBackgroundResource(R.drawable.adddevice_icon_wifiexplain_choosewifi);
|
||||||
|
textView.setText(R.string.add_device_tip_wifi_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initData() {
|
||||||
|
errorcode = getIntent().getIntExtra(ERROR_PARAMS, 0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCommonTitleClick(int id) {
|
||||||
|
switch (id) {
|
||||||
|
case CommonTitle.ID_LEFT:
|
||||||
|
ErrorTipActivity.this.finish();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,112 @@
|
||||||
|
package com.mm.android.deviceaddmodule.device_wifi;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.text.Editable;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.inputmethod.InputMethodManager;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.mm.android.deviceaddmodule.R;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.base.mvp.BaseManagerFragmentActivity;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.widget.ClearEditText;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.widget.ClearPasswordEditText;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.widget.CommonTitle;
|
||||||
|
|
||||||
|
import static com.mm.android.deviceaddmodule.device_wifi.ErrorTipActivity.ERROR_PARAMS;
|
||||||
|
|
||||||
|
public class HiddenWifiActivity<T extends HiddenWifiConstract.Presenter>
|
||||||
|
extends BaseManagerFragmentActivity<T> implements HiddenWifiConstract.View {
|
||||||
|
|
||||||
|
|
||||||
|
private TextView mNext;
|
||||||
|
|
||||||
|
private ClearEditText mWifiName;
|
||||||
|
|
||||||
|
private ClearPasswordEditText mWifiPsw;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected View initTitle() {
|
||||||
|
CommonTitle title = findViewById(R.id.device_hidden_title);
|
||||||
|
title.initView(R.drawable.mobile_common_title_back, 0, R.string.device_manager_wifi_title);
|
||||||
|
title.setOnTitleClickListener(new CommonTitle.OnTitleClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onCommonTitleClick(int id) {
|
||||||
|
if (id == CommonTitle.ID_LEFT) {
|
||||||
|
HiddenWifiActivity.this.finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initLayout() {
|
||||||
|
setContentView(R.layout.activity_device_hidden_wifi);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void initView() {
|
||||||
|
super.initView();
|
||||||
|
|
||||||
|
mWifiName = findViewById(R.id.wifi_name);
|
||||||
|
mWifiPsw = findViewById(R.id.wifi_psw);
|
||||||
|
|
||||||
|
mNext = findViewById(R.id.next);
|
||||||
|
mNext.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(
|
||||||
|
Context.INPUT_METHOD_SERVICE);
|
||||||
|
inputMethodManager.hideSoftInputFromWindow(mWifiPsw.getWindowToken(), 0);
|
||||||
|
mWifiPsw.postDelayed(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
mPresenter.wifiOperate();
|
||||||
|
}
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
findViewById(R.id.tv_5g_tip).setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
Intent intent = new Intent(HiddenWifiActivity.this, ErrorTipActivity.class);
|
||||||
|
intent.putExtra(ERROR_PARAMS, 1);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
mWifiName.addTextChangedListener(new SimpleTextChangedListener() {
|
||||||
|
@Override
|
||||||
|
public void afterTextChanged(Editable s) {
|
||||||
|
mNext.setEnabled(s.length()>0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initPresenter() {
|
||||||
|
mPresenter = (T) new HiddenWifiPresenter<>(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initData() {
|
||||||
|
mPresenter.dispatchIntentData(getIntent());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getWifiSSID() {
|
||||||
|
return mWifiName.getText().toString().trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getWifiPassword() {
|
||||||
|
return mWifiPsw.getText().toString().trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onWifiOperateSucceed(CurWifiInfo curWifiInfo) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.mm.android.deviceaddmodule.device_wifi;
|
||||||
|
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.base.mvp.IBasePresenter;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.base.mvp.IBaseView;
|
||||||
|
|
||||||
|
public interface HiddenWifiConstract {
|
||||||
|
interface Presenter extends IBasePresenter {
|
||||||
|
void wifiOperate();
|
||||||
|
}
|
||||||
|
|
||||||
|
interface View extends IBaseView {
|
||||||
|
String getWifiSSID();
|
||||||
|
String getWifiPassword();
|
||||||
|
void onWifiOperateSucceed(CurWifiInfo curWifiInfo);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,68 @@
|
||||||
|
package com.mm.android.deviceaddmodule.device_wifi;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Handler;
|
||||||
|
|
||||||
|
import com.mm.android.deviceaddmodule.LCDeviceEngine;
|
||||||
|
import com.mm.android.deviceaddmodule.R;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.AppConsume.BusinessException;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.AppConsume.BusinessRunnable;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.AppConsume.DHBaseHandler;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.businesstip.HandleMessageCode;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.common.LCConfiguration;
|
||||||
|
import com.mm.android.deviceaddmodule.openapi.DeviceAddOpenApiManager;
|
||||||
|
|
||||||
|
public class HiddenWifiPresenter<T extends HiddenWifiConstract.View> extends BasePresenter<T> implements HiddenWifiConstract.Presenter {
|
||||||
|
|
||||||
|
protected String mDeviceId;
|
||||||
|
private DHBaseHandler mWifiOperateHandler;
|
||||||
|
|
||||||
|
public HiddenWifiPresenter(T view) {
|
||||||
|
super(view);
|
||||||
|
initModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void initModel() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dispatchIntentData(Intent intent) {
|
||||||
|
if (intent != null && intent.getExtras() != null) {
|
||||||
|
mDeviceId = intent.getStringExtra(LCConfiguration.Device_ID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void wifiOperate() {
|
||||||
|
if (mView.get().getWifiSSID().equalsIgnoreCase("")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
new BusinessRunnable(mWifiOperateHandler) {
|
||||||
|
@Override
|
||||||
|
public void doBusiness() throws BusinessException {
|
||||||
|
try {
|
||||||
|
DeviceAddOpenApiManager.controlDeviceWifi(LCDeviceEngine.newInstance().accessToken, mDeviceId, mView.get().getWifiSSID(),"", true, mView.get().getWifiPassword());
|
||||||
|
mWifiOperateHandler.obtainMessage(HandleMessageCode.HMC_SUCCESS, true).sendToTarget();
|
||||||
|
} catch (BusinessException e) {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
mView.get().showToastInfo(R.string.device_manager_wifi_connetting_tip);
|
||||||
|
Handler mHandler = new Handler();
|
||||||
|
mHandler.postDelayed(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
mView.get().onWifiOperateSucceed(null);
|
||||||
|
}
|
||||||
|
}, 3000);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void unInit() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
package com.mm.android.deviceaddmodule.device_wifi;
|
||||||
|
|
||||||
|
import android.text.Editable;
|
||||||
|
import android.text.TextWatcher;
|
||||||
|
|
||||||
|
public class SimpleTextChangedListener implements TextWatcher{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterTextChanged(Editable s) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,95 @@
|
||||||
|
package com.mm.android.deviceaddmodule.device_wifi;
|
||||||
|
|
||||||
|
import android.text.TextUtils;
|
||||||
|
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备管理相关工具类
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class Utils4DeviceManager {
|
||||||
|
public static String wifiPwdFilter(String str) {
|
||||||
|
|
||||||
|
if (TextUtils.isEmpty(str)) {
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
String chinese1 = "[\u2E80-\uA4CF]";
|
||||||
|
String chinese2 = "[\uF900-\uFAFF]";
|
||||||
|
String chinese3 = "[\uFE30-\uFE4F]";
|
||||||
|
|
||||||
|
for (int i = 0; i < str.length(); i++) {
|
||||||
|
String temp = str.substring(i, i + 1);
|
||||||
|
if (temp.matches(chinese1) || temp.matches(chinese2) || temp.matches(chinese3)) {
|
||||||
|
str = str.replace(temp, "");
|
||||||
|
return wifiPwdFilter(str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String replaceSpecial(String source,
|
||||||
|
List<String> filterStringList) {
|
||||||
|
for (String s : filterStringList) {
|
||||||
|
if (source.contains(s)) {
|
||||||
|
return source.replaceAll(s, "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 转换从服务获取的timeInfo
|
||||||
|
public static long convertTimeInfo(String time){
|
||||||
|
// 服务时间格式:"THHMMSS" 现转换时的格式"HHMM"
|
||||||
|
if(time.length() == 4){
|
||||||
|
long hour = Long.valueOf(time.substring(0, 2));
|
||||||
|
long min = Long.valueOf(time.substring(2, time.length()));
|
||||||
|
return hour * 3600 + min * 60;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getServerBeginTime(int hour, int minute) {
|
||||||
|
Calendar beginCalendar = Calendar.getInstance();
|
||||||
|
beginCalendar.set(Calendar.SECOND, 0);
|
||||||
|
beginCalendar.set(Calendar.HOUR_OF_DAY, hour);
|
||||||
|
beginCalendar.set(Calendar.MINUTE, minute);
|
||||||
|
SimpleDateFormat format = new SimpleDateFormat("HHmmss");
|
||||||
|
Date date = beginCalendar.getTime();
|
||||||
|
String time = format.format(date);
|
||||||
|
return "T" + time;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getServerEndTime(int hour, int minute) {
|
||||||
|
Calendar beginCalendar = Calendar.getInstance();
|
||||||
|
beginCalendar.set(Calendar.SECOND, 59);
|
||||||
|
beginCalendar.set(Calendar.HOUR_OF_DAY, hour);
|
||||||
|
beginCalendar.set(Calendar.MINUTE, minute);
|
||||||
|
SimpleDateFormat format = new SimpleDateFormat("HHmmss");
|
||||||
|
Date date = beginCalendar.getTime();
|
||||||
|
String time = format.format(date);
|
||||||
|
return "T" + time;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Calendar resolveTime(String time){
|
||||||
|
time = time.substring(1);
|
||||||
|
SimpleDateFormat format = new SimpleDateFormat("HHmmss");
|
||||||
|
Date date = null;
|
||||||
|
try {
|
||||||
|
date = format.parse(time);
|
||||||
|
} catch (ParseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
if(date != null){
|
||||||
|
calendar.setTime(date);
|
||||||
|
}
|
||||||
|
|
||||||
|
return calendar;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
package com.mm.android.deviceaddmodule.device_wifi;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wifi配置信息
|
||||||
|
*/
|
||||||
|
public class WifiConfig implements Serializable {
|
||||||
|
public static class Response {
|
||||||
|
public WifiConfig data;
|
||||||
|
|
||||||
|
public void parseData(JsonObject json) {
|
||||||
|
Gson gson = new Gson();
|
||||||
|
this.data = gson.fromJson(json.toString(), WifiConfig.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//设备是否开启WIFI。true:开启,false:关闭
|
||||||
|
private boolean enable;
|
||||||
|
//设备搜索到的wifi列表
|
||||||
|
private List<WifiInfo> wLan;
|
||||||
|
|
||||||
|
public boolean isEnable() {
|
||||||
|
return enable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnable(boolean enable) {
|
||||||
|
this.enable = enable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<WifiInfo> getwLan() {
|
||||||
|
return wLan;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setwLan(List<WifiInfo> wLan) {
|
||||||
|
this.wLan = wLan;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,79 @@
|
||||||
|
package com.mm.android.deviceaddmodule.device_wifi;
|
||||||
|
|
||||||
|
import android.support.annotation.StringDef;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
|
||||||
|
import static com.mm.android.deviceaddmodule.device_wifi.WifiInfo.Status.connected;
|
||||||
|
import static com.mm.android.deviceaddmodule.device_wifi.WifiInfo.Status.connecting;
|
||||||
|
import static com.mm.android.deviceaddmodule.device_wifi.WifiInfo.Status.unconnected;
|
||||||
|
import static java.lang.annotation.RetentionPolicy.SOURCE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wifi状态信息
|
||||||
|
*/
|
||||||
|
public class WifiInfo implements Serializable {
|
||||||
|
//该WIFI的唯一标示符,通常是一个MAC地址
|
||||||
|
private String bssid ;
|
||||||
|
//若连接了热点,填热点的名称;若未连接,填空
|
||||||
|
private String ssid;
|
||||||
|
//连接状态。unconnected:未连接;connecting:连接中;connected:已连接
|
||||||
|
private String linkStatus;
|
||||||
|
//强度, 0最弱,5最强
|
||||||
|
private int intensity;
|
||||||
|
//WIFI认证模式:OPEN,WEP,WPA/WPA2 PSK,WPA/WPA2
|
||||||
|
private String auth;
|
||||||
|
|
||||||
|
@Retention(SOURCE)
|
||||||
|
@StringDef({unconnected, connecting, connected,""})
|
||||||
|
public @interface Status {
|
||||||
|
String unconnected = "unconnected"; //未连接;
|
||||||
|
String connecting = "connecting"; //连接中;
|
||||||
|
String connected = "connected"; //已连接
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBSSID() {
|
||||||
|
return bssid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBssid() {
|
||||||
|
return bssid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBssid(String bssid) {
|
||||||
|
this.bssid = bssid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSsid() {
|
||||||
|
return ssid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSsid(String ssid) {
|
||||||
|
this.ssid = ssid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLinkStatus() {
|
||||||
|
return linkStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLinkStatus(String linkStatus) {
|
||||||
|
this.linkStatus = linkStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getIntensity() {
|
||||||
|
return intensity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIntensity(int intensity) {
|
||||||
|
this.intensity = intensity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAuth() {
|
||||||
|
return auth;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuth(String auth) {
|
||||||
|
this.auth = auth;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
package com.mm.android.deviceaddmodule.entity;
|
||||||
|
|
||||||
|
import com.company.NetSDK.DEVICE_NET_INFO_EX;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 封装DEVICE_NET_INFO_EX
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class DeviceNetInfo {
|
||||||
|
private DEVICE_NET_INFO_EX mDevNetInfoEx;
|
||||||
|
|
||||||
|
private boolean mIsValid;
|
||||||
|
|
||||||
|
public DeviceNetInfo(DEVICE_NET_INFO_EX devNetInfoEx) {
|
||||||
|
mDevNetInfoEx = devNetInfoEx;
|
||||||
|
mIsValid = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DEVICE_NET_INFO_EX getDevNetInfoEx() {
|
||||||
|
return mDevNetInfoEx;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDevNetInfoEx(DEVICE_NET_INFO_EX devNetInfoEx) {
|
||||||
|
this.mDevNetInfoEx = devNetInfoEx;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isValid() {
|
||||||
|
return mIsValid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValid(boolean isValid) {
|
||||||
|
this.mIsValid = isValid;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "byInitStatus:" + mDevNetInfoEx.byInitStatus + "bySpecialAbility:" + mDevNetInfoEx.bySpecialAbility;/*.append(":").append(mDevNetInfoEx)*/
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,75 @@
|
||||||
|
package com.mm.android.deviceaddmodule.entity;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
|
||||||
|
public class WlanInfo implements Serializable {
|
||||||
|
/**
|
||||||
|
* 序列化ID
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private String wlanSSID; //wifi名称
|
||||||
|
private int wlanQuality; //wifi信号
|
||||||
|
private int wlanEncry; //加密方式
|
||||||
|
private int wlanAuthMode; //当wlanAuthMode和wlanEncrAlgr都为0时就是不需要密码
|
||||||
|
private int wlanEncrAlgr;
|
||||||
|
private String wlanPassword; //wifi密码
|
||||||
|
private String wlanBSSID; //wifi Mac地址
|
||||||
|
|
||||||
|
public int getWlanQuality() {
|
||||||
|
return wlanQuality;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWlanQuality(int wlanQuality) {
|
||||||
|
this.wlanQuality = wlanQuality;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getWlanSSID() {
|
||||||
|
return wlanSSID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWlanSSID(String wlanSSID) {
|
||||||
|
this.wlanSSID = wlanSSID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getWlanEncry() {
|
||||||
|
return wlanEncry;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWlanEncry(int wlanEncry) {
|
||||||
|
this.wlanEncry = wlanEncry;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getWlanPassword() {
|
||||||
|
return wlanPassword;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWlanPassword(String wlanPassword) {
|
||||||
|
this.wlanPassword = wlanPassword;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getWlanAuthMode() {
|
||||||
|
return wlanAuthMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWlanAuthMode(int wlanAuthMode) {
|
||||||
|
this.wlanAuthMode = wlanAuthMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getWlanEncrAlgr() {
|
||||||
|
return wlanEncrAlgr;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWlanEncrAlgr(int wlanEncrAlgr) {
|
||||||
|
this.wlanEncrAlgr = wlanEncrAlgr;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getWlanBSSID() {
|
||||||
|
return wlanBSSID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWlanBSSID(String wlanBSSID) {
|
||||||
|
this.wlanBSSID = wlanBSSID;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
package com.mm.android.deviceaddmodule.event;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.eventbus.event.BaseEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备添加消息通信类
|
||||||
|
**/
|
||||||
|
public class DeviceAddEvent extends BaseEvent {
|
||||||
|
//EVENT ACTION
|
||||||
|
public static String TITLE_MODE_ACTION="title_mode_action"; //标题栏模式控制
|
||||||
|
public static String CONFIG_PAGE_NAVIGATION_ACTION="config_page_navigation_action"; //添加流程页跳转通知
|
||||||
|
public static String SOFTAP_REFRSH_WIFI_LIST="softap_refresh_wifi_list"; //软AP刷新wifi列表
|
||||||
|
public static String SOFTAP_REFRSH_WIFI_LIST_DISABLE_ACTION ="softap_refresh_wifi_list_disable_action"; //软AP刷新wifi列表按钮置灰
|
||||||
|
public static String SOFTAP_REFRSH_WIFI_LIST_ENABLE_ACTION ="softap_refresh_wifi_list_enable_action"; //软AP刷新wifi列表按钮高亮
|
||||||
|
public static String SHOW_LOADING_VIEW_ACTION="show_loading_view_action"; //显示加载框
|
||||||
|
public static String DISMISS_LOADING_VIEW_ACTION="dismiss_loading_view_action"; //隐藏加载框
|
||||||
|
public static String CHANGE_TO_WIRELESS_ACTION="change_to_wireless_action"; //切换到无线
|
||||||
|
public static String CHANGE_TO_WIRED_ACTION="change_to_wired_action"; //切换到有线
|
||||||
|
public static String CHANGE_TO_SOFTAP_ACTION="change_to_softap_action"; //切换到软AP
|
||||||
|
public static String SHOW_TYPE_CHOSE_ACTION="show_type_chose_action"; //切换到软AP
|
||||||
|
public static String REFRESH_BATTERY_CAMERA_LIST = "refresh_battery_camera_list"; //更新电池相机列表
|
||||||
|
public static String DESTROY_ACTION = "destroy_action"; //销毁设备添加使用的缓存数据
|
||||||
|
public static String OFFLINE_CONFIG_SUCCESS_ACTION = "offline_config_success"; //离线配网成功
|
||||||
|
|
||||||
|
//EVENT KEY
|
||||||
|
public interface KEY{
|
||||||
|
String TITLE_MODE="title_mode"; //标题栏模式
|
||||||
|
}
|
||||||
|
|
||||||
|
Bundle bundle;
|
||||||
|
public DeviceAddEvent(String code) {
|
||||||
|
super(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DeviceAddEvent(String code,Bundle bundle){
|
||||||
|
super(code);
|
||||||
|
this.bundle=bundle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Bundle getBundle() {
|
||||||
|
return bundle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBundle(Bundle bundle) {
|
||||||
|
this.bundle = bundle;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
package com.mm.android.deviceaddmodule.helper;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class ActivityHelper {
|
||||||
|
public static Activity getCurrentActivity () {
|
||||||
|
try {
|
||||||
|
Class activityThreadClass = Class.forName("android.app.ActivityThread");
|
||||||
|
Object activityThread = activityThreadClass.getMethod("currentActivityThread").invoke(
|
||||||
|
null);
|
||||||
|
Field activitiesField = activityThreadClass.getDeclaredField("mActivities");
|
||||||
|
activitiesField.setAccessible(true);
|
||||||
|
Map activities = (Map) activitiesField.get(activityThread);
|
||||||
|
for (Object activityRecord : activities.values()) {
|
||||||
|
Class activityRecordClass = activityRecord.getClass();
|
||||||
|
Field pausedField = activityRecordClass.getDeclaredField("paused");
|
||||||
|
pausedField.setAccessible(true);
|
||||||
|
if (!pausedField.getBoolean(activityRecord)) {
|
||||||
|
Field activityField = activityRecordClass.getDeclaredField("activity");
|
||||||
|
activityField.setAccessible(true);
|
||||||
|
Activity activity = (Activity) activityField.get(activityRecord);
|
||||||
|
return activity;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (InvocationTargetException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (NoSuchFieldException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,439 @@
|
||||||
|
package com.mm.android.deviceaddmodule.helper;
|
||||||
|
|
||||||
|
import android.annotation.TargetApi;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.net.ConnectivityManager;
|
||||||
|
import android.net.Network;
|
||||||
|
import android.net.NetworkCapabilities;
|
||||||
|
import android.net.NetworkRequest;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
|
||||||
|
import com.company.NetSDK.CFG_NETAPP_WLAN;
|
||||||
|
import com.company.NetSDK.DEVICE_NET_INFO_EX;
|
||||||
|
import com.company.NetSDK.FinalVar;
|
||||||
|
import com.company.NetSDK.INetSDK;
|
||||||
|
import com.dahua.mobile.utility.network.DHWifiUtil;
|
||||||
|
import com.mm.android.deviceaddmodule.LcnDeviceAddActivity;
|
||||||
|
import com.mm.android.deviceaddmodule.event.DeviceAddEvent;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.AppConsume.ProviderManager;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.annotation.DeviceAbility;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.entity.deviceadd.DeviceAddInfo;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.p2pDevice.P2PErrorHelper;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.utils.LogUtil;
|
||||||
|
import com.mm.android.deviceaddmodule.model.DeviceAddModel;
|
||||||
|
|
||||||
|
import org.greenrobot.eventbus.EventBus;
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
public class DeviceAddHelper {
|
||||||
|
public static final String DEVICE_MODEL_NAME_PARAM= "device_model_name_param"; //设备市场型号
|
||||||
|
public static final int DEVICE_NAME_MAX_LENGTH = 20; //设备名长度限制
|
||||||
|
public static final int AP_NAME_MAX_LENGTH = 20; //配件名长度限制
|
||||||
|
public static final String AP_WIFI_NAME_DAP = "DAP-XXXX"; //软Ap通用设备热点名称
|
||||||
|
public static final String AP_WIFI_VERSION_V1 = "V1"; //软Ap wifi version版本
|
||||||
|
public static final String AP_WIFI_VERSION_V2 = "V2"; //软Ap wifi version版本
|
||||||
|
|
||||||
|
// 是否支持新声波,二进制第1位,0表示否,1表示是
|
||||||
|
public static final int ALLOW_SoundWaveV2 = 1; // 0001
|
||||||
|
|
||||||
|
// 是否支持老声波,二进制第2位,0表示否,1表示是
|
||||||
|
public static final int ALLOW_SoundWave = 1 << 1; // 0010
|
||||||
|
|
||||||
|
// 是否支持SmartConfig,二进制第3位,0表示否,1表示是
|
||||||
|
public static final int ALLOW_SmartConfig = 1 << 2; // 0100
|
||||||
|
|
||||||
|
// 是否支持SoftAP,二进制第4位,0表示否,1表示是
|
||||||
|
public static final int ALLOW_SoftAP = 1 << 3; // 1000
|
||||||
|
|
||||||
|
// 是否支持LAN,二进制第4位,0表示否,1表示是
|
||||||
|
public static final int ALLOW_LAN = 1 << 4; // 10000
|
||||||
|
|
||||||
|
// 是否支持蓝牙,二进制第4位,0表示否,1表示是
|
||||||
|
public static final int ALLOW_BT = 1 << 5; // 100000
|
||||||
|
|
||||||
|
public enum TitleMode {
|
||||||
|
// FLASH, //闪光灯
|
||||||
|
MORE, //更多
|
||||||
|
MORE2, //更多模式2
|
||||||
|
MORE3, //更多模式3
|
||||||
|
MORE4, //更多模式4
|
||||||
|
REFRESH, //刷新
|
||||||
|
BLANK, //空白
|
||||||
|
SHARE, //设备共享
|
||||||
|
FREE_CLOUD_STORAGE, //免费云存储
|
||||||
|
MODIFY_DEVICE_NAME //修改设备密码
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum TimeoutDevTypeModel {
|
||||||
|
A_MODEL, //A系列
|
||||||
|
CK_MODEL, //CK系列
|
||||||
|
COMMON_MODEL, //通用设备
|
||||||
|
DOORBELL_MODEL, //门铃系列
|
||||||
|
AP_MODEL, //配件
|
||||||
|
OTHER_MODEL, //其他
|
||||||
|
TP1_MODEL, //TP1类型
|
||||||
|
TP1S_MODEL, //TP1S类型
|
||||||
|
G1_MODEL, //G1类型
|
||||||
|
K5_MODEL //门锁类型
|
||||||
|
}
|
||||||
|
|
||||||
|
//设备添加相关错误码
|
||||||
|
public interface ErrorCode {
|
||||||
|
//输入设备序列号流程相关错误码
|
||||||
|
int INPUT_SN_ERROR_BIND_BY_OTHER = 1000 + 1; //输入序列号时设备被其他用户绑定
|
||||||
|
int DEVICE_BIND_ERROR_BIND_BY_OTHER = 1000 + 2; //绑定时设备被其他用户绑定
|
||||||
|
int DEVICE_BIND_ERROR_NOT_SUPPORT_TO_BIND = 1000 + 3; //扫码、选型号、设备上线绑定时不支持绑定的设备类型
|
||||||
|
//设备选择流程相关错误码
|
||||||
|
int TYPE_CHOOSE_ERROR_1 = 2000;
|
||||||
|
//有线无线配置流程相关错误码
|
||||||
|
int WIRED_WIRELESS_ERROR_CONFIG_TIMEOUT = 3000 + 1; //配置超时
|
||||||
|
//软AP添加流程相关错误码
|
||||||
|
int SOFTAP_ERROR_CONNECT_HOT_FAILED = 4000 + 1; //连接设备热点失败
|
||||||
|
int SOFTAP_ERROR_CONNECT_WIFI_FAILED = 4000 + 2; //设备连接wifi失败
|
||||||
|
//设备初始化流程相关错误码
|
||||||
|
int INIT_ERROR_SERCRITY_CHECK_TIMEOUT = 5000 + 1; //安全检查超时
|
||||||
|
int INIT_ERROR_INIT_FAILED = 5000 + 2; //初始化失败
|
||||||
|
//连接云平台流程相关错误码
|
||||||
|
int CLOUND_CONNECT_ERROR_CONNECT_TIMEOUT = 6000 + 1; //连接超时
|
||||||
|
int CLOUND_CONNECT_QUERY_STATUS_TIMEOUT = 6000 + 2; //查询超时
|
||||||
|
|
||||||
|
//通用
|
||||||
|
int COMMON_ERROR_NOT_SUPPORT_5G = 7000 + 1; //不支持5G
|
||||||
|
int COMMON_ERROR_NOT_SUPPORT_RESET = 7000 + 2; //重置设备
|
||||||
|
int COMMON_ERROR_NOT_SUPPORT_HUB_AP_RESET = 7000 + 3; //重置设备
|
||||||
|
int COMMON_ERROR_NOT_SUPPORT_HUB_RESET = 7000 + 4; //重置设备
|
||||||
|
|
||||||
|
int COMMON_ERROR_DEVICE_LOCKED = 7000 + 5; //设备锁定
|
||||||
|
int COMMON_ERROR_RED_ROTATE = 7000 + 6; //红灯旋转
|
||||||
|
int COMMON_ERROR_RED_ALWAYS = 7000 + 7; //红灯长亮
|
||||||
|
int COMMON_ERROR_RED_FLASH = 7000 + 8; //红灯闪烁
|
||||||
|
int COMMON_ERROR_DEVICE_BIND_MROE_THAN_TEN = 7000 + 9; //超过10次
|
||||||
|
int COMMON_ERROR_DEVICE_MROE_THAN_TEN_TWICE = 7000 + 10; //再次超过10次
|
||||||
|
int COMMON_ERROR_DEVICE_IP_ERROR = 7000 + 11; //IP
|
||||||
|
int COMMON_ERROR_DEVICE_SN_CODE_CONFLICT = 7000 + 12; //串号
|
||||||
|
int COMMON_ERROR_DEVICE_SN_OR_IMEI_NOT_MATCH = 7000 + 13; //imei和device id不匹配
|
||||||
|
|
||||||
|
int COMMON_ERROR_ABOUT_WIFI_PWD = 7000 + 14; //关于WIFI密码
|
||||||
|
|
||||||
|
int COMMON_ERROR_CONNECT_FAIL = 7000 + 15; //软AP连接失败
|
||||||
|
int COMMON_ERROR_WIFI_NAME = 7000 + 16; //软AP连接失败
|
||||||
|
|
||||||
|
//配件
|
||||||
|
int AP_ERROR_PAIR_TIMEOUT = 8000 + 2; //配对超时
|
||||||
|
}
|
||||||
|
|
||||||
|
//OMS配置key
|
||||||
|
public interface OMSKey {
|
||||||
|
final static String ERROR_TIPS_TYPE = "ErrorTipsType";
|
||||||
|
final static String ERROR_WIFI_TIPS_TYPE = "WifiErrorTipsType"; //有线无线配网错误页面模式
|
||||||
|
final static String ERROR_SOFTAP_TIPS_TYPE = "SoftAPErrorTipsType"; //软AP配网错误页面模式
|
||||||
|
final static String ERROR_ACCESSORY_TIPS_TYPE = "AccessoryErrorTipsType"; //配件配网错误页面模式
|
||||||
|
//有线无线
|
||||||
|
final static String WIFI_MODE_GUIDING_LIGHT_IMAGE = "WifiModeGuidingLightImage";
|
||||||
|
final static String WIFI_MODE_CONFIG_INTRODUCTION = "WifiModeConfigIntroduction";
|
||||||
|
final static String WIFI_MODE_CONFIG_CONFIRM_INTRODUCTION = "WifiModeConfigConfirmIntroduction";
|
||||||
|
final static String WIFI_MODE_RESET_GUIDE_INTRODUCTION = "WifiModeResetGuideIntroduction";
|
||||||
|
final static String WIFI_MODE_RESET_IMAGE = "WifiModeResetImage";
|
||||||
|
final static String WIFI_MODE_RESET_OPERATION_INTRODUCTION = "WifiModeResetOperationIntroduction";
|
||||||
|
final static String WIFI_MODE_FINISH_DEVICE_IMAGE = "WifiModeFinishDeviceImage";
|
||||||
|
//软AP
|
||||||
|
final static String SOFT_AP_MODE_WIFI_NAME = "SoftAPModeWifiName";
|
||||||
|
final static String SOFT_AP_MODE_GUIDING_STEP_ONE_IMAGE = "SoftAPModeGuidingStepOneImage";
|
||||||
|
final static String SOFT_AP_MODE_GUIDING_STEP_ONE_INTRODUCTION = "SoftAPModeGuidingStepOneIntroduction";
|
||||||
|
final static String SOFT_AP_MODE_GUIDING_STEP_TWO_IMAGE = "SoftAPModeGuidingStepTwoImage";
|
||||||
|
final static String SOFT_AP_MODE_GUIDING_STEP_TWO_INTRODUCTION = "SoftAPModeGuidingStepTwoIntroduction";
|
||||||
|
final static String SOFT_AP_MODE_GUIDING_STEP_THREE_IMAGE = "SoftAPModeGuidingStepThreeImage";
|
||||||
|
final static String SOFT_AP_MODE_GUIDING_STEP_THREE_INTRODUCTION = "SoftAPModeGuidingStepThreeIntroduction";
|
||||||
|
final static String SOFT_AP_MODE_GUIDING_STEP_FOUR_IMAGE = "SoftAPModeGuidingStepFourImage";
|
||||||
|
final static String SOFT_AP_MODE_GUIDING_STEP_FOUR_INTRODUCTION = "SoftAPModeGuidingStepFourIntroduction";
|
||||||
|
final static String SOFT_AP_MODE_RESET_GUIDE_INTRODUCTION = "SoftAPModeResetGuideIntroduction";
|
||||||
|
final static String SOFT_AP_MODE_RESET_IMAGE = "SoftAPModeResetImage";
|
||||||
|
final static String SOFT_AP_MODE_RESET_OPERATION_INTRODUCTION = "SoftAPModeResetOperationIntroduction";
|
||||||
|
final static String SOFT_AP_MODE_RESULT_PROMPT_IMAGE = "SoftAPModeResultPromptImage";
|
||||||
|
final static String SOFT_AP_MODE_RESULT_INTRODUCTION = "SoftAPModeResultIntroduction";
|
||||||
|
final static String SOFT_AP_MODE_CONFIRM_INTRODUCTION = "SoftAPModeConfirmIntroduction";
|
||||||
|
final static String SOFT_AP_MODE_WIFI_VERSION = "SoftAPModeWifiVersion";
|
||||||
|
//配件
|
||||||
|
final static String ACCESSORY_MODE_PAIR_STATUS_IMAGE = "AccessoryModePairStatusImage";
|
||||||
|
final static String ACCESSORY_MODE_PAIR_OPERATION_INTRODUCTION = "AccessoryModePairOperationIntroduction";
|
||||||
|
final static String ACCESSORY_MODE_PAIR_CONFIRM_INTRODUCTION = "AccessoryModePairConfirmIntroduction";
|
||||||
|
final static String ACCESSORY_MODE_RESET_GUIDE_INTRODUCTION = "AccessoryModeResetGuideIntroduction";
|
||||||
|
final static String ACCESSORY_MODE_RESET_IMAGE = "AccessoryModeResetImage";
|
||||||
|
final static String ACCESSORY_MODE_RESET_OPERATION_INTRODUCTION = "AccessoryModeResetOperationIntroduction";
|
||||||
|
final static String ACCESSORY_MODE_FINISH_DEVICE_IMAGE = "AccessoryModeFinishDeviceImage";
|
||||||
|
//Hub
|
||||||
|
final static String HUB_MODE_PAIR_STATUS_IMAGE = "HubModePairStatusImage";
|
||||||
|
final static String HUB_MODE_PAIR_OPERATION_INTRODUCTION = "HubModePairOperationIntroduction";
|
||||||
|
final static String HUB_MODE_RESET_GUIDE_INTRODUCTION = "HubModeResetGuideIntroduction";
|
||||||
|
final static String HUB_MODE_RESET_IMAGE = "HubModeResetImage";
|
||||||
|
final static String HUB_MODE_RESET_OPERATION_INTRODUCTION = "HubModeResetOperationIntroduction";
|
||||||
|
final static String HUB_ACCESSORY_MODE_PAIR_STATUS_IMAGE = "HubAccessoryModePairStatusImage";
|
||||||
|
final static String HUB_ACCESSORY_MODE_PAIR_OPERATION_INTRODUCTION = "HubAccessoryModePairOperationIntroduction";
|
||||||
|
final static String HUB_ACCESSORY_MODE_RESET_GUIDE_INTRODUCTION = "HubAccessoryModeResetGuideIntroduction";
|
||||||
|
final static String HUB_ACCESSORY_MODE_RESET_IMAGE = "HubAccessoryModeResetImage";
|
||||||
|
final static String HUB_ACCESSORY_MODE_RESET_OPERATION_INTRODUCTION = "HubAccessoryModeResetOperationIntroduction";
|
||||||
|
final static String HUB_MODE_RESULT_PROMPT_IMAGE = "HUBModeResultPromptImage";
|
||||||
|
final static String HUB_MODE_RESULT_INTRODUCTION = "HUBModeResultIntroduction";
|
||||||
|
final static String HUB_MODE_CONFIRM_INTRODUCTION = "HUBModeConfirmIntroduction";
|
||||||
|
//设备本地配网
|
||||||
|
final static String LOCATION_MODE_OPERATION_IMAGE = "LocationOperationImages"; //引导图
|
||||||
|
final static String LOCATION_MODE_OPERATION_INTRODUCTION = "LocationOperationIntroduction"; //引导文案
|
||||||
|
final static String LOCATION_MODE_FINISH_DEVICE_IMAGE = "LocationModeFinishDeviceImage"; //添加完成正视图
|
||||||
|
// NB
|
||||||
|
final static String THIRD_PARTY_PLATFORM_MODE_GUIDING_LIGHT_IMAGE = "ThirdPartyPlatformModeGuidingLightImage"; //引导图
|
||||||
|
final static String THIRD_PARTY_PLATFORM_MODE_RESULT_PROMPT_IMAGE = "ThirdPartyPlatformModeResultPromptImage";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void updateTile(TitleMode titleMode) {
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putString(DeviceAddEvent.KEY.TITLE_MODE, titleMode.name());
|
||||||
|
EventBus.getDefault().post(new DeviceAddEvent(DeviceAddEvent.TITLE_MODE_ACTION, bundle));
|
||||||
|
}
|
||||||
|
|
||||||
|
//判断设备是否需要初始化
|
||||||
|
public static boolean isDeviceNeedInit(DEVICE_NET_INFO_EX device_net_info_ex) {
|
||||||
|
byte[] s = getByteArray(device_net_info_ex.byInitStatus);
|
||||||
|
// 设备初始化状态,按位确定初始化状态
|
||||||
|
// bit0~1:0-老设备,没有初始化功能 1-未初始化帐号 2-已初始化帐户
|
||||||
|
// bit2~3:0-老设备,保留 1-公网接入未使能 2-公网接入已使能
|
||||||
|
// bit4~5:0-老设备,保留 1-手机直连未使能 2-手机直连使能
|
||||||
|
if (s[s.length - 1] != 1) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//判断设备是否已经初始化
|
||||||
|
public static boolean isDeviceInited(DEVICE_NET_INFO_EX device_net_info_ex) {
|
||||||
|
byte[] s = getByteArray(device_net_info_ex.byInitStatus);
|
||||||
|
// 设备初始化状态,按位确定初始化状态
|
||||||
|
// bit0~1:0-老设备,没有初始化功能 1-未初始化帐号 2-已初始化帐户
|
||||||
|
// bit2~3:0-老设备,保留 1-公网接入未使能 2-公网接入已使能
|
||||||
|
// bit4~5:0-老设备,保留 1-手机直连未使能 2-手机直连使能
|
||||||
|
if (s[s.length - 1] != 2) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//判断设备是否支持初始化,仅在软AP添加流程中使用(为了兼容K5不支持初始化,需要用默认用admin登录设备)。其余添加流程仅判断是否需要初始化即可,需要的弹框用户输入,不需要的跳过。
|
||||||
|
public static boolean isDeviceSupportInit(DEVICE_NET_INFO_EX device_net_info_ex){
|
||||||
|
byte[] s = getByteArray(device_net_info_ex.byInitStatus);
|
||||||
|
// 设备初始化状态,按位确定初始化状态
|
||||||
|
// bit0~1:0-老设备,没有初始化功能 1-未初始化帐号 2-已初始化帐户
|
||||||
|
// bit2~3:0-老设备,保留 1-公网接入未使能 2-公网接入已使能
|
||||||
|
// bit4~5:0-老设备,保留 1-手机直连未使能 2-手机直连使能
|
||||||
|
if (s[s.length - 2] != 1) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取配置,3代协议
|
||||||
|
*
|
||||||
|
* @param loginHandle
|
||||||
|
* @param channelID
|
||||||
|
* @param strCommand
|
||||||
|
* @param BUFFERLEN
|
||||||
|
* @param stCfg
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static boolean getNewDevConfig(long loginHandle, int channelID, String strCommand, int BUFFERLEN, CFG_NETAPP_WLAN stCfg, String requestId) {
|
||||||
|
boolean ret = false;
|
||||||
|
//netsdk 使用局限,只能使用 类对象传递参数。
|
||||||
|
Integer error = new Integer(0);
|
||||||
|
char szBuffer[] = new char[BUFFERLEN];
|
||||||
|
ret = INetSDK.GetNewDevConfig(loginHandle, strCommand, channelID, szBuffer, BUFFERLEN, error, 5 * 1000);
|
||||||
|
if (!ret) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
ret = INetSDK.ParseData(strCommand, szBuffer, stCfg, null);
|
||||||
|
if (!ret) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断是否是设备用户名或密码错误
|
||||||
|
*
|
||||||
|
* @param error
|
||||||
|
*/
|
||||||
|
public static boolean isDevPwdError(int error) {
|
||||||
|
return (error == P2PErrorHelper.LOGIN_ERROR_KEY_OR_USER_MISMATCH
|
||||||
|
|| error == P2PErrorHelper.LOGIN_ERROR_KEY_MISMATCH
|
||||||
|
|| error == FinalVar.NET_LOGIN_ERROR_PASSWORD
|
||||||
|
|| error == FinalVar.NET_USER_FLASEPWD
|
||||||
|
|| error == FinalVar.NET_LOGIN_ERROR_USER_OR_PASSOWRD);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte[] getByteArray(byte b) {
|
||||||
|
byte[] array = new byte[8];
|
||||||
|
for (int i = 7; i >= 0; i--) {
|
||||||
|
array[i] = (byte) (b & 1);
|
||||||
|
b = (byte) (b >> 1);
|
||||||
|
}
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字符过滤
|
||||||
|
* @param str
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String strDeviceNameFilter(String str) {
|
||||||
|
if (TextUtils.isEmpty(str)) {
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
String strEx = "^[a-zA-Z0-9\\-\u4E00-\u9FA5\\_\\@\\s]+";
|
||||||
|
|
||||||
|
for (int i = 0; i < str.length(); i++) {
|
||||||
|
String temp = str.substring(i, i + 1);
|
||||||
|
if (temp.matches(strEx)) {
|
||||||
|
builder.append(temp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支持sc码添加
|
||||||
|
* @param deviceAddInfo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static boolean isSupportAddBySc(DeviceAddInfo deviceAddInfo) {
|
||||||
|
if(deviceAddInfo == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(!TextUtils.isEmpty(deviceAddInfo.getSc()) && deviceAddInfo.getSc().length() == 8) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if(deviceAddInfo.hasAbility(DeviceAbility.SCCode)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支持SC码的设备,使用SC码作为设备密码
|
||||||
|
*/
|
||||||
|
public static void setDevicePwdBySc() {
|
||||||
|
DeviceAddInfo deviceAddInfo = DeviceAddModel.newInstance().getDeviceInfoCache();
|
||||||
|
if(DeviceAddHelper.isSupportAddBySc(deviceAddInfo)) {
|
||||||
|
deviceAddInfo.setDevicePwd(deviceAddInfo.getSc());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支持2代声波
|
||||||
|
* @param deviceAddInfo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static boolean isSupportSoundWaveV2(DeviceAddInfo deviceAddInfo) {
|
||||||
|
if(deviceAddInfo == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return deviceAddInfo.getConfigMode() != null && deviceAddInfo.getConfigMode().contains(DeviceAddInfo.ConfigMode.SoundWaveV2.name());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getJsonString(DeviceAddInfo deviceAddInfo, boolean offlineConfigType) {
|
||||||
|
JSONObject result = new JSONObject();
|
||||||
|
try {
|
||||||
|
result.put("SN", deviceAddInfo.getDeviceSn());
|
||||||
|
if(offlineConfigType) {
|
||||||
|
result.put("deviceModelName", deviceAddInfo.getDeviceModel());
|
||||||
|
} else {
|
||||||
|
result.put("SC", deviceAddInfo.getSc());
|
||||||
|
}
|
||||||
|
result.put("imeiCode", deviceAddInfo.getImeiCode());
|
||||||
|
} catch (JSONException e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return result.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 打印错误码
|
||||||
|
public static int printError() {
|
||||||
|
int error = (INetSDK.GetLastError() & 0x7fffffff);
|
||||||
|
LogUtil.debugLog("DeviceAddHelper", "error:" + error);
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public interface BindNetworkListener{
|
||||||
|
void onBindWifiListener();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 指定手机走wifi链路
|
||||||
|
*/
|
||||||
|
public static void bindNetwork(final BindNetworkListener bindNetworkListener){
|
||||||
|
final ConnectivityManager connectivityManager = (ConnectivityManager)
|
||||||
|
ProviderManager.getAppProvider().getAppContext().getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
|
NetworkRequest.Builder builder;
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
|
builder = new NetworkRequest.Builder();
|
||||||
|
//set the transport type do WIFI
|
||||||
|
builder.addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VPN)
|
||||||
|
.addTransportType(NetworkCapabilities.TRANSPORT_WIFI)
|
||||||
|
.build();
|
||||||
|
connectivityManager.requestNetwork(builder.build(), new ConnectivityManager.NetworkCallback() {
|
||||||
|
|
||||||
|
@TargetApi(Build.VERSION_CODES.M)
|
||||||
|
@Override
|
||||||
|
public void onAvailable(Network network) {
|
||||||
|
LogUtil.debugLog(LcnDeviceAddActivity.TAG, "bindNetwork succuss");
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
|
connectivityManager.bindProcessToNetwork(null);
|
||||||
|
connectivityManager.bindProcessToNetwork(network);
|
||||||
|
} else {
|
||||||
|
//This method was deprecated in API level 23
|
||||||
|
ConnectivityManager.setProcessDefaultNetwork(null);
|
||||||
|
ConnectivityManager.setProcessDefaultNetwork(network);
|
||||||
|
}
|
||||||
|
connectivityManager.unregisterNetworkCallback(this);
|
||||||
|
if(bindNetworkListener != null){
|
||||||
|
bindNetworkListener.onBindWifiListener();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清除网络链路配置,注意软ap调用过{@link #bindNetwork},需要在合适的时机释放,否则无法连外网
|
||||||
|
*/
|
||||||
|
public static void clearNetWork(){
|
||||||
|
LogUtil.debugLog(LcnDeviceAddActivity.TAG, "clearNetWork succuss");
|
||||||
|
final ConnectivityManager connectivityManager = (ConnectivityManager)
|
||||||
|
ProviderManager.getAppProvider().getAppContext().getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
|
connectivityManager.bindProcessToNetwork(null);
|
||||||
|
} else if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
|
||||||
|
//This method was deprecated in API level 23
|
||||||
|
ConnectivityManager.setProcessDefaultNetwork(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 连接之前的wifi
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static void connectPreviousWifi(){
|
||||||
|
DeviceAddInfo deviceAddInfo = DeviceAddModel.newInstance().getDeviceInfoCache();
|
||||||
|
String previousSsid = deviceAddInfo.getPreviousSsid();
|
||||||
|
if(!TextUtils.isEmpty(previousSsid)) {
|
||||||
|
deviceAddInfo.setPreviousSsid("");
|
||||||
|
DHWifiUtil wifiUtil = new DHWifiUtil(ProviderManager.getAppProvider().getAppContext());
|
||||||
|
wifiUtil.connectWifi(previousSsid, "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.mm.android.deviceaddmodule.helper;
|
||||||
|
|
||||||
|
import com.mm.android.deviceaddmodule.R;
|
||||||
|
import com.nostra13.universalimageloader.core.DisplayImageOptions;
|
||||||
|
import com.nostra13.universalimageloader.core.assist.ImageScaleType;
|
||||||
|
|
||||||
|
public class DeviceAddImageLoaderHelper {
|
||||||
|
public static DisplayImageOptions getCommonOptions() {
|
||||||
|
DisplayImageOptions displayImageOptions = new DisplayImageOptions.Builder()
|
||||||
|
.cacheOnDisk(true)
|
||||||
|
.showImageForEmptyUri(R.drawable.adddevice_default)
|
||||||
|
.showImageOnFail(R.drawable.adddevice_default)
|
||||||
|
.considerExifParams(true).cacheOnDisk(true).cacheInMemory(true)
|
||||||
|
.imageScaleType(ImageScaleType.EXACTLY_STRETCHED).build();
|
||||||
|
return displayImageOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DisplayImageOptions getCommonOptions4success() {
|
||||||
|
DisplayImageOptions displayImageOptions = new DisplayImageOptions.Builder()
|
||||||
|
.cacheOnDisk(true)
|
||||||
|
.showImageForEmptyUri(R.drawable.adddevice_icon_success_default)
|
||||||
|
.showImageOnFail(R.drawable.adddevice_icon_success_default)
|
||||||
|
.considerExifParams(true).cacheOnDisk(true).cacheInMemory(true)
|
||||||
|
.imageScaleType(ImageScaleType.EXACTLY_STRETCHED).build();
|
||||||
|
return displayImageOptions;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
package com.mm.android.deviceaddmodule.helper;
|
||||||
|
|
||||||
|
import android.text.style.URLSpan;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.View.OnClickListener;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义加下划线及点击事件的文字相关功能类
|
||||||
|
*/
|
||||||
|
class MyURLSpan extends URLSpan {
|
||||||
|
private OnClickListener mListener;
|
||||||
|
|
||||||
|
public MyURLSpan(String url) {
|
||||||
|
super(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOnClickListener(OnClickListener listenr) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
mListener = listenr;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View widget) {
|
||||||
|
if (mListener != null) {
|
||||||
|
mListener.onClick(widget);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,842 @@
|
||||||
|
package com.mm.android.deviceaddmodule.helper;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.support.v4.app.FragmentActivity;
|
||||||
|
import android.support.v4.app.FragmentTransaction;
|
||||||
|
|
||||||
|
import com.company.NetSDK.DEVICE_NET_INFO_EX;
|
||||||
|
import com.mm.android.deviceaddmodule.R;
|
||||||
|
import com.mm.android.deviceaddmodule.entity.WlanInfo;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.AppConsume.ProviderManager;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.common.LCConfiguration;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.entity.AddApResult;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.entity.deviceadd.DeviceAddInfo;
|
||||||
|
import com.mm.android.deviceaddmodule.model.DeviceAddModel;
|
||||||
|
import com.mm.android.deviceaddmodule.p_ap.ApBindSuccessFragment;
|
||||||
|
import com.mm.android.deviceaddmodule.p_ap.ApPairFragment;
|
||||||
|
import com.mm.android.deviceaddmodule.p_ap.GatewayListFragment;
|
||||||
|
import com.mm.android.deviceaddmodule.p_ap.TipApLightFragment;
|
||||||
|
import com.mm.android.deviceaddmodule.p_ap.TipApPowerFragment;
|
||||||
|
import com.mm.android.deviceaddmodule.p_ap.hubap.HubapGuide1Fragment;
|
||||||
|
import com.mm.android.deviceaddmodule.p_ap.hubap.HubapGuide2Fragment;
|
||||||
|
import com.mm.android.deviceaddmodule.p_ap.hubap.HubapGuide3Fragment;
|
||||||
|
import com.mm.android.deviceaddmodule.p_bindsuccess.BindSuccessFragment;
|
||||||
|
import com.mm.android.deviceaddmodule.p_cloudconnect.CloudConnectFragment;
|
||||||
|
import com.mm.android.deviceaddmodule.p_devicelocal.TipDeviceLocalFragment;
|
||||||
|
import com.mm.android.deviceaddmodule.p_devlogin.DevLoginFragment;
|
||||||
|
import com.mm.android.deviceaddmodule.p_devlogin.DevSecCodeFragment;
|
||||||
|
import com.mm.android.deviceaddmodule.p_errortip.ErrorTipFragment;
|
||||||
|
import com.mm.android.deviceaddmodule.p_init.InitFragment;
|
||||||
|
import com.mm.android.deviceaddmodule.p_init.SecurityCheckFragment;
|
||||||
|
import com.mm.android.deviceaddmodule.p_inputsn.DeviceDispatchFragment;
|
||||||
|
import com.mm.android.deviceaddmodule.p_inputsn.IMEIInputFragment;
|
||||||
|
import com.mm.android.deviceaddmodule.p_inputsn.ManualInputFragment;
|
||||||
|
import com.mm.android.deviceaddmodule.p_inputsn.ScanFragment;
|
||||||
|
import com.mm.android.deviceaddmodule.p_nb.TipNBFragment;
|
||||||
|
import com.mm.android.deviceaddmodule.p_offlineconfig.OfflineConfigFragment;
|
||||||
|
import com.mm.android.deviceaddmodule.p_softap.DevWifiListFragment;
|
||||||
|
import com.mm.android.deviceaddmodule.p_softap.HiddenWifiPwdFragment;
|
||||||
|
import com.mm.android.deviceaddmodule.p_softap.SoftApWifiPwdFragment;
|
||||||
|
import com.mm.android.deviceaddmodule.p_softap.TipSoftApConnectWifiFragment;
|
||||||
|
import com.mm.android.deviceaddmodule.p_softap.TipSoftApStep1Fragment;
|
||||||
|
import com.mm.android.deviceaddmodule.p_softap.TipSoftApStep2Fragment;
|
||||||
|
import com.mm.android.deviceaddmodule.p_softap.TipSoftApStep3Fragment;
|
||||||
|
import com.mm.android.deviceaddmodule.p_softap.TipSoftApStep4Fragment;
|
||||||
|
import com.mm.android.deviceaddmodule.p_softap.oversea.SoftApResultFragment;
|
||||||
|
import com.mm.android.deviceaddmodule.p_typechoose.TypeChooseFragment;
|
||||||
|
import com.mm.android.deviceaddmodule.p_wiredwireless.SmartConfigFragment;
|
||||||
|
import com.mm.android.deviceaddmodule.p_wiredwireless.TipLightFragment;
|
||||||
|
import com.mm.android.deviceaddmodule.p_wiredwireless.TipNetCablePluginFragment;
|
||||||
|
import com.mm.android.deviceaddmodule.p_wiredwireless.TipPowerFragment;
|
||||||
|
import com.mm.android.deviceaddmodule.p_wiredwireless.TipSameNetworkFragment;
|
||||||
|
import com.mm.android.deviceaddmodule.p_wiredwireless.TipSoundFragment;
|
||||||
|
import com.mm.android.deviceaddmodule.p_wiredwireless.TipWifiConnectFragment;
|
||||||
|
import com.mm.android.deviceaddmodule.p_wiredwireless.WifiPwdFragment;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备添加页面跳转帮助类
|
||||||
|
**/
|
||||||
|
public class PageNavigationHelper {
|
||||||
|
public static final String TIP_POWER_FRAGMENT_TAG = "tip_power_fragment";
|
||||||
|
public static final String WIFI_PWD_TAG = "wifi_pwd_fragment";
|
||||||
|
public static final String SOFT_AP_TIP_TAG = "soft_ap_tip_fragment";
|
||||||
|
public static final String AP_TIP_TAG = "ap_tip_fragment";
|
||||||
|
public static final String SECURITY_CHECK_TAG = "security_check_fragment";
|
||||||
|
|
||||||
|
private static void setFragmentAnimations(FragmentTransaction transaction, boolean anim) {
|
||||||
|
if (anim) {
|
||||||
|
transaction.setCustomAnimations(R.anim.slide_in_right,
|
||||||
|
R.anim.slide_out_left,
|
||||||
|
R.anim.slide_left_back_in,
|
||||||
|
R.anim.slide_right_back_out);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void setFragmentAnimations(FragmentTransaction transaction) {
|
||||||
|
setFragmentAnimations(transaction, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 跳转至二维码扫描页
|
||||||
|
*
|
||||||
|
* @param fragmentActivity
|
||||||
|
*/
|
||||||
|
public static void gotoScanPage(FragmentActivity fragmentActivity) {
|
||||||
|
if (fragmentActivity == null || fragmentActivity.getSupportFragmentManager() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ScanFragment fragment = ScanFragment.newInstance();
|
||||||
|
FragmentTransaction transaction = fragmentActivity.getSupportFragmentManager().beginTransaction();
|
||||||
|
transaction.add(R.id.content, fragment);
|
||||||
|
transaction.commitAllowingStateLoss();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 跳转至二维码扫描页
|
||||||
|
*
|
||||||
|
* @param fragmentActivity
|
||||||
|
*/
|
||||||
|
public static void gotoDispatchPage(FragmentActivity fragmentActivity) {
|
||||||
|
if (fragmentActivity == null || fragmentActivity.getSupportFragmentManager() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DeviceDispatchFragment fragment = DeviceDispatchFragment.newInstance();
|
||||||
|
FragmentTransaction transaction = fragmentActivity.getSupportFragmentManager().beginTransaction();
|
||||||
|
transaction.add(R.id.content, fragment);
|
||||||
|
transaction.commitAllowingStateLoss();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 跳转至手动输入序列号页
|
||||||
|
*
|
||||||
|
* @param from
|
||||||
|
*/
|
||||||
|
public static void gotoManualInputPage(Fragment from) {
|
||||||
|
if (from == null || from.getFragmentManager() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ManualInputFragment fragment = ManualInputFragment.newInstance();
|
||||||
|
FragmentTransaction transaction = from.getFragmentManager().beginTransaction();
|
||||||
|
setFragmentAnimations(transaction);
|
||||||
|
transaction.replace(R.id.content, fragment);
|
||||||
|
transaction.addToBackStack(null);
|
||||||
|
transaction.commitAllowingStateLoss();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 跳转至输入imei页
|
||||||
|
*
|
||||||
|
* @param from
|
||||||
|
*/
|
||||||
|
public static void gotoIMEIInputPage(Fragment from, boolean anim) {
|
||||||
|
if (from == null || from.getFragmentManager() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
IMEIInputFragment fragment = IMEIInputFragment.newInstance();
|
||||||
|
FragmentTransaction transaction = from.getFragmentManager().beginTransaction();
|
||||||
|
setFragmentAnimations(transaction, anim);
|
||||||
|
transaction.replace(R.id.content, fragment);
|
||||||
|
transaction.addToBackStack(null);
|
||||||
|
transaction.commitAllowingStateLoss();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void gotoIMEIInputPage(Fragment from) {
|
||||||
|
gotoIMEIInputPage(from, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 跳转至设备类型选择页
|
||||||
|
*
|
||||||
|
* @param from
|
||||||
|
*/
|
||||||
|
public static void gotoTypeChoosePage(Fragment from, boolean anim) {
|
||||||
|
if (from == null || from.getFragmentManager() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
TypeChooseFragment fragment = TypeChooseFragment.newInstance();
|
||||||
|
FragmentTransaction transaction = from.getFragmentManager().beginTransaction();
|
||||||
|
setFragmentAnimations(transaction, anim);
|
||||||
|
transaction.replace(R.id.content, fragment);
|
||||||
|
transaction.addToBackStack(null);
|
||||||
|
transaction.commitAllowingStateLoss();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void gotoTypeChoosePage(Fragment from) {
|
||||||
|
gotoTypeChoosePage(from, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 跳转至电源提示页
|
||||||
|
*
|
||||||
|
* @param from
|
||||||
|
* @param isWirelessConfig
|
||||||
|
*/
|
||||||
|
public static void gotoPowerTipPageNoAnim(Fragment from, boolean isWirelessConfig) {
|
||||||
|
if (from == null || from.getFragmentManager() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
TipPowerFragment fragment = TipPowerFragment.newInstance(isWirelessConfig);
|
||||||
|
FragmentTransaction transaction = from.getFragmentManager().beginTransaction();
|
||||||
|
transaction.replace(R.id.content, fragment);
|
||||||
|
transaction.addToBackStack(TIP_POWER_FRAGMENT_TAG);
|
||||||
|
transaction.commitAllowingStateLoss();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 跳转至电源提示页
|
||||||
|
*
|
||||||
|
* @param from
|
||||||
|
* @param isWirelessConfig
|
||||||
|
*/
|
||||||
|
public static void gotoPowerTipPage(Fragment from, boolean isWirelessConfig) {
|
||||||
|
if (from == null || from.getFragmentManager() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
TipPowerFragment fragment = TipPowerFragment.newInstance(isWirelessConfig);
|
||||||
|
FragmentTransaction transaction = from.getFragmentManager().beginTransaction();
|
||||||
|
setFragmentAnimations(transaction);
|
||||||
|
transaction.replace(R.id.content, fragment);
|
||||||
|
transaction.addToBackStack(TIP_POWER_FRAGMENT_TAG);
|
||||||
|
transaction.commitAllowingStateLoss();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 跳转至网线提示页
|
||||||
|
*
|
||||||
|
* @param from
|
||||||
|
*/
|
||||||
|
public static void gotoNetCableTipPage(Fragment from) {
|
||||||
|
if (from == null || from.getFragmentManager() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
TipNetCablePluginFragment fragment = TipNetCablePluginFragment.newInstance();
|
||||||
|
FragmentTransaction transaction = from.getFragmentManager().beginTransaction();
|
||||||
|
setFragmentAnimations(transaction);
|
||||||
|
transaction.replace(R.id.content, fragment);
|
||||||
|
transaction.addToBackStack(null);
|
||||||
|
transaction.commitAllowingStateLoss();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 跳转至同一网络提示页
|
||||||
|
*
|
||||||
|
* @param from
|
||||||
|
*/
|
||||||
|
public static void gotoSameNetworkTipPage(Fragment from) {
|
||||||
|
if (from == null || from.getFragmentManager() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
TipSameNetworkFragment fragment = TipSameNetworkFragment.newInstance();
|
||||||
|
FragmentTransaction transaction = from.getFragmentManager().beginTransaction();
|
||||||
|
setFragmentAnimations(transaction);
|
||||||
|
transaction.replace(R.id.content, fragment);
|
||||||
|
transaction.addToBackStack(null);
|
||||||
|
transaction.commitAllowingStateLoss();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 跳转至wifi连接提示页
|
||||||
|
*
|
||||||
|
* @param from
|
||||||
|
*/
|
||||||
|
public static void gotoWifiConnectTipPage(Fragment from) {
|
||||||
|
if (from == null || from.getFragmentManager() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
TipWifiConnectFragment fragment = TipWifiConnectFragment.newInstance();
|
||||||
|
FragmentTransaction transaction = from.getFragmentManager().beginTransaction();
|
||||||
|
setFragmentAnimations(transaction);
|
||||||
|
transaction.replace(R.id.content, fragment);
|
||||||
|
transaction.addToBackStack(null);
|
||||||
|
transaction.commitAllowingStateLoss();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 跳转至wifi密码输入页
|
||||||
|
*
|
||||||
|
* @param parent 父fragment
|
||||||
|
* @param from
|
||||||
|
*/
|
||||||
|
public static void gotoWifiPwdPage(Fragment parent, Fragment from) {
|
||||||
|
if (parent == null || parent.getFragmentManager() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
WifiPwdFragment fragment = WifiPwdFragment.newInstance();
|
||||||
|
FragmentTransaction transaction = parent.getFragmentManager().beginTransaction();
|
||||||
|
setFragmentAnimations(transaction);
|
||||||
|
transaction.replace(R.id.content, fragment);
|
||||||
|
|
||||||
|
transaction.addToBackStack(WIFI_PWD_TAG);
|
||||||
|
transaction.commitAllowingStateLoss();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 跳转设备灯光提示页
|
||||||
|
*
|
||||||
|
* @param from
|
||||||
|
*/
|
||||||
|
public static void gotoLightTipPage(Fragment from) {
|
||||||
|
if (from == null || from.getFragmentManager() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
TipLightFragment fragment = TipLightFragment.newInstance();
|
||||||
|
FragmentTransaction transaction = from.getFragmentManager().beginTransaction();
|
||||||
|
setFragmentAnimations(transaction);
|
||||||
|
transaction.replace(R.id.content, fragment);
|
||||||
|
transaction.addToBackStack(null);
|
||||||
|
transaction.commitAllowingStateLoss();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 跳转设备声音提示页
|
||||||
|
*
|
||||||
|
* @param from
|
||||||
|
*/
|
||||||
|
public static void gotoSoundTipPage(Fragment from) {
|
||||||
|
if (from == null || from.getFragmentManager() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
TipSoundFragment fragment = TipSoundFragment.newInstance();
|
||||||
|
FragmentTransaction transaction = from.getFragmentManager().beginTransaction();
|
||||||
|
setFragmentAnimations(transaction);
|
||||||
|
transaction.replace(R.id.content, fragment);
|
||||||
|
transaction.addToBackStack(null);
|
||||||
|
transaction.commitAllowingStateLoss();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 跳转设备声音提示页
|
||||||
|
*
|
||||||
|
* @param from
|
||||||
|
*/
|
||||||
|
public static void gotoSmartConfigPage(Fragment from) {
|
||||||
|
if (from == null || from.getFragmentManager() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SmartConfigFragment fragment = SmartConfigFragment.newInstance();
|
||||||
|
FragmentTransaction transaction = from.getFragmentManager().beginTransaction();
|
||||||
|
setFragmentAnimations(transaction);
|
||||||
|
transaction.replace(R.id.content, fragment);
|
||||||
|
transaction.addToBackStack(null);
|
||||||
|
transaction.commitAllowingStateLoss();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 跳转到安全检查页
|
||||||
|
*
|
||||||
|
* @param from
|
||||||
|
*/
|
||||||
|
public static void gotoSecurityCheckPage(Fragment from) {
|
||||||
|
if (from == null || from.getFragmentManager() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SecurityCheckFragment fragment = SecurityCheckFragment.newInstance();
|
||||||
|
FragmentTransaction transaction = from.getFragmentManager().beginTransaction();
|
||||||
|
setFragmentAnimations(transaction);
|
||||||
|
transaction.replace(R.id.content, fragment);
|
||||||
|
transaction.addToBackStack(SECURITY_CHECK_TAG);
|
||||||
|
transaction.commitAllowingStateLoss();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 跳转到设备初始化页
|
||||||
|
*
|
||||||
|
* @param from
|
||||||
|
*/
|
||||||
|
public static void gotoInitPage(Fragment from, DEVICE_NET_INFO_EX device_net_info_ex) {
|
||||||
|
if (from == null || from.getFragmentManager() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
InitFragment fragment = InitFragment.newInstance(device_net_info_ex);
|
||||||
|
FragmentTransaction transaction = from.getFragmentManager().beginTransaction();
|
||||||
|
setFragmentAnimations(transaction);
|
||||||
|
transaction.replace(R.id.content, fragment);
|
||||||
|
transaction.addToBackStack(null);
|
||||||
|
transaction.commitAllowingStateLoss();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 跳转到云平台连接页
|
||||||
|
*
|
||||||
|
* @param from
|
||||||
|
*/
|
||||||
|
public static void gotoCloudConnectPage(Fragment from, boolean anim) {
|
||||||
|
if (from == null || from.getFragmentManager() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
CloudConnectFragment fragment = CloudConnectFragment.newInstance();
|
||||||
|
FragmentTransaction transaction = from.getFragmentManager().beginTransaction();
|
||||||
|
setFragmentAnimations(transaction, anim);
|
||||||
|
transaction.replace(R.id.content, fragment);
|
||||||
|
transaction.addToBackStack(null);
|
||||||
|
transaction.commitAllowingStateLoss();
|
||||||
|
DeviceAddInfo deviceAddInfo = DeviceAddModel.newInstance().getDeviceInfoCache();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void gotoCloudConnectPage(Fragment from) {
|
||||||
|
gotoCloudConnectPage(from, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 跳转到设备登录页
|
||||||
|
*
|
||||||
|
* @param from
|
||||||
|
*/
|
||||||
|
public static void gotoDevLoginPage(Fragment from, boolean anim) {
|
||||||
|
if (from == null || from.getFragmentManager() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DevLoginFragment fragment = DevLoginFragment.newInstance();
|
||||||
|
FragmentTransaction transaction = from.getFragmentManager().beginTransaction();
|
||||||
|
setFragmentAnimations(transaction, anim);
|
||||||
|
transaction.replace(R.id.content, fragment);
|
||||||
|
transaction.addToBackStack(null);
|
||||||
|
transaction.commitAllowingStateLoss();
|
||||||
|
//离线进入的都认为走过初始化检查流程了,都默认上报
|
||||||
|
DeviceAddInfo deviceAddInfo = DeviceAddModel.newInstance().getDeviceInfoCache();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void gotoDevLoginPage(Fragment from) {
|
||||||
|
gotoDevLoginPage(from, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 跳转到设备安全码验证页
|
||||||
|
*
|
||||||
|
* @param from
|
||||||
|
*/
|
||||||
|
public static void gotoDevSecCodePage(Fragment from, boolean anim) {
|
||||||
|
if (from == null || from.getFragmentManager() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DevSecCodeFragment fragment = DevSecCodeFragment.newInstance();
|
||||||
|
FragmentTransaction transaction = from.getFragmentManager().beginTransaction();
|
||||||
|
setFragmentAnimations(transaction, anim);
|
||||||
|
transaction.replace(R.id.content, fragment);
|
||||||
|
transaction.addToBackStack(null);
|
||||||
|
transaction.commitAllowingStateLoss();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void gotoDevSecCodePage(Fragment from) {
|
||||||
|
gotoDevSecCodePage(from, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 跳转到绑定设备连接页
|
||||||
|
*
|
||||||
|
* @param from
|
||||||
|
*/
|
||||||
|
public static void gotoDeviceBindPage(Fragment from, boolean anim) {
|
||||||
|
if (from == null || from.getFragmentManager() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
CloudConnectFragment fragment = CloudConnectFragment.newInstance(true);
|
||||||
|
FragmentTransaction transaction = from.getFragmentManager().beginTransaction();
|
||||||
|
setFragmentAnimations(transaction, anim);
|
||||||
|
transaction.replace(R.id.content, fragment);
|
||||||
|
transaction.addToBackStack(null);
|
||||||
|
transaction.commitAllowingStateLoss();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void gotoDeviceBindPage(Fragment from) {
|
||||||
|
gotoDeviceBindPage(from, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 跳转到绑定成功提示页
|
||||||
|
*
|
||||||
|
* @param from
|
||||||
|
*/
|
||||||
|
public static void gotoBindSuccessPage(Fragment from) {
|
||||||
|
if (from == null || from.getFragmentManager() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
BindSuccessFragment fragment = BindSuccessFragment.newInstance();
|
||||||
|
FragmentTransaction transaction = from.getFragmentManager().beginTransaction();
|
||||||
|
setFragmentAnimations(transaction);
|
||||||
|
transaction.replace(R.id.content, fragment);
|
||||||
|
transaction.addToBackStack(null);
|
||||||
|
transaction.commitAllowingStateLoss();
|
||||||
|
DeviceAddInfo deviceAddInfo = DeviceAddModel.newInstance().getDeviceInfoCache();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param from
|
||||||
|
*/
|
||||||
|
public static void gotoErrorTipPage(Fragment from, int errorCode, boolean anim) {
|
||||||
|
ErrorTipFragment fragment = ErrorTipFragment.newInstance(errorCode);
|
||||||
|
if (from == null || from.getFragmentManager() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
FragmentTransaction transaction = from.getFragmentManager().beginTransaction();
|
||||||
|
setFragmentAnimations(transaction, anim);
|
||||||
|
transaction.replace(R.id.content, fragment);
|
||||||
|
transaction.addToBackStack(null);
|
||||||
|
transaction.commitAllowingStateLoss();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void gotoErrorTipPage(Fragment from, int errorCode) {
|
||||||
|
gotoErrorTipPage(from, errorCode, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 跳转到到软Ap添加引导页
|
||||||
|
*
|
||||||
|
* @param from
|
||||||
|
*/
|
||||||
|
public static void gotoSoftApTipPage(Fragment from) {
|
||||||
|
gotoSoftApTip1Page(from);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void gotoSoftApTip1Page(Fragment from) {
|
||||||
|
if (from == null || from.getFragmentManager() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
TipSoftApStep1Fragment fragment = TipSoftApStep1Fragment.newInstance();
|
||||||
|
FragmentTransaction transaction = from.getFragmentManager().beginTransaction();
|
||||||
|
setFragmentAnimations(transaction);
|
||||||
|
transaction.replace(R.id.content, fragment);
|
||||||
|
transaction.addToBackStack(SOFT_AP_TIP_TAG);
|
||||||
|
transaction.commitAllowingStateLoss();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void gotoSoftApTipPageNoAnim(Fragment from) {
|
||||||
|
if (from == null || from.getFragmentManager() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
TipSoftApStep1Fragment fragment = TipSoftApStep1Fragment.newInstance();
|
||||||
|
FragmentTransaction transaction = from.getFragmentManager().beginTransaction();
|
||||||
|
transaction.replace(R.id.content, fragment, TipSoftApStep1Fragment.class.getName());
|
||||||
|
transaction.addToBackStack(SOFT_AP_TIP_TAG);
|
||||||
|
transaction.commitAllowingStateLoss();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void gotoSoftApTip2Page(Fragment from) {
|
||||||
|
if (from == null || from.getFragmentManager() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
TipSoftApStep2Fragment fragment = TipSoftApStep2Fragment.newInstance();
|
||||||
|
FragmentTransaction transaction = from.getFragmentManager().beginTransaction();
|
||||||
|
setFragmentAnimations(transaction);
|
||||||
|
transaction.replace(R.id.content, fragment);
|
||||||
|
transaction.addToBackStack(null);
|
||||||
|
transaction.commitAllowingStateLoss();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void gotoSoftApTip3Page(Fragment from) {
|
||||||
|
if (from == null || from.getFragmentManager() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
TipSoftApStep3Fragment fragment = TipSoftApStep3Fragment.newInstance();
|
||||||
|
FragmentTransaction transaction = from.getFragmentManager().beginTransaction();
|
||||||
|
setFragmentAnimations(transaction);
|
||||||
|
transaction.replace(R.id.content, fragment);
|
||||||
|
transaction.addToBackStack(null);
|
||||||
|
transaction.commitAllowingStateLoss();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void gotoSoftApTip4Page(Fragment from) {
|
||||||
|
if (from == null || from.getFragmentManager() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
TipSoftApStep4Fragment fragment = TipSoftApStep4Fragment.newInstance();
|
||||||
|
FragmentTransaction transaction = from.getFragmentManager().beginTransaction();
|
||||||
|
setFragmentAnimations(transaction);
|
||||||
|
transaction.replace(R.id.content, fragment);
|
||||||
|
transaction.addToBackStack(null);
|
||||||
|
transaction.commitAllowingStateLoss();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void gotoSoftApTipConnectWifiPage(Fragment from) {
|
||||||
|
if (from == null || from.getFragmentManager() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
TipSoftApConnectWifiFragment fragment = TipSoftApConnectWifiFragment.newInstance();
|
||||||
|
FragmentTransaction transaction = from.getFragmentManager().beginTransaction();
|
||||||
|
setFragmentAnimations(transaction);
|
||||||
|
transaction.replace(R.id.content, fragment);
|
||||||
|
transaction.addToBackStack(null);
|
||||||
|
transaction.commitAllowingStateLoss();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 跳转到到软Ap添加wifi列表
|
||||||
|
*
|
||||||
|
* @param from
|
||||||
|
*/
|
||||||
|
public static void gotoSoftApWifiListPage(Fragment from, boolean isNotNeedLogin) {
|
||||||
|
if (from == null || from.getFragmentManager() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DevWifiListFragment fragment = DevWifiListFragment.newInstance(isNotNeedLogin);
|
||||||
|
FragmentTransaction transaction = from.getFragmentManager().beginTransaction();
|
||||||
|
setFragmentAnimations(transaction);
|
||||||
|
transaction.replace(R.id.content, fragment);
|
||||||
|
transaction.addToBackStack(null);
|
||||||
|
transaction.commitAllowingStateLoss();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 跳转到到软Ap添加wifi列表
|
||||||
|
*
|
||||||
|
* @param from
|
||||||
|
*/
|
||||||
|
public static void gotoSoftApWifiListPage(Fragment from) {
|
||||||
|
gotoSoftApWifiListPage(from, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 跳转到到软Ap添加wifi密码输入页
|
||||||
|
*
|
||||||
|
* @param from
|
||||||
|
*/
|
||||||
|
public static void gotoSoftApWifiPwdPage(Fragment from, WlanInfo wlanInfo, boolean isNotNeedLogin) {
|
||||||
|
if (from == null || from.getFragmentManager() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SoftApWifiPwdFragment fragment = SoftApWifiPwdFragment.newInstance(wlanInfo, isNotNeedLogin);
|
||||||
|
FragmentTransaction transaction = from.getFragmentManager().beginTransaction();
|
||||||
|
setFragmentAnimations(transaction);
|
||||||
|
transaction.replace(R.id.content, fragment);
|
||||||
|
transaction.addToBackStack(null);
|
||||||
|
transaction.commitAllowingStateLoss();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 跳转到到软Ap添加wifi密码输入页
|
||||||
|
*
|
||||||
|
* @param from
|
||||||
|
*/
|
||||||
|
public static void gotoHiddenWifiPwdPage(Fragment from, boolean isNotNeedLogin) {
|
||||||
|
if (from == null || from.getFragmentManager() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
HiddenWifiPwdFragment fragment = HiddenWifiPwdFragment.newInstance(isNotNeedLogin);
|
||||||
|
FragmentTransaction transaction = from.getFragmentManager().beginTransaction();
|
||||||
|
setFragmentAnimations(transaction);
|
||||||
|
transaction.replace(R.id.content, fragment);
|
||||||
|
transaction.addToBackStack(null);
|
||||||
|
transaction.commitAllowingStateLoss();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 跳转到到软Ap添加wifi连接结果页(海外)
|
||||||
|
*
|
||||||
|
* @param from
|
||||||
|
*/
|
||||||
|
public static void gotoSoftApResultdPage(Fragment from) {
|
||||||
|
if (from == null || from.getFragmentManager() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SoftApResultFragment fragment = SoftApResultFragment.newInstance();
|
||||||
|
FragmentTransaction transaction = from.getFragmentManager().beginTransaction();
|
||||||
|
setFragmentAnimations(transaction);
|
||||||
|
transaction.replace(R.id.content, fragment);
|
||||||
|
transaction.commitAllowingStateLoss();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 跳转到到配件添加网关列表页
|
||||||
|
*
|
||||||
|
* @param from
|
||||||
|
*/
|
||||||
|
public static void gotoGatewayListPage(Fragment from, boolean hasSelectGateway) {
|
||||||
|
if (from == null || from.getFragmentManager() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
GatewayListFragment fragment = GatewayListFragment.newInstance(hasSelectGateway);
|
||||||
|
FragmentTransaction transaction = from.getFragmentManager().beginTransaction();
|
||||||
|
setFragmentAnimations(transaction);
|
||||||
|
transaction.replace(R.id.content, fragment);
|
||||||
|
transaction.addToBackStack(null);
|
||||||
|
transaction.commitAllowingStateLoss();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 跳转到到配件电源引导页
|
||||||
|
*
|
||||||
|
* @param from
|
||||||
|
*/
|
||||||
|
public static void gotoApPowerTipPage(Fragment from) {
|
||||||
|
if (from == null || from.getFragmentManager() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
TipApPowerFragment fragment = TipApPowerFragment.newInstance();
|
||||||
|
FragmentTransaction transaction = from.getFragmentManager().beginTransaction();
|
||||||
|
setFragmentAnimations(transaction);
|
||||||
|
transaction.replace(R.id.content, fragment);
|
||||||
|
transaction.addToBackStack(AP_TIP_TAG);
|
||||||
|
transaction.commitAllowingStateLoss();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 跳转到到配件电源引导页
|
||||||
|
*
|
||||||
|
* @param from
|
||||||
|
*/
|
||||||
|
public static void gotoApLightPage(Fragment from) {
|
||||||
|
if (from == null || from.getFragmentManager() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
TipApLightFragment fragment = TipApLightFragment.newInstance();
|
||||||
|
FragmentTransaction transaction = from.getFragmentManager().beginTransaction();
|
||||||
|
setFragmentAnimations(transaction);
|
||||||
|
transaction.replace(R.id.content, fragment);
|
||||||
|
transaction.addToBackStack(null);
|
||||||
|
transaction.commitAllowingStateLoss();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 跳转到到配件配对页
|
||||||
|
*
|
||||||
|
* @param from
|
||||||
|
*/
|
||||||
|
public static void gotoApPairPage(Fragment from) {
|
||||||
|
if (from == null || from.getFragmentManager() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ApPairFragment fragment = ApPairFragment.newInstance();
|
||||||
|
FragmentTransaction transaction = from.getFragmentManager().beginTransaction();
|
||||||
|
setFragmentAnimations(transaction);
|
||||||
|
transaction.replace(R.id.content, fragment);
|
||||||
|
transaction.addToBackStack(null);
|
||||||
|
transaction.commitAllowingStateLoss();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 跳转到到配件绑定成功页
|
||||||
|
*
|
||||||
|
* @param from
|
||||||
|
*/
|
||||||
|
public static void gotoApBindSuccessPage(Fragment from, AddApResult addApResult) {
|
||||||
|
if (from == null || from.getFragmentManager() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ApBindSuccessFragment fragment = ApBindSuccessFragment.newInstance(addApResult);
|
||||||
|
FragmentTransaction transaction = from.getFragmentManager().beginTransaction();
|
||||||
|
setFragmentAnimations(transaction);
|
||||||
|
transaction.replace(R.id.content, fragment);
|
||||||
|
transaction.addToBackStack(null);
|
||||||
|
transaction.commitAllowingStateLoss();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 跳转到电池相机配对引导页
|
||||||
|
*
|
||||||
|
* @param fragmentActivity
|
||||||
|
*/
|
||||||
|
public static void gotoHubGuide1Page(FragmentActivity fragmentActivity, String sn, String hubType) {
|
||||||
|
if (fragmentActivity == null || fragmentActivity.getSupportFragmentManager() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
HubapGuide1Fragment fragment = HubapGuide1Fragment.newInstance(sn, hubType);
|
||||||
|
FragmentTransaction transaction = fragmentActivity.getSupportFragmentManager().beginTransaction();
|
||||||
|
transaction.add(R.id.content, fragment);
|
||||||
|
transaction.commitAllowingStateLoss();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 跳转到电池相机配对引导页
|
||||||
|
*
|
||||||
|
* @param from
|
||||||
|
*/
|
||||||
|
public static void gotoHubGuide2Page(Fragment from) {
|
||||||
|
if (from == null || from.getFragmentManager() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
HubapGuide2Fragment fragment = HubapGuide2Fragment.newInstance();
|
||||||
|
FragmentTransaction transaction = from.getFragmentManager().beginTransaction();
|
||||||
|
setFragmentAnimations(transaction);
|
||||||
|
transaction.replace(R.id.content, fragment);
|
||||||
|
transaction.addToBackStack(null);
|
||||||
|
transaction.commitAllowingStateLoss();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 跳转到hub灯提示页
|
||||||
|
*
|
||||||
|
* @param from
|
||||||
|
*/
|
||||||
|
public static void gotoHubGuide3Page(Fragment from) {
|
||||||
|
if (from == null || from.getFragmentManager() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
HubapGuide3Fragment fragment = HubapGuide3Fragment.newInstance();
|
||||||
|
FragmentTransaction transaction = from.getFragmentManager().beginTransaction();
|
||||||
|
setFragmentAnimations(transaction);
|
||||||
|
transaction.replace(R.id.content, fragment);
|
||||||
|
transaction.addToBackStack(null);
|
||||||
|
transaction.commitAllowingStateLoss();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 跳转到NB设备添加引导页
|
||||||
|
*
|
||||||
|
* @param from
|
||||||
|
*/
|
||||||
|
public static void gotoNBTipPage(Fragment from) {
|
||||||
|
if (from == null || from.getFragmentManager() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
TipNBFragment fragment = TipNBFragment.newInstance();
|
||||||
|
FragmentTransaction transaction = from.getFragmentManager().beginTransaction();
|
||||||
|
setFragmentAnimations(transaction);
|
||||||
|
transaction.replace(R.id.content, fragment);
|
||||||
|
transaction.addToBackStack(null);
|
||||||
|
transaction.commitAllowingStateLoss();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 跳转到离线配网
|
||||||
|
*
|
||||||
|
* @param fragmentActivity
|
||||||
|
* @param sn
|
||||||
|
* @param devModelName
|
||||||
|
*/
|
||||||
|
public static void gotoOfflineConfigPage(FragmentActivity fragmentActivity, String sn, String devModelName, String imei) {
|
||||||
|
if (fragmentActivity == null || fragmentActivity.getSupportFragmentManager() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
OfflineConfigFragment fragment = OfflineConfigFragment.newInstance(sn, devModelName, imei);
|
||||||
|
FragmentTransaction transaction = fragmentActivity.getSupportFragmentManager().beginTransaction();
|
||||||
|
transaction.add(R.id.content, fragment);
|
||||||
|
transaction.commitAllowingStateLoss();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void gotoDeviceSharePage(FragmentActivity fragmentActivity, String deviceSn) {
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putString(LCConfiguration.Device_ID, deviceSn);
|
||||||
|
ProviderManager.getAppProvider().goDeviceSharePage(fragmentActivity, bundle);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 跳转到设备本地配网引导页面
|
||||||
|
*
|
||||||
|
* @param from
|
||||||
|
*/
|
||||||
|
public static void gotoLocationTipPage(Fragment from) {
|
||||||
|
if (from == null || from.getFragmentManager() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
TipDeviceLocalFragment fragment = TipDeviceLocalFragment.newInstance();
|
||||||
|
FragmentTransaction transaction = from.getFragmentManager().beginTransaction();
|
||||||
|
setFragmentAnimations(transaction);
|
||||||
|
transaction.replace(R.id.content, fragment);
|
||||||
|
transaction.addToBackStack(null);
|
||||||
|
transaction.commitAllowingStateLoss();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 跳转到蓝牙模块
|
||||||
|
*/
|
||||||
|
public static void gotoAddBleLockPage(Bundle bundle) {
|
||||||
|
//TODO 不会有逻辑进入
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,376 @@
|
||||||
|
package com.mm.android.deviceaddmodule.helper;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.net.ConnectivityManager;
|
||||||
|
import android.net.NetworkInfo;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.net.wifi.WifiInfo;
|
||||||
|
import android.net.wifi.WifiManager;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.text.SpannableString;
|
||||||
|
import android.text.Spanned;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import android.text.method.LinkMovementMethod;
|
||||||
|
import android.text.style.ForegroundColorSpan;
|
||||||
|
import android.view.View.OnClickListener;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.company.NetSDK.DEVICE_NET_INFO_EX;
|
||||||
|
import com.google.zxing.BarcodeFormat;
|
||||||
|
import com.google.zxing.EncodeHintType;
|
||||||
|
import com.google.zxing.common.BitMatrix;
|
||||||
|
import com.google.zxing.qrcode.QRCodeWriter;
|
||||||
|
import com.mm.android.deviceaddmodule.R;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.common.LCConfiguration;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.dialog.LCAlertDialog;
|
||||||
|
import com.nostra13.universalimageloader.core.DisplayImageOptions;
|
||||||
|
|
||||||
|
import java.util.Hashtable;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备添加相关工具类
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class Utils4AddDevice {
|
||||||
|
public static final int NETWORK_NONE = -1; // 无网络
|
||||||
|
public static final int NETWORK_WIFI = 0; // wifi
|
||||||
|
public static final int NETWORK_MOBILE = 1; // 数据网络
|
||||||
|
|
||||||
|
public static String strRegCodeFilter(String str) {
|
||||||
|
|
||||||
|
if (TextUtils.isEmpty(str)) {
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
String strEx = "[0-9A-Za-z]";
|
||||||
|
for (int i = 0; i < str.length(); i++) {
|
||||||
|
String temp = str.substring(i, i + 1);
|
||||||
|
if (!temp.matches(strEx)) {
|
||||||
|
str = str.replace(temp, "");
|
||||||
|
return strRegCodeFilter(str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String wifiPwdFilter(String str) {
|
||||||
|
|
||||||
|
if (TextUtils.isEmpty(str)) {
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
// TD:20780
|
||||||
|
String chinese1 = "[\u2E80-\uA4CF]";
|
||||||
|
String chinese2 = "[\uF900-\uFAFF]";
|
||||||
|
String chinese3 = "[\uFE30-\uFE4F]";
|
||||||
|
|
||||||
|
for (int i = 0; i < str.length(); i++) {
|
||||||
|
String temp = str.substring(i, i + 1);
|
||||||
|
if (temp.matches(chinese1) || temp.matches(chinese2) || temp.matches(chinese3)) {
|
||||||
|
str = str.replace(temp, "");
|
||||||
|
return wifiPwdFilter(str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isNetworkAvailable(Context context) {
|
||||||
|
ConnectivityManager connectivity = (ConnectivityManager) context
|
||||||
|
.getSystemService(Context.CONNECTIVITY_SERVICE); // 获取系统网络连接管理<EFBFBD>?
|
||||||
|
if (connectivity == null) { // 如果网络管理器为null
|
||||||
|
return false; // 返回false表明网络无法连接
|
||||||
|
} else {
|
||||||
|
NetworkInfo[] info = connectivity.getAllNetworkInfo(); // 获取<EFBFBD>?<EFBFBD><EFBFBD>的网络连接对<EFBFBD>?
|
||||||
|
if (info != null) { // 网络信息不为null
|
||||||
|
for (NetworkInfo anInfo : info) { // 遍历网路连接对象
|
||||||
|
if (anInfo.isConnected()) { // 当有<EFBFBD>?<EFBFBD><EFBFBD>网络连接对象连接上网络时
|
||||||
|
return true; // 返回true表明网络连接正常
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isWifi(Context context) {
|
||||||
|
ConnectivityManager connectivity = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
|
if (connectivity == null) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
NetworkInfo curNetwork = connectivity.getActiveNetworkInfo();
|
||||||
|
if (curNetwork != null && curNetwork.getType() == ConnectivityManager.TYPE_WIFI) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getNetWorkState(Context context) {
|
||||||
|
ConnectivityManager connectivity = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
|
if(connectivity != null) {
|
||||||
|
NetworkInfo curNetwork = connectivity.getActiveNetworkInfo();
|
||||||
|
if (curNetwork != null && curNetwork.isConnected()) {
|
||||||
|
if (curNetwork.getType() == ConnectivityManager.TYPE_WIFI) {
|
||||||
|
return NETWORK_WIFI;
|
||||||
|
} else if (curNetwork.getType() == ConnectivityManager.TYPE_MOBILE) {
|
||||||
|
return NETWORK_MOBILE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NETWORK_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isWifiEnabled(Context context) {
|
||||||
|
WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
|
||||||
|
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
|
||||||
|
boolean wifi= (wifiInfo.getSSID()==null) || wifiInfo.getSSID().equalsIgnoreCase("");
|
||||||
|
return !wifi;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isWifiConnected(Context context) {
|
||||||
|
if (context != null) {
|
||||||
|
ConnectivityManager mConnectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
|
if (mConnectivityManager == null){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
NetworkInfo mWiFiNetworkInfo = mConnectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
|
||||||
|
if (mWiFiNetworkInfo != null) {
|
||||||
|
return mWiFiNetworkInfo.isAvailable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 判断是否只包含数字或大小写字母
|
||||||
|
*
|
||||||
|
* @param str
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static boolean checkString(String str) {
|
||||||
|
String regEx = "[0-9A-Za-z]*"; // 只能是数字以及个别字符
|
||||||
|
Pattern p = Pattern.compile(regEx);
|
||||||
|
Matcher m = p.matcher(str);
|
||||||
|
if (m.matches()) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String filterInvalidString(String str) {
|
||||||
|
if (TextUtils.isEmpty(str)) {
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
String numberAndAbc = "[a-zA-Z0-9]";
|
||||||
|
StringBuilder buffer = new StringBuilder();
|
||||||
|
int len = str.length();
|
||||||
|
for (int i = 0; i < len; ++i) {
|
||||||
|
String temp = str.substring(i, i + 1);
|
||||||
|
if (temp.matches(numberAndAbc)) {
|
||||||
|
buffer.append(temp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return buffer.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String filterInvalidString4Type(String str) {
|
||||||
|
if (TextUtils.isEmpty(str)) {
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
String numberAndAbc = "[a-zA-Z0-9-/\\\\]";
|
||||||
|
StringBuilder buffer = new StringBuilder();
|
||||||
|
int len = str.length();
|
||||||
|
for (int i = 0; i < len; ++i) {
|
||||||
|
String temp = str.substring(i, i + 1);
|
||||||
|
if (temp.matches(numberAndAbc)) {
|
||||||
|
buffer.append(temp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return buffer.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否是乐盒设备
|
||||||
|
*
|
||||||
|
* @param deviceMode
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static boolean isDeviceTypeBox(String deviceMode) {
|
||||||
|
if (deviceMode == null || TextUtils.isEmpty(deviceMode)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (deviceMode.equalsIgnoreCase("G10")) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置下划线字体
|
||||||
|
*/
|
||||||
|
public static SpannableString setSpannableString(Context context, int showResId, int showUnderLineResId) {
|
||||||
|
|
||||||
|
String showResourceTip = context.getResources().getString(showResId);
|
||||||
|
String showUnderLineResTip = context.getResources().getString(showUnderLineResId);
|
||||||
|
String tip = showResourceTip + showUnderLineResTip;
|
||||||
|
SpannableString ss = new SpannableString(tip);
|
||||||
|
int start = showResourceTip.length();
|
||||||
|
int end = showUnderLineResTip.length() + start;
|
||||||
|
int flag = Spanned.SPAN_EXCLUSIVE_EXCLUSIVE;
|
||||||
|
MyURLSpan mus = new MyURLSpan(context.getResources().getString(R.string.assetfont_html));// 字体
|
||||||
|
ForegroundColorSpan fcs = new ForegroundColorSpan(context.getResources()
|
||||||
|
.getColor(R.color.lc_color_4ea7f2));
|
||||||
|
ss.setSpan(mus, start, end, flag);
|
||||||
|
ss.setSpan(fcs, start, end, flag);
|
||||||
|
return ss;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 设置下划线字体及点击事件
|
||||||
|
* </p>
|
||||||
|
*/
|
||||||
|
public static void setSpannableString(int showResId, int showUnderLineResId, OnClickListener listener, TextView view) {
|
||||||
|
String showResourceTip = "";
|
||||||
|
if (showResId != 0) {
|
||||||
|
showResourceTip = view.getContext().getResources().getString(showResId);
|
||||||
|
}
|
||||||
|
String showUnderLineResTip = view.getContext().getResources().getString(showUnderLineResId);
|
||||||
|
String tip = showResourceTip + showUnderLineResTip;
|
||||||
|
SpannableString ss = new SpannableString(tip);
|
||||||
|
int start = showResourceTip.length();
|
||||||
|
int end = showUnderLineResTip.length() + start;
|
||||||
|
int flag = Spanned.SPAN_EXCLUSIVE_EXCLUSIVE;
|
||||||
|
MyURLSpan mus = new MyURLSpan(view.getContext().getResources().getString(R.string.assetfont_html));// 字体
|
||||||
|
mus.setOnClickListener(listener);
|
||||||
|
ForegroundColorSpan fcs = new ForegroundColorSpan(view.getContext().getResources()
|
||||||
|
.getColor(R.color.lc_color_4ea7f2));
|
||||||
|
ss.setSpan(mus, start, end, flag);
|
||||||
|
ss.setSpan(fcs, start, end, flag);
|
||||||
|
view.setText(ss);
|
||||||
|
view.setMovementMethod(LinkMovementMethod.getInstance());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 设置下划线字体及点击事件
|
||||||
|
* </p>
|
||||||
|
*/
|
||||||
|
public static void setSpannableString(int showResId, String showUnderLineResTip, OnClickListener listener, TextView view) {
|
||||||
|
String showResourceTip = "";
|
||||||
|
if (showResId != 0) {
|
||||||
|
showResourceTip = view.getContext().getResources().getString(showResId);
|
||||||
|
}
|
||||||
|
if (showUnderLineResTip == null) {
|
||||||
|
showUnderLineResTip = "";
|
||||||
|
}
|
||||||
|
String tip = showResourceTip + showUnderLineResTip;
|
||||||
|
SpannableString ss = new SpannableString(tip);
|
||||||
|
int start = showResourceTip.length();
|
||||||
|
int end = showUnderLineResTip.length() + start;
|
||||||
|
int flag = Spanned.SPAN_EXCLUSIVE_EXCLUSIVE;
|
||||||
|
MyURLSpan mus = new MyURLSpan(view.getContext().getResources().getString(R.string.assetfont_html));// 字体
|
||||||
|
mus.setOnClickListener(listener);
|
||||||
|
ForegroundColorSpan fcs = new ForegroundColorSpan(view.getContext().getResources()
|
||||||
|
.getColor(R.color.lc_color_4ea7f2));
|
||||||
|
ss.setSpan(mus, start, end, flag);
|
||||||
|
ss.setSpan(fcs, start, end, flag);
|
||||||
|
view.setText(ss);
|
||||||
|
view.setMovementMethod(LinkMovementMethod.getInstance());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static DisplayImageOptions mDeviceModeImageOptions;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否为TP1等设备,包括TP1 TC1 TK1 TC3 TK3 TC4 TC5 TC5S TP6、TP6C、TC6、TC6C、TP7
|
||||||
|
*/
|
||||||
|
public static boolean isTp1And(String deviceModelName) {
|
||||||
|
return LCConfiguration.TYPE_TC1.equals(deviceModelName) || LCConfiguration.TYPE_TK1.equals(deviceModelName)
|
||||||
|
|| LCConfiguration.TYPE_TC3.equals(deviceModelName) || LCConfiguration.TYPE_TK3.equals(deviceModelName)
|
||||||
|
|| LCConfiguration.TYPE_TC4.equals(deviceModelName) || LCConfiguration.TYPE_TC5.equals(deviceModelName)
|
||||||
|
|| LCConfiguration.TYPE_TC5S.equals(deviceModelName) || LCConfiguration.TYPE_TP1.equals(deviceModelName)
|
||||||
|
|| LCConfiguration.TYPE_TP6.equals(deviceModelName) || LCConfiguration.TYPE_TP6C.equals(deviceModelName)
|
||||||
|
|| LCConfiguration.TYPE_TC6.equals(deviceModelName) || LCConfiguration.TYPE_TC6C.equals(deviceModelName)
|
||||||
|
|| LCConfiguration.TYPE_TP7.equals(deviceModelName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//根据域名获取
|
||||||
|
public static String getAddDeviceHelpUrl(String host) {
|
||||||
|
if (host.contains(":443")) {
|
||||||
|
host = host.split(":")[0];
|
||||||
|
}
|
||||||
|
return "http://" + host + "/bindhelp.html";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 检测设备新老版本, ture 表示新版本并且DHCP打开走单播流程, false 老版本/DHCP关闭走组播加单播流程。
|
||||||
|
* * @return
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static boolean checkDeviceVersion(DEVICE_NET_INFO_EX deviceInfo) {
|
||||||
|
if(deviceInfo==null)
|
||||||
|
return false;
|
||||||
|
int flag = (deviceInfo.bySpecialAbility >> 2) & 0x03;
|
||||||
|
return 0x00 != flag && 0x03 != flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 检测设备获取的IP是否有效, ture 有效
|
||||||
|
* * @param deviceInfo
|
||||||
|
* * @return
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static boolean checkEffectiveIP(DEVICE_NET_INFO_EX deviceInfo) {
|
||||||
|
if(deviceInfo==null)
|
||||||
|
return false;
|
||||||
|
int flag = (deviceInfo.bySpecialAbility >> 2) & 0x03;
|
||||||
|
return 0x02 == flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成二维码
|
||||||
|
* @param url
|
||||||
|
* @param width
|
||||||
|
* @param height
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static Bitmap creatQRImage(String url, final int width, final int height) {
|
||||||
|
try {
|
||||||
|
if(TextUtils.isEmpty(url)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
Hashtable<EncodeHintType, String> hints = new Hashtable<>();
|
||||||
|
hints.put(EncodeHintType.CHARACTER_SET, "utf-8");
|
||||||
|
hints.put(EncodeHintType.MARGIN, "0"); // 不要边距
|
||||||
|
// 图像数据变换,使用矩阵转换
|
||||||
|
BitMatrix bitMatrix = new QRCodeWriter().encode(url, BarcodeFormat.QR_CODE, width, height, hints);
|
||||||
|
int[] pixels = new int[width * height];
|
||||||
|
// 下面这里按照二维码的算法,逐个生成二维码的图片
|
||||||
|
// 两个for循环是图片横列扫描的结果
|
||||||
|
for(int y = 0; y < height; y++) {
|
||||||
|
for(int x = 0; x <width; x++) {
|
||||||
|
if(bitMatrix.get(x, y)) {
|
||||||
|
pixels[y * width + x] = 0xff000000;
|
||||||
|
} else {
|
||||||
|
pixels[y * width + x] = 0xffffffff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 生成二维码图片格式,使用ARGB_8888
|
||||||
|
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
||||||
|
bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
|
||||||
|
return bitmap;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
package com.mm.android.deviceaddmodule.mobilecommon.AppConsume;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.base.BaseProvider;
|
||||||
|
|
||||||
|
public class AppBaseProvider extends BaseProvider implements IApp {
|
||||||
|
|
||||||
|
private static int appType = 0;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setAppType(int type) {
|
||||||
|
appType = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getAppType() {
|
||||||
|
return appType;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Context getAppContext() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void goDeviceSharePage(Activity activity, Bundle bundle) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void goBuyCloudPage(Activity activity, Bundle bundle) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void goModifyDevicePwdGuidePage(Activity activity) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getAppLanguage() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,62 @@
|
||||||
|
package com.mm.android.deviceaddmodule.mobilecommon.AppConsume;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
public class AppProvider extends AppBaseProvider implements IApp {
|
||||||
|
|
||||||
|
private volatile static AppProvider appProvider;
|
||||||
|
|
||||||
|
public static AppProvider newInstance() {
|
||||||
|
if (appProvider == null) {
|
||||||
|
synchronized (AppProvider.class) {
|
||||||
|
if (appProvider == null) {
|
||||||
|
appProvider = new AppProvider();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return appProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void uninit() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setAppType(int type) {
|
||||||
|
super.setAppType(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getAppType() {
|
||||||
|
return super.getAppType();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void goDeviceSharePage(Activity activity, Bundle bundle) {
|
||||||
|
super.goDeviceSharePage(activity, bundle);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void goBuyCloudPage(Activity activity, Bundle bundle) {
|
||||||
|
super.goBuyCloudPage(activity, bundle);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void goModifyDevicePwdGuidePage(Activity activity) {
|
||||||
|
super.goModifyDevicePwdGuidePage(activity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getAppLanguage() {
|
||||||
|
return super.getAppLanguage();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Context getAppContext() {
|
||||||
|
return EnvironmentConfig.mContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
/**
|
||||||
|
* Exception style class encapsulating Business errors
|
||||||
|
*/
|
||||||
|
package com.mm.android.deviceaddmodule.mobilecommon.AppConsume;
|
||||||
|
|
||||||
|
|
||||||
|
@SuppressWarnings("serial")
|
||||||
|
public class BusinessException extends Exception{
|
||||||
|
/**
|
||||||
|
* 执行错误码
|
||||||
|
*/
|
||||||
|
public int errorCode = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 错误描述
|
||||||
|
*/
|
||||||
|
public String errorDescription = "UNKNOWN_ERROR";
|
||||||
|
|
||||||
|
public BusinessException(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public BusinessException(String e) {
|
||||||
|
super(e);
|
||||||
|
this.errorDescription =e;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BusinessException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
this.errorDescription =cause.getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
public BusinessException(int errorCode) {
|
||||||
|
this.errorCode = errorCode;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,53 @@
|
||||||
|
package com.mm.android.deviceaddmodule.mobilecommon.AppConsume;
|
||||||
|
|
||||||
|
import android.os.Handler;
|
||||||
|
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.businesstip.BusinessErrorCode;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.businesstip.HandleMessageCode;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.utils.LogUtil;
|
||||||
|
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
|
|
||||||
|
public abstract class BusinessRunnable implements Runnable {
|
||||||
|
|
||||||
|
private WeakReference<Handler> mHandler;
|
||||||
|
|
||||||
|
public BusinessRunnable(Handler handle) {
|
||||||
|
mHandler = new WeakReference<>(handle);
|
||||||
|
Handler handler = getHander();
|
||||||
|
if (handler != null && handler instanceof DHBaseHandler) {
|
||||||
|
((DHBaseHandler) handler).onStart();
|
||||||
|
}
|
||||||
|
ThreadPool.submit(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Handler getHander() {
|
||||||
|
return mHandler.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
doBusiness();
|
||||||
|
} catch (BusinessException e) {
|
||||||
|
Handler handler = getHander();
|
||||||
|
LogUtil.debugLog("BusinessRunnable", "hander == null ? " + (handler == null));
|
||||||
|
if (handler != null) {
|
||||||
|
handler.obtainMessage(HandleMessageCode.HMC_EXCEPTION,
|
||||||
|
e.errorCode, e.errorCode, e).sendToTarget();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
LogUtil.debugLog("HsviewResponse Exception", e.getMessage());
|
||||||
|
Handler handler = getHander();
|
||||||
|
if (handler != null) {
|
||||||
|
handler.obtainMessage(HandleMessageCode.HMC_EXCEPTION,
|
||||||
|
BusinessErrorCode.BEC_COMMON_UNKNOWN,
|
||||||
|
BusinessErrorCode.BEC_COMMON_UNKNOWN,new BusinessException(e)).sendToTarget();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void doBusiness() throws BusinessException;
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
package com.mm.android.deviceaddmodule.mobilecommon.AppConsume;
|
||||||
|
|
||||||
|
public interface Callback<T> {
|
||||||
|
|
||||||
|
public void onSuccess(T t);
|
||||||
|
|
||||||
|
public void onFail(String code, String message);
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.mm.android.deviceaddmodule.mobilecommon.AppConsume;
|
||||||
|
|
||||||
|
import android.os.Message;
|
||||||
|
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.base.LCBusinessHandler;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.base.mvp.IBaseView;
|
||||||
|
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
|
|
||||||
|
public abstract class DHBaseHandler<T extends IBaseView> extends LCBusinessHandler {
|
||||||
|
|
||||||
|
WeakReference<T> mView;
|
||||||
|
public DHBaseHandler(WeakReference<T> view){
|
||||||
|
super();
|
||||||
|
mView=view;
|
||||||
|
}
|
||||||
|
public abstract void onStart();
|
||||||
|
protected abstract void onCompleted();
|
||||||
|
protected abstract void handleBusinessFinally(Message msg);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleBusiness(Message msg) {
|
||||||
|
if(mView==null
|
||||||
|
|| mView.get()==null
|
||||||
|
||!mView.get().isViewActive()){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
onCompleted();
|
||||||
|
handleBusinessFinally(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
package com.mm.android.deviceaddmodule.mobilecommon.AppConsume;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import com.mm.android.deviceaddmodule.helper.ActivityHelper;
|
||||||
|
import com.mm.android.deviceaddmodule.utils.SDsolutionUtility;
|
||||||
|
|
||||||
|
|
||||||
|
public class DeviceAddCustomImpl implements IDeviceAddCustom {
|
||||||
|
|
||||||
|
private volatile static DeviceAddCustomImpl deviceAddCustom;
|
||||||
|
|
||||||
|
public static DeviceAddCustomImpl newInstance() {
|
||||||
|
if (deviceAddCustom == null) {
|
||||||
|
synchronized (DeviceAddCustomImpl.class) {
|
||||||
|
if (deviceAddCustom == null) {
|
||||||
|
deviceAddCustom = new DeviceAddCustomImpl();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return deviceAddCustom;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void goFAQWebview(Context context) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void goHomePage(Context context) {
|
||||||
|
Activity activity=ActivityHelper.getCurrentActivity();
|
||||||
|
if (activity!=null){
|
||||||
|
activity.finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDevAddCachePath() {
|
||||||
|
return SDsolutionUtility.getCachePath();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void uninit() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.mm.android.deviceaddmodule.mobilecommon.AppConsume;
|
||||||
|
|
||||||
|
import android.text.TextUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备模块帮助类
|
||||||
|
**/
|
||||||
|
public class DeviceHelper {
|
||||||
|
public static boolean isH1G(String deviceModelName){
|
||||||
|
return !TextUtils.isEmpty(deviceModelName) && "H1G".equalsIgnoreCase(deviceModelName);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,265 @@
|
||||||
|
package com.mm.android.deviceaddmodule.mobilecommon.AppConsume;
|
||||||
|
|
||||||
|
import android.app.Application;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.pm.ApplicationInfo;
|
||||||
|
import android.content.pm.PackageInfo;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.content.pm.PackageManager.NameNotFoundException;
|
||||||
|
import android.net.wifi.WifiInfo;
|
||||||
|
import android.net.wifi.WifiManager;
|
||||||
|
import android.telephony.TelephonyManager;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.utils.LogUtil;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.utils.PreferencesHelper;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 业务必要属性
|
||||||
|
*
|
||||||
|
* App配置文件必须要配置的 推送ID
|
||||||
|
* {@code meta_data4project} App配置文件必须要配置的 项目名称 {@code meta_data4Type}
|
||||||
|
* App配置文件必须要配置的 协议发起方
|
||||||
|
*/
|
||||||
|
public final class EnvironmentConfig {
|
||||||
|
public static final String meta_data4Type = "meta-data4type";
|
||||||
|
public static final String meta_data4AppId = "meta-data4appid";
|
||||||
|
public static final String meta_isHttps = "meta-ishttps";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 1.clientType:客户端类型(必填),"phone"-手机,"web"-浏览器,"box"-盒子。
|
||||||
|
* {@link } 环境配置属性。
|
||||||
|
*/
|
||||||
|
private String clientType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 2.clientMac:客户端MAC地址(必填),用于唯一标识这个客户端。
|
||||||
|
*/
|
||||||
|
private String clientMac;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 服务端地址
|
||||||
|
*/
|
||||||
|
private String host;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否是走https协议
|
||||||
|
*/
|
||||||
|
private boolean isHttps;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 缓存文件名
|
||||||
|
*/
|
||||||
|
private String userAgent = "volley/0";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 缓存路径
|
||||||
|
*/
|
||||||
|
private File cacheDir;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应用ID
|
||||||
|
*/
|
||||||
|
private String appId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Application
|
||||||
|
*/
|
||||||
|
private Context application;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 版本名
|
||||||
|
*/
|
||||||
|
private String versionName;
|
||||||
|
|
||||||
|
private String language = null;
|
||||||
|
|
||||||
|
public static Context mContext;// applicationContext
|
||||||
|
|
||||||
|
public EnvironmentConfig(Builder b) {
|
||||||
|
this.clientMac = b.clientMac;
|
||||||
|
this.clientType = b.clientType;
|
||||||
|
userAgent = b.userAgent;
|
||||||
|
cacheDir = b.cacheDir;
|
||||||
|
appId = b.appId;
|
||||||
|
host = b.host;
|
||||||
|
this.isHttps = b.isHttps;
|
||||||
|
application = b.applicationContext;
|
||||||
|
versionName = b.versionName;
|
||||||
|
language = b.language;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHost() {
|
||||||
|
return host;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getClientType() {
|
||||||
|
return clientType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHost(String host) {
|
||||||
|
this.host = host;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getClientMacAddress() {
|
||||||
|
return clientMac;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Context getContext() {
|
||||||
|
return application;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getVersionName() {
|
||||||
|
return versionName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLanguage() {
|
||||||
|
return language;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
private String clientType;
|
||||||
|
private String clientMac;
|
||||||
|
private String project;
|
||||||
|
private String userAgent;
|
||||||
|
private File cacheDir;
|
||||||
|
private String appId;
|
||||||
|
private String host;
|
||||||
|
private boolean isHttps;
|
||||||
|
private Context applicationContext;
|
||||||
|
private String versionName;
|
||||||
|
private String language = null;
|
||||||
|
|
||||||
|
public Builder setContext(Context context) throws Exception {
|
||||||
|
if (!(context instanceof Application)) {
|
||||||
|
throw new Exception("context must instance application");
|
||||||
|
}
|
||||||
|
applicationContext = context;
|
||||||
|
mContext = applicationContext.getApplicationContext();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setClientType(String clientType) {
|
||||||
|
this.clientType = clientType;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setVersionName(Context context) {
|
||||||
|
PackageManager pm = context.getPackageManager();
|
||||||
|
PackageInfo pi = null;
|
||||||
|
try {
|
||||||
|
pi = pm.getPackageInfo(context.getPackageName(), 0);
|
||||||
|
versionName = pi.versionName;
|
||||||
|
} catch (NameNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setClientMac(Context context) {
|
||||||
|
try {
|
||||||
|
// FIXME:Mac地址可能为空 IMEI 未识别信息,如果未发现,则功能不正常使用
|
||||||
|
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||||
|
String imei = telephonyManager.getDeviceId();
|
||||||
|
LogUtil.debugLog("lechange", "imei : " + imei);
|
||||||
|
if (imei == null) {
|
||||||
|
WifiManager wifiMgr = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
|
||||||
|
WifiInfo info = (null == wifiMgr ? null : wifiMgr.getConnectionInfo());
|
||||||
|
String mac = info != null ? info.getMacAddress() : "";
|
||||||
|
LogUtil.debugLog("lechange", "mac : " + mac);
|
||||||
|
if (mac != null) {
|
||||||
|
mac = mac.replace(":", "");
|
||||||
|
} else {
|
||||||
|
mac = "";
|
||||||
|
}
|
||||||
|
clientMac = mac;
|
||||||
|
} else {
|
||||||
|
clientMac = imei;
|
||||||
|
}
|
||||||
|
LogUtil.debugLog("lechange", "clientMac : " + clientMac);
|
||||||
|
} catch (Exception e) {
|
||||||
|
clientMac = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setProject(String project) {
|
||||||
|
this.project = project;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setCacheFile(Context context) {
|
||||||
|
cacheDir = context.getCacheDir();
|
||||||
|
userAgent = "volley/0";
|
||||||
|
try {
|
||||||
|
String packageName = context.getPackageName();
|
||||||
|
PackageInfo info = context.getPackageManager().getPackageInfo(packageName, 0);
|
||||||
|
userAgent = packageName + "/" + info.versionCode;
|
||||||
|
} catch (NameNotFoundException e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setHost(String host) {
|
||||||
|
this.host = host;
|
||||||
|
String historyHost = PreferencesHelper.getInstance(applicationContext).getString(PreferencesConfig.HOST_HELP);
|
||||||
|
if (!TextUtils.isEmpty(historyHost)) {// 如果历史记录Host 不是nil
|
||||||
|
// 则设置历史Host,用于测试服务器
|
||||||
|
this.host = historyHost;
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setDefaultHost(String host) {
|
||||||
|
this.host = host;
|
||||||
|
String historyHost = PreferencesHelper.getInstance(applicationContext).getString(PreferencesConfig.HOST_HELP);
|
||||||
|
if (!TextUtils.isEmpty(historyHost)) {// 如果历史记录Host 不是nil
|
||||||
|
// 则设置历史Host,用于测试服务器
|
||||||
|
this.host = historyHost;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setLanguage(String language) {
|
||||||
|
this.language = language;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setLanguage(Context context) {
|
||||||
|
this.language = context.getResources().getConfiguration().locale.getLanguage();
|
||||||
|
}
|
||||||
|
|
||||||
|
public EnvironmentConfig build() {
|
||||||
|
|
||||||
|
if (versionName == null || versionName.equals("")) {
|
||||||
|
setVersionName(applicationContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cacheDir == null) {
|
||||||
|
setCacheFile(applicationContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (clientMac == null || clientMac.equals("")) {
|
||||||
|
setClientMac(applicationContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (language == null || language.equals("")) {
|
||||||
|
setLanguage(applicationContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
ApplicationInfo appInfo = applicationContext.getPackageManager().getApplicationInfo(applicationContext.getPackageName(), PackageManager.GET_META_DATA);
|
||||||
|
|
||||||
|
if (clientType == null || clientType.equals("")) {
|
||||||
|
clientType = appInfo.metaData.getString(meta_data4Type);
|
||||||
|
}
|
||||||
|
|
||||||
|
isHttps = appInfo.metaData.getBoolean(meta_isHttps);
|
||||||
|
|
||||||
|
} catch (NameNotFoundException e) {
|
||||||
|
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return new EnvironmentConfig(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
package com.mm.android.deviceaddmodule.mobilecommon.AppConsume;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.base.IBaseProvider;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* App通用接口类
|
||||||
|
*/
|
||||||
|
|
||||||
|
public interface IApp extends IBaseProvider {
|
||||||
|
/*设备App使用类型,0表示国内,1表示海外*/
|
||||||
|
public void setAppType(int type);
|
||||||
|
|
||||||
|
public int getAppType(); //APP类型(0:乐橙/1:Easy4ip)
|
||||||
|
|
||||||
|
public Context getAppContext(); //获取App上下文
|
||||||
|
|
||||||
|
|
||||||
|
public void goDeviceSharePage(Activity activity , Bundle bundle); //进入设备分享页
|
||||||
|
|
||||||
|
void goBuyCloudPage(Activity activity , Bundle bundle);
|
||||||
|
|
||||||
|
//跳转修改设备密码引导页
|
||||||
|
void goModifyDevicePwdGuidePage(Activity activity);
|
||||||
|
|
||||||
|
String getAppLanguage();
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.mm.android.deviceaddmodule.mobilecommon.AppConsume;
|
||||||
|
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.base.BaseHandler;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.base.IBaseProvider;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备添加对外接口,外部模块可调用的功能
|
||||||
|
*/
|
||||||
|
public interface IDeviceAdd extends IBaseProvider {
|
||||||
|
void stopSearchDevicesAsync(long ret, BaseHandler handler); //异步停止设备搜索
|
||||||
|
boolean stopSearchDevices(long ret, String requestId); //同步停止设备搜索
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.mm.android.deviceaddmodule.mobilecommon.AppConsume;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.base.IBaseProvider;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备添加模块,App需不同实现的接口
|
||||||
|
**/
|
||||||
|
public interface IDeviceAddCustom extends IBaseProvider {
|
||||||
|
void goFAQWebview(Context context); //调整至FAQ
|
||||||
|
void goHomePage(Context context);//回到设备列表页
|
||||||
|
String getDevAddCachePath(); //设备添加文件缓存路径
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
|
||||||
|
package com.mm.android.deviceaddmodule.mobilecommon.AppConsume;
|
||||||
|
import static com.mm.android.deviceaddmodule.mobilecommon.AppConsume.PseudoJsonScanResult.filterInvalidString;
|
||||||
|
import static com.mm.android.deviceaddmodule.mobilecommon.AppConsume.PseudoJsonScanResult.filterInvalidString4Type;
|
||||||
|
|
||||||
|
|
||||||
|
public class OneColonScanResult extends ScanResult {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建一个新的实例OneColonScanResult.
|
||||||
|
*
|
||||||
|
* @param scanString
|
||||||
|
*/
|
||||||
|
public OneColonScanResult(String scanString) {
|
||||||
|
super(scanString);
|
||||||
|
String[] resultStrings = scanString.split(":");
|
||||||
|
this.setSn(filterInvalidString(resultStrings[0]));
|
||||||
|
this.setMode(filterInvalidString4Type(resultStrings[1]));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
package com.mm.android.deviceaddmodule.mobilecommon.AppConsume;
|
||||||
|
|
||||||
|
public class PreferencesConfig {
|
||||||
|
public static final String HOST_HELP = "HOST_HELP_V2";
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.mm.android.deviceaddmodule.mobilecommon.AppConsume;
|
||||||
|
|
||||||
|
|
||||||
|
import com.mm.android.deviceaddmodule.provider.DeviceAddProvider;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 功能接口管理类
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class ProviderManager {
|
||||||
|
|
||||||
|
public static IApp getAppProvider() {
|
||||||
|
return AppProvider.newInstance();
|
||||||
|
}
|
||||||
|
public static IDeviceAdd getDeviceAddProvider() {
|
||||||
|
return DeviceAddProvider.newInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IDeviceAddCustom getDeviceAddCustomProvider() {
|
||||||
|
return DeviceAddCustomImpl.newInstance();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,99 @@
|
||||||
|
package com.mm.android.deviceaddmodule.mobilecommon.AppConsume;
|
||||||
|
|
||||||
|
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.utils.LogUtil;
|
||||||
|
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 伪json格式的二维码扫描结果(带NC)
|
||||||
|
* </p>
|
||||||
|
*/
|
||||||
|
public class PseudoJsonNcScanResult extends ScanResult {
|
||||||
|
|
||||||
|
private static final String TAG = "JsonScanResult";
|
||||||
|
private static final String[] SN_TAGS = new String[]{"SN", "sN", "Sn", "sn"};
|
||||||
|
private static final String[] DT_TAGS = new String[]{"DT", "dT", "Dt", "dt"};
|
||||||
|
private static final String[] RD_TAGS = new String[]{"RD", "rD", "Rd", "rd"};
|
||||||
|
private static final String[] RC_TAGS = new String[]{"RC", "rC", "Rc", "rc"};
|
||||||
|
private static final String[] NC_TAGS = new String[]{"NC", "nC", "Nc", "nc"};
|
||||||
|
private static final String[] SC_TAGS = new String[]{"SC", "sC", "Sc", "sc"};
|
||||||
|
private static final String[] IMEI_TAGS = new String[]{"IMEI", "imei"};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建一个新的实例JsonScanResult.
|
||||||
|
*
|
||||||
|
* @param scanString
|
||||||
|
*/
|
||||||
|
public PseudoJsonNcScanResult(String scanString) {
|
||||||
|
super(scanString);
|
||||||
|
|
||||||
|
//解析伪Json 类似{SN:DVRP2P00LJL0028,DT:DH/HCVR1604HG-SFD-V4/-AF-DVR-II-A/16-16,NC:QR,RC:SQ93W5}
|
||||||
|
|
||||||
|
//替换中文":"
|
||||||
|
scanString = scanString.replace(':', ':');
|
||||||
|
|
||||||
|
// 补充"{" "}"
|
||||||
|
int first = scanString.indexOf("{");
|
||||||
|
if (first < 0) {
|
||||||
|
scanString = "{" + scanString;
|
||||||
|
}
|
||||||
|
int last = scanString.indexOf("}");
|
||||||
|
if (last < 0) {
|
||||||
|
scanString = scanString + "}";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 补充引号"""
|
||||||
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
for(int i = 0; i < scanString.length(); i++) {
|
||||||
|
char c = scanString.charAt(i);
|
||||||
|
if(c == '{') {
|
||||||
|
buffer.append(c).append("\"");
|
||||||
|
}else if(c == ':' || c == ',' || c == ';') {
|
||||||
|
buffer.append("\"").append(c).append("\"");
|
||||||
|
} else if(c == '}') {
|
||||||
|
buffer.append("\"").append(c);
|
||||||
|
} else {
|
||||||
|
buffer.append(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String sn = "";
|
||||||
|
String dt = "";
|
||||||
|
String rd = "";
|
||||||
|
String nc = "";
|
||||||
|
String sc = "";
|
||||||
|
String imeiCode = "";
|
||||||
|
|
||||||
|
try {
|
||||||
|
JSONObject jsonObject = new JSONObject(buffer.toString());
|
||||||
|
sn = getValue(jsonObject, SN_TAGS, "");
|
||||||
|
dt = getValue(jsonObject, DT_TAGS, "");
|
||||||
|
rd = getValue(jsonObject, RD_TAGS, "");
|
||||||
|
rd = getValue(jsonObject, RC_TAGS, "");
|
||||||
|
nc = getValue(jsonObject, NC_TAGS, "");
|
||||||
|
sc = getValue(jsonObject, SC_TAGS, "");
|
||||||
|
imeiCode = getValue(jsonObject, IMEI_TAGS, "");
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
this.setSn(sn);
|
||||||
|
this.setRegcode(rd);
|
||||||
|
this.setMode(dt);
|
||||||
|
this.setNc(nc);
|
||||||
|
this.setSc(sc);
|
||||||
|
this.setImeiCode(imeiCode);
|
||||||
|
LogUtil.debugLog("PseudoJsonNcScanResult", this.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getValue(JSONObject json, String[] tags, String defaultStr) {
|
||||||
|
for (String tag : tags) {
|
||||||
|
if (json.has(tag)) {
|
||||||
|
return json.optString(tag, defaultStr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return defaultStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,157 @@
|
||||||
|
package com.mm.android.deviceaddmodule.mobilecommon.AppConsume;
|
||||||
|
|
||||||
|
import android.text.TextUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 伪json格式的二维码扫描结果
|
||||||
|
* </p>
|
||||||
|
*/
|
||||||
|
public class PseudoJsonScanResult extends ScanResult {
|
||||||
|
|
||||||
|
private static final String TAG = "JsonScanResult";
|
||||||
|
private static final String[] SN_TAGS = new String[]{"SN:", "sN:", "Sn:", "sn:", "SN:", "sN:", "Sn:", "sn:"};
|
||||||
|
private static final String[] DT_TAGS = new String[]{"DT:", "dT:", "Dt:", "dt:", "DT:", "dT:", "Dt:", "dt:"};
|
||||||
|
private static final String[] RD_TAGS = new String[]{"RD:", "rD:", "Rd:", "rd:", "RD:", "rD:", "Rd:", "rd:"};
|
||||||
|
private static final String[] RC_TAGS = new String[]{"RC:", "rC:", "Rc:", "rc:", "RC:", "rC:", "Rc:", "rc:"};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建一个新的实例JsonScanResult.
|
||||||
|
*
|
||||||
|
* @param scanString
|
||||||
|
*/
|
||||||
|
public PseudoJsonScanResult(String scanString) {
|
||||||
|
super(scanString);
|
||||||
|
|
||||||
|
//解析伪Json 类似{SN:DVRP2P00LJL0028,DT:DH/HCVR1604HG-SFD-V4/-AF-DVR-II-A/16-16,RC:SQ93W5}
|
||||||
|
|
||||||
|
String jsonStr;
|
||||||
|
int firstIndex = scanString.indexOf("{");
|
||||||
|
if (firstIndex >= 0 && firstIndex <= scanString.length() - 1) {
|
||||||
|
jsonStr = scanString.substring(firstIndex, scanString.length());
|
||||||
|
} else {
|
||||||
|
jsonStr = scanString;
|
||||||
|
}
|
||||||
|
|
||||||
|
int snEndIndex = -1;
|
||||||
|
int dtEndIndex = -1;
|
||||||
|
int rdEndIndex = -1;
|
||||||
|
int snStartIndex = getStartIndex(jsonStr, SN_TAGS, -1);
|
||||||
|
int dtStartIndex = getStartIndex(jsonStr, DT_TAGS, -1);
|
||||||
|
int rdStartIndex = getStartIndex(jsonStr, RD_TAGS, -1);
|
||||||
|
rdStartIndex = getStartIndex(jsonStr, RC_TAGS, rdStartIndex);
|
||||||
|
|
||||||
|
if (snStartIndex == -1) {
|
||||||
|
this.setSn("");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (snStartIndex > dtStartIndex && snStartIndex > rdStartIndex) { // sn在最后
|
||||||
|
if (dtStartIndex == -1 && rdStartIndex == -1) { // {sn:}
|
||||||
|
snEndIndex = jsonStr.length() - 1;
|
||||||
|
|
||||||
|
} else if (dtStartIndex == -1 && rdStartIndex != -1) { // {rd:,sn:}
|
||||||
|
rdEndIndex = snStartIndex - 1;
|
||||||
|
snEndIndex = jsonStr.length() - 1;
|
||||||
|
} else if (dtStartIndex != -1 && rdStartIndex == -1) { // {dt:,sn:}
|
||||||
|
dtEndIndex = snStartIndex - 1;
|
||||||
|
snEndIndex = jsonStr.length() - 1;
|
||||||
|
} else {
|
||||||
|
if (dtStartIndex > rdStartIndex) { // {rd:,dt:,sn:}
|
||||||
|
rdEndIndex = dtStartIndex - 1;
|
||||||
|
dtEndIndex = snStartIndex - 1;
|
||||||
|
snEndIndex = jsonStr.length() - 1;
|
||||||
|
} else { // {dt:,rd:,sn:}
|
||||||
|
dtEndIndex = rdStartIndex - 1;
|
||||||
|
rdEndIndex = snStartIndex - 1;
|
||||||
|
snEndIndex = jsonStr.length() - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (dtStartIndex > snStartIndex && dtStartIndex > rdStartIndex) { // dt在最后
|
||||||
|
if (rdStartIndex == -1) {
|
||||||
|
snEndIndex = dtStartIndex - 1;
|
||||||
|
dtEndIndex = jsonStr.length() - 1;
|
||||||
|
} else if (snStartIndex > rdStartIndex) {
|
||||||
|
rdEndIndex = snStartIndex - 1;
|
||||||
|
snEndIndex = dtStartIndex - 1;
|
||||||
|
dtEndIndex = jsonStr.length() - 1;
|
||||||
|
|
||||||
|
} else if (snStartIndex < rdStartIndex) {
|
||||||
|
snEndIndex = rdStartIndex - 1;
|
||||||
|
rdEndIndex = dtStartIndex - 1;
|
||||||
|
dtEndIndex = jsonStr.length() - 1;
|
||||||
|
}
|
||||||
|
} else if (rdStartIndex > snStartIndex && rdStartIndex > dtStartIndex) { // rd在最后
|
||||||
|
if (dtStartIndex == -1) {
|
||||||
|
snEndIndex = rdStartIndex - 1;
|
||||||
|
rdEndIndex = jsonStr.length() - 1;
|
||||||
|
} else if (snStartIndex > dtStartIndex) {
|
||||||
|
dtEndIndex = snStartIndex - 1;
|
||||||
|
snEndIndex = rdStartIndex - 1;
|
||||||
|
rdEndIndex = jsonStr.length() - 1;
|
||||||
|
|
||||||
|
} else if (snStartIndex < dtStartIndex) {
|
||||||
|
snEndIndex = dtStartIndex - 1;
|
||||||
|
dtEndIndex = rdStartIndex - 1;
|
||||||
|
rdEndIndex = jsonStr.length() - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rdStartIndex != -1) {
|
||||||
|
this.setRegcode(filterInvalidString(jsonStr.substring(rdStartIndex + 2, rdEndIndex)));
|
||||||
|
} else {
|
||||||
|
this.setRegcode("");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dtStartIndex != -1) {
|
||||||
|
this.setMode(filterInvalidString4Type(jsonStr.substring(dtStartIndex + 2, dtEndIndex)));
|
||||||
|
} else {
|
||||||
|
this.setMode("");
|
||||||
|
}
|
||||||
|
this.setSn(filterInvalidString(jsonStr.substring(snStartIndex + 2, snEndIndex)));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getStartIndex(String jsonStr, String[] tags, int startIndex) {
|
||||||
|
for (String dttag : tags) {
|
||||||
|
if (jsonStr.contains(dttag)) {
|
||||||
|
return jsonStr.indexOf(dttag) + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return startIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String filterInvalidString(String str) {
|
||||||
|
if (TextUtils.isEmpty(str)) {
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
String numberAndAbc = "[a-zA-Z0-9]";
|
||||||
|
StringBuilder buffer = new StringBuilder();
|
||||||
|
int len = str.length();
|
||||||
|
for (int i = 0; i < len; ++i) {
|
||||||
|
String temp = str.substring(i, i + 1);
|
||||||
|
if (temp.matches(numberAndAbc)) {
|
||||||
|
buffer.append(temp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return buffer.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String filterInvalidString4Type(String str) {
|
||||||
|
if (TextUtils.isEmpty(str)) {
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
String numberAndAbc = "[a-zA-Z0-9-/\\\\]";
|
||||||
|
StringBuilder buffer = new StringBuilder();
|
||||||
|
int len = str.length();
|
||||||
|
for (int i = 0; i < len; ++i) {
|
||||||
|
String temp = str.substring(i, i + 1);
|
||||||
|
if (temp.matches(numberAndAbc)) {
|
||||||
|
buffer.append(temp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return buffer.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,124 @@
|
||||||
|
package com.mm.android.deviceaddmodule.mobilecommon.AppConsume;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 二维码扫描结果基类
|
||||||
|
* </p>
|
||||||
|
*/
|
||||||
|
public class ScanResult {
|
||||||
|
/**
|
||||||
|
* 设备序列号
|
||||||
|
*/
|
||||||
|
private String sn = "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备型号
|
||||||
|
*/
|
||||||
|
private String mode = "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备验证码、设备安全码
|
||||||
|
*/
|
||||||
|
private String regcode = "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备随机码,备用
|
||||||
|
*/
|
||||||
|
private String rd = "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备能力
|
||||||
|
*/
|
||||||
|
private String nc = "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备安全验证码
|
||||||
|
*/
|
||||||
|
private String sc = "";
|
||||||
|
|
||||||
|
private String imeiCode = "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建一个新的实例ScanResult.
|
||||||
|
*
|
||||||
|
* @param scanString
|
||||||
|
*/
|
||||||
|
public ScanResult(String scanString) {
|
||||||
|
// TODO Auto-generated constructor stub
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建一个新的实例ScanResult.
|
||||||
|
*/
|
||||||
|
public ScanResult() {
|
||||||
|
// TODO Auto-generated constructor stub
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSn() {
|
||||||
|
return sn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSn(String sn) {
|
||||||
|
this.sn = sn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRegcode() {
|
||||||
|
return regcode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRegcode(String regcode) {
|
||||||
|
this.regcode = regcode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRd() {
|
||||||
|
return rd;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRd(String rd) {
|
||||||
|
this.rd = rd;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMode() {
|
||||||
|
return mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMode(String mode) {
|
||||||
|
this.mode = mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNc() {
|
||||||
|
return nc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNc(String nc) {
|
||||||
|
this.nc = nc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSc() {
|
||||||
|
return sc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSc(String sc) {
|
||||||
|
this.sc = sc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getImeiCode() {
|
||||||
|
return imeiCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setImeiCode(String imeiCode) {
|
||||||
|
this.imeiCode = imeiCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "ScanResult{" +
|
||||||
|
"sn='" + sn + '\'' +
|
||||||
|
", mode='" + mode + '\'' +
|
||||||
|
", regcode='" + regcode + '\'' +
|
||||||
|
", nc='" + nc + '\'' +
|
||||||
|
", sc='" + sc + '\'' +
|
||||||
|
", imeiCode='" + imeiCode + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,140 @@
|
||||||
|
package com.mm.android.deviceaddmodule.mobilecommon.AppConsume;
|
||||||
|
|
||||||
|
import android.text.TextUtils;
|
||||||
|
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.common.LCConfiguration;
|
||||||
|
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 根据二维码扫描结果生成相应的类
|
||||||
|
* </p>
|
||||||
|
*/
|
||||||
|
public class ScanResultFactory {
|
||||||
|
// 工厂方法.注意 返回类型为抽象产品角色
|
||||||
|
private static String tag = "www.hsview.com";
|
||||||
|
private static String tag_lc = "www.lechange.cn";
|
||||||
|
|
||||||
|
public static ScanResult scanResult(String scanString) {
|
||||||
|
if (ProviderManager.getAppProvider().getAppType() == LCConfiguration.APP_LECHANGE_OVERSEA) {//海外二维码规则
|
||||||
|
// 带NC标签的
|
||||||
|
final String[] NC_ARRAYS = new String[]{"NC:", "nC:", "Nc:", "nc:", "NC:", "nC:", "Nc:", "nc:"};
|
||||||
|
// 带SC标签的
|
||||||
|
final String[] SC_ARRAYS = new String[]{"SC:", "sC:", "Sc:", "Sc:", "SC:", "sC:", "Sc:", "sc:"};
|
||||||
|
boolean hasNc = hasTag(scanString, NC_ARRAYS);
|
||||||
|
boolean hasSc = hasTag(scanString, SC_ARRAYS);
|
||||||
|
if((hasNc || hasSc) && scanString.contains("{")) {
|
||||||
|
return new PseudoJsonNcScanResult(scanString);
|
||||||
|
} else {
|
||||||
|
String deviceSN = "";
|
||||||
|
String deviceSerial = "";
|
||||||
|
if (scanString.contains(",")) { //逗号分割,{SN:2J021B3PAK00120,DT:IPC-HFW1120SP-W-0280B,RC:564897}
|
||||||
|
scanString = scanString.substring(1, scanString.length() - 1); //去掉收尾花括号
|
||||||
|
String[] array = scanString.split(",");
|
||||||
|
for (String strArray : array) {
|
||||||
|
if (strArray.contains("SN:")) {
|
||||||
|
deviceSN = strArray.substring(strArray.indexOf("SN:") + 3, strArray.length());
|
||||||
|
}
|
||||||
|
if (strArray.contains("DT:")) {
|
||||||
|
deviceSerial = strArray.substring(strArray.indexOf("DT:") + 3, strArray.length());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (scanString.contains(";")) {//分号分割,{SN:2J021B3PAK00120;DT:IPC-HFW1120SP-W-0280B;RC:564897}
|
||||||
|
scanString = scanString.substring(1, scanString.length() - 1); //去掉收尾花括号
|
||||||
|
String[] array = scanString.split(";");
|
||||||
|
for (String strArray : array) {
|
||||||
|
if (strArray.contains("SN:")) {
|
||||||
|
deviceSN = strArray.substring(strArray.indexOf("SN:") + 3, strArray.length());
|
||||||
|
}
|
||||||
|
if (strArray.contains("DT:")) {
|
||||||
|
deviceSerial = strArray.substring(strArray.indexOf("DT:") + 3, strArray.length());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (scanString.contains(":")) { //2M047C9PAN00005:DHI-ARD1611-W:PJ0V46
|
||||||
|
String[] array = scanString.split(":");
|
||||||
|
deviceSN = array[0];
|
||||||
|
deviceSerial = array[1];
|
||||||
|
} else {
|
||||||
|
deviceSN = scanString;
|
||||||
|
}
|
||||||
|
// 兼容 俄语区Q4的订单采用标签二维码内容异常 格式为:DH-IPC-C35P,4K002C6PAJA49A7
|
||||||
|
if(TextUtils.isEmpty(deviceSN)) {
|
||||||
|
String[] array = scanString.split(",");
|
||||||
|
if(array != null && array.length == 2) {
|
||||||
|
deviceSN = array[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ScanResult scanResult = new ScanResult();
|
||||||
|
scanResult.setSn(deviceSN);
|
||||||
|
scanResult.setMode(deviceSerial);
|
||||||
|
return scanResult;
|
||||||
|
}
|
||||||
|
} else {//国内二维码规则
|
||||||
|
if(scanString.contains(tag) || scanString.contains(tag_lc)){
|
||||||
|
if(scanString.contains("{")){
|
||||||
|
// 兼容TC1
|
||||||
|
ScanResult scanResult = new PseudoJsonScanResult(scanString);
|
||||||
|
return scanResult;
|
||||||
|
}
|
||||||
|
// 兼容老乐橙设备
|
||||||
|
int index = scanString.indexOf('=');
|
||||||
|
String sn = scanString.substring(index + 1, scanString.length());
|
||||||
|
ScanResult scanResult = new ScanResult();
|
||||||
|
scanResult.setSn(sn);
|
||||||
|
return scanResult;
|
||||||
|
} else if (scanString.contains("{")) {
|
||||||
|
ScanResult result = new PseudoJsonNcScanResult(scanString);
|
||||||
|
return result;
|
||||||
|
} else if (!scanString.contains("SN:") || !scanString.contains("SN=") || !scanString.contains("SN =") ||
|
||||||
|
!scanString.contains("sn:") || !scanString.contains("sn=") || !scanString.contains("sn =")) {
|
||||||
|
if (!checkString(scanString)) {
|
||||||
|
String[] strings = scanString.split(":");
|
||||||
|
if (strings != null && !scanString.startsWith("http://") && strings.length == 3) {
|
||||||
|
return new TwoColonsScanResult(scanString);
|
||||||
|
|
||||||
|
} else if (strings != null && !scanString.startsWith("http://") && strings.length == 2) {
|
||||||
|
return new OneColonScanResult(scanString);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ScanResult scanResult = new ScanResult();
|
||||||
|
scanResult.setSn(scanString);
|
||||||
|
return scanResult;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new ScanResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 判断是否有tag
|
||||||
|
private static boolean hasTag(String scanString, String[] tagArrays) {
|
||||||
|
boolean hasTag = false;
|
||||||
|
for (String tag : tagArrays) {
|
||||||
|
if (scanString.contains(tag)) {
|
||||||
|
hasTag = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return hasTag;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断是否只包含数字或大小写字母
|
||||||
|
*
|
||||||
|
* @param str
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static boolean checkString(String str) {
|
||||||
|
String regEx = "[0-9A-Za-z]*"; // 只能是数字以及个别字符
|
||||||
|
Pattern p = Pattern.compile(regEx);
|
||||||
|
Matcher m = p.matcher(str);
|
||||||
|
if (m.matches()) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,60 @@
|
||||||
|
package com.mm.android.deviceaddmodule.mobilecommon.AppConsume;
|
||||||
|
|
||||||
|
import android.os.Process;
|
||||||
|
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
import java.util.concurrent.ThreadFactory;
|
||||||
|
|
||||||
|
public class ThreadPool {
|
||||||
|
private volatile static ExecutorService cachedThreadPool;
|
||||||
|
|
||||||
|
// 提交线程
|
||||||
|
public static Future<?> submit(Runnable mRunnable) {
|
||||||
|
|
||||||
|
if (cachedThreadPool == null) {
|
||||||
|
synchronized (ExecutorService.class) {
|
||||||
|
if (cachedThreadPool == null) {
|
||||||
|
cachedThreadPool = Executors.newFixedThreadPool(Runtime
|
||||||
|
.getRuntime().availableProcessors() * 2,new DefaultFactory());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cachedThreadPool.submit(mRunnable);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 关闭
|
||||||
|
public static void shutdown() {
|
||||||
|
if (cachedThreadPool != null && !cachedThreadPool.isShutdown())
|
||||||
|
cachedThreadPool.shutdown();
|
||||||
|
cachedThreadPool = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
static class DefaultFactory implements ThreadFactory {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Thread newThread(Runnable r) {
|
||||||
|
|
||||||
|
Thread thread = new Thread(new FactoryRunnable(r));
|
||||||
|
|
||||||
|
return thread;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static class FactoryRunnable implements Runnable {
|
||||||
|
Runnable runnable;
|
||||||
|
|
||||||
|
public FactoryRunnable(Runnable runnable) {
|
||||||
|
this.runnable = runnable;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
|
||||||
|
runnable.run();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package com.mm.android.deviceaddmodule.mobilecommon.AppConsume;
|
||||||
|
import static com.mm.android.deviceaddmodule.mobilecommon.AppConsume.PseudoJsonScanResult.filterInvalidString;
|
||||||
|
import static com.mm.android.deviceaddmodule.mobilecommon.AppConsume.PseudoJsonScanResult.filterInvalidString4Type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* xxx:xxx:xxx格式二维码
|
||||||
|
* </p>
|
||||||
|
*/
|
||||||
|
public class TwoColonsScanResult extends ScanResult {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建一个新的实例TwoColonsScanResult.
|
||||||
|
*
|
||||||
|
* @param scanString
|
||||||
|
*/
|
||||||
|
public TwoColonsScanResult(String scanString) {
|
||||||
|
super(scanString);
|
||||||
|
String[] resultStrings = scanString.split(":");
|
||||||
|
this.setSn(filterInvalidString(resultStrings[0]));
|
||||||
|
this.setMode(filterInvalidString4Type(resultStrings[1]));
|
||||||
|
this.setRegcode(filterInvalidString(resultStrings[2]));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,164 @@
|
||||||
|
package com.mm.android.deviceaddmodule.mobilecommon.annotation;
|
||||||
|
|
||||||
|
import android.support.annotation.StringDef;
|
||||||
|
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
|
||||||
|
import static com.mm.android.deviceaddmodule.mobilecommon.annotation.DeviceAbility.*;
|
||||||
|
import static java.lang.annotation.RetentionPolicy.SOURCE;
|
||||||
|
|
||||||
|
@Retention(SOURCE)
|
||||||
|
@StringDef({WLAN, AlarmPIR, AlarmMD, AudioTalk, AudioTalkV1, VVP2P, DHP2P, PTZ, PT, HSEncrypt, CloudStorage, AGW, BreathingLight,
|
||||||
|
PlaybackByFilename, LocalStorage, RegCode, RemoteControl, Panorama, RD, SLAlarm, CK, AudioEncodeOff, MDS, MDW, HeaderDetect,
|
||||||
|
SR, AGWDisarm, CollectionPoint, TimedCruise, SmartTrack, ZoomFocus, SmartLocate, LocalRecord, XUpgrade, Auth, NumberStat,
|
||||||
|
|
||||||
|
HoveringAlarm, BeOpenedDoor, NonAccessoriesAdd, CloseCamera, MobileDetect, Siren, LinkageSiren, WhiteLight, WLV2, Dormant,
|
||||||
|
/*NoVA, */NoAccessories, UnsupportLiveShare, RTSV1, PBSV1, SearchLight, CallByRtsp, SirenTime,NVM, LEDS, TimingGraphics, HumanDetect, AlarmPIRV2, HUBAlarmPIRV2,
|
||||||
|
AlarmPIRV3, AlarmPIRV4, LocalStorageEnable, DaySummerTime, WeekSummerTime,SummerTimeOffset, AiHuman, AiCar, Electric, WIFI, DLOCS, OpenDoorByFace, OpenDoorByTouch,
|
||||||
|
PlaySoundModify, WideDynamic, TalkSoundModify, LinkDevAlarm, LinkAccDevAlarm, AbAlarmSound, CheckAbDecible, Reboot, PlaySound,
|
||||||
|
AudioEncodeControl, SceneMode, SIMCA, TimeFormat, SASQ, MGOCS, ModifyName, ElecInfo, SigInfo, ACT, AlarmSound, DDT, OnlyArmed, TSV1, NoPlan, ChnLocalStorage,
|
||||||
|
AccessoryAlarmSound, RingAlarmSound, SCCode, CustomRing, InfraredLight, AudioEncodeControlV2, InstantDisAlarm,IDAP, RDV2,RDV3, DeviceAlarmSound, FaceDetect,
|
||||||
|
CallAbility, CAV2, HAV2, Ring, RTSV2, PBSV2, TSV2, PT1, AX, HAV3, VideoMotionSMD, TLSEnable, TCM, CLDA, ChnWhiteLight, ChnSiren, LED,
|
||||||
|
CCR, CLS, CLW, ""})
|
||||||
|
|
||||||
|
public @interface DeviceAbility {
|
||||||
|
String WLAN = "WLAN"; // 设备支持接入无线局域网
|
||||||
|
String AlarmPIR = "AlarmPIR"; // 设备支持人体红外报警
|
||||||
|
String AlarmMD = "AlarmMD"; // 设备支持动检报警
|
||||||
|
String AudioTalk = "AudioTalk"; // 设备支持语音对讲
|
||||||
|
String AudioTalkV1 = "AudioTalkV1"; // 通道支持语音对讲
|
||||||
|
String VVP2P = "VVP2P"; // 设备支持威威网络P2P服务
|
||||||
|
String DHP2P = "DHP2P"; // 设备支持大华P2P服务
|
||||||
|
String PTZ = "PTZ"; // 设备支持云台方向操作,及云台缩放
|
||||||
|
String PT = "PT"; // 设备支持云台方向操作
|
||||||
|
String PT1 = "PT1"; // 设备支持云台四方向操作
|
||||||
|
String HSEncrypt = "HSEncrypt"; // 设备支持华视微讯码流加密
|
||||||
|
String CloudStorage = "CloudStorage"; // 设备支持华视微讯平台云存储
|
||||||
|
String CloudUpdate = "CloudUpdate"; // easy4ip支持云升级,自己本地判断使用
|
||||||
|
String AGW = "AGW"; // 设备支持网关功能
|
||||||
|
String BreathingLight = "BreathingLight"; // 设备有呼吸灯
|
||||||
|
String PlaybackByFilename = "PlaybackByFilename"; // 设备支持根据文件名回放
|
||||||
|
String LocalStorage = "LocalStorage"; // 支持设备本地存储,如有SD卡或硬盘
|
||||||
|
String RegCode = "RegCode"; // 设备添加需要支持验证码
|
||||||
|
String RemoteControl = "RemoteControl"; // 支持远程联动
|
||||||
|
String Panorama = "Panorama"; //支持全景图
|
||||||
|
String RD = "RD"; //设备具有远程调试能力(Remote Debug)
|
||||||
|
String RDV2 = "RDV2"; //支持RD能力,支持数据埋点控制,支持调试日志上传 对应设备体验计划开关
|
||||||
|
String RDV3 = "RDV3"; //支持RD能力,支持数据埋点控制,支持级别控制
|
||||||
|
String SLAlarm = "SLAlarm"; //设备支持声光告警(sound and light alarm)
|
||||||
|
String CK = "CK"; // 设备视频加密
|
||||||
|
String AudioEncodeOff = "AudioEncodeOff"; //支持音频编码关闭(无伴音) AudioEncode:支持音频编码(伴音) 老设备不上报,因此只需要使用AudioEncodeOff进行判断即可
|
||||||
|
String MDS = "MDS"; //通道 motion-detect-sensitive支持动检灵敏度设置
|
||||||
|
String MDW = "MDW"; //通道 motion-detect-window支持动检窗口设置
|
||||||
|
String HeaderDetect = "HeaderDetect"; //通道 支持人头检测
|
||||||
|
String SR = "SR"; ////设备,设备支持语音识别
|
||||||
|
String AGWDisarm = "AGWDisarm"; // 网关告警解除配置(APP2.8,网关支持布撤防(过滤配件告警,但保留告警配置)功能)
|
||||||
|
String CollectionPoint = "CollectionPoint"; //支持收藏点
|
||||||
|
String TimedCruise = "TimedCruise"; //支持定时巡航
|
||||||
|
String SmartTrack = "SmartTrack"; //智能追踪
|
||||||
|
String ZoomFocus = "ZoomFocus"; //支持变倍聚焦 变焦相机能力集
|
||||||
|
String SmartLocate = "SmartLocate"; //听声辨位
|
||||||
|
String LocalRecord = "LocalRecord"; //支持设备设备录像设置
|
||||||
|
String XUpgrade = "XUpgrade"; // 云升级
|
||||||
|
String Auth = "Auth"; // 设备端环回RTSP需认证
|
||||||
|
String NumberStat = "NumberStat"; // 客流量数据采集
|
||||||
|
String HoveringAlarm = "HoveringAlarm"; //徘徊报警
|
||||||
|
String BeOpenedDoor = "BeOpenedDoor"; //普通开门,即成功开门(K5电池门锁)
|
||||||
|
String NonAccessoriesAdd = "NonAccessoriesAdd"; //表示不支持C端信令添加方式
|
||||||
|
String CloseCamera = "CloseCamera"; //支持关闭摄像头
|
||||||
|
String MobileDetect = "MobileDetect"; //动检+PIR
|
||||||
|
String Siren = "Siren"; //警笛
|
||||||
|
String LinkageSiren = "LinkageSiren"; //报警联动警笛
|
||||||
|
String WhiteLight = "WhiteLight"; //白光灯
|
||||||
|
String WLV2 = "WLV2"; // 白光灯,不支持亮度调节能力
|
||||||
|
String Dormant = "Dormant"; //可休眠,具有唤醒、休眠状态
|
||||||
|
// String NoVA = "NoVA"; //不支持语音播报(Voice Announcements)
|
||||||
|
String NoAccessories = "NoAccessories"; //不支持配件使能(不支持布撤防)
|
||||||
|
String UnsupportLiveShare = "UnsupportLiveShare"; //是否支持直播分享,easy4ip独有, 客户端自己的能力级,相当于控制开关
|
||||||
|
String RTSV1 = "RTSV1";//实时流支持私有协议拉流
|
||||||
|
String PBSV1 = "PBSV1";//回放流支持私有协议拉流
|
||||||
|
String TSV1 = "TSV1"; //对讲支持私有协议拉流
|
||||||
|
String RTSV2 = "RTSV2";//实时流支持私有协议拉流(TLS)
|
||||||
|
String PBSV2 = "PBSV2";//回放流支持私有协议拉流(TLS)
|
||||||
|
String TSV2 = "TSV2"; //对讲支持私有协议拉流(TLS)
|
||||||
|
String TimingGraphics = "TimingGraphics"; //人形录像服务能力
|
||||||
|
String HumanDetect = "HumanDetect"; //人形检测(海外)
|
||||||
|
String AlarmPIRV2 = "AlarmPIRV2"; //支持PIR开关
|
||||||
|
String HUBAlarmPIRV2 = "HUBAlarmPIRV2"; //支持Hub PIR开关
|
||||||
|
String AlarmPIRV3 = "AlarmPIRV3"; //支持PIR扇形区域,同时支持PIR使能开关
|
||||||
|
String AlarmPIRV4 = "AlarmPIRV4"; //支持PIR扇形区域
|
||||||
|
String LocalStorageEnable = "LocalStorageEnable"; //支持录像存储开关
|
||||||
|
String SearchLight = "SearchLight"; //探照灯
|
||||||
|
String CallByRtsp = "CallByRtsp"; //表示接听、挂断可直接基于RTSP协议实现
|
||||||
|
String SirenTime = "SirenTime"; //支持警笛时长设置
|
||||||
|
String NVM = "NVM"; //支持夜视模式设置
|
||||||
|
String LEDS = "LEDS"; //支持补光灯灵敏度
|
||||||
|
String DaySummerTime = "DaySummerTime"; //按日夏令时
|
||||||
|
String WeekSummerTime = "WeekSummerTime";//按周夏令时
|
||||||
|
String SummerTimeOffset = "SummerTimeOffset"; //支持夏令时偏移量设置
|
||||||
|
String TimeFormat = "TimeFormat";//支持时间格式设置
|
||||||
|
String SceneMode = "SceneMode"; //支持布撤防情景模式设置
|
||||||
|
String SIMCA = "SIMCA"; //支持SIM卡相关配置
|
||||||
|
String SASQ = "SASQ";//配件防拆状态能力集
|
||||||
|
String MGOCS = "MGOCS";//支持门磁开关状态获取
|
||||||
|
String ModifyName = "ModifyName";//配件支持修改名称
|
||||||
|
String ElecInfo = "ElecInfo";//支持电量信息查询上报
|
||||||
|
String SigInfo = "SigInfo";//支持信号信息查询上报
|
||||||
|
String ACT = "ACT";//支持报警持续时间配置
|
||||||
|
String AlarmSound = "AlarmSound"; //支持报警音设置
|
||||||
|
String AiHuman = "AiHuman";//人形智能 TF8P
|
||||||
|
String AiCar = "AiCar";//车辆智能 TF8P
|
||||||
|
String Electric = "Electric";//设备支持电池电量能力
|
||||||
|
String WIFI = "WIFI";//设备支持获取WIFI信号强度能力
|
||||||
|
String DLOCS = "DLOCS";//门锁开关状态
|
||||||
|
|
||||||
|
String DDT = "DDT"; //支持布防延时能力
|
||||||
|
String OnlyArmed = "OnlyArmed"; //只支持布防(永久布防)
|
||||||
|
String NoPlan = "NoPlan";//不支持布防计划
|
||||||
|
String OpenDoorByFace = "OpenDoorByFace";//人脸开门
|
||||||
|
String OpenDoorByTouch = "OpenDoorByTouch";// 触摸开门
|
||||||
|
String PlaySoundModify = "PlaySoundModify";// 设备提示音调节能力
|
||||||
|
String TalkSoundModify = "TalkSoundModify";//对讲音量调节
|
||||||
|
String WideDynamic = "WideDynamic";// 宽动态
|
||||||
|
String LinkDevAlarm = "LinkDevAlarm";//关联设备报警
|
||||||
|
String LinkAccDevAlarm = "LinkAccDevAlarm";//关联配件报警
|
||||||
|
String AbAlarmSound = "AbAlarmSound";//异常报警音
|
||||||
|
String CheckAbDecible = "CheckAbDecible";//异常检测音分贝阈值
|
||||||
|
String Reboot = "Reboot";//设备重启
|
||||||
|
String PlaySound = "PlaySound"; //设备提示音开关能力
|
||||||
|
String AudioEncodeControl = "AudioEncodeControl"; //支持音频编码控制(开或关)
|
||||||
|
String AudioEncodeControlV2 = "AudioEncodeControlV2";//支持音频编码控制(开或关),只影响实时视频、录像音频,不影响对讲音频控制
|
||||||
|
String AccessoryAlarmSound = "AccessoryAlarmSound";//支持报警网关配件报警音效设置
|
||||||
|
String DeviceAlarmSound = "DeviceAlarmSound"; //设备报警音效设置
|
||||||
|
String RingAlarmSound = "RingAlarmSound";//支持门铃音量设置
|
||||||
|
String ChnLocalStorage = "ChnLocalStorage";//支持通道本地存储
|
||||||
|
|
||||||
|
String SCCode = "SCCode"; // 设备支持SC安全码
|
||||||
|
String CustomRing = "CustomRing";//自定义铃声
|
||||||
|
String InfraredLight = "InfraredLight";//红外灯能力集
|
||||||
|
String InstantDisAlarm = "InstantDisAlarm";//支持一键撤防能力
|
||||||
|
String IDAP = "IDAP";//支持一键撤防能力
|
||||||
|
String FaceDetect = "FaceDetect"; //支持人脸检测
|
||||||
|
|
||||||
|
String CallAbility = "CallAbility"; //支持呼叫能力
|
||||||
|
String CAV2 = "CAV2"; //支持呼叫能力,且拒接时可选择播放自定义铃声
|
||||||
|
String HAV2 = "HAV2"; //徘徊报警V2,支持统一的检测距离设置及逗留时长设置
|
||||||
|
String Ring = "Ring"; //仅支持铃声设置 LoginAfter DS11,去除根据设备型号兼容逻辑 2019-4-3
|
||||||
|
String AX = "AX"; // 安消一体机
|
||||||
|
String HAV3 = "HAV3"; // 徘徊报警V3,V2降级版,不支持逗留时长立即设置
|
||||||
|
String VideoMotionSMD = "VideoMotionSMD";//包含人形和车辆能力
|
||||||
|
|
||||||
|
/*3.15.0*/
|
||||||
|
String TCM = "TCM"; //支持3码合一(Three code megre)
|
||||||
|
String TLSEnable = "TLSEnable";// 2019-8-20 支持拉流、图片和云录像链路加密传输
|
||||||
|
|
||||||
|
/*5.0.0*/
|
||||||
|
String CLW = "CLW"; //通道报警联动白光灯
|
||||||
|
String CLS = "CLS"; //通道报警联动警笛
|
||||||
|
String CCR = "CCR"; //通道自定义铃声
|
||||||
|
String LED = "LED"; //补光灯
|
||||||
|
String ChnSiren = "ChnSiren"; //警笛
|
||||||
|
String ChnWhiteLight = "ChnWhiteLight"; //通道白光灯
|
||||||
|
String CLDA = "CLDA"; //通道关联设备报警
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package com.mm.android.deviceaddmodule.mobilecommon.annotation;
|
||||||
|
|
||||||
|
import android.support.annotation.StringDef;
|
||||||
|
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
|
||||||
|
import static com.mm.android.deviceaddmodule.mobilecommon.annotation.DeviceState.OFFLINE;
|
||||||
|
import static com.mm.android.deviceaddmodule.mobilecommon.annotation.DeviceState.ONLINE;
|
||||||
|
import static com.mm.android.deviceaddmodule.mobilecommon.annotation.DeviceState.SLEEP;
|
||||||
|
import static com.mm.android.deviceaddmodule.mobilecommon.annotation.DeviceState.UPGRADE;
|
||||||
|
import static java.lang.annotation.RetentionPolicy.SOURCE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备在离线状态枚举值
|
||||||
|
*/
|
||||||
|
@Retention(SOURCE)
|
||||||
|
@StringDef({ONLINE, OFFLINE, SLEEP,UPGRADE, ""})
|
||||||
|
public @interface DeviceState {
|
||||||
|
String ONLINE = "online";
|
||||||
|
String OFFLINE = "offline";
|
||||||
|
String SLEEP = "sleep";
|
||||||
|
String UPGRADE = "upgrading";
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,71 @@
|
||||||
|
package com.mm.android.deviceaddmodule.mobilecommon.base;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
|
||||||
|
import java.util.Stack;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* activity 栈管理
|
||||||
|
* </p>
|
||||||
|
*/
|
||||||
|
public class ActivityManager {
|
||||||
|
private static Stack<Activity> activityStack;
|
||||||
|
|
||||||
|
private static ActivityManager instance;
|
||||||
|
|
||||||
|
private ActivityManager() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ActivityManager getScreenManager() {
|
||||||
|
if (instance == null) {
|
||||||
|
instance = new ActivityManager();
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 退出栈顶Activity
|
||||||
|
public void popActivity(Activity activity) {
|
||||||
|
if (activity != null) {
|
||||||
|
// 在从自定义集合中取出当前Activity时,也进行了Activity的关闭操作
|
||||||
|
//activity.finish();
|
||||||
|
activityStack.remove(activity);
|
||||||
|
activity = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获得当前栈顶Activity
|
||||||
|
public Activity currentActivity() {
|
||||||
|
Activity activity = null;
|
||||||
|
try{
|
||||||
|
if (activityStack != null && !activityStack.empty()){
|
||||||
|
activity = activityStack.lastElement();
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
return activity;
|
||||||
|
}
|
||||||
|
return activity;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 将当前Activity推入栈中
|
||||||
|
public void pushActivity(Activity activity) {
|
||||||
|
if (activityStack == null) {
|
||||||
|
activityStack = new Stack<>();
|
||||||
|
}
|
||||||
|
activityStack.add(activity);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 退出栈中所有Activity
|
||||||
|
public void popAllActivityExceptOne(Class cls) {
|
||||||
|
while (true) {
|
||||||
|
Activity activity = currentActivity();
|
||||||
|
if (activity == null) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (activity.getClass().equals(cls)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
popActivity(activity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,190 @@
|
||||||
|
package com.mm.android.deviceaddmodule.mobilecommon.base;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.app.ProgressDialog;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.res.Resources;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.CallSuper;
|
||||||
|
import android.view.Gravity;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.mm.android.deviceaddmodule.R;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.eventbus.event.BaseEvent;
|
||||||
|
import com.mm.android.deviceaddmodule.mobilecommon.utils.LogUtil;
|
||||||
|
|
||||||
|
import org.greenrobot.eventbus.EventBus;
|
||||||
|
import org.greenrobot.eventbus.Subscribe;
|
||||||
|
import org.greenrobot.eventbus.ThreadMode;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class BaseActivity extends Activity implements IActivityResultDispatch {
|
||||||
|
|
||||||
|
private Toast mToast;
|
||||||
|
private ProgressDialog mProgressDialog;
|
||||||
|
private boolean isDestroyed = false;
|
||||||
|
|
||||||
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
|
public void onMessageEvent(BaseEvent event) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle arg0) {
|
||||||
|
super.onCreate(arg0);
|
||||||
|
if (!EventBus.getDefault().isRegistered(this)) EventBus.getDefault().register(this);
|
||||||
|
mProgressDialog = new ProgressDialog(this, R.style.mobile_common_custom_dialog);
|
||||||
|
mProgressDialog.setCanceledOnTouchOutside(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
|
||||||
|
dissmissProgressDialog();
|
||||||
|
isDestroyed = true;
|
||||||
|
mProgressDialog = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void showProgressDialog(int layoutId) {
|
||||||
|
if (mProgressDialog != null && !mProgressDialog.isShowing()) {
|
||||||
|
mProgressDialog.show();
|
||||||
|
mProgressDialog.setContentView(layoutId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void dissmissProgressDialog() {
|
||||||
|
if (mProgressDialog != null && mProgressDialog.isShowing()) {
|
||||||
|
mProgressDialog.dismiss();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isActivityDestory() {
|
||||||
|
return isDestroyed;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void toast(int res) {
|
||||||
|
String content = "";
|
||||||
|
try {
|
||||||
|
content = getString(res);
|
||||||
|
} catch (Resources.NotFoundException e) {
|
||||||
|
LogUtil.debugLog("toast", "resource id not found!!!");
|
||||||
|
}
|
||||||
|
|
||||||
|
toast(content);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void toast(String content) {
|
||||||
|
if (mToast == null) {
|
||||||
|
mToast = Toast.makeText(this, content, Toast.LENGTH_SHORT);
|
||||||
|
} else {
|
||||||
|
mToast.setText(content);
|
||||||
|
mToast.setDuration(Toast.LENGTH_SHORT);
|
||||||
|
}
|
||||||
|
mToast.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 带错误码的toast
|
||||||
|
*
|
||||||
|
* @param errorCode
|
||||||
|
*/
|
||||||
|
public void toast(int res, int errorCode) {
|
||||||
|
if (mToast == null) {
|
||||||
|
mToast = Toast.makeText(this, getString(res) + "(" + errorCode + ")",
|
||||||
|
Toast.LENGTH_SHORT);
|
||||||
|
} else {
|
||||||
|
mToast.setText(getString(res) + "(" + errorCode + ")");
|
||||||
|
}
|
||||||
|
mToast.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected void toastInCenter(int res) {
|
||||||
|
String content = "";
|
||||||
|
try {
|
||||||
|
content = getString(res);
|
||||||
|
} catch (Resources.NotFoundException e) {
|
||||||
|
LogUtil.debugLog("toast", "resource id not found!!!");
|
||||||
|
}
|
||||||
|
toastInCenter(content);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void toastInCenter(String content) {
|
||||||
|
if (mToast == null) {
|
||||||
|
mToast = Toast.makeText(this, content, Toast.LENGTH_SHORT);
|
||||||
|
mToast.setGravity(Gravity.CENTER, 0, 0);
|
||||||
|
TextView tv = mToast.getView().findViewById(android.R.id.message);
|
||||||
|
tv.setGravity(Gravity.CENTER);
|
||||||
|
} else {
|
||||||
|
mToast.setText(content);
|
||||||
|
mToast.setDuration(Toast.LENGTH_SHORT);
|
||||||
|
}
|
||||||
|
mToast.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void startActivity(Intent intent) {
|
||||||
|
super.startActivity(intent);
|
||||||
|
overridePendingTransition(R.anim.mobile_common_slide_in_right, R.anim.mobile_common_slide_out_left);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void startActivityNoAnimation(Intent intent) {
|
||||||
|
super.startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void startActivityForResult(Intent intent, int requestCode) {
|
||||||
|
super.startActivityForResult(intent, requestCode);
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
public void startActivityForResultWithAnimation(Intent intent, int requestCode) {
|
||||||
|
super.startActivityForResult(intent, requestCode);
|
||||||
|
overridePendingTransition(R.anim.mobile_common_slide_in_right, R.anim.mobile_common_slide_out_left);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void finish() {
|
||||||
|
|
||||||
|
super.finish();
|
||||||
|
overridePendingTransition(R.anim.mobile_common_slide_left_back_in
|
||||||
|
, R.anim.mobile_common_slide_right_back_out);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void finishNoAnimation() {
|
||||||
|
super.finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@CallSuper
|
||||||
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
if (listeners == null) return;
|
||||||
|
synchronized (listeners) {
|
||||||
|
for (OnActivityResultListener listener : listeners) {
|
||||||
|
if (listener != null) {
|
||||||
|
listener.onActivityResult(requestCode, resultCode, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final List<IActivityResultDispatch.OnActivityResultListener> listeners = new ArrayList<>();
|
||||||
|
|
||||||
|
public void addOnActivityResultListener(IActivityResultDispatch.OnActivityResultListener listener) {
|
||||||
|
listeners.add(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeOnActivityResultListener(IActivityResultDispatch.OnActivityResultListener listener) {
|
||||||
|
if (listener != null) {
|
||||||
|
listeners.remove(listener);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue