├── app
├── .gitignore
├── libs
│ ├── mid-sdk-2.20.jar
│ ├── jg_filter_sdk_1.1.jar
│ ├── wup-1.0.0-SNAPSHOT.jar
│ ├── armeabi
│ │ ├── libtpnsSecurity.so
│ │ └── libtpnsWatchdog.so
│ └── Xg_sdk_v2.39_20150915_1121.jar
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── Thumbs.db
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ ├── Thumbs.db
│ │ │ │ └── ic_launcher.png
│ │ │ ├── drawable-hdpi
│ │ │ │ ├── Thumbs.db
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── ic_head_back.png
│ │ │ │ ├── ic_head_more.png
│ │ │ │ ├── popupwindow_donate.png
│ │ │ │ ├── popupwindow_logout.png
│ │ │ │ ├── popupwindow_update.png
│ │ │ │ └── popupwindow_setting.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── Thumbs.db
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── Thumbs.db
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── Thumbs.db
│ │ │ │ └── ic_launcher.png
│ │ │ ├── drawable
│ │ │ │ ├── bg_view_frame.xml
│ │ │ │ ├── bg_view_frame_green.xml
│ │ │ │ ├── bg_view_frame_red.xml
│ │ │ │ ├── bg_button_no_shape.xml
│ │ │ │ ├── bg_button_main.xml
│ │ │ │ ├── bg_button_main_dialing.xml
│ │ │ │ ├── bg_button_main_dial_error.xml
│ │ │ │ └── bg_button_main_dial_success.xml
│ │ │ ├── values
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── colors.xml
│ │ │ │ ├── strings.xml
│ │ │ │ └── styles.xml
│ │ │ ├── values-v21
│ │ │ │ └── styles.xml
│ │ │ ├── values-w820dp
│ │ │ │ └── dimens.xml
│ │ │ └── layout
│ │ │ │ ├── notification_heart.xml
│ │ │ │ ├── doalog_notice.xml
│ │ │ │ ├── layout_header.xml
│ │ │ │ ├── doalog_update.xml
│ │ │ │ ├── doalog_router_set.xml
│ │ │ │ ├── doalog_exit.xml
│ │ │ │ ├── popupwindow_setting.xml
│ │ │ │ ├── doalog_pay.xml
│ │ │ │ └── activity_main.xml
│ │ ├── jniLibs
│ │ │ └── armeabi
│ │ │ │ ├── libtpnsSecurity.so
│ │ │ │ └── libtpnsWatchdog.so
│ │ ├── java
│ │ │ └── cn
│ │ │ │ └── mandroid
│ │ │ │ └── wtshanxun
│ │ │ │ ├── event
│ │ │ │ ├── ExitApp.java
│ │ │ │ ├── StopHeartEvent.java
│ │ │ │ ├── TotalEvent.java
│ │ │ │ ├── GetUserEvent.java
│ │ │ │ └── CheckCallBackEvent.java
│ │ │ │ ├── Model
│ │ │ │ ├── FetchCallback.java
│ │ │ │ ├── Bean
│ │ │ │ │ ├── BasicBean.java
│ │ │ │ │ ├── UserBean.java
│ │ │ │ │ └── BeanManager.java
│ │ │ │ ├── UserManager.java
│ │ │ │ ├── ApiManager.java
│ │ │ │ ├── HeartManager.java
│ │ │ │ └── ShanxunManager.java
│ │ │ │ ├── UI
│ │ │ │ ├── dialog
│ │ │ │ │ ├── SuperDialog.java
│ │ │ │ │ ├── NoticeDialog.java
│ │ │ │ │ ├── ExitDialog.java
│ │ │ │ │ ├── RouterSetDialog.java
│ │ │ │ │ └── UpdateDialog.java
│ │ │ │ ├── common
│ │ │ │ │ ├── App.java
│ │ │ │ │ ├── BasicActivity.java
│ │ │ │ │ └── PopupWindowClick.java
│ │ │ │ ├── widget
│ │ │ │ │ ├── AlwaysMarqueeTextView.java
│ │ │ │ │ ├── MyProgressBar.java
│ │ │ │ │ └── ActionBar.java
│ │ │ │ ├── Service
│ │ │ │ │ └── HeartService.java
│ │ │ │ └── activity
│ │ │ │ │ └── MainActivity.java
│ │ │ │ └── utils
│ │ │ │ ├── MToast.java
│ │ │ │ ├── Constant.java
│ │ │ │ ├── Sto16.java
│ │ │ │ ├── MLog.java
│ │ │ │ ├── MD5.java
│ │ │ │ ├── Const.java
│ │ │ │ ├── Udp.java
│ │ │ │ ├── PreferenceHelper.java
│ │ │ │ ├── Preference.java
│ │ │ │ ├── Pin.java
│ │ │ │ ├── Tools.java
│ │ │ │ ├── Base64.java
│ │ │ │ └── CheckUtils.java
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── cn
│ │ │ └── mandroid
│ │ │ └── wtshanxun
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── cn
│ │ └── mandroid
│ │ └── wtshanxun
│ │ └── ApplicationTest.java
├── proguard-rules.pro
└── build.gradle
├── settings.gradle
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── README.md
├── gradle.properties
├── sx.iml
├── wtshanxun.iml
├── gradlew.bat
├── gradlew
└── LICENSE
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/app/libs/mid-sdk-2.20.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WrBug/wtshanxun/HEAD/app/libs/mid-sdk-2.20.jar
--------------------------------------------------------------------------------
/app/libs/jg_filter_sdk_1.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WrBug/wtshanxun/HEAD/app/libs/jg_filter_sdk_1.1.jar
--------------------------------------------------------------------------------
/app/libs/wup-1.0.0-SNAPSHOT.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WrBug/wtshanxun/HEAD/app/libs/wup-1.0.0-SNAPSHOT.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WrBug/wtshanxun/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/libs/armeabi/libtpnsSecurity.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WrBug/wtshanxun/HEAD/app/libs/armeabi/libtpnsSecurity.so
--------------------------------------------------------------------------------
/app/libs/armeabi/libtpnsWatchdog.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WrBug/wtshanxun/HEAD/app/libs/armeabi/libtpnsWatchdog.so
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/Thumbs.db:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WrBug/wtshanxun/HEAD/app/src/main/res/mipmap-hdpi/Thumbs.db
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/Thumbs.db:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WrBug/wtshanxun/HEAD/app/src/main/res/mipmap-mdpi/Thumbs.db
--------------------------------------------------------------------------------
/app/libs/Xg_sdk_v2.39_20150915_1121.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WrBug/wtshanxun/HEAD/app/libs/Xg_sdk_v2.39_20150915_1121.jar
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/Thumbs.db:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WrBug/wtshanxun/HEAD/app/src/main/res/drawable-hdpi/Thumbs.db
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/Thumbs.db:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WrBug/wtshanxun/HEAD/app/src/main/res/mipmap-xhdpi/Thumbs.db
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/Thumbs.db:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WrBug/wtshanxun/HEAD/app/src/main/res/mipmap-xxhdpi/Thumbs.db
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/Thumbs.db:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WrBug/wtshanxun/HEAD/app/src/main/res/mipmap-xxxhdpi/Thumbs.db
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WrBug/wtshanxun/HEAD/app/src/main/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WrBug/wtshanxun/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WrBug/wtshanxun/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WrBug/wtshanxun/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WrBug/wtshanxun/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/jniLibs/armeabi/libtpnsSecurity.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WrBug/wtshanxun/HEAD/app/src/main/jniLibs/armeabi/libtpnsSecurity.so
--------------------------------------------------------------------------------
/app/src/main/jniLibs/armeabi/libtpnsWatchdog.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WrBug/wtshanxun/HEAD/app/src/main/jniLibs/armeabi/libtpnsWatchdog.so
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_head_back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WrBug/wtshanxun/HEAD/app/src/main/res/drawable-hdpi/ic_head_back.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_head_more.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WrBug/wtshanxun/HEAD/app/src/main/res/drawable-hdpi/ic_head_more.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WrBug/wtshanxun/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/popupwindow_donate.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WrBug/wtshanxun/HEAD/app/src/main/res/drawable-hdpi/popupwindow_donate.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/popupwindow_logout.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WrBug/wtshanxun/HEAD/app/src/main/res/drawable-hdpi/popupwindow_logout.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/popupwindow_update.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WrBug/wtshanxun/HEAD/app/src/main/res/drawable-hdpi/popupwindow_update.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/popupwindow_setting.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WrBug/wtshanxun/HEAD/app/src/main/res/drawable-hdpi/popupwindow_setting.png
--------------------------------------------------------------------------------
/app/src/main/java/cn/mandroid/wtshanxun/event/ExitApp.java:
--------------------------------------------------------------------------------
1 | package cn.mandroid.wtshanxun.event;
2 |
3 | /**
4 | * Created by Administrator on 2015-11-22.
5 | */
6 | public class ExitApp {
7 | }
8 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | /local.properties
3 | /.idea/workspace.xml
4 | /.idea/libraries
5 | .DS_Store
6 | /build
7 | /captures
8 | app/app-release.apk
9 | app/app-release/
10 | /app/*.iml
11 | .idea/
--------------------------------------------------------------------------------
/app/src/main/java/cn/mandroid/wtshanxun/event/StopHeartEvent.java:
--------------------------------------------------------------------------------
1 | package cn.mandroid.wtshanxun.event;
2 |
3 | /**
4 | * Created by Administrator on 2015-11-24.
5 | */
6 | public class StopHeartEvent {
7 | }
8 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/mandroid/wtshanxun/Model/FetchCallback.java:
--------------------------------------------------------------------------------
1 | package cn.mandroid.wtshanxun.Model;
2 |
3 | /**
4 | * Created by Administrator on 2015-11-22.
5 | */
6 | public interface FetchCallback {
7 | public void get(String result);
8 | public void error();
9 | }
10 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sun Nov 22 17:45:21 CST 2015
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_view_frame.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 | 16dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_view_frame_green.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_view_frame_red.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 | >
2 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/test/java/cn/mandroid/wtshanxun/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package cn.mandroid.wtshanxun;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/app/src/main/java/cn/mandroid/wtshanxun/event/TotalEvent.java:
--------------------------------------------------------------------------------
1 | package cn.mandroid.wtshanxun.event;
2 |
3 | /**
4 | * Created by Administrator on 2015-11-26.
5 | */
6 | public class TotalEvent {
7 | public int getSendHeartCount() {
8 | return sendHeartCount;
9 | }
10 |
11 | public void setSendHeartCount() {
12 | sendHeartCount++;
13 | }
14 |
15 | private static int sendHeartCount;
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/cn/mandroid/wtshanxun/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package cn.mandroid.wtshanxun;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/app/src/main/java/cn/mandroid/wtshanxun/event/GetUserEvent.java:
--------------------------------------------------------------------------------
1 | package cn.mandroid.wtshanxun.event;
2 |
3 | import cn.mandroid.wtshanxun.Model.Bean.UserBean;
4 |
5 | /**
6 | * Created by Administrator on 2015-11-22.
7 | */
8 | public class GetUserEvent {
9 | public UserBean getUserBean() {
10 | return userBean;
11 | }
12 |
13 | private UserBean userBean;
14 | public GetUserEvent(UserBean userBean) {
15 | this.userBean=userBean;
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/mandroid/wtshanxun/UI/dialog/SuperDialog.java:
--------------------------------------------------------------------------------
1 | package cn.mandroid.wtshanxun.UI.dialog;
2 |
3 | import android.app.Dialog;
4 | import android.content.Context;
5 | import android.view.WindowManager;
6 |
7 | /**
8 | * Created by Administrator on 2015-10-21.
9 | */
10 | public class SuperDialog extends Dialog {
11 | public SuperDialog(Context context, int theme) {
12 | super(context, theme);
13 | getWindow().setType(WindowManager.LayoutParams.TYPE_TOAST);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/mandroid/wtshanxun/UI/common/App.java:
--------------------------------------------------------------------------------
1 | package cn.mandroid.wtshanxun.UI.common;
2 |
3 | import android.app.Application;
4 |
5 | import com.pgyersdk.crash.PgyCrashManager;
6 |
7 | import org.androidannotations.annotations.EApplication;
8 |
9 |
10 | /**
11 | * Created by Administrator on 2015-11-22.
12 | */
13 | @EApplication
14 | public class App extends Application{
15 | @Override
16 | public void onCreate() {
17 | super.onCreate();
18 | PgyCrashManager.register(this);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 | #313030
7 | #101010
8 | #43AA76
9 | #ff1111
10 | #339933
11 | #313030
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/mandroid/wtshanxun/utils/MToast.java:
--------------------------------------------------------------------------------
1 | package cn.mandroid.wtshanxun.utils;
2 |
3 | import android.content.Context;
4 | import android.os.Handler;
5 | import android.os.Message;
6 | import android.widget.Toast;
7 |
8 | public class MToast {
9 | public static void show(Context context, String toast) {
10 | Toast.makeText(context, toast, Toast.LENGTH_SHORT).show();
11 | }
12 |
13 | public static void showError(Context context, int status) {
14 |
15 | }
16 | public static void showError(Context context, String msg) {
17 | show(context, msg);
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | 闪讯WIFI助手
3 | 仅需支付49元,即可获得VIP身份,永久使用本软件\n使用淘宝支付的在支付成功后请联系店家开通VIP\n支付成功后需要重新登录账号才能使用VIP特权
4 | application/x-www-form-urlencoded
5 | Mozilla/5.0 (Windows NT 10.0; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0
6 | text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
7 | zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3
8 | gzip, deflate
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/mandroid/wtshanxun/utils/Constant.java:
--------------------------------------------------------------------------------
1 | package cn.mandroid.wtshanxun.utils;
2 |
3 | /**
4 | * Created by Administrator on 2015-11-15.
5 | */
6 | public class Constant {
7 | // public static String API_URL = "http://qq75376632.vicp.cc:18409/index.php";
8 | public static String API_URL = "http://sx.mandroid.cn/index.php";
9 |
10 | public static int SUCCESS = 1;
11 | public static int CREATE_USER = 1001;
12 | public static int MOVE_OLD_USER = 1002;
13 | public static int ERROR_SESSION = 1003;
14 | public static String DEVICES_IP;
15 | public static class Code {
16 | public static int SUCCESS = 1;
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # wtshanxun
2 | #豌豆荚地址:
3 | http://www.wandoujia.com/apps/cn.mandroid.wtshanxun
4 | #心跳接口:
5 | ## request
6 | Url: http://sx.mandroid.cn/index.php/heart/getByRouter
7 |
8 | Method: POST/GET
9 |
10 | Query:
11 | user=[闪讯账号]
12 |
13 | ip=[IP地址]
14 |
15 | 示例:http://sx.mandroid.cn/index.php/heart/getByRouter?user=123456@ABC.XY&ip=192.168.1.1
16 | ## response:
17 | {
18 | "status": 200,
19 | "data": {
20 | "packData": "U04AYwOCQpY85mPaVnecguWKlDde4wIAB8CoAQEDAAwxLjIuMTguMjgUACNiNTcyYjI1NjEwODA4ZGE1N2QyY2Y0YWEyMGViZmE2ORIAB1br6zcBABAxMjM0NTZAQUJDLlhZ", //base64encode
21 | "sendIp": "115.239.134.167",
22 | "sendPort": 8080
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_button_no_shape.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 |
6 |
7 |
8 |
9 |
10 | />
11 |
12 |
13 | -
14 |
15 |
16 |
17 |
18 |
19 | />
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/mandroid/wtshanxun/Model/Bean/BasicBean.java:
--------------------------------------------------------------------------------
1 | package cn.mandroid.wtshanxun.Model.Bean;
2 |
3 | /**
4 | * Created by Administrator on 2015-11-22.
5 | */
6 | public class BasicBean {
7 | private int status;
8 | private String msg;
9 |
10 | public String getData() {
11 | return data.toString();
12 | }
13 |
14 | public void setData(Object data) {
15 | this.data = data;
16 | }
17 |
18 | public int getStatus() {
19 | return status;
20 | }
21 |
22 | public void setStatus(int status) {
23 | this.status = status;
24 | }
25 |
26 | public String getMsg() {
27 | return msg;
28 | }
29 |
30 | public void setMsg(String msg) {
31 | this.msg = msg;
32 | }
33 |
34 | private Object data;
35 | }
36 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/mandroid/wtshanxun/utils/Sto16.java:
--------------------------------------------------------------------------------
1 | package cn.mandroid.wtshanxun.utils;
2 |
3 | public class Sto16 {
4 | public static String bin2hex(String bin) {
5 | char[] digital = "0123456789ABCDEF".toCharArray();
6 | StringBuffer sb = new StringBuffer("");
7 | byte[] bs = bin.getBytes();
8 | int bit;
9 | for (int i = 0; i < bs.length; i++) {
10 | sb.append('%');
11 | bit = (bs[i] & 0x0f0) >> 4;
12 | sb.append(digital[bit]);
13 | bit = bs[i] & 0x0f;
14 | sb.append(digital[bit]);
15 | }
16 | String res = sb.toString();
17 | String a = "%58%59";
18 | int index = res.lastIndexOf(a);
19 | res = res.substring(0, index) + a;
20 | return res;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/mandroid/wtshanxun/event/CheckCallBackEvent.java:
--------------------------------------------------------------------------------
1 | package cn.mandroid.wtshanxun.event;
2 |
3 | /**
4 | * Created by Administrator on 2015-11-23.
5 | */
6 | public class CheckCallBackEvent {
7 | public final static int CHECK_NETWORK_VALID=1;
8 | private boolean isSuccess;
9 |
10 | public CheckCallBackEvent(boolean isSuccess, int action) {
11 | this.isSuccess = isSuccess;
12 | this.action = action;
13 | }
14 |
15 | public boolean isSuccess() {
16 | return isSuccess;
17 | }
18 |
19 | public void setIsSuccess(boolean isSuccess) {
20 | this.isSuccess = isSuccess;
21 | }
22 |
23 | public int getAction() {
24 | return action;
25 | }
26 |
27 | public void setAction(int action) {
28 | this.action = action;
29 | }
30 |
31 | private int action;
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_button_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | -
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_button_main_dialing.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | -
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_button_main_dial_error.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | -
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_button_main_dial_success.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | -
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/app/src/main/java/cn/mandroid/wtshanxun/utils/MLog.java:
--------------------------------------------------------------------------------
1 | package cn.mandroid.wtshanxun.utils;
2 |
3 | import android.content.BroadcastReceiver;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.util.Log;
7 |
8 | public class MLog {
9 | private static boolean display = false;
10 | public static void i(Object log) {
11 | if (display) {
12 | Log.i(Const.LOG_TAG, log + "");
13 | }
14 |
15 | }
16 | public static void v(String log) {
17 | if (display) {
18 | Log.v(Const.LOG_TAG, log);
19 | }
20 |
21 | }
22 |
23 | public static void d(String log) {
24 | if (display) {
25 | Log.d(Const.LOG_TAG, log);
26 | }
27 |
28 | }
29 |
30 | public static void e(String log) {
31 | if (display) {
32 | Log.e(Const.LOG_TAG, log);
33 | }
34 |
35 | }
36 |
37 | public static void w(String log) {
38 | if (display) {
39 | Log.w(Const.LOG_TAG, log);
40 | }
41 |
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/mandroid/wtshanxun/utils/MD5.java:
--------------------------------------------------------------------------------
1 | package cn.mandroid.wtshanxun.utils;
2 |
3 | import java.io.UnsupportedEncodingException;
4 | import java.security.MessageDigest;
5 | import java.security.NoSuchAlgorithmException;
6 |
7 | public class MD5 {
8 | public static String encode(String string) {
9 | byte[] hash;
10 | try {
11 | hash = MessageDigest.getInstance("MD5").digest(string.getBytes("UTF-8"));
12 | } catch (NoSuchAlgorithmException e) {
13 | throw new RuntimeException("Huh, MD5 should be supported?", e);
14 | } catch (UnsupportedEncodingException e) {
15 | throw new RuntimeException("Huh, UTF-8 should be supported?", e);
16 | }
17 |
18 | StringBuilder hex = new StringBuilder(hash.length * 2);
19 | for (byte b : hash) {
20 | if ((b & 0xFF) < 0x10) hex.append("0");
21 | hex.append(Integer.toHexString(b & 0xFF));
22 | }
23 | return hex.toString();
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/sx.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/wtshanxun.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/mandroid/wtshanxun/utils/Const.java:
--------------------------------------------------------------------------------
1 | package cn.mandroid.wtshanxun.utils;
2 |
3 | import java.io.File;
4 |
5 | import android.content.Context;
6 | import android.os.Environment;
7 |
8 | public class Const {
9 | public static String LOG_TAG = "LOG_TAG";
10 | public static String TBPAY_URL = "https://item.taobao.com/item.htm?spm=686.1000925.0.0.yJP7hz&id=522902751643https://item.taobao.com/item.htm?spm=686.1000925.0.0.yJP7hz&id=522902751643";
11 | public static String ADID = "50d71542fec25f97";
12 | public static String ADSECRET = "5445243e7e902992";
13 | private static String APP_MODEL = "original V";
14 | public static String getAppModel(Context context){
15 | return APP_MODEL+Tools.getVersion(context);
16 | }
17 | public static String getDownloadPath() {
18 | File sdDir = Environment.getExternalStorageDirectory();// 获取跟目录
19 | File dir = new File(sdDir.toString() + "/sxDownload");
20 | if (!dir.exists()) {
21 | dir.mkdirs();
22 | }
23 | return sdDir.toString() + "/sxDownload";
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/mandroid/wtshanxun/UI/widget/AlwaysMarqueeTextView.java:
--------------------------------------------------------------------------------
1 | package cn.mandroid.wtshanxun.UI.widget;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.Canvas;
6 | import android.graphics.Color;
7 | import android.graphics.Paint;
8 | import android.graphics.drawable.Drawable;
9 | import android.text.TextPaint;
10 | import android.util.AttributeSet;
11 | import android.view.View;
12 | import android.widget.TextView;
13 |
14 | import cn.mandroid.wtshanxun.R;
15 |
16 | /**
17 | * TODO: document your custom view class.
18 | */
19 | public class AlwaysMarqueeTextView extends TextView {
20 | public AlwaysMarqueeTextView(Context context) {
21 | super(context);
22 | }
23 |
24 | public AlwaysMarqueeTextView(Context context, AttributeSet attrs) {
25 | super(context, attrs);
26 | }
27 |
28 | public AlwaysMarqueeTextView(Context context, AttributeSet attrs, int defStyle) {
29 | super(context, attrs, defStyle);
30 | }
31 |
32 | @Override
33 | public boolean isFocused() {
34 | return true;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/mandroid/wtshanxun/Model/Bean/UserBean.java:
--------------------------------------------------------------------------------
1 | package cn.mandroid.wtshanxun.Model.Bean;
2 |
3 | import java.io.Serializable;
4 |
5 | /**
6 | * Created by Administrator on 2015-11-15.
7 | */
8 | public class UserBean extends BasicBean implements Serializable{
9 | private String sxAcount;
10 | private String sessionId;
11 | private int uid;
12 | private int coin ;
13 |
14 | public String getPassword() {
15 | return password;
16 | }
17 |
18 | public void setPassword(String password) {
19 | this.password = password;
20 | }
21 |
22 | public int getUid() {
23 | return uid;
24 | }
25 |
26 | public void setUid(int uid) {
27 | this.uid = uid;
28 | }
29 |
30 | private String password;
31 | public String getSxAcount() {
32 | return sxAcount;
33 | }
34 |
35 | public void setSxAcount(String sxAcount) {
36 | this.sxAcount = sxAcount;
37 | }
38 |
39 | public String getSessionId() {
40 | return sessionId;
41 | }
42 |
43 | public void setSessionId(String sessionId) {
44 | this.sessionId = sessionId;
45 | }
46 | public void setCoin(int coin) {
47 | this.coin = coin;
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/mandroid/wtshanxun/utils/Udp.java:
--------------------------------------------------------------------------------
1 | package cn.mandroid.wtshanxun.utils;
2 |
3 | import java.io.IOException;
4 | import java.io.UnsupportedEncodingException;
5 | import java.net.DatagramPacket;
6 | import java.net.DatagramSocket;
7 | import java.net.InetSocketAddress;
8 | import java.net.SocketException;
9 |
10 | import cn.mandroid.wtshanxun.utils.MLog;
11 |
12 | public class Udp {
13 | private DatagramSocket clientSocket = null;
14 | private InetSocketAddress serverAddress = null;
15 | private byte[] data;
16 |
17 | private Udp(String host, int port, byte[] data) throws SocketException {
18 | clientSocket = new DatagramSocket();
19 | serverAddress = new InetSocketAddress(host, port);
20 | this.data = data;
21 | }
22 |
23 | public static Udp instance(String host, int port, byte[] data) throws SocketException {
24 | return new Udp(host, port, data);
25 | }
26 |
27 | public void send() {
28 | DatagramPacket packet = null;
29 | try {
30 | packet = new DatagramPacket(data, data.length,
31 | serverAddress);
32 | clientSocket.send(packet);
33 | clientSocket.close();
34 | } catch (SocketException e) {
35 | } catch (IOException e) {
36 | }
37 |
38 | }
39 | }
--------------------------------------------------------------------------------
/app/src/main/java/cn/mandroid/wtshanxun/Model/Bean/BeanManager.java:
--------------------------------------------------------------------------------
1 | package cn.mandroid.wtshanxun.Model.Bean;
2 |
3 | import android.content.Context;
4 |
5 | import com.tencent.android.tpush.XGPushManager;
6 |
7 |
8 | import cn.mandroid.wtshanxun.utils.CheckUtils;
9 | import cn.mandroid.wtshanxun.utils.Preference;
10 |
11 | /**
12 | * Created by Administrator on 2015-11-15.
13 | */
14 | public class BeanManager {
15 | private static UserBean userBean;
16 |
17 | public static UserBean getUserBean(Context context) {
18 | Preference preference = Preference.instance(context);
19 | if (CheckUtils.stringIsEmpty(preference.getString(Preference.SX_USER))) {
20 | return null;
21 | }
22 | if (userBean == null) {
23 | userBean = new UserBean();
24 | String user = preference.getString(Preference.SX_USER);
25 | userBean.setSessionId(preference.getString(Preference.SESSION_ID));
26 | userBean.setSxAcount(user);
27 | XGPushManager.registerPush(context, user);
28 | // XGPushConfig.enableDebug(context, true);
29 | }
30 | return userBean;
31 | }
32 |
33 | public static void cleanUser(Context context) {
34 | userBean = null;
35 | XGPushManager.unregisterPush(context);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in d:\Program Files\Android\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 ic_head_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 | #}Warning:org.androidannotations.api.rest.RestClientHeaders: can't find referenced class org.springframework.http.HttpAuthentication
18 | -dontwarn net.youmi.android.**
19 | -keep class net.youmi.android.** { *;}
20 |
21 | -dontwarn org.apache.http.**
22 | -keep class org.apache.http.** { *;}
23 |
24 | -dontwarn org.springframework.**
25 | -keep class org.springframework.** { *;}
26 |
27 | -dontwarn com.tencent.android.tpush.**
28 | -keep class com.tencent.android.tpush.** { *;}
29 |
30 | -dontwarn com.pgyersdk.**
31 | -keep class com.pgyersdk.** { *; }
32 | -keepclassmembers class ** {
33 | public void onEvent*(**);
34 | void onEvent*(**);
35 | }
36 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/mandroid/wtshanxun/UI/common/BasicActivity.java:
--------------------------------------------------------------------------------
1 | package cn.mandroid.wtshanxun.UI.common;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.os.Bundle;
6 |
7 | import cn.mandroid.wtshanxun.event.ExitApp;
8 | import cn.mandroid.wtshanxun.utils.Preference;
9 | import cn.mandroid.wtshanxun.utils.PreferenceHelper;
10 | import de.greenrobot.event.EventBus;
11 |
12 | /**
13 | * Created by Administrator on 2015-11-22.
14 | */
15 | public class BasicActivity extends Activity {
16 | protected Context context;
17 | protected Preference preference;
18 | protected PreferenceHelper preferenceHelper;
19 |
20 | @Override
21 | protected void onCreate(Bundle savedInstanceState) {
22 | super.onCreate(savedInstanceState);
23 | context = this;
24 | preference = Preference.instance(context);
25 | preferenceHelper = PreferenceHelper.instance(context);
26 | EventBus.getDefault().register(this);
27 | }
28 |
29 | @Override
30 | protected void onStop() {
31 |
32 | super.onStop();
33 | }
34 |
35 | public void onEvent(ExitApp exit) {
36 | finish();
37 | }
38 |
39 | protected void exitApp() {
40 | EventBus.getDefault().post(new ExitApp());
41 | }
42 |
43 | @Override
44 | protected void onDestroy() {
45 | EventBus.getDefault().unregister(this);
46 | super.onDestroy();
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/mandroid/wtshanxun/utils/PreferenceHelper.java:
--------------------------------------------------------------------------------
1 | package cn.mandroid.wtshanxun.utils;
2 |
3 | import android.content.Context;
4 |
5 | import org.json.JSONException;
6 | import org.json.JSONObject;
7 |
8 | import cn.mandroid.wtshanxun.Model.Bean.BeanManager;
9 | import cn.mandroid.wtshanxun.utils.Preference;
10 |
11 | /**
12 | * Created by Administrator on 2015-11-15.
13 | */
14 | public class PreferenceHelper {
15 | Context context;
16 | Preference preference;
17 | private static PreferenceHelper helper;
18 |
19 | private PreferenceHelper(Context context) {
20 | this.context = context;
21 | preference = Preference.instance(context);
22 | }
23 |
24 | public static PreferenceHelper instance(Context context) {
25 | if (helper == null) {
26 | helper = new PreferenceHelper(context);
27 | }
28 | return helper;
29 | }
30 |
31 | public void saveUser(String json) {
32 | JSONObject jsonObject = null;
33 | BeanManager.cleanUser(context);
34 | try {
35 | jsonObject = new JSONObject(json);
36 | preference.putString(Preference.SX_USER, jsonObject.getString("sxAcount"));
37 | preference.putString(Preference.SESSION_ID, jsonObject.has("sessionId") ? jsonObject.getString("sessionId") : "");
38 | preference.putBoolean(Preference.AUTO_GET_PASSWORD, false);
39 | } catch (JSONException e) {
40 | }
41 |
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/mandroid/wtshanxun/UI/dialog/NoticeDialog.java:
--------------------------------------------------------------------------------
1 | package cn.mandroid.wtshanxun.UI.dialog;
2 |
3 | import android.app.Dialog;
4 | import android.content.Context;
5 | import android.view.View;
6 | import android.widget.Button;
7 | import android.widget.TextView;
8 |
9 | import cn.mandroid.wtshanxun.R;
10 |
11 | /**
12 | * Created by Administrator on 2015-09-22.
13 | */
14 | public class NoticeDialog extends SuperDialog implements View.OnClickListener {
15 | private Context context;
16 | private TextView titleText;
17 | private TextView contentText;
18 | private Button submit;
19 |
20 | public NoticeDialog(Context context, String title, String content) {
21 | super(context, R.style.MyDialog);
22 | setContentView(R.layout.doalog_notice);
23 | this.context = context;
24 | contentText = (TextView) findViewById(R.id.contentText);
25 | titleText = (TextView) findViewById(R.id.titleText);
26 | submit = (Button) findViewById(R.id.submit);
27 | submit.setOnClickListener(this);
28 | setContent(content);
29 | setTitle(title);
30 | }
31 | public void setTitle(String title) {
32 | titleText.setText(title);
33 | }
34 |
35 | public void setContent(String content) {
36 | contentText.setText(content);
37 |
38 | }
39 |
40 | @Override
41 | public void onClick(View view) {
42 | switch (view.getId()) {
43 | case R.id.submit:
44 | cancel();
45 | break;
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/notification_heart.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
15 |
16 |
21 |
22 |
29 |
30 |
35 |
36 |
37 |
38 |
39 |
47 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
15 |
16 |
17 |
18 |
19 |
20 |
25 |
30 |
34 |
39 |
40 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/doalog_notice.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
20 |
21 |
34 |
35 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/mandroid/wtshanxun/UI/widget/MyProgressBar.java:
--------------------------------------------------------------------------------
1 | package cn.mandroid.wtshanxun.UI.widget;
2 |
3 | import android.content.Context;
4 | import android.graphics.Canvas;
5 | import android.graphics.Color;
6 | import android.graphics.Paint;
7 | import android.graphics.Rect;
8 | import android.util.AttributeSet;
9 | import android.widget.ProgressBar;
10 |
11 | public class MyProgressBar extends ProgressBar {
12 | String text;
13 | Paint mPaint;
14 |
15 | public MyProgressBar(Context context) {
16 | super(context);
17 | System.out.println("1");
18 | initText();
19 | }
20 |
21 | public MyProgressBar(Context context, AttributeSet attrs, int defStyle) {
22 | super(context, attrs, defStyle);
23 | System.out.println("2");
24 | initText();
25 | }
26 |
27 |
28 | public MyProgressBar(Context context, AttributeSet attrs) {
29 | super(context, attrs);
30 | System.out.println("3");
31 | initText();
32 | }
33 |
34 | @Override
35 | public synchronized void setProgress(int progress) {
36 | setText(progress);
37 | super.setProgress(progress);
38 |
39 | }
40 |
41 | @Override
42 | protected synchronized void onDraw(Canvas canvas) {
43 | super.onDraw(canvas);
44 | //this.setText();
45 | Rect rect = new Rect();
46 | this.mPaint.getTextBounds(this.text, 0, this.text.length(), rect);
47 | int x = (getWidth() / 2) - rect.centerX();
48 | int y = (getHeight() / 2) - rect.centerY();
49 | canvas.drawText(this.text, x, y, this.mPaint);
50 | }
51 |
52 | private void initText() {
53 | this.mPaint = new Paint();
54 | this.mPaint.setColor(Color.WHITE);
55 |
56 | }
57 |
58 | private void setText() {
59 | setText(this.getProgress());
60 | }
61 | private void setText(int progress) {
62 | int i = (progress * 100) / this.getMax();
63 | this.text = String.valueOf(i) + "%";
64 | }
65 |
66 |
67 | }
--------------------------------------------------------------------------------
/app/src/main/java/cn/mandroid/wtshanxun/Model/UserManager.java:
--------------------------------------------------------------------------------
1 | package cn.mandroid.wtshanxun.Model;
2 |
3 | import android.content.Context;
4 |
5 | import com.google.gson.JsonObject;
6 | import com.koushikdutta.async.future.FutureCallback;
7 | import com.koushikdutta.ion.Ion;
8 |
9 | import org.androidannotations.annotations.EBean;
10 |
11 | import java.util.HashMap;
12 | import java.util.Map;
13 |
14 | import cn.mandroid.wtshanxun.utils.Constant;
15 | import cn.mandroid.wtshanxun.utils.Preference;
16 |
17 | /**
18 | * Created by Administrator on 2015-11-15.
19 | */
20 | @EBean
21 | public class UserManager extends ApiManager {
22 | public void getUserInfo(final Context context, final String user, final FetchCallback callback) {
23 | Map map = new HashMap();
24 | map.put("user", user);
25 | Ion.with(context)
26 | .load(Constant.API_URL + "/user/getInfo")
27 | .setMultipartParameters(finalMap(context, map))
28 | .asString()
29 | .setCallback(new FutureCallback() {
30 | @Override
31 | public void onCompleted(Exception e, String result) {
32 | getData(context, result, callback);
33 | }
34 | });
35 | }
36 | public void getNotice(final Context context, final String user, final FetchCallback callback) {
37 | Map map = new HashMap();
38 | map.put("user", user);
39 | Ion.with(context)
40 | .load(Constant.API_URL + "/notice/get")
41 | .setMultipartParameters(finalMap(context, map))
42 | .asJsonObject()
43 | .setCallback(new FutureCallback() {
44 | @Override
45 | public void onCompleted(Exception e, JsonObject result) {
46 | callback.get(result.get("data").getAsString());
47 | }
48 | });
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_header.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
16 |
17 |
26 |
27 |
36 |
37 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/mandroid/wtshanxun/UI/dialog/ExitDialog.java:
--------------------------------------------------------------------------------
1 | package cn.mandroid.wtshanxun.UI.dialog;
2 |
3 | import android.content.Context;
4 | import android.view.View;
5 | import android.widget.Button;
6 | import android.widget.TextView;
7 |
8 | import cn.mandroid.wtshanxun.R;
9 | import cn.mandroid.wtshanxun.event.ExitApp;
10 | import cn.mandroid.wtshanxun.utils.Tools;
11 | import de.greenrobot.event.EventBus;
12 |
13 | /**
14 | * Created by Administrator on 2015-09-22.
15 | */
16 | public class ExitDialog extends SuperDialog implements View.OnClickListener {
17 | private Context context;
18 | private TextView contentText;
19 | private Button exitBut;
20 | private static ExitDialog dialog;
21 |
22 | public static ExitDialog instance(Context context) {
23 | return new ExitDialog(context);
24 | }
25 |
26 | private ExitDialog(Context context) {
27 | super(context, R.style.MyDialog);
28 | setContentView(R.layout.doalog_exit);
29 | this.context = context;
30 | contentText = (TextView) findViewById(R.id.contentText);
31 | exitBut = (Button) findViewById(R.id.exitAppBut);
32 | exitBut.setOnClickListener(this);
33 | setContent();
34 | }
35 |
36 | private void setContent() {
37 | contentText.append(context.getResources().getString(R.string.app_name) + " V");
38 | contentText.append(Tools.getVersion(context));
39 | contentText.append("\n");
40 | contentText.append("本软件主要针对浙江闪讯用户,支持大多数老版本的路由器,具体请自行测试");
41 | contentText.append(",不支持L2TP模式登录的闪讯用户");
42 | contentText.append("\n");
43 | contentText.append("摇一摇即可给我们留言/反馈");
44 | contentText.append("\n");
45 | contentText.append("也有闪讯路由器出售,需要可以联系我们");
46 | contentText.append("\n");
47 | contentText.append("联系QQ:75376632");
48 | contentText.append("\n");
49 | contentText.append("软件交流QQ群:415664606");
50 |
51 | }
52 |
53 | @Override
54 | public void onClick(View view) {
55 | switch (view.getId()) {
56 | case R.id.exitAppBut:
57 | dismiss();
58 | EventBus.getDefault().post(new ExitApp());
59 | break;
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/mandroid/wtshanxun/UI/common/PopupWindowClick.java:
--------------------------------------------------------------------------------
1 | package cn.mandroid.wtshanxun.UI.common;
2 |
3 | import android.content.Context;
4 | import android.view.View;
5 | import android.widget.PopupWindow;
6 |
7 | import com.pgyersdk.update.PgyUpdateManager;
8 | import com.pgyersdk.update.UpdateManagerListener;
9 |
10 | import cn.mandroid.wtshanxun.R;
11 | import cn.mandroid.wtshanxun.UI.dialog.ExitDialog;
12 | import cn.mandroid.wtshanxun.UI.dialog.RouterSetDialog;
13 | import cn.mandroid.wtshanxun.UI.dialog.UpdateDialog;
14 | import cn.mandroid.wtshanxun.utils.MToast;
15 |
16 | /**
17 | * Created by Administrator on 2015-10-05.
18 | */
19 | public class PopupWindowClick implements View.OnClickListener {
20 | private Context context;
21 | private PopupWindow popupWindow;
22 |
23 | public PopupWindowClick(Context context, PopupWindow popupWindow) {
24 | this.context = context;
25 | this.popupWindow = popupWindow;
26 | }
27 |
28 | @Override
29 | public void onClick(View v) {
30 | switch (v.getId()) {
31 | case R.id.popup_rl1:
32 | RouterSetDialog.instance(context).show();
33 | break;
34 | case R.id.popup_rl3: {
35 | PgyUpdateManager.register((BasicActivity) context, new UpdateManagerListener() {
36 | @Override
37 | public void onNoUpdateAvailable() {
38 | MToast.show(context, "暂无更新");
39 | }
40 |
41 | @Override
42 | public void onUpdateAvailable(String s) {
43 | UpdateDialog.instance(context, getAppBeanFromString(s)).show();
44 | }
45 | });
46 |
47 | // Intent intent = new Intent(context, UpdateActivity.class);
48 | // intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
49 | // context.startActivity(intent);
50 | break;
51 | }
52 | case R.id.popup_rl4:
53 | ExitDialog.instance(context).show();
54 | break;
55 | default:
56 | break;
57 | }
58 | popupWindow.dismiss();
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/mandroid/wtshanxun/Model/ApiManager.java:
--------------------------------------------------------------------------------
1 | package cn.mandroid.wtshanxun.Model;
2 |
3 | import android.content.Context;
4 |
5 | import org.json.JSONException;
6 | import org.json.JSONObject;
7 |
8 | import java.util.ArrayList;
9 | import java.util.HashMap;
10 | import java.util.List;
11 | import java.util.Map;
12 |
13 | import cn.mandroid.wtshanxun.utils.Const;
14 | import cn.mandroid.wtshanxun.utils.Constant;
15 | import cn.mandroid.wtshanxun.utils.MD5;
16 | import cn.mandroid.wtshanxun.utils.MToast;
17 | import cn.mandroid.wtshanxun.utils.Preference;
18 | import cn.mandroid.wtshanxun.utils.Tools;
19 |
20 | /**
21 | * Created by Administrator on 2015-11-15.
22 | */
23 | public class ApiManager {
24 | protected Map> finalMap(Context context, Map map) {
25 | String time =System.currentTimeMillis()/1000+"";
26 | map.put("appModel", Const.getAppModel(context));
27 | map.put("mac", Tools.getMacAddress(context));
28 | map.put("timestamp",time );
29 | String sign= MD5.encode(Preference.instance(context).getString(Preference.SX_USER)+Tools.getMacAddress(context)+time+Tools.sign);
30 | map.put("sign",sign);
31 | Map> params = new HashMap<>();
32 | for (Map.Entry entry : map.entrySet()) {
33 | List list = new ArrayList<>();
34 | list.add(entry.getValue());
35 | params.put(entry.getKey(), list);
36 | }
37 | return params;
38 | }
39 |
40 | protected void getData(Context context, String result, FetchCallback fetchCallback) {
41 | JSONObject jsonObject = null;
42 | try {
43 | jsonObject = new JSONObject(result);
44 | if (jsonObject.getInt("status") == Constant.SUCCESS) {
45 | if (jsonObject.getInt("code") != Constant.Code.SUCCESS) {
46 | MToast.show(context, jsonObject.getString("msg"));
47 | }
48 | fetchCallback.get(jsonObject.getString("data"));
49 | } else {
50 | fetchCallback.error();
51 | MToast.showError(context, jsonObject.getString("msg"));
52 | }
53 | } catch (JSONException e) {
54 | fetchCallback.error();
55 | }
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/doalog_update.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
20 |
21 |
33 |
34 |
44 |
45 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 22
5 | buildToolsVersion "23.0.1"
6 |
7 | defaultConfig {
8 | applicationId "cn.mandroid.wtshanxun"
9 | minSdkVersion 15
10 | targetSdkVersion 22
11 | versionCode 4
12 | versionName "2.3.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled true
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | buildscript {
23 | repositories {
24 | mavenCentral()
25 | }
26 | dependencies {
27 | // replace with the current version of the Android plugin
28 | classpath 'com.android.tools.build:gradle:1.5.0'
29 | // replace with the current version of the android-apt plugin
30 | classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
31 | }
32 | }
33 | apply plugin: 'com.android.application'
34 | apply plugin: 'android-apt'
35 | def AAVersion = '3.3'
36 | dependencies {
37 | compile fileTree(include: ['*.jar'], dir: 'libs')
38 | testCompile 'junit:junit:4.12'
39 | //https://github.com/koush/ion
40 | apt "org.androidannotations:androidannotations:$AAVersion"
41 | compile "org.androidannotations:androidannotations-api:$AAVersion"
42 | compile 'com.android.support:appcompat-v7:22.+'
43 | compile 'com.koushikdutta.ion:ion:2.+'
44 | compile 'de.greenrobot:eventbus:2.4.0'
45 | compile 'com.pgyersdk:sdk:2.2.2'
46 | compile 'com.android.support:design:22.+'
47 | }
48 | apt {
49 | arguments {
50 | androidManifestFile variant.outputs[0]?.processResources?.manifestFile
51 | // if you have multiple outputs (when using splits), you may want to have other index than 0
52 |
53 | // you should set your package name here if you are using different application IDs
54 | // resourcePackageName "your.package.name"
55 |
56 | // You can set optional annotation processing options here, like these commented options:
57 | // logLevel 'INFO'
58 | // logFile '/var/log/aa.log'
59 | }
60 | }
61 | allprojects {
62 | repositories {
63 | jcenter()
64 | maven { url "https://raw.githubusercontent.com/Pgyer/mvn_repo_pgyer/master" }
65 | }
66 | }
67 | android {
68 | packagingOptions {
69 | exclude 'META-INF/LICENSE.txt'
70 | exclude 'META-INF/NOTICE.txt'
71 | exclude '.readme'
72 | }
73 | }
--------------------------------------------------------------------------------
/app/src/main/java/cn/mandroid/wtshanxun/UI/widget/ActionBar.java:
--------------------------------------------------------------------------------
1 | package cn.mandroid.wtshanxun.UI.widget;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.View.OnClickListener;
8 | import android.widget.ImageView;
9 | import android.widget.RelativeLayout;
10 | import android.widget.TextView;
11 |
12 | import cn.mandroid.wtshanxun.R;
13 |
14 | public class ActionBar extends RelativeLayout implements OnClickListener {
15 | private ImageView leftImg;
16 | private ImageView rightImg;
17 | private TextView titleText;
18 | private OnHeadImgClickListenner clickListenner;
19 | private Context context;
20 | private String tbUrl = "http://color-we.taobao.com";
21 |
22 | public ActionBar(Context context, AttributeSet attr) {
23 | super(context, attr);
24 | this.context = context;
25 | // TODO Auto-generated constructor stub
26 | LayoutInflater.from(context).inflate(R.layout.layout_header, this);
27 | leftImg = (ImageView) findViewById(R.id.headLeftImg);
28 | rightImg = (ImageView) findViewById(R.id.headRightImg);
29 | titleText = (TextView) findViewById(R.id.headText);
30 | }
31 |
32 | public void setTitle(String title) {
33 | titleText.setText(title);
34 | }
35 |
36 | public void setLeftImgVisible(int visible) {
37 | leftImg.setVisibility(visible);
38 | }
39 |
40 | public void setRigthImgVisible(int visible) {
41 | rightImg.setVisibility(visible);
42 | }
43 |
44 | public void setOnHeadImgClickListenner(OnHeadImgClickListenner clickListenner) {
45 | this.clickListenner = clickListenner;
46 | leftImg.setOnClickListener(this);
47 | rightImg.setOnClickListener(this);
48 | }
49 |
50 | @Override
51 | public void onClick(View arg0) {
52 | // TODO Auto-generated method stub
53 | switch (arg0.getId()) {
54 | case R.id.headLeftImg:
55 | clickListenner.leftImgClick(leftImg);
56 | break;
57 | case R.id.headRightImg:
58 | clickListenner.rightImgClick(rightImg);
59 | break;
60 | default:
61 | break;
62 | }
63 | }
64 |
65 | public interface OnHeadImgClickListenner {
66 | public void leftImgClick(ImageView view);
67 |
68 | public void rightImgClick(ImageView view);
69 | }
70 |
71 | }
72 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/doalog_router_set.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
18 |
19 |
24 |
25 |
34 |
44 |
45 |
57 |
58 |
59 |
60 |
66 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/doalog_exit.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
20 |
21 |
34 |
35 |
36 |
46 |
47 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/mandroid/wtshanxun/utils/Preference.java:
--------------------------------------------------------------------------------
1 | package cn.mandroid.wtshanxun.utils;
2 |
3 | import android.content.Context;
4 | import android.content.SharedPreferences;
5 |
6 | import java.util.HashMap;
7 | import java.util.Map;
8 |
9 | /**
10 | * 简单数据缓存工具类
11 | *
12 | * @author Administrator
13 | *
14 | */
15 | public class Preference {
16 |
17 | public static String USER_VERIFIED="userVerified";
18 | private final String SHARED_PREFERENCE_NAME = "cn.mandroid.Shanxun";
19 | private static Preference catche;
20 | // private static Preference catcheWithName;
21 | private static Map Premap = new HashMap();
22 | private SharedPreferences spf;
23 | public static String ROUTER_TYPE = "routerType1";
24 | public static String ROUTER_ACC = "routerAcc";
25 | public static String ROUTER_IP = "routerIp";
26 | public static String ROUTER_PASS = "routerPass";
27 | public static String SX_PASS = "sxPass";
28 | public static String FIRSTRUN = "firstRun";
29 | public static String AUTO_GET_PASSWORD="autoGetPassword";
30 | public static String SEND_HEART="sendHeart";
31 | public static String SMSDATE="smsDate";
32 | public static String SX_USER = "sxUser";
33 | public static String SESSION_ID = "sessionId";
34 | public static Preference instance(Context context) {
35 | if (catche == null) {
36 | catche = new Preference(context);
37 | }
38 | return catche;
39 | }
40 |
41 | public static Preference instance(Context context, String name) {
42 | if (!Premap.containsKey(name)) {
43 | Premap.put(name, new Preference(context, name));
44 | }
45 | return Premap.get(name);
46 | }
47 |
48 | public Preference(Context context) {
49 | spf = context.getSharedPreferences(SHARED_PREFERENCE_NAME,
50 | Context.MODE_PRIVATE);
51 | }
52 |
53 | public Preference(Context context, String name) {
54 | spf = context.getSharedPreferences(name, Context.MODE_PRIVATE);
55 | }
56 |
57 | public void putBoolean(String key, boolean value) {
58 | spf.edit().putBoolean(key, value).commit();
59 | }
60 |
61 | public boolean getBoolean(String key) {
62 | return spf.getBoolean(key, false);
63 | }
64 |
65 | public void putString(String key, String value) {
66 | spf.edit().putString(key, value).commit();
67 | }
68 |
69 | public String getString(String key) {
70 | return spf.getString(key, "");
71 | }
72 |
73 | public void putInt(String key, int value) {
74 | spf.edit().putInt(key, value).commit();
75 | }
76 |
77 | public void putLong(String key, long value) {
78 | spf.edit().putLong(key, value).commit();
79 | }
80 |
81 | public int getInt(String key) {
82 | return spf.getInt(key, 0);
83 | }
84 |
85 | public int getInt(String key, int defaultValue) {
86 | return spf.getInt(key, defaultValue);
87 | }
88 |
89 | public long getLong(String key) {
90 | return spf.getLong(key, 0);
91 | }
92 |
93 | public long getLong(String key, long def) {
94 | return spf.getLong(key, def);
95 | }
96 |
97 | public void clearData() {
98 | spf.edit().clear().commit();
99 | }
100 |
101 | public void remove(String key) {
102 | spf.edit().remove(key).commit();
103 | }
104 |
105 | public void commit() {
106 | spf.edit().commit();
107 | }
108 |
109 | }
110 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/mandroid/wtshanxun/UI/dialog/RouterSetDialog.java:
--------------------------------------------------------------------------------
1 | package cn.mandroid.wtshanxun.UI.dialog;
2 |
3 | import android.content.Context;
4 | import android.view.View;
5 | import android.widget.Button;
6 | import android.widget.EditText;
7 |
8 | import cn.mandroid.wtshanxun.R;
9 | import cn.mandroid.wtshanxun.utils.CheckUtils;
10 | import cn.mandroid.wtshanxun.utils.MToast;
11 | import cn.mandroid.wtshanxun.utils.Preference;
12 |
13 | public class RouterSetDialog extends SuperDialog implements View.OnClickListener {
14 | private EditText routerIpEdit;
15 | private EditText routerAccEdit;
16 | private EditText routerPassEdit;
17 | private Button button;
18 | private String routerIp;
19 | private String routerAcc;
20 | private String routerPass;
21 | private Preference preference;
22 | private Context context;
23 |
24 | public static RouterSetDialog instance(Context context) {
25 | return new RouterSetDialog(context);
26 | }
27 |
28 | private RouterSetDialog(Context context) {
29 | super(context, R.style.MyDialog);
30 | this.context = context;
31 | setContentView(R.layout.doalog_router_set);
32 | initView();
33 | preference = Preference.instance(context);
34 | initData();
35 | }
36 |
37 | private void initData() {
38 | // TODO Auto-generated method stub
39 | routerAcc = preference.getString(Preference.ROUTER_ACC);
40 | routerIp = preference.getString(Preference.ROUTER_IP).equals("") ? "192.168.1.1"
41 | : preference.getString(Preference.ROUTER_IP);
42 | routerPass = preference.getString(Preference.ROUTER_PASS);
43 | routerIpEdit.setText(routerIp);
44 | routerPassEdit.setText(routerPass);
45 | routerAccEdit.setText(routerAcc);
46 | button.setOnClickListener(this);
47 |
48 | }
49 |
50 | private void initView() {
51 | routerIpEdit = (EditText) findViewById(R.id.routerIPAddrEdit);
52 | routerAccEdit = (EditText) findViewById(R.id.routerAccEdit);
53 | routerPassEdit = (EditText) findViewById(R.id.routerPassEdit);
54 | button = (Button) findViewById(R.id.saveRouterInfoBut);
55 | button.setOnClickListener(this);
56 |
57 | }
58 |
59 | private boolean checkInput() {
60 | // TODO Auto-generated method stub
61 | if (!CheckUtils.isRouterSite(routerIp)) {
62 | MToast.show(context, "路由器后台地址有误");
63 | return false;
64 | }
65 | if (CheckUtils.stringIsEmpty(routerAcc, routerPass)) {
66 | MToast.show(context, "路由器账号或密码输入有误");
67 | return false;
68 | }
69 | return true;
70 | }
71 |
72 | @Override
73 | public void onClick(View view) {
74 | switch (view.getId()) {
75 | case R.id.saveRouterInfoBut:
76 | save();
77 | break;
78 | }
79 | }
80 |
81 | private void save() {
82 | routerAcc = routerAccEdit.getText().toString();
83 | routerIp = routerIpEdit.getText().toString();
84 | routerPass = routerPassEdit.getText().toString();
85 | if (!checkInput()) {
86 | return;
87 | }
88 | preference.putString(Preference.ROUTER_ACC, routerAcc);
89 | preference.putString(Preference.ROUTER_IP, routerIp);
90 | preference.putString(Preference.ROUTER_PASS, routerPass);
91 | MToast.show(context, "已保存");
92 | cancel();
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/mandroid/wtshanxun/UI/dialog/UpdateDialog.java:
--------------------------------------------------------------------------------
1 | package cn.mandroid.wtshanxun.UI.dialog;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.net.Uri;
6 | import android.view.View;
7 | import android.widget.Button;
8 | import android.widget.TextView;
9 |
10 | import com.koushikdutta.async.future.FutureCallback;
11 | import com.koushikdutta.ion.Ion;
12 | import com.pgyersdk.javabean.AppBean;
13 |
14 | import java.io.File;
15 |
16 | import cn.mandroid.wtshanxun.R;
17 | import cn.mandroid.wtshanxun.UI.widget.MyProgressBar;
18 | import cn.mandroid.wtshanxun.utils.Const;
19 | import cn.mandroid.wtshanxun.utils.MToast;
20 |
21 | /**
22 | * Created by Administrator on 2015-09-22.
23 | */
24 | public class UpdateDialog extends SuperDialog implements View.OnClickListener {
25 | private Context context;
26 | private TextView contentText;
27 | private MyProgressBar progressBar;
28 | private Button submit;
29 | private AppBean bean;
30 | private static UpdateDialog dialog;
31 |
32 | public static UpdateDialog instance(Context context, AppBean bean) {
33 | if (dialog == null) {
34 | dialog = new UpdateDialog(context);
35 | }
36 | dialog.setData(bean);
37 | return dialog;
38 | }
39 |
40 | private UpdateDialog(Context context) {
41 | super(context, R.style.MyDialog);
42 | setContentView(R.layout.doalog_update);
43 | this.context = context;
44 | contentText = (TextView) findViewById(R.id.contentText);
45 | progressBar = (MyProgressBar) findViewById(R.id.updateProgressBar);
46 | progressBar.setIndeterminate(false);
47 | submit = (Button) findViewById(R.id.submit);
48 | submit.setOnClickListener(this);
49 | }
50 |
51 | private void setData(AppBean bean) {
52 | this.bean = bean;
53 | contentText.append("版本号:" + bean.getVersionName());
54 | contentText.append("\n");
55 | contentText.append("更新说明\n" + bean.getReleaseNote());
56 | }
57 |
58 | @Override
59 | public void onClick(View view) {
60 | switch (view.getId()) {
61 | case R.id.submit:
62 | File file = new File(Const.getDownloadPath() + "/闪讯wifi助手 " + bean.getVersionName() + ".apk");
63 | if (file.exists()) {
64 | installApk(file);
65 | return;
66 | }
67 | MToast.show(context, "正在下载");
68 | submit.setClickable(false);
69 | submit.setText("正在下载");
70 | progressBar.setVisibility(View.VISIBLE);
71 | Ion.with(context).load(bean.getDownloadURL()).progressBar(progressBar).write(file).setCallback(new FutureCallback() {
72 | @Override
73 | public void onCompleted(Exception e, File result) {
74 | submit.setClickable(true);
75 | submit.setText("安装");
76 | installApk(result);
77 | }
78 | });
79 | break;
80 | }
81 | }
82 |
83 | private void installApk(File file) {
84 | Intent intent = new Intent();
85 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
86 | intent.setAction(android.content.Intent.ACTION_VIEW);
87 | intent.setDataAndType(Uri.fromFile(file),
88 | "application/vnd.android.package-archive");
89 | context.startActivity(intent);
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/mandroid/wtshanxun/utils/Pin.java:
--------------------------------------------------------------------------------
1 | package cn.mandroid.wtshanxun.utils;
2 |
3 | import java.security.MessageDigest;
4 | import java.security.NoSuchAlgorithmException;
5 |
6 | public class Pin {
7 |
8 | public static String getpin(byte[] userName) {
9 | int i, j,z = 0;
10 | long timedivbyfive;
11 | long timenow;
12 | byte[] RADIUS = new byte[16];
13 | byte[] timeByte = new byte[4];
14 | byte[] beforeMD5 = new byte[32];
15 | byte[] afterMD5 = new byte[16];
16 | byte[] MD501H = new byte[2];
17 | byte[] MD501 = new byte[3];
18 | byte[] timeHash = new byte[4];
19 | byte[] temp = new byte[32];
20 | byte[] PIN27 = new byte[6];
21 | String s="singlenet01";
22 | RADIUS = s.getBytes();
23 | timenow = System.currentTimeMillis();
24 | timenow=timenow/1000;
25 | timedivbyfive = timenow / 5;
26 | for (i = 0; i < 4; i++) {
27 | timeByte[i] = (byte) (timedivbyfive >> (8 * (3 - i)) & 0xFF);
28 | }
29 | for (i = 0; i < 4; i++) {
30 | beforeMD5[i] = timeByte[i];
31 | }
32 | for (i = 4; i < 16 && userName[i - 4] != '@'; i++) {
33 | beforeMD5[i] = userName[i - 4];
34 | }
35 | j = 0;
36 | while (j> 4 & 0xF);
57 | MD501H[1] = (byte) (afterMD5[0] & 0xF);
58 | if (MD501H[0] > 9) {
59 | MD501[0] = (byte) (MD501H[0] + 87);
60 | } else {
61 | MD501[0] = (byte) (MD501H[0] + 48);
62 | }
63 | if (MD501H[1] > 9) {
64 | MD501[1] = (byte) (MD501H[1] + 87);
65 | } else {
66 | MD501[1] = (byte) (MD501H[1] + 48);
67 | }
68 | MD501[2] = (byte) 0;
69 | for (i = 0; i < 32; i++) {
70 | temp[i] = (byte) (timeByte[(31 - i) / 8] & 1);
71 | timeByte[(31 - i) / 8] = (byte) (timeByte[(31 - i) / 8] >> 1);
72 | }
73 |
74 | for (i = 0; i < 4; i++) {
75 | timeHash[i] = (byte) (temp[i] * 128 + temp[4 + i] * 64
76 | + temp[8 + i] * 32 + temp[12 + i] * 16 + temp[16 + i] * 8
77 | + temp[20 + i] * 4 + temp[24 + i] * 2 + temp[28 + i]);
78 | }
79 |
80 | temp[1] = (byte) ((timeHash[0] & 3) << 4);
81 | temp[0] = (byte) ((timeHash[0] >> 2) & 0x3F);
82 | temp[2] = (byte) ((timeHash[1] & 0xF) << 2);
83 | temp[1] = (byte) ((timeHash[1] >> 4 & 0xF) + temp[1]);
84 | temp[3] = (byte) (timeHash[2] & 0x3F);
85 | temp[2] = (byte) (((timeHash[2] >> 6) & 0x3) + temp[2]);
86 | temp[5] = (byte) ((timeHash[3] & 3) << 4);
87 | temp[4] = (byte) ((timeHash[3] >> 2) & 0x3F);
88 |
89 | for (i = 0; i < 6; i++) {
90 | PIN27[i] = (byte) (temp[i] + 0x020);
91 | if (PIN27[i] >= 0x40) {
92 | PIN27[i]++;
93 | }
94 | }
95 | byte[] PIN;
96 | if(z==1)
97 | {
98 | PIN = new byte[29];
99 | }
100 | else PIN = new byte[30];
101 | PIN[0] = '\r';
102 | PIN[1] = '\n';
103 | for(int k=2;k<8;k++)
104 | {
105 | PIN[k]=PIN27[k-2];
106 | }
107 |
108 | PIN[8] = MD501[0];
109 | PIN[9] = MD501[1];
110 | for(int k=0;k>= 6;
27 | out[index + 2] = alphabet[(trip ? (val & 0x3F) : 64)];
28 | val >>= 6;
29 | out[index + 1] = alphabet[val & 0x3F];
30 | val >>= 6;
31 | out[index + 0] = alphabet[val & 0x3F];
32 | }
33 | return out;
34 | }
35 | /**
36 | * 将base64编码的数据解码成原始数据
37 | */
38 | static public byte[] decode(char[] data) {
39 | int len = ((data.length + 3) / 4) * 3;
40 | if (data.length > 0 && data[data.length - 1] == '=')
41 | --len;
42 | if (data.length > 1 && data[data.length - 2] == '=')
43 | --len;
44 | byte[] out = new byte[len];
45 | int shift = 0;
46 | int accum = 0;
47 | int index = 0;
48 | for (int ix = 0; ix < data.length; ix++) {
49 | int value = codes[data[ix] & 0xFF];
50 | if (value >= 0) {
51 | accum <<= 6;
52 | shift += 6;
53 | accum |= value;
54 | if (shift >= 8) {
55 | shift -= 8;
56 | out[index++] = (byte) ((accum >> shift) & 0xff);
57 | }
58 | }
59 | }
60 | if (index != out.length)
61 | throw new Error("miscalculated data length!");
62 | return out;
63 | }
64 | public static String decode(String data){
65 | return new String(decode(data.toCharArray()));
66 | }
67 | static private char[] alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
68 | .toCharArray();
69 | static private byte[] codes = new byte[256];
70 | static {
71 | for (int i = 0; i < 256; i++)
72 | codes[i] = -1;
73 | for (int i = 'A'; i <= 'Z'; i++)
74 | codes[i] = (byte) (i - 'A');
75 | for (int i = 'a'; i <= 'z'; i++)
76 | codes[i] = (byte) (26 + i - 'a');
77 | for (int i = '0'; i <= '9'; i++)
78 | codes[i] = (byte) (52 + i - '0');
79 | codes['+'] = 62;
80 | codes['/'] = 63;
81 | }
82 | // public static void main(String[] args) throws Exception {
83 | // // 加密成base64
84 | // String strSrc = "林";
85 | // String strOut = new String(Base64.encode(strSrc.getBytes("GB18030")));
86 | // System.out.println(strOut);
87 | //
88 | // }
89 |
90 | }
91 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/popupwindow_setting.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
11 |
12 |
20 |
21 |
25 |
26 |
35 |
36 |
37 |
45 |
46 |
50 |
51 |
60 |
61 |
62 |
70 |
71 |
75 |
76 |
85 |
86 |
87 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/doalog_pay.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
21 |
22 |
31 |
32 |
41 |
42 |
49 |
50 |
59 |
60 |
61 |
71 |
72 |
82 |
83 |
95 |
96 |
97 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/mandroid/wtshanxun/Model/HeartManager.java:
--------------------------------------------------------------------------------
1 | package cn.mandroid.wtshanxun.Model;
2 |
3 | import android.content.Context;
4 |
5 | import com.google.gson.JsonObject;
6 | import com.koushikdutta.async.future.FutureCallback;
7 | import com.koushikdutta.ion.Ion;
8 |
9 | import org.androidannotations.annotations.EBean;
10 | import org.json.JSONException;
11 | import org.json.JSONObject;
12 |
13 | import java.io.IOException;
14 | import java.util.Map;
15 | import java.util.TreeMap;
16 |
17 | import cn.mandroid.wtshanxun.Model.Bean.BeanManager;
18 | import cn.mandroid.wtshanxun.UI.Service.HeartService;
19 | import cn.mandroid.wtshanxun.event.StopHeartEvent;
20 | import cn.mandroid.wtshanxun.event.TotalEvent;
21 | import cn.mandroid.wtshanxun.utils.Base64;
22 | import cn.mandroid.wtshanxun.utils.Constant;
23 | import cn.mandroid.wtshanxun.utils.Preference;
24 | import cn.mandroid.wtshanxun.utils.Udp;
25 |
26 | /**
27 | * Created by Administrator on 2015-11-26.
28 | */
29 | @EBean
30 | public class HeartManager extends ApiManager {
31 | public void sendHeart(Context context) {
32 | Ion.with(context).load(Constant.API_URL + "/heart/GetIp").asString().setCallback(ipCallback(context));
33 | }
34 |
35 | private void getHeartData(Context context, String ip) {
36 | Map map = new TreeMap<>();
37 | map.put("user", BeanManager.getUserBean(context).getSxAcount());
38 | map.put("ip", ip);
39 | Ion.with(context).load(Constant.API_URL + "/heart/getByApp").setMultipartParameters(finalMap(context, map)).asJsonObject().setCallback(heartDataCallback(context));
40 | }
41 |
42 | private FutureCallback heartDataCallback(final Context context) {
43 | return new FutureCallback() {
44 | @Override
45 | public void onCompleted(Exception e, JsonObject result) {
46 | if (e == null) {
47 | try {
48 | if (result.get("code").getAsInt() == 4) {
49 | HeartService.eventBus.post(new StopHeartEvent());
50 | return;
51 | }else if(result.get("code").getAsInt() != 1){
52 | return;
53 | }
54 | JsonObject data = result.get("data").getAsJsonObject();
55 | String heartData = data.get("data").getAsString();
56 | String heartIp = data.get("sendIp").getAsString();
57 | int heartPort = data.get("sendPort").getAsInt();
58 | HeartService.eventBus.post(Udp.instance(heartIp, heartPort, Base64.decode(heartData.toCharArray())));
59 | } catch (Exception e1) {
60 | return;
61 | }
62 | TotalEvent event = new TotalEvent();
63 | event.setSendHeartCount();
64 | HeartService.eventBus.post(event);
65 | }
66 | }
67 | };
68 | }
69 |
70 | // private FutureCallback heartDataCallback(Context context) {
71 | // return new FutureCallback() {
72 | // @Override
73 | // public void onCompleted(Exception e, String result) {
74 | // if(e==null){
75 | //
76 | //
77 | // }
78 | // }
79 | // };
80 | // }
81 |
82 | private FutureCallback ipCallback(final Context context) {
83 | return new FutureCallback() {
84 | @Override
85 | public void onCompleted(Exception e, String result) {
86 | if (e == null) {
87 | try {
88 | JSONObject jsonObject = new JSONObject(result);
89 | String ip = jsonObject.getString("ip");
90 | getHeartData(context, ip);
91 | } catch (JSONException e1) {
92 | e1.printStackTrace();
93 | }
94 | }
95 | }
96 | };
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/mandroid/wtshanxun/utils/CheckUtils.java:
--------------------------------------------------------------------------------
1 | package cn.mandroid.wtshanxun.utils;
2 |
3 | import android.content.Context;
4 | import android.content.pm.PackageInfo;
5 | import android.content.pm.PackageManager;
6 | import android.content.pm.Signature;
7 | import android.net.ConnectivityManager;
8 | import android.net.NetworkInfo;
9 |
10 | import com.koushikdutta.async.future.FutureCallback;
11 | import com.koushikdutta.ion.Ion;
12 |
13 | import java.io.ByteArrayInputStream;
14 | import java.security.cert.CertificateFactory;
15 | import java.security.cert.X509Certificate;
16 | import java.util.regex.Matcher;
17 | import java.util.regex.Pattern;
18 |
19 | import cn.mandroid.wtshanxun.UI.common.BasicActivity;
20 | import cn.mandroid.wtshanxun.event.CheckCallBackEvent;
21 | import de.greenrobot.event.EventBus;
22 |
23 |
24 | public class CheckUtils {
25 | public static String sign;
26 |
27 | public static Boolean stringIsEmpty(String... s) {
28 | for (String string : s) {
29 | if (string == null) {
30 | return true;
31 | } else if (string.trim().equals("")) {
32 | return true;
33 | } else if (string.trim().toLowerCase().equals("null")) {
34 | return true;
35 | }
36 | }
37 | return false;
38 | }
39 |
40 | public static boolean isWifiConnected(Context context) {
41 | ConnectivityManager connectivityManager = (ConnectivityManager) context
42 | .getSystemService(Context.CONNECTIVITY_SERVICE);
43 | NetworkInfo wifiNetworkInfo = connectivityManager
44 | .getNetworkInfo(ConnectivityManager.TYPE_WIFI);
45 | if (wifiNetworkInfo.isConnected()) {
46 | return true;
47 | }
48 |
49 | return false;
50 | }
51 |
52 | public static boolean isEmail(String phone) {
53 | String check = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
54 | Pattern regex = Pattern.compile(check);
55 | Matcher matcher = regex.matcher(phone);
56 | return matcher.matches();
57 | }
58 |
59 | public static boolean sxAcountIsValid(String username) {
60 | return (isEmail(username) && username.endsWith("XY"));
61 | }
62 |
63 | public static boolean passIsValid(String password) {
64 | return (password.length() >= 6 && password.length() <= 20);
65 | }
66 |
67 | public static boolean isWebSite(String s) {
68 | Pattern p = Pattern
69 | .compile("(([a-zA-z0-9]|-){1,}\\.){1,}[a-zA-z0-9]{1,}-*");
70 | Matcher m = p.matcher(s);
71 | return m.find();
72 | }
73 |
74 | public static boolean isRouterSite(String s) {
75 | return (isWebSite(s) && !s.contains("?") && !s.contains("/") && !s.contains("\\"));
76 | }
77 |
78 | public static boolean routerIsValid(Context context, Preference preference) {
79 | // TODO Auto-generated method stub
80 | String routerAcc = preference.getString(Preference.ROUTER_ACC);
81 | String routerPass = preference.getString(Preference.ROUTER_PASS);
82 | if (CheckUtils.stringIsEmpty(routerAcc, routerPass)) {
83 | MToast.show(context, "路由器配置有误");
84 | return false;
85 | }
86 | return true;
87 | }
88 |
89 | public static boolean shanxunIsValid(Context context, String sxUser, String sxPass) {
90 | // TODO Auto-generated method stub
91 | if (CheckUtils.stringIsEmpty(sxUser, sxPass)) {
92 | MToast.show(context, "闪讯账号或密码输入有误");
93 | return false;
94 | }
95 | if (!CheckUtils.sxAcountIsValid(sxUser)) {
96 | MToast.show(context, "闪讯账号有误");
97 | return false;
98 | }
99 | return true;
100 | }
101 |
102 | public static void networkIsValid(Context context) {
103 | Ion.with(context).load("http://www.baidu.com").setTimeout(3000).asString().setCallback(new FutureCallback() {
104 | @Override
105 | public void onCompleted(Exception e, String result) {
106 | EventBus.getDefault().post(new CheckCallBackEvent(e == null, CheckCallBackEvent.CHECK_NETWORK_VALID));
107 | }
108 | });
109 | }
110 | }
111 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/mandroid/wtshanxun/UI/Service/HeartService.java:
--------------------------------------------------------------------------------
1 | package cn.mandroid.wtshanxun.UI.Service;
2 |
3 | import android.app.IntentService;
4 | import android.app.Notification;
5 | import android.app.NotificationManager;
6 | import android.app.PendingIntent;
7 | import android.content.Context;
8 | import android.content.Intent;
9 | import android.os.IBinder;
10 | import android.os.PowerManager;
11 | import android.widget.RemoteViews;
12 |
13 | import org.androidannotations.annotations.Bean;
14 | import org.androidannotations.annotations.EIntentService;
15 | import org.androidannotations.annotations.Receiver;
16 |
17 | import cn.mandroid.wtshanxun.event.TotalEvent;
18 | import cn.mandroid.wtshanxun.Model.HeartManager;
19 | import cn.mandroid.wtshanxun.R;
20 | import cn.mandroid.wtshanxun.UI.activity.MainActivity;
21 | import cn.mandroid.wtshanxun.event.StopHeartEvent;
22 | import cn.mandroid.wtshanxun.utils.Udp;
23 | import de.greenrobot.event.EventBus;
24 |
25 | @EIntentService
26 | public class HeartService extends IntentService {
27 | public static Context context;
28 | NotificationManager nm;
29 | Notification.Builder notificationBuilder;
30 | Notification mNotification;
31 | RemoteViews contentView;
32 | private PendingIntent pd;
33 | private int nid = 1234;
34 | PowerManager.WakeLock wakeLock;
35 | @Bean
36 | HeartManager mHeartManager;
37 |
38 | public HeartService() {
39 | super("heart");
40 | }
41 |
42 | public static EventBus eventBus;
43 | private int total;
44 | private int successCount;
45 |
46 | @Override
47 | public void onCreate() {
48 | super.onCreate();
49 | eventBus = new EventBus();
50 | eventBus.register(this);
51 | total=0;
52 | successCount=0;
53 | setWake();
54 | }
55 |
56 | @Override
57 | public int onStartCommand(Intent intent, int flags, int startId) {
58 | initNotifi();
59 | return super.onStartCommand(intent, flags, startId);
60 | }
61 |
62 | @Override
63 | public IBinder onBind(Intent intent) {
64 | // TODO: Return the communication channel to the service.
65 | throw new UnsupportedOperationException("Not yet implemented");
66 | }
67 |
68 | @Override
69 | protected void onHandleIntent(Intent intent) {
70 | while (true) {
71 | mHeartManager.sendHeart(this);
72 | total++;
73 | try {
74 | Thread.sleep(1000 * 60 * 3);
75 | } catch (InterruptedException e) {
76 | e.printStackTrace();
77 | }
78 | }
79 | }
80 |
81 |
82 | private void initNotifi() {
83 | nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
84 | contentView = new RemoteViews(getPackageName(),
85 | R.layout.notification_heart);
86 | Intent intent = new Intent("onNotifButClick");
87 | PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0,
88 | intent, 0);
89 | PendingIntent pd = PendingIntent.getActivity(this, 0, new Intent(this,
90 | MainActivity.class), 0);
91 | contentView.setOnClickPendingIntent(R.id.exitHeartBut, pendingIntent);
92 | notificationBuilder = new Notification.Builder(this).setAutoCancel(false).setSmallIcon(R.drawable.ic_launcher).setWhen(System.currentTimeMillis()).setContent(contentView).setContentIntent(pd);
93 | mNotification = notificationBuilder.getNotification();
94 | mNotification.flags |= Notification.FLAG_NO_CLEAR;
95 | nm.notify(nid, mNotification);
96 | }
97 |
98 | private void setWake() {
99 | PowerManager pm = (PowerManager) getApplication().getSystemService(Context.POWER_SERVICE);
100 | // 保持cpu一直运行,不管屏幕是否黑屏
101 | wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
102 | "CPUKeepRunning");
103 | wakeLock.acquire();
104 | }
105 |
106 | public void onEvent(TotalEvent e) {
107 | contentView.setTextViewText(R.id.totalText, "已发送" + total + "次,成功" + (++successCount) + "次");
108 | mNotification.contentView = contentView;
109 | nm.notify(nid, mNotification);
110 | }
111 |
112 | public void onEvent(StopHeartEvent event) {
113 | stopSelf();
114 | }
115 |
116 | public void onEventAsync(Udp udp) {
117 | udp.send();
118 | }
119 |
120 | @Override
121 | public void onDestroy() {
122 | // TODO Auto-generated method stub
123 | nm.cancel(nid);
124 | if (wakeLock != null) {
125 | wakeLock.release();
126 | }
127 | eventBus.unregister(this);
128 | EventBus.getDefault().post(new StopHeartEvent());
129 | super.onDestroy();
130 | }
131 |
132 | @Receiver(actions = "onNotifButClick")
133 | protected void notifButClick() {
134 | stopSelf();
135 | }
136 | }
137 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/mandroid/wtshanxun/Model/ShanxunManager.java:
--------------------------------------------------------------------------------
1 | package cn.mandroid.wtshanxun.Model;
2 |
3 | import android.content.Context;
4 |
5 | import com.google.gson.JsonObject;
6 | import com.koushikdutta.async.future.FutureCallback;
7 | import com.koushikdutta.ion.Ion;
8 |
9 | import org.androidannotations.annotations.EBean;
10 | import org.json.JSONException;
11 | import org.json.JSONObject;
12 |
13 | import java.io.UnsupportedEncodingException;
14 |
15 | import cn.mandroid.wtshanxun.Model.Bean.BeanManager;
16 | import cn.mandroid.wtshanxun.Model.Bean.UserBean;
17 | import cn.mandroid.wtshanxun.utils.Pin;
18 | import cn.mandroid.wtshanxun.utils.Sto16;
19 | import cn.mandroid.wtshanxun.R;
20 | import cn.mandroid.wtshanxun.UI.Service.HeartService_;
21 | import cn.mandroid.wtshanxun.utils.Base64;
22 | import cn.mandroid.wtshanxun.utils.Constant;
23 | import cn.mandroid.wtshanxun.utils.MToast;
24 | import cn.mandroid.wtshanxun.utils.Preference;
25 |
26 | /**
27 | * Created by Administrator on 2015-11-23.
28 | */
29 | @EBean
30 | public class ShanxunManager extends ApiManager {
31 | public void startDial(Context context, String sxAcount, String sxPass, FetchCallback callback) throws UnsupportedEncodingException {
32 | Preference preference = Preference.instance(context);
33 | String acount = getFinalUser(sxAcount);
34 | String routerIp = preference.getString(Preference.ROUTER_IP);
35 | String RouterAcc = preference.getString(Preference.ROUTER_ACC);
36 | String routerPass = preference.getString(Preference.ROUTER_PASS);
37 | String getRequest = "wan=0" + "&wantype=2" + "&acc=" + acount + "&psw="
38 | + sxPass + "&confirm=" + sxPass + "&specialDial=0"
39 | + "&SecType=0" + "&sta_ip=0.0.0.0" + "&sta_mask=0.0.0.0"
40 | + "&linktype=4" + "&waittime2=0" + "&Connect=%C1%AC+%BD%D3";
41 | String url = "http://" + routerIp + "/userRpm/PPPoECfgRpm.htm?"
42 | + getRequest;
43 | String ro = RouterAcc + ":" + routerPass;
44 | String auth = "Basic%20" + new String(Base64.encode(ro.getBytes("GB18030")));
45 | Ion.with(context)
46 | .load(url)
47 | .setTimeout(10000)
48 | .setHeader("Authorization", auth)
49 | .setHeader("Cookie", "Authorization=" + auth + "; ChgPwdSubTag=")
50 | .setHeader("Host", routerIp)
51 | .setHeader("Referer", "http://" + routerIp + "/userRpm/PPPoECfgRpm.htm")
52 | .setHeader("Content-Type", context.getResources().getText(R.string.content_type).toString())
53 | .setHeader("User-Agent", context.getResources().getText(R.string.user_agent).toString())
54 | .setHeader("Accept", context.getResources().getText(R.string.accept).toString())
55 | .setHeader("Accept-Language", context.getResources().getText(R.string.accept_language).toString())
56 | .setHeader("Accept-Encoding", context.getResources().getText(R.string.accept_encoding).toString())
57 | .asString()
58 | .setCallback(dialCall(context, callback));
59 | }
60 |
61 | private FutureCallback dialCall(final Context context, final FetchCallback callback) {
62 | return new FutureCallback() {
63 | @Override
64 | public void onCompleted(Exception e, String result) {
65 | if (e == null) {
66 | callback.get("dial_finish");
67 | checkNetwork(context, callback);
68 | } else {
69 | callback.error();
70 | }
71 |
72 | }
73 | };
74 | }
75 |
76 | private void checkNetwork(final Context context, final FetchCallback callback) {
77 | Ion.with(context).load(Constant.API_URL + "/heart/GetIp").setTimeout(10000).asJsonObject().setCallback(new FutureCallback() {
78 | @Override
79 | public void onCompleted(Exception e, JsonObject result) {
80 | if (e == null) {
81 | Constant.DEVICES_IP = result.get("ip").getAsString();
82 | callback.get("dial_success");
83 | checkNeedSentHeart(context);
84 | } else {
85 | callback.error();
86 | }
87 |
88 | }
89 | });
90 |
91 | }
92 |
93 | public void checkNeedSentHeart(Context context) {
94 | boolean needHeart = Preference.instance(context).getBoolean(Preference.SEND_HEART);
95 | UserBean userBean = BeanManager.getUserBean(context);
96 | if (needHeart) {
97 | HeartService_.intent(context).start();
98 | }
99 | }
100 |
101 | private String getFinalUser(String sxAcount) {
102 | String after = Pin.getpin(sxAcount.getBytes());
103 | String yhm = Sto16.bin2hex(after);
104 | return yhm;
105 | }
106 |
107 |
108 | }
109 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
34 |
35 |
42 |
45 |
46 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
60 |
61 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
98 |
99 |
100 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
112 |
113 |
116 |
117 |
118 |
119 |
120 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
15 |
16 |
34 |
35 |
55 |
56 |
67 |
68 |
82 |
83 |
96 |
97 |
105 |
106 |
107 |
108 |
118 |
119 |
132 |
133 |
143 |
144 |
145 |
154 |
155 |
165 |
166 |
179 |
180 |
181 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/mandroid/wtshanxun/UI/activity/MainActivity.java:
--------------------------------------------------------------------------------
1 | package cn.mandroid.wtshanxun.UI.activity;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.graphics.drawable.BitmapDrawable;
6 | import android.os.Bundle;
7 | import android.os.PowerManager;
8 | import android.provider.Settings;
9 | import android.text.Html;
10 | import android.view.MotionEvent;
11 | import android.view.View;
12 | import android.widget.Button;
13 | import android.widget.CheckBox;
14 | import android.widget.CompoundButton;
15 | import android.widget.EditText;
16 | import android.widget.ImageView;
17 | import android.widget.PopupWindow;
18 | import android.widget.RelativeLayout;
19 | import android.widget.TextView;
20 |
21 |
22 | import org.androidannotations.annotations.AfterTextChange;
23 | import org.androidannotations.annotations.AfterViews;
24 | import org.androidannotations.annotations.Bean;
25 | import org.androidannotations.annotations.CheckedChange;
26 | import org.androidannotations.annotations.Click;
27 | import org.androidannotations.annotations.EActivity;
28 | import org.androidannotations.annotations.ViewById;
29 |
30 | import java.io.UnsupportedEncodingException;
31 |
32 | import cn.mandroid.wtshanxun.Model.Bean.BeanManager;
33 | import cn.mandroid.wtshanxun.Model.Bean.UserBean;
34 | import cn.mandroid.wtshanxun.Model.FetchCallback;
35 | import cn.mandroid.wtshanxun.Model.ShanxunManager;
36 | import cn.mandroid.wtshanxun.Model.UserManager;
37 | import cn.mandroid.wtshanxun.R;
38 | import cn.mandroid.wtshanxun.UI.Service.HeartService_;
39 | import cn.mandroid.wtshanxun.UI.common.BasicActivity;
40 | import cn.mandroid.wtshanxun.UI.common.PopupWindowClick;
41 | import cn.mandroid.wtshanxun.UI.dialog.NoticeDialog;
42 | import cn.mandroid.wtshanxun.UI.dialog.RouterSetDialog;
43 | import cn.mandroid.wtshanxun.UI.widget.ActionBar;
44 | import cn.mandroid.wtshanxun.UI.widget.AlwaysMarqueeTextView;
45 | import cn.mandroid.wtshanxun.event.CheckCallBackEvent;
46 | import cn.mandroid.wtshanxun.event.StopHeartEvent;
47 | import cn.mandroid.wtshanxun.utils.CheckUtils;
48 | import cn.mandroid.wtshanxun.utils.MToast;
49 | import cn.mandroid.wtshanxun.utils.Preference;
50 | import cn.mandroid.wtshanxun.utils.Tools;
51 |
52 | @EActivity(R.layout.activity_main)
53 | public class MainActivity extends BasicActivity implements ActionBar.OnHeadImgClickListenner {
54 | @ViewById
55 | ActionBar actionBar;
56 | @ViewById
57 | TextView sxAcountText;
58 | @ViewById
59 | EditText sxAcountEdit;
60 | @ViewById
61 | TextView exchangeBut;
62 | @ViewById
63 | EditText sxPasswordEdit;
64 | @ViewById
65 | Button mainSubmit;
66 | @ViewById
67 | CheckBox autoGetPasswordCheckBox;
68 | @ViewById
69 | CheckBox sendHeartCheckBox;
70 | @ViewById
71 | AlwaysMarqueeTextView bottomText;
72 | @Bean
73 | UserManager mUserManager;
74 | @Bean
75 | ShanxunManager mShanxunManager;
76 | PopupWindow popupWindow;
77 | boolean sxAcountValid;
78 | PowerManager pm;
79 | PowerManager.WakeLock wakeLock;
80 |
81 | @Override
82 | protected void onCreate(Bundle savedInstanceState) {
83 | super.onCreate(savedInstanceState);
84 | Tools.setWifiNeverDormancy(this);
85 | setWake();
86 | Tools.initSign(this);
87 | }
88 |
89 | private void setWake() {
90 | pm = (PowerManager) getApplication().getSystemService(Context.POWER_SERVICE);
91 | // 保持cpu一直运行,不管屏幕是否黑屏
92 | wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
93 | "CPUKeepRunning");
94 | wakeLock.acquire();
95 | }
96 |
97 | @AfterViews
98 | void afterView() {
99 | actionBar.setTitle(getString(R.string.app_name));
100 | actionBar.setLeftImgVisible(View.GONE);
101 | actionBar.setOnHeadImgClickListenner(this);
102 | initData(BeanManager.getUserBean(context));
103 | if (sxAcountText.getText().toString().length() == 0) {
104 | exchangeButClick();
105 | }
106 | }
107 |
108 | private void initNotice() {
109 | mUserManager.getNotice(context, sxAcountText.getText().toString(), new FetchCallback() {
110 | @Override
111 | public void get(String result) {
112 | bottomText.setText(Html.fromHtml(result));
113 | }
114 |
115 | @Override
116 | public void error() {
117 |
118 | }
119 | });
120 | }
121 |
122 | @Override
123 | protected void onResume() {
124 | initNotice();
125 | super.onResume();
126 | }
127 |
128 | private void initData(UserBean bean) {
129 | if (bean == null) {
130 | return;
131 | }
132 | if (CheckUtils.stringIsEmpty(bean.getSxAcount())) {
133 | sxAcountEdit.setVisibility(View.VISIBLE);
134 | exchangeBut.setText("验证账号");
135 | }
136 | sxAcountText.setText(bean.getSxAcount());
137 | sxPasswordEdit.setText(preference.getString(Preference.SX_PASS));
138 | autoGetPasswordCheckBox.setChecked(preference.getBoolean(Preference.AUTO_GET_PASSWORD));
139 | sendHeartCheckBox.setChecked(preference.getBoolean(Preference.SEND_HEART));
140 | }
141 |
142 | @AfterTextChange(R.id.sxAcountEdit)
143 | void setSxEditChange(TextView editText) {
144 | if (CheckUtils.sxAcountIsValid(editText.getText().toString().toUpperCase())) {
145 | sxAcountValid = true;
146 | editText.setBackgroundResource(R.drawable.bg_view_frame_green);
147 | } else {
148 | sxAcountValid = false;
149 | editText.setBackgroundResource(R.drawable.bg_view_frame_red);
150 |
151 | }
152 | }
153 |
154 | @AfterTextChange(R.id.sxPasswordEdit)
155 | void setSxPassEditChange(TextView editText) {
156 | preference.putString(Preference.SX_PASS, editText.getText().toString());
157 | }
158 |
159 | @Click(R.id.exchangeBut)
160 | public void exchangeButClick() {
161 | if (sxAcountEdit.getVisibility() == View.VISIBLE) {
162 | String sxAcount = sxAcountEdit.getText().toString().toUpperCase();
163 | if (sxAcountValid) {
164 | sxAcountEdit.setVisibility(View.GONE);
165 | preference.putString(preference.SX_USER, sxAcount);
166 | exchangeBut.setText("切换账号");
167 | sxAcountText.setText(sxAcount);
168 | preference.putBoolean(Preference.USER_VERIFIED, false);
169 | setMainBut(0);
170 | HeartService_.intent(context).stop();
171 | } else {
172 | MToast.show(context, "闪讯账号格式有误");
173 | }
174 | } else {
175 | exchangeBut.setText("保存");
176 | sxAcountEdit.setText(preference.getString(Preference.SX_USER));
177 | sxAcountEdit.setVisibility(View.VISIBLE);
178 | }
179 | }
180 |
181 | @CheckedChange({R.id.autoGetPasswordCheckBox, R.id.sendHeartCheckBox})
182 | public void onChecked(CompoundButton view, boolean isChecked) {
183 | switch (view.getId()) {
184 | case R.id.autoGetPasswordCheckBox:
185 | if (isChecked) {
186 | String c = "该功能会自动发送短信获取密码,请慎重使用!非闪讯电话卡或双卡手机请关闭此功能,否则无法正常使用软件";
187 | new NoticeDialog(context, "注意", c).show();
188 | }
189 | preference.putBoolean(Preference.AUTO_GET_PASSWORD, isChecked);
190 | break;
191 | case R.id.sendHeartCheckBox:
192 | preference.putBoolean(Preference.SEND_HEART, isChecked);
193 | break;
194 | }
195 | }
196 |
197 | private void getUserInfo() {
198 | String sxAcount = preference.getString(Preference.SX_USER);
199 | if (CheckUtils.sxAcountIsValid(sxAcount)) {
200 | CheckUtils.networkIsValid(context);
201 | } else {
202 | MToast.show(context, "闪讯账号格式不正确!");
203 | }
204 | }
205 |
206 | public void onEvent(CheckCallBackEvent event) {
207 | switch (event.getAction()) {
208 | case CheckCallBackEvent.CHECK_NETWORK_VALID:
209 | String sxAcount = preference.getString(Preference.SX_USER).toUpperCase();
210 | if (!event.isSuccess()) {
211 | if (!CheckUtils.isWifiConnected(context)) {
212 | MToast.show(context, "连接失败,请检查网络");
213 | } else {
214 | checkSetting(sxAcountEdit.getText().toString().toUpperCase(), sxPasswordEdit.getText().toString());
215 | }
216 | } else {
217 | updateUser(sxAcount, true);
218 | }
219 | break;
220 | }
221 | }
222 |
223 | private void updateUser(String sxAcount, final boolean showToast) {
224 | if (showToast) {
225 | MToast.show(context, "正在获取用户信息!");
226 | }
227 | mUserManager.getUserInfo(context, sxAcount, new FetchCallback() {
228 | @Override
229 | public void get(String result) {
230 | preferenceHelper.saveUser(result);
231 | UserBean userBean = BeanManager.getUserBean(context);
232 | if (showToast) {
233 | MToast.show(context, "获取成功!");
234 | }
235 | mShanxunManager.checkNeedSentHeart(context);
236 | initData(userBean);
237 | }
238 |
239 | @Override
240 | public void error() {
241 | MToast.show(context, "获取失败!");
242 | setMainBut(0);
243 | }
244 | });
245 | }
246 |
247 | public void onEvent(StopHeartEvent event) {
248 | MToast.show(context, "心跳服务已停止");
249 | setMainBut(0);
250 | }
251 |
252 |
253 | @Click(R.id.mainSubmit)
254 | public void submit() {
255 | if (sxAcountEdit.getVisibility() == View.GONE) {
256 | checkSetting(sxAcountText.getText().toString().toUpperCase(), sxPasswordEdit.getText().toString());
257 |
258 | } else {
259 | MToast.show(context, "请先保存账号!");
260 | }
261 | }
262 |
263 | private void checkSetting(final String sxUser, final String sxPass) {
264 | if (!CheckUtils.isWifiConnected(context)) {
265 | Intent intent = new Intent(Settings.ACTION_WIFI_SETTINGS);
266 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
267 | startActivity(intent);
268 | MToast.show(context, "请先设置wifi网络");
269 | return;
270 | }
271 | if (!CheckUtils.routerIsValid(context, preference)) {
272 | RouterSetDialog.instance(context).show();
273 | return;
274 | }
275 | if (!CheckUtils.shanxunIsValid(context, sxUser, sxPass)) {
276 | return;
277 | }
278 | setMainBut(1);
279 | try {
280 | mShanxunManager.startDial(context, sxUser, sxPass, new FetchCallback() {
281 | @Override
282 | public void get(String result) {
283 | if (result.equals("dial_finish")) {
284 | setMainBut(2);
285 | } else if (result.equals("dial_success")) {
286 | if (!preference.getBoolean(Preference.USER_VERIFIED)) {
287 | preference.putString(Preference.SX_USER, sxUser);
288 | getUserInfo();
289 | }
290 | setMainBut(3);
291 | }
292 | }
293 |
294 | @Override
295 | public void error() {
296 | setMainBut(4);
297 | }
298 | });
299 | } catch (UnsupportedEncodingException e) {
300 | e.printStackTrace();
301 | }
302 | }
303 |
304 | @Override
305 | protected void onDestroy() {
306 | super.onDestroy();
307 | if (wakeLock != null) {
308 | wakeLock.release();
309 | }
310 | }
311 |
312 | private void setMainBut(int i) {
313 | switch (i) {
314 | case 0: {
315 | mainSubmit.setClickable(true);
316 | mainSubmit.setText("开始拨号");
317 | mainSubmit.setBackgroundResource(R.drawable.bg_button_main);
318 | }
319 | break;
320 | case 1: {
321 | mainSubmit.setClickable(false);
322 | mainSubmit.setText("正在拨号");
323 | mainSubmit.setBackgroundResource(R.drawable.bg_button_main_dialing);
324 | }
325 | break;
326 | case 2: {
327 | mainSubmit.setClickable(false);
328 | mainSubmit.setText("正在验证网络情况");
329 | mainSubmit.setBackgroundResource(R.drawable.bg_button_main_dialing);
330 | }
331 | break;
332 | case 3: {
333 | mainSubmit.setClickable(false);
334 | mainSubmit.setText("连接成功");
335 | mainSubmit.setBackgroundResource(R.drawable.bg_button_main_dial_success);
336 | }
337 | break;
338 | case 4: {
339 | mainSubmit.setClickable(true);
340 | mainSubmit.setText("连接失败,请重试");
341 | mainSubmit.setBackgroundResource(R.drawable.bg_button_main_dial_error);
342 | }
343 | break;
344 | }
345 |
346 | }
347 |
348 |
349 | private void initPopupWindow() {
350 |
351 | View contentView = getLayoutInflater().inflate(
352 | R.layout.popupwindow_setting, null);
353 | RelativeLayout r1 = (RelativeLayout) contentView
354 | .findViewById(R.id.popup_rl1);
355 | RelativeLayout r3 = (RelativeLayout) contentView
356 | .findViewById(R.id.popup_rl3);
357 | RelativeLayout r4 = (RelativeLayout) contentView
358 | .findViewById(R.id.popup_rl4);
359 | popupWindow = new PopupWindow(contentView,
360 | android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
361 | android.view.ViewGroup.LayoutParams.WRAP_CONTENT, true);
362 | popupWindow.setTouchable(true);
363 | popupWindow.setTouchInterceptor(new View.OnTouchListener() {
364 | @Override
365 | public boolean onTouch(View arg0, MotionEvent arg1) {
366 | // TODO Auto-generated method stub
367 | return false;
368 | }
369 | });
370 | popupWindow.setBackgroundDrawable(new BitmapDrawable());
371 | PopupWindowClick popupWindowClick = new PopupWindowClick(context, popupWindow);
372 | r1.setOnClickListener(popupWindowClick);
373 | r3.setOnClickListener(popupWindowClick);
374 | r4.setOnClickListener(popupWindowClick);
375 |
376 | }
377 |
378 | @Override
379 | public void onBackPressed() {
380 | Intent intent = new Intent(Intent.ACTION_MAIN);
381 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
382 | intent.addCategory(Intent.CATEGORY_HOME);
383 | startActivity(intent);
384 | }
385 |
386 | @Override
387 | public void leftImgClick(ImageView view) {
388 |
389 | }
390 |
391 | @Override
392 | public void rightImgClick(ImageView view) {
393 | initPopupWindow();
394 | popupWindow.showAsDropDown(view, -100, 0);
395 | }
396 |
397 | }
398 |
--------------------------------------------------------------------------------