Skip to content

Commit e0527c9

Browse files
author
xiaoliang0227
committed
add new project modouapi-android
1 parent 86f4dcb commit e0527c9

File tree

447 files changed

+7266
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

447 files changed

+7266
-0
lines changed

ModouDemo.iml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
3+
<component name="FacetManager">
4+
<facet type="java-gradle" name="Java-Gradle">
5+
<configuration>
6+
<option name="BUILD_FOLDER_PATH" value="$MODULE_DIR$/build" />
7+
</configuration>
8+
</facet>
9+
</component>
10+
<component name="NewModuleRootManager" inherit-compiler-output="true">
11+
<exclude-output />
12+
<content url="file://$MODULE_DIR$">
13+
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
14+
</content>
15+
<orderEntry type="jdk" jdkName="JDK" jdkType="JavaSDK" />
16+
<orderEntry type="sourceFolder" forTests="false" />
17+
</component>
18+
</module>
19+

app/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/app.iml

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="ModouDemo" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
3+
<component name="FacetManager">
4+
<facet type="android-gradle" name="Android-Gradle">
5+
<configuration>
6+
<option name="GRADLE_PROJECT_PATH" value=":app" />
7+
</configuration>
8+
</facet>
9+
<facet type="android" name="Android">
10+
<configuration>
11+
<option name="SELECTED_BUILD_VARIANT" value="debug" />
12+
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
13+
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugJava" />
14+
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugTest" />
15+
<option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" />
16+
<option name="ALLOW_USER_CONFIGURATION" value="false" />
17+
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
18+
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
19+
<option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res" />
20+
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
21+
</configuration>
22+
</facet>
23+
</component>
24+
<component name="NewModuleRootManager" inherit-compiler-output="false">
25+
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
26+
<exclude-output />
27+
<content url="file://$MODULE_DIR$">
28+
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
29+
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" />
30+
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
31+
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
32+
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
33+
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/test/debug" isTestSource="true" generated="true" />
34+
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/test/debug" isTestSource="true" generated="true" />
35+
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/test/debug" isTestSource="true" generated="true" />
36+
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/test/debug" isTestSource="true" generated="true" />
37+
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/test/debug" type="java-test-resource" />
38+
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
39+
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
40+
<sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />
41+
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" isTestSource="false" />
42+
<sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
43+
<sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" />
44+
<sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
45+
<sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
46+
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
47+
<sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
48+
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" isTestSource="false" />
49+
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
50+
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
51+
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
52+
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
53+
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
54+
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
55+
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" isTestSource="true" />
56+
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
57+
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
58+
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
59+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates" />
60+
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
61+
</content>
62+
<orderEntry type="jdk" jdkName="Android API 20 Platform" jdkType="Android SDK" />
63+
<orderEntry type="sourceFolder" forTests="false" />
64+
<orderEntry type="library" exported="" name="appcompat-v7-19.1.0" level="project" />
65+
<orderEntry type="library" exported="" name="support-v4-19.1.0" level="project" />
66+
</component>
67+
</module>
68+

app/build.gradle

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 20
5+
buildToolsVersion "20.0.0"
6+
7+
defaultConfig {
8+
applicationId "com.modou.demo"
9+
minSdkVersion 8
10+
targetSdkVersion 20
11+
versionCode 1
12+
versionName "1.0"
13+
}
14+
buildTypes {
15+
release {
16+
runProguard false
17+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18+
}
19+
}
20+
}
21+
22+
dependencies {
23+
compile fileTree(dir: 'libs', include: ['*.jar'])
24+
compile 'com.android.support:appcompat-v7:19.+'
25+
}

app/proguard-rules.pro

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Add project specific ProGuard rules here.
2+
# By default, the flags in this file are appended to flags specified
3+
# in /Users/JasonZhao/tools/android_sdks/sdk/tools/proguard/proguard-android.txt
4+
# You can edit the include path and order by changing the proguardFiles
5+
# directive in build.gradle.
6+
#
7+
# For more details, see
8+
# http://developer.android.com/guide/developing/tools/proguard.html
9+
10+
# Add any project specific keep options here:
11+
12+
# If your project uses WebView with JS, uncomment the following
13+
# and specify the fully qualified class name to the JavaScript interface
14+
# class:
15+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16+
# public *;
17+
#}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.modou.demo;
2+
3+
import android.app.Application;
4+
import android.test.ApplicationTestCase;
5+
6+
/**
7+
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
8+
*/
9+
public class ApplicationTest extends ApplicationTestCase<Application> {
10+
public ApplicationTest() {
11+
super(Application.class);
12+
}
13+
}

