@@ -24,12 +24,34 @@ android { |
||
24 | 24 |
versionCode 1 |
25 | 25 |
versionName "1.0" |
26 | 26 |
} |
27 |
+ signingConfigs { |
|
28 |
+ releaseConfig { |
|
29 |
+ storeFile file("paiai.keystore") |
|
30 |
+ storePassword "chengzhenyu" |
|
31 |
+ keyAlias "paiai" |
|
32 |
+ keyPassword "chengzhenyu" |
|
33 |
+ } |
|
34 |
+ } |
|
35 |
+ |
|
27 | 36 |
buildTypes { |
28 | 37 |
release { |
38 |
+ minifyEnabled true |
|
39 |
+ zipAlignEnabled true |
|
40 |
+ shrinkResources true |
|
41 |
+ debuggable false |
|
42 |
+ jniDebuggable false |
|
43 |
+ buildConfigField "boolean", "isDevMode", "false" |
|
44 |
+ proguardFile 'proguard-project.txt' |
|
45 |
+ signingConfig signingConfigs.releaseConfig |
|
46 |
+ } |
|
47 |
+ debug { |
|
48 |
+ zipAlignEnabled false |
|
29 | 49 |
minifyEnabled false |
30 |
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' |
|
50 |
+ shrinkResources false |
|
51 |
+ signingConfig signingConfigs.releaseConfig |
|
31 | 52 |
} |
32 | 53 |
} |
54 |
+ |
|
33 | 55 |
} |
34 | 56 |
|
35 | 57 |
dependencies { |
@@ -3,6 +3,7 @@ package ai.pai.lensman.login; |
||
3 | 3 |
import android.os.AsyncTask; |
4 | 4 |
|
5 | 5 |
import com.android.common.executors.ThreadExecutor; |
6 |
+import com.android.common.utils.LogHelper; |
|
6 | 7 |
|
7 | 8 |
import org.json.JSONObject; |
8 | 9 |
|
@@ -56,7 +57,7 @@ public class LoginInteractor implements BaseInteractor { |
||
56 | 57 |
|
57 | 58 |
final String tokenUrl = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + APP_ID |
58 | 59 |
+ "&secret=" + APP_SECRET + "&code=" + wxCode + "&grant_type=authorization_code"; |
59 |
- |
|
60 |
+ LogHelper.d("czy","interactor fetchToken with url = "+tokenUrl); |
|
60 | 61 |
fetchTokenTask = new HttpPostTask(null) { |
61 | 62 |
|
62 | 63 |
String token; |
@@ -64,6 +65,7 @@ public class LoginInteractor implements BaseInteractor { |
||
64 | 65 |
|
65 | 66 |
@Override |
66 | 67 |
protected boolean parseResponse(String response) { |
68 |
+ LogHelper.d("czy","interactor fetchToken parseResponse response = "+response); |
|
67 | 69 |
try { |
68 | 70 |
JSONObject json = new JSONObject(response); |
69 | 71 |
token = json.getString("access_token"); |
@@ -86,18 +88,19 @@ public class LoginInteractor implements BaseInteractor { |
||
86 | 88 |
super.onPostFail(); |
87 | 89 |
} |
88 | 90 |
}; |
89 |
- loginTask.executeOnExecutor(ThreadExecutor.getInstance().getExecutor(), tokenUrl); |
|
91 |
+ fetchTokenTask.executeOnExecutor(ThreadExecutor.getInstance().getExecutor(), tokenUrl); |
|
90 | 92 |
} |
91 | 93 |
|
92 | 94 |
private void fetchUserInfo(String token, String openId) { |
93 | 95 |
|
94 | 96 |
String userInfoUrl = "https://api.weixin.qq.com/sns/userinfo?access_token=" + token + "&openid=" + openId; |
95 |
- |
|
97 |
+ LogHelper.d("czy","interactor fetchUserInfo with url = "+userInfoUrl); |
|
96 | 98 |
fetchUserInfoTask = new HttpPostTask(null) { |
97 | 99 |
HashMap<String, String> params; |
98 | 100 |
|
99 | 101 |
@Override |
100 | 102 |
protected boolean parseResponse(String response) { |
103 |
+ LogHelper.d("czy","interactor fetchUserInfo parseResponse response = "+response); |
|
101 | 104 |
try { |
102 | 105 |
JSONObject json = new JSONObject(response); |
103 | 106 |
params = new HashMap<>(); |
@@ -183,13 +186,14 @@ public class LoginInteractor implements BaseInteractor { |
||
183 | 186 |
|
184 | 187 |
@Override |
185 | 188 |
protected boolean parseResponse(String response) { |
189 |
+ LogHelper.d("czy","interactor wxLogin parseResponse response = "+response); |
|
186 | 190 |
try { |
187 | 191 |
JSONObject json = new JSONObject(response); |
188 | 192 |
int status = json.getInt("status"); |
189 | 193 |
if (status == 200) { |
190 | 194 |
JSONObject info = json.getJSONObject("data"); |
191 | 195 |
lensmanId = info.getString("user_id"); |
192 |
- userName = info.getString("username"); |
|
196 |
+ userName = info.getString("nickname"); |
|
193 | 197 |
return true; |
194 | 198 |
} else { |
195 | 199 |
message = json.getString("message"); |
@@ -3,6 +3,7 @@ package ai.pai.lensman.login; |
||
3 | 3 |
import android.content.Context; |
4 | 4 |
import android.text.TextUtils; |
5 | 5 |
|
6 |
+import com.android.common.utils.LogHelper; |
|
6 | 7 |
import com.tencent.mm.sdk.modelmsg.SendAuth; |
7 | 8 |
import com.tencent.mm.sdk.openapi.IWXAPI; |
8 | 9 |
import com.tencent.mm.sdk.openapi.WXAPIFactory; |
@@ -15,6 +16,7 @@ import ai.pai.lensman.db.Preferences; |
||
15 | 16 |
*/ |
16 | 17 |
public class LoginPresenter implements LoginContract.Presenter,BaseInteractor.InteractorListener<String> { |
17 | 18 |
|
19 |
+ private IWXAPI api; |
|
18 | 20 |
private Context context; |
19 | 21 |
private LoginContract.View view; |
20 | 22 |
private LoginInteractor interactor; |
@@ -23,12 +25,14 @@ public class LoginPresenter implements LoginContract.Presenter,BaseInteractor.In |
||
23 | 25 |
public LoginPresenter(Context context,LoginContract.View view){ |
24 | 26 |
this.view = view; |
25 | 27 |
this.context = context; |
28 |
+ api = WXAPIFactory.createWXAPI(context, APP_ID, true); |
|
29 |
+ api.registerApp(APP_ID); |
|
26 | 30 |
} |
27 | 31 |
|
28 | 32 |
@Override |
29 | 33 |
public void login() { |
30 |
- IWXAPI api = WXAPIFactory.createWXAPI(context, APP_ID, true); |
|
31 |
- api.registerApp(APP_ID); |
|
34 |
+ LogHelper.d("czy","presenter login"); |
|
35 |
+ |
|
32 | 36 |
SendAuth.Req req = new SendAuth.Req(); |
33 | 37 |
req.scope = "snsapi_userinfo"; |
34 | 38 |
req.state = "paiai_for_lensman"; |
@@ -38,10 +42,12 @@ public class LoginPresenter implements LoginContract.Presenter,BaseInteractor.In |
||
38 | 42 |
@Override |
39 | 43 |
public void start() { |
40 | 44 |
String wxCode = Preferences.getInstance().getWXCode(); |
45 |
+ LogHelper.d("czy","presenter start with wx code = "+wxCode); |
|
41 | 46 |
if(!TextUtils.isEmpty(wxCode)){ |
42 | 47 |
view.showProgressView(); |
43 | 48 |
interactor = new LoginInteractor(wxCode,this); |
44 | 49 |
interactor.startJob(); |
50 |
+ Preferences.getInstance().setWXCode(""); |
|
45 | 51 |
} |
46 | 52 |
} |
47 | 53 |
|
@@ -4,6 +4,7 @@ import android.app.Activity; |
||
4 | 4 |
import android.content.Intent; |
5 | 5 |
import android.os.Bundle; |
6 | 6 |
|
7 |
+import com.android.common.utils.LogHelper; |
|
7 | 8 |
import com.tencent.mm.sdk.modelbase.BaseReq; |
8 | 9 |
import com.tencent.mm.sdk.modelbase.BaseResp; |
9 | 10 |
import com.tencent.mm.sdk.modelmsg.SendAuth; |
@@ -45,6 +46,8 @@ public class WXEntryActivity extends Activity implements IWXAPIEventHandler { |
||
45 | 46 |
SendAuth.Resp newResp = (SendAuth.Resp) resp; |
46 | 47 |
String code = newResp.code; |
47 | 48 |
Preferences.getInstance().setWXCode(code); |
49 |
+ LogHelper.d("czy","WXEntryActivity onResp wx code = "+code); |
|
50 |
+ finish(); |
|
48 | 51 |
} |
49 | 52 |
} |
50 | 53 |
|