├── .gitignore
├── README.md
├── code
└── ide
│ ├── adt
│ ├── Secret
│ │ ├── .classpath
│ │ ├── .project
│ │ ├── AndroidManifest.xml
│ │ ├── ic_launcher-web.png
│ │ ├── libs
│ │ │ └── android-support-v4.jar
│ │ ├── proguard-project.txt
│ │ ├── project.properties
│ │ ├── res
│ │ │ ├── drawable-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── drawable-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── drawable-xhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── drawable-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── layout
│ │ │ │ ├── aty_comments_list_cell.xml
│ │ │ │ ├── aty_login.xml
│ │ │ │ ├── aty_message.xml
│ │ │ │ ├── aty_publish.xml
│ │ │ │ ├── aty_timeline.xml
│ │ │ │ └── aty_timeline_list_cell.xml
│ │ │ ├── menu
│ │ │ │ └── menu_aty_timeline.xml
│ │ │ ├── values-v11
│ │ │ │ └── styles.xml
│ │ │ ├── values-v14
│ │ │ │ └── styles.xml
│ │ │ ├── values-w820dp
│ │ │ │ └── dimens.xml
│ │ │ ├── values-zh-rCN
│ │ │ │ └── strings.xml
│ │ │ └── values
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── strings.xml
│ │ │ │ └── styles.xml
│ │ └── src
│ │ │ └── com
│ │ │ └── jikexueyuan
│ │ │ └── secret
│ │ │ ├── Config.java
│ │ │ ├── MainActivity.java
│ │ │ ├── atys
│ │ │ ├── AtyLogin.java
│ │ │ ├── AtyMessage.java
│ │ │ ├── AtyMessageCommentListAdapter.java
│ │ │ ├── AtyPublish.java
│ │ │ ├── AtyTimeline.java
│ │ │ └── AtyTimelineMessageListAdapter.java
│ │ │ ├── ld
│ │ │ └── MyContacts.java
│ │ │ ├── net
│ │ │ ├── Comment.java
│ │ │ ├── GetCode.java
│ │ │ ├── GetComment.java
│ │ │ ├── HttpMethod.java
│ │ │ ├── Login.java
│ │ │ ├── Message.java
│ │ │ ├── NetConnection.java
│ │ │ ├── PubComment.java
│ │ │ ├── Publish.java
│ │ │ ├── Timeline.java
│ │ │ └── UploadContacts.java
│ │ │ └── tools
│ │ │ └── MD5Tool.java
│ └── SecretClientPublish
│ │ ├── .classpath
│ │ ├── .project
│ │ ├── .settings
│ │ └── org.eclipse.jdt.core.prefs
│ │ ├── AndroidManifest.xml
│ │ ├── ic_launcher-web.png
│ │ ├── libs
│ │ └── android-support-v4.jar
│ │ ├── proguard-project.txt
│ │ ├── project.properties
│ │ ├── res
│ │ ├── drawable-hdpi
│ │ │ └── ic_launcher.png
│ │ ├── drawable-mdpi
│ │ │ └── ic_launcher.png
│ │ ├── drawable-xhdpi
│ │ │ └── ic_launcher.png
│ │ ├── drawable-xxhdpi
│ │ │ └── ic_launcher.png
│ │ ├── layout
│ │ │ ├── aty_login.xml
│ │ │ └── aty_timeline.xml
│ │ ├── menu
│ │ │ └── main.xml
│ │ ├── values-v11
│ │ │ └── styles.xml
│ │ ├── values-v14
│ │ │ └── styles.xml
│ │ ├── values-w820dp
│ │ │ └── dimens.xml
│ │ └── values
│ │ │ ├── dimens.xml
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ │ └── src
│ │ └── com
│ │ └── jikexueyuan
│ │ └── secretclientpublish
│ │ ├── AtyLogin.java
│ │ ├── AtyTimeline.java
│ │ ├── Config.java
│ │ ├── MainActivity.java
│ │ ├── ld
│ │ └── MyContacts.java
│ │ ├── net
│ │ ├── GetCode.java
│ │ ├── HttpMethod.java
│ │ ├── Login.java
│ │ ├── NetConnection.java
│ │ ├── Timeline.java
│ │ └── UploadContacts.java
│ │ └── tool
│ │ └── MD5Tool.java
│ └── eclipse
│ └── TestServer
│ ├── .classpath
│ ├── .gitignore
│ ├── .project
│ ├── .settings
│ ├── .jsdtscope
│ ├── org.eclipse.jdt.core.prefs
│ ├── org.eclipse.wst.common.component
│ ├── org.eclipse.wst.common.project.facet.core.xml
│ ├── org.eclipse.wst.jsdt.ui.superType.container
│ └── org.eclipse.wst.jsdt.ui.superType.name
│ └── WebContent
│ ├── META-INF
│ └── MANIFEST.MF
│ └── api.jsp
└── docs
├── 《匿名》软件开发参考文档.docx
└── 《匿名》项目开发实战课程大纲.docx
/.gitignore:
--------------------------------------------------------------------------------
1 | .metadata
2 | bin
3 | gen
4 | obj
5 | RemoteSystemsTempFiles
6 | Servers
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | jikexueyuanSecret
2 | =================
3 |
4 | 极客学院《匿名》项目教学课程源码
5 |
6 | 服务器端源码地址:[https://github.com/jikexueyuan/mimi_api](https://github.com/jikexueyuan/mimi_api)
7 |
8 | 更多视频课程请看: [https://yunp.top](https://yunp.top)
9 |
--------------------------------------------------------------------------------
/code/ide/adt/Secret/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/code/ide/adt/Secret/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | Secret
4 |
5 |
6 |
7 |
8 |
9 | com.android.ide.eclipse.adt.ResourceManagerBuilder
10 |
11 |
12 |
13 |
14 | com.android.ide.eclipse.adt.PreCompilerBuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.jdt.core.javabuilder
20 |
21 |
22 |
23 |
24 | com.android.ide.eclipse.adt.ApkBuilder
25 |
26 |
27 |
28 |
29 |
30 | com.android.ide.eclipse.adt.AndroidNature
31 | org.eclipse.jdt.core.javanature
32 |
33 |
34 |
--------------------------------------------------------------------------------
/code/ide/adt/Secret/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
11 |
12 |
13 |
14 |
19 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/code/ide/adt/Secret/ic_launcher-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/plter/jikexueyuanSecret/26177f31535a5594466f3b1b8ec7d53aabad3a32/code/ide/adt/Secret/ic_launcher-web.png
--------------------------------------------------------------------------------
/code/ide/adt/Secret/libs/android-support-v4.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/plter/jikexueyuanSecret/26177f31535a5594466f3b1b8ec7d53aabad3a32/code/ide/adt/Secret/libs/android-support-v4.jar
--------------------------------------------------------------------------------
/code/ide/adt/Secret/proguard-project.txt:
--------------------------------------------------------------------------------
1 | # To enable ProGuard in your project, edit project.properties
2 | # to define the proguard.config property as described in that file.
3 | #
4 | # Add project specific ProGuard rules here.
5 | # By default, the flags in this file are appended to flags specified
6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt
7 | # You can edit the include path and order by changing the ProGuard
8 | # include property in project.properties.
9 | #
10 | # For more details, see
11 | # http://developer.android.com/guide/developing/tools/proguard.html
12 |
13 | # Add any project specific keep options here:
14 |
15 | # If your project uses WebView with JS, uncomment the following
16 | # and specify the fully qualified class name to the JavaScript interface
17 | # class:
18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
19 | # public *;
20 | #}
21 |
--------------------------------------------------------------------------------
/code/ide/adt/Secret/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system edit
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 | #
10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
12 |
13 | # Project target.
14 | target=android-19
15 |
--------------------------------------------------------------------------------
/code/ide/adt/Secret/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/plter/jikexueyuanSecret/26177f31535a5594466f3b1b8ec7d53aabad3a32/code/ide/adt/Secret/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/code/ide/adt/Secret/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/plter/jikexueyuanSecret/26177f31535a5594466f3b1b8ec7d53aabad3a32/code/ide/adt/Secret/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/code/ide/adt/Secret/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/plter/jikexueyuanSecret/26177f31535a5594466f3b1b8ec7d53aabad3a32/code/ide/adt/Secret/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/code/ide/adt/Secret/res/drawable-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/plter/jikexueyuanSecret/26177f31535a5594466f3b1b8ec7d53aabad3a32/code/ide/adt/Secret/res/drawable-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/code/ide/adt/Secret/res/layout/aty_comments_list_cell.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
--------------------------------------------------------------------------------
/code/ide/adt/Secret/res/layout/aty_login.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
19 |
20 |
27 |
28 |
29 |
35 |
36 |
40 |
41 |
46 |
47 |
54 |
55 |
56 |
61 |
62 |
--------------------------------------------------------------------------------
/code/ide/adt/Secret/res/layout/aty_message.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
18 |
19 |
20 |
24 |
25 |
30 |
31 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/code/ide/adt/Secret/res/layout/aty_publish.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
15 |
16 |
22 |
23 |
--------------------------------------------------------------------------------
/code/ide/adt/Secret/res/layout/aty_timeline.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/code/ide/adt/Secret/res/layout/aty_timeline_list_cell.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
--------------------------------------------------------------------------------
/code/ide/adt/Secret/res/menu/menu_aty_timeline.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/code/ide/adt/Secret/res/values-v11/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/code/ide/adt/Secret/res/values-v14/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/code/ide/adt/Secret/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 | 64dp
9 |
10 |
11 |
--------------------------------------------------------------------------------
/code/ide/adt/Secret/res/values-zh-rCN/strings.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 |
--------------------------------------------------------------------------------
/code/ide/adt/Secret/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 16dp
5 | 16dp
6 |
7 |
8 |
--------------------------------------------------------------------------------
/code/ide/adt/Secret/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Secret
5 | Phone
6 | Get code
7 | Code
8 | Login
9 | Publish message
10 | Phone number can\'t be empty
11 | Comment content can\'t be empty
12 | Message content can\'t be empty
13 | Code can\'t be empty
14 | Fail to get code
15 | Fail to login,please try later
16 | Fail to load messages,please try later
17 | Fail to publish comment,please try later
18 | Fail to get comments,please try later
19 | Fail to publish message,please try later
20 | Success to get code,please check your short message
21 | Success to publish message
22 | Connecting
23 | Connecting to server,please wait
24 | publish
25 |
26 |
27 |
--------------------------------------------------------------------------------
/code/ide/adt/Secret/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
14 |
15 |
16 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/code/ide/adt/Secret/src/com/jikexueyuan/secret/Config.java:
--------------------------------------------------------------------------------
1 | package com.jikexueyuan.secret;
2 |
3 | import android.content.Context;
4 | import android.content.SharedPreferences.Editor;
5 |
6 | public class Config {
7 |
8 |
9 | public static final String SERVER_URL = "http://demo.eoeschool.com/api/v1/nimings/io";
10 | // public static final String SERVER_URL = "http://10.0.0.52:8080/TestServer/api.jsp";
11 |
12 | public static final String KEY_TOKEN = "token";
13 | public static final String KEY_ACTION = "action";
14 | public static final String KEY_PHONE_NUM = "phone";
15 | public static final String KEY_PHONE_MD5 = "phone_md5";
16 | public static final String KEY_STATUS = "status";
17 | public static final String KEY_CODE = "code";
18 | public static final String KEY_CONTACTS = "contatcs";
19 | public static final String KEY_PAGE = "page";
20 | public static final String KEY_PERPAGE = "perpage";
21 | public static final String KEY_TIMELINE = "items";
22 | public static final String KEY_MSG_ID = "msgId";
23 | public static final String KEY_MSG = "msg";
24 | public static final String KEY_COMMENTS = "items";
25 | public static final String KEY_CONTENT = "content";
26 |
27 | public static final int RESULT_STATUS_SUCCESS = 1;
28 | public static final int RESULT_STATUS_FAIL = 0;
29 | public static final int RESULT_STATUS_INVALID_TOKEN = 2;
30 |
31 | public static final String APP_ID = "com.jikexueyuan.secret";
32 | public static final String CHARSET = "utf-8";
33 |
34 | public static final String ACTION_GET_CODE = "send_pass";
35 | public static final String ACTION_LOGIN = "login";
36 | public static final String ACTION_UPLOAD_CONTACTS = "upload_contacts";
37 | public static final String ACTION_TIMELINE = "timeline";
38 | public static final String ACTION_GET_COMMENT = "get_comment";
39 | public static final String ACTION_PUB_COMMENT = "pub_comment";
40 | public static final String ACTION_PUBLISH = "publish";
41 |
42 | public static final int ACTIVITY_RESULT_NEED_REFRESH = 10000;
43 |
44 |
45 | public static String getCachedToken(Context context){
46 | return context.getSharedPreferences(APP_ID, Context.MODE_PRIVATE).getString(KEY_TOKEN, null);
47 | }
48 |
49 | public static void cacheToken(Context context,String token){
50 | Editor e = context.getSharedPreferences(APP_ID, Context.MODE_PRIVATE).edit();
51 | e.putString(KEY_TOKEN, token);
52 | e.commit();
53 | }
54 | public static String getCachedPhoneNum(Context context){
55 | return context.getSharedPreferences(APP_ID, Context.MODE_PRIVATE).getString(KEY_PHONE_NUM, null);
56 | }
57 |
58 | public static void cachePhoneNum(Context context,String phoneNum){
59 | Editor e = context.getSharedPreferences(APP_ID, Context.MODE_PRIVATE).edit();
60 | e.putString(KEY_PHONE_NUM, phoneNum);
61 | e.commit();
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/code/ide/adt/Secret/src/com/jikexueyuan/secret/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.jikexueyuan.secret;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 |
7 | import com.jikexueyuan.secret.atys.AtyLogin;
8 | import com.jikexueyuan.secret.atys.AtyTimeline;
9 |
10 | public class MainActivity extends Activity {
11 |
12 | @Override
13 | protected void onCreate(Bundle savedInstanceState) {
14 | super.onCreate(savedInstanceState);
15 |
16 | String token = Config.getCachedToken(this);
17 | String phone_num = Config.getCachedPhoneNum(this);
18 |
19 | if (token!=null&&phone_num!=null) {
20 | Intent i =new Intent(this, AtyTimeline.class);
21 | i.putExtra(Config.KEY_TOKEN, token);
22 | i.putExtra(Config.KEY_PHONE_NUM, phone_num);
23 | startActivity(i);
24 | }else{
25 | startActivity(new Intent(this, AtyLogin.class));
26 | }
27 |
28 | finish();
29 | }
30 |
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/code/ide/adt/Secret/src/com/jikexueyuan/secret/atys/AtyLogin.java:
--------------------------------------------------------------------------------
1 | package com.jikexueyuan.secret.atys;
2 |
3 | import com.jikexueyuan.secret.Config;
4 | import com.jikexueyuan.secret.R;
5 | import com.jikexueyuan.secret.net.GetCode;
6 | import com.jikexueyuan.secret.net.Login;
7 | import com.jikexueyuan.secret.tools.MD5Tool;
8 |
9 | import android.app.Activity;
10 | import android.app.ProgressDialog;
11 | import android.content.Intent;
12 | import android.os.Bundle;
13 | import android.text.TextUtils;
14 | import android.view.View;
15 | import android.widget.EditText;
16 | import android.widget.Toast;
17 |
18 | public class AtyLogin extends Activity {
19 |
20 |
21 | @Override
22 | protected void onCreate(Bundle savedInstanceState) {
23 | super.onCreate(savedInstanceState);
24 | setContentView(R.layout.aty_login);
25 |
26 | etPhone = (EditText) findViewById(R.id.etPhoneNum);
27 | etCode = (EditText) findViewById(R.id.etCode);
28 |
29 | findViewById(R.id.btnGetCode).setOnClickListener(new View.OnClickListener() {
30 |
31 | @Override
32 | public void onClick(View arg0) {
33 |
34 | if (TextUtils.isEmpty(etPhone.getText())) {
35 | Toast.makeText(AtyLogin.this, R.string.phone_num_can_not_be_empty, Toast.LENGTH_LONG).show();
36 | return;
37 | }
38 |
39 | final ProgressDialog pd = ProgressDialog.show(AtyLogin.this, getResources().getString(R.string.connecting), getResources().getString(R.string.connecting_to_server));
40 | new GetCode(etPhone.getText().toString(), new GetCode.SuccessCallback() {
41 |
42 | @Override
43 | public void onSuccess() {
44 | pd.dismiss();
45 | Toast.makeText(AtyLogin.this, R.string.suc_to_get_code, Toast.LENGTH_LONG).show();
46 | }
47 | }, new GetCode.FailCallback() {
48 |
49 | @Override
50 | public void onFail() {
51 | pd.dismiss();
52 | Toast.makeText(AtyLogin.this, R.string.fail_to_get_code, Toast.LENGTH_LONG).show();
53 | }
54 | });
55 |
56 | }
57 | });
58 |
59 |
60 | findViewById(R.id.btnLogin).setOnClickListener(new View.OnClickListener() {
61 |
62 | @Override
63 | public void onClick(View arg0) {
64 |
65 | if (TextUtils.isEmpty(etPhone.getText())) {
66 | Toast.makeText(AtyLogin.this, R.string.phone_num_can_not_be_empty, Toast.LENGTH_LONG).show();
67 | return;
68 | }
69 |
70 | if (TextUtils.isEmpty(etCode.getText())) {
71 | Toast.makeText(AtyLogin.this, R.string.code_can_not_be_empty, Toast.LENGTH_LONG).show();
72 | return;
73 | }
74 |
75 |
76 | final ProgressDialog pd = ProgressDialog.show(AtyLogin.this, getResources().getString(R.string.connecting), getResources().getString(R.string.connecting_to_server));
77 | new Login(MD5Tool.md5(etPhone.getText().toString()), etCode.getText().toString(), new Login.SuccessCallback() {
78 |
79 | @Override
80 | public void onSuccess(String token) {
81 |
82 | pd.dismiss();
83 |
84 | Config.cacheToken(AtyLogin.this, token);
85 | Config.cachePhoneNum(AtyLogin.this, etPhone.getText().toString());
86 |
87 | Intent i = new Intent(AtyLogin.this, AtyTimeline.class);
88 | i.putExtra(Config.KEY_TOKEN, token);
89 | i.putExtra(Config.KEY_PHONE_NUM, etPhone.getText().toString());
90 | startActivity(i);
91 |
92 | finish();
93 | }
94 | }, new Login.FailCallback() {
95 |
96 | @Override
97 | public void onFail() {
98 | pd.dismiss();
99 |
100 | Toast.makeText(AtyLogin.this, R.string.fail_to_login, Toast.LENGTH_LONG).show();
101 | }
102 | });
103 |
104 | }
105 | });
106 | }
107 |
108 | private EditText etPhone = null,etCode;
109 | }
110 |
--------------------------------------------------------------------------------
/code/ide/adt/Secret/src/com/jikexueyuan/secret/atys/AtyMessage.java:
--------------------------------------------------------------------------------
1 | package com.jikexueyuan.secret.atys;
2 |
3 | import java.util.List;
4 |
5 | import com.jikexueyuan.secret.Config;
6 | import com.jikexueyuan.secret.R;
7 | import com.jikexueyuan.secret.net.Comment;
8 | import com.jikexueyuan.secret.net.GetComment;
9 | import com.jikexueyuan.secret.net.PubComment;
10 | import com.jikexueyuan.secret.tools.MD5Tool;
11 |
12 | import android.app.ListActivity;
13 | import android.app.ProgressDialog;
14 | import android.content.Intent;
15 | import android.os.Bundle;
16 | import android.text.TextUtils;
17 | import android.view.View;
18 | import android.widget.EditText;
19 | import android.widget.TextView;
20 | import android.widget.Toast;
21 |
22 | public class AtyMessage extends ListActivity{
23 |
24 | @Override
25 | protected void onCreate(Bundle savedInstanceState) {
26 | super.onCreate(savedInstanceState);
27 | setContentView(R.layout.aty_message);
28 |
29 | adapter = new AtyMessageCommentListAdapter(this);
30 | setListAdapter(adapter);
31 |
32 | tvMessage = (TextView) findViewById(R.id.tvMessage);
33 | etComment = (EditText) findViewById(R.id.etComment);
34 |
35 | Intent data = getIntent();
36 | phone_md5 = data.getStringExtra(Config.KEY_PHONE_MD5);
37 | msg = data.getStringExtra(Config.KEY_MSG);
38 | msgId = data.getStringExtra(Config.KEY_MSG_ID);
39 | token = data.getStringExtra(Config.KEY_TOKEN);
40 |
41 | tvMessage.setText(msg);
42 |
43 | getComments();
44 |
45 | findViewById(R.id.btnSendComment).setOnClickListener(new View.OnClickListener() {
46 |
47 | @Override
48 | public void onClick(View arg0) {
49 |
50 | if (TextUtils.isEmpty(etComment.getText())) {
51 | Toast.makeText(AtyMessage.this, R.string.comment_content_can_not_be_empty, Toast.LENGTH_LONG).show();
52 | return;
53 | }
54 |
55 | final ProgressDialog pd = ProgressDialog.show(AtyMessage.this, getResources().getString(R.string.connecting), getResources().getString(R.string.connecting_to_server));
56 | new PubComment(MD5Tool.md5(Config.getCachedPhoneNum(AtyMessage.this)), token, etComment.getText().toString(), msgId, new PubComment.SuccessCallback() {
57 |
58 | @Override
59 | public void onSuccess() {
60 | pd.dismiss();
61 |
62 | etComment.setText("");
63 |
64 | getComments();
65 | }
66 | }, new PubComment.FailCallback() {
67 |
68 | @Override
69 | public void onFail(int errorCode) {
70 | pd.dismiss();
71 |
72 | if (errorCode==Config.RESULT_STATUS_INVALID_TOKEN) {
73 |
74 | startActivity(new Intent(AtyMessage.this, AtyLogin.class));
75 | finish();
76 | }else{
77 | Toast.makeText(AtyMessage.this, R.string.fail_to_pub_comment, Toast.LENGTH_LONG).show();
78 | }
79 | }
80 | });
81 | }
82 | });
83 | }
84 | private void getComments() {
85 | final ProgressDialog pd = ProgressDialog.show(this, getResources().getString(R.string.connecting), getResources().getString(R.string.connecting_to_server));
86 | new GetComment(phone_md5, token, msgId, 1, 20, new GetComment.SuccessCallback() {
87 |
88 | @Override
89 | public void onSuccess(String msgId, int page, int perpage,
90 | List comments) {
91 |
92 | pd.dismiss();
93 |
94 | adapter.clear();
95 | adapter.addAll(comments);
96 | }
97 | }, new GetComment.FailCallback() {
98 |
99 | @Override
100 | public void onFail(int errorCode) {
101 | pd.dismiss();
102 |
103 | if (errorCode==Config.RESULT_STATUS_INVALID_TOKEN) {
104 | startActivity(new Intent(AtyMessage.this, AtyLogin.class));
105 | finish();
106 | }else{
107 | Toast.makeText(AtyMessage.this, R.string.fail_to_get_comment, Toast.LENGTH_LONG).show();
108 | }
109 | }
110 | });
111 | }
112 |
113 | private TextView tvMessage;
114 | private EditText etComment;
115 | private String phone_md5,msg,msgId,token;
116 | private AtyMessageCommentListAdapter adapter;
117 | }
118 |
--------------------------------------------------------------------------------
/code/ide/adt/Secret/src/com/jikexueyuan/secret/atys/AtyMessageCommentListAdapter.java:
--------------------------------------------------------------------------------
1 | package com.jikexueyuan.secret.atys;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | import android.content.Context;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 | import android.widget.BaseAdapter;
11 | import android.widget.TextView;
12 |
13 | import com.jikexueyuan.secret.R;
14 | import com.jikexueyuan.secret.net.Comment;
15 |
16 | public class AtyMessageCommentListAdapter extends BaseAdapter {
17 |
18 | public AtyMessageCommentListAdapter(Context context) {
19 | this.context = context;
20 | }
21 |
22 |
23 | @Override
24 | public int getCount() {
25 | return comments.size();
26 | }
27 |
28 | @Override
29 | public Comment getItem(int arg0) {
30 | return comments.get(arg0);
31 | }
32 |
33 | @Override
34 | public long getItemId(int arg0) {
35 | return arg0;
36 | }
37 |
38 | public void addAll(List data){
39 | comments.addAll(data);
40 | notifyDataSetChanged();
41 | }
42 |
43 | public void clear(){
44 | comments.clear();
45 | notifyDataSetChanged();
46 | }
47 |
48 |
49 | @Override
50 | public View getView(int arg0, View convertView, ViewGroup arg2) {
51 |
52 | if (convertView==null) {
53 | convertView = LayoutInflater.from(getContext()).inflate(R.layout.aty_timeline_list_cell, null);
54 | convertView.setTag(new ListCell((TextView) convertView.findViewById(R.id.tvCellLabel)));
55 | }
56 |
57 | ListCell lc = (ListCell) convertView.getTag();
58 |
59 | Comment comment = getItem(arg0);
60 |
61 | lc.getTvCellLabel().setText(comment.getContent());
62 |
63 | return convertView;
64 | }
65 |
66 | private List comments = new ArrayList();
67 |
68 | private Context context;
69 |
70 | public Context getContext() {
71 | return context;
72 | }
73 |
74 | private static class ListCell{
75 |
76 | public ListCell(TextView tvCellLabel) {
77 | this.tvCellLabel = tvCellLabel;
78 | }
79 |
80 | private TextView tvCellLabel;
81 |
82 | public TextView getTvCellLabel() {
83 | return tvCellLabel;
84 | }
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/code/ide/adt/Secret/src/com/jikexueyuan/secret/atys/AtyPublish.java:
--------------------------------------------------------------------------------
1 | package com.jikexueyuan.secret.atys;
2 |
3 | import com.jikexueyuan.secret.Config;
4 | import com.jikexueyuan.secret.R;
5 | import com.jikexueyuan.secret.net.Publish;
6 |
7 | import android.app.Activity;
8 | import android.app.ProgressDialog;
9 | import android.content.Intent;
10 | import android.os.Bundle;
11 | import android.text.TextUtils;
12 | import android.view.View;
13 | import android.widget.EditText;
14 | import android.widget.Toast;
15 |
16 | public class AtyPublish extends Activity {
17 |
18 | @Override
19 | protected void onCreate(Bundle savedInstanceState) {
20 | super.onCreate(savedInstanceState);
21 | setContentView(R.layout.aty_publish);
22 |
23 | Intent data = getIntent();
24 | phone_md5 =data.getStringExtra(Config.KEY_PHONE_MD5);
25 | token = data.getStringExtra(Config.KEY_TOKEN);
26 |
27 | etMsgContent = (EditText) findViewById(R.id.etMsgContent);
28 |
29 | findViewById(R.id.btnPublish).setOnClickListener(new View.OnClickListener() {
30 |
31 | @Override
32 | public void onClick(View arg0) {
33 |
34 | if (TextUtils.isEmpty(etMsgContent.getText())) {
35 |
36 | Toast.makeText(AtyPublish.this, R.string.message_content_can_not_be_empty, Toast.LENGTH_LONG).show();
37 | return;
38 | }
39 |
40 |
41 | final ProgressDialog pd = ProgressDialog.show(AtyPublish.this, getResources().getString(R.string.connecting), getResources().getString(R.string.connecting_to_server));
42 | new Publish(phone_md5, token, etMsgContent.getText().toString(), new Publish.SuccessCallback() {
43 |
44 | @Override
45 | public void onSuccess() {
46 | pd.dismiss();
47 |
48 | setResult(Config.ACTIVITY_RESULT_NEED_REFRESH);
49 |
50 | Toast.makeText(AtyPublish.this, R.string.suc_to_publish, Toast.LENGTH_LONG).show();
51 | finish();
52 | }
53 | }, new Publish.FailCallback() {
54 |
55 | @Override
56 | public void onFail(int errorCode) {
57 | pd.dismiss();
58 |
59 | if (errorCode==Config.RESULT_STATUS_INVALID_TOKEN) {
60 | startActivity(new Intent(AtyPublish.this, AtyLogin.class));
61 | finish();
62 | }else{
63 | Toast.makeText(AtyPublish.this, R.string.fail_to_publish, Toast.LENGTH_LONG).show();
64 | }
65 | }
66 | });
67 | }
68 | });
69 | }
70 |
71 | private EditText etMsgContent;
72 | private String phone_md5,token;
73 | }
74 |
--------------------------------------------------------------------------------
/code/ide/adt/Secret/src/com/jikexueyuan/secret/atys/AtyTimeline.java:
--------------------------------------------------------------------------------
1 | package com.jikexueyuan.secret.atys;
2 |
3 | import java.util.List;
4 |
5 | import android.app.ListActivity;
6 | import android.app.ProgressDialog;
7 | import android.content.Intent;
8 | import android.os.Bundle;
9 | import android.view.Menu;
10 | import android.view.MenuItem;
11 | import android.view.View;
12 | import android.widget.ListView;
13 | import android.widget.Toast;
14 |
15 | import com.jikexueyuan.secret.Config;
16 | import com.jikexueyuan.secret.R;
17 | import com.jikexueyuan.secret.ld.MyContacts;
18 | import com.jikexueyuan.secret.net.Message;
19 | import com.jikexueyuan.secret.net.Timeline;
20 | import com.jikexueyuan.secret.net.UploadContacts;
21 | import com.jikexueyuan.secret.tools.MD5Tool;
22 |
23 | public class AtyTimeline extends ListActivity {
24 |
25 | @Override
26 | protected void onCreate(Bundle savedInstanceState) {
27 | super.onCreate(savedInstanceState);
28 | setContentView(R.layout.aty_timeline);
29 |
30 | adapter = new AtyTimelineMessageListAdapter(this);
31 | setListAdapter(adapter);
32 |
33 | phone_num = getIntent().getStringExtra(Config.KEY_PHONE_NUM);
34 | token = getIntent().getStringExtra(Config.KEY_TOKEN);
35 | phone_md5 = MD5Tool.md5(phone_num);
36 |
37 | final ProgressDialog pd = ProgressDialog.show(this, getResources().getString(R.string.connecting), getResources().getString(R.string.connecting_to_server));
38 | new UploadContacts(phone_md5, token, MyContacts.getContactsJSONString(this), new UploadContacts.SuccessCallback() {
39 |
40 | @Override
41 | public void onSuccess() {
42 | loadMessage();
43 |
44 | pd.dismiss();
45 | }
46 | }, new UploadContacts.FailCallback() {
47 |
48 | @Override
49 | public void onFail(int errorCode) {
50 | pd.dismiss();
51 |
52 | if (errorCode==Config.RESULT_STATUS_INVALID_TOKEN) {
53 | startActivity(new Intent(AtyTimeline.this, AtyLogin.class));
54 | finish();
55 | }else{
56 | loadMessage();
57 | }
58 | }
59 | });
60 | }
61 |
62 |
63 | private void loadMessage(){
64 | final ProgressDialog pd = ProgressDialog.show(this, getResources().getString(R.string.connecting), getResources().getString(R.string.connecting_to_server));
65 |
66 | new Timeline(phone_md5, token, 1, 20, new Timeline.SuccessCallback() {
67 |
68 | @Override
69 | public void onSuccess(int page, int perpage, List timeline) {
70 | pd.dismiss();
71 |
72 | adapter.clear();
73 | adapter.addAll(timeline);
74 | }
75 | }, new Timeline.FailCallback() {
76 |
77 | @Override
78 | public void onFail(int errorCode) {
79 | pd.dismiss();
80 |
81 | if (errorCode==Config.RESULT_STATUS_INVALID_TOKEN) {
82 | startActivity(new Intent(AtyTimeline.this, AtyLogin.class));
83 | finish();
84 | }else{
85 | Toast.makeText(AtyTimeline.this, R.string.fail_to_load_timeline_data, Toast.LENGTH_LONG).show();
86 | }
87 | }
88 | });
89 | }
90 |
91 | @Override
92 | protected void onListItemClick(ListView l, View v, int position, long id) {
93 | super.onListItemClick(l, v, position, id);
94 |
95 | Message msg = adapter.getItem(position);
96 | Intent i = new Intent(this, AtyMessage.class);
97 | i.putExtra(Config.KEY_MSG, msg.getMsg());
98 | i.putExtra(Config.KEY_MSG_ID, msg.getMsgId());
99 | i.putExtra(Config.KEY_PHONE_MD5, msg.getPhone_md5());
100 | i.putExtra(Config.KEY_TOKEN, token);
101 | startActivity(i);
102 | }
103 |
104 |
105 | @Override
106 | public boolean onCreateOptionsMenu(Menu menu) {
107 | getMenuInflater().inflate(R.menu.menu_aty_timeline, menu);
108 | return true;
109 | }
110 |
111 | @Override
112 | public boolean onOptionsItemSelected(MenuItem item) {
113 | switch (item.getItemId()) {
114 | case R.id.menuShowAtyPublish:
115 | Intent i = new Intent(AtyTimeline.this, AtyPublish.class);
116 | i.putExtra(Config.KEY_PHONE_MD5, phone_md5);
117 | i.putExtra(Config.KEY_TOKEN, token);
118 | startActivityForResult(i, 0);
119 | break;
120 | default:
121 | break;
122 | }
123 |
124 | return true;
125 | }
126 |
127 |
128 | @Override
129 | protected void onActivityResult(int requestCode, int resultCode, Intent data) {
130 | switch (resultCode) {
131 | case Config.ACTIVITY_RESULT_NEED_REFRESH:
132 | loadMessage();
133 | break;
134 | default:
135 | break;
136 | }
137 | }
138 |
139 |
140 | private String phone_num,token,phone_md5;
141 | private AtyTimelineMessageListAdapter adapter=null;
142 | }
143 |
--------------------------------------------------------------------------------
/code/ide/adt/Secret/src/com/jikexueyuan/secret/atys/AtyTimelineMessageListAdapter.java:
--------------------------------------------------------------------------------
1 | package com.jikexueyuan.secret.atys;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | import android.content.Context;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 | import android.widget.BaseAdapter;
11 | import android.widget.TextView;
12 |
13 | import com.jikexueyuan.secret.R;
14 | import com.jikexueyuan.secret.net.Message;
15 |
16 | public class AtyTimelineMessageListAdapter extends BaseAdapter{
17 |
18 |
19 | public AtyTimelineMessageListAdapter(Context context) {
20 | this.context = context;
21 | }
22 |
23 | @Override
24 | public int getCount() {
25 | return data.size();
26 | }
27 |
28 | @Override
29 | public Message getItem(int position) {
30 | return data.get(position);
31 | }
32 |
33 | @Override
34 | public long getItemId(int position) {
35 | return position;
36 | }
37 |
38 | @Override
39 | public View getView(int position, View convertView, ViewGroup parent) {
40 | if (convertView==null) {
41 | convertView = LayoutInflater.from(getContext()).inflate(R.layout.aty_timeline_list_cell, null);
42 | convertView.setTag(new ListCell((TextView) convertView.findViewById(R.id.tvCellLabel)));
43 | }
44 |
45 | ListCell lc = (ListCell) convertView.getTag();
46 |
47 | Message msg = getItem(position);
48 |
49 | lc.getTvCellLabel().setText(msg.getMsg());
50 |
51 | return convertView;
52 | }
53 |
54 | public Context getContext() {
55 | return context;
56 | }
57 |
58 | public void addAll(List data){
59 | this.data.addAll(data);
60 | notifyDataSetChanged();
61 | }
62 |
63 | public void clear(){
64 | data.clear();
65 | notifyDataSetChanged();
66 | }
67 |
68 | private List data = new ArrayList();
69 | private Context context=null;
70 |
71 | private static class ListCell{
72 |
73 | public ListCell(TextView tvCellLabel) {
74 | this.tvCellLabel = tvCellLabel;
75 | }
76 |
77 | private TextView tvCellLabel;
78 |
79 | public TextView getTvCellLabel() {
80 | return tvCellLabel;
81 | }
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/code/ide/adt/Secret/src/com/jikexueyuan/secret/ld/MyContacts.java:
--------------------------------------------------------------------------------
1 | package com.jikexueyuan.secret.ld;
2 |
3 | import org.json.JSONArray;
4 | import org.json.JSONException;
5 | import org.json.JSONObject;
6 |
7 | import com.jikexueyuan.secret.Config;
8 | import com.jikexueyuan.secret.tools.MD5Tool;
9 |
10 | import android.content.Context;
11 | import android.database.Cursor;
12 | import android.provider.ContactsContract.CommonDataKinds.Phone;
13 |
14 | public class MyContacts {
15 |
16 | public static String getContactsJSONString(Context context){
17 | Cursor c = context.getContentResolver().query(Phone.CONTENT_URI, null, null, null, null);
18 | String phoneNum;
19 | JSONArray jsonArr = new JSONArray();
20 | JSONObject jsonObj;
21 |
22 | while(c.moveToNext()){
23 | phoneNum = c.getString(c.getColumnIndex(Phone.NUMBER));
24 |
25 | if (phoneNum.charAt(0)=='+'&&
26 | phoneNum.charAt(1)=='8'&&
27 | phoneNum.charAt(2)=='6') {
28 | phoneNum = phoneNum.substring(3);
29 | }
30 |
31 | jsonObj = new JSONObject();
32 | try {
33 | jsonObj.put(Config.KEY_PHONE_MD5, MD5Tool.md5(phoneNum));
34 | } catch (JSONException e) {
35 | e.printStackTrace();
36 | }
37 |
38 | jsonArr.put(jsonObj);
39 | }
40 |
41 | return jsonArr.toString();
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/code/ide/adt/Secret/src/com/jikexueyuan/secret/net/Comment.java:
--------------------------------------------------------------------------------
1 | package com.jikexueyuan.secret.net;
2 |
3 | public class Comment {
4 |
5 |
6 | public Comment(String content,String phone_md5) {
7 | this.content = content;
8 | this.phone_md5 = phone_md5;
9 | }
10 |
11 | private String content,phone_md5;
12 |
13 | public String getContent() {
14 | return content;
15 | }
16 |
17 | public String getPhone_md5() {
18 | return phone_md5;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/code/ide/adt/Secret/src/com/jikexueyuan/secret/net/GetCode.java:
--------------------------------------------------------------------------------
1 | package com.jikexueyuan.secret.net;
2 |
3 | import org.json.JSONException;
4 | import org.json.JSONObject;
5 |
6 | import com.jikexueyuan.secret.Config;
7 |
8 | public class GetCode {
9 |
10 | public GetCode(String phone,final SuccessCallback successCallback,final FailCallback failCallback) {
11 |
12 |
13 | new NetConnection(Config.SERVER_URL, HttpMethod.POST, new NetConnection.SuccessCallback() {
14 |
15 | @Override
16 | public void onSuccess(String result) {
17 |
18 | try {
19 | JSONObject jsonObj = new JSONObject(result);
20 | switch (jsonObj.getInt(Config.KEY_STATUS)) {
21 | case Config.RESULT_STATUS_SUCCESS:
22 | if (successCallback!=null) {
23 | successCallback.onSuccess();
24 | }
25 | break;
26 | default:
27 | if (failCallback!=null) {
28 | failCallback.onFail();
29 | }
30 | break;
31 | }
32 |
33 | } catch (JSONException e) {
34 | e.printStackTrace();
35 |
36 | if (failCallback!=null) {
37 | failCallback.onFail();
38 | }
39 | }
40 |
41 | }
42 | }, new NetConnection.FailCallback() {
43 |
44 | @Override
45 | public void onFail() {
46 | if (failCallback!=null) {
47 | failCallback.onFail();
48 | }
49 | }
50 | }, Config.KEY_ACTION,Config.ACTION_GET_CODE,Config.KEY_PHONE_NUM,phone);
51 |
52 | }
53 |
54 |
55 | public static interface SuccessCallback{
56 | void onSuccess();
57 | }
58 |
59 | public static interface FailCallback{
60 | void onFail();
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/code/ide/adt/Secret/src/com/jikexueyuan/secret/net/GetComment.java:
--------------------------------------------------------------------------------
1 | package com.jikexueyuan.secret.net;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | import org.json.JSONArray;
7 | import org.json.JSONException;
8 | import org.json.JSONObject;
9 |
10 | import com.jikexueyuan.secret.Config;
11 |
12 | public class GetComment {
13 |
14 | public GetComment(String phone_md5,String token,String msgId,int page,int perpage,final SuccessCallback successCallback,final FailCallback failCallback) {
15 | new NetConnection(Config.SERVER_URL, HttpMethod.POST, new NetConnection.SuccessCallback() {
16 |
17 | @Override
18 | public void onSuccess(String result) {
19 | try {
20 | JSONObject jsonObject = new JSONObject(result);
21 |
22 | switch (jsonObject.getInt(Config.KEY_STATUS)) {
23 | case Config.RESULT_STATUS_SUCCESS:
24 | if (successCallback!=null) {
25 | List comments = new ArrayList();
26 | JSONArray commentsJsonArray =jsonObject.getJSONArray(Config.KEY_COMMENTS);
27 | JSONObject commentObj;
28 | for (int i = 0; i < commentsJsonArray.length(); i++) {
29 | commentObj = commentsJsonArray.getJSONObject(i);
30 | comments.add(new Comment(commentObj.getString(Config.KEY_CONTENT), commentObj.getString(Config.KEY_PHONE_MD5)));
31 | }
32 |
33 | // successCallback.onSuccess(jsonObject.getString(Config.KEY_MSG_ID), jsonObject.getInt(Config.KEY_PAGE), jsonObject.getInt(Config.KEY_PERPAGE), comments);
34 | successCallback.onSuccess("123", 1, 20, comments);
35 | }
36 |
37 | break;
38 | case Config.RESULT_STATUS_INVALID_TOKEN:
39 | if (failCallback!=null) {
40 | failCallback.onFail(Config.RESULT_STATUS_INVALID_TOKEN);
41 | }
42 | break;
43 | default:
44 | if (failCallback!=null) {
45 | failCallback.onFail(Config.RESULT_STATUS_FAIL);
46 | }
47 | break;
48 | }
49 |
50 | } catch (JSONException e) {
51 | e.printStackTrace();
52 | if (failCallback!=null) {
53 | failCallback.onFail(Config.RESULT_STATUS_FAIL);
54 | }
55 | }
56 | }
57 | }, new NetConnection.FailCallback() {
58 |
59 | @Override
60 | public void onFail() {
61 | if (failCallback!=null) {
62 | failCallback.onFail(Config.RESULT_STATUS_FAIL);
63 | }
64 | }
65 | }, Config.KEY_ACTION,Config.ACTION_GET_COMMENT,
66 | Config.KEY_TOKEN,token,
67 | Config.KEY_MSG_ID,msgId,
68 | Config.KEY_PAGE,page+"",
69 | Config.KEY_PERPAGE,perpage+"");
70 | }
71 |
72 |
73 | public static interface SuccessCallback{
74 | void onSuccess(String msgId,int page,int perpage,List comments);
75 | }
76 |
77 | public static interface FailCallback{
78 | void onFail(int errorCode);
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/code/ide/adt/Secret/src/com/jikexueyuan/secret/net/HttpMethod.java:
--------------------------------------------------------------------------------
1 | package com.jikexueyuan.secret.net;
2 |
3 | public enum HttpMethod {
4 |
5 | GET,POST
6 | }
7 |
--------------------------------------------------------------------------------
/code/ide/adt/Secret/src/com/jikexueyuan/secret/net/Login.java:
--------------------------------------------------------------------------------
1 | package com.jikexueyuan.secret.net;
2 |
3 | import org.json.JSONException;
4 | import org.json.JSONObject;
5 |
6 | import com.jikexueyuan.secret.Config;
7 |
8 | public class Login {
9 |
10 | public Login(String phone_md5,String code,final SuccessCallback successCallback,final FailCallback failCallback) {
11 | new NetConnection(Config.SERVER_URL, HttpMethod.POST, new NetConnection.SuccessCallback() {
12 |
13 | @Override
14 | public void onSuccess(String result) {
15 | try {
16 | JSONObject obj = new JSONObject(result);
17 |
18 | switch (obj.getInt(Config.KEY_STATUS)) {
19 | case Config.RESULT_STATUS_SUCCESS:
20 | if (successCallback!=null) {
21 | successCallback.onSuccess(obj.getString(Config.KEY_TOKEN));
22 | }
23 | break;
24 | default:
25 | if (failCallback!=null) {
26 | failCallback.onFail();
27 | }
28 | break;
29 | }
30 |
31 | } catch (JSONException e) {
32 | e.printStackTrace();
33 |
34 | if (failCallback!=null) {
35 | failCallback.onFail();
36 | }
37 | }
38 | }
39 | }, new NetConnection.FailCallback() {
40 |
41 | @Override
42 | public void onFail() {
43 | if (failCallback!=null) {
44 | failCallback.onFail();
45 | }
46 | }
47 | }, Config.KEY_ACTION,Config.ACTION_LOGIN,Config.KEY_PHONE_MD5,phone_md5,Config.KEY_CODE,code);
48 | }
49 |
50 | public static interface SuccessCallback{
51 | void onSuccess(String token);
52 | }
53 |
54 | public static interface FailCallback{
55 | void onFail();
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/code/ide/adt/Secret/src/com/jikexueyuan/secret/net/Message.java:
--------------------------------------------------------------------------------
1 | package com.jikexueyuan.secret.net;
2 |
3 | public class Message {
4 |
5 | public Message(String msgId,String msg,String phone_md5) {
6 | this.msg = msg;
7 | this.msgId = msgId;
8 | this.phone_md5 = phone_md5;
9 | }
10 |
11 | private String msgId=null,msg=null,phone_md5=null;
12 |
13 | public String getMsg() {
14 | return msg;
15 | }
16 |
17 | public String getMsgId() {
18 | return msgId;
19 | }
20 |
21 | public String getPhone_md5() {
22 | return phone_md5;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/code/ide/adt/Secret/src/com/jikexueyuan/secret/net/NetConnection.java:
--------------------------------------------------------------------------------
1 | package com.jikexueyuan.secret.net;
2 |
3 | import java.io.BufferedReader;
4 | import java.io.BufferedWriter;
5 | import java.io.IOException;
6 | import java.io.InputStreamReader;
7 | import java.io.OutputStreamWriter;
8 | import java.net.MalformedURLException;
9 | import java.net.URL;
10 | import java.net.URLConnection;
11 |
12 | import com.jikexueyuan.secret.Config;
13 |
14 | import android.os.AsyncTask;
15 |
16 |
17 | public class NetConnection {
18 |
19 | public NetConnection(final String url,final HttpMethod method,final SuccessCallback successCallback,final FailCallback failCallback,final String ... kvs) {
20 |
21 | new AsyncTask() {
22 |
23 | @Override
24 | protected String doInBackground(Void... arg0) {
25 |
26 | StringBuffer paramsStr = new StringBuffer();
27 | for (int i = 0; i < kvs.length; i+=2) {
28 | paramsStr.append(kvs[i]).append("=").append(kvs[i+1]).append("&");
29 | }
30 |
31 |
32 | try {
33 | URLConnection uc;
34 |
35 | switch (method) {
36 | case POST:
37 | uc = new URL(url).openConnection();
38 | uc.setDoOutput(true);
39 | BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(uc.getOutputStream(), Config.CHARSET));
40 | bw.write(paramsStr.toString());
41 | bw.flush();
42 | break;
43 | default:
44 | uc = new URL(url+"?"+paramsStr.toString()).openConnection();
45 | break;
46 | }
47 |
48 | System.out.println("Request url:"+uc.getURL());
49 | System.out.println("Request data:"+paramsStr);
50 |
51 | BufferedReader br = new BufferedReader(new InputStreamReader(uc.getInputStream(), Config.CHARSET));
52 | String line = null;
53 | StringBuffer result = new StringBuffer();
54 | while((line=br.readLine())!=null){
55 | result.append(line);
56 | }
57 |
58 | System.out.println("Result:"+result);
59 | return result.toString();
60 |
61 | } catch (MalformedURLException e) {
62 | e.printStackTrace();
63 | } catch (IOException e) {
64 | e.printStackTrace();
65 | }
66 |
67 | return null;
68 | }
69 |
70 | @Override
71 | protected void onPostExecute(String result) {
72 |
73 | if (result!=null) {
74 | if (successCallback!=null) {
75 | successCallback.onSuccess(result);
76 | }
77 | }else{
78 | if (failCallback!=null) {
79 | failCallback.onFail();
80 | }
81 | }
82 |
83 | super.onPostExecute(result);
84 | }
85 | }.execute();
86 |
87 | }
88 |
89 |
90 | public static interface SuccessCallback{
91 | void onSuccess(String result);
92 | }
93 |
94 | public static interface FailCallback{
95 | void onFail();
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/code/ide/adt/Secret/src/com/jikexueyuan/secret/net/PubComment.java:
--------------------------------------------------------------------------------
1 | package com.jikexueyuan.secret.net;
2 |
3 | import org.json.JSONException;
4 | import org.json.JSONObject;
5 |
6 | import com.jikexueyuan.secret.Config;
7 |
8 | public class PubComment {
9 |
10 | public PubComment(String phone_md5,String token,String content,String msgId,final SuccessCallback successCallback,final FailCallback failCallback) {
11 | new NetConnection(Config.SERVER_URL, HttpMethod.POST, new NetConnection.SuccessCallback() {
12 |
13 | @Override
14 | public void onSuccess(String result) {
15 | try {
16 | JSONObject obj = new JSONObject(result);
17 | switch (obj.getInt(Config.KEY_STATUS)) {
18 | case Config.RESULT_STATUS_SUCCESS:
19 | if (successCallback!=null) {
20 | successCallback.onSuccess();
21 | }
22 | break;
23 | case Config.RESULT_STATUS_INVALID_TOKEN:
24 | if (failCallback!=null) {
25 | failCallback.onFail(Config.RESULT_STATUS_INVALID_TOKEN);
26 | }
27 | break;
28 | default:
29 | if (failCallback!=null) {
30 | failCallback.onFail(Config.RESULT_STATUS_FAIL);
31 | }
32 | break;
33 | }
34 |
35 | } catch (JSONException e) {
36 | e.printStackTrace();
37 |
38 | if (failCallback!=null) {
39 | failCallback.onFail(Config.RESULT_STATUS_FAIL);
40 | }
41 | }
42 | }
43 | }, new NetConnection.FailCallback() {
44 |
45 | @Override
46 | public void onFail() {
47 | if (failCallback!=null) {
48 | failCallback.onFail(Config.RESULT_STATUS_FAIL);
49 | }
50 | }
51 | }, Config.KEY_ACTION,Config.ACTION_PUB_COMMENT,
52 | Config.KEY_TOKEN,token,
53 | Config.KEY_PHONE_MD5,phone_md5,
54 | Config.KEY_MSG_ID,msgId);
55 | }
56 |
57 |
58 | public static interface SuccessCallback{
59 | void onSuccess();
60 | }
61 |
62 | public static interface FailCallback{
63 | void onFail(int errorCode);
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/code/ide/adt/Secret/src/com/jikexueyuan/secret/net/Publish.java:
--------------------------------------------------------------------------------
1 | package com.jikexueyuan.secret.net;
2 |
3 | import org.json.JSONException;
4 | import org.json.JSONObject;
5 |
6 | import com.jikexueyuan.secret.Config;
7 |
8 | public class Publish {
9 |
10 |
11 | public Publish(String phone_md5,String token,String msg,final SuccessCallback successCallback,final FailCallback failCallback) {
12 | new NetConnection(Config.SERVER_URL, HttpMethod.POST, new NetConnection.SuccessCallback() {
13 |
14 | @Override
15 | public void onSuccess(String result) {
16 | try {
17 | JSONObject jsonObject = new JSONObject(result);
18 |
19 | switch (jsonObject.getInt(Config.KEY_STATUS)) {
20 | case Config.RESULT_STATUS_SUCCESS:
21 | if (successCallback!=null) {
22 | successCallback.onSuccess();
23 | }
24 | break;
25 | case Config.RESULT_STATUS_INVALID_TOKEN:
26 | if (failCallback!=null) {
27 | failCallback.onFail(Config.RESULT_STATUS_INVALID_TOKEN);
28 | }
29 | break;
30 | default:
31 | if (failCallback!=null) {
32 | failCallback.onFail(Config.RESULT_STATUS_FAIL);
33 | }
34 | break;
35 | }
36 |
37 | } catch (JSONException e) {
38 | e.printStackTrace();
39 |
40 | if (failCallback!=null) {
41 | failCallback.onFail(Config.RESULT_STATUS_FAIL);
42 | }
43 | }
44 | }
45 | }, new NetConnection.FailCallback() {
46 |
47 | @Override
48 | public void onFail() {
49 | if (failCallback!=null) {
50 | failCallback.onFail(Config.RESULT_STATUS_FAIL);
51 | }
52 | }
53 | }, Config.KEY_ACTION,Config.ACTION_PUBLISH,
54 | Config.KEY_PHONE_MD5,phone_md5,
55 | Config.KEY_TOKEN,token,
56 | Config.KEY_MSG,msg);
57 | }
58 |
59 | public static interface SuccessCallback{
60 | void onSuccess();
61 | }
62 |
63 | public static interface FailCallback{
64 | void onFail(int errorCode);
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/code/ide/adt/Secret/src/com/jikexueyuan/secret/net/Timeline.java:
--------------------------------------------------------------------------------
1 | package com.jikexueyuan.secret.net;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | import org.json.JSONArray;
7 | import org.json.JSONException;
8 | import org.json.JSONObject;
9 |
10 | import com.jikexueyuan.secret.Config;
11 |
12 | public class Timeline {
13 |
14 | public Timeline(String phone_md5,String token,int page,int perpage,final SuccessCallback successCallback,final FailCallback failCallback) {
15 | new NetConnection(Config.SERVER_URL , HttpMethod.POST, new NetConnection.SuccessCallback() {
16 |
17 | @Override
18 | public void onSuccess(String result) {
19 | try {
20 | JSONObject obj = new JSONObject(result);
21 |
22 | switch (obj.getInt(Config.KEY_STATUS)) {
23 | case Config.RESULT_STATUS_SUCCESS:
24 | if (successCallback!=null) {
25 | List msgs = new ArrayList();
26 | JSONArray msgJsonArray = obj.getJSONArray(Config.KEY_TIMELINE);
27 | JSONObject msgObj;
28 | for (int i = 0; i timeline);
78 | }
79 |
80 | public static interface FailCallback{
81 | void onFail(int errorCode);
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/code/ide/adt/Secret/src/com/jikexueyuan/secret/net/UploadContacts.java:
--------------------------------------------------------------------------------
1 | package com.jikexueyuan.secret.net;
2 |
3 | import org.json.JSONException;
4 | import org.json.JSONObject;
5 |
6 | import com.jikexueyuan.secret.Config;
7 |
8 | public class UploadContacts {
9 |
10 |
11 | public UploadContacts(String phone_md5,String token,String contacts,final SuccessCallback successCallback,final FailCallback failCallback) {
12 |
13 |
14 | new NetConnection(Config.SERVER_URL, HttpMethod.POST, new NetConnection.SuccessCallback() {
15 |
16 | @Override
17 | public void onSuccess(String result) {
18 | try {
19 | JSONObject obj = new JSONObject(result);
20 |
21 | switch (obj.getInt(Config.KEY_STATUS)) {
22 | case Config.RESULT_STATUS_SUCCESS:
23 | if (successCallback!=null) {
24 | successCallback.onSuccess();
25 | }
26 | break;
27 | case Config.RESULT_STATUS_INVALID_TOKEN:
28 | if (failCallback!=null) {
29 | failCallback.onFail(Config.RESULT_STATUS_INVALID_TOKEN);
30 | }
31 | break;
32 | default:
33 | if (failCallback!=null) {
34 | failCallback.onFail(Config.RESULT_STATUS_FAIL);
35 | }
36 | break;
37 | }
38 |
39 | } catch (JSONException e) {
40 | e.printStackTrace();
41 | if (failCallback!=null) {
42 | failCallback.onFail(Config.RESULT_STATUS_FAIL);
43 | }
44 | }
45 | }
46 | }, new NetConnection.FailCallback() {
47 |
48 | @Override
49 | public void onFail() {
50 | if (failCallback!=null) {
51 | failCallback.onFail(Config.RESULT_STATUS_FAIL);
52 | }
53 | }
54 | }, Config.KEY_ACTION,Config.ACTION_UPLOAD_CONTACTS,Config.KEY_PHONE_MD5,phone_md5,Config.KEY_TOKEN,token,Config.KEY_CONTACTS,contacts);
55 |
56 | }
57 |
58 |
59 | public static interface SuccessCallback{
60 | void onSuccess();
61 | }
62 |
63 | public static interface FailCallback{
64 | void onFail(int errorCode);
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/code/ide/adt/Secret/src/com/jikexueyuan/secret/tools/MD5Tool.java:
--------------------------------------------------------------------------------
1 | package com.jikexueyuan.secret.tools;
2 |
3 | import java.io.UnsupportedEncodingException;
4 | import java.security.MessageDigest;
5 | import java.security.NoSuchAlgorithmException;
6 |
7 | public class MD5Tool {
8 |
9 | public static String md5(String string) {
10 | byte[] hash;
11 | try {
12 | hash = MessageDigest.getInstance("MD5").digest(string.getBytes("UTF-8"));
13 | } catch (NoSuchAlgorithmException e) {
14 | throw new RuntimeException("Huh, MD5 should be supported?", e);
15 | } catch (UnsupportedEncodingException e) {
16 | throw new RuntimeException("Huh, UTF-8 should be supported?", e);
17 | }
18 |
19 | StringBuilder hex = new StringBuilder(hash.length * 2);
20 | for (byte b : hash) {
21 | if ((b & 0xFF) < 0x10) hex.append("0");
22 | hex.append(Integer.toHexString(b & 0xFF));
23 | }
24 | return hex.toString();
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/code/ide/adt/SecretClientPublish/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/code/ide/adt/SecretClientPublish/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | SecretClientPublish
4 |
5 |
6 |
7 |
8 |
9 | com.android.ide.eclipse.adt.ResourceManagerBuilder
10 |
11 |
12 |
13 |
14 | com.android.ide.eclipse.adt.PreCompilerBuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.jdt.core.javabuilder
20 |
21 |
22 |
23 |
24 | com.android.ide.eclipse.adt.ApkBuilder
25 |
26 |
27 |
28 |
29 |
30 | com.android.ide.eclipse.adt.AndroidNature
31 | org.eclipse.jdt.core.javanature
32 |
33 |
34 |
--------------------------------------------------------------------------------
/code/ide/adt/SecretClientPublish/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
3 | org.eclipse.jdt.core.compiler.compliance=1.6
4 | org.eclipse.jdt.core.compiler.source=1.6
5 |
--------------------------------------------------------------------------------
/code/ide/adt/SecretClientPublish/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
11 |
12 |
13 |
14 |
19 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/code/ide/adt/SecretClientPublish/ic_launcher-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/plter/jikexueyuanSecret/26177f31535a5594466f3b1b8ec7d53aabad3a32/code/ide/adt/SecretClientPublish/ic_launcher-web.png
--------------------------------------------------------------------------------
/code/ide/adt/SecretClientPublish/libs/android-support-v4.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/plter/jikexueyuanSecret/26177f31535a5594466f3b1b8ec7d53aabad3a32/code/ide/adt/SecretClientPublish/libs/android-support-v4.jar
--------------------------------------------------------------------------------
/code/ide/adt/SecretClientPublish/proguard-project.txt:
--------------------------------------------------------------------------------
1 | # To enable ProGuard in your project, edit project.properties
2 | # to define the proguard.config property as described in that file.
3 | #
4 | # Add project specific ProGuard rules here.
5 | # By default, the flags in this file are appended to flags specified
6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt
7 | # You can edit the include path and order by changing the ProGuard
8 | # include property in project.properties.
9 | #
10 | # For more details, see
11 | # http://developer.android.com/guide/developing/tools/proguard.html
12 |
13 | # Add any project specific keep options here:
14 |
15 | # If your project uses WebView with JS, uncomment the following
16 | # and specify the fully qualified class name to the JavaScript interface
17 | # class:
18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
19 | # public *;
20 | #}
21 |
--------------------------------------------------------------------------------
/code/ide/adt/SecretClientPublish/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system edit
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 | #
10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
12 |
13 | # Project target.
14 | target=android-19
15 |
--------------------------------------------------------------------------------
/code/ide/adt/SecretClientPublish/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/plter/jikexueyuanSecret/26177f31535a5594466f3b1b8ec7d53aabad3a32/code/ide/adt/SecretClientPublish/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/code/ide/adt/SecretClientPublish/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/plter/jikexueyuanSecret/26177f31535a5594466f3b1b8ec7d53aabad3a32/code/ide/adt/SecretClientPublish/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/code/ide/adt/SecretClientPublish/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/plter/jikexueyuanSecret/26177f31535a5594466f3b1b8ec7d53aabad3a32/code/ide/adt/SecretClientPublish/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/code/ide/adt/SecretClientPublish/res/drawable-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/plter/jikexueyuanSecret/26177f31535a5594466f3b1b8ec7d53aabad3a32/code/ide/adt/SecretClientPublish/res/drawable-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/code/ide/adt/SecretClientPublish/res/layout/aty_login.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
18 |
19 |
26 |
27 |
34 |
35 |
39 |
40 |
47 |
48 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/code/ide/adt/SecretClientPublish/res/layout/aty_timeline.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/code/ide/adt/SecretClientPublish/res/menu/main.xml:
--------------------------------------------------------------------------------
1 |
12 |
--------------------------------------------------------------------------------
/code/ide/adt/SecretClientPublish/res/values-v11/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/code/ide/adt/SecretClientPublish/res/values-v14/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/code/ide/adt/SecretClientPublish/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 | 64dp
9 |
10 |
11 |
--------------------------------------------------------------------------------
/code/ide/adt/SecretClientPublish/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 16dp
5 | 16dp
6 |
7 |
8 |
--------------------------------------------------------------------------------
/code/ide/adt/SecretClientPublish/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 匿名
5 | 手机号
6 | 验证码
7 | 设置
8 | 你好
9 | 获取验证码
10 | 登陆
11 | 手机号不能为空
12 | 验证码不能为空
13 | 获取验证码失败,请重试
14 | 获取验证码成功,如果1分钟内没收到短信,请重试
15 | 登陆失败,请稍候重试
16 | 正在通信,请稍候
17 | 请稍候
18 | 加载消息失败
19 |
20 |
21 |
--------------------------------------------------------------------------------
/code/ide/adt/SecretClientPublish/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
14 |
15 |
16 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/code/ide/adt/SecretClientPublish/src/com/jikexueyuan/secretclientpublish/AtyLogin.java:
--------------------------------------------------------------------------------
1 | package com.jikexueyuan.secretclientpublish;
2 |
3 | import android.app.Activity;
4 | import android.app.ProgressDialog;
5 | import android.content.Intent;
6 | import android.os.Bundle;
7 | import android.text.TextUtils;
8 | import android.view.View;
9 | import android.widget.EditText;
10 | import android.widget.Toast;
11 |
12 | import com.jikexueyuan.secretclientpublish.net.GetCode;
13 | import com.jikexueyuan.secretclientpublish.net.Login;
14 | import com.jikexueyuan.secretclientpublish.tool.MD5Tool;
15 |
16 | public class AtyLogin extends Activity {
17 |
18 | @Override
19 | protected void onCreate(Bundle savedInstanceState) {
20 | super.onCreate(savedInstanceState);
21 | setContentView(R.layout.aty_login);
22 |
23 | etPhoneNum = (EditText) findViewById(R.id.etPhoneNum);
24 | etCode = (EditText) findViewById(R.id.etCode);
25 |
26 | findViewById(R.id.btnGetCode).setOnClickListener(new View.OnClickListener() {
27 |
28 | @Override
29 | public void onClick(View arg0) {
30 |
31 | if (!TextUtils.isEmpty(etPhoneNum.getText())) {
32 |
33 | final ProgressDialog pd = ProgressDialog.show(AtyLogin.this, getResources().getString(R.string.connecting_title),getResources().getString(R.string.connecting));
34 |
35 | new GetCode(etPhoneNum.getText().toString(), new GetCode.SuccessCallback() {
36 |
37 | @Override
38 | public void onSuccess() {
39 | pd.dismiss();
40 | Toast.makeText(AtyLogin.this, R.string.suc_to_get_code,Toast.LENGTH_LONG).show();
41 | }
42 | }, new GetCode.FailCallback() {
43 |
44 | @Override
45 | public void onFail() {
46 | pd.dismiss();
47 | Toast.makeText(AtyLogin.this, R.string.retry_get_code, Toast.LENGTH_LONG).show();
48 | }
49 | });
50 | }else{
51 | Toast.makeText(AtyLogin.this, R.string.phone_num_can_not_be_empty, Toast.LENGTH_LONG).show();
52 | }
53 | }
54 | });
55 |
56 | findViewById(R.id.btnLogin).setOnClickListener(new View.OnClickListener() {
57 |
58 | @Override
59 | public void onClick(View arg0) {
60 |
61 | if (TextUtils.isEmpty(etPhoneNum.getText())) {
62 | Toast.makeText(AtyLogin.this, R.string.phone_num_can_not_be_empty, Toast.LENGTH_LONG).show();
63 | return;
64 | }
65 |
66 | if (TextUtils.isEmpty(etCode.getText())) {
67 | Toast.makeText(AtyLogin.this, R.string.code_can_not_be_empty, Toast.LENGTH_LONG).show();
68 | return;
69 | }
70 |
71 | final ProgressDialog pd = ProgressDialog.show(AtyLogin.this, getResources().getString(R.string.connecting_title), getResources().getString(R.string.connecting));
72 | new Login(MD5Tool.md5(etPhoneNum.getText().toString()), etCode.getText().toString(), new Login.SuccessCallback() {
73 |
74 | @Override
75 | public void onSuccess(String token) {
76 | pd.dismiss();
77 |
78 | Config.saveToken(AtyLogin.this, token);
79 | Config.saveCurrentLoggedPhoneNum(AtyLogin.this, etPhoneNum.getText().toString());
80 |
81 |
82 | Intent i = new Intent(AtyLogin.this, AtyTimeline.class);
83 | i.putExtra(Config.KEY_TOKEN, token);
84 | i.putExtra(Config.KEY_PHONE_NUM, etPhoneNum.getText().toString());
85 | startActivity(i);
86 | System.out.println("token="+token);
87 |
88 | finish();
89 | }
90 | }, new Login.FailCallback() {
91 |
92 | @Override
93 | public void onFail() {
94 | pd.dismiss();
95 |
96 | Toast.makeText(AtyLogin.this, R.string.fail_to_login, Toast.LENGTH_LONG).show();
97 | }
98 | });
99 | }
100 | });
101 | }
102 |
103 | private EditText etPhoneNum;
104 | private EditText etCode;
105 | }
106 |
--------------------------------------------------------------------------------
/code/ide/adt/SecretClientPublish/src/com/jikexueyuan/secretclientpublish/AtyTimeline.java:
--------------------------------------------------------------------------------
1 | package com.jikexueyuan.secretclientpublish;
2 |
3 | import android.app.ListActivity;
4 | import android.app.ProgressDialog;
5 | import android.os.Bundle;
6 | import android.widget.Toast;
7 |
8 | import com.jikexueyuan.secretclientpublish.ld.MyContacts;
9 | import com.jikexueyuan.secretclientpublish.net.Timeline;
10 | import com.jikexueyuan.secretclientpublish.net.UploadContacts;
11 | import com.jikexueyuan.secretclientpublish.tool.MD5Tool;
12 |
13 | public class AtyTimeline extends ListActivity {
14 |
15 | @Override
16 | protected void onCreate(Bundle savedInstanceState) {
17 | super.onCreate(savedInstanceState);
18 | setContentView(R.layout.aty_timeline);
19 |
20 | final String phoneNum = getIntent().getStringExtra(Config.KEY_PHONE_NUM);
21 | final String phoneMd5 = MD5Tool.md5(phoneNum);
22 | final String token = getIntent().getStringExtra(Config.KEY_TOKEN);
23 |
24 | //sync contacts
25 | final ProgressDialog pd = ProgressDialog.show(this, getResources().getString(R.string.connecting_title), getResources().getString(R.string.connecting));
26 | new UploadContacts(MD5Tool.md5(phoneNum), Config.getToken(AtyTimeline.this), MyContacts.getContactsData(AtyTimeline.this), new UploadContacts.SuccessCallback() {
27 |
28 | @Override
29 | public void onSuccess() {
30 | System.out.println("success to upload contacts");
31 | pd.dismiss();
32 |
33 | final ProgressDialog pd1 = ProgressDialog.show(AtyTimeline.this, getResources().getString(R.string.connecting_title), getResources().getString(R.string.connecting));
34 | //get timeline data
35 | new Timeline(phoneMd5, token, ""+1, ""+30, new Timeline.SuccessCallback() {
36 |
37 |
38 | @Override
39 | public void onSuccess() {
40 |
41 | pd1.dismiss();
42 | //TODO AtyTimeline
43 | }
44 | }, new Timeline.FailCallback() {
45 |
46 | @Override
47 | public void onFail() {
48 | pd1.dismiss();
49 |
50 | Toast.makeText(AtyTimeline.this, R.string.fail_to_load_timeline, Toast.LENGTH_LONG).show();
51 | }
52 | });
53 | }
54 | }, new UploadContacts.FailCallback() {
55 |
56 | @Override
57 | public void onFail() {
58 | System.out.println("fail to upload contacts");
59 | pd.dismiss();
60 | }
61 | });
62 | }
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/code/ide/adt/SecretClientPublish/src/com/jikexueyuan/secretclientpublish/Config.java:
--------------------------------------------------------------------------------
1 | package com.jikexueyuan.secretclientpublish;
2 |
3 | import android.content.Context;
4 | import android.content.SharedPreferences.Editor;
5 |
6 | public class Config {
7 |
8 | public static final String SERVER_URL = "http://demo.eoeschool.com/api/v1/nimings/io";
9 | public static final String KEY_TOKEN = "token";
10 | public static final String KEY_ACTION = "action";
11 | public static final String KEY_CODE = "code";
12 | public static final String KEY_PHONE_NUM = "phone";
13 | public static final String KEY_PHONE_MD5 = "phone_md5";
14 | public static final String KEY_APP_ID = "com.jikexueyuan.secret";
15 | public static final String KEY_STATUS = "status";
16 | public static final String KEY_CONTACTS = "contacts";
17 | public static final String KEY_PAGE = "page";
18 | public static final String KEY_PERPAGE = "perpage";
19 | public static final String ACTION_GET_CODE = "send_pass";
20 | public static final String ACTION_LOGIN = "login";
21 | public static final String ACTION_UPLOAD_CONTACTS = "upload_contacts";
22 | public static final String ACTION_TIMELINE = "timeline";
23 | public static final String CHARSET = "utf-8";
24 |
25 | public static final int STATUS_OK = 1;
26 | public static final int STATUS_FAIL = 0;
27 | public static final int STATUS_INVALID_TOKEN = 2;
28 |
29 | public static String getToken(Context context){
30 | return context.getSharedPreferences(KEY_APP_ID, Context.MODE_PRIVATE).getString(KEY_TOKEN, null);
31 | }
32 |
33 | public static void saveToken(Context context,String token){
34 | Editor e = context.getSharedPreferences(KEY_APP_ID, Context.MODE_PRIVATE).edit();
35 | e.putString(KEY_TOKEN, token);
36 | e.commit();
37 | }
38 |
39 | public static String getCurrentLoggedPhoneNum(Context context){
40 | return context.getSharedPreferences(KEY_APP_ID, Context.MODE_PRIVATE).getString(KEY_PHONE_NUM, null);
41 | }
42 |
43 | public static void saveCurrentLoggedPhoneNum(Context context,String phoneNum){
44 | Editor e = context.getSharedPreferences(KEY_APP_ID, Context.MODE_PRIVATE).edit();
45 | e.putString(KEY_PHONE_NUM, phoneNum);
46 | e.commit();
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/code/ide/adt/SecretClientPublish/src/com/jikexueyuan/secretclientpublish/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.jikexueyuan.secretclientpublish;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 |
7 | public class MainActivity extends Activity {
8 |
9 | @Override
10 | protected void onCreate(Bundle savedInstanceState) {
11 | super.onCreate(savedInstanceState);
12 |
13 | String token = Config.getToken(this);
14 | String currentLoggedPhoneNum = Config.getCurrentLoggedPhoneNum(this);
15 |
16 | Intent i;
17 | if (token!=null&¤tLoggedPhoneNum!=null) {
18 | i = new Intent(this, AtyTimeline.class);
19 | i.putExtra(Config.KEY_TOKEN, token);
20 | i.putExtra(Config.KEY_PHONE_NUM, currentLoggedPhoneNum);
21 | }else{
22 | i = new Intent(this, AtyLogin.class);
23 | }
24 |
25 | startActivity(i);
26 | finish();
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/code/ide/adt/SecretClientPublish/src/com/jikexueyuan/secretclientpublish/ld/MyContacts.java:
--------------------------------------------------------------------------------
1 | package com.jikexueyuan.secretclientpublish.ld;
2 |
3 | import org.json.JSONArray;
4 | import org.json.JSONException;
5 | import org.json.JSONObject;
6 |
7 | import com.jikexueyuan.secretclientpublish.Config;
8 | import com.jikexueyuan.secretclientpublish.tool.MD5Tool;
9 |
10 | import android.content.Context;
11 | import android.database.Cursor;
12 | import android.provider.ContactsContract.CommonDataKinds.Phone;
13 |
14 | public class MyContacts {
15 |
16 | public static String getContactsData(Context context){
17 | Cursor c = context.getContentResolver().query(Phone.CONTENT_URI, null, null, null, null);
18 |
19 | JSONArray jarr = new JSONArray();
20 | JSONObject obj;
21 | String phoneNum;
22 | while(c.moveToNext()){
23 | phoneNum = c.getString(c.getColumnIndex(Phone.NUMBER));
24 |
25 | if (phoneNum.charAt(0)=='+'&&phoneNum.charAt(1)=='8'&&phoneNum.charAt(2)=='6') {
26 | phoneNum = phoneNum.substring(3);
27 | }
28 |
29 | obj = new JSONObject();
30 | try {
31 | obj.put(Config.KEY_PHONE_MD5, MD5Tool.md5(phoneNum));
32 | jarr.put(obj);
33 | } catch (JSONException e) {
34 | e.printStackTrace();
35 | }
36 | }
37 |
38 | return jarr.toString();
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/code/ide/adt/SecretClientPublish/src/com/jikexueyuan/secretclientpublish/net/GetCode.java:
--------------------------------------------------------------------------------
1 | package com.jikexueyuan.secretclientpublish.net;
2 |
3 | import org.json.JSONException;
4 | import org.json.JSONObject;
5 |
6 | import com.jikexueyuan.secretclientpublish.Config;
7 |
8 | public class GetCode {
9 |
10 | public GetCode(final String phoneNum,final SuccessCallback successCallback,final FailCallback failCallback) {
11 | new NetConnection(Config.SERVER_URL, HttpMethod.POST,new NetConnection.SuccessCallback() {
12 |
13 | @Override
14 | public void onResult(String result) {
15 | if (result!=null) {
16 | try {
17 | JSONObject obj = new JSONObject(result);
18 | switch (obj.getInt(Config.KEY_STATUS)) {
19 | case Config.STATUS_OK:
20 | if (successCallback!=null) {
21 | successCallback.onSuccess();
22 | }
23 | break;
24 | default:
25 | if (failCallback!=null) {
26 | failCallback.onFail();
27 | }
28 | break;
29 | }
30 |
31 | } catch (JSONException e) {
32 | e.printStackTrace();
33 |
34 | if (failCallback!=null) {
35 | failCallback.onFail();
36 | }
37 | }
38 |
39 | }else{
40 | if (failCallback!=null) {
41 | failCallback.onFail();
42 | }
43 | }
44 | }
45 | },new NetConnection.FailCallback() {
46 |
47 | @Override
48 | public void onFail() {
49 | if (failCallback!=null) {
50 | failCallback.onFail();
51 | }
52 | }
53 | }, Config.KEY_ACTION,Config.ACTION_GET_CODE,Config.KEY_PHONE_NUM,phoneNum);
54 | }
55 |
56 | public static interface SuccessCallback{
57 | void onSuccess();
58 | }
59 |
60 | public static interface FailCallback{
61 | void onFail();
62 | }
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/code/ide/adt/SecretClientPublish/src/com/jikexueyuan/secretclientpublish/net/HttpMethod.java:
--------------------------------------------------------------------------------
1 | package com.jikexueyuan.secretclientpublish.net;
2 |
3 | public enum HttpMethod {
4 |
5 | POST,GET
6 | }
7 |
--------------------------------------------------------------------------------
/code/ide/adt/SecretClientPublish/src/com/jikexueyuan/secretclientpublish/net/Login.java:
--------------------------------------------------------------------------------
1 | package com.jikexueyuan.secretclientpublish.net;
2 |
3 | import org.json.JSONException;
4 | import org.json.JSONObject;
5 |
6 | import com.jikexueyuan.secretclientpublish.Config;
7 |
8 | public class Login {
9 | public Login(String phone_md5,String code,final SuccessCallback successCallback,final FailCallback failCallback) {
10 |
11 | new NetConnection(Config.SERVER_URL,HttpMethod.POST, new NetConnection.SuccessCallback() {
12 |
13 | @Override
14 | public void onResult(String result) {
15 | if (result!=null) {
16 | try {
17 | JSONObject obj = new JSONObject(result);
18 |
19 | switch (obj.getInt(Config.KEY_STATUS)) {
20 | case Config.STATUS_OK:
21 | if (successCallback!=null) {
22 | successCallback.onSuccess(obj.getString(Config.KEY_TOKEN));
23 | }
24 | break;
25 |
26 | default:
27 | if (failCallback!=null) {
28 | failCallback.onFail();
29 | }
30 | break;
31 | }
32 |
33 | } catch (JSONException e) {
34 | e.printStackTrace();
35 |
36 | if (failCallback!=null) {
37 | failCallback.onFail();
38 | }
39 | }
40 | }else{
41 | if (failCallback!=null) {
42 | failCallback.onFail();
43 | }
44 | }
45 | }
46 | },new NetConnection.FailCallback() {
47 |
48 | @Override
49 | public void onFail() {
50 | if (failCallback!=null) {
51 | failCallback.onFail();
52 | }
53 | }
54 | },Config.KEY_ACTION,Config.ACTION_LOGIN,Config.KEY_PHONE_MD5,phone_md5,Config.KEY_CODE,code);
55 |
56 | }
57 |
58 |
59 | public static interface SuccessCallback{
60 | void onSuccess(String token);
61 | }
62 | public static interface FailCallback{
63 | void onFail();
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/code/ide/adt/SecretClientPublish/src/com/jikexueyuan/secretclientpublish/net/NetConnection.java:
--------------------------------------------------------------------------------
1 | package com.jikexueyuan.secretclientpublish.net;
2 |
3 | import java.io.BufferedReader;
4 | import java.io.IOException;
5 | import java.io.InputStream;
6 | import java.io.InputStreamReader;
7 | import java.io.OutputStream;
8 | import java.net.MalformedURLException;
9 | import java.net.URL;
10 | import java.net.URLConnection;
11 |
12 | import com.jikexueyuan.secretclientpublish.Config;
13 |
14 | import android.os.AsyncTask;
15 |
16 |
17 |
18 | public class NetConnection {
19 |
20 |
21 | public NetConnection(final String url,final HttpMethod httpMethod,final SuccessCallback callback,final FailCallback failCallback,final String ...kvs) {
22 |
23 | new AsyncTask() {
24 |
25 | @Override
26 | protected String doInBackground(Void... ps) {
27 | StringBuffer content = new StringBuffer();
28 |
29 | for (int i = 0; i < kvs.length; i+=2) {
30 | content.append(kvs[i]).append("=").append(kvs[i+1]).append("&");
31 | }
32 |
33 | try {
34 | URLConnection uc;
35 | switch (httpMethod) {
36 | case POST:
37 | uc = new URL(url).openConnection();
38 | uc.setDoInput(true);
39 | uc.setDoOutput(true);
40 | OutputStream os = uc.getOutputStream();
41 | os.write(content.toString().getBytes(Config.CHARSET));
42 | os.flush();
43 | break;
44 | default:
45 | uc = new URL(url+"?"+content.toString()).openConnection();
46 | uc.setDoInput(true);
47 | uc.setDoOutput(false);
48 | break;
49 | }
50 |
51 | System.out.println("request url="+uc.getURL());
52 | System.out.println("request content="+content);
53 |
54 | InputStream is = uc.getInputStream();
55 | StringBuffer result = new StringBuffer();
56 | BufferedReader br = new BufferedReader(new InputStreamReader(is, Config.CHARSET));
57 | String line = null;
58 | while((line = br.readLine())!=null){
59 | result.append(line);
60 | }
61 | System.out.println("request result="+result);
62 | return result.toString();
63 |
64 | } catch (MalformedURLException e) {
65 | e.printStackTrace();
66 | } catch (IOException e) {
67 | e.printStackTrace();
68 | }
69 | return null;
70 | }
71 |
72 | @Override
73 | protected void onPostExecute(String result) {
74 | if (result!=null) {
75 | if (callback!=null) {
76 | callback.onResult(result);
77 | }
78 | }else{
79 | if (failCallback!=null) {
80 | failCallback.onFail();
81 | }
82 | }
83 | super.onPostExecute(result);
84 | }
85 | }.execute();
86 | }
87 |
88 | public static interface SuccessCallback{
89 | void onResult(String result);
90 | }
91 | public static interface FailCallback{
92 | void onFail();
93 | }
94 |
95 | }
96 |
--------------------------------------------------------------------------------
/code/ide/adt/SecretClientPublish/src/com/jikexueyuan/secretclientpublish/net/Timeline.java:
--------------------------------------------------------------------------------
1 | package com.jikexueyuan.secretclientpublish.net;
2 |
3 | import org.json.JSONException;
4 | import org.json.JSONObject;
5 |
6 | import com.jikexueyuan.secretclientpublish.Config;
7 |
8 | public class Timeline {
9 |
10 | public Timeline(String phone_md5,String token,String page,String perpage,final SuccessCallback successCallback,final FailCallback failCallback) {
11 | new NetConnection(Config.SERVER_URL, HttpMethod.POST, new NetConnection.SuccessCallback() {
12 |
13 | @Override
14 | public void onResult(String result) {
15 |
16 | try {
17 | JSONObject jsonObj = new JSONObject(result);
18 |
19 | switch (jsonObj.getInt(Config.KEY_STATUS)) {
20 | case Config.STATUS_OK:
21 | //TODO timeline
22 | break;
23 | default:
24 | if (failCallback!=null) {
25 | failCallback.onFail();
26 | }
27 | break;
28 | }
29 |
30 | } catch (JSONException e) {
31 | e.printStackTrace();
32 | if (failCallback!=null) {
33 | failCallback.onFail();
34 | }
35 | }
36 |
37 | }
38 | }, new NetConnection.FailCallback() {
39 |
40 | @Override
41 | public void onFail() {
42 | if (failCallback!=null) {
43 | failCallback.onFail();
44 | }
45 | }
46 | },
47 | Config.KEY_ACTION,Config.ACTION_TIMELINE,
48 | Config.KEY_PHONE_MD5,phone_md5,
49 | Config.KEY_TOKEN,token,
50 | Config.KEY_PAGE,page,
51 | Config.KEY_PERPAGE,perpage);
52 | }
53 |
54 | public static interface SuccessCallback{
55 | void onSuccess();
56 | }
57 | public static interface FailCallback{
58 | void onFail();
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/code/ide/adt/SecretClientPublish/src/com/jikexueyuan/secretclientpublish/net/UploadContacts.java:
--------------------------------------------------------------------------------
1 | package com.jikexueyuan.secretclientpublish.net;
2 |
3 | import org.json.JSONException;
4 | import org.json.JSONObject;
5 |
6 | import com.jikexueyuan.secretclientpublish.Config;
7 |
8 | public class UploadContacts {
9 |
10 | public UploadContacts(String phone_md5,String token,String contactsJsonStr,final SuccessCallback successCallback,final FailCallback failCallback) {
11 | new NetConnection(Config.SERVER_URL, HttpMethod.POST, new NetConnection.SuccessCallback() {
12 |
13 | @Override
14 | public void onResult(String result) {
15 |
16 | try {
17 | JSONObject jsonObj = new JSONObject(result);
18 |
19 | switch (jsonObj.getInt(Config.KEY_STATUS)) {
20 | case Config.STATUS_OK:
21 | if (successCallback!=null) {
22 | successCallback.onSuccess();
23 | }
24 | break;
25 | default:
26 | if (failCallback!=null) {
27 | failCallback.onFail();
28 | }
29 | break;
30 | }
31 |
32 | } catch (JSONException e) {
33 | e.printStackTrace();
34 |
35 | if (failCallback!=null) {
36 | failCallback.onFail();
37 | }
38 | }
39 |
40 | }
41 | }, new NetConnection.FailCallback() {
42 |
43 | @Override
44 | public void onFail() {
45 | if (failCallback!=null) {
46 | failCallback.onFail();
47 | }
48 | }
49 | }, Config.KEY_ACTION,Config.ACTION_UPLOAD_CONTACTS,Config.KEY_PHONE_MD5,phone_md5,Config.KEY_TOKEN,token,Config.KEY_CONTACTS,contactsJsonStr);
50 | }
51 |
52 |
53 | public static interface SuccessCallback{
54 | void onSuccess();
55 | }
56 |
57 | public static interface FailCallback{
58 | void onFail();
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/code/ide/adt/SecretClientPublish/src/com/jikexueyuan/secretclientpublish/tool/MD5Tool.java:
--------------------------------------------------------------------------------
1 | package com.jikexueyuan.secretclientpublish.tool;
2 |
3 | import java.io.UnsupportedEncodingException;
4 | import java.security.MessageDigest;
5 | import java.security.NoSuchAlgorithmException;
6 |
7 | public class MD5Tool {
8 |
9 | public static String md5(String string) {
10 | byte[] hash;
11 | try {
12 | hash = MessageDigest.getInstance("MD5").digest(string.getBytes("UTF-8"));
13 | } catch (NoSuchAlgorithmException e) {
14 | throw new RuntimeException("Huh, MD5 should be supported?", e);
15 | } catch (UnsupportedEncodingException e) {
16 | throw new RuntimeException("Huh, UTF-8 should be supported?", e);
17 | }
18 |
19 | StringBuilder hex = new StringBuilder(hash.length * 2);
20 | for (byte b : hash) {
21 | if ((b & 0xFF) < 0x10) hex.append("0");
22 | hex.append(Integer.toHexString(b & 0xFF));
23 | }
24 | return hex.toString();
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/code/ide/eclipse/TestServer/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/code/ide/eclipse/TestServer/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/code/ide/eclipse/TestServer/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | TestServer
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.wst.jsdt.core.javascriptValidator
10 |
11 |
12 |
13 |
14 | org.eclipse.jdt.core.javabuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.wst.common.project.facet.core.builder
20 |
21 |
22 |
23 |
24 | org.eclipse.wst.validation.validationbuilder
25 |
26 |
27 |
28 |
29 |
30 | org.eclipse.jem.workbench.JavaEMFNature
31 | org.eclipse.wst.common.modulecore.ModuleCoreNature
32 | org.eclipse.wst.common.project.facet.core.nature
33 | org.eclipse.jdt.core.javanature
34 | org.eclipse.wst.jsdt.core.jsNature
35 |
36 |
37 |
--------------------------------------------------------------------------------
/code/ide/eclipse/TestServer/.settings/.jsdtscope:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/code/ide/eclipse/TestServer/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
4 | org.eclipse.jdt.core.compiler.compliance=1.7
5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
7 | org.eclipse.jdt.core.compiler.source=1.7
8 |
--------------------------------------------------------------------------------
/code/ide/eclipse/TestServer/.settings/org.eclipse.wst.common.component:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/code/ide/eclipse/TestServer/.settings/org.eclipse.wst.common.project.facet.core.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/code/ide/eclipse/TestServer/.settings/org.eclipse.wst.jsdt.ui.superType.container:
--------------------------------------------------------------------------------
1 | org.eclipse.wst.jsdt.launching.baseBrowserLibrary
--------------------------------------------------------------------------------
/code/ide/eclipse/TestServer/.settings/org.eclipse.wst.jsdt.ui.superType.name:
--------------------------------------------------------------------------------
1 | Window
--------------------------------------------------------------------------------
/code/ide/eclipse/TestServer/WebContent/META-INF/MANIFEST.MF:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Class-Path:
3 |
4 |
--------------------------------------------------------------------------------
/code/ide/eclipse/TestServer/WebContent/api.jsp:
--------------------------------------------------------------------------------
1 | <%@ page language="java" contentType="text/html; charset=UTF-8"
2 | pageEncoding="UTF-8"%>
3 | <%
4 |
5 | out.clear();
6 |
7 | String action = request.getParameter("action");
8 |
9 | if(action!=null){
10 | if(action.equals("send_pass")){
11 | out.print("{\"status\":1}");
12 | }else if(action.equals("login")){
13 | out.print("{\"status\":1,\"token\":\"asdasdasdsadasd\"}");
14 | }else if(action.equals("upload_contacts")){
15 | out.print("{\"status\":1}");
16 | }else if(action.equals("timeline")){
17 | out.print("{\"status\":1,\"page\":1,\"perpage\":20,\"timeline\":["+
18 | "{\"msg\":\"Haha1\",\"phone_md5\":\"dasdasdbkas\",\"msgId\":\"1231234\"},"+
19 | "{\"msg\":\"Haha2\",\"phone_md5\":\"dasdasdbkas\",\"msgId\":\"1231234\"},"+
20 | "{\"msg\":\"Haha3\",\"phone_md5\":\"dasdasdbkas\",\"msgId\":\"1231234\"},"+
21 | "{\"msg\":\"Haha4\",\"phone_md5\":\"dasdasdbkas\",\"msgId\":\"1231234\"},"+
22 | "{\"msg\":\"Haha5\",\"phone_md5\":\"dasdasdbkas\",\"msgId\":\"1231234\"},"+
23 | "{\"msg\":\"Haha6\",\"phone_md5\":\"dasdasdbkas\",\"msgId\":\"1231234\"},"+
24 | "{\"msg\":\"Haha7\",\"phone_md5\":\"dasdasdbkas\",\"msgId\":\"1231234\"},"+
25 | "{\"msg\":\"Haha8\",\"phone_md5\":\"dasdasdbkas\",\"msgId\":\"1231234\"}"+
26 | "]}");
27 | }else if(action.equals("get_comment")){
28 | out.print("{\"status\":1,\"page\":1,\"perpage\":20,\"msgId\":\"12133\",\"comments\":["+
29 | "{\"content\":\"Hehe1\",\"phone_md5\":\"dasdasdbkas\"},"+
30 | "{\"content\":\"Hehe2\",\"phone_md5\":\"dasdasdbkas\"},"+
31 | "{\"content\":\"Hehe3\",\"phone_md5\":\"dasdasdbkas\"},"+
32 | "{\"content\":\"Hehe4\",\"phone_md5\":\"dasdasdbkas\"},"+
33 | "{\"content\":\"Hehe5\",\"phone_md5\":\"dasdasdbkas\"},"+
34 | "{\"content\":\"Hehe6\",\"phone_md5\":\"dasdasdbkas\"},"+
35 | "{\"content\":\"Hehe7\",\"phone_md5\":\"dasdasdbkas\"},"+
36 | "{\"content\":\"Hehe8\",\"phone_md5\":\"dasdasdbkas\"}"+
37 | "]}");
38 | }else if(action.equals("pub_comment")){
39 | out.print("{\"status\":1}");
40 | }else if(action.equals("publish")){
41 | out.print("{\"status\":1}");
42 | }
43 | }else{
44 | out.print("请指定action");
45 | }
46 |
47 | %>
--------------------------------------------------------------------------------
/docs/《匿名》软件开发参考文档.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/plter/jikexueyuanSecret/26177f31535a5594466f3b1b8ec7d53aabad3a32/docs/《匿名》软件开发参考文档.docx
--------------------------------------------------------------------------------
/docs/《匿名》项目开发实战课程大纲.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/plter/jikexueyuanSecret/26177f31535a5594466f3b1b8ec7d53aabad3a32/docs/《匿名》项目开发实战课程大纲.docx
--------------------------------------------------------------------------------