app/src/main/AndroidManifest.xml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.modou.demo">
4+
5+
<uses-permission android:name="android.permission.INTERNET"/>
6+
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
7+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
8+
9+
<application
10+
android:allowBackup="true"
11+
android:icon="@drawable/ic_launcher"
12+
android:label="@string/app_name"
13+
android:theme="@style/AppTheme">
14+
<activity
15+
android:name=".MainActivity"
16+
android:screenOrientation="portrait"
17+
android:label="@string/app_name">
18+
<intent-filter>
19+
<action android:name="android.intent.action.MAIN"/>
20+
21+
<category android:name="android.intent.category.LAUNCHER"/>
22+
</intent-filter>
23+
</activity>
24+
<activity
25+
android:name=".ContentActivity"
26+
android:screenOrientation="portrait"/>
27+
</application>
28+
29+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package com.modou.demo;
2+
3+
import android.app.Activity;
4+
import android.content.Context;
5+
import android.os.Bundle;
6+
import android.view.View;
7+
import android.widget.TextView;
8+
9+
import com.modou.demo.model.WifiInfo2G;
10+
import com.modou.demo.model.WifiInfo5G;
11+
import com.modou.demo.task.ModouWifiInfoGetTask;
12+
13+
/**
14+
* Created by JasonZhao on 7/9/14.
15+
*/
16+
public class ContentActivity extends Activity {
17+
18+
private Context context;
19+
20+
private TextView display;
21+
22+
@Override
23+
protected void onCreate(Bundle savedInstanceState) {
24+
super.onCreate(savedInstanceState);
25+
setContentView(R.layout.activity_content);
26+
init();
27+
}
28+
29+
private void init() {
30+
initField();
31+
}
32+
33+
private void initField() {
34+
context = this;
35+
display = (TextView) findViewById(R.id.display);
36+
}
37+
38+
39+
public void queryWifi(View view) {
40+
ModouWifiInfoGetTask task = new ModouWifiInfoGetTask(context);
41+
task.execute();
42+
}
43+
44+
public void showWifiInfo(WifiInfo2G info2G, WifiInfo5G info5G) {
45+
StringBuilder sb = new StringBuilder();
46+
sb.append("2G ssid:").append(info2G.getSsid()).append("\n");
47+
sb.append("5G ssid:").append(info5G.getSsid()).append("\n");
48+
display.setText(sb.toString());
49+
}
50+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
package com.modou.demo;
2+
3+
import android.app.Activity;
4+
import android.content.Context;
5+
import android.os.Bundle;
6+
import android.text.TextUtils;
7+
import android.view.View;
8+
import android.widget.EditText;
9+
import android.widget.ProgressBar;
10+
import android.widget.TextView;
11+
12+
import com.modou.demo.task.ModouConnectRouterTask;
13+
import com.modou.demo.task.RouterDiscoverTask;
14+
import com.modou.demo.util.CommonUtil;
15+
import com.modou.demo.util.MessageCenter;
16+
17+
/**
18+
*
19+
*/
20+
public class MainActivity extends Activity {
21+
22+
private Context context;
23+
24+
private ProgressBar disLoa;
25+
26+
private TextView disRes;
27+
28+
private EditText gateway;
29+
30+
private EditText loginUsername;
31+
32+
private EditText loginPass;
33+
34+
public ProgressBar getDisLoa() {
35+
return disLoa;
36+
}
37+
38+
@Override
39+
protected void onCreate(Bundle savedInstanceState) {
40+
super.onCreate(savedInstanceState);
41+
setContentView(R.layout.activity_main);
42+
init();
43+
}
44+
45+
private void init() {
46+
initField();
47+
}
48+
49+
@Override
50+
protected void onResume() {
51+
super.onResume();
52+
RouterDiscoverTask task = new RouterDiscoverTask(context);
53+
task.execute();
54+
}
55+
56+
private void initField() {
57+
context = this;
58+
disLoa = (ProgressBar) findViewById(R.id.loading_discovery);
59+
disRes = (TextView) findViewById(R.id.result_discovery);
60+
gateway = (EditText) findViewById(R.id.gateway);
61+
loginUsername = (EditText) findViewById(R.id.login_username);
62+
loginPass = (EditText) findViewById(R.id.login_pass);
63+
MessageCenter.initInstance();
64+
}
65+
66+
public void doLogin(View view) {
67+
if (submitCheck()) {
68+
ModouConnectRouterTask task = new ModouConnectRouterTask(context);
69+
task.setRouterName(loginUsername.getText().toString());
70+
task.setRouterPassword(loginPass.getText().toString());
71+
task.execute();
72+
}
73+
}
74+
75+
76+
private boolean submitCheck() {
77+
if (TextUtils.isEmpty(gateway.getText())) {
78+
CommonUtil.showToast(context, "网关地址不可为空");
79+
return false;
80+
}
81+
if (TextUtils.isEmpty(loginUsername.getText())) {
82+
CommonUtil.showToast(context, "管理用户名不可为空");
83+
return false;
84+
}
85+
if (TextUtils.isEmpty(loginPass.getText())) {
86+
CommonUtil.showToast(context, "管理密码不可为空");
87+
return false;
88+
}
89+
return true;
90+
}
91+
public void updateDiscoveryResult(Boolean result) {
92+
disRes.setText(result ? "发现1台魔豆路由器" : "发现0台魔豆路由器");
93+
gateway.setText(result ? CommonUtil.getGateway(context) : "");
94+
loginUsername.setText(result ? "matrix" : "");
95+
if (!result) {
96+
CommonUtil.showToast(context, "没有连接wifi或者没有连接魔豆路由器");
97+
}
98+
}
99+
}

0 commit comments

Comments
 (0)